diff options
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | Makefile.main | 24 | ||||
-rw-r--r-- | core/init.c | 2 | ||||
-rw-r--r-- | core/opal.c | 2 | ||||
-rw-r--r-- | hw/fsp/fsp-attn.c | 4 | ||||
-rw-r--r-- | include/fsp-attn.h | 6 | ||||
-rw-r--r-- | include/skiboot.h | 4 | ||||
-rwxr-xr-x | make_version.sh | 38 |
8 files changed, 65 insertions, 18 deletions
@@ -17,7 +17,7 @@ tags cscope.out asm/asm-offsets.s include/asm-offsets.h -gitid.c +version.c core/test/run-device core/test/run-malloc core/test/run-malloc-speed @@ -36,3 +36,4 @@ libc/test/run-time libc/test/run-time-gcov libflash/test/test-flash libflash/test/test-flash-gcov +VERSION diff --git a/Makefile.main b/Makefile.main index 4df3cfd..b584eb8 100644 --- a/Makefile.main +++ b/Makefile.main @@ -108,13 +108,15 @@ OBJS := $(ASM) $(CORE) $(HW) $(PLATFORMS) $(LIBFDT) $(LIBFLASH) ifeq ($(PORE),1) OBJS += $(LIBPORE) endif -OBJS += $(LIBC) $(CCAN) $(DEVSRC_OBJ) gitid.o +OBJS += $(LIBC) $(CCAN) $(DEVSRC_OBJ) +OBJS_NO_VER = $(OBJS) +ALL_OBJS = $(OBJS) version.o $(TARGET).lid: $(TARGET).elf $(call Q,OBJCOPY, $(OBJCOPY) -O binary -S $^ $@, $@) -$(TARGET).elf: $(OBJS) $(TARGET).lds $(KERNEL) - $(call Q,LD, $(CC) $(LDFLAGS) -T $(TARGET).lds $(OBJS) -o $@, $@) +$(TARGET).elf: $(ALL_OBJS) $(TARGET).lds $(KERNEL) + $(call Q,LD, $(CC) $(LDFLAGS) -T $(TARGET).lds $(ALL_OBJS) -o $@, $@) $(TARGET).map: $(TARGET).elf $(call Q,NM, $(NM) -n $< | grep -v '\( [aNUw] \)\|\(__crc_\)\|\( \$[adt]\)' > $@, $@) @@ -128,10 +130,16 @@ $(SUBDIRS): # Set V=1 if you want to see everything. include $(SRC)/Makefile.rules -GIT_SHA ?= $(shell cd $(SRC); GIT_DIR=$(SRC)/.git git describe --always --dirty 2> /dev/null) +VERSION ?= $(shell cd $(SRC); GIT_DIR=$(SRC)/.git $(SRC)/make_version.sh) -gitid.c: - @echo "const char gitid[] = \"$(GIT_SHA)\";" > $@ +.PHONY: VERSION-always +.version: VERSION-always + @echo $(VERSION) > $@.tmp + @cmp -s $@ $@.tmp || cp $@.tmp $@ + @rm -f $@.tmp + +version.c: make_version.sh $(OBJS_NO_VER) .version + @echo "const char version[] = \"$(VERSION)\";" > $@ .PHONY: coverage include $(shell find $(SRC)/* -name Makefile.check) @@ -149,7 +157,7 @@ tags: TAGS: find . -name '*.[chS]' | xargs etags -.PHONY: tags TAGS check gitid.c +.PHONY: tags TAGS check cscope: find . -name '*.[chS]' | xargs cscope @@ -157,7 +165,7 @@ cscope: clean: $(RM) *.[odsa] $(SUBDIRS:%=%/*.[odsa]) $(RM) $(TARGET).elf $(TARGET).lid $(TARGET).map $(TARGET).lds - $(RM) include/asm-offsets.h gitid.c + $(RM) include/asm-offsets.h version.c distclean: clean $(RM) *~ $(SUBDIRS:%=%/*~) include/*~ diff --git a/core/init.c b/core/init.c index 1d32be5..a522493 100644 --- a/core/init.c +++ b/core/init.c @@ -493,7 +493,7 @@ void __noreturn main_cpu_entry(const void *fdt, u32 master_cpu) */ clear_console(); - printf("SkiBoot %s starting...\n", gitid); + printf("SkiBoot %s starting...\n", version); printf("initial console log level: memory %d, driver %d\n", (debug_descriptor.console_log_levels >> 4), (debug_descriptor.console_log_levels & 0x0f)); diff --git a/core/opal.c b/core/opal.c index 5e1c742..deb5aff 100644 --- a/core/opal.c +++ b/core/opal.c @@ -118,7 +118,7 @@ static void add_opal_firmware_node(void) dt_add_property_string(firmware, "compatible", "ibm,opal-firmware"); dt_add_property_string(firmware, "name", "firmware"); - dt_add_property_string(firmware, "git-id", gitid); + dt_add_property_string(firmware, "version", version); } void add_opal_node(void) diff --git a/hw/fsp/fsp-attn.c b/hw/fsp/fsp-attn.c index 755b95d..144b545 100644 --- a/hw/fsp/fsp-attn.c +++ b/hw/fsp/fsp-attn.c @@ -98,11 +98,11 @@ void update_sp_attn_area(const char *msg) ti_attn->src_word[0] = (uint32_t)((uint64_t)__builtin_return_address(0) & 0xffffffff); - snprintf(ti_attn->msg.gitid, GITID_LEN, "%s", gitid); + snprintf(ti_attn->msg.version, VERSION_LEN, "%s", version); __backtrace(ti_attn->msg.bt_buf, BT_FRAME_LEN); snprintf(ti_attn->msg.file_info, FILE_INFO_LEN, "%s", msg); - ti_attn->msg_len = GITID_LEN + BT_FRAME_LEN + + ti_attn->msg_len = VERSION_LEN + BT_FRAME_LEN + strlen(ti_attn->msg.file_info); } diff --git a/include/fsp-attn.h b/include/fsp-attn.h index 947c49f..1eaa5bb 100644 --- a/include/fsp-attn.h +++ b/include/fsp-attn.h @@ -59,14 +59,14 @@ struct sp_attn_area { #define TI_MSG_LEN 940 /* Maximum sapphire version length (approx) */ -#define GITID_LEN 40 +#define VERSION_LEN 80 /* Upto 10 frames each of length 40 bytes + header = 430 bytes */ #define BT_FRAME_LEN 430 /* File info length : Use the rest of the memory for file details */ -#define FILE_INFO_LEN (TI_MSG_LEN - GITID_LEN - BT_FRAME_LEN) +#define FILE_INFO_LEN (TI_MSG_LEN - VERSION_LEN - BT_FRAME_LEN) struct user_data { - char gitid[GITID_LEN]; + char version[VERSION_LEN]; char bt_buf[BT_FRAME_LEN]; char file_info[FILE_INFO_LEN]; } __packed; diff --git a/include/skiboot.h b/include/skiboot.h index 1a1f96f..b65475b 100644 --- a/include/skiboot.h +++ b/include/skiboot.h @@ -175,8 +175,8 @@ extern void parse_hdat(bool is_opal, uint32_t master_cpu); /* Root of device tree. */ extern struct dt_node *dt_root; -/* Generated git id. */ -extern const char gitid[]; +/* Full skiboot version number (possibly includes gitid). */ +extern const char version[]; /* Fast reboot support */ extern void fast_reset(void); diff --git a/make_version.sh b/make_version.sh new file mode 100755 index 0000000..1409704 --- /dev/null +++ b/make_version.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +if test -d .git; +then + version=`git describe --exact-match 2>/dev/null` + if [ -z "$version" ]; + then + version=`git describe 2>/dev/null` + fi + if [ -z "$version" ]; + then + version=`git rev-parse --verify --short HEAD 2>/dev/null` + fi + if [ ! -z "$EXTRA_VERSION" ]; + then + version="$version-$EXTRA_VERSION" + fi + if git diff-index --name-only HEAD |grep -qv '.git'; + then + if [ ! -z "$USER" ]; + then + version="$version-$USER" + fi + version="$version-dirty" + diffsha=`git diff|sha1sum` + diffsha=`cut -c-7 <<< "$diffsha"` + version="$version-$diffsha" + fi + + echo $version +else + if [ ! -z "$SKIBOOT_VERSION" ]; + then + echo $SKIBOOT_VERSION + else + exit 1; + fi +fi |