source: rtems/doc/cpu_supplement/i386.t @ 83fb86f

4.104.114.84.95
Last change on this file since 83fb86f was 83fb86f, checked in by Joel Sherrill <joel.sherrill@…>, on 08/23/06 at 19:11:14

2006-08-23 Joel Sherrill <joel@…>

  • Makefile.am, configure.ac, FAQ/stamp-vti, FAQ/version.texi, common/cpright.texi: Merging CPU Supplements into a single document. As part of this removed the obsolete and impossible to maintain size and timing information.
  • cpu_supplement/.cvsignore, cpu_supplement/Makefile.am, cpu_supplement/arm.t, cpu_supplement/i386.t, cpu_supplement/m68k.t, cpu_supplement/mips.t, cpu_supplement/powerpc.t, cpu_supplement/preface.texi, cpu_supplement/sh.t, cpu_supplement/sparc.t, cpu_supplement/tic4x.t: New files.
  • supplements/.cvsignore, supplements/Makefile.am, supplements/supplement.am, supplements/arm/.cvsignore, supplements/arm/BSP_TIMES, supplements/arm/ChangeLog, supplements/arm/Makefile.am, supplements/arm/arm.texi, supplements/arm/bsp.t, supplements/arm/callconv.t, supplements/arm/cpumodel.t, supplements/arm/cputable.t, supplements/arm/fatalerr.t, supplements/arm/intr_NOTIMES.t, supplements/arm/memmodel.t, supplements/arm/preface.texi, supplements/arm/timeBSP.t, supplements/c4x/.cvsignore, supplements/c4x/BSP_TIMES, supplements/c4x/ChangeLog, supplements/c4x/Makefile.am, supplements/c4x/bsp.t, supplements/c4x/c4x.texi, supplements/c4x/callconv.t, supplements/c4x/cpumodel.t, supplements/c4x/cputable.t, supplements/c4x/fatalerr.t, supplements/c4x/intr_NOTIMES.t, supplements/c4x/memmodel.t, supplements/c4x/preface.texi, supplements/c4x/timeBSP.t, supplements/i386/.cvsignore, supplements/i386/ChangeLog, supplements/i386/FORCE386_TIMES, supplements/i386/Makefile.am, supplements/i386/bsp.t, supplements/i386/callconv.t, supplements/i386/cpumodel.t, supplements/i386/cputable.t, supplements/i386/fatalerr.t, supplements/i386/i386.texi, supplements/i386/intr_NOTIMES.t, supplements/i386/memmodel.t, supplements/i386/preface.texi, supplements/i386/timeFORCE386.t, supplements/m68k/.cvsignore, supplements/m68k/ChangeLog, supplements/m68k/MVME136_TIMES, supplements/m68k/Makefile.am, supplements/m68k/bsp.t, supplements/m68k/callconv.t, supplements/m68k/cpumodel.t, supplements/m68k/cputable.t, supplements/m68k/fatalerr.t, supplements/m68k/intr_NOTIMES.t, supplements/m68k/m68k.texi, supplements/m68k/memmodel.t, supplements/m68k/preface.texi, supplements/m68k/timeMVME136.t, supplements/m68k/timedata.t, supplements/mips/.cvsignore, supplements/mips/BSP_TIMES, supplements/mips/ChangeLog, supplements/mips/Makefile.am, supplements/mips/bsp.t, supplements/mips/callconv.t, supplements/mips/cpumodel.t, supplements/mips/cputable.t, supplements/mips/fatalerr.t, supplements/mips/intr_NOTIMES.t, supplements/mips/memmodel.t, supplements/mips/mips.texi, supplements/mips/preface.texi, supplements/mips/timeBSP.t, supplements/powerpc/.cvsignore, supplements/powerpc/ChangeLog, supplements/powerpc/DMV177_TIMES, supplements/powerpc/Makefile.am, supplements/powerpc/PSIM_TIMES, supplements/powerpc/bsp.t, supplements/powerpc/callconv.t, supplements/powerpc/cpumodel.t, supplements/powerpc/cputable.t, supplements/powerpc/fatalerr.t, supplements/powerpc/intr_NOTIMES.t, supplements/powerpc/memmodel.t, supplements/powerpc/powerpc.texi, supplements/powerpc/preface.texi, supplements/powerpc/timeDMV177.t, supplements/powerpc/timePSIM.t, supplements/sh/.cvsignore, supplements/sh/BSP_TIMES, supplements/sh/ChangeLog, supplements/sh/Makefile.am, supplements/sh/bsp.t, supplements/sh/callconv.t, supplements/sh/cpumodel.t, supplements/sh/cputable.t, supplements/sh/fatalerr.t, supplements/sh/intr_NOTIMES.t, supplements/sh/memmodel.t, supplements/sh/preface.texi, supplements/sh/sh.texi, supplements/sh/timeBSP.t, supplements/sparc/.cvsignore, supplements/sparc/ChangeLog, supplements/sparc/ERC32_TIMES, supplements/sparc/Makefile.am, supplements/sparc/bsp.t, supplements/sparc/callconv.t, supplements/sparc/cpumodel.t, supplements/sparc/cputable.t, supplements/sparc/fatalerr.t, supplements/sparc/intr_NOTIMES.t, supplements/sparc/memmodel.t, supplements/sparc/preface.texi, supplements/sparc/sparc.texi, supplements/sparc/timeERC32.t, supplements/template/.cvsignore, supplements/template/BSP_TIMES, supplements/template/ChangeLog, supplements/template/Makefile.am, supplements/template/bsp.t, supplements/template/callconv.t, supplements/template/cpumodel.t, supplements/template/cputable.t, supplements/template/fatalerr.t, supplements/template/intr_NOTIMES.t, supplements/template/memmodel.t, supplements/template/preface.texi, supplements/template/template.texi, supplements/template/timeBSP.t: Removed.
  • Property mode set to 100644
File size: 25.5 KB
Line 
1@c
2@c  COPYRIGHT (c) 1988-2002.
3@c  On-Line Applications Research Corporation (OAR).
4@c  All rights reserved.
5@c
6@c  $Id$
7@c
8
9@ifinfo
10@end ifinfo
11@chapter Intel/AMD x86 Specific Information
12
13The Real Time Executive for Multiprocessor Systems
14(RTEMS) is designed to be portable across multiple processor
15architectures.  However, the nature of real-time systems makes
16it essential that the application designer understand certain
17processor dependent implementation details.  These processor
18dependencies include calling convention, board support package
19issues, interrupt processing, exact RTEMS memory requirements,
20performance data, header files, and the assembly language
21interface to the executive.
22
23For information on the i386 processor, refer to the
24following documents:
25
26@itemize @bullet
27@item @cite{386 Programmer's Reference Manual, Intel, Order No.  230985-002}.
28
29@item @cite{386 Microprocessor Hardware Reference Manual, Intel,
30Order No. 231732-003}.
31
32@item @cite{80386 System Software Writer's Guide, Intel, Order No.  231499-001}.
33
34@item @cite{80387 Programmer's Reference Manual, Intel, Order No.  231917-001}.
35@end itemize
36
37It is highly recommended that the i386 RTEMS
38application developer obtain and become familiar with Intel's
39386 Programmer's Reference Manual.
40
41@c
42@c  COPYRIGHT (c) 1988-2002.
43@c  On-Line Applications Research Corporation (OAR).
44@c  All rights reserved.
45@c
46@c  $Id$
47@c
48
49@section CPU Model Dependent Features
50
51
52Microprocessors are generally classified into
53families with a variety of CPU models or implementations within
54that family.  Within a processor family, there is a high level
55of binary compatibility.  This family may be based on either an
56architectural specification or on maintaining compatibility with
57a popular processor.  Recent microprocessor families such as the
58SPARC or PowerPC are based on an architectural specification
59which is independent or any particular CPU model or
60implementation.  Older families such as the M68xxx and the iX86
61evolved as the manufacturer strived to produce higher
62performance processor models which maintained binary
63compatibility with older models.
64
65RTEMS takes advantage of the similarity of the
66various models within a CPU family.  Although the models do vary
67in significant ways, the high level of compatibility makes it
68possible to share the bulk of the CPU dependent executive code
69across the entire family.  Each processor family supported by
70RTEMS has a list of features which vary between CPU models
71within a family.  For example, the most common model dependent
72feature regardless of CPU family is the presence or absence of a
73floating point unit or coprocessor.  When defining the list of
74features present on a particular CPU model, one simply notes
75that floating point hardware is or is not present and defines a
76single constant appropriately.  Conditional compilation is
77utilized to include the appropriate source code for this CPU
78model's feature set.  It is important to note that this means
79that RTEMS is thus compiled using the appropriate feature set
80and compilation flags optimal for this CPU model used.  The
81alternative would be to generate a binary which would execute on
82all family members using only the features which were always
83present.
84
85This chapter presents the set of features which vary
86across i386 implementations and are of importance to RTEMS.
87The set of CPU model feature macros are defined in the file
88cpukit/score/cpu/i386/i386.h based upon the particular CPU
89model defined on the compilation command line.
90
91@subsection CPU Model Name
92
93The macro CPU_MODEL_NAME is a string which designates
94the name of this CPU model.  For example, for the Intel i386 without an
95i387 coprocessor, this macro is set to the string "i386 with i387".
96
97@subsection bswap Instruction
98
99The macro I386_HAS_BSWAP is set to 1 to indicate that
100this CPU model has the @code{bswap} instruction which
101endian swaps a thirty-two bit quantity.  This instruction
102appears to be present in all CPU models
103i486's and above.
104
105@subsection Floating Point Unit
106
107The macro I386_HAS_FPU is set to 1 to indicate that
108this CPU model has a hardware floating point unit and 0
109otherwise.  The hardware floating point may be on-chip (as in the
110case of an i486DX or Pentium) or as a coprocessor (as in the case of
111an i386/i387 combination).
112@c
113@c  COPYRIGHT (c) 1988-2002.
114@c  On-Line Applications Research Corporation (OAR).
115@c  All rights reserved.
116@c
117@c  $Id$
118@c
119
120@section Calling Conventions
121
122
123Each high-level language compiler generates
124subroutine entry and exit code based upon a set of rules known
125as the compiler's calling convention.   These rules address the
126following issues:
127
128@itemize @bullet
129@item register preservation and usage
130
131@item parameter passing
132
133@item call and return mechanism
134@end itemize
135
136A compiler's calling convention is of importance when
137interfacing to subroutines written in another language either
138assembly or high-level.  Even when the high-level language and
139target processor are the same, different compilers may use
140different calling conventions.  As a result, calling conventions
141are both processor and compiler dependent.
142
143@subsection Processor Background
144
145The i386 architecture supports a simple yet effective
146call and return mechanism.  A subroutine is invoked via the call
147(call) instruction.  This instruction pushes the return address
148on the stack.  The return from subroutine (ret) instruction pops
149the return address off the current stack and transfers control
150to that instruction.  It is is important to note that the i386
151call and return mechanism does not automatically save or restore
152any registers.  It is the responsibility of the high-level
153language compiler to define the register preservation and usage
154convention.
155
156@subsection Calling Mechanism
157
158All RTEMS directives are invoked using a call
159instruction and return to the user application via the ret
160instruction.
161
162@subsection Register Usage
163
164As discussed above, the call instruction does not
165automatically save any registers.  RTEMS uses the registers EAX,
166ECX, and EDX as scratch registers.  These registers are not
167preserved by RTEMS directives therefore, the contents of these
168registers should not be assumed upon return from any RTEMS
169directive.
170
171@subsection Parameter Passing
172
173RTEMS assumes that arguments are placed on the
174current stack before the directive is invoked via the call
175instruction.  The first argument is assumed to be closest to the
176return address on the stack.  This means that the first argument
177of the C calling sequence is pushed last.  The following
178pseudo-code illustrates the typical sequence used to call a
179RTEMS directive with three (3) arguments:
180
181@example
182push third argument
183push second argument
184push first argument
185invoke directive
186remove arguments from the stack
187@end example
188
189The arguments to RTEMS are typically pushed onto the
190stack using a push instruction.  These arguments must be removed
191from the stack after control is returned to the caller.  This
192removal is typically accomplished by adding the size of the
193argument list in bytes to the stack pointer.
194
195@subsection User-Provided Routines
196
197All user-provided routines invoked by RTEMS, such as
198user extensions, device drivers, and MPCI routines, must also
199adhere to these calling conventions.
200
201@c
202@c  COPYRIGHT (c) 1988-2002.
203@c  On-Line Applications Research Corporation (OAR).
204@c  All rights reserved.
205@c
206@c  $Id$
207@c
208
209@section Memory Model
210
211
212A processor may support any combination of memory
213models ranging from pure physical addressing to complex demand
214paged virtual memory systems.  RTEMS supports a flat memory
215model which ranges contiguously over the processor's allowable
216address space.  RTEMS does not support segmentation or virtual
217memory of any kind.  The appropriate memory model for RTEMS
218provided by the targeted processor and related characteristics
219of that model are described in this chapter.
220
221@subsection Flat Memory Model
222
223RTEMS supports the i386 protected mode, flat memory
224model with paging disabled.  In this mode, the i386
225automatically converts every address from a logical to a
226physical address each time it is used.  The i386 uses
227information provided in the segment registers and the Global
228Descriptor Table to convert these addresses.  RTEMS assumes the
229existence of the following segments:
230
231@itemize @bullet
232@item a single code segment at protection level (0) which
233contains all application and executive code.
234
235@item a single data segment at protection level zero (0) which
236contains all application and executive data.
237@end itemize
238
239The i386 segment registers and associated selectors
240must be initialized when the initialize_executive directive is
241invoked.  RTEMS treats the segment registers as system registers
242and does not modify or context switch them.
243
244This i386 memory model supports a flat 32-bit address
245space with addresses ranging from 0x00000000 to 0xFFFFFFFF (4
246gigabytes).  Each address is represented by a 32-bit value and
247is byte addressable.  The address may be used to reference a
248single byte, half-word (2-bytes), or word (4 bytes).
249
250RTEMS does not require that logical addresses map
251directly to physical addresses, although it is desirable in many
252applications to do so.  If logical and physical addresses are
253not the same, then an additional selector will be required so
254RTEMS can access the Interrupt Descriptor Table to install
255interrupt service routines.  The selector number of this segment
256is provided to RTEMS in the CPU Dependent Information Table.
257
258By not requiring that logical addresses map directly
259to physical addresses, the memory space of an RTEMS application
260can be separated from that of a ROM monitor.  For example, on
261the Force Computers CPU386, the ROM monitor loads application
262programs into a logical address space where logical address
2630x00000000 corresponds to physical address 0x0002000.  On this
264board, RTEMS and the application use virtual addresses which do
265not map to physical addresses.
266
267RTEMS assumes that the DS and ES registers contain
268the selector for the single data segment when a directive is
269invoked.   This assumption is especially important when
270developing interrupt service routines.
271
272@c
273@c  COPYRIGHT (c) 1988-2002.
274@c  On-Line Applications Research Corporation (OAR).
275@c  All rights reserved.
276@c
277@c  $Id$
278@c
279
280@section Interrupt Processing
281
282
283Different types of processors respond to the
284occurrence of an interrupt in their own unique fashion. In
285addition, each processor type provides a control mechanism to
286allow the proper handling of an interrupt.  The processor
287dependent response to the interrupt modifies the execution state
288and results in the modification of the execution stream. This
289modification usually requires that an interrupt handler utilize
290the provided control mechanisms to return to the normal
291processing stream.  Although RTEMS hides many of the processor
292dependent details of interrupt processing, it is important to
293understand how the RTEMS interrupt manager is mapped onto the
294processor's unique architecture. Discussed in this chapter are
295the the processor's response and control mechanisms as they
296pertain to RTEMS.
297
298@subsection Vectoring of Interrupt Handler
299
300Although the i386 supports multiple privilege levels,
301RTEMS and all user software executes at privilege level 0.  This
302decision was made by the RTEMS designers to enhance
303compatibility with processors which do not provide sophisticated
304protection facilities like those of the i386.  This decision
305greatly simplifies the discussion of i386 processing, as one
306need only consider interrupts without privilege transitions.
307
308Upon receipt of an interrupt  the i386 automatically
309performs the following actions:
310
311@itemize @bullet
312@item pushes the EFLAGS register
313
314@item pushes the far address of the interrupted instruction
315
316@item vectors to the interrupt service routine (ISR).
317@end itemize
318
319A nested interrupt is processed similarly by the
320i386.
321
322@subsection Interrupt Stack Frame
323
324The structure of the Interrupt Stack Frame for the
325i386 which is placed on the interrupt stack by the processor in
326response to an interrupt is as follows:
327
328@ifset use-ascii
329@example
330@group
331               +----------------------+
332               | Old EFLAGS Register  | ESP+8
333               +----------+-----------+
334               |   UNUSED |  Old CS   | ESP+4
335               +----------+-----------+
336               |       Old EIP        | ESP
337               +----------------------+
338@end group
339@end example
340@end ifset
341
342@ifset use-tex
343@sp 1
344@tex
345\centerline{\vbox{\offinterlineskip\halign{
346\strut\vrule#&
347\hbox to 1.00in{\enskip\hfil#\hfil}&
348\vrule#&
349\hbox to 1.00in{\enskip\hfil#\hfil}&
350\vrule#&
351\hbox to 0.75in{\enskip\hfil#\hfil}
352\cr
353\multispan{4}\hrulefill\cr
354& \multispan{3} Old EFLAGS Register\quad&&ESP+8\cr
355\multispan{4}\hrulefill\cr
356&UNUSED &&Old CS &&ESP+4\cr
357\multispan{4}\hrulefill\cr
358& \multispan{3} Old EIP && ESP\cr
359\multispan{4}\hrulefill\cr
360}}\hfil}
361@end tex
362@end ifset
363 
364@ifset use-html
365@html
366<CENTER>
367  <TABLE COLS=3 WIDTH="40%" BORDER=2>
368<TR><TD ALIGN=center COLSPAN=2><STRONG>Old EFLAGS Register</STRONG></TD>
369    <TD ALIGN=center>0x0</TD></TR>
370<TR><TD ALIGN=center><STRONG>UNUSED</STRONG></TD>
371    <TD ALIGN=center><STRONG>Old CS</STRONG></TD>
372    <TD ALIGN=center>0x2</TD></TR>
373<TR><TD ALIGN=center COLSPAN=2><STRONG>Old EIP</STRONG></TD>
374    <TD ALIGN=center>0x4</TD></TR>
375  </TABLE>
376</CENTER>
377@end html
378@end ifset
379
380@subsection Interrupt Levels
381
382Although RTEMS supports 256 interrupt levels, the
383i386 only supports two -- enabled and disabled.  Interrupts are
384enabled when the interrupt-enable flag (IF) in the extended
385flags (EFLAGS) is set.  Conversely, interrupt processing is
386inhibited when the IF is cleared.  During a non-maskable
387interrupt, all other interrupts, including other non-maskable
388ones, are inhibited.
389
390RTEMS interrupt levels 0 and 1 such that level zero
391(0) indicates that interrupts are fully enabled and level one
392that interrupts are disabled.  All other RTEMS interrupt levels
393are undefined and their behavior is unpredictable.
394
395@subsection Disabling of Interrupts by RTEMS
396
397During the execution of directive calls, critical
398sections of code may be executed.  When these sections are
399encountered, RTEMS disables interrupts before the execution of
400this section and restores them to the previous level upon
401completion of the section.  RTEMS has been optimized to insure
402that interrupts are disabled for less than RTEMS_MAXIMUM_DISABLE_PERIOD
403microseconds on a RTEMS_MAXIMUM_DISABLE_PERIOD_MHZ Mhz i386 with zero
404wait states.  These numbers will vary based the number of wait states
405and processor speed present on the target board.   [NOTE:  The maximum
406period with interrupts disabled within RTEMS was last calculated for
407Release RTEMS_RELEASE_FOR_MAXIMUM_DISABLE_PERIOD.]
408
409Non-maskable interrupts (NMI) cannot be disabled, and
410ISRs which execute at this level MUST NEVER issue RTEMS system
411calls.  If a directive is invoked, unpredictable results may
412occur due to the inability of RTEMS to protect its critical
413sections.  However, ISRs that make no system calls may safely
414execute as non-maskable interrupts.
415
416@subsection Interrupt Stack
417
418The i386 family does not support a dedicated hardware
419interrupt stack.  On this processor, RTEMS allocates and manages
420a dedicated interrupt stack.  As part of vectoring a non-nested
421interrupt service routine, RTEMS switches from the stack of the
422interrupted task to a dedicated interrupt stack.  When a
423non-nested interrupt returns, RTEMS switches back to the stack
424of the interrupted stack.  The current stack pointer is not
425altered by RTEMS on nested interrupt.
426
427Without a dedicated interrupt stack, every task in
428the system MUST have enough stack space to accommodate the worst
429case stack usage of that particular task and the interrupt
430service routines COMBINED.  By supporting a dedicated interrupt
431stack, RTEMS significantly lowers the stack requirements for
432each task.
433
434RTEMS allocates the dedicated interrupt stack from
435the Workspace Area.  The amount of memory allocated for the
436interrupt stack is determined by the interrupt_stack_size field
437in the CPU Configuration Table.
438
439@c
440@c  COPYRIGHT (c) 1988-2002.
441@c  On-Line Applications Research Corporation (OAR).
442@c  All rights reserved.
443@c
444@c  $Id$
445@c
446
447@section Default Fatal Error Processing
448
449
450Upon detection of a fatal error by either the
451application or RTEMS the fatal error manager is invoked.  The
452fatal error manager will invoke the user-supplied fatal error
453handlers.  If no user-supplied handlers are configured,  the
454RTEMS provided default fatal error handler is invoked.  If the
455user-supplied fatal error handlers return to the executive the
456default fatal error handler is then invoked.  This chapter
457describes the precise operations of the default fatal error
458handler.
459
460@subsection Default Fatal Error Handler Operations
461
462The default fatal error handler which is invoked by
463the fatal_error_occurred directive when there is no user handler
464configured or the user handler returns control to RTEMS.  The
465default fatal error handler disables processor interrupts,
466places the error code in EAX, and executes a HLT instruction to
467halt the processor.
468
469@c
470@c  COPYRIGHT (c) 1988-2002.
471@c  On-Line Applications Research Corporation (OAR).
472@c  All rights reserved.
473@c
474@c  $Id$
475@c
476
477@section Board Support Packages
478
479
480An RTEMS Board Support Package (BSP) must be designed to support a
481particular processor and target board combination.  This chapter presents a
482discussion of i386 specific BSP issues.  For more information on developing
483a BSP, refer to the chapter titled Board Support Packages in the RTEMS
484Applications User's Guide.
485
486@subsection System Reset
487
488An RTEMS based application is initiated when the i386
489processor is reset.  When the i386 is reset,
490
491@itemize @bullet
492
493@item The EAX register is set to indicate the results of the processor's
494power-up self test.  If the self-test was not executed, the contents of
495this register are undefined.  Otherwise, a non-zero value indicates the
496processor is faulty and a zero value indicates a successful self-test.
497
498@item The DX register holds a component identifier and revision level.  DH
499contains 3 to indicate an i386 component and DL contains a unique revision
500level indicator.
501
502@item Control register zero (CR0) is set such that the processor is in real
503mode with paging disabled.  Other portions of CR0 are used to indicate the
504presence of a numeric coprocessor.
505
506@item All bits in the extended flags register (EFLAG) which are not
507permanently set are cleared.  This inhibits all maskable interrupts.
508
509@item The Interrupt Descriptor Register (IDTR) is set to point at address
510zero.
511
512@item All segment registers are set to zero.
513
514@item The instruction pointer is set to 0x0000FFF0.  The first instruction
515executed after a reset is actually at 0xFFFFFFF0 because the i386 asserts
516the upper twelve address until the first intersegment (FAR) JMP or CALL
517instruction.  When a JMP or CALL is executed, the upper twelve address
518lines are lowered and the processor begins executing in the first megabyte
519of memory.
520
521@end itemize
522
523Typically, an intersegment JMP to the application's initialization code is
524placed at address 0xFFFFFFF0.
525
526@subsection Processor Initialization
527
528This initialization code is responsible for initializing all data
529structures required by the i386 in protected mode and for actually entering
530protected mode.  The i386 must be placed in protected mode and the segment
531registers and associated selectors must be initialized before the
532initialize_executive directive is invoked.
533
534The initialization code is responsible for initializing the Global
535Descriptor Table such that the i386 is in the thirty-two bit flat memory
536model with paging disabled.  In this mode, the i386 automatically converts
537every address from a logical to a physical address each time it is used.
538For more information on the memory model used by RTEMS, please refer to the
539Memory Model chapter in this document.
540
541Since the processor is in real mode upon reset, the processor must be
542switched to protected mode before RTEMS can execute.  Before switching to
543protected mode, at least one descriptor table and two descriptors must be
544created.  Descriptors are needed for a code segment and a data segment. (
545This will give you the flat memory model.)  The stack can be placed in a
546normal read/write data segment, so no descriptor for the stack is needed.
547Before the GDT can be used, the base address and limit must be loaded into
548the GDTR register using an LGDT instruction.
549
550If the hardware allows an NMI to be generated, you need to create the IDT
551and a gate for the NMI interrupt handler.  Before the IDT can be used, the
552base address and limit for the idt must be loaded into the IDTR register
553using an LIDT instruction.
554
555Protected mode is entered by setting thye PE bit in the CR0 register.
556Either a LMSW or MOV CR0 instruction may be used to set this bit. Because
557the processor overlaps the interpretation of several instructions, it is
558necessary to discard the instructions from the read-ahead cache. A JMP
559instruction immediately after the LMSW changes the flow and empties the
560processor if intructions which have been pre-fetched and/or decoded.  At
561this point, the processor is in protected mode and begins to perform
562protected mode application initialization.
563
564If the application requires that the IDTR be some value besides zero, then
565it should set it to the required value at this point.  All tasks share the
566same i386 IDTR value.  Because interrupts are enabled automatically by
567RTEMS as part of the initialize_executive directive, the IDTR MUST be set
568properly before this directive is invoked to insure correct interrupt
569vectoring.  If processor caching is to be utilized, then it should be
570enabled during the reset application initialization code.  The reset code
571which is executed before the call to initialize_executive has the following
572requirements:
573
574For more information regarding the i386s data structures and their
575contents, refer to Intel's 386 Programmer's Reference Manual.
576
577@c
578@c  COPYRIGHT (c) 1988-2002.
579@c  On-Line Applications Research Corporation (OAR).
580@c  All rights reserved.
581@c
582@c  $Id$
583@c
584
585@section Processor Dependent Information Table
586
587
588Any highly processor dependent information required
589to describe a processor to RTEMS is provided in the CPU
590Dependent Information Table.  This table is not required for all
591processors supported by RTEMS.  This chapter describes the
592contents, if any, for a particular processor type.
593
594@subsection CPU Dependent Information Table
595
596The i386 version of the RTEMS CPU Dependent
597Information Table contains the information required to interface
598a Board Support Package and RTEMS on the i386.  This information
599is provided to allow RTEMS to interoperate effectively with the
600BSP.  The C structure definition is given here:
601
602@example
603@group
604typedef struct @{
605  void       (*pretasking_hook)( void );
606  void       (*predriver_hook)( void );
607  void       (*idle_task)( void );
608  boolean      do_zero_of_workspace;
609  unsigned32   idle_task_stack_size;
610  unsigned32   interrupt_stack_size;
611  unsigned32   extra_mpci_receive_server_stack;
612  void *     (*stack_allocate_hook)( unsigned32 );
613  void       (*stack_free_hook)( void* );
614  /* end of fields required on all CPUs */
615 
616  unsigned32   interrupt_segment;
617  void        *interrupt_vector_table;
618@} rtems_cpu_table;
619@end group
620@end example
621
622@table @code
623@item pretasking_hook
624is the address of the user provided routine which is invoked
625once RTEMS APIs are initialized.  This routine will be invoked
626before any system tasks are created.  Interrupts are disabled.
627This field may be NULL to indicate that the hook is not utilized.
628
629@item predriver_hook
630is the address of the user provided
631routine that is invoked immediately before the
632the device drivers and MPCI are initialized. RTEMS
633initialization is complete but interrupts and tasking are disabled.
634This field may be NULL to indicate that the hook is not utilized.
635
636@item postdriver_hook
637is the address of the user provided
638routine that is invoked immediately after the
639the device drivers and MPCI are initialized. RTEMS
640initialization is complete but interrupts and tasking are disabled.
641This field may be NULL to indicate that the hook is not utilized.
642
643@item idle_task
644is the address of the optional user
645provided routine which is used as the system's IDLE task.  If
646this field is not NULL, then the RTEMS default IDLE task is not
647used.  This field may be NULL to indicate that the default IDLE
648is to be used.
649
650@item do_zero_of_workspace
651indicates whether RTEMS should
652zero the Workspace as part of its initialization.  If set to
653TRUE, the Workspace is zeroed.  Otherwise, it is not.
654
655@item idle_task_stack_size
656is the size of the RTEMS idle task stack in bytes. 
657If this number is less than MINIMUM_STACK_SIZE, then the
658idle task's stack will be MINIMUM_STACK_SIZE in byte.
659
660@item interrupt_stack_size
661is the size of the RTEMS
662allocated interrupt stack in bytes.  This value must be at least
663as large as MINIMUM_STACK_SIZE.
664
665@item extra_mpci_receive_server_stack
666is the extra stack space allocated for the RTEMS MPCI receive server task
667in bytes.  The MPCI receive server may invoke nearly all directives and
668may require extra stack space on some targets.
669
670@item stack_allocate_hook
671is the address of the optional user provided routine which allocates
672memory for task stacks.  If this hook is not NULL, then a stack_free_hook
673must be provided as well.
674
675@item stack_free_hook
676is the address of the optional user provided routine which frees
677memory for task stacks.  If this hook is not NULL, then a stack_allocate_hook
678must be provided as well.
679
680@item interrupt_segment
681is the value of the selector which should be placed in a segment
682register to access the Interrupt Descriptor Table.
683
684@item interrupt_vector_table
685is the base address of the Interrupt Descriptor Table relative to the
686interrupt_segment.
687
688@end table
689
690The contents of the i386 Interrupt Descriptor Table
691are discussed in  Intel's i386 User's Manual.  Structure
692definitions for the i386 IDT is provided by including the file
693rtems.h.
694
Note: See TracBrowser for help on using the repository browser.