From cb414d6f5f9730d64b4914e45c14d9c16aea0b6c Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 15 Jul 2012 12:05:57 +0800 Subject: [PATCH] General cleanup and bugfixes - 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 | 2 ++ KernelLand/Kernel/Makefile | 8 +++--- KernelLand/Kernel/arch/x86/errors.c | 4 ++- KernelLand/Kernel/system.c | 8 +++++- KernelLand/Kernel/vfs/open.c | 12 +++++++-- .../Filesystems/InitRD/GenerateInitRD.php | 27 ------------------- KernelLand/Modules/Filesystems/InitRD/main.c | 5 +++- KernelLand/Modules/Makefile.tpl | 5 ++-- Usermode/Applications/dhcpclient_src/main.c | 1 + Usermode/Libraries/libc.so_src/Makefile | 6 ----- 10 files changed, 34 insertions(+), 44 deletions(-) diff --git a/BuildConf/x86/default.mk b/BuildConf/x86/default.mk index 274e559f..d9237ca4 100644 --- a/BuildConf/x86/default.mk +++ b/BuildConf/x86/default.mk @@ -13,3 +13,5 @@ MODULES += USB/Core USB/UHCI #USB/OHCI MODULES += USB/HID USB/MSC #MODULES += Interfaces/UDI + +DYNMODS += Filesystems/InitRD diff --git a/KernelLand/Kernel/Makefile b/KernelLand/Kernel/Makefile index 706ae3ff..e391f03c 100644 --- a/KernelLand/Kernel/Makefile +++ b/KernelLand/Kernel/Makefile @@ -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 diff --git a/KernelLand/Kernel/arch/x86/errors.c b/KernelLand/Kernel/arch/x86/errors.c index b69f5f85..9562c413 100644 --- a/KernelLand/Kernel/arch/x86/errors.c +++ b/KernelLand/Kernel/arch/x86/errors.c @@ -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; } diff --git a/KernelLand/Kernel/system.c b/KernelLand/Kernel/system.c index d8eba833..db7da340 100644 --- a/KernelLand/Kernel/system.c +++ b/KernelLand/Kernel/system.c @@ -6,6 +6,7 @@ */ #define DEBUG 0 #include +#include // === 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)"); diff --git a/KernelLand/Kernel/vfs/open.c b/KernelLand/Kernel/vfs/open.c index 12a8f8d1..344b2a14 100644 --- a/KernelLand/Kernel/vfs/open.c +++ b/KernelLand/Kernel/vfs/open.c @@ -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; } diff --git a/KernelLand/Modules/Filesystems/InitRD/GenerateInitRD.php b/KernelLand/Modules/Filesystems/InitRD/GenerateInitRD.php index ca7be3d5..4a6635b4 100644 --- a/KernelLand/Modules/Filesystems/InitRD/GenerateInitRD.php +++ b/KernelLand/Modules/Filesystems/InitRD/GenerateInitRD.php @@ -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 .= << $(BIN).gz + $(xCP) $(BIN).gz $(DISTROOT)/$(ARCH)/Modules/$(NAME).kmd.gz else endif diff --git a/Usermode/Applications/dhcpclient_src/main.c b/Usermode/Applications/dhcpclient_src/main.c index 72957885..820a119a 100644 --- a/Usermode/Applications/dhcpclient_src/main.c +++ b/Usermode/Applications/dhcpclient_src/main.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #define FILENAME_MAX 255 diff --git a/Usermode/Libraries/libc.so_src/Makefile b/Usermode/Libraries/libc.so_src/Makefile index 9abc578a..61d127f7 100644 --- a/Usermode/Libraries/libc.so_src/Makefile +++ b/Usermode/Libraries/libc.so_src/Makefile @@ -18,9 +18,3 @@ BIN = libc.so include ../Makefile.tpl -#all: $(OUTPUTDIR)Libs/crt0.o - -# C Runtime 0 -#$(OUTPUTDIR)Libs/crt0.o: crt0.asm -# @echo --- $(AS) -o $@ -# @$(AS) $(ASFLAGS) -o $@ $< -- 2.20.1