diff mbox

[v5,1/6] hw/arm/boot: load_dtb becomes non static arm_load_dtb

Message ID 1417371570-11789-2-git-send-email-eric.auger@linaro.org
State New
Headers show

Commit Message

Auger Eric Nov. 30, 2014, 6:19 p.m. UTC
load_dtb is renamed into arm_load_dtb and becomes non static.
it will be used by machvirt for dynamic instantiation of
platform devices

Signed-off-by: Eric Auger <eric.auger@linaro.org>

---

v4 -> v5:
s/load_dtb/arm_load_dtb in one comment

v2 -> v3:
load_dtb renamed into arm_load_dtb

Conflicts:
	hw/arm/boot.c
---
 hw/arm/boot.c        | 16 ++++++++--------
 include/hw/arm/arm.h |  2 ++
 2 files changed, 10 insertions(+), 8 deletions(-)

Comments

Peter Maydell Dec. 5, 2014, 4:38 p.m. UTC | #1
On 30 November 2014 at 18:19, Eric Auger <eric.auger@linaro.org> wrote:
> load_dtb is renamed into arm_load_dtb and becomes non static.
> it will be used by machvirt for dynamic instantiation of
> platform devices

'virt' shouldn't be a special case -- we should always
handle setting up the DTB in guest memory in the same
way, whether there happens to be a vfio platform device
available or not.

thanks
-- PMM
Peter Maydell Dec. 5, 2014, 6:16 p.m. UTC | #2
On 5 December 2014 at 16:38, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 30 November 2014 at 18:19, Eric Auger <eric.auger@linaro.org> wrote:
>> load_dtb is renamed into arm_load_dtb and becomes non static.
>> it will be used by machvirt for dynamic instantiation of
>> platform devices
>
> 'virt' shouldn't be a special case -- we should always
> handle setting up the DTB in guest memory in the same
> way, whether there happens to be a vfio platform device
> available or not.

...this probably means that a bunch of the work currently
done in arm_load_kernel() should be deferred to a 'machine
init complete' hook (perhaps all of it?).

-- PMM
Auger Eric Dec. 9, 2014, 10:29 a.m. UTC | #3
On 12/05/2014 07:16 PM, Peter Maydell wrote:
> On 5 December 2014 at 16:38, Peter Maydell <peter.maydell@linaro.org> wrote:
>> On 30 November 2014 at 18:19, Eric Auger <eric.auger@linaro.org> wrote:
>>> load_dtb is renamed into arm_load_dtb and becomes non static.
>>> it will be used by machvirt for dynamic instantiation of
>>> platform devices
>>
>> 'virt' shouldn't be a special case -- we should always
>> handle setting up the DTB in guest memory in the same
>> way, whether there happens to be a vfio platform device
>> available or not.
> 
> ...this probably means that a bunch of the work currently
> done in arm_load_kernel() should be deferred to a 'machine
> init complete' hook (perhaps all of it?).

Hi Peter,

OK

I moved the arm_load_kernel code into a machine init done notify and
arm_load_kernel now only registers the notifier.
For machine files willing to support platform bus, the arm_load_kernel
must happen before the registration of the notifier that adds platform
bus nodes and after CPU init (notifiers are executed in registration
reverse order).

Best Regards

Eric
> 
> -- PMM
>
diff mbox

Patch

diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index 0014c34..9997bea 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -313,7 +313,7 @@  static void set_kernel_args_old(const struct arm_boot_info *info)
 }
 
 /**
- * load_dtb() - load a device tree binary image into memory
+ * arm_load_dtb() - load a device tree binary image into memory
  * @addr:       the address to load the image at
  * @binfo:      struct describing the boot environment
  * @addr_limit: upper limit of the available memory area at @addr
@@ -330,8 +330,8 @@  static void set_kernel_args_old(const struct arm_boot_info *info)
  *          0 if the image size exceeds the limit,
  *          -1 on errors.
  */
-static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
-                    hwaddr addr_limit)
+int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
+                 hwaddr addr_limit)
 {
     void *fdt = NULL;
     int size, rc;
@@ -504,7 +504,7 @@  void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
             /* If we have a device tree blob, but no kernel to supply it to,
              * copy it to the base of RAM for a bootloader to pick up.
              */
-            if (load_dtb(info->loader_start, info, 0) < 0) {
+            if (arm_load_dtb(info->loader_start, info, 0) < 0) {
                 exit(1);
             }
         }
@@ -566,13 +566,13 @@  void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
          */
         if (elf_low_addr > info->loader_start
             || elf_high_addr < info->loader_start) {
-            /* Pass elf_low_addr as address limit to load_dtb if it may be
-             * pointing into RAM, otherwise pass '0' (no limit)
+            /* Pass elf_low_addr as address limit to arm_load_dtb if it may
+             * be pointing into RAM, otherwise pass '0' (no limit)
              */
             if (elf_low_addr < info->loader_start) {
                 elf_low_addr = 0;
             }
-            if (load_dtb(info->loader_start, info, elf_low_addr) < 0) {
+            if (arm_load_dtb(info->loader_start, info, elf_low_addr) < 0) {
                 exit(1);
             }
         }
@@ -637,7 +637,7 @@  void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
              */
             hwaddr dtb_start = QEMU_ALIGN_UP(info->initrd_start + initrd_size,
                                              4096);
-            if (load_dtb(dtb_start, info, 0) < 0) {
+            if (arm_load_dtb(dtb_start, info, 0) < 0) {
                 exit(1);
             }
             fixupcontext[FIXUP_ARGPTR] = dtb_start;
diff --git a/include/hw/arm/arm.h b/include/hw/arm/arm.h
index cefc9e6..5fdae7b 100644
--- a/include/hw/arm/arm.h
+++ b/include/hw/arm/arm.h
@@ -68,6 +68,8 @@  struct arm_boot_info {
     hwaddr entry;
 };
 void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info);
+int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
+                 hwaddr addr_limit);
 
 /* Multiplication factor to convert from system clock ticks to qemu timer
    ticks.  */