xref: /qemu/include/hw/loongarch/virt.h (revision 252b8e68994aa48508cf1c7d365967e3850b70bb)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Definitions for loongarch board emulation.
4  *
5  * Copyright (C) 2021 Loongson Technology Corporation Limited
6  */
7 
8 #ifndef HW_LOONGARCH_H
9 #define HW_LOONGARCH_H
10 
11 #include "target/loongarch/cpu.h"
12 #include "hw/boards.h"
13 #include "qemu/queue.h"
14 #include "hw/intc/loongarch_ipi.h"
15 #include "hw/block/flash.h"
16 #include "hw/loongarch/boot.h"
17 
18 #define LOONGARCH_MAX_CPUS      256
19 
20 #define VIRT_FWCFG_BASE         0x1e020000UL
21 #define VIRT_BIOS_BASE          0x1c000000UL
22 #define VIRT_BIOS_SIZE          (16 * MiB)
23 #define VIRT_FLASH_SECTOR_SIZE  (128 * KiB)
24 #define VIRT_FLASH0_BASE        VIRT_BIOS_BASE
25 #define VIRT_FLASH0_SIZE        VIRT_BIOS_SIZE
26 #define VIRT_FLASH1_BASE        0x1d000000UL
27 #define VIRT_FLASH1_SIZE        (16 * MiB)
28 
29 #define VIRT_LOWMEM_BASE        0
30 #define VIRT_LOWMEM_SIZE        0x10000000
31 #define VIRT_HIGHMEM_BASE       0x80000000
32 #define VIRT_GED_EVT_ADDR       0x100e0000
33 #define VIRT_GED_MEM_ADDR       (VIRT_GED_EVT_ADDR + ACPI_GED_EVT_SEL_LEN)
34 #define VIRT_GED_REG_ADDR       (VIRT_GED_MEM_ADDR + MEMORY_HOTPLUG_IO_LEN)
35 
36 #define COMMAND_LINE_SIZE       512
37 
38 extern struct memmap_entry *memmap_table;
39 extern unsigned memmap_entries;
40 
41 struct memmap_entry {
42     uint64_t address;
43     uint64_t length;
44     uint32_t type;
45     uint32_t reserved;
46 };
47 
48 struct LoongArchMachineState {
49     /*< private >*/
50     MachineState parent_obj;
51 
52     MemoryRegion lowmem;
53     MemoryRegion highmem;
54     MemoryRegion bios;
55     bool         bios_loaded;
56     /* State for other subsystems/APIs: */
57     FWCfgState  *fw_cfg;
58     Notifier     machine_done;
59     Notifier     powerdown_notifier;
60     OnOffAuto    acpi;
61     char         *oem_id;
62     char         *oem_table_id;
63     DeviceState  *acpi_ged;
64     int          fdt_size;
65     DeviceState *platform_bus_dev;
66     PCIBus       *pci_bus;
67     PFlashCFI01  *flash[2];
68     MemoryRegion system_iocsr;
69     MemoryRegion iocsr_mem;
70     AddressSpace as_iocsr;
71     struct loongarch_boot_info bootinfo;
72 };
73 
74 #define TYPE_LOONGARCH_MACHINE  MACHINE_TYPE_NAME("virt")
75 OBJECT_DECLARE_SIMPLE_TYPE(LoongArchMachineState, LOONGARCH_MACHINE)
76 bool loongarch_is_acpi_enabled(LoongArchMachineState *lams);
77 void loongarch_acpi_setup(LoongArchMachineState *lams);
78 #endif
79