OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [m68k/] [mcf52xx/] [var/] [current/] [doc/] [mcf52xx.sgml] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
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 MCFxxxx Variant Support
38
 
39
40
  
41
    MCFxxxx ColdFire Processors
42
  
43
  
44
    CYGPKG_HAL_M68K_MCFxxxx
45
    eCos Support for Freescale MCFxxxx Processors
46
  
47
 
48
  Description
49
    
50
The Freescale ColdFire family is a range of processors including the
51
MCF5206 and the MCF5282. From a programmer's perspective these
52
processors all share basically the same processor core, albeit with
53
minor differences in the instruction set. They differ in areas like
54
performance, on-chip peripherals and caches. Even when it comes to
55
peripherals there is a lot of commonality. For example many but not
56
all Coldfire processors use the same basic interrupt controller(s) as
57
the MCF5282. Similarly the on-chip UARTs tend to use the same basic
58
design although there are variations in the number of UARTs, the fifo
59
sizes, and in certain details.
60
    
61
    
62
    The MCFxxxx variant HAL package
63
CYGPKG_HAL_M68K_MCFxxxx provides support for
64
various features that are common to many but not all Coldfire
65
processors. This includes HAL diagnostics via an on-chip UART and
66
interrupt controller management for those processors which have
67
MCF5282-compatible controllers. The variant HAL complements the M68K
68
architectural HAL package. An eCos configuration should also include a
69
processor-specific HAL package such as
70
CYGPKG_HAL_M68K_MCF5272 to support the
71
chip-specific peripherals and cache details, and a platform HAL
72
package such as CYGPKG_HAL_M68K_M5272C3 to support
73
board-level details like external memory chips. The processor or
74
platform HAL can override the functionality provided by the variant
75
HAL.
76
    
77
  
78
 
79
  Configuration
80
    
81
The MCFxxxx variant HAL package should be loaded automatically when
82
eCos is configured for appropriate target hardware. It should never be
83
necessary to load this package explicitly. Unloading the package
84
should only happen as a side effect of switching target hardware.
85
    
86
    
87
On most ColdFire platforms the variant HAL will provide the HAL
88
diagnostics support via one of the UARTs. Some platforms may provide
89
their own HAL diagnostics facility, for example output via an LCD. The
90
variant HAL diagnostics support is active if the processor or platform
91
implements the
92
CYGINT_HAL_M68K_MCFxxxx_DIAGNOSTICS_USE_DEFAULT
93
interface. It is also active only in configurations which do not rely
94
on an underlying rom monitor such as RedBoot:
95
if CYGSEM_HAL_USE_ROM_MONITOR is enabled then the
96
default diagnostics channel will automatically be inherited from
97
RedBoot. The variant HAL then provides a number of configuration
98
options related to diagnostics:
99
    
100
    
101
      
102
        CYGHWR_HAL_M68K_MCFxxxx_DIAGNOSTICS_PORT
103
        
104
This selects the destination for HAL diagnostics. The number of UARTs
105
available depends on the processor, and on any given board some of the
106
UARTs may not be connected. Hence the variant HAL looks for
107
configuration options
108
CYGHWR_HAL_M68K_MCFxxxx_UART0,
109
CYGHWR_HAL_M68K_MCFxxxx_UART1 and
110
CYGHWR_HAL_M68K_MCFxxxx_UART2 to see which on-chip
111
UARTs are actually available on the processor and target hardware, and
112
uses this information to let the user select a UART.
113
        
114
        
115
When a UART is in use as the HAL diagnostics channel, that UART
116
should not be used for any other purpose. In particular application
117
code should avoid using it for I/O via the serial driver.
118
        
119
      
120
      
121
        CYGNUM_HAL_M68K_MCFxxxx_DIAGNOSTICS_BAUD
122
        
123
When a UART is selected for HAL diagnostics this option specifies the
124
default baud rate. The most common setting is 38400. That provides a
125
compromise between performance and reliability, especially in
126
electrically noisy environments such as an industrial environment or a
127
test farm. Some platforms may define
128
CYGNUM_HAL_M68K_MCFxxxx_DIAGNOSTICS_DEFAULT_BAUD
129
to handle scenarios where another default baud rate is preferable,
130
typically for compatibility with existing software.
131
        
132
      
133
      
134
        CYGNUM_HAL_M68K_MCFxxxx_DIAGNOSTICS_ISRPRI
135
        
136
Usually the HAL diagnostics channel is driven in polled mode but in
137
some scenarios interrupts are required. For example, when debugging an
138
application over a serial line on top of the gdb stubs provided by
139
RedBoot, the user should be able to interrupt the application with a
140
control-C. The application will not be polling the HAL diagnostics
141
UART at this point so instead the eCos interrupt management code
142
interacts with the gdb stubs to do the right thing. This configuration
143
option selects the interrupt priority. It should be noted that on some
144
processors with MCF5282-compatible interrupt controllers all
145
priorities for enabled interrupts should be unique, and it is the
146
responsibility of application developers to ensure this condition is
147
satisfied.
148
        
149
      
150
    
151
  
152
 
153
  The HAL Port
154
    
155
This section describes how the MCFxxxx variant HAL package implements
156
parts of the eCos HAL specification. It should be read in conjunction
157
with similar sections from the architectural and processor HAL
158
documentation.
159
    
160
 
161
    HAL I/O
162
      
163
The cyg/hal/var_io.h header
164
provides various definitions for on-chip peripherals, where the
165
current processor has peripherals compatible with the MCF5282's.
166
This header is automatically included by the architectural
167
cyg/hal/hal_io.h so other
168
packages and application code will usually only include the latter.
169
      
170
      
171
It is up to the processor HAL to specify exactly what 
172
class="headerfile">var_io.h should export. For example the
173
MCF5213's proc_io.h header
174
contains the following:
175
      
176
      
177
# define HAL_MCFxxxx_HAS_MCF5282_INTC               1
178
# define HAL_MCFxxxx_INTC0_BASE                     (HAL_MCF521x_IPSBAR + 0x00000C00)
179
      
180
      
181
This enables support within the variant HAL for a single
182
MCF5282-compatible interrupt controller, and cases 
183
class="headerfile">var_io.h to export symbols such as:
184
      
185
      
186
#ifdef HAL_MCFxxxx_HAS_MCF5282_INTC
187
// Two 32-bit interrupt mask registers
188
# define HAL_MCFxxxx_INTCx_IMRH                     0x0008
189
# define HAL_MCFxxxx_INTCx_IMRL                     0x000C
190
191
# define HAL_MCFxxxx_INTCx_ICRxx_IL_MASK            (0x07 << 3)
192
# define HAL_MCFxxxx_INTCx_ICRxx_IL_SHIFT           3
193
      
194
      
195
Symbols such as HAL_MCFxxxx_INTCx_IMRH can be used
196
to access the relevant hardware registers via
197
HAL_READ_UINT32 and
198
HAL_WRITE_UINT32. Symbols like
199
HAL_MCFxxxx_INTCx_ICRxx_IL_MASK can be used to
200
generate or decode the contents of the hardware registers.
201
      
202
      
203
The header file does mostly use a naming convention, but is not
204
guaranteed to be totally consistent. There may also be discrepancies
205
with the documentation because the manuals for the various Coldfire
206
processors are not always consistent about their naming schemes.
207
All I/O definitions provided by the variant HAL will start with
208
HAL_MCFxxxx_, followed by the name of the
209
peripheral. If a peripheral is likely to be a singleton, for example
210
an on-chip flash unit, then the name is unadorned. If there may be
211
several instances of the peripheral then the name will be followed by
212
a lower case x. For example:
213
      
214
      
215
# define HAL_MCFxxxx_CFM_CR                         0x0000
216
217
# define HAL_MCFxxxx_UARTx_UMR                      0x00
218
      
219
      
220
Register names will be relative to some base address such as
221
HAL_MCFxxxx_CFM_BASE or
222
HAL_MCFxxxx_UART0_BASE, so code accessing a
223
register would look like:
224
      
225
      
226
    HAL_READ_UINT32(HAL_MCFxxxx_CFM_BASE + HAL_MCFxxxx_CFM_PROT, reg);
227
228
    HAL_WRITE_UINT8(base + HAL_MCFxxxx_UARTx_UTB, '*');
229
      
230
      
231
Usually the register names are singletons, but in some cases such as
232
the interrupt controller priority registers there may be multiple
233
instances of the register and the names will be suffixed
234
appropriately. For example
235
HAL_MCFxxxx_INTCx_ICRxx_IL_MASK indicates the field
236
IL within one of the ICR
237
registers within one of the interrupt controllers.
238
      
239
      
240
As mentioned earlier the processor HAL's 
241
class="headerfile">proc_io.h will control which definitions
242
are exported by var_io.h.
243
Sometimes the processor HAL will then go on to undefine or redefine
244
some of the symbols, to reflect incompatibilities between the
245
processor's devices and the equivalent devices on the MCF5282. There
246
may also be additional symbols for the devices, and there will be
247
additional definitions for any processor-specific hardware. In
248
particular GPIO pin handling is handled by the processor HAL, not by
249
the variant HAL. Application developers should examine 
250
class="headerfile">proc_io.h as well as
251
var_io.h and the
252
processor-specific documentation to see exactly what I/O definitions
253
are provided. When porting to a new Coldfire processor it is best to
254
start with an existing processor HAL and copy
255
code as appropriate. A search for _HAS_ in
256
var_io.h will also be
257
informative.
258
      
259
    
260
 
261
    Thread Contexts and Setjmp/Longjmp
262
      
263
All MCFxxxx processors support interrupts and exceptions in a uniform
264
way. When an interrupt or exception occurs the hardware pushes the
265
current program counter, the status register, and an additional 16-bit
266
word containing information about the interrupt source, for a total of
267
64 bits. Hence the PCSR part of a thread context consists of two
268
32-bit integers, and the variant HAL provides appropriate C and
269
assembler macros to examine and manipulate these.
270
      
271
      
272
Not all MCFxxxx processors have hardware floating point, so support
273
for this is left to the processor HAL package. Some MCFxxxx processors
274
have additional hardware units such as a multiply-accumulator, but
275
these are not currently supported by eCos.
276
      
277
    
278
 
279
    HAL Diagnostics
280
      
281
The various MCFxxxx processors usually have one or more UARTs based on
282
very similar hardware. The variant HAL package can provide HAL
283
diagnostic support using such a UART. There are some minor differences
284
such as fifo sizes, and the UARTs will be accessed at different memory
285
locations. These differences are handled by a small number of macros
286
provided by the processor and platform HAL.
287
      
288
      
289
The MCFxxxx variant HAL only provides HAL diagnostic support via a
290
UART if the processor or platform HAL does not provide an alternative
291
implementation. That copes with situations where the on-chip UARTs are
292
not actually accessible on the target board and an alternative
293
communication channel must be used.
294
      
295
      
296
If the variant HAL should implement HAL diagnostics then the processor
297
or platform HAL should implement the CDL interface
298
CYGINT_HAL_M68K_MCFxxxx_DIAGNOSTICS_USE_DEFAULT. It
299
should also define one or more of
300
CYGHWR_HAL_M68K_MCFxxxx_UART0,
301
CYGHWR_HAL_M68K_MCFxxxx_UART1 and
302
CYGHWR_HAL_M68K_MCFxxxx_UART2, and ensure that any
303
multi-purpose GPIO pins are set correctly. The variant HAL will take
304
care of the rest.
305
      
306
    
307
 
308
    Cache Handling
309
      
310
The various MCFxxxx processors all have very different caches, so
311
support for these is deferred to the processor HAL.
312
      
313
    
314
 
315
    Exceptions
316
      
317
All MCFxxxx processors support synchronous exceptions in a uniform
318
way, with the hardware pushing sufficient information on to the stack
319
to identify the nature of the exception. This means that the architectural
320
entry point hal_m68k_exception_vsr can be used as
321
the default VSR for all exceptions, with no need for separate
322
trampoline functions.
323
      
324
      
325
The variant HAL does not provide any special support for recovering
326
from exceptions.
327
      
328
    
329
 
330
    Interrupts
331
      
332
All MCFxxxx processors supports interrupts in a uniform way. When an
333
interrupt occurs the hardware pushes sufficient information on to the
334
stack to identify the interrupt. Therefore the architectural entry
335
point hal_m68k_interrupt_vsr can be used as the
336
default VSR for all interrupts, with the variant just supplying a
337
small number of macros that allow the generic code to extract details of
338
the interrupt source. There is no need for separate trampoline
339
functions for every interrupt source.
340
      
341
      
342
On processors which have MCF5282-compatible interrupt and edge port
343
modules the variant HAL can provide the
344
HAL_INTERRUPT_MASK,
345
HAL_INTERRUPT_UNMASK,
346
HAL_INTERRUPT_SET_LEVEL,
347
HAL_INTERRUPT_ACKNOWLEDGE and
348
HAL_INTERRUPT_CONFIGURE macros. There is support
349
for processors with a single interrupt controller or with two separate
350
interrupt controllers. Otherwise these macros are left to the
351
processor HAL. The allocation of interrupt vectors to the various
352
on-chip devices is also a characteristic of the processor HAL.
353
proc_intr.h should be
354
consulted for appropriate definitions, for example
355
CYGNUM_HAL_ISR_UART0.
356
      
357
      
358
The mask and umask operations are straightforward: if the interrupt
359
controller has the SIMR and CIMR
360
registers those will be used; otherwise the IRM
361
registers will be updated by a read-modify-write cycle. The
362
acknowledge macro is only relevant for external interrupts coming in
363
via the edge port module and will clear the interrupt by writing to
364
the EPIER register. There is no simple way to clear
365
interrupts generated by the on-chip peripherals, so that is the
366
responsibility of the various device drivers or of application code.
367
The configure macro is only relevant for external interrupts and
368
involves manipulating the edge port module.
369
      
370
      
371
The HAL_INTERRUPT_SET_LEVEL macro is used
372
implicitly by higher level code such as
373
cyg_interrupt_create. With MCF5282-compatible
374
interrupt controllers the priority level corresponds to
375
the ICRxx register. The exact format depends on the
376
processor. Interrupt priorities corresponding to IPL level 7 are
377
non-maskable. Such interrupts cannot be managed safely by the usual
378
eCos ISR and DSR mechanisms. Instead application code will have to
379
install a custom VSR and manage the entire interrupt.
380
      
381
      
382
Some MCF5282-compatible interrupt controllers have a major
383
restriction: all interrupt priorities within each controller must be
384
unique. If two interrupts go off at the same time and have exactly the
385
same priority then the controllers' behaviour is undefined. In a
386
typical application some of the interrupts will be handled by eCos
387
device drivers while others will be handled directly by application
388
code. Since eCos cannot know which interrupts may get used, it cannot
389
allocate unique priorities. Instead this has to be left to the
390
application developer. eCos does provide configuration options such as
391
CYGNUM_KERNEL_COUNTERS_CLOCK_ISR_PRIORITY and
392
CYGNUM_DEVS_SERIAL_MCFxxxx_SERIAL0_ISR_PRIORITY to
393
provide control over the eCos-managed interrupts, and provides default
394
values for these which are unique.
395
      
396
      
397
Non-unique interrupt priorities can lead to very confusing system
398
behaviour. For example on an MCF5282, if the PIT3 system clock
399
(interrupt 0x3a) and ethernet RX frame (interrupt 0x1b) are
400
accidentally given the same priority and go off at the same time, the
401
interrupt controller may actually issue an interrupt 0x3b, the bitwise
402
or of the two interrupt numbers. That interrupt belongs to the on-chip
403
flash module. There may not be an installed handler for that interrupt
404
at all, and even if there is a handler it will only manipulate the
405
flash hardware and not clear the system clock and ethernet interrupts.
406
Hence the system is likely to go into a spin, continually trying to
407
service the wrong interrupt. To track down such problems during
408
debugging it may prove useful to install a breakpoint on the
409
hal_arch_default_isr function.
410
      
411
    
412
 
413
    Clock Support
414
      
415
On processors with an MCF5282-compatible programmable interrupt timer
416
module or PIT, the variant HAL can provide the
417
HAL_CLOCK_INITIALIZE,
418
HAL_CLOCK_RESET,
419
HAL_CLOCK_READ and
420
HAL_CLOCK_LATENCY macros. These macros are used
421
by the eCos kernel to implement the system clock and may be used for
422
other purposes in non-kernel configurations. When multiple timers are
423
available it is up to the processor or platform HAL to select which
424
one gets used for the system clock. It is also up to the processor or
425
platform HAL to provide various clock-related configuration options
426
such as CYGNUM_HAL_RTC_PERIOD. Those options need
427
to take into account the processor clock speed, which is usually a
428
characteristic of the platform and hence not known to the variant HAL.
429
      
430
      
431
When porting to a new Coldfire processor, the processor or platform
432
HAL should define the symbols
433
CYGNUM_HAL_INTERRUPT_RTC,
434
_HAL_MCFxxxx_CLOCK_PIT_BASE_, and
435
_HAL_MCFxxxx_CLOCK_PIT_PRE_. Existing ports can be
436
examined for more details.
437
      
438
    
439
 
440
    Reset
441
      
442
On processors with an MCF5282-compatible reset module or RST, the
443
variant HAL can provide the HAL_PLATFORM_RESET
444
macro. That macro is typically used by the gdb stubs support inside
445
RedBoot to reset the hardware between debug sessions, ensuring that
446
each session runs in as close to pristine hardware as possible. The
447
macro uses the SOFTRST bit of the
448
RCR register.
449
      
450
    
451
 
452
    Bit Indexing
453
      
454
By default the variant HAL will provide versions of
455
HAL_LSBIT_INDEX and
456
HAL_MSBIT_INDEX which are more efficient than the
457
default ones in the architectural HAL. The implementation uses the
458
ff1.l and bitrev.l instructions.
459
If the Coldfire processor does not support these instructions then
460
the processor HAL should define
461
_HAL_M68K_MCFxxxx_NO_FF1_.
462
      
463
    
464
 
465
    Other Issues
466
      
467
The MCFxxxx variant HAL does not affect the implementation of data
468
types, stack size definitions, idle thread processing, linker scripts,
469
SMP support, system startup, or debug support.
470
      
471
    
472
 
473
    Other Functionality
474
      
475
The MCFxxxx variant HAL only implements functionality defined in the
476
eCos HAL specification and does not export any additional functions.
477
      
478
    
479
  
480
481
 
482

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.