diff mbox

[RFC] arm: add secondary cpu book callbacks to arm_boot.c

Message ID 1326901853-18807-1-git-send-email-mark.langsdorf@calxeda.com
State New
Headers show

Commit Message

Mark Langsdorf Jan. 18, 2012, 3:50 p.m. UTC
Create two functions, write_secondary_boot() and secondary_cpu_reset_hook(),
to allow platforms more control of how secondary CPUs are brought up. The
new functions default to NULL and aren't called unless they are populated
so there are no changes to existing platform models.

Signed-off-by: Mark Langsdorf <mark.langsdorf@calxeda.com>
---
I'll add this to the Highbank patch series but I wanted to throw it out
now to make sure the general structure was good.

 hw/arm-misc.h |    4 ++++
 hw/arm_boot.c |    6 +++++-
 2 files changed, 9 insertions(+), 1 deletions(-)

Comments

Peter Maydell Jan. 18, 2012, 4:23 p.m. UTC | #1
On 18 January 2012 15:50, Mark Langsdorf <mark.langsdorf@calxeda.com> wrote:
> Create two functions, write_secondary_boot() and secondary_cpu_reset_hook(),
> to allow platforms more control of how secondary CPUs are brought up. The
> new functions default to NULL and aren't called unless they are populated
> so there are no changes to existing platform models.
>
> Signed-off-by: Mark Langsdorf <mark.langsdorf@calxeda.com>
> ---
> I'll add this to the Highbank patch series but I wanted to throw it out
> now to make sure the general structure was good.

Looks OK. I'm tempted to suggest that we should pull the default
code out into separate functions and then at the top of arm_load_kernel()
do
  if (!info->write_secondary_boot) {
      info->write_secondary_boot = default_write_secondary_boot;
  }
  if (!info->secondary_cpu_reset_hook) {
      info->secondary_cpu_reset_hook = default_secondary_cpu_reset_hook;
  }

Then we can put all the secondary-cpu-related code that is in arm_boot.c
in one place in the file.

Probably also nice to add a comment about which fields in arm_boot_info
are only required if you're using the default write_secondary_boot.

-- PMM
diff mbox

Patch

diff --git a/hw/arm-misc.h b/hw/arm-misc.h
index 6e8ae6b..866f848 100644
--- a/hw/arm-misc.h
+++ b/hw/arm-misc.h
@@ -36,6 +36,10 @@  struct arm_boot_info {
     int nb_cpus;
     int board_id;
     int (*atag_board)(const struct arm_boot_info *info, void *p);
+    void (*write_secondary_boot)(CPUState *env,
+                                 const struct arm_boot_info *info);
+    void (*secondary_cpu_reset_hook)(CPUState *env,
+                                     const struct arm_boot_info *info);
     /* Used internally by arm_boot.c */
     int is_linux;
     target_phys_addr_t initrd_size;
diff --git a/hw/arm_boot.c b/hw/arm_boot.c
index bf509a8..78626bb 100644
--- a/hw/arm_boot.c
+++ b/hw/arm_boot.c
@@ -196,6 +196,8 @@  static void do_cpu_reset(void *opaque)
                     set_kernel_args(info, info->initrd_size,
                                     info->loader_start);
                 }
+            } else if (info->secondary_cpu_reset_hook) {
+                info->secondary_cpu_reset_hook(env, info);
             } else {
                 stl_phys_notdirty(info->smp_bootreg_addr, 0);
                 env->regs[15] = info->smp_loader_start;
@@ -272,7 +274,9 @@  void arm_load_kernel(CPUState *env, struct arm_boot_info *info)
         }
         rom_add_blob_fixed("bootloader", bootloader, sizeof(bootloader),
                            info->loader_start);
-        if (info->nb_cpus > 1) {
+        if ((info->nb_cpus > 1) && (info->write_secondary_boot)) {
+            info->write_secondary_boot(env, info);
+        } else if (info->nb_cpus > 1) {
             smpboot[ARRAY_SIZE(smpboot) - 1] = info->smp_bootreg_addr;
             smpboot[ARRAY_SIZE(smpboot) - 2] = info->smp_priv_base;
             for (n = 0; n < ARRAY_SIZE(smpboot); n++) {