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";
43 int spawnv(int flags, const char *execuable, char * const argv[])
46 if( pid != 0 ) return pid;
48 execv(execuable, argv);
49 perror("spawnv - execve");
54 int main(int argc, char *argv[])
56 char **rootapp = NULL;
58 // Parse command line settings
59 for( i = 1; i < argc; i ++ )
61 if( strcmp(argv[i], "--distroot") == 0 ) {
62 gsAcessDir = argv[++i];
64 else if( strcmp(argv[i], "--rootapp") == 0 ) {
66 rootapp_argc = argc - i;
70 fprintf(stderr, "Unknown command line option '%s'\n", argv[i]);
75 // Kernel build information
76 printf("Acess2 Native v%s\n", gsKernelVersion);
77 printf(" Build %i, Git Hash %s\n", giBuildNumber, gsGitHash);
80 UI_Initialise(800, 480);
82 // - Ignore SIGUSR1 (used to wake threads)
84 signal(SIGUSR1, SIG_IGN);
90 if( Video_Install(NULL) ) {
91 Log_Error("Init", "Unable to load NativeVideo");
93 if( NativeKeyboard_Install(NULL) ) {
94 Log_Error("Init", "Unable to load NativeKeyboard");
96 NativeFS_Install(NULL);
101 "Input=NativeKeyboard",
108 VFS_Mount(gsAcessDir, "/Acess", "nativefs", "");
110 Debug_SetKTerminal("/Devices/VTerm/8");
112 // Start syscall server
115 // Spawn root application
120 const char *args[7+rootapp_argc+1+1];
123 args[argcount++] = "valgrind";
125 args[argcount++] = "./ld-acess";
126 args[argcount++] = "--open"; args[argcount++] = "/Devices/VTerm/0";
127 args[argcount++] = "--open"; args[argcount++] = "/Devices/VTerm/0";
128 args[argcount++] = "--open"; args[argcount++] = "/Devices/VTerm/0";
129 for( i = 0; i < rootapp_argc; i ++ )
130 args[argcount+i] = rootapp[i];
131 args[argcount+rootapp_argc] = NULL;
132 pid = spawnv(P_NOWAIT, "./ld-acess", args);
134 perror("Starting root application [fork(2)]");
137 printf("Root application running as PID %i\n", pid);
145 void AcessNative_Exit(void)
147 // TODO: Close client applications too
152 uint64_t DivMod64U(uint64_t Num, uint64_t Den, uint64_t *Rem)
154 if(Rem) *Rem = Num % Den;
158 int Module_EnsureLoaded(const char *Name)