1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 /* 3 * Definitions for LoongArch boot. 4 * 5 * Copyright (C) 2023 Loongson Technology Corporation Limited 6 */ 7 8 #ifndef HW_LOONGARCH_BOOT_H 9 #define HW_LOONGARCH_BOOT_H 10 11 /* UEFI 2.10 */ 12 #define EFI_SYSTEM_TABLE_SIGNATURE 0x5453595320494249 13 #define EFI_2_100_SYSTEM_TABLE_REVISION ((2<<16) | (100)) 14 #define EFI_SPECIFICATION_VERSION EFI_SYSTEM_TABLE_REVISION 15 #define EFI_SYSTEM_TABLE_REVISION EFI_2_100_SYSTEM_TABLE_REVISION 16 17 #define FW_VERSION 0x1 18 #define FW_PATCHLEVEL 0x0 19 20 typedef struct { 21 uint8_t b[16]; 22 } efi_guid_t QEMU_ALIGNED(8); 23 24 #define EFI_GUID(a, b, c, d...) (efi_guid_t){ { \ 25 (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \ 26 (b) & 0xff, ((b) >> 8) & 0xff, \ 27 (c) & 0xff, ((c) >> 8) & 0xff, d } } 28 29 #define LINUX_EFI_BOOT_MEMMAP_GUID \ 30 EFI_GUID(0x800f683f, 0xd08b, 0x423a, 0xa2, 0x93, \ 31 0x96, 0x5c, 0x3c, 0x6f, 0xe2, 0xb4) 32 33 struct efi_config_table { 34 efi_guid_t guid; 35 uint64_t *ptr; 36 const char name[16]; 37 }; 38 39 typedef struct { 40 uint64_t signature; 41 uint32_t revision; 42 uint32_t headersize; 43 uint32_t crc32; 44 uint32_t reserved; 45 } efi_table_hdr_t; 46 47 struct efi_configuration_table { 48 efi_guid_t guid; 49 void *table; 50 }; 51 52 struct efi_system_table { 53 efi_table_hdr_t hdr; 54 uint64_t fw_vendor; /* physical addr of CHAR16 vendor string */ 55 uint32_t fw_revision; 56 uint64_t con_in_handle; 57 uint64_t *con_in; 58 uint64_t con_out_handle; 59 uint64_t *con_out; 60 uint64_t stderr_handle; 61 uint64_t stderr_placeholder; 62 uint64_t *runtime; 63 uint64_t *boottime; 64 uint64_t nr_tables; 65 struct efi_configuration_table *tables; 66 }; 67 68 typedef struct { 69 uint32_t type; 70 uint32_t pad; 71 uint64_t phys_addr; 72 uint64_t virt_addr; 73 uint64_t num_pages; 74 uint64_t attribute; 75 } efi_memory_desc_t; 76 77 struct efi_boot_memmap { 78 uint64_t map_size; 79 uint64_t desc_size; 80 uint32_t desc_ver; 81 uint64_t map_key; 82 uint64_t buff_size; 83 efi_memory_desc_t map[32]; 84 }; 85 86 struct loongarch_boot_info { 87 uint64_t ram_size; 88 const char *kernel_filename; 89 const char *kernel_cmdline; 90 const char *initrd_filename; 91 uint64_t a0, a1, a2; 92 }; 93 94 void loongarch_load_kernel(MachineState *ms, struct loongarch_boot_info *info); 95 96 #endif /* HW_LOONGARCH_BOOT_H */ 97