From 4f4004e9f3c03a1c2539398751dc695d41e25f4c Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Mon, 26 Oct 2015 21:28:13 -0400 Subject: [PATCH] Add version printout to kernel startup --- .gitignore | 1 + Makefile | 7 +++++++ main.c | 5 +++++ vers.c | 13 +++++++++++++ 4 files changed, 26 insertions(+) create mode 100644 vers.c diff --git a/.gitignore b/.gitignore index 3e2c9de..b7a18fb 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ kernel kernelmemfs mkfs .gdbinit +vers.h diff --git a/Makefile b/Makefile index ca7b586..3e45348 100644 --- a/Makefile +++ b/Makefile @@ -29,6 +29,8 @@ OBJS = \ uart.o\ vectors.o\ vm.o\ + \ + vers.o\ # Cross-compiling (e.g., on Mac OS X) # TOOLPREFIX = i386-jos-elf @@ -138,6 +140,11 @@ tags: $(OBJS) entryother.S _init vectors.S: vectors.pl perl vectors.pl > vectors.S +vers.h: .git/HEAD + echo "#define XV6_BUILD_STRING \"$$(git describe --dirty --always)\"" > $@ + +vers.c : vers.h + ULIB = ulib.o usys.o printf.o umalloc.o _%: %.o $(ULIB) diff --git a/main.c b/main.c index d25e719..d9e8efd 100644 --- a/main.c +++ b/main.c @@ -10,6 +10,10 @@ static void startothers(void); static void mpmain(void) __attribute__((noreturn)); extern char end[]; // first address after kernel loaded from ELF file +// If we're not linked with a greeting message routine, don't try. +void __attribute__((weak)) +announce_startup(void) { ; } + // Bootstrap processor starts running C code here. // Allocate a real stack and switch to it, first // doing some setup required for memory allocator to work. @@ -32,6 +36,7 @@ main(void) binit(); // buffer cache fileinit(); // file table ideinit(); // disk + announce_startup(); if(!ismp) timerinit(); // uniprocessor timer startothers(); // start other processors diff --git a/vers.c b/vers.c new file mode 100644 index 0000000..a19282a --- /dev/null +++ b/vers.c @@ -0,0 +1,13 @@ +#include "types.h" +#include "defs.h" +#include "vers.h" + +void +announce_startup(void) +{ + cprintf("The better part of valor is discretion,\n"); + cprintf("in the which better part I have sav'd my life\n"); + cprintf(" -- Henry IV, Part 1, Act 5, Scene 4\n"); + + cprintf("xv6 build " XV6_BUILD_STRING " initialized...\n"); +} -- 2.50.1