From owner-freebsd-arm@FreeBSD.ORG Tue May 8 05:32:17 2012 Return-Path: Delivered-To: arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1CA0F1065673 for ; Tue, 8 May 2012 05:32:17 +0000 (UTC) (envelope-from tim@kientzle.com) Received: from mail-pz0-f54.google.com (mail-pz0-f54.google.com [209.85.210.54]) by mx1.freebsd.org (Postfix) with ESMTP id DA5268FC0C for ; Tue, 8 May 2012 05:32:16 +0000 (UTC) Received: by dadv36 with SMTP id v36so1921196dad.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=EIEW1Q+Y6RJt9G+aMxs3Bcx30CIjXOuuUAVWDrhVw/jL/YS3zuQjZptF/QbVPadfSf ZFbsvUayxyFW0C73mX2eCNFVnYOaet0R+Yo+HlvLXcSwlNG9cixwvUnmoy3YcghZk+Xa ibyFcLN1Hw/qjipssHt9GjHGSAQ22PP727oAvo5dOJWl7UAWB/meFNUrdLIJPBaOvuF/ 8NctMfd4Lsmg84bpbmv1b8eJ1Au2oKNYPSBKKvEWlZJhIf7xUWpKzZe1tIwY6Y5MwMek sIF9WSu5ez449agPdIWoMBusYF/GFORyriIfhlLNuaQTBhUjMCKMgTruI4uw+xun/Smc c0PQ== 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: ALoCoQnFzfqESf93qrxE2Ev6eJdXbNwkCskZxZb61H09aOsWYkLC2CUgJgyiCUMxI3vy5XpXBDmv Cc: arm@freebsd.org, freebsd-hackers@freebsd.org Subject: Re: How does loader(8) decide where to load the kernel? X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor 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