[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1 03/17] hw/loongarch: Add init_cmdline
From: |
Song Gao |
Subject: |
[PATCH v1 03/17] hw/loongarch: Add init_cmdline |
Date: |
Fri, 8 Dec 2023 17:00:28 +0800 |
Add init_cmline and set boot_info->a0, a1
Signed-off-by: Song Gao <gaosong@loongson.cn>
---
hw/loongarch/boot.c | 21 +++++++++++++++++++++
include/hw/loongarch/virt.h | 2 ++
target/loongarch/cpu.h | 2 ++
3 files changed, 25 insertions(+)
diff --git a/hw/loongarch/boot.c b/hw/loongarch/boot.c
index 40796d97bd..b3fbed2ea0 100644
--- a/hw/loongarch/boot.c
+++ b/hw/loongarch/boot.c
@@ -14,6 +14,20 @@
#include "qemu/error-report.h"
#include "sysemu/reset.h"
+static int init_cmdline(struct loongarch_boot_info *info)
+{
+ hwaddr cmdline_addr;
+ cmdline_addr = 0xff00000ULL;
+
+ pstrcpy_targphys("cmdline", 0xff00000ULL,
+ COMMAND_LINE_SIZE, info->kernel_cmdline);
+
+ info->a0 = 1;
+ info->a1 = cmdline_addr;
+
+ return 0;
+}
+
static uint64_t cpu_loongarch_virt_to_phys(void *opaque, uint64_t addr)
{
return addr & MAKE_64BIT_MASK(0, TARGET_PHYS_ADDR_SPACE_BITS);
@@ -60,6 +74,8 @@ static int64_t load_kernel_info(struct loongarch_boot_info
*info)
}
}
+ init_cmdline(info);
+
return kernel_entry;
}
@@ -70,6 +86,10 @@ static void reset_load_elf(void *opaque)
cpu_reset(CPU(cpu));
if (env->load_elf) {
+ if (cpu == LOONGARCH_CPU(first_cpu)) {
+ env->gpr[4] = env->boot_info->a0;
+ env->gpr[5] = env->boot_info->a1;
+ }
cpu_set_pc(CPU(cpu), env->elf_address);
}
}
@@ -121,6 +141,7 @@ static void
loongarch_direct_kernel_boot(LoongArchMachineState *lams,
lacpu = LOONGARCH_CPU(qemu_get_cpu(i));
lacpu->env.load_elf = true;
lacpu->env.elf_address = kernel_addr;
+ lacpu->env.boot_info = info;
}
}
}
diff --git a/include/hw/loongarch/virt.h b/include/hw/loongarch/virt.h
index e4126dd0e7..d21de2cef4 100644
--- a/include/hw/loongarch/virt.h
+++ b/include/hw/loongarch/virt.h
@@ -31,6 +31,8 @@
#define VIRT_GED_MEM_ADDR (VIRT_GED_EVT_ADDR + ACPI_GED_EVT_SEL_LEN)
#define VIRT_GED_REG_ADDR (VIRT_GED_MEM_ADDR + MEMORY_HOTPLUG_IO_LEN)
+#define COMMAND_LINE_SIZE 512
+
struct LoongArchMachineState {
/*< private >*/
MachineState parent_obj;
diff --git a/target/loongarch/cpu.h b/target/loongarch/cpu.h
index 00d1fba597..c7c695138e 100644
--- a/target/loongarch/cpu.h
+++ b/target/loongarch/cpu.h
@@ -362,6 +362,8 @@ typedef struct CPUArchState {
uint64_t elf_address;
/* Store ipistate to access from this struct */
DeviceState *ipistate;
+
+ struct loongarch_boot_info *boot_info;
#endif
} CPULoongArchState;
--
2.25.1
- [PATCH v1 00/17] Add boot LoongArch elf kernel with FDT, Song Gao, 2023/12/08
- [PATCH v1 02/17] hw/loongarch: Add load initrd, Song Gao, 2023/12/08
- [PATCH v1 05/17] hw/loongarch: Init efi_system_table, Song Gao, 2023/12/08
- [PATCH v1 01/17] hw/loongarch: Move boot fucntions to boot.c, Song Gao, 2023/12/08
- [PATCH v1 08/17] hw/loongarch: Init efi_fdt table, Song Gao, 2023/12/08
- [PATCH v1 04/17] hw/loongarch: Add slave cpu boot_code, Song Gao, 2023/12/08
- [PATCH v1 07/17] hw/loongarch: Init efi_initrd table, Song Gao, 2023/12/08
- [PATCH v1 03/17] hw/loongarch: Add init_cmdline,
Song Gao <=
- [PATCH v1 06/17] hw/loongarch: Init efi_boot_memmap table, Song Gao, 2023/12/08
- [PATCH v1 10/17] hw/loongarch: fdt adds cpu interrupt controller node, Song Gao, 2023/12/08
- [PATCH v1 12/17] hw/loongarch: fdt adds pch_pic Controller, Song Gao, 2023/12/08
- [PATCH v1 13/17] hw/loongarch: fdt adds pch_msi Controller, Song Gao, 2023/12/08
- [PATCH v1 17/17] hw/loongarch: Add cells missing from rtc node, Song Gao, 2023/12/08
- [PATCH v1 14/17] hw/loongarch: fdt adds pcie irq_map node, Song Gao, 2023/12/08
- [PATCH v1 15/17] hw/loongarch: fdt remove unused irqchip node, Song Gao, 2023/12/08
- [PATCH v1 11/17] hw/loongarch: fdt adds Extend I/O Interrupt Controller, Song Gao, 2023/12/08
- [PATCH v1 16/17] hw/loongarch: Add cells missing from uart node, Song Gao, 2023/12/08
- [PATCH v1 09/17] hw/loongarch: Fix fdt memory node wrong 'reg', Song Gao, 2023/12/08