Current-Users archive

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

Re: Changing kernel entry point



[ 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
netbsd
architecture: i386:x86-64, flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
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.

Regards,
Martin

On 02/15/2013 12:11 PM, Julio Merino wrote:
On Fri, Feb 15, 2013 at 11:29 AM, Martin Osterloh
<martin.osterloh%dartmouth.edu@localhost> 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
details.

You might also find this useful:
http://onlamp.com/pub/a/bsd/2007/03/01/inside-multiboot.html




Home | Main Index | Thread Index | Old Index