From d1530bb39a40caa7ce083245905c13f8e6399c96 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Thu, 19 Jul 2012 14:58:55 +0800 Subject: [PATCH] Kernel - Standardised kernel build tag (placed in gsBuildInfo) --- KernelLand/Kernel/Makefile | 13 +++++++------ KernelLand/Kernel/arch/x86/main.c | 7 +------ KernelLand/Kernel/bin/elf.c | 2 +- KernelLand/Kernel/drv/proc.c | 8 ++------ KernelLand/Kernel/include/acess.h | 3 ++- KernelLand/Kernel/include/init.h | 2 ++ 6 files changed, 15 insertions(+), 20 deletions(-) diff --git a/KernelLand/Kernel/Makefile b/KernelLand/Kernel/Makefile index 7562079c..40fb4a1c 100644 --- a/KernelLand/Kernel/Makefile +++ b/KernelLand/Kernel/Makefile @@ -96,14 +96,12 @@ apidoc: # Output binary # - Links kernel # - Disassembles it -# - Gets a line count # - Increments the build count # - Does whatever architecture defined rules $(BIN): $(OBJ) $(MODS) arch/$(ARCHDIR)/link.ld Makefile ../../BuildConf/$(ARCH)/Makefile.cfg ../../BuildConf/$(ARCH)/$(PLATFORM).mk @echo --- LD -o $(BIN) @$(LD) $(LDFLAGS) -o $(BIN) $(OBJ) $(MODS) --defsym __buildnum=$$(( $(BUILD_NUM) + 1 )) -Map ../Map.$(ARCH).txt @$(DISASM) -S $(BIN) > $(BIN).dsm - @wc -l $(SRCFILES) include/*.h > LineCounts.$(ARCH).txt @echo BUILD_NUM = $$(( $(BUILD_NUM) + 1 )) > Makefile.BuildNum.$(ARCH) $(POSTBUILD) @cp $(BIN) $(BIN)_ @@ -135,14 +133,18 @@ $(OBJDIR)%.o$(OBJSUFFIX): %.c Makefile include/syscalls.h include/syscalls.inc.asm: syscalls.lst Makefile GenSyscalls.pl perl GenSyscalls.pl -# Rules based on the makefile -Makefile: ../../Makefile.cfg arch/$(ARCHDIR)/Makefile +# Differences for the makefile +Makefile: ../../Makefile.cfg ../../BuildConf/$(ARCH)/Makefile.cfg ../../BuildConf/$(ARCH)/$(PLATFORM).mk arch/$(ARCHDIR)/Makefile # Build-time information (git hash and build number) $(BUILDINFO_SRC): $(filter-out $(BUILDINFO_OBJ), $(OBJ)) $(MODS) arch/$(ARCHDIR)/link.ld Makefile + $(eval _GITHASH=$(shell git log -n 1 | head -n 1 | awk '{print $$2}')) + $(eval _GITCHANGED=$(shell git status --porcelain | grep -c '^ M ')) @echo "#include " > $@ - @echo "const char gsGitHash[] = \""`git log -n 1 | head -n 1 | awk '{print $$2}'`"\";" >> $@ + @echo "const char gsGitHash[] = \"$(_GITHASH)\";" >> $@ @echo "const int giBuildNumber = $(BUILD_NUM);" >> $@ + @echo "const char gsBuildInfo[] = \"Acess2 v$(KERNEL_VERSION) $(ARCH)-$(PLATFORM)\\\\r\\\\n\"" >> $@ + @echo " \"Build $(shell hostname --fqdn):$(BUILD_NUM) Git $(_GITHASH) - $(_GITCHANGED) modified\";" >> $@ # Compile rule for buildinfo (needs a special one because it's not a general source file) $(BUILDINFO_OBJ): $(BUILDINFO_SRC) @echo --- CC -o $@ @@ -151,4 +153,3 @@ $(BUILDINFO_OBJ): $(BUILDINFO_SRC) # Dependency Files -include $(DEPFILES) -%.h: diff --git a/KernelLand/Kernel/arch/x86/main.c b/KernelLand/Kernel/arch/x86/main.c index 466b61e4..b6ac974a 100644 --- a/KernelLand/Kernel/arch/x86/main.c +++ b/KernelLand/Kernel/arch/x86/main.c @@ -20,14 +20,10 @@ // === IMPORTS === extern char gKernelEnd[]; extern void Heap_Install(void); -extern void Desctab_Install(void); extern void MM_PreinitVirtual(void); extern void MM_Install(int NPMemRanges, tPMemMapEnt *PMemRanges); extern void MM_InstallVirtual(void); -extern void Threads_Init(void); extern int Time_Setup(void); -// --- Core --- -extern void System_Init(char *Commandline); // === PROTOTYPES === int kmain(Uint MbMagic, void *MbInfoPtr); @@ -50,8 +46,7 @@ int kmain(Uint MbMagic, void *MbInfoPtr) tPMemMapEnt pmemmap[MAX_PMEMMAP_ENTS]; int nPMemMapEnts; - LogF("Acess2 x86-"PLATFORM" v"EXPAND_STR(KERNEL_VERSION)"\r\n"); - LogF(" Build %i, Git Hash %s\r\n", BUILD_NUM, gsGitHash); + LogF("%s\r\n", gsBuildInfo); MM_PreinitVirtual(); // Initialise virtual mappings diff --git a/KernelLand/Kernel/bin/elf.c b/KernelLand/Kernel/bin/elf.c index 83dfa8ac..b0d96cac 100644 --- a/KernelLand/Kernel/bin/elf.c +++ b/KernelLand/Kernel/bin/elf.c @@ -12,7 +12,7 @@ void *GetSymbol(const char *Name, size_t *Size); void *GetSymbol(const char *Name, size_t *Size) { Uint val; Binary_GetSymbol(Name, &val); if(Size)*Size=0; return (void*)val; }; #define AddLoaded(a,b) do{}while(0) -#define LoadLibrary(a,b,c) 0 +#define LoadLibrary(a,b,c) (Log_Debug("ELF", "Module requested lib '%s'",a),0) #include "../../../Usermode/Libraries/ld-acess.so_src/elf.c" #define DEBUG_WARN 1 diff --git a/KernelLand/Kernel/drv/proc.c b/KernelLand/Kernel/drv/proc.c index 954cab62..cbf25656 100644 --- a/KernelLand/Kernel/drv/proc.c +++ b/KernelLand/Kernel/drv/proc.c @@ -109,12 +109,8 @@ tSysFS_Ent *gSysFS_FileList; */ int SysFS_Install(char **Options) { - { - const char *fmt = "Acess2 "EXPAND_STR(KERNEL_VERSION)" "EXPAND_STR(ARCHDIR)" build %i, hash %s"; - gSysFS_Version_Kernel.Node.Size = snprintf(NULL, 0, fmt, BUILD_NUM, gsGitHash); - gSysFS_Version_Kernel.Node.ImplPtr = malloc( gSysFS_Version_Kernel.Node.Size + 1 ); - sprintf(gSysFS_Version_Kernel.Node.ImplPtr, fmt, BUILD_NUM, gsGitHash); - } + gSysFS_Version_Kernel.Node.Size = strlen(gsBuildInfo); + gSysFS_Version_Kernel.Node.ImplPtr = gsBuildInfo; DevFS_AddDevice( &gSysFS_DriverInfo ); return MODULE_ERR_OK; diff --git a/KernelLand/Kernel/include/acess.h b/KernelLand/Kernel/include/acess.h index 87aef6ec..51ae771b 100644 --- a/KernelLand/Kernel/include/acess.h +++ b/KernelLand/Kernel/include/acess.h @@ -60,7 +60,8 @@ typedef Uint64 off_t; //!< VFS Offset extern char __buildnum[]; #define BUILD_NUM ((int)(Uint)&__buildnum) -extern const char gsGitHash[]; +extern const char gsGitHash[]; +extern const char gsBuildInfo[]; #define VER2(major,minor) ((((major)&0xFF)<<8)|((minor)&0xFF)) /** diff --git a/KernelLand/Kernel/include/init.h b/KernelLand/Kernel/include/init.h index 9f2fc108..6af177dc 100644 --- a/KernelLand/Kernel/include/init.h +++ b/KernelLand/Kernel/include/init.h @@ -7,5 +7,7 @@ extern void Arch_LoadBootModules(void); extern void StartupPrint(const char *String); +extern void System_Init(char *Commandline); +extern void Threads_Init(void); #endif -- 2.20.1