Skip to content

Commit

Permalink
Platform: Nordic: Port spu_peripheral_config
Browse files Browse the repository at this point in the history
Port spu_peripheral_config to also support the new API.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Change-Id: I1763874ce74ad39cbf0ef256ef8edc669038d226
  • Loading branch information
SebastianBoe committed May 16, 2024
1 parent 5d8b824 commit 3f49abf
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions platform/ext/target/nordic_nrf/common/core/native_drivers/spu.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,13 @@ uint32_t spu_regions_sram_get_region_size(void) {
return SRAM_SECURE_ATTRIBUTION_REGION_SIZE;
}

#endif /* NRF_SPU_HAS_MEMORY */

void spu_peripheral_config_secure(const uint32_t periph_base_address, bool periph_lock)
{
uint8_t periph_id = NRFX_PERIPHERAL_ID_GET(periph_base_address);

#if NRF_SPU_HAS_MEMORY
/* ASSERT checking that this is not an explicit Non-Secure peripheral */
NRFX_ASSERT((NRF_SPU->PERIPHID[periph_id].PERM &
SPU_PERIPHID_PERM_SECUREMAPPING_Msk) !=
Expand All @@ -297,12 +300,26 @@ void spu_peripheral_config_secure(const uint32_t periph_base_address, bool perip
1 /* Secure */,
1 /* Secure DMA */,
periph_lock);

#else

NRF_SPU_Type * nrf_spu = spu_instance_from_peripheral_addr(periph_base_address);

uint8_t spu_id = NRFX_PERIPHERAL_ID_GET(nrf_spu);

uint8_t index = periph_id - spu_id;

nrf_spu_periph_perm_secattr_set(nrf_spu, index, true /* Secure */);
nrf_spu_periph_perm_dmasec_set(nrf_spu, index, true /* Secure */);
nrf_spu_periph_perm_lock_enable(nrf_spu, index);
#endif
}

void spu_peripheral_config_non_secure(const uint32_t periph_base_address, bool periph_lock)
{
uint8_t periph_id = NRFX_PERIPHERAL_ID_GET(periph_base_address);

#if NRF_SPU_HAS_MEMORY
/* ASSERT checking that this is not an explicit Secure peripheral */
NRFX_ASSERT((NRF_SPU->PERIPHID[periph_id].PERM &
SPU_PERIPHID_PERM_SECUREMAPPING_Msk) !=
Expand All @@ -313,4 +330,15 @@ void spu_peripheral_config_non_secure(const uint32_t periph_base_address, bool p
0 /* Non-Secure */,
0 /* Non-Secure DMA */,
periph_lock);
#else
NRF_SPU_Type * nrf_spu = spu_instance_from_peripheral_addr(periph_base_address);

uint8_t spu_id = NRFX_PERIPHERAL_ID_GET(nrf_spu);

uint8_t index = periph_id - spu_id;

nrf_spu_periph_perm_secattr_set(nrf_spu, index, false /* Non-Secure */);
nrf_spu_periph_perm_dmasec_set(nrf_spu, index, false /* Non-Secure */);
nrf_spu_periph_perm_lock_enable(nrf_spu, index);
#endif
}

0 comments on commit 3f49abf

Please sign in to comment.