Max. no. entries that can be returned by 0xE820

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
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Max. no. entries that can be returned by 0xE820

Post by BrightLight »

My OS uses BIOS function 0xE820 to detect memory. Before the function starts, I simply have 1024 bytes reserved in my kernel to make space for the memory map. Assuming each entry size is 24 bytes, what is the maximum number of entries that this function can return? I am asking for the sake of keeping my kernel's binary as small as possible.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
alexg
Posts: 16
Joined: Sun Mar 06, 2016 11:59 am

Re: Max. no. entries that can be returned by 0xE820

Post by alexg »

On the systems you will be testing it probably won't exceed 1024 bytes. On huge servers, with TBs of RAM you can expect to have more entries than you can fit in 1024 bytes (I've seen such a machine to have an entry for 8 bytes of memory :)).

If you really want to be able to collect all the entries without increasing the kernel binary too much why don't you 'dynamically' allocate this data? In this stage I guest you don't have a memory allocator, but you could pick any unused memory area in the first MB of physical space.
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: Max. no. entries that can be returned by 0xE820

Post by BrightLight »

alexg wrote:On the systems you will be testing it probably won't exceed 1024 bytes. On huge servers, with TBs of RAM you can expect to have more entries than you can fit in 1024 bytes (I've seen such a machine to have an entry for 8 bytes of memory :)).

If you really want to be able to collect all the entries without increasing the kernel binary too much why don't you 'dynamically' allocate this data? In this stage I guest you don't have a memory allocator, but you could pick any unused memory area in the first MB of physical space.
My kernel is loaded in the first MB of physical space. It lives in low memory and cannot grow more than 512 KB in size. I will fix this some day when my kernel must get bigger than this limit, but now it's just because I am lazy to write a full 64-bit boot loader for my file system that I am constantly redesigning.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
madanra
Member
Member
Posts: 149
Joined: Mon Sep 07, 2009 12:01 pm

Re: Max. no. entries that can be returned by 0xE820

Post by madanra »

The space you store the entries shouldn't be in the kernel, otherwise you're loading zeros that you're just going to overwrite.
Post Reply