_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);
}
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}
DEFSYM(open),
DEFSYM(close),
+ DEFSYM(reopen),
DEFSYM(read),
DEFSYM(write),
DEFSYM(seek),
DEFSYM(_SysGetACL),
DEFSYM(_SysMount),
+ DEFSYM(_SysAllocate),
+
{"_SysSetFaultHandler", _SysSetFaultHandler}
};
SYS_OPENCHILD,
SYS_GETACL,
SYS_MOUNT,
+ SYS_REOPEN,
N_SYSCALLS
};
#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);
#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
}
/**
* \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 --;
}
#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) {
[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
*/
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;
ret->ID = ID;
ret->Write = Write;
ret->CacheSize = CacheSize;
- ret->CacheUsed = 0;
- ret->Entries = 0;
// Append to list
SHORTLOCK( &glIOCache_Caches );
{
#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 );
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
}
/**
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
}
/**