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 struct efi_config_table { 25 efi_guid_t guid; 26 uint64_t *ptr; 27 const char name[16]; 28 }; 29 30 typedef struct { 31 uint64_t signature; 32 uint32_t revision; 33 uint32_t headersize; 34 uint32_t crc32; 35 uint32_t reserved; 36 } efi_table_hdr_t; 37 38 struct efi_configuration_table { 39 efi_guid_t guid; 40 void *table; 41 }; 42 43 struct efi_system_table { 44 efi_table_hdr_t hdr; 45 uint64_t fw_vendor; /* physical addr of CHAR16 vendor string */ 46 uint32_t fw_revision; 47 uint64_t con_in_handle; 48 uint64_t *con_in; 49 uint64_t con_out_handle; 50 uint64_t *con_out; 51 uint64_t stderr_handle; 52 uint64_t stderr_placeholder; 53 uint64_t *runtime; 54 uint64_t *boottime; 55 uint64_t nr_tables; 56 struct efi_configuration_table *tables; 57 }; 58 59 struct loongarch_boot_info { 60 uint64_t ram_size; 61 const char *kernel_filename; 62 const char *kernel_cmdline; 63 const char *initrd_filename; 64 uint64_t a0, a1, a2; 65 }; 66 67 void loongarch_load_kernel(MachineState *ms, struct loongarch_boot_info *info); 68 69 #endif /* HW_LOONGARCH_BOOT_H */ 70