X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=gp2x%2Fsoc.c;h=0d1b8a35515bbbb25cf5b87c8d2909f534395533;hb=HEAD;hp=68b2c892dd8d9b3d394ee43523a44f5616ef8bd2;hpb=fa5e045bdc817112c1abf19e65e2d3481d51c48a;p=libpicofe.git diff --git a/gp2x/soc.c b/gp2x/soc.c index 68b2c89..0d1b8a3 100644 --- a/gp2x/soc.c +++ b/gp2x/soc.c @@ -1,3 +1,14 @@ +/* + * (C) Gražvydas "notaz" Ignotas, 2009-2010 + * + * This work is licensed under the terms of any of these licenses + * (at your option): + * - GNU GPL, version 2 or later. + * - GNU LGPL, version 2.1 or later. + * - MAME license. + * See the COPYING file in the top-level directory. + */ + #include #include #include @@ -7,34 +18,43 @@ #include #include "soc.h" -#include "../common/emu.h" + +volatile unsigned short *memregs; +volatile unsigned int *memregl; +int memdev = -1; + +unsigned int (*gp2x_get_ticks_ms)(void); +unsigned int (*gp2x_get_ticks_us)(void); gp2x_soc_t soc_detect(void) { volatile unsigned short *memregs; volatile unsigned int *memregl; - static gp2x_soc_t ret = -1; + static gp2x_soc_t ret = -2; int pollux_chipname[0x30/4 + 1]; char *pollux_chipname_c = (char *)pollux_chipname; - int memdev; + int memdev_tmp; int i; - if (ret != -1) + if ((int)ret != -2) /* already detected */ return ret; - memdev = open("/dev/mem", O_RDONLY); - if (memdev == -1) + memdev_tmp = open("/dev/mem", O_RDONLY); + if (memdev_tmp == -1) { perror("open(/dev/mem)"); + ret = -1; return -1; } - memregs = mmap(0, 0x20000, PROT_READ, MAP_SHARED, memdev, 0xc0000000); + memregs = mmap(0, 0x20000, PROT_READ, MAP_SHARED, + memdev_tmp, 0xc0000000); if (memregs == MAP_FAILED) { perror("mmap(memregs)"); - close(memdev); + close(memdev_tmp); + ret = -1; return -1; } memregl = (volatile void *)memregs; @@ -73,7 +93,7 @@ gp2x_soc_t soc_detect(void) not_pollux_like: out: munmap((void *)memregs, 0x20000); - close(memdev); + close(memdev_tmp); return ret; }