3 * - Acess kernel emulation on another OS using SDL and UDP
12 #include <sys/prctl.h>
17 #define VALGRIND_CLIENT 0
20 extern int UI_Initialise(int Width, int Height);
21 extern void UI_MainLoop(void);
22 extern int VFS_Init(void);
23 extern int Video_Install(char **Arguments);
24 extern int NativeKeyboard_Install(char **Arguments);
25 extern int NativeFS_Install(char **Arguments);
26 extern void Debug_SetKTerminal(char *Path);
27 extern int VT_Install(char **Arguments);
28 extern int VFS_Mount(const char *Device, const char *MountPoint, const char *Filesystem, const char *Options);
29 extern int VFS_MkDir(const char *Path);
30 extern int SyscallServer(void);
31 extern int Server_Shutdown(void);
32 extern const char gsKernelVersion[];
33 extern const char gsGitHash[];
34 extern int giBuildNumber;
37 const char *gsAcessDir = "../Usermode/Output/x86_64";
40 int main(int argc, char *argv[])
42 char **rootapp = NULL;
44 // Parse command line settings
45 for( i = 1; i < argc; i ++ )
47 if( strcmp(argv[i], "--distroot") == 0 ) {
48 gsAcessDir = argv[++i];
50 else if( strcmp(argv[i], "--rootapp") == 0 ) {
52 rootapp_argc = argc - i;
56 fprintf(stderr, "Unknown command line option '%s'\n", argv[i]);
61 // Kernel build information
62 printf("Acess2 Native v%s\n", gsKernelVersion);
63 printf(" Build %i, Git Hash %s\n", giBuildNumber, gsGitHash);
66 UI_Initialise(800, 480);
68 // - Ignore SIGUSR1 (used to wake threads)
69 signal(SIGUSR1, SIG_IGN);
74 if( Video_Install(NULL) ) {
75 Log_Error("Init", "Unable to load NativeVideo");
77 if( NativeKeyboard_Install(NULL) ) {
78 Log_Error("Init", "Unable to load NativeKeyboard");
80 NativeFS_Install(NULL);
85 "Input=NativeKeyboard",
92 VFS_Mount(gsAcessDir, "/Acess", "nativefs", "");
94 Debug_SetKTerminal("/Devices/VTerm/8");
96 // Start syscall server
99 // Spawn root application
104 char *args[7+rootapp_argc+1+1];
107 args[argcount++] = "valgrind";
109 args[argcount++] = "./ld-acess";
110 args[argcount++] = "--open"; args[argcount++] = "/Devices/VTerm/0";
111 args[argcount++] = "--open"; args[argcount++] = "/Devices/VTerm/0";
112 args[argcount++] = "--open"; args[argcount++] = "/Devices/VTerm/0";
113 for( i = 0; i < rootapp_argc; i ++ )
114 args[argcount+i] = rootapp[i];
115 args[argcount+rootapp_argc] = NULL;
119 perror("Starting root application [fork(2)]");
125 prctl(PR_SET_PDEATHSIG, SIGHUP); // LINUX ONLY!
128 execv("valgrind", args);
130 execv("./ld-acess", args);
133 printf("Root application running as PID %i\n", pid);
141 void AcessNative_Exit(void)
143 // TODO: Close client applications too
148 uint64_t DivMod64U(uint64_t Num, uint64_t Den, uint64_t *Rem)
150 if(Rem) *Rem = Num % Den;
154 int Module_EnsureLoaded(const char *Name)