📄 bsp.t
字号:
@c@c COPYRIGHT (c) 1988-2002.@c On-Line Applications Research Corporation (OAR).@c All rights reserved.@c@c $Id: bsp.t,v 1.9 2002/01/17 21:47:46 joel Exp $@c@chapter Board Support Packages@section IntroductionAn RTEMS Board Support Package (BSP) must be designed to support aparticular processor and target board combination. This chapter presents adiscussion of i386 specific BSP issues. For more information on developinga BSP, refer to the chapter titled Board Support Packages in the RTEMSApplications User's Guide. @section System ResetAn RTEMS based application is initiated when the i386processor is reset. When the i386 is reset,@itemize @bullet@item The EAX register is set to indicate the results of the processor'spower-up self test. If the self-test was not executed, the contents ofthis register are undefined. Otherwise, a non-zero value indicates theprocessor is faulty and a zero value indicates a successful self-test.@item The DX register holds a component identifier and revision level. DHcontains 3 to indicate an i386 component and DL contains a unique revisionlevel indicator. @item Control register zero (CR0) is set such that the processor is in realmode with paging disabled. Other portions of CR0 are used to indicate thepresence of a numeric coprocessor. @item All bits in the extended flags register (EFLAG) which are notpermanently set are cleared. This inhibits all maskable interrupts. @item The Interrupt Descriptor Register (IDTR) is set to point at addresszero. @item All segment registers are set to zero. @item The instruction pointer is set to 0x0000FFF0. The first instructionexecuted after a reset is actually at 0xFFFFFFF0 because the i386 assertsthe upper twelve address until the first intersegment (FAR) JMP or CALLinstruction. When a JMP or CALL is executed, the upper twelve addresslines are lowered and the processor begins executing in the first megabyteof memory.@end itemizeTypically, an intersegment JMP to the application's initialization code isplaced at address 0xFFFFFFF0. @section Processor InitializationThis initialization code is responsible for initializing all datastructures required by the i386 in protected mode and for actually enteringprotected mode. The i386 must be placed in protected mode and the segmentregisters and associated selectors must be initialized before theinitialize_executive directive is invoked. The initialization code is responsible for initializing the GlobalDescriptor Table such that the i386 is in the thirty-two bit flat memorymodel with paging disabled. In this mode, the i386 automatically convertsevery address from a logical to a physical address each time it is used. For more information on the memory model used by RTEMS, please refer to theMemory Model chapter in this document. Since the processor is in real mode upon reset, the processor must beswitched to protected mode before RTEMS can execute. Before switching toprotected mode, at least one descriptor table and two descriptors must becreated. Descriptors are needed for a code segment and a data segment. (This will give you the flat memory model.) The stack can be placed in anormal read/write data segment, so no descriptor for the stack is needed.Before the GDT can be used, the base address and limit must be loaded intothe GDTR register using an LGDT instruction. If the hardware allows an NMI to be generated, you need to create the IDTand a gate for the NMI interrupt handler. Before the IDT can be used, thebase address and limit for the idt must be loaded into the IDTR registerusing an LIDT instruction. Protected mode is entered by setting thye PE bit in the CR0 register. Either a LMSW or MOV CR0 instruction may be used to set this bit. Becausethe processor overlaps the interpretation of several instructions, it isnecessary to discard the instructions from the read-ahead cache. A JMPinstruction immediately after the LMSW changes the flow and empties theprocessor if intructions which have been pre-fetched and/or decoded. Atthis point, the processor is in protected mode and begins to performprotected mode application initialization.If the application requires that the IDTR be some value besides zero, thenit should set it to the required value at this point. All tasks share thesame i386 IDTR value. Because interrupts are enabled automatically byRTEMS as part of the initialize_executive directive, the IDTR MUST be setproperly before this directive is invoked to insure correct interruptvectoring. If processor caching is to be utilized, then it should beenabled during the reset application initialization code. The reset codewhich is executed before the call to initialize_executive has the followingrequirements:For more information regarding the i386s data structures and theircontents, refer to Intel's 386 Programmer's Reference Manual.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -