qemu: generate acpi tables for the guest
v4 cover qemu: generate acpi tables for the guest
This code can also be found here:git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git acpi
While this patch still uses info not available in QOM, I think it's reasonable to merge it and then refactor as QOM properties cover more ground.
In particular, merging this patchset blocks other projects so I think its preferable to merge now and not wait for all required QOM properties to materialize.
I added QOM properties in ich/piix where I knew how to do this.
If everything's in order, I intend to merge this through my tree.
Please review, and comment.
Changes from v3:
- reworked code to use QOM properties
some info isn't yet available in QOM, use old-style APIs and lookups by type
- address comments by Gerd: tables are now updated on guest access after pci configuration
Changes from v2 repost:
- address comment by Anthony - convert to use APIs implemented using QOM
- address comment by Anthony - avoid tricky pointer path, use GArray from glib instead
- Address lots of comments by Hu Tao and Laszlo Ersek
Changes from v2:
- added missing patches to make it actually build Changes from v1 RFC:
- added code to address cross version compatibility
- rebased to latest bits
- updated seabios code to latest bits (added pvpanic device)
This patchset moves all generation of ACPI tables
from guest BIOS to the hypervisor.
Although ACPI tables come from a system BIOS on real hw, it makes sense that the ACPI tables are coupled with the virtual machine, since they have to abstract the x86 machine to the OS's.
This is widely desired as a way to avoid the churn and proliferation of QEMU-specific interfaces associated with ACPI tables in bios code.
There's a bit of code duplication where we
already declare similar acpi structures in qemu.
I think it's best to do it in this order: port code directly, and apply cleanups and reduce duplication that results, on top.
This way it's much easier to see that we don't introduce regressions.
In particular, I booted a guest on qemu with and without the change, and verified that ACPI tables are unchanged except for trivial pointer address changes.
Such binary compatibility makes it easier to be
confident that this change won't break things.
Michael S. Tsirkin (23):
qemu: add Error to typedefs
qom: pull in qemu/typedefs
qom: cleanup struct Error references
qom: add pointer to int property helpers
fw_cfg: interface to trigger callback on read
loader: support for unmapped ROM blobs
pcie_host: expose UNMAPPED macro
pcie_host: expose address format
q35: use macro for MCFG property name
q35: expose mmcfg size as a property
i386: add ACPI table files from seabios
acpi: add rules to compile ASL source
acpi: pre-compiled ASL files
loader: use file path size from fw_cfg.h
i386: add bios linker/loader
loader: allow adding ROMs in done callbacks
i386: define pc guest info
acpi/piix: add macros for acpi property names
piix: APIs for pc guest info
ich9: APIs for pc guest info
pvpanic: add API to access io port
hpet: add API to find it
i386: ACPI table generation code from seabios
configure | 9 +- hw/i386/acpi-defs.h | 331 ++ hw/lm32/lm32_hwsetup.h | 2 +- include/hw/acpi/ich9.h | 2 + include/hw/acpi/piix4.h | 8 + include/hw/i386/acpi-build.h | 9 + include/hw/i386/bios-linker-loader.h | 26 + include/hw/i386/ich9.h | 2 + include/hw/i386/pc.h | 23 + include/hw/loader.h | 8 +- include/hw/nvram/fw_cfg.h | 8 +- include/hw/pci-host/q35.h | 2 + include/hw/pci/pcie_host.h | 27 + include/hw/timer/hpet.h | 2 + include/qemu/typedefs.h | 1 + include/qom/object.h | 73 +- hw/acpi/ich9.c | 24 + hw/acpi/piix4.c | 50 +- hw/core/loader.c | 31 +- hw/i386/acpi-build.c | 1190 ++++++ hw/i386/bios-linker-loader.c | 156 + hw/i386/pc.c | 37 + hw/i386/pc_piix.c | 5 + hw/i386/pc_q35.c | 3 + hw/isa/lpc_ich9.c | 40 + hw/misc/pvpanic.c | 13 +- hw/nvram/fw_cfg.c | 33 +- hw/pci-host/piix.c | 8 + hw/pci-host/q35.c | 26 +- hw/pci/pcie_host.c | 24 - hw/timer/hpet.c | 5 + qom/object.c | 56 + vl.c | 3 + hw/i386/Makefile.objs | 27 + hw/i386/acpi-dsdt-cpu-hotplug.dsl | 93 + hw/i386/acpi-dsdt-dbug.dsl | 41 + hw/i386/acpi-dsdt-hpet.dsl | 51 + hw/i386/acpi-dsdt-isa.dsl | 117 + hw/i386/acpi-dsdt-pci-crs.dsl | 105 + hw/i386/acpi-dsdt.dsl | 343 ++ hw/i386/acpi-dsdt.hex.generated | 4409 ++++++++++++++++++++ hw/i386/q35-acpi-dsdt.dsl | 452 +++ hw/i386/q35-acpi-dsdt.hex.generated | 7346 ++++++++++++++++++++++++++++++++++ hw/i386/ssdt-misc.dsl | 119 + hw/i386/ssdt-misc.hex.generated | 190 + hw/i386/ssdt-pcihp.dsl | 51 + hw/i386/ssdt-pcihp.hex.generated | 108 + hw/i386/ssdt-proc.dsl | 63 + hw/i386/ssdt-proc.hex.generated | 134 + scripts/acpi_extract.py | 362 ++ scripts/acpi_extract_preprocess.py | 51 + scripts/update-acpi.sh | 4 + 52 files changed, 16228 insertions(+), 75 deletions(-) create mode 100644 hw/i386/acpi-defs.h create mode 100644 include/hw/acpi/piix4.h create mode 100644 include/hw/i386/acpi-build.h create mode 100644 include/hw/i386/bios-linker-loader.h create mode 100644 hw/i386/acpi-build.c create mode 100644 hw/i386/bios-linker-loader.c create mode 100644 hw/i386/acpi-dsdt-cpu-hotplug.dsl create mode 100644 hw/i386/acpi-dsdt-dbug.dsl create mode 100644 hw/i386/acpi-dsdt-hpet.dsl create mode 100644 hw/i386/acpi-dsdt-isa.dsl create mode 100644 hw/i386/acpi-dsdt-pci-crs.dsl create mode 100644 hw/i386/acpi-dsdt.dsl create mode 100644 hw/i386/acpi-dsdt.hex.generated create mode 100644 hw/i386/q35-acpi-dsdt.dsl create mode 100644 hw/i386/q35-acpi-dsdt.hex.generated create mode 100644 hw/i386/ssdt-misc.dsl create mode 100644 hw/i386/ssdt-misc.hex.generated create mode 100644 hw/i386/ssdt-pcihp.dsl create mode 100644 hw/i386/ssdt-pcihp.hex.generated create mode 100644 hw/i386/ssdt-proc.dsl create mode 100644 hw/i386/ssdt-proc.hex.generated create mode 100755 scripts/acpi_extract.py create mode 100755 scripts/acpi_extract_preprocess.py create mode 100644 scripts/update-acpi.sh
Signature · 1 line
MST
PATCH v4 1/23 qemu: add Error to typedefs
This is so qom headers can use it without pulling in extra headers.
--- include/qemu/typedefs.h | 1 + 1 file changed, 1 insertion(+)
include/qemu/typedefs.h +1 -0
@@ -7,6 +7,7 @@ typedef struct QEMUTimer QEMUTimer;typedef struct QEMUTimerListGroup QEMUTimerListGroup ;typedef struct QEMUFile QEMUFile ;typedef struct QEMUBH QEMUBH ; +typedef struct Error Error ;typedef struct AioContext AioContext ;
Signature · 1 line
MST
PATCH v4 2/23 qom: pull in qemu/typedefs
In reply to Michael S. TsirkinAs usual so we can use typedefs without header dependencies.
--- include/qom/object.h | 1 + 1 file changed, 1 insertion(+)
include/qom/object.h +1 -0
@@ -17,6 +17,7 @@#include <glib.h> #include <stdint.h> #include <stdbool.h> +#include "qemu/typedefs.h" #include "qemu/queue.h" struct Visitor ;
Signature · 1 line
MST
PATCH v4 3/23 qom: cleanup struct Error references
In reply to Michael S. Tsirkinnow that a typedef for struct Error is available, use it in qom/object.h to match coding style rules.
--- include/qom/object.h | 51 +++++++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 26 deletions(-)
include/qom/object.h +25 -26
@@ -21,7 +21,6 @@#include "qemu/queue.h" struct Visitor ; -struct Error ;struct TypeImpl ;typedef struct TypeImpl *Type ;
@@ -302,7 +301,7 @@ typedef void (ObjectPropertyAccessor)(Object *obj,struct Visitor *v, void *opaque, const char *name, - struct Error **errp); + Error **errp);/** * ObjectPropertyRelease:
@@ -791,9 +790,9 @@ void object_property_add(Object *obj, const char *name, const char *type, ObjectPropertyAccessor *get, ObjectPropertyAccessor *set, ObjectPropertyRelease *release, - void *opaque, struct Error **errp); + void *opaque, Error **errp); -void object_property_del (Object *obj,const char *name,struct Error **errp); +void object_property_del (Object *obj,const char *name,Error **errp);/** * object_property_find:
@@ -804,7 +803,7 @@ void object_property_del(Object *obj, const char *name, struct Error **errp);* Look up a property for an object and return its #ObjectProperty if found. */ ObjectProperty *object_property_find (Object *obj,const char *name, -struct Error **errp); +Error **errp);void object_unparent (Object *obj);
@@ -819,7 +818,7 @@ void object_unparent(Object *obj);* Reads a property from a object. */ void object_property_get (Object *obj,struct Visitor *v,const char *name, -struct Error **errp); +Error **errp);/** * object_property_set_str:
@@ -830,7 +829,7 @@ void object_property_get(Object *obj, struct Visitor *v, const char *name,* Writes a string value to a property. */ void object_property_set_str (Object *obj,const char *value, -const char *name,struct Error **errp); +const char *name,Error **errp);/** * object_property_get_str:
@@ -843,7 +842,7 @@ void object_property_set_str(Object *obj, const char *value,* The caller should free the string. */ char *object_property_get_str (Object *obj,const char *name, -struct Error **errp); +Error **errp);/** * object_property_set_link:
@@ -854,7 +853,7 @@ char *object_property_get_str(Object *obj, const char *name,* Writes an object's canonical path to a property. */ void object_property_set_link (Object *obj,Object *value, -const char *name,struct Error **errp); +const char *name,Error **errp);/** * object_property_get_link:
@@ -867,7 +866,7 @@ void object_property_set_link(Object *obj, Object *value,* string or not a valid object path). */ Object *object_property_get_link (Object *obj,const char *name, -struct Error **errp); +Error **errp);/** * object_property_set_bool:
@@ -878,7 +877,7 @@ Object *object_property_get_link(Object *obj, const char *name,* Writes a bool value to a property. */ void object_property_set_bool (Object *obj,bool value, -const char *name,struct Error **errp); +const char *name,Error **errp);/** * object_property_get_bool:
@@ -890,7 +889,7 @@ void object_property_set_bool(Object *obj, bool value,* an error occurs (including when the property value is not a bool). */ bool object_property_get_bool (Object *obj,const char *name, -struct Error **errp); +Error **errp);/** * object_property_set_int:
@@ -901,7 +900,7 @@ bool object_property_get_bool(Object *obj, const char *name,* Writes an integer value to a property. */ void object_property_set_int (Object *obj,int64_t value, -const char *name,struct Error **errp); +const char *name,Error **errp);/** * object_property_get_int:
@@ -913,7 +912,7 @@ void object_property_set_int(Object *obj, int64_t value,* an error occurs (including when the property value is not an integer). */ int64_t object_property_get_int (Object *obj,const char *name, -struct Error **errp); +Error **errp);/** * object_property_set:
@@ -927,7 +926,7 @@ int64_t object_property_get_int(Object *obj, const char *name,* Writes a property to a object. */ void object_property_set (Object *obj,struct Visitor *v,const char *name, -struct Error **errp); +Error **errp);/** * object_property_parse:
@@ -939,7 +938,7 @@ void object_property_set(Object *obj, struct Visitor *v, const char *name,* Parses a string and writes the result into a property of an object. */ void object_property_parse (Object *obj,const char *string, -const char *name,struct Error **errp); +const char *name,Error **errp);/** * object_property_print:
@@ -951,7 +950,7 @@ void object_property_parse(Object *obj, const char *string,* caller shall free the string. */ char *object_property_print (Object *obj,const char *name, -struct Error **errp); +Error **errp);/** * object_property_get_type:
@@ -962,7 +961,7 @@ char *object_property_print(Object *obj, const char *name,* Returns: The type name of the property. */ const char *object_property_get_type (Object *obj,const char *name, -struct Error **errp); +Error **errp);/** * object_get_root:
@@ -1055,7 +1054,7 @@ Object *object_resolve_path_component(Object *parent, const gchar *part);* The child object itself can be retrieved using object_property_get_link(). */ void object_property_add_child (Object *obj,const char *name, -Object *child,struct Error **errp); +Object *child,Error **errp);/** * object_property_add_link:
@@ -1078,7 +1077,7 @@ void object_property_add_child(Object *obj, const char *name,*/ void object_property_add_link (Object *obj,const char *name,const char *type,Object **child, -struct Error **errp); +Error **errp);/** * object_property_add_str:
@@ -1093,9 +1092,9 @@ void object_property_add_link(Object *obj, const char *name,* property of type 'string'. */ void object_property_add_str (Object *obj,const char *name, -char *(*get)(Object *,struct Error **), -void (*set)(Object *,const char *,struct Error **), -struct Error **errp); +char *(*get)(Object *,Error **), +void (*set)(Object *,const char *,Error **), +Error **errp);/** * object_property_add_bool:
@@ -1109,9 +1108,9 @@ void object_property_add_str(Object *obj, const char *name,* property of type 'bool'. */ void object_property_add_bool (Object *obj,const char *name, -bool (*get)(Object *,struct Error **), -void (*set)(Object *,bool ,struct Error **), -struct Error **errp); +bool (*get)(Object *,Error **), +void (*set)(Object *,bool ,Error **), +Error **errp);/** * object_child_foreach:
Signature · 1 line
MST
PATCH v4 4/23 qom: add pointer to int property helpers
In reply to Michael S. TsirkinMake it easy to add read-only helpers for simple
integer properties in memory.
--- include/qom/object.h | 21 ++++++++++++++++++++ qom/object.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+)
include/qom/object.h +21 -0
@@ -795,6 +795,27 @@ void object_property_add(Object *obj, const char *name, const char *type,void object_property_del (Object *obj,const char *name,Error **errp);/** +* object_property_add_uint8_ptr: +* object_property_add_uint16_ptr: +* object_property_add_uint32_ptr: +* object_property_add_uint64_ptr: +* @obj: the object to add a property to +* @name: the name of the property +* @v: pointer to value +* +* Add an integer property in memory. This function will add a +* property of the appropriate type. +*/ +void object_property_add_uint8_ptr (Object *obj,const char *name, +const uint8_t *v,Error **errp); +void object_property_add_uint16_ptr (Object *obj,const char *name, +const uint16_t *v,Error **errp); +void object_property_add_uint32_ptr (Object *obj,const char *name, +const uint32_t *v,Error **errp); +void object_property_add_uint64_ptr (Object *obj,const char *name, +const uint64_t *v,Error **Errp); + +/** * object_property_find: * @obj: the object * @name: the name of the property
qom/object.c +56 -0
62 lines not on this page · raw message
Signature · 1 line
MST
PATCH v4 5/23 fw_cfg: interface to trigger callback on read
In reply to Michael S. Tsirkin--- include/hw/nvram/fw_cfg.h | 4 ++++ hw/nvram/fw_cfg.c | 33 ++++++++++++++++++++++++++++----- 2 files changed, 32 insertions(+), 5 deletions(-)
include/hw/nvram/fw_cfg.h +4 -0
@@ -60,6 +60,7 @@ typedef struct FWCfgFiles { } FWCfgFiles;typedef void (*FWCfgCallback )(void *opaque,uint8_t *data); +typedef void (*FWCfgReadCallback )(void *opaque,uint32_t offset);void fw_cfg_add_bytes (FWCfgState *s,uint16_t key,void *data,size_t len);void fw_cfg_add_string (FWCfgState *s,uint16_t key,const char *value);
@@ -70,6 +71,9 @@ void fw_cfg_add_callback(FWCfgState *s, uint16_t key, FWCfgCallback callback, void *callback_opaque, void *data, size_t len);void fw_cfg_add_file (FWCfgState *s,const char *filename,void *data,size_t len); +void fw_cfg_add_file_callback (FWCfgState *s,const char *filename, +FWCfgReadCallback callback,void *callback_opaque, +void *data,size_t len);FWCfgState *fw_cfg_init (uint32_t ctl_port,uint32_t data_port,hwaddr crl_addr,hwaddr data_addr);
hw/nvram/fw_cfg.c +28 -5
@@ -42,6 +42,7 @@ typedef struct FWCfgEntry {uint8_t *data;void *callback_opaque;FWCfgCallback callback; +FWCfgReadCallback read_callback; } FWCfgEntry;struct FWCfgState {
@@ -249,8 +250,12 @@ static uint8_t fw_cfg_read(FWCfgState *s)if (s->cur_entry ==FW_CFG_INVALID || !e->data || s->cur_offset >= e->len) ret =0 ; -else +else { +if (e->read_callback) { + e->read_callback (e->callback_opaque, s->cur_offset); + } ret = e->data[s->cur_offset++]; + }trace_fw_cfg_read (s, ret);return ret;
@@ -381,7 +386,10 @@ static const VMStateDescription vmstate_fw_cfg = { } }; -void fw_cfg_add_bytes (FWCfgState *s,uint16_t key,void *data,size_t len) +static void fw_cfg_add_bytes_read_callback (FWCfgState *s,uint16_t key, +FWCfgReadCallback callback, +void *callback_opaque, +void *data,size_t len) {int arch = !!(key &FW_CFG_ARCH_LOCAL );
@@ -391,6 +399,13 @@ void fw_cfg_add_bytes(FWCfgState *s, uint16_t key, void *data, size_t len) s->entries[arch][key].data = data; s->entries[arch][key].len = (uint32_t )len; + s->entries[arch][key].read_callback = callback; + s->entries[arch][key].callback_opaque = callback_opaque; +} + +void fw_cfg_add_bytes (FWCfgState *s,uint16_t key,void *data,size_t len) +{ +fw_cfg_add_bytes_read_callback (s, key,NULL ,NULL , data, len); }void fw_cfg_add_string (FWCfgState *s,uint16_t key,const char *value)
@@ -444,8 +459,9 @@ void fw_cfg_add_callback(FWCfgState *s, uint16_t key, FWCfgCallback callback, s->entries[arch][key].callback = callback; } -void fw_cfg_add_file (FWCfgState *s,const char *filename, -void *data,size_t len) +void fw_cfg_add_file_callback (FWCfgState *s,const char *filename, +FWCfgReadCallback callback,void *callback_opaque, +void *data,size_t len) {int i, index;size_t dsize;
@@ -459,7 +475,8 @@ void fw_cfg_add_file(FWCfgState *s, const char *filename, index =be32_to_cpu (s->files->count);assert (index <FW_CFG_FILE_SLOTS ); -fw_cfg_add_bytes (s,FW_CFG_FILE_FIRST + index, data, len); +fw_cfg_add_bytes_read_callback (s,FW_CFG_FILE_FIRST + index, + callback, callback_opaque, data, len);pstrcpy (s->files->f[index].name,sizeof (s->files->f[index].name), filename);
@@ -477,6 +494,12 @@ void fw_cfg_add_file(FWCfgState *s, const char *filename, s->files->count =cpu_to_be32 (index+1 ); } +void fw_cfg_add_file (FWCfgState *s,const char *filename, +void *data,size_t len) +{ +fw_cfg_add_file_callback (s, filename,NULL ,NULL , data, len); +} +static void fw_cfg_machine_ready (struct Notifier *n,void *data) {size_t len;
Signature · 1 line
MST
PATCH v4 6/23 loader: support for unmapped ROM blobs
In reply to Michael S. TsirkinSupport ROM blobs not mapped into guest memory:
same as ROM files really but use caller's buffer.
Support incoking callback on access and return memory pointer making it easier
for caller to update memory if necessary.
--- hw/lm32/lm32_hwsetup.h | 2 +- include/hw/loader.h | 7 ++++--- hw/core/loader.c | 23 ++++++++++++++++++++--- 3 files changed, 25 insertions(+), 7 deletions(-)
hw/lm32/lm32_hwsetup.h +1 -1
@@ -73,7 +73,7 @@ static inline void hwsetup_free(HWSetup *hw)static inline void hwsetup_create_rom (HWSetup *hw,hwaddr base) { -rom_add_blob ("hwsetup" , hw->data,TARGET_PAGE_SIZE , base); +rom_add_blob ("hwsetup" , hw->data,TARGET_PAGE_SIZE , base,NULL ,NULL ,NULL ); }static inline void hwsetup_add_u8 (HWSetup *hw,uint8_t u)
include/hw/loader.h +4 -3
@@ -40,8 +40,9 @@ extern bool rom_file_in_ram;int rom_add_file (const char *file,const char *fw_dir,hwaddr addr,int32_t bootindex); -int rom_add_blob (const char *name,const void *blob,size_t len, -hwaddr addr); +void *rom_add_blob (const char *name,const void *blob,size_t len, +hwaddr addr,const char *fw_file_name, +FWCfgReadCallback fw_callback,void *callback_opaque);int rom_add_elf_program (const char *name,void *data,size_t datasize,size_t romsize,hwaddr addr);int rom_load_all (void );
@@ -53,7 +54,7 @@ void do_info_roms(Monitor *mon, const QDict *qdict);#define rom_add_file_fixed (_f, _a, _i) \ rom_add_file(_f, NULL, _a, _i)#define rom_add_blob_fixed (_f, _b, _l, _a) \ - rom_add_blob(_f, _b, _l, _a) + (rom_add_blob(_f, _b, _l, _a, NULL, NULL, NULL) ? 0 : -1)#define PC_ROM_MIN_VGA 0xc0000#define PC_ROM_MIN_OPTION 0xc8000
hw/core/loader.c +20 -3
@@ -700,10 +700,12 @@ err:return -1 ; } -int rom_add_blob (const char *name,const void *blob,size_t len, -hwaddr addr) +void *rom_add_blob (const char *name,const void *blob,size_t len, +hwaddr addr,const char *fw_file_name, +FWCfgReadCallback fw_callback,void *callback_opaque) {Rom *rom; +void *data =NULL ; rom =g_malloc0 (sizeof (*rom)); rom->name =g_strdup (name);
@@ -713,7 +715,22 @@ int rom_add_blob(const char *name, const void *blob, size_t len, rom->data =g_malloc0 (rom->datasize);memcpy (rom->data, blob, len);rom_insert (rom); -return 0 ; +if (fw_file_name && fw_cfg) { +char devpath[100 ]; + +snprintf (devpath,sizeof (devpath),"/rom@%s" , fw_file_name); + +if (rom_file_in_ram) { + data =rom_set_mr (rom,OBJECT (fw_cfg), devpath); + }else { + data = rom->data; + } + +fw_cfg_add_file_callback (fw_cfg, fw_file_name, + fw_callback, callback_opaque, + data, rom->romsize); + } +return data; }/* This function is specific for elf program because we don't need to allocate
Signature · 1 line
MST
PATCH v4 7/23 pcie_host: expose UNMAPPED macro
In reply to Michael S. TsirkinMake it possible to test unmapped status through QMP.
--- include/hw/pci/pcie_host.h | 3 +++ hw/pci/pcie_host.c | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-)
include/hw/pci/pcie_host.h +3 -0
@@ -28,6 +28,9 @@#define PCIE_HOST_BRIDGE (obj) \ OBJECT_CHECK(PCIExpressHost, (obj), TYPE_PCIE_HOST_BRIDGE) +/* pcie_host::base_addr == PCIE_BASE_ADDR_UNMAPPED when it isn't mapped. */ +#define PCIE_BASE_ADDR_UNMAPPED ((hwaddr)-1ULL) +struct PCIExpressHost {PCIHostState pci;
hw/pci/pcie_host.c +0 -3
@@ -104,9 +104,6 @@ static const MemoryRegionOps pcie_mmcfg_ops = { .endianness = DEVICE_NATIVE_ENDIAN, }; -/* pcie_host::base_addr == PCIE_BASE_ADDR_UNMAPPED when it isn't mapped. */ -#define PCIE_BASE_ADDR_UNMAPPED ((hwaddr)-1ULL) -int pcie_host_init (PCIExpressHost *e) { e->base_addr =PCIE_BASE_ADDR_UNMAPPED ;
Signature · 1 line
MST
PATCH v4 8/23 pcie_host: expose address format
In reply to Michael S. TsirkinCallers pass in the address so it's helpful for
them to be able to decode it.
--- include/hw/pci/pcie_host.h | 21 +++++++++++++++++++++ hw/pci/pcie_host.c | 21 --------------------- 2 files changed, 21 insertions(+), 21 deletions(-)
include/hw/pci/pcie_host.h +21 -0
@@ -54,4 +54,25 @@ void pcie_host_mmcfg_update(PCIExpressHost *e,hwaddr addr, uint32_t size); +/* +* PCI express ECAM (Enhanced Configuration Address Mapping) format. +* AKA mmcfg address +* bit 20 - 28: bus number +* bit 15 - 19: device number +* bit 12 - 14: function number +* bit 0 - 11: offset in configuration space of a given device +*/ +#define PCIE_MMCFG_SIZE_MAX (1ULL << 28) +#define PCIE_MMCFG_SIZE_MIN (1ULL << 20) +#define PCIE_MMCFG_BUS_BIT 20 +#define PCIE_MMCFG_BUS_MASK 0x1ff +#define PCIE_MMCFG_DEVFN_BIT 12 +#define PCIE_MMCFG_DEVFN_MASK 0xff +#define PCIE_MMCFG_CONFOFFSET_MASK 0xfff +#define PCIE_MMCFG_BUS (addr) (((addr) >> PCIE_MMCFG_BUS_BIT) & \ + PCIE_MMCFG_BUS_MASK) +#define PCIE_MMCFG_DEVFN (addr) (((addr) >> PCIE_MMCFG_DEVFN_BIT) & \ + PCIE_MMCFG_DEVFN_MASK) +#define PCIE_MMCFG_CONFOFFSET (addr) ((addr) & PCIE_MMCFG_CONFOFFSET_MASK) +#endif /* PCIE_HOST_H */
hw/pci/pcie_host.c +0 -21
@@ -24,27 +24,6 @@#include "hw/pci/pcie_host.h" #include "exec/address-spaces.h" -/* -* PCI express mmcfig address -* bit 20 - 28: bus number -* bit 15 - 19: device number -* bit 12 - 14: function number -* bit 0 - 11: offset in configuration space of a given device -*/ -#define PCIE_MMCFG_SIZE_MAX (1ULL << 28) -#define PCIE_MMCFG_SIZE_MIN (1ULL << 20) -#define PCIE_MMCFG_BUS_BIT 20 -#define PCIE_MMCFG_BUS_MASK 0x1ff -#define PCIE_MMCFG_DEVFN_BIT 12 -#define PCIE_MMCFG_DEVFN_MASK 0xff -#define PCIE_MMCFG_CONFOFFSET_MASK 0xfff -#define PCIE_MMCFG_BUS (addr) (((addr) >> PCIE_MMCFG_BUS_BIT) & \ - PCIE_MMCFG_BUS_MASK) -#define PCIE_MMCFG_DEVFN (addr) (((addr) >> PCIE_MMCFG_DEVFN_BIT) & \ - PCIE_MMCFG_DEVFN_MASK) -#define PCIE_MMCFG_CONFOFFSET (addr) ((addr) & PCIE_MMCFG_CONFOFFSET_MASK) - -/* a helper function to get a PCIDevice for a given mmconfig address */ static inline PCIDevice *pcie_dev_find_by_mmcfg_addr (PCIBus *s,uint32_t mmcfg_addr)
Signature · 1 line
MST
PATCH v4 9/23 q35: use macro for MCFG property name
In reply to Michael S. TsirkinUseful to make it accessible through QOM.
--- include/hw/pci/pcie_host.h | 2 ++ hw/pci-host/q35.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
include/hw/pci/pcie_host.h +2 -0
@@ -28,6 +28,8 @@#define PCIE_HOST_BRIDGE (obj) \ OBJECT_CHECK(PCIExpressHost, (obj), TYPE_PCIE_HOST_BRIDGE) +#define PCIE_HOST_MCFG_BASE "MCFG" +/* pcie_host::base_addr == PCIE_BASE_ADDR_UNMAPPED when it isn't mapped. */ #define PCIE_BASE_ADDR_UNMAPPED ((hwaddr)-1ULL)
hw/pci-host/q35.c +1 -1
@@ -110,7 +110,7 @@ static void q35_host_get_pci_hole64_end(Object *obj, Visitor *v, }static Property mch_props[] = { -DEFINE_PROP_UINT64 ("MCFG" , Q35PCIHost, parent_obj.base_addr, +DEFINE_PROP_UINT64 (PCIE_HOST_MCFG_BASE , Q35PCIHost, parent_obj.base_addr,MCH_HOST_BRIDGE_PCIEXBAR_DEFAULT ),DEFINE_PROP_SIZE (PCI_HOST_PROP_PCI_HOLE64_SIZE , Q35PCIHost, mch.pci_hole64_size,DEFAULT_PCI_HOLE64_SIZE ),
Signature · 1 line
MST
PATCH v4 10/23 q35: expose mmcfg size as a property
In reply to Michael S. TsirkinAddress is already exposed, expose size for symmetry.
--- include/hw/pci/pcie_host.h | 1 + hw/pci-host/q35.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+)
include/hw/pci/pcie_host.h +1 -0
@@ -29,6 +29,7 @@ OBJECT_CHECK(PCIExpressHost, (obj), TYPE_PCIE_HOST_BRIDGE)#define PCIE_HOST_MCFG_BASE "MCFG" +#define PCIE_HOST_MCFG_SIZE "mcfg_size"/* pcie_host::base_addr == PCIE_BASE_ADDR_UNMAPPED when it isn't mapped. */ #define PCIE_BASE_ADDR_UNMAPPED ((hwaddr)-1ULL)
hw/pci-host/q35.c +14 -0
@@ -109,6 +109,16 @@ static void q35_host_get_pci_hole64_end(Object *obj, Visitor *v,visit_type_uint64 (v, &w64.end, name, errp); } +static void q35_host_get_mmcfg_size (Object *obj,Visitor *v, +void *opaque,const char *name, +Error **errp) +{ +PCIExpressHost *e =PCIE_HOST_BRIDGE (obj); +uint32_t value = e->size; + +visit_type_uint32 (v, &value, name, errp); +} +static Property mch_props[] = {DEFINE_PROP_UINT64 (PCIE_HOST_MCFG_BASE , Q35PCIHost, parent_obj.base_addr,MCH_HOST_BRIDGE_PCIEXBAR_DEFAULT ),
@@ -160,6 +170,10 @@ static void q35_host_initfn(Object *obj) q35_host_get_pci_hole64_end, NULL, NULL, NULL, NULL); +object_property_add (obj,PCIE_HOST_MCFG_SIZE ,"int" , + q35_host_get_mmcfg_size, +NULL ,NULL ,NULL ,NULL ); +/* Leave enough space for the biggest MCFG BAR */ /* TODO: this matches current bios behaviour, but * it's not a power of two, which means an MTRR
Signature · 1 line
MST
PATCH v4 11/23 i386: add ACPI table files from seabios
In reply to Michael S. TsirkinThis adds ASL code as well as scripts for processing it, imported from seabios git tree
commit 51684b7ced75fb76776e8ee84833fcfb6ecf12dd
Will be used for runtime acpi table generation.
Note:
This patch reuses some code from SeaBIOS, which was originally under LGPLv2 and then relicensed to GPLv3 or LGPLv3, in QEMU under GPLv2+. This relicensing has been acked by all contributors that had contributed to the code since the v2->v3 relicense. ACKs approving the v2+ relicensing are listed below. The list might include ACKs from people not holding copyright on any parts of the reused code, but it's better to err on the side of caution and include them.
Affected SeaBIOS files (GPLv2+ license headers added)
<http://thread.gmane.org/gmane.comp.bios.coreboot.seabios/5949>:
src/acpi-dsdt-cpu-hotplug.dsl
src/acpi-dsdt-dbug.dsl
src/acpi-dsdt-hpet.dsl
src/acpi-dsdt-isa.dsl
src/acpi-dsdt-pci-crs.dsl
src/acpi.c
src/acpi.h
src/ssdt-misc.dsl
src/ssdt-pcihp.dsl
src/ssdt-proc.dsl
tools/acpi_extract.py
tools/acpi_extract_preprocess.py
Each one of the listed people agreed to the following:
Quoted 5 lines
If you allow the use of your contribution in QEMU under the terms of GPLv2 or later as proposed by this patch, please respond to this mail including the line:
Acked-by Name <email address>
--- hw/i386/acpi-dsdt-cpu-hotplug.dsl | 93 ++++++++ hw/i386/acpi-dsdt-dbug.dsl | 41 ++++ hw/i386/acpi-dsdt-hpet.dsl | 51 +++++ hw/i386/acpi-dsdt-isa.dsl | 117 ++++++++++ hw/i386/acpi-dsdt-pci-crs.dsl | 105 +++++++++ hw/i386/acpi-dsdt.dsl | 343 ++++++++++++++++++++++++++++ hw/i386/q35-acpi-dsdt.dsl | 452 +++++++++++++++++++++++++++++++++++++ hw/i386/ssdt-misc.dsl | 119 ++++++++++ hw/i386/ssdt-pcihp.dsl | 51 +++++ hw/i386/ssdt-proc.dsl | 63 ++++++ scripts/acpi_extract.py | 362 +++++++++++++++++++++++++++++ scripts/acpi_extract_preprocess.py | 51 +++++ 12 files changed, 1848 insertions(+) create mode 100644 hw/i386/acpi-dsdt-cpu-hotplug.dsl create mode 100644 hw/i386/acpi-dsdt-dbug.dsl create mode 100644 hw/i386/acpi-dsdt-hpet.dsl create mode 100644 hw/i386/acpi-dsdt-isa.dsl create mode 100644 hw/i386/acpi-dsdt-pci-crs.dsl create mode 100644 hw/i386/acpi-dsdt.dsl create mode 100644 hw/i386/q35-acpi-dsdt.dsl create mode 100644 hw/i386/ssdt-misc.dsl create mode 100644 hw/i386/ssdt-pcihp.dsl create mode 100644 hw/i386/ssdt-proc.dsl create mode 100755 scripts/acpi_extract.py create mode 100755 scripts/acpi_extract_preprocess.py
hw/i386/acpi-dsdt-cpu-hotplug.dsl new file +93 -0
@@ -0,0 +1,93 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License along + * with this program; if not, see <http://www.gnu.org/licenses/>. + */ + +/**************************************************************** + * CPU hotplug + ****************************************************************/ + +Scope(\_SB) { + /* Objects filled in by run-time generated SSDT */ + External(NTFY, MethodObj) + External(CPON, PkgObj) + + /* Methods called by run-time generated SSDT Processor objects */ + Method(CPMA, 1, NotSerialized) { + // _MAT method - create an madt apic buffer + // Arg0 = Processor ID = Local APIC ID + // Local0 = CPON flag for this cpu + Store(DerefOf(Index(CPON, Arg0)), Local0) + // Local1 = Buffer (in madt apic form) to return + Store(Buffer(8) {0x00, 0x08, 0x00, 0x00, 0x00, 0, 0, 0}, Local1) + // Update the processor id, lapic id, and enable/disable status + Store(Arg0, Index(Local1, 2)) + Store(Arg0, Index(Local1, 3)) + Store(Local0, Index(Local1, 4)) + Return (Local1) + } + Method(CPST, 1, NotSerialized) { + // _STA method - return ON status of cpu + // Arg0 = Processor ID = Local APIC ID + // Local0 = CPON flag for this cpu + Store(DerefOf(Index(CPON, Arg0)), Local0) + If (Local0) { + Return (0xF) + } Else { + Return (0x0) + } + } + Method(CPEJ, 2, NotSerialized) { + // _EJ0 method - eject callback + Sleep(200) + } + + /* CPU hotplug notify method */ + OperationRegion(PRST, SystemIO, 0xaf00, 32) + Field(PRST, ByteAcc, NoLock, Preserve) { + PRS, 256 + } + Method(PRSC, 0) { + // Local5 = active cpu bitmap + Store(PRS, Local5) + // Local2 = last read byte from bitmap + Store(Zero, Local2) + // Local0 = Processor ID / APIC ID iterator + Store(Zero, Local0) + While (LLess(Local0, SizeOf(CPON))) { + // Local1 = CPON flag for this cpu + Store(DerefOf(Index(CPON, Local0)), Local1) + If (And(Local0, 0x07)) { + // Shift down previously read bitmap byte + ShiftRight(Local2, 1, Local2) + } Else { + // Read next byte from cpu bitmap + Store(DerefOf(Index(Local5, ShiftRight(Local0, 3))), Local2) + } + // Local3 = active state for this cpu + Store(And(Local2, 1), Local3) + + If (LNotEqual(Local1, Local3)) { + // State change - update CPON with new state + Store(Local3, Index(CPON, Local0)) + // Do CPU notify + If (LEqual(Local3, 1)) { + NTFY(Local0, 1) + } Else { + NTFY(Local0, 3) + } + } + Increment(Local0) + } + } +}
hw/i386/acpi-dsdt-dbug.dsl new file +41 -0
41 lines not on this page · raw message
hw/i386/acpi-dsdt-hpet.dsl new file +51 -0
51 lines not on this page · raw message
hw/i386/acpi-dsdt-isa.dsl new file +117 -0
117 lines not on this page · raw message
hw/i386/acpi-dsdt-pci-crs.dsl new file +105 -0
105 lines not on this page · raw message
hw/i386/acpi-dsdt.dsl new file +343 -0
343 lines not on this page · raw message
hw/i386/q35-acpi-dsdt.dsl new file +452 -0
452 lines not on this page · raw message
hw/i386/ssdt-misc.dsl new file +119 -0
119 lines not on this page · raw message
hw/i386/ssdt-pcihp.dsl new file +51 -0
51 lines not on this page · raw message
hw/i386/ssdt-proc.dsl new file +63 -0
63 lines not on this page · raw message
scripts/acpi_extract.py new file +362 -0
362 lines not on this page · raw message
scripts/acpi_extract_preprocess.py new file +51 -0
51 lines not on this page · raw message
Signature · 1 line
MST
PATCH v4 12/23 acpi: add rules to compile ASL source
In reply to Michael S. TsirkinDetect presence of IASL compiler and use it to process ASL source. If not there, use pre-compiled files in-tree. Add script to update the in-tree files.
Note: distros are known to silently update iasl
so detect correct iasl flags for the installed version on each run as opposed to at configure time.
--- configure | 9 ++++++++- hw/i386/Makefile.objs | 22 ++++++++++++++++++++++ scripts/update-acpi.sh | 4 ++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 scripts/update-acpi.sh
configure +8 -1
@@ -119,6 +119,7 @@ path_of() { # default parameters source_path=`dirname "$0"` cpu="" +iasl="iasl" interp_prefix="/usr/gnemul/qemu-%M" static="no" cross_prefix=""
@@ -257,6 +258,8 @@ for opt do ;; --cxx=*) CXX="$optarg" ;; + --iasl=*) iasl="$optarg" + ;; --source-path=*) source_path="$optarg" ;; --cpu=*) cpu="$optarg"
@@ -1055,6 +1058,7 @@ echo "Advanced options (experts only):" echo " --source-path=PATH path of source code [$source_path]" echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]" echo " --cc=CC use C compiler CC [$cc]" +echo " --iasl=IASL use ACPI compiler IASL [$iasl]" echo " --host-cc=CC use C compiler CC [$host_cc] for code run at" echo " build time" echo " --cxx=CXX use C++ compiler CXX [$cxx]"
@@ -4239,6 +4243,9 @@ else fi echo "PYTHON=$python" >> $config_host_mak echo "CC=$cc" >> $config_host_mak +if $iasl -h > /dev/null 2>&1; then + echo "IASL=$iasl" >> $config_host_mak +fi echo "CC_I386=$cc_i386" >> $config_host_mak echo "HOST_CC=$host_cc" >> $config_host_mak echo "CXX=$cxx" >> $config_host_mak
@@ -4691,7 +4698,7 @@ for rom in seabios vgabios ; do echo "BCC=bcc" >> $config_mak echo "CPP=$cpp" >> $config_mak echo "OBJCOPY=objcopy" >> $config_mak - echo "IASL=iasl" >> $config_mak + echo "IASL=$iasl" >> $config_mak echo "LD=$ld" >> $config_mak done
hw/i386/Makefile.objs +22 -0
@@ -5,3 +5,25 @@ obj-y += pc_sysfw.o obj-$(CONFIG_XEN) += xen_domainbuild.o xen_machine_pv.o obj-y += kvmvapic.o + +iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \ + ; then echo "$(2)"; else echo "$(3)"; fi ;) + +ifdef IASL +#IASL Present. Generate hex files from .dsl +hw/i386/%.hex: $(SRC_PATH)/hw/i386/%.dsl $(SRC_PATH)/scripts/acpi_extract_preprocess.py $(SRC_PATH)/scripts/acpi_extract.py + $(call quiet-command, cpp -P $< -o $*.dsl.i.orig, " CPP $(TARGET_DIR)$*.dsl.i.orig") + $(call quiet-command, $(PYTHON) $(SRC_PATH)/scripts/acpi_extract_preprocess.py $*.dsl.i.orig > $*.dsl.i, " ACPI_PREPROCESS $(TARGET_DIR)$*.dsl.i") + $(call quiet-command, $(IASL) $(call iasl-option,$(IASL),-Pn,) -vs -l -tc -p $* $*.dsl.i $(if $(V), , > /dev/null) 2>&1 ," IASL $(TARGET_DIR)$*.dsl.i") + $(call quiet-command, $(SRC_PATH)/scripts/acpi_extract.py $*.lst > $*.off, " ACPI_EXTRACT $(TARGET_DIR)$*.off") + $(call quiet-command, cat $*.off > $@, " CAT $(TARGET_DIR)$@") +else +#IASL Not present. Restore pre-generated hex files. +hw/i386/%.hex: $(SRC_PATH)/hw/i386/%.hex.generated + $(call quiet-command, cp -f $< $@, " CP $(TARGET_DIR)$@") +endif + +.PHONY: cleanhex +cleanhex: + rm -f hw/i386/*hex +clean: cleanhex
scripts/update-acpi.sh new file +4 -0
@@ -0,0 +1,4 @@ +cd x86_64-softmmu +for file in hw/i386/*.hex; do + cp -f $file ../$file.generated +done
Signature · 1 line
MST
Re: [Qemu-devel] [PATCH v4 12/23] acpi: add rules to compile ASL source
Il 22/09/2013 15:37, Michael S. Tsirkin ha scritto:
Quoted 7 lines
Detect presence of IASL compiler and use it to process ASL source. If not there, use pre-compiled files in-tree. Add script to update the in-tree files.
Note: distros are known to silently update iasl
so detect correct iasl flags for the installed version on each run as opposed to at configure time.
This is not any different from a C compiler, which is likely updated much much more often than iasl. However, I don't feel strongly at all about this.
Paolo
Re: [Qemu-devel] [PATCH v4 12/23] acpi: add rules to compile ASL source
Quoted 11 lines · Paolo Bonzini
Il 22/09/2013 15:37, Michael S. Tsirkin ha scritto:
Quoted 7 lines
Detect presence of IASL compiler and use it to process ASL source. If not there, use pre-compiled files in-tree. Add script to update the in-tree files.
Note: distros are known to silently update iasl
so detect correct iasl flags for the installed version on each run as opposed to at configure time.This is not any different from a C compiler, which is likely updated much much more often than iasl.
Yes but it's not a theoretical issue:
we did catch iasl changing flags semantics on the fly, once.
I think compilers don't do this as a norm :)
Quoted 4 lines
However, I don't feel strongly at all
about this.Paolo
Re: [Qemu-devel] [PATCH v4 12/23] acpi: add rules to compile ASL source
Quoted 10 lines · Michael S. Tsirkin
Quoted 9 lines · Paolo Bonzini
Il 22/09/2013 15:37, Michael S. Tsirkin ha scritto:
Quoted 7 lines
Detect presence of IASL compiler and use it to process ASL source. If not there, use pre-compiled files in-tree. Add script to update the in-tree files.
Note: distros are known to silently update iasl
so detect correct iasl flags for the installed version on each run as opposed to at configure time.
Quoted 7 lines
Quoted 2 lines
This is not any different from a C compiler, which is likely updated much much more often than iasl.
Yes but it's not a theoretical issue:
we did catch iasl changing flags semantics on the fly, once.I think compilers don't do this as a norm :)
(Fully tangentially... gcc and clang emit warnings for a new set of code constructs every other week. When combined with -Werror, it's super annoying; valid and intentional code can stop to build unexpectedly. Good thing we have --disable-werror for this.)
Laszlo
PATCH v4 13/23 acpi: pre-compiled ASL files
In reply to Michael S. TsirkinAdd pre-compiled ASL files. Useful for systems that do not have IASL.
--- hw/i386/acpi-dsdt.hex.generated | 4409 +++++++++++++++++++++ hw/i386/q35-acpi-dsdt.hex.generated | 7346 +++++++++++++++++++++++++++++++++++ hw/i386/ssdt-misc.hex.generated | 190 + hw/i386/ssdt-pcihp.hex.generated | 108 + hw/i386/ssdt-proc.hex.generated | 134 + 5 files changed, 12187 insertions(+) create mode 100644 hw/i386/acpi-dsdt.hex.generated create mode 100644 hw/i386/q35-acpi-dsdt.hex.generated create mode 100644 hw/i386/ssdt-misc.hex.generated create mode 100644 hw/i386/ssdt-pcihp.hex.generated create mode 100644 hw/i386/ssdt-proc.hex.generated
hw/i386/acpi-dsdt.hex.generated new file +4409 -0
@@ -0,0 +1,4409 @@ +static unsigned char AcpiDsdtAmlCode[] = { +0x44, +0x53, +0x44, +0x54, +0x37, +0x11, +0x0, +0x0, +0x1, +0xe1, +0x42, +0x58, +0x50, +0x43, +0x0, +0x0, +0x42, +0x58, +0x44, +0x53, +0x44, +0x54, +0x0, +0x0, +0x1, +0x0, +0x0, +0x0, +0x49, +0x4e, +0x54, +0x4c, +0x28, +0x5, +0x10, +0x20, +0x10, +0x49, +0x4, +0x5c, +0x0, +0x5b, +0x80, +0x44, +0x42, +0x47, +0x5f, +0x1, +0xb, +0x2, +0x4, +0x1, +0x5b, +0x81, +0xb, +0x44, +0x42, +0x47, +0x5f, +0x1, +0x44, +0x42, +0x47, +0x42, +0x8, +0x14, +0x2c, +0x44, +0x42, +0x55, +0x47, +0x1, +0x98, +0x68, +0x60, +0x96, +0x60, +0x60, +0x74, +0x87, +0x60, +0x1, +0x61, +0x70, +0x0, +0x62, +0xa2, +0x10, +0x95, +0x62, +0x61, +0x70, +0x83, +0x88, +0x60, +0x62, +0x0, +0x44, +0x42, +0x47, +0x42, +0x75, +0x62, +0x70, +0xa, +0xa, +0x44, +0x42, +0x47, +0x42, +0x10, +0x22, +0x5f, +0x53, +0x42, +0x5f, +0x5b, +0x82, +0x1b, +0x50, +0x43, +0x49, +0x30, +0x8, +0x5f, +0x48, +0x49, +0x44, +0xc, +0x41, +0xd0, +0xa, +0x3, +0x8, +0x5f, +0x41, +0x44, +0x52, +0x0, +0x8, +0x5f, +0x55, +0x49, +0x44, +0x1, +0x10, +0x4e, +0x15, +0x2e, +0x5f, +0x53, +0x42, +0x5f, +0x50, +0x43, +0x49, +0x30, +0x8, +0x43, +0x52, +0x45, +0x53, +0x11, +0x42, +0x7, +0xa, +0x6e, +0x88, +0xd, +0x0, +0x2, +0xc, +0x0, +0x0, +0x0, +0x0, +0x0, +0xff, +0x0, +0x0, +0x0, +0x0, +0x1, +0x47, +0x1, +0xf8, +0xc, +0xf8, +0xc, +0x1, +0x8, +0x88, +0xd, +0x0, +0x1, +0xc, +0x3, +0x0, +0x0, +0x0, +0x0, +0xf7, +0xc, +0x0, +0x0, +0xf8, +0xc, +0x88, +0xd, +0x0, +0x1, +0xc, +0x3, +0x0, +0x0, +0x0, +0xd, +0xff, +0xff, +0x0, +0x0, +0x0, +0xf3, +0x87, +0x17, +0x0, +0x0, +0xc, +0x3, +0x0, +0x0, +0x0, +0x0, +0x0, +0x0, +0xa, +0x0, +0xff, +0xff, +0xb, +0x0, +0x0, +0x0, +0x0, +0x0, +0x0, +0x0, +0x2, +0x0, +0x87, +0x17, +0x0, +0x0, +0xc, +0x1, +0x0, +0x0, +0x0, +0x0, +0x0, +0x0, +0x0, +0xe0, +0xff, +0xff, +0xbf, +0xfe, +0x0, +0x0, +0x0, +0x0, +0x0, +0x0, +0xc0, +0x1e, +0x79, +0x0, +0x8, +0x43, +0x52, +0x36, +0x34, +0x11, +0x33, +0xa, +0x30, +0x8a, +0x2b, +0x0, +0x0, +0xc, +0x3, +0x0, +0x0, +0x0, +0x0, +0x0, +0x0, +0x0, +0x0, +0x0, +0x0, +0x0, +0x0, +0x80, +0x0, +0x0, +0x0, +0xff, +0xff, +0xff, +0xff, +0xff, +0x0, +0x0, +0x0, +0x0, +0x0, +0x0, +0x0, +0x0, +0x0, +0x0, +0x0, +0x0, +0x0, +0x0, +0x0, +0x80, +0x0, +0x0, +0x0, +0x79, +0x0, +0x14, +0x41, +0xa, +0x5f, +0x43, +0x52, +0x53, +0x0, +0x8a, +0x43, +0x52, +0x45, +0x53, +0xa, +0x5c, +0x50, +0x53, +0x33, +0x32, +0x8a, +0x43, +0x52, +0x45, +0x53, +0xa, +0x60, +0x50, +0x45, +0x33, +0x32, +0x8a, +0x43, +0x52, +0x45, +0x53, +0xa, +0x68, +0x50, +0x4c, +0x33, +0x32, +0x70, +0x50, +0x30, +0x53, +0x5f, +0x50, +0x53, +0x33, +0x32, +0x70, +0x50, +0x30, +0x45, +0x5f, +0x50, +0x45, +0x33, +0x32, +0x70, +0x72, +0x74, +0x50, +0x30, +0x45, +0x5f, +0x50, +0x30, +0x53, +0x5f, +0x0, +0x1, +0x0, +0x50, +0x4c, +0x33, +0x32, +0xa0, +0xc, +0x93, +0x50, +0x31, +0x56, +0x5f, +0x0, +0xa4, +0x43, +0x52, +0x45, +0x53, +0x8f, +0x43, +0x52, +0x36, +0x34, +0xa, +0xe, +0x50, +0x53, +0x36, +0x34, +0x8f, +0x43, +0x52, +0x36, +0x34, +0xa, +0x16, +0x50, +0x45, +0x36, +0x34, +0x8f, +0x43, +0x52, +0x36, +0x34, +0xa, +0x26, +0x50, +0x4c, +0x36, +0x34, +0x70, +0x50, +0x31, +0x53, +0x5f, +0x50, +0x53, +0x36, +0x34, +0x70, +0x50, +0x31, +0x45, +0x5f, +0x50, +0x45, +0x36, +0x34, +0x70, +0x50, +0x31, +0x4c, +0x5f, +0x50, +0x4c, +0x36, +0x34, +0x84, +0x43, +0x52, +0x45, +0x53, +0x43, +0x52, +0x36, +0x34, +0x60, +0xa4, +0x60, +0x10, +0x4d, +0x8, +0x5f, +0x53, +0x42, +0x5f, +0x5b, +0x82, +0x45, +0x8, +0x48, +0x50, +0x45, +0x54, +0x8, +0x5f, +0x48, +0x49, +0x44, +0xc, +0x41, +0xd0, +0x1, +0x3, +0x8, +0x5f, +0x55, +0x49, +0x44, +0x0, +0x5b, +0x80, +0x48, +0x50, +0x54, +0x4d, +0x0, +0xc, +0x0, +0x0, +0xd0, +0xfe, +0xb, +0x0, +0x4, +0x5b, +0x81, +0x10, +0x48, +0x50, +0x54, +0x4d, +0x13, +0x56, +0x45, +0x4e, +0x44, +0x20, +0x50, +0x52, +0x44, +0x5f, +0x20, +0x14, +0x36, +0x5f, +0x53, +0x54, +0x41, +0x0, +0x70, +0x56, +0x45, +0x4e, +0x44, +0x60, +0x70, +0x50, +0x52, +0x44, +0x5f, +0x61, +0x7a, +0x60, +0xa, +0x10, +0x60, +0xa0, +0xc, +0x91, +0x93, +0x60, +0x0, +0x93, +0x60, +0xb, +0xff, +0xff, +0xa4, +0x0, +0xa0, +0xe, +0x91, +0x93, +0x61, +0x0, +0x94, +0x61, +0xc, +0x0, +0xe1, +0xf5, +0x5, +0xa4, +0x0, +0xa4, +0xa, +0xf, +0x8, +0x5f, +0x43, +0x52, +0x53, +0x11, +0x11, +0xa, +0xe, +0x86, +0x9, +0x0, +0x0, +0x0, +0x0, +0xd0, +0xfe, +0x0, +0x4, +0x0, +0x0, +0x79, +0x0, +0x10, +0x40, +0x6, +0x2e, +0x5f, +0x53, +0x42, +0x5f, +0x50, +0x43, +0x49, +0x30, +0x5b, +0x82, +0x43, +0x5, +0x56, +0x47, +0x41, +0x5f, +0x8, +0x5f, +0x41, +0x44, +0x52, +0xc, +0x0, +0x0, +0x2, +0x0, +0x5b, +0x80, +0x50, +0x43, +0x49, +0x43, +0x2, +0x0, +0xa, +0x4, +0x5b, +0x81, +0xb, +0x50, +0x43, +0x49, +0x43, +0x3, +0x56, +0x45, +0x4e, +0x44, +0x20, +0x14, +0x8, +0x5f, +0x53, +0x31, +0x44, +0x0, +0xa4, +0x0, +0x14, +0x8, +0x5f, +0x53, +0x32, +0x44, +0x0, +0xa4, +0x0, +0x14, +0x19, +0x5f, +0x53, +0x33, +0x44, +0x0, +0xa0, +0xe, +0x93, +0x56, +0x45, +0x4e, +0x44, +0xc, +0x36, +0x1b, +0x0, +0x1, +0xa4, +0xa, +0x3, +0xa1, +0x3, +0xa4, +0x0, +0x10, +0x25, +0x2e, +0x5f, +0x53, +0x42, +0x5f, +0x50, +0x43, +0x49, +0x30, +0x5b, +0x82, +0x19, +0x50, +0x58, +0x31, +0x33, +0x8, +0x5f, +0x41, +0x44, +0x52, +0xc, +0x3, +0x0, +0x1, +0x0, +0x5b, +0x80, +0x50, +0x31, +0x33, +0x43, +0x2, +0x0, +0xa, +0xff, +0x10, +0x46, +0x5, +0x2e, +0x5f, +0x53, +0x42, +0x5f, +0x50, +0x43, +0x49, +0x30, +0x5b, +0x82, +0x49, +0x4, +0x49, +0x53, +0x41, +0x5f, +0x8, +0x5f, +0x41, +0x44, +0x52, +0xc, +0x0, +0x0, +0x1, +0x0, +0x5b, +0x80, +0x50, +0x34, +0x30, +0x43, +0x2, +0xa, +0x60, +0xa, +0x4, +0x5b, +0x81, +0x26, +0x5e, +0x2e, +0x50, +0x58, +0x31, +0x33, +0x50, +0x31, +0x33, +0x43, +0x0, +0x0, +0x48, +0x2f, +0x0, +0x7, +0x4c, +0x50, +0x45, +0x4e, +0x1, +0x0, +0x38, +0x0, +0x3, +0x43, +0x41, +0x45, +0x4e, +0x1, +0x0, +0x3, +0x43, +0x42, +0x45, +0x4e, +0x1, +0x8, +0x46, +0x44, +0x45, +0x4e, +0x1, +0x10, +0x4c, +0x1b, +0x2f, +0x3, +0x5f, +0x53, +0x42, +0x5f, +0x50, +0x43, +0x49, +0x30, +0x49, +0x53, +0x41, +0x5f, +0x5b, +0x82, +0x2d, +0x52, +0x54, +0x43, +0x5f, +0x8, +0x5f, +0x48, +0x49, +0x44, +0xc, +0x41, +0xd0, +0xb, +0x0, +0x8, +0x5f, +0x43, +0x52, +0x53, +0x11, +0x18, +0xa, +0x15, +0x47, +0x1, +0x70, +0x0, +0x70, +0x0, +0x10, +0x2, +0x22, +0x0, +0x1, +0x47, +0x1, +0x72, +0x0, +0x72, +0x0, +0x2, +0x6, +0x79, +0x0, +0x5b, +0x82, +0x37, +0x4b, +0x42, +0x44, +0x5f, +0x8, +0x5f, +0x48, +0x49, +0x44, +0xc, +0x41, +0xd0, +0x3, +0x3, +0x14, +0x9, +0x5f, +0x53, +0x54, +0x41, +0x0, +0xa4, +0xa, +0xf, +0x8, +0x5f, +0x43, +0x52, +0x53, +0x11, +0x18, +0xa, +0x15, +0x47, +0x1, +0x60, +0x0, +0x60, +0x0, +0x1, +0x1, +0x47, +0x1, +0x64, +0x0, +0x64, +0x0, +0x1, +0x1, +0x22, +0x2, +0x0, +0x79, +0x0, +0x5b, +0x82, +0x27, +0x4d, +0x4f, +0x55, +0x5f, +0x8, +0x5f, +0x48, +0x49, +0x44, +0xc, +0x41, +0xd0, +0xf, +0x13, +0x14, +0x9, +0x5f, +0x53, +0x54, +0x41, +0x0, +0xa4, +0xa, +0xf, +0x8, +0x5f, +0x43, +0x52, +0x53, +0x11, +0x8, +0xa, +0x5, +0x22, +0x0, +0x10, +0x79, +0x0, +0x5b, +0x82, +0x4a, +0x4, +0x46, +0x44, +0x43, +0x30, +0x8, +0x5f, +0x48, +0x49, +0x44, +0xc, +0x41, +0xd0, +0x7, +0x0, +0x14, +0x18, +0x5f, +0x53, +0x54, +0x41, +0x0, +0x70, +0x46, +0x44, +0x45, +0x4e, +0x60, +0xa0, +0x6, +0x93, +0x60, +0x0, +0xa4, +0x0, +0xa1, +0x4, +0xa4, +0xa, +0xf, +0x8, +0x5f, +0x43, +0x52, +0x53, +0x11, +0x1b, +0xa, +0x18, +0x47, +0x1, +0xf2, +0x3, +0xf2, +0x3, +0x0, +0x4, +0x47, +0x1, +0xf7, +0x3, +0xf7, +0x3, +0x0, +0x1, +0x22, +0x40, +0x0, +0x2a, +0x4, +0x0, +0x79, +0x0, +0x5b, +0x82, +0x3e, +0x4c, +0x50, +0x54, +0x5f, +0x8, +0x5f, +0x48, +0x49, +0x44, +0xc, +0x41, +0xd0, +0x4, +0x0, +0x14, +0x18, +0x5f, +0x53, +0x54, +0x41, +0x0, +0x70, +0x4c, +0x50, +0x45, +0x4e, +0x60, +0xa0, +0x6, +0x93, +0x60, +0x0, +0xa4, +0x0, +0xa1, +0x4, +0xa4, +0xa, +0xf, +0x8, +0x5f, +0x43, +0x52, +0x53, +0x11, +0x10, +0xa, +0xd, +0x47, +0x1, +0x78, +0x3, +0x78, +0x3, +0x8, +0x8, +0x22, +0x80, +0x0, +0x79, +0x0, +0x5b, +0x82, +0x45, +0x4, +0x43, +0x4f, +0x4d, +0x31, +0x8, +0x5f, +0x48, +0x49, +0x44, +0xc, +0x41, +0xd0, +0x5, +0x1, +0x8, +0x5f, +0x55, +0x49, +0x44, +0x1, +0x14, +0x18, +0x5f, +0x53, +0x54, +0x41, +0x0, +0x70, +0x43, +0x41, +0x45, +0x4e, +0x60, +0xa0, +0x6, +0x93, +0x60, +0x0, +0xa4, +0x0, +0xa1, +0x4, +0xa4, +0xa, +0xf, +0x8, +0x5f, +0x43, +0x52, +0x53, +0x11, +0x10, +0xa, +0xd, +0x47, +0x1, +0xf8, +0x3, +0xf8, +0x3, +0x0, +0x8, +0x22, +0x10, +0x0, +0x79, +0x0, +0x5b, +0x82, +0x46, +0x4, +0x43, +0x4f, +0x4d, +0x32, +0x8, +0x5f, +0x48, +0x49, +0x44, +0xc, +0x41, +0xd0, +0x5, +0x1, +0x8, +0x5f, +0x55, +0x49, +0x44, +0xa, +0x2, +0x14, +0x18, +0x5f, +0x53, +0x54, +0x41, +0x0, +0x70, +0x43, +0x42, +0x45, +0x4e, +0x60, +0xa0, +0x6, +0x93, +0x60, +0x0, +0xa4, +0x0, +0xa1, +0x4, +0xa4, +0xa, +0xf, +0x8, +0x5f, +0x43, +0x52, +0x53, +0x11, +0x10, +0xa, +0xd, +0x47, +0x1, +0xf8, +0x2, +0xf8, +0x2, +0x0, +0x8, +0x22, +0x8, +0x0, +0x79, +0x0, +0x10, +0x4b, +0x8, +0x2e, +0x5f, +0x53, +0x42, +0x5f, +0x50, +0x43, +0x49, +0x30, +0x5b, +0x80, +0x50, +0x43, +0x53, +0x54, +0x1, +0xb, +0x0, +0xae, +0xa, +0x8, +0x5b, +0x81, +0x10, +0x50, +0x43, +0x53, +0x54, +0x43, +0x50, +0x43, +0x49, +0x55, +0x20, +0x50, +0x43, +0x49, +0x44, +0x20, +0x5b, +0x80, +0x53, +0x45, +0x4a, +0x5f, +0x1, +0xb, +0x8, +0xae, +0xa, +0x4, +0x5b, +0x81, +0xb, +0x53, +0x45, +0x4a, +0x5f, +0x43, +0x42, +0x30, +0x45, +0x4a, +0x20, +0x14, +0x11, +0x50, +0x43, +0x45, +0x4a, +0x1, +0x70, +0x79, +0x1, +0x68, +0x0, +0x42, +0x30, +0x45, +0x4a, +0xa4, +0x0, +0x14, +0x36, +0x50, +0x43, +0x4e, +0x46, +0x0, +0x70, +0x0, +0x60, +0xa2, +0x2c, +0x95, +0x60, +0xa, +0x1f, +0x75, +0x60, +0xa0, +0x11, +0x7b, +0x50, +0x43, +0x49, +0x55, +0x79, +0x1, +0x60, +0x0, +0x0, +0x50, +0x43, +0x4e, +0x54, +0x60, +0x1, +0xa0, +0x12, +0x7b, +0x50, +0x43, +0x49, +0x44, +0x79, +0x1, +0x60, +0x0, +0x0, +0x50, +0x43, +0x4e, +0x54, +0x60, +0xa, +0x3, +0x10, +0x4a, +0xa0, +0x5f, +0x53, +0x42, +0x5f, +0x10, +0x47, +0x74, +0x50, +0x43, +0x49, +0x30, +0x8, +0x5f, +0x50, +0x52, +0x54, +0x12, +0x4b, +0x73, +0x80, +0x12, +0xb, +0x4, +0xb, +0xff, +0xff, +0x0, +0x4c, +0x4e, +0x4b, +0x44, +0x0, +0x12, +0xb, +0x4, +0xb, +0xff, +0xff, +0x1, +0x4c, +0x4e, +0x4b, +0x41, +0x0, +0x12, +0xc, +0x4, +0xb, +0xff, +0xff, +0xa, +0x2, +0x4c, +0x4e, +0x4b, +0x42, +0x0, +0x12, +0xc, +0x4, +0xb, +0xff, +0xff, +0xa, +0x3, +0x4c, +0x4e, +0x4b, +0x43, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x1, +0x0, +0x0, +0x4c, +0x4e, +0x4b, +0x53, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x1, +0x0, +0x1, +0x4c, +0x4e, +0x4b, +0x42, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x1, +0x0, +0xa, +0x2, +0x4c, +0x4e, +0x4b, +0x43, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x1, +0x0, +0xa, +0x3, +0x4c, +0x4e, +0x4b, +0x44, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x2, +0x0, +0x0, +0x4c, +0x4e, +0x4b, +0x42, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x2, +0x0, +0x1, +0x4c, +0x4e, +0x4b, +0x43, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x2, +0x0, +0xa, +0x2, +0x4c, +0x4e, +0x4b, +0x44, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x2, +0x0, +0xa, +0x3, +0x4c, +0x4e, +0x4b, +0x41, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x3, +0x0, +0x0, +0x4c, +0x4e, +0x4b, +0x43, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x3, +0x0, +0x1, +0x4c, +0x4e, +0x4b, +0x44, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x3, +0x0, +0xa, +0x2, +0x4c, +0x4e, +0x4b, +0x41, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x3, +0x0, +0xa, +0x3, +0x4c, +0x4e, +0x4b, +0x42, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x4, +0x0, +0x0, +0x4c, +0x4e, +0x4b, +0x44, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x4, +0x0, +0x1, +0x4c, +0x4e, +0x4b, +0x41, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x4, +0x0, +0xa, +0x2, +0x4c, +0x4e, +0x4b, +0x42, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x4, +0x0, +0xa, +0x3, +0x4c, +0x4e, +0x4b, +0x43, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x5, +0x0, +0x0, +0x4c, +0x4e, +0x4b, +0x41, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x5, +0x0, +0x1, +0x4c, +0x4e, +0x4b, +0x42, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x5, +0x0, +0xa, +0x2, +0x4c, +0x4e, +0x4b, +0x43, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x5, +0x0, +0xa, +0x3, +0x4c, +0x4e, +0x4b, +0x44, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x6, +0x0, +0x0, +0x4c, +0x4e, +0x4b, +0x42, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x6, +0x0, +0x1, +0x4c, +0x4e, +0x4b, +0x43, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x6, +0x0, +0xa, +0x2, +0x4c, +0x4e, +0x4b, +0x44, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x6, +0x0, +0xa, +0x3, +0x4c, +0x4e, +0x4b, +0x41, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x7, +0x0, +0x0, +0x4c, +0x4e, +0x4b, +0x43, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x7, +0x0, +0x1, +0x4c, +0x4e, +0x4b, +0x44, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x7, +0x0, +0xa, +0x2, +0x4c, +0x4e, +0x4b, +0x41, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x7, +0x0, +0xa, +0x3, +0x4c, +0x4e, +0x4b, +0x42, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x8, +0x0, +0x0, +0x4c, +0x4e, +0x4b, +0x44, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x8, +0x0, +0x1, +0x4c, +0x4e, +0x4b, +0x41, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x8, +0x0, +0xa, +0x2, +0x4c, +0x4e, +0x4b, +0x42, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x8, +0x0, +0xa, +0x3, +0x4c, +0x4e, +0x4b, +0x43, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x9, +0x0, +0x0, +0x4c, +0x4e, +0x4b, +0x41, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x9, +0x0, +0x1, +0x4c, +0x4e, +0x4b, +0x42, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x9, +0x0, +0xa, +0x2, +0x4c, +0x4e, +0x4b, +0x43, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x9, +0x0, +0xa, +0x3, +0x4c, +0x4e, +0x4b, +0x44, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0xa, +0x0, +0x0, +0x4c, +0x4e, +0x4b, +0x42, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0xa, +0x0, +0x1, +0x4c, +0x4e, +0x4b, +0x43, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0xa, +0x0, +0xa, +0x2, +0x4c, +0x4e, +0x4b, +0x44, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0xa, +0x0, +0xa, +0x3, +0x4c, +0x4e, +0x4b, +0x41, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0xb, +0x0, +0x0, +0x4c, +0x4e, +0x4b, +0x43, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0xb, +0x0, +0x1, +0x4c, +0x4e, +0x4b, +0x44, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0xb, +0x0, +0xa, +0x2, +0x4c, +0x4e, +0x4b, +0x41, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0xb, +0x0, +0xa, +0x3, +0x4c, +0x4e, +0x4b, +0x42, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0xc, +0x0, +0x0, +0x4c, +0x4e, +0x4b, +0x44, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0xc, +0x0, +0x1, +0x4c, +0x4e, +0x4b, +0x41, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0xc, +0x0, +0xa, +0x2, +0x4c, +0x4e, +0x4b, +0x42, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0xc, +0x0, +0xa, +0x3, +0x4c, +0x4e, +0x4b, +0x43, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0xd, +0x0, +0x0, +0x4c, +0x4e, +0x4b, +0x41, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0xd, +0x0, +0x1, +0x4c, +0x4e, +0x4b, +0x42, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0xd, +0x0, +0xa, +0x2, +0x4c, +0x4e, +0x4b, +0x43, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0xd, +0x0, +0xa, +0x3, +0x4c, +0x4e, +0x4b, +0x44, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0xe, +0x0, +0x0, +0x4c, +0x4e, +0x4b, +0x42, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0xe, +0x0, +0x1, +0x4c, +0x4e, +0x4b, +0x43, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0xe, +0x0, +0xa, +0x2, +0x4c, +0x4e, +0x4b, +0x44, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0xe, +0x0, +0xa, +0x3, +0x4c, +0x4e, +0x4b, +0x41, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0xf, +0x0, +0x0, +0x4c, +0x4e, +0x4b, +0x43, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0xf, +0x0, +0x1, +0x4c, +0x4e, +0x4b, +0x44, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0xf, +0x0, +0xa, +0x2, +0x4c, +0x4e, +0x4b, +0x41, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0xf, +0x0, +0xa, +0x3, +0x4c, +0x4e, +0x4b, +0x42, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x10, +0x0, +0x0, +0x4c, +0x4e, +0x4b, +0x44, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x10, +0x0, +0x1, +0x4c, +0x4e, +0x4b, +0x41, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x10, +0x0, +0xa, +0x2, +0x4c, +0x4e, +0x4b, +0x42, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x10, +0x0, +0xa, +0x3, +0x4c, +0x4e, +0x4b, +0x43, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x11, +0x0, +0x0, +0x4c, +0x4e, +0x4b, +0x41, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x11, +0x0, +0x1, +0x4c, +0x4e, +0x4b, +0x42, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x11, +0x0, +0xa, +0x2, +0x4c, +0x4e, +0x4b, +0x43, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x11, +0x0, +0xa, +0x3, +0x4c, +0x4e, +0x4b, +0x44, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x12, +0x0, +0x0, +0x4c, +0x4e, +0x4b, +0x42, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x12, +0x0, +0x1, +0x4c, +0x4e, +0x4b, +0x43, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x12, +0x0, +0xa, +0x2, +0x4c, +0x4e, +0x4b, +0x44, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x12, +0x0, +0xa, +0x3, +0x4c, +0x4e, +0x4b, +0x41, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x13, +0x0, +0x0, +0x4c, +0x4e, +0x4b, +0x43, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x13, +0x0, +0x1, +0x4c, +0x4e, +0x4b, +0x44, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x13, +0x0, +0xa, +0x2, +0x4c, +0x4e, +0x4b, +0x41, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x13, +0x0, +0xa, +0x3, +0x4c, +0x4e, +0x4b, +0x42, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x14, +0x0, +0x0, +0x4c, +0x4e, +0x4b, +0x44, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x14, +0x0, +0x1, +0x4c, +0x4e, +0x4b, +0x41, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x14, +0x0, +0xa, +0x2, +0x4c, +0x4e, +0x4b, +0x42, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x14, +0x0, +0xa, +0x3, +0x4c, +0x4e, +0x4b, +0x43, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x15, +0x0, +0x0, +0x4c, +0x4e, +0x4b, +0x41, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x15, +0x0, +0x1, +0x4c, +0x4e, +0x4b, +0x42, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x15, +0x0, +0xa, +0x2, +0x4c, +0x4e, +0x4b, +0x43, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x15, +0x0, +0xa, +0x3, +0x4c, +0x4e, +0x4b, +0x44, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x16, +0x0, +0x0, +0x4c, +0x4e, +0x4b, +0x42, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x16, +0x0, +0x1, +0x4c, +0x4e, +0x4b, +0x43, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x16, +0x0, +0xa, +0x2, +0x4c, +0x4e, +0x4b, +0x44, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x16, +0x0, +0xa, +0x3, +0x4c, +0x4e, +0x4b, +0x41, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x17, +0x0, +0x0, +0x4c, +0x4e, +0x4b, +0x43, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x17, +0x0, +0x1, +0x4c, +0x4e, +0x4b, +0x44, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x17, +0x0, +0xa, +0x2, +0x4c, +0x4e, +0x4b, +0x41, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x17, +0x0, +0xa, +0x3, +0x4c, +0x4e, +0x4b, +0x42, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x18, +0x0, +0x0, +0x4c, +0x4e, +0x4b, +0x44, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x18, +0x0, +0x1, +0x4c, +0x4e, +0x4b, +0x41, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x18, +0x0, +0xa, +0x2, +0x4c, +0x4e, +0x4b, +0x42, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x18, +0x0, +0xa, +0x3, +0x4c, +0x4e, +0x4b, +0x43, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x19, +0x0, +0x0, +0x4c, +0x4e, +0x4b, +0x41, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x19, +0x0, +0x1, +0x4c, +0x4e, +0x4b, +0x42, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x19, +0x0, +0xa, +0x2, +0x4c, +0x4e, +0x4b, +0x43, +0x0, +0x12, +0xe, +0x4, +0xc, +0xff, +0xff, +0x19, +0x0, +0xa, +0x3, +0x4c, +0x4e, +0x4b, +0x44, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x1a, +0x0, +0x0, +0x4c, +0x4e, +0x4b, +0x42, +0x0, +0x12, +0xd, +0x4, +0xc, +0xff, +0xff, +0x1a, +0x0, +0x1, +0x4c, +0x4e, +0x4b, +0x43, +0x0, +0x12, +0xe, +0x4,
Lines of this file are not shown. View the raw message.
hw/i386/q35-acpi-dsdt.hex.generated new file +7346 -0
7,346 lines not on this page · raw message
hw/i386/ssdt-misc.hex.generated new file +190 -0
190 lines not on this page · raw message
hw/i386/ssdt-pcihp.hex.generated new file +108 -0
108 lines not on this page · raw message
hw/i386/ssdt-proc.hex.generated new file +134 -0
134 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
MST
Part of the diff is not shown here. View the raw message.
PATCH v4 14/23 loader: use file path size from fw_cfg.h
In reply to Michael S. TsirkinAvoid a bit of code duplication, make
max file path constant reusable.
--- include/hw/nvram/fw_cfg.h | 4 +++- hw/core/loader.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)
include/hw/nvram/fw_cfg.h +3 -1
@@ -46,12 +46,14 @@#define FW_CFG_INVALID 0xffff +#define FW_CFG_MAX_FILE_PATH 56 + #ifndef NO_QEMU_PROTOS typedef struct FWCfgFile { uint32_t size; /* file size */ uint16_t select; /* write this to 0x510 to read it */ uint16_t reserved; - char name[56]; + char name[FW_CFG_MAX_FILE_PATH]; } FWCfgFile; typedef struct FWCfgFiles {
hw/core/loader.c +1 -1
@@ -663,7 +663,7 @@ int rom_add_file(const char *file, const char *fw_dir,rom_insert (rom);if (rom->fw_file && fw_cfg) {const char *basename; -char fw_file_name[56 ]; +char fw_file_name[FW_CFG_MAX_FILE_PATH ];void *data; basename =strrchr (rom->fw_file,'/' );
Signature · 1 line
MST
PATCH v4 15/23 i386: add bios linker/loader
In reply to Michael S. TsirkinThis adds a dynamic bios linker/loader.
This will be used by acpi table generation code to:
- load each table in the appropriate memory segment
- link tables to each other
- fix up checksums after said linking
--- include/hw/i386/bios-linker-loader.h | 26 ++++++ hw/i386/bios-linker-loader.c | 156 +++++++++++++++++++++++++++++++++++ hw/i386/Makefile.objs | 1 + 3 files changed, 183 insertions(+) create mode 100644 include/hw/i386/bios-linker-loader.h create mode 100644 hw/i386/bios-linker-loader.c
include/hw/i386/bios-linker-loader.h new file +26 -0
@@ -0,0 +1,26 @@ +#ifndef BIOS_LINKER_LOADER_H +#define BIOS_LINKER_LOADER_H + +#include <glib.h> +#include <stdbool.h> +#include <inttypes.h> + +GArray *bios_linker_init (void ); + +void bios_linker_alloc (GArray *linker, +const char *file, +uint32_t alloc_align, +bool alloc_fseg); + +void bios_linker_add_checksum (GArray *linker,const char *file,void *table, +void *start,unsigned size,uint8_t *checksum); + + +void bios_linker_add_pointer (GArray *linker, +const char *dest_file, +const char *src_file, +GArray *table,void *pointer, +uint8_t pointer_size); + +void *bios_linker_cleanup (GArray *linker); +#endif
hw/i386/bios-linker-loader.c new file +156 -0
156 lines not on this page · raw message
hw/i386/Makefile.objs +1 -0
@@ -5,6 +5,7 @@ obj-y += pc_sysfw.o obj-$(CONFIG_XEN) += xen_domainbuild.o xen_machine_pv.o obj-y += kvmvapic.o +obj-y += bios-linker-loader.o iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \ ; then echo "$(2)"; else echo "$(3)"; fi ;)
Signature · 1 line
MST
Re: [Qemu-devel] [PATCH v4 15/23] i386: add bios linker/loader
Il 22/09/2013 15:37, Michael S. Tsirkin ha scritto:
Quoted 7 lines
This adds a dynamic bios linker/loader.
This will be used by acpi table generation code to:
- load each table in the appropriate memory segment
- link tables to each other
- fix up checksums after said linking
Quoted 5 lines
Signed-off-by Michael S. Tsirkin <[email protected]>--- include/hw/i386/bios-linker-loader.h | 26 ++++++ hw/i386/bios-linker-loader.c | 156 +++++++++++++++++++++++++++++++++++ hw/i386/Makefile.objs | 1 +
Just a naming question...
If this is ACPI-specific (or if there are no other uses in sight), it should go in include/hw/acpi and hw/acpi, and renamed with s/bios/acpi/ etc.
If this is i386-specific, it should go entirely in hw/i386 and the headers should be included as "bios-linker-loader.h".
Also, the API is (understandably) bios_linker_*, not bios_linker_loader_*, with the exception of BiosLinkerLoaderEntry, BIOS_LINKER_LOADER_FILESZ and perhaps a few others I've missed. I would just drop the loader part, and if you go for the BIOS -> ACPI rename, make the filenames include/hw/acpi/linker.h and hw/acpi/linker.c.
Just post v5 of this patch in any case, I don't need to see the matching changes in patch 23.
Paolo
Quoted 77 lines
3 files changed, 183 insertions(+) create mode 100644 include/hw/i386/bios-linker-loader.h create mode 100644 hw/i386/bios-linker-loader.cinclude/hw/i386/bios-linker-loader.h new file +26
-0@@ -0,0 +1,26 @@ +#ifndef BIOS_LINKER_LOADER_H +#define BIOS_LINKER_LOADER_H + +#include <glib.h> +#include <stdbool.h> +#include <inttypes.h> + +GArray *bios_linker_init (void ); + +void bios_linker_alloc (GArray *linker, +const char *file, +uint32_t alloc_align, +bool alloc_fseg); + +void bios_linker_add_checksum (GArray *linker,const char *file,void *table, +void *start,unsigned size,uint8_t *checksum); + + +void bios_linker_add_pointer (GArray *linker, +const char *dest_file, +const char *src_file, +GArray *table,void *pointer, +uint8_t pointer_size); + +void *bios_linker_cleanup (GArray *linker); +#endif hw/i386/bios-linker-loader.c new file +35
-0@@ -0,0 +1,156 @@ +/* Dynamic linker/loader of ACPI tables +* +* Copyright (C) 2013 Red Hat Inc +* +* Author: Michael S. Tsirkin <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License along +* with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "hw/i386/bios-linker-loader.h" +#include "hw/nvram/fw_cfg.h" + +#include <string.h> +#include <assert.h> +#include "qemu/bswap.h" + +#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)
hw/i386/bios-linker-loader.c line 45
Quoted 10 lines
hw/i386/bios-linker-loader.c new file +10
-0+* 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 alloc_file[BIOS_LINKER_LOADER_FILESZ ]; +uint32_t alloc_align; +uint8_t alloc_zone; + };
I would prefer to have named structs, like
struct {
char file[BIOS_LINKER_LOADER_FILESZ];
uint32_t align;
uint8_t zone;
} alloc;Also perhaps add QEMU_PACKED here too, just in case someone makes typedefs out of the structs and forgets it.
Quoted 54 lines
hw/i386/bios-linker-loader.c new file +54
-0+/* +* 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 pointer_dest_file[BIOS_LINKER_LOADER_FILESZ ]; +char pointer_src_file[BIOS_LINKER_LOADER_FILESZ ]; +uint32_t pointer_offset; +uint8_t pointer_size; + }; + +/* +* 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 cksum_file[BIOS_LINKER_LOADER_FILESZ ]; +uint32_t cksum_offset; +uint32_t cksum_start; +uint32_t cksum_length; + }; + +/* 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 , +}; + +GArray *bios_linker_init (void ) +{ +return g_array_new (false, true/* clear */ ,sizeof (BiosLinkerLoaderEntry)); +} + +/* Free linker wrapper and return the linker array. */ +void *bios_linker_cleanup (GArray *linker) +{ +return g_array_free (linker, false); +}
hw/i386/bios-linker-loader.c line 110
Quoted 10 lines
hw/i386/bios-linker-loader.c new file +10
-0+ +void bios_linker_alloc (GArray *linker, +const char *file, +uint32_t alloc_align, +bool alloc_fseg) +{ +BiosLinkerLoaderEntry entry; + +memset (&entry,0 ,sizeof entry); +strncpy (entry.alloc_file, file,sizeof entry.alloc_file -1 );
Please use pstrcpy (also below).
Quoted 59 lines
hw/i386/bios-linker-loader.c new file +46
-0+ entry.command =cpu_to_le32 (BIOS_LINKER_LOADER_COMMAND_ALLOCATE ); + entry.alloc_align =cpu_to_le32 (alloc_align); + entry.alloc_zone =cpu_to_le32 (alloc_fseg ? +BIOS_LINKER_LOADER_ALLOC_ZONE_FSEG : +BIOS_LINKER_LOADER_ALLOC_ZONE_HIGH ); + +/* Alloc entries must come first, so prepend them */ +g_array_prepend_val (linker, entry); +} + +void bios_linker_add_checksum (GArray *linker,const char *file,void *table, +void *start,unsigned size,uint8_t *checksum) +{ +BiosLinkerLoaderEntry entry; + +memset (&entry,0 ,sizeof entry); +strncpy (entry.cksum_file, file,sizeof entry.cksum_file -1 ); + entry.command =cpu_to_le32 (BIOS_LINKER_LOADER_COMMAND_ADD_CHECKSUM ); + entry.cksum_offset =cpu_to_le32 (checksum - (uint8_t *)table); + entry.cksum_start =cpu_to_le32 ((uint8_t *)start - (uint8_t *)table); + entry.cksum_length =cpu_to_le32 (size); + +g_array_append_val (linker, entry); +} + +void bios_linker_add_pointer (GArray *linker, +const char *dest_file, +const char *src_file, +GArray *table,void *pointer, +uint8_t pointer_size) +{ +BiosLinkerLoaderEntry entry; + +memset (&entry,0 ,sizeof entry); +strncpy (entry.pointer_dest_file, dest_file, +sizeof entry.pointer_dest_file -1 ); +strncpy (entry.pointer_src_file, src_file, +sizeof entry.pointer_src_file -1 ); + entry.command =cpu_to_le32 (BIOS_LINKER_LOADER_COMMAND_ADD_POINTER ); + entry.pointer_offset =cpu_to_le32 ((gchar *)pointer - table->data); + entry.pointer_size = pointer_size; +assert (pointer_size ==1 || pointer_size ==2 || + pointer_size ==4 || pointer_size ==8 ); + +g_array_append_val (linker, entry); +}hw/i386/Makefile.objs +1
-0@@ -5,6 +5,7 @@ obj-y += pc_sysfw.o obj-$(CONFIG_XEN) += xen_domainbuild.o xen_machine_pv.o obj-y += kvmvapic.o +obj-y += bios-linker-loader.o iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \ ; then echo "$(2)"; else echo "$(3)"; fi ;)
Re: [Qemu-devel] [PATCH v4 15/23] i386: add bios linker/loader
Quoted 14 lines · Paolo Bonzini
Il 22/09/2013 15:37, Michael S. Tsirkin ha scritto:
Quoted 7 lines
This adds a dynamic bios linker/loader.
This will be used by acpi table generation code to:
- load each table in the appropriate memory segment
- link tables to each other
- fix up checksums after said linkingQuoted 5 lines
Signed-off-by Michael S. Tsirkin <[email protected]>--- include/hw/i386/bios-linker-loader.h | 26 ++++++ hw/i386/bios-linker-loader.c | 156 +++++++++++++++++++++++++++++++++++ hw/i386/Makefile.objs | 1 +
Quoted 7 lines
Just a naming question...
If this is ACPI-specific (or if there are no other uses in sight), it should go in
include/hw/acpiand hw/acpi, and renamed with s/bios/acpi/ etc.If this is i386-specific, it should go entirely in hw/i386 and the headers should be included as "
bios-linker-loader.h".
Definitely not ACPI specific.
It's only used on i386 so I put it all under i386. You think we should replace
#include "hw/i386/bios-linker-loader.h" with #include "bios-linker-loader.h"?
I don't really care, even though this makes headers hard to find. What's the benefit?
Quoted 10 lines
Also, the API is (understandably) bios_linker_*, not bios_linker_loader_*, with the exception of BiosLinkerLoaderEntry,
BIOS_LINKER_LOADER_FILESZand perhaps a few others I've missed. I would just drop the loader part, and if you go for the BIOS -> ACPI rename, make the filenamesinclude/hw/acpi/linker.handhw/acpi/linker.c.Just post v5 of this patch in any case, I don't need to see the matching changes in patch 23.
Paolo
It's not easy to find a good name for it.
For now I'll just make all names bios_linker_loader_ consistently. We can always rename it later, it's not set in stone.
Quoted 90 lines
Quoted 77 lines
3 files changed, 183 insertions(+) create mode 100644 include/hw/i386/bios-linker-loader.h create mode 100644 hw/i386/bios-linker-loader.cinclude/hw/i386/bios-linker-loader.h new file +26
-0@@ -0,0 +1,26 @@ +#ifndef BIOS_LINKER_LOADER_H +#define BIOS_LINKER_LOADER_H + +#include <glib.h> +#include <stdbool.h> +#include <inttypes.h> + +GArray *bios_linker_init (void ); + +void bios_linker_alloc (GArray *linker, +const char *file, +uint32_t alloc_align, +bool alloc_fseg); + +void bios_linker_add_checksum (GArray *linker,const char *file,void *table, +void *start,unsigned size,uint8_t *checksum); + + +void bios_linker_add_pointer (GArray *linker, +const char *dest_file, +const char *src_file, +GArray *table,void *pointer, +uint8_t pointer_size); + +void *bios_linker_cleanup (GArray *linker); +#endif hw/i386/bios-linker-loader.c new file +35
-0@@ -0,0 +1,156 @@ +/* Dynamic linker/loader of ACPI tables +* +* Copyright (C) 2013 Red Hat Inc +* +* Author: Michael S. Tsirkin <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License along +* with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "hw/i386/bios-linker-loader.h" +#include "hw/nvram/fw_cfg.h" + +#include <string.h> +#include <assert.h> +#include "qemu/bswap.h" + +#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) hw/i386/bios-linker-loader.c line 45
Quoted 10 lines
hw/i386/bios-linker-loader.c new file +10
-0+* 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 alloc_file[BIOS_LINKER_LOADER_FILESZ ]; +uint32_t alloc_align; +uint8_t alloc_zone; + };I would prefer to have named structs, like
Quoted 5 lines
struct {
char file[BIOS_LINKER_LOADER_FILESZ];
uint32_t align;
uint8_t zone;
} alloc;Why do you prefer this? It just makes code more verbose.
Quoted 2 lines
Also perhaps add
QEMU_PACKEDhere too, just in case someone makes typedefs out of the structs and forgets it.
I don't see why.
Even the QEMU_PACKED at the end is for documentation purposes only:
there's no real need for it in any of the structs here. So let's document it all in one place.
Quoted 58 lines
Quoted 58 lines
hw/i386/bios-linker-loader.c new file +58
-0+/* +* 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 pointer_dest_file[BIOS_LINKER_LOADER_FILESZ ]; +char pointer_src_file[BIOS_LINKER_LOADER_FILESZ ]; +uint32_t pointer_offset; +uint8_t pointer_size; + }; + +/* +* 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 cksum_file[BIOS_LINKER_LOADER_FILESZ ]; +uint32_t cksum_offset; +uint32_t cksum_start; +uint32_t cksum_length; + }; + +/* 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 , +}; + +GArray *bios_linker_init (void ) +{ +return g_array_new (false, true/* clear */ ,sizeof (BiosLinkerLoaderEntry)); +} + +/* Free linker wrapper and return the linker array. */ +void *bios_linker_cleanup (GArray *linker) +{ +return g_array_free (linker, false); +} + +void bios_linker_alloc(GArray *linker, + const char *file, + uint32_t alloc_align,
Quoted 8 lines
hw/i386/bios-linker-loader.c line 110
Quoted 6 lines
hw/i386/bios-linker-loader.c new file +6
-0+ bool alloc_fseg) +{ +BiosLinkerLoaderEntry entry; + +memset (&entry,0 ,sizeof entry); +strncpy (entry.alloc_file, file,sizeof entry.alloc_file -1 );Please use pstrcpy (also below).
OK.
Quoted 59 lines
Quoted 59 lines
hw/i386/bios-linker-loader.c new file +46
-0+ entry.command =cpu_to_le32 (BIOS_LINKER_LOADER_COMMAND_ALLOCATE ); + entry.alloc_align =cpu_to_le32 (alloc_align); + entry.alloc_zone =cpu_to_le32 (alloc_fseg ? +BIOS_LINKER_LOADER_ALLOC_ZONE_FSEG : +BIOS_LINKER_LOADER_ALLOC_ZONE_HIGH ); + +/* Alloc entries must come first, so prepend them */ +g_array_prepend_val (linker, entry); +} + +void bios_linker_add_checksum (GArray *linker,const char *file,void *table, +void *start,unsigned size,uint8_t *checksum) +{ +BiosLinkerLoaderEntry entry; + +memset (&entry,0 ,sizeof entry); +strncpy (entry.cksum_file, file,sizeof entry.cksum_file -1 ); + entry.command =cpu_to_le32 (BIOS_LINKER_LOADER_COMMAND_ADD_CHECKSUM ); + entry.cksum_offset =cpu_to_le32 (checksum - (uint8_t *)table); + entry.cksum_start =cpu_to_le32 ((uint8_t *)start - (uint8_t *)table); + entry.cksum_length =cpu_to_le32 (size); + +g_array_append_val (linker, entry); +} + +void bios_linker_add_pointer (GArray *linker, +const char *dest_file, +const char *src_file, +GArray *table,void *pointer, +uint8_t pointer_size) +{ +BiosLinkerLoaderEntry entry; + +memset (&entry,0 ,sizeof entry); +strncpy (entry.pointer_dest_file, dest_file, +sizeof entry.pointer_dest_file -1 ); +strncpy (entry.pointer_src_file, src_file, +sizeof entry.pointer_src_file -1 ); + entry.command =cpu_to_le32 (BIOS_LINKER_LOADER_COMMAND_ADD_POINTER ); + entry.pointer_offset =cpu_to_le32 ((gchar *)pointer - table->data); + entry.pointer_size = pointer_size; +assert (pointer_size ==1 || pointer_size ==2 || + pointer_size ==4 || pointer_size ==8 ); + +g_array_append_val (linker, entry); +}hw/i386/Makefile.objs +1
-0@@ -5,6 +5,7 @@ obj-y += pc_sysfw.o obj-$(CONFIG_XEN) += xen_domainbuild.o xen_machine_pv.o obj-y += kvmvapic.o +obj-y += bios-linker-loader.o iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \ ; then echo "$(2)"; else echo "$(3)"; fi ;)
Re: [Qemu-devel] [PATCH v4 15/23] i386: add bios linker/loader
Il 23/09/2013 15:36, Michael S. Tsirkin ha scritto:
Quoted 23 lines · Paolo Bonzini
Quoted 14 lines
Il 22/09/2013 15:37, Michael S. Tsirkin ha scritto:
Quoted 7 lines
This adds a dynamic bios linker/loader.
This will be used by acpi table generation code to:
- load each table in the appropriate memory segment
- link tables to each other
- fix up checksums after said linkingQuoted 5 lines
Signed-off-by Michael S. Tsirkin <[email protected]>--- include/hw/i386/bios-linker-loader.h | 26 ++++++ hw/i386/bios-linker-loader.c | 156 +++++++++++++++++++++++++++++++++++ hw/i386/Makefile.objs | 1 +Quoted 7 lines
Just a naming question...
If this is ACPI-specific (or if there are no other uses in sight), it should go in
include/hw/acpiand hw/acpi, and renamed with s/bios/acpi/ etc.If this is i386-specific, it should go entirely in hw/i386 and the headers should be included as "
bios-linker-loader.h".
Quoted 8 lines
Definitely not ACPI specific.
It's only used on i386 so I put it all under i386. You think we should replace
#include "hw/i386/bios-linker-loader.h" with #include "bios-linker-loader.h"?I don't really care, even though this makes headers hard to find. What's the benefit?
Private headers are outside include/, public headers within it. Same conventions as Linux. But if it's not ACPI-specific, I don't feel too strongly about it.
Quoted 3 lines
It's not easy to find a good name for it.
For now I'll just make all namesbios_linker_loader_consistently. We can always rename it later, it's not set in stone.
Ok.
Quoted 19 lines
Quoted 19 lines
Quoted 6 lines
hw/i386/bios-linker-loader.c new file +6
-0+struct BiosLinkerLoaderEntry { +uint32_t command; +union { +/* +* COMMAND_ALLOCATE - allocate a table from @alloc_file +* subject to @alloc_align alignment (must be power of 2) hw/i386/bios-linker-loader.c line 45
Quoted 10 lines
hw/i386/bios-linker-loader.c new file +10
-0+* 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 alloc_file[BIOS_LINKER_LOADER_FILESZ ]; +uint32_t alloc_align; +uint8_t alloc_zone; + };I would prefer to have named structs, like
Quoted 7 lines
Quoted 5 lines
struct { char file[BIOS_LINKER_LOADER_FILESZ]; uint32_t align; uint8_t zone; } alloc;Why do you prefer this? It just makes code more verbose.
It doesn't, the names were already prefixed with alloc_/pointer_/cksum_.
All it does is change underscores to periods.
Paolo
Quoted 128 lines
Quoted 58 lines
Quoted 58 lines
hw/i386/bios-linker-loader.c new file +58
-0+/* +* 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 pointer_dest_file[BIOS_LINKER_LOADER_FILESZ ]; +char pointer_src_file[BIOS_LINKER_LOADER_FILESZ ]; +uint32_t pointer_offset; +uint8_t pointer_size; + }; + +/* +* 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 cksum_file[BIOS_LINKER_LOADER_FILESZ ]; +uint32_t cksum_offset; +uint32_t cksum_start; +uint32_t cksum_length; + }; + +/* 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 , +}; + +GArray *bios_linker_init (void ) +{ +return g_array_new (false, true/* clear */ ,sizeof (BiosLinkerLoaderEntry)); +} + +/* Free linker wrapper and return the linker array. */ +void *bios_linker_cleanup (GArray *linker) +{ +return g_array_free (linker, false); +} + +void bios_linker_alloc(GArray *linker, + const char *file, + uint32_t alloc_align,Quoted 8 lines
hw/i386/bios-linker-loader.c line 110
Quoted 6 lines
hw/i386/bios-linker-loader.c new file +6
-0+ bool alloc_fseg) +{ +BiosLinkerLoaderEntry entry; + +memset (&entry,0 ,sizeof entry); +strncpy (entry.alloc_file, file,sizeof entry.alloc_file -1 );Please use pstrcpy (also below).
OK.
Quoted 59 lines
Quoted 59 lines
hw/i386/bios-linker-loader.c new file +46
-0+ entry.command =cpu_to_le32 (BIOS_LINKER_LOADER_COMMAND_ALLOCATE ); + entry.alloc_align =cpu_to_le32 (alloc_align); + entry.alloc_zone =cpu_to_le32 (alloc_fseg ? +BIOS_LINKER_LOADER_ALLOC_ZONE_FSEG : +BIOS_LINKER_LOADER_ALLOC_ZONE_HIGH ); + +/* Alloc entries must come first, so prepend them */ +g_array_prepend_val (linker, entry); +} + +void bios_linker_add_checksum (GArray *linker,const char *file,void *table, +void *start,unsigned size,uint8_t *checksum) +{ +BiosLinkerLoaderEntry entry; + +memset (&entry,0 ,sizeof entry); +strncpy (entry.cksum_file, file,sizeof entry.cksum_file -1 ); + entry.command =cpu_to_le32 (BIOS_LINKER_LOADER_COMMAND_ADD_CHECKSUM ); + entry.cksum_offset =cpu_to_le32 (checksum - (uint8_t *)table); + entry.cksum_start =cpu_to_le32 ((uint8_t *)start - (uint8_t *)table); + entry.cksum_length =cpu_to_le32 (size); + +g_array_append_val (linker, entry); +} + +void bios_linker_add_pointer (GArray *linker, +const char *dest_file, +const char *src_file, +GArray *table,void *pointer, +uint8_t pointer_size) +{ +BiosLinkerLoaderEntry entry; + +memset (&entry,0 ,sizeof entry); +strncpy (entry.pointer_dest_file, dest_file, +sizeof entry.pointer_dest_file -1 ); +strncpy (entry.pointer_src_file, src_file, +sizeof entry.pointer_src_file -1 ); + entry.command =cpu_to_le32 (BIOS_LINKER_LOADER_COMMAND_ADD_POINTER ); + entry.pointer_offset =cpu_to_le32 ((gchar *)pointer - table->data); + entry.pointer_size = pointer_size; +assert (pointer_size ==1 || pointer_size ==2 || + pointer_size ==4 || pointer_size ==8 ); + +g_array_append_val (linker, entry); +}hw/i386/Makefile.objs +1
-0@@ -5,6 +5,7 @@ obj-y += pc_sysfw.o obj-$(CONFIG_XEN) += xen_domainbuild.o xen_machine_pv.o obj-y += kvmvapic.o +obj-y += bios-linker-loader.o iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \ ; then echo "$(2)"; else echo "$(3)"; fi ;)
Re: [Qemu-devel] [PATCH v4 15/23] i386: add bios linker/loader
Quoted 30 lines · Paolo Bonzini
Il 23/09/2013 15:36, Michael S. Tsirkin ha scritto:
Quoted 29 lines · Paolo Bonzini
Quoted 14 lines
Il 22/09/2013 15:37, Michael S. Tsirkin ha scritto:
Quoted 7 lines
This adds a dynamic bios linker/loader.
This will be used by acpi table generation code to:
- load each table in the appropriate memory segment
- link tables to each other
- fix up checksums after said linkingQuoted 5 lines
Signed-off-by Michael S. Tsirkin <[email protected]>--- include/hw/i386/bios-linker-loader.h | 26 ++++++ hw/i386/bios-linker-loader.c | 156 +++++++++++++++++++++++++++++++++++ hw/i386/Makefile.objs | 1 +Quoted 7 lines
Just a naming question...
If this is ACPI-specific (or if there are no other uses in sight), it should go in
include/hw/acpiand hw/acpi, and renamed with s/bios/acpi/ etc.If this is i386-specific, it should go entirely in hw/i386 and the headers should be included as "
bios-linker-loader.h".Definitely not ACPI specific.
It's only used on i386 so I put it all under i386. You think we should replace
#include "hw/i386/bios-linker-loader.h" with #include "bios-linker-loader.h"?
Quoted 4 lines
Quoted 2 lines
I don't really care, even though this makes headers hard to find. What's the benefit?
Private headers are outside
include/, public headers within it.
Ah you mean move it outside include/. OK.
Quoted 35 lines
Same
conventions as Linux. But if it's not ACPI-specific, I don't feel too strongly about it.Quoted 3 lines
It's not easy to find a good name for it.
For now I'll just make all namesbios_linker_loader_consistently. We can always rename it later, it's not set in stone.Ok.
Quoted 25 lines
Quoted 24 lines
Quoted 6 lines
hw/i386/bios-linker-loader.c new file +6
-0+struct BiosLinkerLoaderEntry { +uint32_t command; +union { +/* +* COMMAND_ALLOCATE - allocate a table from @alloc_file +* subject to @alloc_align alignment (must be power of 2) hw/i386/bios-linker-loader.c line 45
Quoted 10 lines
hw/i386/bios-linker-loader.c new file +10
-0+* 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 alloc_file[BIOS_LINKER_LOADER_FILESZ ]; +uint32_t alloc_align; +uint8_t alloc_zone; + };I would prefer to have named structs, like
struct { char file[BIOS_LINKER_LOADER_FILESZ]; uint32_t align; uint8_t zone; } alloc;
Quoted 6 lines
Quoted 1 line
Why do you prefer this? It just makes code more verbose.
It doesn't, the names were already prefixed with alloc_/pointer_/cksum_.
All it does is change underscores to periods.Paolo
You are right, that's cleaner. I'll do this. I don't want to sprinkle QEMU_PACKED around though, it's just there for documentation purposes, so one place is enough.
Quoted 128 lines
Quoted 128 lines
Quoted 58 lines
Quoted 58 lines
hw/i386/bios-linker-loader.c new file +58
-0+/* +* 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 pointer_dest_file[BIOS_LINKER_LOADER_FILESZ ]; +char pointer_src_file[BIOS_LINKER_LOADER_FILESZ ]; +uint32_t pointer_offset; +uint8_t pointer_size; + }; + +/* +* 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 cksum_file[BIOS_LINKER_LOADER_FILESZ ]; +uint32_t cksum_offset; +uint32_t cksum_start; +uint32_t cksum_length; + }; + +/* 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 , +}; + +GArray *bios_linker_init (void ) +{ +return g_array_new (false, true/* clear */ ,sizeof (BiosLinkerLoaderEntry)); +} + +/* Free linker wrapper and return the linker array. */ +void *bios_linker_cleanup (GArray *linker) +{ +return g_array_free (linker, false); +} + +void bios_linker_alloc(GArray *linker, + const char *file, + uint32_t alloc_align,Quoted 8 lines
hw/i386/bios-linker-loader.c line 110
Quoted 6 lines
hw/i386/bios-linker-loader.c new file +6
-0+ bool alloc_fseg) +{ +BiosLinkerLoaderEntry entry; + +memset (&entry,0 ,sizeof entry); +strncpy (entry.alloc_file, file,sizeof entry.alloc_file -1 );Please use pstrcpy (also below).
OK.
Quoted 59 lines
Quoted 59 lines
hw/i386/bios-linker-loader.c new file +46
-0+ entry.command =cpu_to_le32 (BIOS_LINKER_LOADER_COMMAND_ALLOCATE ); + entry.alloc_align =cpu_to_le32 (alloc_align); + entry.alloc_zone =cpu_to_le32 (alloc_fseg ? +BIOS_LINKER_LOADER_ALLOC_ZONE_FSEG : +BIOS_LINKER_LOADER_ALLOC_ZONE_HIGH ); + +/* Alloc entries must come first, so prepend them */ +g_array_prepend_val (linker, entry); +} + +void bios_linker_add_checksum (GArray *linker,const char *file,void *table, +void *start,unsigned size,uint8_t *checksum) +{ +BiosLinkerLoaderEntry entry; + +memset (&entry,0 ,sizeof entry); +strncpy (entry.cksum_file, file,sizeof entry.cksum_file -1 ); + entry.command =cpu_to_le32 (BIOS_LINKER_LOADER_COMMAND_ADD_CHECKSUM ); + entry.cksum_offset =cpu_to_le32 (checksum - (uint8_t *)table); + entry.cksum_start =cpu_to_le32 ((uint8_t *)start - (uint8_t *)table); + entry.cksum_length =cpu_to_le32 (size); + +g_array_append_val (linker, entry); +} + +void bios_linker_add_pointer (GArray *linker, +const char *dest_file, +const char *src_file, +GArray *table,void *pointer, +uint8_t pointer_size) +{ +BiosLinkerLoaderEntry entry; + +memset (&entry,0 ,sizeof entry); +strncpy (entry.pointer_dest_file, dest_file, +sizeof entry.pointer_dest_file -1 ); +strncpy (entry.pointer_src_file, src_file, +sizeof entry.pointer_src_file -1 ); + entry.command =cpu_to_le32 (BIOS_LINKER_LOADER_COMMAND_ADD_POINTER ); + entry.pointer_offset =cpu_to_le32 ((gchar *)pointer - table->data); + entry.pointer_size = pointer_size; +assert (pointer_size ==1 || pointer_size ==2 || + pointer_size ==4 || pointer_size ==8 ); + +g_array_append_val (linker, entry); +}hw/i386/Makefile.objs +1
-0@@ -5,6 +5,7 @@ obj-y += pc_sysfw.o obj-$(CONFIG_XEN) += xen_domainbuild.o xen_machine_pv.o obj-y += kvmvapic.o +obj-y += bios-linker-loader.o iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \ ; then echo "$(2)"; else echo "$(3)"; fi ;)
Re: [Qemu-devel] [PATCH v4 15/23] i386: add bios linker/loader
Il 23/09/2013 15:47, Michael S. Tsirkin ha scritto:
Quoted 7 lines
Quoted 2 lines
It doesn't, the names were already prefixed with alloc_/pointer_/cksum_.
All it does is change underscores to periods.You are right, that's cleaner. I'll do this. I don't want to sprinkle
QEMU_PACKEDaround though, it's just there for documentation purposes, so one place is enough.
Fair enough. Thanks!
Paolo
Re: [Qemu-devel] [PATCH v4 15/23] i386: add bios linker/loader
Quoted 4 lines · Paolo Bonzini
Il 23/09/2013 15:47, Michael S. Tsirkin ha scritto:
Quoted 3 lines
Quoted 2 lines
It doesn't, the names were already prefixed with alloc_/pointer_/cksum_.
All it does is change underscores to periods.
Quoted 8 lines
Quoted 4 lines
You are right, that's cleaner. I'll do this. I don't want to sprinkle
QEMU_PACKEDaround though, it's just there for documentation purposes, so one place is enough.Fair enough. Thanks!
Paolo
At Paolo's request, I moved the header to hw/i386, and tweaked some names a bit.
The result is below. Not reposting the full series at this time to reduce churn.
commit 7e6224a1a0a07e59668337e7665659760e36ec64
Author: Michael S. Tsirkin <[email protected]> Date: Wed Jul 24 18:56:06 2013 +0300
i386: add bios linker/loader
This adds a dynamic bios linker/loader.
This will be used by acpi table generation code to:
- load each table in the appropriate memory segment
- link tables to each other
- fix up checksums after said linking
---
hw/i386/bios-linker-loader.h new file +27 -0
@@ -0,0 +1,27 @@ +#ifndef BIOS_LINKER_LOADER_H +#define BIOS_LINKER_LOADER_H + +#include <glib.h> +#include <stdbool.h> +#include <inttypes.h> + +GArray *bios_linker_loader_init (void ); + +void bios_linker_loader_alloc (GArray *linker, +const char *file, +uint32_t alloc_align, +bool alloc_fseg); + +void bios_linker_loader_add_checksum (GArray *linker,const char *file, +void *table, +void *start,unsigned size, +uint8_t *checksum); + +void bios_linker_loader_add_pointer (GArray *linker, +const char *dest_file, +const char *src_file, +GArray *table,void *pointer, +uint8_t pointer_size); + +void *bios_linker_loader_cleanup (GArray *linker); +#endif
hw/i386/bios-linker-loader.c new file +158 -0
158 lines not on this page · raw message
hw/i386/Makefile.objs +1 -0
@@ -5,6 +5,7 @@ obj-y += pc_sysfw.o obj-$(CONFIG_XEN) += xen_domainbuild.o xen_machine_pv.o obj-y += kvmvapic.o +obj-y += bios-linker-loader.o iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \ ; then echo "$(2)"; else echo "$(3)"; fi ;)
PATCH v4 16/23 loader: allow adding ROMs in done callbacks
In reply to Michael S. TsirkinDon't abort if machine done callbacks add ROMs.
--- include/hw/loader.h | 1 + hw/core/loader.c | 6 +++++- vl.c | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-)
include/hw/loader.h +1 -0
@@ -46,6 +46,7 @@ void *rom_add_blob(const char *name, const void *blob, size_t len,int rom_add_elf_program (const char *name,void *data,size_t datasize,size_t romsize,hwaddr addr);int rom_load_all (void ); +void rom_load_done (void );void rom_set_fw (FWCfgState *f);int rom_copy (uint8_t *dest,hwaddr addr,size_t size);void *rom_ptr (hwaddr addr);
hw/core/loader.c +5 -1
@@ -812,10 +812,14 @@ int rom_load_all(void)memory_region_unref (section.mr); }qemu_register_reset (rom_reset,NULL ); - roms_loaded =1 ;return 0 ; } +void rom_load_done (void ) +{ + roms_loaded =1 ; +} +void rom_set_fw (FWCfgState *f) { fw_cfg = f;
vl.c +3 -0
@@ -4336,6 +4336,9 @@ int main(int argc, char **argv, char **envp)qemu_register_reset (qbus_reset_all_fn,sysbus_get_default ());qemu_run_machine_init_done_notifiers (); +/* Done notifiers can load ROMs */ +rom_load_done (); +qemu_system_reset (VMRESET_SILENT );if (loadvm) {if (load_vmstate (loadvm) <0 ) {
Signature · 1 line
MST
PATCH v4 17/23 i386: define pc guest info
In reply to Michael S. TsirkinThis defines a structure that will be used to fill in acpi tables where relevant properties are not yet available using QOM.
--- include/hw/i386/pc.h | 10 ++++++++++ hw/i386/pc.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+)
include/hw/i386/pc.h +10 -0
@@ -9,6 +9,9 @@#include "hw/i386/ioapic.h" #include "qemu/range.h" +#include "qemu/bitmap.h" +#include "sysemu/sysemu.h" +#include "hw/pci/pci.h" /* PC-style peripherals (also used by other machines). */
@@ -20,6 +23,13 @@ typedef struct PcPciInfo {struct PcGuestInfo {bool has_pci_info;bool isapc_ram_fw; +hwaddr ram_size; +unsigned apic_id_limit; +bool apic_xrupt_override; +uint64_t numa_nodes; +uint64_t *node_mem; +uint64_t *node_cpu; + DECLARE_BITMAP(found_cpus, MAX_CPUMASK_BITS + 1);FWCfgState *fw_cfg; };
hw/i386/pc.c +35 -0
@@ -1028,6 +1028,26 @@ static void pc_fw_cfg_guest_info(PcGuestInfo *guest_info)fw_cfg_add_file (guest_info->fw_cfg,"etc/pci-info" , info,sizeof *info); } +static void pc_set_cpu_guest_info (CPUState *cpu,PcGuestInfo *guest_info) +{ +CPUClass *klass =CPU_GET_CLASS (cpu); +uint64_t apic_id = klass->get_arch_id (cpu); +int j; + +assert (apic_id <=MAX_CPUMASK_BITS ); +assert (apic_id < guest_info->apic_id_limit); + +set_bit (apic_id, guest_info->found_cpus); + +for (j =0 ; j < guest_info->numa_nodes; j++) { +assert (cpu->cpu_index < max_cpus); +if (test_bit (cpu->cpu_index, node_cpumask[j])) { + guest_info->node_cpu[apic_id] =cpu_to_le64 (j); +break ; + } + } +} + typedef struct PcGuestInfoState { PcGuestInfo info; Notifier machine_done;
@@ -1047,6 +1067,21 @@ PcGuestInfo *pc_guest_info_init(ram_addr_t below_4g_mem_size, {PcGuestInfoState *guest_info_state =g_malloc0 (sizeof *guest_info_state);PcGuestInfo *guest_info = &guest_info_state->info; +CPUState *cpu; + + guest_info->ram_size = below_4g_mem_size + above_4g_mem_size; + guest_info->apic_id_limit =pc_apic_id_limit (max_cpus); + guest_info->apic_xrupt_override =kvm_allows_irq0_override (); + guest_info->numa_nodes = nb_numa_nodes; + guest_info->node_mem =g_memdup (node_mem, guest_info->numa_nodes * +sizeof *guest_info->node_mem); + guest_info->node_cpu =g_malloc0 (guest_info->apic_id_limit * +sizeof *guest_info->node_cpu); + +memset (&guest_info->found_cpus,0 ,sizeof guest_info->found_cpus); +CPU_FOREACH (cpu) { +pc_set_cpu_guest_info (cpu, guest_info); + } guest_info_state->machine_done.notify = pc_guest_info_machine_done;qemu_add_machine_init_done_notifier (&guest_info_state->machine_done);
Signature · 1 line
MST
PATCH v4 18/23 acpi/piix: add macros for acpi property names
In reply to Michael S. Tsirkin--- include/hw/i386/pc.h | 10 ++++++++++ hw/acpi/piix4.c | 6 +++--- 2 files changed, 13 insertions(+), 3 deletions(-)
include/hw/i386/pc.h +10 -0
@@ -20,6 +20,16 @@ typedef struct PcPciInfo {Range w64; } PcPciInfo; +#define ACPI_PM_PROP_S3_DISABLED "disable_s3" +#define ACPI_PM_PROP_S4_DISABLED "disable_s4" +#define ACPI_PM_PROP_S4_VAL "s4_val" +#define ACPI_PM_PROP_SCI_INT "sci_int" +#define ACPI_PM_PROP_ACPI_ENABLE_CMD "acpi_enable_cmd" +#define ACPI_PM_PROP_ACPI_DISABLE_CMD "acpi_disable_cmd" +#define ACPI_PM_PROP_PM_IO_BASE "pm_io_base" +#define ACPI_PM_PROP_GPE0_BLK "gpe0_blk" +#define ACPI_PM_PROP_GPE0_BLK_LEN "gpe0_blk_len" +struct PcGuestInfo {bool has_pci_info;bool isapc_ram_fw;
hw/acpi/piix4.c +3 -3
@@ -489,9 +489,9 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,static Property piix4_pm_properties[] = {DEFINE_PROP_UINT32 ("smb_io_base" , PIIX4PMState, smb_io_base,0 ), -DEFINE_PROP_UINT8 ("disable_s3" , PIIX4PMState, disable_s3,0 ), -DEFINE_PROP_UINT8 ("disable_s4" , PIIX4PMState, disable_s4,0 ), -DEFINE_PROP_UINT8 ("s4_val" , PIIX4PMState, s4_val,2 ), +DEFINE_PROP_UINT8 (ACPI_PM_PROP_S3_DISABLED , PIIX4PMState, disable_s3,0 ), +DEFINE_PROP_UINT8 (ACPI_PM_PROP_S4_DISABLED , PIIX4PMState, disable_s4,0 ), +DEFINE_PROP_UINT8 (ACPI_PM_PROP_S4_VAL , PIIX4PMState, s4_val,2 ),DEFINE_PROP_END_OF_LIST (), };
Signature · 1 line
MST
PATCH v4 19/23 piix: APIs for pc guest info
In reply to Michael S. TsirkinThis adds APIs that will be used to fill in guest acpi tables. Some required information is still lacking in QOM, so we fall back on lookups by type and returning explicit types.
--- include/hw/acpi/piix4.h | 8 ++++++++ include/hw/i386/pc.h | 1 + hw/acpi/piix4.c | 44 ++++++++++++++++++++++++++++++++++++++++---- hw/pci-host/piix.c | 8 ++++++++ 4 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 include/hw/acpi/piix4.h
include/hw/acpi/piix4.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef HW_ACPI_PIIX4_H +#define HW_ACPI_PIIX4_H + +#include "qemu/typedefs.h" + +Object *piix4_pm_find (void ); + +#endif
include/hw/i386/pc.h +1 -0
@@ -193,6 +193,7 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix_devfn, MemoryRegion *pci_memory, MemoryRegion *ram_memory); +PCIBus *find_i440fx (void );/* piix4.c */ extern PCIDevice *piix4_dev;int piix4_init (PCIBus *bus,ISABus **isa_bus,int devfn);
hw/acpi/piix4.c +40 -4
81 lines not on this page · raw message
hw/pci-host/piix.c +8 -0
@@ -416,6 +416,14 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state,return b; } +PCIBus *find_i440fx (void ) +{ +PCIHostState *s =OBJECT_CHECK (PCIHostState, +object_resolve_path ("/machine/i440fx" ,NULL ), +TYPE_PCI_HOST_BRIDGE ); +return s ? s->bus :NULL ; +} +/* PIIX3 PCI to ISA bridge */ static void piix3_set_irq_pic (PIIX3State *piix3,int pic_irq) {
Signature · 1 line
MST
Re: [Qemu-devel] [PATCH v4 19/23] piix: APIs for pc guest info
Quoted 134 lines · On Sun, 22 Sep 2013 16:37:59 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
This adds APIs that will be used to fill in guest acpi tables. Some required information is still lacking in QOM, so we fall back on lookups by type and returning explicit types.
Signed-off-by Michael S. Tsirkin <[email protected]>--- include/hw/acpi/piix4.h | 8 ++++++++ include/hw/i386/pc.h | 1 + hw/acpi/piix4.c | 44 ++++++++++++++++++++++++++++++++++++++++---- hw/pci-host/piix.c | 8 ++++++++ 4 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 include/hw/acpi/piix4.hinclude/hw/acpi/piix4.h new file +8
-0@@ -0,0 +1,8 @@ +#ifndef HW_ACPI_PIIX4_H +#define HW_ACPI_PIIX4_H + +#include "qemu/typedefs.h" + +Object *piix4_pm_find (void ); + +#endif include/hw/i386/pc.h +1
-0@@ -193,6 +193,7 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix_devfn, MemoryRegion *pci_memory, MemoryRegion *ram_memory); +PCIBus *find_i440fx (void );/* piix4.c */ extern PCIDevice *piix4_dev;int piix4_init (PCIBus *bus,ISABus **isa_bus,int devfn);hw/acpi/piix4.c +40
-4@@ -29,6 +29,7 @@#include "exec/ioport.h" #include "hw/nvram/fw_cfg.h" #include "exec/address-spaces.h" +#include "hw/acpi/piix4.h" //#define DEBUG @@ -69,6 +70,8 @@ typedef struct PIIX4PMState {/*< public >*/ MemoryRegion io; +uint32_t io_base; +MemoryRegion io_gpe;MemoryRegion io_pci;MemoryRegion io_cpu;@@ -152,14 +155,13 @@ static void apm_ctrl_changed(uint32_t val, void *arg)static void pm_io_space_update (PIIX4PMState *s) {PCIDevice *d =PCI_DEVICE (s); -uint32_t pm_io_base; - pm_io_base =le32_to_cpu (*(uint32_t *)(d->config +0x40 )); - pm_io_base &=0xffc0 ; + s->io_base =le32_to_cpu (*(uint32_t *)(d->config +0x40 )); + s->io_base &=0xffc0 ;memory_region_transaction_begin ();memory_region_set_enabled (&s->io, d->config[0x80 ] &1 ); -memory_region_set_address (&s->io, pm_io_base); +memory_region_set_address (&s->io, s->io_base);memory_region_transaction_commit (); }@@ -407,6 +409,28 @@ static void piix4_pm_machine_ready(Notifier *n, void *opaque) (memory_region_present (io_as,0x2f8 ) ?0x90 :0 ); } +static void piix4_pm_add_propeties (PIIX4PMState *s) +{ +static const uint8_t acpi_enable_cmd =ACPI_ENABLE ; +static const uint8_t acpi_disable_cmd =ACPI_DISABLE ; +static const uint32_t gpe0_blk =GPE_BASE ; +static const uint32_t gpe0_blk_len =GPE_LEN ; +static const uint16_t sci_int =9 ; + +object_property_add_uint8_ptr (OBJECT (s),ACPI_PM_PROP_ACPI_ENABLE_CMD , + &acpi_enable_cmd,NULL ); +object_property_add_uint8_ptr (OBJECT (s),ACPI_PM_PROP_ACPI_DISABLE_CMD , + &acpi_disable_cmd,NULL ); +object_property_add_uint32_ptr (OBJECT (s),ACPI_PM_PROP_GPE0_BLK , + &gpe0_blk,NULL ); +object_property_add_uint32_ptr (OBJECT (s),ACPI_PM_PROP_GPE0_BLK_LEN , + &gpe0_blk_len,NULL ); +object_property_add_uint16_ptr (OBJECT (s),ACPI_PM_PROP_SCI_INT , + &sci_int,NULL ); +object_property_add_uint32_ptr (OBJECT (s),ACPI_PM_PROP_PM_IO_BASE , + &s->io_base,NULL ); +} +static int piix4_pm_initfn (PCIDevice *dev) {PIIX4PMState *s =PIIX4_PM (dev);@@ -456,9 +480,21 @@ static int piix4_pm_initfn(PCIDevice *dev)piix4_acpi_system_hot_add_init (pci_address_space_io (dev), dev->bus, s); +piix4_pm_add_propeties (s);return 0 ; } +Object *piix4_pm_find (void ) +{ +bool ambig; +Object *o =object_resolve_path_type ("" ,TYPE_PIIX4_PM , &ambig); + +if (ambig || !o) { +return NULL ; + } +return o; +} +i2c_bus *piix4_pm_init (PCIBus *bus,int devfn,uint32_t smb_io_base,qemu_irq sci_irq,qemu_irq smi_irq,int kvm_enabled,FWCfgState *fw_cfg)hw/pci-host/piix.c +0
-0
hw/pci-host/piix.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state, · line 423
Quoted 8 lines
hw/pci-host/piix.c +5
-0@@ -416,6 +416,14 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state,return b; } +PCIBus *find_i440fx (void ) +{ +PCIHostState *s =OBJECT_CHECK (PCIHostState, +object_resolve_path ("/machine/i440fx" ,NULL ), +TYPE_PCI_HOST_BRIDGE );
wouldn't object_resolve_path_type() be cleaner here?
Quoted 6 lines
hw/pci-host/piix.c +3
-0+return s ? s->bus :NULL ; +} +/* PIIX3 PCI to ISA bridge */ static void piix3_set_irq_pic (PIIX3State *piix3,int pic_irq) {
Re: [Qemu-devel] [PATCH v4 19/23] piix: APIs for pc guest info
Quoted 140 lines · Igor Mammedov
Quoted 137 lines · On Sun, 22 Sep 2013 16:37:59 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
This adds APIs that will be used to fill in guest acpi tables. Some required information is still lacking in QOM, so we fall back on lookups by type and returning explicit types.
Signed-off-by Michael S. Tsirkin <[email protected]>--- include/hw/acpi/piix4.h | 8 ++++++++ include/hw/i386/pc.h | 1 + hw/acpi/piix4.c | 44 ++++++++++++++++++++++++++++++++++++++++---- hw/pci-host/piix.c | 8 ++++++++ 4 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 include/hw/acpi/piix4.hinclude/hw/acpi/piix4.h new file +8
-0@@ -0,0 +1,8 @@ +#ifndef HW_ACPI_PIIX4_H +#define HW_ACPI_PIIX4_H + +#include "qemu/typedefs.h" + +Object *piix4_pm_find (void ); + +#endif include/hw/i386/pc.h +1
-0@@ -193,6 +193,7 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix_devfn, MemoryRegion *pci_memory, MemoryRegion *ram_memory); +PCIBus *find_i440fx (void );/* piix4.c */ extern PCIDevice *piix4_dev;int piix4_init (PCIBus *bus,ISABus **isa_bus,int devfn);hw/acpi/piix4.c +40
-4@@ -29,6 +29,7 @@#include "exec/ioport.h" #include "hw/nvram/fw_cfg.h" #include "exec/address-spaces.h" +#include "hw/acpi/piix4.h" //#define DEBUG @@ -69,6 +70,8 @@ typedef struct PIIX4PMState {/*< public >*/ MemoryRegion io; +uint32_t io_base; +MemoryRegion io_gpe;MemoryRegion io_pci;MemoryRegion io_cpu;@@ -152,14 +155,13 @@ static void apm_ctrl_changed(uint32_t val, void *arg)static void pm_io_space_update (PIIX4PMState *s) {PCIDevice *d =PCI_DEVICE (s); -uint32_t pm_io_base; - pm_io_base =le32_to_cpu (*(uint32_t *)(d->config +0x40 )); - pm_io_base &=0xffc0 ; + s->io_base =le32_to_cpu (*(uint32_t *)(d->config +0x40 )); + s->io_base &=0xffc0 ;memory_region_transaction_begin ();memory_region_set_enabled (&s->io, d->config[0x80 ] &1 ); -memory_region_set_address (&s->io, pm_io_base); +memory_region_set_address (&s->io, s->io_base);memory_region_transaction_commit (); }@@ -407,6 +409,28 @@ static void piix4_pm_machine_ready(Notifier *n, void *opaque) (memory_region_present (io_as,0x2f8 ) ?0x90 :0 ); } +static void piix4_pm_add_propeties (PIIX4PMState *s) +{ +static const uint8_t acpi_enable_cmd =ACPI_ENABLE ; +static const uint8_t acpi_disable_cmd =ACPI_DISABLE ; +static const uint32_t gpe0_blk =GPE_BASE ; +static const uint32_t gpe0_blk_len =GPE_LEN ; +static const uint16_t sci_int =9 ; + +object_property_add_uint8_ptr (OBJECT (s),ACPI_PM_PROP_ACPI_ENABLE_CMD , + &acpi_enable_cmd,NULL ); +object_property_add_uint8_ptr (OBJECT (s),ACPI_PM_PROP_ACPI_DISABLE_CMD , + &acpi_disable_cmd,NULL ); +object_property_add_uint32_ptr (OBJECT (s),ACPI_PM_PROP_GPE0_BLK , + &gpe0_blk,NULL ); +object_property_add_uint32_ptr (OBJECT (s),ACPI_PM_PROP_GPE0_BLK_LEN , + &gpe0_blk_len,NULL ); +object_property_add_uint16_ptr (OBJECT (s),ACPI_PM_PROP_SCI_INT , + &sci_int,NULL ); +object_property_add_uint32_ptr (OBJECT (s),ACPI_PM_PROP_PM_IO_BASE , + &s->io_base,NULL ); +} +static int piix4_pm_initfn (PCIDevice *dev) {PIIX4PMState *s =PIIX4_PM (dev);@@ -456,9 +480,21 @@ static int piix4_pm_initfn(PCIDevice *dev)piix4_acpi_system_hot_add_init (pci_address_space_io (dev), dev->bus, s); +piix4_pm_add_propeties (s);return 0 ; } +Object *piix4_pm_find (void ) +{ +bool ambig; +Object *o =object_resolve_path_type ("" ,TYPE_PIIX4_PM , &ambig); + +if (ambig || !o) { +return NULL ; + } +return o; +} +i2c_bus *piix4_pm_init (PCIBus *bus,int devfn,uint32_t smb_io_base,qemu_irq sci_irq,qemu_irq smi_irq,int kvm_enabled,FWCfgState *fw_cfg)hw/pci-host/piix.c +0
-0@@ -416,6 +416,14 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state,return b; }
Quoted 6 lines
hw/pci-host/piix.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state, · line 423
Quoted 5 lines
hw/pci-host/piix.c +5
-0+PCIBus *find_i440fx (void ) +{ +PCIHostState *s =OBJECT_CHECK (PCIHostState, +object_resolve_path ("/machine/i440fx" ,NULL ), +TYPE_PCI_HOST_BRIDGE );wouldn't
object_resolve_path_type()be cleaner here?
Why would it? /machine/i440fx is an absolute path so it's unambigious, adding type is not needed.
And if we do we'd just have to repeat TYPE_PCI_HOST_BRIDGE twice since we need the real type anyway.
What did I miss?
Quoted 7 lines
Quoted 7 lines
hw/pci-host/piix.c +3
-0+return s ? s->bus :NULL ; +} +/* PIIX3 PCI to ISA bridge */ static void piix3_set_irq_pic (PIIX3State *piix3,int pic_irq) {
Re: [Qemu-devel] [PATCH v4 19/23] piix: APIs for pc guest info
Quoted 148 lines · On Mon, 23 Sep 2013 13:10:49 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 140 lines · Igor Mammedov
Quoted 137 lines · On Sun, 22 Sep 2013 16:37:59 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
This adds APIs that will be used to fill in guest acpi tables. Some required information is still lacking in QOM, so we fall back on lookups by type and returning explicit types.
Signed-off-by Michael S. Tsirkin <[email protected]>--- include/hw/acpi/piix4.h | 8 ++++++++ include/hw/i386/pc.h | 1 + hw/acpi/piix4.c | 44 ++++++++++++++++++++++++++++++++++++++++---- hw/pci-host/piix.c | 8 ++++++++ 4 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 include/hw/acpi/piix4.hinclude/hw/acpi/piix4.h new file +8
-0@@ -0,0 +1,8 @@ +#ifndef HW_ACPI_PIIX4_H +#define HW_ACPI_PIIX4_H + +#include "qemu/typedefs.h" + +Object *piix4_pm_find (void ); + +#endif include/hw/i386/pc.h +1
-0@@ -193,6 +193,7 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix_devfn, MemoryRegion *pci_memory, MemoryRegion *ram_memory); +PCIBus *find_i440fx (void );/* piix4.c */ extern PCIDevice *piix4_dev;int piix4_init (PCIBus *bus,ISABus **isa_bus,int devfn);hw/acpi/piix4.c +40
-4@@ -29,6 +29,7 @@#include "exec/ioport.h" #include "hw/nvram/fw_cfg.h" #include "exec/address-spaces.h" +#include "hw/acpi/piix4.h" //#define DEBUG @@ -69,6 +70,8 @@ typedef struct PIIX4PMState {/*< public >*/ MemoryRegion io; +uint32_t io_base; +MemoryRegion io_gpe;MemoryRegion io_pci;MemoryRegion io_cpu;@@ -152,14 +155,13 @@ static void apm_ctrl_changed(uint32_t val, void *arg)static void pm_io_space_update (PIIX4PMState *s) {PCIDevice *d =PCI_DEVICE (s); -uint32_t pm_io_base; - pm_io_base =le32_to_cpu (*(uint32_t *)(d->config +0x40 )); - pm_io_base &=0xffc0 ; + s->io_base =le32_to_cpu (*(uint32_t *)(d->config +0x40 )); + s->io_base &=0xffc0 ;memory_region_transaction_begin ();memory_region_set_enabled (&s->io, d->config[0x80 ] &1 ); -memory_region_set_address (&s->io, pm_io_base); +memory_region_set_address (&s->io, s->io_base);memory_region_transaction_commit (); }@@ -407,6 +409,28 @@ static void piix4_pm_machine_ready(Notifier *n, void *opaque) (memory_region_present (io_as,0x2f8 ) ?0x90 :0 ); } +static void piix4_pm_add_propeties (PIIX4PMState *s) +{ +static const uint8_t acpi_enable_cmd =ACPI_ENABLE ; +static const uint8_t acpi_disable_cmd =ACPI_DISABLE ; +static const uint32_t gpe0_blk =GPE_BASE ; +static const uint32_t gpe0_blk_len =GPE_LEN ; +static const uint16_t sci_int =9 ; + +object_property_add_uint8_ptr (OBJECT (s),ACPI_PM_PROP_ACPI_ENABLE_CMD , + &acpi_enable_cmd,NULL ); +object_property_add_uint8_ptr (OBJECT (s),ACPI_PM_PROP_ACPI_DISABLE_CMD , + &acpi_disable_cmd,NULL ); +object_property_add_uint32_ptr (OBJECT (s),ACPI_PM_PROP_GPE0_BLK , + &gpe0_blk,NULL ); +object_property_add_uint32_ptr (OBJECT (s),ACPI_PM_PROP_GPE0_BLK_LEN , + &gpe0_blk_len,NULL ); +object_property_add_uint16_ptr (OBJECT (s),ACPI_PM_PROP_SCI_INT , + &sci_int,NULL ); +object_property_add_uint32_ptr (OBJECT (s),ACPI_PM_PROP_PM_IO_BASE , + &s->io_base,NULL ); +} +static int piix4_pm_initfn (PCIDevice *dev) {PIIX4PMState *s =PIIX4_PM (dev);@@ -456,9 +480,21 @@ static int piix4_pm_initfn(PCIDevice *dev)piix4_acpi_system_hot_add_init (pci_address_space_io (dev), dev->bus, s); +piix4_pm_add_propeties (s);return 0 ; } +Object *piix4_pm_find (void ) +{ +bool ambig; +Object *o =object_resolve_path_type ("" ,TYPE_PIIX4_PM , &ambig); + +if (ambig || !o) { +return NULL ; + } +return o; +} +i2c_bus *piix4_pm_init (PCIBus *bus,int devfn,uint32_t smb_io_base,qemu_irq sci_irq,qemu_irq smi_irq,int kvm_enabled,FWCfgState *fw_cfg)hw/pci-host/piix.c +0
-0@@ -416,6 +416,14 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state,return b; }Quoted 6 lines
hw/pci-host/piix.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state, · line 423
Quoted 5 lines
hw/pci-host/piix.c +5
-0+PCIBus *find_i440fx (void ) +{ +PCIHostState *s =OBJECT_CHECK (PCIHostState, +object_resolve_path ("/machine/i440fx" ,NULL ), +TYPE_PCI_HOST_BRIDGE );wouldn't
object_resolve_path_type()be cleaner here?
Quoted 8 lines
Why would it? /machine/i440fx is an absolute path so it's unambigious, adding type is not needed.
And if we do we'd just have to repeat
TYPE_PCI_HOST_BRIDGEtwice since we need the real type anyway.What did I miss?
object_resolve_path_type() does type check when object_resolve_path() doesn't. but since you need PCIHostState as result then you'll need cast anyway, so both object_resolve_path_type() or object_resolve_path() would do.
But why not use an exiting type macro for this which does cast+type check instead of open coding it:
PCIHostState *s = PCI_HOST_BRIDGE(object_resolve_path("/machine/i440fx", NULL));
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
hw/pci-host/piix.c +3
-0+return s ? s->bus :NULL ; +} +/* PIIX3 PCI to ISA bridge */ static void piix3_set_irq_pic (PIIX3State *piix3,int pic_irq) {
Re: [Qemu-devel] [PATCH v4 19/23] piix: APIs for pc guest info
Quoted 159 lines · Igor Mammedov
Quoted 148 lines · On Mon, 23 Sep 2013 13:10:49 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 140 lines · Igor Mammedov
Quoted 137 lines · On Sun, 22 Sep 2013 16:37:59 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
This adds APIs that will be used to fill in guest acpi tables. Some required information is still lacking in QOM, so we fall back on lookups by type and returning explicit types.
Signed-off-by Michael S. Tsirkin <[email protected]>--- include/hw/acpi/piix4.h | 8 ++++++++ include/hw/i386/pc.h | 1 + hw/acpi/piix4.c | 44 ++++++++++++++++++++++++++++++++++++++++---- hw/pci-host/piix.c | 8 ++++++++ 4 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 include/hw/acpi/piix4.hinclude/hw/acpi/piix4.h new file +8
-0@@ -0,0 +1,8 @@ +#ifndef HW_ACPI_PIIX4_H +#define HW_ACPI_PIIX4_H + +#include "qemu/typedefs.h" + +Object *piix4_pm_find (void ); + +#endif include/hw/i386/pc.h +1
-0@@ -193,6 +193,7 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix_devfn, MemoryRegion *pci_memory, MemoryRegion *ram_memory); +PCIBus *find_i440fx (void );/* piix4.c */ extern PCIDevice *piix4_dev;int piix4_init (PCIBus *bus,ISABus **isa_bus,int devfn);hw/acpi/piix4.c +40
-4@@ -29,6 +29,7 @@#include "exec/ioport.h" #include "hw/nvram/fw_cfg.h" #include "exec/address-spaces.h" +#include "hw/acpi/piix4.h" //#define DEBUG @@ -69,6 +70,8 @@ typedef struct PIIX4PMState {/*< public >*/ MemoryRegion io; +uint32_t io_base; +MemoryRegion io_gpe;MemoryRegion io_pci;MemoryRegion io_cpu;@@ -152,14 +155,13 @@ static void apm_ctrl_changed(uint32_t val, void *arg)static void pm_io_space_update (PIIX4PMState *s) {PCIDevice *d =PCI_DEVICE (s); -uint32_t pm_io_base; - pm_io_base =le32_to_cpu (*(uint32_t *)(d->config +0x40 )); - pm_io_base &=0xffc0 ; + s->io_base =le32_to_cpu (*(uint32_t *)(d->config +0x40 )); + s->io_base &=0xffc0 ;memory_region_transaction_begin ();memory_region_set_enabled (&s->io, d->config[0x80 ] &1 ); -memory_region_set_address (&s->io, pm_io_base); +memory_region_set_address (&s->io, s->io_base);memory_region_transaction_commit (); }@@ -407,6 +409,28 @@ static void piix4_pm_machine_ready(Notifier *n, void *opaque) (memory_region_present (io_as,0x2f8 ) ?0x90 :0 ); } +static void piix4_pm_add_propeties (PIIX4PMState *s) +{ +static const uint8_t acpi_enable_cmd =ACPI_ENABLE ; +static const uint8_t acpi_disable_cmd =ACPI_DISABLE ; +static const uint32_t gpe0_blk =GPE_BASE ; +static const uint32_t gpe0_blk_len =GPE_LEN ; +static const uint16_t sci_int =9 ; + +object_property_add_uint8_ptr (OBJECT (s),ACPI_PM_PROP_ACPI_ENABLE_CMD , + &acpi_enable_cmd,NULL ); +object_property_add_uint8_ptr (OBJECT (s),ACPI_PM_PROP_ACPI_DISABLE_CMD , + &acpi_disable_cmd,NULL ); +object_property_add_uint32_ptr (OBJECT (s),ACPI_PM_PROP_GPE0_BLK , + &gpe0_blk,NULL ); +object_property_add_uint32_ptr (OBJECT (s),ACPI_PM_PROP_GPE0_BLK_LEN , + &gpe0_blk_len,NULL ); +object_property_add_uint16_ptr (OBJECT (s),ACPI_PM_PROP_SCI_INT , + &sci_int,NULL ); +object_property_add_uint32_ptr (OBJECT (s),ACPI_PM_PROP_PM_IO_BASE , + &s->io_base,NULL ); +} +static int piix4_pm_initfn (PCIDevice *dev) {PIIX4PMState *s =PIIX4_PM (dev);@@ -456,9 +480,21 @@ static int piix4_pm_initfn(PCIDevice *dev)piix4_acpi_system_hot_add_init (pci_address_space_io (dev), dev->bus, s); +piix4_pm_add_propeties (s);return 0 ; } +Object *piix4_pm_find (void ) +{ +bool ambig; +Object *o =object_resolve_path_type ("" ,TYPE_PIIX4_PM , &ambig); + +if (ambig || !o) { +return NULL ; + } +return o; +} +i2c_bus *piix4_pm_init (PCIBus *bus,int devfn,uint32_t smb_io_base,qemu_irq sci_irq,qemu_irq smi_irq,int kvm_enabled,FWCfgState *fw_cfg)hw/pci-host/piix.c +0
-0@@ -416,6 +416,14 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state,return b; }Quoted 6 lines
hw/pci-host/piix.c PCIBus *i440fx_init(PCII440FXState **pi440fx_state, · line 423
Quoted 5 lines
hw/pci-host/piix.c +5
-0+PCIBus *find_i440fx (void ) +{ +PCIHostState *s =OBJECT_CHECK (PCIHostState, +object_resolve_path ("/machine/i440fx" ,NULL ), +TYPE_PCI_HOST_BRIDGE );wouldn't
object_resolve_path_type()be cleaner here?Quoted 8 lines
Why would it? /machine/i440fx is an absolute path so it's unambigious, adding type is not needed.
And if we do we'd just have to repeat
TYPE_PCI_HOST_BRIDGEtwice since we need the real type anyway.What did I miss?
Quoted 8 lines
object_resolve_path_type()does type check whenobject_resolve_path()doesn't. but since you need PCIHostState as result then you'll need cast anyway, so bothobject_resolve_path_type()orobject_resolve_path()would do.But why not use an exiting type macro for this which does cast+type check instead of open coding it:
PCIHostState *s =
PCI_HOST_BRIDGE(object_resolve_path("/machine/i440fx", NULL));
Good point, I'll do it like this.
I won't repost just for this unless there are more comments.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
hw/pci-host/piix.c +3
-0+return s ? s->bus :NULL ; +} +/* PIIX3 PCI to ISA bridge */ static void piix3_set_irq_pic (PIIX3State *piix3,int pic_irq) {
PATCH v4 20/23 ich9: APIs for pc guest info
In reply to Michael S. TsirkinThis adds APIs that will be used to fill in acpi tables, implemented using QOM, to various ich9 components.
Some information is still missing in QOM, so we fall back on lookups by type instead.
--- include/hw/acpi/ich9.h | 2 ++ include/hw/i386/ich9.h | 2 ++ include/hw/pci-host/q35.h | 2 ++ hw/acpi/ich9.c | 24 ++++++++++++++++++++++++ hw/isa/lpc_ich9.c | 40 ++++++++++++++++++++++++++++++++++++++++ hw/pci-host/q35.c | 10 ++++++++++ 6 files changed, 80 insertions(+)
include/hw/acpi/ich9.h +2 -0
@@ -49,4 +49,6 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,void ich9_pm_iospace_update (ICH9LPCPMRegs *pm,uint32_t pm_io_base);extern const VMStateDescription vmstate_ich9_pm; +void ich9_pm_add_properties (Object *obj,ICH9LPCPMRegs *pm,Error **errp); +#endif /* HW_ACPI_ICH9_H */
include/hw/i386/ich9.h +2 -0
@@ -66,6 +66,8 @@ typedef struct ICH9LPCState {qemu_irq *ioapic; } ICH9LPCState; +Object *ich9_lpc_find (void ); +#define Q35_MASK (bit, ms_bit, ls_bit) \ ((uint##bit##_t)(((1ULL << ((ms_bit) + 1)) - 1) & ~((1ULL << ls_bit) - 1)))
include/hw/pci-host/q35.h +2 -0
@@ -156,4 +156,6 @@ typedef struct Q35PCIHost {#define MCH_PCIE_DEV 1#define MCH_PCIE_FUNC 0 +uint64_t mch_mcfg_base (void ); +#endif /* HW_Q35_H */
hw/acpi/ich9.c +24 -0
@@ -24,6 +24,7 @@* GNU GPL, version 2 or (at your option) any later version. */ #include "hw/hw.h" +#include "qapi/visitor.h" #include "hw/i386/pc.h" #include "hw/pci/pci.h" #include "qemu/timer.h"
@@ -228,3 +229,26 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm, pm->powerdown_notifier.notify = pm_powerdown_req;qemu_register_powerdown_notifier (&pm->powerdown_notifier); } + +static void ich9_pm_get_gpe0_blk (Object *obj,Visitor *v, +void *opaque,const char *name, +Error **errp) +{ +ICH9LPCPMRegs *pm = opaque; +uint32_t value = pm->pm_io_base +ICH9_PMIO_GPE0_STS ; + +visit_type_uint32 (v, &value, name, errp); +} + +void ich9_pm_add_properties (Object *obj,ICH9LPCPMRegs *pm,Error **errp) +{ +static const uint32_t gpe0_len =ICH9_PMIO_GPE0_LEN ; + +object_property_add_uint32_ptr (obj,ACPI_PM_PROP_PM_IO_BASE , + &pm->pm_io_base, errp); +object_property_add (obj,ACPI_PM_PROP_GPE0_BLK ,"uint32" , + ich9_pm_get_gpe0_blk, +NULL ,NULL , pm,NULL ); +object_property_add_uint32_ptr (obj,ACPI_PM_PROP_GPE0_BLK_LEN , + &gpe0_len, errp); +}
hw/isa/lpc_ich9.c +40 -0
@@ -29,6 +29,7 @@*/ #include "qemu-common.h" #include "hw/hw.h" +#include "qapi/visitor.h" #include "qemu/range.h" #include "hw/isa/isa.h" #include "hw/sysbus.h"
@@ -525,6 +526,43 @@ static const MemoryRegionOps ich9_rst_cnt_ops = { .endianness = DEVICE_LITTLE_ENDIAN }; +Object *ich9_lpc_find (void ) +{ +bool ambig; +Object *o =object_resolve_path_type ("" ,TYPE_ICH9_LPC_DEVICE , &ambig); + +if (ambig) { +return NULL ; + } +return o; +} + +static void ich9_lpc_get_sci_int (Object *obj,Visitor *v, +void *opaque,const char *name, +Error **errp) +{ +ICH9LPCState *lpc =ICH9_LPC_DEVICE (obj); +uint32_t value =ich9_lpc_sci_irq (lpc); + +visit_type_uint32 (v, &value, name, errp); +} + +static void ich9_lpc_add_properties (ICH9LPCState *lpc) +{ +static const uint8_t acpi_enable_cmd =ICH9_APM_ACPI_ENABLE ; +static const uint8_t acpi_disable_cmd =ICH9_APM_ACPI_DISABLE ; + +object_property_add (OBJECT (lpc),ACPI_PM_PROP_SCI_INT ,"uint32" , + ich9_lpc_get_sci_int, +NULL ,NULL ,NULL ,NULL ); +object_property_add_uint8_ptr (OBJECT (lpc),ACPI_PM_PROP_ACPI_ENABLE_CMD , + &acpi_enable_cmd,NULL ); +object_property_add_uint8_ptr (OBJECT (lpc),ACPI_PM_PROP_ACPI_DISABLE_CMD , + &acpi_disable_cmd,NULL ); + +ich9_pm_add_properties (OBJECT (lpc), &lpc->pm,NULL ); +} +static int ich9_lpc_initfn (PCIDevice *d) {ICH9LPCState *lpc =ICH9_LPC_DEVICE (d);
@@ -552,6 +590,8 @@ static int ich9_lpc_initfn(PCIDevice *d)ICH9_RST_CNT_IOPORT , &lpc->rst_cnt_mem, 1); +ich9_lpc_add_properties (lpc); +return 0 ; }
hw/pci-host/q35.c +10 -0
@@ -389,6 +389,16 @@ static int mch_init(PCIDevice *d)return 0 ; } +uint64_t mch_mcfg_base (void ) +{ +bool ambiguous; +Object *o =object_resolve_path_type ("" ,TYPE_MCH_PCI_DEVICE , &ambiguous); +if (!o) { +return 0 ; + } +return MCH_HOST_BRIDGE_PCIEXBAR_DEFAULT ; +} +static void mch_class_init (ObjectClass *klass,void *data) {PCIDeviceClass *k =PCI_DEVICE_CLASS (klass);
Signature · 1 line
MST
PATCH v4 21/23 pvpanic: add API to access io port
In reply to Michael S. TsirkinAdd API to find pvpanic device and get its io port. Will be used to fill in guest info structure.
--- include/hw/i386/pc.h | 1 + hw/misc/pvpanic.c | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-)
include/hw/i386/pc.h +1 -0
@@ -236,6 +236,7 @@ void pc_system_firmware_init(MemoryRegion *rom_memory,/* pvpanic.c */ void pvpanic_init (ISABus *bus); +uint16_t pvpanic_port (void );/* e820 types */ #define E820_RAM 1
hw/misc/pvpanic.c +12 -1
@@ -117,8 +117,19 @@ void pvpanic_init(ISABus *bus)isa_create_simple (bus,TYPE_ISA_PVPANIC_DEVICE ); } +#define PVPANIC_IOPORT_PROP "ioport" + +uint16_t pvpanic_port (void ) +{ +Object *o =object_resolve_path_type ("" ,TYPE_ISA_PVPANIC_DEVICE ,NULL ); +if (!o) { +return 0 ; + } +return object_property_get_int (o,PVPANIC_IOPORT_PROP ,NULL ); +} +static Property pvpanic_isa_properties[] = { -DEFINE_PROP_UINT16 ("ioport" , PVPanicState, ioport,0x505 ), +DEFINE_PROP_UINT16 (PVPANIC_IOPORT_PROP , PVPanicState, ioport,0x505 ),DEFINE_PROP_END_OF_LIST (), };
Signature · 1 line
MST
PATCH v4 22/23 hpet: add API to find it
In reply to Michael S. TsirkinAdd API to find HPET using QOM.
--- include/hw/timer/hpet.h | 2 ++ hw/timer/hpet.c | 5 +++++ 2 files changed, 7 insertions(+)
include/hw/timer/hpet.h +2 -0
@@ -71,4 +71,6 @@ struct hpet_fw_config } QEMU_PACKED;extern struct hpet_fw_config hpet_cfg; + +bool hpet_find (void );#endif
hw/timer/hpet.c +5 -0
@@ -757,6 +757,11 @@ static void hpet_device_class_init(ObjectClass *klass, void *data) dc->props = hpet_device_properties; } +bool hpet_find (void ) +{ +return object_resolve_path_type ("" ,"hpet" ,NULL ); +} +static const TypeInfo hpet_device_info = { .name =TYPE_HPET , .parent =TYPE_SYS_BUS_DEVICE ,
Signature · 1 line
MST
Re: [Qemu-devel] [PATCH v4 22/23] hpet: add API to find it
Il 22/09/2013 15:38, Michael S. Tsirkin ha scritto:
Quoted 24 lines
Add API to find HPET using QOM.
Signed-off-by Michael S. Tsirkin <[email protected]>--- include/hw/timer/hpet.h | 2 ++ hw/timer/hpet.c | 5 +++++ 2 files changed, 7 insertions(+)include/hw/timer/hpet.h +2
-0@@ -71,4 +71,6 @@ struct hpet_fw_config } QEMU_PACKED;extern struct hpet_fw_config hpet_cfg; + +bool hpet_find (void );#endif hw/timer/hpet.c +0
-0
hw/timer/hpet.c static void hpet_device_class_init(ObjectClass *klass, void *data) · line 762
Quoted 6 lines
hw/timer/hpet.c +3
-0@@ -757,6 +757,11 @@ static void hpet_device_class_init(ObjectClass *klass, void *data) dc->props = hpet_device_properties; } +bool hpet_find (void ) +{ +return object_resolve_path_type ("" ,"hpet" ,NULL );
s/"hpet"/TYPE_HPET/
Paolo
Quoted 6 lines
hw/timer/hpet.c +2
-0+} +static const TypeInfo hpet_device_info = { .name =TYPE_HPET , .parent =TYPE_SYS_BUS_DEVICE ,
Re: [Qemu-devel] [PATCH v4 22/23] hpet: add API to find it
Quoted 28 lines · Paolo Bonzini
Il 22/09/2013 15:38, Michael S. Tsirkin ha scritto:
Quoted 27 lines
Add API to find HPET using QOM.
Signed-off-by Michael S. Tsirkin <[email protected]>--- include/hw/timer/hpet.h | 2 ++ hw/timer/hpet.c | 5 +++++ 2 files changed, 7 insertions(+)include/hw/timer/hpet.h +2
-0@@ -71,4 +71,6 @@ struct hpet_fw_config } QEMU_PACKED;extern struct hpet_fw_config hpet_cfg; + +bool hpet_find (void );#endif hw/timer/hpet.c +0
-0@@ -757,6 +757,11 @@ static void hpet_device_class_init(ObjectClass *klass, void *data) dc->props = hpet_device_properties; }
Quoted 7 lines
hw/timer/hpet.c static void hpet_device_class_init(ObjectClass *klass, void *data) · line 762
Quoted 3 lines
hw/timer/hpet.c +3
-0+bool hpet_find (void ) +{ +return object_resolve_path_type ("" ,"hpet" ,NULL );s/"hpet"/TYPE_HPET/
Paolo
Right. I'll fix it in my tree, won't repost just for this. Thanks!
Quoted 6 lines
Quoted 6 lines
hw/timer/hpet.c +2
-0+} +static const TypeInfo hpet_device_info = { .name =TYPE_HPET , .parent =TYPE_SYS_BUS_DEVICE ,
PATCH v4 23/23 i386: ACPI table generation code from seabios
In reply to Michael S. TsirkinThis adds C code for generating ACPI tables at runtime, imported from seabios git tree
commit 51684b7ced75fb76776e8ee84833fcfb6ecf12dd
Although ACPI tables come from a system BIOS on real hw, it makes sense that the ACPI tables are coupled with the virtual machine, since they have to abstract the x86 machine to the OS's.
This is widely desired as a way to avoid the churn and proliferation of QEMU-specific interfaces associated with ACPI tables in bios code.
Notes:
As BIOS can reprogram devices prior to loading ACPI tables, we pre-format ACPI tables but defer loading hardware configuration there until tables are loaded.
The code structure was intentionally kept as close to the seabios original as possible, to simplify comparison and making sure we didn't lose anything in translation.
Minor code duplication results, to help ensure there are no functional regressions, I think it's better to merge it like this and do more code changes in follow-up patches.
Cross-version compatibility concerns have been addressed:
ACPI tables are exposed to guest as FW_CFG entries. When running with -M 1.5 and older, this patch disables ACPI table generation, and doesn't expose ACPI
tables to guest.
As table content is likely to change over time,
the following measures are taken to simplify
cross-version migration:
- All tables besides the RSDP are packed in a single FW CFG entry. This entry size is currently 23K. We round it up to 64K to avoid too much churn there.
- Tables are placed in special ROM blob (not mapped into guest memory) which is automatically migrated together with the guest, same as BIOS code.
- Offsets where hardware configuration is loaded in ACPI tables are also migrated, this is in case future ACPI changes make us rearrange the tables in memory.
This patch reuses some code from SeaBIOS, which was originally under LGPLv2 and then relicensed to GPLv3 or LGPLv3, in QEMU under GPLv2+. This relicensing has been acked by all contributors that had contributed to the code since the v2->v3 relicense. ACKs approving the v2+ relicensing are listed below. The list might include ACKs from people not holding copyright on any parts of the reused code, but it's better to err on the side of caution and include them.
Affected SeaBIOS files (GPLv2+ license headers added)
<http://thread.gmane.org/gmane.comp.bios.coreboot.seabios/5949>:
src/acpi-dsdt-cpu-hotplug.dsl
src/acpi-dsdt-dbug.dsl
src/acpi-dsdt-hpet.dsl
src/acpi-dsdt-isa.dsl
src/acpi-dsdt-pci-crs.dsl
src/acpi.c
src/acpi.h
src/ssdt-misc.dsl
src/ssdt-pcihp.dsl
src/ssdt-proc.dsl
tools/acpi_extract.py
tools/acpi_extract_preprocess.py
Each one of the listed people agreed to the following:
Quoted 5 lines
If you allow the use of your contribution in QEMU under the terms of GPLv2 or later as proposed by this patch, please respond to this mail including the line:
Acked-by Name <email address>
--- hw/i386/acpi-defs.h | 331 ++++++++++++ include/hw/i386/acpi-build.h | 9 + include/hw/i386/pc.h | 1 + hw/i386/acpi-build.c | 1190 ++++++++++++++++++++++++++++++++++++++++++ hw/i386/pc.c | 2 + hw/i386/pc_piix.c | 5 + hw/i386/pc_q35.c | 3 + hw/i386/Makefile.objs | 4 + 8 files changed, 1545 insertions(+) create mode 100644 hw/i386/acpi-defs.h create mode 100644 include/hw/i386/acpi-build.h create mode 100644 hw/i386/acpi-build.c
hw/i386/acpi-defs.h new file +331 -0
@@ -0,0 +1,331 @@ +/* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License along +* with this program; if not, see <http://www.gnu.org/licenses/>. +*/ +#ifndef QEMU_ACPI_DEFS_H +#define QEMU_ACPI_DEFS_H + +enum { +ACPI_FADT_F_WBINVD , +ACPI_FADT_F_WBINVD_FLUSH , +ACPI_FADT_F_PROC_C1 , +ACPI_FADT_F_P_LVL2_UP , +ACPI_FADT_F_PWR_BUTTON , +ACPI_FADT_F_SLP_BUTTON , +ACPI_FADT_F_FIX_RTC , +ACPI_FADT_F_RTC_S4 , +ACPI_FADT_F_TMR_VAL_EXT , +ACPI_FADT_F_DCK_CAP , +ACPI_FADT_F_RESET_REG_SUP , +ACPI_FADT_F_SEALED_CASE , +ACPI_FADT_F_HEADLESS , +ACPI_FADT_F_CPU_SW_SLP , +ACPI_FADT_F_PCI_EXP_WAK , +ACPI_FADT_F_USE_PLATFORM_CLOCK , +ACPI_FADT_F_S4_RTC_STS_VALID , +ACPI_FADT_F_REMOTE_POWER_ON_CAPABLE , +ACPI_FADT_F_FORCE_APIC_CLUSTER_MODEL , +ACPI_FADT_F_FORCE_APIC_PHYSICAL_DESTINATION_MODE , +ACPI_FADT_F_HW_REDUCED_ACPI , +ACPI_FADT_F_LOW_POWER_S0_IDLE_CAPABLE , +}; + +/* +* ACPI 2.0 Generic Address Space definition. +*/ +struct Acpi20GenericAddress { +uint8_t address_space_id; +uint8_t register_bit_width; +uint8_t register_bit_offset; +uint8_t reserved; +uint64_t address; +}QEMU_PACKED ; +typedef struct Acpi20GenericAddress Acpi20GenericAddress ; + +#define ACPI_RSDP_SIGNATURE 0x2052545020445352LL // "RSD PTR " + +struct AcpiRsdpDescriptor {/* Root System Descriptor Pointer */ +uint64_t signature;/* ACPI signature, contains "RSD PTR " */ +uint8_t checksum;/* To make sum of struct == 0 */ +uint8_t oem_id [6 ];/* OEM identification */ +uint8_t revision;/* Must be 0 for 1.0, 2 for 2.0 */ +uint32_t rsdt_physical_address;/* 32-bit physical address of RSDT */ +uint32_t length;/* XSDT Length in bytes including hdr */ +uint64_t xsdt_physical_address;/* 64-bit physical address of XSDT */ +uint8_t extended_checksum;/* Checksum of entire table */ +uint8_t reserved [3 ];/* Reserved field must be 0 */ +}QEMU_PACKED ; +typedef struct AcpiRsdpDescriptor AcpiRsdpDescriptor ; + +/* Table structure from Linux kernel (the ACPI tables are under the +BSD license) */ + + +#define ACPI_TABLE_HEADER_DEF /* ACPI common table header */ \ + uint32_t signature;/* ACPI signature (4 ASCII characters) */ \ +uint32_t length;/* Length of table, in bytes, including header */ \ +uint8_t revision;/* ACPI Specification minor version # */ \ +uint8_t checksum;/* To make sum of entire table == 0 */ \ +uint8_t oem_id [6 ];/* OEM identification */ \ +uint8_t oem_table_id [8 ];/* OEM table identification */ \ +uint32_t oem_revision;/* OEM revision number */ \ +uint8_t asl_compiler_id [4 ];/* ASL compiler vendor ID */ \ +uint32_t asl_compiler_revision;/* ASL compiler revision number */ + + +struct AcpiTableHeader /* ACPI common table header */ +{ + ACPI_TABLE_HEADER_DEF +}QEMU_PACKED ; +typedef struct AcpiTableHeader AcpiTableHeader ; + +/* +* ACPI 1.0 Fixed ACPI Description Table (FADT) +*/ +#define ACPI_FACP_SIGNATURE 0x50434146 // FACP +struct AcpiFadtDescriptorRev1 +{ +ACPI_TABLE_HEADER_DEF /* ACPI common table header */ + uint32_t firmware_ctrl; /* Physical address of FACS */ +uint32_t dsdt;/* Physical address of DSDT */ +uint8_t model;/* System Interrupt Model */ +uint8_t reserved1;/* Reserved */ +uint16_t sci_int;/* System vector of SCI interrupt */ +uint32_t smi_cmd;/* Port address of SMI command port */ +uint8_t acpi_enable;/* Value to write to smi_cmd to enable ACPI */ +uint8_t acpi_disable;/* Value to write to smi_cmd to disable ACPI */ +uint8_t S4bios_req;/* Value to write to SMI CMD to enter S4BIOS state */ +uint8_t reserved2;/* Reserved - must be zero */ +uint32_t pm1a_evt_blk;/* Port address of Power Mgt 1a acpi_event Reg Blk */ +uint32_t pm1b_evt_blk;/* Port address of Power Mgt 1b acpi_event Reg Blk */ +uint32_t pm1a_cnt_blk;/* Port address of Power Mgt 1a Control Reg Blk */ +uint32_t pm1b_cnt_blk;/* Port address of Power Mgt 1b Control Reg Blk */ +uint32_t pm2_cnt_blk;/* Port address of Power Mgt 2 Control Reg Blk */ +uint32_t pm_tmr_blk;/* Port address of Power Mgt Timer Ctrl Reg Blk */ +uint32_t gpe0_blk;/* Port addr of General Purpose acpi_event 0 Reg Blk */ +uint32_t gpe1_blk;/* Port addr of General Purpose acpi_event 1 Reg Blk */ +uint8_t pm1_evt_len;/* Byte length of ports at pm1_x_evt_blk */ +uint8_t pm1_cnt_len;/* Byte length of ports at pm1_x_cnt_blk */ +uint8_t pm2_cnt_len;/* Byte Length of ports at pm2_cnt_blk */ +uint8_t pm_tmr_len;/* Byte Length of ports at pm_tm_blk */ +uint8_t gpe0_blk_len;/* Byte Length of ports at gpe0_blk */ +uint8_t gpe1_blk_len;/* Byte Length of ports at gpe1_blk */ +uint8_t gpe1_base;/* Offset in gpe model where gpe1 events start */ +uint8_t reserved3;/* Reserved */ +uint16_t plvl2_lat;/* Worst case HW latency to enter/exit C2 state */ +uint16_t plvl3_lat;/* Worst case HW latency to enter/exit C3 state */ +uint16_t flush_size;/* Size of area read to flush caches */ +uint16_t flush_stride;/* Stride used in flushing caches */ +uint8_t duty_offset;/* Bit location of duty cycle field in p_cnt reg */ +uint8_t duty_width;/* Bit width of duty cycle field in p_cnt reg */ +uint8_t day_alrm;/* Index to day-of-month alarm in RTC CMOS RAM */ +uint8_t mon_alrm;/* Index to month-of-year alarm in RTC CMOS RAM */ +uint8_t century;/* Index to century in RTC CMOS RAM */ +uint8_t reserved4;/* Reserved */ +uint8_t reserved4a;/* Reserved */ +uint8_t reserved4b;/* Reserved */ +uint32_t flags; +}QEMU_PACKED ; +typedef struct AcpiFadtDescriptorRev1 AcpiFadtDescriptorRev1 ; + +/* +* ACPI 1.0 Root System Description Table (RSDT) +*/ +#define ACPI_RSDT_SIGNATURE 0x54445352 // RSDT +struct AcpiRsdtDescriptorRev1 +{ +ACPI_TABLE_HEADER_DEF /* ACPI common table header */ + uint32_t table_offset_entry[0]; /* Array of pointers to other */ +/* ACPI tables */ +}QEMU_PACKED ; +typedef struct AcpiRsdtDescriptorRev1 AcpiRsdtDescriptorRev1 ; + +/* +* ACPI 1.0 Firmware ACPI Control Structure (FACS) +*/ +#define ACPI_FACS_SIGNATURE 0x53434146 // FACS +struct AcpiFacsDescriptorRev1 +{ +uint32_t signature;/* ACPI Signature */ +uint32_t length;/* Length of structure, in bytes */ +uint32_t hardware_signature;/* Hardware configuration signature */ +uint32_t firmware_waking_vector;/* ACPI OS waking vector */ +uint32_t global_lock;/* Global Lock */ +uint32_t flags; +uint8_t resverved3 [40 ];/* Reserved - must be zero */ +}QEMU_PACKED ; +typedef struct AcpiFacsDescriptorRev1 AcpiFacsDescriptorRev1 ; + +/* +* Differentiated System Description Table (DSDT) +*/ +#define ACPI_DSDT_SIGNATURE 0x54445344 // DSDT + +/* +* MADT values and structures +*/ + +/* Values for MADT PCATCompat */ + +#define ACPI_DUAL_PIC 0 +#define ACPI_MULTIPLE_APIC 1 + +/* Master MADT */ + +#define ACPI_APIC_SIGNATURE 0x43495041 // APIC +struct AcpiMultipleApicTable +{ +ACPI_TABLE_HEADER_DEF /* ACPI common table header */ + uint32_t local_apic_address; /* Physical address of local APIC */ +uint32_t flags; +}QEMU_PACKED ; +typedef struct AcpiMultipleApicTable AcpiMultipleApicTable ; + +/* Values for Type in APIC sub-headers */ + +#define ACPI_APIC_PROCESSOR 0 +#define ACPI_APIC_IO 1 +#define ACPI_APIC_XRUPT_OVERRIDE 2 +#define ACPI_APIC_NMI 3 +#define ACPI_APIC_LOCAL_NMI 4 +#define ACPI_APIC_ADDRESS_OVERRIDE 5 +#define ACPI_APIC_IO_SAPIC 6 +#define ACPI_APIC_LOCAL_SAPIC 7 +#define ACPI_APIC_XRUPT_SOURCE 8 +#define ACPI_APIC_RESERVED 9/* 9 and greater are reserved */ + +/* +* MADT sub-structures (Follow MULTIPLE_APIC_DESCRIPTION_TABLE) +*/ +#define ACPI_SUB_HEADER_DEF /* Common ACPI sub-structure header */ \ + uint8_t type; \ + uint8_t length; + +/* Sub-structures for MADT */ + +struct AcpiMadtProcessorApic +{ +ACPI_SUB_HEADER_DEF + uint8_t processor_id; /* ACPI processor id */ +uint8_t local_apic_id;/* Processor's local APIC id */ +uint32_t flags; +}QEMU_PACKED ; +typedef struct AcpiMadtProcessorApic AcpiMadtProcessorApic ; + +struct AcpiMadtIoApic +{ +ACPI_SUB_HEADER_DEF + uint8_t io_apic_id; /* I/O APIC ID */ +uint8_t reserved;/* Reserved - must be zero */ +uint32_t address;/* APIC physical address */ +uint32_t interrupt;/* Global system interrupt where INTI +* lines start */ +}QEMU_PACKED ; +typedef struct AcpiMadtIoApic AcpiMadtIoApic ; + +struct AcpiMadtIntsrcovr { +ACPI_SUB_HEADER_DEF + uint8_t bus; +uint8_t source; +uint32_t gsi; +uint16_t flags; +}QEMU_PACKED ; +typedef struct AcpiMadtIntsrcovr AcpiMadtIntsrcovr ; + +struct AcpiMadtLocalNmi { +ACPI_SUB_HEADER_DEF + uint8_t processor_id; /* ACPI processor id */ +uint16_t flags;/* MPS INTI flags */ +uint8_t lint;/* Local APIC LINT# */ +}QEMU_PACKED ; +typedef struct AcpiMadtLocalNmi AcpiMadtLocalNmi ; + +/* +* HPET Description Table +*/ +#define ACPI_HPET_SIGNATURE 0x54455048 // HPET +struct Acpi20Hpet { +ACPI_TABLE_HEADER_DEF /* ACPI common table header */ + uint32_t timer_block_id; +Acpi20GenericAddress addr; +uint8_t hpet_number; +uint16_t min_tick; +uint8_t page_protect; +}QEMU_PACKED ; +typedef struct Acpi20Hpet Acpi20Hpet ; + +/* +* SRAT (NUMA topology description) table +*/ + +#define ACPI_SRAT_SIGNATURE 0x54415253 // SRAT +struct AcpiSystemResourceAffinityTable +{ +ACPI_TABLE_HEADER_DEF + uint32_t reserved1; +uint32_t reserved2[2 ]; +}QEMU_PACKED ; +typedef struct AcpiSystemResourceAffinityTable AcpiSystemResourceAffinityTable ; + +#define ACPI_SRAT_PROCESSOR 0 +#define ACPI_SRAT_MEMORY 1 + +struct AcpiSratProcessorAffinity +{ +ACPI_SUB_HEADER_DEF + uint8_t proximity_lo; +uint8_t local_apic_id; +uint32_t flags; +uint8_t local_sapic_eid; +uint8_t proximity_hi[3 ]; +uint32_t reserved; +}QEMU_PACKED ; +typedef struct AcpiSratProcessorAffinity AcpiSratProcessorAffinity ; + +struct AcpiSratMemoryAffinity +{ +ACPI_SUB_HEADER_DEF + uint8_t proximity[4]; +uint16_t reserved1; +uint64_t base_addr; +uint64_t range_length; +uint32_t reserved2; +uint32_t flags; +uint32_t reserved3[2 ]; +}QEMU_PACKED ; +typedef struct AcpiSratMemoryAffinity AcpiSratMemoryAffinity ; + +/* PCI fw r3.0 MCFG table. */ +/* Subtable */ +struct AcpiMcfgAllocation { +uint64_t address;/* Base address, processor-relative */ +uint16_t pci_segment;/* PCI segment group number */ +uint8_t start_bus_number;/* Starting PCI Bus number */ +uint8_t end_bus_number;/* Final PCI Bus number */ +uint32_t reserved; +}QEMU_PACKED ; +typedef struct AcpiMcfgAllocation AcpiMcfgAllocation ; + +#define ACPI_MCFG_SIGNATURE 0x4746434d // MCFG + +/* Reserved signature: ignored by OSPM */ +#define ACPI_RSRV_SIGNATURE 0x51454d55 // QEMU + +struct AcpiTableMcfg { +ACPI_TABLE_HEADER_DEF ; +uint8_t reserved[8 ]; +AcpiMcfgAllocation allocation[0 ]; +}QEMU_PACKED ; +typedef struct AcpiTableMcfg AcpiTableMcfg ; + +#endif
include/hw/i386/acpi-build.h new file +9 -0
@@ -0,0 +1,9 @@ + +#ifndef HW_I386_ACPI_BUILD_H +#define HW_I386_ACPI_BUILD_H + +#include "qemu/typedefs.h" + +void acpi_setup (PcGuestInfo *); + +#endif
include/hw/i386/pc.h +1 -0
@@ -41,6 +41,7 @@ struct PcGuestInfo {uint64_t *node_cpu;DECLARE_BITMAP (found_cpus,MAX_CPUMASK_BITS +1 );FWCfgState *fw_cfg; +bool has_acpi_build; };/* parallel.c */
hw/i386/acpi-build.c new file +1190 -0
1,190 lines not on this page · raw message
hw/i386/pc.c +2 -0
@@ -56,6 +56,7 @@#include "hw/cpu/icc_bus.h" #include "hw/boards.h" #include "hw/pci/pci_host.h" +#include "hw/i386/acpi-build.h" /* debug PC/ISA interrupts */ //#define DEBUG_IRQ
@@ -1060,6 +1061,7 @@ void pc_guest_info_machine_done(Notifier *notifier, void *data) PcGuestInfoState, machine_done);pc_fw_cfg_guest_info (&guest_info_state->info); +acpi_setup (&guest_info_state->info); } PcGuestInfo *pc_guest_info_init(ram_addr_t below_4g_mem_size,
hw/i386/pc_piix.c +5 -0
@@ -59,6 +59,7 @@ static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };static bool has_pvpanic;static bool has_pci_info = true; +static bool has_acpi_build = true;/* PC hardware initialisation */ static void pc_init1(QEMUMachineInitArgs *args,
@@ -122,6 +123,9 @@ static void pc_init1(QEMUMachineInitArgs *args, } guest_info =pc_guest_info_init (below_4g_mem_size, above_4g_mem_size); + + guest_info->has_acpi_build = has_acpi_build; + guest_info->has_pci_info = has_pci_info; guest_info->isapc_ram_fw = !pci_enabled;
@@ -240,6 +244,7 @@ static void pc_compat_1_6(QEMUMachineInitArgs *args) { has_pci_info = false; rom_file_in_ram = false; + has_acpi_build = false; }static void pc_compat_1_5 (QEMUMachineInitArgs *args)
hw/i386/pc_q35.c +3 -0
@@ -49,6 +49,7 @@static bool has_pvpanic;static bool has_pci_info = true; +static bool has_acpi_build = true;/* PC hardware initialisation */ static void pc_q35_init (QEMUMachineInitArgs *args)
@@ -111,6 +112,7 @@ static void pc_q35_init(QEMUMachineInitArgs *args) guest_info =pc_guest_info_init (below_4g_mem_size, above_4g_mem_size); guest_info->has_pci_info = has_pci_info; guest_info->isapc_ram_fw = false; + guest_info->has_acpi_build = has_acpi_build;/* allocate ram and load rom/bios */ if (!xen_enabled ()) {
@@ -224,6 +226,7 @@ static void pc_compat_1_6(QEMUMachineInitArgs *args) { has_pci_info = false; rom_file_in_ram = false; + has_acpi_build = false; }static void pc_compat_1_5 (QEMUMachineInitArgs *args)
hw/i386/Makefile.objs +4 -0
@@ -5,7 +5,11 @@ obj-y += pc_sysfw.o obj-$(CONFIG_XEN) += xen_domainbuild.o xen_machine_pv.o obj-y += kvmvapic.o +obj-y += acpi-build.o obj-y += bios-linker-loader.o +hw/i386/acpi-build.o: hw/i386/acpi-build.c hw/i386/acpi-dsdt.hex \ + hw/i386/ssdt-proc.hex hw/i386/ssdt-pcihp.hex hw/i386/ssdt-misc.hex \ + hw/i386/acpi-dsdt.hex hw/i386/q35-acpi-dsdt.hex iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \ ; then echo "$(2)"; else echo "$(3)"; fi ;)
Signature · 1 line
MST
Quoted 2 lines · Michael S. Tsirkin
This code can also be found here:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.gitacpi
Program received signal SIGSEGV, Segmentation fault. qobject_to_qint (obj=obj@entry=0x0)
at /home/kraxel/projects/qemu/qobject/qint.c:51
51 QInt *qobject_to_qint(const QObject *obj)
(gdb) bt
#0 qobject_to_qint (obj=obj@entry=0x0)
at /home/kraxel/projects/qemu/qobject/qint.c:51
#1 0x00005555557e1ca5 in acpi_get_pm_info (pm=pm@entry=0x7fffffffd8a0)
at /home/kraxel/projects/qemu/hw/i386/acpi-build.c:107
#2 0x00005555557e282b in acpi_setup
(guest_info=guest_info@entry=0x5555561dcc80)
at /home/kraxel/projects/qemu/hw/i386/acpi-build.c:1107#3 0x00005555557ebf37 in pc_guest_info_machine_done (notifier=0x5555561dcce0,
data=<optimized out>)
at /home/kraxel/projects/qemu/hw/i386/pc.c:1064 #4 0x00005555558dee47 in notifier_list_notify (
list=list@entry=0x555556147348 <machine_init_done_notifiers>,
data=data@entry=0x0)
at /home/kraxel/projects/qemu/util/notify.c:39
#5 0x00005555555e0117 in qemu_run_machine_init_done_notifiers ()
at /home/kraxel/projects/qemu/vl.c:2711
#6 main (argc=<optimized out>, argv=<optimized out>, envp=<optimized
out>)
at /home/kraxel/projects/qemu/vl.c:4337cheers,
Gerd
Quoted 5 lines · Gerd Hoffmann
Quoted 2 lines · Michael S. Tsirkin
This code can also be found here:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.gitacpiProgram received signal SIGSEGV, Segmentation fault.
Fixed now, thanks for the report.