mirror of
https://github.com/polhenarejos/pico-hsm.git
synced 2026-05-03 21:36:25 +00:00
Adding some mutex to improve concurrency.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
parent
3781777138
commit
b61575bbc3
1 changed files with 4 additions and 4 deletions
|
|
@ -153,8 +153,8 @@ int flash_program_block(uintptr_t addr, const uint8_t *data, size_t len) {
|
|||
}
|
||||
if (!(p = find_free_page(addr)))
|
||||
{
|
||||
DEBUG_INFO("ERROR: FLASH CANNOT FIND A PAGE (rare error)\r\n");
|
||||
mutex_exit(&mtx_flash);
|
||||
DEBUG_INFO("ERROR: FLASH CANNOT FIND A PAGE (rare error)\r\n");
|
||||
return HSM_ERR_MEMORY_FATAL;
|
||||
}
|
||||
memcpy(&p->page[addr&(FLASH_SECTOR_SIZE-1)], data, len);
|
||||
|
|
@ -177,19 +177,19 @@ int flash_program_uintptr (uintptr_t addr, uintptr_t data) {
|
|||
|
||||
uint8_t *flash_read(uintptr_t addr) {
|
||||
uintptr_t addr_alg = addr & -FLASH_SECTOR_SIZE;
|
||||
//mutex_enter_blocking(&mtx_flash);
|
||||
mutex_enter_blocking(&mtx_flash);
|
||||
if (ready_pages > 0) {
|
||||
for (int r = 0; r < TOTAL_FLASH_PAGES; r++)
|
||||
{
|
||||
if (flash_pages[r].ready && flash_pages[r].address == addr_alg) {
|
||||
uint8_t *v = &flash_pages[r].page[addr&(FLASH_SECTOR_SIZE-1)];
|
||||
//mutex_exit(&mtx_flash);
|
||||
mutex_exit(&mtx_flash);
|
||||
return v;
|
||||
}
|
||||
}
|
||||
}
|
||||
uint8_t *v = (uint8_t *)addr;
|
||||
//mutex_exit(&mtx_flash);
|
||||
mutex_exit(&mtx_flash);
|
||||
return v;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue