Curious : why does the booloader say i386 on amd64?

Peter Wemm peter at wemm.org
Tue Sep 6 18:47:02 PDT 2005


On Thursday 01 September 2005 09:07 pm, Norberto Meijome wrote:
> FreeBSD/i386 boot
>
> # sysctl -a | grep machine
> hw.machine: amd64
> hw.machine_arch: amd64
>
> # uname -rms
> FreeBSD 6.0-BETA3 amd64
>
>
> Is it common code between i386 + amd64? is it just a label ? do I
> have an old bootloader from a previous non-amd64 incantation
> (possible, though I'm pretty sure I dd'ed the first few megs of all
> drives before installing amd64...)

The amd64 boot loader *is* the i386 boot loader.  We have a common 
loader for both platforms.  Yes, the FreeBSD/i386 loader can load and 
run an amd64 kernel right off the i386 cdrom etc.

There was no benefit to be had by making a 64 bit loader.  It really 
wasn't necessary and would just have been a whole lot of work for no 
good reason.

For what its worth, the loader switches modes depending on which type
of kernel is loaded.  If you load a 64 bit kernel, then moments before 
starting it up, it creates a page table tree to replicate the kernel 
environment over the entire address space, the loader itself switches 
to 64 bit mode, and then jumps directly to the kernel at its native 64 
bit address entry point.   On i386, it jumps to the kernel in "flat" 
protected mode but at before-relocated address.  The i386 kernel has to 
build a page table tree itself and deal with running at its 
non-relocated address by doing lots of work in assembler.  Compare 
i386/locode.s with amd64/locore.S to see the benefit.  Also see 
create_pagetables() in amd64/machdep.c - that code is in assembler on 
i386, but simple C on amd64.
-- 
Peter Wemm - peter at wemm.org; peter at FreeBSD.org; peter at yahoo-inc.com
"All of this is for nothing if we don't go to the stars" - JMS/B5


More information about the freebsd-amd64 mailing list