ConfigurationManager.c 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834
  1. /** @file
  2. Configuration Manager Dxe
  3. Copyright 2020 NXP
  4. Copyright 2020 Puresoftware Ltd
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. @par Glossary:
  7. - Cm or CM - Configuration Manager
  8. - Obj or OBJ - Object
  9. **/
  10. #include <IndustryStandard/MemoryMappedConfigurationSpaceAccessTable.h>
  11. #include <IndustryStandard/SerialPortConsoleRedirectionTable.h>
  12. #include <Library/ArmLib.h>
  13. #include <Library/DebugLib.h>
  14. #include <Library/IoLib.h>
  15. #include <Library/PcdLib.h>
  16. #include <Library/UefiBootServicesTableLib.h>
  17. #include <Protocol/AcpiTable.h>
  18. #include <Protocol/ConfigurationManagerProtocol.h>
  19. /** The platform specific headers
  20. */
  21. #include "ConfigurationManager.h"
  22. #include <Library/SocLib.h>
  23. /** The platform configuration repository information.
  24. */
  25. STATIC
  26. FSL_PLATFORM_REPOSITORY_INFO FslPlatformRepositoryInfo = {
  27. /// Configuration Manager information
  28. { CONFIGURATION_MANAGER_REVISION, CFG_MGR_OEM_ID },
  29. // ACPI Table List
  30. {
  31. // FADT Table
  32. {
  33. EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,
  34. EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_REVISION,
  35. CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdFadt),
  36. NULL,
  37. CFG_MGR_TABLE_ID
  38. },
  39. // GTDT Table
  40. {
  41. EFI_ACPI_6_2_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE,
  42. EFI_ACPI_6_2_GENERIC_TIMER_DESCRIPTION_TABLE_REVISION,
  43. CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdGtdt),
  44. NULL,
  45. CFG_MGR_TABLE_ID
  46. },
  47. // MADT Table
  48. {
  49. EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE,
  50. EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION,
  51. CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdMadt),
  52. NULL,
  53. CFG_MGR_TABLE_ID
  54. },
  55. // PCI MCFG Table
  56. {
  57. EFI_ACPI_6_2_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE,
  58. EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_SPACE_ACCESS_TABLE_REVISION,
  59. CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdMcfg),
  60. NULL,
  61. CFG_MGR_TABLE_ID
  62. },
  63. // SPCR Table
  64. {
  65. EFI_ACPI_6_2_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE,
  66. EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_REVISION,
  67. CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdSpcr),
  68. NULL,
  69. CFG_MGR_TABLE_ID
  70. }
  71. },
  72. // Boot architecture information
  73. { EFI_ACPI_6_2_ARM_PSCI_COMPLIANT }, // BootArchFlags
  74. // Power management profile information
  75. { EFI_ACPI_6_2_PM_PROFILE_ENTERPRISE_SERVER }, // PowerManagement Profile
  76. // Generic Timer Info
  77. {
  78. // The physical base address for the counter control frame
  79. TIMER_BASE_ADDRESS,
  80. // The physical base address for the counter read frame
  81. TIMER_READ_BASE_ADDRESS,
  82. // The secure PL1 timer interrupt
  83. TIMER_SEC_IT,
  84. // The secure PL1 timer flags
  85. GTDT_GTIMER_FLAGS,
  86. // The non-secure PL1 timer interrupt
  87. TIMER_NON_SEC_IT,
  88. // The non-secure PL1 timer flags
  89. GTDT_GTIMER_FLAGS,
  90. // The virtual timer interrupt
  91. TIMER_VIRT_IT,
  92. // The virtual timer flags
  93. GTDT_GTIMER_FLAGS,
  94. // The non-secure PL2 timer interrupt
  95. TIMER_HYP_IT,
  96. // The non-secure PL2 timer flags
  97. GTDT_GTIMER_FLAGS
  98. },
  99. // Generic Timer Block Information
  100. PLAT_TIMER_BLOCK_INFO,
  101. // GTDT Frames
  102. PLAT_TIMER_FRAME_INFO,
  103. // Watchdog info
  104. PLAT_WATCHDOG_INFO,
  105. // GIC CPU Interface information
  106. PLAT_GIC_CPU_INTERFACE,
  107. // GIC Distributor Info
  108. PLAT_GIC_DISTRIBUTOR_INFO,
  109. // GIC Redistributor
  110. PLAT_GIC_REDISTRIBUTOR_INFO,
  111. // GIC ITS
  112. PLAT_GIC_ITS_INFO,
  113. // MCFG Info
  114. PLAT_MCFG_INFO,
  115. // SPCR Info
  116. PLAT_SPCR_INFO,
  117. 2.0 // fsl board revision
  118. };
  119. /** Initialize the platform configuration repository.
  120. @param [in] This Pointer to the Configuration Manager Protocol.
  121. @retval EFI_SUCCESS Success
  122. **/
  123. STATIC
  124. EFI_STATUS
  125. EFIAPI
  126. InitializePlatformRepository (
  127. IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST This
  128. )
  129. {
  130. FSL_PLATFORM_REPOSITORY_INFO * PlatformRepo;
  131. UINT32 Svr;
  132. PlatformRepo = This->PlatRepoInfo;
  133. Svr = SocGetSvr ();
  134. if (SVR_SOC_VER(Svr) == SVR_LX2160A) {
  135. PlatformRepo->FslBoardRevision = SVR_MAJOR(Svr);
  136. DEBUG ((DEBUG_INFO, "Fsl : SoC LX2160A Rev = 0x%x\n", PlatformRepo->FslBoardRevision));
  137. } else {
  138. DEBUG ((DEBUG_INFO, "Fsl : SoC Unknown Rev = 0x%x\n", PlatformRepo->FslBoardRevision));
  139. }
  140. return EFI_SUCCESS;
  141. }
  142. /** Return PCI Configuration Info.
  143. @param [in] This Pointer to the Configuration Manager Protocol.
  144. @param [in] CmObjectId The Object ID of the CM object requested
  145. @param [in] Token A unique token for identifying the requested
  146. CM_ARM_PCI_INFO object.
  147. @param [in, out] CmObject Pointer to the Configuration Manager Object
  148. descriptor describing the requested Object.
  149. @retval EFI_SUCCESS Success.
  150. @retval EFI_INVALID_PARAMETER A parameter is invalid.
  151. @retval EFI_NOT_FOUND The required object information is
  152. not found.
  153. **/
  154. EFI_STATUS
  155. EFIAPI
  156. GetPciConfigInfo (
  157. IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST This,
  158. IN CONST CM_OBJECT_ID CmObjectId,
  159. IN CONST CM_OBJECT_TOKEN Token,
  160. IN OUT CM_OBJ_DESCRIPTOR * CONST CmObject
  161. )
  162. {
  163. FSL_PLATFORM_REPOSITORY_INFO * PlatformRepo;
  164. UINT32 TotalObjCount;
  165. UINT32 ObjIndex;
  166. if ((This == NULL) || (CmObject == NULL)) {
  167. ASSERT (This != NULL);
  168. ASSERT (CmObject != NULL);
  169. return EFI_INVALID_PARAMETER;
  170. }
  171. PlatformRepo = This->PlatRepoInfo;
  172. TotalObjCount = ARRAY_SIZE (PlatformRepo->PciConfigInfo);
  173. for (ObjIndex = 0; ObjIndex < TotalObjCount; ObjIndex++) {
  174. if (Token == (CM_OBJECT_TOKEN)&PlatformRepo->PciConfigInfo[ObjIndex])
  175. {
  176. CmObject->ObjectId = CmObjectId;
  177. CmObject->Size = sizeof (PlatformRepo->PciConfigInfo[ObjIndex]);
  178. CmObject->Data = (VOID*)&PlatformRepo->PciConfigInfo[ObjIndex];
  179. CmObject->Count = 1;
  180. return EFI_SUCCESS;
  181. }
  182. }
  183. return EFI_NOT_FOUND;
  184. }
  185. /** Return GIC CPU Interface Info.
  186. @param [in] This Pointer to the Configuration Manager Protocol.
  187. @param [in] CmObjectId The Object ID of the CM object requested
  188. @param [in] Token A unique token for identifying the requested
  189. CM_ARM_GICC_INFO object.
  190. @param [in, out] CmObject Pointer to the Configuration Manager Object
  191. descriptor describing the requested Object.
  192. @retval EFI_SUCCESS Success.
  193. @retval EFI_INVALID_PARAMETER A parameter is invalid.
  194. @retval EFI_NOT_FOUND The required object information is
  195. not found.
  196. **/
  197. EFI_STATUS
  198. EFIAPI
  199. GetGicCInfo (
  200. IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST This,
  201. IN CONST CM_OBJECT_ID CmObjectId,
  202. IN CONST CM_OBJECT_TOKEN Token,
  203. IN OUT CM_OBJ_DESCRIPTOR * CONST CmObject
  204. )
  205. {
  206. FSL_PLATFORM_REPOSITORY_INFO * PlatformRepo;
  207. if ((This == NULL) || (CmObject == NULL)) {
  208. ASSERT (This != NULL);
  209. ASSERT (CmObject != NULL);
  210. return EFI_INVALID_PARAMETER;
  211. }
  212. PlatformRepo = This->PlatRepoInfo;
  213. if (Token != (CM_OBJECT_TOKEN)&PlatformRepo->GicCInfo) {
  214. return EFI_NOT_FOUND;
  215. }
  216. CmObject->ObjectId = CmObjectId;
  217. CmObject->Size = sizeof (PlatformRepo->GicCInfo);
  218. CmObject->Data = (VOID*)&PlatformRepo->GicCInfo;
  219. CmObject->Count = ARRAY_SIZE (PlatformRepo->GicCInfo);
  220. return EFI_SUCCESS;
  221. }
  222. /** Return a GT Block timer frame info list.
  223. @param [in] This Pointer to the Configuration Manager Protocol.
  224. @param [in] CmObjectId The Configuration Manager Object ID.
  225. @param [in] Token A token for identifying the object
  226. @param [in, out] CmObject Pointer to the Configuration Manager Object
  227. descriptor describing the requested Object.
  228. @retval EFI_SUCCESS Success.
  229. @retval EFI_INVALID_PARAMETER A parameter is invalid.
  230. @retval EFI_NOT_FOUND The required object information is not found.
  231. **/
  232. EFI_STATUS
  233. EFIAPI
  234. GetGTBlockTimerFrameInfo (
  235. IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST This,
  236. IN CONST CM_OBJECT_ID CmObjectId,
  237. IN CONST CM_OBJECT_TOKEN Token,
  238. IN OUT CM_OBJ_DESCRIPTOR * CONST CmObject
  239. )
  240. {
  241. FSL_PLATFORM_REPOSITORY_INFO * PlatformRepo;
  242. if ((This == NULL) || (CmObject == NULL)) {
  243. ASSERT (This != NULL);
  244. ASSERT (CmObject != NULL);
  245. return EFI_INVALID_PARAMETER;
  246. }
  247. PlatformRepo = This->PlatRepoInfo;
  248. if (Token != (CM_OBJECT_TOKEN)&PlatformRepo->GTBlock0TimerInfo) {
  249. return EFI_NOT_FOUND;
  250. }
  251. CmObject->ObjectId = CmObjectId;
  252. CmObject->Size = sizeof (PlatformRepo->GTBlock0TimerInfo);
  253. CmObject->Data = (VOID*)&PlatformRepo->GTBlock0TimerInfo;
  254. CmObject->Count = ARRAY_SIZE (PlatformRepo->GTBlock0TimerInfo);
  255. return EFI_SUCCESS;
  256. }
  257. /** A helper function for returning the Configuration Manager Objects.
  258. @param [in] CmObjectId The Configuration Manager Object ID.
  259. @param [in] Object Pointer to the Object(s).
  260. @param [in] ObjectSize Total size of the Object(s).
  261. @param [in] ObjectCount Number of Objects.
  262. @param [in, out] CmObjectDesc Pointer to the Configuration Manager Object
  263. descriptor describing the requested Object.
  264. @retval EFI_SUCCESS Success.
  265. **/
  266. STATIC
  267. EFI_STATUS
  268. EFIAPI
  269. HandleCmObject (
  270. IN CONST CM_OBJECT_ID CmObjectId,
  271. IN VOID * Object,
  272. IN CONST UINTN ObjectSize,
  273. IN CONST UINTN ObjectCount,
  274. IN OUT CM_OBJ_DESCRIPTOR * CONST CmObjectDesc
  275. )
  276. {
  277. CmObjectDesc->ObjectId = CmObjectId;
  278. CmObjectDesc->Size = ObjectSize;
  279. CmObjectDesc->Data = (VOID*)Object;
  280. CmObjectDesc->Count = ObjectCount;
  281. DEBUG ((
  282. DEBUG_INFO,
  283. "INFO: CmObjectId = %x, Ptr = 0x%p, Size = %d, Count = %d\n",
  284. CmObjectId,
  285. CmObjectDesc->Data,
  286. CmObjectDesc->Size,
  287. CmObjectDesc->Count
  288. ));
  289. return EFI_SUCCESS;
  290. }
  291. /** A helper function for returning the Configuration Manager Objects that
  292. match the token.
  293. @param [in] This Pointer to the Configuration Manager Protocol.
  294. @param [in] CmObjectId The Configuration Manager Object ID.
  295. @param [in] Object Pointer to the Object(s).
  296. @param [in] ObjectSize Total size of the Object(s).
  297. @param [in] ObjectCount Number of Objects.
  298. @param [in] Token A token identifying the object.
  299. @param [in] HandlerProc A handler function to search the object
  300. referenced by the token.
  301. @param [in, out] CmObjectDesc Pointer to the Configuration Manager Object
  302. descriptor describing the requested Object.
  303. @retval EFI_SUCCESS Success.
  304. @retval EFI_INVALID_PARAMETER A parameter is invalid.
  305. @retval EFI_NOT_FOUND The required object information is not found.
  306. **/
  307. STATIC
  308. EFI_STATUS
  309. EFIAPI
  310. HandleCmObjectRefByToken (
  311. IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST This,
  312. IN CONST CM_OBJECT_ID CmObjectId,
  313. IN VOID * Object,
  314. IN CONST UINTN ObjectSize,
  315. IN CONST UINTN ObjectCount,
  316. IN CONST CM_OBJECT_TOKEN Token,
  317. IN CONST CM_OBJECT_HANDLER_PROC HandlerProc,
  318. IN OUT CM_OBJ_DESCRIPTOR * CONST CmObjectDesc
  319. )
  320. {
  321. EFI_STATUS Status;
  322. CmObjectDesc->ObjectId = CmObjectId;
  323. if (Token == CM_NULL_TOKEN) {
  324. CmObjectDesc->Size = ObjectSize;
  325. CmObjectDesc->Data = (VOID*)Object;
  326. CmObjectDesc->Count = ObjectCount;
  327. Status = EFI_SUCCESS;
  328. } else {
  329. Status = HandlerProc (This, CmObjectId, Token, CmObjectDesc);
  330. }
  331. DEBUG ((
  332. DEBUG_INFO,
  333. "INFO: Token = 0x%p, CmObjectId = %x, Ptr = 0x%p, Size = %d, Count = %d\n",
  334. (VOID*)Token,
  335. CmObjectId,
  336. CmObjectDesc->Data,
  337. CmObjectDesc->Size,
  338. CmObjectDesc->Count
  339. ));
  340. return Status;
  341. }
  342. /** Return a standard namespace object.
  343. @param [in] This Pointer to the Configuration Manager Protocol.
  344. @param [in] CmObjectId The Configuration Manager Object ID.
  345. @param [in] Token An optional token identifying the object. If
  346. unused this must be CM_NULL_TOKEN.
  347. @param [in, out] CmObject Pointer to the Configuration Manager Object
  348. descriptor describing the requested Object.
  349. @retval EFI_SUCCESS Success.
  350. @retval EFI_INVALID_PARAMETER A parameter is invalid.
  351. @retval EFI_NOT_FOUND The required object information is not found.
  352. **/
  353. EFI_STATUS
  354. EFIAPI
  355. GetStandardNameSpaceObject (
  356. IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST This,
  357. IN CONST CM_OBJECT_ID CmObjectId,
  358. IN CONST CM_OBJECT_TOKEN Token OPTIONAL,
  359. IN OUT CM_OBJ_DESCRIPTOR * CONST CmObject
  360. )
  361. {
  362. EFI_STATUS Status;
  363. FSL_PLATFORM_REPOSITORY_INFO * PlatformRepo;
  364. Status = EFI_SUCCESS;
  365. if ((This == NULL) || (CmObject == NULL)) {
  366. ASSERT (This != NULL);
  367. ASSERT (CmObject != NULL);
  368. return EFI_INVALID_PARAMETER;
  369. }
  370. PlatformRepo = This->PlatRepoInfo;
  371. switch (GET_CM_OBJECT_ID (CmObjectId)) {
  372. case EStdObjCfgMgrInfo:
  373. Status = HandleCmObject (
  374. CmObjectId,
  375. &PlatformRepo->CmInfo,
  376. sizeof (PlatformRepo->CmInfo),
  377. 1,
  378. CmObject
  379. );
  380. break;
  381. case EStdObjAcpiTableList:
  382. Status = HandleCmObject (
  383. CmObjectId,
  384. &PlatformRepo->CmAcpiTableList,
  385. sizeof (PlatformRepo->CmAcpiTableList),
  386. ARRAY_SIZE (PlatformRepo->CmAcpiTableList),
  387. CmObject
  388. );
  389. break;
  390. default: {
  391. Status = EFI_NOT_FOUND;
  392. DEBUG ((
  393. DEBUG_ERROR,
  394. "ERROR: Object 0x%x. Status = %r\n",
  395. CmObjectId,
  396. Status
  397. ));
  398. break;
  399. }
  400. }
  401. return Status;
  402. }
  403. /** Return an ARM namespace object.
  404. @param [in] This Pointer to the Configuration Manager Protocol.
  405. @param [in] CmObjectId The Configuration Manager Object ID.
  406. @param [in] Token An optional token identifying the object. If
  407. unused this must be CM_NULL_TOKEN.
  408. @param [in, out] CmObject Pointer to the Configuration Manager Object
  409. descriptor describing the requested Object.
  410. @retval EFI_SUCCESS Success.
  411. @retval EFI_INVALID_PARAMETER A parameter is invalid.
  412. @retval EFI_NOT_FOUND The required object information is not found.
  413. **/
  414. EFI_STATUS
  415. EFIAPI
  416. GetArmNameSpaceObject (
  417. IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST This,
  418. IN CONST CM_OBJECT_ID CmObjectId,
  419. IN CONST CM_OBJECT_TOKEN Token OPTIONAL,
  420. IN OUT CM_OBJ_DESCRIPTOR * CONST CmObject
  421. )
  422. {
  423. EFI_STATUS Status;
  424. FSL_PLATFORM_REPOSITORY_INFO * PlatformRepo;
  425. Status = EFI_SUCCESS;
  426. if ((This == NULL) || (CmObject == NULL)) {
  427. ASSERT (This != NULL);
  428. ASSERT (CmObject != NULL);
  429. return EFI_INVALID_PARAMETER;
  430. }
  431. PlatformRepo = This->PlatRepoInfo;
  432. switch (GET_CM_OBJECT_ID (CmObjectId)) {
  433. case EArmObjBootArchInfo:
  434. Status = HandleCmObject (
  435. CmObjectId,
  436. &PlatformRepo->BootArchInfo,
  437. sizeof (PlatformRepo->BootArchInfo),
  438. 1,
  439. CmObject
  440. );
  441. break;
  442. case EArmObjPowerManagementProfileInfo:
  443. Status = HandleCmObject (
  444. CmObjectId,
  445. &PlatformRepo->PmProfileInfo,
  446. sizeof (PlatformRepo->PmProfileInfo),
  447. 1,
  448. CmObject
  449. );
  450. break;
  451. case EArmObjGenericTimerInfo:
  452. Status = HandleCmObject (
  453. CmObjectId,
  454. &PlatformRepo->GenericTimerInfo,
  455. sizeof (PlatformRepo->GenericTimerInfo),
  456. 1,
  457. CmObject
  458. );
  459. break;
  460. case EArmObjPlatformGenericWatchdogInfo:
  461. Status = HandleCmObject (
  462. CmObjectId,
  463. &PlatformRepo->Watchdog,
  464. sizeof (PlatformRepo->Watchdog),
  465. PLAT_WATCHDOG_COUNT,
  466. CmObject
  467. );
  468. break;
  469. case EArmObjPlatformGTBlockInfo:
  470. Status = HandleCmObject (
  471. CmObjectId,
  472. &PlatformRepo->GTBlockInfo,
  473. sizeof (PlatformRepo->GTBlockInfo),
  474. ARRAY_SIZE (PlatformRepo->GTBlockInfo),
  475. CmObject
  476. );
  477. break;
  478. case EArmObjGTBlockTimerFrameInfo:
  479. Status = HandleCmObjectRefByToken (
  480. This,
  481. CmObjectId,
  482. PlatformRepo->GTBlock0TimerInfo,
  483. sizeof (PlatformRepo->GTBlock0TimerInfo),
  484. ARRAY_SIZE (PlatformRepo->GTBlock0TimerInfo),
  485. Token,
  486. GetGTBlockTimerFrameInfo,
  487. CmObject
  488. );
  489. break;
  490. case EArmObjGicCInfo:
  491. Status = HandleCmObjectRefByToken (
  492. This,
  493. CmObjectId,
  494. PlatformRepo->GicCInfo,
  495. sizeof (PlatformRepo->GicCInfo),
  496. ARRAY_SIZE (PlatformRepo->GicCInfo),
  497. Token,
  498. GetGicCInfo,
  499. CmObject
  500. );
  501. break;
  502. case EArmObjGicDInfo:
  503. Status = HandleCmObject (
  504. CmObjectId,
  505. &PlatformRepo->GicDInfo,
  506. sizeof (PlatformRepo->GicDInfo),
  507. 1,
  508. CmObject
  509. );
  510. break;
  511. case EArmObjGicRedistributorInfo:
  512. Status = HandleCmObject (
  513. CmObjectId,
  514. &PlatformRepo->GicRedistInfo,
  515. sizeof (PlatformRepo->GicRedistInfo),
  516. PLAT_GIC_REDISTRIBUTOR_COUNT,
  517. CmObject
  518. );
  519. break;
  520. case EArmObjGicItsInfo:
  521. Status = HandleCmObject (
  522. CmObjectId,
  523. &PlatformRepo->GicItsInfo,
  524. sizeof (PlatformRepo->GicItsInfo),
  525. PLAT_GIC_ITS_COUNT,
  526. CmObject
  527. );
  528. break;
  529. case EArmObjSerialConsolePortInfo:
  530. Status = HandleCmObject (
  531. CmObjectId,
  532. &PlatformRepo->SpcrSerialPort,
  533. sizeof (PlatformRepo->SpcrSerialPort),
  534. 1,
  535. CmObject
  536. );
  537. break;
  538. case EArmObjPciConfigSpaceInfo:
  539. Status = HandleCmObjectRefByToken (
  540. This,
  541. CmObjectId,
  542. PlatformRepo->PciConfigInfo,
  543. sizeof (PlatformRepo->PciConfigInfo),
  544. ARRAY_SIZE (PlatformRepo->PciConfigInfo),
  545. Token,
  546. GetPciConfigInfo,
  547. CmObject
  548. );
  549. break;
  550. default: {
  551. Status = EFI_NOT_FOUND;
  552. DEBUG ((
  553. DEBUG_INFO,
  554. "INFO: Object 0x%x. Status = %r\n",
  555. CmObjectId,
  556. Status
  557. ));
  558. break;
  559. }
  560. }//switch
  561. return Status;
  562. }
  563. /** Return an OEM namespace object.
  564. @param [in] This Pointer to the Configuration Manager Protocol.
  565. @param [in] CmObjectId The Configuration Manager Object ID.
  566. @param [in] Token An optional token identifying the object. If
  567. unused this must be CM_NULL_TOKEN.
  568. @param [in, out] CmObject Pointer to the Configuration Manager Object
  569. descriptor describing the requested Object.
  570. @retval EFI_SUCCESS Success.
  571. @retval EFI_INVALID_PARAMETER A parameter is invalid.
  572. @retval EFI_NOT_FOUND The required object information is not found.
  573. **/
  574. EFI_STATUS
  575. EFIAPI
  576. GetOemNameSpaceObject (
  577. IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST This,
  578. IN CONST CM_OBJECT_ID CmObjectId,
  579. IN CONST CM_OBJECT_TOKEN Token OPTIONAL,
  580. IN OUT CM_OBJ_DESCRIPTOR * CONST CmObject
  581. )
  582. {
  583. EFI_STATUS Status;
  584. Status = EFI_SUCCESS;
  585. if ((This == NULL) || (CmObject == NULL)) {
  586. ASSERT (This != NULL);
  587. ASSERT (CmObject != NULL);
  588. return EFI_INVALID_PARAMETER;
  589. }
  590. switch (GET_CM_OBJECT_ID (CmObjectId)) {
  591. default: {
  592. Status = EFI_NOT_FOUND;
  593. DEBUG ((
  594. DEBUG_ERROR,
  595. "ERROR: Object 0x%x. Status = %r\n",
  596. CmObjectId,
  597. Status
  598. ));
  599. break;
  600. }
  601. }
  602. return Status;
  603. }
  604. /** The GetObject function defines the interface implemented by the
  605. Configuration Manager Protocol for returning the Configuration
  606. Manager Objects.
  607. @param [in] This Pointer to the Configuration Manager Protocol.
  608. @param [in] CmObjectId The Configuration Manager Object ID.
  609. @param [in] Token An optional token identifying the object. If
  610. unused this must be CM_NULL_TOKEN.
  611. @param [in, out] CmObject Pointer to the Configuration Manager Object
  612. descriptor describing the requested Object.
  613. @retval EFI_SUCCESS Success.
  614. @retval EFI_INVALID_PARAMETER A parameter is invalid.
  615. @retval EFI_NOT_FOUND The required object information is not found.
  616. **/
  617. EFI_STATUS
  618. EFIAPI
  619. FslPlatformGetObject (
  620. IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST This,
  621. IN CONST CM_OBJECT_ID CmObjectId,
  622. IN CONST CM_OBJECT_TOKEN Token OPTIONAL,
  623. IN OUT CM_OBJ_DESCRIPTOR * CONST CmObject
  624. )
  625. {
  626. EFI_STATUS Status;
  627. if ((This == NULL) || (CmObject == NULL)) {
  628. ASSERT (This != NULL);
  629. ASSERT (CmObject != NULL);
  630. return EFI_INVALID_PARAMETER;
  631. }
  632. switch (GET_CM_NAMESPACE_ID (CmObjectId)) {
  633. case EObjNameSpaceStandard:
  634. Status = GetStandardNameSpaceObject (This, CmObjectId, Token, CmObject);
  635. break;
  636. case EObjNameSpaceArm:
  637. Status = GetArmNameSpaceObject (This, CmObjectId, Token, CmObject);
  638. break;
  639. case EObjNameSpaceOem:
  640. Status = GetOemNameSpaceObject (This, CmObjectId, Token, CmObject);
  641. break;
  642. default: {
  643. Status = EFI_INVALID_PARAMETER;
  644. DEBUG ((
  645. DEBUG_ERROR,
  646. "ERROR: Unknown Namespace Object = 0x%x. Status = %r\n",
  647. CmObjectId,
  648. Status
  649. ));
  650. break;
  651. }
  652. }
  653. return Status;
  654. }
  655. /** The SetObject function defines the interface implemented by the
  656. Configuration Manager Protocol for updating the Configuration
  657. Manager Objects.
  658. @param [in] This Pointer to the Configuration Manager Protocol.
  659. @param [in] CmObjectId The Configuration Manager Object ID.
  660. @param [in] Token An optional token identifying the object. If
  661. unused this must be CM_NULL_TOKEN.
  662. @param [in] CmObject Pointer to the Configuration Manager Object
  663. descriptor describing the Object.
  664. @retval EFI_UNSUPPORTED This operation is not supported.
  665. **/
  666. EFI_STATUS
  667. EFIAPI
  668. FslPlatformSetObject (
  669. IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST This,
  670. IN CONST CM_OBJECT_ID CmObjectId,
  671. IN CONST CM_OBJECT_TOKEN Token OPTIONAL,
  672. IN CM_OBJ_DESCRIPTOR * CONST CmObject
  673. )
  674. {
  675. return EFI_UNSUPPORTED;
  676. }
  677. /** A structure describing the configuration manager protocol interface.
  678. */
  679. STATIC
  680. CONST
  681. EDKII_CONFIGURATION_MANAGER_PROTOCOL FslConfigManagerProtocol = {
  682. CREATE_REVISION (1, 0),
  683. FslPlatformGetObject,
  684. FslPlatformSetObject,
  685. &FslPlatformRepositoryInfo
  686. };
  687. /**
  688. Entrypoint of Configuration Manager Dxe.
  689. @param ImageHandle
  690. @param SystemTable
  691. @return EFI_SUCCESS
  692. @return EFI_LOAD_ERROR
  693. @return EFI_OUT_OF_RESOURCES
  694. **/
  695. EFI_STATUS
  696. EFIAPI
  697. ConfigurationManagerDxeInitialize (
  698. IN EFI_HANDLE ImageHandle,
  699. IN EFI_SYSTEM_TABLE * SystemTable
  700. )
  701. {
  702. EFI_STATUS Status;
  703. Status = gBS->InstallProtocolInterface (
  704. &ImageHandle,
  705. &gEdkiiConfigurationManagerProtocolGuid,
  706. EFI_NATIVE_INTERFACE,
  707. (VOID*)&FslConfigManagerProtocol
  708. );
  709. if (EFI_ERROR (Status)) {
  710. DEBUG ((
  711. DEBUG_ERROR,
  712. "ERROR: Failed to get Install Configuration Manager Protocol." \
  713. " Status = %r\n",
  714. Status
  715. ));
  716. goto error_handler;
  717. }
  718. Status = InitializePlatformRepository (
  719. &FslConfigManagerProtocol
  720. );
  721. if (EFI_ERROR (Status)) {
  722. DEBUG ((
  723. DEBUG_ERROR,
  724. "ERROR: Failed to initialize the Platform Configuration Repository." \
  725. " Status = %r\n",
  726. Status
  727. ));
  728. }
  729. error_handler:
  730. return Status;
  731. }