hw/loongarch/virt: Remove global variables about initrd

Global variables initrd_offset and initrd_size records loading information
about initrd, it can be moved to structure loongarch_boot_info.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20250430094738.1556670-2-maobibo@loongson.cn>
Signed-off-by: Song Gao <gaosong@loongson.cn>
This commit is contained in:
Bibo Mao 2025-04-30 17:47:37 +08:00 committed by Song Gao
parent e7788da986
commit 4332a641e2
2 changed files with 12 additions and 11 deletions

View file

@ -38,9 +38,6 @@ struct loongarch_linux_hdr {
struct memmap_entry *memmap_table; struct memmap_entry *memmap_table;
unsigned memmap_entries; unsigned memmap_entries;
ram_addr_t initrd_offset;
uint64_t initrd_size;
static const unsigned int slave_boot_code[] = { static const unsigned int slave_boot_code[] = {
/* Configure reset ebase. */ /* Configure reset ebase. */
0x0400302c, /* csrwr $t0, LOONGARCH_CSR_EENTRY */ 0x0400302c, /* csrwr $t0, LOONGARCH_CSR_EENTRY */
@ -121,7 +118,8 @@ static void init_efi_boot_memmap(struct efi_system_table *systab,
} }
} }
static void init_efi_initrd_table(struct efi_system_table *systab, static void init_efi_initrd_table(struct loongarch_boot_info *info,
struct efi_system_table *systab,
void *p, void *start) void *p, void *start)
{ {
efi_guid_t tbl_guid = LINUX_EFI_INITRD_MEDIA_GUID; efi_guid_t tbl_guid = LINUX_EFI_INITRD_MEDIA_GUID;
@ -132,8 +130,8 @@ static void init_efi_initrd_table(struct efi_system_table *systab,
systab->tables[1].table = (struct efi_configuration_table *)(p - start); systab->tables[1].table = (struct efi_configuration_table *)(p - start);
systab->nr_tables = 2; systab->nr_tables = 2;
initrd_table->base = initrd_offset; initrd_table->base = info->initrd_addr;
initrd_table->size = initrd_size; initrd_table->size = info->initrd_size;
} }
static void init_efi_fdt_table(struct efi_system_table *systab) static void init_efi_fdt_table(struct efi_system_table *systab)
@ -169,7 +167,7 @@ static void init_systab(struct loongarch_boot_info *info, void *p, void *start)
init_efi_boot_memmap(systab, p, start); init_efi_boot_memmap(systab, p, start);
p += ROUND_UP(sizeof(struct efi_boot_memmap) + p += ROUND_UP(sizeof(struct efi_boot_memmap) +
sizeof(efi_memory_desc_t) * memmap_entries, 64 * KiB); sizeof(efi_memory_desc_t) * memmap_entries, 64 * KiB);
init_efi_initrd_table(systab, p, start); init_efi_initrd_table(info, systab, p, start);
p += ROUND_UP(sizeof(struct efi_initrd), 64 * KiB); p += ROUND_UP(sizeof(struct efi_initrd), 64 * KiB);
init_efi_fdt_table(systab); init_efi_fdt_table(systab);
@ -276,8 +274,8 @@ static ram_addr_t alloc_initrd_memory(struct loongarch_boot_info *info,
static int64_t load_kernel_info(struct loongarch_boot_info *info) static int64_t load_kernel_info(struct loongarch_boot_info *info)
{ {
uint64_t kernel_entry, kernel_low, kernel_high; uint64_t kernel_entry, kernel_low, kernel_high, initrd_offset = 0;
ssize_t kernel_size; ssize_t kernel_size, initrd_size;
kernel_size = load_elf(info->kernel_filename, NULL, kernel_size = load_elf(info->kernel_filename, NULL,
cpu_loongarch_virt_to_phys, NULL, cpu_loongarch_virt_to_phys, NULL,
@ -313,8 +311,9 @@ static int64_t load_kernel_info(struct loongarch_boot_info *info)
info->initrd_filename); info->initrd_filename);
exit(1); exit(1);
} }
} else {
initrd_size = 0; info->initrd_addr = initrd_offset;
info->initrd_size = initrd_size;
} }
return kernel_entry; return kernel_entry;

View file

@ -102,6 +102,8 @@ struct loongarch_boot_info {
const char *kernel_cmdline; const char *kernel_cmdline;
const char *initrd_filename; const char *initrd_filename;
uint64_t a0, a1, a2; uint64_t a0, a1, a2;
uint64_t initrd_addr;
uint64_t initrd_size;
}; };
extern struct memmap_entry *memmap_table; extern struct memmap_entry *memmap_table;