General cleanup and bugfixes
authorJohn Hodge <[email protected]>
Sun, 15 Jul 2012 04:05:57 +0000 (12:05 +0800)
committerJohn Hodge <[email protected]>
Sun, 15 Jul 2012 04:05:57 +0000 (12:05 +0800)
- Compressed installed versions of kernel modules
- Added backtrace when user apps fault
- Fixed compilation error in dhcpclient
- Added initrd to x86's build

BuildConf/x86/default.mk
KernelLand/Kernel/Makefile
KernelLand/Kernel/arch/x86/errors.c
KernelLand/Kernel/system.c
KernelLand/Kernel/vfs/open.c
KernelLand/Modules/Filesystems/InitRD/GenerateInitRD.php
KernelLand/Modules/Filesystems/InitRD/main.c
KernelLand/Modules/Makefile.tpl
Usermode/Applications/dhcpclient_src/main.c
Usermode/Libraries/libc.so_src/Makefile

index 274e559..d9237ca 100644 (file)
@@ -13,3 +13,5 @@ MODULES += USB/Core USB/UHCI
 #USB/OHCI
 MODULES += USB/HID USB/MSC
 #MODULES += Interfaces/UDI
+
+DYNMODS += Filesystems/InitRD
index 706ae3f..e391f03 100644 (file)
@@ -86,10 +86,6 @@ clean:
 # Creates a stripped and compressed copy of the kernel
 # and installs it to the target
 install: $(BIN) 
-       @cp $(BIN) $(BIN)_
-       @$(STRIP) $(BIN)_
-       @gzip -c $(BIN)_ > $(GZBIN)
-       @$(RM) $(BIN)_
        $(xCP) $(GZBIN) $(DISTROOT)
 
 # Compile API documentation
@@ -109,6 +105,10 @@ $(BIN): $(OBJ) $(MODS) arch/$(ARCHDIR)/link.ld Makefile ../../BuildConf/$(ARCH)/
        @wc -l $(SRCFILES) include/*.h > LineCounts.$(ARCH).txt
        @echo BUILD_NUM = $$(( $(BUILD_NUM) + 1 )) > Makefile.BuildNum.$(ARCH)
        $(POSTBUILD)
+       @cp $(BIN) $(BIN)_
+       @$(STRIP) $(BIN)_
+       @gzip -c $(BIN)_ > $(GZBIN)
+       @$(RM) $(BIN)_
 
 # Assembly Sources
 $(OBJDIR)%.ao$(OBJSUFFIX): %.$(AS_SUFFIX) Makefile
index b69f5f8..9562c41 100644 (file)
@@ -116,6 +116,8 @@ void ErrorHandler(tRegs *Regs)
                        csaERROR_NAMES[Regs->int_num], Regs->err_code);
                Log_Warning("Arch", "at CS:EIP %04x:%08x",
                        Regs->cs, Regs->eip);
+               Error_Backtrace(Regs->eip, Regs->ebp);
+               
                MM_DumpTables(0, KERNEL_BASE);
                switch( Regs->int_num )
                {
@@ -228,7 +230,7 @@ void Error_Backtrace(Uint eip, Uint ebp)
 //             LogF("Backtrace: %s+0x%x", str, delta);
        if(!MM_GetPhysAddr(ebp))
        {
-               LogF("\nBacktrace: Invalid EBP, stopping\n");
+               LogF("\nBacktrace: Invalid EBP %p, stopping\n", ebp);
                return;
        }
        
index d8eba83..db7da34 100644 (file)
@@ -6,6 +6,7 @@
  */
 #define DEBUG  0
 #include <acess.h>
+#include <hal_proc.h>
 
 // === IMPORTS ===
 extern void    Arch_LoadBootModules(void);
@@ -44,7 +45,12 @@ void System_Init(char *CommandLine)
        
        // - Execute the Config Script
        Log_Log("Config", "Spawning init '%s'", gsInitBinary);
-       Proc_Spawn(gsInitBinary);
+       if(Proc_Clone(CLONE_VM|CLONE_NOUSER) == 0)
+       {
+               const char      *args[] = {gsInitBinary, 0};
+               Proc_Execve(gsInitBinary, args, &args[1], 0);
+               Log_KernelPanic("System", "Unable to spawn init '%s'", gsInitBinary);
+       }
        
        // Set the debug to be echoed to the terminal
        Log_Log("Config", "Kernel now echoes to VT7 (Ctrl-Alt-F8)");
index 12a8f8d..344b2a1 100644 (file)
@@ -283,9 +283,16 @@ restart_parse:
                }
                
                // Check if the node has a FindDir method
+               if( !curNode->Type )
+               {
+                       LOG("Finddir failure on '%s' - No type", Path);
+                       Log_Error("VFS", "Node at '%s' has no type (mount %s:%s)",
+                               Path, mnt->Filesystem->Name, mnt->MountPoint);
+                       goto _error;
+               }
                if( !curNode->Type->FindDir )
                {
-                       LOG("Finddir failure on '%s'", Path);
+                       LOG("Finddir failure on '%s' - No FindDir method in %s", Path, curNode->Type->Name);
                        goto _error;
                }
                LOG("FindDir{=%p}(%p, '%s')", curNode->Type->FindDir, curNode, pathEle);
@@ -647,7 +654,8 @@ void VFS_Close(int FD)
        
        _CloseNode(h->Node);
 
-       h->Mount->OpenHandleCount --;   
+       if( h->Mount )
+               h->Mount->OpenHandleCount --;   
 
        h->Node = NULL;
 }
index ca7be3d..4a6635b 100644 (file)
@@ -123,36 +123,9 @@ EOF;
                        }
                        $size = filesize($path);
        
-/*             
-                       $_sym = $prefix."_".$i."_data";
-                       $fp = fopen($path, "rb");
-                       
-                       $gOutput .= "Uint8 $_sym[] = {\n";
-                       for( $j = 0; $j + 16 < $size; $j += 16 ) {
-                               $gOutput .= "\t";
-                               $gOutput .= hd8($fp).",".hd8($fp).",";
-                               $gOutput .= hd8($fp).",".hd8($fp).",";
-                               $gOutput .= hd8($fp).",".hd8($fp).",";
-                               $gOutput .= hd8($fp).",".hd8($fp).",";
-                               $gOutput .= hd8($fp).",".hd8($fp).",";
-                               $gOutput .= hd8($fp).",".hd8($fp).",";
-                               $gOutput .= hd8($fp).",".hd8($fp).",";
-                               $gOutput .= hd8($fp).",".hd8($fp).",\n";
-                       }
-                       $gOutput .= "\t";
-                       for( ; $j < $size; $j ++ ) {
-                               if( $j & 15 )   $gOutput .= ",";
-                               $gOutput .= hd8($fp);
-                       }
-                       fclose($fp);
-                       $gOutput .= "\n};\n";
-*/
-                       
-//*
                        $_sym = "_binary_".str_replace(array("/","-","."), "_", $path)."_start";
                        $gOutput .= "extern Uint8 {$_sym}[];";
                        $gSymFiles[] = $path;
-//*/
                        $gOutput .= <<<EOF
 tVFS_Node {$prefix}_{$i} = {
        .NumACLs = 1,
index 3ee61ac..02af043 100644 (file)
@@ -25,7 +25,10 @@ void InitRD_DumpDir(tVFS_Node *Node, int Indent);
 // === GLOBALS ===
 MODULE_DEFINE(0, 0x0A, FS_InitRD, InitRD_Install, NULL);
 tVFS_Driver    gInitRD_FSInfo = {
-       "initrd", 0, InitRD_InitDevice, InitRD_Unmount, InitRD_GetNodeFromINode
+       .Name = "initrd",
+       .InitDevice = InitRD_InitDevice,
+       .Unmount = InitRD_Unmount,
+       .GetNodeFromINode = InitRD_GetNodeFromINode
        };
 tVFS_NodeType  gInitRD_DirType = {
        .ReadDir = InitRD_ReadDir,
index e365e99..040ea7c 100644 (file)
@@ -51,8 +51,9 @@ clean:
 
 install: $(BIN)
 ifneq ($(BUILDTYPE),static)
-       @$(xMKDIR) $(DISTROOT)/Modules/$(ARCH); true
-       $(xCP) $(BIN) $(DISTROOT)/Modules/$(ARCH)/$(NAME).kmd
+       @$(xMKDIR) $(DISTROOT)/$(ARCH)/Modules; true
+       @gzip -c $(BIN) > $(BIN).gz
+       $(xCP) $(BIN).gz $(DISTROOT)/$(ARCH)/Modules/$(NAME).kmd.gz
 else
 endif
 
index 7295788..820a119 100644 (file)
@@ -6,6 +6,7 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 #include <net.h>
 
 #define FILENAME_MAX   255
index 9abc578..61d127f 100644 (file)
@@ -18,9 +18,3 @@ BIN = libc.so
 \r
 include ../Makefile.tpl\r
 \r
-#all: $(OUTPUTDIR)Libs/crt0.o\r
-\r
-# C Runtime 0\r
-#$(OUTPUTDIR)Libs/crt0.o: crt0.asm\r
-#      @echo --- $(AS) -o $@\r
-#      @$(AS) $(ASFLAGS) -o $@ $<\r

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