summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPali Rohár <pali@kernel.org>2021-04-22 19:09:57 +0300
committerHeinrich Schuchardt <xypron.glpk@gmx.de>2021-07-24 11:49:51 +0300
commit11275e4f72d6d2170db444df95e8f6b6ab627e8e (patch)
treeda36270ae78a7b31b6edf627f56faf64f8e5868e
parent1364029263a34924fa9bb7126a436d3ed562b7e7 (diff)
downloadu-boot-11275e4f72d6d2170db444df95e8f6b6ab627e8e.tar.xz
smbios: Fix calculating BIOS Release Date
BIOS Release Date must be in format mm/dd/yyyy and must be release date. U-Boot currently sets BIOS Release Date from U_BOOT_DMI_DATE macro which is generated from current build timestamp. Fix this issue by setting U_BOOT_DMI_DATE macro to U-Boot version which is better approximation of U-Boot release date than current build timestamp. Current U-Boot versioning is in format yyyy.mm so as a day choose 01. Some operating systems are using BIOS Release Date for detecting when was SMBIOS table filled or if it could support some feature (e.g. BIOS from 1990 cannot support features invented in 2000). So this change also ensures that recompiling U-Boot from same sources but in different year does not change behavior of some operating systems. Macro U_BOOT_DMI_DATE is not used in other file than lib/smbios.c so remove it from global autogenerated files and also from Makefile. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r--Makefile2
-rw-r--r--doc/develop/version.rst1
-rw-r--r--lib/smbios.c23
3 files changed, 23 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index ca2432c8ce..281b81d6cd 100644
--- a/Makefile
+++ b/Makefile
@@ -1905,7 +1905,6 @@ define filechk_timestamp.h
LC_ALL=C $${DATE} -u -d "$${SOURCE_DATE}" +'#define U_BOOT_DATE "%b %d %C%y"'; \
LC_ALL=C $${DATE} -u -d "$${SOURCE_DATE}" +'#define U_BOOT_TIME "%T"'; \
LC_ALL=C $${DATE} -u -d "$${SOURCE_DATE}" +'#define U_BOOT_TZ "%z"'; \
- LC_ALL=C $${DATE} -u -d "$${SOURCE_DATE}" +'#define U_BOOT_DMI_DATE "%m/%d/%Y"'; \
LC_ALL=C $${DATE} -u -d "$${SOURCE_DATE}" +'#define U_BOOT_BUILD_DATE 0x%Y%m%d'; \
LC_ALL=C $${DATE} -u -d "$${SOURCE_DATE}" +'#define U_BOOT_EPOCH %s'; \
else \
@@ -1915,7 +1914,6 @@ define filechk_timestamp.h
LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"'; \
LC_ALL=C date +'#define U_BOOT_TIME "%T"'; \
LC_ALL=C date +'#define U_BOOT_TZ "%z"'; \
- LC_ALL=C date +'#define U_BOOT_DMI_DATE "%m/%d/%Y"'; \
LC_ALL=C date +'#define U_BOOT_BUILD_DATE 0x%Y%m%d'; \
LC_ALL=C date +'#define U_BOOT_EPOCH %s'; \
fi)
diff --git a/doc/develop/version.rst b/doc/develop/version.rst
index a7797db41b..066901bcd2 100644
--- a/doc/develop/version.rst
+++ b/doc/develop/version.rst
@@ -84,7 +84,6 @@ fields. For example::
#define U_BOOT_DATE "Jan 06 2021" (US format only)
#define U_BOOT_TIME "08:50:36" (24-hour clock)
#define U_BOOT_TZ "-0700" (Time zone in hours)
- #define U_BOOT_DMI_DATE "01/06/2021" (US format only)
#define U_BOOT_BUILD_DATE 0x20210106 (hex yyyymmdd format)
#define U_BOOT_EPOCH 1609948236
diff --git a/lib/smbios.c b/lib/smbios.c
index b52e125eeb..a892716d15 100644
--- a/lib/smbios.c
+++ b/lib/smbios.c
@@ -8,6 +8,7 @@
#include <common.h>
#include <dm.h>
#include <env.h>
+#include <linux/stringify.h>
#include <mapmem.h>
#include <smbios.h>
#include <sysinfo.h>
@@ -18,6 +19,28 @@
#include <dm/uclass-internal.h>
#endif
+/* Safeguard for checking that U_BOOT_VERSION_NUM macros are compatible with U_BOOT_DMI */
+#if U_BOOT_VERSION_NUM < 2000 || U_BOOT_VERSION_NUM > 2099 || \
+ U_BOOT_VERSION_NUM_PATCH < 1 || U_BOOT_VERSION_NUM_PATCH > 12
+#error U_BOOT_VERSION_NUM macros are not compatible with DMI, fix U_BOOT_DMI macros
+#endif
+
+/*
+ * U_BOOT_DMI_DATE contains BIOS Release Date in format mm/dd/yyyy.
+ * BIOS Release Date is calculated from U-Boot version and fixed day 01.
+ * So for U-Boot version 2021.04 it is calculated as "04/01/2021".
+ * BIOS Release Date should contain date when code was released
+ * and not when it was built or compiled.
+ */
+#if U_BOOT_VERSION_NUM_PATCH < 10
+#define U_BOOT_DMI_MONTH "0" __stringify(U_BOOT_VERSION_NUM_PATCH)
+#else
+#define U_BOOT_DMI_MONTH __stringify(U_BOOT_VERSION_NUM_PATCH)
+#endif
+#define U_BOOT_DMI_DAY "01"
+#define U_BOOT_DMI_YEAR __stringify(U_BOOT_VERSION_NUM)
+#define U_BOOT_DMI_DATE U_BOOT_DMI_MONTH "/" U_BOOT_DMI_DAY "/" U_BOOT_DMI_YEAR
+
DECLARE_GLOBAL_DATA_PTR;
/**