aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/SAMA/LLD/CRYPTOv1/sama_aes_lld.c
diff options
context:
space:
mode:
Diffstat (limited to 'os/hal/ports/SAMA/LLD/CRYPTOv1/sama_aes_lld.c')
-rw-r--r--os/hal/ports/SAMA/LLD/CRYPTOv1/sama_aes_lld.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/os/hal/ports/SAMA/LLD/CRYPTOv1/sama_aes_lld.c b/os/hal/ports/SAMA/LLD/CRYPTOv1/sama_aes_lld.c
index da66978fc..bbe51ab20 100644
--- a/os/hal/ports/SAMA/LLD/CRYPTOv1/sama_aes_lld.c
+++ b/os/hal/ports/SAMA/LLD/CRYPTOv1/sama_aes_lld.c
@@ -112,6 +112,7 @@ cryerror_t sama_aes_lld_process_polling(CRYDriver *cryp, aesparams *params,
uint32_t i;
cryerror_t ret;
+ osalMutexLock(&cryp->mutex);
//AES soft reset
AES->AES_CR = AES_CR_SWRST;
@@ -125,11 +126,11 @@ cryerror_t sama_aes_lld_process_polling(CRYDriver *cryp, aesparams *params,
AES->AES_MR |= (AES_MR_CFBS(cryp->config->cfbs) | AES_MR_CKEY_PASSWD);
- osalMutexLock(&cryp->mutex);
+
sama_aes_lld_write_key(cryp->key0_buffer,( const uint32_t *) params->iv, cryp->key0_size);
- osalMutexUnlock(&cryp->mutex);
+
if (params->encrypt)
AES->AES_MR |= AES_MR_CIPHER;
@@ -156,6 +157,8 @@ cryerror_t sama_aes_lld_process_polling(CRYDriver *cryp, aesparams *params,
}
+ osalMutexUnlock(&cryp->mutex);
+
return CRY_NOERROR;
}
@@ -167,6 +170,8 @@ cryerror_t sama_aes_lld_process_dma(CRYDriver *cryp, aesparams *params,
osalDbgAssert(cryp->thread == NULL, "already waiting");
+ osalMutexLock(&cryp->mutex);
+
//set chunk size
cryp->dmachunksize = DMA_CHUNK_SIZE_4;
@@ -230,12 +235,8 @@ cryerror_t sama_aes_lld_process_dma(CRYDriver *cryp, aesparams *params,
AES->AES_MR |= (AES_MR_CFBS(cryp->config->cfbs) | AES_MR_CKEY_PASSWD);
- osalMutexLock(&cryp->mutex);
-
sama_aes_lld_write_key(cryp->key0_buffer,( const uint32_t *) params->iv, cryp->key0_size);
- osalMutexUnlock(&cryp->mutex);
-
if (params->encrypt)
AES->AES_MR |= AES_MR_CIPHER;
else
@@ -258,6 +259,8 @@ cryerror_t sama_aes_lld_process_dma(CRYDriver *cryp, aesparams *params,
osalSysUnlock();
+ osalMutexUnlock(&cryp->mutex);
+
return CRY_NOERROR;
}