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 Mouse_Install(char **Arguments);
30 extern int VFS_Mount(const char *Device, const char *MountPoint, const char *Filesystem, const char *Options);
31 extern int VFS_MkDir(const char *Path);
32 extern int SyscallServer(void);
33 extern int Server_Shutdown(void);
34 extern const char gsKernelVersion[];
35 extern const char gsGitHash[];
36 extern int giBuildNumber;
39 const char *gsAcessDir = "../Usermode/Output/x86_64";
44 int spawnv(int flags, const char *execuable, char * const argv[])
47 if( pid != 0 ) return pid;
49 execv(execuable, argv);
50 perror("spawnv - execve");
55 int main(int argc, char *argv[])
57 char **rootapp = NULL;
59 // Parse command line settings
60 for( i = 1; i < argc; i ++ )
62 if( strcmp(argv[i], "--distroot") == 0 ) {
63 gsAcessDir = argv[++i];
65 else if( strcmp(argv[i], "--rootapp") == 0 ) {
67 rootapp_argc = argc - i;
71 fprintf(stderr, "Unknown command line option '%s'\n", argv[i]);
76 // Kernel build information
77 printf("Acess2 Native v%s\n", gsKernelVersion);
78 printf(" Build %i, Git Hash %s\n", giBuildNumber, gsGitHash);
81 UI_Initialise(800, 480);
83 // - Ignore SIGUSR1 (used to wake threads)
85 signal(SIGUSR1, SIG_IGN);
91 if( Video_Install(NULL) ) {
92 Log_Error("Init", "Unable to load NativeVideo");
94 if( NativeKeyboard_Install(NULL) ) {
95 Log_Error("Init", "Unable to load NativeKeyboard");
97 NativeFS_Install(NULL);
103 "Input=NativeKeyboard",
110 VFS_Mount(gsAcessDir, "/Acess", "nativefs", "");
112 Debug_SetKTerminal("/Devices/VTerm/8");
114 // Start syscall server
117 // Spawn root application
122 const char *args[7+rootapp_argc+1+1];
125 args[argcount++] = "valgrind";
127 args[argcount++] = "./ld-acess";
128 args[argcount++] = "--open"; args[argcount++] = "/Devices/VTerm/0";
129 args[argcount++] = "--open"; args[argcount++] = "/Devices/VTerm/0";
130 args[argcount++] = "--open"; args[argcount++] = "/Devices/VTerm/0";
131 for( i = 0; i < rootapp_argc; i ++ )
132 args[argcount+i] = rootapp[i];
133 args[argcount+rootapp_argc] = NULL;
134 pid = spawnv(P_NOWAIT, "./ld-acess", args);
136 perror("Starting root application [fork(2)]");
139 printf("Root application running as PID %i\n", pid);
147 void AcessNative_Exit(void)
149 // TODO: Close client applications too
154 uint64_t DivMod64U(uint64_t Num, uint64_t Den, uint64_t *Rem)
156 if(Rem) *Rem = Num % Den;
160 int Module_EnsureLoaded(const char *Name)