3 * - Acess kernel emulation on another OS using SDL and UDP
12 #include <sys/prctl.h>
16 #include "../../KernelLand/Kernel/include/logdebug.h"
18 #define VALGRIND_CLIENT 0
21 extern int UI_Initialise(int Width, int Height);
22 extern void UI_MainLoop(void);
23 extern int VFS_Init(void);
24 extern int Video_Install(char **Arguments);
25 extern int NativeKeyboard_Install(char **Arguments);
26 extern int NativeFS_Install(char **Arguments);
27 extern void Debug_SetKTerminal(char *Path);
28 extern int VT_Install(char **Arguments);
29 extern int VFS_Mount(const char *Device, const char *MountPoint, const char *Filesystem, const char *Options);
30 extern int VFS_MkDir(const char *Path);
31 extern int SyscallServer(void);
32 extern int Server_Shutdown(void);
33 extern const char gsKernelVersion[];
34 extern const char gsGitHash[];
35 extern int giBuildNumber;
38 const char *gsAcessDir = "../Usermode/Output/x86_64";
41 int main(int argc, char *argv[])
43 char **rootapp = NULL;
45 // Parse command line settings
46 for( i = 1; i < argc; i ++ )
48 if( strcmp(argv[i], "--distroot") == 0 ) {
49 gsAcessDir = argv[++i];
51 else if( strcmp(argv[i], "--rootapp") == 0 ) {
53 rootapp_argc = argc - i;
57 fprintf(stderr, "Unknown command line option '%s'\n", argv[i]);
62 // Kernel build information
63 printf("Acess2 Native v%s\n", gsKernelVersion);
64 printf(" Build %i, Git Hash %s\n", giBuildNumber, gsGitHash);
67 UI_Initialise(800, 480);
69 // - Ignore SIGUSR1 (used to wake threads)
71 signal(SIGUSR1, SIG_IGN);
77 if( Video_Install(NULL) ) {
78 Log_Error("Init", "Unable to load NativeVideo");
80 if( NativeKeyboard_Install(NULL) ) {
81 Log_Error("Init", "Unable to load NativeKeyboard");
83 NativeFS_Install(NULL);
88 "Input=NativeKeyboard",
95 VFS_Mount(gsAcessDir, "/Acess", "nativefs", "");
97 Debug_SetKTerminal("/Devices/VTerm/8");
99 // Start syscall server
102 // Spawn root application
107 const char *args[7+rootapp_argc+1+1];
110 args[argcount++] = "valgrind";
112 args[argcount++] = "./ld-acess";
113 args[argcount++] = "--open"; args[argcount++] = "/Devices/VTerm/0";
114 args[argcount++] = "--open"; args[argcount++] = "/Devices/VTerm/0";
115 args[argcount++] = "--open"; args[argcount++] = "/Devices/VTerm/0";
116 for( i = 0; i < rootapp_argc; i ++ )
117 args[argcount+i] = rootapp[i];
118 args[argcount+rootapp_argc] = NULL;
119 pid = spawnv(P_NOWAIT, "./ld-acess", args);
121 perror("Starting root application [fork(2)]");
124 printf("Root application running as PID %i\n", pid);
132 void AcessNative_Exit(void)
134 // TODO: Close client applications too
139 uint64_t DivMod64U(uint64_t Num, uint64_t Den, uint64_t *Rem)
141 if(Rem) *Rem = Num % Den;
145 int Module_EnsureLoaded(const char *Name)