Organizing Memory
Organizing Memory
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?
Re: Organizing Memory
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.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?
Code: Select all
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 ?
Re: Organizing Memory
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.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.
Re: Organizing Memory
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 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 ?
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Organizing Memory
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.Isaac wrote: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.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.