fsl_xrdc2.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  1. /*
  2. * Copyright 2019-2020 NXP
  3. * All rights reserved.
  4. *
  5. * SPDX-License-Identifier: BSD-3-Clause
  6. */
  7. #ifndef _FSL_XRDC2_H_
  8. #define _FSL_XRDC2_H_
  9. #include "fsl_common.h"
  10. /*!
  11. * @addtogroup xrdc2
  12. * @{
  13. */
  14. /******************************************************************************
  15. * Definitions
  16. *****************************************************************************/
  17. /*! @brief Driver version. */
  18. #define FSL_XRDC2_DRIVER_VERSION (MAKE_VERSION(2, 0, 2))
  19. /* Definitions for XRDC2 Exclusive access lock. */
  20. #define XRDC2_EAL_FORCE_RELEASE_MAGIC_0 0x02000046UL
  21. #define XRDC2_EAL_FORCE_RELEASE_MAGIC_1 0x02000052UL
  22. #define XRDC2_EAL_DISABLE (0UL << XRDC2_MSC_MSAC_W1_EAL_SHIFT)
  23. #define XRDC2_EAL_DISABLE_UNTIL_RESET (1UL << XRDC2_MSC_MSAC_W1_EAL_SHIFT)
  24. #define XRDC2_EAL_UNLOCKED (2UL << XRDC2_MSC_MSAC_W1_EAL_SHIFT)
  25. #define XRDC2_EAL_LOCKED (3UL << XRDC2_MSC_MSAC_W1_EAL_SHIFT)
  26. #define XRDC2_EAL_MASK XRDC2_MSC_MSAC_W1_EAL_MASK
  27. /*!
  28. * @brief Global configuration lock.
  29. */
  30. typedef enum _xrdc2_global_config_lock
  31. {
  32. kXRDC2_GlobalConfigLockDisabled, /*!< Lock disabled, registers can be written by any domain. */
  33. kXRDC2_GlobalConfigLockDisabledUntilReset, /*!< Lock disabled until the next reset. */
  34. kXRDC2_GlobalConfigLockOwnerOnly, /*!< Lock enabled, only the lock owner can write. */
  35. kXRDC2_GlobalConfigLockEnabledUntilReset /*!< Lock enabled, all registers are read only until the next reset. */
  36. } xrdc2_global_config_lock_t;
  37. /*!
  38. * @brief XRDC2 secure attribute, the register bit MDACi_MDAj_W0[SA],
  39. * secure/nonsecure attribute output on a hit.
  40. */
  41. typedef enum _xrdc2_secure_attr
  42. {
  43. kXRDC2_MasterSecure = 0, /*!< Use the bus master's secure/nonsecure attribute directly. */
  44. kXRDC2_ForceSecure = 2, /*!< Force the bus attribute for this master to secure. */
  45. kXRDC2_ForceNonSecure = 3, /*!< Force the bus attribute for this master to non-secure. */
  46. } xrdc2_secure_attr_t;
  47. /*!
  48. * @brief XRDC2 privileged attribute, the register bit MDACi_MDAj_W0[PA],
  49. * defines the privileged/user attribute on a hit.
  50. */
  51. typedef enum _xrdc2_privilege_attr
  52. {
  53. kXRDC2_MasterPrivilege = 0, /*!< Use the bus master's attribute directly. */
  54. kXRDC2_ForceUser = 2, /*!< Force the bus attribute for this master to user. */
  55. kXRDC2_ForcePrivilege = 3, /*!< Force the bus attribute for this master to privileged. */
  56. } xrdc2_privilege_attr_t;
  57. /*!
  58. * @brief Domain assignment for the bus master.
  59. *
  60. * XRDC2 compares the bus master @e match @e input with the parameter @ref mask
  61. * and @ref match in this structure. If hit, the domain ID, privilege attribute,
  62. * and secure attribute are used for the access.
  63. */
  64. typedef struct _xrdc2_master_domain_assignment
  65. {
  66. bool lock; /*!< Set true to lock the descriptor. */
  67. xrdc2_privilege_attr_t privilegeAttr; /*!< Privilege attribute. */
  68. xrdc2_secure_attr_t secureAttr; /*!< Secure attribute. */
  69. uint8_t domainId; /*!< Domain ID used when this descriptor hit. */
  70. uint16_t mask; /*!< Mask used for descriptor hit. */
  71. uint16_t match; /*!< Match used for descriptor hit. */
  72. } xrdc2_master_domain_assignment_t;
  73. /*!
  74. * @brief XRDC2 domain access control policy.
  75. */
  76. typedef enum _xrdc2_access_policy
  77. {
  78. /* policy SecurePriv SecureUser NonSecurePriv NonSecureUsr */
  79. kXRDC2_AccessPolicyNone = 0U, /* 000 none none none none */
  80. kXRDC2_AccessPolicyAlt1 = 1U, /* 001 r r none none */
  81. kXRDC2_AccessPolicyAlt2 = 2U, /* 010 r,w none none none */
  82. kXRDC2_AccessPolicyAlt3 = 3U, /* 011 r,w r,w none none */
  83. kXRDC2_AccessPolicyAlt4 = 4U, /* 100 r,w r,w r none */
  84. kXRDC2_AccessPolicyAlt5 = 5U, /* 101 r,w r,w r r */
  85. kXRDC2_AccessPolicyAlt6 = 6U, /* 110 r,w r,w r,w none */
  86. kXRDC2_AccessPolicyAll = 7U /* 111 r,w r,w r,w r,w */
  87. } xrdc2_access_policy_t;
  88. /*!
  89. * @brief Access configuration lock mode, the register field PDAC and MRGD LK2.
  90. */
  91. typedef enum _xrdc2_access_config_lock
  92. {
  93. kXRDC2_AccessConfigLockDisabled = 0U, /*!< Entire PDACn/MRGDn/MSC can be written. */
  94. kXRDC2_AccessConfigLockDisabledUntilReset = 1U, /*!< Entire PDACn/MRGDn/MSC can be written until next reset. */
  95. kXRDC2_AccessConfigLockDomainXOnly = 2U, /*!< Domain x only write the DxACP field. */
  96. kXRDC2_AccessConfigLockEnabledUntilReset = 3U /*!< PDACn/MRGDn/MSC is read-only until the next reset. */
  97. } xrdc2_access_config_lock_t;
  98. /*!
  99. * @brief XRDC2 peripheral domain access control configuration.
  100. */
  101. typedef struct _xrdc2_periph_access_config
  102. {
  103. xrdc2_access_config_lock_t lockMode; /*!< PDACn lock configuration. */
  104. xrdc2_access_policy_t policy[FSL_FEATURE_XRDC2_DOMAIN_COUNT]; /*!< Access policy for each domain. */
  105. } xrdc2_periph_access_config_t;
  106. /*!
  107. * @brief XRDC2 memory region domain access control configuration.
  108. */
  109. typedef struct _xrdc2_mem_access_config
  110. {
  111. uint32_t startAddr; /*!< Memory region start address, should be 4k aligned. */
  112. uint32_t endAddr; /*!< Memory region end address, (endAddr + 1) should be 4k aligned. */
  113. xrdc2_access_config_lock_t lockMode; /*!< MRGDn lock configuration. */
  114. xrdc2_access_policy_t policy[FSL_FEATURE_XRDC2_DOMAIN_COUNT]; /*!< Access policy for each domain. */
  115. } xrdc2_mem_access_config_t;
  116. /*!
  117. * @brief XRDC2 memory slot domain access control configuration.
  118. */
  119. typedef struct _xrdc2_mem_slot_access_config
  120. {
  121. xrdc2_access_config_lock_t lockMode; /*!< Descriptor lock configuration. */
  122. xrdc2_access_policy_t policy[FSL_FEATURE_XRDC2_DOMAIN_COUNT]; /*!< Access policy for each domain. */
  123. } xrdc2_mem_slot_access_config_t;
  124. /*******************************************************************************
  125. * API
  126. ******************************************************************************/
  127. #if defined(__cplusplus)
  128. extern "C" {
  129. #endif
  130. /*!
  131. * @brief Initializes the XRDC2 module.
  132. *
  133. * @param base XRDC2 peripheral base address.
  134. */
  135. void XRDC2_Init(XRDC2_Type *base);
  136. /*!
  137. * @brief De-initializes the XRDC2 module.
  138. *
  139. * @param base XRDC2 peripheral base address.
  140. */
  141. void XRDC2_Deinit(XRDC2_Type *base);
  142. /*!
  143. * @name XRDC2 manager (XRDC2)
  144. * @{
  145. */
  146. /*!
  147. * @brief Sets the XRDC2 global valid.
  148. *
  149. * This function sets the XRDC2 global valid or invalid. When the XRDC2 is global
  150. * invalid, all accesses from all bus masters to all slaves are allowed.
  151. *
  152. * @param base XRDC2 peripheral base address.
  153. * @param valid True to valid XRDC2.
  154. */
  155. void XRDC2_SetGlobalValid(XRDC2_Type *base, bool valid);
  156. /*!
  157. * @brief Gets the domain ID of the current bus master.
  158. *
  159. * This function returns the domain ID of the current bus master.
  160. *
  161. * @param base XRDC2 peripheral base address.
  162. * @return Domain ID of current bus master.
  163. */
  164. static inline uint8_t XRDC2_GetCurrentMasterDomainId(XRDC2_Type *base)
  165. {
  166. #if defined(XRDC2_SR_DIN_MASK)
  167. return (uint8_t)((base->SR & XRDC2_SR_DIN_MASK) >> XRDC2_SR_DIN_SHIFT);
  168. #else
  169. return (uint8_t)((base->SR & XRDC2_SR_DID_MASK) >> XRDC2_SR_DID_SHIFT);
  170. #endif
  171. }
  172. /*!
  173. * @brief Set the global configuration lock mode.
  174. *
  175. * Once change the lock mode, it could not be changed until next reset.
  176. *
  177. * @param base XRDC2 peripheral base address.
  178. * @param mode The lock mode.
  179. */
  180. static inline void XRDC2_SetGlobalConfigLock(XRDC2_Type *base, xrdc2_global_config_lock_t mode)
  181. {
  182. base->MCR = (base->MCR & ~XRDC2_MCR_GCL_MASK) | XRDC2_MCR_GCL(mode);
  183. }
  184. /*!
  185. * @brief Gets the domain ID of global configuration lock owner.
  186. *
  187. * @param base XRDC2 peripheral base address.
  188. * @return Domain ID of the global configuration lock owner.
  189. */
  190. static inline uint8_t XRDC2_GetCurrentGlobalConfigLockOwnerDomainId(XRDC2_Type *base)
  191. {
  192. return (uint8_t)((base->SR & XRDC2_SR_GCLO_MASK) >> XRDC2_SR_GCLO_SHIFT);
  193. }
  194. /*@}*/
  195. /*!
  196. * @name XRDC2 Master Domain Assignment Controller (XRDC2_MDAC).
  197. * @{
  198. */
  199. /*!
  200. * @brief Gets the default master domain assignment.
  201. *
  202. * This function sets the assignment as follows:
  203. *
  204. * @code
  205. * config->lock = false;
  206. * config->privilegeAttr = kXRDC2_MasterPrivilege;
  207. * config->secureAttr = kXRDC2_MasterSecure;
  208. * config->domainId = 0U;
  209. * config->mask = 0U;
  210. * config->match = 0U;
  211. * @endcode
  212. *
  213. * @param assignment Pointer to the assignment structure.
  214. */
  215. void XRDC2_GetDefaultMasterDomainAssignment(xrdc2_master_domain_assignment_t *assignment);
  216. /*!
  217. * @brief Sets the processor bus master domain assignment.
  218. *
  219. * @param base XRDC2 peripheral base address.
  220. * @param master Which master to configure.
  221. * @param assignIndex Which assignment register to set.
  222. * @param assignment Pointer to the assignment structure.
  223. */
  224. void XRDC2_SetMasterDomainAssignment(XRDC2_Type *base,
  225. xrdc2_master_t master,
  226. uint8_t assignIndex,
  227. const xrdc2_master_domain_assignment_t *assignment);
  228. /*!
  229. * @brief Locks the bus master domain assignment register.
  230. *
  231. * This function locks the master domain assignment. One bus master might have
  232. * multiple domain assignment registers. The parameter \p assignIndex specifies
  233. * which assignment register to lock. After it is locked, the register can't be changed
  234. * until next reset.
  235. *
  236. * @param base XRDC2 peripheral base address.
  237. * @param master Which master to configure.
  238. * @param assignIndex Which assignment register to lock.
  239. */
  240. static inline void XRDC2_LockMasterDomainAssignment(XRDC2_Type *base, xrdc2_master_t master, uint8_t assignIndex)
  241. {
  242. base->MDACI_MDAJ[master][assignIndex].MDAC_MDA_W1 |= XRDC2_MDAC_MDA_W1_DL_MASK;
  243. }
  244. /*!
  245. * @brief Sets the master domain assignment as valid or invalid.
  246. *
  247. * This function sets the master domain assignment as valid or invalid. One bus master might have
  248. * multiple domain assignment registers. The parameter \p assignIndex specifies
  249. * which assignment register to configure.
  250. *
  251. * @param base XRDC2 peripheral base address.
  252. * @param master Which master to configure.
  253. * @param assignIndex Index for the domain assignment register.
  254. * @param valid True to set valid, false to set invalid.
  255. */
  256. static inline void XRDC2_SetMasterDomainAssignmentValid(XRDC2_Type *base,
  257. xrdc2_master_t master,
  258. uint8_t assignIndex,
  259. bool valid)
  260. {
  261. if (valid)
  262. {
  263. base->MDACI_MDAJ[master][assignIndex].MDAC_MDA_W1 |= XRDC2_MDAC_MDA_W1_VLD_MASK;
  264. }
  265. else
  266. {
  267. base->MDACI_MDAJ[master][assignIndex].MDAC_MDA_W1 &= ~XRDC2_MDAC_MDA_W1_VLD_MASK;
  268. }
  269. }
  270. /*@}*/
  271. /*!
  272. * @name XRDC2 Memory Slot Access Controller (XRDC2_MSC).
  273. * @{
  274. */
  275. /*!
  276. * @brief Gets the default memory slot access configuration.
  277. *
  278. * This function sets the assignment as follows:
  279. *
  280. * @code
  281. * config->lockMode = kXRDC2_AccessConfigLockDisabled;
  282. * config->policy[0] = kXRDC2_AccessPolicyNone;
  283. * config->policy[1] = kXRDC2_AccessPolicyNone;
  284. * ...
  285. * @endcode
  286. *
  287. * @param config Pointer to the configuration.
  288. */
  289. void XRDC2_GetMemSlotAccessDefaultConfig(xrdc2_mem_slot_access_config_t *config);
  290. /*!
  291. * @brief Sets the memory slot access policy.
  292. *
  293. * @param base XRDC2 peripheral base address.
  294. * @param memSlot Which memory slot descriptor to set.
  295. * @param config Pointer to the access policy configuration structure.
  296. */
  297. void XRDC2_SetMemSlotAccessConfig(XRDC2_Type *base,
  298. xrdc2_mem_slot_t memSlot,
  299. const xrdc2_mem_slot_access_config_t *config);
  300. /*!
  301. * @brief Sets the memory slot descriptor as valid or invalid.
  302. *
  303. * @param base XRDC2 peripheral base address.
  304. * @param memSlot Which memory slot descriptor to set.
  305. * @param valid True to set valid, false to set invalid.
  306. */
  307. void XRDC2_SetMemSlotAccessValid(XRDC2_Type *base, xrdc2_mem_slot_t memSlot, bool valid);
  308. /*!
  309. * @brief Sets the memory slot descriptor lock mode.
  310. *
  311. * @param base XRDC2 peripheral base address.
  312. * @param memSlot Which memory slot descriptor to set.
  313. * @param lockMode The lock mode to set.
  314. */
  315. void XRDC2_SetMemSlotAccessLockMode(XRDC2_Type *base, xrdc2_mem_slot_t memSlot, xrdc2_access_config_lock_t lockMode);
  316. /*!
  317. * @brief Sets the memory slot access policy for specific domain.
  318. *
  319. * @param base XRDC2 peripheral base address.
  320. * @param memSlot The memory slot to operate.
  321. * @param domainId The ID of the domain whose policy will be changed.
  322. * @param policy The access policy to set.
  323. */
  324. void XRDC2_SetMemSlotDomainAccessPolicy(XRDC2_Type *base,
  325. xrdc2_mem_slot_t memSlot,
  326. uint8_t domainId,
  327. xrdc2_access_policy_t policy);
  328. /*!
  329. * @brief Enable or disable the memory slot exclusive access lock.
  330. *
  331. * The lock must be enabled first before use. Once disabled, it could not be
  332. * enabled until reset.
  333. *
  334. * @param base XRDC2 peripheral base address.
  335. * @param memSlot The memory slot to operate.
  336. * @param enable True to enable, false to disable.
  337. */
  338. void XRDC2_EnableMemSlotExclAccessLock(XRDC2_Type *base, xrdc2_mem_slot_t memSlot, bool enable);
  339. /*!
  340. * @brief Get current memory slot exclusive access lock owner.
  341. *
  342. * @param base XRDC2 peripheral base address.
  343. * @param memSlot The memory slot to operate.
  344. * @return The domain ID of the lock owner.
  345. */
  346. uint8_t XRDC2_GetMemSlotExclAccessLockDomainOwner(XRDC2_Type *base, xrdc2_mem_slot_t memSlot);
  347. /*!
  348. * @brief Try to lock the memory slot exclusive access.
  349. *
  350. * @param base XRDC2 peripheral base address.
  351. * @param memSlot The memory slot to operate.
  352. * @retval kStatus_Fail Failed to lock.
  353. * @retval kStatus_Success Locked succussfully.
  354. */
  355. status_t XRDC2_TryLockMemSlotExclAccess(XRDC2_Type *base, xrdc2_mem_slot_t memSlot);
  356. /*!
  357. * @brief Lock the memory slot exclusive access using blocking method.
  358. *
  359. * @param base XRDC2 peripheral base address.
  360. * @param memSlot The memory slot to operate.
  361. *
  362. * @note This function must be called when the lock is not disabled.
  363. */
  364. void XRDC2_LockMemSlotExclAccess(XRDC2_Type *base, xrdc2_mem_slot_t memSlot);
  365. /*!
  366. * @brief Unlock the memory slot exclusive access.
  367. *
  368. * @param base XRDC2 peripheral base address.
  369. * @param memSlot The memory slot to operate.
  370. *
  371. * @note This function must be called by the lock owner.
  372. */
  373. static inline void XRDC2_UnlockMemSlotExclAccess(XRDC2_Type *base, xrdc2_mem_slot_t memSlot)
  374. {
  375. base->MSCI_MSAC_WK[(uint32_t)memSlot].MSC_MSAC_W1 = XRDC2_EAL_UNLOCKED;
  376. }
  377. /*!
  378. * @brief Force the memory slot exclusive access lock release.
  379. *
  380. * The master does not own the lock could call this function to force release the lock.
  381. *
  382. * @param base XRDC2 peripheral base address.
  383. * @param memSlot The memory slot to operate.
  384. */
  385. static inline void XRDC2_ForceMemSlotExclAccessLockRelease(XRDC2_Type *base, xrdc2_mem_slot_t memSlot)
  386. {
  387. base->MSCI_MSAC_WK[(uint32_t)memSlot].MSC_MSAC_W1 = XRDC2_EAL_FORCE_RELEASE_MAGIC_0;
  388. base->MSCI_MSAC_WK[(uint32_t)memSlot].MSC_MSAC_W1 = XRDC2_EAL_FORCE_RELEASE_MAGIC_1;
  389. }
  390. /*@}*/
  391. /*!
  392. * @name XRDC2 Memory Region Controller (XRDC2_MRC)
  393. * @{
  394. */
  395. /*!
  396. * @brief Gets the default memory access configuration.
  397. *
  398. * This function sets the assignment as follows:
  399. *
  400. * @code
  401. * config->startAddr = 0U;
  402. * config->endAddr = 0xFFFFFFFFU;
  403. * config->lockMode = kXRDC2_AccessConfigLockDisabled;
  404. * config->policy[0] = kXRDC2_AccessPolicyNone;
  405. * config->policy[1] = kXRDC2_AccessPolicyNone;
  406. * ...
  407. * @endcode
  408. *
  409. * @param config Pointer to the configuration.
  410. */
  411. void XRDC2_GetMemAccessDefaultConfig(xrdc2_mem_access_config_t *config);
  412. /*!
  413. * @brief Sets the memory region access policy.
  414. *
  415. * @param base XRDC2 peripheral base address.
  416. * @param mem Which memory region descriptor to set.
  417. * @param config Pointer to the access policy configuration structure.
  418. */
  419. void XRDC2_SetMemAccessConfig(XRDC2_Type *base, xrdc2_mem_t mem, const xrdc2_mem_access_config_t *config);
  420. /*!
  421. * @brief Sets the memory region descriptor as valid or invalid.
  422. *
  423. * @param base XRDC2 peripheral base address.
  424. * @param mem Which memory region descriptor to set.
  425. * @param valid True to set valid, false to set invalid.
  426. */
  427. void XRDC2_SetMemAccessValid(XRDC2_Type *base, xrdc2_mem_t mem, bool valid);
  428. /*!
  429. * @brief Sets the memory descriptor lock mode.
  430. *
  431. * @param base XRDC2 peripheral base address.
  432. * @param mem Which memory descriptor to set.
  433. * @param lockMode The lock mode to set.
  434. */
  435. void XRDC2_SetMemAccessLockMode(XRDC2_Type *base, xrdc2_mem_t mem, xrdc2_access_config_lock_t lockMode);
  436. /*!
  437. * @brief Sets the memory region access policy for specific domain.
  438. *
  439. * @param base XRDC2 peripheral base address.
  440. * @param mem The memory region to operate.
  441. * @param domainId The ID of the domain whose policy will be changed.
  442. * @param policy The access policy to set.
  443. */
  444. void XRDC2_SetMemDomainAccessPolicy(XRDC2_Type *base, xrdc2_mem_t mem, uint8_t domainId, xrdc2_access_policy_t policy);
  445. /*!
  446. * @brief Enable or disable the memory region exclusive access lock.
  447. *
  448. * Once disabled, it could not be enabled until reset.
  449. *
  450. * @param base XRDC2 peripheral base address.
  451. * @param mem The memory region to operate.
  452. * @param enable True to enable, false to disable.
  453. */
  454. void XRDC2_EnableMemExclAccessLock(XRDC2_Type *base, xrdc2_mem_t mem, bool enable);
  455. /*!
  456. * @brief Get current memory region exclusive access lock owner.
  457. *
  458. * @param base XRDC2 peripheral base address.
  459. * @param mem The memory region to operate.
  460. * @return The domain ID of the lock owner.
  461. */
  462. uint8_t XRDC2_GetMemExclAccessLockDomainOwner(XRDC2_Type *base, xrdc2_mem_t mem);
  463. /*!
  464. * @brief Try to lock the memory region exclusive access.
  465. *
  466. * @param base XRDC2 peripheral base address.
  467. * @param mem The memory region to operate.
  468. * @retval kStatus_Fail Failed to lock.
  469. * @retval kStatus_Success Locked succussfully.
  470. */
  471. status_t XRDC2_TryLockMemExclAccess(XRDC2_Type *base, xrdc2_mem_t mem);
  472. /*!
  473. * @brief Lock the memory region exclusive access using blocking method.
  474. *
  475. * @param base XRDC2 peripheral base address.
  476. * @param mem The memory region to operate.
  477. *
  478. * @note This function must be called when the lock is not disabled.
  479. */
  480. void XRDC2_LockMemExclAccess(XRDC2_Type *base, xrdc2_mem_t mem);
  481. /*!
  482. * @brief Unlock the memory region exclusive access.
  483. *
  484. * @param base XRDC2 peripheral base address.
  485. * @param mem The memory region to operate.
  486. *
  487. * @note This function must be called by the lock owner.
  488. */
  489. void XRDC2_UnlockMemExclAccess(XRDC2_Type *base, xrdc2_mem_t mem);
  490. /*!
  491. * @brief Force the memory region exclusive access lock release.
  492. *
  493. * The master does not own the lock could call this function to force release the lock.
  494. *
  495. * @param base XRDC2 peripheral base address.
  496. * @param mem The memory region to operate.
  497. */
  498. void XRDC2_ForceMemExclAccessLockRelease(XRDC2_Type *base, xrdc2_mem_t mem);
  499. /*@}*/
  500. /*!
  501. * @name XRDC2 Peripheral Access Controller (XRDC2_PAC)
  502. * @{
  503. */
  504. /*!
  505. * @brief Gets the default peripheral access configuration.
  506. *
  507. * The default configuration is set as follows:
  508. * @code
  509. * config->lockMode = kXRDC2_AccessConfigLockWritable;
  510. * config->policy[0] = kXRDC2_AccessPolicyNone;
  511. * config->policy[1] = kXRDC2_AccessPolicyNone;
  512. * ...
  513. * config->policy[15] = kXRDC2_AccessPolicyNone;
  514. * @endcode
  515. *
  516. * @param config Pointer to the configuration structure.
  517. */
  518. void XRDC2_GetPeriphAccessDefaultConfig(xrdc2_periph_access_config_t *config);
  519. /*!
  520. * @brief Sets the peripheral access policy.
  521. *
  522. * @param base XRDC2 peripheral base address.
  523. * @param periph Which peripheral descriptor to set.
  524. * @param config Pointer to the access policy configuration structure.
  525. */
  526. void XRDC2_SetPeriphAccessConfig(XRDC2_Type *base, xrdc2_periph_t periph, const xrdc2_periph_access_config_t *config);
  527. /*!
  528. * @brief Sets the peripheral descriptor as valid or invalid.
  529. *
  530. * @param base XRDC2 peripheral base address.
  531. * @param periph Which peripheral descriptor to set.
  532. * @param valid True to set valid, false to set invalid.
  533. */
  534. void XRDC2_SetPeriphAccessValid(XRDC2_Type *base, xrdc2_periph_t periph, bool valid);
  535. /*!
  536. * @brief Sets the peripheral descriptor lock mode.
  537. *
  538. * @param base XRDC2 peripheral base address.
  539. * @param periph Which peripheral descriptor to set.
  540. * @param lockMode The lock mode to set.
  541. */
  542. void XRDC2_SetPeriphAccessLockMode(XRDC2_Type *base, xrdc2_periph_t periph, xrdc2_access_config_lock_t lockMode);
  543. /*!
  544. * @brief Sets the peripheral access policy for specific domain.
  545. *
  546. * @param base XRDC2 peripheral base address.
  547. * @param periph The peripheral to operate.
  548. * @param domainId The ID of the domain whose policy will be changed.
  549. * @param policy The access policy to set.
  550. */
  551. void XRDC2_SetPeriphDomainAccessPolicy(XRDC2_Type *base,
  552. xrdc2_periph_t periph,
  553. uint8_t domainId,
  554. xrdc2_access_policy_t policy);
  555. /*!
  556. * @brief Disable the peripheral exclusive access lock.
  557. *
  558. * Once disabled, it could not be enabled until reset.
  559. *
  560. * @param base XRDC2 peripheral base address.
  561. * @param periph The peripheral to operate.
  562. * @param enable True to enable, false to disable.
  563. */
  564. void XRDC2_EnablePeriphExclAccessLock(XRDC2_Type *base, xrdc2_periph_t periph, bool enable);
  565. /*!
  566. * @brief Get current peripheral exclusive access lock owner.
  567. *
  568. * @param base XRDC2 peripheral base address.
  569. * @param periph The peripheral to operate.
  570. * @return The domain ID of the lock owner.
  571. */
  572. uint8_t XRDC2_GetPeriphExclAccessLockDomainOwner(XRDC2_Type *base, xrdc2_periph_t periph);
  573. /*!
  574. * @brief Try to lock the peripheral exclusive access.
  575. *
  576. * @param base XRDC2 peripheral base address.
  577. * @param periph The peripheral to operate.
  578. * @retval kStatus_Fail Failed to lock.
  579. * @retval kStatus_Success Locked succussfully.
  580. */
  581. status_t XRDC2_TryLockPeriphExclAccess(XRDC2_Type *base, xrdc2_periph_t periph);
  582. /*!
  583. * @brief Lock the peripheral exclusive access using blocking method.
  584. *
  585. * @param base XRDC2 peripheral base address.
  586. * @param periph The peripheral to operate.
  587. *
  588. * @note This function must be called when the lock is not disabled.
  589. */
  590. void XRDC2_LockPeriphExclAccess(XRDC2_Type *base, xrdc2_periph_t periph);
  591. /*!
  592. * @brief Unlock the peripheral exclusive access.
  593. *
  594. * @param base XRDC2 peripheral base address.
  595. * @param periph The peripheral to operate.
  596. *
  597. * @note This function must be called by the lock owner.
  598. */
  599. void XRDC2_UnlockPeriphExclAccess(XRDC2_Type *base, xrdc2_periph_t periph);
  600. /*!
  601. * @brief Force the peripheral exclusive access lock release.
  602. *
  603. * The master does not own the lock could call this function to force release the lock.
  604. *
  605. * @param base XRDC2 peripheral base address.
  606. * @param periph The peripheral to operate.
  607. */
  608. void XRDC2_ForcePeriphExclAccessLockRelease(XRDC2_Type *base, xrdc2_periph_t periph);
  609. /*@}*/
  610. #if defined(__cplusplus)
  611. }
  612. #endif
  613. /*!
  614. * @}
  615. */
  616. #endif /* _FSL_XRDC2_H_ */