Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Feb 2014 02:06:12 +0000 (UTC)
From:      Ian Lepore <ian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r261648 - head/sys/arm/arm
Message-ID:  <201402090206.s1926CwW024428@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ian
Date: Sun Feb  9 02:06:12 2014
New Revision: 261648
URL: http://svnweb.freebsd.org/changeset/base/261648

Log:
  Calculate the kernel's load address from the PC in the elf / gzip
  trampoline instead of relying on KERNPHYSADDR as a compile-time constant.

Modified:
  head/sys/arm/arm/elf_trampoline.c

Modified: head/sys/arm/arm/elf_trampoline.c
==============================================================================
--- head/sys/arm/arm/elf_trampoline.c	Sun Feb  9 01:59:52 2014	(r261647)
+++ head/sys/arm/arm/elf_trampoline.c	Sun Feb  9 02:06:12 2014	(r261648)
@@ -186,14 +186,20 @@ static void arm9_setup(void);
 void
 _startC(void)
 {
-	int physaddr = KERNPHYSADDR;
 	int tmp1;
 	unsigned int sp = ((unsigned int)&_end & ~3) + 4;
-#if defined(FLASHADDR) && defined(PHYSADDR) && defined(LOADERRAMADDR)
-	unsigned int pc;
+	unsigned int pc, kernphysaddr;
 
+	/*
+	 * Figure out the physical address the kernel was loaded at.  This
+	 * assumes the entry point (this code right here) is in the first page,
+	 * which will always be the case for this trampoline code.
+	 */
 	__asm __volatile("mov %0, pc\n"
 	    : "=r" (pc));
+	kernphysaddr = pc & ~PAGE_MASK;
+
+#if defined(FLASHADDR) && defined(PHYSADDR) && defined(LOADERRAMADDR)
 	if ((FLASHADDR > LOADERRAMADDR && pc >= FLASHADDR) ||
 	    (FLASHADDR < LOADERRAMADDR && pc < LOADERRAMADDR)) {
 		/*
@@ -247,7 +253,7 @@ _startC(void)
 			 "mov pc, %0\n"
 			 "2: nop\n"
 			 "mov sp, %2\n"
-			 : "=r" (tmp1), "+r" (physaddr), "+r" (sp));
+			 : "=r" (tmp1), "+r" (kernphysaddr), "+r" (sp));
 #ifndef KZIP
 #ifdef CPU_ARM9
 	/* So that idcache_wbinv works; */



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