Mercurial > flash_v2
annotate packages/io/flash/current/include/flash_priv.h @ 1750:fac0499dabd6
Move legacy macros from a public to an internal header file, to
facilitate future clean-ups
| author | bartv |
|---|---|
| date | Mon, 22 Nov 2004 13:25:23 +0000 |
| parents | 80232dbac7fb |
| children | 61fbcc1cb232 |
| rev | line source |
|---|---|
| 1706 | 1 //========================================================================== |
| 2 // | |
|
1750
fac0499dabd6
Move legacy macros from a public to an internal header file, to
bartv
parents:
1749
diff
changeset
|
3 // flash_priv.h |
| 1706 | 4 // |
|
1750
fac0499dabd6
Move legacy macros from a public to an internal header file, to
bartv
parents:
1749
diff
changeset
|
5 // Flash programming - driver internals |
| 1706 | 6 // |
| 7 //========================================================================== | |
| 8 //####ECOSGPLCOPYRIGHTBEGIN#### | |
| 9 // ------------------------------------------- | |
| 10 // This file is part of eCos, the Embedded Configurable Operating System. | |
| 11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. | |
| 12 // Copyright (C) 2003 Gary Thomas | |
| 13 // copyright (C) 2004 Andrew Lunn | |
| 14 // | |
| 15 // 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 // Software Foundation; either version 2 or (at your option) any later version. | |
| 18 // | |
| 19 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY | |
| 20 // WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 21 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 22 // for more details. | |
| 23 // | |
| 24 // You should have received a copy of the GNU General Public License along | |
| 25 // with eCos; if not, write to the Free Software Foundation, Inc., | |
| 26 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | |
| 27 // | |
| 28 // As a special exception, if other files instantiate templates or use macros | |
| 29 // or inline functions from this file, or you compile this file and link it | |
| 30 // with other works to produce a work based on this file, this file does not | |
| 31 // by itself cause the resulting work to be covered by the GNU General Public | |
| 32 // License. However the source code for this file must still be made available | |
| 33 // in accordance with section (3) of the GNU General Public License. | |
| 34 // | |
| 35 // This exception does not invalidate any other reasons why a work based on | |
| 36 // this file might be covered by the GNU General Public License. | |
| 37 // | |
| 38 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. | |
| 39 // at http://sources.redhat.com/ecos/ecos-license/ | |
| 40 // ------------------------------------------- | |
| 41 //####ECOSGPLCOPYRIGHTEND#### | |
| 42 //========================================================================== | |
| 43 //#####DESCRIPTIONBEGIN#### | |
| 44 // | |
| 45 // Author(s): gthomas | |
| 46 // Contributors: gthomas, Andrew Lunn | |
| 47 // Date: 2000-07-14 | |
| 48 // Purpose: | |
| 49 // Description: | |
| 50 // | |
| 51 //####DESCRIPTIONEND#### | |
| 52 // | |
| 53 //========================================================================== | |
| 54 #ifndef _IO_FLASH_PRIV_H_ | |
| 55 #define _IO_FLASH_PRIV_H_ | |
| 56 | |
|
1747
a221170fac3d
Add an optimization for the common case of a single flash device
bartv
parents:
1745
diff
changeset
|
57 #include <pkgconf/system.h> |
|
a221170fac3d
Add an optimization for the common case of a single flash device
bartv
parents:
1745
diff
changeset
|
58 #include <pkgconf/io_flash.h> |
| 1749 | 59 #include <cyg/hal/hal_cache.h> |
| 60 #include <cyg/hal/hal_tables.h> | |
|
1747
a221170fac3d
Add an optimization for the common case of a single flash device
bartv
parents:
1745
diff
changeset
|
61 |
| 1706 | 62 // Forward reference of the device structure |
| 63 struct cyg_flash_dev; | |
| 64 | |
| 65 // Structure of pointers to functions in the device driver | |
| 66 struct cyg_flash_dev_funs { | |
| 67 int (*flash_init) (struct cyg_flash_dev *dev); | |
| 68 size_t (*flash_query) (struct cyg_flash_dev *dev, void * data, | |
| 69 const size_t len); | |
| 70 int (*flash_erase_block) (struct cyg_flash_dev *dev, | |
| 71 const cyg_flashaddr_t block_base); | |
| 72 int (*flash_program) (struct cyg_flash_dev *dev, | |
| 73 cyg_flashaddr_t base, | |
| 74 const void* data, const size_t len); | |
| 75 int (*flash_read) (struct cyg_flash_dev *dev, | |
| 76 const cyg_flashaddr_t base, | |
| 77 void* data, const size_t len); | |
| 78 int (*flash_hwr_map_error) (struct cyg_flash_dev *dev, int err); | |
| 79 int (*flash_block_lock) (struct cyg_flash_dev *dev, | |
| 80 const cyg_flashaddr_t block_base); | |
| 81 int (*flash_block_unlock) (struct cyg_flash_dev *dev, | |
| 82 const cyg_flashaddr_t block_base); | |
| 83 }; | |
| 84 | |
| 85 // Structure each device places in the HAL table | |
| 86 struct cyg_flash_dev { | |
| 87 struct cyg_flash_dev_funs *funs; // Function pointers | |
| 88 cyg_flashaddr_t start; // First address | |
| 89 cyg_flashaddr_t end; // Last address | |
| 90 cyg_uint32 num_block_infos; // Number of entries | |
| 1749 | 91 cyg_flash_block_info_t *block_info; // Info about one block size |
| 1706 | 92 |
| 93 void *priv; // Devices private data | |
| 94 void *config; // Configuration info | |
| 95 | |
| 96 // The following are only written to by the FLASH IO layer. | |
| 97 cyg_flash_printf *pf; // Pointer to diagnostic printf | |
| 98 bool init; // Device has been initialised | |
| 99 #ifdef CYGPKG_KERNEL | |
| 100 cyg_mutex_t mutex; // Mutex for thread safeness | |
| 101 #endif | |
|
1747
a221170fac3d
Add an optimization for the common case of a single flash device
bartv
parents:
1745
diff
changeset
|
102 #if (CYGHWR_IO_FLASH_DEVICE > 1) |
| 1706 | 103 struct cyg_flash_dev *next; // Pointer to next device |
|
1747
a221170fac3d
Add an optimization for the common case of a single flash device
bartv
parents:
1745
diff
changeset
|
104 #endif |
| 1706 | 105 } CYG_HAL_TABLE_TYPE; |
| 106 | |
| 107 #define CYG_FLASH_FUNS(funs,init,query,erase,prog,read,map,lock,unlock)\ | |
| 108 struct cyg_flash_dev_funs funs = \ | |
| 109 { \ | |
| 110 init, \ | |
| 111 query, \ | |
| 112 erase, \ | |
| 113 prog, \ | |
| 114 read, \ | |
| 115 map, \ | |
| 116 lock, \ | |
| 117 unlock \ | |
| 118 }; | |
| 119 | |
| 120 // We assume HAL tables are placed into RAM. | |
| 121 #define CYG_FLASH_DRIVER(name, _funs, _config, _start, _priv_size) \ | |
| 122 static char priv_ ## name [_priv_size]; \ | |
| 123 struct cyg_flash_dev name CYG_HAL_TABLE_ENTRY(cyg_flashdev) = { \ | |
| 124 .funs = _funs, \ | |
| 125 .config = _config, \ | |
| 126 .priv = priv_ ## name, \ | |
| 127 .start = _start, \ | |
| 128 }; | |
| 129 | |
| 1745 | 130 #ifdef CYGHWR_IO_FLASH_DEVICE_LEGACY |
| 1706 | 131 struct flash_info { |
| 132 int block_size; // Assuming fixed size "blocks" | |
| 133 int blocks; // Number of blocks | |
| 134 int buffer_size; // Size of write buffer (only defined for some devices) | |
| 135 unsigned long block_mask; | |
| 136 void *start, *end; // Address range | |
| 137 int init; | |
| 138 cyg_flash_printf *pf; | |
| 139 }; | |
| 140 | |
| 141 externC struct flash_info flash_info; | |
| 142 externC int flash_hwr_init(void); | |
| 143 externC int flash_hwr_map_error(int err); | |
| 144 externC void flash_dev_query(void *data); | |
| 1745 | 145 #endif // CYGHWR_IO_FLASH_DEVICE_LEGACY |
| 1706 | 146 |
| 147 #endif // _IO_FLASH_PRIV_H_ |
