OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Apr 23, 2024 4:52 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Organizing Memory
PostPosted: Wed May 06, 2015 1:35 pm 
Offline
Member
Member

Joined: Sat Dec 07, 2013 7:08 pm
Posts: 66
I'm trying to organize memory a little. There are different types of memory as we see on the map returned from BIOS INT 0x15 Function 0xE820. So the way I want to organize them is by enabling paging. When creating the page tables I want to put first all the pages that have type 1 page frames, then all the pages that have type 2 page frames, and so on. The problem I run into is that the sizes of some fields are not divisible by 4096. So, for example, what would I do if I encounter a type 2 field that's 2048 bytes long? I can't skip it just like that, it may be important. But I can't make a page frame out of it because it's not long enough. If I map a page to the beginning of such a field, the last 2048 bytes of the page will hang over to the next field which may be, say, a type 4 field. So what will happen is, I'll wind up with some type 2 memory, some type 4 memory and some more type 2 memory. But that's not in order! Is there any way I can do this?


Top
 Profile  
 
 Post subject: Re: Organizing Memory
PostPosted: Wed May 06, 2015 1:44 pm 
Offline
Member
Member

Joined: Thu Mar 25, 2010 11:26 pm
Posts: 1801
Location: Melbourne, Australia
Isaac wrote:
I'm trying to organize memory a little. There are different types of memory as we see on the map returned from BIOS INT 0x15 Function 0xE820. So the way I want to organize them is by enabling paging. When creating the page tables I want to put first all the pages that have type 1 page frames, then all the pages that have type 2 page frames, and so on. The problem I run into is that the sizes of some fields are not divisible by 4096. So, for example, what would I do if I encounter a type 2 field that's 2048 bytes long? I can't skip it just like that, it may be important. But I can't make a page frame out of it because it's not long enough. If I map a page to the beginning of such a field, the last 2048 bytes of the page will hang over to the next field which may be, say, a type 4 field. So what will happen is, I'll wind up with some type 2 memory, some type 4 memory and some more type 2 memory. But that's not in order! Is there any way I can do this?
I ignore any memory that is partly reserved. This is the map for my current machine. I ignore the page at 9f000. If a page is partly reserved then I reserve it all.
Code:
E820 info:
Memory   : base:000000000000 length:00000009f400 end:00000009f400 npages=159
Reserved : base:00000009f400 length:000000000c00 end:0000000a0000 npages=0
Reserved : base:0000000dc000 length:000000024000 end:000000100000 npages=36
Memory   : base:000000100000 length:00003fdf0000 end:00003fef0000 npages=261616
ACPI recl: base:00003fef0000 length:00000000f000 end:00003feff000 npages=15
ACPI NVS : base:00003feff000 length:000000001000 end:00003ff00000 npages=1
Memory   : base:00003ff00000 length:000000100000 end:000040000000 npages=256
Reserved : base:0000f0000000 length:000008000000 end:0000f8000000 npages=32768
Reserved : base:0000fec00000 length:000000010000 end:0000fec10000 npages=16
Reserved : base:0000fee00000 length:000000001000 end:0000fee01000 npages=1
Reserved : base:0000fffe0000 length:000000020000 end:000100000000 npages=32

_________________
If a trainstation is where trains stop, what is a workstation ?


Top
 Profile  
 
 Post subject: Re: Organizing Memory
PostPosted: Wed May 06, 2015 1:55 pm 
Offline
Member
Member

Joined: Sat Dec 07, 2013 7:08 pm
Posts: 66
gerryg400 wrote:
I ignore any memory that is partly reserved. This is the map for my current machine. I ignore the page at 9f000. If a page is partly reserved then I reserve it all.

I think type 2 memory might also include memory mapped I/O in which case you can't ignore it. But I'm not sure about that.


Top
 Profile  
 
 Post subject: Re: Organizing Memory
PostPosted: Wed May 06, 2015 3:21 pm 
Offline
Member
Member

Joined: Thu Mar 25, 2010 11:26 pm
Posts: 1801
Location: Melbourne, Australia
Type 2 is reserved. Don't map it. If any part of a page is reserved then treat it all as reserved.

If later on you find that some MMIO is in the reserved area map it then.

_________________
If a trainstation is where trains stop, what is a workstation ?


Top
 Profile  
 
 Post subject: Re: Organizing Memory
PostPosted: Thu May 07, 2015 1:48 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
Isaac wrote:
gerryg400 wrote:
I ignore any memory that is partly reserved. This is the map for my current machine. I ignore the page at 9f000. If a page is partly reserved then I reserve it all.
I think type 2 memory might also include memory mapped I/O in which case you can't ignore it. But I'm not sure about that.

There are so many things that aren't memory. They all share the same thing: you don't have to guess where they are. You know the address in advance.

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 41 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group