Bugfixing
authorJohn Hodge <[email protected]>
Thu, 27 May 2010 05:57:16 +0000 (13:57 +0800)
committerJohn Hodge <[email protected]>
Thu, 27 May 2010 05:57:16 +0000 (13:57 +0800)
Kernel/Makefile
Kernel/Makefile.BuildNum
Kernel/arch/x86/main.c
Kernel/arch/x86/vm8086.c
Kernel/include/vfs.h
Kernel/logging.c
Kernel/modules.c
Makefile.cfg

index 6bf4b9f..6be6a13 100644 (file)
@@ -15,7 +15,7 @@ KERNEL_VERSION = 0.5
 MAKEDEP                = $(CC) -M
 
 CPPFLAGS       += -I./include -I./arch/$(ARCHDIR)/include
-CPPFLAGS    += -DARCH=$(ARCH) -DARCHDIR=$(ARCHDIR) -DKERNEL_VERSION=$(KERNEL_VERSION) -DBUILD_NUM=$(BUILD_NUM)
+CPPFLAGS       += -DARCH=$(ARCH) -DARCHDIR=$(ARCHDIR) -DKERNEL_VERSION=$(KERNEL_VERSION) -DBUILD_NUM=$(BUILD_NUM)
 CFLAGS         += -Wall -Werror -O3 -fno-stack-protector -fno-builtin
 ASFLAGS                += -D ARCH=\"$(ARCH)\" -D ARCHDIR=\"$(ARCHDIR)\"
 LDFLAGS                += -T arch/$(ARCHDIR)/link.ld
@@ -61,7 +61,7 @@ $(BIN): $(OBJ) $(MODS) arch/$(ARCHDIR)/link.ld Makefile
        @echo --- LD -o $(BIN)
        @$(LD) $(LDFLAGS) -o $(BIN) $(OBJ) $(MODS) -Map ../Map.$(ARCH).txt
        @objdump $(BIN) -D -S > $(BIN).dsm
-       @wc -l $(SRCFILES) > LineCounts.$(ARCH).txt
+       @wc -l $(SRCFILES) include/*.h > LineCounts.$(ARCH).txt
        @echo BUILD_NUM = `calc $(BUILD_NUM)+1` > Makefile.BuildNum
 
 %.ao.$(ARCH): %.asm Makefile
index d780e7e..4188205 100644 (file)
@@ -1 +1 @@
-BUILD_NUM = 2164
+BUILD_NUM = 2183
index 2dca563..6baec03 100644 (file)
@@ -125,7 +125,7 @@ void Arch_LoadBootModules(void)
                
                if( !Module_LoadMem( gaArch_BootModules[i].Base, gaArch_BootModules[i].Size, gaArch_BootModules[i].ArgString ) )
                {
-                       Log_Warning("Arch", "Unable to load module\n");
+                       Log_Warning("Arch", "Unable to load module");
                }
        }
        Log_Log("Arch", "Boot modules loaded");
index 1816eac..1f4f1f4 100644 (file)
@@ -47,7 +47,7 @@ MODULE_DEFINE(0, 0x100, VM8086, VM8086_Install, NULL, NULL);
 tSpinlock      glVM8086_Process;
 tPID   gVM8086_WorkerPID;
 tTID   gVM8086_CallingThread;
-tVM8086        * volatile gpVM8086_State = (void*)-1;  // Set to -1 to avoid race conditions
+tVM8086        volatile * volatile gpVM8086_State = (void*)-1; // Set to -1 to avoid race conditions
 
 // === FUNCTIONS ===
 int VM8086_Install(char **Arguments)
@@ -66,8 +66,8 @@ int VM8086_Install(char **Arguments)
        }
        if(pid == 0)
        {
-               Uint    *stacksetup;    // Initialising Stack
-               Uint16  *rmstack;       // Real Mode Stack
+               Uint    * volatile stacksetup;  // Initialising Stack
+               Uint16  * volatile rmstack;     // Real Mode Stack
                 int    i;
                 
                // Set Image Name
@@ -91,32 +91,32 @@ int VM8086_Install(char **Arguments)
                *(Uint8*)(0x100003) = 0xCB;     // RET FAR
                
                rmstack = (Uint16*)(VM8086_STACK_SEG*16 + VM8086_STACK_OFS);
-               *rmstack-- = 0xFFFF;    //CS
-               *rmstack-- = 0x0010;    //IP
+               rmstack--;      *rmstack = 0xFFFF;      //CS
+               rmstack--;      *rmstack = 0x0010;      //IP
                
                // Setup Stack
                stacksetup = (Uint*)0x101000;
-               *--stacksetup = VM8086_STACK_SEG;       // GS
-               *--stacksetup = VM8086_STACK_SEG;       // FS
-               *--stacksetup = VM8086_STACK_SEG;       // DS
-               *--stacksetup = VM8086_STACK_SEG;       // ES
-               *--stacksetup = VM8086_STACK_SEG;       // SS
-               *--stacksetup = VM8086_STACK_OFS-2;     // SP
-               *--stacksetup = 0x20202;        // FLAGS
-               *--stacksetup = 0xFFFF; // CS
-               *--stacksetup = 0x10;   // IP
-               *--stacksetup = 0xAAAA; // AX
-               *--stacksetup = 0xCCCC; // CX
-               *--stacksetup = 0xDDDD; // DX
-               *--stacksetup = 0xBBBB; // BX
-               *--stacksetup = 0x5454; // SP
-               *--stacksetup = 0xB4B4; // BP
-               *--stacksetup = 0x5151; // SI
-               *--stacksetup = 0xD1D1; // DI
-               *--stacksetup = 0x20|3; // DS - Kernel
-               *--stacksetup = 0x20|3; // ES - Kernel
-               *--stacksetup = 0x20|3; // FS
-               *--stacksetup = 0x20|3; // GS
+               stacksetup--;   *stacksetup = VM8086_STACK_SEG; // GS
+               stacksetup--;   *stacksetup = VM8086_STACK_SEG; // FS
+               stacksetup--;   *stacksetup = VM8086_STACK_SEG; // DS
+               stacksetup--;   *stacksetup = VM8086_STACK_SEG; // ES
+               stacksetup--;   *stacksetup = VM8086_STACK_SEG; // SS
+               stacksetup--;   *stacksetup = VM8086_STACK_OFS-2;       // SP
+               stacksetup--;   *stacksetup = 0x20202;  // FLAGS
+               stacksetup--;   *stacksetup = 0xFFFF;   // CS
+               stacksetup--;   *stacksetup = 0x10;     // IP
+               stacksetup--;   *stacksetup = 0xAAAA;   // AX
+               stacksetup--;   *stacksetup = 0xCCCC;   // CX
+               stacksetup--;   *stacksetup = 0xDDDD;   // DX
+               stacksetup--;   *stacksetup = 0xBBBB;   // BX
+               stacksetup--;   *stacksetup = 0x5454;   // SP
+               stacksetup--;   *stacksetup = 0xB4B4;   // BP
+               stacksetup--;   *stacksetup = 0x5151;   // SI
+               stacksetup--;   *stacksetup = 0xD1D1;   // DI
+               stacksetup--;   *stacksetup = 0x20|3;   // DS - Kernel
+               stacksetup--;   *stacksetup = 0x20|3;   // ES - Kernel
+               stacksetup--;   *stacksetup = 0x20|3;   // FS
+               stacksetup--;   *stacksetup = 0x20|3;   // GS
                __asm__ __volatile__ (
                "mov %%eax,%%esp;\n\t"  // Set stack pointer
                "pop %%gs;\n\t"
@@ -168,12 +168,12 @@ void VM8086_GPF(tRegs *Regs)
                }
                
                //Log_Log("VM8086", "We have a task (%p)", gpVM8086_State);
-               Regs->esp -= 2; *(Uint16*)( (Regs->ss<<4) + (Regs->esp&0xFFFF) ) = VM8086_MAGIC_CS;
-               Regs->esp -= 2; *(Uint16*)( (Regs->ss<<4) + (Regs->esp&0xFFFF) ) = VM8086_MAGIC_IP;
-               Regs->esp -= 2; *(Uint16*)( (Regs->ss<<4) + (Regs->esp&0xFFFF) ) = gpVM8086_State->CS;
-               Regs->esp -= 2; *(Uint16*)( (Regs->ss<<4) + (Regs->esp&0xFFFF) ) = gpVM8086_State->IP;
-               Regs->esp -= 2; *(Uint16*)( (Regs->ss<<4) + (Regs->esp&0xFFFF) ) = gpVM8086_State->DS;
-               Regs->esp -= 2; *(Uint16*)( (Regs->ss<<4) + (Regs->esp&0xFFFF) ) = gpVM8086_State->ES;
+               Regs->esp -= 2; *(Uint16*volatile)( (Regs->ss<<4) + (Regs->esp&0xFFFF) ) = VM8086_MAGIC_CS;
+               Regs->esp -= 2; *(Uint16*volatile)( (Regs->ss<<4) + (Regs->esp&0xFFFF) ) = VM8086_MAGIC_IP;
+               Regs->esp -= 2; *(Uint16*volatile)( (Regs->ss<<4) + (Regs->esp&0xFFFF) ) = gpVM8086_State->CS;
+               Regs->esp -= 2; *(Uint16*volatile)( (Regs->ss<<4) + (Regs->esp&0xFFFF) ) = gpVM8086_State->IP;
+               Regs->esp -= 2; *(Uint16*volatile)( (Regs->ss<<4) + (Regs->esp&0xFFFF) ) = gpVM8086_State->DS;
+               Regs->esp -= 2; *(Uint16*volatile)( (Regs->ss<<4) + (Regs->esp&0xFFFF) ) = gpVM8086_State->ES;
                
                // Set Registers
                Regs->eip = 0x11;       Regs->cs = 0xFFFF;
@@ -212,8 +212,8 @@ void VM8086_GPF(tRegs *Regs)
                id = *(Uint8*)( Regs->cs*16 +(Regs->eip&0xFFFF));
                Regs->eip ++;
                
-               Regs->esp -= 2; *(Uint16*)( Regs->ss*16 + (Regs->esp&0xFFFF) ) = Regs->cs;
-               Regs->esp -= 2; *(Uint16*)( Regs->ss*16 + (Regs->esp&0xFFFF) ) = Regs->eip;
+               Regs->esp -= 2; *(Uint16*volatile)( Regs->ss*16 + (Regs->esp&0xFFFF) ) = Regs->cs;
+               Regs->esp -= 2; *(Uint16*volatile)( Regs->ss*16 + (Regs->esp&0xFFFF) ) = Regs->eip;
                
                Regs->cs = *(Uint16*)(4*id + 2);
                Regs->eip = *(Uint16*)(4*id);
index ab0bd35..057f7f4 100644 (file)
@@ -67,7 +67,7 @@
  */
 
 /**
- * \brief VFS Node
+ * \brief Represents a node (file or directory) in the VFS tree
  * 
  * This structure provides the VFS with the functions required to read/write
  * the file (or directory) that it represents.
@@ -99,8 +99,9 @@ typedef struct sVFS_Node
        Uint32  Flags;  //!< File Flags
        
        /**
-        * Pointer to cached data (FS Specific)
-        * \note Inode_* will free when the node is uncached this if needed
+        * \brief Pointer to cached data (FS Specific)
+        * \note The Inode_* functions will free when the node is uncached
+        *       this if needed
         */
        void    *Data;
        /**
@@ -160,7 +161,7 @@ typedef struct sVFS_Node
         int    (*IOCtl)(struct sVFS_Node *Node, int Id, void *Data);
        
        /**
-        * }
+        * \}
         */
        
        /**
@@ -190,7 +191,7 @@ typedef struct sVFS_Node
        Uint64  (*Write)(struct sVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
        
        /**
-        * }
+        * \}
         */
        
        /**
@@ -247,7 +248,7 @@ typedef struct sVFS_Node
         int    (*Link)(struct sVFS_Node *Node, struct sVFS_Node *Child, char *NewName);
         
         /**
-         * }
+         * \}
          */
 } tVFS_Node;
 
index 747094d..54f16ca 100644 (file)
@@ -65,6 +65,7 @@ EXPORT(Log_Debug);
 
 // === GLOBALS ===
 tSpinlock      glLog;
+tSpinlock      glLogOutput;
 tLogList       gLog;
 tLogList       gLog_Levels[NUM_LOG_LEVELS];
 
index 41fb514..4b095bc 100644 (file)
@@ -88,7 +88,8 @@ int Module_int_Initialise(tModule *Module, char *ArgString)
                                break;
                }
                if( mod ) {
-                       Log_Warning("Module", "Circular dependency detected");
+                       Log_Warning("Module", "Circular dependency detected (%s and %s)",
+                               mod->Name, Module->Name);
                        LEAVE_RET('i', -1);
                }
                
@@ -99,7 +100,8 @@ int Module_int_Initialise(tModule *Module, char *ArgString)
                                break;
                }
                if( i == giNumBuiltinModules ) {
-                       Log_Warning("Module", "Dependency '%s' for module '%s' failed");
+                       Log_Warning("Module", "Dependency '%s' for module '%s' failed",
+                               deps[j], Module->Name);
                        return -1;
                }
                
@@ -132,6 +134,9 @@ int Module_int_Initialise(tModule *Module, char *ArgString)
        
        if(args)        free(args);
        
+       // Remove from loading list
+       gLoadingModules = gLoadingModules->Next;
+       
        if( ret != MODULE_ERR_OK ) {
                switch(ret)
                {
@@ -153,9 +158,6 @@ int Module_int_Initialise(tModule *Module, char *ArgString)
        }
        LOG("ret = %i", ret);
        
-       // Remove from loading list
-       gLoadingModules = gLoadingModules->Next;
-       
        // Add to loaded list
        LOCK( &glModuleSpinlock );
        Module->Next = gLoadedModules;
index b2957a0..35080e9 100644 (file)
@@ -33,7 +33,7 @@ FILESYSTEMS :=
 DRIVERS := 
 MODULES := Storage/ATA Storage/FDD
 MODULES += Network/NE2000
-#MODULES += Display/VESA
+MODULES += Display/VESA
 MODULES += Display/BochsGA
 MODULES += Filesystems/Ext2
 MODULES += Filesystems/FAT

UCC git Repository :: git.ucc.asn.au