From owner-freebsd-arm@FreeBSD.ORG Tue May 8 15:45:59 2012 Return-Path: Delivered-To: arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D26D2106566B for ; Tue, 8 May 2012 15:45:59 +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 9B1D68FC0A for ; Tue, 8 May 2012 15:45:59 +0000 (UTC) Received: by pbbro2 with SMTP id ro2so9216228pbb.13 for ; Tue, 08 May 2012 08:45:59 -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=PnQau39BPOU03qvZh4c9KpezY7gUldVOJjAlS39vsOY=; b=dQYBPbgUhZFYZMPB/IJ3NaZnxk1S6brBhtSdnrx+eiZv7Yk95SKJc//6Ly8RFYB3QT IvYKkcyaVYnrSUpdYvHdvJiPxAJ/5zfLDwnX01a3HHi3G5wnKPT1zSaOEbpwo0Cba3wt j3ZSW4e/rCi2RXpbbFHRjBGaHVPQuf0e1r2hzB4K12P3U8dMYgPdrSbMuhX7PWYLKbHM aIHw6phZbQsRorzfWi2Ynq+05reKBi47hQ18V84JOaDAL3Xhrh5jFK7/s8FtauCuQ/Jq yuk23X1/BovN33AwoGttoAvyqWVoq1U+awyoGoEuTtsNCCFKm8PWfHIexGcHnBidsPky OjAA== Received: by 10.68.213.162 with SMTP id nt2mr1916383pbc.31.1336491959135; Tue, 08 May 2012 08:45:59 -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 py6sm2761479pbc.13.2012.05.08.08.45.55 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 08 May 2012 08:45:57 -0700 (PDT) Sender: Tim Kientzle Mime-Version: 1.0 (Apple Message framework v1257) Content-Type: text/plain; charset=us-ascii From: Tim Kientzle In-Reply-To: <20120508213954.3c4a0c0e@fubar.geek.nz> Date: Tue, 8 May 2012 08:45:53 -0700 Content-Transfer-Encoding: 7bit Message-Id: References: <3B2A320B-3ADE-4F48-B94E-4F0886178251@freebsd.org> <201205070957.03842.jhb@freebsd.org> <8B01DF29-747A-449C-A762-E852F57C6380@freebsd.org> <20120508213954.3c4a0c0e@fubar.geek.nz> To: Andrew Turner X-Mailer: Apple Mail (2.1257) X-Gm-Message-State: ALoCoQlW/2nV9AdbH6b2TW4HRNQVOtxE2CE4qNMuY3s3b8YPPkX0ayZkQMUPHb3pYpkEi48YgANt Cc: arm@freebsd.org, freebsd-hackers@freebsd.org, John Baldwin 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 15:45:59 -0000 On May 8, 2012, at 2:39 AM, Andrew Turner wrote: > On Mon, 7 May 2012 22:32:10 -0700 > Tim Kientzle wrote: > >> >> On May 7, 2012, at 6:57 AM, John Baldwin wrote: >>> >>> 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. > > I have a script at [1] that builds an image to load the kernel directly > from U-Boot. It figures out where to tell U-Boot to load a kernel by > using readelf to find the value of physaddr and kernbase to use to > calculate what physical addresses to use to load the kernel to and > where the first instruction to execute is. I have a script at [2] that builds a FreeBSD image for BeagleBone that chain loads U-Boot, then ubldr, then loads the ELF kernel from UFS. Works very well, but it relies on some hacks to the common load_elf code that I'd like to find a clean way to generalize. [2] https://github.com/kientzle/freebsd-beaglebone