mirror of
https://github.com/eclipse-threadx/levelx.git
synced 2026-09-14 04:06:00 +08:00
Merge pull request #68 from fdesbiens/dev
Updated copyright headers and version number constants
This commit is contained in:
+41
-96
@@ -1,19 +1,20 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
* Portion Copyright (c) 2025 STMicroelectronics
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** Application Interface (API) */
|
||||
/** */
|
||||
@@ -37,62 +38,6 @@
|
||||
/* high-performance LevelX. All service prototypes and data structure */
|
||||
/* definitions are defined in this file. */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), and */
|
||||
/* updated product constants, */
|
||||
/* resulting in version 6.1 */
|
||||
/* 11-09-2020 William E. Lamie Modified comment(s), and */
|
||||
/* added support for lx_user.h */
|
||||
/* so user can specify values, */
|
||||
/* resulting in version 6.1.2 */
|
||||
/* 12-31-2020 William E. Lamie Modified comment(s), and */
|
||||
/* updated product constants, */
|
||||
/* resulting in version 6.1.3 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* added standalone support, */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* 08-02-2021 William E. Lamie Modified comment(s), and */
|
||||
/* updated product constants, */
|
||||
/* resulting in version 6.1.8 */
|
||||
/* 10-15-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* updated configuration for */
|
||||
/* nand flash */
|
||||
/* resulting in version 6.1.9 */
|
||||
/* 01-31-2022 Bhupendra Naphade Modified comment(s), */
|
||||
/* updated include order for */
|
||||
/* standalone mode, */
|
||||
/* resulting in version 6.1.10 */
|
||||
/* 04-25-2022 William E. Lamie Modified comment(s), and */
|
||||
/* updated product constants, */
|
||||
/* resulting in version 6.1.11 */
|
||||
/* 07-29-2022 William E. Lamie Modified comment(s), and */
|
||||
/* updated product constants, */
|
||||
/* resulting in version 6.1.12 */
|
||||
/* 10-31-2022 Xiuwen Cai Modified comment(s), and */
|
||||
/* updated product constants, */
|
||||
/* resulting in version 6.2.0 */
|
||||
/* 03-08-2023 Xiuwen Cai Modified comment(s), */
|
||||
/* modified NAND logic, */
|
||||
/* added new driver interface */
|
||||
/* and user extension, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* 10-31-2023 Xiuwen Cai Modified comment(s), */
|
||||
/* made LX_NOR_SECTOR_SIZE */
|
||||
/* configurable, added mapping */
|
||||
/* bitmap and obsolete count */
|
||||
/* cache for NOR flash, */
|
||||
/* resulting in version 6.3.0 */
|
||||
/* 12-31-2023 Xiuwen Cai Modified comment(s), */
|
||||
/* added configuration checks, */
|
||||
/* resulting in version 6.4.0 */
|
||||
/* 03-01-2024 Tiejun Zhou Modified comment(s), */
|
||||
/* update version number, */
|
||||
/* resulting in version 6.4.1 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef LX_API_H
|
||||
@@ -114,7 +59,7 @@ extern "C" {
|
||||
#ifdef LX_INCLUDE_USER_DEFINE_FILE
|
||||
|
||||
|
||||
/* Yes, include the user defines in lx_user.h. The defines in this file may
|
||||
/* Yes, include the user defines in lx_user.h. The defines in this file may
|
||||
alternately be defined on the command line. */
|
||||
|
||||
#include "lx_user.h"
|
||||
@@ -203,9 +148,9 @@ typedef unsigned long long ULONG64;
|
||||
/* Define basic constants for the LevelX Stack. */
|
||||
#define AZURE_RTOS_LEVELX
|
||||
#define LEVELX_MAJOR_VERSION 6
|
||||
#define LEVELX_MINOR_VERSION 4
|
||||
#define LEVELX_PATCH_VERSION 5
|
||||
#define LEVELX_BUILD_VERSION 202504
|
||||
#define LEVELX_MINOR_VERSION 5
|
||||
#define LEVELX_PATCH_VERSION 0
|
||||
#define LEVELX_BUILD_VERSION 202601
|
||||
#define LEVELX_HOTFIX_VERSION ' '
|
||||
|
||||
|
||||
@@ -240,7 +185,7 @@ typedef unsigned long long ULONG64;
|
||||
#define LX_SYSTEM_INVALID_BLOCK 91
|
||||
#define LX_SYSTEM_ALLOCATION_FAILED 92
|
||||
#define LX_SYSTEM_MUTEX_CREATE_FAILED 93
|
||||
#define LX_SYSTEM_INVALID_SECTOR_MAP 94
|
||||
#define LX_SYSTEM_INVALID_SECTOR_MAP 94
|
||||
|
||||
|
||||
/* Define NOR flash constants. */
|
||||
@@ -269,9 +214,9 @@ typedef unsigned long long ULONG64;
|
||||
#endif
|
||||
|
||||
|
||||
/* Define the mask for the hash index into the sector mapping cache table. The sector mapping cache is divided
|
||||
into 4 entry pieces that are indexed by the formula:
|
||||
|
||||
/* Define the mask for the hash index into the sector mapping cache table. The sector mapping cache is divided
|
||||
into 4 entry pieces that are indexed by the formula:
|
||||
|
||||
index = (sector & LX_NOR_SECTOR_MAPPING_CACHE_HASH_MASK) * LX_NOR_SECTOR_MAPPING_CACHE_DEPTH
|
||||
|
||||
The LX_NOR_SECTOR_MAPPING_CACHE_DEPTH define must not be changed unless the related source code is also changed. */
|
||||
@@ -312,22 +257,22 @@ typedef unsigned long long ULONG64;
|
||||
|
||||
/* Define the NAND sector mapping cache. */
|
||||
|
||||
#define LX_NAND_SECTOR_MAPPING_CACHE_DEPTH 4 /* Not required if LX_NAND_FLASH_DIRECT_MAPPING_CACHE is defined. */
|
||||
#define LX_NAND_SECTOR_MAPPING_CACHE_DEPTH 4 /* Not required if LX_NAND_FLASH_DIRECT_MAPPING_CACHE is defined. */
|
||||
#ifndef LX_NAND_SECTOR_MAPPING_CACHE_SIZE
|
||||
#define LX_NAND_SECTOR_MAPPING_CACHE_SIZE 128 /* Minimum value of 8, all sizes must be a power of 2, unless direct
|
||||
mapping is defined, in which there is no power of 2 requirement. */
|
||||
#endif
|
||||
#ifndef LX_NAND_ERASE_COUNT_WRITE_SIZE
|
||||
#define LX_NAND_ERASE_COUNT_WRITE_SIZE (nand_flash -> lx_nand_flash_pages_per_block + 1)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef LX_NAND_FLASH_MAPPING_LIST_UPDATE_DISABLE
|
||||
#define LX_NAND_FLASH_MAPPING_LIST_UPDATE_DISABLE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef LX_NAND_FLASH_MAX_METADATA_BLOCKS
|
||||
#define LX_NAND_FLASH_MAX_METADATA_BLOCKS 4
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef LX_UTILITY_SHORT_SET
|
||||
#define LX_UTILITY_SHORT_SET(address, value) *((USHORT*)(address)) = (USHORT)(value)
|
||||
@@ -345,9 +290,9 @@ typedef unsigned long long ULONG64;
|
||||
#define LX_UTILITY_LONG_GET(address) (*((ULONG*)(address)))
|
||||
#endif
|
||||
|
||||
/* Define the mask for the hash index into the NAND sector mapping cache table. The sector mapping cache is divided
|
||||
into 4 entry pieces that are indexed by the formula:
|
||||
|
||||
/* Define the mask for the hash index into the NAND sector mapping cache table. The sector mapping cache is divided
|
||||
into 4 entry pieces that are indexed by the formula:
|
||||
|
||||
index = (sector & LX_NAND_SECTOR_MAPPING_CACHE_HASH_MASK) * LX_NAND_SECTOR_MAPPING_CACHE_DEPTH
|
||||
|
||||
The LX_NAND_SECTOR_MAPPING_CACHE_DEPTH define must not be changed unless the related source code is also changed. */
|
||||
@@ -422,7 +367,7 @@ typedef struct LX_NAND_DEVICE_INFO_STRUCT
|
||||
} LX_NAND_DEVICE_INFO;
|
||||
|
||||
|
||||
/* Determine if the flash control block has an extension defined. If not,
|
||||
/* Determine if the flash control block has an extension defined. If not,
|
||||
define the extension to whitespace. */
|
||||
|
||||
#ifndef LX_NAND_FLASH_USER_EXTENSION
|
||||
@@ -509,7 +454,7 @@ typedef struct LX_NAND_FLASH_STRUCT
|
||||
UINT (*lx_nand_flash_driver_extra_bytes_get)(struct LX_NAND_FLASH_STRUCT *nand_flash, ULONG block, ULONG page, UCHAR *destination, UINT size);
|
||||
UINT (*lx_nand_flash_driver_extra_bytes_set)(struct LX_NAND_FLASH_STRUCT *nand_flash, ULONG block, ULONG page, UCHAR *source, UINT size);
|
||||
UINT (*lx_nand_flash_driver_system_error)(struct LX_NAND_FLASH_STRUCT *nand_flash, UINT error_code, ULONG block, ULONG page);
|
||||
|
||||
|
||||
UINT (*lx_nand_flash_driver_pages_read)(struct LX_NAND_FLASH_STRUCT *nand_flash, ULONG block, ULONG page, UCHAR* main_buffer, UCHAR* spare_buffer, ULONG pages);
|
||||
UINT (*lx_nand_flash_driver_pages_write)(struct LX_NAND_FLASH_STRUCT *nand_flash, ULONG block, ULONG page, UCHAR* main_buffer, UCHAR* spare_buffer, ULONG pages);
|
||||
UINT (*lx_nand_flash_driver_pages_copy)(struct LX_NAND_FLASH_STRUCT *nand_flash, ULONG source_block, ULONG source_page, ULONG destination_block, ULONG destination_page, ULONG pages, UCHAR* data_buffer);
|
||||
@@ -524,7 +469,7 @@ typedef struct LX_NAND_FLASH_STRUCT
|
||||
UINT (*lx_nand_flash_driver_extra_bytes_get)(ULONG block, ULONG page, UCHAR *destination, UINT size);
|
||||
UINT (*lx_nand_flash_driver_extra_bytes_set)(ULONG block, ULONG page, UCHAR *source, UINT size);
|
||||
UINT (*lx_nand_flash_driver_system_error)(UINT error_code, ULONG block, ULONG page);
|
||||
|
||||
|
||||
UINT (*lx_nand_flash_driver_pages_read)(ULONG block, ULONG page, UCHAR* main_buffer, UCHAR* spare_buffer, ULONG pages);
|
||||
UINT (*lx_nand_flash_driver_pages_write)(ULONG block, ULONG page, UCHAR* main_buffer, UCHAR* spare_buffer, ULONG pages);
|
||||
UINT (*lx_nand_flash_driver_pages_copy)(ULONG source_block, ULONG source_page, ULONG destination_block, ULONG destination_page, ULONG pages, UCHAR* data_buffer);
|
||||
@@ -538,17 +483,17 @@ typedef struct LX_NAND_FLASH_STRUCT
|
||||
a higher layer. */
|
||||
TX_MUTEX lx_nand_flash_mutex;
|
||||
#endif
|
||||
|
||||
|
||||
/* user data pointer optionally passed by the application to the driver via the lx_nand_flash_open_extended */
|
||||
VOID *lx_nand_flash_driver_info_ptr;
|
||||
/* Define the NAND flash control block open next/previous pointers. */
|
||||
struct LX_NAND_FLASH_STRUCT *lx_nand_flash_open_next,
|
||||
*lx_nand_flash_open_previous;
|
||||
|
||||
/* Define the user extension in the flash control block. This
|
||||
/* Define the user extension in the flash control block. This
|
||||
is typically defined in lx_user.h. */
|
||||
LX_NAND_FLASH_USER_EXTENSION
|
||||
|
||||
|
||||
} LX_NAND_FLASH;
|
||||
|
||||
|
||||
@@ -558,7 +503,7 @@ typedef struct LX_NAND_FLASH_STRUCT
|
||||
typedef struct LX_NOR_SECTOR_MAPPING_CACHE_ENTRY_STRUCT
|
||||
{
|
||||
ULONG lx_nor_sector_mapping_cache_logical_sector;
|
||||
ULONG *lx_nor_sector_mapping_cache_physical_sector_map_entry;
|
||||
ULONG *lx_nor_sector_mapping_cache_physical_sector_map_entry;
|
||||
ULONG *lx_nor_sector_mapping_cache_physical_sector_address;
|
||||
} LX_NOR_SECTOR_MAPPING_CACHE_ENTRY;
|
||||
|
||||
@@ -567,13 +512,13 @@ typedef struct LX_NOR_SECTOR_MAPPING_CACHE_ENTRY_STRUCT
|
||||
|
||||
typedef struct LX_NOR_FLASH_EXTENDED_CACHE_ENTRY_STRUCT
|
||||
{
|
||||
ULONG *lx_nor_flash_extended_cache_entry_sector_address;
|
||||
ULONG *lx_nor_flash_extended_cache_entry_sector_address;
|
||||
ULONG *lx_nor_flash_extended_cache_entry_sector_memory;
|
||||
ULONG lx_nor_flash_extended_cache_entry_access_count;
|
||||
} LX_NOR_FLASH_EXTENDED_CACHE_ENTRY;
|
||||
|
||||
|
||||
/* Determine if the flash control block has an extension defined. If not,
|
||||
/* Determine if the flash control block has an extension defined. If not,
|
||||
define the extension to whitespace. */
|
||||
|
||||
#ifndef LX_NOR_FLASH_USER_EXTENSION
|
||||
@@ -606,7 +551,7 @@ typedef struct LX_NOR_FLASH_STRUCT
|
||||
|
||||
ULONG lx_nor_flash_free_block_search;
|
||||
ULONG lx_nor_flash_found_block_search;
|
||||
ULONG lx_nor_flash_found_sector_search;
|
||||
ULONG lx_nor_flash_found_sector_search;
|
||||
|
||||
ULONG lx_nor_flash_write_requests;
|
||||
ULONG lx_nor_flash_read_requests;
|
||||
@@ -642,7 +587,7 @@ typedef struct LX_NOR_FLASH_STRUCT
|
||||
|
||||
ULONG *lx_nor_flash_sector_buffer;
|
||||
UINT lx_nor_flash_sector_mapping_cache_enabled;
|
||||
LX_NOR_SECTOR_MAPPING_CACHE_ENTRY
|
||||
LX_NOR_SECTOR_MAPPING_CACHE_ENTRY
|
||||
lx_nor_flash_sector_mapping_cache[LX_NOR_SECTOR_MAPPING_CACHE_SIZE];
|
||||
|
||||
#ifndef LX_NOR_DISABLE_EXTENDED_CACHE
|
||||
@@ -660,7 +605,7 @@ typedef struct LX_NOR_FLASH_STRUCT
|
||||
LX_NOR_OBSOLETE_COUNT_CACHE_TYPE
|
||||
*lx_nor_flash_extended_cache_obsolete_count;
|
||||
ULONG lx_nor_flash_extended_cache_obsolete_count_max_block;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef LX_THREAD_SAFE_ENABLE
|
||||
@@ -675,8 +620,8 @@ typedef struct LX_NOR_FLASH_STRUCT
|
||||
/* Define the NOR flash control block open next/previous pointers. */
|
||||
struct LX_NOR_FLASH_STRUCT *lx_nor_flash_open_next,
|
||||
*lx_nor_flash_open_previous;
|
||||
|
||||
/* Define the user extension in the flash control block. This
|
||||
|
||||
/* Define the user extension in the flash control block. This
|
||||
is typically defined in lx_user.h. */
|
||||
LX_NOR_FLASH_USER_EXTENSION
|
||||
|
||||
@@ -686,24 +631,24 @@ typedef struct LX_NOR_FLASH_STRUCT
|
||||
/* Each physical NOR block has the following structure at the beginning of the block:
|
||||
|
||||
Offset Meaning
|
||||
|
||||
|
||||
0 Erase count
|
||||
4 Minimum logical sector number - only when the block is full
|
||||
8 Maximum logical sector number - only when the block is full
|
||||
12 Free physical sector bit map, where a value of 1 indicates a
|
||||
12 Free physical sector bit map, where a value of 1 indicates a
|
||||
free physical sector. The bit map is evenly divisible by 4
|
||||
. Array of physical sector mapping information (4 bytes per entry,
|
||||
. Array of physical sector mapping information (4 bytes per entry,
|
||||
one entry for each physical sector in block). Each entry looks
|
||||
like the following:
|
||||
|
||||
|
||||
Bit(s) Meaning
|
||||
|
||||
|
||||
0-29 Logical sector mapped if not 0x3FFFFFFF
|
||||
30 If 0, entry is being superceded
|
||||
31 If 1, entry is valid
|
||||
|
||||
|
||||
Array of physical sectors, with each of size LX_NOR_SECTOR_SIZE
|
||||
*/
|
||||
*/
|
||||
|
||||
|
||||
typedef struct LX_NOR_FLASH_BLOCK_HEADER_STRUCT
|
||||
@@ -843,5 +788,5 @@ VOID _lx_nor_flash_system_error(LX_NOR_FLASH *nor_flash, UINT error_code);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
+23
-39
@@ -1,10 +1,11 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
@@ -39,23 +40,6 @@
|
||||
/* Note that all the defines in this file may also be made on the */
|
||||
/* command line when building LevelX library and application objects. */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 11-09-2020 William E. Lamie Initial Version 6.1.2 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), and */
|
||||
/* added standalone support, */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* 03-08-2023 Xiuwen Cai Modified comment(s), and */
|
||||
/* added new NAND options, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* 10-31-2023 Xiuwen Cai Modified comment(s), */
|
||||
/* added options for mapping , */
|
||||
/* bitmap cache and obsolete */
|
||||
/* count cache, */
|
||||
/* resulting in version 6.3.0 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef LX_USER_H
|
||||
@@ -63,22 +47,22 @@
|
||||
|
||||
|
||||
|
||||
/* Defined, this option bypasses the NOR flash driver read routine in favor or reading
|
||||
the NOR memory directly, resulting in a significant performance increase.
|
||||
/* Defined, this option bypasses the NOR flash driver read routine in favor or reading
|
||||
the NOR memory directly, resulting in a significant performance increase.
|
||||
*/
|
||||
/*
|
||||
#define LX_DIRECT_READ
|
||||
*/
|
||||
|
||||
|
||||
/* Defined, this causes the LevelX NOR instance open logic to verify free NOR
|
||||
/* Defined, this causes the LevelX NOR instance open logic to verify free NOR
|
||||
sectors are all ones.
|
||||
*/
|
||||
/*
|
||||
#define LX_FREE_SECTOR_DATA_VERIFY
|
||||
#define LX_FREE_SECTOR_DATA_VERIFY
|
||||
*/
|
||||
|
||||
/* By default this value is 4, which represents a maximum of 4 blocks that
|
||||
/* By default this value is 4, which represents a maximum of 4 blocks that
|
||||
can be allocated for metadata.
|
||||
*/
|
||||
/*
|
||||
@@ -90,23 +74,23 @@
|
||||
#define LX_NOR_DISABLE_EXTENDED_CACHE
|
||||
*/
|
||||
|
||||
/* By default this value is 8, which represents a maximum of 8 sectors that
|
||||
/* By default this value is 8, which represents a maximum of 8 sectors that
|
||||
can be cached in a NOR instance.
|
||||
*/
|
||||
/*
|
||||
#define LX_NOR_EXTENDED_CACHE_SIZE 8
|
||||
#define LX_NOR_EXTENDED_CACHE_SIZE 8
|
||||
*/
|
||||
|
||||
|
||||
/* By default this value is 16 and defines the logical sector mapping cache size.
|
||||
Large values improve performance, but cost memory. The minimum size is 8 and all
|
||||
/* By default this value is 16 and defines the logical sector mapping cache size.
|
||||
Large values improve performance, but cost memory. The minimum size is 8 and all
|
||||
values must be a power of 2.
|
||||
*/
|
||||
/*
|
||||
#define LX_NOR_SECTOR_MAPPING_CACHE_SIZE 16
|
||||
*/
|
||||
|
||||
/* Defined, this makes LevelX thread-safe by using a ThreadX mutex object
|
||||
/* Defined, this makes LevelX thread-safe by using a ThreadX mutex object
|
||||
throughout the API.
|
||||
*/
|
||||
/*
|
||||
@@ -118,34 +102,34 @@
|
||||
/* #define LX_STANDALONE_ENABLE */
|
||||
|
||||
/* Define user extension for NOR flash control block. User extension is placed at the end of flash control block and it is not cleared on opening flash. */
|
||||
/*
|
||||
/*
|
||||
#define LX_NOR_FLASH_USER_EXTENSION ????
|
||||
*/
|
||||
|
||||
/* Define user extension for NAND flash control block. User extension is placed at the end of flash control block and it is not cleared on opening flash. */
|
||||
/*
|
||||
/*
|
||||
#define LX_NAND_FLASH_USER_EXTENSION ????
|
||||
*/
|
||||
|
||||
/* Determine if logical sector mapping bitmap should be enabled in extended cache.
|
||||
/* Determine if logical sector mapping bitmap should be enabled in extended cache.
|
||||
Cache memory will be allocated to sector mapping bitmap first. One bit can be allocated for each physical sector. */
|
||||
/*
|
||||
/*
|
||||
#define LX_NOR_ENABLE_MAPPING_BITMAP
|
||||
*/
|
||||
|
||||
/* Determine if obsolete count cache should be enabled in extended cache.
|
||||
Cache memory will be allocated to obsolete count cache after the mapping bitmap if enabled,
|
||||
/* Determine if obsolete count cache should be enabled in extended cache.
|
||||
Cache memory will be allocated to obsolete count cache after the mapping bitmap if enabled,
|
||||
and the rest of the cache memory is allocated to sector cache. */
|
||||
/*
|
||||
/*
|
||||
#define LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE
|
||||
*/
|
||||
|
||||
/* Defines obsolete count cache element size. If number of sectors per block is greater than 256, use USHORT instead of UCHAR. */
|
||||
/*
|
||||
/*
|
||||
#define LX_NOR_OBSOLETE_COUNT_CACHE_TYPE UCHAR
|
||||
*/
|
||||
|
||||
/* Define the logical sector size for NOR flash. The sector size is in units of 32-bit words.
|
||||
/* Define the logical sector size for NOR flash. The sector size is in units of 32-bit words.
|
||||
This sector size should match the sector size used in file system. */
|
||||
/*
|
||||
#define LX_NOR_SECTOR_SIZE (512/sizeof(ULONG))
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** FileX Component */
|
||||
/** */
|
||||
/** FileX Component */
|
||||
/** */
|
||||
/** FileX NAND FLASH Simulator Driver */
|
||||
/** */
|
||||
@@ -42,22 +43,22 @@ VOID _fx_nand_flash_write_sectors(ULONG logical_sector, ULONG sectors, UCHAR *s
|
||||
|
||||
|
||||
/* The simulated NAND driver relies on the fx_media_format call to be made prior to
|
||||
the fx_media_open call.
|
||||
the fx_media_open call.
|
||||
|
||||
fx_media_format(&ram_disk,
|
||||
fx_media_format(&ram_disk,
|
||||
_fx_nand_sim_driver, // Driver entry
|
||||
FX_NULL, // Unused
|
||||
media_memory, // Media buffer pointer
|
||||
sizeof(media_memory), // Media buffer size
|
||||
sizeof(media_memory), // Media buffer size
|
||||
"MY_NAND_DISK", // Volume Name
|
||||
1, // Number of FATs
|
||||
32, // Directory Entries
|
||||
0, // Hidden sectors
|
||||
120, // Total sectors
|
||||
2048, // Sector size
|
||||
120, // Total sectors
|
||||
2048, // Sector size
|
||||
1, // Sectors per cluster
|
||||
1, // Heads
|
||||
1); // Sectors per track
|
||||
1); // Sectors per track
|
||||
|
||||
*/
|
||||
|
||||
@@ -65,69 +66,56 @@ VOID _fx_nand_flash_write_sectors(ULONG logical_sector, ULONG sectors, UCHAR *s
|
||||
VOID _fx_nand_flash_simulator_driver(FX_MEDIA *media_ptr);
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _fx_nand_simulator_driver PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _fx_nand_simulator_driver PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function is the entry point to the generic NAND simulated */
|
||||
/* disk driver that is delivered with the flash wear leveling product */
|
||||
/* LevelX. */
|
||||
/* */
|
||||
/* This driver also serves as a template for developing other LevelX */
|
||||
/* NAND flash drivers for actual flash devices. Simply replace the */
|
||||
/* read/write sector logic with calls to read/write from the */
|
||||
/* appropriate physical device access functions. */
|
||||
/* */
|
||||
/* FileX NAND FLASH structures look like the following: */
|
||||
/* */
|
||||
/* Logical Sector Contents */
|
||||
/* */
|
||||
/* 0 Boot record */
|
||||
/* 1 FAT Area Start */
|
||||
/* +FAT Sectors Root Directory Start */
|
||||
/* +Directory Sectors Data Sector Start */
|
||||
/* */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* media_ptr Media control block pointer */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_close Close NAND flash manager */
|
||||
/* _lx_nand_flash_open Open NAND flash manager */
|
||||
/* _lx_nand_flash_sector_read Read a NAND sector */
|
||||
/* _lx_nand_flash_sector_release Release a NAND sector */
|
||||
/* _lx_nand_flash_sector_write Write a NAND sector */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* FileX System Functions */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* 03-08-2023 Xiuwen Cai Modified comment(s), */
|
||||
/* changed to use new API, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* This function is the entry point to the generic NAND simulated */
|
||||
/* disk driver that is delivered with the flash wear leveling product */
|
||||
/* LevelX. */
|
||||
/* */
|
||||
/* This driver also serves as a template for developing other LevelX */
|
||||
/* NAND flash drivers for actual flash devices. Simply replace the */
|
||||
/* read/write sector logic with calls to read/write from the */
|
||||
/* appropriate physical device access functions. */
|
||||
/* */
|
||||
/* FileX NAND FLASH structures look like the following: */
|
||||
/* */
|
||||
/* Logical Sector Contents */
|
||||
/* */
|
||||
/* 0 Boot record */
|
||||
/* 1 FAT Area Start */
|
||||
/* +FAT Sectors Root Directory Start */
|
||||
/* +Directory Sectors Data Sector Start */
|
||||
/* */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* media_ptr Media control block pointer */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_close Close NAND flash manager */
|
||||
/* _lx_nand_flash_open Open NAND flash manager */
|
||||
/* _lx_nand_flash_sector_read Read a NAND sector */
|
||||
/* _lx_nand_flash_sector_release Release a NAND sector */
|
||||
/* _lx_nand_flash_sector_write Write a NAND sector */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* FileX System Functions */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
VOID _fx_nand_flash_simulator_driver(FX_MEDIA *media_ptr)
|
||||
@@ -137,19 +125,19 @@ ULONG logical_sector;
|
||||
ULONG count;
|
||||
UCHAR *buffer;
|
||||
UINT status;
|
||||
|
||||
|
||||
|
||||
/* There are several useful/important pieces of information contained in the media
|
||||
structure, some of which are supplied by FileX and others are for the driver to
|
||||
setup. The following is a summary of the necessary FX_MEDIA structure members:
|
||||
|
||||
|
||||
FX_MEDIA Member Meaning
|
||||
|
||||
fx_media_driver_request FileX request type. Valid requests from FileX are
|
||||
|
||||
fx_media_driver_request FileX request type. Valid requests from FileX are
|
||||
as follows:
|
||||
|
||||
FX_DRIVER_READ
|
||||
FX_DRIVER_WRITE
|
||||
FX_DRIVER_WRITE
|
||||
FX_DRIVER_FLUSH
|
||||
FX_DRIVER_ABORT
|
||||
FX_DRIVER_INIT
|
||||
@@ -158,11 +146,11 @@ UINT status;
|
||||
FX_DRIVER_BOOT_WRITE
|
||||
FX_DRIVER_UNINIT
|
||||
|
||||
fx_media_driver_status This value is RETURNED by the driver. If the
|
||||
fx_media_driver_status This value is RETURNED by the driver. If the
|
||||
operation is successful, this field should be
|
||||
set to FX_SUCCESS for before returning. Otherwise,
|
||||
if an error occurred, this field should be set
|
||||
to FX_IO_ERROR.
|
||||
to FX_IO_ERROR.
|
||||
|
||||
fx_media_driver_buffer Pointer to buffer to read or write sector data.
|
||||
This is supplied by FileX.
|
||||
@@ -173,24 +161,24 @@ UINT status;
|
||||
|
||||
|
||||
The following is a summary of the optional FX_MEDIA structure members:
|
||||
|
||||
|
||||
FX_MEDIA Member Meaning
|
||||
|
||||
|
||||
fx_media_driver_info Pointer to any additional information or memory.
|
||||
This is optional for the driver use and is setup
|
||||
from the fx_media_open call. The RAM disk uses
|
||||
this pointer for the RAM disk memory itself.
|
||||
|
||||
fx_media_driver_write_protect The DRIVER sets this to FX_TRUE when media is write
|
||||
protected. This is typically done in initialization,
|
||||
fx_media_driver_write_protect The DRIVER sets this to FX_TRUE when media is write
|
||||
protected. This is typically done in initialization,
|
||||
but can be done anytime.
|
||||
|
||||
fx_media_driver_free_sector_update The DRIVER sets this to FX_TRUE when it needs to
|
||||
fx_media_driver_free_sector_update The DRIVER sets this to FX_TRUE when it needs to
|
||||
know when clusters are released. This is important
|
||||
for FLASH wear-leveling drivers.
|
||||
|
||||
fx_media_driver_system_write FileX sets this flag to FX_TRUE if the sector being
|
||||
written is a system sector, e.g., a boot, FAT, or
|
||||
written is a system sector, e.g., a boot, FAT, or
|
||||
directory sector. The driver may choose to use this
|
||||
to initiate error recovery logic for greater fault
|
||||
tolerance.
|
||||
@@ -198,15 +186,15 @@ UINT status;
|
||||
fx_media_driver_data_sector_read FileX sets this flag to FX_TRUE if the sector(s) being
|
||||
read are file data sectors, i.e., NOT system sectors.
|
||||
|
||||
fx_media_driver_sector_type FileX sets this variable to the specific type of
|
||||
fx_media_driver_sector_type FileX sets this variable to the specific type of
|
||||
sector being read or written. The following sector
|
||||
types are identified:
|
||||
|
||||
FX_UNKNOWN_SECTOR
|
||||
FX_UNKNOWN_SECTOR
|
||||
FX_BOOT_SECTOR
|
||||
FX_FAT_SECTOR
|
||||
FX_DIRECTORY_SECTOR
|
||||
FX_DATA_SECTOR
|
||||
FX_DATA_SECTOR
|
||||
*/
|
||||
|
||||
/* Process the driver request specified in the media control block. */
|
||||
@@ -225,18 +213,18 @@ UINT status;
|
||||
|
||||
/* Call LevelX to read one flash sector. */
|
||||
status = _lx_nand_flash_sector_read(&nand_flash, logical_sector, buffer);
|
||||
|
||||
|
||||
/* Determine if the read was successful. */
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
/* Return an I/O error to FileX. */
|
||||
media_ptr -> fx_media_driver_status = FX_IO_ERROR;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Successful sector read. */
|
||||
return;
|
||||
}
|
||||
|
||||
/* Successful sector read. */
|
||||
count--;
|
||||
logical_sector++;
|
||||
buffer += media_ptr -> fx_media_bytes_per_sector;
|
||||
@@ -245,12 +233,12 @@ UINT status;
|
||||
media_ptr -> fx_media_driver_status = FX_SUCCESS;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case FX_DRIVER_WRITE:
|
||||
{
|
||||
|
||||
/* Write sector(s) to NAND flash. */
|
||||
logical_sector = media_ptr -> fx_media_driver_logical_sector;
|
||||
logical_sector = media_ptr -> fx_media_driver_logical_sector;
|
||||
count = media_ptr -> fx_media_driver_sectors;
|
||||
buffer = (UCHAR *) media_ptr -> fx_media_driver_buffer;
|
||||
while (count)
|
||||
@@ -262,12 +250,12 @@ UINT status;
|
||||
/* Determine if the write was successful. */
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
/* Return an I/O error to FileX. */
|
||||
media_ptr -> fx_media_driver_status = FX_IO_ERROR;
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Successful sector write. */
|
||||
count--;
|
||||
@@ -282,7 +270,7 @@ UINT status;
|
||||
|
||||
case FX_DRIVER_RELEASE_SECTORS:
|
||||
{
|
||||
|
||||
|
||||
/* Release the mapping of this sector. */
|
||||
logical_sector = media_ptr -> fx_media_driver_logical_sector;
|
||||
count = media_ptr -> fx_media_driver_sectors;
|
||||
@@ -295,18 +283,18 @@ UINT status;
|
||||
/* Determine if the sector release was successful. */
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
/* Return an I/O error to FileX. */
|
||||
media_ptr -> fx_media_driver_status = FX_IO_ERROR;
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Successful sector release. */
|
||||
count--;
|
||||
logical_sector++;
|
||||
}
|
||||
|
||||
|
||||
/* Successful driver request. */
|
||||
media_ptr -> fx_media_driver_status = FX_SUCCESS;
|
||||
break;
|
||||
@@ -331,7 +319,7 @@ UINT status;
|
||||
case FX_DRIVER_INIT:
|
||||
{
|
||||
|
||||
/* FLASH drivers are responsible for setting several fields in the
|
||||
/* FLASH drivers are responsible for setting several fields in the
|
||||
media structure, as follows:
|
||||
|
||||
media_ptr -> fx_media_driver_free_sector_update
|
||||
@@ -339,7 +327,7 @@ UINT status;
|
||||
|
||||
The fx_media_driver_free_sector_update flag is used to instruct
|
||||
FileX to inform the driver whenever sectors are not being used.
|
||||
This is especially useful for FLASH managers so they don't have
|
||||
This is especially useful for FLASH managers so they don't have
|
||||
maintain mapping for sectors no longer in use.
|
||||
|
||||
The fx_media_driver_write_protect flag can be set anytime by the
|
||||
@@ -359,12 +347,12 @@ UINT status;
|
||||
/* Determine if the flash open was successful. */
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
/* Return an I/O error to FileX. */
|
||||
media_ptr -> fx_media_driver_status = FX_IO_ERROR;
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Successful driver request. */
|
||||
media_ptr -> fx_media_driver_status = FX_SUCCESS;
|
||||
@@ -376,25 +364,25 @@ UINT status;
|
||||
|
||||
/* There is nothing to do in this case for the RAM driver. For actual
|
||||
devices some shutdown processing may be necessary. */
|
||||
|
||||
|
||||
/* Close the NAND flash simulation. */
|
||||
status = _lx_nand_flash_close(&nand_flash);
|
||||
|
||||
|
||||
/* Determine if the flash close was successful. */
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
/* Return an I/O error to FileX. */
|
||||
media_ptr -> fx_media_driver_status = FX_IO_ERROR;
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Successful driver request. */
|
||||
media_ptr -> fx_media_driver_status = FX_SUCCESS;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case FX_DRIVER_BOOT_READ:
|
||||
{
|
||||
|
||||
@@ -404,13 +392,13 @@ UINT status;
|
||||
/* Determine if the read was successful. */
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
/* Return an I/O error to FileX. */
|
||||
media_ptr -> fx_media_driver_status = FX_IO_ERROR;
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Successful driver request. */
|
||||
media_ptr -> fx_media_driver_status = FX_SUCCESS;
|
||||
break;
|
||||
@@ -425,12 +413,12 @@ UINT status;
|
||||
/* Determine if the write was successful. */
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
/* Return an I/O error to FileX. */
|
||||
media_ptr -> fx_media_driver_status = FX_IO_ERROR;
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Successful driver request. */
|
||||
media_ptr -> fx_media_driver_status = FX_SUCCESS;
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** FileX Component */
|
||||
/** */
|
||||
/** FileX Component */
|
||||
/** */
|
||||
/** FileX NOR FLASH Simulator Driver */
|
||||
/** */
|
||||
@@ -32,22 +33,22 @@ LX_NOR_FLASH nor_flash;
|
||||
|
||||
|
||||
/* The simulated NOR driver relies on the fx_media_format call to be made prior to
|
||||
the fx_media_open call.
|
||||
the fx_media_open call.
|
||||
|
||||
fx_media_format(&ram_disk,
|
||||
fx_media_format(&ram_disk,
|
||||
_fx_nor_sim_driver, // Driver entry
|
||||
FX_NULL, // Unused
|
||||
media_memory, // Media buffer pointer
|
||||
sizeof(media_memory), // Media buffer size
|
||||
sizeof(media_memory), // Media buffer size
|
||||
"MY_NOR_DISK", // Volume Name
|
||||
1, // Number of FATs
|
||||
32, // Directory Entries
|
||||
0, // Hidden sectors
|
||||
120, // Total sectors
|
||||
LX_NOR_SECTOR_SIZE * sizeof(ULONG), // Sector size
|
||||
120, // Total sectors
|
||||
LX_NOR_SECTOR_SIZE * sizeof(ULONG), // Sector size
|
||||
1, // Sectors per cluster
|
||||
1, // Heads
|
||||
1); // Sectors per track
|
||||
1); // Sectors per track
|
||||
|
||||
*/
|
||||
|
||||
@@ -58,66 +59,56 @@ UINT _lx_nor_flash_simulator_initialize(LX_NOR_FLASH *nor_flash);
|
||||
VOID _fx_nor_flash_simulator_driver(FX_MEDIA *media_ptr);
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _fx_nor_flash_simulator_driver PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _fx_nor_flash_simulator_driver PORTABLE C */
|
||||
/* 6.1.7 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function is the entry point to the generic NOR simulated */
|
||||
/* disk driver that is delivered with the flash wear leveling product */
|
||||
/* LevelX. */
|
||||
/* */
|
||||
/* This driver also serves as a template for developing other LevelX */
|
||||
/* NOR flash drivers for actual flash devices. Simply replace the */
|
||||
/* read/write sector logic with calls to read/write from the */
|
||||
/* appropriate physical device access functions. */
|
||||
/* */
|
||||
/* FileX NOR FLASH structures look like the following: */
|
||||
/* */
|
||||
/* Logical Sector Contents */
|
||||
/* */
|
||||
/* 0 Boot record */
|
||||
/* 1 FAT Area Start */
|
||||
/* +FAT Sectors Root Directory Start */
|
||||
/* +Directory Sectors Data Sector Start */
|
||||
/* */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* media_ptr Media control block pointer */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* lx_nor_flash_close Close NOR flash manager */
|
||||
/* lx_nor_flash_open Open NOR flash manager */
|
||||
/* lx_nor_flash_sector_read Read a NOR sector */
|
||||
/* lx_nor_flash_sector_release Release a NOR sector */
|
||||
/* lx_nor_flash_sector_write Write a NOR sector */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* FileX System Functions */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* This function is the entry point to the generic NOR simulated */
|
||||
/* disk driver that is delivered with the flash wear leveling product */
|
||||
/* LevelX. */
|
||||
/* */
|
||||
/* This driver also serves as a template for developing other LevelX */
|
||||
/* NOR flash drivers for actual flash devices. Simply replace the */
|
||||
/* read/write sector logic with calls to read/write from the */
|
||||
/* appropriate physical device access functions. */
|
||||
/* */
|
||||
/* FileX NOR FLASH structures look like the following: */
|
||||
/* */
|
||||
/* Logical Sector Contents */
|
||||
/* */
|
||||
/* 0 Boot record */
|
||||
/* 1 FAT Area Start */
|
||||
/* +FAT Sectors Root Directory Start */
|
||||
/* +Directory Sectors Data Sector Start */
|
||||
/* */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* media_ptr Media control block pointer */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* lx_nor_flash_close Close NOR flash manager */
|
||||
/* lx_nor_flash_open Open NOR flash manager */
|
||||
/* lx_nor_flash_sector_read Read a NOR sector */
|
||||
/* lx_nor_flash_sector_release Release a NOR sector */
|
||||
/* lx_nor_flash_sector_write Write a NOR sector */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* FileX System Functions */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
VOID _fx_nor_flash_simulator_driver(FX_MEDIA *media_ptr)
|
||||
@@ -133,14 +124,14 @@ UINT status;
|
||||
/* There are several useful/important pieces of information contained in the media
|
||||
structure, some of which are supplied by FileX and others are for the driver to
|
||||
setup. The following is a summary of the necessary FX_MEDIA structure members:
|
||||
|
||||
|
||||
FX_MEDIA Member Meaning
|
||||
|
||||
fx_media_driver_request FileX request type. Valid requests from FileX are
|
||||
|
||||
fx_media_driver_request FileX request type. Valid requests from FileX are
|
||||
as follows:
|
||||
|
||||
FX_DRIVER_READ
|
||||
FX_DRIVER_WRITE
|
||||
FX_DRIVER_WRITE
|
||||
FX_DRIVER_FLUSH
|
||||
FX_DRIVER_ABORT
|
||||
FX_DRIVER_INIT
|
||||
@@ -149,11 +140,11 @@ UINT status;
|
||||
FX_DRIVER_BOOT_WRITE
|
||||
FX_DRIVER_UNINIT
|
||||
|
||||
fx_media_driver_status This value is RETURNED by the driver. If the
|
||||
fx_media_driver_status This value is RETURNED by the driver. If the
|
||||
operation is successful, this field should be
|
||||
set to FX_SUCCESS for before returning. Otherwise,
|
||||
if an error occurred, this field should be set
|
||||
to FX_IO_ERROR.
|
||||
to FX_IO_ERROR.
|
||||
|
||||
fx_media_driver_buffer Pointer to buffer to read or write sector data.
|
||||
This is supplied by FileX.
|
||||
@@ -164,24 +155,24 @@ UINT status;
|
||||
|
||||
|
||||
The following is a summary of the optional FX_MEDIA structure members:
|
||||
|
||||
|
||||
FX_MEDIA Member Meaning
|
||||
|
||||
|
||||
fx_media_driver_info Pointer to any additional information or memory.
|
||||
This is optional for the driver use and is setup
|
||||
from the fx_media_open call. The RAM disk uses
|
||||
this pointer for the RAM disk memory itself.
|
||||
|
||||
fx_media_driver_write_protect The DRIVER sets this to FX_TRUE when media is write
|
||||
protected. This is typically done in initialization,
|
||||
fx_media_driver_write_protect The DRIVER sets this to FX_TRUE when media is write
|
||||
protected. This is typically done in initialization,
|
||||
but can be done anytime.
|
||||
|
||||
fx_media_driver_free_sector_update The DRIVER sets this to FX_TRUE when it needs to
|
||||
fx_media_driver_free_sector_update The DRIVER sets this to FX_TRUE when it needs to
|
||||
know when clusters are released. This is important
|
||||
for FLASH wear-leveling drivers.
|
||||
|
||||
fx_media_driver_system_write FileX sets this flag to FX_TRUE if the sector being
|
||||
written is a system sector, e.g., a boot, FAT, or
|
||||
written is a system sector, e.g., a boot, FAT, or
|
||||
directory sector. The driver may choose to use this
|
||||
to initiate error recovery logic for greater fault
|
||||
tolerance.
|
||||
@@ -189,15 +180,15 @@ UINT status;
|
||||
fx_media_driver_data_sector_read FileX sets this flag to FX_TRUE if the sector(s) being
|
||||
read are file data sectors, i.e., NOT system sectors.
|
||||
|
||||
fx_media_driver_sector_type FileX sets this variable to the specific type of
|
||||
fx_media_driver_sector_type FileX sets this variable to the specific type of
|
||||
sector being read or written. The following sector
|
||||
types are identified:
|
||||
|
||||
FX_UNKNOWN_SECTOR
|
||||
FX_UNKNOWN_SECTOR
|
||||
FX_BOOT_SECTOR
|
||||
FX_FAT_SECTOR
|
||||
FX_DIRECTORY_SECTOR
|
||||
FX_DATA_SECTOR
|
||||
FX_DATA_SECTOR
|
||||
*/
|
||||
|
||||
/* Process the driver request specified in the media control block. */
|
||||
@@ -214,19 +205,19 @@ UINT status;
|
||||
/* Loop to read sectors from flash. */
|
||||
for (i = 0; i < media_ptr -> fx_media_driver_sectors; i++)
|
||||
{
|
||||
|
||||
|
||||
/* Read a sector from NOR flash. */
|
||||
status = lx_nor_flash_sector_read(&nor_flash, logical_sector, destination_buffer);
|
||||
|
||||
/* Determine if the read was successful. */
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
/* Return an I/O error to FileX. */
|
||||
media_ptr -> fx_media_driver_status = FX_IO_ERROR;
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Move to the next entries. */
|
||||
logical_sector++;
|
||||
@@ -237,7 +228,7 @@ UINT status;
|
||||
media_ptr -> fx_media_driver_status = FX_SUCCESS;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case FX_DRIVER_WRITE:
|
||||
{
|
||||
|
||||
@@ -248,19 +239,19 @@ UINT status;
|
||||
/* Loop to write sectors to flash. */
|
||||
for (i = 0; i < media_ptr -> fx_media_driver_sectors; i++)
|
||||
{
|
||||
|
||||
|
||||
/* Write a sector to NOR flash. */
|
||||
status = lx_nor_flash_sector_write(&nor_flash, logical_sector, source_buffer);
|
||||
|
||||
/* Determine if the write was successful. */
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
/* Return an I/O error to FileX. */
|
||||
media_ptr -> fx_media_driver_status = FX_IO_ERROR;
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Move to the next entries. */
|
||||
logical_sector++;
|
||||
@@ -274,26 +265,26 @@ UINT status;
|
||||
|
||||
case FX_DRIVER_RELEASE_SECTORS:
|
||||
{
|
||||
|
||||
|
||||
/* Setup the logical sector. */
|
||||
logical_sector = media_ptr -> fx_media_driver_logical_sector;
|
||||
|
||||
/* Release sectors. */
|
||||
for (i = 0; i < media_ptr -> fx_media_driver_sectors; i++)
|
||||
{
|
||||
|
||||
|
||||
/* Release NOR flash sector. */
|
||||
status = lx_nor_flash_sector_release(&nor_flash, logical_sector);
|
||||
|
||||
/* Determine if the sector release was successful. */
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
/* Return an I/O error to FileX. */
|
||||
media_ptr -> fx_media_driver_status = FX_IO_ERROR;
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Move to the next entries. */
|
||||
logical_sector++;
|
||||
@@ -323,7 +314,7 @@ UINT status;
|
||||
case FX_DRIVER_INIT:
|
||||
{
|
||||
|
||||
/* FLASH drivers are responsible for setting several fields in the
|
||||
/* FLASH drivers are responsible for setting several fields in the
|
||||
media structure, as follows:
|
||||
|
||||
media_ptr -> fx_media_driver_free_sector_update
|
||||
@@ -331,7 +322,7 @@ UINT status;
|
||||
|
||||
The fx_media_driver_free_sector_update flag is used to instruct
|
||||
FileX to inform the driver whenever sectors are not being used.
|
||||
This is especially useful for FLASH managers so they don't have
|
||||
This is especially useful for FLASH managers so they don't have
|
||||
maintain mapping for sectors no longer in use.
|
||||
|
||||
The fx_media_driver_write_protect flag can be set anytime by the
|
||||
@@ -351,12 +342,12 @@ UINT status;
|
||||
/* Determine if the flash open was successful. */
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
/* Return an I/O error to FileX. */
|
||||
media_ptr -> fx_media_driver_status = FX_IO_ERROR;
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Successful driver request. */
|
||||
media_ptr -> fx_media_driver_status = FX_SUCCESS;
|
||||
@@ -375,18 +366,18 @@ UINT status;
|
||||
/* Determine if the flash close was successful. */
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
/* Return an I/O error to FileX. */
|
||||
media_ptr -> fx_media_driver_status = FX_IO_ERROR;
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Successful driver request. */
|
||||
media_ptr -> fx_media_driver_status = FX_SUCCESS;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case FX_DRIVER_BOOT_READ:
|
||||
{
|
||||
|
||||
@@ -412,12 +403,12 @@ UINT status;
|
||||
/* Determine if the boot read was successful. */
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
/* Return an I/O error to FileX. */
|
||||
media_ptr -> fx_media_driver_status = FX_IO_ERROR;
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Successful driver request. */
|
||||
media_ptr -> fx_media_driver_status = FX_SUCCESS;
|
||||
@@ -447,12 +438,12 @@ UINT status;
|
||||
/* Determine if the boot write was successful. */
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
/* Return an I/O error to FileX. */
|
||||
media_ptr -> fx_media_driver_status = FX_IO_ERROR;
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Successful driver request. */
|
||||
media_ptr -> fx_media_driver_status = FX_SUCCESS;
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,54 +35,44 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_256byte_ecc_check PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_256byte_ecc_check PORTABLE C */
|
||||
/* 6.1.7 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function checks 256 bytes of a NAND flash and ECC and */
|
||||
/* attempts to correct any single bit errors. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* page_buffer Page buffer */
|
||||
/* ecc_buffer Returned ECC buffer */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_256byte_ecc_compute Compute ECC for 256 bytes */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* _lx_nand_flash_page_ecc_check NAND page check */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* This function checks 256 bytes of a NAND flash and ECC and */
|
||||
/* attempts to correct any single bit errors. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* page_buffer Page buffer */
|
||||
/* ecc_buffer Returned ECC buffer */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_256byte_ecc_compute Compute ECC for 256 bytes */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* _lx_nand_flash_page_ecc_check NAND page check */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_256byte_ecc_check(UCHAR *page_buffer, UCHAR *ecc_buffer)
|
||||
{
|
||||
|
||||
INT i, j;
|
||||
UCHAR mask;
|
||||
UCHAR mask;
|
||||
UCHAR new_ecc_buffer[3];
|
||||
UCHAR ecc_errors[3];
|
||||
INT error_count;
|
||||
@@ -103,29 +94,29 @@ ULONG correction_code;
|
||||
error_count = 0;
|
||||
|
||||
/* Loop through the ECC bytes to determine if there is an error in the page. */
|
||||
for (i = 0; i < 3; i++)
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
|
||||
|
||||
/* Check for differences in the ECCs. */
|
||||
ecc_errors[i] = new_ecc_buffer[i] ^ ecc_buffer[i];
|
||||
|
||||
|
||||
/* Are there any errors? */
|
||||
if (ecc_errors[i])
|
||||
{
|
||||
|
||||
|
||||
/* Accumulate the count of set bits. */
|
||||
mask = 1;
|
||||
for (j = 0; j < 8; j++)
|
||||
{
|
||||
|
||||
|
||||
/* Is this bit set? */
|
||||
if (ecc_errors[i] & mask)
|
||||
{
|
||||
|
||||
|
||||
/* Yes, increment the count. */
|
||||
error_count++;
|
||||
}
|
||||
|
||||
|
||||
/* Move mask to next bit. */
|
||||
mask = (UCHAR) ((mask << 1) & 0xFF);
|
||||
}
|
||||
@@ -141,7 +132,7 @@ ULONG correction_code;
|
||||
}
|
||||
|
||||
/* Was a correctable error discovered? */
|
||||
else if (error_count == 11)
|
||||
else if (error_count == 11)
|
||||
{
|
||||
|
||||
/* Initialize bit and byte offset values. */
|
||||
@@ -169,13 +160,13 @@ ULONG correction_code;
|
||||
|
||||
/* Fix the error. */
|
||||
data[byte] = (USHORT) ((data[byte] ^ (1 << bit)) & 0xFFFF);
|
||||
|
||||
|
||||
/* Return an error corrected status. */
|
||||
return(LX_NAND_ERROR_CORRECTED);
|
||||
}
|
||||
|
||||
|
||||
/* Otherwise, an unrecoverable ECC or data error is present. */
|
||||
else
|
||||
else
|
||||
{
|
||||
|
||||
/* Return an error. */
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,51 +35,38 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_256byte_ecc_compute PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_256byte_ecc_compute PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function computes the ECC for 256 bytes of a NAND flash page. */
|
||||
/* The resulting ECC code is returned in 3 bytes. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* page_buffer Page buffer */
|
||||
/* ecc_buffer Returned ECC buffer */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* _lx_nand_flash_page_ecc_compute NAND page ECC compute */
|
||||
/* _lx_nand_flash_256byte_ecc_check Check 256 bytes and ECC */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* 03-08-2023 Xiuwen Cai Modified comment(s), */
|
||||
/* inverted output, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* This function computes the ECC for 256 bytes of a NAND flash page. */
|
||||
/* The resulting ECC code is returned in 3 bytes. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* page_buffer Page buffer */
|
||||
/* ecc_buffer Returned ECC buffer */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* _lx_nand_flash_page_ecc_compute NAND page ECC compute */
|
||||
/* _lx_nand_flash_256byte_ecc_check Check 256 bytes and ECC */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_256byte_ecc_compute(UCHAR *page_buffer, UCHAR *ecc_buffer)
|
||||
@@ -105,27 +93,27 @@ USHORT odd_byte_parity;
|
||||
ecc_buffer[0]= 0;
|
||||
ecc_buffer[1]= 0;
|
||||
ecc_buffer[2]= 0;
|
||||
|
||||
|
||||
/* Setup a 16-bit pointer to the buffer area. */
|
||||
data = (USHORT *) page_buffer;
|
||||
|
||||
|
||||
/* Loop through the 256 byte buffer, 16 bits at a time. */
|
||||
for (i = 0; i < 128; i++)
|
||||
for (i = 0; i < 128; i++)
|
||||
{
|
||||
|
||||
/* Compute the ECC value. */
|
||||
bit_parity = bit_parity ^ data[i];
|
||||
|
||||
|
||||
/* Now count the bits in the current data word. */
|
||||
bits = 0;
|
||||
mask = 1;
|
||||
for (j = 0; j < 16; j++)
|
||||
{
|
||||
|
||||
/* Is the bit set? */
|
||||
/* Is the bit set? */
|
||||
if (data[i] & mask)
|
||||
{
|
||||
|
||||
|
||||
/* Yes, increment the bit count. */
|
||||
bits++;
|
||||
}
|
||||
@@ -133,11 +121,11 @@ USHORT odd_byte_parity;
|
||||
/* Move the mask to the next bit. */
|
||||
mask = (USHORT) ((mask << 1) & 0xFFFF);
|
||||
}
|
||||
|
||||
|
||||
/* Determine if the number of bits is odd. */
|
||||
if ((bits & 1) == 1)
|
||||
if ((bits & 1) == 1)
|
||||
{
|
||||
|
||||
|
||||
/* Odd number of bits. Adjust the odd/even byte parity. */
|
||||
even_byte_parity = (USHORT) ((even_byte_parity ^ (0xffff - i)) & 0xFFFF);
|
||||
odd_byte_parity = odd_byte_parity ^ i;
|
||||
@@ -145,11 +133,11 @@ USHORT odd_byte_parity;
|
||||
}
|
||||
|
||||
/* Now look for bits set in the bit parity. */
|
||||
for (i = 0; i < 16; i++)
|
||||
for (i = 0; i < 16; i++)
|
||||
{
|
||||
|
||||
/* Is the bit set? */
|
||||
if (bit_parity & 1)
|
||||
if (bit_parity & 1)
|
||||
{
|
||||
|
||||
/* Yes, adjust the odd even byte parity. */
|
||||
@@ -160,21 +148,21 @@ USHORT odd_byte_parity;
|
||||
/* Look at next bit position. */
|
||||
bit_parity = bit_parity >> 1;
|
||||
}
|
||||
|
||||
|
||||
/* At this point, we need to pack the 22 ECC bits into the 3 byte return area. */
|
||||
|
||||
|
||||
/* Pack bit 21. */
|
||||
ecc_buffer[(21+2)/8] = ((UCHAR)(ecc_buffer[(21+2)/8] | ((odd_byte_parity >> 6) & 1) << (21+2)%8) & 0xFF);
|
||||
|
||||
|
||||
/* Pack bit 20. */
|
||||
ecc_buffer[(20+2)/8] = ((UCHAR)(ecc_buffer[(20+2)/8] | ((even_byte_parity >> 6) & 1) << (20+2)%8) & 0xFF);
|
||||
|
||||
|
||||
/* Pack bit 19. */
|
||||
ecc_buffer[(19+2)/8] = ((UCHAR)(ecc_buffer[(19+2)/8] | ((odd_byte_parity >> 5) & 1) << (19+2)%8) & 0xFF);
|
||||
|
||||
/* Pack bit 18. */
|
||||
ecc_buffer[(18+2)/8] = ((UCHAR)(ecc_buffer[(18+2)/8] | ((even_byte_parity >> 5) & 1) << (18+2)%8) & 0xFF);
|
||||
|
||||
|
||||
/* Pack bit 17. */
|
||||
ecc_buffer[(17+2)/8] = ((UCHAR)(ecc_buffer[(17+2)/8] | ((odd_byte_parity >> 4) & 1) << (17+2)%8) & 0xFF);
|
||||
|
||||
@@ -189,7 +177,7 @@ USHORT odd_byte_parity;
|
||||
|
||||
/* Pack bit 13. */
|
||||
ecc_buffer[(13+2)/8] = ((UCHAR)(ecc_buffer[(13+2)/8] | ((odd_byte_parity >> 2) & 1) << (13+2)%8) & 0xFF);
|
||||
|
||||
|
||||
/* Pack bit 12. */
|
||||
ecc_buffer[(12+2)/8] = ((UCHAR)(ecc_buffer[(12+2)/8] | ((even_byte_parity >> 2) & 1) << (12+2)%8) & 0xFF);
|
||||
|
||||
@@ -199,18 +187,18 @@ USHORT odd_byte_parity;
|
||||
/* Pack bit 10. */
|
||||
ecc_buffer[(10+2)/8] = ((UCHAR)(ecc_buffer[(10+2)/8] | ((even_byte_parity >> 1) & 1) << (10+2)%8) & 0xFF);
|
||||
|
||||
/* Pack bit 9. */
|
||||
/* Pack bit 9. */
|
||||
ecc_buffer[(9+2)/8] = ((UCHAR)(ecc_buffer[(9+2)/8] | ((odd_byte_parity >> 0) & 1) << (9+2)%8) & 0xFF);
|
||||
|
||||
/* Pack bit 8. */
|
||||
/* Pack bit 8. */
|
||||
ecc_buffer[(8+2)/8] = ((UCHAR)(ecc_buffer[(8+2)/8] | ((even_byte_parity >> 0) & 1) << (8+2)%8) & 0xFF);
|
||||
|
||||
/* Pack bit 7. */
|
||||
ecc_buffer[(7+2)/8] = ((UCHAR)(ecc_buffer[(7+2)/8] | ((odd_bit_parity >> 3) & 1) << (7+2)%8) & 0xFF);
|
||||
|
||||
|
||||
/* Pack bit 6. */
|
||||
ecc_buffer[(6+2)/8] = ((UCHAR)(ecc_buffer[(6+2)/8] | ((even_bit_parity >> 3) & 1) << (6+2)%8) & 0xFF);
|
||||
|
||||
|
||||
/* Pack bit 5. */
|
||||
ecc_buffer[(5+2)/8] = ((UCHAR)(ecc_buffer[(5+2)/8] | ((odd_bit_parity >> 2) & 1) << (5+2)%8) & 0xFF);
|
||||
|
||||
@@ -223,10 +211,10 @@ USHORT odd_byte_parity;
|
||||
/* Pack bit 2. */
|
||||
ecc_buffer[(2+2)/8] = ((UCHAR)(ecc_buffer[(2+2)/8] | ((even_bit_parity >> 1) & 1) << (2+2)%8) & 0xFF);
|
||||
|
||||
/* Pack bit 1. */
|
||||
/* Pack bit 1. */
|
||||
ecc_buffer[(1+2)/8] = ((UCHAR)(ecc_buffer[(1+2)/8] | ((odd_bit_parity >> 0) & 1) << (1+2)%8) & 0xFF);
|
||||
|
||||
/* Pack bit 0. */
|
||||
/* Pack bit 0. */
|
||||
ecc_buffer[(0+2)/8] = ((UCHAR)(ecc_buffer[(0+2)/8] | ((even_bit_parity >> 0) & 1) << (0+2)%8) & 0xFF);
|
||||
|
||||
ecc_buffer[0] = (UCHAR)~ecc_buffer[0];
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,42 +35,36 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_block_allocate PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_block_allocate PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Xiuwen Cai, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function attempts to get a block in the free block list. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* block Return block number */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
|
||||
/* This function attempts to get a block in the free block list. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* block Return block number */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_block_allocate(LX_NAND_FLASH* nand_flash, ULONG* block)
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,55 +35,49 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_block_data_move PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_block_data_move PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Xiuwen Cai, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function finds a block with less erase count and copies pages */
|
||||
/* into new block. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* new_block New block number */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_mapped_block_list_get Get mapped block index */
|
||||
/* _lx_nand_flash_block_find Find the mapped block */
|
||||
/* _lx_nand_flash_data_page_copy Copy data pages */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function finds a block with less erase count and copies pages */
|
||||
/* into new block. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* new_block New block number */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_mapped_block_list_get Get mapped block index */
|
||||
/* _lx_nand_flash_block_find Find the mapped block */
|
||||
/* _lx_nand_flash_data_page_copy Copy data pages */
|
||||
/* _lx_nand_flash_free_block_list_add Add free block to list */
|
||||
/* _lx_nand_flash_block_status_set Set block status */
|
||||
/* _lx_nand_flash_block_mapping_set Set block mapping */
|
||||
/* _lx_nand_flash_block_status_set Set block status */
|
||||
/* _lx_nand_flash_block_mapping_set Set block mapping */
|
||||
/* _lx_nand_flash_mapped_block_list_add Add mapped block to list */
|
||||
/* _lx_nand_flash_driver_block_erase Erase block */
|
||||
/* _lx_nand_flash_driver_block_erase Erase block */
|
||||
/* _lx_nand_flash_erase_count_set Set erase count */
|
||||
/* _lx_nand_flash_free_block_list_add Add free block to list */
|
||||
/* _lx_nand_flash_system_error Internal system error handler */
|
||||
/* tx_mutex_get Get thread protection */
|
||||
/* tx_mutex_put Release thread protection */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* _lx_nand_flash_system_error Internal system error handler */
|
||||
/* tx_mutex_get Get thread protection */
|
||||
/* tx_mutex_put Release thread protection */
|
||||
/* */
|
||||
/* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_block_data_move(LX_NAND_FLASH *nand_flash, ULONG new_block)
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,49 +35,43 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_block_find PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_block_find PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Xiuwen Cai, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function attempts to find the mapped block for the logical */
|
||||
/* sector in the mapping table. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* logical_sector Logical sector number */
|
||||
/* superceded_check Check for page being */
|
||||
/* superceded (can happen if */
|
||||
/* on interruptions of page */
|
||||
/* write) */
|
||||
/* block Destination for block */
|
||||
/* page Destination for page */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
|
||||
/* This function attempts to find the mapped block for the logical */
|
||||
/* sector in the mapping table. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* logical_sector Logical sector number */
|
||||
/* superceded_check Check for page being */
|
||||
/* superceded (can happen if */
|
||||
/* on interruptions of page */
|
||||
/* write) */
|
||||
/* block Destination for block */
|
||||
/* page Destination for page */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_block_find(LX_NAND_FLASH *nand_flash, ULONG logical_sector, ULONG *block, USHORT *block_status)
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,43 +35,37 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_block_mapping_set PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_block_mapping_set PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Xiuwen Cai, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function sets block mappings. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* logical_sector Logical sector number */
|
||||
/* block Block number */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_metadata_write Write metadata */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
|
||||
/* This function sets block mappings. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* logical_sector Logical sector number */
|
||||
/* block Block number */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_metadata_write Write metadata */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_block_mapping_set(LX_NAND_FLASH *nand_flash, ULONG logical_sector, ULONG block)
|
||||
@@ -99,8 +94,8 @@ UINT status;
|
||||
page_number = (UCHAR)(block_mapping_index * sizeof(*nand_flash -> lx_nand_flash_block_mapping_table) / nand_flash -> lx_nand_flash_bytes_per_page);
|
||||
|
||||
/* Save the mapping table. */
|
||||
status = _lx_nand_flash_metadata_write(nand_flash, ((UCHAR*)nand_flash -> lx_nand_flash_block_mapping_table) +
|
||||
page_number * nand_flash -> lx_nand_flash_bytes_per_page,
|
||||
status = _lx_nand_flash_metadata_write(nand_flash, ((UCHAR*)nand_flash -> lx_nand_flash_block_mapping_table) +
|
||||
page_number * nand_flash -> lx_nand_flash_bytes_per_page,
|
||||
LX_NAND_PAGE_TYPE_BLOCK_MAPPING_TABLE | page_number);
|
||||
|
||||
/* Return status. */
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,43 +35,37 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_block_status_set PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_block_status_set PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Xiuwen Cai, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function sets block status. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* block Block number */
|
||||
/* block_status Block status */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_metadata_write Write metadata */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
|
||||
/* This function sets block status. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* block Block number */
|
||||
/* block_status Block status */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_metadata_write Write metadata */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_block_status_set(LX_NAND_FLASH *nand_flash, ULONG block, ULONG block_status)
|
||||
@@ -87,7 +82,7 @@ UINT status;
|
||||
page_number = (UCHAR)(block * sizeof(*nand_flash -> lx_nand_flash_block_status_table) / nand_flash -> lx_nand_flash_bytes_per_page);
|
||||
|
||||
/* Save the status table. */
|
||||
status = _lx_nand_flash_metadata_write(nand_flash, ((UCHAR*)nand_flash -> lx_nand_flash_block_status_table) +
|
||||
status = _lx_nand_flash_metadata_write(nand_flash, ((UCHAR*)nand_flash -> lx_nand_flash_block_status_table) +
|
||||
page_number * nand_flash -> lx_nand_flash_bytes_per_page, LX_NAND_PAGE_TYPE_BLOCK_STATUS_TABLE | page_number);
|
||||
|
||||
/* Return status. */
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,45 +35,35 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_close PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_close PORTABLE C */
|
||||
/* 6.1.7 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function closes a NAND flash instance. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* tx_mutex_delete Delete thread-safe mutex */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* This function closes a NAND flash instance. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* tx_mutex_delete Delete thread-safe mutex */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_close(LX_NAND_FLASH *nand_flash)
|
||||
@@ -105,9 +96,9 @@ LX_INTERRUPT_SAVE_AREA
|
||||
/* See if we have to update the opened list head pointer. */
|
||||
if (_lx_nand_flash_opened_ptr == nand_flash)
|
||||
{
|
||||
|
||||
|
||||
/* Yes, move the head pointer to the next opened NAND flash. */
|
||||
_lx_nand_flash_opened_ptr = nand_flash -> lx_nand_flash_open_next;
|
||||
_lx_nand_flash_opened_ptr = nand_flash -> lx_nand_flash_open_next;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +107,7 @@ LX_INTERRUPT_SAVE_AREA
|
||||
|
||||
/* Finally, indicate that this NAND flash is closed. */
|
||||
nand_flash -> lx_nand_flash_state = LX_NAND_FLASH_CLOSED;
|
||||
|
||||
|
||||
/* Restore interrupt posture. */
|
||||
LX_RESTORE
|
||||
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,54 +35,44 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_data_page_copy PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_data_page_copy PORTABLE C */
|
||||
/* 6.4.0 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Xiuwen Cai, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function copies logical sectors into new block. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* logical_sector Logical sector number */
|
||||
/* source_block Source block number */
|
||||
/* src_block_status Source block status */
|
||||
/* destination_block Destination block number */
|
||||
/* dest_block_status_ptr Pointer to destination block */
|
||||
/* status */
|
||||
/* sectors Number of sectors to copy */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* lx_nand_flash_driver_pages_copy Driver pages copy */
|
||||
/* lx_nand_flash_driver_pages_read Driver pages read */
|
||||
/* _lx_nand_flash_system_error Internal system error handler */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
|
||||
/* 12-31-2023 Xiuwen Cai Modified comment(s), */
|
||||
/* fixed sequential checking */
|
||||
/* logic, */
|
||||
/* resulting in version 6.4.0 */
|
||||
/* This function copies logical sectors into new block. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* logical_sector Logical sector number */
|
||||
/* source_block Source block number */
|
||||
/* src_block_status Source block status */
|
||||
/* destination_block Destination block number */
|
||||
/* dest_block_status_ptr Pointer to destination block */
|
||||
/* status */
|
||||
/* sectors Number of sectors to copy */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* lx_nand_flash_driver_pages_copy Driver pages copy */
|
||||
/* lx_nand_flash_driver_pages_read Driver pages read */
|
||||
/* _lx_nand_flash_system_error Internal system error handler */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_data_page_copy(LX_NAND_FLASH* nand_flash, ULONG logical_sector, ULONG source_block, USHORT src_block_status,
|
||||
@@ -200,7 +191,7 @@ ULONG number_of_pages;
|
||||
source_page = (LONG)(logical_sector % nand_flash -> lx_nand_flash_pages_per_block);
|
||||
|
||||
/* Check if the page to copy is greater than the available pages. */
|
||||
number_of_pages = ((ULONG)source_page + sectors) > available_pages ?
|
||||
number_of_pages = ((ULONG)source_page + sectors) > available_pages ?
|
||||
(available_pages > (ULONG)source_page ? available_pages - (ULONG)source_page : 0) : sectors;
|
||||
|
||||
/* Check if there is any pages to be copied. */
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,56 +35,43 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_defragment PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_defragment PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function defragments the NAND flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_block_reclaim Reclaim a NAND flash block */
|
||||
/* tx_mutex_get Get thread protection */
|
||||
/* tx_mutex_put Release thread protection */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* 03-08-2023 Xiuwen Cai Modified comment(s), */
|
||||
/* deprecated this API, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* This function defragments the NAND flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_block_reclaim Reclaim a NAND flash block */
|
||||
/* tx_mutex_get Get thread protection */
|
||||
/* tx_mutex_put Release thread protection */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_defragment(LX_NAND_FLASH *nand_flash)
|
||||
{
|
||||
|
||||
|
||||
LX_PARAMETER_NOT_USED(nand_flash);
|
||||
|
||||
/* Return not supported. */
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,51 +35,37 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_driver_block_erase PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_driver_block_erase PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function calls the driver to erase a block. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* block Block number */
|
||||
/* erase_count Erase count for this block */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* Completion Status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* (lx_nand_flash_driver_block_erase) Driver erase block */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* 03-08-2023 Xiuwen Cai Modified comment(s), */
|
||||
/* removed cache support, */
|
||||
/* added new driver interface, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* This function calls the driver to erase a block. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* block Block number */
|
||||
/* erase_count Erase count for this block */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* Completion Status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* (lx_nand_flash_driver_block_erase) Driver erase block */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_driver_block_erase(LX_NAND_FLASH *nand_flash, ULONG block, ULONG erase_count)
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,51 +35,38 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_driver_block_erased_verify PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_driver_block_erased_verify PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function calls the driver to verify the block was erased. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* block Block number */
|
||||
/* page Page number */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* Completion Status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* (lx_nand_flash_driver_block_erased_verify) */
|
||||
/* Driver verify page erased */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* 03-08-2023 Xiuwen Cai Modified comment(s), */
|
||||
/* added new driver interface, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* This function calls the driver to verify the block was erased. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* block Block number */
|
||||
/* page Page number */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* Completion Status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* (lx_nand_flash_driver_block_erased_verify) */
|
||||
/* Driver verify page erased */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_driver_block_erased_verify(LX_NAND_FLASH *nand_flash, ULONG block)
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,53 +35,39 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_driver_block_status_get PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_driver_block_status_get PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function calls the driver to get the block status and */
|
||||
/* updates the internal cache. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* block Block number */
|
||||
/* bad_block_flag Pointer to Bad block flag */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* Completion Status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* (lx_nand_flash_driver_block_status_get) */
|
||||
/* NAND flash block status get */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* 03-08-2023 Xiuwen Cai Modified comment(s), */
|
||||
/* removed cache support, */
|
||||
/* added new driver interface, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* This function calls the driver to get the block status and */
|
||||
/* updates the internal cache. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* block Block number */
|
||||
/* bad_block_flag Pointer to Bad block flag */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* Completion Status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* (lx_nand_flash_driver_block_status_get) */
|
||||
/* NAND flash block status get */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_driver_block_status_get(LX_NAND_FLASH *nand_flash, ULONG block, UCHAR *bad_block_flag)
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,53 +35,39 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_driver_block_status_set PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_driver_block_status_set PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function calls the driver to set the block status and */
|
||||
/* updates the internal cache. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* block Block number */
|
||||
/* bad_block_flag Bad block flag */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* Completion Status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* (lx_nand_flash_driver_block_status_set) */
|
||||
/* NAND flash block status set */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* 03-08-2023 Xiuwen Cai Modified comment(s), */
|
||||
/* removed cache support, */
|
||||
/* added new driver interface, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* This function calls the driver to set the block status and */
|
||||
/* updates the internal cache. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* block Block number */
|
||||
/* bad_block_flag Bad block flag */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* Completion Status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* (lx_nand_flash_driver_block_status_set) */
|
||||
/* NAND flash block status set */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_driver_block_status_set(LX_NAND_FLASH *nand_flash, ULONG block, UCHAR bad_block_flag)
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,51 +35,38 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_driver_page_erased_verify PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_driver_page_erased_verify PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function calls the driver to verify the page was erased. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* block Block number */
|
||||
/* page Page number */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* Completion Status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* (lx_nand_flash_driver_page_erased_verify) */
|
||||
/* Driver verify page erased */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* 03-08-2023 Xiuwen Cai Modified comment(s), */
|
||||
/* added new driver interface, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* This function calls the driver to verify the page was erased. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* block Block number */
|
||||
/* page Page number */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* Completion Status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* (lx_nand_flash_driver_page_erased_verify) */
|
||||
/* Driver verify page erased */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_driver_page_erased_verify(LX_NAND_FLASH *nand_flash, ULONG block, ULONG page)
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,43 +35,37 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_erase_count_set PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_erase_count_set PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Xiuwen Cai, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function sets block erase count. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* block Block number */
|
||||
/* erase_count Erase count */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_metadata_write Write metadata */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
|
||||
/* This function sets block erase count. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* block Block number */
|
||||
/* erase_count Erase count */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_metadata_write Write metadata */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_erase_count_set(LX_NAND_FLASH *nand_flash, ULONG block, UCHAR erase_count)
|
||||
@@ -87,8 +82,8 @@ UINT status;
|
||||
page_number = (UCHAR)(block * sizeof(*nand_flash -> lx_nand_flash_erase_count_table) / nand_flash -> lx_nand_flash_bytes_per_page);
|
||||
|
||||
/* Save the erase count table. */
|
||||
status = _lx_nand_flash_metadata_write(nand_flash, ((UCHAR*)nand_flash -> lx_nand_flash_erase_count_table) +
|
||||
page_number * nand_flash -> lx_nand_flash_bytes_per_page,
|
||||
status = _lx_nand_flash_metadata_write(nand_flash, ((UCHAR*)nand_flash -> lx_nand_flash_erase_count_table) +
|
||||
page_number * nand_flash -> lx_nand_flash_bytes_per_page,
|
||||
LX_NAND_PAGE_TYPE_ERASE_COUNT_TABLE | page_number);
|
||||
|
||||
/* Return sector not found status. */
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,53 +35,40 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_extended_cache_enable PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_extended_cache_enable PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function sets up the extended NAND cache for block status, */
|
||||
/* page extra bytes, and page 0 contents. The routine will enable as */
|
||||
/* many cache capabilities as possible until the supplied memory is */
|
||||
/* exhausted. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* memory Pointer to memory for caches */
|
||||
/* size Size of memory in bytes */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* Completion Status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* 03-08-2023 Xiuwen Cai Modified comment(s), */
|
||||
/* deprecated this API, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* This function sets up the extended NAND cache for block status, */
|
||||
/* page extra bytes, and page 0 contents. The routine will enable as */
|
||||
/* many cache capabilities as possible until the supplied memory is */
|
||||
/* exhausted. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* memory Pointer to memory for caches */
|
||||
/* size Size of memory in bytes */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* Completion Status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_extended_cache_enable(LX_NAND_FLASH *nand_flash, VOID *memory, ULONG size)
|
||||
@@ -89,7 +77,7 @@ UINT _lx_nand_flash_extended_cache_enable(LX_NAND_FLASH *nand_flash, VOID *mem
|
||||
LX_PARAMETER_NOT_USED(nand_flash);
|
||||
LX_PARAMETER_NOT_USED(memory);
|
||||
LX_PARAMETER_NOT_USED(size);
|
||||
|
||||
|
||||
/* Return not supported. */
|
||||
return(LX_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
* Copyright (c) 2025 STMicroelectronics
|
||||
*
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -35,42 +36,42 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_format PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_format PORTABLE C */
|
||||
/* */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Xiuwen Cai, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function erases and formats a NAND flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* name Name of NAND flash instance */
|
||||
/* nand_driver_initialize Driver initialize */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function erases and formats a NAND flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* name Name of NAND flash instance */
|
||||
/* nand_driver_initialize Driver initialize */
|
||||
/* memory_ptr Pointer to memory used by the */
|
||||
/* LevelX for this NAND. */
|
||||
/* memory_size Size of memory - must at least*/
|
||||
/* 7 * total block count + */
|
||||
/* 2 * page size */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* _lx_nand_flash_format_extended */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_format(LX_NAND_FLASH* nand_flash, CHAR* name,
|
||||
UINT(*nand_driver_initialize)(LX_NAND_FLASH*),
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
* Copyright (c) 2025 STMicroelectronics
|
||||
*
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -35,55 +36,55 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_format_extended PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_format_extended PORTABLE C */
|
||||
/* */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Xiuwen Cai, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function erases and formats a NAND flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* name Name of NAND flash instance */
|
||||
/* nand_driver_initialize Driver initialize */
|
||||
/* nand_driver_info_ptr Driver user data pointer */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function erases and formats a NAND flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* name Name of NAND flash instance */
|
||||
/* nand_driver_initialize Driver initialize */
|
||||
/* nand_driver_info_ptr Driver user data pointer */
|
||||
/* memory_ptr Pointer to memory used by the */
|
||||
/* LevelX for this NAND. */
|
||||
/* memory_size Size of memory - must at least*/
|
||||
/* 7 * total block count + */
|
||||
/* 2 * page size */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* (nand_driver_initialize) Driver initialize */
|
||||
/* LX_MEMSET Initialize memory */
|
||||
/* _lx_nand_flash_memory_initialize Initialize buffer */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* (nand_driver_initialize) Driver initialize */
|
||||
/* LX_MEMSET Initialize memory */
|
||||
/* _lx_nand_flash_memory_initialize Initialize buffer */
|
||||
/* _lx_nand_flash_driver_block_status_get */
|
||||
/* Driver block status get */
|
||||
/* _lx_nand_flash_driver_block_status_set */
|
||||
/* Driver block status set */
|
||||
/* _lx_nand_flash_metadata_build Build metadata */
|
||||
/* Driver block status get */
|
||||
/* _lx_nand_flash_driver_block_status_set */
|
||||
/* Driver block status set */
|
||||
/* _lx_nand_flash_metadata_build Build metadata */
|
||||
/* _lx_nand_flash_metadata_write Write metadata */
|
||||
/* _lx_nand_flash_driver_block_erase Driver block erase */
|
||||
/* _lx_nand_flash_system_error System error handler */
|
||||
/* tx_mutex_create Create thread-safe mutex */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* _lx_nand_flash_driver_block_erase Driver block erase */
|
||||
/* _lx_nand_flash_system_error System error handler */
|
||||
/* tx_mutex_create Create thread-safe mutex */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_format_extended(LX_NAND_FLASH* nand_flash, CHAR* name,
|
||||
UINT(*nand_driver_initialize)(LX_NAND_FLASH*),VOID* nand_driver_info_ptr,
|
||||
@@ -242,7 +243,7 @@ UCHAR *page_buffer_ptr;
|
||||
nand_flash -> lx_nand_flash_block_status_table[nand_flash -> lx_nand_flash_metadata_block_number_next] = LX_NAND_BLOCK_STATUS_ALLOCATED;
|
||||
nand_flash -> lx_nand_flash_block_status_table[nand_flash -> lx_nand_flash_backup_metadata_block_number] = (USHORT)nand_flash -> lx_nand_flash_backup_metadata_block_number_next;
|
||||
nand_flash -> lx_nand_flash_block_status_table[nand_flash -> lx_nand_flash_metadata_block_number] = (USHORT)nand_flash -> lx_nand_flash_metadata_block_number_next;
|
||||
|
||||
|
||||
/* Initialize the mapping table. */
|
||||
LX_MEMSET(nand_flash -> lx_nand_flash_block_mapping_table, 0xFF, nand_flash -> lx_nand_flash_block_mapping_table_size);
|
||||
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,42 +35,36 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_free_block_list_add PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_free_block_list_add PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Xiuwen Cai, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function adds a block to free block list. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* block Block number */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
|
||||
/* This function adds a block to free block list. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* block Block number */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_free_block_list_add(LX_NAND_FLASH* nand_flash, ULONG block)
|
||||
@@ -101,7 +96,7 @@ UCHAR new_block_erase_count;
|
||||
search_position = (INT)insert_position - 1;
|
||||
|
||||
/* Loop to search the insert position by block erase count. */
|
||||
while ((search_position >= 0) &&
|
||||
while ((search_position >= 0) &&
|
||||
(nand_flash -> lx_nand_flash_erase_count_table[nand_flash -> lx_nand_flash_block_list[search_position]] < new_block_erase_count))
|
||||
{
|
||||
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -33,43 +34,35 @@ LX_NAND_FLASH *_lx_nand_flash_opened_ptr;
|
||||
ULONG _lx_nand_flash_opened_count;
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_initialize PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_initialize PORTABLE C */
|
||||
/* 6.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function initializes the NAND flash data structures. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* This function initializes the NAND flash data structures. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_initialize(void)
|
||||
@@ -78,7 +71,7 @@ UINT _lx_nand_flash_initialize(void)
|
||||
/* Clear open list head pointer and opened count. */
|
||||
_lx_nand_flash_opened_ptr = LX_NULL;
|
||||
_lx_nand_flash_opened_count = 0;
|
||||
|
||||
|
||||
/* Return success! */
|
||||
return(LX_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,42 +35,36 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_mapped_block_list_add PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_mapped_block_list_add PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Xiuwen Cai, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function adds a block to mapped block list. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* block_mapping_index Block mapping index */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
|
||||
/* This function adds a block to mapped block list. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* block_mapping_index Block mapping index */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_mapped_block_list_add(LX_NAND_FLASH* nand_flash, ULONG block_mapping_index)
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,43 +35,37 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_mapped_block_list_get PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_mapped_block_list_get PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Xiuwen Cai, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function gets a block from mapped block list and removes it */
|
||||
/* from the list. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* block_mapping_index Pointer to block mapping index*/
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
|
||||
/* This function gets a block from mapped block list and removes it */
|
||||
/* from the list. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* block_mapping_index Pointer to block mapping index*/
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_mapped_block_list_get(LX_NAND_FLASH* nand_flash, ULONG *block_mapping_index)
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,42 +35,36 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_mapped_block_list_remove PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_mapped_block_list_remove PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Xiuwen Cai, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function removes mapped block from list. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* block_mapping_index Block mapping index */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
|
||||
/* This function removes mapped block from list. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* block_mapping_index Block mapping index */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_mapped_block_list_remove(LX_NAND_FLASH* nand_flash, ULONG block_mapping_index)
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,45 +35,39 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_memory_initialize PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_memory_initialize PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Xiuwen Cai, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function imitialize memory buffer for NAND flash instance. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function imitialize memory buffer for NAND flash instance. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* memory_ptr Pointer to memory used by the */
|
||||
/* LevelX for this NAND. */
|
||||
/* memory_size Size of memory */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* LX_MEMSET Initialize memory */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* LX_MEMSET Initialize memory */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_memory_initialize(LX_NAND_FLASH *nand_flash, ULONG* memory_ptr, UINT memory_size)
|
||||
{
|
||||
@@ -124,7 +119,7 @@ UINT buffer_size;
|
||||
|
||||
/* Assign memory for erase count table. */
|
||||
nand_flash -> lx_nand_flash_erase_count_table = (UCHAR*)(((UCHAR*)memory_ptr) + memory_offset);
|
||||
|
||||
|
||||
/* Update memory offset. */
|
||||
memory_offset += buffer_size;
|
||||
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,50 +35,44 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_metadata_allocate PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_metadata_allocate PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Xiuwen Cai, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function allocates new blocks for metadata if current metadata */
|
||||
/* block is full. This function also frees metadata blocks if the chain*/
|
||||
/* is too long. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_metadata_build Build metadata */
|
||||
/* _lx_nand_flash_driver_block_erase Erase block */
|
||||
/* _lx_nand_flash_block_data_move Move block data */
|
||||
/* _lx_nand_flash_free_block_list_add Add free block list */
|
||||
/* _lx_nand_flash_block_allocate Allocate block */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_metadata_build Build metadata */
|
||||
/* _lx_nand_flash_driver_block_erase Erase block */
|
||||
/* _lx_nand_flash_block_data_move Move block data */
|
||||
/* _lx_nand_flash_free_block_list_add Add free block list */
|
||||
/* _lx_nand_flash_block_allocate Allocate block */
|
||||
/* _lx_nand_flash_block_status_set Set block status */
|
||||
/* _lx_nand_flash_metadata_write Write metadata */
|
||||
/* _lx_nand_flash_system_error Internal system error handler */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* _lx_nand_flash_system_error Internal system error handler */
|
||||
/* */
|
||||
/* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_metadata_allocate(LX_NAND_FLASH *nand_flash)
|
||||
@@ -150,7 +145,7 @@ UCHAR min_erase_count;
|
||||
|
||||
/* Exclude erase count of bad block. */
|
||||
if(nand_flash -> lx_nand_flash_block_status_table[j] != LX_NAND_BLOCK_STATUS_BAD)
|
||||
{
|
||||
{
|
||||
|
||||
/* Check if it has less erase count. */
|
||||
if (nand_flash -> lx_nand_flash_erase_count_table[j] < min_erase_count)
|
||||
@@ -239,7 +234,7 @@ UCHAR min_erase_count;
|
||||
|
||||
/* Erase the block. */
|
||||
status = _lx_nand_flash_driver_block_erase(nand_flash, block, nand_flash -> lx_nand_flash_base_erase_count + nand_flash -> lx_nand_flash_erase_count_table[block]);
|
||||
|
||||
|
||||
/* Check for an error from flash driver. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,41 +35,35 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_metadata_build PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_metadata_build PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Xiuwen Cai, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function rewrites all metadata pages. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_metadata_write Write metadata */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
|
||||
/* This function rewrites all metadata pages. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_metadata_write Write metadata */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_metadata_build(LX_NAND_FLASH *nand_flash)
|
||||
@@ -109,7 +104,7 @@ UINT i;
|
||||
{
|
||||
|
||||
/* Write erase count table. */
|
||||
status = _lx_nand_flash_metadata_write(nand_flash, (UCHAR*)(nand_flash -> lx_nand_flash_erase_count_table +
|
||||
status = _lx_nand_flash_metadata_write(nand_flash, (UCHAR*)(nand_flash -> lx_nand_flash_erase_count_table +
|
||||
i * nand_flash -> lx_nand_flash_bytes_per_page),
|
||||
LX_NAND_PAGE_TYPE_ERASE_COUNT_TABLE | i);
|
||||
|
||||
@@ -130,8 +125,8 @@ UINT i;
|
||||
{
|
||||
|
||||
/* Write block mapping table. */
|
||||
status = _lx_nand_flash_metadata_write(nand_flash, (UCHAR*)(nand_flash -> lx_nand_flash_block_mapping_table +
|
||||
i * nand_flash -> lx_nand_flash_bytes_per_page / sizeof(*nand_flash -> lx_nand_flash_block_mapping_table)),
|
||||
status = _lx_nand_flash_metadata_write(nand_flash, (UCHAR*)(nand_flash -> lx_nand_flash_block_mapping_table +
|
||||
i * nand_flash -> lx_nand_flash_bytes_per_page / sizeof(*nand_flash -> lx_nand_flash_block_mapping_table)),
|
||||
LX_NAND_PAGE_TYPE_BLOCK_MAPPING_TABLE | i);
|
||||
/* Check return status. */
|
||||
if (status != LX_SUCCESS)
|
||||
@@ -150,14 +145,14 @@ UINT i;
|
||||
{
|
||||
|
||||
/* Write block status table. */
|
||||
status = _lx_nand_flash_metadata_write(nand_flash, (UCHAR*)(nand_flash -> lx_nand_flash_block_status_table +
|
||||
i * nand_flash -> lx_nand_flash_bytes_per_page / sizeof(*nand_flash -> lx_nand_flash_block_status_table)),
|
||||
status = _lx_nand_flash_metadata_write(nand_flash, (UCHAR*)(nand_flash -> lx_nand_flash_block_status_table +
|
||||
i * nand_flash -> lx_nand_flash_bytes_per_page / sizeof(*nand_flash -> lx_nand_flash_block_status_table)),
|
||||
LX_NAND_PAGE_TYPE_BLOCK_STATUS_TABLE | i);
|
||||
|
||||
/* Check return status. */
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
/* Return error status. */
|
||||
return(status);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,46 +35,40 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_metadata_write PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_metadata_write PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Xiuwen Cai, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function writes metadata pages into current metadata block and */
|
||||
/* allocates new blocks for metadata. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* main_buffer Main page buffer */
|
||||
/* spare_value Value for spare bytes */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* lx_nand_flash_driver_pages_write Driver pages write */
|
||||
/* _lx_nand_flash_metadata_allocate Allocate blocks for metadata */
|
||||
/* _lx_nand_flash_system_error Internal system error handler */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
|
||||
/* This function writes metadata pages into current metadata block and */
|
||||
/* allocates new blocks for metadata. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* main_buffer Main page buffer */
|
||||
/* spare_value Value for spare bytes */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* lx_nand_flash_driver_pages_write Driver pages write */
|
||||
/* _lx_nand_flash_metadata_allocate Allocate blocks for metadata */
|
||||
/* _lx_nand_flash_system_error Internal system error handler */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_metadata_write(LX_NAND_FLASH *nand_flash, UCHAR* main_buffer, ULONG spare_value)
|
||||
@@ -115,7 +110,7 @@ UCHAR *spare_buffer_ptr;
|
||||
status = (nand_flash -> lx_nand_flash_driver_pages_write)(block, page, main_buffer, spare_buffer_ptr, 1);
|
||||
#endif
|
||||
|
||||
/* Check for an error from flash driver. */
|
||||
/* Check for an error from flash driver. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,55 +35,44 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_open PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_open PORTABLE C */
|
||||
/* 6.3.0 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Xiuwen Cai, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function opens a NAND flash instance and ensures the */
|
||||
/* NAND flash is in a coherent state. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* name Name of NAND flash instance */
|
||||
/* nand_driver_initialize Driver initialize */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function opens a NAND flash instance and ensures the */
|
||||
/* NAND flash is in a coherent state. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* name Name of NAND flash instance */
|
||||
/* nand_driver_initialize Driver initialize */
|
||||
/* nand_driver_info_ptr User data pointer */
|
||||
/* memory_ptr Pointer to memory used by the */
|
||||
/* LevelX for this NAND. */
|
||||
/* memory_size Size of memory - must at least*/
|
||||
/* 7 * total block count + */
|
||||
/* 2 * page size */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* lx_nand_flash_open_extended Pass NULL as driver_info_ptr */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
|
||||
/* 10-31-2023 Xiuwen Cai Modified comment(s), */
|
||||
/* avoided clearing user */
|
||||
/* extension in flash control */
|
||||
/* block, */
|
||||
/* resulting in version 6.3.0 */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* lx_nand_flash_open_extended Pass NULL as driver_info_ptr */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_open(LX_NAND_FLASH *nand_flash, CHAR *name, UINT (*nand_driver_initialize)(LX_NAND_FLASH *),
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,62 +35,51 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_open PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_open PORTABLE C */
|
||||
/* 6.3.0 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Xiuwen Cai, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function opens a NAND flash instance and ensures the */
|
||||
/* NAND flash is in a coherent state. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* name Name of NAND flash instance */
|
||||
/* nand_driver_initialize Driver initialize */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function opens a NAND flash instance and ensures the */
|
||||
/* NAND flash is in a coherent state. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* name Name of NAND flash instance */
|
||||
/* nand_driver_initialize Driver initialize */
|
||||
/* memory_ptr Pointer to memory used by the */
|
||||
/* LevelX for this NAND. */
|
||||
/* memory_size Size of memory - must at least*/
|
||||
/* 7 * total block count + */
|
||||
/* 2 * page size */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* (nand_driver_initialize) Driver initialize */
|
||||
/* _lx_nand_flash_memory_initialize Initialize buffer */
|
||||
/* _lx_nand_flash_driver_block_status_get */
|
||||
/* Get block status */
|
||||
/* lx_nand_flash_driver_pages_read Read pages */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* (nand_driver_initialize) Driver initialize */
|
||||
/* _lx_nand_flash_memory_initialize Initialize buffer */
|
||||
/* _lx_nand_flash_driver_block_status_get */
|
||||
/* Get block status */
|
||||
/* lx_nand_flash_driver_pages_read Read pages */
|
||||
/* _lx_nand_flash_free_block_list_add Add free block to list */
|
||||
/* _lx_nand_flash_mapped_block_list_add Add mapped block to list */
|
||||
/* _lx_nand_flash_system_error System error handler */
|
||||
/* tx_mutex_create Create thread-safe mutex */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* _lx_nand_flash_system_error System error handler */
|
||||
/* tx_mutex_create Create thread-safe mutex */
|
||||
/* */
|
||||
/* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
|
||||
/* 10-31-2023 Xiuwen Cai Modified comment(s), */
|
||||
/* avoided clearing user */
|
||||
/* extension in flash control */
|
||||
/* block, */
|
||||
/* resulting in version 6.3.0 */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
|
||||
@@ -170,17 +160,17 @@ LX_INTERRUPT_SAVE_AREA
|
||||
/* Loop through the blocks to check for bad blocks and determine the minimum and maximum erase count for each good block. */
|
||||
for (block = 0; block < nand_flash -> lx_nand_flash_total_blocks; block++)
|
||||
{
|
||||
|
||||
|
||||
/* First, check to make sure this block is good. */
|
||||
status = _lx_nand_flash_driver_block_status_get(nand_flash, block, &block_status);
|
||||
|
||||
/* Check for an error from flash driver. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nand_flash_system_error(nand_flash, status, block, 0);
|
||||
|
||||
|
||||
/* Return an error. */
|
||||
return(LX_ERROR);
|
||||
}
|
||||
@@ -188,9 +178,9 @@ LX_INTERRUPT_SAVE_AREA
|
||||
/* Is this block bad? */
|
||||
if (block_status != LX_NAND_GOOD_BLOCK)
|
||||
{
|
||||
|
||||
|
||||
/* Yes, this block is bad. */
|
||||
|
||||
|
||||
/* Increment the number of bad blocks. */
|
||||
nand_flash -> lx_nand_flash_bad_blocks++;
|
||||
|
||||
@@ -211,14 +201,14 @@ LX_INTERRUPT_SAVE_AREA
|
||||
/* Check for an error from flash driver. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nand_flash_system_error(nand_flash, status, block, 0);
|
||||
|
||||
/* Determine if the error is fatal. */
|
||||
if (status != LX_NAND_ERROR_CORRECTED)
|
||||
{
|
||||
|
||||
|
||||
/* Return an error. */
|
||||
return(LX_ERROR);
|
||||
}
|
||||
@@ -247,7 +237,7 @@ LX_INTERRUPT_SAVE_AREA
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if we have found the metadata block. */
|
||||
if (nand_flash -> lx_nand_flash_metadata_block_number == LX_NAND_BLOCK_UNMAPPED)
|
||||
@@ -270,13 +260,13 @@ LX_INTERRUPT_SAVE_AREA
|
||||
block_count = 0;
|
||||
|
||||
do
|
||||
{
|
||||
{
|
||||
|
||||
/* Initialize next block to unmapped. */
|
||||
nand_flash -> lx_nand_flash_metadata_block_number_next = LX_NAND_BLOCK_UNMAPPED;
|
||||
nand_flash -> lx_nand_flash_backup_metadata_block_number_next = LX_NAND_BLOCK_UNMAPPED;
|
||||
|
||||
/* Loop to read pages in the metadata block. */
|
||||
/* Loop to read pages in the metadata block. */
|
||||
for (page = 0; page < nand_flash -> lx_nand_flash_pages_per_block ; page++)
|
||||
{
|
||||
|
||||
@@ -397,7 +387,7 @@ LX_INTERRUPT_SAVE_AREA
|
||||
/* Unknown type, return error. */
|
||||
status = LX_ERROR;
|
||||
}
|
||||
|
||||
|
||||
/* Check status. */
|
||||
if (status == LX_ERROR)
|
||||
{
|
||||
@@ -459,7 +449,7 @@ LX_INTERRUPT_SAVE_AREA
|
||||
/* Add the block to free block list. */
|
||||
_lx_nand_flash_free_block_list_add(nand_flash, block);
|
||||
}
|
||||
|
||||
|
||||
/* Check for mapped blocks. */
|
||||
if (nand_flash -> lx_nand_flash_block_mapping_table[block] != LX_NAND_BLOCK_UNMAPPED)
|
||||
{
|
||||
@@ -472,17 +462,17 @@ LX_INTERRUPT_SAVE_AREA
|
||||
|
||||
#ifdef LX_THREAD_SAFE_ENABLE
|
||||
|
||||
/* If the thread safe option is enabled, create a ThreadX mutex that will be used in all external APIs
|
||||
/* If the thread safe option is enabled, create a ThreadX mutex that will be used in all external APIs
|
||||
in order to provide thread-safe operation. */
|
||||
status = tx_mutex_create(&nand_flash -> lx_nand_flash_mutex, "NAND Flash Mutex", TX_NO_INHERIT);
|
||||
|
||||
/* Determine if the mutex creation encountered an error. */
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler, since this should not happen. */
|
||||
_lx_nand_flash_system_error(nand_flash, LX_SYSTEM_MUTEX_CREATE_FAILED, 0, 0);
|
||||
|
||||
|
||||
/* Return error to caller. */
|
||||
return(LX_ERROR);
|
||||
}
|
||||
@@ -491,7 +481,7 @@ LX_INTERRUPT_SAVE_AREA
|
||||
/* Lockout interrupts. */
|
||||
LX_DISABLE
|
||||
|
||||
/* At this point, the NAND flash has been opened successfully. Place the
|
||||
/* At this point, the NAND flash has been opened successfully. Place the
|
||||
NAND flash control block on the linked list of currently opened NAND flashes. */
|
||||
|
||||
/* Set the NAND flash state to open. */
|
||||
@@ -513,7 +503,7 @@ LX_INTERRUPT_SAVE_AREA
|
||||
|
||||
/* Setup this NAND flash's opened links. */
|
||||
nand_flash -> lx_nand_flash_open_previous = tail_ptr;
|
||||
nand_flash -> lx_nand_flash_open_next = _lx_nand_flash_opened_ptr;
|
||||
nand_flash -> lx_nand_flash_open_next = _lx_nand_flash_opened_ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,48 +35,38 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_page_ecc_check PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_page_ecc_check PORTABLE C */
|
||||
/* 6.1.7 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function checks the NAND page and ECC for errors and */
|
||||
/* attempts to correct 1 bit errors. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* page_buffer Page buffer */
|
||||
/* ecc_buffer Returned ECC buffer */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_256byte_ecc_check Check 256 bytes and ECC */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* NAND flash driver */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* This function checks the NAND page and ECC for errors and */
|
||||
/* attempts to correct 1 bit errors. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* page_buffer Page buffer */
|
||||
/* ecc_buffer Returned ECC buffer */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_256byte_ecc_check Check 256 bytes and ECC */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* NAND flash driver */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_page_ecc_check(LX_NAND_FLASH *nand_flash, UCHAR *page_buffer, UCHAR *ecc_buffer)
|
||||
@@ -85,48 +76,48 @@ UINT bytes_checked;
|
||||
UINT status;
|
||||
UINT return_status = LX_SUCCESS;
|
||||
|
||||
|
||||
|
||||
/* Loop to check the entire NAND flash page. */
|
||||
bytes_checked = 0;
|
||||
while (bytes_checked < nand_flash -> lx_nand_flash_bytes_per_page)
|
||||
{
|
||||
|
||||
|
||||
/* Check this 256 byte piece of the NAND page. */
|
||||
status = _lx_nand_flash_256byte_ecc_check(page_buffer, ecc_buffer);
|
||||
|
||||
|
||||
/* Determine if there was an error. */
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
/* Determine if a non-correctable error is present. */
|
||||
if (status == LX_NAND_ERROR_NOT_CORRECTED)
|
||||
{
|
||||
|
||||
|
||||
/* Always return a non-correctable error, if present. */
|
||||
return_status = LX_NAND_ERROR_NOT_CORRECTED;
|
||||
return_status = LX_NAND_ERROR_NOT_CORRECTED;
|
||||
break;
|
||||
}
|
||||
|
||||
/* A single-bit error was corrected, return this status
|
||||
|
||||
/* A single-bit error was corrected, return this status
|
||||
if there is no LX_ERROR status already detected. */
|
||||
else if (return_status == LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
/* Return a notice that the single bit error was corrected. */
|
||||
return_status = LX_NAND_ERROR_CORRECTED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Move to the next 256 byte portion of the page. */
|
||||
bytes_checked = bytes_checked + 256;
|
||||
|
||||
|
||||
/* Move the page buffer forward. */
|
||||
page_buffer = page_buffer + 256;
|
||||
|
||||
|
||||
/* Move the ECC buffer forward, note there are 3 bytes of ECC per page. */
|
||||
ecc_buffer = ecc_buffer + 3;
|
||||
}
|
||||
|
||||
|
||||
/* Return status. */
|
||||
return(return_status);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,47 +35,37 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_page_ecc_compute PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_page_ecc_compute PORTABLE C */
|
||||
/* 6.1.7 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function computes the ECC for a NAND flash page. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* page_buffer Page buffer */
|
||||
/* ecc_buffer Returned ECC buffer */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_256byte_ecc_compute Compute ECC for 256 bytes */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* NAND flash driver */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* This function computes the ECC for a NAND flash page. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* page_buffer Page buffer */
|
||||
/* ecc_buffer Returned ECC buffer */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_256byte_ecc_compute Compute ECC for 256 bytes */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* NAND flash driver */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_page_ecc_compute(LX_NAND_FLASH *nand_flash, UCHAR *page_buffer, UCHAR *ecc_buffer)
|
||||
@@ -82,25 +73,25 @@ UINT _lx_nand_flash_page_ecc_compute(LX_NAND_FLASH *nand_flash, UCHAR *page_buf
|
||||
|
||||
UINT bytes_computed;
|
||||
|
||||
|
||||
|
||||
/* Loop to compute the ECC over the entire NAND flash page. */
|
||||
bytes_computed = 0;
|
||||
while (bytes_computed < nand_flash -> lx_nand_flash_bytes_per_page)
|
||||
{
|
||||
|
||||
|
||||
/* Compute the ECC for this 256 byte piece of the page. */
|
||||
_lx_nand_flash_256byte_ecc_compute(page_buffer, ecc_buffer);
|
||||
|
||||
|
||||
/* Move to the next 256 byte portion of the page. */
|
||||
bytes_computed = bytes_computed + 256;
|
||||
|
||||
|
||||
/* Move the page buffer forward. */
|
||||
page_buffer = page_buffer + 256;
|
||||
|
||||
|
||||
/* Move the ECC buffer forward, note there are 3 bytes of ECC per page. */
|
||||
ecc_buffer = ecc_buffer + 3;
|
||||
}
|
||||
|
||||
|
||||
/* Return success. */
|
||||
return(LX_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,57 +35,44 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_partial_defragment PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_partial_defragment PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function defragments the NAND flash up to the specified */
|
||||
/* number of blocks. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* max_blocks Maximum number of blocks to */
|
||||
/* defragment */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* 03-08-2023 Xiuwen Cai Modified comment(s), */
|
||||
/* deprecated this API, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* This function defragments the NAND flash up to the specified */
|
||||
/* number of blocks. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* max_blocks Maximum number of blocks to */
|
||||
/* defragment */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_partial_defragment(LX_NAND_FLASH *nand_flash, UINT max_blocks)
|
||||
{
|
||||
|
||||
|
||||
LX_PARAMETER_NOT_USED(nand_flash);
|
||||
LX_PARAMETER_NOT_USED(max_blocks);
|
||||
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,49 +35,43 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_sector_read PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_sector_read PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Xiuwen Cai, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function reads a logical sector from NAND flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* logical_sector Logical sector number */
|
||||
/* buffer Pointer to buffer to read into*/
|
||||
/* (the size is number of */
|
||||
/* bytes in a page) */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_block_find Find the mapped block */
|
||||
/* lx_nand_flash_driver_pages_read Read pages */
|
||||
/* _lx_nand_flash_system_error Internal system error handler */
|
||||
/* tx_mutex_get Get thread protection */
|
||||
/* tx_mutex_put Release thread protection */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
|
||||
/* This function reads a logical sector from NAND flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* logical_sector Logical sector number */
|
||||
/* buffer Pointer to buffer to read into*/
|
||||
/* (the size is number of */
|
||||
/* bytes in a page) */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_block_find Find the mapped block */
|
||||
/* lx_nand_flash_driver_pages_read Read pages */
|
||||
/* _lx_nand_flash_system_error Internal system error handler */
|
||||
/* tx_mutex_get Get thread protection */
|
||||
/* tx_mutex_put Release thread protection */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_sector_read(LX_NAND_FLASH *nand_flash, ULONG logical_sector, VOID *buffer)
|
||||
@@ -126,7 +121,7 @@ LONG page;
|
||||
/* Determine if the block is mapped. */
|
||||
if (block != LX_NAND_BLOCK_UNMAPPED)
|
||||
{
|
||||
|
||||
|
||||
/* Setup spare buffer pointer. */
|
||||
spare_buffer_ptr = (UCHAR*)nand_flash -> lx_nand_flash_page_buffer;
|
||||
|
||||
@@ -162,7 +157,7 @@ LONG page;
|
||||
/* Return an error. */
|
||||
return(LX_ERROR);
|
||||
}
|
||||
|
||||
|
||||
/* Get the logical sector number from spare bytes, and check if it matches the addressed sector number. */
|
||||
if ((LX_UTILITY_LONG_GET(&spare_buffer_ptr[nand_flash -> lx_nand_flash_spare_data1_offset]) & LX_NAND_PAGE_TYPE_USER_DATA_MASK) == logical_sector)
|
||||
{
|
||||
@@ -240,14 +235,14 @@ LONG page;
|
||||
|
||||
/* Setup pointer to users buffer. */
|
||||
word_ptr = (ULONG *) buffer;
|
||||
|
||||
|
||||
/* Put all ones in he buffer. */
|
||||
for (i = 0; i < nand_flash -> lx_nand_flash_words_per_page; i++)
|
||||
{
|
||||
|
||||
|
||||
/* Copy a word. */
|
||||
*word_ptr++ = LX_ALL_ONES;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the status to success. */
|
||||
status = LX_SUCCESS;
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,58 +35,52 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_sector_release PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_sector_release PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Xiuwen Cai, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function releases a logical sector from being managed in the */
|
||||
/* NAND flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* logical_sector Logical sector number */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_block_find Find the mapped block */
|
||||
/* lx_nand_flash_driver_pages_read Read pages */
|
||||
/* _lx_nand_flash_block_allocate Allocate block */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function releases a logical sector from being managed in the */
|
||||
/* NAND flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* logical_sector Logical sector number */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_block_find Find the mapped block */
|
||||
/* lx_nand_flash_driver_pages_read Read pages */
|
||||
/* _lx_nand_flash_block_allocate Allocate block */
|
||||
/* _lx_nand_flash_mapped_block_list_remove */
|
||||
/* Remove mapped block */
|
||||
/* _lx_nand_flash_data_page_copy Copy data pages */
|
||||
/* Remove mapped block */
|
||||
/* _lx_nand_flash_data_page_copy Copy data pages */
|
||||
/* _lx_nand_flash_free_block_list_add Add free block to list */
|
||||
/* _lx_nand_flash_block_mapping_set Set block mapping */
|
||||
/* _lx_nand_flash_driver_block_erase Erase block */
|
||||
/* _lx_nand_flash_block_mapping_set Set block mapping */
|
||||
/* _lx_nand_flash_driver_block_erase Erase block */
|
||||
/* _lx_nand_flash_erase_count_set Set erase count */
|
||||
/* _lx_nand_flash_block_data_move Move block data */
|
||||
/* _lx_nand_flash_block_status_set Set block status */
|
||||
/* _lx_nand_flash_block_status_set Set block status */
|
||||
/* _lx_nand_flash_mapped_block_list_add Add mapped block to list */
|
||||
/* _lx_nand_flash_system_error Internal system error handler */
|
||||
/* tx_mutex_get Get thread protection */
|
||||
/* tx_mutex_put Release thread protection */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* _lx_nand_flash_system_error Internal system error handler */
|
||||
/* tx_mutex_get Get thread protection */
|
||||
/* tx_mutex_put Release thread protection */
|
||||
/* */
|
||||
/* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_sector_release(LX_NAND_FLASH *nand_flash, ULONG logical_sector)
|
||||
@@ -388,7 +383,7 @@ USHORT new_block_status;
|
||||
/* Check if there is valid pages in the new block. */
|
||||
if ((new_block_status & LX_NAND_BLOCK_STATUS_PAGE_NUMBER_MASK) != 0)
|
||||
{
|
||||
|
||||
|
||||
/* Add the new block to mapped block list. */
|
||||
_lx_nand_flash_mapped_block_list_add(nand_flash, logical_sector / nand_flash -> lx_nand_flash_pages_per_block);
|
||||
}
|
||||
@@ -398,7 +393,7 @@ USHORT new_block_status;
|
||||
|
||||
/* Set page buffer to all 0xFF bytes. */
|
||||
LX_MEMSET(nand_flash -> lx_nand_flash_page_buffer, 0xFF, nand_flash -> lx_nand_flash_bytes_per_page + nand_flash -> lx_nand_flash_spare_total_length);
|
||||
|
||||
|
||||
/* Setup spare buffer pointer. */
|
||||
spare_buffer_ptr = nand_flash -> lx_nand_flash_page_buffer + nand_flash -> lx_nand_flash_bytes_per_page;
|
||||
|
||||
@@ -412,7 +407,7 @@ USHORT new_block_status;
|
||||
|
||||
/* Set page type and sector address. */
|
||||
LX_UTILITY_LONG_SET(&spare_buffer_ptr[nand_flash -> lx_nand_flash_spare_data1_offset], LX_NAND_PAGE_TYPE_USER_DATA_RELEASED | logical_sector);
|
||||
|
||||
|
||||
/* Write the page. */
|
||||
#ifdef LX_NAND_ENABLE_CONTROL_BLOCK_FOR_DRIVER_INTERFACE
|
||||
status = (nand_flash -> lx_nand_flash_driver_pages_write)(nand_flash, block, available_pages, (UCHAR*)nand_flash -> lx_nand_flash_page_buffer, spare_buffer_ptr, 1);
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,60 +35,54 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_sector_write PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_sector_write PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Xiuwen Cai, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function writes a logical sector to the NAND flash page. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* logical_sector Logical sector number */
|
||||
/* buffer Pointer to buffer to write */
|
||||
/* (the size is number of */
|
||||
/* bytes in a page) */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_block_find Find the mapped block */
|
||||
/* _lx_nand_flash_block_allocate Allocate block */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function writes a logical sector to the NAND flash page. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* logical_sector Logical sector number */
|
||||
/* buffer Pointer to buffer to write */
|
||||
/* (the size is number of */
|
||||
/* bytes in a page) */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_block_find Find the mapped block */
|
||||
/* _lx_nand_flash_block_allocate Allocate block */
|
||||
/* _lx_nand_flash_mapped_block_list_remove */
|
||||
/* Remove mapped block */
|
||||
/* _lx_nand_flash_data_page_copy Copy data pages */
|
||||
/* Remove mapped block */
|
||||
/* _lx_nand_flash_data_page_copy Copy data pages */
|
||||
/* _lx_nand_flash_free_block_list_add Add free block to list */
|
||||
/* _lx_nand_flash_block_mapping_set Set block mapping */
|
||||
/* lx_nand_flash_driver_pages_write Write pages */
|
||||
/* _lx_nand_flash_block_status_set Set block status */
|
||||
/* _lx_nand_flash_driver_block_erase Erase block */
|
||||
/* _lx_nand_flash_block_mapping_set Set block mapping */
|
||||
/* lx_nand_flash_driver_pages_write Write pages */
|
||||
/* _lx_nand_flash_block_status_set Set block status */
|
||||
/* _lx_nand_flash_driver_block_erase Erase block */
|
||||
/* _lx_nand_flash_erase_count_set Set erase count */
|
||||
/* _lx_nand_flash_block_data_move Move block data */
|
||||
/* _lx_nand_flash_mapped_block_list_add Add mapped block to list */
|
||||
/* _lx_nand_flash_system_error Internal system error handler */
|
||||
/* tx_mutex_get Get thread protection */
|
||||
/* tx_mutex_put Release thread protection */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* _lx_nand_flash_system_error Internal system error handler */
|
||||
/* tx_mutex_get Get thread protection */
|
||||
/* tx_mutex_put Release thread protection */
|
||||
/* */
|
||||
/* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_sector_write(LX_NAND_FLASH *nand_flash, ULONG logical_sector, VOID *buffer)
|
||||
@@ -114,7 +109,7 @@ UINT copy_block = LX_FALSE;
|
||||
|
||||
/* See if we can find the logical sector in the current mapping. */
|
||||
status = _lx_nand_flash_block_find(nand_flash, logical_sector, &block, &block_status);
|
||||
|
||||
|
||||
/* Check return status. */
|
||||
if(status != LX_SUCCESS)
|
||||
{
|
||||
@@ -195,7 +190,7 @@ UINT copy_block = LX_FALSE;
|
||||
new_block = block;
|
||||
new_block_status = block_status;
|
||||
}
|
||||
|
||||
|
||||
/* Check if copy block flag is set. */
|
||||
if (copy_block)
|
||||
{
|
||||
@@ -222,7 +217,7 @@ UINT copy_block = LX_FALSE;
|
||||
return(LX_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Check if update mapping flag is set. */
|
||||
if (update_mapping)
|
||||
{
|
||||
@@ -236,7 +231,7 @@ UINT copy_block = LX_FALSE;
|
||||
|
||||
/* Set spare buffer to all 0xFF bytes. */
|
||||
LX_MEMSET(spare_buffer_ptr, 0xFF, nand_flash -> lx_nand_flash_spare_total_length);
|
||||
|
||||
|
||||
/* Check if there is enough spare data for metadata block number. */
|
||||
if (nand_flash -> lx_nand_flash_spare_data2_length >= sizeof(USHORT))
|
||||
{
|
||||
@@ -247,7 +242,7 @@ UINT copy_block = LX_FALSE;
|
||||
|
||||
/* Set page type and sector address. */
|
||||
LX_UTILITY_LONG_SET(&spare_buffer_ptr[nand_flash -> lx_nand_flash_spare_data1_offset], LX_NAND_PAGE_TYPE_USER_DATA | logical_sector);
|
||||
|
||||
|
||||
/* Get page to write. */
|
||||
page = new_block_status & LX_NAND_BLOCK_STATUS_PAGE_NUMBER_MASK;
|
||||
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,46 +35,40 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_sectors_read PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_sectors_read PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Xiuwen Cai, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function reads multiple logical sectors from NAND flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* logical_sector Logical sector number */
|
||||
/* buffer Pointer to buffer to read into*/
|
||||
/* (the size is number of */
|
||||
/* bytes in a page) */
|
||||
/* sector_count Number of sector to read */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_sector_read Read a sector */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
|
||||
/* This function reads multiple logical sectors from NAND flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* logical_sector Logical sector number */
|
||||
/* buffer Pointer to buffer to read into*/
|
||||
/* (the size is number of */
|
||||
/* bytes in a page) */
|
||||
/* sector_count Number of sector to read */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_sector_read Read a sector */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_sectors_read(LX_NAND_FLASH *nand_flash, ULONG logical_sector, VOID *buffer, ULONG sector_count)
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,44 +35,38 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_sectors_release PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_sectors_release PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Xiuwen Cai, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function releases multiple logical sectors from being managed */
|
||||
/* in the NAND flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* logical_sector Logical sector number */
|
||||
/* sector_count Number of sector to release */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_sector_release Release one sector */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
|
||||
/* This function releases multiple logical sectors from being managed */
|
||||
/* in the NAND flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* logical_sector Logical sector number */
|
||||
/* sector_count Number of sector to release */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_sector_release Release one sector */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_sectors_release(LX_NAND_FLASH *nand_flash, ULONG logical_sector, ULONG sector_count)
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,46 +35,40 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_sectors_write PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_sectors_write PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Xiuwen Cai, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function writes multiple logical sectors to the NAND flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* logical_sector Logical sector number */
|
||||
/* buffer Pointer to buffer to write */
|
||||
/* (the size is number of */
|
||||
/* bytes in a page) */
|
||||
/* sector_count Number of sector to write */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_sector_write Write one sector */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
|
||||
/* This function writes multiple logical sectors to the NAND flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* logical_sector Logical sector number */
|
||||
/* buffer Pointer to buffer to write */
|
||||
/* (the size is number of */
|
||||
/* bytes in a page) */
|
||||
/* sector_count Number of sector to write */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nand_flash_sector_write Write one sector */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nand_flash_sectors_write(LX_NAND_FLASH *nand_flash, ULONG logical_sector, VOID *buffer, ULONG sector_count)
|
||||
@@ -89,7 +84,7 @@ UINT i;
|
||||
|
||||
/* Write one sector. */
|
||||
status = _lx_nand_flash_sector_write(nand_flash, logical_sector + i, ((UCHAR*)buffer) + i * nand_flash -> lx_nand_flash_bytes_per_page);
|
||||
|
||||
|
||||
/* Check return status. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash Simulator */
|
||||
/** */
|
||||
@@ -28,13 +29,13 @@
|
||||
|
||||
#define TOTAL_BLOCKS 1024
|
||||
#define PHYSICAL_PAGES_PER_BLOCK 256 /* Min value of 2 */
|
||||
#define BYTES_PER_PHYSICAL_PAGE 512 /* 512 bytes per page */
|
||||
#define WORDS_PER_PHYSICAL_PAGE 512 / 4 /* Words per page */
|
||||
#define BYTES_PER_PHYSICAL_PAGE 512 /* 512 bytes per page */
|
||||
#define WORDS_PER_PHYSICAL_PAGE 512 / 4 /* Words per page */
|
||||
#define SPARE_BYTES_PER_PAGE 16 /* 16 "spare" bytes per page */
|
||||
/* For 2048 byte block spare area: */
|
||||
#define BAD_BLOCK_POSITION 0 /* 0 is the bad block byte postion */
|
||||
#define EXTRA_BYTE_POSITION 0 /* 0 is the extra bytes starting byte postion */
|
||||
#define ECC_BYTE_POSITION 8 /* 8 is the ECC starting byte position */
|
||||
/* For 2048 byte block spare area: */
|
||||
#define BAD_BLOCK_POSITION 0 /* 0 is the bad block byte postion */
|
||||
#define EXTRA_BYTE_POSITION 0 /* 0 is the extra bytes starting byte postion */
|
||||
#define ECC_BYTE_POSITION 8 /* 8 is the ECC starting byte position */
|
||||
#define SPARE_DATA1_OFFSET 4
|
||||
#define SPARE_DATA1_LENGTH 4
|
||||
#define SPARE_DATA2_OFFSET 2
|
||||
@@ -42,29 +43,29 @@
|
||||
|
||||
|
||||
|
||||
/* Definition of the spare area is relative to the block size of the NAND part and perhaps manufactures of the NAND part.
|
||||
/* Definition of the spare area is relative to the block size of the NAND part and perhaps manufactures of the NAND part.
|
||||
Here are some common definitions:
|
||||
|
||||
|
||||
256 Byte Block
|
||||
|
||||
|
||||
Bytes Meaning
|
||||
|
||||
|
||||
0,1,2 ECC bytes
|
||||
3,4,6,7 Extra
|
||||
5 Bad block flag
|
||||
|
||||
|
||||
512 Byte Block
|
||||
|
||||
|
||||
Bytes Meaning
|
||||
|
||||
|
||||
0,1,2,3,6,7 ECC bytes
|
||||
8-15 Extra
|
||||
5 Bad block flag
|
||||
|
||||
|
||||
2048 Byte Block
|
||||
|
||||
|
||||
Bytes Meaning
|
||||
|
||||
|
||||
0 Bad block flag
|
||||
2-39 Extra
|
||||
40-63 ECC bytes
|
||||
@@ -288,7 +289,7 @@ UINT ecc_status = LX_SUCCESS;
|
||||
status = _lx_nand_flash_simulator_extra_bytes_get(block, page + i, spare_buffer + i * SPARE_BYTES_PER_PAGE, SPARE_BYTES_PER_PAGE);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
return (ecc_status);
|
||||
}
|
||||
|
||||
@@ -328,32 +329,32 @@ ULONG *page_ptr = &(nand_memory_area[block].physical_pages[page].memory[0]);
|
||||
in a NAND device. */
|
||||
if ((*source & *flash_address) != *source)
|
||||
return(LX_INVALID_WRITE);
|
||||
|
||||
|
||||
/* Copy word. */
|
||||
*flash_address++ = *source++;
|
||||
}
|
||||
|
||||
/* Loop to compute the ECC over the entire NAND flash page. */
|
||||
bytes_computed = 0;
|
||||
|
||||
|
||||
while (bytes_computed < BYTES_PER_PHYSICAL_PAGE)
|
||||
{
|
||||
|
||||
{
|
||||
|
||||
/* Compute the ECC for this 256 byte piece of the page. */
|
||||
_lx_nand_flash_256byte_ecc_compute((UCHAR *)page_ptr, (UCHAR *)new_ecc_buffer_ptr);
|
||||
|
||||
|
||||
/* Move to the next 256 byte portion of the page. */
|
||||
bytes_computed = bytes_computed + 256;
|
||||
|
||||
|
||||
/* Move the page buffer forward. */
|
||||
page_ptr = page_ptr + 64;
|
||||
|
||||
|
||||
ecc_bytes = ecc_bytes + 3;
|
||||
|
||||
/* Move the ECC buffer forward, note there are 3 bytes of ECC per page. */
|
||||
new_ecc_buffer_ptr = new_ecc_buffer_ptr + 3;
|
||||
}
|
||||
|
||||
|
||||
/* Setup destination pointer in the spare area. */
|
||||
flash_spare_address = (UCHAR *) &(nand_memory_area[block].physical_pages[page].spare[ECC_BYTE_POSITION]);
|
||||
while(ecc_bytes--)
|
||||
@@ -464,7 +465,7 @@ UINT i;
|
||||
words = sizeof(NAND_FLASH_BLOCK)/sizeof(ULONG);
|
||||
while (words--)
|
||||
{
|
||||
|
||||
|
||||
/* Erase word of block. */
|
||||
*pointer++ = (ULONG) 0xFFFFFFFF;
|
||||
}
|
||||
@@ -488,7 +489,7 @@ UINT i, j;
|
||||
for (j = 0; j < PHYSICAL_PAGES_PER_BLOCK;j++)
|
||||
nand_block_diag[i].page_writes[j] = 0;
|
||||
}
|
||||
|
||||
|
||||
/* Setup pointer. */
|
||||
pointer = (ULONG *) &nand_memory_area[0];
|
||||
|
||||
@@ -496,7 +497,7 @@ UINT i, j;
|
||||
words = sizeof(nand_memory_area)/(sizeof(ULONG));
|
||||
while (words--)
|
||||
{
|
||||
|
||||
|
||||
/* Erase word of block. */
|
||||
*pointer++ = (ULONG) 0xFFFFFFFF;
|
||||
}
|
||||
@@ -520,22 +521,22 @@ ULONG words;
|
||||
#endif
|
||||
|
||||
/* Determine if the block is completely erased. */
|
||||
|
||||
|
||||
/* Pickup the pointer to the first word of the block. */
|
||||
word_ptr = (ULONG *) &nand_memory_area[block];
|
||||
|
||||
|
||||
/* Calculate the number of words in a block. */
|
||||
words = sizeof(NAND_FLASH_BLOCK)/sizeof(ULONG);
|
||||
|
||||
|
||||
/* Loop to check if the block is erased. */
|
||||
while (words--)
|
||||
{
|
||||
|
||||
|
||||
/* Is this word erased? */
|
||||
if (*word_ptr++ != 0xFFFFFFFF)
|
||||
return(LX_ERROR);
|
||||
}
|
||||
|
||||
|
||||
/* Return success. */
|
||||
return(LX_SUCCESS);
|
||||
}
|
||||
@@ -555,22 +556,22 @@ ULONG words;
|
||||
#endif
|
||||
|
||||
/* Determine if the block is completely erased. */
|
||||
|
||||
|
||||
/* Pickup the pointer to the first word of the block's page. */
|
||||
word_ptr = (ULONG *) &nand_memory_area[block].physical_pages[page];
|
||||
|
||||
|
||||
/* Calculate the number of words in a block. */
|
||||
words = WORDS_PER_PHYSICAL_PAGE;
|
||||
|
||||
|
||||
/* Loop to check if the page is erased. */
|
||||
while (words--)
|
||||
{
|
||||
|
||||
|
||||
/* Is this word erased? */
|
||||
if (*word_ptr++ != 0xFFFFFFFF)
|
||||
return(LX_ERROR);
|
||||
}
|
||||
|
||||
|
||||
/* Return success. */
|
||||
return(LX_SUCCESS);
|
||||
}
|
||||
@@ -588,7 +589,7 @@ UINT _lx_nand_flash_simulator_block_status_get(ULONG block, UCHAR *bad_block_by
|
||||
|
||||
/* Pickup the bad block byte and return it. */
|
||||
*bad_block_byte = nand_memory_area[block].physical_pages[0].spare[BAD_BLOCK_POSITION];
|
||||
|
||||
|
||||
/* Return success. */
|
||||
return(LX_SUCCESS);
|
||||
}
|
||||
@@ -606,7 +607,7 @@ UINT _lx_nand_flash_simulator_block_status_set(ULONG block, UCHAR bad_block_byt
|
||||
|
||||
/* Set the bad block byte. */
|
||||
nand_memory_area[block].physical_pages[0].spare[BAD_BLOCK_POSITION] = bad_block_byte;
|
||||
|
||||
|
||||
/* Return success. */
|
||||
return(LX_SUCCESS);
|
||||
}
|
||||
@@ -624,14 +625,14 @@ UCHAR *source;
|
||||
#ifdef LX_NAND_ENABLE_CONTROL_BLOCK_FOR_DRIVER_INTERFACE
|
||||
LX_PARAMETER_NOT_USED(nand_flash);
|
||||
#endif
|
||||
|
||||
|
||||
/* Setup source pointer in the spare area. */
|
||||
source = (UCHAR *) &(nand_memory_area[block].physical_pages[page].spare[EXTRA_BYTE_POSITION]);
|
||||
|
||||
|
||||
/* Loop to return the extra bytes requested. */
|
||||
while (size--)
|
||||
{
|
||||
|
||||
|
||||
/* Retrieve an extra byte from the spare area. */
|
||||
*destination++ = *source++;
|
||||
}
|
||||
@@ -652,19 +653,19 @@ UCHAR *destination;
|
||||
#ifdef LX_NAND_ENABLE_CONTROL_BLOCK_FOR_DRIVER_INTERFACE
|
||||
LX_PARAMETER_NOT_USED(nand_flash);
|
||||
#endif
|
||||
|
||||
|
||||
/* Increment the diag info. */
|
||||
nand_block_diag[block].page_writes[page]++;
|
||||
if (nand_block_diag[block].page_writes[page] > nand_block_diag[block].max_page_writes[page])
|
||||
nand_block_diag[block].max_page_writes[page] = nand_block_diag[block].page_writes[page];
|
||||
|
||||
|
||||
/* Setup destination pointer in the spare area. */
|
||||
destination = (UCHAR *) &(nand_memory_area[block].physical_pages[page].spare[EXTRA_BYTE_POSITION]);
|
||||
|
||||
|
||||
/* Loop to set the extra bytes. */
|
||||
while (size--)
|
||||
{
|
||||
|
||||
|
||||
/* Set an extra byte in the spare area. */
|
||||
*destination++ = *source++;
|
||||
}
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NAND Flash */
|
||||
/** */
|
||||
@@ -34,51 +35,38 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_system_error PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nand_flash_system_error PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function handles system errors in the NAND flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* error_code System error code */
|
||||
/* block Block where error occurred */
|
||||
/* page Page where error occurred */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* (lx_nand_flash_driver_system_error) Driver system error handler */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* 03-08-2023 Xiuwen Cai Modified comment(s), */
|
||||
/* added new driver interface, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* This function handles system errors in the NAND flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nand_flash NAND flash instance */
|
||||
/* error_code System error code */
|
||||
/* block Block where error occurred */
|
||||
/* page Page where error occurred */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* (lx_nand_flash_driver_system_error) Driver system error handler */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
VOID _lx_nand_flash_system_error(LX_NAND_FLASH *nand_flash, UINT error_code, ULONG block, ULONG page)
|
||||
@@ -86,26 +74,26 @@ VOID _lx_nand_flash_system_error(LX_NAND_FLASH *nand_flash, UINT error_code, UL
|
||||
|
||||
/* Increment the system error counter. */
|
||||
nand_flash -> lx_nand_flash_diagnostic_system_errors++;
|
||||
|
||||
|
||||
/* Save the most recent system error code. */
|
||||
nand_flash -> lx_nand_flash_diagnostic_system_error = error_code;
|
||||
|
||||
|
||||
/* Determine if the system error is a NAND page corrected error. */
|
||||
if (error_code == LX_NAND_ERROR_CORRECTED)
|
||||
{
|
||||
|
||||
|
||||
/* Yes, increment error correction information. */
|
||||
nand_flash -> lx_nand_flash_page_corrections++;
|
||||
|
||||
|
||||
/* Remember the last block/page of corrected error. */
|
||||
nand_flash -> lx_nand_flash_last_block_correction = block;
|
||||
nand_flash -> lx_nand_flash_last_page_correction = page;
|
||||
}
|
||||
|
||||
|
||||
/* Determine if the driver has setup a system error handler. */
|
||||
if (nand_flash -> lx_nand_flash_driver_system_error)
|
||||
{
|
||||
|
||||
|
||||
/* Yes, call the driver's system error handler. */
|
||||
#ifdef LX_NAND_ENABLE_CONTROL_BLOCK_FOR_DRIVER_INTERFACE
|
||||
(nand_flash -> lx_nand_flash_driver_system_error)(nand_flash, error_code, block, page);
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NOR Flash */
|
||||
/** */
|
||||
@@ -34,59 +35,44 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_block_reclaim PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_block_reclaim PORTABLE C */
|
||||
/* 6.3.0 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function reclaims one block from the NOR flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nor_flash_driver_block_erase Driver erase block */
|
||||
/* _lx_nor_flash_driver_write Driver flash sector write */
|
||||
/* _lx_nor_flash_driver_read Driver flash sector read */
|
||||
/* _lx_nor_flash_next_block_to_erase_find */
|
||||
/* Find next block to erase */
|
||||
/* _lx_nor_flash_physical_sector_allocate */
|
||||
/* Allocate new logical sector */
|
||||
/* _lx_nor_flash_sector_mapping_cache_invalidate */
|
||||
/* Invalidate cache entry */
|
||||
/* _lx_nor_flash_system_error Internal system error handler */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* 10-31-2023 Xiuwen Cai Modified comment(s), */
|
||||
/* added count for minimum */
|
||||
/* erased blocks, added */
|
||||
/* obsolete count cache, */
|
||||
/* resulting in version 6.3.0 */
|
||||
/* This function reclaims one block from the NOR flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nor_flash_driver_block_erase Driver erase block */
|
||||
/* _lx_nor_flash_driver_write Driver flash sector write */
|
||||
/* _lx_nor_flash_driver_read Driver flash sector read */
|
||||
/* _lx_nor_flash_next_block_to_erase_find */
|
||||
/* Find next block to erase */
|
||||
/* _lx_nor_flash_physical_sector_allocate */
|
||||
/* Allocate new logical sector */
|
||||
/* _lx_nor_flash_sector_mapping_cache_invalidate */
|
||||
/* Invalidate cache entry */
|
||||
/* _lx_nor_flash_system_error Internal system error handler */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nor_flash_block_reclaim(LX_NOR_FLASH *nor_flash)
|
||||
@@ -116,10 +102,10 @@ UINT status;
|
||||
/* Determine if the search pointer is set for this block. */
|
||||
if (nor_flash -> lx_nor_flash_free_block_search == erase_block)
|
||||
{
|
||||
|
||||
|
||||
/* Ensure the search block is not the block we are trying to free. */
|
||||
nor_flash -> lx_nor_flash_free_block_search = erase_block + 1;
|
||||
|
||||
|
||||
/* Check for wrap condition. */
|
||||
if (nor_flash -> lx_nor_flash_free_block_search >= nor_flash -> lx_nor_flash_total_blocks)
|
||||
nor_flash -> lx_nor_flash_free_block_search = 0;
|
||||
@@ -132,31 +118,31 @@ UINT status;
|
||||
if (obsolete_sectors == nor_flash -> lx_nor_flash_physical_sectors_per_block)
|
||||
{
|
||||
|
||||
/* Write the erased started indication. */
|
||||
/* Write the erased started indication. */
|
||||
erase_started_value = LX_BLOCK_ERASE_STARTED;
|
||||
status = _lx_nor_flash_driver_write(nor_flash, block_word_ptr, &erase_started_value, 1);
|
||||
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
/* Return the error. */
|
||||
return(status);
|
||||
}
|
||||
|
||||
|
||||
/* Erase the entire block. */
|
||||
status = _lx_nor_flash_driver_block_erase(nor_flash, erase_block, erase_count+1);
|
||||
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
|
||||
/* Return the error. */
|
||||
return(status);
|
||||
}
|
||||
@@ -164,47 +150,47 @@ UINT status;
|
||||
/* Determine if the erase count is at the minimum. */
|
||||
if (erase_count == nor_flash -> lx_nor_flash_minimum_erase_count)
|
||||
{
|
||||
|
||||
|
||||
/* Yes, decrement the minimum erased block count. */
|
||||
nor_flash -> lx_nor_flash_minimum_erased_blocks--;
|
||||
}
|
||||
|
||||
/* Increment the erase count. */
|
||||
erase_count++;
|
||||
erase_count++;
|
||||
|
||||
/* Determine if the new erase count exceeds the maximum. */
|
||||
if (erase_count > ((ULONG) LX_BLOCK_ERASE_COUNT_MAX))
|
||||
{
|
||||
|
||||
|
||||
/* Yes, erase count is in overflow. Stay at the maximum count. */
|
||||
erase_count = ((ULONG) LX_BLOCK_ERASE_COUNT_MAX);
|
||||
}
|
||||
|
||||
|
||||
/* Determine if we need to update the maximum erase count. */
|
||||
if (erase_count > nor_flash -> lx_nor_flash_maximum_erase_count)
|
||||
{
|
||||
|
||||
|
||||
/* Yes, a new maximum is present. */
|
||||
nor_flash -> lx_nor_flash_maximum_erase_count = erase_count;
|
||||
}
|
||||
|
||||
|
||||
/* Setup the free bit map that corresponds to the free physical sectors in this
|
||||
block. Note that we only need to setup the portion of the free bit map that doesn't
|
||||
have sectors associated with it. */
|
||||
status = _lx_nor_flash_driver_write(nor_flash, block_word_ptr+(nor_flash -> lx_nor_flash_block_free_bit_map_offset + (nor_flash -> lx_nor_flash_block_bit_map_words - 1)),
|
||||
block. Note that we only need to setup the portion of the free bit map that doesn't
|
||||
have sectors associated with it. */
|
||||
status = _lx_nor_flash_driver_write(nor_flash, block_word_ptr+(nor_flash -> lx_nor_flash_block_free_bit_map_offset + (nor_flash -> lx_nor_flash_block_bit_map_words - 1)),
|
||||
&(nor_flash -> lx_nor_flash_block_bit_map_mask), 1);
|
||||
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
/* Return the error. */
|
||||
return(status);
|
||||
}
|
||||
|
||||
|
||||
/* Write the initial erase count for the block with upper bit set. */
|
||||
temp_erase_count = (erase_count | LX_BLOCK_ERASED);
|
||||
status = _lx_nor_flash_driver_write(nor_flash, block_word_ptr, &temp_erase_count, 1);
|
||||
@@ -212,7 +198,7 @@ UINT status;
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
@@ -226,14 +212,14 @@ UINT status;
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
/* Return the error. */
|
||||
return(status);
|
||||
}
|
||||
|
||||
|
||||
/* Update parameters of this flash. */
|
||||
nor_flash -> lx_nor_flash_free_physical_sectors = nor_flash -> lx_nor_flash_free_physical_sectors + obsolete_sectors;
|
||||
nor_flash -> lx_nor_flash_obsolete_physical_sectors = nor_flash -> lx_nor_flash_obsolete_physical_sectors - obsolete_sectors;
|
||||
@@ -248,16 +234,16 @@ UINT status;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
/* Calculate the number of free sectors in this block. */
|
||||
free_sectors = nor_flash -> lx_nor_flash_physical_sectors_per_block - (obsolete_sectors + mapped_sectors);
|
||||
|
||||
|
||||
/* Determine if there are enough free sectors outside of this block to reclaim this block. */
|
||||
if (mapped_sectors <= (nor_flash -> lx_nor_flash_free_physical_sectors - free_sectors))
|
||||
{
|
||||
|
||||
|
||||
/* Setup a pointer to the mapped list. */
|
||||
list_word_ptr = block_word_ptr + nor_flash -> lx_nor_flash_block_physical_sector_mapping_offset;
|
||||
|
||||
@@ -267,7 +253,7 @@ UINT status;
|
||||
|
||||
/* Pickup the mapped sector list entry. */
|
||||
#ifdef LX_DIRECT_READ
|
||||
|
||||
|
||||
/* Read the word directly. */
|
||||
list_word = *(list_word_ptr);
|
||||
#else
|
||||
@@ -276,7 +262,7 @@ UINT status;
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
@@ -288,33 +274,33 @@ UINT status;
|
||||
/* Determine if the entry hasn't been used. */
|
||||
if (list_word == LX_NOR_PHYSICAL_SECTOR_FREE)
|
||||
{
|
||||
|
||||
|
||||
/* Since allocations are done sequentially in the block, we know nothing
|
||||
else exists after this point. */
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* Is this entry mapped? */
|
||||
if (list_word & LX_NOR_PHYSICAL_SECTOR_VALID)
|
||||
{
|
||||
|
||||
|
||||
/* Pickup the logical sector associated with this mapped physical sector. */
|
||||
logical_sector = list_word & LX_NOR_LOGICAL_SECTOR_MASK;
|
||||
|
||||
/* Invalidate the old sector mapping cache entry. */
|
||||
_lx_nor_flash_sector_mapping_cache_invalidate(nor_flash, logical_sector);
|
||||
|
||||
|
||||
/* Allocate a new physical sector for this write. */
|
||||
_lx_nor_flash_physical_sector_allocate(nor_flash, logical_sector, &new_mapping_address, &new_sector_address);
|
||||
|
||||
|
||||
/* Check to see if the new sector is also in the erase block. */
|
||||
if ((new_sector_address >= block_word_ptr) && (new_sector_address < (block_word_ptr + nor_flash -> lx_nor_flash_words_per_block)))
|
||||
{
|
||||
|
||||
|
||||
/* Yes, the new sector was found in the block to be erased. Simply move the search pointer
|
||||
to the block after the erase block and search for another sector from there. */
|
||||
nor_flash -> lx_nor_flash_free_block_search = erase_block + 1;
|
||||
|
||||
|
||||
/* Check for wrap condition. */
|
||||
if (nor_flash -> lx_nor_flash_free_block_search >= nor_flash -> lx_nor_flash_total_blocks)
|
||||
nor_flash -> lx_nor_flash_free_block_search = 0;
|
||||
@@ -328,7 +314,7 @@ UINT status;
|
||||
if ((new_sector_address >= block_word_ptr) && (new_sector_address < (block_word_ptr + LX_NOR_SECTOR_SIZE)))
|
||||
{
|
||||
|
||||
/* System error, a new sector is not available outside of the erase block.
|
||||
/* System error, a new sector is not available outside of the erase block.
|
||||
Clear the new sector so we fall through to the error handling. */
|
||||
new_mapping_address = LX_NULL;
|
||||
}
|
||||
@@ -337,9 +323,9 @@ UINT status;
|
||||
/* Determine if the new sector allocation was successful. */
|
||||
if (new_mapping_address)
|
||||
{
|
||||
|
||||
|
||||
/* Yes, we were able to allocate a new physical sector. */
|
||||
|
||||
|
||||
#ifdef LX_DIRECT_READ
|
||||
/* First, write the sector data to the new physical sector. */
|
||||
status = _lx_nor_flash_driver_write(nor_flash, new_sector_address, (block_word_ptr + nor_flash -> lx_nor_flash_block_physical_sector_offset) +
|
||||
@@ -348,7 +334,7 @@ UINT status;
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
@@ -366,7 +352,7 @@ UINT status;
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
@@ -380,7 +366,7 @@ UINT status;
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
@@ -390,34 +376,34 @@ UINT status;
|
||||
#endif
|
||||
|
||||
/* Now deprecate the old sector mapping. */
|
||||
|
||||
|
||||
/* Clear bit 30, which indicates this sector is superceded. */
|
||||
list_word = list_word & ~((ULONG) LX_NOR_PHYSICAL_SECTOR_SUPERCEDED);
|
||||
|
||||
|
||||
/* Write the value back to the flash to clear bit 30. */
|
||||
status = _lx_nor_flash_driver_write(nor_flash, list_word_ptr, &list_word, 1);
|
||||
|
||||
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
/* Return the error. */
|
||||
return(status);
|
||||
}
|
||||
|
||||
|
||||
/* Now build the new mapping entry - with the not valid bit set initially. */
|
||||
new_mapping_entry = ((ULONG) LX_NOR_PHYSICAL_SECTOR_VALID) | ((ULONG) LX_NOR_PHYSICAL_SECTOR_SUPERCEDED) | (ULONG) LX_NOR_PHYSICAL_SECTOR_MAPPING_NOT_VALID | logical_sector;
|
||||
|
||||
|
||||
/* Write out the new mapping entry. */
|
||||
status = _lx_nor_flash_driver_write(nor_flash, new_mapping_address, &new_mapping_entry, 1);
|
||||
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
@@ -425,17 +411,17 @@ UINT status;
|
||||
return(status);
|
||||
}
|
||||
|
||||
/* Now clear the not valid bit to make this sector mapping valid. This is done because the writing of the extra bytes itself can
|
||||
/* Now clear the not valid bit to make this sector mapping valid. This is done because the writing of the extra bytes itself can
|
||||
be interrupted and we need to make sure this can be detected when the flash is opened again. */
|
||||
new_mapping_entry = new_mapping_entry & ~((ULONG) LX_NOR_PHYSICAL_SECTOR_MAPPING_NOT_VALID);
|
||||
|
||||
|
||||
/* Clear the not valid bit. */
|
||||
status = _lx_nor_flash_driver_write(nor_flash, new_mapping_address, &new_mapping_entry, 1);
|
||||
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
@@ -445,14 +431,14 @@ UINT status;
|
||||
|
||||
/* Now clear bit 31, which indicates this sector is now obsoleted. */
|
||||
list_word = list_word & ~((ULONG) LX_NOR_PHYSICAL_SECTOR_VALID);
|
||||
|
||||
|
||||
/* Write the value back to the flash to clear bit 31. */
|
||||
status = _lx_nor_flash_driver_write(nor_flash, list_word_ptr, &list_word, 1);
|
||||
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
@@ -469,10 +455,10 @@ UINT status;
|
||||
/* Return the error. */
|
||||
return(status);
|
||||
}
|
||||
|
||||
|
||||
/* Decrement the number of mapped sectors. */
|
||||
mapped_sectors--;
|
||||
|
||||
|
||||
/* Determine if we are done. */
|
||||
if (mapped_sectors == 0)
|
||||
break;
|
||||
@@ -482,50 +468,50 @@ UINT status;
|
||||
list_word_ptr++;
|
||||
}
|
||||
|
||||
/* Write the erased started indication. */
|
||||
/* Write the erased started indication. */
|
||||
erase_started_value = LX_BLOCK_ERASE_STARTED;
|
||||
status = _lx_nor_flash_driver_write(nor_flash, block_word_ptr, &erase_started_value, 1);
|
||||
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
/* Return the error. */
|
||||
return(status);
|
||||
}
|
||||
|
||||
|
||||
/* Erase the entire block. */
|
||||
status = _lx_nor_flash_driver_block_erase(nor_flash, erase_block, erase_count+1);
|
||||
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
/* Return the error. */
|
||||
return(status);
|
||||
}
|
||||
|
||||
|
||||
/* Determine if the erase count is at the minimum. */
|
||||
if (erase_count == nor_flash -> lx_nor_flash_minimum_erase_count)
|
||||
{
|
||||
|
||||
|
||||
/* Yes, decrement the minimum erased block count. */
|
||||
nor_flash -> lx_nor_flash_minimum_erased_blocks--;
|
||||
}
|
||||
|
||||
/* Increment the erase count. */
|
||||
erase_count++;
|
||||
erase_count++;
|
||||
|
||||
/* Determine if the new erase count exceeds the maximum. */
|
||||
if (erase_count > ((ULONG) LX_BLOCK_ERASE_COUNT_MAX))
|
||||
{
|
||||
|
||||
|
||||
/* Yes, erase count is in overflow. Stay at the maximum count. */
|
||||
erase_count = ((ULONG) LX_BLOCK_ERASE_COUNT_MAX);
|
||||
}
|
||||
@@ -533,21 +519,21 @@ UINT status;
|
||||
/* Determine if we need to update the maximum erase count. */
|
||||
if (erase_count > nor_flash -> lx_nor_flash_maximum_erase_count)
|
||||
{
|
||||
|
||||
|
||||
/* Yes, a new maximum is present. */
|
||||
nor_flash -> lx_nor_flash_maximum_erase_count = erase_count;
|
||||
}
|
||||
|
||||
|
||||
/* Setup the free bit map that corresponds to the free physical sectors in this
|
||||
block. Note that we only need to setup the portion of the free bit map that doesn't
|
||||
have sectors associated with it. */
|
||||
status = _lx_nor_flash_driver_write(nor_flash, block_word_ptr+(nor_flash -> lx_nor_flash_block_free_bit_map_offset + (nor_flash -> lx_nor_flash_block_bit_map_words - 1)) ,
|
||||
block. Note that we only need to setup the portion of the free bit map that doesn't
|
||||
have sectors associated with it. */
|
||||
status = _lx_nor_flash_driver_write(nor_flash, block_word_ptr+(nor_flash -> lx_nor_flash_block_free_bit_map_offset + (nor_flash -> lx_nor_flash_block_bit_map_words - 1)) ,
|
||||
&(nor_flash -> lx_nor_flash_block_bit_map_mask), 1);
|
||||
|
||||
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
@@ -562,7 +548,7 @@ UINT status;
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
@@ -576,7 +562,7 @@ UINT status;
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NOR Flash */
|
||||
/** */
|
||||
@@ -34,45 +35,35 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_close PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_close PORTABLE C */
|
||||
/* 6.1.7 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function closes a NOR flash instance. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* tx_mutex_delete Delete thread-safe mutex */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* This function closes a NOR flash instance. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* tx_mutex_delete Delete thread-safe mutex */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nor_flash_close(LX_NOR_FLASH *nor_flash)
|
||||
@@ -105,9 +96,9 @@ LX_INTERRUPT_SAVE_AREA
|
||||
/* See if we have to update the opened list head pointer. */
|
||||
if (_lx_nor_flash_opened_ptr == nor_flash)
|
||||
{
|
||||
|
||||
|
||||
/* Yes, move the head pointer to the next opened NOR flash. */
|
||||
_lx_nor_flash_opened_ptr = nor_flash -> lx_nor_flash_open_next;
|
||||
_lx_nor_flash_opened_ptr = nor_flash -> lx_nor_flash_open_next;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +107,7 @@ LX_INTERRUPT_SAVE_AREA
|
||||
|
||||
/* Finally, indicate that this NOR flash is closed. */
|
||||
nor_flash -> lx_nor_flash_state = LX_NOR_FLASH_CLOSED;
|
||||
|
||||
|
||||
/* Restore interrupt posture. */
|
||||
LX_RESTORE
|
||||
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NOR Flash */
|
||||
/** */
|
||||
@@ -34,53 +35,43 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_defragment PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_defragment PORTABLE C */
|
||||
/* 6.1.7 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function defragments the NOR flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nor_flash_block_reclaim Reclaim a NOR flash block */
|
||||
/* tx_mutex_get Get thread protection */
|
||||
/* tx_mutex_put Release thread protection */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* This function defragments the NOR flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nor_flash_block_reclaim Reclaim a NOR flash block */
|
||||
/* tx_mutex_get Get thread protection */
|
||||
/* tx_mutex_put Release thread protection */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nor_flash_defragment(LX_NOR_FLASH *nor_flash)
|
||||
{
|
||||
|
||||
|
||||
ULONG i;
|
||||
|
||||
|
||||
@@ -93,11 +84,11 @@ ULONG i;
|
||||
/* Loop for max number of blocks, while there are obsolete count. */
|
||||
for (i = 0; i < nor_flash -> lx_nor_flash_total_blocks; i++)
|
||||
{
|
||||
|
||||
|
||||
/* Determine if there is any more defragment work. */
|
||||
if (nor_flash -> lx_nor_flash_obsolete_physical_sectors == 0)
|
||||
break;
|
||||
|
||||
break;
|
||||
|
||||
/* Call the block reclaim function to defragment. */
|
||||
_lx_nor_flash_block_reclaim(nor_flash);
|
||||
}
|
||||
@@ -108,7 +99,7 @@ ULONG i;
|
||||
tx_mutex_put(&nor_flash -> lx_nor_flash_mutex);
|
||||
#endif
|
||||
|
||||
/* Return successful completion. */
|
||||
/* Return successful completion. */
|
||||
return(LX_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NOR Flash */
|
||||
/** */
|
||||
@@ -34,50 +35,37 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_driver_block_erase PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_driver_block_erase PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function performs a NOR flash block erase. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* block Block number to erase */
|
||||
/* erase_count Erase count for this block */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* (lx_nor_flash_driver_block_erase) Actual driver block erase */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* 03-08-2023 Xiuwen Cai Modified comment(s), */
|
||||
/* added new driver interface, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* This function performs a NOR flash block erase. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* block Block number to erase */
|
||||
/* erase_count Erase count for this block */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* (lx_nor_flash_driver_block_erase) Actual driver block erase */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nor_flash_driver_block_erase(LX_NOR_FLASH *nor_flash, ULONG block, ULONG erase_count)
|
||||
@@ -97,21 +85,21 @@ ULONG *cache_entry_end;
|
||||
/* 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;
|
||||
|
||||
|
||||
/* 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++)
|
||||
{
|
||||
|
||||
|
||||
/* Search through the cache to see if this cache entry needs to be invalidated. */
|
||||
|
||||
|
||||
/* 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))
|
||||
{
|
||||
|
||||
|
||||
/* 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;
|
||||
@@ -127,7 +115,7 @@ ULONG *cache_entry_end;
|
||||
#endif
|
||||
|
||||
/* Return completion status. */
|
||||
return(status);
|
||||
return(status);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NOR Flash */
|
||||
/** */
|
||||
@@ -34,51 +35,38 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_extended_cache_read PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_extended_cache_read PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function performs a read of the NOR flash memory. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* flash_address Address of NOR flash to read */
|
||||
/* destination Destination for the read */
|
||||
/* words Number of words to read */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* (lx_nor_flash_driver_read) Actual driver read */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* 03-08-2023 Xiuwen Cai Modified comment(s), */
|
||||
/* added new driver interface, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* This function performs a read of the NOR flash memory. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* flash_address Address of NOR flash to read */
|
||||
/* destination Destination for the read */
|
||||
/* words Number of words to read */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* (lx_nor_flash_driver_read) Actual driver read */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nor_flash_driver_read(LX_NOR_FLASH *nor_flash, ULONG *flash_address, ULONG *destination, ULONG words)
|
||||
@@ -98,57 +86,57 @@ UINT least_used_cache_entry;
|
||||
{
|
||||
|
||||
/* One word request, which implies that it is a NOR flash metadata read. */
|
||||
|
||||
|
||||
|
||||
|
||||
/* Initialize the least used cache entry. */
|
||||
least_used_cache_entry = 0;
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
{
|
||||
|
||||
/* 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++)
|
||||
{
|
||||
|
||||
|
||||
/* Search through the cache to find the entry. */
|
||||
|
||||
|
||||
/* 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) && (flash_address >= cache_entry_start) && (flash_address < cache_entry_end))
|
||||
{
|
||||
|
||||
|
||||
/* Yes, we found the entry. */
|
||||
|
||||
|
||||
/* Increment the accessed count. */
|
||||
nor_flash -> lx_nor_flash_extended_cache[i].lx_nor_flash_extended_cache_entry_access_count++;
|
||||
|
||||
|
||||
/* Calculate the offset into the cache entry. */
|
||||
cache_offset = (ULONG)(flash_address - cache_entry_start);
|
||||
|
||||
|
||||
/* Copy the word from the cache. */
|
||||
*destination = *(nor_flash -> lx_nor_flash_extended_cache[i].lx_nor_flash_extended_cache_entry_sector_memory + cache_offset);
|
||||
|
||||
|
||||
/* Increment the number of cache hits. */
|
||||
nor_flash -> lx_nor_flash_extended_cache_hits++;
|
||||
|
||||
|
||||
/* Return success. */
|
||||
return(LX_SUCCESS);
|
||||
return(LX_SUCCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
/* Determine if we have a new least used sector. */
|
||||
if (i != least_used_cache_entry)
|
||||
{
|
||||
|
||||
|
||||
/* Determine if this entry has a smaller accessed count. */
|
||||
if (nor_flash -> lx_nor_flash_extended_cache[i].lx_nor_flash_extended_cache_entry_access_count <
|
||||
nor_flash -> lx_nor_flash_extended_cache[least_used_cache_entry].lx_nor_flash_extended_cache_entry_access_count)
|
||||
{
|
||||
|
||||
|
||||
/* New least used entry. */
|
||||
least_used_cache_entry = i;
|
||||
}
|
||||
@@ -160,44 +148,44 @@ UINT least_used_cache_entry;
|
||||
cache_offset = (ULONG)(flash_address - nor_flash -> lx_nor_flash_base_address);
|
||||
cache_offset = cache_offset & ~((ULONG) (LX_NOR_SECTOR_SIZE-1));
|
||||
cache_entry_start = nor_flash -> lx_nor_flash_base_address + cache_offset;
|
||||
|
||||
|
||||
/* Call the actual driver read function. */
|
||||
#ifdef LX_NOR_ENABLE_CONTROL_BLOCK_FOR_DRIVER_INTERFACE
|
||||
status = (nor_flash -> lx_nor_flash_driver_read)(nor_flash, cache_entry_start,
|
||||
nor_flash -> lx_nor_flash_extended_cache[least_used_cache_entry].lx_nor_flash_extended_cache_entry_sector_memory,
|
||||
status = (nor_flash -> lx_nor_flash_driver_read)(nor_flash, cache_entry_start,
|
||||
nor_flash -> lx_nor_flash_extended_cache[least_used_cache_entry].lx_nor_flash_extended_cache_entry_sector_memory,
|
||||
LX_NOR_SECTOR_SIZE);
|
||||
#else
|
||||
status = (nor_flash -> lx_nor_flash_driver_read)(cache_entry_start,
|
||||
nor_flash -> lx_nor_flash_extended_cache[least_used_cache_entry].lx_nor_flash_extended_cache_entry_sector_memory,
|
||||
status = (nor_flash -> lx_nor_flash_driver_read)(cache_entry_start,
|
||||
nor_flash -> lx_nor_flash_extended_cache[least_used_cache_entry].lx_nor_flash_extended_cache_entry_sector_memory,
|
||||
LX_NOR_SECTOR_SIZE);
|
||||
#endif
|
||||
|
||||
/* Determine if there was an error. */
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
/* Return the error to the caller. */
|
||||
return(status);
|
||||
}
|
||||
|
||||
|
||||
/* Setup the cache entry. */
|
||||
nor_flash -> lx_nor_flash_extended_cache[least_used_cache_entry].lx_nor_flash_extended_cache_entry_sector_address = cache_entry_start;
|
||||
nor_flash -> lx_nor_flash_extended_cache[least_used_cache_entry].lx_nor_flash_extended_cache_entry_access_count = 0;
|
||||
|
||||
|
||||
/* Increment the number of cache misses. */
|
||||
nor_flash -> lx_nor_flash_extended_cache_misses++;
|
||||
|
||||
|
||||
/* Decrement the number of cache hits, so that the increment that will happen next will be cancelled out. */
|
||||
nor_flash -> lx_nor_flash_extended_cache_hits--;
|
||||
|
||||
|
||||
} while (status == LX_SUCCESS);
|
||||
|
||||
|
||||
/* Return success. */
|
||||
return(LX_SUCCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
/* Call the actual driver read function. */
|
||||
#ifdef LX_NOR_ENABLE_CONTROL_BLOCK_FOR_DRIVER_INTERFACE
|
||||
status = (nor_flash -> lx_nor_flash_driver_read)(nor_flash, flash_address, destination, words);
|
||||
@@ -206,7 +194,7 @@ UINT least_used_cache_entry;
|
||||
#endif
|
||||
|
||||
/* Return completion status. */
|
||||
return(status);
|
||||
return(status);
|
||||
}
|
||||
#else
|
||||
UINT status;
|
||||
@@ -220,7 +208,7 @@ UINT status;
|
||||
#endif
|
||||
|
||||
/* Return completion status. */
|
||||
return(status);
|
||||
return(status);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NOR Flash */
|
||||
/** */
|
||||
@@ -34,51 +35,38 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_driver_write PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_driver_write PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function performs a write of the NOR flash memory. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* flash_address Address of NOR flash to write */
|
||||
/* source Source for the write */
|
||||
/* words Number of words to write */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* (lx_nor_flash_driver_write) Actual driver write */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* 03-08-2023 Xiuwen Cai Modified comment(s), */
|
||||
/* added new driver interface, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* This function performs a write of the NOR flash memory. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* flash_address Address of NOR flash to write */
|
||||
/* source Source for the write */
|
||||
/* words Number of words to write */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* (lx_nor_flash_driver_write) Actual driver write */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nor_flash_driver_write(LX_NOR_FLASH *nor_flash, ULONG *flash_address, ULONG *source, ULONG words)
|
||||
@@ -102,31 +90,31 @@ ULONG cache_offset;
|
||||
/* 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++)
|
||||
{
|
||||
|
||||
|
||||
/* Search through the cache to see if there is a cache entry. */
|
||||
|
||||
|
||||
/* 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) && (flash_address >= cache_entry_start) && (flash_address < cache_entry_end))
|
||||
{
|
||||
|
||||
|
||||
/* Yes, we found the entry. */
|
||||
|
||||
|
||||
/* Calculate the offset into the cache entry. */
|
||||
cache_offset = (ULONG)(flash_address - cache_entry_start);
|
||||
|
||||
|
||||
/* Copy the word into the cache. */
|
||||
*(nor_flash -> lx_nor_flash_extended_cache[i].lx_nor_flash_extended_cache_entry_sector_memory + cache_offset) = *source;
|
||||
|
||||
|
||||
/* Get out of the loop. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* In any case, call the actual driver write function. */
|
||||
#ifdef LX_NOR_ENABLE_CONTROL_BLOCK_FOR_DRIVER_INTERFACE
|
||||
status = (nor_flash -> lx_nor_flash_driver_write)(nor_flash, flash_address, source, words);
|
||||
@@ -135,8 +123,8 @@ ULONG cache_offset;
|
||||
#endif
|
||||
|
||||
/* Return completion status. */
|
||||
return(status);
|
||||
|
||||
return(status);
|
||||
|
||||
#else
|
||||
UINT status;
|
||||
|
||||
@@ -147,9 +135,9 @@ UINT status;
|
||||
#else
|
||||
status = (nor_flash -> lx_nor_flash_driver_write)(flash_address, source, words);
|
||||
#endif
|
||||
|
||||
|
||||
/* Return completion status. */
|
||||
return(status);
|
||||
return(status);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NOR Flash */
|
||||
/** */
|
||||
@@ -34,59 +35,37 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_extended_cache_enable PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_extended_cache_enable PORTABLE C */
|
||||
/* 6.3.0 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function enables or disables the extended cache. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* memory Address of RAM for cache */
|
||||
/* size Size of the RAM for cache */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 12-31-2020 William E. Lamie Modified comment(s), */
|
||||
/* fixed compiler warnings, */
|
||||
/* resulting in version 6.1.3 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), and */
|
||||
/* updated product constants */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* 10-15-2021 Bhupendra Naphade Modified comment(s), and */
|
||||
/* added check for out of */
|
||||
/* bound memory access, */
|
||||
/* resulting in version 6.1.9 */
|
||||
/* 10-31-2023 Xiuwen Cai Modified comment(s), */
|
||||
/* added mapping bitmap cache, */
|
||||
/* added obsolete count cache, */
|
||||
/* resulting in version 6.3.0 */
|
||||
/* This function enables or disables the extended cache. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* memory Address of RAM for cache */
|
||||
/* size Size of the RAM for cache */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nor_flash_extended_cache_enable(LX_NOR_FLASH *nor_flash, VOID *memory, ULONG size)
|
||||
@@ -117,7 +96,7 @@ ULONG block_word;
|
||||
/* Determine if memory was specified but with an invalid size (less than one NOR sector). */
|
||||
if ((memory) && (size < LX_NOR_SECTOR_SIZE))
|
||||
{
|
||||
|
||||
|
||||
/* Error in memory size supplied. */
|
||||
return(LX_ERROR);
|
||||
}
|
||||
@@ -146,7 +125,7 @@ ULONG block_word;
|
||||
|
||||
/* Get the mapping bitmap cache size. */
|
||||
mapping_bitmap_words = (nor_flash -> lx_nor_flash_total_physical_sectors + 31) / 32;
|
||||
|
||||
|
||||
/* Check if the mapping bitmap cache fits in the suppiled cache memory. */
|
||||
if (cache_size < mapping_bitmap_words)
|
||||
{
|
||||
@@ -154,13 +133,13 @@ ULONG block_word;
|
||||
/* Update the cache size. */
|
||||
mapping_bitmap_words = cache_size;
|
||||
}
|
||||
|
||||
|
||||
/* Setup the mapping bitmap cache. */
|
||||
nor_flash -> lx_nor_flash_extended_cache_mapping_bitmap = cache_memory;
|
||||
|
||||
/* Setup the mapping bitmap cache size. */
|
||||
nor_flash -> lx_nor_flash_extended_cache_mapping_bitmap_max_logical_sector = mapping_bitmap_words * 32;
|
||||
|
||||
|
||||
/* Clear the mapping bitmap cache. */
|
||||
for (i = 0; i < mapping_bitmap_words; i++)
|
||||
{
|
||||
@@ -176,12 +155,12 @@ ULONG block_word;
|
||||
/* Update the cache memory pointer. */
|
||||
cache_memory = cache_memory + mapping_bitmap_words;
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE)
|
||||
|
||||
/* Get the obsolete count cache size. */
|
||||
obsolete_count_words = nor_flash -> lx_nor_flash_total_blocks * sizeof(LX_NOR_OBSOLETE_COUNT_CACHE_TYPE) / 4;
|
||||
|
||||
|
||||
/* Check if the obsolete count cache fits in the suppiled cache memory. */
|
||||
if (cache_size < obsolete_count_words)
|
||||
{
|
||||
@@ -189,7 +168,7 @@ ULONG block_word;
|
||||
/* Update the cache size. */
|
||||
obsolete_count_words = cache_size;
|
||||
}
|
||||
|
||||
|
||||
/* Setup the obsolete count cache. */
|
||||
nor_flash -> lx_nor_flash_extended_cache_obsolete_count = (LX_NOR_OBSOLETE_COUNT_CACHE_TYPE*)cache_memory;
|
||||
|
||||
@@ -218,10 +197,10 @@ ULONG block_word;
|
||||
/* Now walk the list of logical-physical sector mapping. */
|
||||
for (j = 0; j < nor_flash ->lx_nor_flash_physical_sectors_per_block; j++)
|
||||
{
|
||||
|
||||
|
||||
/* Read this word of the sector mapping list. */
|
||||
#ifdef LX_DIRECT_READ
|
||||
|
||||
|
||||
/* Read the word directly. */
|
||||
block_word = *(block_word_ptr + nor_flash -> lx_nor_flash_block_physical_sector_mapping_offset + j);
|
||||
#else
|
||||
@@ -230,7 +209,7 @@ ULONG block_word;
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
@@ -243,7 +222,7 @@ ULONG block_word;
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* Is this entry valid? */
|
||||
if ((block_word & (LX_NOR_PHYSICAL_SECTOR_VALID | LX_NOR_PHYSICAL_SECTOR_MAPPING_NOT_VALID)) == LX_NOR_PHYSICAL_SECTOR_VALID)
|
||||
{
|
||||
@@ -251,10 +230,10 @@ ULONG block_word;
|
||||
|
||||
/* Yes, get the logical sector. */
|
||||
logical_sector = block_word & LX_NOR_LOGICAL_SECTOR_MASK;
|
||||
|
||||
|
||||
/* Get the mapping bitmap word. */
|
||||
mapping_bitmap_word = logical_sector >> 5;
|
||||
|
||||
|
||||
/* Check if the mapping bitmap word is within the cache. */
|
||||
if (mapping_bitmap_word < mapping_bitmap_words)
|
||||
{
|
||||
@@ -263,7 +242,7 @@ ULONG block_word;
|
||||
mapping_bitmap_ptr[mapping_bitmap_word] |= (ULONG)(1 << (logical_sector & 31));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -287,27 +266,27 @@ ULONG block_word;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Loop through the memory supplied and assign to cache entries. */
|
||||
i = 0;
|
||||
while ((cache_size >= LX_NOR_SECTOR_SIZE) && (i < LX_NOR_EXTENDED_CACHE_SIZE))
|
||||
{
|
||||
|
||||
|
||||
/* Setup this cache entry. */
|
||||
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_sector_memory = cache_memory;
|
||||
nor_flash -> lx_nor_flash_extended_cache[i].lx_nor_flash_extended_cache_entry_access_count = 0;
|
||||
|
||||
|
||||
/* Move the cache memory forward. */
|
||||
cache_memory = cache_memory + LX_NOR_SECTOR_SIZE;
|
||||
|
||||
|
||||
/* Decrement the size. */
|
||||
cache_size = cache_size - LX_NOR_SECTOR_SIZE;
|
||||
|
||||
|
||||
/* Move to next cache entry. */
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
/* Save the number of cache entries. */
|
||||
if(i == LX_NOR_EXTENDED_CACHE_SIZE)
|
||||
{
|
||||
@@ -318,7 +297,7 @@ ULONG block_word;
|
||||
{
|
||||
|
||||
nor_flash -> lx_nor_flash_extended_cache_entries = i;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef LX_THREAD_SAFE_ENABLE
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2025 Microsoft Corporation
|
||||
* Copyright (c) 2025 Microsoft Corporation
|
||||
* Copyright (c) 2025 STmicroelectronics
|
||||
*
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NOR Flash */
|
||||
/** */
|
||||
@@ -33,45 +34,35 @@ LX_NOR_FLASH *_lx_nor_flash_opened_ptr;
|
||||
ULONG _lx_nor_flash_opened_count;
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_initialize PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_initialize PORTABLE C */
|
||||
/* 6.1.7 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function initializes the NOR flash data structures. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* This function initializes the NOR flash data structures. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nor_flash_initialize(void)
|
||||
@@ -80,7 +71,7 @@ UINT _lx_nor_flash_initialize(void)
|
||||
/* Clear open list head pointer and opened count. */
|
||||
_lx_nor_flash_opened_ptr = LX_NULL;
|
||||
_lx_nor_flash_opened_count = 0;
|
||||
|
||||
|
||||
/* Return success! */
|
||||
return(LX_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NOR Flash */
|
||||
/** */
|
||||
@@ -34,63 +35,47 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_logical_sector_find PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_logical_sector_find PORTABLE C */
|
||||
/* 6.3.0 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function attempts to find the specified logical sector in */
|
||||
/* the NOR flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* logical_sector Logical sector number */
|
||||
/* superceded_check Check for sector being */
|
||||
/* superceded (can happen if */
|
||||
/* on interruptions of sector */
|
||||
/* write) */
|
||||
/* physical_sector_map_entry Destination for physical */
|
||||
/* sector map entry address */
|
||||
/* physical_sector_address Destination for physical */
|
||||
/* sector data */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nor_flash_driver_read Driver flash sector read */
|
||||
/* _lx_nor_flash_driver_write Driver flash sector write */
|
||||
/* _lx_nor_flash_system_error Internal system error handler */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* 10-31-2023 Xiuwen Cai Modified comment(s), */
|
||||
/* added mapping bitmap cache, */
|
||||
/* added obsolete count cache, */
|
||||
/* optimized full obsoleted */
|
||||
/* block searching logic, */
|
||||
/* resulting in version 6.3.0 */
|
||||
/* This function attempts to find the specified logical sector in */
|
||||
/* the NOR flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* logical_sector Logical sector number */
|
||||
/* superceded_check Check for sector being */
|
||||
/* superceded (can happen if */
|
||||
/* on interruptions of sector */
|
||||
/* write) */
|
||||
/* physical_sector_map_entry Destination for physical */
|
||||
/* sector map entry address */
|
||||
/* physical_sector_address Destination for physical */
|
||||
/* sector data */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nor_flash_driver_read Driver flash sector read */
|
||||
/* _lx_nor_flash_driver_write Driver flash sector write */
|
||||
/* _lx_nor_flash_system_error Internal system error handler */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nor_flash_logical_sector_find(LX_NOR_FLASH *nor_flash, ULONG logical_sector, ULONG superceded_check, ULONG **physical_sector_map_entry, ULONG **physical_sector_address)
|
||||
@@ -119,7 +104,7 @@ UINT status;
|
||||
/* Initialize the return parameters. */
|
||||
*physical_sector_map_entry = (ULONG *) 0;
|
||||
*physical_sector_address = (ULONG *) 0;
|
||||
|
||||
|
||||
/* Determine if there are any mapped physical sectors. */
|
||||
if (nor_flash -> lx_nor_flash_mapped_physical_sectors == 0)
|
||||
{
|
||||
@@ -127,7 +112,7 @@ UINT status;
|
||||
/* No mapped sector so nothing can be found!. */
|
||||
return(LX_SECTOR_NOT_FOUND);
|
||||
}
|
||||
|
||||
|
||||
#ifndef LX_NOR_DISABLE_EXTENDED_CACHE
|
||||
#ifdef LX_NOR_ENABLE_MAPPING_BITMAP
|
||||
|
||||
@@ -138,7 +123,7 @@ UINT status;
|
||||
/* Determine if the logical sector is mapped. */
|
||||
if ((nor_flash -> lx_nor_flash_extended_cache_mapping_bitmap[logical_sector >> 5] & (ULONG)(1 << (logical_sector & 31))) == 0)
|
||||
{
|
||||
|
||||
|
||||
/* Not mapped, return not found. */
|
||||
return(LX_SECTOR_NOT_FOUND);
|
||||
}
|
||||
@@ -149,14 +134,14 @@ UINT status;
|
||||
/* Determine if the sector mapping cache is enabled. */
|
||||
if (nor_flash -> lx_nor_flash_sector_mapping_cache_enabled)
|
||||
{
|
||||
|
||||
|
||||
/* Calculate the starting index of the sector cache for this sector entry. */
|
||||
i = (logical_sector & LX_NOR_SECTOR_MAPPING_CACHE_HASH_MASK) * LX_NOR_SECTOR_MAPPING_CACHE_DEPTH;
|
||||
|
||||
/* Build a pointer to the cache entry. */
|
||||
sector_mapping_cache_entry_ptr = &nor_flash -> lx_nor_flash_sector_mapping_cache[i];
|
||||
|
||||
/* Determine if the sector is in the sector mapping cache - assuming the depth of the sector
|
||||
/* Determine if the sector is in the sector mapping cache - assuming the depth of the sector
|
||||
mapping cache is LX_NOR_SECTOR_MAPPING_CACHE_DEPTH entries. */
|
||||
if ((sector_mapping_cache_entry_ptr -> lx_nor_sector_mapping_cache_logical_sector) == (logical_sector | LX_NOR_SECTOR_MAPPING_CACHE_ENTRY_VALID))
|
||||
{
|
||||
@@ -230,7 +215,7 @@ UINT status;
|
||||
/* Return a successful status. */
|
||||
return(LX_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
/* If we get here, we have a cache miss so increment the counter before we fall through the loop. */
|
||||
nor_flash -> lx_nor_flash_sector_mapping_cache_misses++;
|
||||
}
|
||||
@@ -248,9 +233,9 @@ UINT status;
|
||||
total_blocks = nor_flash -> lx_nor_flash_total_blocks;
|
||||
|
||||
/* Loop through the blocks to attempt to find the mapped logical sector. */
|
||||
while (total_blocks--)
|
||||
while (total_blocks--)
|
||||
{
|
||||
|
||||
|
||||
#ifdef LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE
|
||||
/* Determine if the obsolete sector count is available in the cache. */
|
||||
if (i < nor_flash -> lx_nor_flash_extended_cache_obsolete_count_max_block)
|
||||
@@ -262,20 +247,20 @@ UINT status;
|
||||
|
||||
/* Move to the next block. */
|
||||
i++;
|
||||
|
||||
|
||||
/* Determine if we have wrapped. */
|
||||
if (i >= nor_flash -> lx_nor_flash_total_blocks)
|
||||
{
|
||||
|
||||
|
||||
/* Yes, we have wrapped, set to block 0. */
|
||||
i = 0;
|
||||
}
|
||||
|
||||
|
||||
/* Start at the first sector in the next block. */
|
||||
j = 0;
|
||||
|
||||
|
||||
/* No point in looking further into this block, just continue the loop. */
|
||||
continue;
|
||||
continue;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -284,12 +269,12 @@ UINT status;
|
||||
/* Setup the block word pointer to the first word of the search block. */
|
||||
block_word_ptr = (nor_flash -> lx_nor_flash_base_address + (i * nor_flash -> lx_nor_flash_words_per_block));
|
||||
|
||||
/* Determine if the minimum and maximum logical sector values are present in the block header. If these are
|
||||
/* Determine if the minimum and maximum logical sector values are present in the block header. If these are
|
||||
present, we can quickly skip blocks that don't have our sector. */
|
||||
|
||||
/* Read the minimum and maximum logical sector values in this block. */
|
||||
#ifdef LX_DIRECT_READ
|
||||
|
||||
|
||||
/* Read the word directly. */
|
||||
min_logical_sector = *(block_word_ptr + LX_NOR_FLASH_MIN_LOGICAL_SECTOR_OFFSET);
|
||||
#else
|
||||
@@ -298,7 +283,7 @@ UINT status;
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
@@ -306,12 +291,12 @@ UINT status;
|
||||
return(status);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Is the value valid? */
|
||||
if (min_logical_sector != LX_ALL_ONES)
|
||||
{
|
||||
#ifdef LX_DIRECT_READ
|
||||
|
||||
|
||||
/* Read the word directly. */
|
||||
max_logical_sector = *(block_word_ptr + LX_NOR_FLASH_MAX_LOGICAL_SECTOR_OFFSET);
|
||||
#else
|
||||
@@ -320,7 +305,7 @@ UINT status;
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
@@ -339,20 +324,20 @@ UINT status;
|
||||
|
||||
/* Move to the next block. */
|
||||
i++;
|
||||
|
||||
|
||||
/* Determine if we have wrapped. */
|
||||
if (i >= nor_flash -> lx_nor_flash_total_blocks)
|
||||
{
|
||||
|
||||
|
||||
/* Yes, we have wrapped, set to block 0. */
|
||||
i = 0;
|
||||
}
|
||||
|
||||
/* Start at the first sector in the next block. */
|
||||
j = 0;
|
||||
|
||||
|
||||
/* No point in looking further into this block, just continue the loop. */
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -363,17 +348,17 @@ UINT status;
|
||||
max_logical_sector = LX_ALL_ONES;
|
||||
}
|
||||
#ifndef LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE
|
||||
|
||||
|
||||
/* Clear the valid sector found flag. */
|
||||
valid_sector_found = LX_FALSE;
|
||||
#endif
|
||||
|
||||
/* Setup the total number of sectors. */
|
||||
total_sectors = nor_flash -> lx_nor_flash_physical_sectors_per_block;
|
||||
|
||||
|
||||
/* Remember the start of the search. */
|
||||
search_start = j;
|
||||
|
||||
|
||||
/* Now search through the sector list to find a match. */
|
||||
while (total_sectors--)
|
||||
{
|
||||
@@ -381,10 +366,10 @@ UINT status;
|
||||
/* Setup a pointer to the mapped list. */
|
||||
list_word_ptr = block_word_ptr + nor_flash -> lx_nor_flash_block_physical_sector_mapping_offset + j;
|
||||
|
||||
|
||||
|
||||
/* Read in the mapped list for this block. */
|
||||
#ifdef LX_DIRECT_READ
|
||||
|
||||
|
||||
/* Read the word directly. */
|
||||
list_word = *(list_word_ptr);
|
||||
#else
|
||||
@@ -393,7 +378,7 @@ UINT status;
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
@@ -401,42 +386,42 @@ UINT status;
|
||||
return(status);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Determine if the entry hasn't been used. */
|
||||
if (list_word == LX_NOR_PHYSICAL_SECTOR_FREE)
|
||||
{
|
||||
|
||||
|
||||
/* Since the mapping is done sequentially in the block, we know nothing
|
||||
else exists after this point. */
|
||||
|
||||
|
||||
/* Determine if the search started at the beginning of the block. */
|
||||
if (search_start == 0)
|
||||
{
|
||||
|
||||
|
||||
/* Yes, we started at the beginning of the block. We are now done with this block. */
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
/* Setup the new total to the search start. */
|
||||
total_sectors = search_start;
|
||||
|
||||
|
||||
/* Clear search start. */
|
||||
search_start = 0;
|
||||
|
||||
|
||||
/* Start search over. */
|
||||
j = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Is this entry valid? */
|
||||
if ((list_word & (LX_NOR_PHYSICAL_SECTOR_VALID | LX_NOR_PHYSICAL_SECTOR_MAPPING_NOT_VALID)) == LX_NOR_PHYSICAL_SECTOR_VALID)
|
||||
{
|
||||
|
||||
|
||||
/* Decrement the number of mapped sectors. */
|
||||
mapped_sectors--;
|
||||
mapped_sectors--;
|
||||
|
||||
/* Do we have a valid sector match? */
|
||||
if ((list_word & LX_NOR_LOGICAL_SECTOR_MASK) == logical_sector)
|
||||
@@ -445,7 +430,7 @@ UINT status;
|
||||
/* Determine if we care about the superceded bit. */
|
||||
if (superceded_check == LX_FALSE)
|
||||
{
|
||||
|
||||
|
||||
/* Prepare the return information. */
|
||||
*physical_sector_map_entry = list_word_ptr;
|
||||
*physical_sector_address = block_word_ptr + nor_flash -> lx_nor_flash_block_physical_sector_offset + (j * LX_NOR_SECTOR_SIZE);
|
||||
@@ -455,7 +440,7 @@ UINT status;
|
||||
{
|
||||
|
||||
/* Yes, update the cache with the sector mapping. */
|
||||
|
||||
|
||||
/* Move all the cache entries down so the oldest is at the bottom. */
|
||||
*(sector_mapping_cache_entry_ptr + 3) = *(sector_mapping_cache_entry_ptr + 2);
|
||||
*(sector_mapping_cache_entry_ptr + 2) = *(sector_mapping_cache_entry_ptr + 1);
|
||||
@@ -469,26 +454,26 @@ UINT status;
|
||||
|
||||
/* Remember the last found block for next search. */
|
||||
nor_flash -> lx_nor_flash_found_block_search = i;
|
||||
|
||||
|
||||
/* Remember the last found sector. */
|
||||
nor_flash -> lx_nor_flash_found_sector_search = j+1;
|
||||
|
||||
|
||||
/* Has this wrapped around? */
|
||||
if (nor_flash -> lx_nor_flash_found_sector_search >= nor_flash -> lx_nor_flash_physical_sectors_per_block)
|
||||
{
|
||||
|
||||
|
||||
/* Reset to the beginning sector. */
|
||||
nor_flash -> lx_nor_flash_found_sector_search = 0;
|
||||
}
|
||||
|
||||
/* Return success! */
|
||||
return(LX_SUCCESS);
|
||||
return(LX_SUCCESS);
|
||||
}
|
||||
|
||||
/* Check for the superceded bit being clear, which means the sector was superceded. */
|
||||
else if (list_word & LX_NOR_PHYSICAL_SECTOR_SUPERCEDED)
|
||||
{
|
||||
|
||||
|
||||
/* Prepare the return information. */
|
||||
*physical_sector_map_entry = list_word_ptr;
|
||||
*physical_sector_address = block_word_ptr + nor_flash -> lx_nor_flash_block_physical_sector_offset + (j * LX_NOR_SECTOR_SIZE);
|
||||
@@ -500,17 +485,17 @@ UINT status;
|
||||
|
||||
/* Remember the last found sector. */
|
||||
nor_flash -> lx_nor_flash_found_sector_search = j+1;
|
||||
|
||||
|
||||
/* Has this wrapped around? */
|
||||
if (nor_flash -> lx_nor_flash_found_sector_search >= nor_flash -> lx_nor_flash_physical_sectors_per_block)
|
||||
{
|
||||
|
||||
|
||||
/* Reset to the beginning sector. */
|
||||
nor_flash -> lx_nor_flash_found_sector_search = 0;
|
||||
}
|
||||
|
||||
/* Return success! */
|
||||
return(LX_SUCCESS);
|
||||
return(LX_SUCCESS);
|
||||
}
|
||||
}
|
||||
#ifndef LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE
|
||||
@@ -522,11 +507,11 @@ UINT status;
|
||||
|
||||
/* Move to the next list entry. */
|
||||
j++;
|
||||
|
||||
|
||||
/* Check for wrap around. */
|
||||
if (j >= nor_flash -> lx_nor_flash_physical_sectors_per_block)
|
||||
{
|
||||
|
||||
|
||||
/* Yes, wrap around, go back to the beginning. */
|
||||
j = 0;
|
||||
}
|
||||
@@ -541,14 +526,14 @@ UINT status;
|
||||
|
||||
/* Write the max logical sector to the block header. */
|
||||
status = _lx_nor_flash_driver_write(nor_flash, block_word_ptr + LX_NOR_FLASH_MAX_LOGICAL_SECTOR_OFFSET, &max_logical_sector, 1);
|
||||
|
||||
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
|
||||
/* Return the error. */
|
||||
return(status);
|
||||
}
|
||||
@@ -558,14 +543,14 @@ UINT status;
|
||||
/* Determine if there are any more mapped sectors. */
|
||||
if (mapped_sectors == 0)
|
||||
break;
|
||||
|
||||
|
||||
/* Move to the next block. */
|
||||
i++;
|
||||
|
||||
|
||||
/* Determine if we have wrapped. */
|
||||
if (i >= nor_flash -> lx_nor_flash_total_blocks)
|
||||
{
|
||||
|
||||
|
||||
/* Yes, we have wrapped, set to block 0. */
|
||||
i = 0;
|
||||
}
|
||||
@@ -575,6 +560,6 @@ UINT status;
|
||||
}
|
||||
|
||||
/* Return sector not found status. */
|
||||
return(LX_SECTOR_NOT_FOUND);
|
||||
return(LX_SECTOR_NOT_FOUND);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NOR Flash */
|
||||
/** */
|
||||
@@ -34,58 +35,42 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_next_block_to_erase_find PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_next_block_to_erase_find PORTABLE C */
|
||||
/* 6.3.0 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function finds the next block to erase in the NOR flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* return_erase_block Returned block to erase */
|
||||
/* return_erase_count Returned erase count of block */
|
||||
/* return_mapped_sectors Returned number of mapped */
|
||||
/* sectors */
|
||||
/* return_obsolete_sectors Returned number of obsolete */
|
||||
/* sectors */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nor_flash_driver_read Driver flash sector read */
|
||||
/* _lx_nor_flash_system_error Internal system error handler */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* 10-31-2023 Xiuwen Cai Modified comment(s), */
|
||||
/* added mapping bitmap cache, */
|
||||
/* added obsolete count cache, */
|
||||
/* optimized full obsoleted */
|
||||
/* block searching logic, */
|
||||
/* resulting in version 6.3.0 */
|
||||
/* This function finds the next block to erase in the NOR flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* return_erase_block Returned block to erase */
|
||||
/* return_erase_count Returned erase count of block */
|
||||
/* return_mapped_sectors Returned number of mapped */
|
||||
/* sectors */
|
||||
/* return_obsolete_sectors Returned number of obsolete */
|
||||
/* sectors */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nor_flash_driver_read Driver flash sector read */
|
||||
/* _lx_nor_flash_system_error Internal system error handler */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nor_flash_next_block_to_erase_find(LX_NOR_FLASH *nor_flash, ULONG *return_erase_block, ULONG *return_erase_count, ULONG *return_mapped_sectors, ULONG *return_obsolete_sectors)
|
||||
@@ -126,36 +111,36 @@ UINT mapped_sectors_available;
|
||||
|
||||
/* Initialize the minimum erase count. */
|
||||
min_block_erase_count = LX_ALL_ONES;
|
||||
|
||||
|
||||
/* Initialize the system minimum and maximum erase counts. */
|
||||
min_system_block_erase_count = LX_ALL_ONES;
|
||||
system_min_erased_blocks = 0;
|
||||
max_system_block_erase_count = 0;
|
||||
|
||||
|
||||
/* Initialize the maximum obsolete sector count. */
|
||||
max_obsolete_sectors = 0;
|
||||
|
||||
|
||||
/* Calculate the erase count threshold. */
|
||||
if (nor_flash -> lx_nor_flash_free_physical_sectors >= nor_flash -> lx_nor_flash_physical_sectors_per_block)
|
||||
{
|
||||
|
||||
|
||||
/* Calculate erase count threshold by adding constant to the current minimum. */
|
||||
erase_count_threshold = nor_flash -> lx_nor_flash_minimum_erase_count + LX_NOR_FLASH_MAX_ERASE_COUNT_DELTA;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
/* When the number of free sectors is low, simply pick the block that has the most number of obsolete sectors. */
|
||||
erase_count_threshold = LX_ALL_ONES;
|
||||
}
|
||||
|
||||
|
||||
/* Loop through the blocks to attempt to find the mapped logical sector. */
|
||||
for (i = 0; i < nor_flash -> lx_nor_flash_total_blocks; i++)
|
||||
{
|
||||
|
||||
/* Read the erase count of this block. */
|
||||
#ifdef LX_DIRECT_READ
|
||||
|
||||
|
||||
/* Read the word directly. */
|
||||
erase_count = *(block_word_ptr);
|
||||
#else
|
||||
@@ -164,7 +149,7 @@ UINT mapped_sectors_available;
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
@@ -189,7 +174,7 @@ UINT mapped_sectors_available;
|
||||
/* Initialize the obsolete and mapped sector count available flags. */
|
||||
obsolete_sectors_available = LX_FALSE;
|
||||
mapped_sectors_available = LX_FALSE;
|
||||
|
||||
|
||||
#ifdef LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE
|
||||
|
||||
/* Determine if the obsolete sector count is available in the cache. */
|
||||
@@ -207,7 +192,7 @@ UINT mapped_sectors_available;
|
||||
#endif
|
||||
/* Read the minimum and maximum logical sector values in this block. */
|
||||
#ifdef LX_DIRECT_READ
|
||||
|
||||
|
||||
/* Read the word directly. */
|
||||
min_logical_sector = *(block_word_ptr + LX_NOR_FLASH_MIN_LOGICAL_SECTOR_OFFSET);
|
||||
#else
|
||||
@@ -216,7 +201,7 @@ UINT mapped_sectors_available;
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
@@ -224,12 +209,12 @@ UINT mapped_sectors_available;
|
||||
return(status);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Determine if the minimum logical sector is valid. */
|
||||
if (min_logical_sector != LX_ALL_ONES)
|
||||
{
|
||||
#ifdef LX_DIRECT_READ
|
||||
|
||||
|
||||
/* Read the word directly. */
|
||||
max_logical_sector = *(block_word_ptr + LX_NOR_FLASH_MAX_LOGICAL_SECTOR_OFFSET);
|
||||
#else
|
||||
@@ -238,7 +223,7 @@ UINT mapped_sectors_available;
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
@@ -251,7 +236,7 @@ UINT mapped_sectors_available;
|
||||
/* Now let's check to see if all the sector are obsoleted. */
|
||||
if ((max_logical_sector != LX_ALL_ONES) && (max_logical_sector < min_logical_sector))
|
||||
{
|
||||
|
||||
|
||||
obsolete_sectors_available = LX_TRUE;
|
||||
obsolete_sectors = nor_flash -> lx_nor_flash_physical_sectors_per_block;
|
||||
}
|
||||
@@ -280,10 +265,10 @@ UINT mapped_sectors_available;
|
||||
/* Loop through the mapped list for this block. */
|
||||
for (j = 0; j < nor_flash -> lx_nor_flash_physical_sectors_per_block; j++)
|
||||
{
|
||||
|
||||
|
||||
/* Read the current mapping entry. */
|
||||
#ifdef LX_DIRECT_READ
|
||||
|
||||
|
||||
/* Read the word directly. */
|
||||
list_word = *(list_word_ptr);
|
||||
#else
|
||||
@@ -292,7 +277,7 @@ UINT mapped_sectors_available;
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
@@ -300,26 +285,26 @@ UINT mapped_sectors_available;
|
||||
return(status);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Determine if the entry hasn't been used. */
|
||||
if (list_word == LX_NOR_PHYSICAL_SECTOR_FREE)
|
||||
{
|
||||
|
||||
|
||||
/* Since allocations are done sequentially in the block, we know nothing
|
||||
else exists after this point. */
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* Is this entry obsolete? */
|
||||
if ((list_word & LX_NOR_PHYSICAL_SECTOR_VALID) == 0)
|
||||
{
|
||||
|
||||
|
||||
/* Increment the number of obsolete sectors. */
|
||||
obsolete_sectors++;
|
||||
obsolete_sectors++;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
/* Increment the number of mapped sectors. */
|
||||
mapped_sectors++;
|
||||
}
|
||||
@@ -328,9 +313,9 @@ UINT mapped_sectors_available;
|
||||
list_word_ptr++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Determine if this block contains full obsoleted sectors and the erase count is minimum. */
|
||||
if ((obsolete_sectors == nor_flash -> lx_nor_flash_physical_sectors_per_block) &&
|
||||
if ((obsolete_sectors == nor_flash -> lx_nor_flash_physical_sectors_per_block) &&
|
||||
(erase_count == nor_flash -> lx_nor_flash_minimum_erase_count) &&
|
||||
(nor_flash -> lx_nor_flash_minimum_erased_blocks > 0))
|
||||
{
|
||||
@@ -343,28 +328,28 @@ UINT mapped_sectors_available;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Determine if we have a block with a new maximum number of obsolete sectors. */
|
||||
if ((obsolete_sectors > max_obsolete_sectors) && (erase_count <= erase_count_threshold))
|
||||
{
|
||||
|
||||
|
||||
/* Update the new maximum obsolete sectors and related information. */
|
||||
max_obsolete_sectors = obsolete_sectors;
|
||||
max_obsolete_block = i;
|
||||
max_obsolete_erase_count = erase_count;
|
||||
max_obsolete_mapped_count = mapped_sectors;
|
||||
max_obsolete_mapped_count_available = mapped_sectors_available;
|
||||
|
||||
|
||||
}
|
||||
else if ((max_obsolete_sectors) && (obsolete_sectors == max_obsolete_sectors) && (erase_count <= erase_count_threshold))
|
||||
{
|
||||
|
||||
|
||||
/* Another block has the same number of obsolete sectors. Does this new block have a smaller erase
|
||||
count? */
|
||||
if (erase_count < max_obsolete_erase_count)
|
||||
{
|
||||
|
||||
|
||||
/* Yes, erase the block with the smaller erase count. */
|
||||
max_obsolete_sectors = obsolete_sectors;
|
||||
max_obsolete_block = i;
|
||||
@@ -373,11 +358,11 @@ UINT mapped_sectors_available;
|
||||
max_obsolete_mapped_count_available = mapped_sectors_available;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Determine if we have a new minimum erase count. */
|
||||
if (erase_count < min_block_erase_count)
|
||||
{
|
||||
|
||||
|
||||
/* Update the new minimum erase count and related information. */
|
||||
min_block_erase_count = erase_count;
|
||||
min_block_erase = i;
|
||||
@@ -385,7 +370,7 @@ UINT mapped_sectors_available;
|
||||
min_block_mapped_count = mapped_sectors;
|
||||
min_block_mapped_count_available = mapped_sectors_available;
|
||||
}
|
||||
|
||||
|
||||
/* Move to the next block. */
|
||||
block_word_ptr = block_word_ptr + nor_flash -> lx_nor_flash_words_per_block;
|
||||
}
|
||||
@@ -397,7 +382,7 @@ UINT mapped_sectors_available;
|
||||
/* Determine if we can erase the block with the most obsolete sectors. */
|
||||
if (max_obsolete_sectors)
|
||||
{
|
||||
|
||||
|
||||
/* Erase the block with the most obsolete sectors. */
|
||||
*return_erase_block = max_obsolete_block;
|
||||
*return_erase_count = max_obsolete_erase_count;
|
||||
@@ -407,7 +392,7 @@ UINT mapped_sectors_available;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
/* Otherwise, choose the block with the smallest erase count. */
|
||||
*return_erase_block = min_block_erase;
|
||||
*return_erase_count = min_block_erase_count;
|
||||
@@ -432,55 +417,55 @@ UINT mapped_sectors_available;
|
||||
/* Setup a pointer to the mapped list. */
|
||||
block_word_ptr = nor_flash -> lx_nor_flash_base_address + *return_erase_block * nor_flash -> lx_nor_flash_words_per_block;
|
||||
list_word_ptr = block_word_ptr + nor_flash -> lx_nor_flash_block_physical_sector_mapping_offset;
|
||||
|
||||
|
||||
/* Loop through the mapped list for this block. */
|
||||
for (j = 0; j < nor_flash -> lx_nor_flash_physical_sectors_per_block; j++)
|
||||
{
|
||||
|
||||
|
||||
/* Read the current mapping entry. */
|
||||
#ifdef LX_DIRECT_READ
|
||||
|
||||
|
||||
/* Read the word directly. */
|
||||
list_word = *(list_word_ptr);
|
||||
#else
|
||||
status = _lx_nor_flash_driver_read(nor_flash, list_word_ptr, &list_word, 1);
|
||||
|
||||
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
|
||||
/* Return the error. */
|
||||
return(status);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Determine if the entry hasn't been used. */
|
||||
if (list_word == LX_NOR_PHYSICAL_SECTOR_FREE)
|
||||
{
|
||||
|
||||
|
||||
/* Since allocations are done sequentially in the block, we know nothing
|
||||
else exists after this point. */
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* Is this entry mapped? */
|
||||
if ((list_word & LX_NOR_PHYSICAL_SECTOR_VALID) != 0)
|
||||
{
|
||||
|
||||
|
||||
/* Increment the number of mapped sectors. */
|
||||
mapped_sectors++;
|
||||
}
|
||||
|
||||
|
||||
/* Move the list pointer ahead. */
|
||||
list_word_ptr++;
|
||||
}
|
||||
|
||||
|
||||
/* Return the mapped sector count. */
|
||||
*return_mapped_sectors = mapped_sectors;
|
||||
|
||||
|
||||
}
|
||||
/* Return success. */
|
||||
return(LX_SUCCESS);
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
* Portion Copyright (c) 2025 STMicroelectronics
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NOR Flash */
|
||||
/** */
|
||||
|
||||
@@ -76,34 +76,6 @@
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 11-09-2020 William E. Lamie Modified comment(s), */
|
||||
/* fixed compiler warnings, */
|
||||
/* resulting in version 6.1.2 */
|
||||
/* 12-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* fixed compiler warnings, */
|
||||
/* resulting in version 6.1.3 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), and */
|
||||
/* updated product constants */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* 03-08-2023 Xiuwen Cai Modified comment(s), */
|
||||
/* added new driver interface, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* 10-31-2023 Xiuwen Cai Modified comment(s), */
|
||||
/* added count for minimum */
|
||||
/* erased blocks, added */
|
||||
/* obsolete count cache, */
|
||||
/* avoided clearing user */
|
||||
/* extension in flash control */
|
||||
/* block, */
|
||||
/* resulting in version 6.3.0 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
|
||||
UINT _lx_nor_flash_open_extended(LX_NOR_FLASH *nor_flash, CHAR *name, UINT (*nor_driver_initialize)(LX_NOR_FLASH *), VOID *nor_driver_info_ptr)
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NOR Flash */
|
||||
/** */
|
||||
@@ -34,56 +35,46 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_partial_defragment PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_partial_defragment PORTABLE C */
|
||||
/* 6.1.7 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function defragments the NOR flash up to the specified */
|
||||
/* number of blocks. . */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* max_blocks Maximum number of blocks to */
|
||||
/* defragment */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nor_flash_block_reclaim Reclaim a NOR flash block */
|
||||
/* tx_mutex_get Get thread protection */
|
||||
/* tx_mutex_put Release thread protection */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* This function defragments the NOR flash up to the specified */
|
||||
/* number of blocks. . */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* max_blocks Maximum number of blocks to */
|
||||
/* defragment */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nor_flash_block_reclaim Reclaim a NOR flash block */
|
||||
/* tx_mutex_get Get thread protection */
|
||||
/* tx_mutex_put Release thread protection */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nor_flash_partial_defragment(LX_NOR_FLASH *nor_flash, UINT max_blocks)
|
||||
{
|
||||
|
||||
|
||||
ULONG i;
|
||||
|
||||
|
||||
@@ -96,7 +87,7 @@ ULONG i;
|
||||
/* Determine if the maximum number of blocks exceeds the total blocks in this flash instance. */
|
||||
if (max_blocks >= nor_flash -> lx_nor_flash_total_blocks)
|
||||
{
|
||||
|
||||
|
||||
/* Adjust the maximum to the total number of blocks. */
|
||||
max_blocks = nor_flash -> lx_nor_flash_total_blocks;
|
||||
}
|
||||
@@ -104,11 +95,11 @@ ULONG i;
|
||||
/* Loop for max number of blocks, while there are obsolete count. */
|
||||
for (i = 0; i < max_blocks; i++)
|
||||
{
|
||||
|
||||
|
||||
/* Determine if there is any more defragment work. */
|
||||
if (nor_flash -> lx_nor_flash_obsolete_physical_sectors == 0)
|
||||
break;
|
||||
|
||||
break;
|
||||
|
||||
/* Call the block reclaim function to defragment. */
|
||||
_lx_nor_flash_block_reclaim(nor_flash);
|
||||
}
|
||||
@@ -119,7 +110,7 @@ ULONG i;
|
||||
tx_mutex_put(&nor_flash -> lx_nor_flash_mutex);
|
||||
#endif
|
||||
|
||||
/* Return successful completion. */
|
||||
/* Return successful completion. */
|
||||
return(LX_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NOR Flash */
|
||||
/** */
|
||||
@@ -34,51 +35,41 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_physical_sector_allocate PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_physical_sector_allocate PORTABLE C */
|
||||
/* 6.1.7 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function allocates a free physical sector for mapping to a */
|
||||
/* logical sector. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* logical_sector Logical sector number */
|
||||
/* physical_sector_map_entry Pointer to sector map entry */
|
||||
/* physical_sector_address Address of physical sector */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nor_flash_driver_write Driver flash sector write */
|
||||
/* _lx_nor_flash_driver_read Driver flash sector read */
|
||||
/* _lx_nor_flash_system_error Internal system error handler */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* This function allocates a free physical sector for mapping to a */
|
||||
/* logical sector. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* logical_sector Logical sector number */
|
||||
/* physical_sector_map_entry Pointer to sector map entry */
|
||||
/* physical_sector_address Address of physical sector */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nor_flash_driver_write Driver flash sector write */
|
||||
/* _lx_nor_flash_driver_read Driver flash sector read */
|
||||
/* _lx_nor_flash_system_error Internal system error handler */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nor_flash_physical_sector_allocate(LX_NOR_FLASH *nor_flash, ULONG logical_sector, ULONG **physical_sector_map_entry, ULONG **physical_sector_address)
|
||||
@@ -101,7 +92,7 @@ UINT status;
|
||||
/* Initialize the return parameters. */
|
||||
*physical_sector_map_entry = (ULONG *) 0;
|
||||
*physical_sector_address = (ULONG *) 0;
|
||||
|
||||
|
||||
/* Determine if there are any free physical sectors. */
|
||||
if (nor_flash -> lx_nor_flash_free_physical_sectors == 0)
|
||||
{
|
||||
@@ -126,10 +117,10 @@ UINT status;
|
||||
/* Find the first free physical sector from the free sector bit map of this block. */
|
||||
for (j = 0; j < nor_flash -> lx_nor_flash_block_bit_map_words; j++)
|
||||
{
|
||||
|
||||
|
||||
/* Read this word of the free sector bit map. */
|
||||
#ifdef LX_DIRECT_READ
|
||||
|
||||
|
||||
/* Read the word directly. */
|
||||
block_word = *(block_word_ptr + nor_flash -> lx_nor_flash_block_free_bit_map_offset + j);
|
||||
#else
|
||||
@@ -138,32 +129,32 @@ UINT status;
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
|
||||
/* Return the error. */
|
||||
return(status);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Are there any free sectors in this word? */
|
||||
if (block_word)
|
||||
{
|
||||
|
||||
|
||||
/* Yes, there are free sectors in this word. */
|
||||
for (k = 0; k < 32; k++)
|
||||
{
|
||||
|
||||
|
||||
/* Is this sector free? */
|
||||
if (block_word & 1)
|
||||
{
|
||||
|
||||
|
||||
/* Yes, this sector is free, clear the bit for this sector in the free sector map. */
|
||||
|
||||
|
||||
/* Read this word of the free sector bit map again. */
|
||||
#ifdef LX_DIRECT_READ
|
||||
|
||||
|
||||
/* Read the word directly. */
|
||||
block_word = *(block_word_ptr + nor_flash -> lx_nor_flash_block_free_bit_map_offset + j);
|
||||
#else
|
||||
@@ -172,7 +163,7 @@ UINT status;
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
@@ -180,17 +171,17 @@ UINT status;
|
||||
return(status);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Clear the bit associated with the free sector to indicate it is not free. */
|
||||
block_word = block_word & ~(((ULONG) 1) << k);
|
||||
|
||||
|
||||
/* Now write back free bit map word with the bit for this sector cleared. */
|
||||
status = _lx_nor_flash_driver_write(nor_flash, (block_word_ptr + nor_flash -> lx_nor_flash_block_free_bit_map_offset + j), &block_word, 1);
|
||||
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
@@ -201,14 +192,14 @@ UINT status;
|
||||
/* Determine if this is the last entry available in this block. */
|
||||
if (((block_word >> 1) == 0) && (j == (nor_flash -> lx_nor_flash_block_bit_map_words - 1)))
|
||||
{
|
||||
|
||||
|
||||
/* This is the last physical sector in the block. Now we need to calculate the minimum valid logical
|
||||
sector and the maximum valid logical sector. */
|
||||
|
||||
/* Setup the minimum and maximum logical sectors to the current logical sector. */
|
||||
min_logical_sector = logical_sector;
|
||||
max_logical_sector = logical_sector;
|
||||
|
||||
|
||||
/* Setup a pointer to the mapped list. */
|
||||
list_word_ptr = block_word_ptr + nor_flash -> lx_nor_flash_block_physical_sector_mapping_offset;
|
||||
|
||||
@@ -218,16 +209,16 @@ UINT status;
|
||||
|
||||
/* Read the mapped sector entry. */
|
||||
#ifdef LX_DIRECT_READ
|
||||
|
||||
|
||||
/* Read the word directly. */
|
||||
list_word = *(list_word_ptr);
|
||||
#else
|
||||
status = _lx_nor_flash_driver_read(nor_flash, list_word_ptr, &list_word, 1);
|
||||
|
||||
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
@@ -235,7 +226,7 @@ UINT status;
|
||||
return(status);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Is this entry valid? */
|
||||
if (list_word & LX_NOR_PHYSICAL_SECTOR_VALID)
|
||||
{
|
||||
@@ -246,50 +237,50 @@ UINT status;
|
||||
/* Determine if a new minimum has been found. */
|
||||
if (list_word < min_logical_sector)
|
||||
min_logical_sector = list_word;
|
||||
|
||||
|
||||
/* Determine if a new maximum has been found. */
|
||||
if (list_word != LX_NOR_LOGICAL_SECTOR_MASK)
|
||||
{
|
||||
if (list_word > max_logical_sector)
|
||||
max_logical_sector = list_word;
|
||||
max_logical_sector = list_word;
|
||||
}
|
||||
}
|
||||
|
||||
/* Move the list pointer ahead. */
|
||||
list_word_ptr++;
|
||||
}
|
||||
|
||||
|
||||
/* Move the search pointer forward, since we know this block is exhausted. */
|
||||
search_block++;
|
||||
|
||||
|
||||
/* Check for wrap condition on the search block. */
|
||||
if (search_block >= nor_flash -> lx_nor_flash_total_blocks)
|
||||
{
|
||||
|
||||
|
||||
/* Reset search block to the beginning. */
|
||||
search_block = 0;
|
||||
}
|
||||
|
||||
|
||||
/* Now write the minimum and maximum logical sector in this block. */
|
||||
status = _lx_nor_flash_driver_write(nor_flash, block_word_ptr + LX_NOR_FLASH_MIN_LOGICAL_SECTOR_OFFSET, &min_logical_sector, 1);
|
||||
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
/* Return the error. */
|
||||
return(status);
|
||||
}
|
||||
|
||||
|
||||
status = _lx_nor_flash_driver_write(nor_flash, block_word_ptr + LX_NOR_FLASH_MAX_LOGICAL_SECTOR_OFFSET, &max_logical_sector, 1);
|
||||
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
@@ -297,35 +288,35 @@ UINT status;
|
||||
return(status);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Remember the block to search. */
|
||||
nor_flash -> lx_nor_flash_free_block_search = search_block;
|
||||
|
||||
|
||||
/* Prepare the return information. */
|
||||
*physical_sector_map_entry = block_word_ptr + (nor_flash -> lx_nor_flash_block_physical_sector_mapping_offset + (j * 32)) + k;
|
||||
*physical_sector_address = block_word_ptr + (nor_flash -> lx_nor_flash_block_physical_sector_offset) + (((j * 32) + k) * LX_NOR_SECTOR_SIZE);
|
||||
|
||||
/* Return success! */
|
||||
return(LX_SUCCESS);
|
||||
return(LX_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
/* Shift down the bit map. */
|
||||
block_word = block_word >> 1;
|
||||
|
||||
|
||||
/* Determine if there are any more bits set? If not, we can break out of the search of this word. */
|
||||
if (block_word == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Move to the next flash block. */
|
||||
search_block++;
|
||||
|
||||
|
||||
/* Determine if we have to wrap the search block. */
|
||||
if (search_block >= nor_flash -> lx_nor_flash_total_blocks)
|
||||
{
|
||||
|
||||
|
||||
/* Set the search block to the beginning. */
|
||||
search_block = 0;
|
||||
}
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NOR Flash */
|
||||
/** */
|
||||
@@ -34,47 +35,37 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_sector_mapping_cache_invalidate PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_sector_mapping_cache_invalidate PORTABLE C */
|
||||
/* 6.1.7 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function invalidates the sector's entry in the NOR flash */
|
||||
/* cache. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* logical_sector Logical sector */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* This function invalidates the sector's entry in the NOR flash */
|
||||
/* cache. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* logical_sector Logical sector */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
VOID _lx_nor_flash_sector_mapping_cache_invalidate(LX_NOR_FLASH *nor_flash, ULONG logical_sector)
|
||||
@@ -87,14 +78,14 @@ LX_NOR_SECTOR_MAPPING_CACHE_ENTRY *sector_mapping_cache_entry_ptr;
|
||||
/* Determine if the sector mapping cache is enabled. */
|
||||
if (nor_flash -> lx_nor_flash_sector_mapping_cache_enabled)
|
||||
{
|
||||
|
||||
|
||||
/* Calculate the starting index of the sector mapping cache for this sector entry. */
|
||||
i = (logical_sector & LX_NOR_SECTOR_MAPPING_CACHE_HASH_MASK) * LX_NOR_SECTOR_MAPPING_CACHE_DEPTH;
|
||||
|
||||
/* Build a pointer to the cache entry. */
|
||||
sector_mapping_cache_entry_ptr = &nor_flash -> lx_nor_flash_sector_mapping_cache[i];
|
||||
|
||||
/* Determine if the sector is in the sector mapping cache - assuming the depth of the sector
|
||||
/* Determine if the sector is in the sector mapping cache - assuming the depth of the sector
|
||||
mapping cache is LX_NOR_SECTOR_MAPPING_CACHE_DEPTH entries. */
|
||||
if ((sector_mapping_cache_entry_ptr -> lx_nor_sector_mapping_cache_logical_sector) == (logical_sector | LX_NOR_SECTOR_MAPPING_CACHE_ENTRY_VALID))
|
||||
{
|
||||
@@ -103,7 +94,7 @@ LX_NOR_SECTOR_MAPPING_CACHE_ENTRY *sector_mapping_cache_entry_ptr;
|
||||
*(sector_mapping_cache_entry_ptr) = *(sector_mapping_cache_entry_ptr + 1);
|
||||
*(sector_mapping_cache_entry_ptr + 1) = *(sector_mapping_cache_entry_ptr + 2);
|
||||
*(sector_mapping_cache_entry_ptr + 2) = *(sector_mapping_cache_entry_ptr + 3);
|
||||
|
||||
|
||||
/* Invalidate the last entry. */
|
||||
(sector_mapping_cache_entry_ptr + 3) -> lx_nor_sector_mapping_cache_logical_sector = 0;
|
||||
}
|
||||
@@ -113,7 +104,7 @@ LX_NOR_SECTOR_MAPPING_CACHE_ENTRY *sector_mapping_cache_entry_ptr;
|
||||
/* Move all subsequent cache entries up and invalidate the last entry. */
|
||||
*(sector_mapping_cache_entry_ptr + 1) = *(sector_mapping_cache_entry_ptr + 2);
|
||||
*(sector_mapping_cache_entry_ptr + 2) = *(sector_mapping_cache_entry_ptr + 3);
|
||||
|
||||
|
||||
/* Invalidate the last entry. */
|
||||
(sector_mapping_cache_entry_ptr + 3) -> lx_nor_sector_mapping_cache_logical_sector = 0;
|
||||
}
|
||||
@@ -122,7 +113,7 @@ LX_NOR_SECTOR_MAPPING_CACHE_ENTRY *sector_mapping_cache_entry_ptr;
|
||||
|
||||
/* Move all subsequent cache entries up and invalidate the last entry. */
|
||||
*(sector_mapping_cache_entry_ptr + 2) = *(sector_mapping_cache_entry_ptr + 3);
|
||||
|
||||
|
||||
/* Invalidate the last entry. */
|
||||
(sector_mapping_cache_entry_ptr + 3) -> lx_nor_sector_mapping_cache_logical_sector = 0;
|
||||
}
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NOR Flash */
|
||||
/** */
|
||||
@@ -34,58 +35,45 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_sector_read PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_sector_read PORTABLE C */
|
||||
/* 6.3.0 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function reads a logical sector from NOR flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* logical_sector Logical sector number */
|
||||
/* buffer Pointer to buffer to read into*/
|
||||
/* (the size is 512 bytes) */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nor_flash_driver_write Driver flash sector write */
|
||||
/* _lx_nor_flash_driver_read Driver flash sector read */
|
||||
/* _lx_nor_flash_logical_sector_find Find logical sector */
|
||||
/* _lx_nor_flash_physical_sector_allocate */
|
||||
/* Allocate new logical sector */
|
||||
/* _lx_nor_flash_system_error Internal system error handler */
|
||||
/* tx_mutex_get Get thread protection */
|
||||
/* tx_mutex_put Release thread protection */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* 10-31-2023 Xiuwen Cai Modified comment(s), */
|
||||
/* added mapping bitmap cache, */
|
||||
/* resulting in version 6.3.0 */
|
||||
/* This function reads a logical sector from NOR flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* logical_sector Logical sector number */
|
||||
/* buffer Pointer to buffer to read into*/
|
||||
/* (the size is 512 bytes) */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nor_flash_driver_write Driver flash sector write */
|
||||
/* _lx_nor_flash_driver_read Driver flash sector read */
|
||||
/* _lx_nor_flash_logical_sector_find Find logical sector */
|
||||
/* _lx_nor_flash_physical_sector_allocate */
|
||||
/* Allocate new logical sector */
|
||||
/* _lx_nor_flash_system_error Internal system error handler */
|
||||
/* tx_mutex_get Get thread protection */
|
||||
/* tx_mutex_put Release thread protection */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nor_flash_sector_read(LX_NOR_FLASH *nor_flash, ULONG logical_sector, VOID *buffer)
|
||||
@@ -108,23 +96,23 @@ ULONG *sector_address;
|
||||
|
||||
/* See if we can find the sector in the current mapping. */
|
||||
_lx_nor_flash_logical_sector_find(nor_flash, logical_sector, LX_FALSE, &mapping_address, §or_address);
|
||||
|
||||
|
||||
/* Determine if the logical sector was found. */
|
||||
if (mapping_address)
|
||||
{
|
||||
|
||||
|
||||
/* Yes, we were able to find the logical sector. */
|
||||
|
||||
|
||||
/* Read the sector data from the physical sector. */
|
||||
status = _lx_nor_flash_driver_read(nor_flash, sector_address, buffer, LX_NOR_SECTOR_SIZE);
|
||||
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
|
||||
/* Adjust return status. */
|
||||
status = LX_ERROR;
|
||||
}
|
||||
@@ -137,7 +125,7 @@ ULONG *sector_address;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
/* Allocate a new physical sector for this write. */
|
||||
_lx_nor_flash_physical_sector_allocate(nor_flash, logical_sector, &mapping_address, §or_address);
|
||||
|
||||
@@ -147,31 +135,31 @@ ULONG *sector_address;
|
||||
|
||||
/* Update the number of free physical sectors. */
|
||||
nor_flash -> lx_nor_flash_free_physical_sectors--;
|
||||
|
||||
|
||||
/* Read the sector data from the physical sector. */
|
||||
status = _lx_nor_flash_driver_read(nor_flash, sector_address, buffer, LX_NOR_SECTOR_SIZE);
|
||||
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
}
|
||||
|
||||
/* Now build the new mapping entry. */
|
||||
mapping_entry = ((ULONG) LX_NOR_PHYSICAL_SECTOR_VALID) | ((ULONG) LX_NOR_PHYSICAL_SECTOR_SUPERCEDED) | logical_sector;
|
||||
|
||||
|
||||
/* Write out the new mapping entry. */
|
||||
status = _lx_nor_flash_driver_write(nor_flash, mapping_address, &mapping_entry, 1);
|
||||
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
|
||||
#ifdef LX_THREAD_SAFE_ENABLE
|
||||
|
||||
/* Release the thread safe mutex. */
|
||||
@@ -202,12 +190,12 @@ ULONG *sector_address;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
/* Could not find the logical sector. */
|
||||
status = LX_SECTOR_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef LX_THREAD_SAFE_ENABLE
|
||||
|
||||
/* Release the thread safe mutex. */
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NOR Flash */
|
||||
/** */
|
||||
@@ -34,59 +35,45 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_sector_release PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_sector_release PORTABLE C */
|
||||
/* 6.3.0 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function releases a logical sector from being managed in the */
|
||||
/* NOR flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* logical_sector Logical sector number */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nor_flash_driver_write Driver flash sector write */
|
||||
/* _lx_nor_flash_driver_read Driver flash sector read */
|
||||
/* _lx_nor_flash_block_reclaim Reclaim one flash block */
|
||||
/* _lx_nor_flash_sector_mapping_cache_invalidate */
|
||||
/* Invalidate cache entry */
|
||||
/* _lx_nor_flash_logical_sector_find Find logical sector */
|
||||
/* _lx_nor_flash_system_error Internal system error handler */
|
||||
/* tx_mutex_get Get thread protection */
|
||||
/* tx_mutex_put Release thread protection */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* 10-31-2023 Xiuwen Cai Modified comment(s), */
|
||||
/* added mapping bitmap cache, */
|
||||
/* added obsolete count cache, */
|
||||
/* resulting in version 6.3.0 */
|
||||
/* This function releases a logical sector from being managed in the */
|
||||
/* NOR flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* logical_sector Logical sector number */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nor_flash_driver_write Driver flash sector write */
|
||||
/* _lx_nor_flash_driver_read Driver flash sector read */
|
||||
/* _lx_nor_flash_block_reclaim Reclaim one flash block */
|
||||
/* _lx_nor_flash_sector_mapping_cache_invalidate */
|
||||
/* Invalidate cache entry */
|
||||
/* _lx_nor_flash_logical_sector_find Find logical sector */
|
||||
/* _lx_nor_flash_system_error Internal system error handler */
|
||||
/* tx_mutex_get Get thread protection */
|
||||
/* tx_mutex_put Release thread protection */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nor_flash_sector_release(LX_NOR_FLASH *nor_flash, ULONG logical_sector)
|
||||
@@ -113,16 +100,16 @@ ULONG block;
|
||||
|
||||
/* See if we can find the sector in the current mapping. */
|
||||
_lx_nor_flash_logical_sector_find(nor_flash, logical_sector, LX_FALSE, &mapping_address, §or_address);
|
||||
|
||||
|
||||
/* Determine if the logical sector was found. */
|
||||
if (mapping_address)
|
||||
{
|
||||
|
||||
|
||||
/* Yes, we were able to find the logical sector. */
|
||||
|
||||
|
||||
/* Read in the old sector mapping. */
|
||||
#ifdef LX_DIRECT_READ
|
||||
|
||||
|
||||
/* Read the word directly. */
|
||||
mapping_entry = *(mapping_address);
|
||||
#else
|
||||
@@ -131,7 +118,7 @@ ULONG block;
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
@@ -149,14 +136,14 @@ ULONG block;
|
||||
/* Mark this sector as invalid. */
|
||||
/* Now clear bits 31 and 30, which indicates this sector is now obsoleted. */
|
||||
mapping_entry = mapping_entry & ~(((ULONG) LX_NOR_PHYSICAL_SECTOR_VALID) | ((ULONG) LX_NOR_PHYSICAL_SECTOR_SUPERCEDED));
|
||||
|
||||
|
||||
/* Write the value back to the flash to clear bits 31 & 30. */
|
||||
status = _lx_nor_flash_driver_write(nor_flash, mapping_address, &mapping_entry, 1);
|
||||
|
||||
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
@@ -190,7 +177,7 @@ ULONG block;
|
||||
|
||||
/* Get the block number from mapping address. */
|
||||
block = (ULONG)(mapping_address - nor_flash -> lx_nor_flash_base_address) / nor_flash -> lx_nor_flash_words_per_block;
|
||||
|
||||
|
||||
/* Determine if this block is within the range of the obsolete count cache. */
|
||||
if (block < nor_flash -> lx_nor_flash_extended_cache_obsolete_count_max_block)
|
||||
{
|
||||
@@ -202,7 +189,7 @@ ULONG block;
|
||||
|
||||
/* Decrement the number of mapped physical sectors. */
|
||||
nor_flash -> lx_nor_flash_mapped_physical_sectors--;
|
||||
|
||||
|
||||
/* Ensure the sector mapping cache no longer has this sector. */
|
||||
_lx_nor_flash_sector_mapping_cache_invalidate(nor_flash, logical_sector);
|
||||
|
||||
@@ -210,7 +197,7 @@ ULONG block;
|
||||
i = 0;
|
||||
while (nor_flash -> lx_nor_flash_free_physical_sectors <= nor_flash -> lx_nor_flash_physical_sectors_per_block)
|
||||
{
|
||||
|
||||
|
||||
/* Attempt to reclaim one physical block. */
|
||||
_lx_nor_flash_block_reclaim(nor_flash);
|
||||
|
||||
@@ -219,8 +206,8 @@ ULONG block;
|
||||
|
||||
/* Have we exceeded the number of blocks in the system? */
|
||||
if (i >= nor_flash -> lx_nor_flash_total_blocks)
|
||||
{
|
||||
|
||||
{
|
||||
|
||||
/* Yes, break out of the loop. */
|
||||
break;
|
||||
}
|
||||
@@ -235,7 +222,7 @@ ULONG block;
|
||||
/* Could not find the logical sector. */
|
||||
status = LX_SECTOR_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
#ifdef LX_THREAD_SAFE_ENABLE
|
||||
|
||||
/* Release the thread safe mutex. */
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NOR Flash */
|
||||
/** */
|
||||
@@ -34,62 +35,48 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_sector_write PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_sector_write PORTABLE C */
|
||||
/* 6.3.0 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function writes a logical sector to the NOR flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* logical_sector Logical sector number */
|
||||
/* buffer Pointer to buffer to write */
|
||||
/* (the size is 512 bytes) */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nor_flash_driver_write Driver flash sector write */
|
||||
/* _lx_nor_flash_driver_read Driver flash sector read */
|
||||
/* _lx_nor_flash_block_reclaim Reclaim one flash block */
|
||||
/* _lx_nor_flash_logical_sector_find Find logical sector */
|
||||
/* _lx_nor_flash_physical_sector_allocate */
|
||||
/* Allocate new physical sector */
|
||||
/* _lx_nor_flash_sector_mapping_cache_invalidate */
|
||||
/* Invalidate cache entry */
|
||||
/* _lx_nor_flash_system_error Internal system error handler */
|
||||
/* tx_mutex_get Get thread protection */
|
||||
/* tx_mutex_put Release thread protection */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* 10-31-2023 Xiuwen Cai Modified comment(s), */
|
||||
/* added mapping bitmap cache, */
|
||||
/* added obsolete count cache, */
|
||||
/* resulting in version 6.3.0 */
|
||||
/* This function writes a logical sector to the NOR flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* logical_sector Logical sector number */
|
||||
/* buffer Pointer to buffer to write */
|
||||
/* (the size is 512 bytes) */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* return status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _lx_nor_flash_driver_write Driver flash sector write */
|
||||
/* _lx_nor_flash_driver_read Driver flash sector read */
|
||||
/* _lx_nor_flash_block_reclaim Reclaim one flash block */
|
||||
/* _lx_nor_flash_logical_sector_find Find logical sector */
|
||||
/* _lx_nor_flash_physical_sector_allocate */
|
||||
/* Allocate new physical sector */
|
||||
/* _lx_nor_flash_sector_mapping_cache_invalidate */
|
||||
/* Invalidate cache entry */
|
||||
/* _lx_nor_flash_system_error Internal system error handler */
|
||||
/* tx_mutex_get Get thread protection */
|
||||
/* tx_mutex_put Release thread protection */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _lx_nor_flash_sector_write(LX_NOR_FLASH *nor_flash, ULONG logical_sector, VOID *buffer)
|
||||
@@ -118,7 +105,7 @@ ULONG block;
|
||||
i = 0;
|
||||
while (nor_flash -> lx_nor_flash_free_physical_sectors <= nor_flash -> lx_nor_flash_physical_sectors_per_block)
|
||||
{
|
||||
|
||||
|
||||
/* Attempt to reclaim one physical block. */
|
||||
_lx_nor_flash_block_reclaim(nor_flash);
|
||||
|
||||
@@ -127,8 +114,8 @@ ULONG block;
|
||||
|
||||
/* Have we exceeded the number of blocks in the system? */
|
||||
if (i >= nor_flash -> lx_nor_flash_total_blocks)
|
||||
{
|
||||
|
||||
{
|
||||
|
||||
/* Yes, break out of the loop. */
|
||||
break;
|
||||
}
|
||||
@@ -139,14 +126,14 @@ ULONG block;
|
||||
|
||||
/* See if we can find the sector in the current mapping. */
|
||||
_lx_nor_flash_logical_sector_find(nor_flash, logical_sector, LX_FALSE, &old_mapping_address, &old_sector_address);
|
||||
|
||||
|
||||
/* Allocate a new physical sector for this write. */
|
||||
_lx_nor_flash_physical_sector_allocate(nor_flash, logical_sector, &new_mapping_address, &new_sector_address);
|
||||
|
||||
/* Determine if the new sector allocation was successful. */
|
||||
if (new_mapping_address)
|
||||
{
|
||||
|
||||
|
||||
/* Yes, we were able to allocate a new physical sector. */
|
||||
|
||||
/* Update the number of free physical sectors. */
|
||||
@@ -158,7 +145,7 @@ ULONG block;
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
@@ -177,10 +164,10 @@ ULONG block;
|
||||
{
|
||||
|
||||
/* Now deprecate the old sector mapping. */
|
||||
|
||||
|
||||
/* Read in the old sector mapping. */
|
||||
#ifdef LX_DIRECT_READ
|
||||
|
||||
|
||||
/* Read the word directly. */
|
||||
old_mapping_entry = *(old_mapping_address);
|
||||
#else
|
||||
@@ -189,7 +176,7 @@ ULONG block;
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
@@ -203,17 +190,17 @@ ULONG block;
|
||||
return(LX_ERROR);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Clear bit 30, which indicates this sector is superceded. */
|
||||
old_mapping_entry = old_mapping_entry & ~((ULONG) LX_NOR_PHYSICAL_SECTOR_SUPERCEDED);
|
||||
|
||||
|
||||
/* Write the value back to the flash to clear bit 30. */
|
||||
status = _lx_nor_flash_driver_write(nor_flash, old_mapping_address, &old_mapping_entry, 1);
|
||||
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
@@ -227,17 +214,17 @@ ULONG block;
|
||||
return(LX_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Now build the new mapping entry - with the not valid bit set initially. */
|
||||
new_mapping_entry = ((ULONG) LX_NOR_PHYSICAL_SECTOR_VALID) | ((ULONG) LX_NOR_PHYSICAL_SECTOR_SUPERCEDED) | ((ULONG) LX_NOR_PHYSICAL_SECTOR_MAPPING_NOT_VALID) | logical_sector;
|
||||
|
||||
|
||||
/* Write out the new mapping entry. */
|
||||
status = _lx_nor_flash_driver_write(nor_flash, new_mapping_address, &new_mapping_entry, 1);
|
||||
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
@@ -251,17 +238,17 @@ ULONG block;
|
||||
return(LX_ERROR);
|
||||
}
|
||||
|
||||
/* Now clear the not valid bit to make this sector mapping valid. This is done because the writing of the extra bytes itself can
|
||||
/* Now clear the not valid bit to make this sector mapping valid. This is done because the writing of the extra bytes itself can
|
||||
be interrupted and we need to make sure this can be detected when the flash is opened again. */
|
||||
new_mapping_entry = new_mapping_entry & ~((ULONG) LX_NOR_PHYSICAL_SECTOR_MAPPING_NOT_VALID);
|
||||
|
||||
|
||||
/* Clear the not valid bit. */
|
||||
status = _lx_nor_flash_driver_write(nor_flash, new_mapping_address, &new_mapping_entry, 1);
|
||||
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
@@ -289,21 +276,21 @@ ULONG block;
|
||||
|
||||
/* Increment the number of mapped physical sectors. */
|
||||
nor_flash -> lx_nor_flash_mapped_physical_sectors++;
|
||||
|
||||
|
||||
/* Was there a previously mapped sector? */
|
||||
if (old_mapping_address)
|
||||
{
|
||||
|
||||
|
||||
/* Now clear bit 31, which indicates this sector is now obsoleted. */
|
||||
old_mapping_entry = old_mapping_entry & ~((ULONG) LX_NOR_PHYSICAL_SECTOR_VALID);
|
||||
|
||||
|
||||
/* Write the value back to the flash to clear bit 31. */
|
||||
status = _lx_nor_flash_driver_write(nor_flash, old_mapping_address, &old_mapping_entry, 1);
|
||||
|
||||
|
||||
/* Check for an error from flash driver. Drivers should never return an error.. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
|
||||
/* Call system error handler. */
|
||||
_lx_nor_flash_system_error(nor_flash, status);
|
||||
|
||||
@@ -336,7 +323,7 @@ ULONG block;
|
||||
|
||||
/* Decrement the number of mapped physical sectors. */
|
||||
nor_flash -> lx_nor_flash_mapped_physical_sectors--;
|
||||
|
||||
|
||||
/* Invalidate the old sector mapping cache entry. */
|
||||
_lx_nor_flash_sector_mapping_cache_invalidate(nor_flash, logical_sector);
|
||||
}
|
||||
@@ -344,9 +331,9 @@ ULONG block;
|
||||
/* Determine if the sector mapping cache is enabled. */
|
||||
if (nor_flash -> lx_nor_flash_sector_mapping_cache_enabled)
|
||||
{
|
||||
|
||||
|
||||
/* Yes, sector mapping cache is enabled, place this sector information in the cache. */
|
||||
|
||||
|
||||
/* Calculate the starting index of the sector mapping cache for this sector entry. */
|
||||
i = (logical_sector & LX_NOR_SECTOR_MAPPING_CACHE_HASH_MASK) * LX_NOR_SECTOR_MAPPING_CACHE_DEPTH;
|
||||
|
||||
@@ -357,7 +344,7 @@ ULONG block;
|
||||
*(sector_mapping_cache_entry_ptr + 3) = *(sector_mapping_cache_entry_ptr + 2);
|
||||
*(sector_mapping_cache_entry_ptr + 2) = *(sector_mapping_cache_entry_ptr + 1);
|
||||
*(sector_mapping_cache_entry_ptr + 1) = *(sector_mapping_cache_entry_ptr);
|
||||
|
||||
|
||||
/* Setup the new sector information in the cache. */
|
||||
sector_mapping_cache_entry_ptr -> lx_nor_sector_mapping_cache_logical_sector = (logical_sector | LX_NOR_SECTOR_MAPPING_CACHE_ENTRY_VALID);
|
||||
sector_mapping_cache_entry_ptr -> lx_nor_sector_mapping_cache_physical_sector_map_entry = new_mapping_address;
|
||||
@@ -365,11 +352,11 @@ ULONG block;
|
||||
}
|
||||
|
||||
/* Indicate the write was successful. */
|
||||
status = LX_SUCCESS;
|
||||
status = LX_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
/* Indicate the write was unsuccessful. */
|
||||
status = LX_NO_SECTORS;
|
||||
}
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NOR Flash Simulator */
|
||||
/** */
|
||||
@@ -134,7 +135,7 @@ UINT _lx_nor_flash_simulator_write(ULONG *flash_address, ULONG *source, ULONG w
|
||||
/* Loop to write flash. */
|
||||
while (words--)
|
||||
{
|
||||
|
||||
|
||||
/* Copy word. */
|
||||
*flash_address++ = *source++;
|
||||
}
|
||||
@@ -164,7 +165,7 @@ ULONG words;
|
||||
words = sizeof(FLASH_BLOCK)/sizeof(ULONG);
|
||||
while (words--)
|
||||
{
|
||||
|
||||
|
||||
/* Erase word of block. */
|
||||
*pointer++ = (ULONG) 0xFFFFFFFF;
|
||||
}
|
||||
@@ -187,7 +188,7 @@ ULONG words;
|
||||
words = sizeof(nor_memory_area)/(sizeof(ULONG));
|
||||
while (words--)
|
||||
{
|
||||
|
||||
|
||||
/* Erase word of block. */
|
||||
*pointer++ = (ULONG) 0xFFFFFFFF;
|
||||
}
|
||||
@@ -211,22 +212,22 @@ ULONG words;
|
||||
#endif
|
||||
|
||||
/* Determine if the block is completely erased. */
|
||||
|
||||
|
||||
/* Pickup the pointer to the first word of the block. */
|
||||
word_ptr = (ULONG *) &nor_memory_area[block].erase_count;
|
||||
|
||||
|
||||
/* Calculate the number of words in a block. */
|
||||
words = sizeof(FLASH_BLOCK)/sizeof(ULONG);
|
||||
|
||||
|
||||
/* Loop to check if the block is erased. */
|
||||
while (words--)
|
||||
{
|
||||
|
||||
|
||||
/* Is this word erased? */
|
||||
if (*word_ptr++ != 0xFFFFFFFF)
|
||||
return(LX_ERROR);
|
||||
}
|
||||
|
||||
|
||||
/* Return success. */
|
||||
return(LX_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
* Copyright (c) 2026-present Eclipse ThreadX contributors
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** LevelX Component */
|
||||
/** */
|
||||
/** NOR Flash */
|
||||
/** */
|
||||
@@ -34,49 +35,36 @@
|
||||
#include "lx_api.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_system_error PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _lx_nor_flash_system_error PORTABLE C */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function handles system errors in the NOR flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* error_code System error code */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* (lx_nor_flash_driver_system_error) Driver system error handler */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 William E. Lamie Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||
/* resulting in version 6.1.7 */
|
||||
/* 03-08-2023 Xiuwen Cai Modified comment(s), */
|
||||
/* added new driver interface, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* This function handles system errors in the NOR flash. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* nor_flash NOR flash instance */
|
||||
/* error_code System error code */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* (lx_nor_flash_driver_system_error) Driver system error handler */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Internal LevelX */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
VOID _lx_nor_flash_system_error(LX_NOR_FLASH *nor_flash, UINT error_code)
|
||||
@@ -84,14 +72,14 @@ VOID _lx_nor_flash_system_error(LX_NOR_FLASH *nor_flash, UINT error_code)
|
||||
|
||||
/* Increment the system error counter. */
|
||||
nor_flash -> lx_nor_flash_diagnostic_system_errors++;
|
||||
|
||||
|
||||
/* Save the most recent system error code. */
|
||||
nor_flash -> lx_nor_flash_diagnostic_system_error = error_code;
|
||||
|
||||
|
||||
/* Determine if the driver has setup a system error handler. */
|
||||
if (nor_flash -> lx_nor_flash_driver_system_error)
|
||||
{
|
||||
|
||||
|
||||
/* Yes, call the driver's system error handler. */
|
||||
#ifdef LX_NOR_ENABLE_CONTROL_BLOCK_FOR_DRIVER_INTERFACE
|
||||
(nor_flash -> lx_nor_flash_driver_system_error)(nor_flash, error_code);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* This is a small demo of the high-performance FileX FAT file system with LevelX
|
||||
/* This is a small demo of the high-performance FileX FAT file system with LevelX
|
||||
and the NAND simulated driver. */
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -9,7 +9,7 @@
|
||||
#define DEMO_STACK_SIZE 4096
|
||||
|
||||
|
||||
/* Buffer for FileX FX_MEDIA sector cache. This must be large enough for at least one
|
||||
/* Buffer for FileX FX_MEDIA sector cache. This must be large enough for at least one
|
||||
sector, which are typically 512 bytes in size. */
|
||||
|
||||
unsigned char media_memory[4096];
|
||||
@@ -23,8 +23,8 @@ VOID _fx_nand_flash_simulator_driver(FX_MEDIA *media_ptr);
|
||||
/* Define LevelX NAND simulated flash erase. */
|
||||
|
||||
UINT _lx_nand_flash_simulator_erase_all(VOID);
|
||||
|
||||
|
||||
|
||||
|
||||
/* Define thread prototypes. */
|
||||
|
||||
void thread_0_entry(ULONG thread_input);
|
||||
@@ -54,8 +54,8 @@ int main(void)
|
||||
#else
|
||||
|
||||
/* Initialize NAND flash. */
|
||||
lx_nand_flash_initialize();
|
||||
|
||||
lx_nand_flash_initialize();
|
||||
|
||||
/* Initialize FileX. */
|
||||
fx_system_initialize();
|
||||
|
||||
@@ -76,13 +76,13 @@ void tx_application_define(void *first_unused_memory)
|
||||
create information. */
|
||||
|
||||
/* Create the main thread. */
|
||||
tx_thread_create(&thread_0, "thread 0", thread_0_entry, 0,
|
||||
thread_0_stack, DEMO_STACK_SIZE,
|
||||
tx_thread_create(&thread_0, "thread 0", thread_0_entry, 0,
|
||||
thread_0_stack, DEMO_STACK_SIZE,
|
||||
1, 1, TX_NO_TIME_SLICE, TX_AUTO_START);
|
||||
|
||||
/* Initialize NAND flash. */
|
||||
lx_nand_flash_initialize();
|
||||
|
||||
lx_nand_flash_initialize();
|
||||
|
||||
/* Initialize FileX. */
|
||||
fx_system_initialize();
|
||||
}
|
||||
@@ -97,27 +97,27 @@ ULONG actual;
|
||||
CHAR local_buffer[30];
|
||||
|
||||
LX_PARAMETER_NOT_USED(thread_input);
|
||||
|
||||
|
||||
/* Erase the simulated NAND flash. */
|
||||
_lx_nand_flash_simulator_erase_all();
|
||||
|
||||
/* Format the NAND disk - the memory for the NAND flash disk is setup in
|
||||
|
||||
/* Format the NAND disk - the memory for the NAND flash disk is setup in
|
||||
the NAND simulator. Note that for best performance, the format of the
|
||||
NAND flash should be less than one full NAND flash block of sectors. */
|
||||
fx_media_format(&nand_disk,
|
||||
fx_media_format(&nand_disk,
|
||||
_fx_nand_flash_simulator_driver, // Driver entry
|
||||
FX_NULL, // Unused
|
||||
media_memory, // Media buffer pointer
|
||||
sizeof(media_memory), // Media buffer size
|
||||
sizeof(media_memory), // Media buffer size
|
||||
"MY_NAND_DISK", // Volume Name
|
||||
1, // Number of FATs
|
||||
32, // Directory Entries
|
||||
0, // Hidden sectors
|
||||
120, // Total sectors
|
||||
2048, // Sector size
|
||||
120, // Total sectors
|
||||
2048, // Sector size
|
||||
1, // Sectors per cluster
|
||||
1, // Heads
|
||||
1); // Sectors per track
|
||||
1); // Sectors per track
|
||||
|
||||
/* Loop to repeat the demo over and over! */
|
||||
do
|
||||
@@ -219,7 +219,7 @@ CHAR local_buffer[30];
|
||||
|
||||
/* Delete the file. */
|
||||
status = fx_file_delete(&nand_disk, "TEST.TXT");
|
||||
|
||||
|
||||
/* Check the file delete status. */
|
||||
if (status != FX_SUCCESS)
|
||||
{
|
||||
@@ -227,7 +227,7 @@ CHAR local_buffer[30];
|
||||
/* Error deleting the file, break the loop. */
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* Close the media. */
|
||||
status = fx_media_close(&nand_disk);
|
||||
|
||||
@@ -243,7 +243,7 @@ CHAR local_buffer[30];
|
||||
of successful passes through this loop. */
|
||||
thread_0_counter++;
|
||||
} while (1);
|
||||
|
||||
|
||||
/* If we get here the FileX test failed! */
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* This is a small demo of the high-performance FileX FAT file system with LevelX
|
||||
/* This is a small demo of the high-performance FileX FAT file system with LevelX
|
||||
and the NOR simulated driver. */
|
||||
|
||||
#include "fx_api.h"
|
||||
@@ -8,7 +8,7 @@
|
||||
#define DEMO_STACK_SIZE 2048
|
||||
|
||||
|
||||
/* Buffer for FileX FX_MEDIA sector cache. This must be large enough for at least one
|
||||
/* Buffer for FileX FX_MEDIA sector cache. This must be large enough for at least one
|
||||
sector, which are typically 512 bytes in size. */
|
||||
|
||||
unsigned char media_memory[512];
|
||||
@@ -22,8 +22,8 @@ VOID _fx_nor_flash_simulator_driver(FX_MEDIA *media_ptr);
|
||||
/* Define LevelX NOR simulated flash erase. */
|
||||
|
||||
UINT _lx_nor_flash_simulator_erase_all(VOID);
|
||||
|
||||
|
||||
|
||||
|
||||
/* Define thread prototypes. */
|
||||
|
||||
void thread_0_entry(ULONG thread_input);
|
||||
@@ -53,8 +53,8 @@ int main(void)
|
||||
#else
|
||||
|
||||
/* Initialize NOR flash. */
|
||||
lx_nor_flash_initialize();
|
||||
|
||||
lx_nor_flash_initialize();
|
||||
|
||||
/* Initialize FileX. */
|
||||
fx_system_initialize();
|
||||
|
||||
@@ -74,13 +74,13 @@ void tx_application_define(void *first_unused_memory)
|
||||
create information. */
|
||||
|
||||
/* Create the main thread. */
|
||||
tx_thread_create(&thread_0, "thread 0", thread_0_entry, 0,
|
||||
thread_0_stack, DEMO_STACK_SIZE,
|
||||
tx_thread_create(&thread_0, "thread 0", thread_0_entry, 0,
|
||||
thread_0_stack, DEMO_STACK_SIZE,
|
||||
1, 1, TX_NO_TIME_SLICE, TX_AUTO_START);
|
||||
|
||||
/* Initialize NOR flash. */
|
||||
lx_nor_flash_initialize();
|
||||
|
||||
lx_nor_flash_initialize();
|
||||
|
||||
/* Initialize FileX. */
|
||||
fx_system_initialize();
|
||||
}
|
||||
@@ -96,27 +96,27 @@ ULONG actual;
|
||||
CHAR local_buffer[30];
|
||||
|
||||
LX_PARAMETER_NOT_USED(thread_input);
|
||||
|
||||
|
||||
/* Erase the simulated NOR flash. */
|
||||
_lx_nor_flash_simulator_erase_all();
|
||||
|
||||
/* Format the NOR disk - the memory for the NOR flash disk is setup in
|
||||
|
||||
/* Format the NOR disk - the memory for the NOR flash disk is setup in
|
||||
the NOR simulator. Note that for best performance, the format of the
|
||||
NOR flash should be less than one full NOR flash block of sectors. */
|
||||
fx_media_format(&nor_disk,
|
||||
fx_media_format(&nor_disk,
|
||||
_fx_nor_flash_simulator_driver, // Driver entry
|
||||
FX_NULL, // Unused
|
||||
media_memory, // Media buffer pointer
|
||||
sizeof(media_memory), // Media buffer size
|
||||
sizeof(media_memory), // Media buffer size
|
||||
"MY_NOR_DISK", // Volume Name
|
||||
1, // Number of FATs
|
||||
32, // Directory Entries
|
||||
0, // Hidden sectors
|
||||
120, // Total sectors
|
||||
512, // Sector size
|
||||
120, // Total sectors
|
||||
512, // Sector size
|
||||
1, // Sectors per cluster
|
||||
1, // Heads
|
||||
1); // Sectors per track
|
||||
1); // Sectors per track
|
||||
|
||||
/* Loop to repeat the demo over and over! */
|
||||
do
|
||||
@@ -218,7 +218,7 @@ CHAR local_buffer[30];
|
||||
|
||||
/* Delete the file. */
|
||||
status = fx_file_delete(&nor_disk, "TEST.TXT");
|
||||
|
||||
|
||||
/* Check the file delete status. */
|
||||
if (status != FX_SUCCESS)
|
||||
{
|
||||
@@ -226,7 +226,7 @@ CHAR local_buffer[30];
|
||||
/* Error deleting the file, break the loop. */
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* Close the media. */
|
||||
status = fx_media_close(&nor_disk);
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ INT CorrectPageECC(UCHAR *data, INT size, UCHAR *code);
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
|
||||
/* Enter the ThreadX kernel. */
|
||||
#ifndef LX_STANDALONE_ENABLE
|
||||
tx_kernel_enter();
|
||||
@@ -82,8 +82,8 @@ void tx_application_define(void *first_unused_memory)
|
||||
|
||||
|
||||
/* Create the main thread. */
|
||||
tx_thread_create(&thread_0, "thread 0", thread_0_entry, 0,
|
||||
thread_0_stack, DEMO_STACK_SIZE,
|
||||
tx_thread_create(&thread_0, "thread 0", thread_0_entry, 0,
|
||||
thread_0_stack, DEMO_STACK_SIZE,
|
||||
1, 1, TX_NO_TIME_SLICE, TX_AUTO_START);
|
||||
}
|
||||
#endif
|
||||
@@ -109,10 +109,10 @@ UINT status;
|
||||
ULONG *word_ptr;
|
||||
UCHAR *byte_ptr;
|
||||
|
||||
|
||||
|
||||
/* Erase the simulated NOR flash. */
|
||||
_lx_nand_flash_simulator_erase_all();
|
||||
|
||||
|
||||
/* Initialize LevelX. */
|
||||
_lx_nand_flash_initialize();
|
||||
|
||||
@@ -145,15 +145,15 @@ UCHAR *byte_ptr;
|
||||
#ifdef EXTENDED_CACHE
|
||||
lx_nand_flash_extended_cache_enable(&nand_sim_flash, cache_memory, sizeof(cache_memory));
|
||||
#endif
|
||||
|
||||
|
||||
/* Write 520 sectors.... */
|
||||
for (i = 0; i < 520; i++)
|
||||
{
|
||||
for (j = 0; j < 512; j++)
|
||||
buffer[j] = i;
|
||||
|
||||
|
||||
status = lx_nand_flash_sector_write(&nand_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -165,7 +165,7 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Close and reopen the flash. */
|
||||
lx_nand_flash_close(&nand_sim_flash);
|
||||
|
||||
@@ -187,9 +187,9 @@ UCHAR *byte_ptr;
|
||||
/* Read back 520 sectors... */
|
||||
for (i = 0; i < 520; i++)
|
||||
{
|
||||
|
||||
|
||||
status = lx_nand_flash_sector_read(&nand_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
#ifdef BATCH_TEST
|
||||
@@ -200,10 +200,10 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (j = 0; j < 128; j++)
|
||||
{
|
||||
|
||||
|
||||
if (buffer[j] != i)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -222,11 +222,11 @@ UCHAR *byte_ptr;
|
||||
|
||||
/* Test 2: Write same sector 320 times. */
|
||||
printf("Test 2: Write same sector 320 times.............");
|
||||
|
||||
/* Reinitialize... */
|
||||
|
||||
/* Reinitialize... */
|
||||
_lx_nand_flash_simulator_erase_all();
|
||||
|
||||
|
||||
|
||||
|
||||
lx_nand_flash_initialize();
|
||||
|
||||
status = lx_nand_flash_format(&nand_sim_flash, "sim nand flash", _lx_nand_flash_simulator_initialize, nand_memory_space, sizeof(nand_memory_space));
|
||||
@@ -236,20 +236,20 @@ UCHAR *byte_ptr;
|
||||
#ifdef EXTENDED_CACHE
|
||||
lx_nand_flash_extended_cache_enable(&nand_sim_flash, cache_memory, sizeof(cache_memory));
|
||||
#endif
|
||||
|
||||
|
||||
for (j = 0; j < 512; j++)
|
||||
buffer[j] = 0xFFFFFFFF;
|
||||
|
||||
|
||||
/* Write same sector 320 sectors.... */
|
||||
for (i = 0; i < 320; i++)
|
||||
{
|
||||
for (j = 0; j < 512; j++)
|
||||
buffer[j] = i;
|
||||
|
||||
|
||||
if (i == 319)
|
||||
buffer[j-1]--;
|
||||
status = lx_nand_flash_sector_write(&nand_sim_flash, 7, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -260,9 +260,9 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nand_flash_sector_read(&nand_sim_flash, 7, readbuffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -273,10 +273,10 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (j = 0; j < 128; j++)
|
||||
{
|
||||
|
||||
|
||||
if (buffer[j] != readbuffer[j])
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -288,7 +288,7 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Write other sectors just to have additional sectors to manage. */
|
||||
if (i == 1)
|
||||
lx_nand_flash_sector_write(&nand_sim_flash, 1, buffer);
|
||||
@@ -310,7 +310,7 @@ UCHAR *byte_ptr;
|
||||
|
||||
status = lx_nand_flash_defragment(&nand_sim_flash);
|
||||
|
||||
|
||||
|
||||
status = lx_nand_flash_sector_read(&nand_sim_flash, 7, readbuffer);
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
@@ -502,7 +502,7 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
|
||||
status = lx_nand_flash_defragment(&nand_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_NOT_SUPPORTED)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -513,9 +513,9 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nand_flash_close(&nand_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -527,7 +527,7 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
}
|
||||
printf("SUCCESS!\n");
|
||||
|
||||
|
||||
printf("Test 3: Page copy test..........................");
|
||||
|
||||
/* Reinitialize... */
|
||||
@@ -612,9 +612,9 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nand_flash_close(&nand_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -760,7 +760,7 @@ UCHAR *byte_ptr;
|
||||
|
||||
while (sector_count--)
|
||||
{
|
||||
|
||||
|
||||
#ifdef FULL_SECTOR_DATA_VERIFY
|
||||
LX_MEMSET((local_data_buffer + sector_number * SECTOR_SIZE), data_byte, SECTOR_SIZE);
|
||||
#else
|
||||
@@ -816,25 +816,25 @@ UCHAR *byte_ptr;
|
||||
#if 0
|
||||
/* Point at the simulated NOR flash memory. */
|
||||
word_ptr = nand_flash_memory;
|
||||
|
||||
|
||||
/* Test 3: Corrupt block 0, simulate a power interruption during erase of block 0,
|
||||
|
||||
|
||||
/* Test 3: Corrupt block 0, simulate a power interruption during erase of block 0,
|
||||
after the erase, but before the erase count is setup. */
|
||||
printf("Test 3: Block erase-initialize interrupted......");
|
||||
word_ptr[0] = 0xFFFFFFFF;
|
||||
word_ptr[3] = 0x00000000; /* This simulates a non-erased block. */
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nand_flash_open(&nand_sim_flash, "sim nor flash", _lx_nand_flash_simulator_initialize, nand_memory_space, sizeof(nand_memory_space));
|
||||
#ifdef EXTENDED_CACHE
|
||||
status += lx_nand_flash_extended_cache_enable(&nand_sim_flash, cache_memory, sizeof(cache_memory));
|
||||
#endif
|
||||
|
||||
|
||||
if ((status != LX_SUCCESS) ||
|
||||
(nand_sim_flash.lx_nand_flash_free_pages != 111) ||
|
||||
(nand_sim_flash.lx_nand_flash_mapped_pages != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -843,9 +843,9 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nand_flash_close(&nand_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -857,22 +857,22 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Corrupt block 0, simulate a power interruption after erase of block 0,
|
||||
|
||||
/* Corrupt block 0, simulate a power interruption after erase of block 0,
|
||||
but before erase count is setup. */
|
||||
word_ptr[0] = 0xFFFFFFFF;
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nand_flash_open(&nand_sim_flash, "sim nor flash", _lx_nand_flash_simulator_initialize, nand_memory_space, sizeof(nand_memory_space));
|
||||
#ifdef EXTENDED_CACHE
|
||||
status += lx_nand_flash_extended_cache_enable(&nand_sim_flash, cache_memory, sizeof(cache_memory));
|
||||
#endif
|
||||
|
||||
|
||||
if ((status != LX_SUCCESS) ||
|
||||
(nand_sim_flash.lx_nand_flash_free_pages != 111) ||
|
||||
(nand_sim_flash.lx_nand_flash_mapped_pages != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -883,7 +883,7 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
|
||||
status = lx_nand_flash_close(&nand_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -899,23 +899,23 @@ UCHAR *byte_ptr;
|
||||
|
||||
/* Test 4: simulate a power interruption while a new page is being setup. */
|
||||
printf("Test 4: Power interrupted new page setup........");
|
||||
|
||||
|
||||
/* Partially setup new page. */
|
||||
byte_ptr = (UCHAR *) word_ptr;
|
||||
byte_ptr[2053] = 0xBF; /* Set block 0/page 0 extra bytes to indicate block not empty. */
|
||||
word_ptr[528] = 0x60;
|
||||
|
||||
/* Open the flash and see if we recover properly. We should mark this page as obsolete. */
|
||||
/* Open the flash and see if we recover properly. We should mark this page as obsolete. */
|
||||
status = lx_nand_flash_open(&nand_sim_flash, "sim nor flash", _lx_nand_flash_simulator_initialize, nand_memory_space, sizeof(nand_memory_space));
|
||||
#ifdef EXTENDED_CACHE
|
||||
status += lx_nand_flash_extended_cache_enable(&nand_sim_flash, cache_memory, sizeof(cache_memory));
|
||||
#endif
|
||||
|
||||
|
||||
if ((status != LX_SUCCESS) ||
|
||||
(nand_sim_flash.lx_nand_flash_free_pages != 110) ||
|
||||
(nand_sim_flash.lx_nand_flash_mapped_pages != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -924,9 +924,9 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nand_flash_close(&nand_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -942,28 +942,28 @@ UCHAR *byte_ptr;
|
||||
/* Simulate a power interruption after a new sector is allocated, after data
|
||||
had been copied, and the superceeded bit is clear, but before the new entry can be
|
||||
setup. */
|
||||
|
||||
|
||||
/* Copy data block and reset spare. */
|
||||
byte_ptr[2053] = 0xBF; /* Set block 0/page 0 extra bytes to indicate block not empty. */
|
||||
for (i = 1; i < 512; i++) /* Fill block 0, page 1 data */
|
||||
word_ptr[i+528] = 0x60;
|
||||
word_ptr[i+528] = 0x60;
|
||||
word_ptr[i+528] = 0xFFFFFFFF; /* Reset extra bytes for block 0, page 1 */
|
||||
word_ptr[i+529] = 0xFFFFFFFF; /* Reset extra bytes for block 0, page 1 */
|
||||
|
||||
word_ptr[i+529] = 0xFFFFFFFF; /* Reset extra bytes for block 0, page 1 */
|
||||
|
||||
/* Set the superceded bit in block 1/page 1. */
|
||||
byte_ptr[37957] = 0x80;
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nand_flash_open(&nand_sim_flash, "sim nor flash", _lx_nand_flash_simulator_initialize, nand_memory_space, sizeof(nand_memory_space));
|
||||
#ifdef EXTENDED_CACHE
|
||||
lx_nand_flash_extended_cache_enable(&nand_sim_flash, cache_memory, sizeof(cache_memory));
|
||||
#endif
|
||||
|
||||
|
||||
if ((status != LX_SUCCESS) ||
|
||||
(nand_sim_flash.lx_nand_flash_free_pages != 110) ||
|
||||
(nand_sim_flash.lx_nand_flash_mapped_pages != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -980,10 +980,10 @@ UCHAR *byte_ptr;
|
||||
has not been invalidated. */
|
||||
byte_ptr[2053] = 0xBF; /* Set block 0/page 0 extra bytes to indicate block not empty. */
|
||||
for (i = 1; i < 512; i++) /* Fill block 0, page 1 data */
|
||||
word_ptr[i+528] = 0x60;
|
||||
word_ptr[i+528] = 0x60;
|
||||
word_ptr[i+528] = 0xFFFFFFFF; /* Reset extra bytes for block 0, page 1 */
|
||||
word_ptr[i+529] = 0xFFFFFFFF; /* Reset extra bytes for block 0, page 1 */
|
||||
|
||||
|
||||
byte_ptr = (UCHAR *) word_ptr;
|
||||
|
||||
/* set the spare info in the new page. */
|
||||
@@ -995,17 +995,17 @@ UCHAR *byte_ptr;
|
||||
/* Set the superceded bit in block 1/page 1. */
|
||||
byte_ptr[37957] = 0x80;
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nand_flash_open(&nand_sim_flash, "sim nor flash", _lx_nand_flash_simulator_initialize, nand_memory_space, sizeof(nand_memory_space));
|
||||
#ifdef EXTENDED_CACHE
|
||||
status += lx_nand_flash_extended_cache_enable(&nand_sim_flash, cache_memory, sizeof(cache_memory));
|
||||
#endif
|
||||
|
||||
|
||||
if ((status != LX_SUCCESS) ||
|
||||
(nand_sim_flash.lx_nand_flash_free_pages != 110) ||
|
||||
(nand_sim_flash.lx_nand_flash_mapped_pages != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -1206,7 +1206,7 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
|
||||
status = lx_nand_flash_defragment(&nand_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_NOT_SUPPORTED)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1217,10 +1217,10 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
status = lx_nand_flash_defragment(&nand_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_NOT_SUPPORTED)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1231,7 +1231,7 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nand_flash_sector_read(&nand_sim_flash, 7, readbuffer);
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
@@ -1612,7 +1612,7 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nand_flash_sector_release(&nand_sim_flash, 7);
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
@@ -1635,9 +1635,9 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nand_flash_defragment(&nand_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1661,7 +1661,7 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
printf("SUCCESS!\n");
|
||||
#endif
|
||||
#if 0
|
||||
@@ -1670,15 +1670,15 @@ UCHAR *byte_ptr;
|
||||
/* Erase the simulated NOR flash. */
|
||||
_lx_nand_flash_simulator_erase_all();
|
||||
|
||||
/* Open the flash. */
|
||||
/* Open the flash. */
|
||||
status = lx_nand_flash_open(&nand_sim_flash, "sim nor flash", _lx_nand_flash_simulator_initialize, nand_memory_space, sizeof(nand_memory_space));
|
||||
#ifdef EXTENDED_CACHE
|
||||
status += lx_nand_flash_extended_cache_enable(&nand_sim_flash, cache_memory, sizeof(cache_memory));
|
||||
#endif
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -1687,15 +1687,15 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Write 100 sectors.... */
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
for (j = 0; j < 512; j++)
|
||||
buffer[j] = i;
|
||||
|
||||
|
||||
status = lx_nand_flash_sector_write(&nand_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1707,13 +1707,13 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Read back 100 sectors... */
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
|
||||
|
||||
status = lx_nand_flash_sector_read(&nand_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1724,10 +1724,10 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (j = 0; j < 512; j++)
|
||||
{
|
||||
|
||||
|
||||
if (buffer[j] != i)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1740,18 +1740,18 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Now, perform 1000 sector writes to randomly selected sectors, each time
|
||||
reading first to make sure the previous contents are valid. */
|
||||
for (i = 0; i < 1000; i++)
|
||||
{
|
||||
|
||||
|
||||
/* Pickup random sector. */
|
||||
sector = (rand() % 100);
|
||||
|
||||
/* Read that sector. */
|
||||
status = lx_nand_flash_sector_read(&nand_sim_flash, sector, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1762,10 +1762,10 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (j = 0; j < 512; j++)
|
||||
{
|
||||
|
||||
|
||||
if ((buffer[j] & 0x0000FFFF) != sector)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1781,10 +1781,10 @@ UCHAR *byte_ptr;
|
||||
/* Include the itteraction in the buffer to generate a new write. */
|
||||
for (j = 0; j < 512; j++)
|
||||
{
|
||||
|
||||
|
||||
buffer[j] = (buffer[j] & 0x0000FFFF) | (i << 16);
|
||||
}
|
||||
|
||||
|
||||
status = lx_nand_flash_sector_write(&nand_sim_flash, sector, buffer);
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
@@ -1798,9 +1798,9 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nand_flash_close(&nand_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1813,22 +1813,22 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
printf("SUCCESS!\n");
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
|
||||
|
||||
/* Setup buffer. */
|
||||
for (j = 0; j < 2048; j++)
|
||||
byte_buffer[j] = (UCHAR) (rand() % 256);
|
||||
|
||||
|
||||
/* Call the ECC calculate routine. */
|
||||
ComputePageECC(byte_buffer, 2048, ecc_bytes);
|
||||
status = (UINT) CorrectPageECC(byte_buffer, 2048, ecc_bytes);
|
||||
if (status != 0)
|
||||
{
|
||||
|
||||
|
||||
/* Check for corrected return value. */
|
||||
if (status != 1)
|
||||
{
|
||||
@@ -1837,7 +1837,7 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Call LevelX ECC routines to do the same thing. */
|
||||
status = lx_nand_flash_page_ecc_compute(&nand_sim_flash, byte_buffer, lx_ecc_buffer);
|
||||
|
||||
@@ -1851,17 +1851,17 @@ UCHAR *byte_ptr;
|
||||
|
||||
// ComputePageECC(byte_buffer, 2048, ecc_bytes);
|
||||
|
||||
|
||||
|
||||
/* Determine if there is any difference between the original and the new ECC routine. */
|
||||
if ((ecc_bytes[0] != lx_ecc_buffer[0]) ||
|
||||
if ((ecc_bytes[0] != lx_ecc_buffer[0]) ||
|
||||
(ecc_bytes[1] != lx_ecc_buffer[1]) ||
|
||||
(ecc_bytes[2] != lx_ecc_buffer[2]) ||
|
||||
(ecc_bytes[3] != lx_ecc_buffer[3]) ||
|
||||
(ecc_bytes[4] != lx_ecc_buffer[4]) ||
|
||||
(ecc_bytes[5] != lx_ecc_buffer[5]) ||
|
||||
(ecc_bytes[6] != lx_ecc_buffer[6]) ||
|
||||
(ecc_bytes[7] != lx_ecc_buffer[7]) ||
|
||||
(ecc_bytes[8] != lx_ecc_buffer[8]) ||
|
||||
(ecc_bytes[7] != lx_ecc_buffer[7]) ||
|
||||
(ecc_bytes[8] != lx_ecc_buffer[8]) ||
|
||||
(ecc_bytes[9] != lx_ecc_buffer[9]) ||
|
||||
(ecc_bytes[10] != lx_ecc_buffer[10]) ||
|
||||
(ecc_bytes[11] != lx_ecc_buffer[11]))
|
||||
@@ -1875,7 +1875,7 @@ UCHAR *byte_ptr;
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
/* Is it the corrected status? */
|
||||
if (status != LX_NAND_ERROR_CORRECTED)
|
||||
{
|
||||
@@ -1888,23 +1888,23 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#if 0
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
|
||||
|
||||
/* Setup buffer. */
|
||||
for (j = 0; j < 2048; j++)
|
||||
byte_buffer[j] = (UCHAR) (rand() % 256);
|
||||
|
||||
|
||||
/* Call the ECC calculate routine. */
|
||||
ComputePageECC(byte_buffer, 2048, ecc_bytes);
|
||||
|
||||
|
||||
/* Corrupt a bit in each 256 byte page. */
|
||||
if (byte_buffer[7] & 1)
|
||||
byte_buffer[7] = byte_buffer[7] & 0xFE;
|
||||
else
|
||||
byte_buffer[7] = byte_buffer[7] | 1;
|
||||
|
||||
|
||||
if (byte_buffer[277] & 1)
|
||||
byte_buffer[277] = byte_buffer[277] & 0xFE;
|
||||
else
|
||||
@@ -1914,12 +1914,12 @@ UCHAR *byte_ptr;
|
||||
byte_buffer[577] = byte_buffer[577] & 0xFE;
|
||||
else
|
||||
byte_buffer[577] = byte_buffer[577] | 1;
|
||||
|
||||
|
||||
if (byte_buffer[777] & 1)
|
||||
byte_buffer[777] = byte_buffer[777] & 0xFE;
|
||||
else
|
||||
byte_buffer[777] = byte_buffer[777] | 1;
|
||||
|
||||
|
||||
if (byte_buffer[1077] & 1)
|
||||
byte_buffer[1077] = byte_buffer[1077] & 0xFE;
|
||||
else
|
||||
@@ -1929,7 +1929,7 @@ UCHAR *byte_ptr;
|
||||
byte_buffer[1297] = byte_buffer[1297] & 0xFE;
|
||||
else
|
||||
byte_buffer[1297] = byte_buffer[1297] | 1;
|
||||
|
||||
|
||||
if (byte_buffer[1636] & 1)
|
||||
byte_buffer[1636] = byte_buffer[1636] & 0xFE;
|
||||
else
|
||||
@@ -1939,12 +1939,12 @@ UCHAR *byte_ptr;
|
||||
byte_buffer[1892] = byte_buffer[1892] & 0xFE;
|
||||
else
|
||||
byte_buffer[1892] = byte_buffer[1892] | 1;
|
||||
|
||||
|
||||
|
||||
|
||||
status = (UINT) CorrectPageECC(byte_buffer, 2048, ecc_bytes);
|
||||
if (status != 0)
|
||||
{
|
||||
|
||||
|
||||
/* Check for corrected return value. */
|
||||
if (status != 1)
|
||||
{
|
||||
@@ -1953,7 +1953,7 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Call LevelX ECC routines to do the same thing. */
|
||||
status = lx_nand_flash_page_ecc_compute(&nand_sim_flash, byte_buffer, lx_ecc_buffer);
|
||||
|
||||
@@ -1966,17 +1966,17 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Determine if there is any difference between the original and the new ECC routine. */
|
||||
if ((ecc_bytes[0] != lx_ecc_buffer[0]) ||
|
||||
if ((ecc_bytes[0] != lx_ecc_buffer[0]) ||
|
||||
(ecc_bytes[1] != lx_ecc_buffer[1]) ||
|
||||
(ecc_bytes[2] != lx_ecc_buffer[2]) ||
|
||||
(ecc_bytes[3] != lx_ecc_buffer[3]) ||
|
||||
(ecc_bytes[4] != lx_ecc_buffer[4]) ||
|
||||
(ecc_bytes[5] != lx_ecc_buffer[5]) ||
|
||||
(ecc_bytes[6] != lx_ecc_buffer[6]) ||
|
||||
(ecc_bytes[7] != lx_ecc_buffer[7]) ||
|
||||
(ecc_bytes[8] != lx_ecc_buffer[8]) ||
|
||||
(ecc_bytes[7] != lx_ecc_buffer[7]) ||
|
||||
(ecc_bytes[8] != lx_ecc_buffer[8]) ||
|
||||
(ecc_bytes[9] != lx_ecc_buffer[9]) ||
|
||||
(ecc_bytes[10] != lx_ecc_buffer[10]) ||
|
||||
(ecc_bytes[11] != lx_ecc_buffer[11]))
|
||||
@@ -1991,7 +1991,7 @@ UCHAR *byte_ptr;
|
||||
byte_buffer[7] = byte_buffer[7] & 0xFE;
|
||||
else
|
||||
byte_buffer[7] = byte_buffer[7] | 1;
|
||||
|
||||
|
||||
if (byte_buffer[277] & 1)
|
||||
byte_buffer[277] = byte_buffer[277] & 0xFE;
|
||||
else
|
||||
@@ -2001,12 +2001,12 @@ UCHAR *byte_ptr;
|
||||
byte_buffer[577] = byte_buffer[577] & 0xFE;
|
||||
else
|
||||
byte_buffer[577] = byte_buffer[577] | 1;
|
||||
|
||||
|
||||
if (byte_buffer[777] & 1)
|
||||
byte_buffer[777] = byte_buffer[777] & 0xFE;
|
||||
else
|
||||
byte_buffer[777] = byte_buffer[777] | 1;
|
||||
|
||||
|
||||
if (byte_buffer[1077] & 1)
|
||||
byte_buffer[1077] = byte_buffer[1077] & 0xFE;
|
||||
else
|
||||
@@ -2016,7 +2016,7 @@ UCHAR *byte_ptr;
|
||||
byte_buffer[1297] = byte_buffer[1297] & 0xFE;
|
||||
else
|
||||
byte_buffer[1297] = byte_buffer[1297] | 1;
|
||||
|
||||
|
||||
if (byte_buffer[1636] & 1)
|
||||
byte_buffer[1636] = byte_buffer[1636] & 0xFE;
|
||||
else
|
||||
@@ -2026,12 +2026,12 @@ UCHAR *byte_ptr;
|
||||
byte_buffer[1892] = byte_buffer[1892] & 0xFE;
|
||||
else
|
||||
byte_buffer[1892] = byte_buffer[1892] | 1;
|
||||
|
||||
|
||||
status = lx_nand_flash_page_ecc_check(&nand_sim_flash, byte_buffer, lx_ecc_buffer);
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
/* Is it the corrected status? */
|
||||
if (status != LX_NAND_ERROR_CORRECTED)
|
||||
{
|
||||
@@ -2064,22 +2064,22 @@ UCHAR *byte_ptr;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
|
||||
#if 0
|
||||
|
||||
/* Corrupting ECC code is detected and returns a failure... this test is not valid! */
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
|
||||
|
||||
/* Setup buffer. */
|
||||
for (j = 0; j < 2048; j++)
|
||||
byte_buffer[j] = (UCHAR) (rand() % 256);
|
||||
|
||||
|
||||
/* Call the ECC calculate routine. */
|
||||
ComputePageECC(byte_buffer, 2048, ecc_bytes);
|
||||
|
||||
|
||||
|
||||
|
||||
/* Call LevelX ECC routines to do the same thing. */
|
||||
status = lx_nand_flash_page_ecc_compute(&nand_sim_flash, byte_buffer, lx_ecc_buffer);
|
||||
|
||||
@@ -2092,15 +2092,15 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
|
||||
/* Determine if there is any difference between the original and the new ECC routine. */
|
||||
if ((ecc_bytes[0] != lx_ecc_buffer[0]) ||
|
||||
if ((ecc_bytes[0] != lx_ecc_buffer[0]) ||
|
||||
(ecc_bytes[1] != lx_ecc_buffer[1]) ||
|
||||
(ecc_bytes[2] != lx_ecc_buffer[2]) ||
|
||||
(ecc_bytes[3] != lx_ecc_buffer[3]) ||
|
||||
(ecc_bytes[4] != lx_ecc_buffer[4]) ||
|
||||
(ecc_bytes[5] != lx_ecc_buffer[5]) ||
|
||||
(ecc_bytes[6] != lx_ecc_buffer[6]) ||
|
||||
(ecc_bytes[7] != lx_ecc_buffer[7]) ||
|
||||
(ecc_bytes[8] != lx_ecc_buffer[8]) ||
|
||||
(ecc_bytes[7] != lx_ecc_buffer[7]) ||
|
||||
(ecc_bytes[8] != lx_ecc_buffer[8]) ||
|
||||
(ecc_bytes[9] != lx_ecc_buffer[9]) ||
|
||||
(ecc_bytes[10] != lx_ecc_buffer[10]) ||
|
||||
(ecc_bytes[11] != lx_ecc_buffer[11]))
|
||||
@@ -2115,7 +2115,7 @@ UCHAR *byte_ptr;
|
||||
ecc_bytes[1] = ecc_bytes[1] & 0xFE;
|
||||
else
|
||||
ecc_bytes[1] = ecc_bytes[1] | 1;
|
||||
|
||||
|
||||
if (ecc_bytes[4] & 1)
|
||||
ecc_bytes[4] = ecc_bytes[4] & 0xFE;
|
||||
else
|
||||
@@ -2125,12 +2125,12 @@ UCHAR *byte_ptr;
|
||||
ecc_bytes[7] = ecc_bytes[7] & 0xFE;
|
||||
else
|
||||
ecc_bytes[7] = ecc_bytes[7] | 1;
|
||||
|
||||
|
||||
if (ecc_bytes[10] & 1)
|
||||
ecc_bytes[10] = ecc_bytes[10] & 0xFE;
|
||||
else
|
||||
ecc_bytes[10] = ecc_bytes[10] | 1;
|
||||
|
||||
|
||||
if (ecc_bytes[13] & 1)
|
||||
ecc_bytes[13] = ecc_bytes[13] & 0xFE;
|
||||
else
|
||||
@@ -2140,7 +2140,7 @@ UCHAR *byte_ptr;
|
||||
ecc_bytes[16] = ecc_bytes[16] & 0xFE;
|
||||
else
|
||||
ecc_bytes[16] = ecc_bytes[16] | 1;
|
||||
|
||||
|
||||
if (ecc_bytes[19] & 1)
|
||||
ecc_bytes[19] = ecc_bytes[19] & 0xFE;
|
||||
else
|
||||
@@ -2150,12 +2150,12 @@ UCHAR *byte_ptr;
|
||||
ecc_bytes[22] = ecc_bytes[22] & 0xFE;
|
||||
else
|
||||
ecc_bytes[22] = ecc_bytes[22] | 1;
|
||||
|
||||
|
||||
|
||||
|
||||
status = (UINT) CorrectPageECC(byte_buffer, 2048, ecc_bytes);
|
||||
if (status != 0)
|
||||
{
|
||||
|
||||
|
||||
/* Check for corrected return value. */
|
||||
if (status != 1)
|
||||
{
|
||||
@@ -2170,7 +2170,7 @@ UCHAR *byte_ptr;
|
||||
lx_ecc_buffer[1] = lx_ecc_buffer[1] & 0xFE;
|
||||
else
|
||||
lx_ecc_buffer[1] = lx_ecc_buffer[1] | 1;
|
||||
|
||||
|
||||
if (lx_ecc_buffer[4] & 1)
|
||||
lx_ecc_buffer[4] = lx_ecc_buffer[4] & 0xFE;
|
||||
else
|
||||
@@ -2180,12 +2180,12 @@ UCHAR *byte_ptr;
|
||||
lx_ecc_buffer[7] = lx_ecc_buffer[7] & 0xFE;
|
||||
else
|
||||
lx_ecc_buffer[7] = lx_ecc_buffer[7] | 1;
|
||||
|
||||
|
||||
if (lx_ecc_buffer[10] & 1)
|
||||
lx_ecc_buffer[10] = lx_ecc_buffer[10] & 0xFE;
|
||||
else
|
||||
lx_ecc_buffer[10] = lx_ecc_buffer[10] | 1;
|
||||
|
||||
|
||||
if (lx_ecc_buffer[13] & 1)
|
||||
lx_ecc_buffer[13] = lx_ecc_buffer[13] & 0xFE;
|
||||
else
|
||||
@@ -2195,7 +2195,7 @@ UCHAR *byte_ptr;
|
||||
lx_ecc_buffer[16] = lx_ecc_buffer[16] & 0xFE;
|
||||
else
|
||||
lx_ecc_buffer[16] = lx_ecc_buffer[16] | 1;
|
||||
|
||||
|
||||
if (lx_ecc_buffer[19] & 1)
|
||||
lx_ecc_buffer[19] = lx_ecc_buffer[19] & 0xFE;
|
||||
else
|
||||
@@ -2205,14 +2205,14 @@ UCHAR *byte_ptr;
|
||||
lx_ecc_buffer[22] = lx_ecc_buffer[22] & 0xFE;
|
||||
else
|
||||
lx_ecc_buffer[22] = lx_ecc_buffer[22] | 1;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
status = lx_nand_flash_page_ecc_check(&nand_sim_flash, byte_buffer, lx_ecc_buffer);
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
/* Is it the corrected status? */
|
||||
if (status != LX_NAND_ERROR_CORRECTED)
|
||||
{
|
||||
@@ -2245,24 +2245,24 @@ UCHAR *byte_ptr;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
/* TEST FileX packing routines. */
|
||||
|
||||
/* Erase the simulated NAND flash. */
|
||||
_lx_nand_flash_simulator_erase_all();
|
||||
|
||||
/* Open the flash. */
|
||||
/* Open the flash. */
|
||||
status = lx_nand_flash_open(&nand_sim_flash, "sim nor flash", _lx_nand_flash_simulator_initialize);
|
||||
#ifdef EXTENDED_CACHE
|
||||
status += lx_nand_flash_extended_cache_enable(&nand_sim_flash, cache_memory, sizeof(cache_memory));
|
||||
#endif
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
while(1)
|
||||
{
|
||||
@@ -2294,7 +2294,7 @@ UCHAR *byte_ptr;
|
||||
{
|
||||
_fx_nand_flash_read_sectors(i, 1, (UCHAR *) &test_read[i].words[0]);
|
||||
}
|
||||
|
||||
|
||||
/* Setup the read buffer. */
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
@@ -2315,9 +2315,9 @@ UCHAR *byte_ptr;
|
||||
|
||||
_fx_nand_flash_read_sectors(0, 8, (UCHAR *) &test_read[0].words[0]);
|
||||
|
||||
|
||||
|
||||
status = lx_nand_flash_close(&nand_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -2329,15 +2329,15 @@ UCHAR *byte_ptr;
|
||||
/* Erase the simulated NAND flash. */
|
||||
_lx_nand_flash_simulator_erase_all();
|
||||
|
||||
/* Open the flash. */
|
||||
/* Open the flash. */
|
||||
status = lx_nand_flash_open(&nand_sim_flash, "sim nor flash", _lx_nand_flash_simulator_initialize);
|
||||
#ifdef EXTENDED_CACHE
|
||||
status += lx_nand_flash_extended_cache_enable(&nand_sim_flash, cache_memory, sizeof(cache_memory));
|
||||
#endif
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
while(1)
|
||||
{
|
||||
@@ -2360,7 +2360,7 @@ UCHAR *byte_ptr;
|
||||
_fx_nand_flash_read_sectors(3, 5, (UCHAR *) &test_read[3].words[0]);
|
||||
|
||||
status = lx_nand_flash_close(&nand_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -2369,9 +2369,9 @@ UCHAR *byte_ptr;
|
||||
}
|
||||
}
|
||||
|
||||
/* End */
|
||||
#endif
|
||||
|
||||
/* End */
|
||||
#endif
|
||||
|
||||
#ifdef BATCH_TEST
|
||||
exit(0);
|
||||
#endif
|
||||
|
||||
@@ -35,7 +35,7 @@ void thread_0_entry(ULONG thread_input);
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
|
||||
/* Enter the ThreadX kernel. */
|
||||
#ifndef LX_STANDALONE_ENABLE
|
||||
tx_kernel_enter();
|
||||
@@ -52,8 +52,8 @@ void tx_application_define(void *first_unused_memory)
|
||||
|
||||
|
||||
/* Create the main thread. */
|
||||
tx_thread_create(&thread_0, "thread 0", thread_0_entry, 0,
|
||||
thread_0_stack, DEMO_STACK_SIZE,
|
||||
tx_thread_create(&thread_0, "thread 0", thread_0_entry, 0,
|
||||
thread_0_stack, DEMO_STACK_SIZE,
|
||||
1, 1, TX_NO_TIME_SLICE, TX_AUTO_START);
|
||||
}
|
||||
#endif
|
||||
@@ -68,27 +68,27 @@ UINT status;
|
||||
|
||||
ULONG *word_ptr;
|
||||
|
||||
|
||||
|
||||
/* format the simulated NOR flash. */
|
||||
|
||||
|
||||
/* Initialize LevelX. */
|
||||
_lx_nor_flash_initialize();
|
||||
|
||||
|
||||
lx_nor_flash_format(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize, NULL);
|
||||
|
||||
/* Test 1: Simple write 100 sectors and read 100 sectors. */
|
||||
printf("Test 1: Simple write-read 100 sectors...........");
|
||||
|
||||
|
||||
lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
|
||||
|
||||
/* Write 100 sectors.... */
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
for (j = 0; j < 128; j++)
|
||||
buffer[j] = i;
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_write(&nor_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -100,13 +100,13 @@ ULONG *word_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Read back 100 sectors... */
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -117,10 +117,10 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (j = 0; j < 128; j++)
|
||||
{
|
||||
|
||||
|
||||
if (buffer[j] != i)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -139,9 +139,9 @@ ULONG *word_ptr;
|
||||
|
||||
/* Test 2: Write same sector 120 times. */
|
||||
printf("Test 2: Write same sector 120 times.............");
|
||||
|
||||
/* Reinitialize... */
|
||||
|
||||
|
||||
/* Reinitialize... */
|
||||
|
||||
lx_nor_flash_initialize();
|
||||
lx_nor_flash_format(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize, NULL);
|
||||
|
||||
@@ -149,15 +149,15 @@ ULONG *word_ptr;
|
||||
|
||||
for (j = 0; j < 128; j++)
|
||||
buffer[j] = 0xFFFFFFFF;
|
||||
|
||||
|
||||
/* Write same sector 120 sectors.... */
|
||||
for (i = 0; i < 120; i++)
|
||||
{
|
||||
for (j = 0; j < 128; j++)
|
||||
buffer[j] = i;
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_write(&nor_sim_flash, 7, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -168,9 +168,9 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, 7, readbuffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -181,10 +181,10 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (j = 0; j < 128; j++)
|
||||
{
|
||||
|
||||
|
||||
if (buffer[j] != readbuffer[j])
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -196,7 +196,7 @@ ULONG *word_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Write other sectors just to have additional sectors to manage. */
|
||||
if (i == 1)
|
||||
lx_nor_flash_sector_write(&nor_sim_flash, 1, buffer);
|
||||
@@ -218,7 +218,7 @@ ULONG *word_ptr;
|
||||
|
||||
status = lx_nor_flash_defragment(&nor_sim_flash);
|
||||
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, 7, readbuffer);
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
@@ -410,7 +410,7 @@ ULONG *word_ptr;
|
||||
}
|
||||
|
||||
status = lx_nor_flash_defragment(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -421,13 +421,13 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Point at the simulated NOR flash memory. */
|
||||
word_ptr = nor_sim_flash.lx_nor_flash_base_address;
|
||||
|
||||
|
||||
status = lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -439,21 +439,21 @@ ULONG *word_ptr;
|
||||
}
|
||||
}
|
||||
printf("SUCCESS!\n");
|
||||
|
||||
/* Test 3: Corrupt block 0, simulate a power interruption during erase of block 0,
|
||||
|
||||
/* Test 3: Corrupt block 0, simulate a power interruption during erase of block 0,
|
||||
after the erase, but before the free bit map and erase count is setup. */
|
||||
printf("Test 3: Block erase-initialize interrupted......");
|
||||
word_ptr[0] = 0xFFFFFFFF;
|
||||
word_ptr[3] = 0xFFFFFFFF;
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
|
||||
if ((status != LX_SUCCESS) ||
|
||||
(nor_sim_flash.lx_nor_flash_free_physical_sectors != 111) ||
|
||||
(nor_sim_flash.lx_nor_flash_mapped_physical_sectors != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -462,9 +462,9 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -475,19 +475,19 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/* Corrupt block 0, simulate a power interruption during erase of block 0,
|
||||
|
||||
/* Corrupt block 0, simulate a power interruption during erase of block 0,
|
||||
after the erase, and after the free bit map setup, but before erase count is setup. */
|
||||
word_ptr[0] = 0xFFFFFFFF;
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
|
||||
if ((status != LX_SUCCESS) ||
|
||||
(nor_sim_flash.lx_nor_flash_free_physical_sectors != 111) ||
|
||||
(nor_sim_flash.lx_nor_flash_mapped_physical_sectors != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -498,7 +498,7 @@ ULONG *word_ptr;
|
||||
}
|
||||
|
||||
status = lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -516,14 +516,14 @@ ULONG *word_ptr;
|
||||
printf("Test 4: Power interrupted new block allocation..");
|
||||
word_ptr[3] = word_ptr[3] & ~((ULONG) 1);
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
|
||||
if ((status != LX_SUCCESS) ||
|
||||
(nor_sim_flash.lx_nor_flash_free_physical_sectors != 110) ||
|
||||
(nor_sim_flash.lx_nor_flash_mapped_physical_sectors != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -532,9 +532,9 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -550,14 +550,14 @@ ULONG *word_ptr;
|
||||
anything else can be done. */
|
||||
word_ptr[(16*128)+3] = 0x7C00;
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
|
||||
if ((status != LX_SUCCESS) ||
|
||||
(nor_sim_flash.lx_nor_flash_free_physical_sectors != 109) ||
|
||||
(nor_sim_flash.lx_nor_flash_mapped_physical_sectors != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -568,7 +568,7 @@ ULONG *word_ptr;
|
||||
}
|
||||
|
||||
status = lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -585,15 +585,15 @@ ULONG *word_ptr;
|
||||
setup. */
|
||||
word_ptr[3] = 0x7FFC;
|
||||
word_ptr[(16*128)+6] = word_ptr[(16*128)+6] & ~((ULONG) 0x40000000);
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
|
||||
if ((status != LX_SUCCESS) ||
|
||||
(nor_sim_flash.lx_nor_flash_free_physical_sectors != 108) ||
|
||||
(nor_sim_flash.lx_nor_flash_mapped_physical_sectors != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -604,7 +604,7 @@ ULONG *word_ptr;
|
||||
}
|
||||
|
||||
lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
/* Simulate a power interruption after a new sector is allocated, after data
|
||||
had been copied, and the superceeded bit is clear, the new entry is setup, but the old entry
|
||||
has not been invalidated. */
|
||||
@@ -614,15 +614,15 @@ ULONG *word_ptr;
|
||||
{
|
||||
word_ptr[(3*128)+i] = 0x70;
|
||||
}
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
|
||||
if ((status != LX_SUCCESS) ||
|
||||
(nor_sim_flash.lx_nor_flash_free_physical_sectors != 107) ||
|
||||
(nor_sim_flash.lx_nor_flash_mapped_physical_sectors != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -823,7 +823,7 @@ ULONG *word_ptr;
|
||||
}
|
||||
|
||||
status = lx_nor_flash_defragment(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -834,10 +834,10 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
status = lx_nor_flash_defragment(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -848,7 +848,7 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, 7, readbuffer);
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
@@ -1229,7 +1229,7 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_release(&nor_sim_flash, 7);
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
@@ -1252,9 +1252,9 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_defragment(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1278,7 +1278,7 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
printf("SUCCESS!\n");
|
||||
|
||||
printf("Test 5: Randow write/read sector................");
|
||||
@@ -1286,12 +1286,12 @@ ULONG *word_ptr;
|
||||
/* format the simulated NOR flash. */
|
||||
|
||||
lx_nor_flash_format(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize, NULL);
|
||||
/* Open the flash. */
|
||||
/* Open the flash. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -1300,15 +1300,15 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Write 100 sectors.... */
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
for (j = 0; j < 128; j++)
|
||||
buffer[j] = i;
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_write(&nor_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1320,13 +1320,13 @@ ULONG *word_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Read back 100 sectors... */
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1337,10 +1337,10 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (j = 0; j < 128; j++)
|
||||
{
|
||||
|
||||
|
||||
if (buffer[j] != i)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1353,18 +1353,18 @@ ULONG *word_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Now, perform 1000 sector writes to randomly selected sectors, each time
|
||||
reading first to make sure the previous contents are valid. */
|
||||
for (i = 0; i < 1000; i++)
|
||||
{
|
||||
|
||||
|
||||
/* Pickup random sector. */
|
||||
sector = (rand() % 100);
|
||||
|
||||
/* Read that sector. */
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, sector, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1375,10 +1375,10 @@ ULONG *word_ptr;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (j = 0; j < 128; j++)
|
||||
{
|
||||
|
||||
|
||||
if ((buffer[j] & 0x0000FFFF) != sector)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1394,10 +1394,10 @@ ULONG *word_ptr;
|
||||
/* Include the itteraction in the buffer to generate a new write. */
|
||||
for (j = 0; j < 128; j++)
|
||||
{
|
||||
|
||||
|
||||
buffer[j] = (buffer[j] & 0x0000FFFF) | (i << 16);
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_write(&nor_sim_flash, sector, buffer);
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
@@ -1411,9 +1411,9 @@ ULONG *word_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
|
||||
@@ -38,7 +38,7 @@ void thread_0_entry(ULONG thread_input);
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
|
||||
/* Enter the ThreadX kernel. */
|
||||
#ifndef LX_STANDALONE_ENABLE
|
||||
tx_kernel_enter();
|
||||
@@ -56,8 +56,8 @@ void tx_application_define(void *first_unused_memory)
|
||||
|
||||
|
||||
/* Create the main thread. */
|
||||
tx_thread_create(&thread_0, "thread 0", thread_0_entry, 0,
|
||||
thread_0_stack, DEMO_STACK_SIZE,
|
||||
tx_thread_create(&thread_0, "thread 0", thread_0_entry, 0,
|
||||
thread_0_stack, DEMO_STACK_SIZE,
|
||||
1, 1, TX_NO_TIME_SLICE, TX_AUTO_START);
|
||||
}
|
||||
#endif
|
||||
@@ -72,13 +72,13 @@ UINT status;
|
||||
|
||||
ULONG *word_ptr;
|
||||
|
||||
|
||||
|
||||
/* Initialize LevelX. */
|
||||
_lx_nor_flash_initialize();
|
||||
|
||||
|
||||
/* Test 1: Simple write 100 sectors and read 100 sectors. */
|
||||
printf("Test 1: Simple write-read 100 sectors...........");
|
||||
|
||||
|
||||
lx_nor_flash_format(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize, NULL);
|
||||
lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
#ifndef LX_NOR_DISABLE_EXTENDED_CACHE
|
||||
@@ -115,9 +115,9 @@ lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_
|
||||
{
|
||||
for (j = 0; j < 128; j++)
|
||||
buffer[j] = i;
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_write(&nor_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -129,13 +129,13 @@ lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Read back 100 sectors... */
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -146,10 +146,10 @@ lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (j = 0; j < 128; j++)
|
||||
{
|
||||
|
||||
|
||||
if (buffer[j] != i)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -198,9 +198,9 @@ lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_
|
||||
/* Release 100 sectors... */
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_release(&nor_sim_flash, i);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -262,9 +262,9 @@ lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_
|
||||
|
||||
/* Test 2: Write same sector 120 times. */
|
||||
printf("Test 2: Write same sector 120 times.............");
|
||||
|
||||
/* Reinitialize... */
|
||||
|
||||
|
||||
/* Reinitialize... */
|
||||
|
||||
lx_nor_flash_initialize();
|
||||
lx_nor_flash_format(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize, NULL);
|
||||
lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
@@ -274,15 +274,15 @@ lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_
|
||||
|
||||
for (j = 0; j < 128; j++)
|
||||
buffer[j] = 0xFFFFFFFF;
|
||||
|
||||
|
||||
/* Write same sector 120 sectors.... */
|
||||
for (i = 0; i < 120; i++)
|
||||
{
|
||||
for (j = 0; j < 128; j++)
|
||||
buffer[j] = i;
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_write(&nor_sim_flash, 7, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -293,9 +293,9 @@ lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, 7, readbuffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -306,10 +306,10 @@ lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (j = 0; j < 128; j++)
|
||||
{
|
||||
|
||||
|
||||
if (buffer[j] != readbuffer[j])
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -321,7 +321,7 @@ lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Write other sectors just to have additional sectors to manage. */
|
||||
if (i == 1)
|
||||
lx_nor_flash_sector_write(&nor_sim_flash, 1, buffer);
|
||||
@@ -343,7 +343,7 @@ lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_
|
||||
|
||||
status = lx_nor_flash_defragment(&nor_sim_flash);
|
||||
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, 7, readbuffer);
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
@@ -535,7 +535,7 @@ lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_
|
||||
}
|
||||
|
||||
status = lx_nor_flash_defragment(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -546,13 +546,13 @@ lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Point at the simulated NOR flash memory. */
|
||||
word_ptr = nor_sim_flash.lx_nor_flash_base_address;
|
||||
|
||||
|
||||
status = lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -564,14 +564,14 @@ lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_
|
||||
}
|
||||
}
|
||||
printf("SUCCESS!\n");
|
||||
|
||||
/* Test 3: Corrupt block 0, simulate a power interruption during erase of block 0,
|
||||
|
||||
/* Test 3: Corrupt block 0, simulate a power interruption during erase of block 0,
|
||||
after the erase, but before the free bit map and erase count is setup. */
|
||||
printf("Test 3: Block erase-initialize interrupted......");
|
||||
word_ptr[0] = 0xFFFFFFFF;
|
||||
word_ptr[3] = 0xFFFFFFFF;
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
#ifndef LX_NOR_DISABLE_EXTENDED_CACHE
|
||||
status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_cache_memory));
|
||||
@@ -581,7 +581,7 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
(nor_sim_flash.lx_nor_flash_free_physical_sectors != 111) ||
|
||||
(nor_sim_flash.lx_nor_flash_mapped_physical_sectors != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -590,9 +590,9 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -603,12 +603,12 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/* Corrupt block 0, simulate a power interruption during erase of block 0,
|
||||
|
||||
/* Corrupt block 0, simulate a power interruption during erase of block 0,
|
||||
after the erase, and after the free bit map setup, but before erase count is setup. */
|
||||
word_ptr[0] = 0xFFFFFFFF;
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
#ifndef LX_NOR_DISABLE_EXTENDED_CACHE
|
||||
status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_cache_memory));
|
||||
@@ -618,7 +618,7 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
(nor_sim_flash.lx_nor_flash_free_physical_sectors != 111) ||
|
||||
(nor_sim_flash.lx_nor_flash_mapped_physical_sectors != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -629,7 +629,7 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
}
|
||||
|
||||
status = lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -647,7 +647,7 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
printf("Test 4: Power interrupted new block allocation..");
|
||||
word_ptr[3] = word_ptr[3] & ~((ULONG) 1);
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
#ifndef LX_NOR_DISABLE_EXTENDED_CACHE
|
||||
status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_cache_memory));
|
||||
@@ -657,7 +657,7 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
(nor_sim_flash.lx_nor_flash_free_physical_sectors != 110) ||
|
||||
(nor_sim_flash.lx_nor_flash_mapped_physical_sectors != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -666,9 +666,9 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -684,7 +684,7 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
anything else can be done. */
|
||||
word_ptr[(16*128)+3] = 0x7C00;
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
#ifndef LX_NOR_DISABLE_EXTENDED_CACHE
|
||||
status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_cache_memory));
|
||||
@@ -694,7 +694,7 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
(nor_sim_flash.lx_nor_flash_free_physical_sectors != 109) ||
|
||||
(nor_sim_flash.lx_nor_flash_mapped_physical_sectors != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -705,7 +705,7 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
}
|
||||
|
||||
status = lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -722,8 +722,8 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
setup. */
|
||||
word_ptr[3] = 0x7FFC;
|
||||
word_ptr[(16*128)+6] = word_ptr[(16*128)+6] & ~((ULONG) 0x40000000);
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
#ifndef LX_NOR_DISABLE_EXTENDED_CACHE
|
||||
status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_cache_memory));
|
||||
@@ -733,7 +733,7 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
(nor_sim_flash.lx_nor_flash_free_physical_sectors != 108) ||
|
||||
(nor_sim_flash.lx_nor_flash_mapped_physical_sectors != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -744,7 +744,7 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
}
|
||||
|
||||
lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
/* Simulate a power interruption after a new sector is allocated, after data
|
||||
had been copied, and the superceeded bit is clear, the new entry is setup, but the old entry
|
||||
has not been invalidated. */
|
||||
@@ -754,8 +754,8 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
{
|
||||
word_ptr[(3*128)+i] = 0x70;
|
||||
}
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
|
||||
/* Open the flash and see if we recover properly. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
#ifndef LX_NOR_DISABLE_EXTENDED_CACHE
|
||||
status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_cache_memory));
|
||||
@@ -765,7 +765,7 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
(nor_sim_flash.lx_nor_flash_free_physical_sectors != 107) ||
|
||||
(nor_sim_flash.lx_nor_flash_mapped_physical_sectors != 9))
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -966,7 +966,7 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
}
|
||||
|
||||
status = lx_nor_flash_defragment(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -977,10 +977,10 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
status = lx_nor_flash_defragment(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -991,7 +991,7 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, 7, readbuffer);
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
@@ -1372,7 +1372,7 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_release(&nor_sim_flash, 7);
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
@@ -1395,9 +1395,9 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_defragment(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1421,24 +1421,24 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
printf("SUCCESS!\n");
|
||||
|
||||
printf("Test 5: Randow write/read sector................");
|
||||
|
||||
/*format the simulated NOR flash. */
|
||||
|
||||
|
||||
/* Open the flash. */
|
||||
|
||||
/* Open the flash. */
|
||||
status = lx_nor_flash_format(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize, NULL);
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
#ifndef LX_NOR_DISABLE_EXTENDED_CACHE
|
||||
status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, sizeof(nor_cache_memory));
|
||||
#endif
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -1447,15 +1447,15 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Write 100 sectors.... */
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
for (j = 0; j < 128; j++)
|
||||
buffer[j] = i;
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_write(&nor_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1467,13 +1467,13 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Read back 100 sectors... */
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1484,10 +1484,10 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (j = 0; j < 128; j++)
|
||||
{
|
||||
|
||||
|
||||
if (buffer[j] != i)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1500,18 +1500,18 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Now, perform 1000 sector writes to randomly selected sectors, each time
|
||||
reading first to make sure the previous contents are valid. */
|
||||
for (i = 0; i < 1000; i++)
|
||||
{
|
||||
|
||||
|
||||
/* Pickup random sector. */
|
||||
sector = (rand() % 100);
|
||||
|
||||
/* Read that sector. */
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, sector, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1522,10 +1522,10 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (j = 0; j < 128; j++)
|
||||
{
|
||||
|
||||
|
||||
if ((buffer[j] & 0x0000FFFF) != sector)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1541,10 +1541,10 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
/* Include the itteraction in the buffer to generate a new write. */
|
||||
for (j = 0; j < 128; j++)
|
||||
{
|
||||
|
||||
|
||||
buffer[j] = (buffer[j] & 0x0000FFFF) | (i << 16);
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_write(&nor_sim_flash, sector, buffer);
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
@@ -1558,9 +1558,9 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = lx_nor_flash_close(&nor_sim_flash);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1578,15 +1578,15 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory, s
|
||||
/* Format the simulated NOR flash. */
|
||||
status = lx_nor_flash_format(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize, NULL);
|
||||
|
||||
/* Open the flash. */
|
||||
/* Open the flash. */
|
||||
status = lx_nor_flash_open(&nor_sim_flash, "sim nor flash", _lx_nor_flash_simulator_initialize);
|
||||
#ifndef LX_NOR_DISABLE_EXTENDED_CACHE
|
||||
status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory2, sizeof(nor_cache_memory2));
|
||||
#endif
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
|
||||
|
||||
printf("FAILED!\n");
|
||||
#ifdef BATCH_TEST
|
||||
exit(1);
|
||||
@@ -1601,9 +1601,9 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory2,
|
||||
{
|
||||
for (j = 0; j < 128; j++)
|
||||
buffer[j] = i;
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_write(&nor_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1615,13 +1615,13 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory2,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Read back 100 sectors... */
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
|
||||
|
||||
status = lx_nor_flash_sector_read(&nor_sim_flash, i, buffer);
|
||||
|
||||
|
||||
if (status != LX_SUCCESS)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1632,10 +1632,10 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory2,
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (j = 0; j < 128; j++)
|
||||
{
|
||||
|
||||
|
||||
if (buffer[j] != i)
|
||||
{
|
||||
printf("FAILED!\n");
|
||||
@@ -1648,7 +1648,7 @@ status += lx_nor_flash_extended_cache_enable(&nor_sim_flash, nor_cache_memory2,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef BATCH_TEST
|
||||
exit(0);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user