qemu/hw/acpi/bios-linker-loader.c
/*
 * bios_linker_loader_add_checksum: ask guest to add checksum of ACPI
 * table in the specified file at the specified offset.
 *
 * Checksum calculation simply sums -X for each byte X in the range
 * using 8-bit math (i.e. ACPI checksum).
 *
 * @linker: linker object instance
 * @file: file that includes the checksum to be calculated
 *        and the data to be checksummed
 * @start_offset, @size: range of data in the file to checksum,
 *                       relative to the start of file blob
 * @checksum_offset: location of the checksum to be patched within file blob,
 *                   relative to the start of file blob
 */
ask guest to add checksum of ACPI
table in the specified file at the specified offset.

Checksum calculation simply sums -X for each byte X in the range
using 8-bit math .


ask guest to add checksum of ACPI table in the specified file at the specified offset . Checksum calculation simply sums - X for each byte X in the range using 8 - bit math .
void bios_linker_loader_add_checksum(BIOSLinker *linker, const char *file_name,
                                     unsigned start_offset, unsigned size,
                                     unsigned checksum_offset)
{
    BiosLinkerLoaderEntry entry;
    const BiosLinkerFileEntry *file = bios_linker_find_file(linker, file_name);
    assert(file);
    assert(start_offset < file->blob->len);
    assert(start_offset + size <= file->blob->len);
    assert(checksum_offset >= start_offset);
    assert(checksum_offset + 1 <= start_offset + size);
    *(file->blob->data + checksum_offset) = 0;
    memset(&entry, 0, sizeof entry);
    strncpy(entry.cksum.file, file_name, sizeof entry.cksum.file - 1);
    entry.command = cpu_to_le32(BIOS_LINKER_LOADER_COMMAND_ADD_CHECKSUM);
    entry.cksum.offset = cpu_to_le32(checksum_offset);
    entry.cksum.start = cpu_to_le32(start_offset);
    entry.cksum.length = cpu_to_le32(size);
    g_array_append_vals(linker->cmd_blob, &entry, sizeof entry);
}
void bios_linker_loader_add_checksum ( BIOSLinker * linker , const char * file_name , unsigned start_offset , unsigned size , unsigned checksum_offset ) { BiosLinkerLoaderEntry entry ; const BiosLinkerFileEntry * file = bios_linker_find_file ( linker , file_name ) ; assert ( file ) ; assert ( start_offset < file -> blob -> len ) ; assert ( start_offset + size <= file -> blob -> len ) ; assert ( checksum_offset >= start_offset ) ; assert ( checksum_offset + 1 <= start_offset + size ) ; * ( file -> blob -> data + checksum_offset ) = 0 ; memset ( & entry , 0 , sizeof entry ) ; strncpy ( entry . cksum . file , file_name , sizeof entry . cksum . file - 1 ) ; entry . command = cpu_to_le32 ( BIOS_LINKER_LOADER_COMMAND_ADD_CHECKSUM ) ; entry . cksum . offset = cpu_to_le32 ( checksum_offset ) ; entry . cksum . start = cpu_to_le32 ( start_offset ) ; entry . cksum . length = cpu_to_le32 ( size ) ; g_array_append_vals ( linker -> cmd_blob , & entry , sizeof entry ) ; }
bios_linker_loader_add_checksum: ask guest to add checksum of ACPI
 table in the specified file at the specified offset.
bios_linker_loader_add_checksum : ask guest to add checksum of ACPI table in the specified file at the specified offset .