1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22#ifndef HW_MIPS_LOONGSON3_BOOTP_H
23#define HW_MIPS_LOONGSON3_BOOTP_H
24
25struct efi_memory_map_loongson {
26 uint16_t vers;
27 uint32_t nr_map;
28 uint32_t mem_freq;
29 struct mem_map {
30 uint32_t node_id;
31 uint32_t mem_type;
32 uint64_t mem_start;
33 uint32_t mem_size;
34 } map[128];
35} QEMU_PACKED;
36
37enum loongson_cpu_type {
38 Legacy_2E = 0x0,
39 Legacy_2F = 0x1,
40 Legacy_3A = 0x2,
41 Legacy_3B = 0x3,
42 Legacy_1A = 0x4,
43 Legacy_1B = 0x5,
44 Legacy_2G = 0x6,
45 Legacy_2H = 0x7,
46 Loongson_1A = 0x100,
47 Loongson_1B = 0x101,
48 Loongson_2E = 0x200,
49 Loongson_2F = 0x201,
50 Loongson_2G = 0x202,
51 Loongson_2H = 0x203,
52 Loongson_3A = 0x300,
53 Loongson_3B = 0x301
54};
55
56
57
58
59struct efi_cpuinfo_loongson {
60 uint16_t vers;
61 uint32_t processor_id;
62 uint32_t cputype;
63 uint32_t total_node;
64 uint16_t cpu_startup_core_id;
65 uint16_t reserved_cores_mask;
66 uint32_t cpu_clock_freq;
67 uint32_t nr_cpus;
68 char cpuname[64];
69} QEMU_PACKED;
70
71#define MAX_UARTS 64
72struct uart_device {
73 uint32_t iotype;
74 uint32_t uartclk;
75 uint32_t int_offset;
76 uint64_t uart_base;
77} QEMU_PACKED;
78
79#define MAX_SENSORS 64
80#define SENSOR_TEMPER 0x00000001
81#define SENSOR_VOLTAGE 0x00000002
82#define SENSOR_FAN 0x00000004
83struct sensor_device {
84 char name[32];
85 char label[64];
86 uint32_t type;
87 uint32_t id;
88 uint32_t fan_policy;
89 uint32_t fan_percent;
90 uint64_t base_addr;
91} QEMU_PACKED;
92
93struct system_loongson {
94 uint16_t vers;
95 uint32_t ccnuma_smp;
96 uint32_t sing_double_channel;
97 uint32_t nr_uarts;
98 struct uart_device uarts[MAX_UARTS];
99 uint32_t nr_sensors;
100 struct sensor_device sensors[MAX_SENSORS];
101 char has_ec;
102 char ec_name[32];
103 uint64_t ec_base_addr;
104 char has_tcm;
105 char tcm_name[32];
106 uint64_t tcm_base_addr;
107 uint64_t workarounds;
108 uint64_t of_dtb_addr;
109} QEMU_PACKED;
110
111struct irq_source_routing_table {
112 uint16_t vers;
113 uint16_t size;
114 uint16_t rtr_bus;
115 uint16_t rtr_devfn;
116 uint32_t vendor;
117 uint32_t device;
118 uint32_t PIC_type;
119 uint64_t ht_int_bit;
120 uint64_t ht_enable;
121 uint32_t node_id;
122 uint64_t pci_mem_start_addr;
123 uint64_t pci_mem_end_addr;
124 uint64_t pci_io_start_addr;
125 uint64_t pci_io_end_addr;
126 uint64_t pci_config_addr;
127 uint16_t dma_mask_bits;
128 uint16_t dma_noncoherent;
129} QEMU_PACKED;
130
131struct interface_info {
132 uint16_t vers;
133 uint16_t size;
134 uint8_t flag;
135 char description[64];
136} QEMU_PACKED;
137
138#define MAX_RESOURCE_NUMBER 128
139struct resource_loongson {
140 uint64_t start;
141 uint64_t end;
142 char name[64];
143 uint32_t flags;
144};
145
146struct archdev_data {};
147
148struct board_devices {
149 char name[64];
150 uint32_t num_resources;
151
152 struct resource_loongson resource[MAX_RESOURCE_NUMBER];
153
154 struct archdev_data archdata;
155};
156
157struct loongson_special_attribute {
158 uint16_t vers;
159 char special_name[64];
160 uint32_t loongson_special_type;
161
162 struct resource_loongson resource[MAX_RESOURCE_NUMBER];
163};
164
165struct loongson_params {
166 uint64_t memory_offset;
167 uint64_t cpu_offset;
168 uint64_t system_offset;
169 uint64_t irq_offset;
170 uint64_t interface_offset;
171 uint64_t special_offset;
172 uint64_t boarddev_table_offset;
173};
174
175struct smbios_tables {
176 uint16_t vers;
177 uint64_t vga_bios;
178 struct loongson_params lp;
179};
180
181struct efi_reset_system_t {
182 uint64_t ResetCold;
183 uint64_t ResetWarm;
184 uint64_t ResetType;
185 uint64_t Shutdown;
186 uint64_t DoSuspend;
187};
188
189struct efi_loongson {
190 uint64_t mps;
191 uint64_t acpi;
192 uint64_t acpi20;
193 struct smbios_tables smbios;
194 uint64_t sal_systab;
195 uint64_t boot_info;
196};
197
198struct boot_params {
199 struct efi_loongson efi;
200 struct efi_reset_system_t reset_system;
201};
202
203
204enum {
205 VIRT_LOWMEM,
206 VIRT_PM,
207 VIRT_FW_CFG,
208 VIRT_RTC,
209 VIRT_PCIE_PIO,
210 VIRT_PCIE_ECAM,
211 VIRT_BIOS_ROM,
212 VIRT_UART,
213 VIRT_LIOINTC,
214 VIRT_PCIE_MMIO,
215 VIRT_HIGHMEM
216};
217
218
219enum {
220 LOADER_KERNEL,
221 LOADER_INITRD,
222 LOADER_CMDLINE
223};
224
225
226enum {
227 LOADER_BOOTROM,
228 LOADER_PARAM,
229};
230
231extern const MemMapEntry virt_memmap[];
232void init_loongson_params(struct loongson_params *lp, void *p,
233 uint64_t cpu_freq, uint64_t ram_size);
234void init_reset_system(struct efi_reset_system_t *reset);
235
236#endif
237