diff options
author | John Willis | 2007-06-26 08:50:11 +0000 |
---|---|---|
committer | John Willis | 2007-06-26 08:50:11 +0000 |
commit | 11fccdbff242ec238d9ccd86525bfa5a41be01bc (patch) | |
tree | 000f978497697b56311fd2602bcb4ed64fde3a96 /backends/platform/gp2x/gp2x-mem.c | |
parent | cf0eb563adb10454b1a4c9b0d7c387526b348b30 (diff) | |
download | scummvm-rg350-11fccdbff242ec238d9ccd86525bfa5a41be01bc.tar.gz scummvm-rg350-11fccdbff242ec238d9ccd86525bfa5a41be01bc.tar.bz2 scummvm-rg350-11fccdbff242ec238d9ccd86525bfa5a41be01bc.zip |
Cleanup of the GP2X port to fix compile issues (and the odd warning).
svn-id: r27728
Diffstat (limited to 'backends/platform/gp2x/gp2x-mem.c')
-rw-r--r-- | backends/platform/gp2x/gp2x-mem.c | 124 |
1 files changed, 73 insertions, 51 deletions
diff --git a/backends/platform/gp2x/gp2x-mem.c b/backends/platform/gp2x/gp2x-mem.c index f129deb783..1c2c1562a8 100644 --- a/backends/platform/gp2x/gp2x-mem.c +++ b/backends/platform/gp2x/gp2x-mem.c @@ -39,20 +39,22 @@ #include "gp2x-mem.h" -void InitRam (void) -{ - if(!gp2x_dev) - { - gp2x_dev = open("/dev/mem", O_RDWR); - gp2x_ram = (unsigned short *)mmap(0, 0x10000, 3, 1, gp2x_dev, 0x03000000); - gp2x_memregs = (unsigned short *)mmap(0, 0x10000, 3, 1, gp2x_dev, 0xc0000000); - } -} - -void CloseRam (void) -{ - if(gp2x_dev) close(gp2x_dev); -} +char uname[256]; + +//void InitRam (void) +//{ +// if(!gp2x_dev) +// { +// gp2x_dev = open("/dev/mem", O_RDWR); +// gp2x_ram = (unsigned short *)mmap(0, 0x10000, 3, 1, gp2x_dev, 0x03000000); +// gp2x_memregs = (unsigned short *)mmap(0, 0x10000, 3, 1, gp2x_dev, 0xc0000000); +// } +//} + +//void CloseRam (void) +//{ +// if(gp2x_dev) close(gp2x_dev); +//} /* ****** [BEGIN] Squidge's MMU hack code ****** @@ -201,34 +203,30 @@ int hackpgtable (void) // do this in user mode, so we have to patch the kernel to get it to run it for us in supervisor mode. We dothis // at the moment by overwriting the sys_newuname function and then calling it. - lseek (gp2x_dev, 0x6ec00, SEEK_SET); // fixme: We should ask the kernel for this address rather than assuming it... - read (gp2x_dev, &oldc1, 4); - read (gp2x_dev, &oldc2, 4); - read (gp2x_dev, &oldc3, 4); - read (gp2x_dev, &oldc4, 4); - - printf ("0:%08X %08X - %08X %08X\n", oldc1, oldc2, newc1, newc2); - + lseek (gp2x_dev[2], 0x6ec00, SEEK_SET); // fixme: We should ask the kernel for this address rather than assuming it... + read (gp2x_dev[2], &oldc1, 4); + read (gp2x_dev[2], &oldc2, 4); + read (gp2x_dev[2], &oldc3, 4); + read (gp2x_dev[2], &oldc4, 4); + //printf ("0:%08X %08X - %08X %08X\n", oldc1, oldc2, newc1, newc2); + //printf ("point1 %d\n",a); - printf ("point1 %d\n",a); do { - lseek (gp2x_dev, 0x6ec00, SEEK_SET); - a+=write (gp2x_dev, &newc1, 4); - a+=write (gp2x_dev, &newc2, 4); + lseek (gp2x_dev[2], 0x6ec00, SEEK_SET); + a+=write (gp2x_dev[2], &newc1, 4); + a+=write (gp2x_dev[2], &newc2, 4); SDL_Delay(200); try++; - ttb = myuname(name); - printf ("2:%08X try %d\n", ttb,try); + ttb = myuname(uname); + //printf ("2:%08X try %d\n", ttb,try); } while (ttb==0 && try<4); + lseek (gp2x_dev[2], 0x6ec00, SEEK_SET); + a+=write (gp2x_dev[2], &oldc1, 4); + a+=write (gp2x_dev[2], &oldc2, 4); - - lseek (gp2x_dev, 0x6ec00, SEEK_SET); - a+=write (gp2x_dev, &oldc1, 4); - a+=write (gp2x_dev, &oldc2, 4); - - printf ("2:%08X %d\n", ttb,a); + //printf ("2:%08X %d\n", ttb,a); if (ttb!=0) { @@ -243,28 +241,28 @@ int hackpgtable (void) unsigned int tlbc3 = 0xee080f17; // mcr 15, 0, r0, cr8, cr7, 0 unsigned int tlbc4 = 0xe1a0f00e; // mov pc, lr - lseek (gp2x_dev, 0x6ec00, SEEK_SET); - write (gp2x_dev, &tlbc1, 4); - write (gp2x_dev, &tlbc2, 4); - write (gp2x_dev, &tlbc3, 4); - write (gp2x_dev, &tlbc4, 4); + lseek (gp2x_dev[2], 0x6ec00, SEEK_SET); + write (gp2x_dev[2], &tlbc1, 4); + write (gp2x_dev[2], &tlbc2, 4); + write (gp2x_dev[2], &tlbc3, 4); + write (gp2x_dev[2], &tlbc4, 4); SDL_Delay(200); - ttx = myuname(name); + ttx = myuname(uname); printf ("Return from uname: %08X\n", ttx); - lseek (gp2x_dev, 0x6ec00, SEEK_SET); - write (gp2x_dev, &oldc1, 4); - write (gp2x_dev, &oldc2, 4); - write (gp2x_dev, &oldc3, 4); - write (gp2x_dev, &oldc4, 4); - lseek (gp2x_dev, 0x0, SEEK_SET); + lseek (gp2x_dev[2], 0x6ec00, SEEK_SET); + write (gp2x_dev[2], &oldc1, 4); + write (gp2x_dev[2], &oldc2, 4); + write (gp2x_dev[2], &oldc3, 4); + write (gp2x_dev[2], &oldc4, 4); + lseek (gp2x_dev[2], 0x0, SEEK_SET); return 0; } - lseek (gp2x_dev, 0x0, SEEK_SET); + lseek (gp2x_dev[2], 0x0, SEEK_SET); return 1; //printf ("Restored contents\n"); @@ -292,10 +290,34 @@ void SetClock (unsigned c) gp2x_memregs[0x910>>1] = v; } -void MMUpatch (void) +void patchMMU (void) { - volatile unsigned int *secbuf = (unsigned int *)malloc (204800); + //volatile unsigned int *secbuf = (unsigned int *)malloc (204800); - // Squidge's MMU hack - hackpgtable(); + printf ("Reconfiguring cached memory regions...\n"); + + //hackpgtable(); + //printf ("Sucess...\n"); + + system("/sbin/rmmod mmuhack"); + system("/sbin/insmod -f mmuhack.o"); + + int mmufd = open("/dev/mmuhack", O_RDWR); + + if(mmufd < 0) + { + printf ("Upper memory uncached (attempt failed, access to upper memory will be slower)...\n"); + } + else + { + printf ("Upper memory cached...\n"); + close(mmufd); + } +} + +void unpatchMMU (void) +{ + printf ("Restoreing cached memory regions...\n"); + system("/sbin/rmmod mmuhack"); + return 1; } |