2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2017 Free Software Foundation, Inc.
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.
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.
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/>.
19 #ifndef GRUB_EFI_LOONGSON_HEADER
20 #define GRUB_EFI_LOONGSON_HEADER 1
22 #include <grub/types.h>
24 #include <grub/efi/api.h>
26 #define GRUB_EFI_LOONGSON_SMBIOS_TABLE_GUID \
27 { 0x4660f721, 0x2ec5, 0x416a, \
28 { 0x89, 0x9a, 0x43, 0x18, 0x02, 0x50, 0xa0, 0xc9 } \
31 #define GRUB_EFI_LOONGSON_MMAP_MAX 128
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
51 grub_efi_loongson_memory_type
;
55 grub_uint16_t vers
; /* version */
56 grub_uint32_t nr_map
; /* number of memory_maps */
57 grub_uint32_t mem_freq
; /* memory frequence */
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
];
65 grub_efi_loongson_memory_map
;
68 * Capability and feature descriptor structure for MIPS CPU
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
;
81 grub_efi_loongson_cpu_info
;
83 #define GRUB_EFI_LOONGSON_MAX_UARTS 64
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
;
92 grub_efi_loongson_uart_device
;
94 #define GRUB_EFI_LOONGSON_MAX_SENSORS 64
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 */
106 grub_efi_loongson_sensor_device
;
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
];
119 grub_uint64_t ec_base_addr
;
122 grub_uint64_t tcm_base_addr
;
123 grub_uint64_t workarounds
; /* see workarounds.h */
125 grub_efi_loongson_system_info
;
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
;
146 grub_efi_loongson_irq_src_routing_table
;
150 grub_uint16_t vers
; /* version */
153 char description
[64];
155 grub_efi_loongson_interface_info
;
157 #define GRUB_EFI_LOONGSON_MAX_RESOURCE_NUMBER 128
161 grub_uint64_t start
; /* resource start address */
162 grub_uint64_t end
; /* resource end address */
166 grub_efi_loongson_resource
;
168 /* arch specific additions */
172 grub_efi_loongson_archdev_data
;
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
;
183 grub_efi_loongson_board_devices
;
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
];
193 grub_efi_loongson_special_attribute
;
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 */
205 grub_efi_loongson_params
;
209 grub_uint16_t vers
; /* version */
210 grub_uint64_t vga_bios
; /* vga_bios address */
211 grub_efi_loongson_params lp
;
213 grub_efi_loongson_smbios_table
;
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 */
223 grub_efi_loongson_reset_system
;
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 */
238 grub_efi_loongson efi
;
239 grub_efi_loongson_reset_system reset_system
;
241 grub_efi_loongson_boot_params
;
243 extern grub_uint64_t grub_efi_loongson_reset_system_addr
;
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);
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);
256 int EXPORT_FUNC(grub_efi_is_loongson
) (void);
259 EXPORT_FUNC(grub_efi_loongson_calculatesum8
) (const grub_uint8_t
*Buffer
, grub_efi_uintn_t Length
);
262 EXPORT_FUNC(grub_efi_loongson_grub_calculatechecksum8
) (const grub_uint8_t
*Buffer
, grub_efi_uintn_t Length
);
266 EXPORT_FUNC(grub_efi_loongson_get_boot_params
) (void);
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
;
277 typedef struct bootparamsinterface
{
278 grub_uint64_t signature
; //{'B', 'P', 'I', '_', '0', '_', '1'}
279 grub_efi_system_table_t
*systemtable
;
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
];
296 ext_list header
; // {VBIOS}
297 grub_uint64_t vbiosaddr
;
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 */