return VAddr; // HACK!
}
+int MM_IsValidBuffer(tVAddr Base, int Size)
+{
+ return 1;
+}
+
Uint MM_GetFlags(tVAddr VAddr)
{
return 0;
#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;
#include <arch.h>
+#define MAX_CPUS 1
+
+typedef struct {} tTaskState;
+typedef struct {} tMemoryState;
+
#endif
// === GLOBALS ===
tThread gThreadZero = {
- State: 1,
- ThreadName: "ThreadZero"
+ .State=1,
+ .ThreadName="ThreadZero"
};
tThread *gpThreads = &gThreadZero;
__thread tThread *gpCurrentThread = &gThreadZero;
us->Next = NULL;
us->State = 3;
+ // TODO: Locking
if(thread->WaitingThreadsEnd)
{
thread->WaitingThreadsEnd->Next = us;
}
while(thread->State != 0)
+ {
pause();
+ Log_Debug("Threads", "Huh?... state = %i", thread->State);
+ }
if(Status) *Status = thread->ExitStatus;
thread->WaitingThreads = thread->WaitingThreads->Next;
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)
int Threads_Wake(tThread *Thread)
{
+ Thread->State = 0;
kill( Thread->KernelTID, SIGUSR1 );
return 0;
}
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:
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)
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);
// === IMPORTS ===
extern int giSyscall_ClientID;
+extern void acess__exit(int Status);
// === PROTOTYPES ===
void CallUser(void *Entry, int argc, char *argv[], char **envp) __attribute__((noreturn));
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;
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(;;);
}
#include <stdarg.h>
#include <string.h>
#include <stddef.h>
+#include <unistd.h>
#include "request.h"
#define DEBUG(str, x...) Debug(str, x)
{
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;
+}