problem with int 0x15 function 0xe801
problem with int 0x15 function 0xe801
Hello,
when i want to get memory size in real pc with 8gb of memory,
int 0x15 function 0xe801 just detect 512mb of that,
can you tell my what was my fault ?
note : in qemu emulator this function detects 128mb of memory that I think it is a plausible value.
thank you all
when i want to get memory size in real pc with 8gb of memory,
int 0x15 function 0xe801 just detect 512mb of that,
can you tell my what was my fault ?
note : in qemu emulator this function detects 128mb of memory that I think it is a plausible value.
thank you all
- Nutterts
- Member

- Posts: 159
- Joined: Wed Aug 05, 2015 5:33 pm
- Libera.chat IRC: Nutterts
- Location: Drenthe, Netherlands
Re: problem with int 0x15 function 0xe801
Afaik qemu has a default of 128MB so yeah, that seems legit. I can't explain why 0xE801 returns 512MB but imho you should be using 0XE820.
http://wiki.osdev.org/Detecting_Memory_ ... .3D_0xE820
http://wiki.osdev.org/Detecting_Memory_ ... .3D_0xE820
It is the only BIOS function that can detect memory areas above 4G.
"Always code as if the guy who ends up maintaining it will be a violent psychopath who knows where you live." - John F. Woods
Failed project: GoOS - https://github.com/nutterts/GoOS
Failed project: GoOS - https://github.com/nutterts/GoOS
Re: problem with int 0x15 function 0xe801
thanks,Nutterts wrote:Afaik qemu has a default of 128MB so yeah, that seems legit. I can't explain why 0xE801 returns 512MB but imho you should be using 0XE820.
http://wiki.osdev.org/Detecting_Memory_ ... .3D_0xE820
It is the only BIOS function that can detect memory areas above 4G.
i used this code :
Code: Select all
for (i = 0; i<multiboot.MMapEntryCount; i++)
MemorySize += (Region[i].SizeHigh<<32) + Region[i].SizeLow;
so i think there is another problem :
My Memory has 25 region and every region (as you know) has two important property (starting address and length).
Starting Address of 17th region of my memory is : 1
output of some print function for that was : (Start Addresses Are in Decimal While Length is in Hexadecimal)
Code: Select all
start : -1157726208, length : 0x018000
start : 1, length : 0x13FE00000
start : -1149239296, length : 0x04200000
thanks.
- BrightLight
- Member

- Posts: 901
- Joined: Sat Dec 27, 2014 9:11 am
- Location: Maadi, Cairo, Egypt
- Contact:
Re: problem with int 0x15 function 0xe801
From the Wiki on INT 0x15 function 0xE801:RezaNoei wrote:int 0x15 function 0xe801 just detect 512mb of that
It is built to handle the 15M memory hole, but stops at the next hole / memory mapped device / reserved area above that.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
-
Octocontrabass
- Member

- Posts: 6298
- Joined: Mon Mar 25, 2013 7:01 pm
Re: problem with int 0x15 function 0xe801
I think this would be a lot easier to figure out if you knew what the memory map was supposed to look like.RezaNoei wrote:what do you think about it ?
Download this and write it to a floppy disk or flash drive. It's a disk image, so you must use a tool like HxD (Windows) or dd (Linux, etc.) to write it to the disk. When you boot it, it will display a memory map.
- 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: problem with int 0x15 function 0xe801
I can tell that this map is bogus, and that you should also take a very good look at your print functions.RezaNoei wrote:what do you think about it ?Code: Select all
start : -1157726208, length : 0x018000 start : 1, length : 0x13FE00000 start : -1149239296, length : 0x04200000
Re: problem with int 0x15 function 0xe801
thank you,Octocontrabass wrote:I think this would be a lot easier to figure out if you knew what the memory map was supposed to look like.RezaNoei wrote:what do you think about it ?
Download this and write it to a floppy disk or flash drive. It's a disk image, so you must use a tool like HxD (Windows) or dd (Linux, etc.) to write it to the disk. When you boot it, it will display a memory map.
that works fine,
as i think, number of regions that you print out at the end is in hex, so 019 is the same 25 in decimal, then it has the same value.
as my friends said to me, i think the problem is in my printf function, your image displays this output for that regions :
Code: Select all
region 16 : 00000000bafe8000-0000000000018000-00000003-00000001
region 17 : 0000000100000000-000000013FE00000-00000001-00000001 // My printf function print this line with wrong values.
region 18 : 00000000bb800000-0000000004200000-00000002-00000001
thank you again,
Re: problem with int 0x15 function 0xe801
isn't something wrong with this result ?RezaNoei wrote:
as my friends said to me, i think the problem is in my printf function, your image displays this output for that regions :Code: Select all
region 16 : 00000000bafe8000-0000000000018000-00000003-00000001 region 17 : 0000000100000000-000000013FE00000-00000001-00000001 // My printf function print this line with wrong values. region 18 : 00000000bb800000-0000000004200000-00000002-00000001
region 17 : starting address is 2^64 . what is this means ?
-
Octocontrabass
- Member

- Posts: 6298
- Joined: Mon Mar 25, 2013 7:01 pm
Re: problem with int 0x15 function 0xe801
No, that's 2^32.RezaNoei wrote:2^64
Re: problem with int 0x15 function 0xe801
Octocontrabass wrote:No, that's 2^32.RezaNoei wrote:2^64
thanks,
i have improved my stdio.h and my printf function,
there is an interesting output about my memory size; when i added size of regions to get the real size, the result shows 8255MB !
but my real memory size is 8GB or 8192MB,
is this different will cause some problem in the next developments ?
and another problem that i faced to, was frequent casting, when i want to add a uint64_t value with another value, i had to cast lower bit value (e.g. uint32_t) to uint64_t, in assignments and even in printf function and ... .
how can i get ride of this frequently casting ?
-
Octocontrabass
- Member

- Posts: 6298
- Joined: Mon Mar 25, 2013 7:01 pm
Re: problem with int 0x15 function 0xe801
That's because some of the regions are not RAM. You should only add the ones that are usable RAM.RezaNoei wrote:when i added size of regions to get the real size, the result shows 8255MB !
Re: problem with int 0x15 function 0xe801
Octocontrabass wrote:That's because some of the regions are not RAM. You should only add the ones that are usable RAM.RezaNoei wrote:when i added size of regions to get the real size, the result shows 8255MB !
ok, Now I Can Breathe The Fresh AirOctocontrabass wrote:That's because some of the regions are not RAM. You should only add the ones that are usable RAM.RezaNoei wrote:when i added size of regions to get the real size, the result shows 8255MB !
i have removed Address Range Type 2 (Reserved Bytes), And Result became true (i guess); 8102MB !
And i think that is the safe area for managing the memory, isn't right ?
thank you for all,
-
Octocontrabass
- Member

- Posts: 6298
- Joined: Mon Mar 25, 2013 7:01 pm
Re: problem with int 0x15 function 0xe801
No. You can only use type 1 (RAM) and type 3 (ACPI reclaimable RAM), all other types are not usable RAM.RezaNoei wrote:i have removed Address Range Type 2 (Reserved Bytes), And Result became true (i guess); 8102MB !
And i think that is the safe area for managing the memory, isn't right ?
The result can also be wrong if some ranges overlap, but that doesn't happen very often. When you have a memory manager, you will need to divide RAM into pages, so you might also lose some RAM if the range is not aligned to page boundaries.
Re: problem with int 0x15 function 0xe801
Ok,Octocontrabass wrote:No. You can only use type 1 (RAM) and type 3 (ACPI reclaimable RAM), all other types are not usable RAM.RezaNoei wrote:i have removed Address Range Type 2 (Reserved Bytes), And Result became true (i guess); 8102MB !
And i think that is the safe area for managing the memory, isn't right ?
The result can also be wrong if some ranges overlap, but that doesn't happen very often. When you have a memory manager, you will need to divide RAM into pages, so you might also lose some RAM if the range is not aligned to page boundaries.
Thanks.
excuse me, im not a bold one
when we want to print some 64bit value like 0x0123456789ABCDEF in a not free-standing environment (e.g linux or window or ...)
it's enough to write :
Code: Select all
printf("\nuint64_t 0x0123456789ABCDEF = 0x%016lx\n",0x0123456789ABCDEF);
Code: Select all
printf("\nuint64_t 0x0123456789ABCDEF = 0x%016lx\n",(uint64_t)0x0123456789ABCDEF);
^
i learned from some places that, the problem is about CPU's (32bit) register size.
i wish to pay back you kindness, someday
Last edited by RezaNoei on Sun Sep 20, 2015 8:40 am, edited 1 time in total.
- 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: problem with int 0x15 function 0xe801
Please learn some C before making matters worse: http://forums.codeguru.com/showthread.p ... es-0L-mean
