diff --git a/Docs/Configuration.pdf b/Docs/Configuration.pdf index 7c969d5df549e40f8e1203af9aacfb796a414902..e40907c623226e0fc71730cbefdaf761f6d7976b 100644 Binary files a/Docs/Configuration.pdf and b/Docs/Configuration.pdf differ diff --git a/Docs/Configuration.tex b/Docs/Configuration.tex index 2cd02e4abcc2f0b4dc7b2113b6bda0d175c994dd..1117b9aa8393846025dac0166f40219261dc9297 100644 --- a/Docs/Configuration.tex +++ b/Docs/Configuration.tex @@ -1422,6 +1422,13 @@ nvram 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:boot-log | awk '{gsub(/%0d%0a%00/,"");gsub(/%0d%0a/,"\n")}1' \end{lstlisting} + While OpenCore boot log already contains basic version information with build type and + date, this data may also be found in NVRAM in \texttt{opencore-version} variable + even with boot log disabled: +\begin{lstlisting}[label=nvramver, style=ocbash] +nvram 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:opencore-version +\end{lstlisting} + \emph{Note}: File logging is currently not implemented. \end{enumerate} diff --git a/Include/OpenCore.h b/Include/OpenCore.h index 5af23de8a8bc7cda1540e7fb7d01c7ad4d5cd2f4..8cb1883ee53d680fe77b9e67458c2fc398ebcf5f 100644 --- a/Include/OpenCore.h +++ b/Include/OpenCore.h @@ -18,11 +18,30 @@ #include #include #include +#include +#include #include #include -#define OPEN_CORE_VERSION L"0.1" +/** + OpenCore version reported to log and NVRAM. + OPEN_CORE_VERSION must follow X.Y.Z format, where X.Y.Z are single digits. +**/ +#define OPEN_CORE_VERSION "0.0.1" + +/** + OpenCore build type reported to log and NVRAM. +**/ +#if defined (OC_RELEASE_TARGET) +#define OPEN_CORE_TARGET "REL" ///< Release. +#elif defined (OC_DEBUG_TARGET) +#define OPEN_CORE_TARGET "DBG" ///< Debug with compiler optimisations. +#elif defined (OC_NOOPT_TARGET) +#define OPEN_CORE_TARGET "NPT" ///< Debug with no compiler optimisations. +#else +#define OPEN_CORE_TARGET "UNK" ///< This one should not happen in public builds. +#endif #define OPEN_CORE_IMAGE_PATH L"EFI\\OC\\OpenCore.efi" diff --git a/OpenCorePkg.dsc b/OpenCorePkg.dsc index 703ce7e8b5c4109de620b88bcfb4233b3fcf01d8..962cc804be842eef805bc4e1857e6b5bc0da3274 100755 --- a/OpenCorePkg.dsc +++ b/OpenCorePkg.dsc @@ -108,12 +108,12 @@ # While there are no PCDs as of now, there at least are some custom macros. DEFINE OCPKG_BUILD_OPTIONS_GEN = -D DISABLE_NEW_DEPRECATED_INTERFACES $(OCPKG_BUILD_OPTIONS) - GCC:DEBUG_*_*_CC_FLAGS = $(OCPKG_BUILD_OPTIONS_GEN) - GCC:NOOPT_*_*_CC_FLAGS = $(OCPKG_BUILD_OPTIONS_GEN) - GCC:RELEASE_*_*_CC_FLAGS = $(OCPKG_BUILD_OPTIONS_GEN) - MSFT:DEBUG_*_*_CC_FLAGS = $(OCPKG_BUILD_OPTIONS_GEN) - MSFT:NOOPT_*_*_CC_FLAGS = $(OCPKG_BUILD_OPTIONS_GEN) - MSFT:RELEASE_*_*_CC_FLAGS = $(OCPKG_BUILD_OPTIONS_GEN) - XCODE:DEBUG_*_*_CC_FLAGS = $(OCPKG_BUILD_OPTIONS_GEN) - XCODE:NOOPT_*_*_CC_FLAGS = $(OCPKG_BUILD_OPTIONS_GEN) - XCODE:RELEASE_*_*_CC_FLAGS = -flto $(OCPKG_BUILD_OPTIONS_GEN) + GCC:DEBUG_*_*_CC_FLAGS = $(OCPKG_BUILD_OPTIONS_GEN) -D OC_DEBUG_TARGET + GCC:NOOPT_*_*_CC_FLAGS = $(OCPKG_BUILD_OPTIONS_GEN) -D OC_NOOPT_TARGET + GCC:RELEASE_*_*_CC_FLAGS = $(OCPKG_BUILD_OPTIONS_GEN) -D OC_RELEASE_TARGET + MSFT:DEBUG_*_*_CC_FLAGS = $(OCPKG_BUILD_OPTIONS_GEN) -D OC_DEBUG_TARGET + MSFT:NOOPT_*_*_CC_FLAGS = $(OCPKG_BUILD_OPTIONS_GEN) -D OC_NOOPT_TARGET + MSFT:RELEASE_*_*_CC_FLAGS = $(OCPKG_BUILD_OPTIONS_GEN) -D OC_RELEASE_TARGET + XCODE:DEBUG_*_*_CC_FLAGS = $(OCPKG_BUILD_OPTIONS_GEN) -D OC_DEBUG_TARGET + XCODE:NOOPT_*_*_CC_FLAGS = $(OCPKG_BUILD_OPTIONS_GEN) -D OC_NOOPT_TARGET + XCODE:RELEASE_*_*_CC_FLAGS = -flto $(OCPKG_BUILD_OPTIONS_GEN) -D OC_RELEASE_TARGET diff --git a/Platform/OpenCore/OpenCoreNvram.c b/Platform/OpenCore/OpenCoreNvram.c index cda725b369acdfa9d70200856cbd673c80079a2c..0b3aee54d8bcbde3f5c990adfdd2e1777f488e75 100644 --- a/Platform/OpenCore/OpenCoreNvram.c +++ b/Platform/OpenCore/OpenCoreNvram.c @@ -14,6 +14,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include +#include + #include #include #include @@ -23,6 +25,79 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include +// +// Force the assertions in case we forget about them. +// +OC_GLOBAL_STATIC_ASSERT ( + L_STR_LEN (OPEN_CORE_VERSION) == 5, + "OPEN_CORE_VERSION must follow X.Y.Z format, where X.Y.Z are single digits." + ); + +OC_GLOBAL_STATIC_ASSERT ( + L_STR_LEN (OPEN_CORE_TARGET) == 3, + "OPEN_CORE_TARGET must XYZ format, where XYZ is build target." + ); + +STATIC CHAR8 mOpenCoreVersion[] = { + /* [0] = */ OPEN_CORE_TARGET[0], + /* [1] = */ OPEN_CORE_TARGET[1], + /* [2] = */ OPEN_CORE_TARGET[2], + /* [3] = */ '-', + /* [4] = */ OPEN_CORE_VERSION[0], + /* [5] = */ OPEN_CORE_VERSION[2], + /* [6] = */ OPEN_CORE_VERSION[4], + /* [7] = */ '-', + /* [8] = */ __DATE__[7], + /* [9] = */ __DATE__[8], + /* [10] = */ __DATE__[9], + /* [11] = */ __DATE__[10], + /* [12] = */ '-', + /* [13] = */ 'M', + /* [14] = */ 'M', + /* [15] = */ '-', + /* [16] = */ 'D', + /* [17] = */ 'D', + /* [18] = */ '\0' +}; + +STATIC +VOID +OcReportVersion ( + VOID + ) +{ + UINT32 Month; + + Month = + (__DATE__[0] == 'J' && __DATE__[1] == 'a' && __DATE__[2] == 'n') ? 1 : + (__DATE__[0] == 'F' && __DATE__[2] == 'e' && __DATE__[2] == 'b') ? 2 : + (__DATE__[0] == 'M' && __DATE__[1] == 'a' && __DATE__[2] == 'r') ? 3 : + (__DATE__[0] == 'A' && __DATE__[1] == 'p' && __DATE__[2] == 'r') ? 4 : + (__DATE__[0] == 'M' && __DATE__[1] == 'a' && __DATE__[2] == 'y') ? 5 : + (__DATE__[0] == 'J' && __DATE__[1] == 'u' && __DATE__[2] == 'n') ? 6 : + (__DATE__[0] == 'J' && __DATE__[1] == 'u' && __DATE__[2] == 'l') ? 7 : + (__DATE__[0] == 'A' && __DATE__[1] == 'u' && __DATE__[2] == 'g') ? 8 : + (__DATE__[0] == 'S' && __DATE__[1] == 'e' && __DATE__[2] == 'p') ? 9 : + (__DATE__[0] == 'O' && __DATE__[1] == 'c' && __DATE__[2] == 't') ? 10 : + (__DATE__[0] == 'N' && __DATE__[1] == 'o' && __DATE__[2] == 'v') ? 11 : + (__DATE__[0] == 'D' && __DATE__[1] == 'e' && __DATE__[2] == 'c') ? 12 : 0; + + mOpenCoreVersion[13] = Month < 10 ? '0' : '1'; + mOpenCoreVersion[14] = '0' + (Month % 10); + mOpenCoreVersion[16] = __DATE__[4] >= '0' ? __DATE__[4] : '0'; + mOpenCoreVersion[17] = __DATE__[5]; + + DEBUG ((DEBUG_INFO, "OC: Current version is %a\n", mOpenCoreVersion)); + + gRT->SetVariable ( + OC_VERSION_VARIABLE_NAME, + &gOcVendorVariableGuid, + OPEN_CORE_NVRAM_ATTR, + sizeof (mOpenCoreVersion), + &mOpenCoreVersion[0] + ); +} + VOID OcLoadNvramSupport ( IN OC_GLOBAL_CONFIG *Config @@ -143,4 +218,6 @@ OcLoadNvramSupport ( FreePool (UnicodeVariableName); } } + + OcReportVersion (); }