I was also alarmed to find that when I attempted to count all forms of RAM (reserved and otherwise), the number didn't change in Bochs.
Anyway, the base question is: Am I just losing precision somewhere or is that 1% untouchable or is the memory map broken? I'm sorta worried because the manipulation of qwords is just a tad awkward...
If you need reference: here is the ASM for loading the e820 tables:
Code: Select all
xor ebx,ebx
mov es, bx
mov di, 0x4EC
ramloop:
mov eax,0x0000E820
mov edx,0x534D4150
mov ecx,20
add di,20
int 0x15
jc error
cmp ebx, 00000000h
je read
jmp ramloop
Code: Select all
struct mmap
{
long long base;
long long length;
int type;
};
struct converter
{
int top;
int bottom;
};
struct mmap *testmap = (struct mmap *) 0x500;
int i = 0;
long long totalRAM = 0;
for (i=0;i<10;i++)
{
if(testmap[i].type == 1) ;There was a type, thanks Pype.
totalRAM += testmap[i].length;
}
struct converter *displayableRAM;
displayableRAM = &totalRAM;
k_printf("Displayable RAM:%d + %d", 0, 13, displayableRAM[0].top, displayableRAM[0].bottom);