Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Changing kernel entry point

To follow up on this.

I made my bootloader MULTIBOOT compliant. At the end of "my" boot2, I have C code in which I create the MIS structure, push the magic number into EAX and the address of the MIS into EBX.

Now I have the following problem. I am not sure what to call from here? Should I just jump to location 0x100000 and execute from there (while having EAX and EBX set correctly)?


On 02/21/2013 10:15 AM, Martin Osterloh wrote:
Anyone an idea on this?

On 02/19/2013 12:39 PM, Martin Osterloh wrote:
[ Please find the previous correspondence below this email I forgot to include the mailing list]


Thanks for the document. I've been reading it and I understand more and more how the BSD bootloader works. I am getting closer.

One thing you mentioned in your article is that the kernel maps itself at a very hogh location (0xC0100000 and higher). Since the BL cannot address anything like that, the physical location will be 0x100000 (1MiByte) - right after the BIOS. That makes sense to me.

However, a readelf -x -t -s -d netbsd shows me the following (just the top)

netbsd:     file format elf64-x86-64
architecture: i386:x86-64, flags 0x00000112:
start address 0xffffffff80100000

Program Header:
LOAD off 0x0000000000100000 vaddr 0xffffffff80100000 paddr 0xffffffff80100000 align 2**20
         filesz 0x0000000000265e88 memsz 0x0000000000265e88 flags r-x
LOAD off 0x0000000000366000 vaddr 0xffffffff80466000 paddr 0xffffffff80466000 align 2**20
         filesz 0x0000000000040598 memsz 0x00000000000ade80 flags rw-

I am confused as to why the paddr is set to 0xffffffff80100000? Shouldn't that be 0x100000? That is actually what causes trouble for me.

I found that KERNBASE, KERNTEXTOFF, etc. are all defined in /usr.src.sys.arch.amd64.compile/CUSTOM/machine/param.h (whereas CUSTOM is the name of my configuration). The next thing that came to my mind is that if I change it here I might be able to change the physical entry point. Unfortunately, I messed up the memory map and locore.S is complaining during the compilation process.

So I guess, I am wondering why the paddr attribute in the elf file is not set to 0x100000? And there must be another way to adjust these parameters (KERNBASE, KERNTEXTOFF, etc.)?

Again, I truly appreciate your help and advise.


On 02/15/2013 12:11 PM, Julio Merino wrote:
On Fri, Feb 15, 2013 at 11:29 AM, Martin Osterloh
<> wrote:
Hi Julio,

Thanks a lot for your quick response!

My bootloader is currently very simple (two stages like the BSD bootloader). At the end of boot2 it kicks off my micro-kernel in long mode. I think I
will have to change this since the entry point is 32 bit.

Could you please point out what/where these data structures are? I am
browsing the source tree at the moment and am trying to figure out at which point the elf binary is being loaded. From there on I would back trace to
see what the BL does before loading the binary.
Look for "bootinfo" in the code and in filenames. It has been a long
time since I touched this code, so I don't remember the specific

You might also find this useful:

Home | Main Index | Thread Index | Old Index