Page 1 of 2

problem with int 0x15 function 0xe801

Posted: Wed Sep 16, 2015 12:08 pm
by RezaNoei
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

Re: problem with int 0x15 function 0xe801

Posted: Wed Sep 16, 2015 1:00 pm
by Nutterts
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.

Re: problem with int 0x15 function 0xe801

Posted: Wed Sep 16, 2015 3:45 pm
by RezaNoei
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.
thanks,

i used this code :

Code: Select all

for (i = 0; i<multiboot.MMapEntryCount; i++)
	MemorySize += (Region[i].SizeHigh<<32) + Region[i].SizeLow;
and the result was 4159MB, while i have 8GB of memory, is that was correct ?

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
what do you think about it ?

thanks.

Re: problem with int 0x15 function 0xe801

Posted: Wed Sep 16, 2015 5:56 pm
by BrightLight
RezaNoei wrote:int 0x15 function 0xe801 just detect 512mb of that
From the Wiki on INT 0x15 function 0xE801:
It is built to handle the 15M memory hole, but stops at the next hole / memory mapped device / reserved area above that.

Re: problem with int 0x15 function 0xe801

Posted: Wed Sep 16, 2015 6:27 pm
by Octocontrabass
RezaNoei wrote:what do you think about it ?
I think this would be a lot easier to figure out if you knew what the memory map was supposed to look like.

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.

Re: problem with int 0x15 function 0xe801

Posted: Thu Sep 17, 2015 12:50 am
by Combuster
RezaNoei wrote:

Code: Select all

  start : -1157726208,     length : 0x018000
  start : 1,                      length : 0x13FE00000
  start : -1149239296,     length : 0x04200000
what do you think about it ?
I can tell that this map is bogus, and that you should also take a very good look at your print functions.

Re: problem with int 0x15 function 0xe801

Posted: Thu Sep 17, 2015 2:28 am
by RezaNoei
Octocontrabass wrote:
RezaNoei wrote:what do you think about it ?
I think this would be a lot easier to figure out if you knew what the memory map was supposed to look like.

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.
thank you,

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
i should rewrite my print function.

thank you again,

Re: problem with int 0x15 function 0xe801

Posted: Thu Sep 17, 2015 5:23 am
by RezaNoei
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
isn't something wrong with this result ?

region 17 : starting address is 2^64 . what is this means ?

Re: problem with int 0x15 function 0xe801

Posted: Thu Sep 17, 2015 5:34 am
by Octocontrabass
RezaNoei wrote:2^64
No, that's 2^32.

Re: problem with int 0x15 function 0xe801

Posted: Sat Sep 19, 2015 6:47 am
by RezaNoei
Octocontrabass wrote:
RezaNoei wrote:2^64
No, that's 2^32.
#-o :wink:

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 ?

Re: problem with int 0x15 function 0xe801

Posted: Sat Sep 19, 2015 7:11 am
by Octocontrabass
RezaNoei wrote:when i added size of regions to get the real size, the result shows 8255MB !
That's because some of the regions are not RAM. You should only add the ones that are usable RAM.

Re: problem with int 0x15 function 0xe801

Posted: Sat Sep 19, 2015 1:01 pm
by RezaNoei
Octocontrabass wrote:
RezaNoei wrote:when i added size of regions to get the real size, the result shows 8255MB !
That's because some of the regions are not RAM. You should only add the ones that are usable RAM.
Octocontrabass wrote:
RezaNoei wrote:when i added size of regions to get the real size, the result shows 8255MB !
That's because some of the regions are not RAM. You should only add the ones that are usable RAM.
ok, Now I Can Breathe The Fresh Air :lol:

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,

Re: problem with int 0x15 function 0xe801

Posted: Sun Sep 20, 2015 2:45 am
by Octocontrabass
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 ?
No. You can only use type 1 (RAM) and type 3 (ACPI reclaimable RAM), all other types are not usable RAM.

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

Posted: Sun Sep 20, 2015 8:24 am
by RezaNoei
Octocontrabass wrote:
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 ?
No. You can only use type 1 (RAM) and type 3 (ACPI reclaimable RAM), all other types are not usable RAM.

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.
Ok,
Thanks.

excuse me, im not a bold one :oops: but i have another problem :
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);
but in os development environment (free-standing) i should add some extra casting :

Code: Select all

        printf("\nuint64_t 0x0123456789ABCDEF = 0x%016lx\n",(uint64_t)0x0123456789ABCDEF);
                                                            ^
this problem is not limited to print function, this true about the all other 64bit operations,
i learned from some places that, the problem is about CPU's (32bit) register size.
i wish to pay back you kindness, someday :wink:

Re: problem with int 0x15 function 0xe801

Posted: Sun Sep 20, 2015 8:39 am
by Combuster
Please learn some C before making matters worse: http://forums.codeguru.com/showthread.p ... es-0L-mean