RTEMS 6.1-rc6
Loading...
Searching...
No Matches
fsl_xrdc2.h
1/*
2 * Copyright 2019-2020 NXP
3 * All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8#ifndef _FSL_XRDC2_H_
9#define _FSL_XRDC2_H_
10
11#include "fsl_common.h"
12
18/******************************************************************************
19 * Definitions
20 *****************************************************************************/
22#define FSL_XRDC2_DRIVER_VERSION (MAKE_VERSION(2, 0, 2))
23
24/* Definitions for XRDC2 Exclusive access lock. */
25#define XRDC2_EAL_FORCE_RELEASE_MAGIC_0 0x02000046UL
26#define XRDC2_EAL_FORCE_RELEASE_MAGIC_1 0x02000052UL
27
28#define XRDC2_EAL_DISABLE (0UL << XRDC2_MSC_MSAC_W1_EAL_SHIFT)
29#define XRDC2_EAL_DISABLE_UNTIL_RESET (1UL << XRDC2_MSC_MSAC_W1_EAL_SHIFT)
30#define XRDC2_EAL_UNLOCKED (2UL << XRDC2_MSC_MSAC_W1_EAL_SHIFT)
31#define XRDC2_EAL_LOCKED (3UL << XRDC2_MSC_MSAC_W1_EAL_SHIFT)
32
33#define XRDC2_EAL_MASK XRDC2_MSC_MSAC_W1_EAL_MASK
34
39{
45
51{
56
62{
67
76{
77 bool lock;
80 uint8_t domainId;
81 uint16_t mask;
82 uint16_t match;
84
89{
90 /* policy SecurePriv SecureUser NonSecurePriv NonSecureUsr */
91 kXRDC2_AccessPolicyNone = 0U, /* 000 none none none none */
92 kXRDC2_AccessPolicyAlt1 = 1U, /* 001 r r none none */
93 kXRDC2_AccessPolicyAlt2 = 2U, /* 010 r,w none none none */
94 kXRDC2_AccessPolicyAlt3 = 3U, /* 011 r,w r,w none none */
95 kXRDC2_AccessPolicyAlt4 = 4U, /* 100 r,w r,w r none */
96 kXRDC2_AccessPolicyAlt5 = 5U, /* 101 r,w r,w r r */
97 kXRDC2_AccessPolicyAlt6 = 6U, /* 110 r,w r,w r,w none */
98 kXRDC2_AccessPolicyAll = 7U /* 111 r,w r,w r,w r,w */
100
105{
111
116{
118 xrdc2_access_policy_t policy[FSL_FEATURE_XRDC2_DOMAIN_COUNT];
120
125{
126 uint32_t startAddr;
127 uint32_t endAddr;
129 xrdc2_access_policy_t policy[FSL_FEATURE_XRDC2_DOMAIN_COUNT];
131
136{
138 xrdc2_access_policy_t policy[FSL_FEATURE_XRDC2_DOMAIN_COUNT];
140
141/*******************************************************************************
142 * API
143 ******************************************************************************/
144
145#if defined(__cplusplus)
146extern "C" {
147#endif
148
154void XRDC2_Init(XRDC2_Type *base);
155
161void XRDC2_Deinit(XRDC2_Type *base);
162
177void XRDC2_SetGlobalValid(XRDC2_Type *base, bool valid);
178
187static inline uint8_t XRDC2_GetCurrentMasterDomainId(XRDC2_Type *base)
188{
189#if defined(XRDC2_SR_DIN_MASK)
190 return (uint8_t)((base->SR & XRDC2_SR_DIN_MASK) >> XRDC2_SR_DIN_SHIFT);
191#else
192 return (uint8_t)((base->SR & XRDC2_SR_DID_MASK) >> XRDC2_SR_DID_SHIFT);
193#endif
194}
195
204static inline void XRDC2_SetGlobalConfigLock(XRDC2_Type *base, xrdc2_global_config_lock_t mode)
205{
206 base->MCR = (base->MCR & ~XRDC2_MCR_GCL_MASK) | XRDC2_MCR_GCL(mode);
207}
208
215static inline uint8_t XRDC2_GetCurrentGlobalConfigLockOwnerDomainId(XRDC2_Type *base)
216{
217 return (uint8_t)((base->SR & XRDC2_SR_GCLO_MASK) >> XRDC2_SR_GCLO_SHIFT);
218}
219
244
254 xrdc2_master_t master,
255 uint8_t assignIndex,
256 const xrdc2_master_domain_assignment_t *assignment);
257
270static inline void XRDC2_LockMasterDomainAssignment(XRDC2_Type *base, xrdc2_master_t master, uint8_t assignIndex)
271{
272 base->MDACI_MDAJ[master][assignIndex].MDAC_MDA_W1 |= XRDC2_MDAC_MDA_W1_DL_MASK;
273}
274
287static inline void XRDC2_SetMasterDomainAssignmentValid(XRDC2_Type *base,
288 xrdc2_master_t master,
289 uint8_t assignIndex,
290 bool valid)
291{
292 if (valid)
293 {
294 base->MDACI_MDAJ[master][assignIndex].MDAC_MDA_W1 |= XRDC2_MDAC_MDA_W1_VLD_MASK;
295 }
296 else
297 {
298 base->MDACI_MDAJ[master][assignIndex].MDAC_MDA_W1 &= ~XRDC2_MDAC_MDA_W1_VLD_MASK;
299 }
300}
301
324
333 xrdc2_mem_slot_t memSlot,
335
343void XRDC2_SetMemSlotAccessValid(XRDC2_Type *base, xrdc2_mem_slot_t memSlot, bool valid);
344
352void XRDC2_SetMemSlotAccessLockMode(XRDC2_Type *base, xrdc2_mem_slot_t memSlot, xrdc2_access_config_lock_t lockMode);
353
363 xrdc2_mem_slot_t memSlot,
364 uint8_t domainId,
365 xrdc2_access_policy_t policy);
366
377void XRDC2_EnableMemSlotExclAccessLock(XRDC2_Type *base, xrdc2_mem_slot_t memSlot, bool enable);
378
386uint8_t XRDC2_GetMemSlotExclAccessLockDomainOwner(XRDC2_Type *base, xrdc2_mem_slot_t memSlot);
387
396status_t XRDC2_TryLockMemSlotExclAccess(XRDC2_Type *base, xrdc2_mem_slot_t memSlot);
397
406void XRDC2_LockMemSlotExclAccess(XRDC2_Type *base, xrdc2_mem_slot_t memSlot);
407
416static inline void XRDC2_UnlockMemSlotExclAccess(XRDC2_Type *base, xrdc2_mem_slot_t memSlot)
417{
418 base->MSCI_MSAC_WK[(uint32_t)memSlot].MSC_MSAC_W1 = XRDC2_EAL_UNLOCKED;
419}
420
429static inline void XRDC2_ForceMemSlotExclAccessLockRelease(XRDC2_Type *base, xrdc2_mem_slot_t memSlot)
430{
431 base->MSCI_MSAC_WK[(uint32_t)memSlot].MSC_MSAC_W1 = XRDC2_EAL_FORCE_RELEASE_MAGIC_0;
432 base->MSCI_MSAC_WK[(uint32_t)memSlot].MSC_MSAC_W1 = XRDC2_EAL_FORCE_RELEASE_MAGIC_1;
433}
434
459
467void XRDC2_SetMemAccessConfig(XRDC2_Type *base, xrdc2_mem_t mem, const xrdc2_mem_access_config_t *config);
468
476void XRDC2_SetMemAccessValid(XRDC2_Type *base, xrdc2_mem_t mem, bool valid);
477
485void XRDC2_SetMemAccessLockMode(XRDC2_Type *base, xrdc2_mem_t mem, xrdc2_access_config_lock_t lockMode);
486
495void XRDC2_SetMemDomainAccessPolicy(XRDC2_Type *base, xrdc2_mem_t mem, uint8_t domainId, xrdc2_access_policy_t policy);
496
506void XRDC2_EnableMemExclAccessLock(XRDC2_Type *base, xrdc2_mem_t mem, bool enable);
507
515uint8_t XRDC2_GetMemExclAccessLockDomainOwner(XRDC2_Type *base, xrdc2_mem_t mem);
516
525status_t XRDC2_TryLockMemExclAccess(XRDC2_Type *base, xrdc2_mem_t mem);
526
535void XRDC2_LockMemExclAccess(XRDC2_Type *base, xrdc2_mem_t mem);
536
545void XRDC2_UnlockMemExclAccess(XRDC2_Type *base, xrdc2_mem_t mem);
546
555void XRDC2_ForceMemExclAccessLockRelease(XRDC2_Type *base, xrdc2_mem_t mem);
556
579
587void XRDC2_SetPeriphAccessConfig(XRDC2_Type *base, xrdc2_periph_t periph, const xrdc2_periph_access_config_t *config);
588
596void XRDC2_SetPeriphAccessValid(XRDC2_Type *base, xrdc2_periph_t periph, bool valid);
597
605void XRDC2_SetPeriphAccessLockMode(XRDC2_Type *base, xrdc2_periph_t periph, xrdc2_access_config_lock_t lockMode);
606
616 xrdc2_periph_t periph,
617 uint8_t domainId,
618 xrdc2_access_policy_t policy);
619
629void XRDC2_EnablePeriphExclAccessLock(XRDC2_Type *base, xrdc2_periph_t periph, bool enable);
630
638uint8_t XRDC2_GetPeriphExclAccessLockDomainOwner(XRDC2_Type *base, xrdc2_periph_t periph);
639
648status_t XRDC2_TryLockPeriphExclAccess(XRDC2_Type *base, xrdc2_periph_t periph);
649
658void XRDC2_LockPeriphExclAccess(XRDC2_Type *base, xrdc2_periph_t periph);
659
668void XRDC2_UnlockPeriphExclAccess(XRDC2_Type *base, xrdc2_periph_t periph);
669
678void XRDC2_ForcePeriphExclAccessLockRelease(XRDC2_Type *base, xrdc2_periph_t periph);
679
682#if defined(__cplusplus)
683}
684#endif
685
690#endif /* _FSL_XRDC2_H_ */
#define XRDC2_MCR_GCL(x)
Definition: MIMXRT1166_cm4.h:93253
int32_t status_t
Type used for all status and error return values.
Definition: fsl_common.h:225
enum _xrdc2_master xrdc2_master_t
Structure for the XRDC2 mapping.
void XRDC2_LockMemSlotExclAccess(XRDC2_Type *base, xrdc2_mem_slot_t memSlot)
Lock the memory slot exclusive access using blocking method.
Definition: fsl_xrdc2.c:377
void XRDC2_SetPeriphAccessConfig(XRDC2_Type *base, xrdc2_periph_t periph, const xrdc2_periph_access_config_t *config)
Sets the peripheral access policy.
Definition: fsl_xrdc2.c:699
bool lock
Definition: fsl_xrdc2.h:77
struct _xrdc2_mem_access_config xrdc2_mem_access_config_t
XRDC2 memory region domain access control configuration.
xrdc2_privilege_attr_t privilegeAttr
Definition: fsl_xrdc2.h:78
enum _xrdc2_privilege_attr xrdc2_privilege_attr_t
XRDC2 privileged attribute, the register bit MDACi_MDAj_W0[PA], defines the privileged/user attribute...
uint8_t XRDC2_GetMemExclAccessLockDomainOwner(XRDC2_Type *base, xrdc2_mem_t mem)
Get current memory region exclusive access lock owner.
Definition: fsl_xrdc2.c:560
xrdc2_access_config_lock_t lockMode
Definition: fsl_xrdc2.h:137
void XRDC2_GetMemAccessDefaultConfig(xrdc2_mem_access_config_t *config)
Gets the default memory access configuration.
Definition: fsl_xrdc2.c:414
void XRDC2_SetMemDomainAccessPolicy(XRDC2_Type *base, xrdc2_mem_t mem, uint8_t domainId, xrdc2_access_policy_t policy)
Sets the memory region access policy for specific domain.
Definition: fsl_xrdc2.c:509
void XRDC2_GetPeriphAccessDefaultConfig(xrdc2_periph_access_config_t *config)
Gets the default peripheral access configuration.
Definition: fsl_xrdc2.c:679
struct _xrdc2_mem_slot_access_config xrdc2_mem_slot_access_config_t
XRDC2 memory slot domain access control configuration.
uint8_t XRDC2_GetMemSlotExclAccessLockDomainOwner(XRDC2_Type *base, xrdc2_mem_slot_t memSlot)
Get current memory slot exclusive access lock owner.
Definition: fsl_xrdc2.c:333
uint8_t XRDC2_GetPeriphExclAccessLockDomainOwner(XRDC2_Type *base, xrdc2_periph_t periph)
Get current peripheral exclusive access lock owner.
Definition: fsl_xrdc2.c:796
uint32_t endAddr
Definition: fsl_xrdc2.h:127
void XRDC2_SetMasterDomainAssignment(XRDC2_Type *base, xrdc2_master_t master, uint8_t assignIndex, const xrdc2_master_domain_assignment_t *assignment)
Sets the processor bus master domain assignment.
Definition: fsl_xrdc2.c:162
enum _xrdc2_access_config_lock xrdc2_access_config_lock_t
Access configuration lock mode, the register field PDAC and MRGD LK2.
status_t XRDC2_TryLockMemExclAccess(XRDC2_Type *base, xrdc2_mem_t mem)
Try to lock the memory region exclusive access.
Definition: fsl_xrdc2.c:577
void XRDC2_Deinit(XRDC2_Type *base)
De-initializes the XRDC2 module.
Definition: fsl_xrdc2.c:91
void XRDC2_EnableMemExclAccessLock(XRDC2_Type *base, xrdc2_mem_t mem, bool enable)
Enable or disable the memory region exclusive access lock.
Definition: fsl_xrdc2.c:538
void XRDC2_ForceMemExclAccessLockRelease(XRDC2_Type *base, xrdc2_mem_t mem)
Force the memory region exclusive access lock release.
Definition: fsl_xrdc2.c:656
xrdc2_access_policy_t policy[FSL_FEATURE_XRDC2_DOMAIN_COUNT]
Definition: fsl_xrdc2.h:138
uint16_t match
Definition: fsl_xrdc2.h:82
void XRDC2_EnableMemSlotExclAccessLock(XRDC2_Type *base, xrdc2_mem_slot_t memSlot, bool enable)
Enable or disable the memory slot exclusive access lock.
Definition: fsl_xrdc2.c:314
void XRDC2_LockMemExclAccess(XRDC2_Type *base, xrdc2_mem_t mem)
Lock the memory region exclusive access using blocking method.
Definition: fsl_xrdc2.c:609
void XRDC2_SetMemAccessConfig(XRDC2_Type *base, xrdc2_mem_t mem, const xrdc2_mem_access_config_t *config)
Sets the memory region access policy.
Definition: fsl_xrdc2.c:436
uint8_t domainId
Definition: fsl_xrdc2.h:80
void XRDC2_SetMemAccessValid(XRDC2_Type *base, xrdc2_mem_t mem, bool valid)
Sets the memory region descriptor as valid or invalid.
Definition: fsl_xrdc2.c:469
uint32_t startAddr
Definition: fsl_xrdc2.h:126
_xrdc2_privilege_attr
XRDC2 privileged attribute, the register bit MDACi_MDAj_W0[PA], defines the privileged/user attribute...
Definition: fsl_xrdc2.h:62
void XRDC2_LockPeriphExclAccess(XRDC2_Type *base, xrdc2_periph_t periph)
Lock the peripheral exclusive access using blocking method.
Definition: fsl_xrdc2.c:870
void XRDC2_ForcePeriphExclAccessLockRelease(XRDC2_Type *base, xrdc2_periph_t periph)
Force the peripheral exclusive access lock release.
Definition: fsl_xrdc2.c:918
void XRDC2_SetMemSlotAccessLockMode(XRDC2_Type *base, xrdc2_mem_slot_t memSlot, xrdc2_access_config_lock_t lockMode)
Sets the memory slot descriptor lock mode.
Definition: fsl_xrdc2.c:267
void XRDC2_SetMemSlotAccessConfig(XRDC2_Type *base, xrdc2_mem_slot_t memSlot, const xrdc2_mem_slot_access_config_t *config)
Sets the memory slot access policy.
Definition: fsl_xrdc2.c:221
_xrdc2_global_config_lock
Global configuration lock.
Definition: fsl_xrdc2.h:39
uint16_t mask
Definition: fsl_xrdc2.h:81
status_t XRDC2_TryLockPeriphExclAccess(XRDC2_Type *base, xrdc2_periph_t periph)
Try to lock the peripheral exclusive access.
Definition: fsl_xrdc2.c:837
void XRDC2_UnlockMemExclAccess(XRDC2_Type *base, xrdc2_mem_t mem)
Unlock the memory region exclusive access.
Definition: fsl_xrdc2.c:640
_xrdc2_access_config_lock
Access configuration lock mode, the register field PDAC and MRGD LK2.
Definition: fsl_xrdc2.h:105
status_t XRDC2_TryLockMemSlotExclAccess(XRDC2_Type *base, xrdc2_mem_slot_t memSlot)
Try to lock the memory slot exclusive access.
Definition: fsl_xrdc2.c:347
xrdc2_secure_attr_t secureAttr
Definition: fsl_xrdc2.h:79
enum _xrdc2_global_config_lock xrdc2_global_config_lock_t
Global configuration lock.
enum _xrdc2_access_policy xrdc2_access_policy_t
XRDC2 domain access control policy.
void XRDC2_SetMemAccessLockMode(XRDC2_Type *base, xrdc2_mem_t mem, xrdc2_access_config_lock_t lockMode)
Sets the memory descriptor lock mode.
Definition: fsl_xrdc2.c:492
void XRDC2_UnlockPeriphExclAccess(XRDC2_Type *base, xrdc2_periph_t periph)
Unlock the peripheral exclusive access.
Definition: fsl_xrdc2.c:902
struct _xrdc2_periph_access_config xrdc2_periph_access_config_t
XRDC2 peripheral domain access control configuration.
void XRDC2_SetGlobalValid(XRDC2_Type *base, bool valid)
Sets the XRDC2 global valid.
Definition: fsl_xrdc2.c:104
void XRDC2_GetMemSlotAccessDefaultConfig(xrdc2_mem_slot_access_config_t *config)
Gets the default memory slot access configuration.
Definition: fsl_xrdc2.c:201
xrdc2_access_config_lock_t lockMode
Definition: fsl_xrdc2.h:128
void XRDC2_SetPeriphAccessLockMode(XRDC2_Type *base, xrdc2_periph_t periph, xrdc2_access_config_lock_t lockMode)
Sets the peripheral descriptor lock mode.
Definition: fsl_xrdc2.c:748
struct _xrdc2_master_domain_assignment xrdc2_master_domain_assignment_t
Domain assignment for the bus master.
void XRDC2_SetPeriphAccessValid(XRDC2_Type *base, xrdc2_periph_t periph, bool valid)
Sets the peripheral descriptor as valid or invalid.
Definition: fsl_xrdc2.c:725
void XRDC2_EnablePeriphExclAccessLock(XRDC2_Type *base, xrdc2_periph_t periph, bool enable)
Disable the peripheral exclusive access lock.
Definition: fsl_xrdc2.c:814
xrdc2_access_policy_t policy[FSL_FEATURE_XRDC2_DOMAIN_COUNT]
Definition: fsl_xrdc2.h:129
_xrdc2_access_policy
XRDC2 domain access control policy.
Definition: fsl_xrdc2.h:89
void XRDC2_GetDefaultMasterDomainAssignment(xrdc2_master_domain_assignment_t *assignment)
Gets the default master domain assignment.
Definition: fsl_xrdc2.c:142
xrdc2_access_policy_t policy[FSL_FEATURE_XRDC2_DOMAIN_COUNT]
Definition: fsl_xrdc2.h:118
xrdc2_access_config_lock_t lockMode
Definition: fsl_xrdc2.h:117
void XRDC2_Init(XRDC2_Type *base)
Initializes the XRDC2 module.
Definition: fsl_xrdc2.c:80
_xrdc2_secure_attr
XRDC2 secure attribute, the register bit MDACi_MDAj_W0[SA], secure/nonsecure attribute output on a hi...
Definition: fsl_xrdc2.h:51
void XRDC2_SetPeriphDomainAccessPolicy(XRDC2_Type *base, xrdc2_periph_t periph, uint8_t domainId, xrdc2_access_policy_t policy)
Sets the peripheral access policy for specific domain.
Definition: fsl_xrdc2.c:765
void XRDC2_SetMemSlotAccessValid(XRDC2_Type *base, xrdc2_mem_slot_t memSlot, bool valid)
Sets the memory slot descriptor as valid or invalid.
Definition: fsl_xrdc2.c:246
void XRDC2_SetMemSlotDomainAccessPolicy(XRDC2_Type *base, xrdc2_mem_slot_t memSlot, uint8_t domainId, xrdc2_access_policy_t policy)
Sets the memory slot access policy for specific domain.
Definition: fsl_xrdc2.c:282
enum _xrdc2_secure_attr xrdc2_secure_attr_t
XRDC2 secure attribute, the register bit MDACi_MDAj_W0[SA], secure/nonsecure attribute output on a hi...
@ kXRDC2_ForcePrivilege
Definition: fsl_xrdc2.h:65
@ kXRDC2_ForceUser
Definition: fsl_xrdc2.h:64
@ kXRDC2_MasterPrivilege
Definition: fsl_xrdc2.h:63
@ kXRDC2_GlobalConfigLockDisabledUntilReset
Definition: fsl_xrdc2.h:41
@ kXRDC2_GlobalConfigLockOwnerOnly
Definition: fsl_xrdc2.h:42
@ kXRDC2_GlobalConfigLockEnabledUntilReset
Definition: fsl_xrdc2.h:43
@ kXRDC2_GlobalConfigLockDisabled
Definition: fsl_xrdc2.h:40
@ kXRDC2_AccessConfigLockDisabled
Definition: fsl_xrdc2.h:106
@ kXRDC2_AccessConfigLockDisabledUntilReset
Definition: fsl_xrdc2.h:107
@ kXRDC2_AccessConfigLockDomainXOnly
Definition: fsl_xrdc2.h:108
@ kXRDC2_AccessConfigLockEnabledUntilReset
Definition: fsl_xrdc2.h:109
@ kXRDC2_ForceSecure
Definition: fsl_xrdc2.h:53
@ kXRDC2_MasterSecure
Definition: fsl_xrdc2.h:52
@ kXRDC2_ForceNonSecure
Definition: fsl_xrdc2.h:54
Definition: MIMXRT1166_cm4.h:93188
Domain assignment for the bus master.
Definition: fsl_xrdc2.h:76
XRDC2 memory region domain access control configuration.
Definition: fsl_xrdc2.h:125
XRDC2 memory slot domain access control configuration.
Definition: fsl_xrdc2.h:136
XRDC2 peripheral domain access control configuration.
Definition: fsl_xrdc2.h:116
Definition: deflate.c:114