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 PTY_Install(char **Arguments);
25 extern int Video_Install(char **Arguments);
26 extern int NativeKeyboard_Install(char **Arguments);
27 extern int NativeFS_Install(char **Arguments);
28 extern void Debug_SetKTerminal(char *Path);
29 extern int VT_Install(char **Arguments);
30 extern int Mouse_Install(char **Arguments);
31 extern int IPCPipe_Install(char **Arguments);
32 extern int VFS_Mount(const char *Device, const char *MountPoint, const char *Filesystem, const char *Options);
33 extern int VFS_MkDir(const char *Path);
34 extern int SyscallServer(void);
35 extern int Server_Shutdown(void);
36 extern const char gsKernelVersion[];
37 extern const char gsGitHash[];
38 extern int giBuildNumber;
41 const char *gsAcessDir = "../Usermode/Output/x86_64";
46 int spawnv(int flags, const char *execuable, char * const argv[])
49 if( pid != 0 ) return pid;
51 execv(execuable, argv);
52 perror("spawnv - execve");
57 int main(int argc, char *argv[])
59 char **rootapp = NULL;
61 // Parse command line settings
62 for( i = 1; i < argc; i ++ )
64 if( strcmp(argv[i], "--distroot") == 0 ) {
65 gsAcessDir = argv[++i];
67 else if( strcmp(argv[i], "--rootapp") == 0 ) {
69 rootapp_argc = argc - i;
73 fprintf(stderr, "Unknown command line option '%s'\n", argv[i]);
78 // Kernel build information
79 printf("Acess2 Native v%s\n", gsKernelVersion);
80 printf(" Build %i, Git Hash %s\n", giBuildNumber, gsGitHash);
83 UI_Initialise(800, 480);
85 // - Ignore SIGUSR1 (used to wake threads)
87 signal(SIGUSR1, SIG_IGN);
93 if( Video_Install(NULL) ) {
94 Log_Error("Init", "Unable to load NativeVideo");
96 if( NativeKeyboard_Install(NULL) ) {
97 Log_Error("Init", "Unable to load NativeKeyboard");
99 NativeFS_Install(NULL);
101 IPCPipe_Install(NULL);
107 "Input=NativeKeyboard",
114 VFS_Mount(gsAcessDir, "/Acess", "nativefs", "");
116 Debug_SetKTerminal("/Devices/pts/vt7c");
118 // Start syscall server
121 // Spawn root application
126 const char *args[7+rootapp_argc+1+1];
129 args[argcount++] = "valgrind";
131 args[argcount++] = "./ld-acess";
132 args[argcount++] = "--open"; args[argcount++] = "/Devices/VTerm/0";
133 args[argcount++] = "--open"; args[argcount++] = "/Devices/VTerm/0";
134 args[argcount++] = "--open"; args[argcount++] = "/Devices/VTerm/0";
135 for( i = 0; i < rootapp_argc; i ++ )
136 args[argcount+i] = rootapp[i];
137 args[argcount+rootapp_argc] = NULL;
138 pid = spawnv(P_NOWAIT, "./ld-acess", args);
140 perror("Starting root application [fork(2)]");
143 printf("Root application running as PID %i\n", pid);
151 void AcessNative_Exit(void)
153 // TODO: Close client applications too
158 uint64_t DivMod64U(uint64_t Num, uint64_t Den, uint64_t *Rem)
160 if(Rem) *Rem = Num % Den;
164 int Module_EnsureLoaded(const char *Name)