[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 07/17] hw/loongarch: Init efi_initrd table
From: |
Song Gao |
Subject: |
[PATCH v2 07/17] hw/loongarch: Init efi_initrd table |
Date: |
Mon, 18 Dec 2023 17:00:49 +0800 |
Signed-off-by: Song Gao <gaosong@loongson.cn>
---
hw/loongarch/boot.c | 29 +++++++++++++++++++++++++++--
include/hw/loongarch/boot.h | 9 +++++++++
2 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/hw/loongarch/boot.c b/hw/loongarch/boot.c
index 5d963176bd..1600ae6e55 100644
--- a/hw/loongarch/boot.c
+++ b/hw/loongarch/boot.c
@@ -14,11 +14,15 @@
#include "qemu/error-report.h"
#include "sysemu/reset.h"
+ram_addr_t initrd_offset;
+uint64_t initrd_size;
+
enum {
SLAVE_BOOT,
EFI_SYSTAB,
EFI_TABLES,
EFI_MEMMAP,
+ EFI_INITRD,
};
static const MemMapEntry loader_rommap[] = {
@@ -26,6 +30,7 @@ static const MemMapEntry loader_rommap[] = {
[EFI_SYSTAB] = {0xf200000, 0x10000},
[EFI_TABLES] = {0xf300000, 0x10000},
[EFI_MEMMAP] = {0xf400000, 0x10000},
+ [EFI_INITRD] = {0xf500000, 0x10000},
};
static unsigned int slave_boot_code[] = {
@@ -117,6 +122,26 @@ static void init_efi_boot_memmap(struct efi_system_table
*systab)
g_free(boot_memmap);
}
+static void init_efi_initrd_table(struct efi_system_table *systab)
+{
+ efi_guid_t tbl_guid = LINUX_EFI_INITRD_MEDIA_GUID;
+ struct efi_initrd *initrd_table =
g_malloc0(loader_rommap[EFI_INITRD].size);
+
+ initrd_table->base = initrd_offset;
+ initrd_table->size = initrd_size;
+
+ rom_add_blob_fixed("initrd_tbl_rom", initrd_table,
+ loader_rommap[EFI_INITRD].size,
+ loader_rommap[EFI_INITRD].base);
+
+ /* efi_configuration_table 2 */
+ guidcpy(&systab->tables[1].guid, &tbl_guid);
+ systab->tables[1].table = (void *)loader_rommap[EFI_INITRD].base;
+ systab->nr_tables = 2;
+
+ g_free(initrd_table);
+}
+
static void init_systab(struct loongarch_boot_info *info)
{
struct efi_system_table *systab;
@@ -134,6 +159,7 @@ static void init_systab(struct loongarch_boot_info *info)
systab->tables = efi_tables;
init_efi_boot_memmap(systab);
+ init_efi_initrd_table(systab);
rom_add_blob_fixed("tables_rom", efi_tables,
loader_rommap[EFI_TABLES].size,
@@ -173,8 +199,7 @@ static uint64_t cpu_loongarch_virt_to_phys(void *opaque,
uint64_t addr)
static int64_t load_kernel_info(struct loongarch_boot_info *info)
{
- uint64_t kernel_entry, kernel_low, kernel_high, initrd_size;
- ram_addr_t initrd_offset;
+ uint64_t kernel_entry, kernel_low, kernel_high;
ssize_t kernel_size;
kernel_size = load_elf(info->kernel_filename, NULL,
diff --git a/include/hw/loongarch/boot.h b/include/hw/loongarch/boot.h
index bef9ab659e..e482b829f7 100644
--- a/include/hw/loongarch/boot.h
+++ b/include/hw/loongarch/boot.h
@@ -32,6 +32,10 @@ typedef struct {
EFI_GUID(0x800f683f, 0xd08b, 0x423a, 0xa2, 0x93, \
0x96, 0x5c, 0x3c, 0x6f, 0xe2, 0xb4)
+#define LINUX_EFI_INITRD_MEDIA_GUID \
+ EFI_GUID(0x5568e427, 0x68fc, 0x4f3d, 0xac, 0x74, \
+ 0xca, 0x55, 0x52, 0x31, 0xcc, 0x68)
+
struct efi_config_table {
efi_guid_t guid;
uint64_t *ptr;
@@ -85,6 +89,11 @@ struct efi_boot_memmap {
efi_memory_desc_t map[32];
};
+struct efi_initrd {
+ uint64_t base;
+ uint64_t size;
+};
+
struct loongarch_boot_info {
uint64_t ram_size;
const char *kernel_filename;
--
2.25.1
- Re: [PATCH v2 04/17] hw/loongarch: Add slave cpu boot_code, (continued)
- [PATCH v2 05/17] hw/loongarch: Init efi_system_table, Song Gao, 2023/12/18
- [PATCH v2 06/17] hw/loongarch: Init efi_boot_memmap table, Song Gao, 2023/12/18
- [PATCH v2 01/17] hw/loongarch: Move boot fucntions to boot.c, Song Gao, 2023/12/18
- [PATCH v2 08/17] hw/loongarch: Init efi_fdt table, Song Gao, 2023/12/18
- [PATCH v2 03/17] hw/loongarch: Add init_cmdline, Song Gao, 2023/12/18
- [PATCH v2 07/17] hw/loongarch: Init efi_initrd table,
Song Gao <=
- [PATCH v2 09/17] hw/loongarch: Fix fdt memory node wrong 'reg', Song Gao, 2023/12/18
- [PATCH v2 14/17] hw/loongarch: fdt adds pcie irq_map node, Song Gao, 2023/12/18
- [PATCH v2 13/17] hw/loongarch: fdt adds pch_msi Controller, Song Gao, 2023/12/18
- [PATCH v2 15/17] hw/loongarch: fdt remove unused irqchip node, Song Gao, 2023/12/18
- [PATCH v2 17/17] hw/loongarch: Add cells missing from rtc node, Song Gao, 2023/12/18
- [PATCH v2 11/17] hw/loongarch: fdt adds Extend I/O Interrupt Controller, Song Gao, 2023/12/18
- [PATCH v2 12/17] hw/loongarch: fdt adds pch_pic Controller, Song Gao, 2023/12/18
- [PATCH v2 16/17] hw/loongarch: Add cells missing from uart node, Song Gao, 2023/12/18
- [PATCH v2 10/17] hw/loongarch: fdt adds cpu interrupt controller node, Song Gao, 2023/12/18