From owner-freebsd-hackers@FreeBSD.ORG Tue May 8 15:45:59 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E09F51065674 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 9B3638FC12 for ; Tue, 8 May 2012 15:45:59 +0000 (UTC) Received: by pbbro2 with SMTP id ro2so9216226pbb.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=ibwLCD6qjAfaDWDNc4h/DAK2nH9kEXL+KPHv7wBJT+z+5aBV6CW6ciH8gxgaPYyW9U JleSRb4ngnpvkyCCG7VywEzUDS00mEIwGSxhKDka+S2NlCJsKqrBkvZ3Hyq70ushJafd vipKFwMYwng5aXO9mv8YHW/aLrGqaq2/LZhgesJ6q1SS6N+c9531IZEW0B9bQmMiS8kg Iz+S+mSLMbQxZjh1WDu+3zNpiJUBRftNWO8TeTjjnNsybM4d6TbcbEsfCyhtfhxAc0ut LpRQMCjgP3LbR5CluHAXx3ahnBd+MNeib8bvm1G2RHqVpuFtXOTV0INu+YUC3dIsZGgu S0Mg== 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: ALoCoQmU4jflIiCwHTLy7CiOMelkttICoOW30tNG8udxq78ye66e/XBB8a8U5dnfDhsk2Jj1VBFa 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 15:46:00 -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