[PATCH kvm-unit-tests 04/15] powerpc: better document setup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



To prepare for another region illustrate where we move the FDT.
No functional change.

Signed-off-by: Andrew Jones <drjones@xxxxxxxxxx>
---
 lib/powerpc/setup.c | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/lib/powerpc/setup.c b/lib/powerpc/setup.c
index 00969da8f12c..f55b23fb5080 100644
--- a/lib/powerpc/setup.c
+++ b/lib/powerpc/setup.c
@@ -153,28 +153,48 @@ static void mem_init(phys_addr_t freemem_start)
 
 void setup(const void *fdt)
 {
+	void *freemem = &stacktop;
 	const char *bootargs;
 	u32 fdt_size;
 	int ret;
 
 	/*
-	 * Move the fdt to just above the stack. The free memory
-	 * then starts just after the fdt.
+	 * Before calling mem_init we need to move the fdt to a safe
+	 * location. We move it above the stack to construct the memory
+	 * map illustrated below:
+	 *
+	 * +----------------------+   <-- top of physical memory
+	 * |                      |
+	 * ~                      ~
+	 * |                      |
+	 * +----------------------+   <-- top of FDT
+	 * |                      |
+	 * +----------------------+   <-- top of cpu0's stack
+	 * |                      |
+	 * +----------------------+   <-- top of text/data/bss sections,
+	 * |                      |       see arm/flat.lds
+	 * |                      |
+	 * +----------------------+   <-- load address
+	 * |                      |
+	 * +----------------------+
 	 */
 	fdt_size = fdt_totalsize(fdt);
-	ret = fdt_move(fdt, &stacktop, fdt_size);
+	ret = fdt_move(fdt, freemem, fdt_size);
 	assert(ret == 0);
-	ret = dt_init(&stacktop);
+	ret = dt_init(freemem);
 	assert(ret == 0);
+	freemem += fdt_size;
 
+	/* call init functions */
 	cpu_init();
 
 	/* cpu_init must be called before mem_init */
-	mem_init(PAGE_ALIGN((unsigned long)&stacktop + fdt_size));
+	mem_init(PAGE_ALIGN((unsigned long)freemem));
 
 	/* mem_init must be called before io_init */
 	io_init();
 
+	/* finish setup */
 	ret = dt_get_bootargs(&bootargs);
 	assert(ret == 0 || ret == -FDT_ERR_NOTFOUND);
 	setup_args_progname(bootargs);
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux