loading kernel to 0x100000 and learning how much is ram?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
ycyos
Posts: 1
Joined: Mon Oct 29, 2007 9:01 am

loading kernel to 0x100000 and learning how much is ram?

Post by ycyos »

how can i load my kernel to 0x100000 when my bootloader in real mode with 13h int?

and how can i learn how much ram does the computer have in protected mode


thank you for your answers
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

Hi,

The way to load your kernel above 1MB is to load it in to a buffer below 1MB, and then copy it over. If your kernel is less than 64k in size, you can achieve this by enabling A20 and then just doing a normal copy over. If not, you will need to either:

1. Write a protected mod floppy driver and do it all from there.
2. Keep switching between real and protected mode.
3. Use Unreal mode.
4. Use a v86 task (probably overkill if you are at an early OS stage).
5. Use GRUB (my personal recommendation).

As for how much RAM the computer has, see the wiki article: http://www.osdev.org/wiki/How_Do_I_Dete ... unt_Of_RAM . Using option 5 above will also give you a nice memory map to use. Although this information is obtained in real mode, it will return the total amount of RAM you have to play with (real mode / pmode or long mode).

HTH
Adam
User avatar
Alboin
Member
Member
Posts: 1466
Joined: Thu Jan 04, 2007 3:29 pm
Location: Noricum and Pannonia

Post by Alboin »

I've used this. It actually contains more info than the wiki on the memory map int.

I was going to add it yesterday, but I didn't had time.
C8H10N4O2 | #446691 | Trust the nodes.
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post by frank »

In my bootloader I load my kernel in 64kb chunks to a buffer in low memory and then switch to protected mode to copy the data above 1mb. I then return to real mode and repeat the process until it is completely loaded. It wasn't that hard to do, you just have to make sure that you get rid of all of the artifacts of protected mode before calling any BIOS interrupts. i.e. clean up all segment registers.

EDIT: As for the memory size I use INT 15h. Just look at the link Alboin posted for more information.
Post Reply