Mercurial > flash_v2
comparison packages/io/flash/current/include/flash.h @ 1749:80232dbac7fb
Flash API clean-ups
| author | bartv |
|---|---|
| date | Mon, 22 Nov 2004 12:05:55 +0000 |
| parents | 172edf8a96d8 |
| children | 96ec7e534d98 |
comparison
equal
deleted
inserted
replaced
| 1748:6588c38f09cf | 1749:80232dbac7fb |
|---|---|
| 6 // | 6 // |
| 7 //========================================================================== | 7 //========================================================================== |
| 8 //####ECOSGPLCOPYRIGHTBEGIN#### | 8 //####ECOSGPLCOPYRIGHTBEGIN#### |
| 9 // ------------------------------------------- | 9 // ------------------------------------------- |
| 10 // This file is part of eCos, the Embedded Configurable Operating System. | 10 // This file is part of eCos, the Embedded Configurable Operating System. |
| 11 // copyright (C) 2004 Andrew Lunn | |
| 12 // Copyright (C) eCosCentric Ltd. | |
| 13 // Copyright (C) 2003 Gary Thomas | |
| 11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. | 14 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
| 12 // Copyright (C) 2003 Gary Thomas | |
| 13 // copyright (C) 2004 Andrew Lunn | |
| 14 // | 15 // |
| 15 // eCos is free software; you can redistribute it and/or modify it under | 16 // eCos is free software; you can redistribute it and/or modify it under |
| 16 // the terms of the GNU General Public License as published by the Free | 17 // the terms of the GNU General Public License as published by the Free |
| 17 // Software Foundation; either version 2 or (at your option) any later version. | 18 // Software Foundation; either version 2 or (at your option) any later version. |
| 18 // | 19 // |
| 41 //####ECOSGPLCOPYRIGHTEND#### | 42 //####ECOSGPLCOPYRIGHTEND#### |
| 42 //========================================================================== | 43 //========================================================================== |
| 43 //#####DESCRIPTIONBEGIN#### | 44 //#####DESCRIPTIONBEGIN#### |
| 44 // | 45 // |
| 45 // Author(s): gthomas | 46 // Author(s): gthomas |
| 46 // Contributors: gthomas, Andrew Lunn | 47 // Contributors: gthomas, Andrew Lunn, bartv |
| 47 // Date: 2000-07-14 | 48 // Date: 2000-07-14 |
| 48 // Purpose: | 49 // Purpose: |
| 49 // Description: | 50 // Description: |
| 50 // | 51 // |
| 51 //####DESCRIPTIONEND#### | 52 //####DESCRIPTIONEND#### |
| 55 #ifndef _IO_FLASH_H_ | 56 #ifndef _IO_FLASH_H_ |
| 56 #define _IO_FLASH_H_ | 57 #define _IO_FLASH_H_ |
| 57 | 58 |
| 58 #include <pkgconf/system.h> | 59 #include <pkgconf/system.h> |
| 59 #include <pkgconf/io_flash.h> | 60 #include <pkgconf/io_flash.h> |
| 60 #include <cyg/hal/hal_cache.h> | 61 #include <stddef.h> |
| 61 #include <cyg/hal/hal_tables.h> | 62 #include <cyg/infra/cyg_type.h> |
| 62 #ifdef CYGPKG_KERNEL | 63 #ifdef CYGPKG_KERNEL |
| 63 #include <cyg/kernel/kapi.h> | 64 #include <cyg/kernel/kapi.h> |
| 64 #endif | 65 #endif |
| 65 | 66 |
| 67 // Currently a 32-bit quantity. In future this may be 64-bits on some | |
| 68 // platforms, e.g. to support very large nand flashes which can only | |
| 69 // be accessed indirectly. | |
| 66 typedef CYG_ADDRESS cyg_flashaddr_t; | 70 typedef CYG_ADDRESS cyg_flashaddr_t; |
| 67 | 71 |
| 68 typedef struct cyg_block_info | 72 typedef struct cyg_flash_block_info |
| 69 { | 73 { |
| 70 size_t block_size; | 74 size_t block_size; |
| 71 cyg_uint32 blocks; | 75 cyg_uint32 blocks; |
| 72 } cyg_block_info_t; | 76 } cyg_flash_block_info_t; |
| 73 | 77 |
| 74 // Information about what one device driver drives | 78 // Information about what one device driver drives |
| 75 typedef struct { | 79 typedef struct { |
| 76 cyg_flashaddr_t start; // First address | 80 cyg_flashaddr_t start; // First address |
| 77 cyg_flashaddr_t end; // Last address | 81 cyg_flashaddr_t end; // Last address |
| 78 cyg_uint32 num_block_infos; // Number of entries | 82 cyg_uint32 num_block_infos; // Number of entries |
| 79 cyg_block_info_t *block_info; // Info about block sizes | 83 const cyg_flash_block_info_t* block_info; // Info about block sizes |
| 80 } cyg_flash_info_t; | 84 } cyg_flash_info_t; |
| 81 | 85 |
| 82 typedef int cyg_flash_printf(const char *fmt, ...); | 86 typedef int cyg_flash_printf(const char *fmt, ...); |
| 83 __externC int cyg_flash_init( cyg_flash_printf *pf ); | 87 __externC int cyg_flash_init( cyg_flash_printf *pf ); |
| 84 __externC int cyg_flash_get_info(cyg_uint32 devno, | 88 __externC int cyg_flash_get_info(cyg_uint32 devno, |
| 85 cyg_flash_info_t * info); | 89 cyg_flash_info_t * info); |
| 86 __externC int cyg_flash_get_info_addr(cyg_flashaddr_t flash_base, | 90 __externC int cyg_flash_get_info_addr(const cyg_flashaddr_t flash_base, |
| 87 cyg_flash_info_t * info); | 91 cyg_flash_info_t * info); |
| 88 __externC int cyg_flash_verify_addr(const cyg_flashaddr_t address); | 92 __externC int cyg_flash_verify_addr(const cyg_flashaddr_t address); |
| 89 __externC size_t cyg_flash_block_size(const cyg_flashaddr_t flash_base); | 93 __externC size_t cyg_flash_block_size(const cyg_flashaddr_t flash_base); |
| 90 __externC int cyg_flash_read(cyg_flashaddr_t flash_base, | 94 __externC int cyg_flash_read(const cyg_flashaddr_t flash_base, |
| 91 const void *ram_base, | 95 void *ram_base, |
| 92 const size_t len, | 96 size_t len, |
| 93 cyg_flashaddr_t *err_address); | 97 cyg_flashaddr_t *err_address); |
| 94 __externC int cyg_flash_erase(const cyg_flashaddr_t flash_base, | 98 __externC int cyg_flash_erase(cyg_flashaddr_t flash_base, |
| 95 const size_t len, | 99 size_t len, |
| 96 cyg_flashaddr_t *err_address); | 100 cyg_flashaddr_t *err_address); |
| 97 __externC int cyg_flash_program(const cyg_flashaddr_t flash_base, | 101 __externC int cyg_flash_program(cyg_flashaddr_t flash_base, |
| 98 void *ram_base, | 102 const void *ram_base, |
| 99 const size_t len, | 103 size_t len, |
| 100 cyg_flashaddr_t *err_address); | 104 cyg_flashaddr_t *err_address); |
| 101 __externC int cyg_flash_lock(const cyg_flashaddr_t flash_base, | 105 __externC int cyg_flash_lock(const cyg_flashaddr_t flash_base, |
| 102 const size_t len, | 106 size_t len, |
| 103 cyg_flashaddr_t *err_address); | 107 cyg_flashaddr_t *err_address); |
| 104 __externC int cyg_flash_unlock(const cyg_flashaddr_t flash_base, | 108 __externC int cyg_flash_unlock(const cyg_flashaddr_t flash_base, |
| 105 const size_t len, | 109 size_t len, |
| 106 cyg_flashaddr_t *err_address); | 110 cyg_flashaddr_t *err_address); |
| 107 __externC const char *cyg_flash_errmsg(const int err); | 111 __externC const char *cyg_flash_errmsg(const int err); |
| 108 #ifdef CYGPKG_KERNEL | 112 #ifdef CYGPKG_KERNEL |
| 109 __externC int cyg_flash_mutex_lock(const cyg_flashaddr_t from, | 113 __externC int cyg_flash_mutex_lock(const cyg_flashaddr_t from, |
| 110 const size_t len); | 114 size_t len); |
| 111 __externC int cyg_flash_mutex_unlock(const cyg_flashaddr_t from, | 115 __externC int cyg_flash_mutex_unlock(const cyg_flashaddr_t from, |
| 112 const size_t len); | 116 size_t len); |
| 113 #endif | 117 #endif |
| 114 | 118 |
| 115 #define CYG_FLASH_ERR_OK 0x00 // No error - operation complete | 119 #define CYG_FLASH_ERR_OK 0x00 // No error - operation complete |
| 116 #define CYG_FLASH_ERR_INVALID 0x01 // Invalid FLASH address | 120 #define CYG_FLASH_ERR_INVALID 0x01 // Invalid FLASH address |
| 117 #define CYG_FLASH_ERR_ERASE 0x02 // Error trying to erase | 121 #define CYG_FLASH_ERR_ERASE 0x02 // Error trying to erase |
