X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=linux%2Fplat.c;h=492007cd853474ac02eb614d5525f02dfc735018;hb=1e122e31195b065d2ec5d055a29696b6d415151d;hp=842cd5b26df8f87b67f05651b19541c171b8f059;hpb=1eb704b6332072581bf7c3bc411babc66f8bda8a;p=libpicofe.git diff --git a/linux/plat.c b/linux/plat.c index 842cd5b..492007c 100644 --- a/linux/plat.c +++ b/linux/plat.c @@ -1,8 +1,10 @@ #include +#include #include #include #include #include +#include #include "../common/plat.h" @@ -17,6 +19,21 @@ int plat_is_dir(const char *path) return 0; } +int plat_get_root_dir(char *dst, int len) +{ + extern char **g_argv; + int j; + + strncpy(dst, g_argv[0], len); + len -= 32; // reserve + if (len < 0) len = 0; + dst[len] = 0; + for (j = strlen(dst); j > 0; j--) + if (dst[j] == '/') { dst[j+1] = 0; break; } + + return j + 1; +} + #ifdef __GP2X__ /* Wiz has a borked gettimeofday().. */ #define plat_get_ticks_ms plat_get_ticks_ms_good @@ -92,3 +109,21 @@ int plat_wait_event(int *fds_hnds, int count, int timeout_ms) return ret; } +void *plat_mmap(unsigned long addr, size_t size) +{ + void *req, *ret; + req = (void *)addr; + ret = mmap(req, size, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0); + if (ret == MAP_FAILED) + return NULL; + if (ret != req) + printf("warning: mmaped to %p, requested %p\n", ret, req); + + return ret; +} + +void plat_munmap(void *ptr, size_t size) +{ + munmap(ptr, size); +} +