AcpiViewConfig.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. /** @file
  2. State and accessors for 'acpiview' configuration.
  3. Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include <Library/BaseMemoryLib.h>
  7. #include <Library/DebugLib.h>
  8. #include "AcpiViewConfig.h"
  9. // Report variables
  10. STATIC BOOLEAN mConsistencyCheck;
  11. STATIC BOOLEAN mColourHighlighting;
  12. STATIC EREPORT_OPTION mReportType;
  13. STATIC BOOLEAN mMandatoryTableValidate;
  14. STATIC UINTN mMandatoryTableSpec;
  15. // User selection of which ACPI table should be checked
  16. SELECTED_ACPI_TABLE mSelectedAcpiTable;
  17. /**
  18. Reset the AcpiView user configuration to defaults
  19. **/
  20. VOID
  21. EFIAPI
  22. AcpiConfigSetDefaults (
  23. VOID
  24. )
  25. {
  26. mReportType = ReportAll;
  27. mSelectedAcpiTable.Type = 0;
  28. mSelectedAcpiTable.Name = NULL;
  29. mSelectedAcpiTable.Found = FALSE;
  30. mConsistencyCheck = TRUE;
  31. mMandatoryTableValidate = FALSE;
  32. mMandatoryTableSpec = 0;
  33. }
  34. /**
  35. This function converts a string to ACPI table signature.
  36. @param [in] Str Pointer to the string to be converted to the
  37. ACPI table signature.
  38. @retval The ACPI table signature.
  39. **/
  40. STATIC
  41. UINT32
  42. ConvertStrToAcpiSignature (
  43. IN CONST CHAR16 *Str
  44. )
  45. {
  46. UINT8 Index;
  47. CHAR8 Ptr[4];
  48. ZeroMem (Ptr, sizeof (Ptr));
  49. Index = 0;
  50. // Convert to Upper case and convert to ASCII
  51. while ((Index < 4) && (Str[Index] != 0)) {
  52. if ((Str[Index] >= L'a') && (Str[Index] <= L'z')) {
  53. Ptr[Index] = (CHAR8)(Str[Index] - (L'a' - L'A'));
  54. } else {
  55. Ptr[Index] = (CHAR8)Str[Index];
  56. }
  57. Index++;
  58. }
  59. return *(UINT32 *)Ptr;
  60. }
  61. /**
  62. This function selects an ACPI table in current context.
  63. The string name of the table is converted into UINT32
  64. table signature.
  65. @param [in] TableName The name of the ACPI table to select.
  66. **/
  67. VOID
  68. EFIAPI
  69. SelectAcpiTable (
  70. IN CONST CHAR16 *TableName
  71. )
  72. {
  73. ASSERT (TableName != NULL);
  74. mSelectedAcpiTable.Name = TableName;
  75. mSelectedAcpiTable.Type = ConvertStrToAcpiSignature (mSelectedAcpiTable.Name);
  76. }
  77. /**
  78. This function returns the selected ACPI table.
  79. @param [out] SelectedAcpiTable Pointer that will contain the returned struct.
  80. **/
  81. VOID
  82. EFIAPI
  83. GetSelectedAcpiTable (
  84. OUT SELECTED_ACPI_TABLE **SelectedAcpiTable
  85. )
  86. {
  87. *SelectedAcpiTable = &mSelectedAcpiTable;
  88. }
  89. /**
  90. This function returns the colour highlighting status.
  91. @retval TRUE Colour highlighting is enabled.
  92. **/
  93. BOOLEAN
  94. EFIAPI
  95. GetColourHighlighting (
  96. VOID
  97. )
  98. {
  99. return mColourHighlighting;
  100. }
  101. /**
  102. This function sets the colour highlighting status.
  103. @param [in] Highlight The highlight status.
  104. **/
  105. VOID
  106. EFIAPI
  107. SetColourHighlighting (
  108. BOOLEAN Highlight
  109. )
  110. {
  111. mColourHighlighting = Highlight;
  112. }
  113. /**
  114. This function returns the consistency checking status.
  115. @retval TRUE Consistency checking is enabled.
  116. **/
  117. BOOLEAN
  118. EFIAPI
  119. GetConsistencyChecking (
  120. VOID
  121. )
  122. {
  123. return mConsistencyCheck;
  124. }
  125. /**
  126. This function sets the consistency checking status.
  127. @param [in] ConsistencyChecking The consistency checking status.
  128. **/
  129. VOID
  130. EFIAPI
  131. SetConsistencyChecking (
  132. BOOLEAN ConsistencyChecking
  133. )
  134. {
  135. mConsistencyCheck = ConsistencyChecking;
  136. }
  137. /**
  138. This function returns the report options.
  139. @return The current report option.
  140. **/
  141. EREPORT_OPTION
  142. EFIAPI
  143. GetReportOption (
  144. VOID
  145. )
  146. {
  147. return mReportType;
  148. }
  149. /**
  150. This function sets the report options.
  151. @param [in] ReportType The report option to set.
  152. **/
  153. VOID
  154. EFIAPI
  155. SetReportOption (
  156. EREPORT_OPTION ReportType
  157. )
  158. {
  159. mReportType = ReportType;
  160. }
  161. /**
  162. This function returns the ACPI table requirements validation flag.
  163. @retval TRUE Check for mandatory table presence should be performed.
  164. **/
  165. BOOLEAN
  166. EFIAPI
  167. GetMandatoryTableValidate (
  168. VOID
  169. )
  170. {
  171. return mMandatoryTableValidate;
  172. }
  173. /**
  174. This function sets the ACPI table requirements validation flag.
  175. @param [in] Validate Enable/Disable ACPI table requirements validation.
  176. **/
  177. VOID
  178. EFIAPI
  179. SetMandatoryTableValidate (
  180. BOOLEAN Validate
  181. )
  182. {
  183. mMandatoryTableValidate = Validate;
  184. }
  185. /**
  186. This function returns the identifier of specification to validate ACPI table
  187. requirements against.
  188. @return ID of specification listing mandatory tables.
  189. **/
  190. UINTN
  191. EFIAPI
  192. GetMandatoryTableSpec (
  193. VOID
  194. )
  195. {
  196. return mMandatoryTableSpec;
  197. }
  198. /**
  199. This function sets the identifier of specification to validate ACPI table
  200. requirements against.
  201. @param [in] Spec ID of specification listing mandatory tables.
  202. **/
  203. VOID
  204. EFIAPI
  205. SetMandatoryTableSpec (
  206. UINTN Spec
  207. )
  208. {
  209. mMandatoryTableSpec = Spec;
  210. }