Memory Map using 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
guest

Memory Map using 0xe820

Post 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?
mr. xsism

Re:Memory Map using 0xe820

Post 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
Slasher

Re:Memory Map using 0xe820

Post 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)
mr. xsism

Re:Memory Map using 0xe820

Post 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
Slasher

Re:Memory Map using 0xe820

Post 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
Tim

Re:Memory Map using 0xe820

Post by Tim »

Incidentally, long long is standard in C99 onwards. However, the Microsoft compiler still uses __int64.
User avatar
Candy
Member
Member
Posts: 3883
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Memory Map using 0xe820

Post 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)
User avatar
Solar
Member
Member
Posts: 7632
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Memory Map using 0xe820

Post 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.
Every good solution is obvious once you've found it.
mr. xsism

Re:Memory Map using 0xe820

Post 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.


;) :o
Regards,
mr. xsism
User avatar
Candy
Member
Member
Posts: 3883
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Memory Map using 0xe820

Post 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.
Tim

Re:Memory Map using 0xe820

Post 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.
Post Reply