AcessNative - Fixing bad handling of errors, add run script for ARCH=native
authorJohn Hodge (sonata) <[email protected]>
Wed, 5 Nov 2014 07:07:33 +0000 (15:07 +0800)
committerJohn Hodge (sonata) <[email protected]>
Wed, 5 Nov 2014 07:07:33 +0000 (15:07 +0800)
AcessNative/Makefile
AcessNative/RunNative [new file with mode: 0755]
AcessNative/RunRootApp
AcessNative/RunTest
AcessNative/acesskernel_src/Makefile
AcessNative/ld-acess_src/request.c
AcessNative/ld-acess_src/syscalls.c
AcessNative/libacess-native.so_src/Makefile
AcessNative/libacess-native.so_src/main.c

index 7448f4f..c7090be 100644 (file)
@@ -4,3 +4,4 @@
 all clean:
        @$(MAKE) -C acesskernel_src $@
        @$(MAKE) -C ld-acess_src $@
+       @$(MAKE) -C libacess-native.so_src $@
diff --git a/AcessNative/RunNative b/AcessNative/RunNative
new file mode 100755 (executable)
index 0000000..255cf83
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/sh
+#
+# Execute the specified root application using the ARCH=native build
+#
+_=$PWD; cd $(dirname $0); DIR=$PWD; cd $_
+DISTROOT=$(dirname $DIR)/Usermode/Output/native/
+VTERM=/Devices/pts/vt0
+
+# 1. Start up AcessKernel
+# - Set DISTROOT to the output directory of ARCH=native
+# - Don't start a root application
+${DIR}/AcessKernel --distroot $DISTROOT > ${DIR}/log/native_AcessKernel.log &
+sleep 1
+LD_LIBRARY_PATH=${DIR}:${DISTROOT}Libs AN_PREOPEN=$VTERM:$VTERM:$VTERM ${DBG} ${DISTROOT}Apps/AxWin/4.0/AxWinServer
index 39a30fa..a3d31ab 100755 (executable)
@@ -1,3 +1,7 @@
 #!/bin/sh
 
+#
+# Spin up an application bound to VTerm 0 using ./ld-acess
+#
+
 $DBG ./ld-acess --open /Devices/VTerm/0 --open /Devices/VTerm/0 --open /Devices/VTerm/0 $*
index 6ea88b6..069ea14 100755 (executable)
@@ -1,4 +1,7 @@
 #!/bin/sh
+#
+# Runs the AcessNative kernel and spawns a native executable using ./ld-acess
+#
 trap '' 2
 #$1 ./AcessKernel --rootapp /Acess/SBin/login
 $1 ./AcessKernel --rootapp /Acess/Apps/AxWin/3.0/AxWinWM
index d2a22c6..4f388a2 100644 (file)
@@ -46,6 +46,7 @@ KCPPFLAGS = -I include/ -I $(KERNEL_SRC)include/ -I$(LDACESS_SRC)include_exp/ -D
 CFLAGS += -Wall -g -std=gnu99\r
 CPPFLAGS += $(shell sdl-config --cflags) -I /usr/include/\r
 LDFLAGS += $(shell sdl-config --libs) -g -Wl,--defsym,__buildnum=$(BUILD_NUM)\r
+LDFLAGS += -Wl,-Map,obj-$(PLATFORM)/Map.txt\r
 \r
 ifeq ($(PLATFORM),win)\r
        BIN := ../AcessKernel.exe\r
index c516a22..690c7f7 100644 (file)
@@ -229,12 +229,12 @@ int SendRequest(tRequestHeader *Request, int RequestSize, int ResponseSize)
        // Send it off
        SendData(Request, RequestSize);
 
-       if( Request->CallID == SYS_EXIT )       return 0;
-
        // Wait for a response (no timeout)
        ReadData(Request, sizeof(*Request), 0);
+       
+       size_t  recvbytes = sizeof(*Request);
        // TODO: Sanity
-       size_t  recvbytes = sizeof(*Request), expbytes = Request->MessageLength;
+       size_t  expbytes = Request->MessageLength;
        char    *ptr = (void*)Request->Params;
        while( recvbytes < expbytes )
        {
index 60b7d95..9822972 100644 (file)
@@ -171,7 +171,6 @@ uint64_t _Syscall(int SyscallID, const char *ArgTypes, ...)
        tRequestHeader  *req;
        void    *dataPtr;
        uint64_t        retValue;
-        int    i;
        
        // DEBUG!
 //     printf("&tRequestHeader->Params = %i\n", offsetof(tRequestHeader, Params));
@@ -244,8 +243,11 @@ uint64_t _Syscall(int SyscallID, const char *ArgTypes, ...)
                exit(127);
        }
        
+       if( !(req->NParams >= 2) ) {
+               fprintf(stderr, "syscalls.c: Too few return params (%i)", req->NParams);
+               exit(127);
+       }
        dataPtr = (void*)&req->Params[req->NParams];
-       assert(req->NParams >= 2);
        // return
        assert(req->Params[0].Type == ARG_TYPE_INT64);
        assert(req->Params[0].Length == sizeof(uint64_t));
@@ -264,7 +266,7 @@ uint64_t _Syscall(int SyscallID, const char *ArgTypes, ...)
                exit(127);
        }
        retCount = 0;
-       for( i = 2; i < req->NParams; i ++ )
+       for( unsigned int i = 2; i < req->NParams; i ++ )
        {
                #if 0
                 int     j;
index 9278311..2a0f0c4 100644 (file)
@@ -20,7 +20,7 @@ $(warning $(BINLINK))
 
 CFLAGS   += -Wall
 CFLAGS   += -Werror
-CFLAGS   += -g -shared -fPIC
+CFLAGS   += -g -shared -fPIC -std=c99
 CPPFLAGS += -DARCHDIR_is_x86_64=1
 LDFLAGS  += -g -shared -Wl,--no-undefined -lc
 
index 74d9d3c..7f62545 100644 (file)
@@ -59,7 +59,7 @@ int libacessnative_init(int argc, char *argv[], char **envp)
                        path[len] = 0;
                        int fd = acess__SysOpen(path, 6);       // WRITE,READ,no EXEC
                        if( fd == -1 ) {
-                               fprintf(stderr, "Unable to preopen '%s'\n", path);
+                               fprintf(stderr, "Unable to preopen '%s' errno=%i\n", path, acess__errno);
                        }
                        
                        if( !splitter )
@@ -77,7 +77,7 @@ int libacessnative_init(int argc, char *argv[], char **envp)
 int acessnative_spawn(const char *Binary, int SyscallID, const char * const * argv, const char * const * envp)
 {
         int    envc = 0;
-       while( envp[envc++] )
+       while( envp && envp[envc++] )
                envc ++;
 
        // Set environment variables for libacess-native
@@ -89,7 +89,7 @@ int acessnative_spawn(const char *Binary, int SyscallID, const char * const * ar
        
        const char *newenv[envc+2+1];
         int    i = 0;
-       for( ; envp[i]; i ++ )
+       for( ; envp && envp[i]; i ++ )
        {
                const char      *ev = envp[i];
                if( strncmp(ev, ENV_VAR_KEY"=", sizeof(ENV_VAR_KEY"=")) == 0 ) {
@@ -100,7 +100,7 @@ int acessnative_spawn(const char *Binary, int SyscallID, const char * const * ar
        }
        if( !bKeyHit )
                newenv[i++] = keystr;
-       newenv[i++] = "LD_LIBRARY_PATH=Libs/";  // HACK
+       newenv[i++] = getenv("LD_LIBRARY_PATH") - (sizeof("LD_LIBRARY_PATH=")-1);       // VERY hacky
        newenv[i] = NULL;
        
        // TODO: Detect native_spawn failing

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