View Full Version : GP2x: accessing hw regs from asm

30-03-2008, 06:00 PM
I translated the SDL function gp2x_joystick_read to Pascal, using fpMmap and /dev/mem.

Will the ARM throw an exception if I access the hw regs directly? I could 'try', but I'd like to know the proper way to do full access full speed hw access.

I dunno how many GP2x guys are on here... getting an answer is a long shot maybe? :)

30-03-2008, 06:57 PM
AFAIK you can access hw registers in two way:

MY_REGISTER: pinteger = pointer($04000000);


MY_REGISTER: pinteger absolute $04000000;

I do it in arm nds and all works without exceptions, though I don't know if it works fine on gp2x because the linux OS :?

30-03-2008, 07:21 PM
Thanks for anwering!

But how do you know the hardware registers start on $04000000 on the gp2x?? :)

For system-stuff and games I would probably use SDL/Open2X or something. But for a demo, the ultimate goal is to

1. Get some resources from the OS with SWI's and own them, or point the hardware to my own buffers etc.
2. Get control of the interrupts and replace them with my own (simplification: turn off all ints and start my own little vsync interrupt
3. When demo is exited, provide a clean exit to menu after returning interrupts and resources to the system.

It's the way I make demos on all platforms, and I want to make sure I have full control and performance, i.e. no processes running in the background... it's not like people play videos or read pdfs while watching demos or playing games anyway :)

I would like to access hw regs physically, uncached. Frame and sound buffer could be taken from the upper 32MB, just don't know how to "malloc", mmapping means virtual access (?) which is slow and can't be used in asm.

But I'd still like to get base pointers etc, in case something is moved between firmware versions.

30-03-2008, 07:35 PM
You can access the hardware registers on the gp2x if you mmap them into your address space. To do so you open /dev/mem and then mmap a page at the right offset. It is very easy to do.

30-03-2008, 07:35 PM
The GP2X should have an open source sdk. Try to get the infos you need from it :)
BTW, try to ask in the official GP2X forums too and read this thread:


30-03-2008, 08:18 PM
Yep, I was on page 5 of the thread when I asked this, he seemed to do it with /dev/mem, so...

Is there a full list of hw registers and their bits, with official names of the constants? Or do you have to 'extract' them from the MagicEyes PDF? I have 100+MB of PDFs, still haven't found one :)

I'll be happy to make such a list if the info is available! But it almost seems like you have to talk to the chip companies to get the info :P