AcessNative - Now can use the `dir` CLIShell builtin
authorJohn Hodge <[email protected]>
Mon, 24 Oct 2011 01:17:41 +0000 (09:17 +0800)
committerJohn Hodge <[email protected]>
Mon, 24 Oct 2011 01:17:41 +0000 (09:17 +0800)
AcessNative/acesskernel_src/Makefile.BuildNum
AcessNative/acesskernel_src/include/arch.h
AcessNative/acesskernel_src/main.c
AcessNative/acesskernel_src/nativefs.c
AcessNative/acesskernel_src/server.c
AcessNative/acesskernel_src/syscalls.c
AcessNative/ld-acess_src/exports.c
AcessNative/ld-acess_src/syscalls.c

index 849eba8..fdd23a8 100644 (file)
@@ -28,11 +28,6 @@ typedef intptr_t     tPAddr;
 
 typedef        int     BOOL;
 
-//typedef uint32_t     tTID;
-//typedef uint32_t     tPID;
-//typedef uint32_t     tUID;
-//typedef uint32_t     tGID;
-
 struct sShortSpinlock
 {
         int    IsValid;
index 9f0daa4..bc4083c 100644 (file)
@@ -25,7 +25,7 @@ extern const char     gsGitHash[];
 extern int     giBuildNumber;
 
 // === GLOBALS ===
-const char     *gsAcessDir = "../Usermode/Output/i386";
+const char     *gsAcessDir = "../Usermode/Output/x86";
 
 // === CODE ===
 int main(int argc, char *argv[])
@@ -55,7 +55,8 @@ int main(int argc, char *argv[])
                        };
                VT_Install(args);
        }
-       
+
+       VFS_MkDir("/Acess");    
        VFS_Mount(gsAcessDir, "/Acess", "nativefs", "");
 
        Debug_SetKTerminal("/Devices/VTerm/8");
index 6d6e2fe..9de8ae2 100644 (file)
@@ -53,7 +53,10 @@ tVFS_Node *NativeFS_Mount(const char *Device, const char **Arguments)
        DIR     *dp;\r
        \r
        dp = opendir(Device);\r
-       if(!dp) return NULL;\r
+       if(!dp) {\r
+               Log_Warning("NativeFS", "ERRO: Unable to open device root '%s'", Device);\r
+               return NULL;\r
+       }\r
        \r
        // Check if directory exists\r
        // Parse flags from arguments\r
@@ -144,6 +147,7 @@ tVFS_Node *NativeFS_FindDir(tVFS_Node *Node, const char *Name)
 char *NativeFS_ReadDir(tVFS_Node *Node, int Position)\r
 {\r
        // Keep track of the current directory position\r
+       // TODO: Implement NativeFS_ReadDir\r
        return NULL;\r
 }\r
 \r
index 80d7c25..953722c 100644 (file)
@@ -136,11 +136,12 @@ int Server_WorkerThread(void *ClientPtr)
                        cur_client_id = Client->ClientID;
                }
                
-               Log_Debug("AcessSrv", "Worker %i takes %p",
-                       Client->ClientID, Client->CurrentRequest);
-               
                // Get the response
                retHeader = SyscallRecieve(Client->CurrentRequest, &retSize);
+
+               Log_Debug("AcessSrv", "Client %i request %i",
+                       Client->ClientID, Client->CurrentRequest->CallID);
+               
                
                if( !retHeader ) {
                        // Return an error to the client
index 70e09f1..84eb416 100644 (file)
@@ -4,6 +4,7 @@
  *
  * Syscall Distribution
  */
+#define DEBUG  1
 #include <acess.h>
 #include <threads.h>
 #include "../syscalls.h"
@@ -23,6 +24,7 @@ typedef int   (*tSyscallHandler)(Uint *Errno, const char *Format, void *Args, int
        a2 = *(_t2*)Args;Args+=sizeof(_t2);\
        a3 = *(_t3*)Args;Args+=sizeof(_t3);\
        a4 = *(_t4*)Args;Args+=sizeof(_t4);\
+       LOG("SYSCALL5 '%s' %p %p %p %p %p", Fmt, (intptr_t)a0,(intptr_t)a1,(intptr_t)a2,(intptr_t)a3,(intptr_t)a4);\
        _call\
 }
 #define SYSCALL4(_name, _fmtstr, _t0, _t1, _t2, _t3, _call) int _name(Uint*Errno,const char*Fmt,void*Args,int*Sizes){\
@@ -32,6 +34,7 @@ typedef int   (*tSyscallHandler)(Uint *Errno, const char *Format, void *Args, int
        a1 = *(_t1*)Args;Args+=sizeof(_t1);\
        a2 = *(_t2*)Args;Args+=sizeof(_t2);\
        a3 = *(_t3*)Args;Args+=sizeof(_t3);\
+       LOG("SYSCALL4 '%s' %p %p %p %p", Fmt, (intptr_t)a0,(intptr_t)a1,(intptr_t)a2,(intptr_t)a3);\
        _call\
 }
 
@@ -41,6 +44,7 @@ typedef int   (*tSyscallHandler)(Uint *Errno, const char *Format, void *Args, int
        a0 = *(_t0*)Args;Args+=sizeof(_t0);\
        a1 = *(_t1*)Args;Args+=sizeof(_t1);\
        a2 = *(_t2*)Args;Args+=sizeof(_t2);\
+       LOG("SYSCALL3 '%s' %p %p %p", Fmt, (intptr_t)a0,(intptr_t)a1,(intptr_t)a2);\
        _call\
 }
 
@@ -49,6 +53,7 @@ typedef int   (*tSyscallHandler)(Uint *Errno, const char *Format, void *Args, int
        if(strcmp(Fmt,_fmtstr)!=0)return 0;\
        a0 = *(_t0*)Args;Args+=sizeof(_t0);\
        a1 = *(_t1*)Args;Args+=sizeof(_t1);\
+       LOG("SYSCALL2 '%s' %p %p", Fmt, (intptr_t)a0,(intptr_t)a1);\
        _call;\
 }
 
@@ -56,11 +61,13 @@ typedef int (*tSyscallHandler)(Uint *Errno, const char *Format, void *Args, int
        _t0 a0;\
        if(strcmp(Fmt,_fmtstr)!=0)return 0;\
        a0 = *(_t0*)Args;Args+=sizeof(_t0);\
+       LOG("SYSCALL1 '%s' %p", Fmt,(intptr_t)a0);\
        _call;\
 }
 
 #define SYSCALL0(_name, _call) int _name(Uint*Errno,const char*Fmt, void*Args,int*Sizes){\
        if(strcmp(Fmt,"")!=0)return 0;\
+       LOG("SYSCALL0");\
        _call;\
 }
 
@@ -104,8 +111,12 @@ SYSCALL3(Syscall_IOCtl, "iid", int, int, void *,
        return VFS_IOCtl(a0, a1, a2);
 );
 SYSCALL3(Syscall_FInfo, "idi", int, void *, int,
-       if( Sizes[1] < sizeof(tFInfo)+a2*sizeof(tVFS_ACL))
+       if( Sizes[1] < sizeof(tFInfo)+a2*sizeof(tVFS_ACL)) {
+               LOG("offsetof(size) = %i", offsetof(tFInfo, size));
+               LOG("Bad size %i < %i", Sizes[1], sizeof(tFInfo)+a2*sizeof(tVFS_ACL));
+               *Errno = -EINVAL;
                return -1;
+       }
        return VFS_FInfo(a0, a1, a2);
 );
 SYSCALL2(Syscall_ReadDir, "id", int, char *,
@@ -263,19 +274,19 @@ tRequestHeader *SyscallRecieve(tRequestHeader *Request, int *ReturnLength)
                        case ARG_TYPE_VOID:
                                break;
                        case ARG_TYPE_INT32:
-                               LOG("Syscalls", "%i INT32: 0x%x", i, *(Uint32*)inData);
+                               LOG("%i INT32: 0x%x", i, *(Uint32*)inData);
                                *(Uint32*)&argListData[argListLen] = *(Uint32*)inData;
                                argListLen += sizeof(Uint32);
                                inData += sizeof(Uint32);
                                break;
                        case ARG_TYPE_INT64:
-                               LOG("Syscalls", "%i INT64: 0x%llx", i, *(Uint64*)inData);
+                               LOG("%i INT64: 0x%llx", i, *(Uint64*)inData);
                                *(Uint64*)&argListData[argListLen] = *(Uint64*)inData;
                                argListLen += sizeof(Uint64);
                                inData += sizeof(Uint64);
                                break;
                        case ARG_TYPE_STRING:
-                               LOG("Syscalls", "%i STR: '%s'", i, (char*)inData);
+                               LOG("%i STR: '%s'", i, (char*)inData);
                                *(char**)&argListData[argListLen] = (char*)inData;
                                argListLen += sizeof(void*);
                                inData += Request->Params[i].Length;
@@ -296,7 +307,7 @@ tRequestHeader *SyscallRecieve(tRequestHeader *Request, int *ReturnLength)
                                {
                                        // Allocate and zero the buffer
                                        returnData[i] = calloc(1, Request->Params[i].Length);
-                                       LOG("Syscalls", "%i ZDAT: %i %p", i,
+                                       LOG("%i ZDAT: %i %p", i,
                                                Request->Params[i].Length, returnData[i]);
                                        *(void**)&argListData[argListLen] = returnData[i];
                                        argListLen += sizeof(void*);
@@ -304,7 +315,7 @@ tRequestHeader *SyscallRecieve(tRequestHeader *Request, int *ReturnLength)
                                else
                                {
                                        returnData[i] = (void*)inData;
-                                       LOG("Syscalls", "%i DATA: %i %p", i,
+                                       LOG("%i DATA: %i %p", i,
                                                Request->Params[i].Length, returnData[i]);
                                        *(void**)&argListData[argListLen] = (void*)inData;
                                        argListLen += sizeof(void*);
index 533c25b..0c1a671 100644 (file)
@@ -93,10 +93,13 @@ int acess_ioctl(int fd, int id, void *data) {
        return _Syscall(SYS_IOCTL, ">i >i ?d", fd, id, 1024, data);
 }
 int acess_finfo(int fd, t_sysFInfo *info, int maxacls) {
+       DEBUG("offsetof(size, t_sysFInfo) = %i", offsetof(t_sysFInfo, size));
+       DEBUG("finfo(%i, %p, %i)", fd, info, maxacls);
        return _Syscall(SYS_FINFO, ">i <d >i",
                fd,
                sizeof(t_sysFInfo)+maxacls*sizeof(t_sysACL), info,
-               maxacls);
+               maxacls
+               );
 }
 
 int acess_readdir(int fd, char *dest) {
@@ -120,7 +123,7 @@ int acess__SysOpenChild(int fd, char *name, int flags) {
 }
 
 int acess__SysGetACL(int fd, t_sysACL *dest) {
-       return _Syscall(SYS_GETACL, "<i >i <d", fd, sizeof(t_sysACL), dest);
+       return _Syscall(SYS_GETACL, ">i <d", fd, sizeof(t_sysACL), dest);
 }
 
 int acess__SysMount(const char *Device, const char *Directory, const char *Type, const char *Options) {
@@ -129,7 +132,7 @@ int acess__SysMount(const char *Device, const char *Directory, const char *Type,
 
 
 // --- Error Handler
-int    acess__SysSetFaultHandler(int (*Handler)(int)) {
+int acess__SysSetFaultHandler(int (*Handler)(int)) {
        printf("TODO: Set fault handler (asked to set to %p)\n", Handler);
        return 0;
 }
index 7bb3b03..c8348f5 100644 (file)
@@ -29,11 +29,13 @@ const char *ReadEntry(tRequestValue *Dest, void *DataDest, void **PtrDest, const
         int    direction = 0;  // 0: Invalid, 1: Out, 2: In, 3: Out
        char    *str;
         int    len;
-       
+
        // Eat whitespace
        while(*ArgTypes && *ArgTypes == ' ')    ArgTypes ++;
        if( *ArgTypes == '\0' ) return ArgTypes;
        
+//     DEBUG("ArgTypes = '%s'", ArgTypes);
+       
        // Get direction
        switch(*ArgTypes)
        {

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