From: John Hodge Date: Fri, 2 Dec 2011 03:02:44 +0000 (+0800) Subject: AcessNative - Fixing errors caused by API changes X-Git-Tag: rel0.14~36 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=c84c6acf1e8be4fb6e76ef0f8fd275400be8d5ae;p=tpg%2Facess2.git AcessNative - Fixing errors caused by API changes --- diff --git a/AcessNative/acesskernel_src/helpers.c b/AcessNative/acesskernel_src/helpers.c index b08906c4..fb3e48cf 100644 --- a/AcessNative/acesskernel_src/helpers.c +++ b/AcessNative/acesskernel_src/helpers.c @@ -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; diff --git a/AcessNative/acesskernel_src/include/arch.h b/AcessNative/acesskernel_src/include/arch.h index fdd23a82..f5135306 100644 --- a/AcessNative/acesskernel_src/include/arch.h +++ b/AcessNative/acesskernel_src/include/arch.h @@ -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; diff --git a/AcessNative/acesskernel_src/include/proc.h b/AcessNative/acesskernel_src/include/proc.h index 56eb6e75..f178c801 100644 --- a/AcessNative/acesskernel_src/include/proc.h +++ b/AcessNative/acesskernel_src/include/proc.h @@ -5,5 +5,10 @@ #include +#define MAX_CPUS 1 + +typedef struct {} tTaskState; +typedef struct {} tMemoryState; + #endif diff --git a/AcessNative/acesskernel_src/threads.c b/AcessNative/acesskernel_src/threads.c index 34659926..dc4d643a 100644 --- a/AcessNative/acesskernel_src/threads.c +++ b/AcessNative/acesskernel_src/threads.c @@ -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; } diff --git a/AcessNative/acesskernel_src/ui_sdl.c b/AcessNative/acesskernel_src/ui_sdl.c index 6917c6c1..9f463568 100644 --- a/AcessNative/acesskernel_src/ui_sdl.c +++ b/AcessNative/acesskernel_src/ui_sdl.c @@ -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: diff --git a/AcessNative/ld-acess_src/exports.c b/AcessNative/ld-acess_src/exports.c index 0c1a671b..947e0d36 100644 --- a/AcessNative/ld-acess_src/exports.c +++ b/AcessNative/ld-acess_src/exports.c @@ -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) diff --git a/AcessNative/ld-acess_src/exports.h b/AcessNative/ld-acess_src/exports.h index 43d620ff..feb5bfd5 100644 --- a/AcessNative/ld-acess_src/exports.h +++ b/AcessNative/ld-acess_src/exports.h @@ -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); diff --git a/AcessNative/ld-acess_src/main.c b/AcessNative/ld-acess_src/main.c index 598055f4..cbe0ac1f 100644 --- a/AcessNative/ld-acess_src/main.c +++ b/AcessNative/ld-acess_src/main.c @@ -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(;;); } diff --git a/AcessNative/ld-acess_src/syscalls.c b/AcessNative/ld-acess_src/syscalls.c index c8348f5b..3c691aa1 100644 --- a/AcessNative/ld-acess_src/syscalls.c +++ b/AcessNative/ld-acess_src/syscalls.c @@ -8,6 +8,7 @@ #include #include #include +#include #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; +}