1 | :orphan: |
---|
2 | |
---|
3 | |
---|
4 | |
---|
5 | .. COMMENT: %**end of header |
---|
6 | |
---|
7 | .. COMMENT: COPYRIGHT (c) 1989-2013. |
---|
8 | |
---|
9 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
10 | |
---|
11 | .. COMMENT: All rights reserved. |
---|
12 | |
---|
13 | .. COMMENT: Master file for the CPU Supplement |
---|
14 | |
---|
15 | .. COMMENT: COPYRIGHT (c) 1988-2002. |
---|
16 | |
---|
17 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
18 | |
---|
19 | .. COMMENT: All rights reserved. |
---|
20 | |
---|
21 | .. COMMENT: The following determines which set of the tables and figures we will use. |
---|
22 | |
---|
23 | .. COMMENT: We default to ASCII but if available TeX or HTML versions will |
---|
24 | |
---|
25 | .. COMMENT: be used instead. |
---|
26 | |
---|
27 | .. COMMENT: @clear use-html |
---|
28 | |
---|
29 | .. COMMENT: @clear use-tex |
---|
30 | |
---|
31 | .. COMMENT: The following variable says to use texinfo or html for the two column |
---|
32 | |
---|
33 | .. COMMENT: texinfo tables. For somethings the format does not look good in html. |
---|
34 | |
---|
35 | .. COMMENT: With our adjustment to the left column in TeX, it nearly always looks |
---|
36 | |
---|
37 | .. COMMENT: good printed. |
---|
38 | |
---|
39 | .. COMMENT: Custom whitespace adjustments. We could fiddle a bit more. |
---|
40 | |
---|
41 | .. COMMENT: Title Page Stuff |
---|
42 | |
---|
43 | .. COMMENT: I don't really like having a short title page. -joel |
---|
44 | |
---|
45 | .. COMMENT: @shorttitlepage RTEMS CPU Architecture Supplement |
---|
46 | |
---|
47 | ================================= |
---|
48 | RTEMS CPU Architecture Supplement |
---|
49 | ================================= |
---|
50 | |
---|
51 | .. COMMENT: COPYRIGHT (c) 1988-2015. |
---|
52 | |
---|
53 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
54 | |
---|
55 | .. COMMENT: All rights reserved. |
---|
56 | |
---|
57 | .. COMMENT: The following puts a space somewhere on an otherwise empty page so we |
---|
58 | |
---|
59 | .. COMMENT: can force the copyright description onto a left hand page. |
---|
60 | |
---|
61 | COPYRIGHT © 1988 - 2015. |
---|
62 | |
---|
63 | On-Line Applications Research Corporation (OAR). |
---|
64 | |
---|
65 | The authors have used their best efforts in preparing |
---|
66 | this material. These efforts include the development, research, |
---|
67 | and testing of the theories and programs to determine their |
---|
68 | effectiveness. No warranty of any kind, expressed or implied, |
---|
69 | with regard to the software or the material contained in this |
---|
70 | document is provided. No liability arising out of the |
---|
71 | application or use of any product described in this document is |
---|
72 | assumed. The authors reserve the right to revise this material |
---|
73 | and to make changes from time to time in the content hereof |
---|
74 | without obligation to notify anyone of such revision or changes. |
---|
75 | |
---|
76 | The RTEMS Project is hosted at http://www.rtems.org. Any |
---|
77 | inquiries concerning RTEMS, its related support components, or its |
---|
78 | documentation should be directed to the Community Project hosted athttp://www.rtems.org. |
---|
79 | |
---|
80 | Any inquiries for commercial services including training, support, custom |
---|
81 | development, application development assistance should be directed tohttp://www.rtems.com. |
---|
82 | |
---|
83 | .. COMMENT: This prevents a black box from being printed on "overflow" lines. |
---|
84 | |
---|
85 | .. COMMENT: The alternative is to rework a sentence to avoid this problem. |
---|
86 | |
---|
87 | RTEMS CPU Architecture Supplement |
---|
88 | ################################# |
---|
89 | |
---|
90 | .. COMMENT: COPYRIGHT (c) 1989-2011. |
---|
91 | |
---|
92 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
93 | |
---|
94 | .. COMMENT: All rights reserved. |
---|
95 | |
---|
96 | Preface |
---|
97 | ####### |
---|
98 | |
---|
99 | The Real Time Executive for Multiprocessor Systems |
---|
100 | (RTEMS) is designed to be portable across multiple processor |
---|
101 | architectures. However, the nature of real-time systems makes |
---|
102 | it essential that the application designer understand certain |
---|
103 | processor dependent implementation details. These processor |
---|
104 | dependencies include calling convention, board support package |
---|
105 | issues, interrupt processing, exact RTEMS memory requirements, |
---|
106 | performance data, header files, and the assembly language |
---|
107 | interface to the executive. |
---|
108 | |
---|
109 | Each architecture represents a CPU family and usually there are |
---|
110 | a wide variety of CPU models within it. These models share a |
---|
111 | common Instruction Set Architecture (ISA) which often varies |
---|
112 | based upon some well-defined rules. There are often |
---|
113 | multiple implementations of the ISA and these may be from |
---|
114 | one or multiple vendors. |
---|
115 | |
---|
116 | On top of variations in the ISA, there may also be variations |
---|
117 | which occur when a CPU core implementation is combined with |
---|
118 | a set of peripherals to form a system on chip. For example, |
---|
119 | there are many ARM CPU models from numerous semiconductor |
---|
120 | vendors and a wide variety of peripherals. But at the |
---|
121 | ISA level, they share a common compatibility. |
---|
122 | |
---|
123 | RTEMS depends upon this core similarity across the CPU models |
---|
124 | and leverages that to minimize the source code that is specific |
---|
125 | to any particular CPU core implementation or CPU model. |
---|
126 | |
---|
127 | This manual is separate and distinct from the RTEMS Porting |
---|
128 | Guide. That manual is a guide on porting RTEMS to a new |
---|
129 | architecture. This manual is focused on the more mundane |
---|
130 | CPU architecture specific issues that may impact |
---|
131 | application development. For example, if you need to write |
---|
132 | a subroutine in assembly language, it is critical to understand |
---|
133 | the calling conventions for the target architecture. |
---|
134 | |
---|
135 | The first chapter in this manual describes these issues |
---|
136 | in general terms. In a sense, it is posing the questions |
---|
137 | one should be aware may need to be answered and understood |
---|
138 | when porting an RTEMS application to a new architecture. |
---|
139 | Each subsequent chapter gives the answers to those questions |
---|
140 | for a particular CPU architecture. |
---|
141 | |
---|
142 | .. COMMENT: COPYRIGHT (c) 1988-2002. |
---|
143 | |
---|
144 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
145 | |
---|
146 | .. COMMENT: All rights reserved. |
---|
147 | |
---|
148 | Port Specific Information |
---|
149 | ######################### |
---|
150 | |
---|
151 | This chaper provides a general description of the type of |
---|
152 | architecture specific information which is in each of |
---|
153 | the architecture specific chapters that follow. The outline |
---|
154 | of this chapter is identical to that of the architecture |
---|
155 | specific chapters. |
---|
156 | |
---|
157 | In each of the architecture specific chapters, this |
---|
158 | introductory section will provide an overview of the |
---|
159 | architecture |
---|
160 | |
---|
161 | **Architecture Documents** |
---|
162 | |
---|
163 | In each of the architecture specific chapters, this |
---|
164 | section will provide pointers on where to obtain |
---|
165 | documentation. |
---|
166 | |
---|
167 | CPU Model Dependent Features |
---|
168 | ============================ |
---|
169 | |
---|
170 | Microprocessors are generally classified into families with a variety of |
---|
171 | CPU models or implementations within that family. Within a processor |
---|
172 | family, there is a high level of binary compatibility. This family |
---|
173 | may be based on either an architectural specification or on maintaining |
---|
174 | compatibility with a popular processor. Recent microprocessor families |
---|
175 | such as the SPARC or PowerPC are based on an architectural specification |
---|
176 | which is independent or any particular CPU model or implementation. |
---|
177 | Older families such as the Motorola 68000 and the Intel x86 evolved as the |
---|
178 | manufacturer strived to produce higher performance processor models which |
---|
179 | maintained binary compatibility with older models. |
---|
180 | |
---|
181 | RTEMS takes advantage of the similarity of the various models within a |
---|
182 | CPU family. Although the models do vary in significant ways, the high |
---|
183 | level of compatibility makes it possible to share the bulk of the CPU |
---|
184 | dependent executive code across the entire family. Each processor family |
---|
185 | supported by RTEMS has a list of features which vary between CPU models |
---|
186 | within a family. For example, the most common model dependent feature |
---|
187 | regardless of CPU family is the presence or absence of a floating point |
---|
188 | unit or coprocessor. When defining the list of features present on a |
---|
189 | particular CPU model, one simply notes that floating point hardware |
---|
190 | is or is not present and defines a single constant appropriately. |
---|
191 | Conditional compilation is utilized to include the appropriate source |
---|
192 | code for this CPU modelâs feature set. It is important to note that |
---|
193 | this means that RTEMS is thus compiled using the appropriate feature set |
---|
194 | and compilation flags optimal for this CPU model used. The alternative |
---|
195 | would be to generate a binary which would execute on all family members |
---|
196 | using only the features which were always present. |
---|
197 | |
---|
198 | The set of CPU model feature macros are defined in the file``cpukit/score/cpu/CPU/rtems/score/cpu.h`` based upon the GNU tools |
---|
199 | multilib variant that is appropriate for the particular CPU model defined |
---|
200 | on the compilation command line. |
---|
201 | |
---|
202 | In each of the architecture specific chapters, this section presents |
---|
203 | the set of features which vary across various implementations of the |
---|
204 | architecture that may be of importance to RTEMS application developers. |
---|
205 | |
---|
206 | The subsections will vary amongst the target architecture chapters as |
---|
207 | the specific features may vary. However, each port will include a few |
---|
208 | common features such as the CPU Model Name and presence of a hardware |
---|
209 | Floating Point Unit. The common features are described here. |
---|
210 | |
---|
211 | CPU Model Name |
---|
212 | -------------- |
---|
213 | |
---|
214 | The macro ``CPU_MODEL_NAME`` is a string which designates |
---|
215 | the name of this CPU model. For example, for the MC68020 |
---|
216 | processor model from the m68k architecture, this macro |
---|
217 | is set to the string "mc68020". |
---|
218 | |
---|
219 | Floating Point Unit |
---|
220 | ------------------- |
---|
221 | |
---|
222 | In most architectures, the presence of a floating point unit is an option. |
---|
223 | It does not matter whether the hardware floating point support is |
---|
224 | incorporated on-chip or is an external coprocessor as long as it |
---|
225 | appears an FPU per the ISA. However, if a hardware FPU is not present, |
---|
226 | it is possible that the floating point emulation library for this |
---|
227 | CPU is not reentrant and thus context switched by RTEMS. |
---|
228 | |
---|
229 | RTEMS provides two feature macros to indicate the FPU configuration: |
---|
230 | |
---|
231 | - CPU_HARDWARE_FP |
---|
232 | is set to TRUE to indicate that a hardware FPU is present. |
---|
233 | |
---|
234 | - CPU_SOFTWARE_FP |
---|
235 | is set to TRUE to indicate that a hardware FPU is not present and that |
---|
236 | the FP software emulation will be context switched. |
---|
237 | |
---|
238 | Multilibs |
---|
239 | ========= |
---|
240 | |
---|
241 | Newlib and GCC provide several target libraries like the :file:`libc.a`,:file:`libm.a` and :file:`libgcc.a`. These libraries are artifacts of the GCC |
---|
242 | build process. Newlib is built together with GCC. To provide optimal support |
---|
243 | for various chip derivatives and instruction set revisions multiple variants of |
---|
244 | these libraries are available for each architecture. For example one set may |
---|
245 | use software floating point support and another set may use hardware floating |
---|
246 | point instructions. These sets of libraries are called *multilibs*. Each |
---|
247 | library set corresponds to an application binary interface (ABI) and |
---|
248 | instruction set. |
---|
249 | |
---|
250 | A multilib variant can be usually detected via built-in compiler defines at |
---|
251 | compile-time. This mechanism is used by RTEMS to select for example the |
---|
252 | context switch support for a particular BSP. The built-in compiler defines |
---|
253 | corresponding to multilibs are the only architecture specific defines allowed |
---|
254 | in the ``cpukit`` area of the RTEMS sources. |
---|
255 | |
---|
256 | Invoking the GCC with the ``-print-multi-lib`` option lists the available |
---|
257 | multilibs. Each line of the output describes one multilib variant. The |
---|
258 | default variant is denoted by ``.`` which is selected when no or |
---|
259 | contradicting GCC machine options are selected. The multilib selection for a |
---|
260 | target is specified by target makefile fragments (see file :file:`t-rtems` in |
---|
261 | the GCC sources and section`The Target Makefile Fragment <https://gcc.gnu.org/onlinedocs/gccint/Target-Fragment.html#Target-Fragment>`_ |
---|
262 | in the `GCC Internals Manual <https://gcc.gnu.org/onlinedocs/gccint/>`_. |
---|
263 | |
---|
264 | Calling Conventions |
---|
265 | =================== |
---|
266 | |
---|
267 | Each high-level language compiler generates subroutine entry and exit |
---|
268 | code based upon a set of rules known as the compilerâs calling convention. |
---|
269 | These rules address the following issues: |
---|
270 | |
---|
271 | - register preservation and usage |
---|
272 | |
---|
273 | - parameter passing |
---|
274 | |
---|
275 | - call and return mechanism |
---|
276 | |
---|
277 | A compilerâs calling convention is of importance when |
---|
278 | interfacing to subroutines written in another language either |
---|
279 | assembly or high-level. Even when the high-level language and |
---|
280 | target processor are the same, different compilers may use |
---|
281 | different calling conventions. As a result, calling conventions |
---|
282 | are both processor and compiler dependent. |
---|
283 | |
---|
284 | Calling Mechanism |
---|
285 | ----------------- |
---|
286 | |
---|
287 | In each of the architecture specific chapters, this subsection will |
---|
288 | describe the instruction(s) used to perform a *normal* subroutine |
---|
289 | invocation. All RTEMS directives are invoked as *normal* C language |
---|
290 | functions so it is important to the user application to understand the |
---|
291 | call and return mechanism. |
---|
292 | |
---|
293 | Register Usage |
---|
294 | -------------- |
---|
295 | |
---|
296 | In each of the architecture specific chapters, this subsection will |
---|
297 | detail the set of registers which are *NOT* preserved across subroutine |
---|
298 | invocations. The registers which are not preserved are assumed to be |
---|
299 | available for use as scratch registers. Therefore, the contents of these |
---|
300 | registers should not be assumed upon return from any RTEMS directive. |
---|
301 | |
---|
302 | In some architectures, there may be a set of registers made available |
---|
303 | automatically as a side-effect of the subroutine invocation |
---|
304 | mechanism. |
---|
305 | |
---|
306 | Parameter Passing |
---|
307 | ----------------- |
---|
308 | |
---|
309 | In each of the architecture specific chapters, this subsection will |
---|
310 | describe the mechanism by which the parameters or arguments are passed |
---|
311 | by the caller to a subroutine. In some architectures, all parameters |
---|
312 | are passed on the stack while in others some are passed in registers. |
---|
313 | |
---|
314 | User-Provided Routines |
---|
315 | ---------------------- |
---|
316 | |
---|
317 | All user-provided routines invoked by RTEMS, such as |
---|
318 | user extensions, device drivers, and MPCI routines, must also |
---|
319 | adhere to these calling conventions. |
---|
320 | |
---|
321 | Memory Model |
---|
322 | ============ |
---|
323 | |
---|
324 | A processor may support any combination of memory |
---|
325 | models ranging from pure physical addressing to complex demand |
---|
326 | paged virtual memory systems. RTEMS supports a flat memory |
---|
327 | model which ranges contiguously over the processorâs allowable |
---|
328 | address space. RTEMS does not support segmentation or virtual |
---|
329 | memory of any kind. The appropriate memory model for RTEMS |
---|
330 | provided by the targeted processor and related characteristics |
---|
331 | of that model are described in this chapter. |
---|
332 | |
---|
333 | Flat Memory Model |
---|
334 | ----------------- |
---|
335 | |
---|
336 | Most RTEMS target processors can be initialized to support a flat address |
---|
337 | space. Although the size of addresses varies between architectures, on |
---|
338 | most RTEMS targets, an address is 32-bits wide which defines addresses |
---|
339 | ranging from 0x00000000 to 0xFFFFFFFF (4 gigabytes). Each address is |
---|
340 | represented by a 32-bit value and is byte addressable. The address may be |
---|
341 | used to reference a single byte, word (2-bytes), or long word (4 bytes). |
---|
342 | Memory accesses within this address space may be performed in little or |
---|
343 | big endian fashion. |
---|
344 | |
---|
345 | On smaller CPU architectures supported by RTEMS, the address space |
---|
346 | may only be 20 or 24 bits wide. |
---|
347 | |
---|
348 | If the CPU model has support for virtual memory or segmentation, it is |
---|
349 | the responsibility of the Board Support Package (BSP) to initialize the |
---|
350 | MMU hardware to perform address translations which correspond to flat |
---|
351 | memory model. |
---|
352 | |
---|
353 | In each of the architecture specific chapters, this subsection will |
---|
354 | describe any architecture characteristics that differ from this general |
---|
355 | description. |
---|
356 | |
---|
357 | Interrupt Processing |
---|
358 | ==================== |
---|
359 | |
---|
360 | Different types of processors respond to the occurrence of an interrupt |
---|
361 | in its own unique fashion. In addition, each processor type provides |
---|
362 | a control mechanism to allow for the proper handling of an interrupt. |
---|
363 | The processor dependent response to the interrupt modifies the current |
---|
364 | execution state and results in a change in the execution stream. Most |
---|
365 | processors require that an interrupt handler utilize some special control |
---|
366 | mechanisms to return to the normal processing stream. Although RTEMS |
---|
367 | hides many of the processor dependent details of interrupt processing, |
---|
368 | it is important to understand how the RTEMS interrupt manager is mapped |
---|
369 | onto the processorâs unique architecture. |
---|
370 | |
---|
371 | RTEMS supports a dedicated interrupt stack for all architectures. |
---|
372 | On architectures with hardware support for a dedicated interrupt stack, |
---|
373 | it will be initialized such that when an interrupt occurs, the processor |
---|
374 | automatically switches to this dedicated stack. On architectures without |
---|
375 | hardware support for a dedicated interrupt stack which is separate from |
---|
376 | those of the tasks, RTEMS will support switching to a dedicated stack |
---|
377 | for interrupt processing. |
---|
378 | |
---|
379 | Without a dedicated interrupt stack, every task in |
---|
380 | the system MUST have enough stack space to accommodate the worst |
---|
381 | case stack usage of that particular task and the interrupt |
---|
382 | service routines COMBINED. By supporting a dedicated interrupt |
---|
383 | stack, RTEMS significantly lowers the stack requirements for |
---|
384 | each task. |
---|
385 | |
---|
386 | A nested interrupt is processed similarly with the exception that since |
---|
387 | the CPU is already executing on the interrupt stack, there is no need |
---|
388 | to switch to the interrupt stack. |
---|
389 | |
---|
390 | In some configurations, RTEMS allocates the interrupt stack from the |
---|
391 | Workspace Area. The amount of memory allocated for the interrupt stack |
---|
392 | is user configured and based upon the ``confdefs.h`` parameter``CONFIGURE_INTERRUPT_STACK_SIZE``. This parameter is described |
---|
393 | in detail in the Configuring a System chapter of the Userâs Guide. |
---|
394 | On configurations in which RTEMS allocates the interrupt stack, during |
---|
395 | the initialization process, RTEMS will also install its interrupt stack. |
---|
396 | In other configurations, the interrupt stack is allocated and installed |
---|
397 | by the Board Support Package (BSP). |
---|
398 | |
---|
399 | In each of the architecture specific chapters, this section discesses |
---|
400 | the interrupt response and control mechanisms of the architecture as |
---|
401 | they pertain to RTEMS. |
---|
402 | |
---|
403 | Vectoring of an Interrupt Handler |
---|
404 | --------------------------------- |
---|
405 | |
---|
406 | In each of the architecture specific chapters, this subsection will |
---|
407 | describe the architecture specific details of the interrupt vectoring |
---|
408 | process. In particular, it should include a description of the |
---|
409 | Interrupt Stack Frame (ISF). |
---|
410 | |
---|
411 | Interrupt Levels |
---|
412 | ---------------- |
---|
413 | |
---|
414 | In each of the architecture specific chapters, this subsection will |
---|
415 | describe how the interrupt levels available on this particular architecture |
---|
416 | are mapped onto the 255 reserved in the task mode. The interrupt level |
---|
417 | value of zero (0) should always mean that interrupts are enabled. |
---|
418 | |
---|
419 | Any use of an interrupt level that is is not undefined on a particular |
---|
420 | architecture may result in behavior that is unpredictable. |
---|
421 | |
---|
422 | Disabling of Interrupts by RTEMS |
---|
423 | -------------------------------- |
---|
424 | |
---|
425 | During the execution of directive calls, critical sections of code may |
---|
426 | be executed. When these sections are encountered, RTEMS disables all |
---|
427 | external interrupts before the execution of this section and restores |
---|
428 | them to the previous level upon completion of the section. RTEMS has |
---|
429 | been optimized to ensure that interrupts are disabled for the shortest |
---|
430 | number of instructions possible. Since the precise number of instructions |
---|
431 | and their execution time varies based upon target CPU family, CPU model, |
---|
432 | board memory speed, compiler version, and optimization level, it is |
---|
433 | not practical to provide the precise number for all possible RTEMS |
---|
434 | configurations. |
---|
435 | |
---|
436 | Historically, the measurements were made by hand analyzing and counting |
---|
437 | the execution time of instruction sequences during interrupt disable |
---|
438 | critical sections. For reference purposes, on a 16 Mhz Motorola |
---|
439 | MC68020, the maximum interrupt disable period was typically approximately |
---|
440 | ten (10) to thirteen (13) microseconds. This architecture was memory bound |
---|
441 | and had a slow bit scan instruction. In contrast, during the same |
---|
442 | period a 14 Mhz SPARC would have a worst case disable time of approximately |
---|
443 | two (2) to three (3) microseconds because it had a single cycle bit scan |
---|
444 | instruction and used fewer cycles for memory accesses. |
---|
445 | |
---|
446 | If you are interested in knowing the worst case execution time for |
---|
447 | a particular version of RTEMS, please contact OAR Corporation and |
---|
448 | we will be happy to product the results as a consulting service. |
---|
449 | |
---|
450 | Non-maskable interrupts (NMI) cannot be disabled, and |
---|
451 | ISRs which execute at this level MUST NEVER issue RTEMS system |
---|
452 | calls. If a directive is invoked, unpredictable results may |
---|
453 | occur due to the inability of RTEMS to protect its critical |
---|
454 | sections. However, ISRs that make no system calls may safely |
---|
455 | execute as non-maskable interrupts. |
---|
456 | |
---|
457 | Default Fatal Error Processing |
---|
458 | ============================== |
---|
459 | |
---|
460 | Upon detection of a fatal error by either the application or RTEMS during |
---|
461 | initialization the ``rtems_fatal_error_occurred`` directive supplied |
---|
462 | by the Fatal Error Manager is invoked. The Fatal Error Manager will |
---|
463 | invoke the user-supplied fatal error handlers. If no user-supplied |
---|
464 | handlers are configured or all of them return without taking action to |
---|
465 | shutdown the processor or reset, a default fatal error handler is invoked. |
---|
466 | |
---|
467 | Most of the action performed as part of processing the fatal error are |
---|
468 | described in detail in the Fatal Error Manager chapter in the Userâs |
---|
469 | Guide. However, the if no user provided extension or BSP specific fatal |
---|
470 | error handler takes action, the final default action is to invoke a |
---|
471 | CPU architecture specific function. Typically this function disables |
---|
472 | interrupts and halts the processor. |
---|
473 | |
---|
474 | In each of the architecture specific chapters, this describes the precise |
---|
475 | operations of the default CPU specific fatal error handler. |
---|
476 | |
---|
477 | Symmetric Multiprocessing |
---|
478 | ========================= |
---|
479 | |
---|
480 | This section contains information about the Symmetric Multiprocessing (SMP) |
---|
481 | status of a particular architecture. |
---|
482 | |
---|
483 | Thread-Local Storage |
---|
484 | ==================== |
---|
485 | |
---|
486 | In order to support thread-local storage (TLS) the CPU port must implement the |
---|
487 | facilities mandated by the application binary interface (ABI) of the CPU |
---|
488 | architecture. The CPU port must initialize the TLS area in the``_CPU_Context_Initialize()`` function. There are support functions available |
---|
489 | via ``#include <rtems/score/tls.h>`` which implement Variants I and II |
---|
490 | according to Ulrich Drepper, *ELF Handling For Thread-Local Storage*. |
---|
491 | |
---|
492 | ``_TLS_TCB_at_area_begin_initialize()`` |
---|
493 | Uses Variant I, TLS offsets emitted by linker takes the TCB into account. For |
---|
494 | a reference implementation see :file:`cpukit/score/cpu/arm/cpu.c`. |
---|
495 | |
---|
496 | ``_TLS_TCB_before_TLS_block_initialize()`` |
---|
497 | Uses Variant I, TLS offsets emitted by linker neglects the TCB. For a |
---|
498 | reference implementation see:file:`c/src/lib/libcpu/powerpc/new-exceptions/cpu.c`. |
---|
499 | |
---|
500 | ``_TLS_TCB_after_TLS_block_initialize()`` |
---|
501 | Uses Variant II. For a reference implementation see:file:`cpukit/score/cpu/sparc/cpu.c`. |
---|
502 | |
---|
503 | The board support package (BSP) must provide the following sections and symbols |
---|
504 | in its linker command file: |
---|
505 | .. code:: c |
---|
506 | |
---|
507 | .tdata : { |
---|
508 | _TLS_Data_begin = .; |
---|
509 | \*(.tdata .tdata.* .gnu.linkonce.td.*) |
---|
510 | _TLS_Data_end = .; |
---|
511 | } |
---|
512 | .tbss : { |
---|
513 | _TLS_BSS_begin = .; |
---|
514 | \*(.tbss .tbss.* .gnu.linkonce.tb.*) \*(.tcommon) |
---|
515 | _TLS_BSS_end = .; |
---|
516 | } |
---|
517 | _TLS_Data_size = _TLS_Data_end - _TLS_Data_begin; |
---|
518 | _TLS_Data_begin = _TLS_Data_size != 0 ? _TLS_Data_begin : _TLS_BSS_begin; |
---|
519 | _TLS_Data_end = _TLS_Data_size != 0 ? _TLS_Data_end : _TLS_BSS_begin; |
---|
520 | _TLS_BSS_size = _TLS_BSS_end - _TLS_BSS_begin; |
---|
521 | _TLS_Size = _TLS_BSS_end - _TLS_Data_begin; |
---|
522 | _TLS_Alignment = MAX (ALIGNOF (.tdata), ALIGNOF (.tbss)); |
---|
523 | |
---|
524 | CPU counter |
---|
525 | =========== |
---|
526 | |
---|
527 | The CPU support must implement the CPU counter interface. A CPU counter is |
---|
528 | some free-running counter. It ticks usually with a frequency close to the CPU |
---|
529 | or system bus clock. On some architectures the actual implementation is board |
---|
530 | support package dependent. The CPU counter is used for profiling of low-level |
---|
531 | functions. It is also used to implement two busy wait functions``rtems_counter_delay_ticks()`` and ``rtems_counter_delay_nanoseconds()`` |
---|
532 | which may be used in device drivers. It may be also used as an entropy source |
---|
533 | for random number generators. |
---|
534 | |
---|
535 | The CPU counter interface uses a CPU port specific unsigned integer type``CPU_Counter_ticks`` to represent CPU counter values. The CPU port must |
---|
536 | provide the following two functions |
---|
537 | |
---|
538 | - ``_CPU_Counter_read()`` to read the current CPU counter value, and |
---|
539 | |
---|
540 | - ``_CPU_Counter_difference()`` to get the difference between two CPU |
---|
541 | counter values. |
---|
542 | |
---|
543 | Interrupt Profiling |
---|
544 | =================== |
---|
545 | |
---|
546 | The RTEMS profiling needs support by the CPU port for the interrupt entry and |
---|
547 | exit times. In case profiling is enabled via the RTEMS build configuration |
---|
548 | option ``--enable-profiling`` (in this case the pre-processor symbol``RTEMS_PROFILING`` is defined) the CPU port may provide data for the |
---|
549 | interrupt entry and exit times of the outer-most interrupt. The CPU port can |
---|
550 | feed interrupt entry and exit times with the``_Profiling_Outer_most_interrupt_entry_and_exit()`` function |
---|
551 | (``#include <rtems/score/profiling.h>``). For an example please have a look |
---|
552 | at ``cpukit/score/cpu/arm/arm_exc_interrupt.S``. |
---|
553 | |
---|
554 | Board Support Packages |
---|
555 | ====================== |
---|
556 | |
---|
557 | An RTEMS Board Support Package (BSP) must be designed to support a |
---|
558 | particular processor model and target board combination. |
---|
559 | |
---|
560 | In each of the architecture specific chapters, this section will present |
---|
561 | a discussion of architecture specific BSP issues. For more information |
---|
562 | on developing a BSP, refer to BSP and Device Driver Development Guide |
---|
563 | and the chapter titled Board Support Packages in the RTEMS |
---|
564 | Applications Userâs Guide. |
---|
565 | |
---|
566 | System Reset |
---|
567 | ------------ |
---|
568 | |
---|
569 | An RTEMS based application is initiated or re-initiated when the processor |
---|
570 | is reset or transfer is passed to it from a boot monitor or ROM monitor. |
---|
571 | |
---|
572 | In each of the architecture specific chapters, this subsection describes |
---|
573 | the actions that the BSP must tak assuming the application gets control |
---|
574 | when the microprocessor is reset. |
---|
575 | |
---|
576 | .. COMMENT: COPYRIGHT (c) 1988-2002. |
---|
577 | |
---|
578 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
579 | |
---|
580 | .. COMMENT: All rights reserved. |
---|
581 | |
---|
582 | ARM Specific Information |
---|
583 | ######################## |
---|
584 | |
---|
585 | This chapter discusses the`ARM architecture <http://en.wikipedia.org/wiki/ARM_architecture>`_ |
---|
586 | dependencies in this port of RTEMS. The ARMv4T (and compatible), ARMv7-A, |
---|
587 | ARMv7-R and ARMv7-M architecture versions are supported by RTEMS. Processors |
---|
588 | with a MMU use a static configuration which is set up during system start. SMP |
---|
589 | is supported. |
---|
590 | |
---|
591 | **Architecture Documents** |
---|
592 | |
---|
593 | For information on the ARM architecture refer to the`ARM Infocenter <http://infocenter.arm.com>`_. |
---|
594 | |
---|
595 | CPU Model Dependent Features |
---|
596 | ============================ |
---|
597 | |
---|
598 | This section presents the set of features which vary |
---|
599 | across ARM implementations and are of importance to RTEMS. The set of CPU |
---|
600 | model feature macros are defined in the file:file:`cpukit/score/cpu/arm/rtems/score/arm.h` based upon the particular CPU |
---|
601 | model flags specified on the compilation command line. |
---|
602 | |
---|
603 | CPU Model Name |
---|
604 | -------------- |
---|
605 | |
---|
606 | The macro ``CPU_MODEL_NAME`` is a string which designates |
---|
607 | the architectural level of this CPU model. See in:file:`cpukit/score/cpu/arm/rtems/score/arm.h` for the values. |
---|
608 | |
---|
609 | Count Leading Zeroes Instruction |
---|
610 | -------------------------------- |
---|
611 | |
---|
612 | The ARMv5 and later has the count leading zeroes ``clz`` instruction which |
---|
613 | could be used to speed up the find first bit operation. The use of this |
---|
614 | instruction should significantly speed up the scheduling associated with a |
---|
615 | thread blocking. This is currently not used. |
---|
616 | |
---|
617 | Floating Point Unit |
---|
618 | ------------------- |
---|
619 | |
---|
620 | The following floating point units are supported. |
---|
621 | |
---|
622 | - VFPv3-D32/NEON (for example available on Cortex-A processors) |
---|
623 | |
---|
624 | - VFPv3-D16 (for example available on Cortex-R processors) |
---|
625 | |
---|
626 | - FPv4-SP-D16 (for example available on Cortex-M processors) |
---|
627 | |
---|
628 | Multilibs |
---|
629 | ========= |
---|
630 | |
---|
631 | The following multilibs are available: |
---|
632 | |
---|
633 | # ``.``: ARMv4T, ARM instruction set |
---|
634 | |
---|
635 | # ``thumb``: ARMv4T, Thumb-1 instruction set |
---|
636 | |
---|
637 | # ``thumb/armv6-m``: ARMv6M, subset of Thumb-2 instruction set |
---|
638 | |
---|
639 | # ``thumb/armv7-a``: ARMv7-A, Thumb-2 instruction set |
---|
640 | |
---|
641 | # ``thumb/armv7-a/neon/hard``: ARMv7-A, Thumb-2 instruction set with |
---|
642 | hard-float ABI Neon and VFP-D32 support |
---|
643 | |
---|
644 | # ``thumb/armv7-r``: ARMv7-R, Thumb-2 instruction set |
---|
645 | |
---|
646 | # ``thumb/armv7-r/vfpv3-d16/hard``: ARMv7-R, Thumb-2 instruction set |
---|
647 | with hard-float ABI VFP-D16 support |
---|
648 | |
---|
649 | # ``thumb/armv7-m``: ARMv7-M, Thumb-2 instruction set with hardware |
---|
650 | integer division (SDIV/UDIV) |
---|
651 | |
---|
652 | # ``thumb/armv7-m/fpv4-sp-d16``: ARMv7-M, Thumb-2 instruction set with |
---|
653 | hardware integer division (SDIV/UDIV) and hard-float ABI FPv4-SP support |
---|
654 | |
---|
655 | # ``eb/thumb/armv7-r``: ARMv7-R, Big-endian Thumb-2 instruction set |
---|
656 | |
---|
657 | # ``eb/thumb/armv7-r/vfpv3-d16/hard``: ARMv7-R, Big-endian Thumb-2 |
---|
658 | instruction set with hard-float ABI VFP-D16 support |
---|
659 | |
---|
660 | Multilib 1. and 2. support the standard ARM7TDMI and ARM926EJ-S targets. |
---|
661 | |
---|
662 | Multilib 3. supports the Cortex-M0 and Cortex-M1 cores. |
---|
663 | |
---|
664 | Multilib 8. supports the Cortex-M3 and Cortex-M4 cores, which have a special |
---|
665 | hardware integer division instruction (this is not present in the A and R |
---|
666 | profiles). |
---|
667 | |
---|
668 | Multilib 9. supports the Cortex-M4 cores with a floating point unit. |
---|
669 | |
---|
670 | Multilib 4. and 5. support the Cortex-A processors. |
---|
671 | |
---|
672 | Multilib 6., 7., 10. and 11. support the Cortex-R processors. Here also |
---|
673 | big-endian variants are available. |
---|
674 | |
---|
675 | Use for example the following GCC options |
---|
676 | .. code:: c |
---|
677 | |
---|
678 | -mthumb -march=armv7-a -mfpu=neon -mfloat-abi=hard -mtune=cortex-a9 |
---|
679 | |
---|
680 | to build an application or BSP for the ARMv7-A architecture and tune the code |
---|
681 | for a Cortex-A9 processor. It is important to select the options used for the |
---|
682 | multilibs. For example |
---|
683 | .. code:: c |
---|
684 | |
---|
685 | -mthumb -mcpu=cortex-a9 |
---|
686 | |
---|
687 | alone will not select the ARMv7-A multilib. |
---|
688 | |
---|
689 | Calling Conventions |
---|
690 | =================== |
---|
691 | |
---|
692 | Please refer to the`Procedure Call Standard for the ARM Architecture <http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042c/IHI0042C_aapcs.pdf>`_. |
---|
693 | |
---|
694 | Memory Model |
---|
695 | ============ |
---|
696 | |
---|
697 | A flat 32-bit memory model is supported. The board support package must take |
---|
698 | care about the MMU if necessary. |
---|
699 | |
---|
700 | Interrupt Processing |
---|
701 | ==================== |
---|
702 | |
---|
703 | The ARMv4T (and compatible) architecture has seven exception types: |
---|
704 | |
---|
705 | - Reset |
---|
706 | |
---|
707 | - Undefined |
---|
708 | |
---|
709 | - Software Interrupt (SWI) |
---|
710 | |
---|
711 | - Prefetch Abort |
---|
712 | |
---|
713 | - Data Abort |
---|
714 | |
---|
715 | - Interrupt (IRQ) |
---|
716 | |
---|
717 | - Fast Interrupt (FIQ) |
---|
718 | |
---|
719 | Of these types only the IRQ has explicit operating system support. It is |
---|
720 | intentional that the FIQ is not supported by the operating system. Without |
---|
721 | operating system support for the FIQ it is not necessary to disable them during |
---|
722 | critical sections of the system. |
---|
723 | |
---|
724 | The ARMv7-M architecture has a completely different exception model. Here |
---|
725 | interrupts are disabled with a write of 0x80 to the ``basepri_max`` |
---|
726 | register. This means that all exceptions and interrupts with a priority value |
---|
727 | of greater than or equal to 0x80 are disabled. Thus exceptions and interrupts |
---|
728 | with a priority value of less than 0x80 are non-maskable with respect to the |
---|
729 | operating system and therefore must not use operating system services. Several |
---|
730 | support libraries of chip vendors implicitly shift the priority value somehow |
---|
731 | before the value is written to the NVIC IPR register. This can easily lead to |
---|
732 | confusion. |
---|
733 | |
---|
734 | Interrupt Levels |
---|
735 | ---------------- |
---|
736 | |
---|
737 | There are exactly two interrupt levels on ARM with respect to RTEMS. Level |
---|
738 | zero corresponds to interrupts enabled. Level one corresponds to interrupts |
---|
739 | disabled. |
---|
740 | |
---|
741 | Interrupt Stack |
---|
742 | --------------- |
---|
743 | |
---|
744 | The board support package must initialize the interrupt stack. The memory for |
---|
745 | the stacks is usually reserved in the linker script. |
---|
746 | |
---|
747 | Default Fatal Error Processing |
---|
748 | ============================== |
---|
749 | |
---|
750 | The default fatal error handler for this architecture performs the |
---|
751 | following actions: |
---|
752 | |
---|
753 | - disables operating system supported interrupts (IRQ), |
---|
754 | |
---|
755 | - places the error code in ``r0``, and |
---|
756 | |
---|
757 | - executes an infinite loop to simulate a halt processor instruction. |
---|
758 | |
---|
759 | Symmetric Multiprocessing |
---|
760 | ========================= |
---|
761 | |
---|
762 | SMP is supported on ARMv7-A. Available platforms are the Altera Cyclone V and |
---|
763 | the Xilinx Zynq. |
---|
764 | |
---|
765 | Thread-Local Storage |
---|
766 | ==================== |
---|
767 | |
---|
768 | Thread-local storage is supported. |
---|
769 | |
---|
770 | .. COMMENT: COPYRIGHT (c) 1988-2009. |
---|
771 | |
---|
772 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
773 | |
---|
774 | .. COMMENT: All rights reserved. |
---|
775 | |
---|
776 | Atmel AVR Specific Information |
---|
777 | ############################## |
---|
778 | |
---|
779 | This chapter discusses the AVR architecture dependencies in this |
---|
780 | port of RTEMS. |
---|
781 | |
---|
782 | **Architecture Documents** |
---|
783 | |
---|
784 | For information on the AVR architecture, refer to the following |
---|
785 | documents available from Atmel. |
---|
786 | |
---|
787 | TBD |
---|
788 | |
---|
789 | - See other CPUs for documentation reference formatting examples. |
---|
790 | |
---|
791 | CPU Model Dependent Features |
---|
792 | ============================ |
---|
793 | |
---|
794 | CPUs of the AVR 53X only differ in the peripherals and thus in the |
---|
795 | device drivers. This port does not yet support the 56X dual core variants. |
---|
796 | |
---|
797 | Count Leading Zeroes Instruction |
---|
798 | -------------------------------- |
---|
799 | |
---|
800 | The AVR CPU has the XXX instruction which could be used to speed |
---|
801 | up the find first bit operation. The use of this instruction should |
---|
802 | significantly speed up the scheduling associated with a thread blocking. |
---|
803 | |
---|
804 | Calling Conventions |
---|
805 | =================== |
---|
806 | |
---|
807 | Processor Background |
---|
808 | -------------------- |
---|
809 | |
---|
810 | The AVR architecture supports a simple call and return mechanism. |
---|
811 | A subroutine is invoked via the call (``call``) instruction. |
---|
812 | This instruction saves the return address in the ``RETS`` register |
---|
813 | and transfers the execution to the given address. |
---|
814 | |
---|
815 | It is the called funcions responsability to use the link instruction |
---|
816 | to reserve space on the stack for the local variables. Returning from |
---|
817 | a subroutine is done by using the RTS (``RTS``) instruction which |
---|
818 | loads the PC with the adress stored in RETS. |
---|
819 | |
---|
820 | It is is important to note that the ``call`` instruction does not |
---|
821 | automatically save or restore any registers. It is the responsibility |
---|
822 | of the high-level language compiler to define the register preservation |
---|
823 | and usage convention. |
---|
824 | |
---|
825 | Register Usage |
---|
826 | -------------- |
---|
827 | |
---|
828 | A called function may clobber all registers, except RETS, R4-R7, P3-P5, |
---|
829 | FP and SP. It may also modify the first 12 bytes in the callerâÂÂs stack |
---|
830 | frame which is used as an argument area for the first three arguments |
---|
831 | (which are passed in R0...R3 but may be placed on the stack by the |
---|
832 | called function). |
---|
833 | |
---|
834 | Parameter Passing |
---|
835 | ----------------- |
---|
836 | |
---|
837 | RTEMS assumes that the AVR GCC calling convention is followed. |
---|
838 | The first three parameters are stored in registers R0, R1, and R2. |
---|
839 | All other parameters are put pushed on the stack. The result is returned |
---|
840 | through register R0. |
---|
841 | |
---|
842 | Memory Model |
---|
843 | ============ |
---|
844 | |
---|
845 | The AVR family architecutre support a single unified 4 GB byte |
---|
846 | address space using 32-bit addresses. It maps all resources like internal |
---|
847 | and external memory and IO registers into separate sections of this |
---|
848 | common address space. |
---|
849 | |
---|
850 | The AVR architcture supports some form of memory |
---|
851 | protection via its Memory Management Unit. Since the |
---|
852 | AVR port runs in supervisior mode this memory |
---|
853 | protection mechanisms are not used. |
---|
854 | |
---|
855 | Interrupt Processing |
---|
856 | ==================== |
---|
857 | |
---|
858 | Discussed in this chapter are the AVRâs interrupt response and |
---|
859 | control mechanisms as they pertain to RTEMS. |
---|
860 | |
---|
861 | Vectoring of an Interrupt Handler |
---|
862 | --------------------------------- |
---|
863 | |
---|
864 | TBD |
---|
865 | |
---|
866 | Disabling of Interrupts by RTEMS |
---|
867 | -------------------------------- |
---|
868 | |
---|
869 | During interrupt disable critical sections, RTEMS disables interrupts to |
---|
870 | level N (N) before the execution of this section and restores them |
---|
871 | to the previous level upon completion of the section. RTEMS uses the |
---|
872 | instructions CLI and STI to enable and disable Interrupts. Emulation, |
---|
873 | Reset, NMI and Exception Interrupts are never disabled. |
---|
874 | |
---|
875 | Interrupt Stack |
---|
876 | --------------- |
---|
877 | |
---|
878 | The AVR Architecture works with two different kind of stacks, |
---|
879 | User and Supervisor Stack. Since RTEMS and its Application run |
---|
880 | in supervisor mode, all interrupts will use the interrupted |
---|
881 | tasks stack for execution. |
---|
882 | |
---|
883 | Default Fatal Error Processing |
---|
884 | ============================== |
---|
885 | |
---|
886 | The default fatal error handler for the AVR performs the following |
---|
887 | actions: |
---|
888 | |
---|
889 | - disables processor interrupts, |
---|
890 | |
---|
891 | - places the error code in *r0*, and |
---|
892 | |
---|
893 | - executes an infinite loop (``while(0);`` to |
---|
894 | simulate a halt processor instruction. |
---|
895 | |
---|
896 | Symmetric Multiprocessing |
---|
897 | ========================= |
---|
898 | |
---|
899 | SMP is not supported. |
---|
900 | |
---|
901 | Thread-Local Storage |
---|
902 | ==================== |
---|
903 | |
---|
904 | Thread-local storage is not supported due to a broken tool chain. |
---|
905 | |
---|
906 | Board Support Packages |
---|
907 | ====================== |
---|
908 | |
---|
909 | System Reset |
---|
910 | ------------ |
---|
911 | |
---|
912 | TBD |
---|
913 | |
---|
914 | .. COMMENT: COPYRIGHT (c) 1988-2006. |
---|
915 | |
---|
916 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
917 | |
---|
918 | .. COMMENT: All rights reserved. |
---|
919 | |
---|
920 | Blackfin Specific Information |
---|
921 | ############################# |
---|
922 | |
---|
923 | This chapter discusses the Blackfin architecture dependencies in this |
---|
924 | port of RTEMS. |
---|
925 | |
---|
926 | **Architecture Documents** |
---|
927 | |
---|
928 | For information on the Blackfin architecture, refer to the following |
---|
929 | documents available from Analog Devices. |
---|
930 | |
---|
931 | TBD |
---|
932 | |
---|
933 | - *"ADSP-BF533 Blackfin Processor Hardware Reference."*:file:`http://www.analog.com/UploadedFiles/Associated_Docs/892485982bf533_hwr.pdf` |
---|
934 | |
---|
935 | CPU Model Dependent Features |
---|
936 | ============================ |
---|
937 | |
---|
938 | CPUs of the Blackfin 53X only differ in the peripherals and thus in the |
---|
939 | device drivers. This port does not yet support the 56X dual core variants. |
---|
940 | |
---|
941 | Count Leading Zeroes Instruction |
---|
942 | -------------------------------- |
---|
943 | |
---|
944 | The Blackfin CPU has the BITTST instruction which could be used to speed |
---|
945 | up the find first bit operation. The use of this instruction should |
---|
946 | significantly speed up the scheduling associated with a thread blocking. |
---|
947 | |
---|
948 | Calling Conventions |
---|
949 | =================== |
---|
950 | |
---|
951 | This section is heavily based on content taken from the Blackfin uCLinux |
---|
952 | documentation wiki which is edited by Analog Devices and Arcturus |
---|
953 | Networks. :file:`http://docs.blackfin.uclinux.org/` |
---|
954 | |
---|
955 | Processor Background |
---|
956 | -------------------- |
---|
957 | |
---|
958 | The Blackfin architecture supports a simple call and return mechanism. |
---|
959 | A subroutine is invoked via the call (``call``) instruction. |
---|
960 | This instruction saves the return address in the ``RETS`` register |
---|
961 | and transfers the execution to the given address. |
---|
962 | |
---|
963 | It is the called funcions responsability to use the link instruction |
---|
964 | to reserve space on the stack for the local variables. Returning from |
---|
965 | a subroutine is done by using the RTS (``RTS``) instruction which |
---|
966 | loads the PC with the adress stored in RETS. |
---|
967 | |
---|
968 | It is is important to note that the ``call`` instruction does not |
---|
969 | automatically save or restore any registers. It is the responsibility |
---|
970 | of the high-level language compiler to define the register preservation |
---|
971 | and usage convention. |
---|
972 | |
---|
973 | Register Usage |
---|
974 | -------------- |
---|
975 | |
---|
976 | A called function may clobber all registers, except RETS, R4-R7, P3-P5, |
---|
977 | FP and SP. It may also modify the first 12 bytes in the callerâÂÂs stack |
---|
978 | frame which is used as an argument area for the first three arguments |
---|
979 | (which are passed in R0...R3 but may be placed on the stack by the |
---|
980 | called function). |
---|
981 | |
---|
982 | Parameter Passing |
---|
983 | ----------------- |
---|
984 | |
---|
985 | RTEMS assumes that the Blackfin GCC calling convention is followed. |
---|
986 | The first three parameters are stored in registers R0, R1, and R2. |
---|
987 | All other parameters are put pushed on the stack. The result is returned |
---|
988 | through register R0. |
---|
989 | |
---|
990 | Memory Model |
---|
991 | ============ |
---|
992 | |
---|
993 | The Blackfin family architecutre support a single unified 4 GB byte |
---|
994 | address space using 32-bit addresses. It maps all resources like internal |
---|
995 | and external memory and IO registers into separate sections of this |
---|
996 | common address space. |
---|
997 | |
---|
998 | The Blackfin architcture supports some form of memory |
---|
999 | protection via its Memory Management Unit. Since the |
---|
1000 | Blackfin port runs in supervisior mode this memory |
---|
1001 | protection mechanisms are not used. |
---|
1002 | |
---|
1003 | Interrupt Processing |
---|
1004 | ==================== |
---|
1005 | |
---|
1006 | Discussed in this chapter are the Blackfinâs interrupt response and |
---|
1007 | control mechanisms as they pertain to RTEMS. The Blackfin architecture |
---|
1008 | support 16 kinds of interrupts broken down into Core and general-purpose |
---|
1009 | interrupts. |
---|
1010 | |
---|
1011 | Vectoring of an Interrupt Handler |
---|
1012 | --------------------------------- |
---|
1013 | |
---|
1014 | RTEMS maps levels 0 -15 directly to Blackfins event vectors EVT0 - |
---|
1015 | EVT15. Since EVT0 - EVT6 are core events and it is suggested to use |
---|
1016 | EVT15 and EVT15 for Software interrupts, 7 Interrupts (EVT7-EVT13) |
---|
1017 | are left for periferical use. |
---|
1018 | |
---|
1019 | When installing an RTEMS interrupt handler RTEMS installs a generic |
---|
1020 | Interrupt Handler which saves some context and enables nested interrupt |
---|
1021 | servicing and then vectors to the users interrupt handler. |
---|
1022 | |
---|
1023 | Disabling of Interrupts by RTEMS |
---|
1024 | -------------------------------- |
---|
1025 | |
---|
1026 | During interrupt disable critical sections, RTEMS disables interrupts to |
---|
1027 | level four (4) before the execution of this section and restores them |
---|
1028 | to the previous level upon completion of the section. RTEMS uses the |
---|
1029 | instructions CLI and STI to enable and disable Interrupts. Emulation, |
---|
1030 | Reset, NMI and Exception Interrupts are never disabled. |
---|
1031 | |
---|
1032 | Interrupt Stack |
---|
1033 | --------------- |
---|
1034 | |
---|
1035 | The Blackfin Architecture works with two different kind of stacks, |
---|
1036 | User and Supervisor Stack. Since RTEMS and its Application run |
---|
1037 | in supervisor mode, all interrupts will use the interrupted |
---|
1038 | tasks stack for execution. |
---|
1039 | |
---|
1040 | Default Fatal Error Processing |
---|
1041 | ============================== |
---|
1042 | |
---|
1043 | The default fatal error handler for the Blackfin performs the following |
---|
1044 | actions: |
---|
1045 | |
---|
1046 | - disables processor interrupts, |
---|
1047 | |
---|
1048 | - places the error code in *r0*, and |
---|
1049 | |
---|
1050 | - executes an infinite loop (``while(0);`` to |
---|
1051 | simulate a halt processor instruction. |
---|
1052 | |
---|
1053 | Symmetric Multiprocessing |
---|
1054 | ========================= |
---|
1055 | |
---|
1056 | SMP is not supported. |
---|
1057 | |
---|
1058 | Thread-Local Storage |
---|
1059 | ==================== |
---|
1060 | |
---|
1061 | Thread-local storage is not implemented. |
---|
1062 | |
---|
1063 | Board Support Packages |
---|
1064 | ====================== |
---|
1065 | |
---|
1066 | System Reset |
---|
1067 | ------------ |
---|
1068 | |
---|
1069 | TBD |
---|
1070 | |
---|
1071 | .. COMMENT: Copyright (c) 2015 University of York. |
---|
1072 | |
---|
1073 | .. COMMENT: Hesham ALMatary <hmka501@york.ac.uk> |
---|
1074 | |
---|
1075 | Epiphany Specific Information |
---|
1076 | ############################# |
---|
1077 | |
---|
1078 | This chapter discusses the`Epiphany Architecture <http://adapteva.com/docs/epiphany_sdk_ref.pdf>`_ |
---|
1079 | dependencies in this port of RTEMS. Epiphany is a chip that can come with 16 and |
---|
1080 | 64 cores, each of which can run RTEMS separately or they can work together to |
---|
1081 | run a SMP RTEMS application. |
---|
1082 | |
---|
1083 | **Architecture Documents** |
---|
1084 | |
---|
1085 | For information on the Epiphany architecture refer to the`Epiphany Architecture Reference <http://adapteva.com/docs/epiphany_arch_ref.pdf>`_. |
---|
1086 | |
---|
1087 | Calling Conventions |
---|
1088 | =================== |
---|
1089 | |
---|
1090 | Please refer to the`Epiphany SDK <http://adapteva.com/docs/epiphany_sdk_ref.pdf>`_ |
---|
1091 | Appendix A: Application Binary Interface |
---|
1092 | |
---|
1093 | Floating Point Unit |
---|
1094 | ------------------- |
---|
1095 | |
---|
1096 | A floating point unit is currently not supported. |
---|
1097 | |
---|
1098 | Memory Model |
---|
1099 | ============ |
---|
1100 | |
---|
1101 | A flat 32-bit memory model is supported, no caches. Each core has its own 32 KiB |
---|
1102 | strictly ordered local memory along with an access to a shared 32 MiB external |
---|
1103 | DRAM. |
---|
1104 | |
---|
1105 | Interrupt Processing |
---|
1106 | ==================== |
---|
1107 | |
---|
1108 | Every Epiphany core has 10 exception types: |
---|
1109 | |
---|
1110 | - Reset |
---|
1111 | |
---|
1112 | - Software Exception |
---|
1113 | |
---|
1114 | - Data Page Fault |
---|
1115 | |
---|
1116 | - Timer 0 |
---|
1117 | |
---|
1118 | - Timer 1 |
---|
1119 | |
---|
1120 | - Message Interrupt |
---|
1121 | |
---|
1122 | - DMA0 Interrupt |
---|
1123 | |
---|
1124 | - DMA1 Interrupt |
---|
1125 | |
---|
1126 | - WANT Interrupt |
---|
1127 | |
---|
1128 | - User Interrupt |
---|
1129 | |
---|
1130 | Interrupt Levels |
---|
1131 | ---------------- |
---|
1132 | |
---|
1133 | There are only two levels: interrupts enabled and interrupts disabled. |
---|
1134 | |
---|
1135 | Interrupt Stack |
---|
1136 | --------------- |
---|
1137 | |
---|
1138 | The Epiphany RTEMS port uses a dedicated software interrupt stack. |
---|
1139 | The stack for interrupts is allocated during interrupt driver initialization. |
---|
1140 | When an interrupt is entered, the _ISR_Handler routine is responsible for |
---|
1141 | switching from the interrupted task stack to RTEMS software interrupt stack. |
---|
1142 | |
---|
1143 | Default Fatal Error Processing |
---|
1144 | ============================== |
---|
1145 | |
---|
1146 | The default fatal error handler for this architecture performs the |
---|
1147 | following actions: |
---|
1148 | |
---|
1149 | - disables operating system supported interrupts (IRQ), |
---|
1150 | |
---|
1151 | - places the error code in ``r0``, and |
---|
1152 | |
---|
1153 | - executes an infinite loop to simulate a halt processor instruction. |
---|
1154 | |
---|
1155 | Symmetric Multiprocessing |
---|
1156 | ========================= |
---|
1157 | |
---|
1158 | SMP is not supported. |
---|
1159 | |
---|
1160 | .. COMMENT: COPYRIGHT (c) 1988-2002. |
---|
1161 | |
---|
1162 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
1163 | |
---|
1164 | .. COMMENT: All rights reserved. |
---|
1165 | |
---|
1166 | Intel/AMD x86 Specific Information |
---|
1167 | ################################## |
---|
1168 | |
---|
1169 | This chapter discusses the Intel x86 architecture dependencies |
---|
1170 | in this port of RTEMS. This family has multiple implementations |
---|
1171 | from multiple vendors and suffers more from having evolved rather |
---|
1172 | than being designed for growth. |
---|
1173 | |
---|
1174 | For information on the i386 processor, refer to the |
---|
1175 | following documents: |
---|
1176 | |
---|
1177 | - *386 Programmerâs Reference Manual, Intel, Order No. 230985-002*. |
---|
1178 | |
---|
1179 | - *386 Microprocessor Hardware Reference Manual, Intel, |
---|
1180 | Order No. 231732-003*. |
---|
1181 | |
---|
1182 | - *80386 System Software Writerâs Guide, Intel, Order No. 231499-001*. |
---|
1183 | |
---|
1184 | - *80387 Programmerâs Reference Manual, Intel, Order No. 231917-001*. |
---|
1185 | |
---|
1186 | CPU Model Dependent Features |
---|
1187 | ============================ |
---|
1188 | |
---|
1189 | This section presents the set of features which vary |
---|
1190 | across i386 implementations and are of importance to RTEMS. |
---|
1191 | The set of CPU model feature macros are defined in the file``cpukit/score/cpu/i386/i386.h`` based upon the particular CPU |
---|
1192 | model specified on the compilation command line. |
---|
1193 | |
---|
1194 | bswap Instruction |
---|
1195 | ----------------- |
---|
1196 | |
---|
1197 | The macro ``I386_HAS_BSWAP`` is set to 1 to indicate that |
---|
1198 | this CPU model has the ``bswap`` instruction which |
---|
1199 | endian swaps a thirty-two bit quantity. This instruction |
---|
1200 | appears to be present in all CPU models |
---|
1201 | i486âs and above. |
---|
1202 | |
---|
1203 | Calling Conventions |
---|
1204 | =================== |
---|
1205 | |
---|
1206 | Processor Background |
---|
1207 | -------------------- |
---|
1208 | |
---|
1209 | The i386 architecture supports a simple yet effective |
---|
1210 | call and return mechanism. A subroutine is invoked via the call |
---|
1211 | (``call``) instruction. This instruction pushes the return address |
---|
1212 | on the stack. The return from subroutine (``ret``) instruction pops |
---|
1213 | the return address off the current stack and transfers control |
---|
1214 | to that instruction. It is is important to note that the i386 |
---|
1215 | call and return mechanism does not automatically save or restore |
---|
1216 | any registers. It is the responsibility of the high-level |
---|
1217 | language compiler to define the register preservation and usage |
---|
1218 | convention. |
---|
1219 | |
---|
1220 | Calling Mechanism |
---|
1221 | ----------------- |
---|
1222 | |
---|
1223 | All RTEMS directives are invoked using a call instruction and return to |
---|
1224 | the user application via the ret instruction. |
---|
1225 | |
---|
1226 | Register Usage |
---|
1227 | -------------- |
---|
1228 | |
---|
1229 | As discussed above, the call instruction does not automatically save |
---|
1230 | any registers. RTEMS uses the registers EAX, ECX, and EDX as scratch |
---|
1231 | registers. These registers are not preserved by RTEMS directives |
---|
1232 | therefore, the contents of these registers should not be assumed upon |
---|
1233 | return from any RTEMS directive. |
---|
1234 | |
---|
1235 | Parameter Passing |
---|
1236 | ----------------- |
---|
1237 | |
---|
1238 | RTEMS assumes that arguments are placed on the |
---|
1239 | current stack before the directive is invoked via the call |
---|
1240 | instruction. The first argument is assumed to be closest to the |
---|
1241 | return address on the stack. This means that the first argument |
---|
1242 | of the C calling sequence is pushed last. The following |
---|
1243 | pseudo-code illustrates the typical sequence used to call a |
---|
1244 | RTEMS directive with three (3) arguments: |
---|
1245 | .. code:: c |
---|
1246 | |
---|
1247 | push third argument |
---|
1248 | push second argument |
---|
1249 | push first argument |
---|
1250 | invoke directive |
---|
1251 | remove arguments from the stack |
---|
1252 | |
---|
1253 | The arguments to RTEMS are typically pushed onto the |
---|
1254 | stack using a push instruction. These arguments must be removed |
---|
1255 | from the stack after control is returned to the caller. This |
---|
1256 | removal is typically accomplished by adding the size of the |
---|
1257 | argument list in bytes to the stack pointer. |
---|
1258 | |
---|
1259 | Memory Model |
---|
1260 | ============ |
---|
1261 | |
---|
1262 | Flat Memory Model |
---|
1263 | ----------------- |
---|
1264 | |
---|
1265 | RTEMS supports the i386 protected mode, flat memory |
---|
1266 | model with paging disabled. In this mode, the i386 |
---|
1267 | automatically converts every address from a logical to a |
---|
1268 | physical address each time it is used. The i386 uses |
---|
1269 | information provided in the segment registers and the Global |
---|
1270 | Descriptor Table to convert these addresses. RTEMS assumes the |
---|
1271 | existence of the following segments: |
---|
1272 | |
---|
1273 | - a single code segment at protection level (0) which |
---|
1274 | contains all application and executive code. |
---|
1275 | |
---|
1276 | - a single data segment at protection level zero (0) which |
---|
1277 | contains all application and executive data. |
---|
1278 | |
---|
1279 | The i386 segment registers and associated selectors |
---|
1280 | must be initialized when the initialize_executive directive is |
---|
1281 | invoked. RTEMS treats the segment registers as system registers |
---|
1282 | and does not modify or context switch them. |
---|
1283 | |
---|
1284 | This i386 memory model supports a flat 32-bit address |
---|
1285 | space with addresses ranging from 0x00000000 to 0xFFFFFFFF (4 |
---|
1286 | gigabytes). Each address is represented by a 32-bit value and |
---|
1287 | is byte addressable. The address may be used to reference a |
---|
1288 | single byte, half-word (2-bytes), or word (4 bytes). |
---|
1289 | |
---|
1290 | Interrupt Processing |
---|
1291 | ==================== |
---|
1292 | |
---|
1293 | Although RTEMS hides many of the processor |
---|
1294 | dependent details of interrupt processing, it is important to |
---|
1295 | understand how the RTEMS interrupt manager is mapped onto the |
---|
1296 | processorâs unique architecture. Discussed in this chapter are |
---|
1297 | the the processorâs response and control mechanisms as they |
---|
1298 | pertain to RTEMS. |
---|
1299 | |
---|
1300 | Vectoring of Interrupt Handler |
---|
1301 | ------------------------------ |
---|
1302 | |
---|
1303 | Although the i386 supports multiple privilege levels, |
---|
1304 | RTEMS and all user software executes at privilege level 0. This |
---|
1305 | decision was made by the RTEMS designers to enhance |
---|
1306 | compatibility with processors which do not provide sophisticated |
---|
1307 | protection facilities like those of the i386. This decision |
---|
1308 | greatly simplifies the discussion of i386 processing, as one |
---|
1309 | need only consider interrupts without privilege transitions. |
---|
1310 | |
---|
1311 | Upon receipt of an interrupt the i386 automatically |
---|
1312 | performs the following actions: |
---|
1313 | |
---|
1314 | - pushes the EFLAGS register |
---|
1315 | |
---|
1316 | - pushes the far address of the interrupted instruction |
---|
1317 | |
---|
1318 | - vectors to the interrupt service routine (ISR). |
---|
1319 | |
---|
1320 | A nested interrupt is processed similarly by the |
---|
1321 | i386. |
---|
1322 | |
---|
1323 | Interrupt Stack Frame |
---|
1324 | --------------------- |
---|
1325 | |
---|
1326 | The structure of the Interrupt Stack Frame for the |
---|
1327 | i386 which is placed on the interrupt stack by the processor in |
---|
1328 | response to an interrupt is as follows: |
---|
1329 | .. code:: c |
---|
1330 | |
---|
1331 | +----------------------+ |
---|
1332 | | Old EFLAGS Register | ESP+8 |
---|
1333 | +----------+-----------+ |
---|
1334 | | UNUSED | Old CS | ESP+4 |
---|
1335 | +----------+-----------+ |
---|
1336 | | Old EIP | ESP |
---|
1337 | +----------------------+ |
---|
1338 | |
---|
1339 | Interrupt Levels |
---|
1340 | ---------------- |
---|
1341 | |
---|
1342 | Although RTEMS supports 256 interrupt levels, the |
---|
1343 | i386 only supports two â enabled and disabled. Interrupts are |
---|
1344 | enabled when the interrupt-enable flag (IF) in the extended |
---|
1345 | flags (EFLAGS) is set. Conversely, interrupt processing is |
---|
1346 | inhibited when the IF is cleared. During a non-maskable |
---|
1347 | interrupt, all other interrupts, including other non-maskable |
---|
1348 | ones, are inhibited. |
---|
1349 | |
---|
1350 | RTEMS interrupt levels 0 and 1 such that level zero |
---|
1351 | (0) indicates that interrupts are fully enabled and level one |
---|
1352 | that interrupts are disabled. All other RTEMS interrupt levels |
---|
1353 | are undefined and their behavior is unpredictable. |
---|
1354 | |
---|
1355 | Interrupt Stack |
---|
1356 | --------------- |
---|
1357 | |
---|
1358 | The i386 family does not support a dedicated hardware |
---|
1359 | interrupt stack. On this processor, RTEMS allocates and manages |
---|
1360 | a dedicated interrupt stack. As part of vectoring a non-nested |
---|
1361 | interrupt service routine, RTEMS switches from the stack of the |
---|
1362 | interrupted task to a dedicated interrupt stack. When a |
---|
1363 | non-nested interrupt returns, RTEMS switches back to the stack |
---|
1364 | of the interrupted stack. The current stack pointer is not |
---|
1365 | altered by RTEMS on nested interrupt. |
---|
1366 | |
---|
1367 | Default Fatal Error Processing |
---|
1368 | ============================== |
---|
1369 | |
---|
1370 | The default fatal error handler for this architecture disables processor |
---|
1371 | interrupts, places the error code in EAX, and executes a HLT instruction |
---|
1372 | to halt the processor. |
---|
1373 | |
---|
1374 | Symmetric Multiprocessing |
---|
1375 | ========================= |
---|
1376 | |
---|
1377 | SMP is not supported. |
---|
1378 | |
---|
1379 | Thread-Local Storage |
---|
1380 | ==================== |
---|
1381 | |
---|
1382 | Thread-local storage is not implemented. |
---|
1383 | |
---|
1384 | Board Support Packages |
---|
1385 | ====================== |
---|
1386 | |
---|
1387 | System Reset |
---|
1388 | ------------ |
---|
1389 | |
---|
1390 | An RTEMS based application is initiated when the i386 processor is reset. |
---|
1391 | When the i386 is reset, |
---|
1392 | |
---|
1393 | - The EAX register is set to indicate the results of the processorâs |
---|
1394 | power-up self test. If the self-test was not executed, the contents of |
---|
1395 | this register are undefined. Otherwise, a non-zero value indicates the |
---|
1396 | processor is faulty and a zero value indicates a successful self-test. |
---|
1397 | |
---|
1398 | - The DX register holds a component identifier and revision level. DH |
---|
1399 | contains 3 to indicate an i386 component and DL contains a unique revision |
---|
1400 | level indicator. |
---|
1401 | |
---|
1402 | - Control register zero (CR0) is set such that the processor is in real |
---|
1403 | mode with paging disabled. Other portions of CR0 are used to indicate the |
---|
1404 | presence of a numeric coprocessor. |
---|
1405 | |
---|
1406 | - All bits in the extended flags register (EFLAG) which are not |
---|
1407 | permanently set are cleared. This inhibits all maskable interrupts. |
---|
1408 | |
---|
1409 | - The Interrupt Descriptor Register (IDTR) is set to point at address |
---|
1410 | zero. |
---|
1411 | |
---|
1412 | - All segment registers are set to zero. |
---|
1413 | |
---|
1414 | - The instruction pointer is set to 0x0000FFF0. The first instruction |
---|
1415 | executed after a reset is actually at 0xFFFFFFF0 because the i386 asserts |
---|
1416 | the upper twelve address until the first intersegment (FAR) JMP or CALL |
---|
1417 | instruction. When a JMP or CALL is executed, the upper twelve address |
---|
1418 | lines are lowered and the processor begins executing in the first megabyte |
---|
1419 | of memory. |
---|
1420 | |
---|
1421 | Typically, an intersegment JMP to the applicationâs initialization code is |
---|
1422 | placed at address 0xFFFFFFF0. |
---|
1423 | |
---|
1424 | Processor Initialization |
---|
1425 | ------------------------ |
---|
1426 | |
---|
1427 | This initialization code is responsible for initializing all data |
---|
1428 | structures required by the i386 in protected mode and for actually entering |
---|
1429 | protected mode. The i386 must be placed in protected mode and the segment |
---|
1430 | registers and associated selectors must be initialized before the |
---|
1431 | initialize_executive directive is invoked. |
---|
1432 | |
---|
1433 | The initialization code is responsible for initializing the Global |
---|
1434 | Descriptor Table such that the i386 is in the thirty-two bit flat memory |
---|
1435 | model with paging disabled. In this mode, the i386 automatically converts |
---|
1436 | every address from a logical to a physical address each time it is used. |
---|
1437 | For more information on the memory model used by RTEMS, please refer to the |
---|
1438 | Memory Model chapter in this document. |
---|
1439 | |
---|
1440 | Since the processor is in real mode upon reset, the processor must be |
---|
1441 | switched to protected mode before RTEMS can execute. Before switching to |
---|
1442 | protected mode, at least one descriptor table and two descriptors must be |
---|
1443 | created. Descriptors are needed for a code segment and a data segment. ( |
---|
1444 | This will give you the flat memory model.) The stack can be placed in a |
---|
1445 | normal read/write data segment, so no descriptor for the stack is needed. |
---|
1446 | Before the GDT can be used, the base address and limit must be loaded into |
---|
1447 | the GDTR register using an LGDT instruction. |
---|
1448 | |
---|
1449 | If the hardware allows an NMI to be generated, you need to create the IDT |
---|
1450 | and a gate for the NMI interrupt handler. Before the IDT can be used, the |
---|
1451 | base address and limit for the idt must be loaded into the IDTR register |
---|
1452 | using an LIDT instruction. |
---|
1453 | |
---|
1454 | Protected mode is entered by setting thye PE bit in the CR0 register. |
---|
1455 | Either a LMSW or MOV CR0 instruction may be used to set this bit. Because |
---|
1456 | the processor overlaps the interpretation of several instructions, it is |
---|
1457 | necessary to discard the instructions from the read-ahead cache. A JMP |
---|
1458 | instruction immediately after the LMSW changes the flow and empties the |
---|
1459 | processor if intructions which have been pre-fetched and/or decoded. At |
---|
1460 | this point, the processor is in protected mode and begins to perform |
---|
1461 | protected mode application initialization. |
---|
1462 | |
---|
1463 | If the application requires that the IDTR be some value besides zero, then |
---|
1464 | it should set it to the required value at this point. All tasks share the |
---|
1465 | same i386 IDTR value. Because interrupts are enabled automatically by |
---|
1466 | RTEMS as part of the initialize_executive directive, the IDTR MUST be set |
---|
1467 | properly before this directive is invoked to insure correct interrupt |
---|
1468 | vectoring. If processor caching is to be utilized, then it should be |
---|
1469 | enabled during the reset application initialization code. The reset code |
---|
1470 | which is executed before the call to initialize_executive has the following |
---|
1471 | requirements: |
---|
1472 | |
---|
1473 | For more information regarding the i386 data structures and their |
---|
1474 | contents, refer to Intelâs 386 Programmerâs Reference Manual. |
---|
1475 | |
---|
1476 | .. COMMENT: COPYRIGHT (c) 1988-2002. |
---|
1477 | |
---|
1478 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
1479 | |
---|
1480 | .. COMMENT: All rights reserved. |
---|
1481 | |
---|
1482 | .. COMMENT: Jukka Pietarinen <jukka.pietarinen@mrf.fi>, 2008, |
---|
1483 | |
---|
1484 | .. COMMENT: Micro-Research Finland Oy |
---|
1485 | |
---|
1486 | Lattice Mico32 Specific Information |
---|
1487 | ################################### |
---|
1488 | |
---|
1489 | This chaper discusses the Lattice Mico32 architecture dependencies in |
---|
1490 | this port of RTEMS. The Lattice Mico32 is a 32-bit Harvard, RISC |
---|
1491 | architecture "soft" microprocessor, available for free with an open IP |
---|
1492 | core licensing agreement. Although mainly targeted for Lattice FPGA |
---|
1493 | devices the microprocessor can be implemented on other vendorsâ FPGAs, |
---|
1494 | too. |
---|
1495 | |
---|
1496 | **Architecture Documents** |
---|
1497 | |
---|
1498 | For information on the Lattice Mico32 architecture, refer to the |
---|
1499 | following documents available from Lattice Semiconductor:file:`http://www.latticesemi.com/`. |
---|
1500 | |
---|
1501 | - *"LatticeMico32 Processor Reference Manual"*:file:`http://www.latticesemi.com/dynamic/view_document.cfm?document_id=20890` |
---|
1502 | |
---|
1503 | CPU Model Dependent Features |
---|
1504 | ============================ |
---|
1505 | |
---|
1506 | The Lattice Mico32 architecture allows for different configurations of |
---|
1507 | the processor. This port is based on the assumption that the following options are implemented: |
---|
1508 | |
---|
1509 | - hardware multiplier |
---|
1510 | |
---|
1511 | - hardware divider |
---|
1512 | |
---|
1513 | - hardware barrel shifter |
---|
1514 | |
---|
1515 | - sign extension instructions |
---|
1516 | |
---|
1517 | - instruction cache |
---|
1518 | |
---|
1519 | - data cache |
---|
1520 | |
---|
1521 | - debug |
---|
1522 | |
---|
1523 | Register Architecture |
---|
1524 | ===================== |
---|
1525 | |
---|
1526 | This section gives a brief introduction to the register architecture |
---|
1527 | of the Lattice Mico32 processor. |
---|
1528 | |
---|
1529 | The Lattice Mico32 is a RISC archictecture processor with a |
---|
1530 | 32-register file of 32-bit registers. |
---|
1531 | |
---|
1532 | Register Name |
---|
1533 | |
---|
1534 | Function |
---|
1535 | |
---|
1536 | r0 |
---|
1537 | |
---|
1538 | holds value zero |
---|
1539 | |
---|
1540 | r1-r25 |
---|
1541 | |
---|
1542 | general purpose |
---|
1543 | |
---|
1544 | r26/gp |
---|
1545 | |
---|
1546 | general pupose / global pointer |
---|
1547 | |
---|
1548 | r27/fp |
---|
1549 | |
---|
1550 | general pupose / frame pointer |
---|
1551 | |
---|
1552 | r28/sp |
---|
1553 | |
---|
1554 | stack pointer |
---|
1555 | |
---|
1556 | r29/ra |
---|
1557 | |
---|
1558 | return address |
---|
1559 | |
---|
1560 | r30/ea |
---|
1561 | |
---|
1562 | exception address |
---|
1563 | |
---|
1564 | r31/ba |
---|
1565 | |
---|
1566 | breakpoint address |
---|
1567 | |
---|
1568 | Note that on processor startup all register values are undefined |
---|
1569 | including r0, thus r0 has to be initialized to zero. |
---|
1570 | |
---|
1571 | Calling Conventions |
---|
1572 | =================== |
---|
1573 | |
---|
1574 | Calling Mechanism |
---|
1575 | ----------------- |
---|
1576 | |
---|
1577 | A call instruction places the return address to register r29 and a |
---|
1578 | return from subroutine (ret) is actually a branch to r29/ra. |
---|
1579 | |
---|
1580 | Register Usage |
---|
1581 | -------------- |
---|
1582 | |
---|
1583 | A subroutine may freely use registers r1 to r10 which are *not* |
---|
1584 | preserved across subroutine invocations. |
---|
1585 | |
---|
1586 | Parameter Passing |
---|
1587 | ----------------- |
---|
1588 | |
---|
1589 | When calling a C function the first eight arguments are stored in |
---|
1590 | registers r1 to r8. Registers r1 and r2 hold the return value. |
---|
1591 | |
---|
1592 | Memory Model |
---|
1593 | ============ |
---|
1594 | |
---|
1595 | The Lattice Mico32 processor supports a flat memory model with a 4 |
---|
1596 | Gbyte address space with 32-bit addresses. |
---|
1597 | |
---|
1598 | The following data types are supported: |
---|
1599 | |
---|
1600 | Type |
---|
1601 | |
---|
1602 | Bits |
---|
1603 | |
---|
1604 | C Compiler Type |
---|
1605 | |
---|
1606 | unsigned byte |
---|
1607 | |
---|
1608 | 8 |
---|
1609 | |
---|
1610 | unsigned char |
---|
1611 | |
---|
1612 | signed byte |
---|
1613 | |
---|
1614 | 8 |
---|
1615 | |
---|
1616 | char |
---|
1617 | |
---|
1618 | unsigned half-word |
---|
1619 | |
---|
1620 | 16 |
---|
1621 | |
---|
1622 | unsigned short |
---|
1623 | |
---|
1624 | signed half-word |
---|
1625 | |
---|
1626 | 16 |
---|
1627 | |
---|
1628 | short |
---|
1629 | |
---|
1630 | unsigned word |
---|
1631 | |
---|
1632 | 32 |
---|
1633 | |
---|
1634 | unsigned int / unsigned long |
---|
1635 | |
---|
1636 | signed word |
---|
1637 | |
---|
1638 | 32 |
---|
1639 | |
---|
1640 | int / long |
---|
1641 | |
---|
1642 | Data accesses need to be aligned, with unaligned accesses result are |
---|
1643 | undefined. |
---|
1644 | |
---|
1645 | Interrupt Processing |
---|
1646 | ==================== |
---|
1647 | |
---|
1648 | The Lattice Mico32 has 32 interrupt lines which are however served by |
---|
1649 | only one exception vector. When an interrupt occurs following happens: |
---|
1650 | |
---|
1651 | - address of next instruction placed in r30/ea |
---|
1652 | |
---|
1653 | - IE field of IE CSR saved to EIE field and IE field cleared preventing further exceptions from occuring. |
---|
1654 | |
---|
1655 | - branch to interrupt exception address EBA CSR + 0xC0 |
---|
1656 | |
---|
1657 | The interrupt exception handler determines from the state of the |
---|
1658 | interrupt pending registers (IP CSR) and interrupt enable register (IE |
---|
1659 | CSR) which interrupt to serve and jumps to the interrupt routine |
---|
1660 | pointed to by the corresponding interrupt vector. |
---|
1661 | |
---|
1662 | For now there is no dedicated interrupt stack so every task in |
---|
1663 | the system MUST have enough stack space to accommodate the worst |
---|
1664 | case stack usage of that particular task and the interrupt |
---|
1665 | service routines COMBINED. |
---|
1666 | |
---|
1667 | Nested interrupts are not supported. |
---|
1668 | |
---|
1669 | Default Fatal Error Processing |
---|
1670 | ============================== |
---|
1671 | |
---|
1672 | Upon detection of a fatal error by either the application or RTEMS during |
---|
1673 | initialization the ``rtems_fatal_error_occurred`` directive supplied |
---|
1674 | by the Fatal Error Manager is invoked. The Fatal Error Manager will |
---|
1675 | invoke the user-supplied fatal error handlers. If no user-supplied |
---|
1676 | handlers are configured or all of them return without taking action to |
---|
1677 | shutdown the processor or reset, a default fatal error handler is invoked. |
---|
1678 | |
---|
1679 | Most of the action performed as part of processing the fatal error are |
---|
1680 | described in detail in the Fatal Error Manager chapter in the Userâs |
---|
1681 | Guide. However, the if no user provided extension or BSP specific fatal |
---|
1682 | error handler takes action, the final default action is to invoke a |
---|
1683 | CPU architecture specific function. Typically this function disables |
---|
1684 | interrupts and halts the processor. |
---|
1685 | |
---|
1686 | In each of the architecture specific chapters, this describes the precise |
---|
1687 | operations of the default CPU specific fatal error handler. |
---|
1688 | |
---|
1689 | Symmetric Multiprocessing |
---|
1690 | ========================= |
---|
1691 | |
---|
1692 | SMP is not supported. |
---|
1693 | |
---|
1694 | Thread-Local Storage |
---|
1695 | ==================== |
---|
1696 | |
---|
1697 | Thread-local storage is not implemented. |
---|
1698 | |
---|
1699 | Board Support Packages |
---|
1700 | ====================== |
---|
1701 | |
---|
1702 | An RTEMS Board Support Package (BSP) must be designed to support a |
---|
1703 | particular processor model and target board combination. |
---|
1704 | |
---|
1705 | In each of the architecture specific chapters, this section will present |
---|
1706 | a discussion of architecture specific BSP issues. For more information |
---|
1707 | on developing a BSP, refer to BSP and Device Driver Development Guide |
---|
1708 | and the chapter titled Board Support Packages in the RTEMS |
---|
1709 | Applications Userâs Guide. |
---|
1710 | |
---|
1711 | System Reset |
---|
1712 | ------------ |
---|
1713 | |
---|
1714 | An RTEMS based application is initiated or re-initiated when the processor |
---|
1715 | is reset. |
---|
1716 | |
---|
1717 | .. COMMENT: Copyright (c) 2014 embedded brains GmbH. All rights reserved. |
---|
1718 | |
---|
1719 | Renesas M32C Specific Information |
---|
1720 | ################################# |
---|
1721 | |
---|
1722 | Symmetric Multiprocessing |
---|
1723 | ========================= |
---|
1724 | |
---|
1725 | SMP is not supported. |
---|
1726 | |
---|
1727 | Thread-Local Storage |
---|
1728 | ==================== |
---|
1729 | |
---|
1730 | Thread-local storage is not implemented. |
---|
1731 | |
---|
1732 | .. COMMENT: COPYRIGHT (c) 1988-2002. |
---|
1733 | |
---|
1734 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
1735 | |
---|
1736 | .. COMMENT: All rights reserved. |
---|
1737 | |
---|
1738 | M68xxx and Coldfire Specific Information |
---|
1739 | ######################################## |
---|
1740 | |
---|
1741 | This chapter discusses the Freescale (formerly Motorola) MC68xxx |
---|
1742 | and Coldfire architectural dependencies. The MC68xxx family has a |
---|
1743 | wide variety of CPU models within it based upon different CPU core |
---|
1744 | implementations. Ignoring the Coldfire parts, the part numbers for |
---|
1745 | these models are generally divided into MC680xx and MC683xx. The MC680xx |
---|
1746 | models are more general purpose processors with no integrated peripherals. |
---|
1747 | The MC683xx models, on the other hand, are more specialized and have a |
---|
1748 | variety of peripherals on chip including sophisticated timers and serial |
---|
1749 | communications controllers. |
---|
1750 | |
---|
1751 | **Architecture Documents** |
---|
1752 | |
---|
1753 | For information on the MC68xxx and Coldfire architecture, refer to the following documents available from Freescale website (:file:`http//www.freescale.com/`): |
---|
1754 | |
---|
1755 | - *M68000 Family Reference, Motorola, FR68K/D*. |
---|
1756 | |
---|
1757 | - *MC68020 Userâs Manual, Motorola, MC68020UM/AD*. |
---|
1758 | |
---|
1759 | - *MC68881/MC68882 Floating-Point Coprocessor Userâs Manual, |
---|
1760 | Motorola, MC68881UM/AD*. |
---|
1761 | |
---|
1762 | CPU Model Dependent Features |
---|
1763 | ============================ |
---|
1764 | |
---|
1765 | This section presents the set of features which vary |
---|
1766 | across m68k/Coldfire implementations that are of importance to RTEMS. |
---|
1767 | The set of CPU model feature macros are defined in the file``cpukit/score/cpu/m68k/m68k.h`` based upon the particular CPU |
---|
1768 | model selected on the compilation command line. |
---|
1769 | |
---|
1770 | BFFFO Instruction |
---|
1771 | ----------------- |
---|
1772 | |
---|
1773 | The macro ``M68K_HAS_BFFFO`` is set to 1 to indicate that |
---|
1774 | this CPU model has the bfffo instruction. |
---|
1775 | |
---|
1776 | Vector Base Register |
---|
1777 | -------------------- |
---|
1778 | |
---|
1779 | The macro ``M68K_HAS_VBR`` is set to 1 to indicate that |
---|
1780 | this CPU model has a vector base register (vbr). |
---|
1781 | |
---|
1782 | Separate Stacks |
---|
1783 | --------------- |
---|
1784 | |
---|
1785 | The macro ``M68K_HAS_SEPARATE_STACKS`` is set to 1 to |
---|
1786 | indicate that this CPU model has separate interrupt, user, and |
---|
1787 | supervisor mode stacks. |
---|
1788 | |
---|
1789 | Pre-Indexing Address Mode |
---|
1790 | ------------------------- |
---|
1791 | |
---|
1792 | The macro ``M68K_HAS_PREINDEXING`` is set to 1 to indicate that |
---|
1793 | this CPU model has the pre-indexing address mode. |
---|
1794 | |
---|
1795 | Extend Byte to Long Instruction |
---|
1796 | ------------------------------- |
---|
1797 | |
---|
1798 | The macro ``M68K_HAS_EXTB_L`` is set to 1 to indicate that this CPU model |
---|
1799 | has the extb.l instruction. This instruction is supposed to be available |
---|
1800 | in all models based on the cpu32 core as well as mc68020 and up models. |
---|
1801 | |
---|
1802 | Calling Conventions |
---|
1803 | =================== |
---|
1804 | |
---|
1805 | The MC68xxx architecture supports a simple yet effective call and |
---|
1806 | return mechanism. A subroutine is invoked via the branch to subroutine |
---|
1807 | (``bsr``) or the jump to subroutine (``jsr``) instructions. |
---|
1808 | These instructions push the return address on the current stack. |
---|
1809 | The return from subroutine (``rts``) instruction pops the return |
---|
1810 | address off the current stack and transfers control to that instruction. |
---|
1811 | It is is important to note that the MC68xxx call and return mechanism does |
---|
1812 | not automatically save or restore any registers. It is the responsibility |
---|
1813 | of the high-level language compiler to define the register preservation |
---|
1814 | and usage convention. |
---|
1815 | |
---|
1816 | Calling Mechanism |
---|
1817 | ----------------- |
---|
1818 | |
---|
1819 | All RTEMS directives are invoked using either a ``bsr`` or ``jsr`` |
---|
1820 | instruction and return to the user application via the rts instruction. |
---|
1821 | |
---|
1822 | Register Usage |
---|
1823 | -------------- |
---|
1824 | |
---|
1825 | As discussed above, the ``bsr`` and ``jsr`` instructions do not |
---|
1826 | automatically save any registers. RTEMS uses the registers D0, D1, |
---|
1827 | A0, and A1 as scratch registers. These registers are not preserved by |
---|
1828 | RTEMS directives therefore, the contents of these registers should not |
---|
1829 | be assumed upon return from any RTEMS directive. |
---|
1830 | |
---|
1831 | Parameter Passing |
---|
1832 | ----------------- |
---|
1833 | |
---|
1834 | RTEMS assumes that arguments are placed on the current stack before |
---|
1835 | the directive is invoked via the bsr or jsr instruction. The first |
---|
1836 | argument is assumed to be closest to the return address on the stack. |
---|
1837 | This means that the first argument of the C calling sequence is pushed |
---|
1838 | last. The following pseudo-code illustrates the typical sequence used |
---|
1839 | to call a RTEMS directive with three (3) arguments: |
---|
1840 | .. code:: c |
---|
1841 | |
---|
1842 | push third argument |
---|
1843 | push second argument |
---|
1844 | push first argument |
---|
1845 | invoke directive |
---|
1846 | remove arguments from the stack |
---|
1847 | |
---|
1848 | The arguments to RTEMS are typically pushed onto the stack using a move |
---|
1849 | instruction with a pre-decremented stack pointer as the destination. |
---|
1850 | These arguments must be removed from the stack after control is returned |
---|
1851 | to the caller. This removal is typically accomplished by adding the |
---|
1852 | size of the argument list in bytes to the current stack pointer. |
---|
1853 | |
---|
1854 | Memory Model |
---|
1855 | ============ |
---|
1856 | |
---|
1857 | The MC68xxx family supports a flat 32-bit address |
---|
1858 | space with addresses ranging from 0x00000000 to 0xFFFFFFFF (4 |
---|
1859 | gigabytes). Each address is represented by a 32-bit value and |
---|
1860 | is byte addressable. The address may be used to reference a |
---|
1861 | single byte, word (2-bytes), or long word (4 bytes). Memory |
---|
1862 | accesses within this address space are performed in big endian |
---|
1863 | fashion by the processors in this family. |
---|
1864 | |
---|
1865 | Some of the MC68xxx family members such as the |
---|
1866 | MC68020, MC68030, and MC68040 support virtual memory and |
---|
1867 | segmentation. The MC68020 requires external hardware support |
---|
1868 | such as the MC68851 Paged Memory Management Unit coprocessor |
---|
1869 | which is typically used to perform address translations for |
---|
1870 | these systems. RTEMS does not support virtual memory or |
---|
1871 | segmentation on any of the MC68xxx family members. |
---|
1872 | |
---|
1873 | Interrupt Processing |
---|
1874 | ==================== |
---|
1875 | |
---|
1876 | Discussed in this section are the MC68xxxâs interrupt response and |
---|
1877 | control mechanisms as they pertain to RTEMS. |
---|
1878 | |
---|
1879 | Vectoring of an Interrupt Handler |
---|
1880 | --------------------------------- |
---|
1881 | |
---|
1882 | Depending on whether or not the particular CPU supports a separate |
---|
1883 | interrupt stack, the MC68xxx family has two different interrupt handling |
---|
1884 | models. |
---|
1885 | |
---|
1886 | Models Without Separate Interrupt Stacks |
---|
1887 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
1888 | |
---|
1889 | Upon receipt of an interrupt the MC68xxx family members without separate |
---|
1890 | interrupt stacks automatically perform the following actions: |
---|
1891 | |
---|
1892 | - To Be Written |
---|
1893 | |
---|
1894 | Models With Separate Interrupt Stacks |
---|
1895 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
1896 | |
---|
1897 | Upon receipt of an interrupt the MC68xxx family members with separate |
---|
1898 | interrupt stacks automatically perform the following actions: |
---|
1899 | |
---|
1900 | - saves the current status register (SR), |
---|
1901 | |
---|
1902 | - clears the master/interrupt (M) bit of the SR to |
---|
1903 | indicate the switch from master state to interrupt state, |
---|
1904 | |
---|
1905 | - sets the privilege mode to supervisor, |
---|
1906 | |
---|
1907 | - suppresses tracing, |
---|
1908 | |
---|
1909 | - sets the interrupt mask level equal to the level of the |
---|
1910 | interrupt being serviced, |
---|
1911 | |
---|
1912 | - pushes an interrupt stack frame (ISF), which includes |
---|
1913 | the program counter (PC), the status register (SR), and the |
---|
1914 | format/exception vector offset (FVO) word, onto the supervisor |
---|
1915 | and interrupt stacks, |
---|
1916 | |
---|
1917 | - switches the current stack to the interrupt stack and |
---|
1918 | vectors to an interrupt service routine (ISR). If the ISR was |
---|
1919 | installed with the interrupt_catch directive, then the RTEMS |
---|
1920 | interrupt handler will begin execution. The RTEMS interrupt |
---|
1921 | handler saves all registers which are not preserved according to |
---|
1922 | the calling conventions and invokes the applicationâs ISR. |
---|
1923 | |
---|
1924 | A nested interrupt is processed similarly by these |
---|
1925 | CPU models with the exception that only a single ISF is placed |
---|
1926 | on the interrupt stack and the current stack need not be |
---|
1927 | switched. |
---|
1928 | |
---|
1929 | The FVO word in the Interrupt Stack Frame is examined |
---|
1930 | by RTEMS to determine when an outer most interrupt is being |
---|
1931 | exited. Since the FVO is used by RTEMS for this purpose, the |
---|
1932 | user application code MUST NOT modify this field. |
---|
1933 | |
---|
1934 | The following shows the Interrupt Stack Frame for |
---|
1935 | MC68xxx CPU models with separate interrupt stacks: |
---|
1936 | .. code:: c |
---|
1937 | |
---|
1938 | +----------------------+ |
---|
1939 | | Status Register | 0x0 |
---|
1940 | +----------------------+ |
---|
1941 | | Program Counter High | 0x2 |
---|
1942 | +----------------------+ |
---|
1943 | | Program Counter Low | 0x4 |
---|
1944 | +----------------------+ |
---|
1945 | | Format/Vector Offset | 0x6 |
---|
1946 | +----------------------+ |
---|
1947 | |
---|
1948 | CPU Models Without VBR and RAM at 0 |
---|
1949 | ----------------------------------- |
---|
1950 | |
---|
1951 | This is from a post by Zoltan Kocsi <zoltan@bendor.com.au> and is |
---|
1952 | a nice trick in certain situations. In his words: |
---|
1953 | |
---|
1954 | I think somebody on this list asked about the interupt vector handling |
---|
1955 | w/o VBR and RAM at 0. The usual trick is to initialise the vector table |
---|
1956 | (except the first 2 two entries, of course) to point to the same location |
---|
1957 | BUT you also add the vector number times 0x1000000 to them. That is, |
---|
1958 | bits 31-24 contain the vector number and 23-0 the address of the common |
---|
1959 | handler. Since the PC is 32 bit wide but the actual address bus is only |
---|
1960 | 24, the top byte will be in the PC but will be ignored when jumping onto |
---|
1961 | your routine. |
---|
1962 | |
---|
1963 | Then your common interrupt routine gets this info by loading the PC |
---|
1964 | into some register and based on that info, you can jump to a vector in |
---|
1965 | a vector table pointed by a virtual VBR: |
---|
1966 | .. code:: c |
---|
1967 | |
---|
1968 | // |
---|
1969 | // Real vector table at 0 |
---|
1970 | // |
---|
1971 | .long initial_sp |
---|
1972 | .long initial_pc |
---|
1973 | .long myhandler+0x02000000 |
---|
1974 | .long myhandler+0x03000000 |
---|
1975 | .long myhandler+0x04000000 |
---|
1976 | ... |
---|
1977 | .long myhandler+0xff000000 |
---|
1978 | // |
---|
1979 | // This handler will jump to the interrupt routine of which |
---|
1980 | // the address is stored at VBR[ vector_no ] |
---|
1981 | // The registers and stackframe will be intact, the interrupt |
---|
1982 | // routine will see exactly what it would see if it was called |
---|
1983 | // directly from the HW vector table at 0. |
---|
1984 | // |
---|
1985 | .comm VBR,4,2 // This defines the 'virtual' VBR |
---|
1986 | // From C: extern void \*VBR; |
---|
1987 | myhandler: // At entry, PC contains the full vector |
---|
1988 | move.l %d0,-(%sp) // Save d0 |
---|
1989 | move.l %a0,-(%sp) // Save a0 |
---|
1990 | lea 0(%pc),%a0 // Get the value of the PC |
---|
1991 | move.l %a0,%d0 // Copy it to a data reg, d0 is VV?????? |
---|
1992 | swap %d0 // Now d0 is ????VV?? |
---|
1993 | and.w #0xff00,%d0 // Now d0 is ????VV00 (1) |
---|
1994 | lsr.w #6,%d0 // Now d0.w contains the VBR table offset |
---|
1995 | move.l VBR,%a0 // Get the address from VBR to a0 |
---|
1996 | move.l (%a0,%d0.w),%a0 // Fetch the vector |
---|
1997 | move.l 4(%sp),%d0 // Restore d0 |
---|
1998 | move.l %a0,4(%sp) // Place target address to the stack |
---|
1999 | move.l (%sp)+,%a0 // Restore a0, target address is on TOS |
---|
2000 | ret // This will jump to the handler and |
---|
2001 | // restore the stack |
---|
2002 | (1) If 'myhandler' is guaranteed to be in the first 64K, e.g. just |
---|
2003 | after the vector table then that insn is not needed. |
---|
2004 | |
---|
2005 | There are probably shorter ways to do this, but it I believe is enough |
---|
2006 | to illustrate the trick. Optimisation is left as an exercise to the |
---|
2007 | reader :-) |
---|
2008 | |
---|
2009 | Interrupt Levels |
---|
2010 | ---------------- |
---|
2011 | |
---|
2012 | Eight levels (0-7) of interrupt priorities are |
---|
2013 | supported by MC68xxx family members with level seven (7) being |
---|
2014 | the highest priority. Level zero (0) indicates that interrupts |
---|
2015 | are fully enabled. Interrupt requests for interrupts with |
---|
2016 | priorities less than or equal to the current interrupt mask |
---|
2017 | level are ignored. |
---|
2018 | |
---|
2019 | Although RTEMS supports 256 interrupt levels, the |
---|
2020 | MC68xxx family only supports eight. RTEMS interrupt levels 0 |
---|
2021 | through 7 directly correspond to MC68xxx interrupt levels. All |
---|
2022 | other RTEMS interrupt levels are undefined and their behavior is |
---|
2023 | unpredictable. |
---|
2024 | |
---|
2025 | Default Fatal Error Processing |
---|
2026 | ============================== |
---|
2027 | |
---|
2028 | The default fatal error handler for this architecture disables processor |
---|
2029 | interrupts to level 7, places the error code in D0, and executes a``stop`` instruction to simulate a halt processor instruction. |
---|
2030 | |
---|
2031 | Symmetric Multiprocessing |
---|
2032 | ========================= |
---|
2033 | |
---|
2034 | SMP is not supported. |
---|
2035 | |
---|
2036 | Thread-Local Storage |
---|
2037 | ==================== |
---|
2038 | |
---|
2039 | Thread-local storage is supported. |
---|
2040 | |
---|
2041 | Board Support Packages |
---|
2042 | ====================== |
---|
2043 | |
---|
2044 | System Reset |
---|
2045 | ------------ |
---|
2046 | |
---|
2047 | An RTEMS based application is initiated or re-initiated when the MC68020 |
---|
2048 | processor is reset. When the MC68020 is reset, the processor performs |
---|
2049 | the following actions: |
---|
2050 | |
---|
2051 | - The tracing bits of the status register are cleared to |
---|
2052 | disable tracing. |
---|
2053 | |
---|
2054 | - The supervisor interrupt state is entered by setting the |
---|
2055 | supervisor (S) bit and clearing the master/interrupt (M) bit of |
---|
2056 | the status register. |
---|
2057 | |
---|
2058 | - The interrupt mask of the status register is set to |
---|
2059 | level 7 to effectively disable all maskable interrupts. |
---|
2060 | |
---|
2061 | - The vector base register (VBR) is set to zero. |
---|
2062 | |
---|
2063 | - The cache control register (CACR) is set to zero to |
---|
2064 | disable and freeze the processor cache. |
---|
2065 | |
---|
2066 | - The interrupt stack pointer (ISP) is set to the value |
---|
2067 | stored at vector 0 (bytes 0-3) of the exception vector table |
---|
2068 | (EVT). |
---|
2069 | |
---|
2070 | - The program counter (PC) is set to the value stored at |
---|
2071 | vector 1 (bytes 4-7) of the EVT. |
---|
2072 | |
---|
2073 | - The processor begins execution at the address stored in |
---|
2074 | the PC. |
---|
2075 | |
---|
2076 | Processor Initialization |
---|
2077 | ------------------------ |
---|
2078 | |
---|
2079 | The address of the applicationâs initialization code should be stored in |
---|
2080 | the first vector of the EVT which will allow the immediate vectoring to |
---|
2081 | the application code. If the application requires that the VBR be some |
---|
2082 | value besides zero, then it should be set to the required value at this |
---|
2083 | point. All tasks share the same MC68020âs VBR value. Because interrupts |
---|
2084 | are enabled automatically by RTEMS as part of the context switch to the |
---|
2085 | first task, the VBR MUST be set by either RTEMS of the BSP before this |
---|
2086 | occurs ensure correct interrupt vectoring. If processor caching is |
---|
2087 | to be utilized, then it should be enabled during the reset application |
---|
2088 | initialization code. |
---|
2089 | |
---|
2090 | In addition to the requirements described in the |
---|
2091 | Board Support Packages chapter of the Applications Userâs |
---|
2092 | Manual for the reset code which is executed before the call to |
---|
2093 | initialize executive, the MC68020 version has the following |
---|
2094 | specific requirements: |
---|
2095 | |
---|
2096 | - Must leave the S bit of the status register set so that |
---|
2097 | the MC68020 remains in the supervisor state. |
---|
2098 | |
---|
2099 | - Must set the M bit of the status register to remove the |
---|
2100 | MC68020 from the interrupt state. |
---|
2101 | |
---|
2102 | - Must set the master stack pointer (MSP) such that a |
---|
2103 | minimum stack size of MINIMUM_STACK_SIZE bytes is provided for |
---|
2104 | the initialize executive directive. |
---|
2105 | |
---|
2106 | - Must initialize the MC68020âs vector table. |
---|
2107 | |
---|
2108 | .. COMMENT: Copyright (c) 2014 embedded brains GmbH. All rights reserved. |
---|
2109 | |
---|
2110 | Xilinx MicroBlaze Specific Information |
---|
2111 | ###################################### |
---|
2112 | |
---|
2113 | Symmetric Multiprocessing |
---|
2114 | ========================= |
---|
2115 | |
---|
2116 | SMP is not supported. |
---|
2117 | |
---|
2118 | Thread-Local Storage |
---|
2119 | ==================== |
---|
2120 | |
---|
2121 | Thread-local storage is not implemented. |
---|
2122 | |
---|
2123 | .. COMMENT: COPYRIGHT (c) 1988-2002. |
---|
2124 | |
---|
2125 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
2126 | |
---|
2127 | .. COMMENT: All rights reserved. |
---|
2128 | |
---|
2129 | MIPS Specific Information |
---|
2130 | ######################### |
---|
2131 | |
---|
2132 | This chapter discusses the MIPS architecture dependencies |
---|
2133 | in this port of RTEMS. The MIPS family has a wide variety |
---|
2134 | of implementations by a wide range of vendors. Consequently, |
---|
2135 | there are many, many CPU models within it. |
---|
2136 | |
---|
2137 | **Architecture Documents** |
---|
2138 | |
---|
2139 | IDT docs are online at http://www.idt.com/products/risc/Welcome.html |
---|
2140 | |
---|
2141 | For information on the XXX architecture, refer to the following documents |
---|
2142 | available from VENDOR (:file:`http//www.XXX.com/`): |
---|
2143 | |
---|
2144 | - *XXX Family Reference, VENDOR, PART NUMBER*. |
---|
2145 | |
---|
2146 | CPU Model Dependent Features |
---|
2147 | ============================ |
---|
2148 | |
---|
2149 | This section presents the set of features which vary |
---|
2150 | across MIPS implementations and are of importance to RTEMS. |
---|
2151 | The set of CPU model feature macros are defined in the file``cpukit/score/cpu/mips/mips.h`` based upon the particular CPU |
---|
2152 | model specified on the compilation command line. |
---|
2153 | |
---|
2154 | Another Optional Feature |
---|
2155 | ------------------------ |
---|
2156 | |
---|
2157 | The macro XXX |
---|
2158 | |
---|
2159 | Calling Conventions |
---|
2160 | =================== |
---|
2161 | |
---|
2162 | Processor Background |
---|
2163 | -------------------- |
---|
2164 | |
---|
2165 | TBD |
---|
2166 | |
---|
2167 | Calling Mechanism |
---|
2168 | ----------------- |
---|
2169 | |
---|
2170 | TBD |
---|
2171 | |
---|
2172 | Register Usage |
---|
2173 | -------------- |
---|
2174 | |
---|
2175 | TBD |
---|
2176 | |
---|
2177 | Parameter Passing |
---|
2178 | ----------------- |
---|
2179 | |
---|
2180 | TBD |
---|
2181 | |
---|
2182 | Memory Model |
---|
2183 | ============ |
---|
2184 | |
---|
2185 | Flat Memory Model |
---|
2186 | ----------------- |
---|
2187 | |
---|
2188 | The MIPS family supports a flat 32-bit address |
---|
2189 | space with addresses ranging from 0x00000000 to 0xFFFFFFFF (4 |
---|
2190 | gigabytes). Each address is represented by a 32-bit value and |
---|
2191 | is byte addressable. The address may be used to reference a |
---|
2192 | single byte, word (2-bytes), or long word (4 bytes). Memory |
---|
2193 | accesses within this address space are performed in big endian |
---|
2194 | fashion by the processors in this family. |
---|
2195 | |
---|
2196 | Some of the MIPS family members such as the support virtual memory and |
---|
2197 | segmentation. RTEMS does not support virtual memory or |
---|
2198 | segmentation on any of these family members. |
---|
2199 | |
---|
2200 | Interrupt Processing |
---|
2201 | ==================== |
---|
2202 | |
---|
2203 | Although RTEMS hides many of the processor dependent |
---|
2204 | details of interrupt processing, it is important to understand |
---|
2205 | how the RTEMS interrupt manager is mapped onto the processorâs |
---|
2206 | unique architecture. Discussed in this chapter are the MIPSâs |
---|
2207 | interrupt response and control mechanisms as they pertain to |
---|
2208 | RTEMS. |
---|
2209 | |
---|
2210 | Vectoring of an Interrupt Handler |
---|
2211 | --------------------------------- |
---|
2212 | |
---|
2213 | Upon receipt of an interrupt the XXX family |
---|
2214 | members with separate interrupt stacks automatically perform the |
---|
2215 | following actions: |
---|
2216 | |
---|
2217 | - TBD |
---|
2218 | |
---|
2219 | A nested interrupt is processed similarly by these |
---|
2220 | CPU models with the exception that only a single ISF is placed |
---|
2221 | on the interrupt stack and the current stack need not be |
---|
2222 | switched. |
---|
2223 | |
---|
2224 | Interrupt Levels |
---|
2225 | ---------------- |
---|
2226 | |
---|
2227 | TBD |
---|
2228 | |
---|
2229 | Default Fatal Error Processing |
---|
2230 | ============================== |
---|
2231 | |
---|
2232 | The default fatal error handler for this target architecture disables |
---|
2233 | processor interrupts, places the error code in *XXX*, and executes a``XXX`` instruction to simulate a halt processor instruction. |
---|
2234 | |
---|
2235 | Symmetric Multiprocessing |
---|
2236 | ========================= |
---|
2237 | |
---|
2238 | SMP is not supported. |
---|
2239 | |
---|
2240 | Thread-Local Storage |
---|
2241 | ==================== |
---|
2242 | |
---|
2243 | Thread-local storage is not implemented. |
---|
2244 | |
---|
2245 | Board Support Packages |
---|
2246 | ====================== |
---|
2247 | |
---|
2248 | System Reset |
---|
2249 | ------------ |
---|
2250 | |
---|
2251 | An RTEMS based application is initiated or |
---|
2252 | re-initiated when the processor is reset. When the |
---|
2253 | processor is reset, it performs the following actions: |
---|
2254 | |
---|
2255 | - TBD |
---|
2256 | |
---|
2257 | Processor Initialization |
---|
2258 | ------------------------ |
---|
2259 | |
---|
2260 | TBD |
---|
2261 | |
---|
2262 | .. COMMENT: Copyright (c) 2014 embedded brains GmbH. All rights reserved. |
---|
2263 | |
---|
2264 | Altera Nios II Specific Information |
---|
2265 | ################################### |
---|
2266 | |
---|
2267 | Symmetric Multiprocessing |
---|
2268 | ========================= |
---|
2269 | |
---|
2270 | SMP is not supported. |
---|
2271 | |
---|
2272 | Thread-Local Storage |
---|
2273 | ==================== |
---|
2274 | |
---|
2275 | Thread-local storage is not implemented. |
---|
2276 | |
---|
2277 | .. COMMENT: COPYRIGHT (c) 2014 Hesham ALMatary <heshamelmatary@gmail.com> |
---|
2278 | |
---|
2279 | .. COMMENT: All rights reserved. |
---|
2280 | |
---|
2281 | OpenRISC 1000 Specific Information |
---|
2282 | ################################## |
---|
2283 | |
---|
2284 | This chapter discusses the`OpenRISC 1000 architecture <http://opencores.org/or1k/Main_Page>`_ |
---|
2285 | dependencies in this port of RTEMS. There are many implementations |
---|
2286 | for OpenRISC like or1200 and mor1kx. Currently RTEMS supports basic |
---|
2287 | features that all implementations should have. |
---|
2288 | |
---|
2289 | **Architecture Documents** |
---|
2290 | |
---|
2291 | For information on the OpenRISC 1000 architecture refer to the`OpenRISC 1000 architecture manual <http://openrisc.github.io/or1k.html>`_. |
---|
2292 | |
---|
2293 | Calling Conventions |
---|
2294 | =================== |
---|
2295 | |
---|
2296 | Please refer to the`Function Calling Sequence <http://openrisc.github.io/or1k.html#__RefHeading__504887_595890882>`_. |
---|
2297 | |
---|
2298 | Floating Point Unit |
---|
2299 | ------------------- |
---|
2300 | |
---|
2301 | A floating point unit is currently not supported. |
---|
2302 | |
---|
2303 | Memory Model |
---|
2304 | ============ |
---|
2305 | |
---|
2306 | A flat 32-bit memory model is supported. |
---|
2307 | |
---|
2308 | Interrupt Processing |
---|
2309 | ==================== |
---|
2310 | |
---|
2311 | OpenRISC 1000 architecture has 13 exception types: |
---|
2312 | |
---|
2313 | - Reset |
---|
2314 | |
---|
2315 | - Bus Error |
---|
2316 | |
---|
2317 | - Data Page Fault |
---|
2318 | |
---|
2319 | - Instruction Page Fault |
---|
2320 | |
---|
2321 | - Tick Timer |
---|
2322 | |
---|
2323 | - Alignment |
---|
2324 | |
---|
2325 | - Illegal Instruction |
---|
2326 | |
---|
2327 | - External Interrupt |
---|
2328 | |
---|
2329 | - D-TLB Miss |
---|
2330 | |
---|
2331 | - I-TLB Miss |
---|
2332 | |
---|
2333 | - Range |
---|
2334 | |
---|
2335 | - System Call |
---|
2336 | |
---|
2337 | - Floating Point |
---|
2338 | |
---|
2339 | - Trap |
---|
2340 | |
---|
2341 | Interrupt Levels |
---|
2342 | ---------------- |
---|
2343 | |
---|
2344 | There are only two levels: interrupts enabled and interrupts disabled. |
---|
2345 | |
---|
2346 | Interrupt Stack |
---|
2347 | --------------- |
---|
2348 | |
---|
2349 | The OpenRISC RTEMS port uses a dedicated software interrupt stack. |
---|
2350 | The stack for interrupts is allocated during interrupt driver initialization. |
---|
2351 | When an interrupt is entered, the _ISR_Handler routine is responsible for |
---|
2352 | switching from the interrupted task stack to RTEMS software interrupt stack. |
---|
2353 | |
---|
2354 | Default Fatal Error Processing |
---|
2355 | ============================== |
---|
2356 | |
---|
2357 | The default fatal error handler for this architecture performs the |
---|
2358 | following actions: |
---|
2359 | |
---|
2360 | - disables operating system supported interrupts (IRQ), |
---|
2361 | |
---|
2362 | - places the error code in ``r0``, and |
---|
2363 | |
---|
2364 | - executes an infinite loop to simulate a halt processor instruction. |
---|
2365 | |
---|
2366 | Symmetric Multiprocessing |
---|
2367 | ========================= |
---|
2368 | |
---|
2369 | SMP is not supported. |
---|
2370 | |
---|
2371 | .. COMMENT: COPYRIGHT (c) 1989-2007. |
---|
2372 | |
---|
2373 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
2374 | |
---|
2375 | .. COMMENT: All rights reserved. |
---|
2376 | |
---|
2377 | PowerPC Specific Information |
---|
2378 | ############################ |
---|
2379 | |
---|
2380 | This chapter discusses the PowerPC architecture dependencies |
---|
2381 | in this port of RTEMS. The PowerPC family has a wide variety |
---|
2382 | of implementations by a range of vendors. Consequently, |
---|
2383 | there are many, many CPU models within it. |
---|
2384 | |
---|
2385 | It is highly recommended that the PowerPC RTEMS |
---|
2386 | application developer obtain and become familiar with the |
---|
2387 | documentation for the processor being used as well as the |
---|
2388 | specification for the revision of the PowerPC architecture which |
---|
2389 | corresponds to that processor. |
---|
2390 | |
---|
2391 | **PowerPC Architecture Documents** |
---|
2392 | |
---|
2393 | For information on the PowerPC architecture, refer to |
---|
2394 | the following documents available from Motorola and IBM: |
---|
2395 | |
---|
2396 | - *PowerPC Microprocessor Family: The Programming Environment* |
---|
2397 | (Motorola Document MPRPPCFPE-01). |
---|
2398 | |
---|
2399 | - *IBM PPC403GB Embedded Controller Userâs Manual*. |
---|
2400 | |
---|
2401 | - *PoweRisControl MPC500 Family RCPU RISC Central Processing |
---|
2402 | Unit Reference Manual* (Motorola Document RCPUURM/AD). |
---|
2403 | |
---|
2404 | - *PowerPC 601 RISC Microprocessor Userâs Manual* |
---|
2405 | (Motorola Document MPR601UM/AD). |
---|
2406 | |
---|
2407 | - *PowerPC 603 RISC Microprocessor Userâs Manual* |
---|
2408 | (Motorola Document MPR603UM/AD). |
---|
2409 | |
---|
2410 | - *PowerPC 603e RISC Microprocessor Userâs Manual* |
---|
2411 | (Motorola Document MPR603EUM/AD). |
---|
2412 | |
---|
2413 | - *PowerPC 604 RISC Microprocessor Userâs Manual* |
---|
2414 | (Motorola Document MPR604UM/AD). |
---|
2415 | |
---|
2416 | - *PowerPC MPC821 Portable Systems Microprocessor Userâs Manual* |
---|
2417 | (Motorola Document MPC821UM/AD). |
---|
2418 | |
---|
2419 | - *PowerQUICC MPC860 Userâs Manual* (Motorola Document MPC860UM/AD). |
---|
2420 | |
---|
2421 | Motorola maintains an on-line electronic library for the PowerPC |
---|
2422 | at the following URL: |
---|
2423 | |
---|
2424 | - ```` *http://www.mot.com/powerpc/library/library.html* |
---|
2425 | |
---|
2426 | This site has a a wealth of information and examples. Many of the |
---|
2427 | manuals are available from that site in electronic format. |
---|
2428 | |
---|
2429 | **PowerPC Processor Simulator Information** |
---|
2430 | |
---|
2431 | PSIM is a program which emulates the Instruction Set Architecture |
---|
2432 | of the PowerPC microprocessor family. It is reely available in source |
---|
2433 | code form under the terms of the GNU General Public License (version |
---|
2434 | 2 or later). PSIM can be integrated with the GNU Debugger (gdb) to |
---|
2435 | execute and debug PowerPC executables on non-PowerPC hosts. PSIM |
---|
2436 | supports the addition of user provided device models which can be |
---|
2437 | used to allow one to develop and debug embedded applications using |
---|
2438 | the simulator. |
---|
2439 | |
---|
2440 | The latest version of PSIM is included in GDB and enabled on pre-built |
---|
2441 | binaries provided by the RTEMS Project. |
---|
2442 | |
---|
2443 | CPU Model Dependent Features |
---|
2444 | ============================ |
---|
2445 | |
---|
2446 | This section presents the set of features which vary |
---|
2447 | across PowerPC implementations and are of importance to RTEMS. |
---|
2448 | The set of CPU model feature macros are defined in the file``cpukit/score/cpu/powerpc/powerpc.h`` based upon the particular CPU |
---|
2449 | model specified on the compilation command line. |
---|
2450 | |
---|
2451 | Alignment |
---|
2452 | --------- |
---|
2453 | |
---|
2454 | The macro PPC_ALIGNMENT is set to the PowerPC modelâs worst case alignment |
---|
2455 | requirement for data types on a byte boundary. This value is used |
---|
2456 | to derive the alignment restrictions for memory allocated from |
---|
2457 | regions and partitions. |
---|
2458 | |
---|
2459 | Cache Alignment |
---|
2460 | --------------- |
---|
2461 | |
---|
2462 | The macro PPC_CACHE_ALIGNMENT is set to the line size of the cache. It is |
---|
2463 | used to align the entry point of critical routines so that as much code |
---|
2464 | as possible can be retrieved with the initial read into cache. This |
---|
2465 | is done for the interrupt handler as well as the context switch routines. |
---|
2466 | |
---|
2467 | In addition, the "shortcut" data structure used by the PowerPC implementation |
---|
2468 | to ease access to data elements frequently accessed by RTEMS routines |
---|
2469 | implemented in assembly language is aligned using this value. |
---|
2470 | |
---|
2471 | Maximum Interrupts |
---|
2472 | ------------------ |
---|
2473 | |
---|
2474 | The macro PPC_INTERRUPT_MAX is set to the number of exception sources |
---|
2475 | supported by this PowerPC model. |
---|
2476 | |
---|
2477 | Has Double Precision Floating Point |
---|
2478 | ----------------------------------- |
---|
2479 | |
---|
2480 | The macro PPC_HAS_DOUBLE is set to 1 to indicate that the PowerPC model |
---|
2481 | has support for double precision floating point numbers. This is |
---|
2482 | important because the floating point registers need only be four bytes |
---|
2483 | wide (not eight) if double precision is not supported. |
---|
2484 | |
---|
2485 | Critical Interrupts |
---|
2486 | ------------------- |
---|
2487 | |
---|
2488 | The macro PPC_HAS_RFCI is set to 1 to indicate that the PowerPC model |
---|
2489 | has the Critical Interrupt capability as defined by the IBM 403 models. |
---|
2490 | |
---|
2491 | Use Multiword Load/Store Instructions |
---|
2492 | ------------------------------------- |
---|
2493 | |
---|
2494 | The macro PPC_USE_MULTIPLE is set to 1 to indicate that multiword load and |
---|
2495 | store instructions should be used to perform context switch operations. |
---|
2496 | The relative efficiency of multiword load and store instructions versus |
---|
2497 | an equivalent set of single word load and store instructions varies based |
---|
2498 | upon the PowerPC model. |
---|
2499 | |
---|
2500 | Instruction Cache Size |
---|
2501 | ---------------------- |
---|
2502 | |
---|
2503 | The macro PPC_I_CACHE is set to the size in bytes of the instruction cache. |
---|
2504 | |
---|
2505 | Data Cache Size |
---|
2506 | --------------- |
---|
2507 | |
---|
2508 | The macro PPC_D_CACHE is set to the size in bytes of the data cache. |
---|
2509 | |
---|
2510 | Debug Model |
---|
2511 | ----------- |
---|
2512 | |
---|
2513 | The macro PPC_DEBUG_MODEL is set to indicate the debug support features |
---|
2514 | present in this CPU model. The following debug support feature sets |
---|
2515 | are currently supported: |
---|
2516 | |
---|
2517 | *``PPC_DEBUG_MODEL_STANDARD``* |
---|
2518 | indicates that the single-step trace enable (SE) and branch trace |
---|
2519 | enable (BE) bits in the MSR are supported by this CPU model. |
---|
2520 | |
---|
2521 | *``PPC_DEBUG_MODEL_SINGLE_STEP_ONLY``* |
---|
2522 | indicates that only the single-step trace enable (SE) bit in the MSR |
---|
2523 | is supported by this CPU model. |
---|
2524 | |
---|
2525 | *``PPC_DEBUG_MODEL_IBM4xx``* |
---|
2526 | indicates that the debug exception enable (DE) bit in the MSR is supported |
---|
2527 | by this CPU model. At this time, this particular debug feature set |
---|
2528 | has only been seen in the IBM 4xx series. |
---|
2529 | |
---|
2530 | Low Power Model |
---|
2531 | ~~~~~~~~~~~~~~~ |
---|
2532 | |
---|
2533 | The macro PPC_LOW_POWER_MODE is set to indicate the low power model |
---|
2534 | supported by this CPU model. The following low power modes are currently |
---|
2535 | supported. |
---|
2536 | |
---|
2537 | *``PPC_LOW_POWER_MODE_NONE``* |
---|
2538 | indicates that this CPU model has no low power mode support. |
---|
2539 | |
---|
2540 | *``PPC_LOW_POWER_MODE_STANDARD``* |
---|
2541 | indicates that this CPU model follows the low power model defined for |
---|
2542 | the PPC603e. |
---|
2543 | |
---|
2544 | Multilibs |
---|
2545 | ========= |
---|
2546 | |
---|
2547 | The following multilibs are available: |
---|
2548 | |
---|
2549 | # ``.``: 32-bit PowerPC with FPU |
---|
2550 | |
---|
2551 | # ``nof``: 32-bit PowerPC with software floating point support |
---|
2552 | |
---|
2553 | # ``m403``: Instruction set for PPC403 with FPU |
---|
2554 | |
---|
2555 | # ``m505``: Instruction set for MPC505 with FPU |
---|
2556 | |
---|
2557 | # ``m603e``: Instruction set for MPC603e with FPU |
---|
2558 | |
---|
2559 | # ``m603e/nof``: Instruction set for MPC603e with software floating |
---|
2560 | point support |
---|
2561 | |
---|
2562 | # ``m604``: Instruction set for MPC604 with FPU |
---|
2563 | |
---|
2564 | # ``m604/nof``: Instruction set for MPC604 with software floating point |
---|
2565 | support |
---|
2566 | |
---|
2567 | # ``m860``: Instruction set for MPC860 with FPU |
---|
2568 | |
---|
2569 | # ``m7400``: Instruction set for MPC7500 with FPU |
---|
2570 | |
---|
2571 | # ``m7400/nof``: Instruction set for MPC7500 with software floating |
---|
2572 | point support |
---|
2573 | |
---|
2574 | # ``m8540``: Instruction set for e200, e500 and e500v2 cores with |
---|
2575 | single-precision FPU and SPE |
---|
2576 | |
---|
2577 | # ``m8540/gprsdouble``: Instruction set for e200, e500 and e500v2 cores |
---|
2578 | with double-precision FPU and SPE |
---|
2579 | |
---|
2580 | # ``m8540/nof/nospe``: Instruction set for e200, e500 and e500v2 cores |
---|
2581 | with software floating point support and no SPE |
---|
2582 | |
---|
2583 | # ``me6500/m32``: 32-bit instruction set for e6500 core with FPU and |
---|
2584 | AltiVec |
---|
2585 | |
---|
2586 | # ``me6500/m32/nof/noaltivec``: 32-bit instruction set for e6500 core |
---|
2587 | with software floating point support and no AltiVec |
---|
2588 | |
---|
2589 | Calling Conventions |
---|
2590 | =================== |
---|
2591 | |
---|
2592 | RTEMS supports the Embedded Application Binary Interface (EABI) |
---|
2593 | calling convention. Documentation for EABI is available by sending |
---|
2594 | a message with a subject line of "EABI" to eabi@goth.sis.mot.com. |
---|
2595 | |
---|
2596 | Programming Model |
---|
2597 | ----------------- |
---|
2598 | |
---|
2599 | This section discusses the programming model for the |
---|
2600 | PowerPC architecture. |
---|
2601 | |
---|
2602 | Non-Floating Point Registers |
---|
2603 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
2604 | |
---|
2605 | The PowerPC architecture defines thirty-two non-floating point registers |
---|
2606 | directly visible to the programmer. In thirty-two bit implementations, each |
---|
2607 | register is thirty-two bits wide. In sixty-four bit implementations, each |
---|
2608 | register is sixty-four bits wide. |
---|
2609 | |
---|
2610 | These registers are referred to as ``gpr0`` to ``gpr31``. |
---|
2611 | |
---|
2612 | Some of the registers serve defined roles in the EABI programming model. |
---|
2613 | The following table describes the role of each of these registers: |
---|
2614 | .. code:: c |
---|
2615 | |
---|
2616 | +---------------+----------------+------------------------------+ |
---|
2617 | | Register Name | Alternate Name | Description | |
---|
2618 | +---------------+----------------+------------------------------+ |
---|
2619 | | r1 | sp | stack pointer | |
---|
2620 | +---------------+----------------+------------------------------+ |
---|
2621 | | | | global pointer to the Small | |
---|
2622 | | r2 | na | Constant Area (SDA2) | |
---|
2623 | +---------------+----------------+------------------------------+ |
---|
2624 | | r3 - r12 | na | parameter and result passing | |
---|
2625 | +---------------+----------------+------------------------------+ |
---|
2626 | | | | global pointer to the Small | |
---|
2627 | | r13 | na | Data Area (SDA) | |
---|
2628 | +---------------+----------------+------------------------------+ |
---|
2629 | |
---|
2630 | Floating Point Registers |
---|
2631 | ~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
2632 | |
---|
2633 | The PowerPC architecture includes thirty-two, sixty-four bit |
---|
2634 | floating point registers. All PowerPC floating point instructions |
---|
2635 | interpret these registers as 32 double precision floating point registers, |
---|
2636 | regardless of whether the processor has 64-bit or 32-bit implementation. |
---|
2637 | |
---|
2638 | The floating point status and control register (fpscr) records exceptions |
---|
2639 | and the type of result generated by floating-point operations. |
---|
2640 | Additionally, it controls the rounding mode of operations and allows the |
---|
2641 | reporting of floating exceptions to be enabled or disabled. |
---|
2642 | |
---|
2643 | Special Registers |
---|
2644 | ~~~~~~~~~~~~~~~~~ |
---|
2645 | |
---|
2646 | The PowerPC architecture includes a number of special registers |
---|
2647 | which are critical to the programming model: |
---|
2648 | |
---|
2649 | *Machine State Register* |
---|
2650 | The MSR contains the processor mode, power management mode, endian mode, |
---|
2651 | exception information, privilege level, floating point available and |
---|
2652 | floating point excepiton mode, address translation information and |
---|
2653 | the exception prefix. |
---|
2654 | |
---|
2655 | *Link Register* |
---|
2656 | The LR contains the return address after a function call. This register |
---|
2657 | must be saved before a subsequent subroutine call can be made. The |
---|
2658 | use of this register is discussed further in the *Call and Return |
---|
2659 | Mechanism* section below. |
---|
2660 | |
---|
2661 | *Count Register* |
---|
2662 | The CTR contains the iteration variable for some loops. It may also be used |
---|
2663 | for indirect function calls and jumps. |
---|
2664 | |
---|
2665 | Call and Return Mechanism |
---|
2666 | ------------------------- |
---|
2667 | |
---|
2668 | The PowerPC architecture supports a simple yet effective call |
---|
2669 | and return mechanism. A subroutine is invoked |
---|
2670 | via the "branch and link" (``bl``) and |
---|
2671 | "brank and link absolute" (``bla``) |
---|
2672 | instructions. This instructions place the return address |
---|
2673 | in the Link Register (LR). The callee returns to the caller by |
---|
2674 | executing a "branch unconditional to the link register" (``blr``) |
---|
2675 | instruction. Thus the callee returns to the caller via a jump |
---|
2676 | to the return address which is stored in the LR. |
---|
2677 | |
---|
2678 | The previous contents of the LR are not automatically saved |
---|
2679 | by either the ``bl`` or ``bla``. It is the responsibility |
---|
2680 | of the callee to save the contents of the LR before invoking |
---|
2681 | another subroutine. If the callee invokes another subroutine, |
---|
2682 | it must restore the LR before executing the ``blr`` instruction |
---|
2683 | to return to the caller. |
---|
2684 | |
---|
2685 | It is important to note that the PowerPC subroutine |
---|
2686 | call and return mechanism does not automatically save and |
---|
2687 | restore any registers. |
---|
2688 | |
---|
2689 | The LR may be accessed as special purpose register 8 (``SPR8``) using the |
---|
2690 | "move from special register" (``mfspr``) and |
---|
2691 | "move to special register" (``mtspr``) instructions. |
---|
2692 | |
---|
2693 | Calling Mechanism |
---|
2694 | ----------------- |
---|
2695 | |
---|
2696 | All RTEMS directives are invoked using the regular |
---|
2697 | PowerPC EABI calling convention via the ``bl`` or``bla`` instructions. |
---|
2698 | |
---|
2699 | Register Usage |
---|
2700 | -------------- |
---|
2701 | |
---|
2702 | As discussed above, the call instruction does not |
---|
2703 | automatically save any registers. It is the responsibility |
---|
2704 | of the callee to save and restore any registers which must be preserved |
---|
2705 | across subroutine calls. The callee is responsible for saving |
---|
2706 | callee-preserved registers to the program stack and restoring them |
---|
2707 | before returning to the caller. |
---|
2708 | |
---|
2709 | Parameter Passing |
---|
2710 | ----------------- |
---|
2711 | |
---|
2712 | RTEMS assumes that arguments are placed in the |
---|
2713 | general purpose registers with the first argument in |
---|
2714 | register 3 (``r3``), the second argument in general purpose |
---|
2715 | register 4 (``r4``), and so forth until the seventh |
---|
2716 | argument is in general purpose register 10 (``r10``). |
---|
2717 | If there are more than seven arguments, then subsequent arguments |
---|
2718 | are placed on the program stack. The following pseudo-code |
---|
2719 | illustrates the typical sequence used to call a RTEMS directive |
---|
2720 | with three (3) arguments: |
---|
2721 | .. code:: c |
---|
2722 | |
---|
2723 | load third argument into r5 |
---|
2724 | load second argument into r4 |
---|
2725 | load first argument into r3 |
---|
2726 | invoke directive |
---|
2727 | |
---|
2728 | Memory Model |
---|
2729 | ============ |
---|
2730 | |
---|
2731 | Flat Memory Model |
---|
2732 | ----------------- |
---|
2733 | |
---|
2734 | The PowerPC architecture supports a variety of memory models. |
---|
2735 | RTEMS supports the PowerPC using a flat memory model with |
---|
2736 | paging disabled. In this mode, the PowerPC automatically |
---|
2737 | converts every address from a logical to a physical address |
---|
2738 | each time it is used. The PowerPC uses information provided |
---|
2739 | in the Block Address Translation (BAT) to convert these addresses. |
---|
2740 | |
---|
2741 | Implementations of the PowerPC architecture may be thirty-two or sixty-four bit. |
---|
2742 | The PowerPC architecture supports a flat thirty-two or sixty-four bit address |
---|
2743 | space with addresses ranging from 0x00000000 to 0xFFFFFFFF (4 |
---|
2744 | gigabytes) in thirty-two bit implementations or to 0xFFFFFFFFFFFFFFFF |
---|
2745 | in sixty-four bit implementations. Each address is represented |
---|
2746 | by either a thirty-two bit or sixty-four bit value and is byte addressable. |
---|
2747 | The address may be used to reference a single byte, half-word |
---|
2748 | (2-bytes), word (4 bytes), or in sixty-four bit implementations a |
---|
2749 | doubleword (8 bytes). Memory accesses within the address space are |
---|
2750 | performed in big or little endian fashion by the PowerPC based |
---|
2751 | upon the current setting of the Little-endian mode enable bit (LE) |
---|
2752 | in the Machine State Register (MSR). While the processor is in |
---|
2753 | big endian mode, memory accesses which are not properly aligned |
---|
2754 | generate an "alignment exception" (vector offset 0x00600). In |
---|
2755 | little endian mode, the PowerPC architecture does not require |
---|
2756 | the processor to generate alignment exceptions. |
---|
2757 | |
---|
2758 | The following table lists the alignment requirements for a variety |
---|
2759 | of data accesses: |
---|
2760 | .. code:: c |
---|
2761 | |
---|
2762 | +--------------+-----------------------+ |
---|
2763 | | Data Type | Alignment Requirement | |
---|
2764 | +--------------+-----------------------+ |
---|
2765 | | byte | 1 | |
---|
2766 | | half-word | 2 | |
---|
2767 | | word | 4 | |
---|
2768 | | doubleword | 8 | |
---|
2769 | +--------------+-----------------------+ |
---|
2770 | |
---|
2771 | Doubleword load and store operations are only available in |
---|
2772 | PowerPC CPU models which are sixty-four bit implementations. |
---|
2773 | |
---|
2774 | RTEMS does not directly support any PowerPC Memory Management |
---|
2775 | Units, therefore, virtual memory or segmentation systems |
---|
2776 | involving the PowerPC are not supported. |
---|
2777 | |
---|
2778 | .. COMMENT: COPYRIGHT (c) 1989-2007. |
---|
2779 | |
---|
2780 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
2781 | |
---|
2782 | .. COMMENT: All rights reserved. |
---|
2783 | |
---|
2784 | Interrupt Processing |
---|
2785 | ==================== |
---|
2786 | |
---|
2787 | Although RTEMS hides many of the processor dependent |
---|
2788 | details of interrupt processing, it is important to understand |
---|
2789 | how the RTEMS interrupt manager is mapped onto the processorâs |
---|
2790 | unique architecture. Discussed in this chapter are the PowerPCâs |
---|
2791 | interrupt response and control mechanisms as they pertain to |
---|
2792 | RTEMS. |
---|
2793 | |
---|
2794 | RTEMS and associated documentation uses the terms interrupt and vector. |
---|
2795 | In the PowerPC architecture, these terms correspond to exception and |
---|
2796 | exception handler, respectively. The terms will be used interchangeably |
---|
2797 | in this manual. |
---|
2798 | |
---|
2799 | Synchronous Versus Asynchronous Exceptions |
---|
2800 | ------------------------------------------ |
---|
2801 | |
---|
2802 | In the PowerPC architecture exceptions can be either precise or |
---|
2803 | imprecise and either synchronous or asynchronous. Asynchronous |
---|
2804 | exceptions occur when an external event interrupts the processor. |
---|
2805 | Synchronous exceptions are caused by the actions of an |
---|
2806 | instruction. During an exception SRR0 is used to calculate where |
---|
2807 | instruction processing should resume. All instructions prior to |
---|
2808 | the resume instruction will have completed execution. SRR1 is used to |
---|
2809 | store the machine status. |
---|
2810 | |
---|
2811 | There are two asynchronous nonmaskable, highest-priority exceptions |
---|
2812 | system reset and machine check. There are two asynchrononous maskable |
---|
2813 | low-priority exceptions external interrupt and decrementer. Nonmaskable |
---|
2814 | execptions are never delayed, therefore if two nonmaskable, asynchronous |
---|
2815 | exceptions occur in immediate succession, the state information saved by |
---|
2816 | the first exception may be overwritten when the subsequent exception occurs. |
---|
2817 | |
---|
2818 | The PowerPC arcitecure defines one imprecise exception, the imprecise |
---|
2819 | floating point enabled exception. All other synchronous exceptions are |
---|
2820 | precise. The synchronization occuring during asynchronous precise |
---|
2821 | exceptions conforms to the requirements for context synchronization. |
---|
2822 | |
---|
2823 | Vectoring of Interrupt Handler |
---|
2824 | ------------------------------ |
---|
2825 | |
---|
2826 | Upon determining that an exception can be taken the PowerPC automatically |
---|
2827 | performs the following actions: |
---|
2828 | |
---|
2829 | - an instruction address is loaded into SRR0 |
---|
2830 | |
---|
2831 | - bits 33-36 and 42-47 of SRR1 are loaded with information |
---|
2832 | specific to the exception. |
---|
2833 | |
---|
2834 | - bits 0-32, 37-41, and 48-63 of SRR1 are loaded with corresponding |
---|
2835 | bits from the MSR. |
---|
2836 | |
---|
2837 | - the MSR is set based upon the exception type. |
---|
2838 | |
---|
2839 | - instruction fetch and execution resumes, using the new MSR value, at a location specific to the execption type. |
---|
2840 | |
---|
2841 | If the interrupt handler was installed as an RTEMS |
---|
2842 | interrupt handler, then upon receipt of the interrupt, the |
---|
2843 | processor passes control to the RTEMS interrupt handler which |
---|
2844 | performs the following actions: |
---|
2845 | |
---|
2846 | - saves the state of the interrupted task on itâs stack, |
---|
2847 | |
---|
2848 | - saves all registers which are not normally preserved |
---|
2849 | by the calling sequence so the userâs interrupt service |
---|
2850 | routine can be written in a high-level language. |
---|
2851 | |
---|
2852 | - if this is the outermost (i.e. non-nested) interrupt, |
---|
2853 | then the RTEMS interrupt handler switches from the current stack |
---|
2854 | to the interrupt stack, |
---|
2855 | |
---|
2856 | - enables exceptions, |
---|
2857 | |
---|
2858 | - invokes the vectors to a user interrupt service routine (ISR). |
---|
2859 | |
---|
2860 | Asynchronous interrupts are ignored while exceptions are |
---|
2861 | disabled. Synchronous interrupts which occur while are |
---|
2862 | disabled result in the CPU being forced into an error mode. |
---|
2863 | |
---|
2864 | A nested interrupt is processed similarly with the |
---|
2865 | exception that the current stack need not be switched to the |
---|
2866 | interrupt stack. |
---|
2867 | |
---|
2868 | Interrupt Levels |
---|
2869 | ---------------- |
---|
2870 | |
---|
2871 | The PowerPC architecture supports only a single external |
---|
2872 | asynchronous interrupt source. This interrupt source |
---|
2873 | may be enabled and disabled via the External Interrupt Enable (EE) |
---|
2874 | bit in the Machine State Register (MSR). Thus only two level (enabled |
---|
2875 | and disabled) of external device interrupt priorities are |
---|
2876 | directly supported by the PowerPC architecture. |
---|
2877 | |
---|
2878 | Some PowerPC implementations include a Critical Interrupt capability |
---|
2879 | which is often used to receive interrupts from high priority external |
---|
2880 | devices. |
---|
2881 | |
---|
2882 | The RTEMS interrupt level mapping scheme for the PowerPC is not |
---|
2883 | a numeric level as on most RTEMS ports. It is a bit mapping in |
---|
2884 | which the least three significiant bits of the interrupt level |
---|
2885 | are mapped directly to the enabling of specific interrupt |
---|
2886 | sources as follows: |
---|
2887 | |
---|
2888 | *Critical Interrupt* |
---|
2889 | Setting bit 0 (the least significant bit) of the interrupt level |
---|
2890 | enables the Critical Interrupt source, if it is available on this |
---|
2891 | CPU model. |
---|
2892 | |
---|
2893 | *Machine Check* |
---|
2894 | Setting bit 1 of the interrupt level enables Machine Check execptions. |
---|
2895 | |
---|
2896 | *External Interrupt* |
---|
2897 | Setting bit 2 of the interrupt level enables External Interrupt execptions. |
---|
2898 | |
---|
2899 | All other bits in the RTEMS task interrupt level are ignored. |
---|
2900 | |
---|
2901 | Default Fatal Error Processing |
---|
2902 | ============================== |
---|
2903 | |
---|
2904 | The default fatal error handler for this architecture performs the |
---|
2905 | following actions: |
---|
2906 | |
---|
2907 | - places the error code in r3, and |
---|
2908 | |
---|
2909 | - executes a trap instruction which results in a Program Exception. |
---|
2910 | |
---|
2911 | If the Program Exception returns, then the following actions are performed: |
---|
2912 | |
---|
2913 | - disables all processor exceptions by loading a 0 into the MSR, and |
---|
2914 | |
---|
2915 | - goes into an infinite loop to simulate a halt processor instruction. |
---|
2916 | |
---|
2917 | Symmetric Multiprocessing |
---|
2918 | ========================= |
---|
2919 | |
---|
2920 | SMP is supported. Available platforms are the Freescale QorIQ P series (e.g. |
---|
2921 | P1020) and T series (e.g. T2080, T4240). |
---|
2922 | |
---|
2923 | Thread-Local Storage |
---|
2924 | ==================== |
---|
2925 | |
---|
2926 | Thread-local storage is supported. |
---|
2927 | |
---|
2928 | Board Support Packages |
---|
2929 | ====================== |
---|
2930 | |
---|
2931 | System Reset |
---|
2932 | ------------ |
---|
2933 | |
---|
2934 | An RTEMS based application is initiated or |
---|
2935 | re-initiated when the PowerPC processor is reset. The PowerPC |
---|
2936 | architecture defines a Reset Exception, but leaves the |
---|
2937 | details of the CPU state as implementation specific. Please |
---|
2938 | refer to the Userâs Manual for the CPU model in question. |
---|
2939 | |
---|
2940 | In general, at power-up the PowerPC begin execution at address |
---|
2941 | 0xFFF00100 in supervisor mode with all exceptions disabled. For |
---|
2942 | soft resets, the CPU will vector to either 0xFFF00100 or 0x00000100 |
---|
2943 | depending upon the setting of the Exception Prefix bit in the MSR. |
---|
2944 | If during a soft reset, a Machine Check Exception occurs, then the |
---|
2945 | CPU may execute a hard reset. |
---|
2946 | |
---|
2947 | Processor Initialization |
---|
2948 | ------------------------ |
---|
2949 | |
---|
2950 | If this PowerPC implementation supports on-chip caching |
---|
2951 | and this is to be utilized, then it should be enabled during the |
---|
2952 | reset application initialization code. On-chip caching has been |
---|
2953 | observed to prevent some emulators from working properly, so it |
---|
2954 | may be necessary to run with caching disabled to use these emulators. |
---|
2955 | |
---|
2956 | In addition to the requirements described in the*Board Support Packages* chapter of the RTEMS C |
---|
2957 | Applications Userâs Manual for the reset code |
---|
2958 | which is executed before the call to ``rtems_initialize_executive``, |
---|
2959 | the PowrePC version has the following specific requirements: |
---|
2960 | |
---|
2961 | - Must leave the PR bit of the Machine State Register (MSR) set |
---|
2962 | to 0 so the PowerPC remains in the supervisor state. |
---|
2963 | |
---|
2964 | - Must set stack pointer (sp or r1) such that a minimum stack |
---|
2965 | size of MINIMUM_STACK_SIZE bytes is provided for the RTEMS initialization |
---|
2966 | sequence. |
---|
2967 | |
---|
2968 | - Must disable all external interrupts (i.e. clear the EI (EE) |
---|
2969 | bit of the machine state register). |
---|
2970 | |
---|
2971 | - Must enable traps so window overflow and underflow |
---|
2972 | conditions can be properly handled. |
---|
2973 | |
---|
2974 | - Must initialize the PowerPCâs initial Exception Table with default |
---|
2975 | handlers. |
---|
2976 | |
---|
2977 | .. COMMENT: COPYRIGHT (c) 1988-2002. |
---|
2978 | |
---|
2979 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
2980 | |
---|
2981 | .. COMMENT: All rights reserved. |
---|
2982 | |
---|
2983 | SuperH Specific Information |
---|
2984 | ########################### |
---|
2985 | |
---|
2986 | This chapter discusses the SuperH architecture dependencies |
---|
2987 | in this port of RTEMS. The SuperH family has a wide variety |
---|
2988 | of implementations by a wide range of vendors. Consequently, |
---|
2989 | there are many, many CPU models within it. |
---|
2990 | |
---|
2991 | **Architecture Documents** |
---|
2992 | |
---|
2993 | For information on the SuperH architecture, |
---|
2994 | refer to the following documents available from VENDOR |
---|
2995 | (:file:`http//www.XXX.com/`): |
---|
2996 | |
---|
2997 | - *SuperH Family Reference, VENDOR, PART NUMBER*. |
---|
2998 | |
---|
2999 | CPU Model Dependent Features |
---|
3000 | ============================ |
---|
3001 | |
---|
3002 | This chapter presents the set of features which vary |
---|
3003 | across SuperH implementations and are of importance to RTEMS. |
---|
3004 | The set of CPU model feature macros are defined in the file``cpukit/score/cpu/sh/sh.h`` based upon the particular CPU |
---|
3005 | model specified on the compilation command line. |
---|
3006 | |
---|
3007 | Another Optional Feature |
---|
3008 | ------------------------ |
---|
3009 | |
---|
3010 | The macro XXX |
---|
3011 | |
---|
3012 | Calling Conventions |
---|
3013 | =================== |
---|
3014 | |
---|
3015 | Calling Mechanism |
---|
3016 | ----------------- |
---|
3017 | |
---|
3018 | All RTEMS directives are invoked using a ``XXX`` |
---|
3019 | instruction and return to the user application via the``XXX`` instruction. |
---|
3020 | |
---|
3021 | Register Usage |
---|
3022 | -------------- |
---|
3023 | |
---|
3024 | The SH1 has 16 general registers (r0..r15). |
---|
3025 | |
---|
3026 | - r0..r3 used as general volatile registers |
---|
3027 | |
---|
3028 | - r4..r7 used to pass up to 4 arguments to functions, arguments |
---|
3029 | above 4 are |
---|
3030 | passed via the stack) |
---|
3031 | |
---|
3032 | - r8..13 caller saved registers (i.e. push them to the stack if you |
---|
3033 | need them inside of a function) |
---|
3034 | |
---|
3035 | - r14 frame pointer |
---|
3036 | |
---|
3037 | - r15 stack pointer |
---|
3038 | |
---|
3039 | Parameter Passing |
---|
3040 | ----------------- |
---|
3041 | |
---|
3042 | XXX |
---|
3043 | |
---|
3044 | Memory Model |
---|
3045 | ============ |
---|
3046 | |
---|
3047 | Flat Memory Model |
---|
3048 | ----------------- |
---|
3049 | |
---|
3050 | The SuperH family supports a flat 32-bit address |
---|
3051 | space with addresses ranging from 0x00000000 to 0xFFFFFFFF (4 |
---|
3052 | gigabytes). Each address is represented by a 32-bit value and |
---|
3053 | is byte addressable. The address may be used to reference a |
---|
3054 | single byte, word (2-bytes), or long word (4 bytes). Memory |
---|
3055 | accesses within this address space are performed in big endian |
---|
3056 | fashion by the processors in this family. |
---|
3057 | |
---|
3058 | Some of the SuperH family members support virtual memory and |
---|
3059 | segmentation. RTEMS does not support virtual memory or |
---|
3060 | segmentation on any of the SuperH family members. It is the |
---|
3061 | responsibility of the BSP to initialize the mapping for |
---|
3062 | a flat memory model. |
---|
3063 | |
---|
3064 | Interrupt Processing |
---|
3065 | ==================== |
---|
3066 | |
---|
3067 | Although RTEMS hides many of the processor dependent |
---|
3068 | details of interrupt processing, it is important to understand |
---|
3069 | how the RTEMS interrupt manager is mapped onto the processorâs |
---|
3070 | unique architecture. Discussed in this chapter are the MIPSâs |
---|
3071 | interrupt response and control mechanisms as they pertain to |
---|
3072 | RTEMS. |
---|
3073 | |
---|
3074 | Vectoring of an Interrupt Handler |
---|
3075 | --------------------------------- |
---|
3076 | |
---|
3077 | Upon receipt of an interrupt the XXX family |
---|
3078 | members with separate interrupt stacks automatically perform the |
---|
3079 | following actions: |
---|
3080 | |
---|
3081 | - TBD |
---|
3082 | |
---|
3083 | A nested interrupt is processed similarly by these |
---|
3084 | CPU models with the exception that only a single ISF is placed |
---|
3085 | on the interrupt stack and the current stack need not be |
---|
3086 | switched. |
---|
3087 | |
---|
3088 | Interrupt Levels |
---|
3089 | ---------------- |
---|
3090 | |
---|
3091 | TBD |
---|
3092 | |
---|
3093 | Default Fatal Error Processing |
---|
3094 | ============================== |
---|
3095 | |
---|
3096 | The default fatal error handler for this architecture disables processor |
---|
3097 | interrupts, places the error code in *XXX*, and executes a ``XXX`` |
---|
3098 | instruction to simulate a halt processor instruction. |
---|
3099 | |
---|
3100 | Symmetric Multiprocessing |
---|
3101 | ========================= |
---|
3102 | |
---|
3103 | SMP is not supported. |
---|
3104 | |
---|
3105 | Thread-Local Storage |
---|
3106 | ==================== |
---|
3107 | |
---|
3108 | Thread-local storage is not implemented. |
---|
3109 | |
---|
3110 | Board Support Packages |
---|
3111 | ====================== |
---|
3112 | |
---|
3113 | System Reset |
---|
3114 | ------------ |
---|
3115 | |
---|
3116 | An RTEMS based application is initiated or |
---|
3117 | re-initiated when the processor is reset. When the |
---|
3118 | processor is reset, it performs the following actions: |
---|
3119 | |
---|
3120 | - TBD |
---|
3121 | |
---|
3122 | Processor Initialization |
---|
3123 | ------------------------ |
---|
3124 | |
---|
3125 | TBD |
---|
3126 | |
---|
3127 | .. COMMENT: COPYRIGHT (c) 1988-2002. |
---|
3128 | |
---|
3129 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
3130 | |
---|
3131 | .. COMMENT: All rights reserved. |
---|
3132 | |
---|
3133 | SPARC Specific Information |
---|
3134 | ########################## |
---|
3135 | |
---|
3136 | The Real Time Executive for Multiprocessor Systems |
---|
3137 | (RTEMS) is designed to be portable across multiple processor |
---|
3138 | architectures. However, the nature of real-time systems makes |
---|
3139 | it essential that the application designer understand certain |
---|
3140 | processor dependent implementation details. These processor |
---|
3141 | dependencies include calling convention, board support package |
---|
3142 | issues, interrupt processing, exact RTEMS memory requirements, |
---|
3143 | performance data, header files, and the assembly language |
---|
3144 | interface to the executive. |
---|
3145 | |
---|
3146 | This document discusses the SPARC architecture dependencies in this |
---|
3147 | port of RTEMS. This architectural port is for SPARC Version 7 and |
---|
3148 | 8. Implementations for SPARC V9 are in the sparc64 target. |
---|
3149 | |
---|
3150 | It is highly recommended that the SPARC RTEMS |
---|
3151 | application developer obtain and become familiar with the |
---|
3152 | documentation for the processor being used as well as the |
---|
3153 | specification for the revision of the SPARC architecture which |
---|
3154 | corresponds to that processor. |
---|
3155 | |
---|
3156 | **SPARC Architecture Documents** |
---|
3157 | |
---|
3158 | For information on the SPARC architecture, refer to |
---|
3159 | the following documents available from SPARC International, Inc. |
---|
3160 | (http://www.sparc.com): |
---|
3161 | |
---|
3162 | - SPARC Standard Version 7. |
---|
3163 | |
---|
3164 | - SPARC Standard Version 8. |
---|
3165 | |
---|
3166 | **ERC32 Specific Information** |
---|
3167 | |
---|
3168 | The European Space Agencyâs ERC32 is a three chip |
---|
3169 | computing core implementing a SPARC V7 processor and associated |
---|
3170 | support circuitry for embedded space applications. The integer |
---|
3171 | and floating-point units (90C601E & 90C602E) are based on the |
---|
3172 | Cypress 7C601 and 7C602, with additional error-detection and |
---|
3173 | recovery functions. The memory controller (MEC) implements |
---|
3174 | system support functions such as address decoding, memory |
---|
3175 | interface, DMA interface, UARTs, timers, interrupt control, |
---|
3176 | write-protection, memory reconfiguration and error-detection. |
---|
3177 | The core is designed to work at 25MHz, but using space qualified |
---|
3178 | memories limits the system frequency to around 15 MHz, resulting |
---|
3179 | in a performance of 10 MIPS and 2 MFLOPS. |
---|
3180 | |
---|
3181 | Information on the ERC32 and a number of development |
---|
3182 | support tools, such as the SPARC Instruction Simulator (SIS), |
---|
3183 | are freely available on the Internet. The following documents |
---|
3184 | and SIS are available via anonymous ftp or pointing your web |
---|
3185 | browser at ftp://ftp.estec.esa.nl/pub/ws/wsd/erc32. |
---|
3186 | |
---|
3187 | - ERC32 System Design Document |
---|
3188 | |
---|
3189 | - MEC Device Specification |
---|
3190 | |
---|
3191 | Additionally, the SPARC RISC Userâs Guide from Matra |
---|
3192 | MHS documents the functionality of the integer and floating |
---|
3193 | point units including the instruction set information. To |
---|
3194 | obtain this document as well as ERC32 components and VHDL models |
---|
3195 | contact: |
---|
3196 | .. code:: c |
---|
3197 | |
---|
3198 | Matra MHS SA |
---|
3199 | 3 Avenue du Centre, BP 309, |
---|
3200 | 78054 St-Quentin-en-Yvelines, |
---|
3201 | Cedex, France |
---|
3202 | VOICE: +31-1-30607087 |
---|
3203 | FAX: +31-1-30640693 |
---|
3204 | |
---|
3205 | Amar Guennon (amar.guennon@matramhs.fr) is familiar with the ERC32. |
---|
3206 | |
---|
3207 | .. COMMENT: COPYRIGHT (c) 1988-2002. |
---|
3208 | |
---|
3209 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
3210 | |
---|
3211 | .. COMMENT: All rights reserved. |
---|
3212 | |
---|
3213 | CPU Model Dependent Features |
---|
3214 | ============================ |
---|
3215 | |
---|
3216 | Microprocessors are generally classified into |
---|
3217 | families with a variety of CPU models or implementations within |
---|
3218 | that family. Within a processor family, there is a high level |
---|
3219 | of binary compatibility. This family may be based on either an |
---|
3220 | architectural specification or on maintaining compatibility with |
---|
3221 | a popular processor. Recent microprocessor families such as the |
---|
3222 | SPARC or PowerPC are based on an architectural specification |
---|
3223 | which is independent or any particular CPU model or |
---|
3224 | implementation. Older families such as the M68xxx and the iX86 |
---|
3225 | evolved as the manufacturer strived to produce higher |
---|
3226 | performance processor models which maintained binary |
---|
3227 | compatibility with older models. |
---|
3228 | |
---|
3229 | RTEMS takes advantage of the similarity of the |
---|
3230 | various models within a CPU family. Although the models do vary |
---|
3231 | in significant ways, the high level of compatibility makes it |
---|
3232 | possible to share the bulk of the CPU dependent executive code |
---|
3233 | across the entire family. |
---|
3234 | |
---|
3235 | CPU Model Feature Flags |
---|
3236 | ----------------------- |
---|
3237 | |
---|
3238 | Each processor family supported by RTEMS has a |
---|
3239 | list of features which vary between CPU models |
---|
3240 | within a family. For example, the most common model dependent |
---|
3241 | feature regardless of CPU family is the presence or absence of a |
---|
3242 | floating point unit or coprocessor. When defining the list of |
---|
3243 | features present on a particular CPU model, one simply notes |
---|
3244 | that floating point hardware is or is not present and defines a |
---|
3245 | single constant appropriately. Conditional compilation is |
---|
3246 | utilized to include the appropriate source code for this CPU |
---|
3247 | modelâs feature set. It is important to note that this means |
---|
3248 | that RTEMS is thus compiled using the appropriate feature set |
---|
3249 | and compilation flags optimal for this CPU model used. The |
---|
3250 | alternative would be to generate a binary which would execute on |
---|
3251 | all family members using only the features which were always |
---|
3252 | present. |
---|
3253 | |
---|
3254 | This section presents the set of features which vary |
---|
3255 | across SPARC implementations and are of importance to RTEMS. |
---|
3256 | The set of CPU model feature macros are defined in the file |
---|
3257 | cpukit/score/cpu/sparc/sparc.h based upon the particular CPU |
---|
3258 | model defined on the compilation command line. |
---|
3259 | |
---|
3260 | CPU Model Name |
---|
3261 | ~~~~~~~~~~~~~~ |
---|
3262 | |
---|
3263 | The macro CPU_MODEL_NAME is a string which designates |
---|
3264 | the name of this CPU model. For example, for the European Space |
---|
3265 | Agencyâs ERC32 SPARC model, this macro is set to the string |
---|
3266 | "erc32". |
---|
3267 | |
---|
3268 | Floating Point Unit |
---|
3269 | ~~~~~~~~~~~~~~~~~~~ |
---|
3270 | |
---|
3271 | The macro SPARC_HAS_FPU is set to 1 to indicate that |
---|
3272 | this CPU model has a hardware floating point unit and 0 |
---|
3273 | otherwise. |
---|
3274 | |
---|
3275 | Bitscan Instruction |
---|
3276 | ~~~~~~~~~~~~~~~~~~~ |
---|
3277 | |
---|
3278 | The macro SPARC_HAS_BITSCAN is set to 1 to indicate |
---|
3279 | that this CPU model has the bitscan instruction. For example, |
---|
3280 | this instruction is supported by the Fujitsu SPARClite family. |
---|
3281 | |
---|
3282 | Number of Register Windows |
---|
3283 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
3284 | |
---|
3285 | The macro SPARC_NUMBER_OF_REGISTER_WINDOWS is set to |
---|
3286 | indicate the number of register window sets implemented by this |
---|
3287 | CPU model. The SPARC architecture allows a for a maximum of |
---|
3288 | thirty-two register window sets although most implementations |
---|
3289 | only include eight. |
---|
3290 | |
---|
3291 | Low Power Mode |
---|
3292 | ~~~~~~~~~~~~~~ |
---|
3293 | |
---|
3294 | The macro SPARC_HAS_LOW_POWER_MODE is set to one to |
---|
3295 | indicate that this CPU model has a low power mode. If low power |
---|
3296 | is enabled, then there must be CPU model specific implementation |
---|
3297 | of the IDLE task in cpukit/score/cpu/sparc/cpu.c. The low |
---|
3298 | power mode IDLE task should be of the form: |
---|
3299 | .. code:: c |
---|
3300 | |
---|
3301 | while ( TRUE ) { |
---|
3302 | enter low power mode |
---|
3303 | } |
---|
3304 | |
---|
3305 | The code required to enter low power mode is CPU model specific. |
---|
3306 | |
---|
3307 | CPU Model Implementation Notes |
---|
3308 | ------------------------------ |
---|
3309 | |
---|
3310 | The ERC32 is a custom SPARC V7 implementation based on the Cypress 601/602 |
---|
3311 | chipset. This CPU has a number of on-board peripherals and was developed by |
---|
3312 | the European Space Agency to target space applications. RTEMS currently |
---|
3313 | provides support for the following peripherals: |
---|
3314 | |
---|
3315 | - UART Channels A and B |
---|
3316 | |
---|
3317 | - General Purpose Timer |
---|
3318 | |
---|
3319 | - Real Time Clock |
---|
3320 | |
---|
3321 | - Watchdog Timer (so it can be disabled) |
---|
3322 | |
---|
3323 | - Control Register (so powerdown mode can be enabled) |
---|
3324 | |
---|
3325 | - Memory Control Register |
---|
3326 | |
---|
3327 | - Interrupt Control |
---|
3328 | |
---|
3329 | The General Purpose Timer and Real Time Clock Timer provided with the ERC32 |
---|
3330 | share the Timer Control Register. Because the Timer Control Register is write |
---|
3331 | only, we must mirror it in software and insure that writes to one timer do not |
---|
3332 | alter the current settings and status of the other timer. Routines are |
---|
3333 | provided in erc32.h which promote the view that the two timers are completely |
---|
3334 | independent. By exclusively using these routines to access the Timer Control |
---|
3335 | Register, the application can view the system as having a General Purpose |
---|
3336 | Timer Control Register and a Real Time Clock Timer Control Register |
---|
3337 | rather than the single shared value. |
---|
3338 | |
---|
3339 | The RTEMS Idle thread take advantage of the low power mode provided by the |
---|
3340 | ERC32. Low power mode is entered during idle loops and is enabled at |
---|
3341 | initialization time. |
---|
3342 | |
---|
3343 | .. COMMENT: COPYRIGHT (c) 1988-2002. |
---|
3344 | |
---|
3345 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
3346 | |
---|
3347 | .. COMMENT: All rights reserved. |
---|
3348 | |
---|
3349 | Calling Conventions |
---|
3350 | =================== |
---|
3351 | |
---|
3352 | Each high-level language compiler generates subroutine entry and exit code |
---|
3353 | based upon a set of rules known as the application binary interface (ABI) |
---|
3354 | calling convention. These rules address the following issues: |
---|
3355 | |
---|
3356 | - register preservation and usage |
---|
3357 | |
---|
3358 | - parameter passing |
---|
3359 | |
---|
3360 | - call and return mechanism |
---|
3361 | |
---|
3362 | An ABI calling convention is of importance when interfacing to subroutines |
---|
3363 | written in another language either assembly or high-level. It determines also |
---|
3364 | the set of registers to be saved or restored during a context switch and |
---|
3365 | interrupt processing. |
---|
3366 | |
---|
3367 | The ABI relevant for RTEMS on SPARC is defined by SYSTEM V APPLICATION BINARY |
---|
3368 | INTERFACE, SPARC Processor Supplement, Third Edition. |
---|
3369 | |
---|
3370 | Programming Model |
---|
3371 | ----------------- |
---|
3372 | |
---|
3373 | This section discusses the programming model for the |
---|
3374 | SPARC architecture. |
---|
3375 | |
---|
3376 | Non-Floating Point Registers |
---|
3377 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
3378 | |
---|
3379 | The SPARC architecture defines thirty-two |
---|
3380 | non-floating point registers directly visible to the programmer. |
---|
3381 | These are divided into four sets: |
---|
3382 | |
---|
3383 | - input registers |
---|
3384 | |
---|
3385 | - local registers |
---|
3386 | |
---|
3387 | - output registers |
---|
3388 | |
---|
3389 | - global registers |
---|
3390 | |
---|
3391 | Each register is referred to by either two or three |
---|
3392 | names in the SPARC reference manuals. First, the registers are |
---|
3393 | referred to as r0 through r31 or with the alternate notation |
---|
3394 | r[0] through r[31]. Second, each register is a member of one of |
---|
3395 | the four sets listed above. Finally, some registers have an |
---|
3396 | architecturally defined role in the programming model which |
---|
3397 | provides an alternate name. The following table describes the |
---|
3398 | mapping between the 32 registers and the register sets: |
---|
3399 | .. code:: c |
---|
3400 | |
---|
3401 | +-----------------+----------------+------------------+ |
---|
3402 | | Register Number | Register Names | Description | |
---|
3403 | +-----------------+----------------+------------------+ |
---|
3404 | | 0 - 7 | g0 - g7 | Global Registers | |
---|
3405 | +-----------------+----------------+------------------+ |
---|
3406 | | 8 - 15 | o0 - o7 | Output Registers | |
---|
3407 | +-----------------+----------------+------------------+ |
---|
3408 | | 16 - 23 | l0 - l7 | Local Registers | |
---|
3409 | +-----------------+----------------+------------------+ |
---|
3410 | | 24 - 31 | i0 - i7 | Input Registers | |
---|
3411 | +-----------------+----------------+------------------+ |
---|
3412 | |
---|
3413 | As mentioned above, some of the registers serve |
---|
3414 | defined roles in the programming model. The following table |
---|
3415 | describes the role of each of these registers: |
---|
3416 | .. code:: c |
---|
3417 | |
---|
3418 | +---------------+----------------+----------------------+ |
---|
3419 | | Register Name | Alternate Name | Description | |
---|
3420 | +---------------+----------------+----------------------+ |
---|
3421 | | g0 | na | reads return 0 | |
---|
3422 | | | | writes are ignored | |
---|
3423 | +---------------+----------------+----------------------+ |
---|
3424 | | o6 | sp | stack pointer | |
---|
3425 | +---------------+----------------+----------------------+ |
---|
3426 | | i6 | fp | frame pointer | |
---|
3427 | +---------------+----------------+----------------------+ |
---|
3428 | | i7 | na | return address | |
---|
3429 | +---------------+----------------+----------------------+ |
---|
3430 | |
---|
3431 | The registers g2 through g4 are reserved for applications. GCC uses them as |
---|
3432 | volatile registers by default. So they are treated like volatile registers in |
---|
3433 | RTEMS as well. |
---|
3434 | |
---|
3435 | The register g6 is reserved for the operating system and contains the address |
---|
3436 | of the per-CPU control block of the current processor. This register is |
---|
3437 | initialized during system start and then remains unchanged. It is not |
---|
3438 | saved/restored by the context switch or interrupt processing code. |
---|
3439 | |
---|
3440 | The register g7 is reserved for the operating system and contains the thread |
---|
3441 | pointer used for thread-local storage (TLS) as mandated by the SPARC ABI. |
---|
3442 | |
---|
3443 | Floating Point Registers |
---|
3444 | ~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
3445 | |
---|
3446 | The SPARC V7 architecture includes thirty-two, |
---|
3447 | thirty-two bit registers. These registers may be viewed as |
---|
3448 | follows: |
---|
3449 | |
---|
3450 | - 32 single precision floating point or integer registers |
---|
3451 | (f0, f1, ... f31) |
---|
3452 | |
---|
3453 | - 16 double precision floating point registers (f0, f2, |
---|
3454 | f4, ... f30) |
---|
3455 | |
---|
3456 | - 8 extended precision floating point registers (f0, f4, |
---|
3457 | f8, ... f28) |
---|
3458 | |
---|
3459 | The floating point status register (FSR) specifies |
---|
3460 | the behavior of the floating point unit for rounding, contains |
---|
3461 | its condition codes, version specification, and trap information. |
---|
3462 | |
---|
3463 | According to the ABI all floating point registers and the floating point status |
---|
3464 | register (FSR) are volatile. Thus the floating point context of a thread is the |
---|
3465 | empty set. The rounding direction is a system global state and must not be |
---|
3466 | modified by threads. |
---|
3467 | |
---|
3468 | A queue of the floating point instructions which have |
---|
3469 | started execution but not yet completed is maintained. This |
---|
3470 | queue is needed to support the multiple cycle nature of floating |
---|
3471 | point operations and to aid floating point exception trap |
---|
3472 | handlers. Once a floating point exception has been encountered, |
---|
3473 | the queue is frozen until it is emptied by the trap handler. |
---|
3474 | The floating point queue is loaded by launching instructions. |
---|
3475 | It is emptied normally when the floating point completes all |
---|
3476 | outstanding instructions and by floating point exception |
---|
3477 | handlers with the store double floating point queue (stdfq) |
---|
3478 | instruction. |
---|
3479 | |
---|
3480 | Special Registers |
---|
3481 | ~~~~~~~~~~~~~~~~~ |
---|
3482 | |
---|
3483 | The SPARC architecture includes two special registers |
---|
3484 | which are critical to the programming model: the Processor State |
---|
3485 | Register (psr) and the Window Invalid Mask (wim). The psr |
---|
3486 | contains the condition codes, processor interrupt level, trap |
---|
3487 | enable bit, supervisor mode and previous supervisor mode bits, |
---|
3488 | version information, floating point unit and coprocessor enable |
---|
3489 | bits, and the current window pointer (cwp). The cwp field of |
---|
3490 | the psr and wim register are used to manage the register windows |
---|
3491 | in the SPARC architecture. The register windows are discussed |
---|
3492 | in more detail below. |
---|
3493 | |
---|
3494 | Register Windows |
---|
3495 | ---------------- |
---|
3496 | |
---|
3497 | The SPARC architecture includes the concept of |
---|
3498 | register windows. An overly simplistic way to think of these |
---|
3499 | windows is to imagine them as being an infinite supply of |
---|
3500 | "fresh" register sets available for each subroutine to use. In |
---|
3501 | reality, they are much more complicated. |
---|
3502 | |
---|
3503 | The save instruction is used to obtain a new register |
---|
3504 | window. This instruction decrements the current window pointer, |
---|
3505 | thus providing a new set of registers for use. This register |
---|
3506 | set includes eight fresh local registers for use exclusively by |
---|
3507 | this subroutine. When done with a register set, the restore |
---|
3508 | instruction increments the current window pointer and the |
---|
3509 | previous register set is once again available. |
---|
3510 | |
---|
3511 | The two primary issues complicating the use of |
---|
3512 | register windows are that (1) the set of register windows is |
---|
3513 | finite, and (2) some registers are shared between adjacent |
---|
3514 | registers windows. |
---|
3515 | |
---|
3516 | Because the set of register windows is finite, it is |
---|
3517 | possible to execute enough save instructions without |
---|
3518 | corresponding restoreâs to consume all of the register windows. |
---|
3519 | This is easily accomplished in a high level language because |
---|
3520 | each subroutine typically performs a save instruction upon |
---|
3521 | entry. Thus having a subroutine call depth greater than the |
---|
3522 | number of register windows will result in a window overflow |
---|
3523 | condition. The window overflow condition generates a trap which |
---|
3524 | must be handled in software. The window overflow trap handler |
---|
3525 | is responsible for saving the contents of the oldest register |
---|
3526 | window on the program stack. |
---|
3527 | |
---|
3528 | Similarly, the subroutines will eventually complete |
---|
3529 | and begin to perform restoreâs. If the restore results in the |
---|
3530 | need for a register window which has previously been written to |
---|
3531 | memory as part of an overflow, then a window underflow condition |
---|
3532 | results. Just like the window overflow, the window underflow |
---|
3533 | condition must be handled in software by a trap handler. The |
---|
3534 | window underflow trap handler is responsible for reloading the |
---|
3535 | contents of the register window requested by the restore |
---|
3536 | instruction from the program stack. |
---|
3537 | |
---|
3538 | The Window Invalid Mask (wim) and the Current Window |
---|
3539 | Pointer (cwp) field in the psr are used in conjunction to manage |
---|
3540 | the finite set of register windows and detect the window |
---|
3541 | overflow and underflow conditions. The cwp contains the index |
---|
3542 | of the register window currently in use. The save instruction |
---|
3543 | decrements the cwp modulo the number of register windows. |
---|
3544 | Similarly, the restore instruction increments the cwp modulo the |
---|
3545 | number of register windows. Each bit in the wim represents |
---|
3546 | represents whether a register window contains valid information. |
---|
3547 | The value of 0 indicates the register window is valid and 1 |
---|
3548 | indicates it is invalid. When a save instruction causes the cwp |
---|
3549 | to point to a register window which is marked as invalid, a |
---|
3550 | window overflow condition results. Conversely, the restore |
---|
3551 | instruction may result in a window underflow condition. |
---|
3552 | |
---|
3553 | Other than the assumption that a register window is |
---|
3554 | always available for trap (i.e. interrupt) handlers, the SPARC |
---|
3555 | architecture places no limits on the number of register windows |
---|
3556 | simultaneously marked as invalid (i.e. number of bits set in the |
---|
3557 | wim). However, RTEMS assumes that only one register window is |
---|
3558 | marked invalid at a time (i.e. only one bit set in the wim). |
---|
3559 | This makes the maximum possible number of register windows |
---|
3560 | available to the user while still meeting the requirement that |
---|
3561 | window overflow and underflow conditions can be detected. |
---|
3562 | |
---|
3563 | The window overflow and window underflow trap |
---|
3564 | handlers are a critical part of the run-time environment for a |
---|
3565 | SPARC application. The SPARC architectural specification allows |
---|
3566 | for the number of register windows to be any power of two less |
---|
3567 | than or equal to 32. The most common choice for SPARC |
---|
3568 | implementations appears to be 8 register windows. This results |
---|
3569 | in the cwp ranging in value from 0 to 7 on most implementations. |
---|
3570 | |
---|
3571 | The second complicating factor is the sharing of |
---|
3572 | registers between adjacent register windows. While each |
---|
3573 | register window has its own set of local registers, the input |
---|
3574 | and output registers are shared between adjacent windows. The |
---|
3575 | output registers for register window N are the same as the input |
---|
3576 | registers for register window ((N - 1) modulo RW) where RW is |
---|
3577 | the number of register windows. An alternative way to think of |
---|
3578 | this is to remember how parameters are passed to a subroutine on |
---|
3579 | the SPARC. The caller loads values into what are its output |
---|
3580 | registers. Then after the callee executes a save instruction, |
---|
3581 | those parameters are available in its input registers. This is |
---|
3582 | a very efficient way to pass parameters as no data is actually |
---|
3583 | moved by the save or restore instructions. |
---|
3584 | |
---|
3585 | Call and Return Mechanism |
---|
3586 | ------------------------- |
---|
3587 | |
---|
3588 | The SPARC architecture supports a simple yet |
---|
3589 | effective call and return mechanism. A subroutine is invoked |
---|
3590 | via the call (call) instruction. This instruction places the |
---|
3591 | return address in the callerâs output register 7 (o7). After |
---|
3592 | the callee executes a save instruction, this value is available |
---|
3593 | in input register 7 (i7) until the corresponding restore |
---|
3594 | instruction is executed. |
---|
3595 | |
---|
3596 | The callee returns to the caller via a jmp to the |
---|
3597 | return address. There is a delay slot following this |
---|
3598 | instruction which is commonly used to execute a restore |
---|
3599 | instruction â if a register window was allocated by this |
---|
3600 | subroutine. |
---|
3601 | |
---|
3602 | It is important to note that the SPARC subroutine |
---|
3603 | call and return mechanism does not automatically save and |
---|
3604 | restore any registers. This is accomplished via the save and |
---|
3605 | restore instructions which manage the set of registers windows. |
---|
3606 | |
---|
3607 | In case a floating-point unit is supported, then floating-point return values |
---|
3608 | appear in the floating-point registers. Single-precision values occupy %f0; |
---|
3609 | double-precision values occupy %f0 and %f1. Otherwise, these are scratch |
---|
3610 | registers. Due to this the hardware and software floating-point ABIs are |
---|
3611 | incompatible. |
---|
3612 | |
---|
3613 | Calling Mechanism |
---|
3614 | ----------------- |
---|
3615 | |
---|
3616 | All RTEMS directives are invoked using the regular |
---|
3617 | SPARC calling convention via the call instruction. |
---|
3618 | |
---|
3619 | Register Usage |
---|
3620 | -------------- |
---|
3621 | |
---|
3622 | As discussed above, the call instruction does not |
---|
3623 | automatically save any registers. The save and restore |
---|
3624 | instructions are used to allocate and deallocate register |
---|
3625 | windows. When a register window is allocated, the new set of |
---|
3626 | local registers are available for the exclusive use of the |
---|
3627 | subroutine which allocated this register set. |
---|
3628 | |
---|
3629 | Parameter Passing |
---|
3630 | ----------------- |
---|
3631 | |
---|
3632 | RTEMS assumes that arguments are placed in the |
---|
3633 | callerâs output registers with the first argument in output |
---|
3634 | register 0 (o0), the second argument in output register 1 (o1), |
---|
3635 | and so forth. Until the callee executes a save instruction, the |
---|
3636 | parameters are still visible in the output registers. After the |
---|
3637 | callee executes a save instruction, the parameters are visible |
---|
3638 | in the corresponding input registers. The following pseudo-code |
---|
3639 | illustrates the typical sequence used to call a RTEMS directive |
---|
3640 | with three (3) arguments: |
---|
3641 | .. code:: c |
---|
3642 | |
---|
3643 | load third argument into o2 |
---|
3644 | load second argument into o1 |
---|
3645 | load first argument into o0 |
---|
3646 | invoke directive |
---|
3647 | |
---|
3648 | User-Provided Routines |
---|
3649 | ---------------------- |
---|
3650 | |
---|
3651 | All user-provided routines invoked by RTEMS, such as |
---|
3652 | user extensions, device drivers, and MPCI routines, must also |
---|
3653 | adhere to these calling conventions. |
---|
3654 | |
---|
3655 | .. COMMENT: COPYRIGHT (c) 1988-2002. |
---|
3656 | |
---|
3657 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
3658 | |
---|
3659 | .. COMMENT: All rights reserved. |
---|
3660 | |
---|
3661 | Memory Model |
---|
3662 | ============ |
---|
3663 | |
---|
3664 | A processor may support any combination of memory |
---|
3665 | models ranging from pure physical addressing to complex demand |
---|
3666 | paged virtual memory systems. RTEMS supports a flat memory |
---|
3667 | model which ranges contiguously over the processorâs allowable |
---|
3668 | address space. RTEMS does not support segmentation or virtual |
---|
3669 | memory of any kind. The appropriate memory model for RTEMS |
---|
3670 | provided by the targeted processor and related characteristics |
---|
3671 | of that model are described in this chapter. |
---|
3672 | |
---|
3673 | Flat Memory Model |
---|
3674 | ----------------- |
---|
3675 | |
---|
3676 | The SPARC architecture supports a flat 32-bit address |
---|
3677 | space with addresses ranging from 0x00000000 to 0xFFFFFFFF (4 |
---|
3678 | gigabytes). Each address is represented by a 32-bit value and |
---|
3679 | is byte addressable. The address may be used to reference a |
---|
3680 | single byte, half-word (2-bytes), word (4 bytes), or doubleword |
---|
3681 | (8 bytes). Memory accesses within this address space are |
---|
3682 | performed in big endian fashion by the SPARC. Memory accesses |
---|
3683 | which are not properly aligned generate a "memory address not |
---|
3684 | aligned" trap (type number 7). The following table lists the |
---|
3685 | alignment requirements for a variety of data accesses: |
---|
3686 | .. code:: c |
---|
3687 | |
---|
3688 | +--------------+-----------------------+ |
---|
3689 | | Data Type | Alignment Requirement | |
---|
3690 | +--------------+-----------------------+ |
---|
3691 | | byte | 1 | |
---|
3692 | | half-word | 2 | |
---|
3693 | | word | 4 | |
---|
3694 | | doubleword | 8 | |
---|
3695 | +--------------+-----------------------+ |
---|
3696 | |
---|
3697 | Doubleword load and store operations must use a pair |
---|
3698 | of registers as their source or destination. This pair of |
---|
3699 | registers must be an adjacent pair of registers with the first |
---|
3700 | of the pair being even numbered. For example, a valid |
---|
3701 | destination for a doubleword load might be input registers 0 and |
---|
3702 | 1 (i0 and i1). The pair i1 and i2 would be invalid. \[NOTE: |
---|
3703 | Some assemblers for the SPARC do not generate an error if an odd |
---|
3704 | numbered register is specified as the beginning register of the |
---|
3705 | pair. In this case, the assembler assumes that what the |
---|
3706 | programmer meant was to use the even-odd pair which ends at the |
---|
3707 | specified register. This may or may not have been a correct |
---|
3708 | assumption.] |
---|
3709 | |
---|
3710 | RTEMS does not support any SPARC Memory Management |
---|
3711 | Units, therefore, virtual memory or segmentation systems |
---|
3712 | involving the SPARC are not supported. |
---|
3713 | |
---|
3714 | .. COMMENT: COPYRIGHT (c) 1988-2002. |
---|
3715 | |
---|
3716 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
3717 | |
---|
3718 | .. COMMENT: All rights reserved. |
---|
3719 | |
---|
3720 | Interrupt Processing |
---|
3721 | ==================== |
---|
3722 | |
---|
3723 | Different types of processors respond to the |
---|
3724 | occurrence of an interrupt in its own unique fashion. In |
---|
3725 | addition, each processor type provides a control mechanism to |
---|
3726 | allow for the proper handling of an interrupt. The processor |
---|
3727 | dependent response to the interrupt modifies the current |
---|
3728 | execution state and results in a change in the execution stream. |
---|
3729 | Most processors require that an interrupt handler utilize some |
---|
3730 | special control mechanisms to return to the normal processing |
---|
3731 | stream. Although RTEMS hides many of the processor dependent |
---|
3732 | details of interrupt processing, it is important to understand |
---|
3733 | how the RTEMS interrupt manager is mapped onto the processorâs |
---|
3734 | unique architecture. Discussed in this chapter are the SPARCâs |
---|
3735 | interrupt response and control mechanisms as they pertain to |
---|
3736 | RTEMS. |
---|
3737 | |
---|
3738 | RTEMS and associated documentation uses the terms |
---|
3739 | interrupt and vector. In the SPARC architecture, these terms |
---|
3740 | correspond to traps and trap type, respectively. The terms will |
---|
3741 | be used interchangeably in this manual. |
---|
3742 | |
---|
3743 | Synchronous Versus Asynchronous Traps |
---|
3744 | ------------------------------------- |
---|
3745 | |
---|
3746 | The SPARC architecture includes two classes of traps: |
---|
3747 | synchronous and asynchronous. Asynchronous traps occur when an |
---|
3748 | external event interrupts the processor. These traps are not |
---|
3749 | associated with any instruction executed by the processor and |
---|
3750 | logically occur between instructions. The instruction currently |
---|
3751 | in the execute stage of the processor is allowed to complete |
---|
3752 | although subsequent instructions are annulled. The return |
---|
3753 | address reported by the processor for asynchronous traps is the |
---|
3754 | pair of instructions following the current instruction. |
---|
3755 | |
---|
3756 | Synchronous traps are caused by the actions of an |
---|
3757 | instruction. The trap stimulus in this case either occurs |
---|
3758 | internally to the processor or is from an external signal that |
---|
3759 | was provoked by the instruction. These traps are taken |
---|
3760 | immediately and the instruction that caused the trap is aborted |
---|
3761 | before any state changes occur in the processor itself. The |
---|
3762 | return address reported by the processor for synchronous traps |
---|
3763 | is the instruction which caused the trap and the following |
---|
3764 | instruction. |
---|
3765 | |
---|
3766 | Vectoring of Interrupt Handler |
---|
3767 | ------------------------------ |
---|
3768 | |
---|
3769 | Upon receipt of an interrupt the SPARC automatically |
---|
3770 | performs the following actions: |
---|
3771 | |
---|
3772 | - disables traps (sets the ET bit of the psr to 0), |
---|
3773 | |
---|
3774 | - the S bit of the psr is copied into the Previous |
---|
3775 | Supervisor Mode (PS) bit of the psr, |
---|
3776 | |
---|
3777 | - the cwp is decremented by one (modulo the number of |
---|
3778 | register windows) to activate a trap window, |
---|
3779 | |
---|
3780 | - the PC and nPC are loaded into local register 1 and 2 |
---|
3781 | (l0 and l1), |
---|
3782 | |
---|
3783 | - the trap type (tt) field of the Trap Base Register (TBR) |
---|
3784 | is set to the appropriate value, and |
---|
3785 | |
---|
3786 | - if the trap is not a reset, then the PC is written with |
---|
3787 | the contents of the TBR and the nPC is written with TBR + 4. If |
---|
3788 | the trap is a reset, then the PC is set to zero and the nPC is |
---|
3789 | set to 4. |
---|
3790 | |
---|
3791 | Trap processing on the SPARC has two features which |
---|
3792 | are noticeably different than interrupt processing on other |
---|
3793 | architectures. First, the value of psr register in effect |
---|
3794 | immediately before the trap occurred is not explicitly saved. |
---|
3795 | Instead only reversible alterations are made to it. Second, the |
---|
3796 | Processor Interrupt Level (pil) is not set to correspond to that |
---|
3797 | of the interrupt being processed. When a trap occurs, ALL |
---|
3798 | subsequent traps are disabled. In order to safely invoke a |
---|
3799 | subroutine during trap handling, traps must be enabled to allow |
---|
3800 | for the possibility of register window overflow and underflow |
---|
3801 | traps. |
---|
3802 | |
---|
3803 | If the interrupt handler was installed as an RTEMS |
---|
3804 | interrupt handler, then upon receipt of the interrupt, the |
---|
3805 | processor passes control to the RTEMS interrupt handler which |
---|
3806 | performs the following actions: |
---|
3807 | |
---|
3808 | - saves the state of the interrupted task on itâs stack, |
---|
3809 | |
---|
3810 | - insures that a register window is available for |
---|
3811 | subsequent traps, |
---|
3812 | |
---|
3813 | - if this is the outermost (i.e. non-nested) interrupt, |
---|
3814 | then the RTEMS interrupt handler switches from the current stack |
---|
3815 | to the interrupt stack, |
---|
3816 | |
---|
3817 | - enables traps, |
---|
3818 | |
---|
3819 | - invokes the vectors to a user interrupt service routine (ISR). |
---|
3820 | |
---|
3821 | Asynchronous interrupts are ignored while traps are |
---|
3822 | disabled. Synchronous traps which occur while traps are |
---|
3823 | disabled result in the CPU being forced into an error mode. |
---|
3824 | |
---|
3825 | A nested interrupt is processed similarly with the |
---|
3826 | exception that the current stack need not be switched to the |
---|
3827 | interrupt stack. |
---|
3828 | |
---|
3829 | Traps and Register Windows |
---|
3830 | -------------------------- |
---|
3831 | |
---|
3832 | One of the register windows must be reserved at all |
---|
3833 | times for trap processing. This is critical to the proper |
---|
3834 | operation of the trap mechanism in the SPARC architecture. It |
---|
3835 | is the responsibility of the trap handler to insure that there |
---|
3836 | is a register window available for a subsequent trap before |
---|
3837 | re-enabling traps. It is likely that any high level language |
---|
3838 | routines invoked by the trap handler (such as a user-provided |
---|
3839 | RTEMS interrupt handler) will allocate a new register window. |
---|
3840 | The save operation could result in a window overflow trap. This |
---|
3841 | trap cannot be correctly processed unless (1) traps are enabled |
---|
3842 | and (2) a register window is reserved for traps. Thus, the |
---|
3843 | RTEMS interrupt handler insures that a register window is |
---|
3844 | available for subsequent traps before enabling traps and |
---|
3845 | invoking the userâs interrupt handler. |
---|
3846 | |
---|
3847 | Interrupt Levels |
---|
3848 | ---------------- |
---|
3849 | |
---|
3850 | Sixteen levels (0-15) of interrupt priorities are |
---|
3851 | supported by the SPARC architecture with level fifteen (15) |
---|
3852 | being the highest priority. Level zero (0) indicates that |
---|
3853 | interrupts are fully enabled. Interrupt requests for interrupts |
---|
3854 | with priorities less than or equal to the current interrupt mask |
---|
3855 | level are ignored. Level fifteen (15) is a non-maskable interrupt |
---|
3856 | (NMI), which makes it unsuitable for standard usage since it can |
---|
3857 | affect the real-time behaviour by interrupting critical sections |
---|
3858 | and spinlocks. Disabling traps stops also the NMI interrupt from |
---|
3859 | happening. It can however be used for power-down or other |
---|
3860 | critical events. |
---|
3861 | |
---|
3862 | Although RTEMS supports 256 interrupt levels, the |
---|
3863 | SPARC only supports sixteen. RTEMS interrupt levels 0 through |
---|
3864 | 15 directly correspond to SPARC processor interrupt levels. All |
---|
3865 | other RTEMS interrupt levels are undefined and their behavior is |
---|
3866 | unpredictable. |
---|
3867 | |
---|
3868 | Many LEON SPARC v7/v8 systems features an extended interrupt controller |
---|
3869 | which adds an extra step of interrupt decoding to allow handling of |
---|
3870 | interrupt 16-31. When such an extended interrupt is generated the CPU |
---|
3871 | traps into a specific interrupt trap level 1-14 and software reads out from |
---|
3872 | the interrupt controller which extended interrupt source actually caused the |
---|
3873 | interrupt. |
---|
3874 | |
---|
3875 | Disabling of Interrupts by RTEMS |
---|
3876 | -------------------------------- |
---|
3877 | |
---|
3878 | During the execution of directive calls, critical |
---|
3879 | sections of code may be executed. When these sections are |
---|
3880 | encountered, RTEMS disables interrupts to level fifteen (15) |
---|
3881 | before the execution of the section and restores them to the |
---|
3882 | previous level upon completion of the section. RTEMS has been |
---|
3883 | optimized to ensure that interrupts are disabled for less than |
---|
3884 | RTEMS_MAXIMUM_DISABLE_PERIOD microseconds on a RTEMS_MAXIMUM_DISABLE_PERIOD_MHZ |
---|
3885 | Mhz ERC32 with zero wait states. |
---|
3886 | These numbers will vary based the number of wait states and |
---|
3887 | processor speed present on the target board. |
---|
3888 | \[NOTE: The maximum period with interrupts disabled is hand calculated. This |
---|
3889 | calculation was last performed for Release |
---|
3890 | RTEMS_RELEASE_FOR_MAXIMUM_DISABLE_PERIOD.] |
---|
3891 | |
---|
3892 | [NOTE: It is thought that the length of time at which |
---|
3893 | the processor interrupt level is elevated to fifteen by RTEMS is |
---|
3894 | not anywhere near as long as the length of time ALL traps are |
---|
3895 | disabled as part of the "flush all register windows" operation.] |
---|
3896 | |
---|
3897 | Non-maskable interrupts (NMI) cannot be disabled, and |
---|
3898 | ISRs which execute at this level MUST NEVER issue RTEMS system |
---|
3899 | calls. If a directive is invoked, unpredictable results may |
---|
3900 | occur due to the inability of RTEMS to protect its critical |
---|
3901 | sections. However, ISRs that make no system calls may safely |
---|
3902 | execute as non-maskable interrupts. |
---|
3903 | |
---|
3904 | Interrupts are disabled or enabled by performing a system call |
---|
3905 | to the Operating System reserved software traps 9 |
---|
3906 | (SPARC_SWTRAP_IRQDIS) or 10 (SPARC_SWTRAP_IRQDIS). The trap is |
---|
3907 | generated by the software trap (Ticc) instruction or indirectly |
---|
3908 | by calling sparc_disable_interrupts() or sparc_enable_interrupts() |
---|
3909 | functions. Disabling interrupts return the previous interrupt level |
---|
3910 | (on trap entry) in register G1 and sets PSR.PIL to 15 to disable |
---|
3911 | all maskable interrupts. The interrupt level can be restored by |
---|
3912 | trapping into the enable interrupt handler with G1 containing the |
---|
3913 | new interrupt level. |
---|
3914 | |
---|
3915 | Interrupt Stack |
---|
3916 | --------------- |
---|
3917 | |
---|
3918 | The SPARC architecture does not provide for a |
---|
3919 | dedicated interrupt stack. Thus by default, trap handlers would |
---|
3920 | execute on the stack of the RTEMS task which they interrupted. |
---|
3921 | This artificially inflates the stack requirements for each task |
---|
3922 | since EVERY task stack would have to include enough space to |
---|
3923 | account for the worst case interrupt stack requirements in |
---|
3924 | addition to itâs own worst case usage. RTEMS addresses this |
---|
3925 | problem on the SPARC by providing a dedicated interrupt stack |
---|
3926 | managed by software. |
---|
3927 | |
---|
3928 | During system initialization, RTEMS allocates the |
---|
3929 | interrupt stack from the Workspace Area. The amount of memory |
---|
3930 | allocated for the interrupt stack is determined by the |
---|
3931 | interrupt_stack_size field in the CPU Configuration Table. As |
---|
3932 | part of processing a non-nested interrupt, RTEMS will switch to |
---|
3933 | the interrupt stack before invoking the installed handler. |
---|
3934 | |
---|
3935 | .. COMMENT: COPYRIGHT (c) 1988-2002. |
---|
3936 | |
---|
3937 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
3938 | |
---|
3939 | .. COMMENT: All rights reserved. |
---|
3940 | |
---|
3941 | Default Fatal Error Processing |
---|
3942 | ============================== |
---|
3943 | |
---|
3944 | Upon detection of a fatal error by either the |
---|
3945 | application or RTEMS the fatal error manager is invoked. The |
---|
3946 | fatal error manager will invoke the user-supplied fatal error |
---|
3947 | handlers. If no user-supplied handlers are configured, the |
---|
3948 | RTEMS provided default fatal error handler is invoked. If the |
---|
3949 | user-supplied fatal error handlers return to the executive the |
---|
3950 | default fatal error handler is then invoked. This chapter |
---|
3951 | describes the precise operations of the default fatal error |
---|
3952 | handler. |
---|
3953 | |
---|
3954 | Default Fatal Error Handler Operations |
---|
3955 | -------------------------------------- |
---|
3956 | |
---|
3957 | The default fatal error handler which is invoked by |
---|
3958 | the fatal_error_occurred directive when there is no user handler |
---|
3959 | configured or the user handler returns control to RTEMS. |
---|
3960 | |
---|
3961 | If the BSP has been configured with ``BSP_POWER_DOWN_AT_FATAL_HALT`` |
---|
3962 | set to true, the default handler will disable interrupts |
---|
3963 | and enter power down mode. If power down mode is not available, |
---|
3964 | it goes into an infinite loop to simulate a halt processor instruction. |
---|
3965 | |
---|
3966 | If ``BSP_POWER_DOWN_AT_FATAL_HALT`` is set to false, the default |
---|
3967 | handler will place the value ``1`` in register ``g1``, the |
---|
3968 | error source in register ``g2``, and the error code in register``g3``. It will then generate a system error which will |
---|
3969 | hand over control to the debugger, simulator, etc. |
---|
3970 | |
---|
3971 | Symmetric Multiprocessing |
---|
3972 | ========================= |
---|
3973 | |
---|
3974 | SMP is supported. Available platforms are the Cobham Gaisler GR712RC and |
---|
3975 | GR740. |
---|
3976 | |
---|
3977 | Thread-Local Storage |
---|
3978 | ==================== |
---|
3979 | |
---|
3980 | Thread-local storage is supported. |
---|
3981 | |
---|
3982 | .. COMMENT: COPYRIGHT (c) 1988-2002. |
---|
3983 | |
---|
3984 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
3985 | |
---|
3986 | .. COMMENT: All rights reserved. |
---|
3987 | |
---|
3988 | Board Support Packages |
---|
3989 | ====================== |
---|
3990 | |
---|
3991 | An RTEMS Board Support Package (BSP) must be designed |
---|
3992 | to support a particular processor and target board combination. |
---|
3993 | This chapter presents a discussion of SPARC specific BSP issues. |
---|
3994 | For more information on developing a BSP, refer to the chapter |
---|
3995 | titled Board Support Packages in the RTEMS |
---|
3996 | Applications Userâs Guide. |
---|
3997 | |
---|
3998 | System Reset |
---|
3999 | ------------ |
---|
4000 | |
---|
4001 | An RTEMS based application is initiated or |
---|
4002 | re-initiated when the SPARC processor is reset. When the SPARC |
---|
4003 | is reset, the processor performs the following actions: |
---|
4004 | |
---|
4005 | - the enable trap (ET) of the psr is set to 0 to disable |
---|
4006 | traps, |
---|
4007 | |
---|
4008 | - the supervisor bit (S) of the psr is set to 1 to enter |
---|
4009 | supervisor mode, and |
---|
4010 | |
---|
4011 | - the PC is set 0 and the nPC is set to 4. |
---|
4012 | |
---|
4013 | The processor then begins to execute the code at |
---|
4014 | location 0. It is important to note that all fields in the psr |
---|
4015 | are not explicitly set by the above steps and all other |
---|
4016 | registers retain their value from the previous execution mode. |
---|
4017 | This is true even of the Trap Base Register (TBR) whose contents |
---|
4018 | reflect the last trap which occurred before the reset. |
---|
4019 | |
---|
4020 | Processor Initialization |
---|
4021 | ------------------------ |
---|
4022 | |
---|
4023 | It is the responsibility of the applicationâs |
---|
4024 | initialization code to initialize the TBR and install trap |
---|
4025 | handlers for at least the register window overflow and register |
---|
4026 | window underflow conditions. Traps should be enabled before |
---|
4027 | invoking any subroutines to allow for register window |
---|
4028 | management. However, interrupts should be disabled by setting |
---|
4029 | the Processor Interrupt Level (pil) field of the psr to 15. |
---|
4030 | RTEMS installs itâs own Trap Table as part of initialization |
---|
4031 | which is initialized with the contents of the Trap Table in |
---|
4032 | place when the ``rtems_initialize_executive`` directive was invoked. |
---|
4033 | Upon completion of executive initialization, interrupts are |
---|
4034 | enabled. |
---|
4035 | |
---|
4036 | If this SPARC implementation supports on-chip caching |
---|
4037 | and this is to be utilized, then it should be enabled during the |
---|
4038 | reset application initialization code. |
---|
4039 | |
---|
4040 | In addition to the requirements described in the |
---|
4041 | Board Support Packages chapter of the C |
---|
4042 | Applications Users Manual for the reset code |
---|
4043 | which is executed before the call to``rtems_initialize_executive``, the SPARC version has the following |
---|
4044 | specific requirements: |
---|
4045 | |
---|
4046 | - Must leave the S bit of the status register set so that |
---|
4047 | the SPARC remains in the supervisor state. |
---|
4048 | |
---|
4049 | - Must set stack pointer (sp) such that a minimum stack |
---|
4050 | size of MINIMUM_STACK_SIZE bytes is provided for the``rtems_initialize_executive`` directive. |
---|
4051 | |
---|
4052 | - Must disable all external interrupts (i.e. set the pil |
---|
4053 | to 15). |
---|
4054 | |
---|
4055 | - Must enable traps so window overflow and underflow |
---|
4056 | conditions can be properly handled. |
---|
4057 | |
---|
4058 | - Must initialize the SPARCâs initial trap table with at |
---|
4059 | least trap handlers for register window overflow and register |
---|
4060 | window underflow. |
---|
4061 | |
---|
4062 | .. COMMENT: COPYRIGHT (c) 1988-2002. |
---|
4063 | |
---|
4064 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
4065 | |
---|
4066 | .. COMMENT: All rights reserved. |
---|
4067 | |
---|
4068 | SPARC-64 Specific Information |
---|
4069 | ############################# |
---|
4070 | |
---|
4071 | This document discusses the SPARC Version 9 (aka SPARC-64, SPARC64 or SPARC V9) |
---|
4072 | architecture dependencies in this port of RTEMS. |
---|
4073 | |
---|
4074 | The SPARC V9 architecture leaves a lot of undefined implemenation dependencies |
---|
4075 | which are defined by the processor models. Consult the specific CPU model |
---|
4076 | section in this document for additional documents covering the implementation |
---|
4077 | dependent architectural features. |
---|
4078 | |
---|
4079 | **sun4u Specific Information** |
---|
4080 | |
---|
4081 | sun4u is the subset of the SPARC V9 implementations comprising the UltraSPARC I |
---|
4082 | through UltraSPARC IV processors. |
---|
4083 | |
---|
4084 | The following documents were used in developing the SPARC-64 sun4u port: |
---|
4085 | |
---|
4086 | - UltraSPARC UserâÂÂs Manual |
---|
4087 | (http://www.sun.com/microelectronics/manuals/ultrasparc/802-7220-02.pdf) |
---|
4088 | |
---|
4089 | - UltraSPARC IIIi Processor (datasheets.chipdb.org/Sun/UltraSparc-IIIi.pdf) |
---|
4090 | |
---|
4091 | **sun4v Specific Information** |
---|
4092 | |
---|
4093 | sun4v is the subset of the SPARC V9 implementations comprising the |
---|
4094 | UltraSPARC T1 or T2 processors. |
---|
4095 | |
---|
4096 | The following documents were used in developing the SPARC-64 sun4v port: |
---|
4097 | |
---|
4098 | - UltraSPARC Architecture 2005 Specification |
---|
4099 | (http://opensparc-t1.sunsource.net/specs/UA2005-current-draft-P-EXT.pdf) |
---|
4100 | |
---|
4101 | - UltraSPARC T1 supplement to UltraSPARC Architecture 2005 Specification |
---|
4102 | (http://opensparc-t1.sunsource.net/specs/UST1-UASuppl-current-draft-P-EXT.pdf) |
---|
4103 | |
---|
4104 | The defining feature that separates the sun4v architecture from its |
---|
4105 | predecessor is the existence of a super-privileged hypervisor that |
---|
4106 | is responsible for providing virtualized execution environments. The impact |
---|
4107 | of the hypervisor on the real-time guarantees available with sun4v has not |
---|
4108 | yet been determined. |
---|
4109 | |
---|
4110 | CPU Model Dependent Features |
---|
4111 | ============================ |
---|
4112 | |
---|
4113 | CPU Model Feature Flags |
---|
4114 | ----------------------- |
---|
4115 | |
---|
4116 | This section presents the set of features which vary across |
---|
4117 | SPARC-64 implementations and |
---|
4118 | are of importance to RTEMS. The set of CPU model feature macros |
---|
4119 | are defined in the file |
---|
4120 | cpukit/score/cpu/sparc64/sparc64.h based upon the particular |
---|
4121 | CPU model defined on the compilation command line. |
---|
4122 | |
---|
4123 | CPU Model Name |
---|
4124 | ~~~~~~~~~~~~~~ |
---|
4125 | |
---|
4126 | The macro CPU MODEL NAME is a string which designates |
---|
4127 | the name of this CPU model. |
---|
4128 | For example, for the UltraSPARC T1 SPARC V9 model, |
---|
4129 | this macro is set to the string "sun4v". |
---|
4130 | |
---|
4131 | Floating Point Unit |
---|
4132 | ~~~~~~~~~~~~~~~~~~~ |
---|
4133 | |
---|
4134 | The macro SPARC_HAS_FPU is set to 1 to indicate that |
---|
4135 | this CPU model has a hardware floating point unit and 0 |
---|
4136 | otherwise. |
---|
4137 | |
---|
4138 | Number of Register Windows |
---|
4139 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
4140 | |
---|
4141 | The macro SPARC_NUMBER_OF_REGISTER_WINDOWS is set to |
---|
4142 | indicate the number of register window sets implemented by this |
---|
4143 | CPU model. The SPARC architecture allows for a maximum of |
---|
4144 | thirty-two register window sets although most implementations |
---|
4145 | only include eight. |
---|
4146 | |
---|
4147 | CPU Model Implementation Notes |
---|
4148 | ------------------------------ |
---|
4149 | |
---|
4150 | This section describes the implemenation dependencies of the |
---|
4151 | CPU Models sun4u and sun4v of the SPARC V9 architecture. |
---|
4152 | |
---|
4153 | sun4u Notes |
---|
4154 | ~~~~~~~~~~~ |
---|
4155 | |
---|
4156 | XXX |
---|
4157 | |
---|
4158 | sun4v Notes |
---|
4159 | ----------- |
---|
4160 | |
---|
4161 | XXX |
---|
4162 | |
---|
4163 | .. COMMENT: COPYRIGHT (c) 1988-2002. |
---|
4164 | |
---|
4165 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
4166 | |
---|
4167 | .. COMMENT: All rights reserved. |
---|
4168 | |
---|
4169 | Calling Conventions |
---|
4170 | =================== |
---|
4171 | |
---|
4172 | Each high-level language compiler generates |
---|
4173 | subroutine entry and exit code based upon a set of rules known |
---|
4174 | as the compilerâs calling convention. These rules address the |
---|
4175 | following issues: |
---|
4176 | |
---|
4177 | - register preservation and usage |
---|
4178 | |
---|
4179 | - parameter passing |
---|
4180 | |
---|
4181 | - call and return mechanism |
---|
4182 | |
---|
4183 | A compilerâs calling convention is of importance when |
---|
4184 | interfacing to subroutines written in another language either |
---|
4185 | assembly or high-level. Even when the high-level language and |
---|
4186 | target processor are the same, different compilers may use |
---|
4187 | different calling conventions. As a result, calling conventions |
---|
4188 | are both processor and compiler dependent. |
---|
4189 | |
---|
4190 | The following document also provides some conventions on the |
---|
4191 | global register usage in SPARC V9: |
---|
4192 | http://developers.sun.com/solaris/articles/sparcv9abi.html |
---|
4193 | |
---|
4194 | Programming Model |
---|
4195 | ----------------- |
---|
4196 | |
---|
4197 | This section discusses the programming model for the |
---|
4198 | SPARC architecture. |
---|
4199 | |
---|
4200 | Non-Floating Point Registers |
---|
4201 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
4202 | |
---|
4203 | The SPARC architecture defines thirty-two |
---|
4204 | non-floating point registers directly visible to the programmer. |
---|
4205 | These are divided into four sets: |
---|
4206 | |
---|
4207 | - input registers |
---|
4208 | |
---|
4209 | - local registers |
---|
4210 | |
---|
4211 | - output registers |
---|
4212 | |
---|
4213 | - global registers |
---|
4214 | |
---|
4215 | Each register is referred to by either two or three |
---|
4216 | names in the SPARC reference manuals. First, the registers are |
---|
4217 | referred to as r0 through r31 or with the alternate notation |
---|
4218 | r[0] through r[31]. Second, each register is a member of one of |
---|
4219 | the four sets listed above. Finally, some registers have an |
---|
4220 | architecturally defined role in the programming model which |
---|
4221 | provides an alternate name. The following table describes the |
---|
4222 | mapping between the 32 registers and the register sets: |
---|
4223 | .. code:: c |
---|
4224 | |
---|
4225 | +-----------------+----------------+------------------+ |
---|
4226 | | Register Number | Register Names | Description | |
---|
4227 | +-----------------+----------------+------------------+ |
---|
4228 | | 0 - 7 | g0 - g7 | Global Registers | |
---|
4229 | +-----------------+----------------+------------------+ |
---|
4230 | | 8 - 15 | o0 - o7 | Output Registers | |
---|
4231 | +-----------------+----------------+------------------+ |
---|
4232 | | 16 - 23 | l0 - l7 | Local Registers | |
---|
4233 | +-----------------+----------------+------------------+ |
---|
4234 | | 24 - 31 | i0 - i7 | Input Registers | |
---|
4235 | +-----------------+----------------+------------------+ |
---|
4236 | |
---|
4237 | As mentioned above, some of the registers serve |
---|
4238 | defined roles in the programming model. The following table |
---|
4239 | describes the role of each of these registers: |
---|
4240 | .. code:: c |
---|
4241 | |
---|
4242 | +---------------+----------------+----------------------+ |
---|
4243 | | Register Name | Alternate Name | Description | |
---|
4244 | +---------------+----------------+----------------------+ |
---|
4245 | | g0 | na | reads return 0 | |
---|
4246 | | | | writes are ignored | |
---|
4247 | +---------------+----------------+----------------------+ |
---|
4248 | | o6 | sp | stack pointer | |
---|
4249 | +---------------+----------------+----------------------+ |
---|
4250 | | i6 | fp | frame pointer | |
---|
4251 | +---------------+----------------+----------------------+ |
---|
4252 | | i7 | na | return address | |
---|
4253 | +---------------+----------------+----------------------+ |
---|
4254 | |
---|
4255 | Floating Point Registers |
---|
4256 | ~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
4257 | |
---|
4258 | The SPARC V9 architecture includes sixty-four, |
---|
4259 | thirty-two bit registers. These registers may be viewed as |
---|
4260 | follows: |
---|
4261 | |
---|
4262 | - 32 32-bit single precision floating point or integer registers |
---|
4263 | (f0, f1, ... f31) |
---|
4264 | |
---|
4265 | - 32 64-bit double precision floating point registers (f0, f2, |
---|
4266 | f4, ... f62) |
---|
4267 | |
---|
4268 | - 16 128-bit extended precision floating point registers (f0, f4, |
---|
4269 | f8, ... f60) |
---|
4270 | |
---|
4271 | The floating point state register (fsr) specifies |
---|
4272 | the behavior of the floating point unit for rounding, contains |
---|
4273 | its condition codes, version specification, and trap information. |
---|
4274 | |
---|
4275 | Special Registers |
---|
4276 | ~~~~~~~~~~~~~~~~~ |
---|
4277 | |
---|
4278 | The SPARC architecture includes a number of special registers: |
---|
4279 | |
---|
4280 | *``Ancillary State Registers (ASRs)``* |
---|
4281 | The ancillary state registers (ASRs) are optional state registers that |
---|
4282 | may be privileged or nonprivileged. ASRs 16-31 are implementation- |
---|
4283 | dependent. The SPARC V9 ASRs include: y, ccr, asi, tick, pc, fprs. |
---|
4284 | The sun4u ASRs include: pcr, pic, dcr, gsr, softint set, softint clr, |
---|
4285 | softint, and tick cmpr. The sun4v ASRs include: pcr, pic, gsr, soft- |
---|
4286 | int set, softint clr, softint, tick cmpr, stick, and stick cmpr. |
---|
4287 | |
---|
4288 | *``Processor State Register (pstate)``* |
---|
4289 | The privileged pstate register contains control fields for the proces- |
---|
4290 | sorâÂÂs current state. Its flag fields include the interrupt enable, privi- |
---|
4291 | leged mode, and enable FPU. |
---|
4292 | |
---|
4293 | *``Processor Interrupt Level (pil)``* |
---|
4294 | The PIL specifies the interrupt level above which interrupts will be |
---|
4295 | accepted. |
---|
4296 | |
---|
4297 | *``Trap Registers``* |
---|
4298 | The trap handling mechanism of the SPARC V9 includes a number of |
---|
4299 | registers, including: trap program counter (tpc), trap next pc (tnpc), |
---|
4300 | trap state (tstate), trap type (tt), trap base address (tba), and trap |
---|
4301 | level (tl). |
---|
4302 | |
---|
4303 | *``Alternate Globals``* |
---|
4304 | The AG bit of the pstate register provides access to an alternate set |
---|
4305 | of global registers. On sun4v, the AG bit is replaced by the global |
---|
4306 | level (gl) register, providing access to at least two and at most eight |
---|
4307 | alternate sets of globals. |
---|
4308 | |
---|
4309 | *``Register Window registers``* |
---|
4310 | A number of registers assist in register window management. |
---|
4311 | These include the current window pointer (cwp), savable windows |
---|
4312 | (cansave), restorable windows (canrestore), clean windows (clean- |
---|
4313 | win), other windows (otherwin), and window state (wstate). |
---|
4314 | |
---|
4315 | Register Windows |
---|
4316 | ---------------- |
---|
4317 | |
---|
4318 | The SPARC architecture includes the concept of |
---|
4319 | register windows. An overly simplistic way to think of these |
---|
4320 | windows is to imagine them as being an infinite supply of |
---|
4321 | "fresh" register sets available for each subroutine to use. In |
---|
4322 | reality, they are much more complicated. |
---|
4323 | |
---|
4324 | The save instruction is used to obtain a new register window. |
---|
4325 | This instruction increments the current window pointer, thus |
---|
4326 | providing a new set of registers for use. This register set |
---|
4327 | includes eight fresh local registers for use exclusively by |
---|
4328 | this subroutine. When done with a register set, the restore |
---|
4329 | instruction decrements the current window pointer and the |
---|
4330 | previous register set is once again available. |
---|
4331 | |
---|
4332 | The two primary issues complicating the use of register windows |
---|
4333 | are that (1) the set of register windows is finite, and (2) some |
---|
4334 | registers are shared between adjacent registers windows. |
---|
4335 | |
---|
4336 | Because the set of register windows is finite, it is |
---|
4337 | possible to execute enough save instructions without |
---|
4338 | corresponding restoreâs to consume all of the register windows. |
---|
4339 | This is easily accomplished in a high level language because |
---|
4340 | each subroutine typically performs a save instruction upon |
---|
4341 | entry. Thus having a subroutine call depth greater than the |
---|
4342 | number of register windows will result in a window overflow |
---|
4343 | condition. The window overflow condition generates a trap which |
---|
4344 | must be handled in software. The window overflow trap handler |
---|
4345 | is responsible for saving the contents of the oldest register |
---|
4346 | window on the program stack. |
---|
4347 | |
---|
4348 | Similarly, the subroutines will eventually complete |
---|
4349 | and begin to perform restoreâs. If the restore results in the |
---|
4350 | need for a register window which has previously been written to |
---|
4351 | memory as part of an overflow, then a window underflow condition |
---|
4352 | results. Just like the window overflow, the window underflow |
---|
4353 | condition must be handled in software by a trap handler. The |
---|
4354 | window underflow trap handler is responsible for reloading the |
---|
4355 | contents of the register window requested by the restore |
---|
4356 | instruction from the program stack. |
---|
4357 | |
---|
4358 | The cansave, canrestore, otherwin, and cwp are used in conjunction |
---|
4359 | to manage the finite set of register windows and detect the window |
---|
4360 | overflow and underflow conditions. The first three of these |
---|
4361 | registers must satisfy the invariant cansave + canrestore + otherwin = |
---|
4362 | nwindow - 2, where nwindow is the number of register windows. |
---|
4363 | The cwp contains the index of the register window currently in use. |
---|
4364 | RTEMS does not use the cleanwin and otherwin registers. |
---|
4365 | |
---|
4366 | The save instruction increments the cwp modulo the number of |
---|
4367 | register windows, and if cansave is 0 then it also generates a |
---|
4368 | window overflow. Similarly, the restore instruction decrements the |
---|
4369 | cwp modulo the number of register windows, and if canrestore is 0 then it |
---|
4370 | also generates a window underflow. |
---|
4371 | |
---|
4372 | Unlike with the SPARC model, the SPARC-64 port does not assume that |
---|
4373 | a register window is available for a trap. The window overflow |
---|
4374 | and underflow conditions are not detected without hardware generating |
---|
4375 | the trap. (These conditions can be detected by reading the register window |
---|
4376 | registers and doing some simple arithmetic.) |
---|
4377 | |
---|
4378 | The window overflow and window underflow trap |
---|
4379 | handlers are a critical part of the run-time environment for a |
---|
4380 | SPARC application. The SPARC architectural specification allows |
---|
4381 | for the number of register windows to be any power of two less |
---|
4382 | than or equal to 32. The most common choice for SPARC |
---|
4383 | implementations appears to be 8 register windows. This results |
---|
4384 | in the cwp ranging in value from 0 to 7 on most implementations. |
---|
4385 | |
---|
4386 | The second complicating factor is the sharing of |
---|
4387 | registers between adjacent register windows. While each |
---|
4388 | register window has its own set of local registers, the input |
---|
4389 | and output registers are shared between adjacent windows. The |
---|
4390 | output registers for register window N are the same as the input |
---|
4391 | registers for register window ((N + 1) modulo RW) where RW is |
---|
4392 | the number of register windows. An alternative way to think of |
---|
4393 | this is to remember how parameters are passed to a subroutine on |
---|
4394 | the SPARC. The caller loads values into what are its output |
---|
4395 | registers. Then after the callee executes a save instruction, |
---|
4396 | those parameters are available in its input registers. This is |
---|
4397 | a very efficient way to pass parameters as no data is actually |
---|
4398 | moved by the save or restore instructions. |
---|
4399 | |
---|
4400 | Call and Return Mechanism |
---|
4401 | ------------------------- |
---|
4402 | |
---|
4403 | The SPARC architecture supports a simple yet |
---|
4404 | effective call and return mechanism. A subroutine is invoked |
---|
4405 | via the call (call) instruction. This instruction places the |
---|
4406 | return address in the callerâs output register 7 (o7). After |
---|
4407 | the callee executes a save instruction, this value is available |
---|
4408 | in input register 7 (i7) until the corresponding restore |
---|
4409 | instruction is executed. |
---|
4410 | |
---|
4411 | The callee returns to the caller via a jmp to the |
---|
4412 | return address. There is a delay slot following this |
---|
4413 | instruction which is commonly used to execute a restore |
---|
4414 | instruction â if a register window was allocated by this |
---|
4415 | subroutine. |
---|
4416 | |
---|
4417 | It is important to note that the SPARC subroutine |
---|
4418 | call and return mechanism does not automatically save and |
---|
4419 | restore any registers. This is accomplished via the save and |
---|
4420 | restore instructions which manage the set of registers windows. |
---|
4421 | This allows for the compiler to generate leaf-optimized functions |
---|
4422 | that utilize the callerâÂÂs output registers without using save and restore. |
---|
4423 | |
---|
4424 | Calling Mechanism |
---|
4425 | ----------------- |
---|
4426 | |
---|
4427 | All RTEMS directives are invoked using the regular |
---|
4428 | SPARC calling convention via the call instruction. |
---|
4429 | |
---|
4430 | Register Usage |
---|
4431 | -------------- |
---|
4432 | |
---|
4433 | As discussed above, the call instruction does not |
---|
4434 | automatically save any registers. The save and restore |
---|
4435 | instructions are used to allocate and deallocate register |
---|
4436 | windows. When a register window is allocated, the new set of |
---|
4437 | local registers are available for the exclusive use of the |
---|
4438 | subroutine which allocated this register set. |
---|
4439 | |
---|
4440 | Parameter Passing |
---|
4441 | ----------------- |
---|
4442 | |
---|
4443 | RTEMS assumes that arguments are placed in the |
---|
4444 | callerâs output registers with the first argument in output |
---|
4445 | register 0 (o0), the second argument in output register 1 (o1), |
---|
4446 | and so forth. Until the callee executes a save instruction, the |
---|
4447 | parameters are still visible in the output registers. After the |
---|
4448 | callee executes a save instruction, the parameters are visible |
---|
4449 | in the corresponding input registers. The following pseudo-code |
---|
4450 | illustrates the typical sequence used to call a RTEMS directive |
---|
4451 | with three (3) arguments: |
---|
4452 | .. code:: c |
---|
4453 | |
---|
4454 | load third argument into o2 |
---|
4455 | load second argument into o1 |
---|
4456 | load first argument into o0 |
---|
4457 | invoke directive |
---|
4458 | |
---|
4459 | User-Provided Routines |
---|
4460 | ---------------------- |
---|
4461 | |
---|
4462 | All user-provided routines invoked by RTEMS, such as |
---|
4463 | user extensions, device drivers, and MPCI routines, must also |
---|
4464 | adhere to these calling conventions. |
---|
4465 | |
---|
4466 | .. COMMENT: COPYRIGHT (c) 1988-2002. |
---|
4467 | |
---|
4468 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
4469 | |
---|
4470 | .. COMMENT: All rights reserved. |
---|
4471 | |
---|
4472 | Memory Model |
---|
4473 | ============ |
---|
4474 | |
---|
4475 | A processor may support any combination of memory |
---|
4476 | models ranging from pure physical addressing to complex demand |
---|
4477 | paged virtual memory systems. RTEMS supports a flat memory |
---|
4478 | model which ranges contiguously over the processorâs allowable |
---|
4479 | address space. RTEMS does not support segmentation or virtual |
---|
4480 | memory of any kind. The appropriate memory model for RTEMS |
---|
4481 | provided by the targeted processor and related characteristics |
---|
4482 | of that model are described in this chapter. |
---|
4483 | |
---|
4484 | Flat Memory Model |
---|
4485 | ----------------- |
---|
4486 | |
---|
4487 | The SPARC-64 architecture supports a flat 64-bit address space with |
---|
4488 | addresses ranging from 0x0000000000000000 to 0xFFFFFFFFFFFFFFFF. |
---|
4489 | Each address is represented by a 64-bit value (and an 8-bit address |
---|
4490 | space identifider or ASI) and is byte addressable. The address |
---|
4491 | may be used to reference a single byte, half-word (2-bytes), |
---|
4492 | word (4 bytes), doubleword (8 bytes), or quad-word (16 bytes). |
---|
4493 | Memory accesses within this address space are performed |
---|
4494 | in big endian fashion by the SPARC. Memory accesses which are not |
---|
4495 | properly aligned generate a "memory address not aligned" trap |
---|
4496 | (type number 0x34). The following table lists the alignment |
---|
4497 | requirements for a variety of data accesses: |
---|
4498 | .. code:: c |
---|
4499 | |
---|
4500 | +--------------+-----------------------+ |
---|
4501 | | Data Type | Alignment Requirement | |
---|
4502 | +--------------+-----------------------+ |
---|
4503 | | byte | 1 | |
---|
4504 | | half-word | 2 | |
---|
4505 | | word | 4 | |
---|
4506 | | doubleword | 8 | |
---|
4507 | | quadword | 16 | |
---|
4508 | +--------------+-----------------------+ |
---|
4509 | |
---|
4510 | RTEMS currently does not support any SPARC Memory Management |
---|
4511 | Units, therefore, virtual memory or segmentation systems |
---|
4512 | involving the SPARC are not supported. |
---|
4513 | |
---|
4514 | .. COMMENT: COPYRIGHT (c) 1988-2002. |
---|
4515 | |
---|
4516 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
4517 | |
---|
4518 | .. COMMENT: All rights reserved. |
---|
4519 | |
---|
4520 | Interrupt Processing |
---|
4521 | ==================== |
---|
4522 | |
---|
4523 | RTEMS and associated documentation uses the terms |
---|
4524 | interrupt and vector. In the SPARC architecture, these terms |
---|
4525 | correspond to traps and trap type, respectively. The terms will |
---|
4526 | be used interchangeably in this manual. Note that in the SPARC manuals, |
---|
4527 | interrupts are a subset of the traps that are delivered to software |
---|
4528 | interrupt handlers. |
---|
4529 | |
---|
4530 | Synchronous Versus Asynchronous Traps |
---|
4531 | ------------------------------------- |
---|
4532 | |
---|
4533 | The SPARC architecture includes two classes of traps: |
---|
4534 | synchronous (precise) and asynchronous (deferred). |
---|
4535 | Asynchronous traps occur when an |
---|
4536 | external event interrupts the processor. These traps are not |
---|
4537 | associated with any instruction executed by the processor and |
---|
4538 | logically occur between instructions. The instruction currently |
---|
4539 | in the execute stage of the processor is allowed to complete |
---|
4540 | although subsequent instructions are annulled. The return |
---|
4541 | address reported by the processor for asynchronous traps is the |
---|
4542 | pair of instructions following the current instruction. |
---|
4543 | |
---|
4544 | Synchronous traps are caused by the actions of an |
---|
4545 | instruction. The trap stimulus in this case either occurs |
---|
4546 | internally to the processor or is from an external signal that |
---|
4547 | was provoked by the instruction. These traps are taken |
---|
4548 | immediately and the instruction that caused the trap is aborted |
---|
4549 | before any state changes occur in the processor itself. The |
---|
4550 | return address reported by the processor for synchronous traps |
---|
4551 | is the instruction which caused the trap and the following |
---|
4552 | instruction. |
---|
4553 | |
---|
4554 | Vectoring of Interrupt Handler |
---|
4555 | ------------------------------ |
---|
4556 | |
---|
4557 | Upon receipt of an interrupt the SPARC automatically |
---|
4558 | performs the following actions: |
---|
4559 | |
---|
4560 | - The trap level is set. This provides access to a fresh set of |
---|
4561 | privileged trap-state registers used to save the current state, |
---|
4562 | in effect, pushing a frame on the trap stack. |
---|
4563 | TL <- TL + 1 |
---|
4564 | |
---|
4565 | - Existing state is preserved |
---|
4566 | - TSTATE[TL].CCR <- CCR |
---|
4567 | - TSTATE[TL].ASI <- ASI |
---|
4568 | - TSTATE[TL].PSTATE <- PSTATE |
---|
4569 | - TSTATE[TL].CWP <- CWP |
---|
4570 | - TPC[TL] <- PC |
---|
4571 | - TNPC[TL] <- nPC |
---|
4572 | |
---|
4573 | - The trap type is preserved. TT[TL] <- the trap type |
---|
4574 | |
---|
4575 | - The PSTATE register is updated to a predefined state |
---|
4576 | - PSTATE.MM is unchanged |
---|
4577 | - PSTATE.RED <- 0 |
---|
4578 | - PSTATE.PEF <- 1 if FPU is present, 0 otherwise |
---|
4579 | - PSTATE.AM <- 0 (address masking is turned off) |
---|
4580 | - PSTATE.PRIV <- 1 (the processor enters privileged mode) |
---|
4581 | - PSTATE.IE <- 0 (interrupts are disabled) |
---|
4582 | - PSTATE.AG <- 1 (global regs are replaced with alternate globals) |
---|
4583 | - PSTATE.CLE <- PSTATE.TLE (set endian mode for traps) |
---|
4584 | |
---|
4585 | - For a register-window trap only, CWP is set to point to the register |
---|
4586 | window that must be accessed by the trap-handler software, that is: |
---|
4587 | - If TT[TL] = 0x24 (a clean window trap), then CWP <- CWP + 1. |
---|
4588 | - If (0x80 <= TT[TL] <= 0xBF) (window spill trap), then CWP <- CWP + |
---|
4589 | CANSAVE + 2. |
---|
4590 | - If (0xC0 <= TT[TL] <= 0xFF) (window fill trap), then CWP <- CWP1. |
---|
4591 | - For non-register-window traps, CWP is not changed. |
---|
4592 | |
---|
4593 | - Control is transferred into the trap table: |
---|
4594 | - PC <- TBA<63:15> (TL>0) TT[TL] 0 0000 |
---|
4595 | - nPC <- TBA<63:15> (TL>0) TT[TL] 0 0100 |
---|
4596 | - where (TL>0) is 0 if TL = 0, and 1 if TL > 0. |
---|
4597 | |
---|
4598 | In order to safely invoke a subroutine during trap handling, traps must be |
---|
4599 | enabled to allow for the possibility of register window overflow and |
---|
4600 | underflow traps. |
---|
4601 | |
---|
4602 | If the interrupt handler was installed as an RTEMS |
---|
4603 | interrupt handler, then upon receipt of the interrupt, the |
---|
4604 | processor passes control to the RTEMS interrupt handler which |
---|
4605 | performs the following actions: |
---|
4606 | |
---|
4607 | - saves the state of the interrupted task on itâs stack, |
---|
4608 | |
---|
4609 | - switches the processor to trap level 0, |
---|
4610 | |
---|
4611 | - if this is the outermost (i.e. non-nested) interrupt, |
---|
4612 | then the RTEMS interrupt handler switches from the current stack |
---|
4613 | to the interrupt stack, |
---|
4614 | |
---|
4615 | - enables traps, |
---|
4616 | |
---|
4617 | - invokes the vectors to a user interrupt service routine (ISR). |
---|
4618 | |
---|
4619 | Asynchronous interrupts are ignored while traps are |
---|
4620 | disabled. Synchronous traps which occur while traps are |
---|
4621 | disabled may result in the CPU being forced into an error mode. |
---|
4622 | |
---|
4623 | A nested interrupt is processed similarly with the |
---|
4624 | exception that the current stack need not be switched to the |
---|
4625 | interrupt stack. |
---|
4626 | |
---|
4627 | Traps and Register Windows |
---|
4628 | -------------------------- |
---|
4629 | |
---|
4630 | XXX |
---|
4631 | |
---|
4632 | Interrupt Levels |
---|
4633 | ---------------- |
---|
4634 | |
---|
4635 | Sixteen levels (0-15) of interrupt priorities are |
---|
4636 | supported by the SPARC architecture with level fifteen (15) |
---|
4637 | being the highest priority. Level zero (0) indicates that |
---|
4638 | interrupts are fully enabled. Interrupt requests for interrupts |
---|
4639 | with priorities less than or equal to the current interrupt mask |
---|
4640 | level are ignored. |
---|
4641 | |
---|
4642 | Although RTEMS supports 256 interrupt levels, the |
---|
4643 | SPARC only supports sixteen. RTEMS interrupt levels 0 through |
---|
4644 | 15 directly correspond to SPARC processor interrupt levels. All |
---|
4645 | other RTEMS interrupt levels are undefined and their behavior is |
---|
4646 | unpredictable. |
---|
4647 | |
---|
4648 | Disabling of Interrupts by RTEMS |
---|
4649 | -------------------------------- |
---|
4650 | |
---|
4651 | XXX |
---|
4652 | |
---|
4653 | Interrupt Stack |
---|
4654 | --------------- |
---|
4655 | |
---|
4656 | The SPARC architecture does not provide for a |
---|
4657 | dedicated interrupt stack. Thus by default, trap handlers would |
---|
4658 | execute on the stack of the RTEMS task which they interrupted. |
---|
4659 | This artificially inflates the stack requirements for each task |
---|
4660 | since EVERY task stack would have to include enough space to |
---|
4661 | account for the worst case interrupt stack requirements in |
---|
4662 | addition to itâs own worst case usage. RTEMS addresses this |
---|
4663 | problem on the SPARC by providing a dedicated interrupt stack |
---|
4664 | managed by software. |
---|
4665 | |
---|
4666 | During system initialization, RTEMS allocates the |
---|
4667 | interrupt stack from the Workspace Area. The amount of memory |
---|
4668 | allocated for the interrupt stack is determined by the |
---|
4669 | interrupt_stack_size field in the CPU Configuration Table. As |
---|
4670 | part of processing a non-nested interrupt, RTEMS will switch to |
---|
4671 | the interrupt stack before invoking the installed handler. |
---|
4672 | |
---|
4673 | .. COMMENT: COPYRIGHT (c) 1988-2002. |
---|
4674 | |
---|
4675 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
4676 | |
---|
4677 | .. COMMENT: All rights reserved. |
---|
4678 | |
---|
4679 | Default Fatal Error Processing |
---|
4680 | ============================== |
---|
4681 | |
---|
4682 | Upon detection of a fatal error by either the |
---|
4683 | application or RTEMS the fatal error manager is invoked. The |
---|
4684 | fatal error manager will invoke the user-supplied fatal error |
---|
4685 | handlers. If no user-supplied handlers are configured, the |
---|
4686 | RTEMS provided default fatal error handler is invoked. If the |
---|
4687 | user-supplied fatal error handlers return to the executive the |
---|
4688 | default fatal error handler is then invoked. This chapter |
---|
4689 | describes the precise operations of the default fatal error |
---|
4690 | handler. |
---|
4691 | |
---|
4692 | Default Fatal Error Handler Operations |
---|
4693 | -------------------------------------- |
---|
4694 | |
---|
4695 | The default fatal error handler which is invoked by |
---|
4696 | the fatal_error_occurred directive when there is no user handler |
---|
4697 | configured or the user handler returns control to RTEMS. The |
---|
4698 | default fatal error handler disables processor interrupts to |
---|
4699 | level 15, places the error code in g1, and goes into an infinite |
---|
4700 | loop to simulate a halt processor instruction. |
---|
4701 | |
---|
4702 | Symmetric Multiprocessing |
---|
4703 | ========================= |
---|
4704 | |
---|
4705 | SMP is not supported. |
---|
4706 | |
---|
4707 | Thread-Local Storage |
---|
4708 | ==================== |
---|
4709 | |
---|
4710 | Thread-local storage is supported. |
---|
4711 | |
---|
4712 | .. COMMENT: COPYRIGHT (c) 1988-2002. |
---|
4713 | |
---|
4714 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
4715 | |
---|
4716 | .. COMMENT: All rights reserved. |
---|
4717 | |
---|
4718 | Board Support Packages |
---|
4719 | ====================== |
---|
4720 | |
---|
4721 | An RTEMS Board Support Package (BSP) must be designed |
---|
4722 | to support a particular processor and target board combination. |
---|
4723 | This chapter presents a discussion of SPARC specific BSP issues. |
---|
4724 | For more information on developing a BSP, refer to the chapter |
---|
4725 | titled Board Support Packages in the RTEMS |
---|
4726 | Applications Userâs Guide. |
---|
4727 | |
---|
4728 | HelenOS and Open Firmware |
---|
4729 | ------------------------- |
---|
4730 | |
---|
4731 | The provided BSPs make use of some bootstrap and low-level hardware code |
---|
4732 | of the HelenOS operating system. These files can be found in the shared/helenos |
---|
4733 | directory of the sparc64 bsp directory. Consult the sources for more |
---|
4734 | detailed information. |
---|
4735 | |
---|
4736 | The shared BSP code also uses the Open Firmware interface to re-use firmware |
---|
4737 | code, primarily for console support and default trap handlers. |
---|
4738 | |
---|
4739 | Command and Variable Index |
---|
4740 | ########################## |
---|
4741 | |
---|
4742 | There are currently no Command and Variable Index entries. |
---|
4743 | |
---|
4744 | .. COMMENT: @printindex fn |
---|
4745 | |
---|
4746 | Concept Index |
---|
4747 | ############# |
---|
4748 | |
---|
4749 | There are currently no Concept Index entries. |
---|
4750 | |
---|
4751 | .. COMMENT: @printindex cp |
---|