From owner-freebsd-hackers@FreeBSD.ORG Tue May 8 05:32:17 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0BAD8106566C for ; Tue, 8 May 2012 05:32:17 +0000 (UTC) (envelope-from tim@kientzle.com) Received: from mail-pb0-f54.google.com (mail-pb0-f54.google.com [209.85.160.54]) by mx1.freebsd.org (Postfix) with ESMTP id CC8788FC08 for ; Tue, 8 May 2012 05:32:16 +0000 (UTC) Received: by pbbro2 with SMTP id ro2so8461573pbb.13 for ; Mon, 07 May 2012 22:32:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer :x-gm-message-state; bh=MX9zryC2Cu3MwYSe7jN0diR8YVnYnN0lg9vrajHAHhI=; b=htezlPC+4lsD6Z+3cLRvpN1stgB2hn98j0XI51icTqnV7djGW/DYH9uGLfJUYlO8cD dj8kFwfrGQNVHvV9DgBy1J0YrCUtT0LuueAXqItN5Wktj3Jp1b0Zd0ULD+yU+sslJpu9 zL/Gx1PP1RZ+6mHySxeBRhSDqWUuURRZdoEv/+SxeUiJX4GxiCMJbmOf+BD8ODDFnxD2 ARzDu7pHw3cgGH1WOnCR9sbZmPr2ALIyaEfCWRn0oSi8CGa4DD1lY1iFQhQ+L1hxnZzf xGohfbP62UWzBlkYf+I5DXRvAOcBZFauziND8YXwNmO74Ev/z4YAAp93M8YR6mHXu2cy TiXQ== Received: by 10.68.212.197 with SMTP id nm5mr4267947pbc.110.1336455136349; Mon, 07 May 2012 22:32:16 -0700 (PDT) Received: from [192.168.1.69] (99-74-169-43.lightspeed.sntcca.sbcglobal.net. [99.74.169.43]) by mx.google.com with ESMTPS id d6sm1185045pbi.23.2012.05.07.22.32.12 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 07 May 2012 22:32:13 -0700 (PDT) Sender: Tim Kientzle Mime-Version: 1.0 (Apple Message framework v1257) Content-Type: text/plain; charset=iso-8859-1 From: Tim Kientzle In-Reply-To: <201205070957.03842.jhb@freebsd.org> Date: Mon, 7 May 2012 22:32:10 -0700 Content-Transfer-Encoding: 7bit Message-Id: <8B01DF29-747A-449C-A762-E852F57C6380@freebsd.org> References: <3B2A320B-3ADE-4F48-B94E-4F0886178251@freebsd.org> <201205070957.03842.jhb@freebsd.org> To: John Baldwin X-Mailer: Apple Mail (2.1257) X-Gm-Message-State: ALoCoQl43cA6GPMLefgVwJ7pvjeaniw8lJ5zzdfUodRJV2cBsWNcmEQto33VSkS1W0oS/baoOh32 Cc: arm@freebsd.org, freebsd-hackers@freebsd.org Subject: Re: How does loader(8) decide where to load the kernel? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 May 2012 05:32:17 -0000 On May 7, 2012, at 6:57 AM, John Baldwin wrote: > On Saturday, May 05, 2012 1:06:13 am Tim Kientzle wrote: >> I have ubldr loading the ELF kernel on BeagleBone and am now >> trying to untangle some of the hacks I used to get this working. >> >> Unfortunately, there's one area of the common loader(8) code >> that I really don't understand: How does sys/boot/common/load_elf.c >> determine the physical address at which to load the kernel? >> >> __elfN(loadfile) has the following comment: >> >> [The file] will be stored at (dest). >> >> But that's not really true. For starters, loadfile maps dest >> through archsw.arch_loadaddr. (This mechanism seems >> to only be used on ia64 and pc98, though the result is >> later discarded on those platforms.) >> >> Loadfile then passes the value to loadimage which does >> very strange things: >> >> On i386, amd64, powerpc, and arm, loadimage subtracts >> the dest value from the address declared in the actual ELF >> headers so that the kernel always gets loaded into low memory. >> (there's some intermediate bit-twiddling I'm glossing over, but >> this is the general idea). > > The bit twiddling is supposed to be the equivalent of subtracting > KERNBASE from the load address. On both i386 and amd64, there is > a direct mapping of the kernel text such that KERNBASE maps address > 0, etc. By default on i386 KERNBASE is 0xc0000000. Exactly my problem. This all assumes that you're loading the kernel into low memory. On the AM3358, the DRAM starts at 0x8000 0000 on boot, so I'm trying to find a clean way to convince the loader's ELF code to put the kernel there. Tim