AcessNative - Bugfixes 'r' us, GUI can start and render (partially)
[tpg/acess2.git] / AcessNative / acesskernel_src / main.c
index f3ab196..609ea2a 100644 (file)
@@ -14,6 +14,8 @@
 #include <unistd.h>
 #include <string.h>
 
+#define VALGRIND_CLIENT        0
+
 // === IMPORTS ===
 extern int     UI_Initialise(int Width, int Height);
 extern void    UI_MainLoop(void);
@@ -26,12 +28,13 @@ extern int  VT_Install(char **Arguments);
 extern int     VFS_Mount(const char *Device, const char *MountPoint, const char *Filesystem, const char *Options);
 extern int     VFS_MkDir(const char *Path);
 extern int     SyscallServer(void);
+extern int     Server_Shutdown(void);
 extern const char      gsKernelVersion[];
 extern const char      gsGitHash[];
 extern int     giBuildNumber;
 
 // === GLOBALS ===
-const char     *gsAcessDir = "../Usermode/Output/x86";
+const char     *gsAcessDir = "../Usermode/Output/x86_64";
 
 // === CODE ===
 int main(int argc, char *argv[])
@@ -68,8 +71,12 @@ int main(int argc, char *argv[])
        // Initialise VFS
        VFS_Init();
        // - Start IO Drivers
-       Video_Install(NULL);
-       NativeKeyboard_Install(NULL);
+       if( Video_Install(NULL) ) {
+               Log_Error("Init", "Unable to load NativeVideo");
+       }
+       if( NativeKeyboard_Install(NULL) ) {
+               Log_Error("Init", "Unable to load NativeKeyboard");
+       }
        NativeFS_Install(NULL);
        // - Start VTerm
        {
@@ -93,15 +100,19 @@ int main(int argc, char *argv[])
        if( rootapp )
        {
                 int    pid;
-               char    *args[7+rootapp_argc+1];
-               
-               args[0] = "ld-acess";
-               args[1] = "--open";     args[2] = "/Devices/VTerm/0";
-               args[3] = "--open";     args[4] = "/Devices/VTerm/0";
-               args[5] = "--open";     args[6] = "/Devices/VTerm/0";
+                int    argcount = 0;
+               char    *args[7+rootapp_argc+1+1];
+
+               #if VALGRIND_CLIENT
+               args[argcount++] = "valgrind";
+               #endif
+               args[argcount++] = "./ld-acess";
+               args[argcount++] = "--open";    args[argcount++] = "/Devices/VTerm/0";
+               args[argcount++] = "--open";    args[argcount++] = "/Devices/VTerm/0";
+               args[argcount++] = "--open";    args[argcount++] = "/Devices/VTerm/0";
                for( i = 0; i < rootapp_argc; i ++ )
-                       args[7+i] = rootapp[i];
-               args[7+rootapp_argc] = NULL;
+                       args[argcount+i] = rootapp[i];
+               args[argcount+rootapp_argc] = NULL;
                
                pid = fork();
                if(pid < 0) {
@@ -113,7 +124,11 @@ int main(int argc, char *argv[])
                        #ifdef __LINUX__
                        prctl(PR_SET_PDEATHSIG, SIGHUP);        // LINUX ONLY!
                        #endif
+                       #if VALGRIND_CLIENT
+                       execv("valgrind", args);
+                       #else
                        execv("./ld-acess", args);
+                       #endif
                }
                printf("Root application running as PID %i\n", pid);
        }
@@ -126,6 +141,7 @@ int main(int argc, char *argv[])
 void AcessNative_Exit(void)
 {
        // TODO: Close client applications too
+       Server_Shutdown();
        exit(0);
 }
 

UCC git Repository :: git.ucc.asn.au