URL
https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk
Subversion Repositories openrisc_me
Compare Revisions
- This comparison shows the changes necessary to convert path
/openrisc/trunk/rtos/ecos-2.0/packages/io/flash/v2_0
- from Rev 27 to Rev 174
- ↔ Reverse comparison
Rev 27 → Rev 174
/cdl/io_flash.cdl
0,0 → 1,158
# ==================================================================== |
# |
# io_flash.cdl |
# |
# eCos IO configuration data |
# |
# ==================================================================== |
#####ECOSGPLCOPYRIGHTBEGIN#### |
## ------------------------------------------- |
## This file is part of eCos, the Embedded Configurable Operating System. |
## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
## |
## eCos is free software; you can redistribute it and/or modify it under |
## the terms of the GNU General Public License as published by the Free |
## Software Foundation; either version 2 or (at your option) any later version. |
## |
## eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
## WARRANTY; without even the implied warranty of MERCHANTABILITY or |
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
## for more details. |
## |
## You should have received a copy of the GNU General Public License along |
## with eCos; if not, write to the Free Software Foundation, Inc., |
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
## |
## As a special exception, if other files instantiate templates or use macros |
## or inline functions from this file, or you compile this file and link it |
## with other works to produce a work based on this file, this file does not |
## by itself cause the resulting work to be covered by the GNU General Public |
## License. However the source code for this file must still be made available |
## in accordance with section (3) of the GNU General Public License. |
## |
## This exception does not invalidate any other reasons why a work based on |
## this file might be covered by the GNU General Public License. |
## |
## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
## at http://sources.redhat.com/ecos/ecos-license/ |
## ------------------------------------------- |
#####ECOSGPLCOPYRIGHTEND#### |
# ==================================================================== |
######DESCRIPTIONBEGIN#### |
# |
# Author(s): gthomas |
# Original data: gthomas |
# Contributors: |
# Date: 2000-07-06 |
# |
#####DESCRIPTIONEND#### |
# |
# ==================================================================== |
|
cdl_package CYGPKG_IO_FLASH { |
display "FLASH device drivers" |
include_dir cyg/io |
description " |
This option enables drivers for basic I/O services on |
flash devices." |
requires CYGPKG_ISOINFRA |
requires CYGINT_ISO_STRING_STRFUNCS |
|
compile flash.c |
|
define_proc { |
puts $::cdl_header "#include <pkgconf/system.h>" |
puts $::cdl_header "#ifdef CYGDAT_IO_FLASH_DEVICE_HEADER" |
puts $::cdl_header "# include CYGDAT_IO_FLASH_DEVICE_HEADER" |
puts $::cdl_header "#endif " |
} |
|
cdl_option CYGNUM_FLASH_WORKSPACE_SIZE { |
display "Extra memory required by FLASH device drivers" |
flavor data |
default_value 0x1000 |
description " |
Use this option to control how much extra memory is used |
by the FLASH drivers to perform certain operations. This |
memory is used to hold driver functions in RAM (for platforms |
which require it). The value should thus be large enough |
to hold any such driver. Reducing this value will make |
more RAM available to general programs." |
} |
|
cdl_interface CYGHWR_IO_FLASH_DEVICE { |
display "Hardware FLASH device drivers" |
description " |
This option enables the hardware device drivers |
for the current platform." |
} |
|
cdl_interface CYGHWR_IO_FLASH_DEVICE_NOT_IN_RAM { |
display "Hardware FLASH device drivers are not in RAM" |
flavor booldata |
description " |
This option makes the IO driver copy the device |
driver functions to RAM before calling them. Newer |
drivers should make sure that the functions are |
linked to RAM by putting them in .2ram sections." |
} |
|
cdl_interface CYGHWR_IO_FLASH_BLOCK_LOCKING { |
display "Hardware can support block locking" |
flavor booldata |
description " |
This option will be enabled by devices which can support |
locking (write-protection) of individual blocks." |
} |
|
cdl_option CYGSEM_IO_FLASH_VERIFY_PROGRAM { |
display "Verify data programmed to flash" |
flavor bool |
default_value 1 |
description " |
Selecting this option will cause verification of data |
programmed to flash." |
} |
cdl_option CYGSEM_IO_FLASH_SOFT_WRITE_PROTECT { |
display "Platform has flash soft DIP switch write-protect" |
flavor bool |
default_value 0 |
description " |
Selecting this option will cause the state of a hardware jumper or |
dipswitch to be read by software to determine whether the flash is |
write-protected or not." |
} |
cdl_component CYGPKG_IO_FLASH_BLOCK_DEVICE { |
display "Instantiate in I/O block device API" |
flavor bool |
active_if CYGPKG_IO |
default_value 0 |
compile -library=libextras.a flashiodev.c |
description " |
Provides a block device accessible using the standard I/O |
API ( cyg_io_read() etc. )" |
|
cdl_component CYGDAT_IO_FLASH_BLOCK_DEVICE_NAME_1 { |
display "Name of flash device 1 block device" |
flavor data |
default_value { "\"/dev/flash1\"" } |
|
cdl_option CYGNUM_IO_FLASH_BLOCK_OFFSET_1 { |
display "Start offset from flash base" |
flavor data |
default_value 0x100000 |
description " |
This gives the offset from the base of flash which this |
block device corresponds to." |
} |
cdl_option CYGNUM_IO_FLASH_BLOCK_LENGTH_1 { |
display "Length" |
flavor data |
default_value 0x100000 |
description " |
This gives the length of the region of flash given over |
to this block device." |
} |
} |
} |
} |
/include/flash_dev.h
0,0 → 1,166
#ifndef CYGONCE_IO_FLASH_FLASH_DEV_H |
#define CYGONCE_IO_FLASH_FLASH_DEV_H |
//========================================================================== |
// |
// flash_dev.h |
// |
// Common flash device driver definitions |
// |
//========================================================================== |
//####ECOSGPLCOPYRIGHTBEGIN#### |
// ------------------------------------------- |
// This file is part of eCos, the Embedded Configurable Operating System. |
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
// |
// eCos is free software; you can redistribute it and/or modify it under |
// the terms of the GNU General Public License as published by the Free |
// Software Foundation; either version 2 or (at your option) any later version. |
// |
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
// for more details. |
// |
// You should have received a copy of the GNU General Public License along |
// with eCos; if not, write to the Free Software Foundation, Inc., |
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
// |
// As a special exception, if other files instantiate templates or use macros |
// or inline functions from this file, or you compile this file and link it |
// with other works to produce a work based on this file, this file does not |
// by itself cause the resulting work to be covered by the GNU General Public |
// License. However the source code for this file must still be made available |
// in accordance with section (3) of the GNU General Public License. |
// |
// This exception does not invalidate any other reasons why a work based on |
// this file might be covered by the GNU General Public License. |
// |
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
// at http://sources.redhat.com/ecos/ecos-license/ |
// ------------------------------------------- |
//####ECOSGPLCOPYRIGHTEND#### |
//========================================================================== |
//#####DESCRIPTIONBEGIN#### |
// |
// Author(s): hmt |
// Contributors: hmt, jskov, Jose Pascual <josepascual@almudi.com> |
// Date: 2001-02-22 |
// Purpose: Define common flash device driver definitions |
// Description: The flash_data_t type is used for accessing |
// devices at the correct width. |
// The FLASHWORD macro must be used to create constants |
// of suitable width. |
// The FLASH_P2V macro can be used to fix up non-linear |
// mappings of flash blocks (defaults to a linear |
// implementation). |
// |
//####DESCRIPTIONEND#### |
// |
//========================================================================== |
|
#ifdef _FLASH_PRIVATE_ |
|
// ------------------------------------------------------------------------ |
// |
// No mapping on this target - but these casts would be needed if some |
// manipulation did occur. An example of this might be: |
// // First 4K page of flash at physical address zero is |
// // virtually mapped at address 0xa0000000. |
// #define FLASH_P2V(x) ((volatile flash_t *)(((unsigned)(x) < 0x1000) ? |
// ((unsigned)(x) | 0xa0000000) : |
// (unsigned)(x))) |
|
#ifndef FLASH_P2V |
#define FLASH_P2V( _a_ ) ((volatile flash_t *)((CYG_ADDRWORD)(_a_))) |
#endif |
|
// ------------------------------------------------------------------------ |
// |
// This generic code is intended to deal with all shapes and orientations |
// of Intel StrataFlash. Trademarks &c belong to their respective owners. |
// |
// It therefore needs some trickery to define the constants and accessor |
// types that we use to interact with the device or devices. |
// |
// The assumptions are that |
// o Parallel devices, we write to, with the "opcode" replicated per |
// device |
// o The "opcode" and status returns exist only in the low byte of the |
// device's interface regardless of its width. |
// o Hence opcodes and status are only one byte. |
// An exception is the test for succesfully erased data. |
// |
// ------------------------------------------------------------------------ |
|
#if 8 == CYGNUM_FLASH_WIDTH |
|
# if 1 == CYGNUM_FLASH_INTERLEAVE |
# define FLASHWORD( k ) ((flash_data_t)(k)) // To narrow a 16-bit constant |
typedef cyg_uint8 flash_data_t; |
# elif 2 == CYGNUM_FLASH_INTERLEAVE |
// 2 devices to make 16-bit |
# define FLASHWORD( k ) ((k)+((k)<<8)) |
typedef cyg_uint16 flash_data_t; |
# elif 4 == CYGNUM_FLASH_INTERLEAVE |
// 4 devices to make 32-bit |
# define FLASHWORD( k ) ((k)+((k)<<8)+((k)<<16)+((k)<<24)) |
typedef cyg_uint32 flash_data_t; |
# elif 8 == CYGNUM_FLASH_INTERLEAVE |
// 8 devices to make 64-bit - intermediate requires explicit widening |
# define FLASHWORD32( k ) ((flash_data_t)((k)+((k)<<8)+((k)<<16)+((k)<<24))) |
# define FLASHWORD( k ) (FLASHWORD32( k ) + (FLASHWORD32( k ) << 32)); |
typedef cyg_uint64 flash_data_t; |
# else |
# error How many 8-bit flash devices? |
# endif |
|
#elif 16 == CYGNUM_FLASH_WIDTH |
|
# if 1 == CYGNUM_FLASH_INTERLEAVE |
# define FLASHWORD( k ) (k) |
typedef cyg_uint16 flash_data_t; |
# elif 2 == CYGNUM_FLASH_INTERLEAVE |
// 2 devices to make 32-bit |
# define FLASHWORD( k ) ((k)+((k)<<16)) |
typedef cyg_uint32 flash_data_t; |
# elif 4 == CYGNUM_FLASH_INTERLEAVE |
// 4 devices to make 64-bit - intermediate requires explicit widening |
# define FLASHWORD32( k ) ((flash_data_t)((k)+((k)<<16))) |
# define FLASHWORD( k ) (FLASHWORD32( k ) + (FLASHWORD32( k ) << 32)); |
typedef cyg_uint64 flash_data_t; |
# else |
# error How many 16-bit flash devices? |
# endif |
|
#elif 32 == CYGNUM_FLASH_WIDTH |
|
# if 1 == CYGNUM_FLASH_INTERLEAVE |
# define FLASHWORD( k ) (k) |
typedef cyg_uint32 flash_data_t; |
# elif 2 == CYGNUM_FLASH_INTERLEAVE |
// 2 devices to make 64-bit - intermediate requires explicit widening |
# define FLASHWORD32( k ) ((flash_data_t)(k)) |
# define FLASHWORD( k ) (FLASHWORD32( k ) + (FLASHWORD32( k ) << 32)); |
typedef cyg_uint64 flash_data_t; |
# else |
# error How many 32-bit flash devices? |
# endif |
|
#else |
# error What flash width? |
#endif |
|
// Data (not) that we read back: |
#if 0 == CYGNUM_FLASH_BLANK |
# define FLASH_BlankValue ((flash_data_t)0) |
#elif 1 == CYGNUM_FLASH_BLANK |
# define FLASH_BlankValue ((flash_data_t)(-1ll)) |
#else |
# error What blank value? |
#endif |
|
#endif // _FLASH_PRIVATE_ |
|
#endif // CYGONCE_IO_FLASH_FLASH_DEV_H |
//---------------------------------------------------------------------------- |
// end of flash_dev.h |
/include/flash.h
0,0 → 1,243
//========================================================================== |
// |
// flash.h |
// |
// Flash programming - external interfaces |
// |
//========================================================================== |
//####ECOSGPLCOPYRIGHTBEGIN#### |
// ------------------------------------------- |
// This file is part of eCos, the Embedded Configurable Operating System. |
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
// |
// eCos is free software; you can redistribute it and/or modify it under |
// the terms of the GNU General Public License as published by the Free |
// Software Foundation; either version 2 or (at your option) any later version. |
// |
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
// for more details. |
// |
// You should have received a copy of the GNU General Public License along |
// with eCos; if not, write to the Free Software Foundation, Inc., |
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
// |
// As a special exception, if other files instantiate templates or use macros |
// or inline functions from this file, or you compile this file and link it |
// with other works to produce a work based on this file, this file does not |
// by itself cause the resulting work to be covered by the GNU General Public |
// License. However the source code for this file must still be made available |
// in accordance with section (3) of the GNU General Public License. |
// |
// This exception does not invalidate any other reasons why a work based on |
// this file might be covered by the GNU General Public License. |
// |
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
// at http://sources.redhat.com/ecos/ecos-license/ |
// ------------------------------------------- |
//####ECOSGPLCOPYRIGHTEND#### |
//========================================================================== |
//#####DESCRIPTIONBEGIN#### |
// |
// Author(s): gthomas |
// Contributors: gthomas |
// Date: 2000-07-14 |
// Purpose: |
// Description: |
// |
//####DESCRIPTIONEND#### |
// |
//========================================================================== |
|
#ifndef _IO_FLASH_H_ |
#define _IO_FLASH_H_ |
|
#include <pkgconf/io_flash.h> |
#include <cyg/hal/hal_cache.h> |
|
typedef int _printf(const char *fmt, ...); |
|
#define FLASH_MIN_WORKSPACE CYGNUM_FLASH_WORKSPACE_SIZE // Space used by FLASH code |
|
externC int flash_init(void *work_space, int work_space_length, _printf *pf); |
externC int flash_erase(void *base, int len, void **err_address); |
externC int flash_program(void *flash_base, void *ram_base, int len, void **err_address); |
externC void flash_dev_query(void *data); |
#ifdef CYGHWR_IO_FLASH_BLOCK_LOCKING |
externC int flash_lock(void *base, int len, void **err_address); |
externC int flash_unlock(void *base, int len, void **err_address); |
#endif |
externC int flash_verify_addr(void *base); |
externC int flash_get_limits(void *base, void **start, void **end); |
externC int flash_get_block_info(int *block_size, int *blocks); |
externC bool flash_code_overlaps(void *start, void *end); |
externC char *flash_errmsg(int err); |
|
#define FLASH_ERR_OK 0x00 // No error - operation complete |
#define FLASH_ERR_INVALID 0x01 // Invalid FLASH address |
#define FLASH_ERR_ERASE 0x02 // Error trying to erase |
#define FLASH_ERR_LOCK 0x03 // Error trying to lock/unlock |
#define FLASH_ERR_PROGRAM 0x04 // Error trying to program |
#define FLASH_ERR_PROTOCOL 0x05 // Generic error |
#define FLASH_ERR_PROTECT 0x06 // Device/region is write-protected |
#define FLASH_ERR_NOT_INIT 0x07 // FLASH info not yet initialized |
#define FLASH_ERR_HWR 0x08 // Hardware (configuration?) problem |
#define FLASH_ERR_ERASE_SUSPEND 0x09 // Device is in erase suspend mode |
#define FLASH_ERR_PROGRAM_SUSPEND 0x0a // Device is in in program suspend mode |
#define FLASH_ERR_DRV_VERIFY 0x0b // Driver failed to verify data |
#define FLASH_ERR_DRV_TIMEOUT 0x0c // Driver timed out waiting for device |
#define FLASH_ERR_DRV_WRONG_PART 0x0d // Driver does not support device |
#define FLASH_ERR_LOW_VOLTAGE 0x0e // Not enough juice to complete job |
|
#ifdef CYGPKG_IO_FLASH_BLOCK_DEVICE |
typedef struct { |
CYG_ADDRESS offset; |
int len; |
int flasherr; |
void **err_address; |
} cyg_io_flash_getconfig_erase_t; |
|
typedef struct { |
int dev_size; |
} cyg_io_flash_getconfig_devsize_t; |
|
typedef struct { |
CYG_ADDRESS offset; |
int block_size; |
} cyg_io_flash_getconfig_blocksize_t; |
#endif |
|
#ifdef _FLASH_PRIVATE_ |
|
struct flash_info { |
void *work_space; |
int work_space_size; |
int block_size; // Assuming fixed size "blocks" |
int blocks; // Number of blocks |
int buffer_size; // Size of write buffer (only defined for some devices) |
unsigned long block_mask; |
void *start, *end; // Address range |
int init; |
_printf *pf; |
}; |
|
externC struct flash_info flash_info; |
externC int flash_hwr_init(void); |
externC int flash_hwr_map_error(int err); |
|
// |
// Some FLASH devices may require additional support, e.g. to turn on |
// appropriate voltage drivers, before any operation. |
// |
#ifdef CYGIMP_FLASH_ENABLE |
#define FLASH_Enable CYGIMP_FLASH_ENABLE |
extern void CYGIMP_FLASH_ENABLE(void *, void *); |
#else |
#define FLASH_Enable(_start_, _end_) |
#endif |
#ifdef CYGIMP_FLASH_DISABLE |
#define FLASH_Disable CYGIMP_FLASH_DISABLE |
extern void CYGIMP_FLASH_DISABLE(void *, void *); |
#else |
#define FLASH_Disable(_start_, _end_) |
#endif |
|
// |
// Some platforms have a DIP switch or jumper that tells the software that |
// the flash is write protected. |
// |
#ifdef CYGSEM_IO_FLASH_SOFT_WRITE_PROTECT |
externC cyg_bool plf_flash_query_soft_wp(void *addr, int len); |
#endif |
|
//--------------------------------------------------------------------------- |
// Execution of flash code must be done inside a |
// HAL_FLASH_CACHES_OFF/HAL_FLASH_CACHES_ON region - disabling the |
// cache on unified cache systems is necessary to prevent burst access |
// to the flash area being programmed. With Harvard style caches, only |
// the data cache needs to be disabled, but the instruction cache is |
// disabled for consistency. |
|
// Targets may provide alternative implementations for these macros in |
// the hal_cache.h (or var/plf) files. |
|
// The first part below is a generic, optimal implementation. The |
// second part is the old implementation that has been tested to work |
// on some targets - but it is not be suitable for targets that would |
// do burst access to the flash (it does not disable the data cache). |
|
// Both implementations must be called with interrupts disabled. |
|
// NOTE: Do _not_ change any of the below macros without checking that |
// the changed code still works on _all_ platforms that rely on these |
// macros. There is no such thing as logical and correct when dealing |
// with different cache and IO models, so _do not_ mess with this code |
// unless you test it properly afterwards. |
|
#ifndef HAL_FLASH_CACHES_OFF |
|
// Some drivers have only been tested with the old macros below. |
#ifndef HAL_FLASH_CACHES_OLD_MACROS |
|
#ifdef HAL_CACHE_UNIFIED |
|
// Note: the ucache code has not been tested yet on any target. |
#define HAL_FLASH_CACHES_OFF(_d_, _i_) \ |
CYG_MACRO_START \ |
_i_ = 0; /* avoids warning */ \ |
HAL_UCACHE_IS_ENABLED(_d_); \ |
HAL_UCACHE_SYNC(); \ |
HAL_UCACHE_INVALIDATE_ALL(); \ |
HAL_UCACHE_DISABLE(); \ |
CYG_MACRO_END |
|
#define HAL_FLASH_CACHES_ON(_d_, _i_) \ |
CYG_MACRO_START \ |
if (_d_) HAL_UCACHE_ENABLE(); \ |
CYG_MACRO_END |
|
#else // HAL_CACHE_UNIFIED |
|
#define HAL_FLASH_CACHES_OFF(_d_, _i_) \ |
CYG_MACRO_START \ |
_i_ = 0; /* avoids warning */ \ |
HAL_DCACHE_IS_ENABLED(_d_); \ |
HAL_DCACHE_SYNC(); \ |
HAL_DCACHE_INVALIDATE_ALL(); \ |
HAL_DCACHE_DISABLE(); \ |
HAL_ICACHE_INVALIDATE_ALL(); \ |
CYG_MACRO_END |
|
#define HAL_FLASH_CACHES_ON(_d_, _i_) \ |
CYG_MACRO_START \ |
if (_d_) HAL_DCACHE_ENABLE(); \ |
CYG_MACRO_END |
|
#endif // HAL_CACHE_UNIFIED |
|
#else // HAL_FLASH_CACHES_OLD_MACROS |
|
// Note: This implementation is broken as it will always enable the i-cache |
// even if it was not enabled before. It also doesn't work if the |
// target uses burst access to flash since the d-cache is left enabled. |
// However, this does not mean you can change this code! Leave it as |
// is - if you want a different implementation, provide it in the |
// arch/var/platform cache header file. |
|
#define HAL_FLASH_CACHES_OFF(_d_, _i_) \ |
_d_ = 0; /* avoids warning */ \ |
_i_ = 0; /* avoids warning */ \ |
HAL_DCACHE_SYNC(); \ |
HAL_ICACHE_DISABLE(); |
|
#define HAL_FLASH_CACHES_ON(_d_, _i_) \ |
HAL_ICACHE_ENABLE(); |
|
#endif // HAL_FLASH_CACHES_OLD_MACROS |
|
#endif // HAL_FLASH_CACHES_OFF |
|
#endif // _FLASH_PRIVATE_ |
|
#endif // _IO_FLASH_H_ |
/src/flashiodev.c
0,0 → 1,245
//========================================================================== |
// |
// flashiodev.c |
// |
// Flash device interface to I/O subsystem |
// |
//========================================================================== |
//####ECOSGPLCOPYRIGHTBEGIN#### |
// ------------------------------------------- |
// This file is part of eCos, the Embedded Configurable Operating System. |
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
// |
// eCos is free software; you can redistribute it and/or modify it under |
// the terms of the GNU General Public License as published by the Free |
// Software Foundation; either version 2 or (at your option) any later version. |
// |
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
// for more details. |
// |
// You should have received a copy of the GNU General Public License along |
// with eCos; if not, write to the Free Software Foundation, Inc., |
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
// |
// As a special exception, if other files instantiate templates or use macros |
// or inline functions from this file, or you compile this file and link it |
// with other works to produce a work based on this file, this file does not |
// by itself cause the resulting work to be covered by the GNU General Public |
// License. However the source code for this file must still be made available |
// in accordance with section (3) of the GNU General Public License. |
// |
// This exception does not invalidate any other reasons why a work based on |
// this file might be covered by the GNU General Public License. |
// |
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
// at http://sources.redhat.com/ecos/ecos-license/ |
// ------------------------------------------- |
//####ECOSGPLCOPYRIGHTEND#### |
//========================================================================== |
//#####DESCRIPTIONBEGIN#### |
// |
// Author(s): jlarmour |
// Contributors: |
// Date: 2002-01-16 |
// Purpose: |
// Description: |
// |
//####DESCRIPTIONEND#### |
// |
//========================================================================== |
|
#define _FLASH_PRIVATE_ |
#include <pkgconf/io_flash.h> |
|
#include <errno.h> |
#include <cyg/infra/cyg_type.h> |
#include <cyg/io/devtab.h> |
#include <cyg/io/config_keys.h> |
#include <cyg/io/flash.h> |
#include <string.h> // memcpy |
|
#define MIN(x,y) ((x)<(y) ? (x) : (y)) |
|
// 1 per devtab entry, so only 1 for now |
static char flashiodev_workspaces[1][FLASH_MIN_WORKSPACE]; |
|
static int dummy_printf( const char *fmt, ... ) {return 0;} |
|
static bool |
flashiodev_init( struct cyg_devtab_entry *tab ) |
{ |
char *ws = (char *)tab->priv; |
int stat = flash_init( ws, FLASH_MIN_WORKSPACE, &dummy_printf ); |
|
if ( stat == 0 ) |
return true; |
else |
return false; |
} // flashiodev_init() |
|
#if 0 |
static Cyg_ErrNo |
flashiodev_lookup( struct cyg_devtab_entry **tab, |
struct cyg_devtab_entry *sub_tab, |
const char *name) |
{ |
} // flashiodev_lookup() |
#endif |
|
static Cyg_ErrNo |
flashiodev_bread( cyg_io_handle_t handle, void *buf, cyg_uint32 *len, |
cyg_uint32 pos) |
{ |
char *startpos = (char *)flash_info.start + pos + |
CYGNUM_IO_FLASH_BLOCK_OFFSET_1; |
|
#ifdef CYGPKG_INFRA_DEBUG // don't bother checking this all the time |
char *endpos = startpos + *len - 1; |
char *flashend = MIN( (char *)flash_info.end, |
((char *)flash_info.start + CYGNUM_IO_FLASH_BLOCK_OFFSET_1 + |
CYGNUM_IO_FLASH_BLOCK_LENGTH_1)); |
if ( startpos < (char *)flash_info.start+CYGNUM_IO_FLASH_BLOCK_OFFSET_1 ) |
return -EINVAL; |
if ( endpos > flashend ) |
return -EINVAL; |
#endif |
memcpy( buf, startpos, *len ); |
|
return ENOERR; |
} // flashiodev_bread() |
|
static Cyg_ErrNo |
flashiodev_bwrite( cyg_io_handle_t handle, const void *buf, cyg_uint32 *len, |
cyg_uint32 pos ) |
{ |
Cyg_ErrNo err = ENOERR; |
void *erraddr; |
|
char *startpos = (char *)flash_info.start + pos + CYGNUM_IO_FLASH_BLOCK_OFFSET_1; |
|
#ifdef CYGPKG_INFRA_DEBUG // don't bother checking this all the time |
char *endpos = startpos + *len - 1; |
char *flashend = MIN( (char *)flash_info.end, |
((char *)flash_info.start + CYGNUM_IO_FLASH_BLOCK_OFFSET_1 + |
CYGNUM_IO_FLASH_BLOCK_LENGTH_1)); |
if ( startpos < (char *)flash_info.start + CYGNUM_IO_FLASH_BLOCK_OFFSET_1 ) |
return -EINVAL; |
if ( endpos > flashend ) |
return -EINVAL; |
#endif |
err = flash_program( startpos, |
(void *)buf, *len, &erraddr ); |
|
if ( err ) |
err = -EIO; // just something sane |
return err; |
} // flashiodev_bwrite() |
|
static Cyg_ErrNo |
flashiodev_get_config( cyg_io_handle_t handle, |
cyg_uint32 key, |
void* buf, |
cyg_uint32* len) |
{ |
switch (key) { |
case CYG_IO_GET_CONFIG_FLASH_ERASE: |
{ |
if ( *len != sizeof( cyg_io_flash_getconfig_erase_t ) ) |
return -EINVAL; |
{ |
cyg_io_flash_getconfig_erase_t *e = |
(cyg_io_flash_getconfig_erase_t *)buf; |
char *startpos = (char *)flash_info.start + e->offset + CYGNUM_IO_FLASH_BLOCK_OFFSET_1; |
|
#ifdef CYGPKG_INFRA_DEBUG // don't bother checking this all the time |
char *endpos = startpos + e->len - 1; |
char *flashend = MIN( (char *)flash_info.end, |
((char *)flash_info.start + CYGNUM_IO_FLASH_BLOCK_OFFSET_1 + |
CYGNUM_IO_FLASH_BLOCK_LENGTH_1)); |
if ( startpos < (char *)flash_info.start + CYGNUM_IO_FLASH_BLOCK_OFFSET_1 ) |
return -EINVAL; |
if ( endpos > flashend ) |
return -EINVAL; |
#endif |
e->flasherr = flash_erase( startpos, e->len, e->err_address ); |
} |
return ENOERR; |
} |
case CYG_IO_GET_CONFIG_FLASH_DEVSIZE: |
{ |
if ( *len != sizeof( cyg_io_flash_getconfig_devsize_t ) ) |
return -EINVAL; |
{ |
cyg_io_flash_getconfig_devsize_t *d = |
(cyg_io_flash_getconfig_devsize_t *)buf; |
|
//d->dev_size = flash_info.blocks * flash_info.block_size; |
d->dev_size = CYGNUM_IO_FLASH_BLOCK_LENGTH_1; |
} |
return ENOERR; |
} |
|
case CYG_IO_GET_CONFIG_FLASH_BLOCKSIZE: |
{ |
cyg_io_flash_getconfig_blocksize_t *b = |
(cyg_io_flash_getconfig_blocksize_t *)buf; |
char *startpos = (char *)flash_info.start + CYGNUM_IO_FLASH_BLOCK_OFFSET_1 + b->offset; |
#ifdef CYGPKG_INFRA_DEBUG // don't bother checking this all the time |
char *flashend = MIN( (char *)flash_info.end, |
((char *)flash_info.start + CYGNUM_IO_FLASH_BLOCK_OFFSET_1 + |
CYGNUM_IO_FLASH_BLOCK_LENGTH_1)); |
if ( startpos < (char *)flash_info.start + CYGNUM_IO_FLASH_BLOCK_OFFSET_1 ) |
return -EINVAL; |
if ( startpos > flashend ) |
return -EINVAL; |
#endif |
if ( *len != sizeof( cyg_io_flash_getconfig_blocksize_t ) ) |
return -EINVAL; |
|
// offset unused for now |
b->block_size = flash_info.block_size; |
return ENOERR; |
} |
|
default: |
return -EINVAL; |
} |
} // flashiodev_get_config() |
|
#if 0 |
static Cyg_ErrNo |
flashiodev_set_config( cyg_io_handle_t handle, |
cyg_uint32 key, |
const void* buf, |
cyg_uint32* len) |
{ |
switch (key) { |
default: |
return -EINVAL; |
} |
} // flashiodev_set_config() |
#endif |
|
// get_config/set_config should be added later to provide the other flash |
// operations possible, like erase etc. |
|
BLOCK_DEVIO_TABLE( cyg_io_flashdev1_ops, |
&flashiodev_bwrite, |
&flashiodev_bread, |
0, // no select |
&flashiodev_get_config, |
0 // &flashiodev_set_config |
); |
|
|
BLOCK_DEVTAB_ENTRY( cyg_io_flashdev1, |
CYGDAT_IO_FLASH_BLOCK_DEVICE_NAME_1, |
0, |
&cyg_io_flashdev1_ops, |
&flashiodev_init, |
0, // No lookup required |
&flashiodev_workspaces[0] ); |
|
// EOF flashiodev.c |
/src/flash.c
0,0 → 1,518
//========================================================================== |
// |
// flash.c |
// |
// Flash programming |
// |
//========================================================================== |
//####ECOSGPLCOPYRIGHTBEGIN#### |
// ------------------------------------------- |
// This file is part of eCos, the Embedded Configurable Operating System. |
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
// |
// eCos is free software; you can redistribute it and/or modify it under |
// the terms of the GNU General Public License as published by the Free |
// Software Foundation; either version 2 or (at your option) any later version. |
// |
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
// for more details. |
// |
// You should have received a copy of the GNU General Public License along |
// with eCos; if not, write to the Free Software Foundation, Inc., |
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
// |
// As a special exception, if other files instantiate templates or use macros |
// or inline functions from this file, or you compile this file and link it |
// with other works to produce a work based on this file, this file does not |
// by itself cause the resulting work to be covered by the GNU General Public |
// License. However the source code for this file must still be made available |
// in accordance with section (3) of the GNU General Public License. |
// |
// This exception does not invalidate any other reasons why a work based on |
// this file might be covered by the GNU General Public License. |
// |
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
// at http://sources.redhat.com/ecos/ecos-license/ |
// ------------------------------------------- |
//####ECOSGPLCOPYRIGHTEND#### |
//========================================================================== |
//#####DESCRIPTIONBEGIN#### |
// |
// Author(s): gthomas |
// Contributors: gthomas |
// Date: 2000-07-26 |
// Purpose: |
// Description: |
// |
//####DESCRIPTIONEND#### |
// |
//========================================================================== |
|
#include <pkgconf/system.h> |
#include <pkgconf/io_flash.h> |
|
#include <cyg/hal/hal_arch.h> |
#include <cyg/hal/hal_intr.h> |
#include <cyg/hal/hal_cache.h> |
#include <string.h> |
|
#define _FLASH_PRIVATE_ |
#include <cyg/io/flash.h> |
|
// When this flag is set, do not actually jump to the relocated code. |
// This can be used for running the function in place (RAM startup only), |
// allowing calls to diag_printf() and similar. |
#undef RAM_FLASH_DEV_DEBUG |
#if !defined(CYG_HAL_STARTUP_RAM) && defined(RAM_FLASH_DEV_DEBUG) |
# warning "Can only enable the flash debugging when configured for RAM startup" |
# undef CYGHWR_IO_FLASH_DEVICE_NOT_IN_RAM |
#endif |
|
struct flash_info flash_info; |
|
int |
flash_init(void *work_space, int work_space_size, _printf *pf) |
{ |
int err; |
|
if (flash_info.init) return FLASH_ERR_OK; |
flash_info.pf = pf; // Do this before calling into the driver |
flash_info.work_space = work_space; |
flash_info.work_space_size = work_space_size; |
if ((err = flash_hwr_init()) != FLASH_ERR_OK) { |
return err; |
} |
flash_info.block_mask = ~(flash_info.block_size-1); |
flash_info.init = 1; |
return FLASH_ERR_OK; |
} |
|
#ifndef CYGHWR_IO_FLASH_DEVICE_NOT_IN_RAM |
// Use this function to make function pointers anonymous - forcing the |
// compiler to use jumps instead of branches when calling driver |
// services. |
static void* __anonymizer(void* p) |
{ |
return p; |
} |
#endif |
|
// FIXME: Want to change all drivers to use this function. But it may |
// make sense to wait till device structure pointer arguments get |
// added as well. |
void |
flash_dev_query(void* data) |
{ |
typedef void code_fun(void*); |
code_fun *_flash_query; |
int d_cache, i_cache; |
|
#ifdef CYGHWR_IO_FLASH_DEVICE_NOT_IN_RAM |
{ |
extern char flash_query[], flash_query_end[]; |
CYG_ADDRESS code_len; |
|
// Query the device driver - copy 'query' code to RAM for execution |
code_len = (CYG_ADDRESS)&flash_query_end - (CYG_ADDRESS)&flash_query; |
_flash_query = (code_fun *)flash_info.work_space; |
memcpy(_flash_query, &flash_query, code_len); |
} |
#else |
{ |
externC code_fun flash_query; |
_flash_query = (code_fun*) __anonymizer(&flash_query); |
} |
#endif |
|
HAL_FLASH_CACHES_OFF(d_cache, i_cache); |
(*_flash_query)(data); |
HAL_FLASH_CACHES_ON(d_cache, i_cache); |
} |
|
int |
flash_verify_addr(void *target) |
{ |
if (!flash_info.init) { |
return FLASH_ERR_NOT_INIT; |
} |
if (((CYG_ADDRESS)target >= (CYG_ADDRESS)flash_info.start) && |
((CYG_ADDRESS)target <= ( ((CYG_ADDRESS)flash_info.end) - 1) )) { |
return FLASH_ERR_OK; |
} else { |
return FLASH_ERR_INVALID; |
} |
} |
|
int |
flash_get_limits(void *target, void **start, void **end) |
{ |
if (!flash_info.init) { |
return FLASH_ERR_NOT_INIT; |
} |
*start = flash_info.start; |
*end = flash_info.end; |
return FLASH_ERR_OK; |
} |
|
int |
flash_get_block_info(int *block_size, int *blocks) |
{ |
if (!flash_info.init) { |
return FLASH_ERR_NOT_INIT; |
} |
*block_size = flash_info.block_size; |
*blocks = flash_info.blocks; |
return FLASH_ERR_OK; |
} |
|
int |
flash_erase(void *addr, int len, void **err_addr) |
{ |
unsigned short *block, *end_addr; |
int stat = 0; |
typedef int code_fun(unsigned short *, unsigned int); |
code_fun *_flash_erase_block; |
int d_cache, i_cache; |
|
if (!flash_info.init) { |
return FLASH_ERR_NOT_INIT; |
} |
|
#ifdef CYGSEM_IO_FLASH_SOFT_WRITE_PROTECT |
if (plf_flash_query_soft_wp(addr,len)) |
return FLASH_ERR_PROTECT; |
#endif |
|
#ifdef CYGHWR_IO_FLASH_DEVICE_NOT_IN_RAM |
{ |
extern char flash_erase_block[], flash_erase_block_end[]; |
CYG_ADDRESS code_len; |
|
// Copy 'erase' code to RAM for execution |
code_len = (CYG_ADDRESS)&flash_erase_block_end - (CYG_ADDRESS)&flash_erase_block; |
_flash_erase_block = (code_fun *)flash_info.work_space; |
memcpy(_flash_erase_block, &flash_erase_block, code_len); |
} |
#else |
{ |
externC code_fun flash_erase_block; |
_flash_erase_block = (code_fun*) __anonymizer(&flash_erase_block); |
} |
#endif |
|
block = (unsigned short *)((CYG_ADDRESS)addr & flash_info.block_mask); |
end_addr = (unsigned short *)((CYG_ADDRESS)addr+len); |
|
/* Check to see if end_addr overflowed */ |
if( (end_addr < block) && (len > 0) ){ |
end_addr = (unsigned short *) ((CYG_ADDRESS) flash_info.end - 1); |
} |
|
(*flash_info.pf)("... Erase from %p-%p: ", (void*)block, (void*)end_addr); |
|
HAL_FLASH_CACHES_OFF(d_cache, i_cache); |
FLASH_Enable(block, end_addr); |
while (block < end_addr) { |
// Supply the blocksize for a gross check for erase success |
int i; |
unsigned char *dp; |
bool erased = true; |
unsigned short *tmp_block; |
|
dp = (unsigned char *)block; |
for (i = 0; i < flash_info.block_size; i++) { |
if (*dp++ != (unsigned char)0xFF) { |
erased = false; |
break; |
} |
} |
if (!erased) { |
stat = (*_flash_erase_block)(block, flash_info.block_size); |
stat = flash_hwr_map_error(stat); |
} |
if (stat) { |
*err_addr = (void *)block; |
break; |
} |
|
// Check to see if block will overflow |
tmp_block = block + flash_info.block_size / sizeof(*block); |
if(tmp_block < block){ |
// If block address overflows, set block value to end on this loop |
block = end_addr; |
} |
else{ |
block = tmp_block; |
} |
(*flash_info.pf)("."); |
} |
FLASH_Disable(block, end_addr); |
HAL_FLASH_CACHES_ON(d_cache, i_cache); |
(*flash_info.pf)("\n"); |
return (stat); |
} |
|
int |
flash_program(void *_addr, void *_data, int len, void **err_addr) |
{ |
int stat = 0; |
int size; |
typedef int code_fun(void *, void *, int, unsigned long, int); |
code_fun *_flash_program_buf; |
unsigned char *addr = (unsigned char *)_addr; |
unsigned char *data = (unsigned char *)_data; |
CYG_ADDRESS tmp; |
int d_cache, i_cache; |
|
if (!flash_info.init) { |
return FLASH_ERR_NOT_INIT; |
} |
|
#ifdef CYGSEM_IO_FLASH_SOFT_WRITE_PROTECT |
if (plf_flash_query_soft_wp(addr,len)) |
return FLASH_ERR_PROTECT; |
#endif |
|
#ifdef CYGHWR_IO_FLASH_DEVICE_NOT_IN_RAM |
{ |
CYG_ADDRESS code_len; |
extern char flash_program_buf[], flash_program_buf_end[]; |
// Copy 'program' code to RAM for execution |
code_len = (CYG_ADDRESS)&flash_program_buf_end - (CYG_ADDRESS)&flash_program_buf; |
_flash_program_buf = (code_fun *)flash_info.work_space; |
memcpy(_flash_program_buf, &flash_program_buf, code_len); |
} |
#else |
{ |
externC code_fun flash_program_buf; |
_flash_program_buf = (code_fun*) __anonymizer(&flash_program_buf); |
} |
#endif |
|
(*flash_info.pf)("... Program from %p-%p at %p: ", (void*)data, |
(void*)(((CYG_ADDRESS)data)+len), (void*)addr); |
|
HAL_FLASH_CACHES_OFF(d_cache, i_cache); |
FLASH_Enable((unsigned short*)addr, (unsigned short *)(addr+len)); |
while (len > 0) { |
size = len; |
if (size > flash_info.block_size) size = flash_info.block_size; |
|
tmp = (CYG_ADDRESS)addr & ~flash_info.block_mask; |
if (tmp) { |
tmp = flash_info.block_size - tmp; |
if (size>tmp) size = tmp; |
|
} |
|
stat = (*_flash_program_buf)(addr, data, size, |
flash_info.block_mask, flash_info.buffer_size); |
stat = flash_hwr_map_error(stat); |
#ifdef CYGSEM_IO_FLASH_VERIFY_PROGRAM |
if (0 == stat) // Claims to be OK |
if (memcmp(addr, data, size) != 0) { |
stat = 0x0BAD; |
(*flash_info.pf)("V"); |
} |
#endif |
if (stat) { |
*err_addr = (void *)addr; |
break; |
} |
(*flash_info.pf)("."); |
len -= size; |
addr += size/sizeof(*addr); |
data += size/sizeof(*data); |
} |
FLASH_Disable((unsigned short*)addr, (unsigned short *)(addr+len)); |
HAL_FLASH_CACHES_ON(d_cache, i_cache); |
(*flash_info.pf)("\n"); |
return (stat); |
} |
|
#ifdef CYGHWR_IO_FLASH_BLOCK_LOCKING |
|
int |
flash_lock(void *addr, int len, void **err_addr) |
{ |
unsigned short *block, *end_addr; |
int stat = 0; |
typedef int code_fun(unsigned short *); |
code_fun *_flash_lock_block; |
int d_cache, i_cache; |
|
if (!flash_info.init) { |
return FLASH_ERR_NOT_INIT; |
} |
|
#ifdef CYGSEM_IO_FLASH_SOFT_WRITE_PROTECT |
if (plf_flash_query_soft_wp(addr,len)) |
return FLASH_ERR_PROTECT; |
#endif |
|
#ifdef CYGHWR_IO_FLASH_DEVICE_NOT_IN_RAM |
{ |
extern char flash_lock_block[], flash_lock_block_end[]; |
CYG_ADDRESS code_len; |
// Copy 'lock' code to RAM for execution |
code_len = (CYG_ADDRESS)&flash_lock_block_end - (CYG_ADDRESS)&flash_lock_block; |
_flash_lock_block = (code_fun *)flash_info.work_space; |
memcpy(_flash_lock_block, &flash_lock_block, code_len); |
} |
#else |
{ |
externC code_fun flash_lock_block; |
_flash_lock_block = (code_fun*) __anonymizer(&flash_lock_block); |
} |
#endif |
|
block = (unsigned short *)((CYG_ADDRESS)addr & flash_info.block_mask); |
end_addr = (unsigned short *)((CYG_ADDRESS)addr+len); |
|
/* Check to see if end_addr overflowed */ |
if( (end_addr < block) && (len > 0) ){ |
end_addr = (unsigned short *) ((CYG_ADDRESS) flash_info.end - 1); |
} |
|
(*flash_info.pf)("... Lock from %p-%p: ", block, end_addr); |
|
HAL_FLASH_CACHES_OFF(d_cache, i_cache); |
FLASH_Enable(block, end_addr); |
while (block < end_addr) { |
unsigned short *tmp_block; |
stat = (*_flash_lock_block)(block); |
stat = flash_hwr_map_error(stat); |
if (stat) { |
*err_addr = (void *)block; |
break; |
} |
|
// Check to see if block will overflow |
tmp_block = block + flash_info.block_size / sizeof(*block); |
if(tmp_block < block){ |
// If block address overflows, set block value to end on this loop |
block = end_addr; |
} |
else{ |
block = tmp_block; |
} |
(*flash_info.pf)("."); |
} |
FLASH_Disable(block, end_addr); |
HAL_FLASH_CACHES_ON(d_cache, i_cache); |
(*flash_info.pf)("\n"); |
return (stat); |
} |
|
int |
flash_unlock(void *addr, int len, void **err_addr) |
{ |
unsigned short *block, *end_addr; |
int stat = 0; |
typedef int code_fun(unsigned short *, int, int); |
code_fun *_flash_unlock_block; |
int d_cache, i_cache; |
|
if (!flash_info.init) { |
return FLASH_ERR_NOT_INIT; |
} |
|
#ifdef CYGSEM_IO_FLASH_SOFT_WRITE_PROTECT |
if (plf_flash_query_soft_wp(addr,len)) |
return FLASH_ERR_PROTECT; |
#endif |
|
#ifdef CYGHWR_IO_FLASH_DEVICE_NOT_IN_RAM |
{ |
extern char flash_unlock_block[], flash_unlock_block_end[]; |
CYG_ADDRESS code_len; |
// Copy 'lock' code to RAM for execution |
code_len = (CYG_ADDRESS)&flash_unlock_block_end - (CYG_ADDRESS)&flash_unlock_block; |
_flash_unlock_block = (code_fun *)flash_info.work_space; |
memcpy(_flash_unlock_block, &flash_unlock_block, code_len); |
} |
#else |
{ |
externC code_fun flash_unlock_block; |
_flash_unlock_block = (code_fun*) __anonymizer(&flash_unlock_block); |
} |
#endif |
|
block = (unsigned short *)((CYG_ADDRESS)addr & flash_info.block_mask); |
end_addr = (unsigned short *)((CYG_ADDRESS)addr+len); |
|
/* Check to see if end_addr overflowed */ |
if( (end_addr < block) && (len > 0) ){ |
end_addr = (unsigned short *) ((CYG_ADDRESS) flash_info.end - 1); |
} |
|
(*flash_info.pf)("... Unlock from %p-%p: ", block, end_addr); |
|
HAL_FLASH_CACHES_OFF(d_cache, i_cache); |
FLASH_Enable(block, end_addr); |
while (block < end_addr) { |
unsigned short *tmp_block; |
stat = (*_flash_unlock_block)(block, flash_info.block_size, flash_info.blocks); |
stat = flash_hwr_map_error(stat); |
if (stat) { |
*err_addr = (void *)block; |
break; |
} |
|
tmp_block = block + flash_info.block_size / sizeof(*block); |
if(tmp_block < block){ |
// If block address overflows, set block value to end on this loop |
block = end_addr; |
} |
else{ |
block = tmp_block; |
} |
(*flash_info.pf)("."); |
} |
FLASH_Disable(block, end_addr); |
HAL_FLASH_CACHES_ON(d_cache, i_cache); |
(*flash_info.pf)("\n"); |
return (stat); |
} |
#endif |
|
char * |
flash_errmsg(int err) |
{ |
switch (err) { |
case FLASH_ERR_OK: |
return "No error - operation complete"; |
case FLASH_ERR_ERASE_SUSPEND: |
return "Device is in erase suspend state"; |
case FLASH_ERR_PROGRAM_SUSPEND: |
return "Device is in program suspend state"; |
case FLASH_ERR_INVALID: |
return "Invalid FLASH address"; |
case FLASH_ERR_ERASE: |
return "Error trying to erase"; |
case FLASH_ERR_LOCK: |
return "Error trying to lock/unlock"; |
case FLASH_ERR_PROGRAM: |
return "Error trying to program"; |
case FLASH_ERR_PROTOCOL: |
return "Generic error"; |
case FLASH_ERR_PROTECT: |
return "Device/region is write-protected"; |
case FLASH_ERR_NOT_INIT: |
return "FLASH sub-system not initialized"; |
case FLASH_ERR_DRV_VERIFY: |
return "Data verify failed after operation"; |
case FLASH_ERR_DRV_TIMEOUT: |
return "Driver timed out waiting for device"; |
case FLASH_ERR_DRV_WRONG_PART: |
return "Driver does not support device"; |
case FLASH_ERR_LOW_VOLTAGE: |
return "Device reports low voltage"; |
default: |
return "Unknown error"; |
} |
} |
|
// EOF io/flash/..../flash.c |
/ChangeLog
0,0 → 1,265
2003-02-24 Jonathan Larmour <jifl@eCosCentric.com> |
|
* cdl/io_flash.cdl: Remove irrelevant doc link - default to top |
level. |
|
2002-01-31 Jonathan Larmour <jlarmour@redhat.com> |
|
* src/flashiodev.c: Fix bounds checking and offsetting. |
|
* cdl/io_flash.cdl (CYGNUM_IO_FLASH_BLOCK_LENGTH_1): Default to |
0x100000 for convenience. |
|
2002-01-30 Jonathan Larmour <jlarmour@redhat.com> |
|
* cdl/io_flash.cdl: Allow specification of an offset and length |
of the region of flash. |
* src/flashiodev.c: Use it. |
|
2002-01-24 Jesper Skov <jskov@redhat.com> |
|
* include/flash.h: Add a comment about the obvious: the flash |
caching macros should be called with interrupts disabled. |
|
2002-01-23 Jonathan Larmour <jlarmour@redhat.com> |
|
* cdl/io_flash.cdl: Add CYGPKG_IO_FLASH_BLOCK_DEVICE and |
CYGDAT_IO_FLASH_BLOCK_DEVICE_NAME_1 to allow exporting flash |
as block devices accessible from file systems. |
* src/fileiodev.c: New file implementing this. |
* include/flash.h: Add typedefs for the various structures used |
to configure the block devices. |
|
2002-01-18 Paul Fine <pfine@delcomsys.com> |
|
* src/flash.c : Modified flash_verify_addr, flash_erase, |
flash_lock and flash_unlock to to work properly when the location |
of the flash in the memory map is at the very top of the address |
space. We check and handle values that may overflow. |
|
2001-10-28 Gary Thomas <gthomas@redhat.com> |
|
* src/flash.c (flash_erase): Don't call hardware layer if block |
appears to be already erased [faster and less wear & tear]. |
|
2001-10-25 Jonathan Larmour <jlarmour@redhat.com> |
|
* include/flash_dev.h: Fix test of 4x16-bit flash parts. |
Spotted by Jose Pascual <josepascual@almudi.com> |
|
2001-10-16 Jesper Skov <jskov@redhat.com> |
|
* src/flash.c: Include string.h |
|
* cdl/io_flash.cdl: Package requires ISOINFRA and string |
functions. |
|
2001-10-15 David Howells <dhowells@redhat.com> |
|
* src/flash.c: Include string.h to get mem*() functions. |
|
2001-09-25 Gary Thomas <gthomas@redhat.com> |
|
* include/flash.h: Remove warning on printf() prototype. |
|
2001-08-10 Jesper Skov <jskov@redhat.com> |
|
* cdl/io_flash.cdl: Changed flavor of |
CYGHWR_IO_FLASH_BLOCK_LOCKING to booldata. |
* include/flash.h: Matching changes. |
* src/flash.c: Matching changes. |
|
2001-07-23 David Howells <dhowells@redhat.com> |
|
* cdl/io_flash.cdl: Added software write protect option. |
* include/flash.h: Ditto. |
* src/flash.c: Added software write protect option and bank |
support, and prevented low-level writes from being handed |
cross-block data chunks. |
|
2001-07-20 Gary Thomas <gthomas@redhat.com> |
|
* include/flash.h: |
* cdl/io_flash.cdl: Name convention: CYGINT_FLASH_WORKSPACE_SIZE |
renamed to be CYGNUM_FLASH_WORKSPACE_SIZE. |
|
2001-07-19 Gary Thomas <gthomas@redhat.com> |
|
* include/flash.h: |
* cdl/io_flash.cdl: New option CYGINT_FLASH_WORKSPACE_SIZE used |
to control how much memory is reserved for use by FLASH drivers. |
|
2001-06-19 Hugo Tyson <hmt@redhat.com> |
|
* src/flash.c (flash_program): Only verify program with memcmp if |
the status code suggests the programming went OK so far. |
Otherwise all errors become verify errors. |
|
(flash_init): Fix bug in removal of dependency of printf(). The |
pointer was not initialized until after the call into the driver. |
|
2001-06-11 Gary Thomas <gthomas@redhat.com> |
|
* src/flash.c: |
* include/flash.h: Remove dependency on printf() via user functions. |
|
2001-05-23 Jesper Skov <jskov@redhat.com> |
|
* include/flash_dev.h (FLASH_P2V): Use CYG_ADDRWORD instead of int. |
|
* src/flash.c: Copy functions to RAM iff |
CYGHWR_IO_FLASH_DEVICE_NOT_IN_RAM defined. |
|
* cdl/io_flash.cdl: Changed CYGHWR_IO_FLASH_DEVICE_IN_RAM to |
CYGHWR_IO_FLASH_DEVICE_NOT_IN_RAM. |
|
2001-05-21 Jonathan Larmour <jlarmour@redhat.com> |
|
* include/flash_dev.h: Fix cyg_uin16 typo. |
|
2001-03-29 Mark Salter <msalter@redhat.com> |
|
* cdl/io_flash.cdl (CYGSEM_IO_FLASH_VERIFY_PROGRAM): New option |
to control whether or not to perform extra verification of flash |
programming. |
* src/flash.c (flash_program): No verification unless |
CYGSEM_IO_FLASH_VERIFY_PROGRAM defined. |
|
2001-03-21 Gary Thomas <gthomas@redhat.com> |
|
* src/flash.c (flash_program): Verify data after programming. |
|
2001-03-21 Jesper Skov <jskov@redhat.com> |
|
* include/flash.h: Added low voltage error message. |
* src/flash.c: And its error message. |
|
2001-03-17 Gary Thomas <gthomas@redhat.com> |
|
* src/flash.c (flash_program): |
* include/flash.h: Add support for [StrataFLASH] buffered writes. |
This requires knowledge of the device write buffer size [saved]. |
|
2001-03-01 Gary Thomas <gthomas@redhat.com> |
|
* src/flash.c: |
* include/flash.h: Allow platform to define pre/post routines |
to enable/disable device access. These may be required, e.g. |
to turn on some voltage, etc. |
|
2001-02-23 Jesper Skov <jskov@redhat.com> |
|
* include/flash.h: HAL_FLASH_CACHES_WANT_OPTIMAL replaced with |
(opposite sense) HAL_FLASH_CACHES_OLD_MACROS. |
|
* src/flash.c (__anonymizer): Use to force the compiler to use |
jumps instead of branches. |
|
2001-02-22 Jesper Skov <jskov@redhat.com> |
|
* include/flash_dev.h: Added. Contains macros and definitions |
common to all (new style) flash device drivers. |
|
* include/flash.h: Added two new error codes. |
* cdl/io_flash.cdl: Added CYGHWR_IO_FLASH_DEVICE_IN_RAM. |
* src/flash.c: Made functions respect |
CYGHWR_IO_FLASH_DEVICE_IN_RAM and jump directly to the code |
instead of copying it around. |
(__arm_broken): Work around problem with ARM tools. |
|
2001-02-06 Hugo Tyson <hmt@redhat.com> |
|
* src/flash.c (flash_erase): Add an additional argument to the |
call into the driver, being the blocksize (as discovered). This |
allows a gross check for actual erase in some drivers. Those that |
don't use it, it's harmless - after all, this is an API by trust. |
|
2000-12-06 Jesper Skov <jskov@redhat.com> |
|
* src/flash.c (flash_dev_query): Added. Allows reloc/cache magic |
to be removed from device drivers (eventually). Also fixed some |
warnings, and made function references use char[] instead of just |
char to prevent MIPS compiler from messing up. |
|
* include/flash.h: Added FLASH_ERR_DRV_VERIFY and flash_dev_query. |
|
2000-11-27 Jesper Skov <jskov@redhat.com> |
|
* src/flash.c: Do all flash access inside properly |
cache-controlled region. |
* include/flash.h: Cache definitions. |
|
2000-11-17 Jesper Skov <jskov@redhat.com> |
|
* src/flash.c: Added debug mode, allowing device driver to use printf. |
|
2000-11-16 Jesper Skov <jskov@redhat.com> |
|
* src/flash.c: Added suspend error messages. |
* include/flash.h: Same. |
|
2000-09-01 Hugo Tyson <hmt@cygnus.co.uk> |
|
* include/flash.h: |
* src/flash.c: CYGHWR_IO_FLASH_BLOCK_LOCKING is an interface, so |
it's always defined; look for > 0 instead. |
|
2000-08-28 Gary Thomas <gthomas@redhat.com> |
|
* src/flash.c: |
* include/flash.h: |
* cdl/io_flash.cdl: Support block locking (optional by hardware). |
|
2000-08-22 Hugo Tyson <hmt@cygnus.co.uk> |
|
* src/flash.c (flash_program): Add HAL_ICACHE_DISABLE/ENABLE pairs |
around calls to RAM copy of programming/erasing function - this is |
necessary to get reliable operation on EBSA285 and similar. |
Otherwise, what is in the instruction cache might be run instead. |
|
2000-08-14 Gary Thomas <gthomas@redhat.com> |
|
* include/flash.h: Add block size mask for finding block boundaries. |
|
* src/flash.c: Use block size properly. |
|
2000-07-29 Gary Thomas <gthomas@redhat.com> |
|
* include/flash.h: |
* src/flash.c (flash_get_block_info): New function. |
(flash_program): Program in block_size chunks as much as possible. |
|
//=========================================================================== |
//####ECOSGPLCOPYRIGHTBEGIN#### |
// ------------------------------------------- |
// This file is part of eCos, the Embedded Configurable Operating System. |
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
// |
// eCos is free software; you can redistribute it and/or modify it under |
// the terms of the GNU General Public License as published by the Free |
// Software Foundation; either version 2 or (at your option) any later version. |
// |
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
// for more details. |
// |
// You should have received a copy of the GNU General Public License along |
// with eCos; if not, write to the Free Software Foundation, Inc., |
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
// |
// As a special exception, if other files instantiate templates or use macros |
// or inline functions from this file, or you compile this file and link it |
// with other works to produce a work based on this file, this file does not |
// by itself cause the resulting work to be covered by the GNU General Public |
// License. However the source code for this file must still be made available |
// in accordance with section (3) of the GNU General Public License. |
// |
// This exception does not invalidate any other reasons why a work based on |
// this file might be covered by the GNU General Public License. |
// |
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
// at http://sources.redhat.com/ecos/ecos-license/ |
// ------------------------------------------- |
//####ECOSGPLCOPYRIGHTEND#### |
//=========================================================================== |