version: Update version handling and code

The kernel version has been converted from a string to a four-byte
quantity that is divided into two parts.
Part 1: The three most significant bytes represent the kernel's
numeric version, x.y.z. These fields denote:
      x -- major release
      y -- minor release
      z -- patchlevel release
Each of these elements must therefore be in the range 0 to 256, inclusive.

Part 2: The least significant byte is reserved for future use.

EXTRAVERSION is used for intermediate releases and customised
builds on top of an existing/released version.

Change-Id: Ibb7dd5654c36daeaa3a53499857d254aaef25bdf
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
Anas Nashif 2015-06-23 18:52:06 -04:00
commit c61820bdf8
2 changed files with 16 additions and 29 deletions

View file

@ -1,10 +1,8 @@
VERSION_GENERATION = 2
VERSION_MAJOR = 2
VERSION_MINOR = 3
VERSION_REVISION = 0
VERSION_PATCHLEVEL = 0
VERSION_RESERVED = 0
PATCHLEVEL = 0
SUBLEVEL = 0
EXTRAVERSION =
NAME = Zephyr Kernel
export SOURCE_DIR PROJECT MDEF_FILE KLIBC_DIR
@ -385,10 +383,10 @@ LDFLAGS += $(call ld-option,-nostdlib)
LDFLAGS += $(call ld-option,-static)
LDLIBS_TOOLCHAIN ?= -lgcc
KERNELVERSION = $(VERSION_GENERATION).$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_REVISION)
KERNELVERSION = $(VERSION_MAJOR)$(if $(VERSION_MINOR),.$(VERSION_MINOR)$(if $(VERSION_PATCHLEVEL),.$(VERSION_PATCHLEVEL)))$(VERSION_EXTRAVERSION)
export VERSION_GENERATION VERSION_MAJOR VERSION_MINOR VERSION_REVISION VERSION_RESERVED
export PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
export VERSION_MAJOR VERSION_MINOR VERSION_PATCHLEVEL VERSION_RESERVED EXTRAVERSION
export KERNELRELEASE KERNELVERSION
export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC
export CPP AR NM STRIP OBJCOPY OBJDUMP
export MAKE AWK GENKSYMS INSTALLKERNEL PERL PYTHON UTS_MACHINE GENIDT
@ -868,13 +866,12 @@ prepare: $(archprepare) FORCE
# KERNELRELEASE can change from a few different places, meaning version.h
# needs to be updated, so this check is forced on all builds
VERSION_GENERATION_HEX=$(shell echo "obase=16; ${VERSION_GENERATION}" | bc)
VERSION_MAJOR_HEX=$(shell echo "obase=16; ${VERSION_MAJOR}" | bc)
VERSION_MINOR_HEX=$(shell echo "obase=16; ${VERSION_MINOR}" | bc)
VERSION_REVISION_HEX=$(shell echo "obase=16; ${VERSION_REVISION}" | bc)
VERSION_PATCHLEVEL_HEX=$(shell echo "obase=16; ${VERSION_PATCHLEVEL}" | bc)
KERNEL_FLAGS=00
VERSION_RESERVED_HEX=00
KERNEL_VERSION_HEX=0x$(VERSION_GENERATION_HEX)$(VERSION_MAJOR_HEX)$(VERSION_MINOR_HEX)$(VERSION_REVISION_HEX)
KERNEL_VERSION_HEX=0x$(VERSION_MAJOR_HEX)$(VERSION_MINOR_HEX)$(VERSION_PATCHLEVEL_HEX)
define filechk_version.h
(echo "#ifndef _KERNEL_VERSION_H_"; \
@ -883,10 +880,9 @@ define filechk_version.h
echo -n "#define KERNELVERSION "; \
echo "$(KERNEL_VERSION_HEX)$(KERNEL_FLAGS)$(VERSION_RESERVED_HEX)"; \
echo "#define KERNEL_VERSION_NUMBER $(KERNEL_VERSION_HEX)"; \
echo "#define KERNEL_VERSION_GENERATION $(VERSION_GENERATION)"; \
echo "#define KERNEL_VERSION_MAJOR $(VERSION_MAJOR)"; \
echo "#define KERNEL_VERSION_MINOR $(VERSION_MINOR)"; \
echo "#define KERNEL_VERSION_REVISION $(VERSION_REVISION)"; \
echo "#define KERNEL_VERSION_PATCHLEVEL $(VERSION_PATCHLEVEL)"; \
echo "#define KERNEL_VERSION_STRING \"$(KERNELVERSION)\""; \
echo; \
echo "#endif /* _KERNEL_VERSION_H_ */";)

View file

@ -35,29 +35,20 @@
/*
* The kernel version has been converted from a string to a four-byte
* quantity that is divided into three parts.
* quantity that is divided into two parts.
*
* Part 1: The two most significant bytes are sub-divided into four nibbles,
* representing the kernel's numeric version, w.x.y.z. These fields denote:
* w -- generation release number
* Part 1: The three most significant bytes represent the kernel's
* numeric version, x.y.z. These fields denote:
* x -- major release
* y -- minor release
* z -- servicepack release
* Each of these elements must therefore be in the range 0 to 15, inclusive.
* z -- patchlevel release
* Each of these elements must therefore be in the range 0 to 256, inclusive.
*
* Part 2: The next most significant byte is used for a variety of flags and is
* broken down as follows:
* Bits 7..0 - Cleared as the are currently unused.
*
* Part 3: The least significant byte is reserved for future use.
* Part 2: The least significant byte is reserved for future use.
*/
#define SYS_KERNEL_VER_GENERATION(ver) ((ver >> 28) & 0x0F)
#define SYS_KERNEL_VER_MAJOR(ver) ((ver >> 24) & 0x0F)
#define SYS_KERNEL_VER_MINOR(ver) ((ver >> 20) & 0x0F)
#define SYS_KERNEL_VER_SERVICEPACK(ver) ((ver >> 16) & 0x0F)
/* return 8-bit flags */
#define SYS_KERNEL_VER_FLAGS(ver) ((ver >> 8) & 0xFF)
#define SYS_KERNEL_VER_MINOR(ver) ((ver >> 16) & 0x0F)
#define SYS_KERNEL_VER_PATCHLEVEL(ver) ((ver >> 8) & 0x0F)
/* kernel version routines */