10 #include "../common/emu.h"
12 gp2x_soc_t gp2x_soc = -1;
14 gp2x_soc_t soc_detect(void)
16 volatile unsigned short *memregs;
17 volatile unsigned int *memregl;
18 int pollux_chipname[0x30/4 + 1];
19 char *pollux_chipname_c = (char *)pollux_chipname;
24 memdev = open("/dev/mem", O_RDONLY);
27 perror("open(/dev/mem)");
31 memregs = mmap(0, 0x20000, PROT_READ, MAP_SHARED, memdev, 0xc0000000);
32 if (memregs == MAP_FAILED)
34 perror("mmap(memregs)");
38 memregl = (volatile void *)memregs;
40 if (memregs[0x1836>>1] == 0x2330)
42 printf("looks like this is MMSP2\n");
47 /* perform word reads. Byte reads might also work,
48 * but we don't want to play with that. */
49 for (i = 0; i < 0x30; i += 4)
51 pollux_chipname[i >> 2] = memregl[(0x1f810 + i) >> 2];
53 pollux_chipname_c[0x30] = 0;
55 for (i = 0; i < 0x30; i++)
57 unsigned char c = pollux_chipname_c[i];
58 if (c < 0x20 || c > 0x7f)
62 printf("found pollux-like id: \"%s\"\n", pollux_chipname_c);
64 if (strncmp(pollux_chipname_c, "MAGICEYES-LEAPFROG-LF1000", 25) ||
65 strncmp(pollux_chipname_c, "MAGICEYES-POLLUX", 16))
73 munmap((void *)memregs, 0x20000);