From: notaz Date: Thu, 5 Jul 2007 20:33:23 +0000 (+0000) Subject: better mmuhack usage X-Git-Tag: v1.85~709 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=55ca4154a2e8aa3687c4f73f2c4c4d5fcdc5a836;p=picodrive.git better mmuhack usage git-svn-id: file:///home/notaz/opt/svn/PicoDrive@184 be3aeb3a-fb24-0410-a615-afba39da0efa --- diff --git a/platform/gp2x/main.c b/platform/gp2x/main.c index 61579cfd..4d8317e8 100644 --- a/platform/gp2x/main.c +++ b/platform/gp2x/main.c @@ -63,7 +63,7 @@ void parse_cmd_line(int argc, char *argv[]) } if (unrecognized) { - printf("\n\n\nPicoDrive v" VERSION " (c) notaz, 2006\n"); + printf("\n\n\nPicoDrive v" VERSION " (c) notaz, 2006-2007\n"); printf("usage: %s [options] [romfile]\n", argv[0]); printf( "options:\n" "-menu launch a custom program on exit instead of default gp2xmenu\n" diff --git a/platform/gp2x/squidgehack.c b/platform/gp2x/squidgehack.c index f831bd4f..36e9bcbe 100644 --- a/platform/gp2x/squidgehack.c +++ b/platform/gp2x/squidgehack.c @@ -12,25 +12,29 @@ extern char **g_argv; int mmuhack(void) { char kocmd[1024]; - int i, mmufd = open("/dev/mmuhack", O_RDWR); - - if(mmufd < 0) { - strcpy(kocmd, "/sbin/insmod "); - strncpy(kocmd+13, g_argv[0], 1023-13); - kocmd[1023] = 0; - for (i = strlen(kocmd); i > 0; i--) - if (kocmd[i] == '/') { kocmd[i] = 0; break; } - strcat(kocmd, "/mmuhack.o"); - - printf("Installing NK's kernel module for Squidge MMU Hack (%s)...\n", kocmd); - system(kocmd); - mmufd = open("/dev/mmuhack", O_RDWR); - } + int i, mmufd; + + /* some programs like some versions of gpSP use some weird version of mmuhack.o + * which doesn't seem to work. What's even worse they leave their mmuhack loaded on exit. + * So we must remove whatever may be left and always reload _our_ mmuhack.o */ + system("/sbin/rmmod mmuhack"); + + strcpy(kocmd, "/sbin/insmod "); + strncpy(kocmd+13, g_argv[0], 1023-13); + kocmd[1023] = 0; + for (i = strlen(kocmd); i > 0; i--) + if (kocmd[i] == '/') { kocmd[i] = 0; break; } + strcat(kocmd, "/mmuhack.o"); + + printf("Installing NK's kernel module for Squidge MMU Hack (%s)...\n", kocmd); + system(kocmd); + mmufd = open("/dev/mmuhack", O_RDWR); + if(mmufd < 0) return 0; - + close(mmufd); return 1; -} +} /* Unload MMU Hack kernel module after closing all memory devices*/