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 IPCPipe_Install(char **Arguments);
31 extern int VFS_Mount(const char *Device, const char *MountPoint, const char *Filesystem, const char *Options);
32 extern int VFS_MkDir(const char *Path);
33 extern int SyscallServer(void);
34 extern int Server_Shutdown(void);
35 extern const char gsKernelVersion[];
36 extern const char gsGitHash[];
37 extern int giBuildNumber;
40 const char *gsAcessDir = "../Usermode/Output/x86_64";
45 int spawnv(int flags, const char *execuable, char * const argv[])
48 if( pid != 0 ) return pid;
50 execv(execuable, argv);
51 perror("spawnv - execve");
56 int main(int argc, char *argv[])
58 char **rootapp = NULL;
60 // Parse command line settings
61 for( i = 1; i < argc; i ++ )
63 if( strcmp(argv[i], "--distroot") == 0 ) {
64 gsAcessDir = argv[++i];
66 else if( strcmp(argv[i], "--rootapp") == 0 ) {
68 rootapp_argc = argc - i;
72 fprintf(stderr, "Unknown command line option '%s'\n", argv[i]);
77 // Kernel build information
78 printf("Acess2 Native v%s\n", gsKernelVersion);
79 printf(" Build %i, Git Hash %s\n", giBuildNumber, gsGitHash);
82 UI_Initialise(800, 480);
84 // - Ignore SIGUSR1 (used to wake threads)
86 signal(SIGUSR1, SIG_IGN);
92 if( Video_Install(NULL) ) {
93 Log_Error("Init", "Unable to load NativeVideo");
95 if( NativeKeyboard_Install(NULL) ) {
96 Log_Error("Init", "Unable to load NativeKeyboard");
98 NativeFS_Install(NULL);
100 IPCPipe_Install(NULL);
105 "Input=NativeKeyboard",
112 VFS_Mount(gsAcessDir, "/Acess", "nativefs", "");
114 Debug_SetKTerminal("/Devices/VTerm/8");
116 // Start syscall server
119 // Spawn root application
124 const char *args[7+rootapp_argc+1+1];
127 args[argcount++] = "valgrind";
129 args[argcount++] = "./ld-acess";
130 args[argcount++] = "--open"; args[argcount++] = "/Devices/VTerm/0";
131 args[argcount++] = "--open"; args[argcount++] = "/Devices/VTerm/0";
132 args[argcount++] = "--open"; args[argcount++] = "/Devices/VTerm/0";
133 for( i = 0; i < rootapp_argc; i ++ )
134 args[argcount+i] = rootapp[i];
135 args[argcount+rootapp_argc] = NULL;
136 pid = spawnv(P_NOWAIT, "./ld-acess", args);
138 perror("Starting root application [fork(2)]");
141 printf("Root application running as PID %i\n", pid);
149 void AcessNative_Exit(void)
151 // TODO: Close client applications too
156 uint64_t DivMod64U(uint64_t Num, uint64_t Den, uint64_t *Rem)
158 if(Rem) *Rem = Num % Den;
162 int Module_EnsureLoaded(const char *Name)