commit 4bb3e726c572f89550e6c74116fa924817fd5821
parent ca76195fd4afaeb1f364f60a5280d0f1ce761a52
Author: Roberto Vargas <roberto.vargas@arm.com>
Date: Fri, 23 Nov 2018 11:56:03 +0000
[native] Add git hash information in the output
Change-Id: Ib645d9f6ad33b231f5a350f6df6518cc5d886f54
Diffstat:
5 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/target/native/.gitignore b/target/native/.gitignore
@@ -1,2 +1,3 @@
sysreg.h
sysreg.s
+version.h
diff --git a/target/native/Makefile b/target/native/Makefile
@@ -31,7 +31,8 @@ all: $(TARGET)
ram-crt.o rom-crt.o: crt.s
-rom.o: sysreg.h
+ram.o: version.h
+rom.o: sysreg.h version.h
cache.o: sysreg.h
sysreg.h: sysreg.lst
@@ -40,6 +41,9 @@ sysreg.h: sysreg.lst
sysreg.s: sysreg.lst
./mksysreg -s sysreg.lst
+version.h:
+ ./mkver
+
$(BINDIR)/romfw.elf: $(ROMOBJS) $(LIBDEP)
$(LD) $(RCODE_LDFLAGS) $(ROMOBJS) $(RCODE_LDLIBS) -o $@
@@ -52,4 +56,4 @@ $(BINDIR)/romfw.bin: $(BINDIR)/romfw.tst
clean:
rm -f $(TARGET:.bin=.elf)
rm -f $(TARGET:.bin=.tst)
- rm -f sysreg.h sysreg.s
+ rm -f sysreg.h sysreg.s version.h
diff --git a/target/native/mkver b/target/native/mkver
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+set -e
+trap 'r=$?;rm -f $$.tmp;exit $r' EXIT HUP INT QUIT TERM
+
+git log -n1 |
+awk '/commit/ {
+ printf("#define RCODEVERSION \"%s\"\n",
+ substr($2, 1, 8))
+}' > $$.tmp && mv $$.tmp version.h
diff --git a/target/native/ram.c b/target/native/ram.c
@@ -1,5 +1,7 @@
#include <rcode.h>
+#include "version.h"
+
void
main(void)
{
diff --git a/target/native/rom.c b/target/native/rom.c
@@ -4,6 +4,7 @@
#include <rcode.h>
#include <uart.h>
+#include "version.h"
#include "sysreg.h"
#include "arch.h"
@@ -85,13 +86,13 @@ idev(Mach *mp)
static void
info(Mach *mp)
{
- dbg("romfw: version %d\n"
+ dbg("romfw: version %s\n"
"txt = %p, txtsiz = 0x%llx\n"
"ram = %p, ramsiz = 0x%llx\n"
"bss = %p, bsssiz = 0x%llx\n"
"env = %p, envsiz = 0x%llx\n"
"sp = %p, stacksiz = 0x%llx\n",
- 1,
+ RCODEVERSION,
mp->txt, (unsigned long long) mp->txtsiz,
mp->ram, (unsigned long long) mp->ramsiz,
mp->bss_, (unsigned long long) mp->bsssiz,