OS Memory Map

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
pskyboy

OS Memory Map

Post by pskyboy »

Hey guys

I was just wondering how you guys where laying your OS out in memory. I was thinking of starting at 0 and giving my kernel 1Gb of Logical space.

To do this i load it in at 0bytes to start with then jump to it and run it. So anyway this is waht i was thinking for layout what do you think? hwo are you doing it?

0bytes - Kernel
2MBytes - GDT
2M32bytes - Page Tables
6M32bytes - Page directory
7M - Any other kernel stuff

This is physical memory layout obviously

Peter
Schol-R-LEA

Re:OS Memory Map

Post by Schol-R-LEA »

As I told Berserk just now, even in p-mode it is better to leave the first 1M of physical memory free for hardware accessing and any real-mode or v86-mode programming you may need. The first 0x600 (1536) bytes of memory contain the IVT and the BDA, which you will need if you have to drop back into real mode to use any 16-bit BIOS calls.

Above 1M, however, you should be able to do whatever you wish with whatever physical memory you have, for the most part. I'll leave certain details (the 'hole' at the the 15-16Mbyte boundary that exists under certain BIOS settings, for example) to those who know p-mode programming better.
pskyboy

Re:OS Memory Map

Post by pskyboy »

Yeah, i was not intending on dropping back to v86 mode at all unless someone can give me a very good reason why i would need to. I also only think teh 15m-16m memory hole only applies to ISA based devices and since my OS won't be supporting ISA its not going to be a problem fo rme.

Peter
DarylD

Re:OS Memory Map

Post by DarylD »

As far as I know, don't you need to use ISA to access floppy drives?? I am sure I read somewhere about the DMA for it needing to be below 16M, preferably below 1M.

This was something I was wondering about too.
pskyboy

Re:OS Memory Map

Post by pskyboy »

LOL, I have no intention of supporting floppy drives either.

I know everyone will try and flame me for that but hey my OS is dropping everything legacy. Im not even supporting 32bit x86.

Peter
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:OS Memory Map

Post by Pype.Clicker »

my own map:
0 -- 0x8000 : BIOS data & bootsector

0x8000 -- kernel_base : second stage bootloader & SOS (a kind of restricted 32bits BIOS)

kernel_base -- lomembase : microkernel (about 128Kb), ramdisk (holding the modules we'll load). Those both *must* lie under 640Kb because they're loaded in real mode

lomembase -- lomemtop : kernel's heap.
0xA000 -- 0x100000 : reserved (ROM)

under 1MB, physical & logical addresses are directly mapped.
after 1MB, you're welcome in on-demand paged allocation

1MB -- 4MB : microkernel's shared memory. These pages will be same in every process.
4MB -- 4GB-8MB : current process space
4GB-8MB -- 4GB-4MB : current process' page tables
4GB-4MB -- 4GB : the "page frame viewer" : a place for the kernel to allocate virtual memory to watch any page frame it wants. The mapping set up here is identical in every process too.
Post Reply