10 #include "../common/emu.h"
12 gp2x_soc_t soc_detect(void)
14 volatile unsigned short *memregs;
15 volatile unsigned int *memregl;
16 static gp2x_soc_t ret = -1;
17 int pollux_chipname[0x30/4 + 1];
18 char *pollux_chipname_c = (char *)pollux_chipname;
23 /* already detected */
26 memdev = open("/dev/mem", O_RDONLY);
29 perror("open(/dev/mem)");
33 memregs = mmap(0, 0x20000, PROT_READ, MAP_SHARED, memdev, 0xc0000000);
34 if (memregs == MAP_FAILED)
36 perror("mmap(memregs)");
40 memregl = (volatile void *)memregs;
42 if (memregs[0x1836>>1] == 0x2330)
44 printf("looks like this is MMSP2\n");
49 /* perform word reads. Byte reads might also work,
50 * but we don't want to play with that. */
51 for (i = 0; i < 0x30; i += 4)
53 pollux_chipname[i >> 2] = memregl[(0x1f810 + i) >> 2];
55 pollux_chipname_c[0x30] = 0;
57 for (i = 0; i < 0x30; i++)
59 unsigned char c = pollux_chipname_c[i];
60 if (c < 0x20 || c > 0x7f)
64 printf("found pollux-like id: \"%s\"\n", pollux_chipname_c);
66 if (strncmp(pollux_chipname_c, "MAGICEYES-LEAPFROG-LF1000", 25) ||
67 strncmp(pollux_chipname_c, "MAGICEYES-POLLUX", 16))
75 munmap((void *)memregs, 0x20000);