]> hydra-www.ietfng.org Git - xv6-public/commitdiff
Add version printout to kernel startup
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Tue, 27 Oct 2015 01:28:13 +0000 (21:28 -0400)
committerNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Wed, 11 Nov 2015 04:42:27 +0000 (23:42 -0500)
.gitignore
Makefile
main.c
vers.c [new file with mode: 0644]

index 3e2c9deafe7948680a6ceb9b0ddd4a456bc9504a..b7a18fbb23ccd3ae3fae401fc75ac0195c7d043e 100644 (file)
@@ -14,3 +14,4 @@ kernel
 kernelmemfs
 mkfs
 .gdbinit
+vers.h
index ca7b586001b040bce1186b75ac0a02c3460b562e..3e4534831da7acd1481a7e1b6662685bcbb52343 100644 (file)
--- 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 d25e71982f24d0282d376adf28c6b34a8e9b6c8f..d9e8efd1822482953e8767d93b710a414ab326f8 100644 (file)
--- 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 (file)
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");
+}