From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44961) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDp0z-00024g-9W for qemu-devel@nongnu.org; Fri, 17 Jun 2016 04:20:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDp0w-0007Bv-Q0 for qemu-devel@nongnu.org; Fri, 17 Jun 2016 04:20:32 -0400 Received: from mga02.intel.com ([134.134.136.20]:55279) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDp0w-0007Ag-Ad for qemu-devel@nongnu.org; Fri, 17 Jun 2016 04:20:30 -0400 From: Chao Peng Date: Fri, 17 Jun 2016 04:14:12 -0400 Message-Id: <1466151257-96318-5-git-send-email-chao.p.peng@linux.intel.com> In-Reply-To: <1466151257-96318-1-git-send-email-chao.p.peng@linux.intel.com> References: <1466151257-96318-1-git-send-email-chao.p.peng@linux.intel.com> Subject: [Qemu-devel] [RFC 4/9] acpi: expose data structurs and functions of BIOS linker loader List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , gor Mammedov , Xiao Guangrong , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Haozhong Zhang From: Haozhong Zhang Expose some data structures and functions of BIOS linker loader which will be used by later commits. Signed-off-by: Haozhong Zhang --- hw/acpi/bios-linker-loader.c | 83 +---------------------------------- include/hw/acpi/bios-linker-loader.h | 85 ++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 82 deletions(-) diff --git a/hw/acpi/bios-linker-loader.c b/hw/acpi/bios-linker-loader.c index d963ebe..e9c19cf 100644 --- a/hw/acpi/bios-linker-loader.c +++ b/hw/acpi/bios-linker-loader.c @@ -21,91 +21,10 @@ #include "qemu/osdep.h" #include "qemu-common.h" #include "hw/acpi/bios-linker-loader.h" -#include "hw/nvram/fw_cfg.h" #include "qemu/bswap.h" /* - * Linker/loader is a paravirtualized interface that passes commands to guest. - * The commands can be used to request guest to - * - allocate memory chunks and initialize them from QEMU FW CFG files - * - link allocated chunks by storing pointer to one chunk into another - * - calculate ACPI checksum of part of the chunk and store into same chunk - */ -#define BIOS_LINKER_LOADER_FILESZ FW_CFG_MAX_FILE_PATH - -struct BiosLinkerLoaderEntry { - uint32_t command; - union { - /* - * COMMAND_ALLOCATE - allocate a table from @alloc.file - * subject to @alloc.align alignment (must be power of 2) - * and @alloc.zone (can be HIGH or FSEG) requirements. - * - * Must appear exactly once for each file, and before - * this file is referenced by any other command. - */ - struct { - char file[BIOS_LINKER_LOADER_FILESZ]; - uint32_t align; - uint8_t zone; - } alloc; - - /* - * COMMAND_ADD_POINTER - patch the table (originating from - * @dest_file) at @pointer.offset, by adding a pointer to the table - * originating from @src_file. 1,2,4 or 8 byte unsigned - * addition is used depending on @pointer.size. - */ - struct { - char dest_file[BIOS_LINKER_LOADER_FILESZ]; - char src_file[BIOS_LINKER_LOADER_FILESZ]; - uint32_t offset; - uint8_t size; - } pointer; - - /* - * COMMAND_ADD_CHECKSUM - calculate checksum of the range specified by - * @cksum_start and @cksum_length fields, - * and then add the value at @cksum.offset. - * Checksum simply sums -X for each byte X in the range - * using 8-bit math. - */ - struct { - char file[BIOS_LINKER_LOADER_FILESZ]; - uint32_t offset; - uint32_t start; - uint32_t length; - } cksum; - - /* padding */ - char pad[124]; - }; -} QEMU_PACKED; -typedef struct BiosLinkerLoaderEntry BiosLinkerLoaderEntry; - -enum { - BIOS_LINKER_LOADER_COMMAND_ALLOCATE = 0x1, - BIOS_LINKER_LOADER_COMMAND_ADD_POINTER = 0x2, - BIOS_LINKER_LOADER_COMMAND_ADD_CHECKSUM = 0x3, -}; - -enum { - BIOS_LINKER_LOADER_ALLOC_ZONE_HIGH = 0x1, - BIOS_LINKER_LOADER_ALLOC_ZONE_FSEG = 0x2, -}; - -/* - * BiosLinkerFileEntry: - * - * An internal type used for book-keeping file entries - */ -typedef struct BiosLinkerFileEntry { - char *name; /* file name */ - GArray *blob; /* data accosiated with @name */ -} BiosLinkerFileEntry; - -/* * bios_linker_loader_init: allocate a new linker object instance. * * After initialization, linker commands can be added, and will @@ -137,7 +56,7 @@ void bios_linker_loader_cleanup(BIOSLinker *linker) g_free(linker); } -static const BiosLinkerFileEntry * +const BiosLinkerFileEntry * bios_linker_find_file(const BIOSLinker *linker, const char *name) { int i; diff --git a/include/hw/acpi/bios-linker-loader.h b/include/hw/acpi/bios-linker-loader.h index fa1e5d1..52c1e44 100644 --- a/include/hw/acpi/bios-linker-loader.h +++ b/include/hw/acpi/bios-linker-loader.h @@ -1,12 +1,93 @@ #ifndef BIOS_LINKER_LOADER_H #define BIOS_LINKER_LOADER_H +#include "hw/nvram/fw_cfg.h" typedef struct BIOSLinker { GArray *cmd_blob; GArray *file_list; } BIOSLinker; +/* + * Linker/loader is a paravirtualized interface that passes commands to guest. + * The commands can be used to request guest to + * - allocate memory chunks and initialize them from QEMU FW CFG files + * - link allocated chunks by storing pointer to one chunk into another + * - calculate ACPI checksum of part of the chunk and store into same chunk + */ +#define BIOS_LINKER_LOADER_FILESZ FW_CFG_MAX_FILE_PATH + +struct BiosLinkerLoaderEntry { + uint32_t command; + union { + /* + * COMMAND_ALLOCATE - allocate a table from @alloc.file + * subject to @alloc.align alignment (must be power of 2) + * and @alloc.zone (can be HIGH or FSEG) requirements. + * + * Must appear exactly once for each file, and before + * this file is referenced by any other command. + */ + struct { + char file[BIOS_LINKER_LOADER_FILESZ]; + uint32_t align; + uint8_t zone; + } alloc; + + /* + * COMMAND_ADD_POINTER - patch the table (originating from + * @dest_file) at @pointer.offset, by adding a pointer to the table + * originating from @src_file. 1,2,4 or 8 byte unsigned + * addition is used depending on @pointer.size. + */ + struct { + char dest_file[BIOS_LINKER_LOADER_FILESZ]; + char src_file[BIOS_LINKER_LOADER_FILESZ]; + uint32_t offset; + uint8_t size; + } pointer; + + /* + * COMMAND_ADD_CHECKSUM - calculate checksum of the range specified by + * @cksum_start and @cksum_length fields, + * and then add the value at @cksum.offset. + * Checksum simply sums -X for each byte X in the range + * using 8-bit math. + */ + struct { + char file[BIOS_LINKER_LOADER_FILESZ]; + uint32_t offset; + uint32_t start; + uint32_t length; + } cksum; + + /* padding */ + char pad[124]; + }; +} QEMU_PACKED; +typedef struct BiosLinkerLoaderEntry BiosLinkerLoaderEntry; + +enum { + BIOS_LINKER_LOADER_COMMAND_ALLOCATE = 0x1, + BIOS_LINKER_LOADER_COMMAND_ADD_POINTER = 0x2, + BIOS_LINKER_LOADER_COMMAND_ADD_CHECKSUM = 0x3, +}; + +enum { + BIOS_LINKER_LOADER_ALLOC_ZONE_HIGH = 0x1, + BIOS_LINKER_LOADER_ALLOC_ZONE_FSEG = 0x2, +}; + +/* + * BiosLinkerFileEntry: + * + * An internal type used for book-keeping file entries + */ +typedef struct BiosLinkerFileEntry { + char *name; /* file name */ + GArray *blob; /* data accosiated with @name */ +} BiosLinkerFileEntry; + BIOSLinker *bios_linker_loader_init(void); void bios_linker_loader_alloc(BIOSLinker *linker, @@ -27,4 +108,8 @@ void bios_linker_loader_add_pointer(BIOSLinker *linker, uint32_t src_offset); void bios_linker_loader_cleanup(BIOSLinker *linker); + +const BiosLinkerFileEntry * +bios_linker_find_file(const BIOSLinker *linker, const char *name); + #endif -- 1.8.3.1