Using the top of ram.

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
User avatar
astrocrep
Member
Member
Posts: 127
Joined: Sat Apr 21, 2007 7:21 pm

Using the top of ram.

Post by astrocrep »

Basically I want to push my paging structures and mm bitmap at the top of ram.

What I am doing is:

Code: Select all

char *temp;
temp = (char *) ((mbd->mem_upper + 1024) * 1024);
temp[0] = 0x1;
--or--
*temp = 0x1;
That works without error... but if I

Code: Select all

temp[1] = 0x1;
--or--
*temp++;
*temp  = 0x1;
It doesn't error out either... I would expect it to crash if or do something if I am pointing out of bounds of memory...

NOTE: mbd is the grub multiboot record.

Whats the deal...

Thanks,
Rich
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post by pcmattman »

Remember, there's usually 640K as well (LOWER memory).
User avatar
astrocrep
Member
Member
Posts: 127
Joined: Sat Apr 21, 2007 7:21 pm

Post by astrocrep »

Well grub says... here the amount of ram above 1mb, thats why I add on the 1024 before I convert it to bytes.

I am assuming that the memory wraps?? I tried setting a ptr to like 1gb in a system where only 128mb ram is present (and paging is off) and it set a byte without issue...

??

-Rich
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Post by Brendan »

Hi,
astrocrep wrote:I am assuming that the memory wraps?? I tried setting a ptr to like 1gb in a system where only 128mb ram is present (and paging is off) and it set a byte without issue...
It doesn't wrap - there's 4 GB (or more) of physical address space. Some of the space has RAM connected to it, some has ROM, some has memory mapped devices and some of it has nothing connected to it.

When you write to "top of RAM + 1 KB" you're writing to nothing. If you try to read the value back you'll probably (but not necessarily) read back 0xFFFFFFF, regardless of what value you wrote.

It's a bit like writing a letter addressed to "The Aliens" - you can send the letter, but don't expect the aliens to actually receive it.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
astrocrep
Member
Member
Posts: 127
Joined: Sat Apr 21, 2007 7:21 pm

Post by astrocrep »

Ahh...

Thank you! Crystal clear now.

-Rich
Post Reply