]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - GRUB2/MOD_SRC/grub-2.04/include/grub/mips64/efi/loongson.h
Disable Fn/L/Ctrl hotkeys on select WIM menu.
[Ventoy.git] / GRUB2 / MOD_SRC / grub-2.04 / include / grub / mips64 / efi / loongson.h
1 /*
2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2017 Free Software Foundation, Inc.
4 *
5 * GRUB is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * GRUB is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #ifndef GRUB_EFI_LOONGSON_HEADER
20 #define GRUB_EFI_LOONGSON_HEADER 1
21
22 #include <grub/types.h>
23
24 #include <grub/efi/api.h>
25
26 #define GRUB_EFI_LOONGSON_SMBIOS_TABLE_GUID \
27 { 0x4660f721, 0x2ec5, 0x416a, \
28 { 0x89, 0x9a, 0x43, 0x18, 0x02, 0x50, 0xa0, 0xc9 } \
29 }
30
31 #define GRUB_EFI_LOONGSON_MMAP_MAX 128
32 typedef enum
33 {
34 GRUB_EFI_LOONGSON_SYSTEM_RAM_LOW = 1,
35 GRUB_EFI_LOONGSON_SYSTEM_RAM_HIGH,
36 GRUB_EFI_LOONGSON_MEMORY_RESERVED,
37 GRUB_EFI_LOONGSON_PCI_IO,
38 GRUB_EFI_LOONGSON_PCI_MEM,
39 GRUB_EFI_LOONGSON_CFG_REG,
40 GRUB_EFI_LOONGSON_VIDEO_ROM,
41 GRUB_EFI_LOONGSON_ADAPTER_ROM,
42 GRUB_EFI_LOONGSON_ACPI_TABLE,
43 GRUB_EFI_LOONGSON_SMBIOS_TABLE,
44 GRUB_EFI_LOONGSON_UMA_VIDEO_RAM,
45 GRUB_EFI_LOONGSON_VUMA_VIDEO_RAM,
46 GRUB_EFI_LOONGSON_SYSTEM_RAM_LOW_DMA,
47 GRUB_EFI_LOONGSON_SYSTEM_RAM_HIGH_DMA,
48 GRUB_EFI_LOONGSON_ACPI_NVS,
49 GRUB_EFI_LOONGSON_MAX_MEMORY_TYPE
50 }
51 grub_efi_loongson_memory_type;
52
53 typedef struct
54 {
55 grub_uint16_t vers; /* version */
56 grub_uint32_t nr_map; /* number of memory_maps */
57 grub_uint32_t mem_freq; /* memory frequence */
58 struct mem_map {
59 grub_uint32_t node_id; /* node_id which memory attached to */
60 grub_uint32_t mem_type; /* system memory, pci memory, pci io, etc. */
61 grub_uint64_t mem_start; /* memory map start address */
62 grub_uint32_t mem_size; /* each memory_map size, not the total size */
63 } map[GRUB_EFI_LOONGSON_MMAP_MAX];
64 } GRUB_PACKED
65 grub_efi_loongson_memory_map;
66
67 /*
68 * Capability and feature descriptor structure for MIPS CPU
69 */
70 typedef struct
71 {
72 grub_uint16_t vers; /* version */
73 grub_uint32_t processor_id; /* PRID, e.g. 6305, 6306 */
74 grub_uint32_t cputype; /* Loongson_3A/3B, etc. */
75 grub_uint32_t total_node; /* num of total numa nodes */
76 grub_uint16_t cpu_startup_core_id; /* Boot core id */
77 grub_uint16_t reserved_cores_mask;
78 grub_uint32_t cpu_clock_freq; /* cpu_clock */
79 grub_uint32_t nr_cpus;
80 } GRUB_PACKED
81 grub_efi_loongson_cpu_info;
82
83 #define GRUB_EFI_LOONGSON_MAX_UARTS 64
84
85 typedef struct
86 {
87 grub_uint32_t iotype; /* see include/linux/serial_core.h */
88 grub_uint32_t uartclk;
89 grub_uint32_t int_offset;
90 grub_uint64_t uart_base;
91 } GRUB_PACKED
92 grub_efi_loongson_uart_device;
93
94 #define GRUB_EFI_LOONGSON_MAX_SENSORS 64
95
96 typedef struct
97 {
98 char name[32]; /* a formal name */
99 char label[64]; /* a flexible description */
100 grub_uint32_t type; /* SENSOR_* */
101 grub_uint32_t id; /* instance id of a sensor-class */
102 grub_uint32_t fan_policy;
103 grub_uint32_t fan_percent; /* only for constant speed policy */
104 grub_uint64_t base_addr; /* base address of device registers */
105 } GRUB_PACKED
106 grub_efi_loongson_sensor_device;
107
108 typedef struct
109 {
110 grub_uint16_t vers; /* version */
111 grub_uint32_t ccnuma_smp; /* 0: no numa; 1: has numa */
112 grub_uint32_t sing_double_channel; /* 1:single; 2:double */
113 grub_uint32_t nr_uarts;
114 grub_efi_loongson_uart_device uarts[GRUB_EFI_LOONGSON_MAX_UARTS];
115 grub_uint32_t nr_sensors;
116 grub_efi_loongson_sensor_device sensors[GRUB_EFI_LOONGSON_MAX_SENSORS];
117 char has_ec;
118 char ec_name[32];
119 grub_uint64_t ec_base_addr;
120 char has_tcm;
121 char tcm_name[32];
122 grub_uint64_t tcm_base_addr;
123 grub_uint64_t workarounds; /* see workarounds.h */
124 } GRUB_PACKED
125 grub_efi_loongson_system_info;
126
127 typedef struct
128 {
129 grub_uint16_t vers;
130 grub_uint16_t size;
131 grub_uint16_t rtr_bus;
132 grub_uint16_t rtr_devfn;
133 grub_uint32_t vendor;
134 grub_uint32_t device;
135 grub_uint32_t PIC_type; /* conform use HT or PCI to route to CPU-PIC */
136 grub_uint64_t ht_int_bit; /* 3A: 1<<24; 3B: 1<<16 */
137 grub_uint64_t ht_enable; /* irqs used in this PIC */
138 grub_uint32_t node_id; /* node id: 0x0-0; 0x1-1; 0x10-2; 0x11-3 */
139 grub_uint64_t pci_mem_start_addr;
140 grub_uint64_t pci_mem_end_addr;
141 grub_uint64_t pci_io_start_addr;
142 grub_uint64_t pci_io_end_addr;
143 grub_uint64_t pci_config_addr;
144 grub_uint32_t dma_mask_bits;
145 } GRUB_PACKED
146 grub_efi_loongson_irq_src_routing_table;
147
148 typedef struct
149 {
150 grub_uint16_t vers; /* version */
151 grub_uint16_t size;
152 grub_uint8_t flag;
153 char description[64];
154 } GRUB_PACKED
155 grub_efi_loongson_interface_info;
156
157 #define GRUB_EFI_LOONGSON_MAX_RESOURCE_NUMBER 128
158
159 typedef struct
160 {
161 grub_uint64_t start; /* resource start address */
162 grub_uint64_t end; /* resource end address */
163 char name[64];
164 grub_uint32_t flags;
165 }
166 grub_efi_loongson_resource;
167
168 /* arch specific additions */
169 typedef struct
170 {
171 }
172 grub_efi_loongson_archdev_data;
173
174 typedef struct
175 {
176 char name[64]; /* hold the device name */
177 grub_uint32_t num_resources; /* number of device_resource */
178 /* for each device's resource */
179 grub_efi_loongson_resource resource[GRUB_EFI_LOONGSON_MAX_RESOURCE_NUMBER];
180 /* arch specific additions */
181 grub_efi_loongson_archdev_data archdata;
182 }
183 grub_efi_loongson_board_devices;
184
185 typedef struct
186 {
187 grub_uint16_t vers; /* version */
188 char special_name[64]; /* special_atribute_name */
189 grub_uint32_t loongson_special_type; /* type of special device */
190 /* for each device's resource */
191 grub_efi_loongson_resource resource[GRUB_EFI_LOONGSON_MAX_RESOURCE_NUMBER];
192 }
193 grub_efi_loongson_special_attribute;
194
195 typedef struct
196 {
197 grub_uint64_t memory_offset; /* efi_loongson_memory_map struct offset */
198 grub_uint64_t cpu_offset; /* efi_loongson_cpuinfo struct offset */
199 grub_uint64_t system_offset; /* efi_loongson_system_info struct offset */
200 grub_uint64_t irq_offset; /* efi_loongson_irq_src_routing_table struct offset */
201 grub_uint64_t interface_offset; /* interface_info struct offset */
202 grub_uint64_t special_offset; /* efi_loongson_special_attribute struct offset */
203 grub_uint64_t boarddev_table_offset; /* efi_loongson_board_devices offset */
204 }
205 grub_efi_loongson_params;
206
207 typedef struct
208 {
209 grub_uint16_t vers; /* version */
210 grub_uint64_t vga_bios; /* vga_bios address */
211 grub_efi_loongson_params lp;
212 }
213 grub_efi_loongson_smbios_table;
214
215 typedef struct
216 {
217 grub_uint64_t reset_cold;
218 grub_uint64_t reset_warm;
219 grub_uint64_t reset_type;
220 grub_uint64_t shutdown;
221 grub_uint64_t do_suspend; /* NULL if not support */
222 }
223 grub_efi_loongson_reset_system;
224
225 typedef struct
226 {
227 grub_uint64_t mps; /* MPS table */
228 grub_uint64_t acpi; /* ACPI table (IA64 ext 0.71) */
229 grub_uint64_t acpi20; /* ACPI table (ACPI 2.0) */
230 grub_efi_loongson_smbios_table smbios; /* SM BIOS table */
231 grub_uint64_t sal_systab; /* SAL system table */
232 grub_uint64_t boot_info; /* boot info table */
233 }
234 grub_efi_loongson;
235
236 typedef struct
237 {
238 grub_efi_loongson efi;
239 grub_efi_loongson_reset_system reset_system;
240 }
241 grub_efi_loongson_boot_params;
242
243 extern grub_uint64_t grub_efi_loongson_reset_system_addr;
244
245 extern void grub_efi_loongson_reset_cold (void);
246 extern void grub_efi_loongson_reset_warm (void);
247 extern void grub_efi_loongson_reset_shutdown (void);
248 extern void grub_efi_loongson_reset_suspend (void);
249
250 void grub_efi_loongson_init (void);
251 void grub_efi_loongson_fini (void);
252 void grub_efi_loongson_alloc_boot_params (void);
253 void grub_efi_loongson_free_boot_params (void);
254 void * grub_efi_loongson_get_smbios_table (void);
255
256 int EXPORT_FUNC(grub_efi_is_loongson) (void);
257
258 grub_uint8_t
259 EXPORT_FUNC(grub_efi_loongson_calculatesum8) (const grub_uint8_t *Buffer, grub_efi_uintn_t Length);
260
261 grub_uint8_t
262 EXPORT_FUNC(grub_efi_loongson_grub_calculatechecksum8) (const grub_uint8_t *Buffer, grub_efi_uintn_t Length);
263
264
265 void *
266 EXPORT_FUNC(grub_efi_loongson_get_boot_params) (void);
267
268 typedef struct _extention_list_hdr{
269 grub_uint64_t signature;
270 grub_uint32_t length;
271 grub_uint8_t revision;
272 grub_uint8_t checksum;
273 struct _extention_list_hdr *next;
274 }GRUB_PACKED
275 ext_list;
276
277 typedef struct bootparamsinterface {
278 grub_uint64_t signature; //{'B', 'P', 'I', '_', '0', '_', '1'}
279 grub_efi_system_table_t *systemtable;
280 ext_list *extlist;
281 }GRUB_PACKED
282 bootparamsinterface;
283
284 typedef struct {
285 ext_list header; // {'M', 'E', 'M'}
286 grub_uint8_t mapcount;
287 struct GRUB_PACKED memmap {
288 grub_uint32_t memtype;
289 grub_uint64_t memstart;
290 grub_uint64_t memsize;
291 } map[GRUB_EFI_LOONGSON_MMAP_MAX];
292 }GRUB_PACKED
293 mem_map;
294
295 typedef struct {
296 ext_list header; // {VBIOS}
297 grub_uint64_t vbiosaddr;
298 }GRUB_PACKED
299 vbios;
300
301 grub_uint32_t
302 EXPORT_FUNC (grub_efi_loongson_memmap_sort) (struct memmap array[], grub_uint32_t length, mem_map * bpmem, grub_uint32_t index, grub_uint32_t memtype);
303 #endif /* ! GRUB_EFI_LOONGSON_HEADER */