endif
OBJ = $(addprefix arch/$(ARCHDIR)/,$(A_OBJ))
-OBJ += heap.o messages.o debug.o modules.o lib.o syscalls.o system.o threads.o drvutil.o
+OBJ += heap.o messages.o debug.o modules.o lib.o syscalls.o system.o threads.o drvutil.o logging.o
OBJ += $(addprefix vfs/fs/, $(addsuffix .o,$(FILESYSTEMS)))
OBJ += drv/vterm.o drv/proc.o drv/fifo.o drv/iocache.o drv/dma.o drv/pci.o drv/kb.o drv/vga.o
OBJ += binary.o bin/elf.o bin/pe.o
-BUILD_NUM = 1556
+BUILD_NUM = 1563
#define VGA_ERRORS 0
// === IMPORTS ===
-extern void Heap_Install();
-extern void Desctab_Install();
-extern void MM_PreinitVirtual();
+extern void Heap_Install(void);
+extern void Desctab_Install(void);
+extern void MM_PreinitVirtual(void);
extern void MM_Install(tMBoot_Info *MBoot);
-extern void MM_InstallVirtual();
-extern void Threads_Init();
-extern int Time_Setup();
+extern void MM_InstallVirtual(void);
+extern void Threads_Init(void);
+extern int Time_Setup(void);
extern Uint Proc_Clone(Uint *Err, Uint Flags);
-extern void Threads_Sleep();
-extern void Threads_Exit();
+extern void Threads_Sleep(void);
+extern void Threads_Exit(void);
+
+extern int Modules_LoadBuiltins(void);
// === GLOBALS ===
// Load Virtual Filesystem
VFS_Init();
+ // Initialise builtin modules
+ Log("Initialising builtin modules...");
+ Modules_LoadBuiltins();
+
Log("Loading Modules... (%i of them)", MbInfo->ModuleCount);
// Load initial modules
return inb(GDB_SERIAL_PORT);
}
-static void E9(char ch)
+static void Debug_Putchar(char ch)
{
if(giDebug_KTerm != -1)
VFS_Write(giDebug_KTerm, 1, &ch);
#endif
}
-static void E9_Str(char *Str)
+static void Debug_Puts(char *Str)
{
- while(*Str) E9(*Str++);
+ while(*Str) Debug_Putchar(*Str++);
}
-void E9_Fmt(const char *format, va_list *args)
+void Debug_Fmt(const char *format, va_list *args)
{
char c, pad = ' ';
int minSize = 0;
{
// Non control character
if( c != '%' ) {
- E9(c);
+ Debug_Putchar(c);
continue;
}
// Literal %
if(c == '%') {
- E9('%');
+ Debug_Putchar('%');
continue;
}
// Pointer
if(c == 'p') {
Uint ptr = va_arg(*args, Uint);
- E9('*'); E9('0'); E9('x');
+ Debug_Putchar('*'); Debug_Putchar('0'); Debug_Putchar('x');
p = tmpBuf;
itoa(p, ptr, 16, BITS/4, '0');
goto printString;
case 'd':
case 'i':
if( (isLongLong && arg >> 63) || (!isLongLong && arg >> 31) ) {
- E9('-');
+ Debug_Putchar('-');
arg = -arg;
}
itoa(p, arg, 10, minSize, pad);
goto printString;
case 'B': //Boolean
- if(arg) E9_Str("True");
- else E9_Str("False");
+ if(arg) Debug_Puts("True");
+ else Debug_Puts("False");
break;
case 's':
p = (char*)(Uint)arg;
printString:
if(!p) p = "(null)";
- while(*p) E9(*p++);
+ while(*p) Debug_Putchar(*p++);
break;
// Single Character / Array
case 'c':
if(minSize == 1) {
- E9(arg);
+ Debug_Putchar(arg);
break;
}
p = (char*)(Uint)arg;
if(!p) goto printString;
- while(minSize--) E9(*p++);
+ while(minSize--) Debug_Putchar(*p++);
break;
- default: E9(arg); break;
+ default:
+ Debug_Putchar(arg);
+ break;
}
}
}
-/**
- * \fn void LogV(char *Fmt, va_list Args)
- */
-void LogV(char *Fmt, va_list Args)
-{
- E9_Str("Log: ");
- E9_Fmt(Fmt, &Args);
- E9('\n');
-}
/**
* \fn void LogF(char *Msg, ...)
*/
va_start(args, Fmt);
- E9_Fmt(Fmt, &args);
+ Debug_Fmt(Fmt, &args);
va_end(args);
}
{
va_list args;
- E9_Str("Log: ");
+ Debug_Puts("Log: ");
va_start(args, Fmt);
- E9_Fmt(Fmt, &args);
+ Debug_Fmt(Fmt, &args);
va_end(args);
- E9('\n');
+ Debug_Putchar('\n');
}
void Warning(char *Fmt, ...)
{
va_list args;
- E9_Str("Warning: ");
+ Debug_Puts("Warning: ");
va_start(args, Fmt);
- E9_Fmt(Fmt, &args);
+ Debug_Fmt(Fmt, &args);
va_end(args);
- E9('\n');
+ Debug_Putchar('\n');
}
void Panic(char *Fmt, ...)
{
va_list args;
- E9_Str("Panic: ");
+ Debug_Puts("Panic: ");
va_start(args, Fmt);
- E9_Fmt(Fmt, &args);
+ Debug_Fmt(Fmt, &args);
va_end(args);
- E9('\n');
+ Debug_Putchar('\n');
Threads_Dump();
va_start(args, ArgTypes);
- while(i--) E9(' ');
+ while(i--) Debug_Putchar(' ');
- E9_Str(FuncName); E9_Str(": (");
+ Debug_Puts(FuncName); Debug_Puts(": (");
while(*ArgTypes)
{
pos = strpos(ArgTypes, ' ');
if(pos != -1) ArgTypes[pos] = '\0';
if(pos == -1 || pos > 1) {
- E9_Str(ArgTypes+1);
- E9('=');
+ Debug_Puts(ArgTypes+1);
+ Debug_Putchar('=');
}
if(pos != -1) ArgTypes[pos] = ' ';
switch(*ArgTypes)
{
- case 'p': E9_Fmt("%p", &args); break;
- case 's': E9_Fmt("'%s'", &args); break;
- case 'i': E9_Fmt("%i", &args); break;
- case 'u': E9_Fmt("%u", &args); break;
- case 'x': E9_Fmt("0x%x", &args); break;
- case 'b': E9_Fmt("0b%b", &args); break;
+ case 'p': Debug_Fmt("%p", &args); break;
+ case 's': Debug_Fmt("'%s'", &args); break;
+ case 'i': Debug_Fmt("%i", &args); break;
+ case 'u': Debug_Fmt("%u", &args); break;
+ case 'x': Debug_Fmt("0x%x", &args); break;
+ case 'b': Debug_Fmt("0b%b", &args); break;
// Extended (64-Bit)
- case 'X': E9_Fmt("0x%llx", &args); break;
- case 'B': E9_Fmt("0b%llb", &args); break;
+ case 'X': Debug_Fmt("0x%llx", &args); break;
+ case 'B': Debug_Fmt("0b%llb", &args); break;
}
if(pos != -1) {
- E9(','); E9(' ');
+ Debug_Putchar(','); Debug_Putchar(' ');
}
if(pos == -1) break;
}
va_end(args);
- E9(')'); E9('\n');
+ Debug_Putchar(')'); Debug_Putchar('\n');
}
void Debug_Log(char *FuncName, char *Fmt, ...)
va_start(args, Fmt);
- while(i--) E9(' ');
+ while(i--) Debug_Putchar(' ');
- E9_Str(FuncName); E9_Str(": ");
- E9_Fmt(Fmt, &args);
+ Debug_Puts(FuncName); Debug_Puts(": ");
+ Debug_Fmt(Fmt, &args);
va_end(args);
- E9('\n');
+ Debug_Putchar('\n');
}
void Debug_Leave(char *FuncName, char RetType, ...)
i = 0;
}
// Indenting
- while(i--) E9(' ');
+ while(i--) Debug_Putchar(' ');
- E9_Str(FuncName); E9_Str(": RETURN");
+ Debug_Puts(FuncName); Debug_Puts(": RETURN");
// No Return
if(RetType == '-') {
- E9('\n');
+ Debug_Putchar('\n');
return;
}
- E9(' ');
+ Debug_Putchar(' ');
switch(RetType)
{
- case 'n': E9_Str("NULL"); break;
- case 'p': E9_Fmt("%p", &args); break;
- case 's': E9_Fmt("'%s'", &args); break;
- case 'i': E9_Fmt("%i", &args); break;
- case 'u': E9_Fmt("%u", &args); break;
- case 'x': E9_Fmt("0x%x", &args); break;
+ case 'n': Debug_Puts("NULL"); break;
+ case 'p': Debug_Fmt("%p", &args); break;
+ case 's': Debug_Fmt("'%s'", &args); break;
+ case 'i': Debug_Fmt("%i", &args); break;
+ case 'u': Debug_Fmt("%u", &args); break;
+ case 'x': Debug_Fmt("0x%x", &args); break;
// Extended (64-Bit)
- case 'X': E9_Fmt("0x%llx", &args); break;
+ case 'X': Debug_Fmt("0x%llx", &args); break;
}
- E9('\n');
+ Debug_Putchar('\n');
va_end(args);
}
{
Uint8 *cdat = Data;
Uint pos = 0;
- E9_Str(Header);
+ Debug_Puts(Header);
LogF(" (Hexdump of %p)\n", Data);
while(Length >= 16)
Length--;
cdat ++;
}
- E9('\n');
+ Debug_Putchar('\n');
}
// --- EXPORTS ---
* \name Strings
* \{
*/
+extern int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args);
extern int sprintf(char *__s, const char *__format, ...);
extern Uint strlen(const char *Str);
extern char *strcpy(char *__dest, const char *__src);
* Marks a file as a symbolic link
*/
#define VFS_FFLAG_SYMLINK 0x04
+/**
+ * \brief Set User ID Flag
+ *
+ * Allows an executable file to change it's executing user to the file's
+ * owner.
+ * In the case of a directory, it means that all immediate children will
+ * inherit the UID of the parent.
+ */
+#define VFS_FFLAG_SETUID 0x08
+/**
+ * \brief Set Group ID Flag
+ *
+ * Allows an executable file to change it's executing group to the file's
+ * owning group.
+ * In the case of a directory, it means that all immediate children will
+ * inherit the GID of the parent.
+ */
+#define VFS_FFLAG_SETGID 0x10
/**
* \}
*/
* This structure provides the VFS with the functions required to read/write
* the file (or directory) that it represents.
*/
-typedef struct sVFS_Node {
+typedef struct sVFS_Node
+{
/**
* \name Identifiers
* \brief Fields used by the driver to identify what data this node
#define UNIX_TO_2K ((30*365*3600*24) + (7*3600*24)) //Normal years + leap years
// === PROTOTYPES ===
+ int atoi(const char *string);
+void itoa(char *buf, Uint num, int base, int minLength, char pad);
+ int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args);
+ int sprintf(char *__s, const char *__format, ...);
+ int tolower(int c);
+ int strucmp(const char *Str1, const char *Str2);
+ int strpos(const char *Str, char Ch);
+ Uint8 ByteSum(void *Ptr, int Size);
+size_t strlen(const char *__s);
+char *strcpy(char *__str1, const char *__str2);
+char *strncpy(char *__str1, const char *__str2, size_t max);
+ int strcmp(const char *str1, const char *str2);
+ int strncmp(const char *str1, const char *str2, size_t num);
+char *strdup(const char *Str);
+ int DivUp(int num, int dem);
+ int strpos8(const char *str, Uint32 Search);
int ReadUTF8(Uint8 *str, Uint32 *Val);
+ int WriteUTF8(Uint8 *str, Uint32 Val);
+Sint64 timestamp(int sec, int mins, int hrs, int day, int month, int year);
+Uint rand(void);
+ int CheckString(char *String);
+ int CheckMem(void *Mem, int NumBytes);
+ int ModUtil_LookupString(char **Array, char *Needle);
+ int ModUtil_SetIdent(char *Dest, char *Value);
+
+// === EXPORTS ===
+EXPORT(atoi);
+EXPORT(itoa);
+EXPORT(vsnprintf);
+EXPORT(sprintf);
+EXPORT(tolower);
+EXPORT(strucmp);
+EXPORT(strpos);
+EXPORT(ByteSum);
+EXPORT(strlen);
+EXPORT(strcpy);
+EXPORT(strncpy);
+EXPORT(strcmp);
+EXPORT(strncmp);
+EXPORT(strdup);
+EXPORT(DivUp);
+EXPORT(strpos8);
+EXPORT(ReadUTF8);
+EXPORT(WriteUTF8);
+EXPORT(timestamp);
+EXPORT(CheckString);
+EXPORT(CheckMem);
+EXPORT(ModUtil_LookupString);
+EXPORT(ModUtil_SetIdent);
// === GLOBALS ===
static Uint giRandomState = RANDOM_SEED;
PUTCH( (Uint8)val );
break;
}
+
+ if(pos == __maxlen)
+ break;
}
if(__s && pos != __maxlen)
* \brief Pseudo random number generator
* \note Unknown effectiveness (made up on the spot)
*/
-Uint rand()
+Uint rand(void)
{
Uint old = giRandomState;
// Get the next state value
strncpy(Dest, Value, 32);
return 1;
}
-
-EXPORT(strlen);
-EXPORT(strdup);
-EXPORT(strcmp);
-EXPORT(strncmp);
-EXPORT(strcpy);
-EXPORT(strncpy);
-
-EXPORT(timestamp);
-EXPORT(ReadUTF8);
-EXPORT(CheckMem);
-EXPORT(CheckString);
-EXPORT(ModUtil_LookupString);
-EXPORT(ModUtil_SetIdent);
--- /dev/null
+/*
+ * Acess 2 Kernel
+ * - By John Hodge (thePowersGang)
+ *
+ * logging.c - Kernel Logging Service
+ */
+#include <acess.h>
+
+#define PRINT_ON_APPEND 1
+
+// === CONSTANTS ===
+enum eLogLevels
+{
+ LOG_LEVEL_KPANIC,
+ LOG_LEVEL_PANIC,
+ LOG_LEVEL_FATAL,
+ LOG_LEVEL_ERROR,
+ LOG_LEVEL_WARNING,
+ LOG_LEVEL_NOTICE,
+ LOG_LEVEL_LOG,
+ LOG_LEVEL_DEBUG,
+ NUM_LOG_LEVELS
+};
+const char csaLevelCodes[] = {'k','p','f','e','w','n','l','d'};
+
+// === TYPES ===
+typedef struct sLogEntry
+{
+ struct sLogEntry *Next;
+ struct sLogEntry *LevelNext;
+ Sint64 Time;
+ Uint64 Ident;
+ int Level;
+ int Length;
+ char Data[];
+} tLogEntry;
+typedef struct sLogList
+{
+ tLogEntry *Head;
+ tLogEntry *Tail;
+} tLogList;
+
+// === PROTOTYPES ===
+void Log_AddEvent(char *Ident, int Level, char *Format, va_list Args);
+static void Log_Int_PrintMessage(tLogEntry *Entry);
+void Log_KernelPanic(char *Ident, char *Message, ...);
+void Log_Panic(char *Ident, char *Message, ...);
+void Log_Error(char *Ident, char *Message, ...);
+void Log_Warning(char *Ident, char *Message, ...);
+void Log_Log(char *Ident, char *Message, ...);
+void Log_Notice(char *Ident, char *Message, ...);
+void Log_Debug(char *Ident, char *Message, ...);
+static Uint64 Log_Int_GetIdent(const char *Str);
+
+// === GLOBALS ===
+tSpinlock glLog;
+tLogList gLog;
+tLogList gLog_Levels[NUM_LOG_LEVELS];
+
+// === CODE ===
+/**
+ * \brief Adds an event to the log
+ */
+void Log_AddEvent(char *Ident, int Level, char *Format, va_list Args)
+{
+ int len;
+ tLogEntry *ent;
+ Uint64 ident = Log_Int_GetIdent(Ident);
+
+ if( Level >= NUM_LOG_LEVELS ) return;
+
+ len = vsnprintf(NULL, 256, Format, Args);
+
+ ent = malloc(sizeof(tLogEntry)+len+1);
+ ent->Time = now();
+ ent->Ident = ident;
+ ent->Level = Level;
+ ent->Length = len;
+ vsnprintf( ent->Data, 256, Format, Args );
+
+ LOCK( &glLog );
+
+ ent->Next = gLog.Tail;
+ if(gLog.Head)
+ gLog.Tail = ent;
+ else
+ gLog.Tail = gLog.Head = ent;
+
+ ent->LevelNext = gLog_Levels[Level].Tail;
+ if(gLog_Levels[Level].Head)
+ gLog_Levels[Level].Tail = ent;
+ else
+ gLog_Levels[Level].Tail = gLog_Levels[Level].Head = ent;
+
+ RELEASE( &glLog );
+
+ #if PRINT_ON_APPEND
+ Log_Int_PrintMessage( ent );
+ #endif
+
+}
+
+/**
+ * \brief Prints a log message to the debug console
+ */
+void Log_Int_PrintMessage(tLogEntry *Entry)
+{
+ LogF("%018%c [%8s] %s\n",
+ Entry->Time,
+ csaLevelCodes[Entry->Level],
+ &Entry->Ident,
+ Entry->Data
+ );
+}
+
+/**
+ * \brief KERNEL PANIC!!!!
+ */
+void Log_KernelPanic(char *Ident, char *Message, ...)
+{
+ va_list args;
+ va_start(args, Message);
+ Log_AddEvent(Ident, LOG_LEVEL_KPANIC, Message, args);
+ va_end(args);
+}
+
+/**
+ * \brief Panic Message - Driver Unrecoverable error
+ */
+void Log_Panic(char *Ident, char *Message, ...)
+{
+ va_list args;
+ va_start(args, Message);
+ Log_AddEvent(Ident, LOG_LEVEL_PANIC, Message, args);
+ va_end(args);
+}
+
+/**
+ * \brief Error Message - Recoverable Error
+ */
+void Log_Error(char *Ident, char *Message, ...)
+{
+ va_list args;
+ va_start(args, Message);
+ Log_AddEvent(Ident, LOG_LEVEL_ERROR, Message, args);
+ va_end(args);
+}
+
+/**
+ * \brief Warning Message - Something the user should know
+ */
+void Log_Warning(char *Ident, char *Message, ...)
+{
+ va_list args;
+
+ va_start(args, Message);
+ Log_AddEvent(Ident, LOG_LEVEL_WARNING, Message, args);
+ va_end(args);
+}
+
+/**
+ * \brief Notice Message - Something the user might like to know
+ */
+void Log_Notice(char *Ident, char *Message, ...)
+{
+ va_list args;
+ va_start(args, Message);
+ Log_AddEvent(Ident, LOG_LEVEL_NOTICE, Message, args);
+ va_end(args);
+}
+
+/**
+ * \brief Log Message - Possibly useful information
+ */
+void Log_Log(char *Ident, char *Message, ...)
+{
+ va_list args;
+ va_start(args, Message);
+ Log_AddEvent(Ident, LOG_LEVEL_LOG, Message, args);
+ va_end(args);
+}
+
+/**
+ * \brief Debug Message - Only a developer would want this info
+ */
+void Log_Debug(char *Ident, char *Message, ...)
+{
+ va_list args;
+ va_start(args, Message);
+ Log_AddEvent(Ident, LOG_LEVEL_DEBUG, Message, args);
+ va_end(args);
+}
+
+/**
+ * \brief Converts a string into a 64-bit ident
+ */
+static Uint64 Log_Int_GetIdent(const char *Str)
+{
+ Uint64 ret = 0;
+ int i;
+ char ch;
+
+ for( i = 0; Str[i] && i < 7; i++ )
+ {
+ ch = Str[i];
+
+ if(ch < ' ')
+ ch = '?';
+ else if(ch > '~')
+ ch = '?';
+
+ ret |= (Uint64)ch << 8*i;
+ }
+
+ for( ; i < 7; i++ )
+ ret |= 0x20 << (8*i);
+
+ return ret;
+}
#include <modules.h>
#define USE_EDI 0
-#define USE_UDI 1
+#define USE_UDI 0
// === PROTOTYPES ===
- int Modules_LoadBuiltins();
+ int Modules_LoadBuiltins(void);
+ int Module_RegisterLoader(tModuleLoader *Loader);
int Module_LoadMem(void *Buffer, Uint Length, char *ArgString);
int Module_LoadFile(char *Path, char *ArgString);
int Module_int_ResolveDeps(tModule *Info);
int Module_IsLoaded(char *Name);
+// === EXPORTS ===
+EXPORT(Module_RegisterLoader);
+
// === IMPORTS ===
#if USE_UDI
extern int UDI_LoadDriver(void *Base);
// === CODE ===
void System_Init(char *ArgString)
-{
- // - Start Builtin Drivers & Filesystems
- //StartupPrint("Scanning PCI Bus...");
- //PCI_Install();
- StartupPrint("Loading DMA...");
- DMA_Install();
- StartupPrint("Loading staticly compiled modules...");
- Modules_LoadBuiltins();
-
+{
// Set the debug to be echoed to the terminal
- StartupPrint("Kernel now echoes to VT6 (Ctrl-Alt-F7)");
- Debug_SetKTerminal("/Devices/VTerm/6");
+ StartupPrint("Kernel now echoes to VT7 (Ctrl-Alt-F8)");
+ Debug_SetKTerminal("/Devices/VTerm/7");
// - Parse Kernel's Command Line
System_ParseCommandLine(ArgString);
str = ArgString;
for( argc = 0; argc < 32; argc++ )
{
- while(*str == ' ') str++; // Eat Whitespace
- if(*str == '\0') { argc--; break;} // End of string
+ // Eat Whitespace
+ while(*str == ' ') str++;
+ // Check for the end of the string
+ if(*str == '\0') { argc--; break;}
argv[argc] = str;
while(*str && *str != ' ')
{
}*/
str++;
}
- if(*str == '\0') break; // End of string
+ if(*str == '\0') break; // Check for EOS
*str = '\0'; // Cap off argument string
str ++; // and increment the string pointer
}
// Check for boolean/flag (no '=')
if(*value == '\0')
{
- if(strcmp(Arg, "") == 0) {
- } else {
+ //if(strcmp(Arg, "") == 0) {
+ //} else {
Warning("Kernel flag '%s' is not recognised", Arg);
- }
+ //}
}
else
{
// Parse File
file = System_Int_ParseFile(fData);
- // Loop lines
+ // Parse each line
for( i = 0; i < file->nLines; i++ )
{
line = &file->Lines[i];
if( line->nParts == 0 ) continue; // Skip blank
- // Mount
- if( strcmp(line->Parts[0], "mount") == 0 ) {
+ // Mount Device
+ if( strcmp(line->Parts[0], "mount") == 0 )
+ {
if( line->nParts != 4 ) {
Warning("Configuration command 'mount' requires 3 arguments, %i given",
line->nParts-1);
//! \todo Use an optional 4th argument for the options string
VFS_Mount(line->Parts[1], line->Parts[2], line->Parts[3], "");
}
- // Module
- else if(strcmp(line->Parts[0], "module") == 0) {
+ // Load a Module
+ else if(strcmp(line->Parts[0], "module") == 0)
+ {
if( line->nParts < 2 || line->nParts > 3 ) {
Warning("Configuration command 'module' requires 1 or 2 arguments, %i given",
line->nParts-1);
else
Module_LoadFile(line->Parts[1], "");
}
- // UDI Module
- else if(strcmp(line->Parts[0], "udimod") == 0) {
+ // Load a UDI Module
+ else if(strcmp(line->Parts[0], "udimod") == 0)
+ {
if( line->nParts != 2 ) {
Warning("Configuration command 'udimod' requires 1 argument, %i given",
line->nParts-1);
Log("[CFG ] Load UDI Module '%s'", line->Parts[1]);
Module_LoadFile(line->Parts[1], "");
}
- // EDI Module
- else if(strcmp(line->Parts[0], "edimod") == 0) {
+ // Load a EDI Module
+ else if(strcmp(line->Parts[0], "edimod") == 0)
+ {
if( line->nParts != 2 ) {
Warning("Configuration command 'edimod' requires 1 argument, %i given",
line->nParts-1);
Log("[CFG ] Load EDI Module '%s'", line->Parts[1]);
Module_LoadFile(line->Parts[1], "");
}
- // Symbolic Link
- else if(strcmp(line->Parts[0], "symlink") == 0) {
+ // Create a Symbolic Link
+ else if(strcmp(line->Parts[0], "symlink") == 0)
+ {
if( line->nParts != 3 ) {
Warning("Configuration command 'symlink' requires 2 arguments, %i given",
line->nParts-1);
line->Parts[1], line->Parts[2]);
VFS_Symlink(line->Parts[1], line->Parts[2]);
}
- // Create Directory
- else if(strcmp(line->Parts[0], "mkdir") == 0) {
+ // Create a Directory
+ else if(strcmp(line->Parts[0], "mkdir") == 0)
+ {
if( line->nParts != 2 ) {
Warning("Configuration command 'mkdir' requires 1 argument, %i given",
line->nParts-1);
VFS_MkDir(line->Parts[1]);
}
// Spawn a process
- else if(strcmp(line->Parts[0], "spawn") == 0) {
+ else if(strcmp(line->Parts[0], "spawn") == 0)
+ {
if( line->nParts != 2 ) {
Warning("Configuration command 'spawn' requires 1 argument, %i given",
line->nParts-1);
FILESYSTEMS =
DRIVERS =
MODULES = Storage/ATA Storage/FDD
-#MODULES += Network/NE2000
+MODULES += Network/NE2000
#MODULES += Display/BochsGA
MODULES += Filesystems/Ext2
MODULES += Filesystems/FAT
#endif\r
return ;\r
}\r
-\r
-/**\r
- * \fn void fat_install()\r
- * \brief Add the FAT Filesystem to the VFS\r
- */\r
-void fat_install()\r
-{\r
- VFS_AddDriver( &gFAT_FSInfo );\r
-}\r
File "CLIShell" "../../../Usermode/Applications/CLIShell"
File "ls" "../../../Usermode/Applications/ls"
File "cat" "../../../Usermode/Applications/cat"
+ File "mount" "../../../Usermode/Applications/mount"
}
Dir "Libs" {
File "ld-acess.so" "../../../Usermode/Libraries/ld-acess.so"
int i;
tInitRD_File *dir = Node->ImplPtr;
- Log("InirRD_FindDir: Name = '%s'", Name);
+ //Log("InirRD_FindDir: Name = '%s'", Name);
for( i = 0; i < Node->Size; i++ )
{
// === CODE ===
udi_size_t udi_snprintf(char *s, udi_size_t max_bytes, const char *format, ...)
{
- s[0] = '\0';
- return 0;
+ udi_size_t ret;
+ va_list args;
+ va_start(args, format);
+
+ ret = vsnprintf(s, max_bytes, format, args);
+
+ va_end(args);
+ return ret;
}
Ne2k_WriteReg(base, MAC5, gpNe2k_Cards[ k ].MacAddr[5]);
*/
+ Log_Log("NE2K", "Card %i 0x%04x %02x:%02x:%02x:%02x:%02x:%02x",
+ k, base,
+ gpNe2k_Cards[k].MacAddr[0], gpNe2k_Cards[k].MacAddr[1],
+ gpNe2k_Cards[k].MacAddr[2], gpNe2k_Cards[k].MacAddr[3],
+ gpNe2k_Cards[k].MacAddr[4], gpNe2k_Cards[k].MacAddr[5]
+ );
+
Log("[NE2K]: Card #%i: IRQ=%i, IOBase=0x%x",
k, gpNe2k_Cards[ k ].IRQ, gpNe2k_Cards[ k ].IOBase);
Log("MAC Address %x:%x:%x:%x:%x:%x",
--- /dev/null
+/* Acess2 RTL8139 Driver
+ * - By John Hodge (thePowersGang)
+ *
+ * main.c - Driver Core
+ */
+#define DEBUG 0
+#define VERSION ((0<<8)|50)
+#include <acess.h>
+#include <modules.h>
+#include <fs_devfs.h>
+#include <drv_pci.h>
+#include <tpl_drv_network.h>
+
+// === CONSTANTS ===
+enum eRTL8139_Regs
+{
+ MAC0, MAC1, MAC2,
+ MAC3, MAC4, MAC5,
+ MAR0 = 0x08,
+ MAR1, MAR2, MAR3,
+ MAR4, MAR5, MAR6, MAR7,
+
+ RBSTART = 0x30, //!< Recieve Buffer Start
+ // ??, ??, ??, RST, RE, TE, ??, ??
+ CMD = 0x37,
+ IMR = 0x3C,
+ ISR = 0x3E,
+
+ RCR = 0x44,
+
+ CONFIG1 = 0x52
+};
+
+// === TYPES ===
+typedef struct sCard
+{
+ Uint16 IOBase;
+ Uint8 IRQ;
+
+ int NumWaitingPackets;
+
+ void *ReceiveBuffer;
+ tPAddr PhysReceiveBuffer;
+
+ char Name[2];
+ tVFS_Node Node;
+ Uint8 MacAddr[6];
+} tCard;
+
+// === PROTOTYPES ===
+
+// === GLOBALS ===
+MODULE_DEFINE(0, VERSION, RTL8139, RTL8139_Install, NULL, NULL);
+ int giRTL8139_CardCount;
+tCard gpRTL8139_Cards;
+
+// === CODE ===
+/**
+ * \brief Installs the RTL8139 Driver
+ */
+int RTL8139_Install(char **Options)
+{
+ int id = -1;
+ int i = 0;
+ Uint16 base;
+
+ giRTL8139_CardCount = PCI_CountDevices( 0x10EC, 0x8139, 0 );
+
+ gpRTL8139_Cards = calloc( giRTL8139_CardCount, sizeof(tCard) );
+
+
+ while( (id = PCI_GetDevice(0x10EC, 0x8139, 0, id)) != -1 )
+ {
+ base = PCI_AssignPort( id, 0, 0x100 );
+ gpRTL8139_Cards[i].IOBase = base;
+ gpRTL8139_Cards[i].IRQ = PCI_GetIRQ( id );
+
+ // Install IRQ Handler
+ IRQ_AddHandler(gpRTL8139_Cards[ k ].IRQ, RTL8136_IRQHandler);
+
+ // Power on
+ outb( base + CONFIG1, 0x00 );
+ // Reset (0x10 to CMD)
+ outb( base + CMD, 0x10 );
+
+ gpRTL8139_Cards[i].ReceiveBuffer = MM_AllocDMA( 2, 32, &gpRTL8139_Cards[i].PhysReceiveBuffer );
+ // Set up recieve buffer
+ outl(base + RBSTART, (Uint32)gpRTL8139_Cards[i].PhysReceiveBuffer);
+ // Set IMR to Transmit OK and Receive OK
+ outw(base + IMR, 0x5);
+
+ // Set recieve buffer size, buffer wrap and recieve mask
+ outl(base + RCR, 0x8F);
+
+ outb(base + CMD, 0x0C); // Recive Enable and Transmit Enable
+
+ gpRTL8139_Cards[ i ].MacAddr[0] = inb(base+MAC0);
+ gpRTL8139_Cards[ i ].MacAddr[1] = inb(base+MAC1);
+ gpRTL8139_Cards[ i ].MacAddr[2] = inb(base+MAC2);
+ gpRTL8139_Cards[ i ].MacAddr[3] = inb(base+MAC3);
+ gpRTL8139_Cards[ i ].MacAddr[4] = inb(base+MAC4);
+ gpRTL8139_Cards[ i ].MacAddr[5] = inb(base+MAC5);
+
+ // Set VFS Node
+ gpRTL8139_Cards[ i ].Name[0] = '0'+i;
+ gpRTL8139_Cards[ i ].Name[1] = '\0';
+ gpRTL8139_Cards[ i ].Node.ImplPtr = &gpRTL8139_Cards[ i ];
+ gpRTL8139_Cards[ i ].Node.NumACLs = 0;
+ gpRTL8139_Cards[ i ].Node.CTime = now();
+ gpRTL8139_Cards[ i ].Node.Write = RTL8139_Write;
+ gpRTL8139_Cards[ i ].Node.Read = RTL8139_Read;
+ gpRTL8139_Cards[ i ].Node.IOCtl = RTL8139_IOCtl;
+
+ Log_Log("RTL8139", "Card %i 0x%04x %02x:%02x:%02x:%02x:%02x:%02x",
+ i, base,
+ gpRTL8139_Cards[ i ].MacAddr[0], gpRTL8139_Cards[ i ].MacAddr[1],
+ gpRTL8139_Cards[ i ].MacAddr[2], gpRTL8139_Cards[ i ].MacAddr[3],
+ gpRTL8139_Cards[ i ].MacAddr[4], gpRTL8139_Cards[ i ].MacAddr[5]
+ );
+
+ i ++;
+ }
+ return MODULE_ERR_OK;
+}
#include <stdio.h>
#define MOUNTABLE_FILE "/Acess/Conf/Mountable"
-#define MOUNTED_FILE "/Acess/Conf/Mounted"
+#define MOUNTED_FILE "/Devices/System/VFS/Mounts"
// === PROTOTYPES ===
void ShowUsage();
- int GetMountDefs(char **spDevice, char **spDir, char **spType, char **spOptions);
+ int GetMountDefs(char *Ident, char **spDevice, char **spDir, char **spType, char **spOptions);
// === CODE ===
/**
{
switch(arg[1])
{
+ // -t <driver> :: Filesystem driver to use
case 't': sType = argv[++i]; break;
case '-':
//TODO: Long Arguments
continue;
}
+ // Device?
if(sDevice == NULL) {
sDevice = arg;
continue;
}
+ // Directory?
if(sDir == NULL) {
sDir = arg;
continue;
if(sDir == NULL || getuid() != 0)
{
// Check if it is defined in the mounts file
- if(GetMountDefs(&sDevice, &sDir, &sType, &sOptions) == 0)
+ // - At this point sDevice could be a device name or a mount point
+ if(GetMountDefs(sDevice, &sDevice, &sDir, &sType, &sOptions) == 0)
{
if(sDir == NULL)
fprintf(stderr, "Unable to find '%s' in '%s'\n",
}
/**
- * \fn int GetMountDefs(char **spDevice, char **spDir, char **spType, char **spOptions)
+ * \fn int GetMountDefs(char *Ident, char **spDevice, char **spDir, char **spType, char **spOptions)
* \brief Reads the mountable definitions file and returns the corresponding entry
* \param spDevice Pointer to a string (pointer) determining the device (also is the input for this function)
* \note STUB
*/
-int GetMountDefs(char **spDevice, char **spDir, char **spType, char **spOptions)
+int GetMountDefs(char *Ident, char **spDevice, char **spDir, char **spType, char **spOptions)
{
// TODO: Read the mounts file (after deciding what it will be)
return 0;