📄 memmodel.t
字号:
@c@c COPYRIGHT (c) 1988-1999.@c On-Line Applications Research Corporation (OAR).@c All rights reserved.@c@c $Id: memmodel.t,v 1.1 2003/01/24 13:57:31 joel Exp $@c@chapter Memory Model@section IntroductionA processor may support any combination of memorymodels ranging from pure physical addressing to complex demandpaged virtual memory systems. RTEMS supports a flat memorymodel which ranges contiguously over the processor's allowableaddress space. RTEMS does not support segmentation or virtualmemory of any kind. The appropriate memory model for RTEMSprovided by the targeted processor and related characteristicsof that model are described in this chapter.@section Byte Addressable versus Word AddressableProcessor in the Texas Instruments C3x/C4x family are word addressable. This is in sharp contrast to CISC andRISC processors that are typically byte addressable. In a wordaddressable architecture, each address points not to an8-bit byte or octet but to 32 bits.On first glance, byte versus word addressability does notsound like a problem but in fact, this issue can result insubtle problems in high-level language software that is portedto a word addressable processor family. The following is a list of the commonly encountered problems:@table @b@item String OptimizationsAlthough each character in a string occupies a single address justas it does on a byte addressable CPU, each character occupies32 rather than 8 bits. The most significant 24 bytes are of each address are ignored. This in and of itself does notcause problems but it violates the assumption that two adjacent characters in a string have no intervening bits.This assumption is often implicit in string and memory comparisonroutines that are optimized to compare 4 adjacent characterswith a word oriented operation. This optimization is invalid on word addressable processors.@item SizeofThe C operation @code{sizeof} returns very different resultson the C3x/C4x than on traditional RISC/CISC processors. The @code{sizeof(char)}, @code{sizeof(short)}, and @code{sizeof(int)}are all 1 since each occupies a single addressable unit that isthirty-two bits wide. On most thirty-two bit processors,@code{sizeof(char} is one, @code{sizeof(short)} is two,and @code{sizeof(int)} is four. Just as software makes assumptionsabout the sizes of the primitive data types has problemswhen ported to a sixty-four bit architecture, these sameassumptions cause problems on the C3x/C4x.@item AlignmentSince each addressable unit is thirty-two bit wide, thereare no alignment restrictions. The native integer typeneed only be aligned on a "one unit" boundary not a "fourunit" boundary as on numerous other processors.@end table@section Flat Memory ModelXXX check actual bits on the various processor families.The XXX family supports a flat 32-bit addressspace with addresses ranging from 0x00000000 to 0xFFFFFFFF (4gigabytes). Each address is represented by a 32-bit value andis byte addressable. The address may be used to reference asingle byte, word (2-bytes), or long word (4 bytes). Memoryaccesses within this address space are performed in big endianfashion by the processors in this family.@section Compiler Memory ModelsThe Texas Instruments C3x/C4x processors include a Data Page(@code{dp}) register that logically is a base address. The@code{dp} register allows the use of shorter offsets ininstructions. Up to 64K words may be addressed usingoffsets from the @code{dp} register. In order to addresswords not addressable based on the current value of@code{dp}, the register must be loaded with a differentvalue.The @code{dp} register is managed automatically bythe high-level language compilers.The various compilers for this processor family supporttwo memory models that manage the @code{dp} registerin very different manners. The large and small memorymodels are discussed in the following sections.NOTE: The C3x/C4x port of RTEMS has been writtenso that it should support either memory model.However, it has only been tested using thelarge memory model.@subsection Small Memory ModelThe small memory model is the simplest and mostefficient. However, it includes a limitation thatmake it inappropriate for numerous applications. Thesmall memory model assumes that the application needsto access no more than 64K words. Thus the @code{dp} register can be loaded at application start time and never reloaded. Thus the compiler will noteven generate instructions to load the @code{dp}.This can significantly reduce the code spacerequired by an application but the applicationis limited in the amount of data it can access.With the GNU Compiler Suite, small memory model is selected by invoking the compiler with either the @code{-msmall} or @code{-msmallmemoryXXX} argument.This argument must be included when linking the applicationin order to ensure that support libraries also compiledfor the large memory model are used. The default memory model is XXX.When this memory model is selected, the @code{XXX}symbol is predefined by the C and C++ compilersand the @code{XXX} symbol is predefined by the assembler.This behavior is the same for the GNU and Texas Instrumentstoolsets. RTEMS uses these predefines to determine the proper handlingof the @code{dp} register in those C3x/C4x specific routinesthat were written in assembly language.@subsection Large Memory ModelThe large memory model is more complex and less efficientthan the small memory model. However, it removes the64K uninitialized data restriction from applications.The @code{dp} register is reloaded automaticallyby the compiler each time data is accessed. This leadsto an increase in the code space requirements for theapplication but gives it access to much more data space.With the GNU Compiler Suite, large memory model is selected by invoking the compiler with either the @code{-mlarge} or @code{-mlargememoryXXX} argument.This argument must be included when linking the applicationin order to ensure that support libraries also compiledfor the large memory model are used.The default memory model is XXX.When this memory model is selected, the @code{XXX}symbol is predefined by the C and C++ compilersand the @code{XXX} symbol is predefined by the assembler.This behavior is the same for the GNU and Texas Instrumentstoolsets. RTEMS uses these predefines to determine the proper handlingof the @code{dp} register in those C3x/C4x specific routinesthat were written in assembly language.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -