annotate packages/io/flash/current/src/flash_legacy.h @ 2729:74dbf4c3f2e1 after-copyright-change-20090129

Update all copyright banners to reflect FSF ownership; fix and improve licence text.
author jlarmour
date Thu, 29 Jan 2009 17:47:46 +0000
parents a2f5434df2cb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2626
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
1 //==========================================================================
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
2 //
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
3 // flash_legacy.h
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
4 //
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
5 // Flash programming - some internal implementation details.
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
6 //
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
7 //==========================================================================
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2626
diff changeset
8 // ####ECOSGPLCOPYRIGHTBEGIN####
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2626
diff changeset
9 // -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2626
diff changeset
10 // This file is part of eCos, the Embedded Configurable Operating System.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2626
diff changeset
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
2626
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
12 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2626
diff changeset
13 // eCos is free software; you can redistribute it and/or modify it under
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2626
diff changeset
14 // the terms of the GNU General Public License as published by the Free
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2626
diff changeset
15 // Software Foundation; either version 2 or (at your option) any later
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2626
diff changeset
16 // version.
2626
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
17 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2626
diff changeset
18 // eCos is distributed in the hope that it will be useful, but WITHOUT
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2626
diff changeset
19 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2626
diff changeset
20 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2626
diff changeset
21 // for more details.
2626
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
22 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2626
diff changeset
23 // You should have received a copy of the GNU General Public License
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2626
diff changeset
24 // along with eCos; if not, write to the Free Software Foundation, Inc.,
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2626
diff changeset
25 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2626
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
26 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2626
diff changeset
27 // As a special exception, if other files instantiate templates or use
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2626
diff changeset
28 // macros or inline functions from this file, or you compile this file
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2626
diff changeset
29 // and link it with other works to produce a work based on this file,
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2626
diff changeset
30 // this file does not by itself cause the resulting work to be covered by
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2626
diff changeset
31 // the GNU General Public License. However the source code for this file
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2626
diff changeset
32 // must still be made available in accordance with section (3) of the GNU
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2626
diff changeset
33 // General Public License v2.
2626
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
34 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2626
diff changeset
35 // This exception does not invalidate any other reasons why a work based
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2626
diff changeset
36 // on this file might be covered by the GNU General Public License.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2626
diff changeset
37 // -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2626
diff changeset
38 // ####ECOSGPLCOPYRIGHTEND####
2626
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
39 //==========================================================================
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
40 //#####DESCRIPTIONBEGIN####
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
41 //
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
42 // Author(s): gthomas
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
43 // Contributors: gthomas, Andrew Lunn
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
44 // Date: 2000-07-14
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
45 // Purpose:
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
46 // Description:
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
47 //
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
48 //####DESCRIPTIONEND####
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
49 //
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
50 //==========================================================================
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
51
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
52 #include <pkgconf/system.h>
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
53 #include <pkgconf/io_flash.h>
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
54 #include <cyg/infra/cyg_type.h>
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
55 #include <cyg/hal/hal_arch.h>
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
56 #include <cyg/hal/hal_cache.h>
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
57
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
58
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
59 // Some FLASH devices may require additional support, e.g. to turn on
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
60 // appropriate voltage drivers, before any operation.
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
61 #ifdef CYGIMP_FLASH_ENABLE
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
62 # define FLASH_Enable(__start, __end) CYGIMP_FLASH_ENABLE((void *)__start, (void *)__end)
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
63 extern void CYGIMP_FLASH_ENABLE(void *, void *);
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
64 #else
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
65 # define FLASH_Enable(_start_, _end_) CYG_EMPTY_STATEMENT
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
66 #endif
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
67 #ifdef CYGIMP_FLASH_DISABLE
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
68 # define FLASH_Disable(__start, __end) CYGIMP_FLASH_DISABLE((void *)__start, (void *)__end)
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
69 extern void CYGIMP_FLASH_DISABLE(void *, void *);
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
70 #else
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
71 # define FLASH_Disable(_start_, _end_) CYG_EMPTY_STATEMENT
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
72 #endif
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
73
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
74 //
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
75 // Some platforms have a DIP switch or jumper that tells the software that
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
76 // the flash is write protected.
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
77 //
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
78 #ifdef CYGSEM_IO_FLASH_SOFT_WRITE_PROTECT
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
79 externC cyg_bool plf_flash_query_soft_wp(void *addr, int len);
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
80 #endif
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
81
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
82 //---------------------------------------------------------------------------
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
83 // If all of the flash devices handle cache themselves, or do not need any
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
84 // special cache treatment, then the flash macros can be no-ops.
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
85 #ifndef CYGHWR_IO_FLASH_DEVICE_NEEDS_CACHE_HANDLED
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
86 # undef HAL_FLASH_CACHES_OFF
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
87 # undef HAL_FLASH_CACHES_ON
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
88 # undef HAL_FLASH_CACHES_STATE
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
89 # define HAL_FLASH_CACHES_OFF(_d_, _i_) CYG_EMPTY_STATEMENT
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
90 # define HAL_FLASH_CACHES_ON(_d_, _i_) CYG_EMPTY_STATEMENT
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
91 # define HAL_FLASH_CACHES_STATE(_d_, _i_) CYG_EMPTY_STATEMENT
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
92 #endif
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
93
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
94 // Execution of flash code must be done inside a
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
95 // HAL_FLASH_CACHES_OFF/HAL_FLASH_CACHES_ON region - disabling the
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
96 // cache on unified cache systems is necessary to prevent burst access
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
97 // to the flash area being programmed. With Harvard style caches, only
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
98 // the data cache needs to be disabled, but the instruction cache is
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
99 // disabled for consistency.
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
100
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
101 // Targets may provide alternative implementations for these macros in
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
102 // the hal_cache.h (or var/plf) files.
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
103
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
104 // The first part below is a generic, optimal implementation. The
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
105 // second part is the old implementation that has been tested to work
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
106 // on some targets - but it is not be suitable for targets that would
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
107 // do burst access to the flash (it does not disable the data cache).
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
108
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
109 // Both implementations must be called with interrupts disabled.
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
110
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
111 // NOTE: Do _not_ change any of the below macros without checking that
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
112 // the changed code still works on _all_ platforms that rely on these
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
113 // macros. There is no such thing as logical and correct when dealing
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
114 // with different cache and IO models, so _do not_ mess with this code
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
115 // unless you test it properly afterwards.
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
116
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
117 #ifndef HAL_FLASH_CACHES_OFF
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
118
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
119 // Some drivers have only been tested with the old macros below.
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
120 #ifndef HAL_FLASH_CACHES_OLD_MACROS
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
121
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
122 #ifdef HAL_CACHE_UNIFIED
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
123
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
124 // Note: the ucache code has not been tested yet on any target.
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
125 #define HAL_FLASH_CACHES_OFF(_d_, _i_) \
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
126 CYG_MACRO_START \
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
127 _i_ = 0; /* avoids warning */ \
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
128 HAL_UCACHE_IS_ENABLED(_d_); \
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
129 HAL_UCACHE_SYNC(); \
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
130 HAL_UCACHE_INVALIDATE_ALL(); \
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
131 HAL_UCACHE_DISABLE(); \
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
132 CYG_MACRO_END
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
133
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
134 #define HAL_FLASH_CACHES_ON(_d_, _i_) \
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
135 CYG_MACRO_START \
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
136 if (_d_) HAL_UCACHE_ENABLE(); \
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
137 CYG_MACRO_END
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
138
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
139 #else // HAL_CACHE_UNIFIED
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
140
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
141 #define HAL_FLASH_CACHES_OFF(_d_, _i_) \
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
142 CYG_MACRO_START \
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
143 _i_ = 0; /* avoids warning */ \
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
144 HAL_DCACHE_IS_ENABLED(_d_); \
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
145 HAL_DCACHE_SYNC(); \
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
146 HAL_DCACHE_INVALIDATE_ALL(); \
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
147 HAL_DCACHE_DISABLE(); \
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
148 HAL_ICACHE_INVALIDATE_ALL(); \
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
149 CYG_MACRO_END
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
150
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
151 #define HAL_FLASH_CACHES_ON(_d_, _i_) \
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
152 CYG_MACRO_START \
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
153 if (_d_) HAL_DCACHE_ENABLE(); \
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
154 CYG_MACRO_END
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
155
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
156 #endif // HAL_CACHE_UNIFIED
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
157
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
158 #else // HAL_FLASH_CACHES_OLD_MACROS
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
159
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
160 // Note: This implementation is broken as it will always enable the i-cache
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
161 // even if it was not enabled before. It also doesn't work if the
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
162 // target uses burst access to flash since the d-cache is left enabled.
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
163 // However, this does not mean you can change this code! Leave it as
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
164 // is - if you want a different implementation, provide it in the
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
165 // arch/var/platform cache header file.
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
166
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
167 #define HAL_FLASH_CACHES_OFF(_d_, _i_) \
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
168 _d_ = 0; /* avoids warning */ \
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
169 _i_ = 0; /* avoids warning */ \
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
170 HAL_DCACHE_SYNC(); \
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
171 HAL_ICACHE_DISABLE();
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
172
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
173 #define HAL_FLASH_CACHES_ON(_d_, _i_) \
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
174 HAL_ICACHE_ENABLE();
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
175
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
176 #endif // HAL_FLASH_CACHES_OLD_MACROS
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
177
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
178 #endif // HAL_FLASH_CACHES_OFF
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
179
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
180 #ifndef HAL_FLASH_CACHES_STATE
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
181 # define HAL_FLASH_CACHES_STATE(_d_, _i_) int _d_, _i_
a2f5434df2cb Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff changeset
182 #endif