mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 17:23:56 -06:00
hw/loongarch: Rename LoongArchMachineState with LoongArchVirtMachineState
Rename LoongArchMachineState with LoongArchVirtMachineState, and change variable name LoongArchMachineState *lams with LoongArchVirtMachineState *lvms. Rename function specific for virtmachine loongarch_xxx() with virt_xxx(). However some common functions keep unchanged such as loongarch_acpi_setup()/loongarch_load_kernel(), since there functions can be used for real hw boards. Signed-off-by: Bibo Mao <maobibo@loongson.cn> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-ID: <20240508031110.2507477-3-maobibo@loongson.cn> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
This commit is contained in:
parent
df0d93c1e2
commit
d804ad98f5
6 changed files with 226 additions and 224 deletions
|
@ -105,14 +105,15 @@ build_facs(GArray *table_data)
|
|||
|
||||
/* build MADT */
|
||||
static void
|
||||
build_madt(GArray *table_data, BIOSLinker *linker, LoongArchMachineState *lams)
|
||||
build_madt(GArray *table_data, BIOSLinker *linker,
|
||||
LoongArchVirtMachineState *lvms)
|
||||
{
|
||||
MachineState *ms = MACHINE(lams);
|
||||
MachineState *ms = MACHINE(lvms);
|
||||
MachineClass *mc = MACHINE_GET_CLASS(ms);
|
||||
const CPUArchIdList *arch_ids = mc->possible_cpu_arch_ids(ms);
|
||||
int i, arch_id;
|
||||
AcpiTable table = { .sig = "APIC", .rev = 1, .oem_id = lams->oem_id,
|
||||
.oem_table_id = lams->oem_table_id };
|
||||
AcpiTable table = { .sig = "APIC", .rev = 1, .oem_id = lvms->oem_id,
|
||||
.oem_table_id = lvms->oem_table_id };
|
||||
|
||||
acpi_table_begin(&table, table_data);
|
||||
|
||||
|
@ -167,11 +168,11 @@ build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine)
|
|||
int i, arch_id, node_id;
|
||||
uint64_t mem_len, mem_base;
|
||||
int nb_numa_nodes = machine->numa_state->num_nodes;
|
||||
LoongArchMachineState *lams = LOONGARCH_VIRT_MACHINE(machine);
|
||||
MachineClass *mc = MACHINE_GET_CLASS(lams);
|
||||
LoongArchVirtMachineState *lvms = LOONGARCH_VIRT_MACHINE(machine);
|
||||
MachineClass *mc = MACHINE_GET_CLASS(lvms);
|
||||
const CPUArchIdList *arch_ids = mc->possible_cpu_arch_ids(machine);
|
||||
AcpiTable table = { .sig = "SRAT", .rev = 1, .oem_id = lams->oem_id,
|
||||
.oem_table_id = lams->oem_table_id };
|
||||
AcpiTable table = { .sig = "SRAT", .rev = 1, .oem_id = lvms->oem_id,
|
||||
.oem_table_id = lvms->oem_table_id };
|
||||
|
||||
acpi_table_begin(&table, table_data);
|
||||
build_append_int_noprefix(table_data, 1, 4); /* Reserved */
|
||||
|
@ -279,13 +280,13 @@ static void
|
|||
build_la_ged_aml(Aml *dsdt, MachineState *machine)
|
||||
{
|
||||
uint32_t event;
|
||||
LoongArchMachineState *lams = LOONGARCH_VIRT_MACHINE(machine);
|
||||
LoongArchVirtMachineState *lvms = LOONGARCH_VIRT_MACHINE(machine);
|
||||
|
||||
build_ged_aml(dsdt, "\\_SB."GED_DEVICE,
|
||||
HOTPLUG_HANDLER(lams->acpi_ged),
|
||||
HOTPLUG_HANDLER(lvms->acpi_ged),
|
||||
VIRT_SCI_IRQ, AML_SYSTEM_MEMORY,
|
||||
VIRT_GED_EVT_ADDR);
|
||||
event = object_property_get_uint(OBJECT(lams->acpi_ged),
|
||||
event = object_property_get_uint(OBJECT(lvms->acpi_ged),
|
||||
"ged-event", &error_abort);
|
||||
if (event & ACPI_GED_MEM_HOTPLUG_EVT) {
|
||||
build_memory_hotplug_aml(dsdt, machine->ram_slots, "\\_SB", NULL,
|
||||
|
@ -295,7 +296,7 @@ build_la_ged_aml(Aml *dsdt, MachineState *machine)
|
|||
acpi_dsdt_add_power_button(dsdt);
|
||||
}
|
||||
|
||||
static void build_pci_device_aml(Aml *scope, LoongArchMachineState *lams)
|
||||
static void build_pci_device_aml(Aml *scope, LoongArchVirtMachineState *lvms)
|
||||
{
|
||||
struct GPEXConfig cfg = {
|
||||
.mmio64.base = VIRT_PCI_MEM_BASE,
|
||||
|
@ -305,13 +306,13 @@ static void build_pci_device_aml(Aml *scope, LoongArchMachineState *lams)
|
|||
.ecam.base = VIRT_PCI_CFG_BASE,
|
||||
.ecam.size = VIRT_PCI_CFG_SIZE,
|
||||
.irq = VIRT_GSI_BASE + VIRT_DEVICE_IRQS,
|
||||
.bus = lams->pci_bus,
|
||||
.bus = lvms->pci_bus,
|
||||
};
|
||||
|
||||
acpi_dsdt_add_gpex(scope, &cfg);
|
||||
}
|
||||
|
||||
static void build_flash_aml(Aml *scope, LoongArchMachineState *lams)
|
||||
static void build_flash_aml(Aml *scope, LoongArchVirtMachineState *lvms)
|
||||
{
|
||||
Aml *dev, *crs;
|
||||
MemoryRegion *flash_mem;
|
||||
|
@ -322,11 +323,11 @@ static void build_flash_aml(Aml *scope, LoongArchMachineState *lams)
|
|||
hwaddr flash1_base;
|
||||
hwaddr flash1_size;
|
||||
|
||||
flash_mem = pflash_cfi01_get_memory(lams->flash[0]);
|
||||
flash_mem = pflash_cfi01_get_memory(lvms->flash[0]);
|
||||
flash0_base = flash_mem->addr;
|
||||
flash0_size = memory_region_size(flash_mem);
|
||||
|
||||
flash_mem = pflash_cfi01_get_memory(lams->flash[1]);
|
||||
flash_mem = pflash_cfi01_get_memory(lvms->flash[1]);
|
||||
flash1_base = flash_mem->addr;
|
||||
flash1_size = memory_region_size(flash_mem);
|
||||
|
||||
|
@ -352,7 +353,7 @@ static void build_flash_aml(Aml *scope, LoongArchMachineState *lams)
|
|||
}
|
||||
|
||||
#ifdef CONFIG_TPM
|
||||
static void acpi_dsdt_add_tpm(Aml *scope, LoongArchMachineState *vms)
|
||||
static void acpi_dsdt_add_tpm(Aml *scope, LoongArchVirtMachineState *vms)
|
||||
{
|
||||
PlatformBusDevice *pbus = PLATFORM_BUS_DEVICE(vms->platform_bus_dev);
|
||||
hwaddr pbus_base = VIRT_PLATFORM_BUS_BASEADDRESS;
|
||||
|
@ -391,18 +392,18 @@ static void
|
|||
build_dsdt(GArray *table_data, BIOSLinker *linker, MachineState *machine)
|
||||
{
|
||||
Aml *dsdt, *scope, *pkg;
|
||||
LoongArchMachineState *lams = LOONGARCH_VIRT_MACHINE(machine);
|
||||
AcpiTable table = { .sig = "DSDT", .rev = 1, .oem_id = lams->oem_id,
|
||||
.oem_table_id = lams->oem_table_id };
|
||||
LoongArchVirtMachineState *lvms = LOONGARCH_VIRT_MACHINE(machine);
|
||||
AcpiTable table = { .sig = "DSDT", .rev = 1, .oem_id = lvms->oem_id,
|
||||
.oem_table_id = lvms->oem_table_id };
|
||||
|
||||
acpi_table_begin(&table, table_data);
|
||||
dsdt = init_aml_allocator();
|
||||
build_uart_device_aml(dsdt);
|
||||
build_pci_device_aml(dsdt, lams);
|
||||
build_pci_device_aml(dsdt, lvms);
|
||||
build_la_ged_aml(dsdt, machine);
|
||||
build_flash_aml(dsdt, lams);
|
||||
build_flash_aml(dsdt, lvms);
|
||||
#ifdef CONFIG_TPM
|
||||
acpi_dsdt_add_tpm(dsdt, lams);
|
||||
acpi_dsdt_add_tpm(dsdt, lvms);
|
||||
#endif
|
||||
/* System State Package */
|
||||
scope = aml_scope("\\");
|
||||
|
@ -421,7 +422,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, MachineState *machine)
|
|||
|
||||
static void acpi_build(AcpiBuildTables *tables, MachineState *machine)
|
||||
{
|
||||
LoongArchMachineState *lams = LOONGARCH_VIRT_MACHINE(machine);
|
||||
LoongArchVirtMachineState *lvms = LOONGARCH_VIRT_MACHINE(machine);
|
||||
GArray *table_offsets;
|
||||
AcpiFadtData fadt_data;
|
||||
unsigned facs, rsdt, dsdt;
|
||||
|
@ -455,14 +456,14 @@ static void acpi_build(AcpiBuildTables *tables, MachineState *machine)
|
|||
fadt_data.dsdt_tbl_offset = &dsdt;
|
||||
fadt_data.xdsdt_tbl_offset = &dsdt;
|
||||
build_fadt(tables_blob, tables->linker, &fadt_data,
|
||||
lams->oem_id, lams->oem_table_id);
|
||||
lvms->oem_id, lvms->oem_table_id);
|
||||
|
||||
acpi_add_table(table_offsets, tables_blob);
|
||||
build_madt(tables_blob, tables->linker, lams);
|
||||
build_madt(tables_blob, tables->linker, lvms);
|
||||
|
||||
acpi_add_table(table_offsets, tables_blob);
|
||||
build_pptt(tables_blob, tables->linker, machine,
|
||||
lams->oem_id, lams->oem_table_id);
|
||||
lvms->oem_id, lvms->oem_table_id);
|
||||
|
||||
acpi_add_table(table_offsets, tables_blob);
|
||||
build_srat(tables_blob, tables->linker, machine);
|
||||
|
@ -470,13 +471,13 @@ static void acpi_build(AcpiBuildTables *tables, MachineState *machine)
|
|||
if (machine->numa_state->num_nodes) {
|
||||
if (machine->numa_state->have_numa_distance) {
|
||||
acpi_add_table(table_offsets, tables_blob);
|
||||
build_slit(tables_blob, tables->linker, machine, lams->oem_id,
|
||||
lams->oem_table_id);
|
||||
build_slit(tables_blob, tables->linker, machine, lvms->oem_id,
|
||||
lvms->oem_table_id);
|
||||
}
|
||||
if (machine->numa_state->hmat_enabled) {
|
||||
acpi_add_table(table_offsets, tables_blob);
|
||||
build_hmat(tables_blob, tables->linker, machine->numa_state,
|
||||
lams->oem_id, lams->oem_table_id);
|
||||
lvms->oem_id, lvms->oem_table_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -486,8 +487,8 @@ static void acpi_build(AcpiBuildTables *tables, MachineState *machine)
|
|||
.base = cpu_to_le64(VIRT_PCI_CFG_BASE),
|
||||
.size = cpu_to_le64(VIRT_PCI_CFG_SIZE),
|
||||
};
|
||||
build_mcfg(tables_blob, tables->linker, &mcfg, lams->oem_id,
|
||||
lams->oem_table_id);
|
||||
build_mcfg(tables_blob, tables->linker, &mcfg, lvms->oem_id,
|
||||
lvms->oem_table_id);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_TPM
|
||||
|
@ -495,8 +496,8 @@ static void acpi_build(AcpiBuildTables *tables, MachineState *machine)
|
|||
if (tpm_get_version(tpm_find()) == TPM_VERSION_2_0) {
|
||||
acpi_add_table(table_offsets, tables_blob);
|
||||
build_tpm2(tables_blob, tables->linker,
|
||||
tables->tcpalog, lams->oem_id,
|
||||
lams->oem_table_id);
|
||||
tables->tcpalog, lvms->oem_id,
|
||||
lvms->oem_table_id);
|
||||
}
|
||||
#endif
|
||||
/* Add tables supplied by user (if any) */
|
||||
|
@ -510,13 +511,13 @@ static void acpi_build(AcpiBuildTables *tables, MachineState *machine)
|
|||
/* RSDT is pointed to by RSDP */
|
||||
rsdt = tables_blob->len;
|
||||
build_rsdt(tables_blob, tables->linker, table_offsets,
|
||||
lams->oem_id, lams->oem_table_id);
|
||||
lvms->oem_id, lvms->oem_table_id);
|
||||
|
||||
/* RSDP is in FSEG memory, so allocate it separately */
|
||||
{
|
||||
AcpiRsdpData rsdp_data = {
|
||||
.revision = 0,
|
||||
.oem_id = lams->oem_id,
|
||||
.oem_id = lvms->oem_id,
|
||||
.xsdt_tbl_offset = NULL,
|
||||
.rsdt_tbl_offset = &rsdt,
|
||||
};
|
||||
|
@ -593,17 +594,25 @@ static const VMStateDescription vmstate_acpi_build = {
|
|||
},
|
||||
};
|
||||
|
||||
void loongarch_acpi_setup(LoongArchMachineState *lams)
|
||||
static bool loongarch_is_acpi_enabled(LoongArchVirtMachineState *lvms)
|
||||
{
|
||||
if (lvms->acpi == ON_OFF_AUTO_OFF) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void loongarch_acpi_setup(LoongArchVirtMachineState *lvms)
|
||||
{
|
||||
AcpiBuildTables tables;
|
||||
AcpiBuildState *build_state;
|
||||
|
||||
if (!lams->fw_cfg) {
|
||||
if (!lvms->fw_cfg) {
|
||||
ACPI_BUILD_DPRINTF("No fw cfg. Bailing out.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!loongarch_is_acpi_enabled(lams)) {
|
||||
if (!loongarch_is_acpi_enabled(lvms)) {
|
||||
ACPI_BUILD_DPRINTF("ACPI disabled. Bailing out.\n");
|
||||
return;
|
||||
}
|
||||
|
@ -611,7 +620,7 @@ void loongarch_acpi_setup(LoongArchMachineState *lams)
|
|||
build_state = g_malloc0(sizeof *build_state);
|
||||
|
||||
acpi_build_tables_init(&tables);
|
||||
acpi_build(&tables, MACHINE(lams));
|
||||
acpi_build(&tables, MACHINE(lvms));
|
||||
|
||||
/* Now expose it all to Guest */
|
||||
build_state->table_mr = acpi_add_rom_blob(acpi_build_update,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue