⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hal-porting-architecture.html

📁 有关ecos2。0介绍了实时嵌入式的结构以及线程调度的实现和内存的管理等
💻 HTML
📖 第 1 页 / 共 3 页
字号:
><LI><P>Create the <TTCLASS="FILENAME">&lt;architecture&gt;.ld</TT> file. Whilethis file may need to be moved to the variant HAL in the future, itshould initially be defined here, and only moved if necessary.</P><P>This file defines a set of macros that are used by the platform<TTCLASS="LITERAL">.ldi</TT> files to generate linker scripts. Most GCCtoolchains are very similar so the correct approach is to copy thefile from an existing architecture and edit it. The main things thatwill need editing are the <TTCLASS="LITERAL">OUTPUT_FORMAT()</TT> directiveand maybe the creation or allocation of extra sections to variousmacros. Running the target linker with just the<TTCLASS="LITERAL">--verbose</TT> argument will cause it to output itsdefault linker script. This can be compared with the<TTCLASS="LITERAL">.ld</TT> file and appropriate edits made.</P></LI><LI><P>If GDB stubs are to be supported in RedBoot or eCos, then support mustbe included for these. The most important of these are <TTCLASS="FILENAME">include/&lt;architecture&gt;-stub.h</TT> and<TTCLASS="FILENAME">src/&lt;architecture&gt;-stub.c</TT>. In all existingarchitecture HALs these files, and any support files they need, havebeen derived from files supplied in <TTCLASS="LITERAL">libgloss</TT>, aspart of the GDB toolchain package. If this is a totally newarchitecture, this may not have been done, and they must be createdfrom scratch.</P><P><TTCLASS="FILENAME">include/&lt;architecture&gt;-stub.h</TT>contains definitions that are used by the GDB stubs to describe thesize, type, number and names of CPU registers. This information isusually found in the GDB support files for the architecture. It alsocontains prototypes for the functions exported by<TTCLASS="FILENAME">src/&lt;architecture&gt;-stub.c</TT>; however, sincethis is common to all architectures, it can be copied from some otherHAL.</P><P><TTCLASS="FILENAME">src/&lt;architecture&gt;-stub.c</TT> implements thefunctions exported by the header. Most of this is fairly straightforward: the implementation in existing HALs should show exactly whatneeds to be done. The only complex part is the support forsingle-stepping. This is used a lot by GDB, so it cannot beavoided. If the architecture has support for a trace or single-steptrap then that can be used for this purpose. If it does not then thismust be simulated by planting a breakpoint in the nextinstruction. This can be quite involved since it requires someanalysis of the current instruction plus the state of the CPU todetermine where execution is going to go next.</P></LI></OL></DIV><DIVCLASS="SECTION"><H2CLASS="SECTION"><ANAME="HAL-PORTING-ARCHITECTURE-CDL">CDL Requirements</H2><P>The CDL needed for any particular architecture HAL depends to a largeextent on the needs of that architecture. This includes issues such assupport for different variants, use of FPUs, MMUs and caches. Theexact split between the architecture, variant and platform HALs forvarious features is also somewhat fluid. </P><P>To give a rough idea about how the CDL for an architecture isstructured, we will take as an example the I386 CDL.</P><P>This first section introduces the CDL package and placed it under themain HAL package. Include files from this package will be put in the<TTCLASS="FILENAME">include/cyg/hal</TT> directory, and definitions fromthis file will be placed in<TTCLASS="FILENAME">include/pkgconf/hal_i386.h</TT>. The<TTCLASS="LITERAL">compile</TT> line specifies the files in the<TTCLASS="FILENAME">src</TT> directory that are to be compiled as part ofthis package.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">cdl_package CYGPKG_HAL_I386 {    display       "i386 architecture"    parent        CYGPKG_HAL    hardware    include_dir   cyg/hal    define_header hal_i386.h    description   "        The i386 architecture HAL package provides generic        support for this processor architecture. It is also        necessary to select a specific target platform HAL        package."    compile       hal_misc.c context.S i386_stub.c hal_syscall.c</PRE></TD></TR></TABLE><P>Next we need to generate some files using non-standard make rules. Thefirst is <TTCLASS="FILENAME">vectors.S</TT>, which is not put into thelibrary, but linked explicitly with all applications. The second isthe generation of the <TTCLASS="FILENAME">target.ld</TT> file from<TTCLASS="FILENAME">i386.ld</TT> and the startup-selected<TTCLASS="FILENAME">.ldi</TT> file. Both of these are essentiallyboilerplate code that can be copied and edited.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">&#13;    make {        &lt;PREFIX&gt;/lib/vectors.o : &lt;PACKAGE&gt;/src/vectors.S        $(CC) -Wp,-MD,vectors.tmp $(INCLUDE_PATH) $(CFLAGS) -c -o $@ $&lt;        @echo $@ ": \\" &gt; $(notdir $@).deps        @tail +2 vectors.tmp &gt;&gt; $(notdir $@).deps        @echo &gt;&gt; $(notdir $@).deps        @rm vectors.tmp    }    make {        &lt;PREFIX&gt;/lib/target.ld: &lt;PACKAGE&gt;/src/i386.ld        $(CC) -E -P -Wp,-MD,target.tmp -DEXTRAS=1 -xc $(INCLUDE_PATH) $(CFLAGS) -o $@ $&lt;        @echo $@ ": \\" &gt; $(notdir $@).deps        @tail +2 target.tmp &gt;&gt; $(notdir $@).deps        @echo &gt;&gt; $(notdir $@).deps        @rm target.tmp    }</PRE></TD></TR></TABLE><P>The i386 is currently the only architecture that supports SMP. Thefollowing CDL simply enabled the HAL SMP support ifrequired. Generally this will get enabled as a result of a<TTCLASS="LITERAL">requires</TT> statement in the kernel. The<TTCLASS="LITERAL">requires</TT> statement here turns off lazy FPUswitching in the FPU support code, since it is inconsistent with SMPoperation.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">&#13;    cdl_component CYGPKG_HAL_SMP_SUPPORT {	display       "SMP support"	default_value 0	requires { CYGHWR_HAL_I386_FPU_SWITCH_LAZY == 0 }		cdl_option CYGPKG_HAL_SMP_CPU_MAX {	    display       "Max number of CPUs supported"	    flavor        data	    default_value 2	}    }</PRE></TD></TR></TABLE><P>The i386 HAL has optional FPU support, which is enabled by default. Itcan be disabled to improve system performance. There are two FPUsupport options: either to save and restore the FPU state on everycontext switch, or to only switch the FPU state when necessary.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">            cdl_component CYGHWR_HAL_I386_FPU {	display       "Enable I386 FPU support"	default_value 1	description   "This component enables support for the	              I386 floating point unit."	cdl_option CYGHWR_HAL_I386_FPU_SWITCH_LAZY {	    display       "Use lazy FPU state switching"	    flavor        bool	    default_value 1	    description "	                This option enables lazy FPU state switching.                        The default behaviour for eCos is to save and                        restore FPU state on every thread switch, interrupt	                and exception. While simple and deterministic, this	                approach can be expensive if the FPU is not used by	                all threads. The alternative, enabled by this option,	                is to use hardware features that allow the FPU state	                of a thread to be left in the FPU after it has been	                descheduled, and to allow the state to be switched to	                a new thread only if it actually uses the FPU. Where	                only one or two threads use the FPU this can avoid a	                lot of unnecessary state switching."	}    }</PRE></TD></TR></TABLE><P>The i386 HAL also has support for different classes of CPU. Inparticular, Pentium class CPUs have extra functional units, and somevariants of GDB expect more registers to be reported. These optionsenable these features. Generally these are enabled by<TTCLASS="LITERAL">requires</TT> statements in variant or platformpackages, or in <TTCLASS="LITERAL">.ecm</TT> files.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">&#13;    cdl_component CYGHWR_HAL_I386_PENTIUM {	display       "Enable Pentium class CPU features"	default_value 0	description   "This component enables support for various	              features of Pentium class CPUs."	cdl_option CYGHWR_HAL_I386_PENTIUM_SSE {	    display       "Save/Restore SSE registers on context switch"	    flavor        bool	    default_value 0	    description "	                This option enables SSE state switching. The default                        behaviour for eCos is to ignore the SSE registers.                        Enabling this option adds SSE state information to                        every thread context."	}	cdl_option CYGHWR_HAL_I386_PENTIUM_GDB_REGS {	    display       "Support extra Pentium registers in GDB stub"	    flavor        bool	    default_value 0	    description "	                This option enables support for extra Pentium registers			in the GDB stub. These are registers such as CR0-CR4, and                        all MSRs. Not all GDBs support these registers, so the                        default behaviour for eCos is to not include them in the			GDB stub support code."	}    }</PRE></TD></TR></TABLE><P>In the i386 HALs, the linker script is provided by the architectureHAL. In other HALs, for example MIPS, it is provided in the variantHAL. The following option provides the name of the linker script toother elements in the configuration system.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    cdl_option CYGBLD_LINKER_SCRIPT {        display "Linker script"        flavor data	no_define        calculated  { "src/i386.ld" }    }</PRE></TD></TR></TABLE><P>Finally, this interface indicates whether the platform supplied animplementation of the<TTCLASS="FUNCTION">hal_i386_mem_real_region_top()</TT> function. If itdoes then it will contain a line of the form: <TTCLASS="LITERAL">implementsCYGINT_HAL_I386_MEM_REAL_REGION_TOP</TT>. This allows packagessuch as RedBoot to detect the presence of this function so that theymay call it.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">&#13;    cdl_interface CYGINT_HAL_I386_MEM_REAL_REGION_TOP {        display  "Implementations of hal_i386_mem_real_region_top()"    }    }</PRE></TD></TR></TABLE></DIV></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLESUMMARY="Footer navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="hal-porting-variant.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="ecos-ref.html"ACCESSKEY="H">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="hal-future-developments.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Variant HAL Porting</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="hal-porting-guide.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Future developments</TD></TR></TABLE></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -