return 0;
);
SYSCALL3(Syscall_Read, "iid", int, int, void *,
- if( Sizes[2] < a1 )
+ if( Sizes[2] < a1 ) {
+ Log_Warning("Syscalls", "Read - %i < %i", Sizes[2], a1);
return -1;
+ }
return VFS_Read(a0, a1, a2);
);
SYSCALL3(Syscall_Write, "iid", int, int, const void *,
SYSCALL4(Syscall_Mount, "ssss", const char *, const char *, const char *, const char *,
return VFS_Mount(a0, a1, a2, a3);
);
+SYSCALL1(Syscall_Chdir, "s", const char *,
+ return VFS_ChDir(a0);
+);
SYSCALL0(Syscall_Sleep,
Threads_Sleep();
return 0;
Syscall_GetACL,
Syscall_Mount,
NULL, // SYS_REOPEN
+ Syscall_Chdir,
Syscall_WaitTID,
Syscall_SetUID,
*(Uint64*)inData = retVal;
inData += sizeof(Uint64);
- LOG("Syscalls", "Return 0x%llx", retVal);
+ Log_Debug("Syscalls", "Return 0x%llx", retVal);
retValueCount = 1;
for( i = 0; i < Request->NParams; i ++ )
}
}
+void Threads_SetThread(int TID)
+{
+ tThread *thread;
+ for( thread = gpThreads; thread; thread = thread->GlobalNext )
+ {
+ if( thread->TID == TID ) {
+ gpCurrentThread = thread;
+ return ;
+ }
+ }
+ Log_Error("Threads", "_SetThread - Thread %i is not on global list", TID);
+}
+
tThread *Threads_GetThread(int TID)
{
tThread *thread;
Uint *Threads_GetCfgPtr(int Index)
{
+// Log_Debug("Threads", "Index=%i, gpCurrentThread=%p",
+// Index, gpCurrentThread);
if( Index < 0 || Index >= NUM_CFG_ENTRIES )
return NULL;
if( !gpCurrentThread )
* Acess2 VFS
* - AllocHandle, GetHandle
*/
-#define DEBUG 1
+#define DEBUG 0
#include <acess.h>
#include <vfs.h>
#include <vfs_int.h>
tUserHandles *ent, *prev = NULL;
for( ent = gpUserHandles; ent; prev = ent, ent = ent->Next ) {
if( ent->PID == PID ) {
- Log_Warning("VFS", "Process %i already has a handle list", PID);
+ if( bCreate )
+ Log_Warning("VFS", "Process %i already has a handle list", PID);
return ent;
}
if( ent->PID > PID ) break;
{
char *path;
void *ret;
- int (*entry)(int,char*[],char**) = NULL;
+ int (*entry)(void *,int,char*[],char**) = NULL;
// Find File
path = Binary_LocateLibrary(Name);
}
ret = Binary_Load(path, (uintptr_t*)&entry);
+ printf("LOADED '%s' to %p (Entry=%p)\n", path, ret, entry);
free(path);
#if DEBUG
#if DEBUG
printf("Calling '%s' entry point %p\n", Name, entry);
#endif
- entry(0, argv, NULL);
+ entry(ret, 0, argv, NULL);
}
return ret;
#include <stdarg.h>
#include <string.h>
+// === PROTOTYPES ===
+void CallUser(void *Entry, int argc, char *argv[], char **envp) __attribute__((noreturn));
+
// === CODE ===
int main(int argc, char *argv[], char **envp)
{
}
if( i >= argc ) {
- fprintf(stderr, "Usage: ld-acess <executable> [arguments ...]\n");
+ fprintf(stderr,
+ "Usage: ld-acess <executable> [arguments ...]\n"
+ "\n"
+ "--key\t(internal) used to pass the system call handle when run with execve\n"
+ "--binary\tLoad a local binary directly\n"
+ "--open\tOpen a file before executing\n"
+ );
return 1;
}
if( !base ) return 127;
printf("==============================\n");
+ printf("%i %p ", appArgc, appArgv);
for(i = 0; i < appArgc; i ++)
printf("\"%s\" ", appArgv[i]);
printf("\n");
+ printf("appMain = %p\n", appMain);
+ #if 0
__asm__ __volatile__ (
"push %0;\n\t"
"push %1;\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
+}
+
+void CallUser(void *Entry, int argc, char *argv[], char **envp)
+{
+ __asm__ __volatile__ (
+ "mov %1, %%esp;\n\t"
+ "jmp *%0"
+ : : "r" (Entry), "r" (&argc)
+ );
+ for(;;);
}
void Warning(const char *Format, ...)
}
// --- VFS Calls
+int acess_chdir(const char *Path)
+{
+ return _Syscall(SYS_CHDIR, ">s", Path);
+}
+
int acess_open(const char *Path, int Flags)
{
if( strncmp(Path, "$$$$", 4) == 0 )
const tSym caBuiltinSymbols[] = {
DEFSYM(_exit),
+ DEFSYM(chdir),
DEFSYM(open),
DEFSYM(close),
DEFSYM(reopen),
SYS_GETACL,
SYS_MOUNT,
SYS_REOPEN,
+ SYS_CHDIR,
SYS_WAITTID,
SYS_SETUID,
* AcessMicro VFS
* - File IO Passthru's
*/
+#define DEBUG 0
#include <acess.h>
#include "vfs.h"
#include "vfs_int.h"
-#define DEBUG 0
-
-#if DEBUG
-#else
-# undef ENTER
-# undef LOG
-# undef LEAVE
-# define ENTER(...)
-# define LOG(...)
-# define LEAVE(...)
-#endif
-
// === CODE ===
/**
* \fn Uint64 VFS_Read(int FD, Uint64 Length, void *Buffer)
ENTER("iFD XLength pBuffer", FD, Length, Buffer);
h = VFS_GetHandle(FD);
- if(!h) return -1;
+ if(!h) LEAVE_RET('i', -1);
- if( !(h->Mode & VFS_OPENFLAG_READ) || h->Node->Flags & VFS_FFLAG_DIRECTORY ) {
- LEAVE('i', -1);
- return -1;
- }
+ if( !(h->Mode & VFS_OPENFLAG_READ) || h->Node->Flags & VFS_FFLAG_DIRECTORY )
+ LEAVE_RET('i', -1);
- if(!h->Node->Read) {
- LEAVE('i', 0);
- return 0;
- }
+ if(!h->Node->Read) LEAVE_RET('i', 0);
ret = h->Node->Read(h->Node, h->Position, Length, Buffer);
- if(ret == -1) {
- LEAVE('i', -1);
- return -1;
- }
+ if(ret == -1) LEAVE_RET('i', -1);
h->Position += ret;
LEAVE('X', ret);
*/
int KB_Install(char **Arguments)
{
- Uint8 temp;
-
- // Attempt to get around a strange bug in Bochs/Qemu by toggling
- // the controller on and off
- temp = inb(0x61);
- outb(0x61, temp | 0x80);
- outb(0x61, temp & 0x7F);
- inb(0x60); // Clear keyboard buffer
IRQ_AddHandler(1, KB_IRQHandler);
+
+ {
+ Uint8 temp;
+ // Attempt to get around a strange bug in Bochs/Qemu by toggling
+ // the controller on and off
+ temp = inb(0x61);
+ outb(0x61, temp | 0x80);
+ outb(0x61, temp & 0x7F);
+ inb(0x60); // Clear keyboard buffer
+ }
+
DevFS_AddDevice( &gKB_DevInfo );
//Log("KB_Install: Installed");
return MODULE_ERR_OK;
// Read as much as possible (appending to remaining data)
len = read(STDIN_FD, READ_BUFFER_SIZE - 1 - Info->ReadBufferLen, Info->ReadBuffer);
+ if( len <= 0 ) return NULL;
Info->ReadBuffer[Info->ReadBufferLen + len] = '\0';
// Parse the data we have
extern int read(int fp, int len, void *buf);\r
extern int write(int fp, int len, void *buf);\r
extern int tell(int fp);\r
-extern void seek(int fp, int64_t dist, int flag);\r
+extern void seek(int fp, int64_t dist, int flag);\r
extern int fstat(int fp, t_fstat *st);\r
extern int ioctl(int fp, int call, void *arg);\r
extern int readdir(int fp, char *file);\r