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 Net_Install(char **Arguments);
33 extern int VFS_Mount(const char *Device, const char *MountPoint, const char *Filesystem, const char *Options);
34 extern int VFS_MkDir(const char *Path);
35 extern int SyscallServer(void);
36 extern int Server_Shutdown(void);
37 extern const char gsKernelVersion[];
38 extern const char gsGitHash[];
39 extern int giBuildNumber;
42 const char *gsAcessDir = "../Usermode/Output/native";
47 int spawnv(int flags, const char *execuable, char * const argv[])
50 if( pid != 0 ) return pid;
52 execv(execuable, argv);
53 perror("spawnv - execve");
58 int main(int argc, char *argv[])
60 char **rootapp = NULL;
62 // Parse command line settings
63 for( i = 1; i < argc; i ++ )
65 if( strcmp(argv[i], "--distroot") == 0 ) {
66 gsAcessDir = argv[++i];
68 else if( strcmp(argv[i], "--rootapp") == 0 ) {
70 rootapp_argc = argc - i;
74 fprintf(stderr, "Unknown command line option '%s'\n", argv[i]);
79 // Kernel build information
80 printf("Acess2 Native v%s\n", gsKernelVersion);
81 printf(" Build %i, Git Hash %s\n", giBuildNumber, gsGitHash);
84 UI_Initialise(800, 480);
86 // - Ignore SIGUSR1 (used to wake threads)
88 signal(SIGUSR1, SIG_IGN);
94 if( Video_Install(NULL) ) {
95 Log_Error("Init", "Unable to load NativeVideo");
97 if( NativeKeyboard_Install(NULL) ) {
98 Log_Error("Init", "Unable to load NativeKeyboard");
100 NativeFS_Install(NULL);
102 IPCPipe_Install(NULL);
109 "Input=NativeKeyboard",
116 VFS_Mount(gsAcessDir, "/Acess", "nativefs", "");
118 Debug_SetKTerminal("/Devices/pts/vt7c");
120 // Start syscall server
123 // Spawn root application
128 const char *args[7+rootapp_argc+1+1];
131 args[argcount++] = "valgrind";
133 args[argcount++] = "./ld-acess";
134 args[argcount++] = "--open"; args[argcount++] = "/Devices/pts/vt0";
135 args[argcount++] = "--open"; args[argcount++] = "/Devices/pts/vt0";
136 args[argcount++] = "--open"; args[argcount++] = "/Devices/pts/vt0";
137 for( i = 0; i < rootapp_argc; i ++ )
138 args[argcount+i] = rootapp[i];
139 args[argcount+rootapp_argc] = NULL;
140 pid = spawnv(P_NOWAIT, "./ld-acess", (char *const*)args);
142 perror("Starting root application [fork(2)]");
145 printf("Root application running as PID %i\n", pid);
153 void AcessNative_Exit(void)
155 // TODO: Close client applications too
160 uint64_t DivMod64U(uint64_t Num, uint64_t Den, uint64_t *Rem)
162 if(Rem) *Rem = Num % Den;
166 int Module_EnsureLoaded(const char *Name)
171 void Proc_PrintBacktrace(void)