diff --git a/AcessNative/ld-acess_src/syscalls.c b/AcessNative/ld-acess_src/syscalls.c index ff299973e320a871d0c2e8bd1fe0218e51257d78..02a59b90587be63906b9d2e4a8cfbd7cc2331cc0 100644 --- a/AcessNative/ld-acess_src/syscalls.c +++ b/AcessNative/ld-acess_src/syscalls.c @@ -265,6 +265,10 @@ void close(int FD) { _Syscall(SYS_CLOSE, ">i", FD); } +int reopen(int FD, const char *Path, int Flags) { + return _Syscall(SYS_REOPEN, ">i >s >i", FD, Path, Flags); +} + size_t read(int FD, size_t Bytes, void *Dest) { return _Syscall(SYS_READ, "<i >i >i <d", FD, Bytes, Bytes, Dest); } @@ -314,6 +318,14 @@ int _SysSetFaultHandler(int (*Handler)(int)) { return 0; } +// --- Memory Management --- +uint64_t _SysAllocate(uint vaddr) +{ + if( AllocateMemory(vaddr, 0x1000) == -1 ) // Allocate a page + return 0; + return vaddr; // Just ignore the need for paddrs :) +} + // === Symbol List === #define DEFSYM(name) {#name, name} @@ -322,6 +334,7 @@ const tSym caBuiltinSymbols[] = { DEFSYM(open), DEFSYM(close), + DEFSYM(reopen), DEFSYM(read), DEFSYM(write), DEFSYM(seek), @@ -333,6 +346,8 @@ const tSym caBuiltinSymbols[] = { DEFSYM(_SysGetACL), DEFSYM(_SysMount), + DEFSYM(_SysAllocate), + {"_SysSetFaultHandler", _SysSetFaultHandler} }; diff --git a/AcessNative/syscalls.h b/AcessNative/syscalls.h index 4a64474b42cea9f9961db9fe2d4140a37f321488..b4d211c7a052b98614efd09c54acd8f8cd76a55a 100644 --- a/AcessNative/syscalls.h +++ b/AcessNative/syscalls.h @@ -43,6 +43,7 @@ enum eSyscalls { SYS_OPENCHILD, SYS_GETACL, SYS_MOUNT, + SYS_REOPEN, N_SYSCALLS }; diff --git a/Kernel/arch/x86/lib.c b/Kernel/arch/x86/lib.c index 2160805c4e81ee298712a01b7a699ecb2bbbbdfb..796baa43f98370ba88e5c7c7a80ad962bbb6e771 100644 --- a/Kernel/arch/x86/lib.c +++ b/Kernel/arch/x86/lib.c @@ -5,7 +5,11 @@ #include <acess.h> #include <threads.h> -#define TRACE_LOCKS 1 +#define TRACE_LOCKS 0 + +#if TRACE_LOCKS +struct sShortSpinlock glDebug_Lock; +#endif extern int GetCPUNum(void); @@ -107,7 +111,11 @@ void SHORTLOCK(struct sShortSpinlock *Lock) #endif #if TRACE_LOCKS - Log_Log("LOCK", "%p locked by %p\n", Lock, __builtin_return_address(0)); + if( Lock != &glDebug_Lock ) + { + //Log_Log("LOCK", "%p locked by %p", Lock, __builtin_return_address(0)); + LogF("Lock %p locked by %p\n", Lock, __builtin_return_address(0)); + } #endif } /** @@ -115,11 +123,7 @@ void SHORTLOCK(struct sShortSpinlock *Lock) * \param Lock Lock pointer */ void SHORTREL(struct sShortSpinlock *Lock) -{ - #if TRACE_LOCKS - Log_Log("LOCK", "%p released by %p\n", Lock, __builtin_return_address(0)); - #endif - +{ #if STACKED_LOCKS if( Lock->Depth ) { Lock->Depth --; @@ -127,6 +131,14 @@ void SHORTREL(struct sShortSpinlock *Lock) } #endif + #if TRACE_LOCKS + if( Lock != &glDebug_Lock ) + { + //Log_Log("LOCK", "%p released by %p", Lock, __builtin_return_address(0)); + LogF("Lock %p released by %p\n", Lock, __builtin_return_address(0)); + } + #endif + #if LOCK_DISABLE_INTS // Lock->IF can change anytime once Lock->Lock is zeroed if(Lock->IF) { diff --git a/Kernel/arch/x86/start.asm b/Kernel/arch/x86/start.asm index d161e69953a5b405e3398d5ca94f4fe5f5b2724a..0a4f920e7e2807de73f2166c907d6b0e206d38eb 100644 --- a/Kernel/arch/x86/start.asm +++ b/Kernel/arch/x86/start.asm @@ -221,10 +221,12 @@ CallWithArgArray: [global gaInitPageTable] align 0x1000 gaInitPageDir: - dd gaInitPageTable-KERNEL_BASE+3 ; 0x00 - times 1024-256-1 dd 0 - dd gaInitPageTable-KERNEL_BASE+3 ; 0xC0 - times 256-1 dd 0 + dd gaInitPageTable-KERNEL_BASE+3 ; 0x000 - Low kernel + times 0x300-1 dd 0 + dd gaInitPageTable-KERNEL_BASE+3 ; 0xC00 - High kernel + times 0x3F0-0x300-1 dd 0 + dd gaInitPageDir-KERNEL_BASE+3 ; 0xFC0 - Fractal + times 0x400-0x3F0-1 dd 0 align 0x1000 gaInitPageTable: %assign i 0 diff --git a/Kernel/drv/iocache.c b/Kernel/drv/iocache.c index 743dabc49e78c73e0d1633cc27f5930733da0e65..271fc8402680234a7e68054d5e7873eb6ce417c0 100644 --- a/Kernel/drv/iocache.c +++ b/Kernel/drv/iocache.c @@ -46,7 +46,7 @@ tIOCache *gIOCache_Caches = NULL; */ tIOCache *IOCache_Create( tIOCache_WriteCallback Write, Uint32 ID, int SectorSize, int CacheSize ) { - tIOCache *ret = malloc( sizeof(tIOCache) ); + tIOCache *ret = calloc( 1, sizeof(tIOCache) ); // Sanity Check if(!ret) return NULL; @@ -57,8 +57,6 @@ tIOCache *IOCache_Create( tIOCache_WriteCallback Write, Uint32 ID, int SectorSiz ret->ID = ID; ret->Write = Write; ret->CacheSize = CacheSize; - ret->CacheUsed = 0; - ret->Entries = 0; // Append to list SHORTLOCK( &glIOCache_Caches ); diff --git a/Kernel/logging.c b/Kernel/logging.c index 165034289fbcbb16d7eff289fafc5f02627a4032..cb3c61cb8d16cbac410e053d61b51efe9c4f1a9a 100644 --- a/Kernel/logging.c +++ b/Kernel/logging.c @@ -111,6 +111,8 @@ void Log_AddEvent(char *Ident, int Level, char *Format, va_list Args) { #define LOG_HDR_LEN (14+1+2+8+2) char newData[ LOG_HDR_LEN + len + 2 + 1 ]; + char _ident[9]; + strncpy(_ident, Ident, 9); sprintf( newData, "%014lli%s [%+8s] ", ent->Time, csaLevelCodes[Level], Ident); strcpy( newData + LOG_HDR_LEN, ent->Data ); diff --git a/Kernel/threads.c b/Kernel/threads.c index c9a123d14274c6c4589a04041e1addc7a8ea0bef..73c3f3c08b649d10d62c504a17ce2de0f8ea7dcc 100644 --- a/Kernel/threads.c +++ b/Kernel/threads.c @@ -1174,6 +1174,12 @@ void Mutex_Acquire(tMutex *Mutex) Mutex->Owner = us; SHORTREL( &Mutex->Protector ); } + + #if 0 + extern tMutex glPhysAlloc; + if( Mutex != &glPhysAlloc ) + LogF("Mutex %p taken by %i %p\n", Mutex, us->TID, __builtin_return_address(0)); + #endif } /** @@ -1204,6 +1210,12 @@ void Mutex_Release(tMutex *Mutex) Mutex->Owner = NULL; } SHORTREL( &Mutex->Protector ); + + #if 0 + extern tMutex glPhysAlloc; + if( Mutex != &glPhysAlloc ) + LogF("Mutex %p released by %i %p\n", Mutex, Threads_GetTID(), __builtin_return_address(0)); + #endif } /**