2 * (C) GraÅžvydas "notaz" Ignotas, 2009-2010
4 * This work is licensed under the terms of any of these licenses
6 * - GNU GPL, version 2 or later.
7 * - GNU LGPL, version 2.1 or later.
9 * See the COPYING file in the top-level directory.
14 #include <sys/types.h>
22 volatile unsigned short *memregs;
23 volatile unsigned int *memregl;
26 unsigned int (*gp2x_get_ticks_ms)(void);
27 unsigned int (*gp2x_get_ticks_us)(void);
29 gp2x_soc_t soc_detect(void)
31 volatile unsigned short *memregs;
32 volatile unsigned int *memregl;
33 static gp2x_soc_t ret = -2;
34 int pollux_chipname[0x30/4 + 1];
35 char *pollux_chipname_c = (char *)pollux_chipname;
40 /* already detected */
43 memdev_tmp = open("/dev/mem", O_RDONLY);
46 perror("open(/dev/mem)");
51 memregs = mmap(0, 0x20000, PROT_READ, MAP_SHARED,
52 memdev_tmp, 0xc0000000);
53 if (memregs == MAP_FAILED)
55 perror("mmap(memregs)");
60 memregl = (volatile void *)memregs;
62 if (memregs[0x1836>>1] == 0x2330)
64 printf("looks like this is MMSP2\n");
69 /* perform word reads. Byte reads might also work,
70 * but we don't want to play with that. */
71 for (i = 0; i < 0x30; i += 4)
73 pollux_chipname[i >> 2] = memregl[(0x1f810 + i) >> 2];
75 pollux_chipname_c[0x30] = 0;
77 for (i = 0; i < 0x30; i++)
79 unsigned char c = pollux_chipname_c[i];
80 if (c < 0x20 || c > 0x7f)
84 printf("found pollux-like id: \"%s\"\n", pollux_chipname_c);
86 if (strncmp(pollux_chipname_c, "MAGICEYES-LEAPFROG-LF1000", 25) ||
87 strncmp(pollux_chipname_c, "MAGICEYES-POLLUX", 16))
95 munmap((void *)memregs, 0x20000);