AcessNative - Fixes mostly, still not yet complete
authorJohn Hodge <[email protected]>
Mon, 16 May 2011 12:51:20 +0000 (20:51 +0800)
committerJohn Hodge <[email protected]>
Mon, 16 May 2011 12:51:20 +0000 (20:51 +0800)
AcessNative/acesskernel_src/Makefile
AcessNative/acesskernel_src/server.c
AcessNative/ld-acess_src/Makefile
AcessNative/ld-acess_src/binary.c
AcessNative/ld-acess_src/elf.c
AcessNative/ld-acess_src/syscalls.c

index 1c92b47..ed79684 100644 (file)
@@ -38,7 +38,7 @@ endif
 all: $(BIN)\r
 \r
 clean:\r
-       $(RM) $(BIN) $(OBJ)\r
+       $(RM) $(BIN) $(OBJ) $(DEPFILES)\r
 \r
 $(BIN): $(OBJ)\r
        @echo [LINK] -o $@\r
@@ -48,3 +48,5 @@ $(BIN): $(OBJ)
        @echo [CC] -o $@\r
        @$(CC) -c $< -o $@ $(CFLAGS) $(CPPFLAGS)\r
        @$(CC) -M $(CPPFLAGS) -MT $@ -o $*.d.$(PLATFORM) $<\r
+\r
+-include $(DEPFILES)\r
index 725a326..0cede83 100644 (file)
@@ -118,6 +118,7 @@ int Server_WorkerThread(void *ClientPtr)
        tRequestHeader  errorHeader;
         int    retSize = 0;
         int    sentSize;
+        int    cur_client_id = 0;
        
        #if USE_TCP
        #else
@@ -127,6 +128,11 @@ int Server_WorkerThread(void *ClientPtr)
                while( Client->CurrentRequest == NULL )
                        SDL_CondWait(Client->WaitFlag, Client->Mutex);
                
+               if(Client->ClientID != cur_client_id) {
+                       Threads_SetThread( Client->ClientID );
+                       cur_client_id = Client->ClientID;
+               }
+               
                Log_Debug("AcessSrv", "Worker %i takes %p",
                        Client->ClientID, Client->CurrentRequest);
                
@@ -245,9 +251,11 @@ int SyscallServer(void)
                tRequestHeader  *req = (void*)data;
                struct sockaddr_in      addr;
                uint    clientSize = sizeof(addr);
-                int    length = recvfrom(gSocket, data, BUFSIZ, 0, (struct sockaddr*)&addr, &clientSize);
+                int    length;
                tClient *client;
                
+               length = recvfrom(gSocket, data, BUFSIZ, 0, (struct sockaddr*)&addr, &clientSize);
+               
                if( length == -1 ) {
                        perror("SyscallServer - recv");
                        break;
index f7543fd..eb84ad8 100644 (file)
@@ -27,7 +27,7 @@ DEPFILES := $(DEPFILES:%.o.$(PLATFORM)=%.d.$(PLATFORM))
 all: $(BIN)
 
 clean:
-       $(RM) $(BIN) $(OBJ)
+       $(RM) $(BIN) $(OBJ) $(DEPFILES)
 
 $(BIN): link.ld.$(PLATFORM) $(OBJ)
 #      $(LD) -g -o $@ $(OBJ) -T link.ld.$(PLATFORM)
@@ -43,3 +43,5 @@ link.ld.lin:
        @echo Making Linker Script ($@)
        @$(LD) --verbose | awk '{ if( substr($$0,0,5) == "====="){ bPrint = !bPrint; } else { if(bPrint){ print $$0;} } }' | sed 's/\b0x0[08][0-9]*\b/0x00100000/g' > $@
 
+-include $(DEPFILES)
+
index d3dee99..6439fb9 100644 (file)
@@ -239,7 +239,7 @@ int Binary_GetSymbol(const char *SymbolName, uintptr_t *Value)
                }
        }
        
-       // TODO: Search list of loaded binaries
+       // Search list of loaded binaries
        for(bin = gLoadedBinaries; bin; bin = bin->Next)
        {
                if( !bin->Ready )       continue;
index c01d24d..daea044 100644 (file)
@@ -2,7 +2,7 @@
  * Acess v0.1\r
  * ELF Executable Loader Code\r
  */\r
-#define DEBUG  1\r
+#define DEBUG  0\r
 #include <stdlib.h>\r
 #include <stdio.h>\r
 #include <string.h>\r
@@ -108,8 +108,8 @@ void *Elf_Load(int FD)
                        continue;\r
                if( phtab[i].VAddr < base )\r
                        base = phtab[i].VAddr;\r
-               if( phtab[i].VAddr > max )\r
-                       max = phtab[i].VAddr;\r
+               if( phtab[i].VAddr + phtab[i].MemSize > max )\r
+                       max = phtab[i].VAddr + phtab[i].MemSize;\r
        }\r
 \r
        LOG("base = %08x, max = %08x\n", base, max);\r
@@ -492,6 +492,8 @@ int Elf_GetSymbol(void *Base, char *Name, uintptr_t *ret)
        pBuckets = PTR(hdr->misc.HashTable);\r
        symtab = PTR(hdr->misc.SymTable);\r
        \r
+//     LOG("Base = %p : pBuckets = %p, symtab = %p\n", Base, pBuckets, symtab);\r
+       \r
        if(!pBuckets || !symtab)\r
                return 0;\r
        \r
index 5882435..5fbecbd 100644 (file)
@@ -318,7 +318,7 @@ size_t acess_read(int FD, size_t Bytes, void *Dest) {
 size_t acess_write(int FD, size_t Bytes, void *Src) {
        if(FD & NATIVE_FILE_MASK)
                return fwrite( Src, Bytes, 1, gaSyscall_LocalFPs[FD & (NATIVE_FILE_MASK-1)] );
-       DEBUG("write(0x%x, 0x%x, %p(\"%.*s\"))", FD, Bytes, Src, Bytes, (char*)Src);
+       DEBUG("write(0x%x, 0x%x, %p\"%.*s\")", FD, Bytes, Src, Bytes, (char*)Src);
        return _Syscall(SYS_WRITE, ">i >i >d", FD, Bytes, Bytes, Src);
 }
 
@@ -372,6 +372,7 @@ int acess__SysMount(const char *Device, const char *Directory, const char *Type,
 
 // --- Error Handler
 int    acess__SysSetFaultHandler(int (*Handler)(int)) {
+       printf("TODO: Set fault handler (asked to set to %p)\n", Handler);
        return 0;
 }
 

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