From ce6768965b5713c353097d362f712e2bca1ef354 Mon Sep 17 00:00:00 2001 From: Philippe Mathieu-Daudé Date: Sun, 12 Jan 2025 21:14:07 +0100 Subject: hw/mips/loongson3_bootp: Include missing headers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MemMapEntry is declared in "exec/hwaddr.h", cpu_to_le32() in "qemu/bswap.h". These headers are indirectly included via "cpu.h". Include them explicitly in order to avoid when removing "cpu.h": In file included from ../../hw/mips/loongson3_bootp.c:27: hw/mips/loongson3_bootp.h:234:14: error: unknown type name 'MemMapEntry' 234 | extern const MemMapEntry virt_memmap[]; | ^ hw/mips/loongson3_bootp.c:33:18: error: call to undeclared function 'cpu_to_le32'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 33 | c->cputype = cpu_to_le32(Loongson_3A); | ^ Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20250115232952.31166-6-philmd@linaro.org> --- hw/mips/loongson3_bootp.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'hw/mips/loongson3_bootp.c') diff --git a/hw/mips/loongson3_bootp.c b/hw/mips/loongson3_bootp.c index b97b81903b..712439c257 100644 --- a/hw/mips/loongson3_bootp.c +++ b/hw/mips/loongson3_bootp.c @@ -21,6 +21,8 @@ #include "qemu/osdep.h" #include "qemu/units.h" #include "qemu/cutils.h" +#include "qemu/bswap.h" +#include "exec/hwaddr.h" #include "cpu.h" #include "hw/boards.h" #include "hw/mips/loongson3_bootp.h" -- cgit 1.4.1 From 61f6e494e3ee060c92491d8df9315e4fdf590864 Mon Sep 17 00:00:00 2001 From: Philippe Mathieu-Daudé Date: Sun, 12 Jan 2025 21:15:30 +0100 Subject: hw/mips/loongson3: Propagate cpu_count to init_loongson_params() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Propagate the %cpu_count from the machine file, allowing to remove the "hw/boards.h" dependency (which is machine specific) from loongson3_bootp. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20250115232952.31166-7-philmd@linaro.org> --- hw/mips/loongson3_bootp.c | 11 ++++++----- hw/mips/loongson3_bootp.h | 1 + hw/mips/loongson3_virt.c | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) (limited to 'hw/mips/loongson3_bootp.c') diff --git a/hw/mips/loongson3_bootp.c b/hw/mips/loongson3_bootp.c index 712439c257..91b58a71a6 100644 --- a/hw/mips/loongson3_bootp.c +++ b/hw/mips/loongson3_bootp.c @@ -24,10 +24,10 @@ #include "qemu/bswap.h" #include "exec/hwaddr.h" #include "cpu.h" -#include "hw/boards.h" #include "hw/mips/loongson3_bootp.h" -static void init_cpu_info(void *g_cpuinfo, uint64_t cpu_freq) +static void init_cpu_info(void *g_cpuinfo, uint32_t cpu_count, + uint64_t cpu_freq) { struct efi_cpuinfo_loongson *c = g_cpuinfo; @@ -40,8 +40,8 @@ static void init_cpu_info(void *g_cpuinfo, uint64_t cpu_freq) } c->cpu_startup_core_id = cpu_to_le16(0); - c->nr_cpus = cpu_to_le32(current_machine->smp.cpus); - c->total_node = cpu_to_le32(DIV_ROUND_UP(current_machine->smp.cpus, + c->nr_cpus = cpu_to_le32(cpu_count); + c->total_node = cpu_to_le32(DIV_ROUND_UP(cpu_count, LOONGSON3_CORE_PER_NODE)); } @@ -112,9 +112,10 @@ static void init_special_info(void *g_special) } void init_loongson_params(struct loongson_params *lp, void *p, + uint32_t cpu_count, uint64_t cpu_freq, uint64_t ram_size) { - init_cpu_info(p, cpu_freq); + init_cpu_info(p, cpu_count, cpu_freq); lp->cpu_offset = cpu_to_le64((uintptr_t)p - (uintptr_t)lp); p += ROUND_UP(sizeof(struct efi_cpuinfo_loongson), 64); diff --git a/hw/mips/loongson3_bootp.h b/hw/mips/loongson3_bootp.h index 9091265df7..ee6340e42c 100644 --- a/hw/mips/loongson3_bootp.h +++ b/hw/mips/loongson3_bootp.h @@ -233,6 +233,7 @@ enum { extern const MemMapEntry virt_memmap[]; void init_loongson_params(struct loongson_params *lp, void *p, + uint32_t cpu_count, uint64_t cpu_freq, uint64_t ram_size); void init_reset_system(struct efi_reset_system_t *reset); diff --git a/hw/mips/loongson3_virt.c b/hw/mips/loongson3_virt.c index 9f6fdd0f28..eb2a6a248d 100644 --- a/hw/mips/loongson3_virt.c +++ b/hw/mips/loongson3_virt.c @@ -185,6 +185,7 @@ static void init_boot_param(void) init_reset_system(&(bp->reset_system)); p += ROUND_UP(sizeof(struct boot_params), 64); init_loongson_params(&(bp->efi.smbios.lp), p, + current_machine->smp.cpus, loaderparams.cpu_freq, loaderparams.ram_size); rom_add_blob_fixed("params_rom", bp, -- cgit 1.4.1 From 18271b5357a288c915d86f8f997085668e9d0b47 Mon Sep 17 00:00:00 2001 From: Philippe Mathieu-Daudé Date: Sun, 12 Jan 2025 21:08:06 +0100 Subject: hw/mips/loongson3_bootp: Propagate processor_id to init_cpu_info() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20250115232952.31166-9-philmd@linaro.org> --- hw/mips/loongson3_bootp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'hw/mips/loongson3_bootp.c') diff --git a/hw/mips/loongson3_bootp.c b/hw/mips/loongson3_bootp.c index 91b58a71a6..1aab26df69 100644 --- a/hw/mips/loongson3_bootp.c +++ b/hw/mips/loongson3_bootp.c @@ -27,12 +27,12 @@ #include "hw/mips/loongson3_bootp.h" static void init_cpu_info(void *g_cpuinfo, uint32_t cpu_count, - uint64_t cpu_freq) + uint32_t processor_id, uint64_t cpu_freq) { struct efi_cpuinfo_loongson *c = g_cpuinfo; c->cputype = cpu_to_le32(Loongson_3A); - c->processor_id = cpu_to_le32(MIPS_CPU(first_cpu)->env.CP0_PRid); + c->processor_id = cpu_to_le32(processor_id); if (cpu_freq > UINT_MAX) { c->cpu_clock_freq = cpu_to_le32(UINT_MAX); } else { @@ -115,7 +115,7 @@ void init_loongson_params(struct loongson_params *lp, void *p, uint32_t cpu_count, uint64_t cpu_freq, uint64_t ram_size) { - init_cpu_info(p, cpu_count, cpu_freq); + init_cpu_info(p, MIPS_CPU(first_cpu)->env.CP0_PRid, cpu_count, cpu_freq); lp->cpu_offset = cpu_to_le64((uintptr_t)p - (uintptr_t)lp); p += ROUND_UP(sizeof(struct efi_cpuinfo_loongson), 64); -- cgit 1.4.1 From 7eb372cc8bed1639e43529632a4fbb8b3f645194 Mon Sep 17 00:00:00 2001 From: Philippe Mathieu-Daudé Date: Sun, 12 Jan 2025 21:09:50 +0100 Subject: hw/mips/loongson3_virt: Propagate processor_id to init_loongson_params() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove one &first_cpu use in hw/mips/loongson3_bootp.c. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20250115232952.31166-10-philmd@linaro.org> --- hw/mips/loongson3_bootp.c | 5 ++--- hw/mips/loongson3_bootp.h | 2 +- hw/mips/loongson3_virt.c | 1 + 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'hw/mips/loongson3_bootp.c') diff --git a/hw/mips/loongson3_bootp.c b/hw/mips/loongson3_bootp.c index 1aab26df69..67812666c5 100644 --- a/hw/mips/loongson3_bootp.c +++ b/hw/mips/loongson3_bootp.c @@ -23,7 +23,6 @@ #include "qemu/cutils.h" #include "qemu/bswap.h" #include "exec/hwaddr.h" -#include "cpu.h" #include "hw/mips/loongson3_bootp.h" static void init_cpu_info(void *g_cpuinfo, uint32_t cpu_count, @@ -112,10 +111,10 @@ static void init_special_info(void *g_special) } void init_loongson_params(struct loongson_params *lp, void *p, - uint32_t cpu_count, + uint32_t cpu_count, uint32_t processor_id, uint64_t cpu_freq, uint64_t ram_size) { - init_cpu_info(p, MIPS_CPU(first_cpu)->env.CP0_PRid, cpu_count, cpu_freq); + init_cpu_info(p, cpu_count, processor_id, cpu_freq); lp->cpu_offset = cpu_to_le64((uintptr_t)p - (uintptr_t)lp); p += ROUND_UP(sizeof(struct efi_cpuinfo_loongson), 64); diff --git a/hw/mips/loongson3_bootp.h b/hw/mips/loongson3_bootp.h index ee6340e42c..9dc325a855 100644 --- a/hw/mips/loongson3_bootp.h +++ b/hw/mips/loongson3_bootp.h @@ -233,7 +233,7 @@ enum { extern const MemMapEntry virt_memmap[]; void init_loongson_params(struct loongson_params *lp, void *p, - uint32_t cpu_count, + uint32_t cpu_count, uint32_t processor_id, uint64_t cpu_freq, uint64_t ram_size); void init_reset_system(struct efi_reset_system_t *reset); diff --git a/hw/mips/loongson3_virt.c b/hw/mips/loongson3_virt.c index 5fe5bc6fc0..ee71fe9e9b 100644 --- a/hw/mips/loongson3_virt.c +++ b/hw/mips/loongson3_virt.c @@ -185,6 +185,7 @@ static void init_boot_param(unsigned cpu_count) init_reset_system(&(bp->reset_system)); p += ROUND_UP(sizeof(struct boot_params), 64); init_loongson_params(&(bp->efi.smbios.lp), p, cpu_count, + MIPS_CPU(first_cpu)->env.CP0_PRid, loaderparams.cpu_freq, loaderparams.ram_size); rom_add_blob_fixed("params_rom", bp, -- cgit 1.4.1