version.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /*++
  2. Copyright (c) 2014 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. version.c
  5. Abstract:
  6. This module implements support for returning the firmware version
  7. information.
  8. Author:
  9. Evan Green 26-Feb-2014
  10. Environment:
  11. Boot
  12. --*/
  13. //
  14. // ------------------------------------------------------------------- Includes
  15. //
  16. #include "ueficore.h"
  17. #include "version.h"
  18. //
  19. // --------------------------------------------------------------------- Macros
  20. //
  21. //
  22. // ---------------------------------------------------------------- Definitions
  23. //
  24. //
  25. // Define the system version information.
  26. //
  27. #define PRODUCT_NAME "Minoca UEFI Firmware"
  28. #ifndef VERSION_RELEASE
  29. #define VERSION_RELEASE SystemReleaseDevelopment
  30. #endif
  31. #ifdef DEBUG
  32. #define VERSION_DEBUG SystemBuildChecked
  33. #else
  34. #define VERSION_DEBUG SystemBuildFree
  35. #endif
  36. #ifndef VERSION_MAJOR
  37. #define VERSION_MAJOR 0
  38. #define VERSION_MINOR 0
  39. #define VERSION_REVISION 0
  40. #endif
  41. #ifndef VERSION_SERIAL
  42. #define VERSION_SERIAL 0
  43. #endif
  44. #ifndef VERSION_BUILD_TIME
  45. #define VERSION_BUILD_TIME 0
  46. #endif
  47. #ifndef VERSION_BUILD_STRING
  48. #define VERSION_BUILD_STRING ""
  49. #endif
  50. //
  51. // ------------------------------------------------------ Data Type Definitions
  52. //
  53. //
  54. // ----------------------------------------------- Internal Function Prototypes
  55. //
  56. //
  57. // -------------------------------------------------------------------- Globals
  58. //
  59. UINT16 EfiVersionMajor = VERSION_MAJOR;
  60. UINT16 EfiVersionMinor = VERSION_MINOR;
  61. UINT16 EfiVersionRevision = VERSION_REVISION;
  62. UINT8 EfiVersionRelease = VERSION_RELEASE;
  63. UINT32 EfiVersionSerial = VERSION_SERIAL;
  64. UINT32 EfiBuildTime = VERSION_BUILD_TIME;
  65. CHAR8 *EfiBuildString = VERSION_BUILD_STRING;
  66. CHAR8 *EfiProductName = PRODUCT_NAME;
  67. CHAR8 *EfiBuildTimeString = VERSION_BUILD_TIME_STRING;
  68. //
  69. // ------------------------------------------------------------------ Functions
  70. //
  71. KSTATUS
  72. KeGetSystemVersion (
  73. PSYSTEM_VERSION_INFORMATION VersionInformation,
  74. PVOID Buffer,
  75. PULONG BufferSize
  76. )
  77. /*++
  78. Routine Description:
  79. This routine gets the system version information.
  80. Arguments:
  81. VersionInformation - Supplies a pointer where the system version
  82. information will be returned.
  83. Buffer - Supplies an optional pointer to the buffer to use for the
  84. product name and build string.
  85. BufferSize - Supplies an optional pointer that on input contains the size
  86. of the supplied string buffer in bytes. On output, returns the needed
  87. size of the build string buffer in bytes including the null terminator
  88. characters.
  89. Return Value:
  90. STATUS_SUCCESS on success.
  91. STATUS_BUFFER_TOO_SMALL if the supplied buffer was not big enough to hold
  92. both strings.
  93. --*/
  94. {
  95. ULONG BuildStringSize;
  96. ULONG ProductNameSize;
  97. KSTATUS Status;
  98. Status = STATUS_SUCCESS;
  99. VersionInformation->MajorVersion = EfiVersionMajor;
  100. VersionInformation->MinorVersion = EfiVersionMinor;
  101. VersionInformation->Revision = EfiVersionRevision;
  102. VersionInformation->SerialVersion = EfiVersionSerial;
  103. VersionInformation->ReleaseLevel = EfiVersionRelease;
  104. VersionInformation->DebugLevel = VERSION_DEBUG;
  105. VersionInformation->BuildTime.Seconds = EfiBuildTime;
  106. VersionInformation->BuildTime.Nanoseconds = 0;
  107. VersionInformation->ProductName = NULL;
  108. VersionInformation->BuildString = NULL;
  109. BuildStringSize = RtlStringLength(EfiBuildString);
  110. if (BuildStringSize != 0) {
  111. BuildStringSize += 1;
  112. }
  113. ProductNameSize = RtlStringLength(EfiProductName) + 1;
  114. if ((BufferSize != NULL) && (Buffer != NULL)) {
  115. if (*BufferSize < BuildStringSize + ProductNameSize) {
  116. Status = STATUS_BUFFER_TOO_SMALL;
  117. } else {
  118. RtlCopyMemory(Buffer, EfiProductName, ProductNameSize);
  119. VersionInformation->ProductName = Buffer;
  120. if (BuildStringSize != 0) {
  121. VersionInformation->BuildString = Buffer + ProductNameSize;
  122. RtlCopyMemory(VersionInformation->BuildString,
  123. EfiBuildString,
  124. BuildStringSize);
  125. }
  126. }
  127. }
  128. if (BufferSize != NULL) {
  129. *BufferSize = BuildStringSize + ProductNameSize;
  130. }
  131. return Status;
  132. }
  133. //
  134. // --------------------------------------------------------- Internal Functions
  135. //