diff --git a/common/inc/lx_api.h b/common/inc/lx_api.h index 1753a52..69bc51e 100644 --- a/common/inc/lx_api.h +++ b/common/inc/lx_api.h @@ -26,7 +26,7 @@ /* APPLICATION INTERFACE DEFINITION RELEASE */ /* */ /* lx_api.h PORTABLE C */ -/* 6.1 */ +/* 6.1.2 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ @@ -45,6 +45,10 @@ /* 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 */ /* */ /**************************************************************************/ @@ -52,10 +56,32 @@ #define LX_API_H +/* Determine if a C++ compiler is being used. If so, ensure that standard + C is used to process the API information. */ + +#ifdef __cplusplus + +/* Yes, C++ compiler is present. Use standard C. */ +extern "C" { + +#endif + /* Include necessary system files. */ #include "tx_api.h" +/* Determine if the optional LevelX user define file should be used. */ + +#ifdef LX_INCLUDE_USER_DEFINE_FILE + + +/* 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" +#endif + + /* Disable warning of parameter not used. */ #ifndef LX_PARAMETER_NOT_USED #define LX_PARAMETER_NOT_USED(p) ((void)(p)) @@ -66,7 +92,7 @@ #define AZURE_RTOS_LEVELX #define LEVELX_MAJOR_VERSION 6 #define LEVELX_MINOR_VERSION 1 -#define LEVELX_PATCH_VERSION 0 +#define LEVELX_PATCH_VERSION 2 /* Define general LevelX Constants. */ @@ -536,5 +562,10 @@ UINT _lx_nor_flash_physical_sector_allocate(LX_NOR_FLASH *nor_flash, ULONG lo VOID _lx_nor_flash_sector_mapping_cache_invalidate(LX_NOR_FLASH *nor_flash, ULONG logical_sector); VOID _lx_nor_flash_system_error(LX_NOR_FLASH *nor_flash, UINT error_code); + +#ifdef __cplusplus +} +#endif + #endif diff --git a/common/inc/lx_user_sample.h b/common/inc/lx_user_sample.h new file mode 100644 index 0000000..f388c10 --- /dev/null +++ b/common/inc/lx_user_sample.h @@ -0,0 +1,119 @@ +/**************************************************************************/ +/* */ +/* Copyright (c) Microsoft Corporation. All rights reserved. */ +/* */ +/* This software is licensed under the Microsoft Software License */ +/* Terms for Microsoft Azure RTOS. Full text of the license can be */ +/* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ +/* and in the root directory of this software. */ +/* */ +/**************************************************************************/ + + +/**************************************************************************/ +/**************************************************************************/ +/** */ +/** LevelX Component */ +/** */ +/** User Specific */ +/** */ +/**************************************************************************/ +/**************************************************************************/ + + +/**************************************************************************/ +/* */ +/* PORT SPECIFIC C INFORMATION RELEASE */ +/* */ +/* lx_user.h PORTABLE C */ +/* 6.1.2 */ +/* */ +/* AUTHOR */ +/* */ +/* William E. Lamie, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ +/* This file contains user defines for configuring LevelX in specific */ +/* ways. This file will have an effect only if the application and */ +/* LevelX library are built with LX_INCLUDE_USER_DEFINE_FILE defined. */ +/* 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 */ +/* */ +/**************************************************************************/ + +#ifndef LX_USER_H +#define LX_USER_H + + + +/* 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 + sectors are all ones. +*/ +/* +#define LX_FREE_SECTOR_DATA_VERIFY +*/ + +/* By default this value is 128 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_NAND_SECTOR_MAPPING_CACHE_SIZE 128 +*/ + +/* Defined, this creates a direct mapping cache, such that there are no cache misses. + It also requires that LX_NAND_SECTOR_MAPPING_CACHE_SIZE represents the exact number + of total pages in your flash device. +*/ +/* +#define LX_NAND_FLASH_DIRECT_MAPPING_CACHE +*/ + + +/* Defined, this disabled the extended NOR cache. */ +/* +#define LX_NOR_DISABLE_EXTENDED_CACHE +*/ + +/* 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 +*/ + + +/* 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 + throughout the API. +*/ +/* +#define LX_THREAD_SAFE_ENABLE +*/ + + + +#endif + diff --git a/common/src/lx_nor_flash_open.c b/common/src/lx_nor_flash_open.c index ab6a290..c57eaac 100644 --- a/common/src/lx_nor_flash_open.c +++ b/common/src/lx_nor_flash_open.c @@ -40,7 +40,7 @@ /* FUNCTION RELEASE */ /* */ /* _lx_nor_flash_open PORTABLE C */ -/* 6.1 */ +/* 6.1.2 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ @@ -83,6 +83,9 @@ /* 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 */ /* */ /**************************************************************************/ UINT _lx_nor_flash_open(LX_NOR_FLASH *nor_flash, CHAR *name, UINT (*nor_driver_initialize)(LX_NOR_FLASH *)) @@ -101,7 +104,7 @@ ULONG used_sectors; ULONG *new_map_entry; ULONG *new_sector_address; ULONG erased_count, min_erased_count, max_erased_count, temp_erased_count; -ULONG i, j, k; +ULONG j, k, l; UINT status; #ifdef LX_FREE_SECTOR_DATA_VERIFY ULONG *sector_word_ptr; @@ -208,7 +211,7 @@ TX_INTERRUPT_SAVE_AREA block_word_ptr = nor_flash -> lx_nor_flash_base_address; /* Loop through the blocks to determine the minimum and maximum erase count. */ - for (i = 0; i < nor_flash -> lx_nor_flash_total_blocks; i++) + for (l = 0; l < nor_flash -> lx_nor_flash_total_blocks; l++) { /* Pickup the first word of the block. If the flash manager has executed before, this word contains the @@ -277,7 +280,7 @@ TX_INTERRUPT_SAVE_AREA block_word_ptr = nor_flash -> lx_nor_flash_base_address; /* Loop through the blocks to setup the flash the fist time. */ - for (i = 0; i < nor_flash -> lx_nor_flash_total_blocks; i++) + for (l = 0; l < nor_flash -> lx_nor_flash_total_blocks; l++) { /* Setup the free bit map that corresponds to the free physical sectors in this @@ -338,7 +341,7 @@ TX_INTERRUPT_SAVE_AREA block_word_ptr = nor_flash -> lx_nor_flash_base_address; /* Loop through the blocks. */ - for (i = 0; i < nor_flash -> lx_nor_flash_total_blocks; i++) + for (l = 0; l < nor_flash -> lx_nor_flash_total_blocks; l++) { /* First, determine if this block has a valid erase count. */ @@ -384,7 +387,7 @@ TX_INTERRUPT_SAVE_AREA nor_flash -> lx_nor_flash_diagnostic_erased_block++; /* Check to see if the block is erased. */ - status = (nor_flash -> lx_nor_flash_driver_block_erased_verify)(i); + status = (nor_flash -> lx_nor_flash_driver_block_erased_verify)(l); /* Is the block completely erased? */ if (status != LX_SUCCESS) @@ -406,7 +409,7 @@ TX_INTERRUPT_SAVE_AREA nor_flash -> lx_nor_flash_diagnostic_re_erase_block++; /* No, the block is not fully erased, erase it again. */ - status = _lx_nor_flash_driver_block_erase(nor_flash, i, max_erased_count); + status = _lx_nor_flash_driver_block_erase(nor_flash, l, max_erased_count); /* Check for an error from flash driver. Drivers should never return an error.. */ if (status) @@ -511,7 +514,7 @@ TX_INTERRUPT_SAVE_AREA { /* Remember the block with free sectors. */ - nor_flash -> lx_nor_flash_free_block_search = i; + nor_flash -> lx_nor_flash_free_block_search = l; } }