From: John Hodge Date: Mon, 20 Dec 2010 01:55:59 +0000 (+0845) Subject: AcessNative - Cleaned up some of acesskernel's code X-Git-Tag: rel0.07~31 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=602ba046995f564d8ca4b85c873cbfcafed72d42;p=tpg%2Facess2.git AcessNative - Cleaned up some of acesskernel's code - Moved logging etc out to a helper function to keep main.c clean - Added a common syscalls header to aid maintaining the syscall interface. --- diff --git a/AcessNative/acesskernel_src/Makefile b/AcessNative/acesskernel_src/Makefile index 1ec22b38..4ff36c95 100644 --- a/AcessNative/acesskernel_src/Makefile +++ b/AcessNative/acesskernel_src/Makefile @@ -12,7 +12,7 @@ KERNEL_OBJ += vfs/main.o vfs/open.o vfs/acls.o vfs/io.o vfs/dir.o vfs/nodecache. KERNEL_OBJ += vfs/fs/root.o vfs/fs/devfs.o KERNEL_OBJ += drv/vterm.o drv/fifo.o drv/proc.o -OBJ := main.o threads.o video.o keyboard.o mouse.o nativefs.o vfs_handle.o +OBJ := main.o helpers.o threads.o video.o keyboard.o mouse.o nativefs.o vfs_handle.o OBJ += $(addprefix $(KERNEL_SRC),$(KERNEL_OBJ)) OBJ := $(addsuffix .$(PLATFORM),$(OBJ)) diff --git a/AcessNative/acesskernel_src/helpers.c b/AcessNative/acesskernel_src/helpers.c new file mode 100644 index 00000000..2209b05f --- /dev/null +++ b/AcessNative/acesskernel_src/helpers.c @@ -0,0 +1,83 @@ +/* + * Acess2 Native Kernel + * - Acess kernel emulation on another OS using SDL and UDP + * + * Kernel Main + */ +#include +#include +#include +#include + +void LogF(const char *Fmt, ...) +{ + va_list args; + va_start(args, Fmt); + vprintf(Fmt, args); + va_end(args); +} + +void Log(const char *Fmt, ...) +{ + va_list args; + printf("Log: "); + va_start(args, Fmt); + vprintf(Fmt, args); + va_end(args); + printf("\n"); +} + +void Warning(const char *Fmt, ...) +{ + va_list args; + printf("Warning: "); + va_start(args, Fmt); + vprintf(Fmt, args); + va_end(args); + printf("\n"); +} + +void Panic(const char *Format, ...) +{ + va_list args; + printf("Panic: "); + va_start(args, Format); + vprintf(Format, args); + va_end(args); + printf("\n"); + exit(-1); +} + +void Debug_SetKTerminal(const char *Path) +{ + // Ignored, kernel debug goes to stdout +} + +void *Heap_Allocate(int Count, const char *File, int Line) +{ + return malloc(Count); +} + +tPAddr MM_GetPhysAddr(tVAddr VAddr) +{ + return VAddr; // HACK! +} + +Uint MM_GetFlags(tVAddr VAddr) +{ + return 0; +} + +int Modules_InitialiseBuiltin(const char *Name) +{ + return 0; // Ignored +} + +Sint64 now(void) +{ + struct timeval tv; + struct timezone tz; + gettimeofday(&tv, &tz); + return tv.tv_sec * 1000 + tv.tv_usec/1000; +} + diff --git a/AcessNative/acesskernel_src/main.c b/AcessNative/acesskernel_src/main.c index 1dcf61a7..09e09dc4 100644 --- a/AcessNative/acesskernel_src/main.c +++ b/AcessNative/acesskernel_src/main.c @@ -4,85 +4,12 @@ * * Kernel Main */ -#include #include #include -#include +#include int main(int argc, char *argv[]) { return 0; } -void LogF(const char *Fmt, ...) -{ - va_list args; - va_start(args, Fmt); - vprintf(Fmt, args); - va_end(args); -} - -void Log(const char *Fmt, ...) -{ - va_list args; - printf("Log: "); - va_start(args, Fmt); - vprintf(Fmt, args); - va_end(args); - printf("\n"); -} - -void Warning(const char *Fmt, ...) -{ - va_list args; - printf("Warning: "); - va_start(args, Fmt); - vprintf(Fmt, args); - va_end(args); - printf("\n"); -} - -void Panic(const char *Format, ...) -{ - va_list args; - printf("Panic: "); - va_start(args, Format); - vprintf(Format, args); - va_end(args); - printf("\n"); - exit(-1); -} - -void Debug_SetKTerminal(const char *Path) -{ - // Ignored, kernel debug goes to stdout -} - -void *Heap_Allocate(int Count, const char *File, int Line) -{ - return malloc(Count); -} - -tPAddr MM_GetPhysAddr(tVAddr VAddr) -{ - return VAddr; // HACK! -} - -Uint MM_GetFlags(tVAddr VAddr) -{ - return 0; -} - -int Modules_InitialiseBuiltin(const char *Name) -{ - return 0; // Ignored -} - -Sint64 now(void) -{ - struct timeval tv; - struct timezone tz; - gettimeofday(&tv, &tz); - return tv.tv_sec * 1000 + tv.tv_usec/1000; -} - diff --git a/AcessNative/syscalls.h b/AcessNative/syscalls.h new file mode 100644 index 00000000..2784fd02 --- /dev/null +++ b/AcessNative/syscalls.h @@ -0,0 +1,23 @@ +/** + */ +#ifndef _NATIVE_SYSCALLS_H_ +#define _NATIVE_SYSCALLS_H_ + +enum eSyscalls { + SYS_NULL, + SYS_OPEN +}; + +enum eArgumentTypes { + ARG_TYPE_VOID, + ARG_TYPE_INT32, + ARG_TYPE_INT64, + ARG_TYPE_STRING, + ARG_TYPE_DATA +}; + +#define ARG_DIR_TOSRV 0x10 +#define ARG_DIR_TOCLI 0x20 +#define ARG_DIR_BOTH 0x30 + +#endif