How To Use The Mmu Hack.


GP2X_Coder

Member
Joined
May 17, 2006
Messages
220
Age
51
Location
USA
Website
mysite.verizon.net
After you have access to the upper 32mb of memory how do you make use of it? Is it compatible with the official SDK and if so how do I go about using it? I can gain access to the upper 32mb fine but do not know how to use the memory for my benefit any help would be great. Thanks.
 
The 'easy mode' to it IMHO is to mmap it so you've got a pointer to the extra 32MB; you can't use free/malloc/etc to use it, but you can manage it yourself.

ie:

Instead of using 'free', use my_free() or somesuch; I tend to wrap up most system calls anyway, for portability, so that I can do whatever I like. ie: In my_free() you could use 'free' but do somethign else in an #ifdef on other platforms.

So, write your own malloc/free replacements, then fetch from normal RAM until you get low, and then from high memory, say.

jeff
 
As I said in the other thread, it's in the Wiki.

Code:
  int Uppermemfd;
  unsigned char* UpperMem;
  Uppermemfd = open("/dev/mem", O_RDWR); //Open the memory for reading/writing
  UpperMem = (unsigned char*)mmap(0, 0x2000000, PROT_READ|PROT_WRITE, MAP_SHARED, Uppermemfd, 0x2000000); //mmap the upper 32MB.

This gives you a pointer (UpperMem) to use to access the upper 32MB. It doesn't extend the heap size or give SDL any extra memory to use, you can do what you like with it.

You have to manage the memory yourself - the Wiki includes functions for providing a malloc function.

P.S. did I mention the Wiki? :)

P.P.S. This is not the MMU hack, just a way of accessing the upper 32MB of memory, which is what I believe you were looking for.
 
Parkydr posted on Oct 13 2006 at 03:27 PM said:
As I said in the other thread, it's in the Wiki.

Code:
  int Uppermemfd;
  unsigned char* UpperMem;
  Uppermemfd = open("/dev/mem", O_RDWR); //Open the memory for reading/writing
  UpperMem = (unsigned char*)mmap(0, 0x2000000, PROT_READ|PROT_WRITE, MAP_SHARED, Uppermemfd, 0x2000000); //mmap the upper 32MB.

This gives you a pointer (UpperMem) to use to access the upper 32MB. It doesn't extend the heap size or give SDL any extra memory to use, you can do what you like with it.

You have to manage the memory yourself - the Wiki includes functions for providing a malloc function.

P.S. did I mention the Wiki? :)

P.P.S. This is not the MMU hack, just a way of accessing the upper 32MB of memory, which is what I believe you were looking for.

Thanks guys for the response. Parkydr I have a question for you I understand how to get access to the extended memory no problem but what I am looking for is how do I use it to store the extra data say I have over 40mb of graphic data to load in with sdl load image can I make use of the extra memory to access it from there how do I have sdl store it there if it can. I am just a little confused with it thats all. I have access to the memory fine but don't know how to use it with the sdl functions.
 
Last edited by a moderator:
Read up ;)

Since you can nolonger use malloc/free to access it, anythign that does (buried in a lib) is out of luck; if SDL uses SDL_malloc or something, then you could perhaps modify that to in turn call your own special malloc routine, for instance.

jeff
 
Sorry, I misunderstood your question.

What you want is for sdl image image to create an SDL_Surface at a specific memory location in the upper 32Mb. I don't know if that is possible - I haven't done anything like this.

You could load the image then copy the pixels part of the surface to memory, but you'd have to write a function to blit it to the screen.

I'm no expert on this, others may know a better way.
 
If I enable it and use it for the hardware blitter will it speed up any of the emulation? I know the wiki says that it will speed up programs but it can't be by to much or it would already be enabled...right?
 
Back
Top