All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chao Peng <chao.p.peng@linux.intel.com>
To: qemu-devel@nongnu.org
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	gor Mammedov <imammedo@redhat.com>,
	Xiao Guangrong <guangrong.xiao@linux.intel.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Richard Henderson <rth@twiddle.net>,
	Eduardo Habkost <ehabkost@redhat.com>,
	Haozhong Zhang <haozhong.zhang@intel.com>
Subject: [Qemu-devel] [RFC PATCH v2 06/12] acpi: expose data structurs and functions of BIOS linker loader
Date: Thu, 25 Aug 2016 06:14:59 -0400	[thread overview]
Message-ID: <1472120105-29235-7-git-send-email-chao.p.peng@linux.intel.com> (raw)
In-Reply-To: <1472120105-29235-1-git-send-email-chao.p.peng@linux.intel.com>

From: Haozhong Zhang <haozhong.zhang@intel.com>

Expose some data structures and functions of BIOS linker loader which
will be used by later commits.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
---
 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

  parent reply	other threads:[~2016-08-25 10:23 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-25 10:14 [Qemu-devel] [RFC PATCH v2 00/12] Guest startup time optimization Chao Peng
2016-08-25 10:14 ` [Qemu-devel] [RFC PATCH v2 01/12] pc: make smbus configurable Chao Peng
2016-09-06 20:18   ` Eduardo Habkost
2016-08-25 10:14 ` [Qemu-devel] [RFC PATCH v2 02/12] pc: make sata configurable Chao Peng
2016-08-25 10:14 ` [Qemu-devel] [RFC PATCH v2 03/12] pc: make pic configurable Chao Peng
2016-08-25 10:14 ` [Qemu-devel] [RFC PATCH v2 04/12] pc: make pit configurable Chao Peng
2016-08-25 10:14 ` [Qemu-devel] [RFC PATCH v2 05/12] acpi: build static _PRT Chao Peng
2016-08-29 17:06   ` Paolo Bonzini
2016-08-25 10:14 ` Chao Peng [this message]
2016-08-25 10:15 ` [Qemu-devel] [RFC PATCH v2 07/12] acpi: expose acpi_checksum() Chao Peng
2016-08-25 10:15 ` [Qemu-devel] [RFC PATCH v2 08/12] acpi: patch guest ACPI when there is no firmware Chao Peng
2016-08-25 10:15 ` [Qemu-devel] [RFC PATCH v2 09/12] ich9: enable pm registers " Chao Peng
2016-08-25 10:15 ` [Qemu-devel] [RFC PATCH v2 10/12] q35: initialize MMCFG base " Chao Peng
2016-08-25 10:15 ` [Qemu-devel] [RFC PATCH v2 11/12] pc: support direct loading protected/long mode kernel Chao Peng
2016-08-25 10:15 ` [Qemu-devel] [RFC PATCH v2 12/12] pc: skip firmware Chao Peng
2016-08-29 17:08   ` Paolo Bonzini
2016-09-02 11:08 ` [Qemu-devel] [RFC PATCH v2 00/12] Guest startup time optimization Paolo Bonzini
2016-09-05  2:37   ` Michael S. Tsirkin
2016-09-06 10:48   ` Chao Peng
2016-09-06 11:53     ` Michael S. Tsirkin
2016-09-06 14:28       ` Chao Peng
2016-09-12 15:15         ` Gerd Hoffmann
2016-09-12 17:57           ` [Qemu-devel] [SeaBIOS] " Peter Stuge
2016-09-06 14:21     ` [Qemu-devel] " Paolo Bonzini
2016-09-06 14:31       ` Chao Peng
2016-09-06 14:45       ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1472120105-29235-7-git-send-email-chao.p.peng@linux.intel.com \
    --to=chao.p.peng@linux.intel.com \
    --cc=ehabkost@redhat.com \
    --cc=guangrong.xiao@linux.intel.com \
    --cc=haozhong.zhang@intel.com \
    --cc=imammedo@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.