AcessNative - Loads login process and runs again (shell doesn't spawn)
authorJohn Hodge <[email protected]>
Wed, 3 Oct 2012 14:16:42 +0000 (22:16 +0800)
committerJohn Hodge <[email protected]>
Wed, 3 Oct 2012 14:16:42 +0000 (22:16 +0800)
AcessNative/acesskernel_src/server.c
AcessNative/acesskernel_src/threads.c
AcessNative/ld-acess_src/exports.c
BuildConf/x86_64/Makefile.cfg

index 02aa290..2f6b46f 100644 (file)
@@ -127,8 +127,15 @@ tClient *Server_GetClient(int ClientID)
 int Server_WorkerThread(void *ClientPtr)
 {
        tClient *Client = ClientPtr;
-       
+
+       Log_Debug("Server", "Worker %p", ClientPtr);    
+
        #if USE_TCP
+
+       while( *((volatile typeof(Client->Socket)*)&Client->Socket) == 0 )
+               SDL_Delay(10);
+       Threads_SetThread( Client->ClientID );
+       
        for( ;; )
        {
                fd_set  fds;
@@ -137,11 +144,12 @@ int Server_WorkerThread(void *ClientPtr)
                FD_SET(Client->Socket, &fds);
                
                int rv = select(nfd, &fds, NULL, NULL, NULL);   // TODO: Timeouts?
-               if(rv <= 0) {
+               if(rv < 0) {
                        perror("select");
                        continue ;
                }
-               
+               Log_Debug("Server", "%p: rv=%i", Client, rv);           
+
                if( FD_ISSET(Client->Socket, &fds) )
                {
                        const int       ciMaxParamCount = 6;
@@ -275,6 +283,8 @@ int Server_WorkerThread(void *ClientPtr)
                        free( retHeader );
        }
        #endif
+       Log_Notice("Server", "Terminated Worker %p", ClientPtr);        
+       return 0;
 }
 
 int SyscallServer(void)
@@ -386,7 +396,7 @@ int Server_ListenThread(void *Unused)
                                client->Socket = clientSock;
                        }
                }
-               Log_Debug("Server", "Client given PID %i", authhdr.pid);
+               Log_Debug("Server", "Client given PID %i - info %p", authhdr.pid, client);
                
                len = send(clientSock, &authhdr, sizeof(authhdr), 0);
                if( len != sizeof(authhdr) ) {
index a7aace8..c31c5d0 100644 (file)
@@ -120,6 +120,9 @@ tThread *Threads_CloneTCB(tThread *TemplateThread)
        
        ret->ThreadName = strdup(TemplateThread->ThreadName);
        ret->EventSem = SDL_CreateSemaphore(0);
+       if( !ret->EventSem ) {
+               Log_Warning("Threads", "Semaphore creation failed - %s", SDL_GetError());
+       }
        
        ret->WaitingThreads = NULL;
        ret->WaitingThreadsEnd = NULL;
@@ -373,12 +376,22 @@ Uint32 Threads_WaitEvents(Uint32 Mask)
        gpCurrentThread->WaitMask = Mask;
        if( !(gpCurrentThread->Events & Mask) )
        {
-               SDL_SemWait( gpCurrentThread->EventSem );
+               do {
+                       if( SDL_SemWait( gpCurrentThread->EventSem ) == -1 ) {
+                               Log_Warning("Threads", "Wait on eventsem of %p, %p failed",
+                                       gpCurrentThread, gpCurrentThread->EventSem);
+                               break;
+                       }
+               } while(SDL_SemValue(gpCurrentThread->EventSem));
+               // NOTE: While loop catches multiple event occurances
+               Log_Debug("Threads", "Woken from nap (%i here)", SDL_SemValue(gpCurrentThread->EventSem));
        }
        rv = gpCurrentThread->Events & Mask;
        gpCurrentThread->Events &= ~Mask;
        gpCurrentThread->WaitMask = -1;
-       
+
+       Log_Debug("Threads", "- rv = %x", rv);
+
        return rv;
 }
 
index fc336c8..55606a8 100644 (file)
@@ -35,6 +35,9 @@ extern int    AllocateMemory(uintptr_t VirtAddr, size_t ByteCount);
 // === CONSTANTS ===
 #define NATIVE_FILE_MASK       0x40000000
 
+// === GLOBALS ===
+int    acess__errno;
+
 // === CODE ===
 // --- VFS Calls
 int acess_chdir(const char *Path)
@@ -303,7 +306,7 @@ void acess__exit(int Status)
 
 
 // === Symbol List ===
-#define DEFSYM(name)   {#name, acess_##name}
+#define DEFSYM(name)   {#name, &acess_##name}
 const tSym     caBuiltinSymbols[] = {
        DEFSYM(_exit),
        
@@ -339,7 +342,9 @@ const tSym  caBuiltinSymbols[] = {
        DEFSYM(_SysAllocate),
        DEFSYM(_SysDebug),
        DEFSYM(_SysSetFaultHandler),
-       DEFSYM(_SysWaitEvent)
+       DEFSYM(_SysWaitEvent),
+       
+       DEFSYM(_errno)
 };
 
 const int      ciNumBuiltinSymbols = sizeof(caBuiltinSymbols)/sizeof(caBuiltinSymbols[0]);
index ebca2d9..6aa3afc 100644 (file)
@@ -1,6 +1,6 @@
 
-#PREFIX := x86_64-pc-elf
-PREFIX := x86_64-none-elf
+PREFIX := x86_64-pc-elf
+#PREFIX := x86_64-none-elf
 
 CC := $(PREFIX)-gcc
 LD := $(PREFIX)-ld

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