AcessNative - Fixing errors caused by API changes
authorJohn Hodge <[email protected]>
Fri, 2 Dec 2011 03:02:44 +0000 (11:02 +0800)
committerJohn Hodge <[email protected]>
Fri, 2 Dec 2011 03:02:44 +0000 (11:02 +0800)
AcessNative/acesskernel_src/helpers.c
AcessNative/acesskernel_src/include/arch.h
AcessNative/acesskernel_src/include/proc.h
AcessNative/acesskernel_src/threads.c
AcessNative/acesskernel_src/ui_sdl.c
AcessNative/ld-acess_src/exports.c
AcessNative/ld-acess_src/exports.h
AcessNative/ld-acess_src/main.c
AcessNative/ld-acess_src/syscalls.c

index b08906c..fb3e48c 100644 (file)
@@ -98,6 +98,11 @@ tPAddr MM_GetPhysAddr(tVAddr VAddr)
        return VAddr;   // HACK!
 }
 
+int MM_IsValidBuffer(tVAddr Base, int Size)
+{
+       return 1;
+}
+
 Uint MM_GetFlags(tVAddr VAddr)
 {
        return 0;
index fdd23a8..f513530 100644 (file)
@@ -9,6 +9,7 @@
 #undef CLONE_VM
 #define        _MODULE_NAME_   "NativeKernel"
 
+#define PAGE_SIZE      0x1000  // Assume, making an Ass out of u and me
 #define BITS   (sizeof(intptr_t)*8)
 
 typedef uint8_t        Uint8;
index 56eb6e7..f178c80 100644 (file)
@@ -5,5 +5,10 @@
 
 #include <arch.h>
 
+#define MAX_CPUS       1
+
+typedef struct {} tTaskState;
+typedef struct {} tMemoryState;
+
 #endif
 
index 3465992..dc4d643 100644 (file)
@@ -70,8 +70,8 @@ typedef struct sThread
 
 // === GLOBALS ===
 tThread        gThreadZero = {
-       State: 1,
-       ThreadName: "ThreadZero"
+       .State=1,
+       .ThreadName="ThreadZero"
 };
 tThread        *gpThreads = &gThreadZero;
 __thread tThread       *gpCurrentThread = &gThreadZero;
@@ -207,6 +207,7 @@ int Threads_WaitTID(int TID, int *Status)
                
                us->Next = NULL;
                us->State = 3;
+               // TODO: Locking
                if(thread->WaitingThreadsEnd)
                {
                        thread->WaitingThreadsEnd->Next = us;
@@ -219,7 +220,10 @@ int Threads_WaitTID(int TID, int *Status)
                }
                
                while(thread->State != 0)
+               {
                        pause();
+                       Log_Debug("Threads", "Huh?... state = %i", thread->State);
+               }
                
                if(Status)      *Status = thread->ExitStatus;
                thread->WaitingThreads = thread->WaitingThreads->Next;
@@ -247,15 +251,22 @@ void Threads_Exit(int TID, int Status)
        tThread *toWake;
        
 //     VFS_Handles_Cleanup();
+
+       gpCurrentThread->ExitStatus = Status;
        
        #if 1
-       // Wait for the thread to be waited upon
-       while( gpCurrentThread->WaitingThreads == NULL )
-               SDL_Delay(10);
+       if( gpCurrentThread->Parent )
+       {
+               // Wait for the thread to be waited upon
+               while( gpCurrentThread->WaitingThreads == NULL )
+                       SDL_Delay(10);
+       }
        #endif
        
        while( (toWake = gpCurrentThread->WaitingThreads) )
        {
+               Log_Debug("Threads", "Threads_Exit - Waking %p %i '%s'", toWake, toWake->TID, toWake->ThreadName);
+
                Threads_Wake(toWake);
                
                while(gpCurrentThread->WaitingThreads == toWake)
@@ -265,6 +276,7 @@ void Threads_Exit(int TID, int Status)
 
 int Threads_Wake(tThread *Thread)
 {
+       Thread->State = 0;
        kill( Thread->KernelTID, SIGUSR1 );
        return 0;
 }
index 6917c6c..9f46356 100644 (file)
@@ -131,16 +131,20 @@ void UI_MainLoop(void)
                                acess_sym = UI_GetAcessKeyFromSDL(event.key.keysym.sym,
                                        event.key.keysym.unicode);
                                
-                               if( gUI_KeyboardCallback )
-                                       gUI_KeyboardCallback(acess_sym);
+                               if( gUI_KeyboardCallback ) {
+                                       gUI_KeyboardCallback(KEY_ACTION_RAWSYM|event.key.keysym.sym);
+                                       gUI_KeyboardCallback(KEY_ACTION_PRESS|acess_sym);
+                               }
                                break;
                        
                        case SDL_KEYUP:
                                acess_sym = UI_GetAcessKeyFromSDL(event.key.keysym.sym,
                                        event.key.keysym.unicode);
                                
-                               if( gUI_KeyboardCallback )
-                                       gUI_KeyboardCallback(0x80000000|acess_sym);
+                               if( gUI_KeyboardCallback ) {
+                                       gUI_KeyboardCallback(KEY_ACTION_RAWSYM|event.key.keysym.sym);
+                                       gUI_KeyboardCallback(KEY_ACTION_RELEASE|acess_sym);
+                               }
                                break;
                        
                        default:
index 0c1a671..947e0d3 100644 (file)
@@ -200,10 +200,17 @@ int acess_execve(char *path, char **argv, char **envp)
        for( i = 0; i < argc; i ++ )
                printf("\"%s\" ", new_argv[i]);
        printf("\n");
+       if(envp)
+       {
+               printf("envp = %p\n", envp);
+               for( i = 0; envp[i]; i ++ )
+                       printf("%i: \"%s\"\n", i, envp[i]);
+               printf("envc = %i\n", i);
+       }
        #endif
        
        // Call actual execve
-       return execve("./ld-acess", new_argv, envp);
+       return native_execve("./ld-acess", new_argv, envp);
 }
 
 void acess_sleep(void)
index 43d620f..feb5bfd 100644 (file)
@@ -18,6 +18,8 @@ extern size_t native_write(int FD, const void *Src, size_t Bytes);
 extern int     native_seek(int FD, int64_t Offset, int Dir);
 extern uint64_t        native_tell(int FD);
 
+extern int     native_execve(const char *filename, char *const argv[], char *const envp[]);
+
 // Syscalls used by the linker
 extern int     acess_open(const char *Path, int Flags);
 extern void    acess_close(int FD);
index 598055f..cbe0ac1 100644 (file)
@@ -8,6 +8,7 @@
 
 // === IMPORTS ===
 extern int     giSyscall_ClientID;
+extern void    acess__exit(int Status);
 
 // === PROTOTYPES ===
 void   CallUser(void *Entry, int argc, char *argv[], char **envp) __attribute__((noreturn));
@@ -19,8 +20,9 @@ int main(int argc, char *argv[], char **envp)
         int    appArgc;
        char    **appArgv;
        char    *appPath = NULL;
-        int    (*appMain)(int, char *[], char **);
+        int    (*appMain)(int, char *[], char **) __attribute__((cdecl));
        void    *base;
+        int    rv;
        
 //      int    syscall_handle = -1;
        
@@ -77,28 +79,24 @@ int main(int argc, char *argv[], char **envp)
                printf("\"%s\" ", appArgv[i]);
        printf("\n");
        printf("[DEBUG %i] appMain = %p\n", giSyscall_ClientID, appMain);
-       #if 0
-       __asm__ __volatile__ (
-               "push %0;\n\t"
-               "push %1;\n\t"
-               "push %2;\n\t"
-               "jmp *%3;\n\t"
-               : : "r" (envp), "r" (appArgv), "r" (appArgc), "r" (appMain) );
-       return -1;
-       #elif 1
-       CallUser(appMain, appArgc, appArgv, envp);
-       #else
-       return appMain(appArgc, appArgv, NULL);
-       #endif
+//     CallUser(appMain, appArgc, appArgv, envp);
+       rv = appMain(appArgc, appArgv, envp);
+       acess__exit(rv);
+       return rv;
 }
 
 void CallUser(void *Entry, int argc, char *argv[], char **envp)
 {
+       #if 0
        __asm__ __volatile__ (
-               "mov %1, %%esp;\n\t"
-               "jmp *%0"
-               : : "r" (Entry), "r" (&argc)
+               "push %3;\n\t"
+               "push %2;\n\t"
+               "push %1;\n\t"
+               "call *%0"
+               : : "r" (Entry), "r" (argc), "r" (argv), "r" (envp)
                );
+       #else
+       #endif
        for(;;);
 }
 
index c8348f5..3c691aa 100644 (file)
@@ -8,6 +8,7 @@
 #include <stdarg.h>
 #include <string.h>
 #include <stddef.h>
+#include <unistd.h>
 #include "request.h"
 
 #define DEBUG(str, x...)       Debug(str, x)
@@ -316,3 +317,11 @@ uint64_t native_tell(int FD)
 {
        return ftell( gaSyscall_LocalFPs[FD] );
 }
+
+int native_execve(const char *filename, char *const argv[], char *const envp[])
+{
+       int ret;
+       ret = execve(filename, argv, envp);
+       perror("native_execve");
+       return ret;
+}

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