# HG changeset patch # User bartv # Date 1101125155 0 # Node ID 80232dbac7fbba7289a89bca045aeb0d51d7e7e3 # Parent 6588c38f09cf20527ad125e8d83ca6a62e43eb8e Flash API clean-ups diff --git a/packages/devs/flash/amd/am29xxxxxv2/current/ChangeLog b/packages/devs/flash/amd/am29xxxxxv2/current/ChangeLog --- a/packages/devs/flash/amd/am29xxxxxv2/current/ChangeLog +++ b/packages/devs/flash/amd/am29xxxxxv2/current/ChangeLog @@ -1,3 +1,8 @@ +2004-11-22 Bart Veer + + * include/am29xxxxx_dev.h: rename cyg_block_info to + cyg_flash_block_info + 2004-11-21 Bart Veer * doc/am29xxxxx.sgml: describe CDL implications for custom locking diff --git a/packages/devs/flash/amd/am29xxxxxv2/current/include/am29xxxxx_dev.h b/packages/devs/flash/amd/am29xxxxxv2/current/include/am29xxxxx_dev.h --- a/packages/devs/flash/amd/am29xxxxxv2/current/include/am29xxxxx_dev.h +++ b/packages/devs/flash/amd/am29xxxxxv2/current/include/am29xxxxx_dev.h @@ -105,11 +105,11 @@ externC int cyg_am29xxxxx_program_16as8( // a cyg_flash_dev structure. typedef struct cyg_am29xxxxx_dev { // The device id, mainly for use by the init_check_devid() routines - cyg_uint32 devid; + cyg_uint32 devid; // Space for the block_info fields needed for the cyg_flash_dev. // These can be statically initialized, or dynamically via // init_cfi(). - cyg_block_info_t block_info[CYGNUM_DEVS_FLASH_AMD_AM29XXXXX_V2_ERASE_REGIONS]; + cyg_flash_block_info_t block_info[CYGNUM_DEVS_FLASH_AMD_AM29XXXXX_V2_ERASE_REGIONS]; } cyg_am29xxxxx_dev; #endif // CYGONCE_DEVS_FLASH_AM29xxxxx_dev_V2_H diff --git a/packages/devs/flash/atmel/dataflash/current/ChangeLog b/packages/devs/flash/atmel/dataflash/current/ChangeLog --- a/packages/devs/flash/atmel/dataflash/current/ChangeLog +++ b/packages/devs/flash/atmel/dataflash/current/ChangeLog @@ -1,3 +1,8 @@ +2004-11-22 Bart Veer + + * src/devs_flash_atmel_dataflash_flash_dev_funs.c (df_flash_init): + Rename cyg_block_info to cyg_flash_block_info + 2004-11-21 Bart Veer * cdl/devs_flash_atmel_dataflash.cdl: CYGHWR_IO_FLASH_DEVICE_V2 is diff --git a/packages/devs/flash/atmel/dataflash/current/src/devs_flash_atmel_dataflash_flash_dev_funs.c b/packages/devs/flash/atmel/dataflash/current/src/devs_flash_atmel_dataflash_flash_dev_funs.c --- a/packages/devs/flash/atmel/dataflash/current/src/devs_flash_atmel_dataflash_flash_dev_funs.c +++ b/packages/devs/flash/atmel/dataflash/current/src/devs_flash_atmel_dataflash_flash_dev_funs.c @@ -73,7 +73,7 @@ static int df_flash_init(struct cyg_flash_dev *dev) { - static cyg_block_info_t block_info[1]; + static cyg_flash_block_info_t block_info[1]; cyg_dataflash_flash_dev_config_t *config; cyg_dataflash_flash_dev_priv_t *priv; diff --git a/packages/devs/flash/intel/stratav2/current/ChangeLog b/packages/devs/flash/intel/stratav2/current/ChangeLog --- a/packages/devs/flash/intel/stratav2/current/ChangeLog +++ b/packages/devs/flash/intel/stratav2/current/ChangeLog @@ -1,3 +1,8 @@ +2004-11-22 Bart Veer + + * include/flash_strata_v2.inl: rename cyg_block_info to + cyg_flash_block_info + 2004-11-21 Bart Veer * cdl/flash_strata_v2.cdl: CYGHWR_IO_FLASH_DEVICE_V2 is now diff --git a/packages/devs/flash/intel/stratav2/current/include/flash_strata_v2.inl b/packages/devs/flash/intel/stratav2/current/include/flash_strata_v2.inl --- a/packages/devs/flash/intel/stratav2/current/include/flash_strata_v2.inl +++ b/packages/devs/flash/intel/stratav2/current/include/flash_strata_v2.inl @@ -112,8 +112,8 @@ static int strata_lock_block(struct cyg_ //---------------------------------------------------------------------------- // Private structure used by the device. struct cyg_flash_strata_v2_priv { - cyg_block_info_t block_info [1]; - unsigned int buffer_size; // Size of write buffer + cyg_flash_block_info_t block_info [1]; + unsigned int buffer_size; // Size of write buffer }; //---------------------------------------------------------------------------- diff --git a/packages/devs/flash/sst/39vfxxx/current/ChangeLog b/packages/devs/flash/sst/39vfxxx/current/ChangeLog --- a/packages/devs/flash/sst/39vfxxx/current/ChangeLog +++ b/packages/devs/flash/sst/39vfxxx/current/ChangeLog @@ -1,3 +1,8 @@ +2004-11-22 Bart Veer + + * include/flash_sst_39vfxxx.inl: rename cyg_block_info to + cyg_flash_block_info + 2004-09-14 Andrew Lunn * include/flash_sst_39vfxxx.inl: Set the end address to the last diff --git a/packages/devs/flash/sst/39vfxxx/current/include/flash_sst_39vfxxx.inl b/packages/devs/flash/sst/39vfxxx/current/include/flash_sst_39vfxxx.inl --- a/packages/devs/flash/sst/39vfxxx/current/include/flash_sst_39vfxxx.inl +++ b/packages/devs/flash/sst/39vfxxx/current/include/flash_sst_39vfxxx.inl @@ -137,7 +137,7 @@ // Private structure used by the device struct cyg_flash_sst_priv { - cyg_block_info_t block_info[1]; + cyg_flash_block_info_t block_info[1]; }; //---------------------------------------------------------------------------- // Functions that put the flash device into non-read mode must reside diff --git a/packages/devs/flash/synthv2/current/ChangeLog b/packages/devs/flash/synthv2/current/ChangeLog --- a/packages/devs/flash/synthv2/current/ChangeLog +++ b/packages/devs/flash/synthv2/current/ChangeLog @@ -1,3 +1,8 @@ +2004-11-22 Bart Veer + + * include/synth.h (struct cyg_flash_synth_priv): rename + cyg_block_info to cyg_flash_block_info + 2004-11-21 Bart Veer * tests/flash1.c (cyg_user_start): diff --git a/packages/devs/flash/synthv2/current/include/synth.h b/packages/devs/flash/synthv2/current/include/synth.h --- a/packages/devs/flash/synthv2/current/include/synth.h +++ b/packages/devs/flash/synthv2/current/include/synth.h @@ -68,8 +68,8 @@ struct cyg_flash_synth_config // Structure of data private to the drive struct cyg_flash_synth_priv { - int flashfd; - struct cyg_block_info block_info[2]; + int flashfd; + struct cyg_flash_block_info block_info[2]; }; extern struct cyg_flash_dev_funs cyg_flash_synth_funs; diff --git a/packages/io/flash/current/ChangeLog b/packages/io/flash/current/ChangeLog --- a/packages/io/flash/current/ChangeLog +++ b/packages/io/flash/current/ChangeLog @@ -1,3 +1,9 @@ +2004-11-22 Bart Veer + + * include/flash.h, include/flash_priv.h, doc/flash.sgml, + src/flash.c, src/legacy_dev.c: put const in the right places, + and rename cyg_block_info to cyg_flash_block_info + 2004-11-21 Bart Veer * src/flash.c, include/flash_priv.h, cdl/io_flash.h: optimize diff --git a/packages/io/flash/current/doc/flash.sgml b/packages/io/flash/current/doc/flash.sgml --- a/packages/io/flash/current/doc/flash.sgml +++ b/packages/io/flash/current/doc/flash.sgml @@ -147,16 +147,16 @@ The following five functions return info __externC int cyg_flash_verify_addr(const flashaddr_t address); __extern size_t cyg_flash_block_size(const cyg_flashaddr_t flash_base); -typedef struct cyg_block_info +typedef struct cyg_flash_block_info size_t block_size; cyg_unit32 blocks; -} cyg_block_info_t; +} cyg_flash_block_info_t; typedef struct { - flashaddr_t start; // First address - flashaddr_t end; // Last address - cyg_uint32 num_block_infos // Number of entries - cyg_block_info_t *blocks_info; // Info about one block size + flashaddr_t start; // First address + flashaddr_t end; // Last address + cyg_uint32 num_block_infos // Number of entries + const cyg_flash_block_info_t *blocks_info; // Info about one block size } cyg_flash_info_t; @@ -329,7 +329,7 @@ between the FLASH IO library the FLASH d flashaddr_t *end; // Last address void *priv; // Devices private data cyg_uint32 num_block_infos; // Number of entries - cyg_block_info_t *blocks_info; // Info about one block size + cyg_flash_block_info_t *blocks_info; // Info about one block size // The following are only written to by the FLASH IO layer. diff --git a/packages/io/flash/current/include/flash.h b/packages/io/flash/current/include/flash.h --- a/packages/io/flash/current/include/flash.h +++ b/packages/io/flash/current/include/flash.h @@ -8,9 +8,10 @@ //####ECOSGPLCOPYRIGHTBEGIN#### // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. -// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. +// copyright (C) 2004 Andrew Lunn +// Copyright (C) eCosCentric Ltd. // Copyright (C) 2003 Gary Thomas -// copyright (C) 2004 Andrew Lunn +// 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 @@ -43,7 +44,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): gthomas -// Contributors: gthomas, Andrew Lunn +// Contributors: gthomas, Andrew Lunn, bartv // Date: 2000-07-14 // Purpose: // Description: @@ -57,59 +58,62 @@ #include #include -#include -#include +#include +#include #ifdef CYGPKG_KERNEL #include #endif +// Currently a 32-bit quantity. In future this may be 64-bits on some +// platforms, e.g. to support very large nand flashes which can only +// be accessed indirectly. typedef CYG_ADDRESS cyg_flashaddr_t; -typedef struct cyg_block_info +typedef struct cyg_flash_block_info { size_t block_size; cyg_uint32 blocks; -} cyg_block_info_t; +} cyg_flash_block_info_t; // Information about what one device driver drives typedef struct { - cyg_flashaddr_t start; // First address - cyg_flashaddr_t end; // Last address - cyg_uint32 num_block_infos; // Number of entries - cyg_block_info_t *block_info; // Info about block sizes + cyg_flashaddr_t start; // First address + cyg_flashaddr_t end; // Last address + cyg_uint32 num_block_infos; // Number of entries + const cyg_flash_block_info_t* block_info; // Info about block sizes } cyg_flash_info_t; typedef int cyg_flash_printf(const char *fmt, ...); __externC int cyg_flash_init( cyg_flash_printf *pf ); __externC int cyg_flash_get_info(cyg_uint32 devno, cyg_flash_info_t * info); -__externC int cyg_flash_get_info_addr(cyg_flashaddr_t flash_base, +__externC int cyg_flash_get_info_addr(const cyg_flashaddr_t flash_base, cyg_flash_info_t * info); __externC int cyg_flash_verify_addr(const cyg_flashaddr_t address); __externC size_t cyg_flash_block_size(const cyg_flashaddr_t flash_base); -__externC int cyg_flash_read(cyg_flashaddr_t flash_base, - const void *ram_base, - const size_t len, +__externC int cyg_flash_read(const cyg_flashaddr_t flash_base, + void *ram_base, + size_t len, cyg_flashaddr_t *err_address); -__externC int cyg_flash_erase(const cyg_flashaddr_t flash_base, - const size_t len, +__externC int cyg_flash_erase(cyg_flashaddr_t flash_base, + size_t len, cyg_flashaddr_t *err_address); -__externC int cyg_flash_program(const cyg_flashaddr_t flash_base, - void *ram_base, - const size_t len, +__externC int cyg_flash_program(cyg_flashaddr_t flash_base, + const void *ram_base, + size_t len, cyg_flashaddr_t *err_address); __externC int cyg_flash_lock(const cyg_flashaddr_t flash_base, - const size_t len, + size_t len, cyg_flashaddr_t *err_address); __externC int cyg_flash_unlock(const cyg_flashaddr_t flash_base, - const size_t len, + size_t len, cyg_flashaddr_t *err_address); __externC const char *cyg_flash_errmsg(const int err); #ifdef CYGPKG_KERNEL __externC int cyg_flash_mutex_lock(const cyg_flashaddr_t from, - const size_t len); + size_t len); __externC int cyg_flash_mutex_unlock(const cyg_flashaddr_t from, - const size_t len); + size_t len); #endif #define CYG_FLASH_ERR_OK 0x00 // No error - operation complete diff --git a/packages/io/flash/current/include/flash_priv.h b/packages/io/flash/current/include/flash_priv.h --- a/packages/io/flash/current/include/flash_priv.h +++ b/packages/io/flash/current/include/flash_priv.h @@ -56,6 +56,8 @@ #include #include +#include +#include // Forward reference of the device structure struct cyg_flash_dev; @@ -86,7 +88,7 @@ struct cyg_flash_dev { cyg_flashaddr_t start; // First address cyg_flashaddr_t end; // Last address cyg_uint32 num_block_infos; // Number of entries - cyg_block_info_t *block_info; // Info about one block size + cyg_flash_block_info_t *block_info; // Info about one block size void *priv; // Devices private data void *config; // Configuration info diff --git a/packages/io/flash/current/src/flash.c b/packages/io/flash/current/src/flash.c --- a/packages/io/flash/current/src/flash.c +++ b/packages/io/flash/current/src/flash.c @@ -319,7 +319,7 @@ cyg_flash_get_info(cyg_uint32 Nth, cyg_f // Return information about the flash at the given address __externC int -cyg_flash_get_info_addr(cyg_flashaddr_t flash_base, cyg_flash_info_t * info) +cyg_flash_get_info_addr(const cyg_flashaddr_t flash_base, cyg_flash_info_t * info) { struct cyg_flash_dev *dev; int stat = CYG_FLASH_ERR_OK; @@ -337,7 +337,7 @@ cyg_flash_get_info_addr(cyg_flashaddr_t #ifdef CYGPKG_KERNEL // Lock the mutex's for a range of addresses __externC int -cyg_flash_mutex_lock(const cyg_flashaddr_t from, const size_t len) +cyg_flash_mutex_lock(const cyg_flashaddr_t from, size_t len) { struct cyg_flash_dev * dev; int stat = CYG_FLASH_ERR_OK; @@ -358,7 +358,7 @@ cyg_flash_mutex_lock(const cyg_flashaddr // Unlock the mutex's for a range of addresses __externC int -cyg_flash_mutex_unlock(const cyg_flashaddr_t from, const size_t len) +cyg_flash_mutex_unlock(const cyg_flashaddr_t from, size_t len) { struct cyg_flash_dev * dev; int stat = CYG_FLASH_ERR_OK; @@ -431,8 +431,8 @@ flash_block_begin(cyg_flashaddr_t addr, __externC int -cyg_flash_erase(const cyg_flashaddr_t flash_base, - const size_t len, +cyg_flash_erase(cyg_flashaddr_t flash_base, + size_t len, cyg_flashaddr_t *err_address) { cyg_flashaddr_t block, end_addr; @@ -520,14 +520,14 @@ cyg_flash_erase(const cyg_flashaddr_t fl } __externC int -cyg_flash_program(const cyg_flashaddr_t flash_base, - void *ram_base, - const size_t len, +cyg_flash_program(cyg_flashaddr_t flash_base, + const void *ram_base, + size_t len, cyg_flashaddr_t *err_address) { struct cyg_flash_dev * dev; cyg_flashaddr_t addr, end_addr, block; - unsigned char * ram = ram_base; + const unsigned char * ram = ram_base; size_t write_count, offset; int stat = CYG_FLASH_ERR_OK; int d_cache, i_cache; @@ -604,9 +604,9 @@ cyg_flash_program(const cyg_flashaddr_t } __externC int -cyg_flash_read(cyg_flashaddr_t flash_base, - const void *ram_base, - const size_t len, +cyg_flash_read(const cyg_flashaddr_t flash_base, + void *ram_base, + size_t len, cyg_flashaddr_t *err_address) { struct cyg_flash_dev * dev; @@ -697,7 +697,7 @@ cyg_flash_read(cyg_flashaddr_t flash_bas #ifdef CYGHWR_IO_FLASH_BLOCK_LOCKING __externC int cyg_flash_lock(const cyg_flashaddr_t flash_base, - const size_t len, + size_t len, cyg_flashaddr_t *err_address) { cyg_flashaddr_t block, end_addr; @@ -761,7 +761,7 @@ cyg_flash_lock(const cyg_flashaddr_t fla __externC int cyg_flash_unlock(const cyg_flashaddr_t flash_base, - const size_t len, + size_t len, cyg_flashaddr_t *err_address) { cyg_flashaddr_t block, end_addr; diff --git a/packages/io/flash/current/src/legacy_dev.c b/packages/io/flash/current/src/legacy_dev.c --- a/packages/io/flash/current/src/legacy_dev.c +++ b/packages/io/flash/current/src/legacy_dev.c @@ -86,7 +86,7 @@ static int legacy_flash_init (struct cyg_flash_dev *dev) { int err; - static cyg_block_info_t block_info[1]; + static cyg_flash_block_info_t block_info[1]; err=flash_hwr_init();