1 | @c |
---|
2 | @c COPYRIGHT (c) 1988-2002. |
---|
3 | @c On-Line Applications Research Corporation (OAR). |
---|
4 | @c All rights reserved. |
---|
5 | @c |
---|
6 | @c $Id$ |
---|
7 | @c |
---|
8 | |
---|
9 | @ifinfo |
---|
10 | @end ifinfo |
---|
11 | @chapter Motorola M68xxx and Coldfire Specific Information |
---|
12 | |
---|
13 | The Real Time Executive for Multiprocessor Systems (RTEMS) |
---|
14 | is designed to be portable across multiple processor |
---|
15 | architectures. However, the nature of real-time systems makes |
---|
16 | it essential that the application designer understand certain |
---|
17 | processor dependent implementation details. These processor |
---|
18 | dependencies include calling convention, board support package |
---|
19 | issues, interrupt processing, exact RTEMS memory requirements, |
---|
20 | performance data, header files, and the assembly language |
---|
21 | interface to the executive. |
---|
22 | |
---|
23 | This document discusses the Motorola MC68xxx |
---|
24 | architecture dependencies in this port of RTEMS. The MC68xxx |
---|
25 | family has a wide variety of CPU models within it. The part |
---|
26 | numbers for these models are generally divided into MC680xx and |
---|
27 | MC683xx. The MC680xx models are more general purpose processors |
---|
28 | with no integrated peripherals. The MC683xx models, on the |
---|
29 | other hand, are more specialized and have a variety of |
---|
30 | peripherals on chip including sophisticated timers and serial |
---|
31 | communications controllers. |
---|
32 | |
---|
33 | It is highly recommended that the Motorola MC68xxx |
---|
34 | RTEMS application developer obtain and become familiar with the |
---|
35 | documentation for the processor being used as well as the |
---|
36 | documentation for the family as a whole. |
---|
37 | |
---|
38 | @subheading Architecture Documents |
---|
39 | |
---|
40 | For information on the Motorola MC68xxx architecture, |
---|
41 | refer to the following documents available from Motorola |
---|
42 | (@file{http//www.moto.com/}): |
---|
43 | |
---|
44 | @itemize @bullet |
---|
45 | @item @cite{M68000 Family Reference, Motorola, FR68K/D}. |
---|
46 | @end itemize |
---|
47 | |
---|
48 | @subheading MODEL SPECIFIC DOCUMENTS |
---|
49 | |
---|
50 | For information on specific processor models and |
---|
51 | their associated coprocessors, refer to the following documents: |
---|
52 | |
---|
53 | @itemize @bullet |
---|
54 | @item @cite{MC68020 User's Manual, Motorola, MC68020UM/AD}. |
---|
55 | |
---|
56 | @item @cite{MC68881/MC68882 Floating-Point Coprocessor User's |
---|
57 | Manual, Motorola, MC68881UM/AD}. |
---|
58 | @end itemize |
---|
59 | |
---|
60 | @c |
---|
61 | @c COPYRIGHT (c) 1988-2002. |
---|
62 | @c On-Line Applications Research Corporation (OAR). |
---|
63 | @c All rights reserved. |
---|
64 | @c |
---|
65 | @c $Id$ |
---|
66 | @c |
---|
67 | |
---|
68 | @section CPU Model Dependent Features |
---|
69 | |
---|
70 | |
---|
71 | Microprocessors are generally classified into |
---|
72 | families with a variety of CPU models or implementations within |
---|
73 | that family. Within a processor family, there is a high level |
---|
74 | of binary compatibility. This family may be based on either an |
---|
75 | architectural specification or on maintaining compatibility with |
---|
76 | a popular processor. Recent microprocessor families such as the |
---|
77 | SPARC or PowerPC are based on an architectural specification |
---|
78 | which is independent or any particular CPU model or |
---|
79 | implementation. Older families such as the M68xxx and the iX86 |
---|
80 | evolved as the manufacturer strived to produce higher |
---|
81 | performance processor models which maintained binary |
---|
82 | compatibility with older models. |
---|
83 | |
---|
84 | RTEMS takes advantage of the similarity of the |
---|
85 | various models within a CPU family. Although the models do vary |
---|
86 | in significant ways, the high level of compatibility makes it |
---|
87 | possible to share the bulk of the CPU dependent executive code |
---|
88 | across the entire family. Each processor family supported by |
---|
89 | RTEMS has a list of features which vary between CPU models |
---|
90 | within a family. For example, the most common model dependent |
---|
91 | feature regardless of CPU family is the presence or absence of a |
---|
92 | floating point unit or coprocessor. When defining the list of |
---|
93 | features present on a particular CPU model, one simply notes |
---|
94 | that floating point hardware is or is not present and defines a |
---|
95 | single constant appropriately. Conditional compilation is |
---|
96 | utilized to include the appropriate source code for this CPU |
---|
97 | model's feature set. It is important to note that this means |
---|
98 | that RTEMS is thus compiled using the appropriate feature set |
---|
99 | and compilation flags optimal for this CPU model used. The |
---|
100 | alternative would be to generate a binary which would execute on |
---|
101 | all family members using only the features which were always |
---|
102 | present. |
---|
103 | |
---|
104 | This chapter presents the set of features which vary |
---|
105 | across SPARC implementations and are of importance to RTEMS. |
---|
106 | The set of CPU model feature macros are defined in the file |
---|
107 | cpukit/score/cpu/m68k/m68k.h based upon the particular CPU |
---|
108 | model defined on the compilation command line. |
---|
109 | |
---|
110 | @subsection CPU Model Name |
---|
111 | |
---|
112 | The macro CPU_MODEL_NAME is a string which designates |
---|
113 | the name of this CPU model. For example, for the MC68020 |
---|
114 | processor, this macro is set to the string "mc68020". |
---|
115 | |
---|
116 | @subsection Floating Point Unit |
---|
117 | |
---|
118 | The macro M68K_HAS_FPU is set to 1 to indicate that |
---|
119 | this CPU model has a hardware floating point unit and 0 |
---|
120 | otherwise. It does not matter whether the hardware floating |
---|
121 | point support is incorporated on-chip or is an external |
---|
122 | coprocessor. |
---|
123 | |
---|
124 | @subsection BFFFO Instruction |
---|
125 | |
---|
126 | The macro M68K_HAS_BFFFO is set to 1 to indicate that |
---|
127 | this CPU model has the bfffo instruction. |
---|
128 | |
---|
129 | @subsection Vector Base Register |
---|
130 | |
---|
131 | The macro M68K_HAS_VBR is set to 1 to indicate that |
---|
132 | this CPU model has a vector base register (vbr). |
---|
133 | |
---|
134 | @subsection Separate Stacks |
---|
135 | |
---|
136 | The macro M68K_HAS_SEPARATE_STACKS is set to 1 to |
---|
137 | indicate that this CPU model has separate interrupt, user, and |
---|
138 | supervisor mode stacks. |
---|
139 | |
---|
140 | @subsection Pre-Indexing Address Mode |
---|
141 | |
---|
142 | The macro M68K_HAS_PREINDEXING is set to 1 to indicate that |
---|
143 | this CPU model has the pre-indexing address mode. |
---|
144 | |
---|
145 | @subsection Extend Byte to Long Instruction |
---|
146 | |
---|
147 | The macro M68K_HAS_EXTB_L is set to 1 to indicate that this CPU model |
---|
148 | has the extb.l instruction. This instruction is supposed to be available |
---|
149 | in all models based on the cpu32 core as well as mc68020 and up models. |
---|
150 | @c |
---|
151 | @c COPYRIGHT (c) 1988-2002. |
---|
152 | @c On-Line Applications Research Corporation (OAR). |
---|
153 | @c All rights reserved. |
---|
154 | @c |
---|
155 | @c $Id$ |
---|
156 | @c |
---|
157 | |
---|
158 | @section Calling Conventions |
---|
159 | |
---|
160 | |
---|
161 | Each high-level language compiler generates |
---|
162 | subroutine entry and exit code based upon a set of rules known |
---|
163 | as the compiler's calling convention. These rules address the |
---|
164 | following issues: |
---|
165 | |
---|
166 | @itemize @bullet |
---|
167 | @item register preservation and usage |
---|
168 | @item parameter passing |
---|
169 | @item call and return mechanism |
---|
170 | @end itemize |
---|
171 | |
---|
172 | A compiler's calling convention is of importance when |
---|
173 | interfacing to subroutines written in another language either |
---|
174 | assembly or high-level. Even when the high-level language and |
---|
175 | target processor are the same, different compilers may use |
---|
176 | different calling conventions. As a result, calling conventions |
---|
177 | are both processor and compiler dependent. |
---|
178 | |
---|
179 | @subsection Processor Background |
---|
180 | |
---|
181 | The MC68xxx architecture supports a simple yet |
---|
182 | effective call and return mechanism. A subroutine is invoked |
---|
183 | via the branch to subroutine (bsr) or the jump to subroutine |
---|
184 | (jsr) instructions. These instructions push the return address |
---|
185 | on the current stack. The return from subroutine (rts) |
---|
186 | instruction pops the return address off the current stack and |
---|
187 | transfers control to that instruction. It is is important to |
---|
188 | note that the MC68xxx call and return mechanism does not |
---|
189 | automatically save or restore any registers. It is the |
---|
190 | responsibility of the high-level language compiler to define the |
---|
191 | register preservation and usage convention. |
---|
192 | |
---|
193 | @subsection Calling Mechanism |
---|
194 | |
---|
195 | All RTEMS directives are invoked using either a bsr |
---|
196 | or jsr instruction and return to the user application via the |
---|
197 | rts instruction. |
---|
198 | |
---|
199 | @subsection Register Usage |
---|
200 | |
---|
201 | As discussed above, the bsr and jsr instructions do |
---|
202 | not automatically save any registers. RTEMS uses the registers |
---|
203 | D0, D1, A0, and A1 as scratch registers. These registers are |
---|
204 | not preserved by RTEMS directives therefore, the contents of |
---|
205 | these registers should not be assumed upon return from any RTEMS |
---|
206 | directive. |
---|
207 | |
---|
208 | @subsection Parameter Passing |
---|
209 | |
---|
210 | RTEMS assumes that arguments are placed on the |
---|
211 | current stack before the directive is invoked via the bsr or jsr |
---|
212 | instruction. The first argument is assumed to be closest to the |
---|
213 | return address on the stack. This means that the first argument |
---|
214 | of the C calling sequence is pushed last. The following |
---|
215 | pseudo-code illustrates the typical sequence used to call a |
---|
216 | RTEMS directive with three (3) arguments: |
---|
217 | |
---|
218 | @example |
---|
219 | @group |
---|
220 | push third argument |
---|
221 | push second argument |
---|
222 | push first argument |
---|
223 | invoke directive |
---|
224 | remove arguments from the stack |
---|
225 | @end group |
---|
226 | @end example |
---|
227 | |
---|
228 | The arguments to RTEMS are typically pushed onto the |
---|
229 | stack using a move instruction with a pre-decremented stack |
---|
230 | pointer as the destination. These arguments must be removed |
---|
231 | from the stack after control is returned to the caller. This |
---|
232 | removal is typically accomplished by adding the size of the |
---|
233 | argument list in bytes to the current stack pointer. |
---|
234 | |
---|
235 | @subsection User-Provided Routines |
---|
236 | |
---|
237 | All user-provided routines invoked by RTEMS, such as |
---|
238 | user extensions, device drivers, and MPCI routines, must also |
---|
239 | adhere to these calling conventions. |
---|
240 | |
---|
241 | @c |
---|
242 | @c COPYRIGHT (c) 1988-2002. |
---|
243 | @c On-Line Applications Research Corporation (OAR). |
---|
244 | @c All rights reserved. |
---|
245 | @c |
---|
246 | @c $Id$ |
---|
247 | @c |
---|
248 | |
---|
249 | @section Memory Model |
---|
250 | |
---|
251 | |
---|
252 | A processor may support any combination of memory |
---|
253 | models ranging from pure physical addressing to complex demand |
---|
254 | paged virtual memory systems. RTEMS supports a flat memory |
---|
255 | model which ranges contiguously over the processor's allowable |
---|
256 | address space. RTEMS does not support segmentation or virtual |
---|
257 | memory of any kind. The appropriate memory model for RTEMS |
---|
258 | provided by the targeted processor and related characteristics |
---|
259 | of that model are described in this chapter. |
---|
260 | |
---|
261 | @subsection Flat Memory Model |
---|
262 | |
---|
263 | The MC68xxx family supports a flat 32-bit address |
---|
264 | space with addresses ranging from 0x00000000 to 0xFFFFFFFF (4 |
---|
265 | gigabytes). Each address is represented by a 32-bit value and |
---|
266 | is byte addressable. The address may be used to reference a |
---|
267 | single byte, word (2-bytes), or long word (4 bytes). Memory |
---|
268 | accesses within this address space are performed in big endian |
---|
269 | fashion by the processors in this family. |
---|
270 | |
---|
271 | Some of the MC68xxx family members such as the |
---|
272 | MC68020, MC68030, and MC68040 support virtual memory and |
---|
273 | segmentation. The MC68020 requires external hardware support |
---|
274 | such as the MC68851 Paged Memory Management Unit coprocessor |
---|
275 | which is typically used to perform address translations for |
---|
276 | these systems. RTEMS does not support virtual memory or |
---|
277 | segmentation on any of the MC68xxx family members. |
---|
278 | |
---|
279 | @c |
---|
280 | @c Interrupt Stack Frame Picture |
---|
281 | @c |
---|
282 | @c COPYRIGHT (c) 1988-2002. |
---|
283 | @c On-Line Applications Research Corporation (OAR). |
---|
284 | @c All rights reserved. |
---|
285 | @c |
---|
286 | @c $Id$ |
---|
287 | @c |
---|
288 | |
---|
289 | @section Interrupt Processing |
---|
290 | |
---|
291 | |
---|
292 | Different types of processors respond to the |
---|
293 | occurrence of an interrupt in its own unique fashion. In |
---|
294 | addition, each processor type provides a control mechanism to |
---|
295 | allow for the proper handling of an interrupt. The processor |
---|
296 | dependent response to the interrupt modifies the current |
---|
297 | execution state and results in a change in the execution stream. |
---|
298 | Most processors require that an interrupt handler utilize some |
---|
299 | special control mechanisms to return to the normal processing |
---|
300 | stream. Although RTEMS hides many of the processor dependent |
---|
301 | details of interrupt processing, it is important to understand |
---|
302 | how the RTEMS interrupt manager is mapped onto the processor's |
---|
303 | unique architecture. Discussed in this chapter are the MC68xxx's |
---|
304 | interrupt response and control mechanisms as they pertain to |
---|
305 | RTEMS. |
---|
306 | |
---|
307 | @subsection Vectoring of an Interrupt Handler |
---|
308 | |
---|
309 | Depending on whether or not the particular CPU |
---|
310 | supports a separate interrupt stack, the MC68xxx family has two |
---|
311 | different interrupt handling models. |
---|
312 | |
---|
313 | @subsubsection Models Without Separate Interrupt Stacks |
---|
314 | |
---|
315 | Upon receipt of an interrupt the MC68xxx family |
---|
316 | members without separate interrupt stacks automatically perform |
---|
317 | the following actions: |
---|
318 | |
---|
319 | @itemize @bullet |
---|
320 | @item To Be Written |
---|
321 | @end itemize |
---|
322 | |
---|
323 | @subsubsection Models With Separate Interrupt Stacks |
---|
324 | |
---|
325 | Upon receipt of an interrupt the MC68xxx family |
---|
326 | members with separate interrupt stacks automatically perform the |
---|
327 | following actions: |
---|
328 | |
---|
329 | @itemize @bullet |
---|
330 | @item saves the current status register (SR), |
---|
331 | |
---|
332 | @item clears the master/interrupt (M) bit of the SR to |
---|
333 | indicate the switch from master state to interrupt state, |
---|
334 | |
---|
335 | @item sets the privilege mode to supervisor, |
---|
336 | |
---|
337 | @item suppresses tracing, |
---|
338 | |
---|
339 | @item sets the interrupt mask level equal to the level of the |
---|
340 | interrupt being serviced, |
---|
341 | |
---|
342 | @item pushes an interrupt stack frame (ISF), which includes |
---|
343 | the program counter (PC), the status register (SR), and the |
---|
344 | format/exception vector offset (FVO) word, onto the supervisor |
---|
345 | and interrupt stacks, |
---|
346 | |
---|
347 | @item switches the current stack to the interrupt stack and |
---|
348 | vectors to an interrupt service routine (ISR). If the ISR was |
---|
349 | installed with the interrupt_catch directive, then the RTEMS |
---|
350 | interrupt handler will begin execution. The RTEMS interrupt |
---|
351 | handler saves all registers which are not preserved according to |
---|
352 | the calling conventions and invokes the application's ISR. |
---|
353 | @end itemize |
---|
354 | |
---|
355 | A nested interrupt is processed similarly by these |
---|
356 | CPU models with the exception that only a single ISF is placed |
---|
357 | on the interrupt stack and the current stack need not be |
---|
358 | switched. |
---|
359 | |
---|
360 | The FVO word in the Interrupt Stack Frame is examined |
---|
361 | by RTEMS to determine when an outer most interrupt is being |
---|
362 | exited. Since the FVO is used by RTEMS for this purpose, the |
---|
363 | user application code MUST NOT modify this field. |
---|
364 | |
---|
365 | The following shows the Interrupt Stack Frame for |
---|
366 | MC68xxx CPU models with separate interrupt stacks: |
---|
367 | |
---|
368 | @ifset use-ascii |
---|
369 | @example |
---|
370 | @group |
---|
371 | +----------------------+ |
---|
372 | | Status Register | 0x0 |
---|
373 | +----------------------+ |
---|
374 | | Program Counter High | 0x2 |
---|
375 | +----------------------+ |
---|
376 | | Program Counter Low | 0x4 |
---|
377 | +----------------------+ |
---|
378 | | Format/Vector Offset | 0x6 |
---|
379 | +----------------------+ |
---|
380 | @end group |
---|
381 | @end example |
---|
382 | @end ifset |
---|
383 | |
---|
384 | @ifset use-tex |
---|
385 | @sp 1 |
---|
386 | @tex |
---|
387 | \centerline{\vbox{\offinterlineskip\halign{ |
---|
388 | \strut\vrule#& |
---|
389 | \hbox to 2.00in{\enskip\hfil#\hfil}& |
---|
390 | \vrule#& |
---|
391 | \hbox to 0.50in{\enskip\hfil#\hfil} |
---|
392 | \cr |
---|
393 | \multispan{3}\hrulefill\cr |
---|
394 | & Status Register && 0x0\cr |
---|
395 | \multispan{3}\hrulefill\cr |
---|
396 | & Program Counter High && 0x2\cr |
---|
397 | \multispan{3}\hrulefill\cr |
---|
398 | & Program Counter Low && 0x4\cr |
---|
399 | \multispan{3}\hrulefill\cr |
---|
400 | & Format/Vector Offset && 0x6\cr |
---|
401 | \multispan{3}\hrulefill\cr |
---|
402 | }}\hfil} |
---|
403 | @end tex |
---|
404 | @end ifset |
---|
405 | |
---|
406 | @ifset use-html |
---|
407 | @html |
---|
408 | <CENTER> |
---|
409 | <TABLE COLS=2 WIDTH="40%" BORDER=2> |
---|
410 | <TR><TD ALIGN=center><STRONG>Status Register</STRONG></TD> |
---|
411 | <TD ALIGN=center>0x0</TD></TR> |
---|
412 | <TR><TD ALIGN=center><STRONG>Program Counter High</STRONG></TD> |
---|
413 | <TD ALIGN=center>0x2</TD></TR> |
---|
414 | <TR><TD ALIGN=center><STRONG>Program Counter Low</STRONG></TD> |
---|
415 | <TD ALIGN=center>0x4</TD></TR> |
---|
416 | <TR><TD ALIGN=center><STRONG>Format/Vector Offset</STRONG></TD> |
---|
417 | <TD ALIGN=center>0x6</TD></TR> |
---|
418 | </TABLE> |
---|
419 | </CENTER> |
---|
420 | @end html |
---|
421 | @end ifset |
---|
422 | |
---|
423 | @subsection CPU Models Without VBR and RAM at 0 |
---|
424 | |
---|
425 | This is from a post by Zoltan Kocsi <zoltan@@bendor.com.au> and is |
---|
426 | a nice trick in certain situations. In his words: |
---|
427 | |
---|
428 | I think somebody on this list asked about the interupt vector |
---|
429 | handling w/o VBR and RAM at 0. The usual trick is |
---|
430 | to initialise the vector table (except the first 2 two entries, of |
---|
431 | course) to point to the same location BUT you also add the vector |
---|
432 | number times 0x1000000 to them. That is, bits 31-24 contain the vector |
---|
433 | number and 23-0 the address of the common handler. |
---|
434 | Since the PC is 32 bit wide but the actual address bus is only 24, |
---|
435 | the top byte will be in the PC but will be ignored when jumping |
---|
436 | onto your routine. |
---|
437 | |
---|
438 | Then your common interrupt routine gets this info by loading the PC |
---|
439 | into some register and based on that info, you can jump to a vector |
---|
440 | in a vector table pointed by a virtual VBR: |
---|
441 | |
---|
442 | @example |
---|
443 | // |
---|
444 | // Real vector table at 0 |
---|
445 | // |
---|
446 | |
---|
447 | .long initial_sp |
---|
448 | .long initial_pc |
---|
449 | .long myhandler+0x02000000 |
---|
450 | .long myhandler+0x03000000 |
---|
451 | .long myhandler+0x04000000 |
---|
452 | ... |
---|
453 | .long myhandler+0xff000000 |
---|
454 | |
---|
455 | |
---|
456 | // |
---|
457 | // This handler will jump to the interrupt routine of which |
---|
458 | // the address is stored at VBR[ vector_no ] |
---|
459 | // The registers and stackframe will be intact, the interrupt |
---|
460 | // routine will see exactly what it would see if it was called |
---|
461 | // directly from the HW vector table at 0. |
---|
462 | // |
---|
463 | |
---|
464 | .comm VBR,4,2 // This defines the 'virtual' VBR |
---|
465 | // From C: extern void *VBR; |
---|
466 | |
---|
467 | myhandler: // At entry, PC contains the full vector |
---|
468 | move.l %d0,-(%sp) // Save d0 |
---|
469 | move.l %a0,-(%sp) // Save a0 |
---|
470 | lea 0(%pc),%a0 // Get the value of the PC |
---|
471 | move.l %a0,%d0 // Copy it to a data reg, d0 is VV?????? |
---|
472 | swap %d0 // Now d0 is ????VV?? |
---|
473 | and.w #0xff00,%d0 // Now d0 is ????VV00 (1) |
---|
474 | lsr.w #6,%d0 // Now d0.w contains the VBR table offset |
---|
475 | move.l VBR,%a0 // Get the address from VBR to a0 |
---|
476 | move.l (%a0,%d0.w),%a0 // Fetch the vector |
---|
477 | move.l 4(%sp),%d0 // Restore d0 |
---|
478 | move.l %a0,4(%sp) // Place target address to the stack |
---|
479 | move.l (%sp)+,%a0 // Restore a0, target address is on TOS |
---|
480 | ret // This will jump to the handler and |
---|
481 | // restore the stack |
---|
482 | |
---|
483 | (1) If 'myhandler' is guaranteed to be in the first 64K, e.g. just |
---|
484 | after the vector table then that insn is not needed. |
---|
485 | |
---|
486 | @end example |
---|
487 | |
---|
488 | There are probably shorter ways to do this, but it I believe is enough |
---|
489 | to illustrate the trick. Optimisation is left as an exercise to the |
---|
490 | reader :-) |
---|
491 | |
---|
492 | |
---|
493 | @subsection Interrupt Levels |
---|
494 | |
---|
495 | Eight levels (0-7) of interrupt priorities are |
---|
496 | supported by MC68xxx family members with level seven (7) being |
---|
497 | the highest priority. Level zero (0) indicates that interrupts |
---|
498 | are fully enabled. Interrupt requests for interrupts with |
---|
499 | priorities less than or equal to the current interrupt mask |
---|
500 | level are ignored. |
---|
501 | |
---|
502 | Although RTEMS supports 256 interrupt levels, the |
---|
503 | MC68xxx family only supports eight. RTEMS interrupt levels 0 |
---|
504 | through 7 directly correspond to MC68xxx interrupt levels. All |
---|
505 | other RTEMS interrupt levels are undefined and their behavior is |
---|
506 | unpredictable. |
---|
507 | |
---|
508 | @subsection Disabling of Interrupts by RTEMS |
---|
509 | |
---|
510 | During the execution of directive calls, critical |
---|
511 | sections of code may be executed. When these sections are |
---|
512 | encountered, RTEMS disables interrupts to level seven (7) before |
---|
513 | the execution of this section and restores them to the previous |
---|
514 | level upon completion of the section. RTEMS has been optimized |
---|
515 | to insure that interrupts are disabled for less than |
---|
516 | RTEMS_MAXIMUM_DISABLE_PERIOD microseconds on a |
---|
517 | RTEMS_MAXIMUM_DISABLE_PERIOD_MHZ Mhz MC68020 with |
---|
518 | zero wait states. These numbers will vary based the |
---|
519 | number of wait states and processor speed present on the target board. |
---|
520 | [NOTE: The maximum period with interrupts disabled is hand calculated. This |
---|
521 | calculation was last performed for Release |
---|
522 | RTEMS_RELEASE_FOR_MAXIMUM_DISABLE_PERIOD.] |
---|
523 | |
---|
524 | Non-maskable interrupts (NMI) cannot be disabled, and |
---|
525 | ISRs which execute at this level MUST NEVER issue RTEMS system |
---|
526 | calls. If a directive is invoked, unpredictable results may |
---|
527 | occur due to the inability of RTEMS to protect its critical |
---|
528 | sections. However, ISRs that make no system calls may safely |
---|
529 | execute as non-maskable interrupts. |
---|
530 | |
---|
531 | @subsection Interrupt Stack |
---|
532 | |
---|
533 | RTEMS allocates the interrupt stack from the |
---|
534 | Workspace Area. The amount of memory allocated for the |
---|
535 | interrupt stack is determined by the interrupt_stack_size field |
---|
536 | in the CPU Configuration Table. During the initialization |
---|
537 | process, RTEMS will install its interrupt stack. |
---|
538 | |
---|
539 | The MC68xxx port of RTEMS supports a software managed |
---|
540 | dedicated interrupt stack on those CPU models which do not |
---|
541 | support a separate interrupt stack in hardware. |
---|
542 | |
---|
543 | |
---|
544 | @c |
---|
545 | @c COPYRIGHT (c) 1988-2002. |
---|
546 | @c On-Line Applications Research Corporation (OAR). |
---|
547 | @c All rights reserved. |
---|
548 | @c |
---|
549 | @c $Id$ |
---|
550 | @c |
---|
551 | |
---|
552 | @section Default Fatal Error Processing |
---|
553 | |
---|
554 | |
---|
555 | Upon detection of a fatal error by either the |
---|
556 | application or RTEMS the fatal error manager is invoked. The |
---|
557 | fatal error manager will invoke the user-supplied fatal error |
---|
558 | handlers. If no user-supplied handlers are configured, the |
---|
559 | RTEMS provided default fatal error handler is invoked. If the |
---|
560 | user-supplied fatal error handlers return to the executive the |
---|
561 | default fatal error handler is then invoked. This chapter |
---|
562 | describes the precise operations of the default fatal error |
---|
563 | handler. |
---|
564 | |
---|
565 | @subsection Default Fatal Error Handler Operations |
---|
566 | |
---|
567 | The default fatal error handler which is invoked by |
---|
568 | the fatal_error_occurred directive when there is no user handler |
---|
569 | configured or the user handler returns control to RTEMS. The |
---|
570 | default fatal error handler disables processor interrupts to |
---|
571 | level 7, places the error code in D0, and executes a stop |
---|
572 | instruction to simulate a halt processor instruction. |
---|
573 | |
---|
574 | @c |
---|
575 | @c COPYRIGHT (c) 1988-2002. |
---|
576 | @c On-Line Applications Research Corporation (OAR). |
---|
577 | @c All rights reserved. |
---|
578 | @c |
---|
579 | @c $Id$ |
---|
580 | @c |
---|
581 | |
---|
582 | @section Board Support Packages |
---|
583 | |
---|
584 | |
---|
585 | An RTEMS Board Support Package (BSP) must be designed |
---|
586 | to support a particular processor and target board combination. |
---|
587 | This chapter presents a discussion of MC68020 specific BSP |
---|
588 | issues. For more information on developing a BSP, refer to the |
---|
589 | chapter titled Board Support Packages in the RTEMS |
---|
590 | Applications User's Guide. |
---|
591 | |
---|
592 | @subsection System Reset |
---|
593 | |
---|
594 | An RTEMS based application is initiated or |
---|
595 | re-initiated when the MC68020 processor is reset. When the |
---|
596 | MC68020 is reset, the processor performs the following actions: |
---|
597 | |
---|
598 | @itemize @bullet |
---|
599 | @item The tracing bits of the status register are cleared to |
---|
600 | disable tracing. |
---|
601 | |
---|
602 | @item The supervisor interrupt state is entered by setting the |
---|
603 | supervisor (S) bit and clearing the master/interrupt (M) bit of |
---|
604 | the status register. |
---|
605 | |
---|
606 | @item The interrupt mask of the status register is set to |
---|
607 | level 7 to effectively disable all maskable interrupts. |
---|
608 | |
---|
609 | @item The vector base register (VBR) is set to zero. |
---|
610 | |
---|
611 | @item The cache control register (CACR) is set to zero to |
---|
612 | disable and freeze the processor cache. |
---|
613 | |
---|
614 | @item The interrupt stack pointer (ISP) is set to the value |
---|
615 | stored at vector 0 (bytes 0-3) of the exception vector table |
---|
616 | (EVT). |
---|
617 | |
---|
618 | @item The program counter (PC) is set to the value stored at |
---|
619 | vector 1 (bytes 4-7) of the EVT. |
---|
620 | |
---|
621 | @item The processor begins execution at the address stored in |
---|
622 | the PC. |
---|
623 | @end itemize |
---|
624 | |
---|
625 | @subsection Processor Initialization |
---|
626 | |
---|
627 | The address of the application's initialization code |
---|
628 | should be stored in the first vector of the EVT which will allow |
---|
629 | the immediate vectoring to the application code. If the |
---|
630 | application requires that the VBR be some value besides zero, |
---|
631 | then it should be set to the required value at this point. All |
---|
632 | tasks share the same MC68020's VBR value. Because interrupts |
---|
633 | are enabled automatically by RTEMS as part of the initialize |
---|
634 | executive directive, the VBR MUST be set before this directive |
---|
635 | is invoked to insure correct interrupt vectoring. If processor |
---|
636 | caching is to be utilized, then it should be enabled during the |
---|
637 | reset application initialization code. |
---|
638 | |
---|
639 | In addition to the requirements described in the |
---|
640 | Board Support Packages chapter of the Applications User's |
---|
641 | Manual for the reset code which is executed before the call to |
---|
642 | initialize executive, the MC68020 version has the following |
---|
643 | specific requirements: |
---|
644 | |
---|
645 | @itemize @bullet |
---|
646 | @item Must leave the S bit of the status register set so that |
---|
647 | the MC68020 remains in the supervisor state. |
---|
648 | |
---|
649 | @item Must set the M bit of the status register to remove the |
---|
650 | MC68020 from the interrupt state. |
---|
651 | |
---|
652 | @item Must set the master stack pointer (MSP) such that a |
---|
653 | minimum stack size of MINIMUM_STACK_SIZE bytes is provided for |
---|
654 | the initialize executive directive. |
---|
655 | |
---|
656 | @item Must initialize the MC68020's vector table. |
---|
657 | @end itemize |
---|
658 | |
---|
659 | Note that the BSP is not responsible for allocating |
---|
660 | or installing the interrupt stack. RTEMS does this |
---|
661 | automatically as part of initialization. If the BSP does not |
---|
662 | install an interrupt stack and -- for whatever reason -- an |
---|
663 | interrupt occurs before initialize_executive is invoked, then |
---|
664 | the results are unpredictable. |
---|
665 | |
---|
666 | @c |
---|
667 | @c COPYRIGHT (c) 1988-2002. |
---|
668 | @c On-Line Applications Research Corporation (OAR). |
---|
669 | @c All rights reserved. |
---|
670 | @c |
---|
671 | @c $Id$ |
---|
672 | @c |
---|
673 | |
---|
674 | @section Processor Dependent Information Table |
---|
675 | |
---|
676 | |
---|
677 | Any highly processor dependent information required |
---|
678 | to describe a processor to RTEMS is provided in the CPU |
---|
679 | Dependent Information Table. This table is not required for all |
---|
680 | processors supported by RTEMS. This chapter describes the |
---|
681 | contents, if any, for a particular processor type. |
---|
682 | |
---|
683 | @subsection CPU Dependent Information Table |
---|
684 | |
---|
685 | The MC68xxx version of the RTEMS CPU Dependent |
---|
686 | Information Table contains the information required to interface |
---|
687 | a Board Support Package and RTEMS on the MC68xxx. This |
---|
688 | information is provided to allow RTEMS to interoperate |
---|
689 | effectively with the BSP. The C structure definition is given |
---|
690 | here: |
---|
691 | |
---|
692 | @example |
---|
693 | @group |
---|
694 | typedef struct @{ |
---|
695 | unsigned32 interrupt_stack_size; |
---|
696 | /* end of fields required on all CPUs */ |
---|
697 | @} rtems_cpu_table; |
---|
698 | @end group |
---|
699 | @end example |
---|
700 | |
---|
701 | @table @code |
---|
702 | |
---|
703 | @item interrupt_stack_size |
---|
704 | is the size of the RTEMS |
---|
705 | allocated interrupt stack in bytes. This value must be at least |
---|
706 | as large as MINIMUM_STACK_SIZE. |
---|
707 | |
---|
708 | @end table |
---|