problem with int 0x15 function 0xe801

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.
User avatar
RezaNoei
Member
Member
Posts: 40
Joined: Sun Jun 01, 2014 1:39 pm

problem with int 0x15 function 0xe801

Post 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
User avatar
Nutterts
Member
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

Post 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.
"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
User avatar
RezaNoei
Member
Member
Posts: 40
Joined: Sun Jun 01, 2014 1:39 pm

Re: problem with int 0x15 function 0xe801

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

Re: problem with int 0x15 function 0xe801

Post 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.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
Octocontrabass
Member
Member
Posts: 6298
Joined: Mon Mar 25, 2013 7:01 pm

Re: problem with int 0x15 function 0xe801

Post 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.
User avatar
Combuster
Member
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

Post 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.
"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 ]
User avatar
RezaNoei
Member
Member
Posts: 40
Joined: Sun Jun 01, 2014 1:39 pm

Re: problem with int 0x15 function 0xe801

Post 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,
User avatar
RezaNoei
Member
Member
Posts: 40
Joined: Sun Jun 01, 2014 1:39 pm

Re: problem with int 0x15 function 0xe801

Post 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 ?
Octocontrabass
Member
Member
Posts: 6298
Joined: Mon Mar 25, 2013 7:01 pm

Re: problem with int 0x15 function 0xe801

Post by Octocontrabass »

RezaNoei wrote:2^64
No, that's 2^32.
User avatar
RezaNoei
Member
Member
Posts: 40
Joined: Sun Jun 01, 2014 1:39 pm

Re: problem with int 0x15 function 0xe801

Post 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 ?
Octocontrabass
Member
Member
Posts: 6298
Joined: Mon Mar 25, 2013 7:01 pm

Re: problem with int 0x15 function 0xe801

Post 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.
User avatar
RezaNoei
Member
Member
Posts: 40
Joined: Sun Jun 01, 2014 1:39 pm

Re: problem with int 0x15 function 0xe801

Post 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,
Octocontrabass
Member
Member
Posts: 6298
Joined: Mon Mar 25, 2013 7:01 pm

Re: problem with int 0x15 function 0xe801

Post 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.
User avatar
RezaNoei
Member
Member
Posts: 40
Joined: Sun Jun 01, 2014 1:39 pm

Re: problem with int 0x15 function 0xe801

Post 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:
Last edited by RezaNoei on Sun Sep 20, 2015 8:40 am, edited 1 time in total.
User avatar
Combuster
Member
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

Post by Combuster »

Please learn some C before making matters worse: http://forums.codeguru.com/showthread.p ... es-0L-mean
"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 ]
Post Reply