Copy Link
Add to Bookmark
Report

Modify GP32's MMU tables and change caching settings

sang's profile picture
Published in 
GP32
 · 4 Mar 2024

The following simple example shows how to modify GP32's MMU tables in order to change caching settings. This is especially useful if you want to move your frame buffers into "user RAM area" i.e. somewhere between 0x0C000000 and 0x0C79C000. The example uses BIOS call to do the job. Keep in mind that the granularity of MMU pages is 4KB, which means that the addresses you feed into the BIOS call must 4KB aligned addresses.

    // C example and using SDK - libgpstdlib.a 
//

void swi_mmu_change( void* start_addr, void* end_addr, ulong flags );

start_addr - a starting address of the memory region you
want these MMU changes to affect.
end_addr - an end address of the memory reqion you want
these MMU changes to affect.
flags - This value is ORed to the second level MMU page
table descriptor. Only the low 12 bits are used.
use:
0xFF2 - to disable cache and writeback
0xFFA - to enable cache and disable writeback
0xFFE - to enable cache and writeback

For example to turn on caching but disabling writeback from
0xc66A000 to 0xc700000 call BIOS function with the following
parameters:

swi_mmu_change( 0xC66A000, 0xC6FFFFF, 0xFFA );

@ ASM example and not using SDK
@

r0 = start_addr
r1 = end_addr
r2 = flags

BIOS call: SWI #0x02

For example to turn on caching but disabling writeback from
0xc66A000 to 0xc700000 call BIOS function with the following
parameters:

ldr r0,strt
ldr r1,end
ldr r2,flg
swi #0x02
...

strt: .word 0xC66A000
end: .word 0xC6FFFFF
flg: .word 0xFFA

So when you are defining caching for your custom frame buffers make sure that the writeback is disabled. The BIOS disables caching and writeback for frame buffers but I have tested frame buffers with cache on and they seemed to work (no guarantees though). You can play safe and use 0xFF2.

← previous
next →
loading
sending ...
New to Neperos ? Sign Up for free
download Neperos App from Google Play
install Neperos as PWA

Let's discover also

Recent Articles

Recent Comments

Neperos cookies
This website uses cookies to store your preferences and improve the service. Cookies authorization will allow me and / or my partners to process personal data such as browsing behaviour.

By pressing OK you agree to the Terms of Service and acknowledge the Privacy Policy

By pressing REJECT you will be able to continue to use Neperos (like read articles or write comments) but some important cookies will not be set. This may affect certain features and functions of the platform.
OK
REJECT