mirror of
https://github.com/eclipse-threadx/levelx.git
synced 2026-09-14 12:37:01 +08:00
Fixed NOR extended cache size validation
Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
co-authored by
Codex
parent
4005a425b7
commit
c232f9f8e3
@@ -9,6 +9,8 @@
|
|||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
|
// Some portions generated by Codex (GPT-5).
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
@@ -93,8 +95,11 @@ ULONG block_word;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Calculate cache size in words. */
|
||||||
|
cache_size = size / sizeof(ULONG);
|
||||||
|
|
||||||
/* Determine if memory was specified but with an invalid size (less than one NOR sector). */
|
/* Determine if memory was specified but with an invalid size (less than one NOR sector). */
|
||||||
if ((memory) && (size < LX_NOR_SECTOR_SIZE))
|
if ((memory) && (cache_size < LX_NOR_SECTOR_SIZE))
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Error in memory size supplied. */
|
/* Error in memory size supplied. */
|
||||||
@@ -110,9 +115,6 @@ ULONG block_word;
|
|||||||
/* Initialize the internal NOR cache. */
|
/* Initialize the internal NOR cache. */
|
||||||
nor_flash -> lx_nor_flash_extended_cache_entries = 0;
|
nor_flash -> lx_nor_flash_extended_cache_entries = 0;
|
||||||
|
|
||||||
/* Calculate cache size in words. */
|
|
||||||
cache_size = size/sizeof(ULONG);
|
|
||||||
|
|
||||||
/* Setup cache memory pointer. */
|
/* Setup cache memory pointer. */
|
||||||
cache_memory = (ULONG *) memory;
|
cache_memory = (ULONG *) memory;
|
||||||
|
|
||||||
@@ -317,5 +319,3 @@ ULONG block_word;
|
|||||||
return(LX_DISABLED);
|
return(LX_DISABLED);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
/* SPDX-License-Identifier: MIT */
|
/* SPDX-License-Identifier: MIT */
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
|
|
||||||
|
// Some portions generated by Codex (GPT-5).
|
||||||
|
|
||||||
/* Basic NOR flash tests... */
|
/* Basic NOR flash tests... */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -31,6 +33,7 @@ ULONG readbuffer[128];
|
|||||||
|
|
||||||
UCHAR nor_cache_memory[2048+16+8];
|
UCHAR nor_cache_memory[2048+16+8];
|
||||||
UCHAR nor_cache_memory2[8192];
|
UCHAR nor_cache_memory2[8192];
|
||||||
|
UCHAR nor_cache_memory_invalid[256];
|
||||||
|
|
||||||
|
|
||||||
/* Define LevelX NOR flash simulator prototoypes. */
|
/* Define LevelX NOR flash simulator prototoypes. */
|
||||||
@@ -1592,7 +1595,25 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
|||||||
/* Open the flash. */
|
/* Open the flash. */
|
||||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||||
#ifndef LX_NOR_DISABLE_EXTENDED_CACHE
|
#ifndef LX_NOR_DISABLE_EXTENDED_CACHE
|
||||||
status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory2, sizeof(nor_cache_memory2));
|
if (status == LX_SUCCESS)
|
||||||
|
{
|
||||||
|
|
||||||
|
status = lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory_invalid, sizeof(nor_cache_memory_invalid));
|
||||||
|
|
||||||
|
if (status != LX_ERROR)
|
||||||
|
{
|
||||||
|
|
||||||
|
printf("FAILED!\n");
|
||||||
|
#ifdef BATCH_TEST
|
||||||
|
exit(1);
|
||||||
|
#endif
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
status = lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory2, sizeof(nor_cache_memory2));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (status != LX_SUCCESS)
|
if (status != LX_SUCCESS)
|
||||||
@@ -1668,5 +1689,3 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory2,
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user