From owner-svn-src-head@FreeBSD.ORG Sun Feb 9 02:06:12 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B1696DB; Sun, 9 Feb 2014 02:06:12 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 9AF4F141A; Sun, 9 Feb 2014 02:06:12 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s1926CiD024429; Sun, 9 Feb 2014 02:06:12 GMT (envelope-from ian@svn.freebsd.org) Received: (from ian@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s1926CwW024428; Sun, 9 Feb 2014 02:06:12 GMT (envelope-from ian@svn.freebsd.org) Message-Id: <201402090206.s1926CwW024428@svn.freebsd.org> From: Ian Lepore Date: Sun, 9 Feb 2014 02:06:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r261648 - head/sys/arm/arm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Feb 2014 02:06:12 -0000 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; */