- Large ammounts of debug enabled to trace #PF in FAT driver
- Added TID to Debug logging
- Enabled locking on debug prints
* Acess2
* Common Binary Loader
*/
* Acess2
* Common Binary Loader
*/
#include <acess.h>
#include <binary.h>
#include <mm_virt.h>
#include <acess.h>
#include <binary.h>
#include <mm_virt.h>
#define GDB_SERIAL_PORT 0x2F8
#define DEBUG_MAX_LINE_LEN 256
#define GDB_SERIAL_PORT 0x2F8
#define DEBUG_MAX_LINE_LEN 256
-#define LOCK_DEBUG_OUTPUT 0
+#define LOCK_DEBUG_OUTPUT 1
// === IMPORTS ===
extern void Threads_Dump(void);
// === IMPORTS ===
extern void Threads_Dump(void);
int gbDebug_IsKPanic = 0;
volatile int gbInPutChar = 0;
#if LOCK_DEBUG_OUTPUT
int gbDebug_IsKPanic = 0;
volatile int gbInPutChar = 0;
#if LOCK_DEBUG_OUTPUT
+tShortSpinlock glDebug_Lock;
+void Debug_FmtS(const char *format, ...)
+{
+ va_list args;
+ va_start(args, format);
+ Debug_Fmt(format, args);
+ va_end(args);
+}
+
void Debug_KernelPanic()
{
gbDebug_IsKPanic = 1;
void Debug_KernelPanic()
{
gbDebug_IsKPanic = 1;
va_list args;
#if LOCK_DEBUG_OUTPUT
va_list args;
#if LOCK_DEBUG_OUTPUT
- VTIGHTLOCK(&glDebug_Lock);
+ SHORTLOCK(&glDebug_Lock);
#endif
va_start(args, Fmt);
#endif
va_start(args, Fmt);
va_end(args);
#if LOCK_DEBUG_OUTPUT
va_end(args);
#if LOCK_DEBUG_OUTPUT
- RELEASE(&glDebug_Lock);
+ SHORTREL(&glDebug_Lock);
va_list args;
#if LOCK_DEBUG_OUTPUT
va_list args;
#if LOCK_DEBUG_OUTPUT
+ SHORTLOCK(&glDebug_Lock);
#endif
Debug_Puts(0, "Debug: ");
#endif
Debug_Puts(0, "Debug: ");
Debug_PutCharDebug('\r');
Debug_PutCharDebug('\n');
#if LOCK_DEBUG_OUTPUT
Debug_PutCharDebug('\r');
Debug_PutCharDebug('\n');
#if LOCK_DEBUG_OUTPUT
- RELEASE(&glDebug_Lock);
+ SHORTREL(&glDebug_Lock);
va_list args;
#if LOCK_DEBUG_OUTPUT
va_list args;
#if LOCK_DEBUG_OUTPUT
+ SHORTLOCK(&glDebug_Lock);
#endif
Debug_Puts(1, "Log: ");
#endif
Debug_Puts(1, "Log: ");
Debug_Putchar('\n');
#if LOCK_DEBUG_OUTPUT
Debug_Putchar('\n');
#if LOCK_DEBUG_OUTPUT
- RELEASE(&glDebug_Lock);
+ SHORTREL(&glDebug_Lock);
#endif
}
void Warning(char *Fmt, ...)
#endif
}
void Warning(char *Fmt, ...)
va_list args;
#if LOCK_DEBUG_OUTPUT
va_list args;
#if LOCK_DEBUG_OUTPUT
+ SHORTLOCK(&glDebug_Lock);
#endif
Debug_Puts(1, "Warning: ");
#endif
Debug_Puts(1, "Warning: ");
Debug_Putchar('\n');
#if LOCK_DEBUG_OUTPUT
Debug_Putchar('\n');
#if LOCK_DEBUG_OUTPUT
- RELEASE(&glDebug_Lock);
+ SHORTREL(&glDebug_Lock);
#endif
}
void Panic(char *Fmt, ...)
#endif
}
void Panic(char *Fmt, ...)
va_list args;
#if LOCK_DEBUG_OUTPUT
va_list args;
#if LOCK_DEBUG_OUTPUT
+ SHORTLOCK(&glDebug_Lock);
void Debug_Enter(char *FuncName, char *ArgTypes, ...)
{
va_list args;
void Debug_Enter(char *FuncName, char *ArgTypes, ...)
{
va_list args;
- int i = gDebug_Level ++;
+ tTID tid = Threads_GetTID();
+
+ #if LOCK_DEBUG_OUTPUT
+ SHORTLOCK(&glDebug_Lock);
+ #endif
+
+ i = gDebug_Level ++;
va_start(args, ArgTypes);
while(i--) Debug_Putchar(' ');
va_start(args, ArgTypes);
while(i--) Debug_Putchar(' ');
- Debug_Puts(1, FuncName); Debug_Puts(1, ": (");
+ Debug_Puts(1, FuncName);
+ Debug_FmtS("[%i]", tid);
+ Debug_Puts(1, ": (");
va_end(args);
Debug_Putchar(')'); Debug_Putchar('\r'); Debug_Putchar('\n');
va_end(args);
Debug_Putchar(')'); Debug_Putchar('\r'); Debug_Putchar('\n');
+
+ #if LOCK_DEBUG_OUTPUT
+ SHORTREL(&glDebug_Lock);
+ #endif
}
void Debug_Log(char *FuncName, char *Fmt, ...)
{
va_list args;
int i = gDebug_Level;
}
void Debug_Log(char *FuncName, char *Fmt, ...)
{
va_list args;
int i = gDebug_Level;
+ tTID tid = Threads_GetTID();
+
+ #if LOCK_DEBUG_OUTPUT
+ SHORTLOCK(&glDebug_Lock);
+ #endif
va_start(args, Fmt);
while(i--) Debug_Putchar(' ');
va_start(args, Fmt);
while(i--) Debug_Putchar(' ');
- Debug_Puts(1, FuncName); Debug_Puts(1, ": ");
+ Debug_Puts(1, FuncName);
+ Debug_FmtS("[%i]", tid);
+ Debug_Puts(1, ": ");
Debug_Fmt(Fmt, args);
va_end(args);
Debug_Putchar('\r');
Debug_Putchar('\n');
Debug_Fmt(Fmt, args);
va_end(args);
Debug_Putchar('\r');
Debug_Putchar('\n');
+
+ #if LOCK_DEBUG_OUTPUT
+ SHORTREL(&glDebug_Lock);
+ #endif
}
void Debug_Leave(char *FuncName, char RetType, ...)
{
va_list args;
}
void Debug_Leave(char *FuncName, char RetType, ...)
{
va_list args;
- int i = --gDebug_Level;
+ int i;
+ tTID tid = Threads_GetTID();
+ SHORTLOCK(&glDebug_Lock);
// Indenting
while(i--) Debug_Putchar(' ');
// Indenting
while(i--) Debug_Putchar(' ');
- Debug_Puts(1, FuncName); Debug_Puts(1, ": RETURN");
+ Debug_Puts(1, FuncName);
+ Debug_FmtS("(%i)", tid);
+ Debug_Puts(1, ": RETURN");
// No Return
if(RetType == '-') {
Debug_Putchar('\r');
Debug_Putchar('\n');
// No Return
if(RetType == '-') {
Debug_Putchar('\r');
Debug_Putchar('\n');
+ #if LOCK_DEBUG_OUTPUT
+ SHORTREL(&glDebug_Lock);
+ #endif
Debug_Putchar('\n');
va_end(args);
Debug_Putchar('\n');
va_end(args);
+
+ #if LOCK_DEBUG_OUTPUT
+ SHORTREL(&glDebug_Lock);
+ #endif
}
void Debug_HexDump(char *Header, void *Data, Uint Length)
}
void Debug_HexDump(char *Header, void *Data, Uint Length)
#define RANDOM_SEED 0xACE55052
#define RANDOM_A 0x00731ADE
#define RANDOM_C 12345
#define RANDOM_SEED 0xACE55052
#define RANDOM_A 0x00731ADE
#define RANDOM_C 12345
-#define RANDOM_SPRUCE 0xf12b02b
+#define RANDOM_SPRUCE 0xf12b039
// Jan Feb Mar Apr May Jun Jul Aug Sept Oct Nov Dec
const short DAYS_BEFORE[] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
#define UNIX_TO_2K ((30*365*3600*24) + (7*3600*24)) //Normal years + leap years
// Jan Feb Mar Apr May Jun Jul Aug Sept Oct Nov Dec
const short DAYS_BEFORE[] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
#define UNIX_TO_2K ((30*365*3600*24) + (7*3600*24)) //Normal years + leap years
EXPORT(ModUtil_LookupString);
EXPORT(ModUtil_SetIdent);
EXPORT(ModUtil_LookupString);
EXPORT(ModUtil_SetIdent);
-// === GLOBALS ===
-static Uint giRandomState = RANDOM_SEED;
-
// === CODE ===
/**
* \brief Convert a string into an integer
// === CODE ===
/**
* \brief Convert a string into an integer
- Uint old = giRandomState;
+ #if 0
+ static Uint state = RANDOM_SEED;
+ Uint old = state;
// Get the next state value
// Get the next state value
- giRandomState = (RANDOM_A*giRandomState + RANDOM_C) & 0xFFFFFFFF;
+ giRandomState = (RANDOM_A*state + RANDOM_C);
// Check if it has changed, and if it hasn't, change it
// Check if it has changed, and if it hasn't, change it
- if(giRandomState == old) giRandomState += RANDOM_SPRUCE;
- return giRandomState;
+ if(state == old) state += RANDOM_SPRUCE;
+ return state;
+ #else
+ // http://en.wikipedia.org/wiki/Xorshift
+ // 2010-10-03
+ static Uint32 x = 123456789;
+ static Uint32 y = 362436069;
+ static Uint32 z = 521288629;
+ static Uint32 w = 88675123;
+ Uint32 t;
+
+ t = x ^ (x << 11);
+ x = y; y = z; z = w;
+ return w = w ^ (w >> 19) ^ t ^ (t >> 8);
+ #endif
}
LEAVE('s', "Assuming 0");
// Path, **Argv, **Envp
}
LEAVE('s', "Assuming 0");
// Path, **Argv, **Envp
- ret = Proc_Execve((char*)Regs->Arg1, (char**)Regs->Arg2, (char**)Regs->Arg3);
+ ret = Proc_Execve( (char*)Regs->Arg1, (char**)Regs->Arg2, (char**)Regs->Arg3 );
break;
// -- Load a binary into the current process
case SYS_LOADBIN:
break;
// -- Load a binary into the current process
case SYS_LOADBIN:
tmp = VFS_GetAbsPath(Path);
if(tmp == NULL) return NULL;
tmp = VFS_GetAbsPath(Path);
if(tmp == NULL) return NULL;
+ Log(" VFS_GetTruePath: tmp = '%s'", tmp);
node = VFS_ParsePath(tmp, &ret);
free(tmp);
node = VFS_ParsePath(tmp, &ret);
free(tmp);
+ Log(" VFS_GetTruePath: node=%p, ret='%s'", node, ret);
if(!node) return NULL;
if(node->Close) node->Close(node);
if(!node) return NULL;
if(node->Close) node->Close(node);
* AcessMicro VFS
* - Open, Close and ChDir
*/
* AcessMicro VFS
* - Open, Close and ChDir
*/
#include <acess.h>
#include <mm_virt.h>
#include "vfs.h"
#include <acess.h>
#include <mm_virt.h>
#include "vfs.h"
(*TruePath)[retLength] = '/';
strcpy(*TruePath+retLength+1, pathEle);
(*TruePath)[retLength] = '/';
strcpy(*TruePath+retLength+1, pathEle);
- LOG("*TruePath = '%s'\n", *TruePath);
+ LOG("*TruePath = '%s'", *TruePath);
// - Extend Path
retLength += nextSlash + 1;
// - Extend Path
retLength += nextSlash + 1;
* \todo Implement changing of the parent directory when a file is written to\r
* \todo Implement file creation / deletion\r
*/\r
* \todo Implement changing of the parent directory when a file is written to\r
* \todo Implement file creation / deletion\r
*/\r
#define VERBOSE 1\r
\r
#define CACHE_FAT 0 //!< Caches the FAT in memory\r
#define VERBOSE 1\r
\r
#define CACHE_FAT 0 //!< Caches the FAT in memory\r
+ printf("pid = %i\n", pid);
+
// Spawn shell in a child process
if(pid == 0)
{
// Spawn shell in a child process
if(pid == 0)
{