How does loader(8) decide where to load the kernel?
Tim Kientzle
kientzle at freebsd.org
Tue May 8 15:46:00 UTC 2012
On May 8, 2012, at 2:39 AM, Andrew Turner wrote:
> On Mon, 7 May 2012 22:32:10 -0700
> Tim Kientzle <kientzle at freebsd.org> 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
More information about the freebsd-hackers
mailing list