X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=AcessNative%2Facesskernel_src%2Fmain.c;h=eb0883d7b729a73cdd76273263cfe379107b613e;hb=03900b58142ae00b0bf708accbbe97e1ba83188b;hp=f3ab1968bac8c3b3b3e0527b8c14267f38cfaf50;hpb=b0e7f44c01b9779093fd8ba65f69cb29a9308841;p=tpg%2Facess2.git diff --git a/AcessNative/acesskernel_src/main.c b/AcessNative/acesskernel_src/main.c index f3ab1968..eb0883d7 100644 --- a/AcessNative/acesskernel_src/main.c +++ b/AcessNative/acesskernel_src/main.c @@ -13,6 +13,9 @@ #endif #include #include +#include "../../KernelLand/Kernel/include/logdebug.h" + +#define VALGRIND_CLIENT 0 // === IMPORTS === extern int UI_Initialise(int Width, int Height); @@ -23,17 +26,32 @@ extern int NativeKeyboard_Install(char **Arguments); extern int NativeFS_Install(char **Arguments); extern void Debug_SetKTerminal(char *Path); extern int VT_Install(char **Arguments); +extern int Mouse_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 === +#ifndef __WIN32__ +#define P_NOWAIT 0 +int spawnv(int flags, const char *execuable, char * const argv[]) +{ + int pid = fork(); + if( pid != 0 ) return pid; + + execv(execuable, argv); + perror("spawnv - execve"); + for(;;); +} +#endif + int main(int argc, char *argv[]) { char **rootapp = NULL; @@ -63,14 +81,21 @@ int main(int argc, char *argv[]) UI_Initialise(800, 480); // - Ignore SIGUSR1 (used to wake threads) + #ifdef SIGUSR1 signal(SIGUSR1, SIG_IGN); + #endif // 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); + Mouse_Install(NULL); // - Start VTerm { char *args[] = { @@ -93,28 +118,24 @@ 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; + const 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; - - pid = fork(); + args[argcount+i] = rootapp[i]; + args[argcount+rootapp_argc] = NULL; + pid = spawnv(P_NOWAIT, "./ld-acess", args); if(pid < 0) { perror("Starting root application [fork(2)]"); return 1; } - if(pid == 0) - { - #ifdef __LINUX__ - prctl(PR_SET_PDEATHSIG, SIGHUP); // LINUX ONLY! - #endif - execv("./ld-acess", args); - } printf("Root application running as PID %i\n", pid); } @@ -126,6 +147,7 @@ int main(int argc, char *argv[]) void AcessNative_Exit(void) { // TODO: Close client applications too + Server_Shutdown(); exit(0); }