diff mbox series

hw/tricore/triboard: Remove use of &first_cpu

Message ID 20250110180909.83165-1-philmd@linaro.org
State New
Headers show
Series hw/tricore/triboard: Remove use of &first_cpu | expand

Commit Message

Philippe Mathieu-Daudé Jan. 10, 2025, 6:09 p.m. UTC
triboard_machine_init() has access to the single CPU via:

  TriBoardMachineState {
    TC27XSoCState {
      TriCoreCPU cpu;
      ...
    } tc27x_soc;
  } ms;

Pass it as argument to tricore_load_kernel() so we can
remove the &first_cpu global use.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/tricore/triboard.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Richard Henderson Jan. 10, 2025, 6:25 p.m. UTC | #1
On 1/10/25 10:09, Philippe Mathieu-Daudé wrote:
> triboard_machine_init() has access to the single CPU via:
> 
>    TriBoardMachineState {
>      TC27XSoCState {
>        TriCoreCPU cpu;
>        ...
>      } tc27x_soc;
>    } ms;
> 
> Pass it as argument to tricore_load_kernel() so we can
> remove the &first_cpu global use.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   hw/tricore/triboard.c | 6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
Pierrick Bouvier Jan. 10, 2025, 8:50 p.m. UTC | #2
On 1/10/25 10:09, Philippe Mathieu-Daudé wrote:
> triboard_machine_init() has access to the single CPU via:
> 
>    TriBoardMachineState {
>      TC27XSoCState {
>        TriCoreCPU cpu;
>        ...
>      } tc27x_soc;
>    } ms;
> 
> Pass it as argument to tricore_load_kernel() so we can
> remove the &first_cpu global use.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   hw/tricore/triboard.c | 6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/tricore/triboard.c b/hw/tricore/triboard.c
> index 4dba0259cd3..9cc8d282ff2 100644
> --- a/hw/tricore/triboard.c
> +++ b/hw/tricore/triboard.c
> @@ -31,11 +31,10 @@
>   #include "hw/tricore/triboard.h"
>   #include "hw/tricore/tc27x_soc.h"
>   
> -static void tricore_load_kernel(const char *kernel_filename)
> +static void tricore_load_kernel(TriCoreCPU *cpu, const char *kernel_filename)
>   {
>       uint64_t entry;
>       long kernel_size;
> -    TriCoreCPU *cpu;
>       CPUTriCoreState *env;
>   
>       kernel_size = load_elf(kernel_filename, NULL,
> @@ -46,7 +45,6 @@ static void tricore_load_kernel(const char *kernel_filename)
>           error_report("no kernel file '%s'", kernel_filename);
>           exit(1);
>       }
> -    cpu = TRICORE_CPU(first_cpu);
>       env = &cpu->env;
>       env->PC = entry;
>   }
> @@ -62,7 +60,7 @@ static void triboard_machine_init(MachineState *machine)
>       sysbus_realize(SYS_BUS_DEVICE(&ms->tc27x_soc), &error_fatal);
>   
>       if (machine->kernel_filename) {
> -        tricore_load_kernel(machine->kernel_filename);
> +        tricore_load_kernel(&ms->tc27x_soc.cpu, machine->kernel_filename);
>       }
>   }
>   

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
diff mbox series

Patch

diff --git a/hw/tricore/triboard.c b/hw/tricore/triboard.c
index 4dba0259cd3..9cc8d282ff2 100644
--- a/hw/tricore/triboard.c
+++ b/hw/tricore/triboard.c
@@ -31,11 +31,10 @@ 
 #include "hw/tricore/triboard.h"
 #include "hw/tricore/tc27x_soc.h"
 
-static void tricore_load_kernel(const char *kernel_filename)
+static void tricore_load_kernel(TriCoreCPU *cpu, const char *kernel_filename)
 {
     uint64_t entry;
     long kernel_size;
-    TriCoreCPU *cpu;
     CPUTriCoreState *env;
 
     kernel_size = load_elf(kernel_filename, NULL,
@@ -46,7 +45,6 @@  static void tricore_load_kernel(const char *kernel_filename)
         error_report("no kernel file '%s'", kernel_filename);
         exit(1);
     }
-    cpu = TRICORE_CPU(first_cpu);
     env = &cpu->env;
     env->PC = entry;
 }
@@ -62,7 +60,7 @@  static void triboard_machine_init(MachineState *machine)
     sysbus_realize(SYS_BUS_DEVICE(&ms->tc27x_soc), &error_fatal);
 
     if (machine->kernel_filename) {
-        tricore_load_kernel(machine->kernel_filename);
+        tricore_load_kernel(&ms->tc27x_soc.cpu, machine->kernel_filename);
     }
 }