mirror of https://github.com/xemu-project/xemu.git
hw/arm/virt-acpi-build: remove redundant members from VirtGuestInfo
Now that we pass VirtMachineState, and guest-info is just part of that state, we can remove all the redundant members and access the VirtMachineState directly. Signed-off-by: Andrew Jones <drjones@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Message-id: 20170102200153.28864-12-drjones@redhat.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
e9a8e474fb
commit
da4f09a7dc
|
@ -384,7 +384,7 @@ build_rsdp(GArray *rsdp_table, BIOSLinker *linker, unsigned rsdt_tbl_offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
build_iort(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info)
|
build_iort(GArray *table_data, BIOSLinker *linker)
|
||||||
{
|
{
|
||||||
int iort_start = table_data->len;
|
int iort_start = table_data->len;
|
||||||
AcpiIortIdMapping *idmap;
|
AcpiIortIdMapping *idmap;
|
||||||
|
@ -439,11 +439,11 @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
build_spcr(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info)
|
build_spcr(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
|
||||||
{
|
{
|
||||||
AcpiSerialPortConsoleRedirection *spcr;
|
AcpiSerialPortConsoleRedirection *spcr;
|
||||||
const MemMapEntry *uart_memmap = &guest_info->memmap[VIRT_UART];
|
const MemMapEntry *uart_memmap = &vms->memmap[VIRT_UART];
|
||||||
int irq = guest_info->irqmap[VIRT_UART] + ARM_SPI_BASE;
|
int irq = vms->irqmap[VIRT_UART] + ARM_SPI_BASE;
|
||||||
|
|
||||||
spcr = acpi_data_push(table_data, sizeof(*spcr));
|
spcr = acpi_data_push(table_data, sizeof(*spcr));
|
||||||
|
|
||||||
|
@ -472,16 +472,16 @@ build_spcr(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
build_srat(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info)
|
build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
|
||||||
{
|
{
|
||||||
AcpiSystemResourceAffinityTable *srat;
|
AcpiSystemResourceAffinityTable *srat;
|
||||||
AcpiSratProcessorGiccAffinity *core;
|
AcpiSratProcessorGiccAffinity *core;
|
||||||
AcpiSratMemoryAffinity *numamem;
|
AcpiSratMemoryAffinity *numamem;
|
||||||
int i, j, srat_start;
|
int i, j, srat_start;
|
||||||
uint64_t mem_base;
|
uint64_t mem_base;
|
||||||
uint32_t *cpu_node = g_malloc0(guest_info->smp_cpus * sizeof(uint32_t));
|
uint32_t *cpu_node = g_malloc0(vms->smp_cpus * sizeof(uint32_t));
|
||||||
|
|
||||||
for (i = 0; i < guest_info->smp_cpus; i++) {
|
for (i = 0; i < vms->smp_cpus; i++) {
|
||||||
j = numa_get_node_for_cpu(i);
|
j = numa_get_node_for_cpu(i);
|
||||||
if (j < nb_numa_nodes) {
|
if (j < nb_numa_nodes) {
|
||||||
cpu_node[i] = j;
|
cpu_node[i] = j;
|
||||||
|
@ -492,7 +492,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info)
|
||||||
srat = acpi_data_push(table_data, sizeof(*srat));
|
srat = acpi_data_push(table_data, sizeof(*srat));
|
||||||
srat->reserved1 = cpu_to_le32(1);
|
srat->reserved1 = cpu_to_le32(1);
|
||||||
|
|
||||||
for (i = 0; i < guest_info->smp_cpus; ++i) {
|
for (i = 0; i < vms->smp_cpus; ++i) {
|
||||||
core = acpi_data_push(table_data, sizeof(*core));
|
core = acpi_data_push(table_data, sizeof(*core));
|
||||||
core->type = ACPI_SRAT_PROCESSOR_GICC;
|
core->type = ACPI_SRAT_PROCESSOR_GICC;
|
||||||
core->length = sizeof(*core);
|
core->length = sizeof(*core);
|
||||||
|
@ -502,7 +502,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info)
|
||||||
}
|
}
|
||||||
g_free(cpu_node);
|
g_free(cpu_node);
|
||||||
|
|
||||||
mem_base = guest_info->memmap[VIRT_MEM].base;
|
mem_base = vms->memmap[VIRT_MEM].base;
|
||||||
for (i = 0; i < nb_numa_nodes; ++i) {
|
for (i = 0; i < nb_numa_nodes; ++i) {
|
||||||
numamem = acpi_data_push(table_data, sizeof(*numamem));
|
numamem = acpi_data_push(table_data, sizeof(*numamem));
|
||||||
build_srat_memory(numamem, mem_base, numa_info[i].node_mem, i,
|
build_srat_memory(numamem, mem_base, numa_info[i].node_mem, i,
|
||||||
|
@ -515,10 +515,10 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
build_mcfg(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info)
|
build_mcfg(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
|
||||||
{
|
{
|
||||||
AcpiTableMcfg *mcfg;
|
AcpiTableMcfg *mcfg;
|
||||||
const MemMapEntry *memmap = guest_info->memmap;
|
const MemMapEntry *memmap = vms->memmap;
|
||||||
int len = sizeof(*mcfg) + sizeof(mcfg->allocation[0]);
|
int len = sizeof(*mcfg) + sizeof(mcfg->allocation[0]);
|
||||||
|
|
||||||
mcfg = acpi_data_push(table_data, len);
|
mcfg = acpi_data_push(table_data, len);
|
||||||
|
@ -562,11 +562,12 @@ build_gtdt(GArray *table_data, BIOSLinker *linker)
|
||||||
|
|
||||||
/* MADT */
|
/* MADT */
|
||||||
static void
|
static void
|
||||||
build_madt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info)
|
build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
|
||||||
{
|
{
|
||||||
|
VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
|
||||||
int madt_start = table_data->len;
|
int madt_start = table_data->len;
|
||||||
const MemMapEntry *memmap = guest_info->memmap;
|
const MemMapEntry *memmap = vms->memmap;
|
||||||
const int *irqmap = guest_info->irqmap;
|
const int *irqmap = vms->irqmap;
|
||||||
AcpiMultipleApicTable *madt;
|
AcpiMultipleApicTable *madt;
|
||||||
AcpiMadtGenericDistributor *gicd;
|
AcpiMadtGenericDistributor *gicd;
|
||||||
AcpiMadtGenericMsiFrame *gic_msi;
|
AcpiMadtGenericMsiFrame *gic_msi;
|
||||||
|
@ -578,16 +579,16 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info)
|
||||||
gicd->type = ACPI_APIC_GENERIC_DISTRIBUTOR;
|
gicd->type = ACPI_APIC_GENERIC_DISTRIBUTOR;
|
||||||
gicd->length = sizeof(*gicd);
|
gicd->length = sizeof(*gicd);
|
||||||
gicd->base_address = cpu_to_le64(memmap[VIRT_GIC_DIST].base);
|
gicd->base_address = cpu_to_le64(memmap[VIRT_GIC_DIST].base);
|
||||||
gicd->version = guest_info->gic_version;
|
gicd->version = vms->gic_version;
|
||||||
|
|
||||||
for (i = 0; i < guest_info->smp_cpus; i++) {
|
for (i = 0; i < vms->smp_cpus; i++) {
|
||||||
AcpiMadtGenericCpuInterface *gicc = acpi_data_push(table_data,
|
AcpiMadtGenericCpuInterface *gicc = acpi_data_push(table_data,
|
||||||
sizeof(*gicc));
|
sizeof(*gicc));
|
||||||
ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(i));
|
ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(i));
|
||||||
|
|
||||||
gicc->type = ACPI_APIC_GENERIC_CPU_INTERFACE;
|
gicc->type = ACPI_APIC_GENERIC_CPU_INTERFACE;
|
||||||
gicc->length = sizeof(*gicc);
|
gicc->length = sizeof(*gicc);
|
||||||
if (guest_info->gic_version == 2) {
|
if (vms->gic_version == 2) {
|
||||||
gicc->base_address = cpu_to_le64(memmap[VIRT_GIC_CPU].base);
|
gicc->base_address = cpu_to_le64(memmap[VIRT_GIC_CPU].base);
|
||||||
}
|
}
|
||||||
gicc->cpu_interface_number = cpu_to_le32(i);
|
gicc->cpu_interface_number = cpu_to_le32(i);
|
||||||
|
@ -600,7 +601,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (guest_info->gic_version == 3) {
|
if (vms->gic_version == 3) {
|
||||||
AcpiMadtGenericTranslator *gic_its;
|
AcpiMadtGenericTranslator *gic_its;
|
||||||
AcpiMadtGenericRedistributor *gicr = acpi_data_push(table_data,
|
AcpiMadtGenericRedistributor *gicr = acpi_data_push(table_data,
|
||||||
sizeof *gicr);
|
sizeof *gicr);
|
||||||
|
@ -610,7 +611,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info)
|
||||||
gicr->base_address = cpu_to_le64(memmap[VIRT_GIC_REDIST].base);
|
gicr->base_address = cpu_to_le64(memmap[VIRT_GIC_REDIST].base);
|
||||||
gicr->range_length = cpu_to_le32(memmap[VIRT_GIC_REDIST].size);
|
gicr->range_length = cpu_to_le32(memmap[VIRT_GIC_REDIST].size);
|
||||||
|
|
||||||
if (its_class_name() && !guest_info->no_its) {
|
if (its_class_name() && !vmc->no_its) {
|
||||||
gic_its = acpi_data_push(table_data, sizeof *gic_its);
|
gic_its = acpi_data_push(table_data, sizeof *gic_its);
|
||||||
gic_its->type = ACPI_APIC_GENERIC_TRANSLATOR;
|
gic_its->type = ACPI_APIC_GENERIC_TRANSLATOR;
|
||||||
gic_its->length = sizeof(*gic_its);
|
gic_its->length = sizeof(*gic_its);
|
||||||
|
@ -659,11 +660,11 @@ build_fadt(GArray *table_data, BIOSLinker *linker, unsigned dsdt_tbl_offset)
|
||||||
|
|
||||||
/* DSDT */
|
/* DSDT */
|
||||||
static void
|
static void
|
||||||
build_dsdt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info)
|
build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
|
||||||
{
|
{
|
||||||
Aml *scope, *dsdt;
|
Aml *scope, *dsdt;
|
||||||
const MemMapEntry *memmap = guest_info->memmap;
|
const MemMapEntry *memmap = vms->memmap;
|
||||||
const int *irqmap = guest_info->irqmap;
|
const int *irqmap = vms->irqmap;
|
||||||
|
|
||||||
dsdt = init_aml_allocator();
|
dsdt = init_aml_allocator();
|
||||||
/* Reserve space for header */
|
/* Reserve space for header */
|
||||||
|
@ -675,7 +676,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info)
|
||||||
* the RTC ACPI device at all when using UEFI.
|
* the RTC ACPI device at all when using UEFI.
|
||||||
*/
|
*/
|
||||||
scope = aml_scope("\\_SB");
|
scope = aml_scope("\\_SB");
|
||||||
acpi_dsdt_add_cpus(scope, guest_info->smp_cpus);
|
acpi_dsdt_add_cpus(scope, vms->smp_cpus);
|
||||||
acpi_dsdt_add_uart(scope, &memmap[VIRT_UART],
|
acpi_dsdt_add_uart(scope, &memmap[VIRT_UART],
|
||||||
(irqmap[VIRT_UART] + ARM_SPI_BASE));
|
(irqmap[VIRT_UART] + ARM_SPI_BASE));
|
||||||
acpi_dsdt_add_flash(scope, &memmap[VIRT_FLASH]);
|
acpi_dsdt_add_flash(scope, &memmap[VIRT_FLASH]);
|
||||||
|
@ -683,7 +684,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info)
|
||||||
acpi_dsdt_add_virtio(scope, &memmap[VIRT_MMIO],
|
acpi_dsdt_add_virtio(scope, &memmap[VIRT_MMIO],
|
||||||
(irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPORTS);
|
(irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPORTS);
|
||||||
acpi_dsdt_add_pci(scope, memmap, (irqmap[VIRT_PCIE] + ARM_SPI_BASE),
|
acpi_dsdt_add_pci(scope, memmap, (irqmap[VIRT_PCIE] + ARM_SPI_BASE),
|
||||||
guest_info->use_highmem);
|
vms->highmem);
|
||||||
acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO],
|
acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO],
|
||||||
(irqmap[VIRT_GPIO] + ARM_SPI_BASE));
|
(irqmap[VIRT_GPIO] + ARM_SPI_BASE));
|
||||||
acpi_dsdt_add_power_button(scope);
|
acpi_dsdt_add_power_button(scope);
|
||||||
|
@ -710,8 +711,9 @@ struct AcpiBuildState {
|
||||||
} AcpiBuildState;
|
} AcpiBuildState;
|
||||||
|
|
||||||
static
|
static
|
||||||
void virt_acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables)
|
void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)
|
||||||
{
|
{
|
||||||
|
VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
|
||||||
GArray *table_offsets;
|
GArray *table_offsets;
|
||||||
unsigned dsdt, rsdt;
|
unsigned dsdt, rsdt;
|
||||||
GArray *tables_blob = tables->table_data;
|
GArray *tables_blob = tables->table_data;
|
||||||
|
@ -725,32 +727,32 @@ void virt_acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables)
|
||||||
|
|
||||||
/* DSDT is pointed to by FADT */
|
/* DSDT is pointed to by FADT */
|
||||||
dsdt = tables_blob->len;
|
dsdt = tables_blob->len;
|
||||||
build_dsdt(tables_blob, tables->linker, guest_info);
|
build_dsdt(tables_blob, tables->linker, vms);
|
||||||
|
|
||||||
/* FADT MADT GTDT MCFG SPCR pointed to by RSDT */
|
/* FADT MADT GTDT MCFG SPCR pointed to by RSDT */
|
||||||
acpi_add_table(table_offsets, tables_blob);
|
acpi_add_table(table_offsets, tables_blob);
|
||||||
build_fadt(tables_blob, tables->linker, dsdt);
|
build_fadt(tables_blob, tables->linker, dsdt);
|
||||||
|
|
||||||
acpi_add_table(table_offsets, tables_blob);
|
acpi_add_table(table_offsets, tables_blob);
|
||||||
build_madt(tables_blob, tables->linker, guest_info);
|
build_madt(tables_blob, tables->linker, vms);
|
||||||
|
|
||||||
acpi_add_table(table_offsets, tables_blob);
|
acpi_add_table(table_offsets, tables_blob);
|
||||||
build_gtdt(tables_blob, tables->linker);
|
build_gtdt(tables_blob, tables->linker);
|
||||||
|
|
||||||
acpi_add_table(table_offsets, tables_blob);
|
acpi_add_table(table_offsets, tables_blob);
|
||||||
build_mcfg(tables_blob, tables->linker, guest_info);
|
build_mcfg(tables_blob, tables->linker, vms);
|
||||||
|
|
||||||
acpi_add_table(table_offsets, tables_blob);
|
acpi_add_table(table_offsets, tables_blob);
|
||||||
build_spcr(tables_blob, tables->linker, guest_info);
|
build_spcr(tables_blob, tables->linker, vms);
|
||||||
|
|
||||||
if (nb_numa_nodes > 0) {
|
if (nb_numa_nodes > 0) {
|
||||||
acpi_add_table(table_offsets, tables_blob);
|
acpi_add_table(table_offsets, tables_blob);
|
||||||
build_srat(tables_blob, tables->linker, guest_info);
|
build_srat(tables_blob, tables->linker, vms);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (its_class_name() && !guest_info->no_its) {
|
if (its_class_name() && !vmc->no_its) {
|
||||||
acpi_add_table(table_offsets, tables_blob);
|
acpi_add_table(table_offsets, tables_blob);
|
||||||
build_iort(tables_blob, tables->linker, guest_info);
|
build_iort(tables_blob, tables->linker);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* RSDT is pointed to by RSDP */
|
/* RSDT is pointed to by RSDP */
|
||||||
|
@ -789,13 +791,13 @@ static void virt_acpi_build_update(void *build_opaque)
|
||||||
|
|
||||||
acpi_build_tables_init(&tables);
|
acpi_build_tables_init(&tables);
|
||||||
|
|
||||||
virt_acpi_build(build_state->guest_info, &tables);
|
virt_acpi_build(container_of(build_state->guest_info,
|
||||||
|
VirtMachineState, acpi_guest_info), &tables);
|
||||||
|
|
||||||
acpi_ram_update(build_state->table_mr, tables.table_data);
|
acpi_ram_update(build_state->table_mr, tables.table_data);
|
||||||
acpi_ram_update(build_state->rsdp_mr, tables.rsdp);
|
acpi_ram_update(build_state->rsdp_mr, tables.rsdp);
|
||||||
acpi_ram_update(build_state->linker_mr, tables.linker->cmd_blob);
|
acpi_ram_update(build_state->linker_mr, tables.linker->cmd_blob);
|
||||||
|
|
||||||
|
|
||||||
acpi_build_tables_cleanup(&tables, true);
|
acpi_build_tables_cleanup(&tables, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -843,7 +845,7 @@ void virt_acpi_setup(VirtMachineState *vms)
|
||||||
build_state->guest_info = guest_info;
|
build_state->guest_info = guest_info;
|
||||||
|
|
||||||
acpi_build_tables_init(&tables);
|
acpi_build_tables_init(&tables);
|
||||||
virt_acpi_build(build_state->guest_info, &tables);
|
virt_acpi_build(vms, &tables);
|
||||||
|
|
||||||
/* Now expose it all to Guest */
|
/* Now expose it all to Guest */
|
||||||
build_state->table_mr = acpi_add_rom_blob(build_state, tables.table_data,
|
build_state->table_mr = acpi_add_rom_blob(build_state, tables.table_data,
|
||||||
|
|
|
@ -1372,13 +1372,7 @@ static void machvirt_init(MachineState *machine)
|
||||||
create_fw_cfg(vms, &address_space_memory);
|
create_fw_cfg(vms, &address_space_memory);
|
||||||
rom_set_fw(fw_cfg_find());
|
rom_set_fw(fw_cfg_find());
|
||||||
|
|
||||||
guest_info->smp_cpus = smp_cpus;
|
|
||||||
guest_info->fw_cfg = fw_cfg_find();
|
guest_info->fw_cfg = fw_cfg_find();
|
||||||
guest_info->memmap = vms->memmap;
|
|
||||||
guest_info->irqmap = vms->irqmap;
|
|
||||||
guest_info->use_highmem = vms->highmem;
|
|
||||||
guest_info->gic_version = vms->gic_version;
|
|
||||||
guest_info->no_its = vmc->no_its;
|
|
||||||
vms->machine_done.notify = virt_machine_done;
|
vms->machine_done.notify = virt_machine_done;
|
||||||
qemu_add_machine_init_done_notifier(&vms->machine_done);
|
qemu_add_machine_init_done_notifier(&vms->machine_done);
|
||||||
|
|
||||||
|
|
|
@ -78,13 +78,7 @@ typedef struct MemMapEntry {
|
||||||
} MemMapEntry;
|
} MemMapEntry;
|
||||||
|
|
||||||
typedef struct VirtGuestInfo {
|
typedef struct VirtGuestInfo {
|
||||||
int smp_cpus;
|
|
||||||
FWCfgState *fw_cfg;
|
FWCfgState *fw_cfg;
|
||||||
const MemMapEntry *memmap;
|
|
||||||
const int *irqmap;
|
|
||||||
bool use_highmem;
|
|
||||||
int gic_version;
|
|
||||||
bool no_its;
|
|
||||||
} VirtGuestInfo;
|
} VirtGuestInfo;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
Loading…
Reference in New Issue