diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2024-02-24 12:10:08 +0100 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2024-02-24 12:10:08 +0100 |
| commit | ec0d333d812dce81453cefa4188e346d8a931a08 (patch) | |
| tree | e4151efe477e14d3a1b0ece19c1b03045992d59b /src | |
| parent | d3eb6b8a11bf4812a02872577a4737116e24c912 (diff) | |
| download | box64-ec0d333d812dce81453cefa4188e346d8a931a08.tar.gz box64-ec0d333d812dce81453cefa4188e346d8a931a08.zip | |
Improve emulation of clocksource
Diffstat (limited to 'src')
| -rw-r--r-- | src/wrapped/wrappedlibc.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c index 4e615629..107eeb94 100644 --- a/src/wrapped/wrappedlibc.c +++ b/src/wrapped/wrappedlibc.c @@ -1623,6 +1623,11 @@ void CreateCPUPresentFile(int fd) dummy = write(fd, buff, strlen(buff)); (void)dummy; } +void CreateClocksourceFile(int fd) +{ + size_t dummy; + write(fd, "tsc", strlen("tsc")); +} #ifdef ANDROID static int shm_open(const char *name, int oflag, mode_t mode) { @@ -1635,6 +1640,7 @@ static int shm_unlink(const char *name) { #define TMP_CPUINFO "box64_tmpcpuinfo" #define TMP_CPUTOPO "box64_tmpcputopo%d" +#define TMP_CLOCKSOURCE "box64_tmpclocksource" #endif #define TMP_MEMMAP "box64_tmpmemmap" #define TMP_CMDLINE "box64_tmpcmdline" @@ -1680,6 +1686,15 @@ EXPORT int32_t my_open(x64emu_t* emu, void* pathname, int32_t flags, uint32_t mo lseek(tmp, 0, SEEK_SET); return tmp; } + if(!strcmp((const char*)pathname, "/sys/bus/clocksource/devices/clocksource0/current_clocksource")) { + // special case to say tsc as current clocksource + int tmp = shm_open(TMP_CLOCKSOURCE, O_RDWR | O_CREAT, S_IRWXU); + if(tmp<0) return open(pathname, flags, mode); // error fallback + shm_unlink(TMP_CPUINFO); // remove the shm file, but it will still exist because it's currently in use + CreateClocksourceFile(tmp); + lseek(tmp, 0, SEEK_SET); + return tmp; + } #endif int ret = open(pathname, flags, mode); return ret; @@ -1801,6 +1816,15 @@ EXPORT FILE* my_fopen64(x64emu_t* emu, const char* path, const char* mode) lseek(tmp, 0, SEEK_SET); return fdopen(tmp, mode); } + if(strcmp(path, "/sys/bus/clocksource/devices/clocksource0/current_clocksource")==0) { + // special case for cpuinfo + int tmp = shm_open(TMP_CLOCKSOURCE, O_RDWR | O_CREAT, S_IRWXU); + if(tmp<0) return fopen64(path, mode); // error fallback + shm_unlink(TMP_CPUINFO); // remove the shm file, but it will still exist because it's currently in use + CreateClocksourceFile(tmp); + lseek(tmp, 0, SEEK_SET); + return fdopen(tmp, mode); + } #endif if(isProcSelf(path, "exe")) { return fopen64(emu->context->fullpath, mode); |