mirror of
https://github.com/eclipse-threadx/levelx.git
synced 2026-09-14 12:37:01 +08:00
Fixed NOR extended cache zero base handling
Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
co-authored by
Codex
parent
3729d2f2c2
commit
6122a080be
@@ -9,6 +9,8 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
// Some portions generated by Codex (GPT-5).
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
@@ -76,15 +78,19 @@ UINT status;
|
||||
#ifndef LX_NOR_DISABLE_EXTENDED_CACHE
|
||||
|
||||
UINT i;
|
||||
ULONG *block_start_address;
|
||||
ULONG *block_end_address;
|
||||
ULONG block_start_address;
|
||||
ULONG block_end_address;
|
||||
ULONG *cache_entry_start;
|
||||
ULONG *cache_entry_end;
|
||||
ULONG cache_entry_start_value;
|
||||
ULONG cache_entry_end_value;
|
||||
|
||||
|
||||
/* Calculate the block starting address. */
|
||||
block_start_address = nor_flash -> lx_nor_flash_base_address + (block * nor_flash -> lx_nor_flash_words_per_block);
|
||||
block_end_address = block_start_address + nor_flash -> lx_nor_flash_words_per_block;
|
||||
/* Calculate the block starting address.
|
||||
MISRA C:2012 Rule 11.4 deviation: NOR driver addresses may be logical
|
||||
address tokens, including zero, so compare address values without
|
||||
dereferencing them. */
|
||||
block_start_address = (ULONG)(nor_flash -> lx_nor_flash_base_address) + (block * nor_flash -> lx_nor_flash_words_per_block * sizeof(ULONG));
|
||||
block_end_address = block_start_address + (nor_flash -> lx_nor_flash_words_per_block * sizeof(ULONG));
|
||||
|
||||
/* Loop through the cache entries to see if there is a sector in cache. */
|
||||
for (i = 0; i < nor_flash -> lx_nor_flash_extended_cache_entries; i++)
|
||||
@@ -94,15 +100,21 @@ ULONG *cache_entry_end;
|
||||
|
||||
/* Determine the cache entry addresses. */
|
||||
cache_entry_start = nor_flash -> lx_nor_flash_extended_cache[i].lx_nor_flash_extended_cache_entry_sector_address;
|
||||
cache_entry_end = cache_entry_start + LX_NOR_SECTOR_SIZE;
|
||||
|
||||
/* Determine if the flash address in in the cache entry. */
|
||||
if ((cache_entry_start) && (block_start_address <= cache_entry_start) && (block_end_address > cache_entry_end))
|
||||
/* Determine if the cache entry is in the block being erased. */
|
||||
if (nor_flash -> lx_nor_flash_extended_cache[i].lx_nor_flash_extended_cache_entry_valid)
|
||||
{
|
||||
cache_entry_start_value = (ULONG)cache_entry_start;
|
||||
cache_entry_end_value = cache_entry_start_value + (LX_NOR_SECTOR_SIZE * sizeof(ULONG));
|
||||
|
||||
/* Yes, this cache entry is in the block to be erased so invalidate it. */
|
||||
nor_flash -> lx_nor_flash_extended_cache[i].lx_nor_flash_extended_cache_entry_sector_address = LX_NULL;
|
||||
nor_flash -> lx_nor_flash_extended_cache[i].lx_nor_flash_extended_cache_entry_access_count = 0;
|
||||
if ((block_start_address <= cache_entry_start_value) && (block_end_address > cache_entry_end_value))
|
||||
{
|
||||
|
||||
/* Yes, this cache entry is in the block to be erased so invalidate it. */
|
||||
nor_flash -> lx_nor_flash_extended_cache[i].lx_nor_flash_extended_cache_entry_sector_address = LX_NULL;
|
||||
nor_flash -> lx_nor_flash_extended_cache[i].lx_nor_flash_extended_cache_entry_access_count = 0;
|
||||
nor_flash -> lx_nor_flash_extended_cache[i].lx_nor_flash_extended_cache_entry_valid = LX_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -117,5 +129,3 @@ ULONG *cache_entry_end;
|
||||
/* Return completion status. */
|
||||
return(status);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user