Page 1 of 1
Memory Map using 0xe820
Posted: Mon Sep 22, 2003 11:05 am
by guest
I want to know how to display extended memory map of a computer i have used the INT 15h,0xe820 and have read that it returns memory map. how can i display this or use it. I read the Ralph interrupt list but cant understand it very well. Please help.
Also how to use more than 64Mb in BOCHS and test?
Re:Memory Map using 0xe820
Posted: Mon Sep 22, 2003 11:04 pm
by mr. xsism
Code: Select all
push ds
pop es
mov di,0x500
xor ebx,ebx
get_e820:
mov eax,0x0000E820
mov ecx,0x20
mov edx,0x534D4150
int 0x15
jc e820_end
cmp eax,0x534D4150
jne e820_end
add dword di,20
cmp ebx,0
jne get_e820
e820_end:
That code puts the memory map at 0x500. When you read it you just follow as ralph brown's docs say.
address,length,type
qword,qword,dword
IIRC. So take that data and read what is there. I'll let you figure out the rest.
Regards,
mr. xsism
Re:Memory Map using 0xe820
Posted: Tue Sep 23, 2003 8:45 am
by Slasher
And if you are using a 32bit system ie x86 then you only need to read the first double word (32bits) in each field increasing the map address by 8 to get to the next field
so if map at 0x0500
then
first :-
base 0x0500 (read 32 bits from this address)
length 0x0508 (read 32 bits from this address)
type 0x0510 (read 32 bits from this address)
second :-
base 0x0518 (read 32 bits from this address)
length 0x0520 (read 32 bits from this address)
type 0x0528 (read 32 bits from this address)
Re:Memory Map using 0xe820
Posted: Tue Sep 23, 2003 10:16 am
by mr. xsism
that would work, but could have problems if the address is over 32bits. i suggest using long longbecause base and size are 64bit vars. But that would work too, for most situantions.
Regards,
mr. xsism
Re:Memory Map using 0xe820
Posted: Tue Sep 23, 2003 10:29 am
by Slasher
long long is compiler specific ie its for gcc, so he'll have to find out the equivalent for a different compiler if he's not using gcc or similar. Also we are using 32 bit systems but if we were in a 64bit system then there would be a default 64bit type just as a dword is the 32bit type in current systems.
But I also agree with your suggestions, the more ways of doing things the better ;D
Re:Memory Map using 0xe820
Posted: Tue Sep 23, 2003 11:04 am
by Tim
Incidentally, long long is standard in C99 onwards. However, the Microsoft compiler still uses __int64.
Re:Memory Map using 0xe820
Posted: Thu Sep 25, 2003 5:12 am
by Candy
if only to add to the confusion, GCC now sees "long long" as a mistake and warns for uses (which is odd, if it is C99) and uses normal long for 64-bit ints, at least, on 64-bit processors. (seen in docs for AMD64)
Re:Memory Map using 0xe820
Posted: Thu Sep 25, 2003 5:17 am
by Solar
Candy wrote:
GCC now sees "long long" as a mistake and warns for uses (which is odd, if it is C99)...
C99 compliance in gcc is still lacking.
Re:Memory Map using 0xe820
Posted: Fri Sep 26, 2003 10:17 am
by mr. xsism
get a newer version of gcc. This error ocurred for me once too. But not this time for some reason. Make sure that you are declaring it as "long long" and nothing else. It might also help to post the error you got.

Regards,
mr. xsism
Re:Memory Map using 0xe820
Posted: Sat Sep 27, 2003 2:33 pm
by Candy
mr. xsism wrote:
get a newer version of gcc. This error ocurred for me once too. But not this time for some reason. Make sure that you are declaring it as "long long" and nothing else. It might also help to post the error you got.
GCC 3.3.1 manual:
-Wlong-long
Warn if long long type is used. This is default. To inhibit the warning messages, use -Wno-long-long. Flags -Wlong-long and -Wno-long-long are taken into account only when -pedantic flag is used.
This kind of indicates that long long is deprecated (according to GCC), which shows it does support it (it is C99 compliant as far as long long is concerned) but it disadvises the use of it... which is odd to say the least.
Re:Memory Map using 0xe820
Posted: Mon Sep 29, 2003 5:56 pm
by Tim
If you ask gcc to be ANSI-compilant, it assumes you're programming for C89; in C89, long long is a syntax error. If you don't ask for strict ANSI compliance, gcc lets you use all of its many extensions, some of which happen to be included in C99 (like long long). However, gcc doesn't fully support C99 yet.