Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 2 Nov 2013 21:25:31 +0000 (UTC)
From:      Andrew Turner <andrew@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r257558 - in projects/specific_leg/sys: arm/arm conf
Message-ID:  <201311022125.rA2LPV7k050857@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: andrew
Date: Sat Nov  2 21:25:31 2013
New Revision: 257558
URL: http://svnweb.freebsd.org/changeset/base/257558

Log:
  Remove the need for a hardcoded startup page table address. We now allocate
  space for one in the kernel.

Modified:
  projects/specific_leg/sys/arm/arm/locore.S
  projects/specific_leg/sys/conf/ldscript.arm

Modified: projects/specific_leg/sys/arm/arm/locore.S
==============================================================================
--- projects/specific_leg/sys/arm/arm/locore.S	Sat Nov  2 21:07:39 2013	(r257557)
+++ projects/specific_leg/sys/arm/arm/locore.S	Sat Nov  2 21:25:31 2013	(r257558)
@@ -144,9 +144,27 @@ disable_mmu:
 	nop
 	mov	pc, r7
 Lunmapped:
-#ifdef STARTUP_PAGETABLE_ADDR
-	/* build page table from scratch */
-	ldr	r0, Lstartup_pagetable
+	/*
+	 * Build page table from scratch.
+	 */
+
+	/* Find the delta between VA and PA */
+	adr	r0, Lpagetable
+	ldr	r1, [r0]
+	sub	r2, r1, r0
+	/* At this point: r2 = VA - PA */
+
+	/*
+	 * Find the physical address of the table. After these two
+	 * instructions:
+	 * r1 = va(pagetable)
+	 *
+	 * r0 = va(pagetable) - (VA - PA)
+	 *    = va(pagetable) - VA + PA
+	 *    = pa(pagetable)
+	 */
+	ldr	r1, [r0, #4]
+	sub	r0, r1, r2
 
 	/*
 	 * Map PA == VA
@@ -200,7 +218,6 @@ Lunmapped:
 	nop
 	CPWAIT(r0)
 
-#endif
 mmu_done:
 	nop
 	adr	r1, .Lstart
@@ -234,6 +251,8 @@ virt_done:
 	adr	r0, .Lmainreturned
 	b	_C_LABEL(panic)
 	/* NOTREACHED */
+END(btext)
+END(_start)
 
 /*
  * Builds the page table
@@ -266,30 +285,27 @@ build_pagetables:
 
 	RET
 
-#ifdef STARTUP_PAGETABLE_ADDR
-#define MMU_INIT(va,pa,n_sec,attr) \
-	.word	n_sec					    ; \
-	.word	4*((va)>>L1_S_SHIFT)			    ; \
-	.word	(pa)|(attr)				    ;
+Lpagetable:
+	.word	.
+	.word	pagetable
 
 Lvirtaddr:
 	.word	KERNVIRTADDR
 Lphysaddr:
 	.word	KERNPHYSADDR
+
+#if defined (FLASHADDR) && defined(LOADERRAMADDR)
 Lreal_start:
 	.word	_start
-Lend:	
+Lend:
 	.word	_edata
-Lstartup_pagetable:
-	.word	STARTUP_PAGETABLE_ADDR
+#endif
+
 #ifdef SMP
 Lstartup_pagetable_secondary:
 	.word	temp_pagetable
 #endif
-END(btext)
-END(_start)
 
-#endif
 .Lstart:
 	.word	_edata
 	.word	_end
@@ -310,6 +326,15 @@ END(_start)
 svcstk:
 	.space	INIT_ARM_STACK_SIZE
 
+/*
+ * Memory for the initial pagetable. We are unable to place this in
+ * the bss as this will be cleared after the table is loaded.
+ */
+	.section ".init_pagetable"
+	.align	14 /* 16KiB aligned */
+pagetable:
+	.space	L1_TABLE_SIZE
+
 	.text
 	.align	0
 

Modified: projects/specific_leg/sys/conf/ldscript.arm
==============================================================================
--- projects/specific_leg/sys/conf/ldscript.arm	Sat Nov  2 21:07:39 2013	(r257557)
+++ projects/specific_leg/sys/conf/ldscript.arm	Sat Nov  2 21:25:31 2013	(r257558)
@@ -107,10 +107,14 @@ SECTIONS
    *(.dynbss)
    *(.bss)
    *(COMMON)
+   . = ALIGN(32 / 8);
+   _end = . ;
+   PROVIDE (end = .);
+   /* A section for the initial page table, it doesn't need to be in the
+      kernel file, however unlike normal .bss entries should not be zeroed
+      out as we use it before the .bss section is cleared. */
+   *(.init_pagetable)
   }
-  . = ALIGN(32 / 8);
-  _end = . ;
-  PROVIDE (end = .);
   /* Stabs debugging sections.  */
   .stab 0 : { *(.stab) }
   .stabstr 0 : { *(.stabstr) }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201311022125.rA2LPV7k050857>