Improve libk handling
[ps4-sdk.git] / libPS4 / source / kernel.c
blob5fc88411ea71efe7553ea4d8dbdda6c968ce30a0
1 #include "module.h"
2 #include "syscall.h"
4 #include "kernel.h"
6 int libKernelHandle;
8 int (*sceKernelLoadStartModule)(const char *name, size_t argc, const void *argv, unsigned int flags, int, int);
10 int (*sceKernelAllocateDirectMemory)(off_t searchStart, off_t searchEnd, size_t length, size_t alignment, int type, off_t *physicalAddressDestination);
11 int (*sceKernelMapDirectMemory)(void **addr, size_t length, int protection, int flags, off_t start, size_t alignment);
13 unsigned int (*sceKernelSleep)(unsigned int seconds);
14 int (*sceKernelUsleep)(unsigned int microseconds);
15 int (*sceKernelGettimeofday)(SceKernelTimeval *tp);
16 uint64_t (*sceKernelGetProcessTime)(void);
17 int (*sceKernelGetCurrentCpu)(void);
19 int (*sysctl)(int *name, unsigned int namelen, char *oldval, size_t *oldlen, char *newval, size_t *newlen);
20 int (*sysctlbyname)(char *name, char *oldval, size_t *oldlen, char *newval, size_t *newlen);
21 int (*sysarch)(int type, void *arg);
22 int (*execve)(char *path, char *argv[], char *envp[]);
24 void *(*pthread_self)();
25 int (*pthread_setaffinity_np)(void *one, long unsigned int two, void *three);
27 int (*sceKernelCreateEqueue)(SceKernelEqueue *eq, const char *name);
28 int (*sceKernelDeleteEqueue)(SceKernelEqueue eq);
29 int (*sceKernelAddUserEvent)(SceKernelEqueue eq, int id);
30 int (*sceKernelAddReadEvent)(SceKernelEqueue eq, int fd, size_t size, void *udata);
32 int (*getuid)();
33 int (*getgid)();
34 int (*getpid)();
36 int (*setuid)(int uid);
37 int (*setgid)(int gid);
38 int (*setreuid)(int ruid, int euid);
39 int (*setregid)(int rgid, int egid);
42 SYSCALL(kill, 37);
43 SYSCALL(ioctl, 54);
45 void initKernel(void) {
46 loadModule("libkernel.sprx", &libKernelHandle);
48 RESOLVE(libKernelHandle, sceKernelLoadStartModule);
50 RESOLVE(libKernelHandle, sceKernelAllocateDirectMemory);
51 RESOLVE(libKernelHandle, sceKernelMapDirectMemory);
53 RESOLVE(libKernelHandle, sceKernelSleep);
54 RESOLVE(libKernelHandle, sceKernelUsleep);
55 RESOLVE(libKernelHandle, sceKernelGettimeofday);
56 RESOLVE(libKernelHandle, sceKernelGetProcessTime);
57 RESOLVE(libKernelHandle, sceKernelGetCurrentCpu);
59 RESOLVE(libKernelHandle, sysctl);
60 RESOLVE(libKernelHandle, sysctlbyname);
61 RESOLVE(libKernelHandle, sysarch);
62 RESOLVE(libKernelHandle, execve);
64 RESOLVE(libKernelHandle, pthread_self);
65 RESOLVE(libKernelHandle, pthread_setaffinity_np);
67 RESOLVE(libKernelHandle, sceKernelCreateEqueue);
68 RESOLVE(libKernelHandle, sceKernelDeleteEqueue);
69 RESOLVE(libKernelHandle, sceKernelAddUserEvent);
70 RESOLVE(libKernelHandle, sceKernelAddReadEvent);
72 RESOLVE(libKernelHandle, getuid);
73 RESOLVE(libKernelHandle, getgid);
74 RESOLVE(libKernelHandle, getpid);
76 RESOLVE(libKernelHandle, setuid);
77 RESOLVE(libKernelHandle, setgid);
78 RESOLVE(libKernelHandle, setreuid);
79 RESOLVE(libKernelHandle, setregid);