1 |
786 |
skrzyp |
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
Freescale MCF5272 Processor Support
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
The MCF5272 ColdFire Processor
|
42 |
|
|
|
43 |
|
|
|
44 |
|
|
CYGPKG_HAL_M68K_MCF5272
|
45 |
|
|
eCos Support for the Freescale MCF5272 Processor
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
Description
|
49 |
|
|
|
50 |
|
|
The MCF5272 is one member of the Freescale MCFxxxx ColdFire range of
|
51 |
|
|
processors. It comes with a number of on-chip peripherals including 2
|
52 |
|
|
UARTs, ethernet, and USB slave. The processor HAL package
|
53 |
|
|
CYGPKG_HAL_M68K_MCF5272 provides support for
|
54 |
|
|
features that are specific to the MCF5272. It complements the M68K
|
55 |
|
|
architectural HAL package CYGPKG_HAL_M68K and the
|
56 |
|
|
variant HAL package CYGPKG_HAL_M68K_MCFxxxx. An
|
57 |
|
|
eCos configuration should also include a platform HAL package, for
|
58 |
|
|
example CYGPKG_HAL_M68K_M5272C3 to support
|
59 |
|
|
board-level details like the external memory chips.
|
60 |
|
|
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
Configuration
|
64 |
|
|
|
65 |
|
|
The MCF5272 processor HAL package should be loaded automatically when
|
66 |
|
|
eCos is configured for appropriate target hardware. It should never be
|
67 |
|
|
necessary to load this package explicitly. Unloading the package
|
68 |
|
|
should only happen as a side effect of switching target hardware.
|
69 |
|
|
|
70 |
|
|
|
71 |
|
|
The component CYGPKG_HAL_M68K_MCF5272_HARDWARE
|
72 |
|
|
contains configuration options for the available hardware. This
|
73 |
|
|
includes all GPIO pin settings, with defaults provided by the
|
74 |
|
|
platform HAL. In turn the pin settings are used to determine defaults
|
75 |
|
|
for other hardware settings, for example which of the two on-chip
|
76 |
|
|
uarts are usable. Users can override these settings if necessary,
|
77 |
|
|
subject to any constraints imposed by the platform HAL, but care has
|
78 |
|
|
to be taken that the resulting configuration still matches the actual
|
79 |
|
|
hardware.
|
80 |
|
|
|
81 |
|
|
|
82 |
|
|
The option CYGIMP_HAL_M68K_MCF5272_IDLE controls
|
83 |
|
|
what happens in configurations containing the eCos kernel when the
|
84 |
|
|
idle thread runs, i.e. when there is nothing for the processor to do
|
85 |
|
|
until the next interrupt comes in. Usually the processor made to
|
86 |
|
|
sleep, halting the cpu but leaving all peripherals active.
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
The package contains a single configuration option
|
90 |
|
|
CYGFUN_HAL_M68K_MCF5272_PROFILE_TIMER. This
|
91 |
|
|
controls the support for gprof-based profiling. By default it is
|
92 |
|
|
active and enabled if the configuration contains the gprof profiling
|
93 |
|
|
package, otherwise inactive. The relevant code uses hardware timer 2,
|
94 |
|
|
so that timer is no longer available for application code. If the
|
95 |
|
|
timer is required but a platform HAL provides an alternative
|
96 |
|
|
implementation of the profiling support then this option can be
|
97 |
|
|
disabled.
|
98 |
|
|
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
The HAL Port
|
102 |
|
|
|
103 |
|
|
This section describes how the MCF5272 processor HAL package
|
104 |
|
|
implements parts of the eCos HAL specification. It should be read in
|
105 |
|
|
conjunction with similar sections from the architectural and variant
|
106 |
|
|
HAL documentation.
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
HAL I/O
|
110 |
|
|
|
111 |
|
|
The header
|
112 |
|
|
file
|
113 |
|
|
specifies which generic MCFxxxx devices are present, and provides
|
114 |
|
|
details of MCF5272-specific devices. This header file is automatically
|
115 |
|
|
included by the architectural
|
116 |
|
|
header , so
|
117 |
|
|
typically application code and other packages will just include the
|
118 |
|
|
latter.
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
It should be noted that the Freescale documentation is occasionally
|
122 |
|
|
confusing when it comes to numbering devices. For example the four
|
123 |
|
|
on-chip timers are numbered TMR0 to TMR3, but in the interrupt
|
124 |
|
|
controller the corresponding interrupts are numbered TMR1 to TMR4. The
|
125 |
|
|
eCos port consistently starts numbering at 0, so these interrupts have
|
126 |
|
|
been renamed TMR0 to TMR3.
|
127 |
|
|
|
128 |
|
|
|
129 |
|
|
|
130 |
|
|
Interrupt Handling
|
131 |
|
|
|
132 |
|
|
The header file
|
133 |
|
|
class="headerfile">cyg/hal/proc_intr.h provides VSR and ISR
|
134 |
|
|
vector numbers for all interrupt sources. The VSR vector number, for
|
135 |
|
|
example CYGNUM_HAL_VECTOR_TMR0, should be used
|
136 |
|
|
for calls like cyg_interrupt_get_vsr. It
|
137 |
|
|
corresponds directly to the M68K exception number. The ISR vector
|
138 |
|
|
number, for example CYGNUM_HAL_ISR_TMR0, should be
|
139 |
|
|
used for calls like cyg_interrupt_create. This
|
140 |
|
|
header file is automatically included by the architectural header
|
141 |
|
|
, and other
|
142 |
|
|
packages and application code will normally just include the latter.
|
143 |
|
|
|
144 |
|
|
|
145 |
|
|
The eCos HAL macros HAL_INTERRUPT_MASK,
|
146 |
|
|
HAL_INTERRUPT_UNMASK,
|
147 |
|
|
HAL_INTERRUPT_SET_LEVEL,
|
148 |
|
|
HAL_INTERRUPT_ACKNOWLEDGE, and
|
149 |
|
|
HAL_INTERRUPT_CONFIGURE are implemented by the
|
150 |
|
|
processor HAL. The mask and unmask operations are straightforward,
|
151 |
|
|
simply manipulating the on-chip interrupt controller. The acknowledge
|
152 |
|
|
and configure macros are only relevant for external interrupts:
|
153 |
|
|
internal interrupts generated by on-chip devices do not need to be
|
154 |
|
|
acknowledged. The set-level operation, used implicitly by higher level
|
155 |
|
|
code such as cyg_interrupt_create, is mapped on
|
156 |
|
|
to M68K IPL levels so interrupts can be given a priority between 1
|
157 |
|
|
and 7. Priority 7 corresponds to non-maskable interrupts and must be
|
158 |
|
|
used with care: such interrupts cannot be managed safely by the usual
|
159 |
|
|
eCos ISR and DSR mechanisms; instead application code will have to
|
160 |
|
|
install a custom VSR and manage the entire interrupt.
|
161 |
|
|
|
162 |
|
|
|
163 |
|
|
|
164 |
|
|
Clock Support
|
165 |
|
|
|
166 |
|
|
The processor HAL provides support for the eCos system clock. This
|
167 |
|
|
always uses hardware timer 3, which should not be used directly by
|
168 |
|
|
application code. If gprof-based profiling is in use then that will
|
169 |
|
|
use hardware timer 2. Timers 0 and 1 are never used by eCos so
|
170 |
|
|
application code is free to manipulate these as required.
|
171 |
|
|
|
172 |
|
|
|
173 |
|
|
Some of the configuration options related to the system clock, for
|
174 |
|
|
example CYGNUM_HAL_RTC_PERIOD, are actually
|
175 |
|
|
contained in the platform HAL rather than the processor HAL. These
|
176 |
|
|
options need to take into account the processor clock speed, a
|
177 |
|
|
characteristic of the platform rather than the processor.
|
178 |
|
|
|
179 |
|
|
|
180 |
|
|
|
181 |
|
|
Cache Handling
|
182 |
|
|
|
183 |
|
|
The MCF5272 has a small instruction cache of 1024 bytes. This is fully
|
184 |
|
|
supported by the processor HAL. There is no data cache.
|
185 |
|
|
|
186 |
|
|
|
187 |
|
|
|
188 |
|
|
Idle Thread Support
|
189 |
|
|
|
190 |
|
|
The configuration
|
191 |
|
|
option CYGIMP_HAL_M68K_MCF5272_IDLE controls what
|
192 |
|
|
happens when the kernel idle thread runs. The default behaviour is to
|
193 |
|
|
put the processor to sleep until the next interrupt.
|
194 |
|
|
|
195 |
|
|
|
196 |
|
|
|
197 |
|
|
Profiling Support
|
198 |
|
|
|
199 |
|
|
The MCF5272 processor HAL provides a profiling timer for use with the
|
200 |
|
|
gprof profiling package. This uses hardware timer 2, so application
|
201 |
|
|
code should not manipulate this timer if profiling is enabled. The
|
202 |
|
|
M68K architectural HAL implements the mcount
|
203 |
|
|
function so profiling is fully supported on all MCF5272-based platforms.
|
204 |
|
|
|
205 |
|
|
|
206 |
|
|
|
207 |
|
|
Other Issues
|
208 |
|
|
|
209 |
|
|
The MCF5272 processor HAL does not affect the implementation of data
|
210 |
|
|
types, stack size definitions, linker scripts, SMP support, system
|
211 |
|
|
startup, or debug support. The architectural HAL's bit index
|
212 |
|
|
instructions are used rather than the MCFxxxx variant HAL's versions
|
213 |
|
|
since the MCF5272 does not implement the ff1 and bitrev instructions.
|
214 |
|
|
|
215 |
|
|
|
216 |
|
|
|
217 |
|
|
Other Functionality
|
218 |
|
|
|
219 |
|
|
The MCF5272 processor HAL only implements functionality defined in the
|
220 |
|
|
eCos HAL specification and does not export any additional functions.
|
221 |
|
|
|
222 |
|
|
|
223 |
|
|
|
224 |
|
|
|
225 |
|
|
|
226 |
|
|
|