3 * - Acess kernel emulation on another OS using SDL and UDP
12 #include <sys/prctl.h>
17 #include "../../KernelLand/Kernel/include/logdebug.h"
19 #define VALGRIND_CLIENT 0
22 extern int UI_Initialise(int Width, int Height);
23 extern void UI_MainLoop(void);
24 extern int VFS_Init(void);
25 extern int PTY_Install(char **Arguments);
26 extern int Video_Install(char **Arguments);
27 extern int NativeKeyboard_Install(char **Arguments);
28 extern int NativeFS_Install(char **Arguments);
29 extern void Debug_SetKTerminal(char *Path);
30 extern int VT_Install(char **Arguments);
31 extern int Mouse_Install(char **Arguments);
32 extern int IPCPipe_Install(char **Arguments);
33 extern int Net_Install(char **Arguments);
34 extern int VFS_Mount(const char *Device, const char *MountPoint, const char *Filesystem, const char *Options);
35 extern int VFS_MkDir(const char *Path);
36 extern int SyscallServer(void);
37 extern int Server_Shutdown(void);
38 extern const char gsKernelVersion[];
39 extern const char gsGitHash[];
40 extern int giBuildNumber;
43 const char *gsAcessDir = "../Usermode/Output/native";
48 int spawnv(int flags, const char *execuable, char * const argv[])
51 if( pid != 0 ) return pid;
53 execv(execuable, argv);
54 perror("spawnv - execve");
59 int main(int argc, char *argv[])
61 char **rootapp = NULL;
63 // Parse command line settings
64 for( i = 1; i < argc; i ++ )
66 if( strcmp(argv[i], "--distroot") == 0 ) {
67 gsAcessDir = argv[++i];
69 else if( strcmp(argv[i], "--rootapp") == 0 ) {
71 rootapp_argc = argc - i;
75 fprintf(stderr, "Unknown command line option '%s'\n", argv[i]);
80 // Kernel build information
81 printf("Acess2 Native v%s\n", gsKernelVersion);
82 printf(" Build %i, Git Hash %s\n", giBuildNumber, gsGitHash);
85 UI_Initialise(800, 480);
87 // - Ignore SIGUSR1 (used to wake threads)
89 signal(SIGUSR1, SIG_IGN);
95 if( Video_Install(NULL) ) {
96 Log_Error("Init", "Unable to load NativeVideo");
98 if( NativeKeyboard_Install(NULL) ) {
99 Log_Error("Init", "Unable to load NativeKeyboard");
101 NativeFS_Install(NULL);
103 IPCPipe_Install(NULL);
110 "Input=NativeKeyboard",
117 VFS_Mount(gsAcessDir, "/Acess", "nativefs", "");
119 Debug_SetKTerminal("/Devices/pts/vt7c");
121 // Start syscall server
124 // Spawn root application
129 const char *args[7+rootapp_argc+1+1];
132 args[argcount++] = "valgrind";
134 args[argcount++] = "./ld-acess";
135 args[argcount++] = "--open"; args[argcount++] = "/Devices/pts/vt0";
136 args[argcount++] = "--open"; args[argcount++] = "/Devices/pts/vt0";
137 args[argcount++] = "--open"; args[argcount++] = "/Devices/pts/vt0";
138 for( i = 0; i < rootapp_argc; i ++ )
139 args[argcount+i] = rootapp[i];
140 args[argcount+rootapp_argc] = NULL;
141 pid = spawnv(P_NOWAIT, "./ld-acess", (char *const*)args);
143 perror("Starting root application [fork(2)]");
146 printf("Root application running as PID %i\n", pid);
154 void AcessNative_Exit(void)
156 // TODO: Close client applications too
161 uint64_t DivMod64U(uint64_t Num, uint64_t Den, uint64_t *Rem)
163 if(Rem) *Rem = Num % Den;
167 int Module_EnsureLoaded(const char *Name)
172 void Proc_PrintBacktrace(void)