grub-0.5.93.1/stage2/boot.c lines 423:
if (type == KERNEL_TYPE_FREEBSD)
memaddr = RAW_ADDR (phdr->p_paddr & 0xFFFFFF);
else
memaddr = RAW_ADDR (phdr->p_paddr);
Honestly I find these two lines really strange if you consider that
phdr->p_paddr is always equal to 0. In most of the cases it does not
make sense to specify the physical location of an ELF binary. It is
only used in rare cases. I use this facility to enable my bootloader
to load my kernel at the right physical place (it loads every segment
at the address specified by p_paddr withiut any & 0xFFFFFF type of
thing). My kernel uses both p_paddr and p_vaddr. All the kernel is is
in virtual memory starting at around 0xC0100000. Which means that the
p_paddr and p_vaddr are different for most of the kernel. There are
only the setup part (which is responsible for the setup of paging and
a few other basic things) which has p_paddr == p_vaddr, and the other
part (which does not yet exist) that has p_paddr == p_vaddr is the SMP
boot code for the APs. The entry point is at a location where p_vaddr
== p_paddr which means that I don't have to modify e_entry. I can
directly jump to it.
In late 97 early 98 I had contacted Erich Boleyn about the way he was
loading ELF kernels. At that time he was using phdr->p_vaddr. Since I
am using p_paddr I asked him if he could check if p_paddr was used and
load the kernel at this location, otherwise use something like
(p_vaddr & 0xffffff). At that time he didn't have time but said it
would be feasible.
Another problem with your bootloader is that it does not like code
that has to go below the 1MB (according to the code, it loads it but
sets errnum to ERR_BELOW_1MB). Which is a problem for my OS since I
will have to link the SMP boot code below the 640Kb (or even 512Kb)
when I implement SMP. Would it be possible to specify an area in the
first 511Kb that the OS would be free to use as part of the MultiBoot
spec?! I am sure that you can leave a few Kb!
Please comment on everything.
Have a nice day.
Nicolas Weidmann
This message contains confidential information and is intended only
for the individual named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.
E-mail transmission cannot be guaranteed to be secure or error-free
as information could be intercepted, corrupted, lost, destroyed,
arrive late or incomplete, or contain viruses. The sender therefore
does not accept liability for any errors or omissions in the contents
of this message which arise as a result of e-mail transmission. If
verification is required please request a hard-copy version. This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities or
related financial instruments.