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 const char gsKernelVersion[];
32 extern const char gsGitHash[];
33 extern int giBuildNumber;
36 const char *gsAcessDir = "../Usermode/Output/x86_64";
39 int main(int argc, char *argv[])
41 char **rootapp = NULL;
43 // Parse command line settings
44 for( i = 1; i < argc; i ++ )
46 if( strcmp(argv[i], "--distroot") == 0 ) {
47 gsAcessDir = argv[++i];
49 else if( strcmp(argv[i], "--rootapp") == 0 ) {
51 rootapp_argc = argc - i;
55 fprintf(stderr, "Unknown command line option '%s'\n", argv[i]);
60 // Kernel build information
61 printf("Acess2 Native v%s\n", gsKernelVersion);
62 printf(" Build %i, Git Hash %s\n", giBuildNumber, gsGitHash);
65 UI_Initialise(800, 480);
67 // - Ignore SIGUSR1 (used to wake threads)
68 signal(SIGUSR1, SIG_IGN);
73 if( Video_Install(NULL) ) {
74 Log_Error("Init", "Unable to load NativeVideo");
76 if( NativeKeyboard_Install(NULL) ) {
77 Log_Error("Init", "Unable to load NativeKeyboard");
79 NativeFS_Install(NULL);
84 "Input=NativeKeyboard",
91 VFS_Mount(gsAcessDir, "/Acess", "nativefs", "");
93 Debug_SetKTerminal("/Devices/VTerm/8");
95 // Start syscall server
98 // Spawn root application
103 char *args[7+rootapp_argc+1+1];
106 args[argcount++] = "valgrind";
108 args[argcount++] = "./ld-acess";
109 args[argcount++] = "--open"; args[argcount++] = "/Devices/VTerm/0";
110 args[argcount++] = "--open"; args[argcount++] = "/Devices/VTerm/0";
111 args[argcount++] = "--open"; args[argcount++] = "/Devices/VTerm/0";
112 for( i = 0; i < rootapp_argc; i ++ )
113 args[argcount+i] = rootapp[i];
114 args[argcount+rootapp_argc] = NULL;
118 perror("Starting root application [fork(2)]");
124 prctl(PR_SET_PDEATHSIG, SIGHUP); // LINUX ONLY!
127 execv("valgrind", args);
129 execv("./ld-acess", args);
132 printf("Root application running as PID %i\n", pid);
140 void AcessNative_Exit(void)
142 // TODO: Close client applications too
146 uint64_t DivMod64U(uint64_t Num, uint64_t Den, uint64_t *Rem)
148 if(Rem) *Rem = Num % Den;
152 int Module_EnsureLoaded(const char *Name)