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

📄 hal-porting-architecture.html

📁 有关ecos2。0介绍了实时嵌入式的结构以及线程调度的实现和内存的管理等
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<!-- Copyright (C) 2003 Red Hat, Inc.                                --><!-- This material may be distributed only subject to the terms      --><!-- and conditions set forth in the Open Publication License, v1.0  --><!-- or later (the latest version is presently available at          --><!-- http://www.opencontent.org/openpub/).                           --><!-- Distribution of the work or derivative of the work in any       --><!-- standard (paper) book form is prohibited unless prior           --><!-- permission is obtained from the copyright holder.               --><HTML><HEAD><TITLE>Architecture HAL Porting</TITLE><meta name="MSSmartTagsPreventParsing" content="TRUE"><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+"><LINKREL="HOME"TITLE="eCos Reference Manual"HREF="ecos-ref.html"><LINKREL="UP"TITLE="	Porting Guide"HREF="hal-porting-guide.html"><LINKREL="PREVIOUS"TITLE="Variant HAL Porting"HREF="hal-porting-variant.html"><LINKREL="NEXT"TITLE="Future developments"HREF="hal-future-developments.html"></HEAD><BODYCLASS="SECTION"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLESUMMARY="Header navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">eCos Reference Manual</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="hal-porting-variant.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom">Chapter 11. Porting Guide</TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="hal-future-developments.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="SECTION"><H1CLASS="SECTION"><ANAME="HAL-PORTING-ARCHITECTURE">Architecture HAL Porting</H1><P>A new architecture HAL is the most complex HAL to write, and it theleast easily described. Hence this section is presently nothing morethan a place holder for the future.</P><DIVCLASS="SECTION"><H2CLASS="SECTION"><ANAME="AEN9793">HAL Architecture Porting Process</H2><P>The easiest way to make a new architecture HAL is simply to copy anexisting architecture HAL of an, if possible, closely matchingarchitecture and change all the files to match the newarchitecture. The MIPS architecture HAL should be used if possible, asit has the appropriate layout and coding conventions. Other HALsmay deviate from that norm in various ways.</P><DIVCLASS="NOTE"><BLOCKQUOTECLASS="NOTE"><P><B>Note: </B> eCos is written for GCC. It requires C and C++compiler support as well as a few compiler features introduced duringeCos development - so compilers older than eCos may not provide thesefeatures. Note that there is no C++ support for any 8 or 16 bitCPUs. Before you can undertake an eCos port, you need the requiredcompiler support.</P></BLOCKQUOTE></DIV><P>The following gives a rough outline of the steps needed to create anew architecture HAL. The exact order and set of steps needed willvary greatly from architecture to architecture, so a lot offlexibility is required. And of course, if the architecture HAL is tobe tested, it is necessary to do variant and  platform ports for theinitial target simultaneously.</P><P></P><OLTYPE="1"><LI><P>Make a new directory for the new architecture under the<TTCLASS="FILENAME">hal</TT> directory in the source repository. Make an<TTCLASS="FILENAME">arch</TT> directory under this and populate this withthe standard set of package directories.</P></LI><LI><P>Copy the CDL file from an example HAL changing its name to match thenew HAL. Edit the file, changing option names as appropriate. Deleteany options that are specific to the original HAL, and and any newoptions that are necessary for the new architecture. This is likely tobe a continuing process during the development of the HAL. See <AHREF="hal-porting-architecture.html#HAL-PORTING-ARCHITECTURE-CDL">the Section called <I>CDL Requirements</I></A> for more details.</P></LI><LI><P>Copy the <TTCLASS="FILENAME">hal_arch.h</TT> file from an exampleHAL. Within this file you need to change or define the following:</P><P></P><UL><LI><P>Define the <SPANCLASS="STRUCTNAME">HAL_SavedRegisters</SPAN> structure. Thismay need to reflect the save order of any group register save/restoreinstructions, the interrupt and exception save and restore formats,and the procedure calling conventions. It may also need to cater foroptional FPUs and other functional units. It can be quite difficult todevelop a layout that copes with all requirements.</P></LI><LI><P>Define the bit manipulation routines,<TTCLASS="LITERAL">HAL_LSBIT_INDEX()</TT> and<TTCLASS="LITERAL">HAL_MSBIT_INDEX()</TT>. If the architecture containsinstructions to perform these, or related, operations, then theseshould be defined as inline assembler fragments. Otherwise make themcalls to functions.</P></LI><LI><P>Define <TTCLASS="LITERAL">HAL_THREAD_INIT_CONTEXT()</TT>. This initializesa restorable CPU context onto a stack pointer so that a later call to<TTCLASS="LITERAL">HAL_THREAD_LOAD_CONTEXT()</TT> or<TTCLASS="LITERAL">HAL_THREAD_SWITCH_CONTEXT()</TT> will execute itcorrectly. This macro needs to take account of the same optionalfeatures of the architecture as the definition of<SPANCLASS="STRUCTNAME">HAL_SavedRegisters</SPAN>.</P></LI><LI><P>Define <TTCLASS="LITERAL">HAL_THREAD_LOAD_CONTEXT()</TT> and<TTCLASS="LITERAL">HAL_THREAD_SWITCH_CONTEXT()</TT>. These should just becalls to functions in <TTCLASS="FILENAME">context.S</TT>.</P></LI><LI><P>Define <TTCLASS="LITERAL">HAL_REORDER_BARRIER()</TT>. This prevents codebeing moved by the compiler and is necessary in some order-sensitivecode. This macro is actually defined identically in all architecture,so it can just be copied.</P></LI><LI><P>Define breakpoint support. The macro<TTCLASS="LITERAL">HAL_BREAKPOINT(label)</TT> needs to be an inline assemblyfragment that invokes a breakpoint. The breakpoint instruction shouldbe labeled with the <TTCLASS="PARAMETER"><I>label</I></TT>argument. <TTCLASS="LITERAL">HAL_BREAKINST</TT> and<TTCLASS="LITERAL">HAL_BREAKINST_SIZE</TT> define the breakpointinstruction for debugging purposes.</P></LI><LI><P>Define GDB support. GDB views the registers of the target as a lineararray, with each register having a well defined offset. This array maydiffer from the ordering defined in<SPANCLASS="STRUCTNAME">HAL_SavedRegisters</SPAN>. The macros<TTCLASS="LITERAL">HAL_GET_GDB_REGISTERS()</TT> and<TTCLASS="LITERAL">HAL_SET_GDB_REGISTERS()</TT> translate between the GDBarray and the <SPANCLASS="STRUCTNAME">HAL_SavedRegisters</SPAN> structure.The <TTCLASS="LITERAL">HAL_THREAD_GET_SAVED_REGISTERS()</TT> translates astack pointer saved by the context switch macros into a pointer to a<SPANCLASS="STRUCTNAME">HAL_SavedRegisters</SPAN> structure. Usually this isa one-to-one translation, but this macro allows it to differ ifnecessary.</P></LI><LI><P>Define long jump support. The type <SPANCLASS="TYPE">hal_jmp_buf</SPAN> and thefunctions <TTCLASS="FUNCTION">hal_setjmp()</TT> and<TTCLASS="LITERAL">hal_longjmp()</TT> provide the underlying implementationof the C library <TTCLASS="FUNCTION">setjmp()</TT> and<TTCLASS="FUNCTION">longjmp()</TT>.</P></LI><LI><P>Define idle thread action. Generally the macro<TTCLASS="LITERAL">HAL_IDLE_THREAD_ACTION()</TT> is defined to call afunction in <TTCLASS="FILENAME">hal_misc.c</TT>.</P></LI><LI><P>Define stack sizes. The macros<TTCLASS="LITERAL">CYGNUM_HAL_STACK_SIZE_MINIMUM</TT> and<TTCLASS="LITERAL">CYGNUM_HAL_STACK_SIZE_TYPICAL</TT> should be defined tothe minimum size for any thread stack and a reasonable default formost threads respectively. It is usually best to construct these outof component sizes for the CPU save state and procedure call stackusage. These definitions should not use anything other than numericalvalues since they can be used from assembly code in some HALs.</P></LI><LI><P>Define memory access macros. These macros provide translation betweencached and uncached and physical memory spaces. They usually consistof masking out bits of the supplied address and ORing in alternativeaddress bits.</P></LI><LI><P>Define global pointer save/restore macros. These really only needdefining if the calling conventions of the architecture require aglobal pointer (as does the MIPS architecture), they may be emptyotherwise. If it is necessary to define these, then take a look at theMIPS implementation for an example.</P></LI></UL></LI><LI><P>Copy <TTCLASS="FILENAME">hal_intr.h</TT> from an example HAL. Within thisfile you should change or define the following:</P><P></P><UL><LI><P>Define the exception vectors. These should be detailed in thearchitecture specification. Essentially for each exception entry pointdefined by the architecture there should be an entry in the VSRtable. The offsets of these VSR table entries should be defined hereby <TTCLASS="LITERAL">CYGNUM_HAL_VECTOR_*</TT> definitions. The size of theVSR table also needs to be defined here.</P></LI><LI><P>Map any hardware exceptions to standard names. There is a group ofexception vector name of the form<TTCLASS="LITERAL">CYGNUM_HAL_EXCEPTION_*</TT> that define a wide varietyof possible exceptions that many architectures raise. Generic codedetects whether the architecture can raise a given exception bytesting whether a given <TTCLASS="LITERAL">CYGNUM_HAL_EXCEPTION_*</TT>definition is present. If it is present then its value is the vectorthat raises that exception. This does not need to be a one-to-onecorrespondence, and several <TTCLASS="LITERAL">CYGNUM_HAL_EXCEPTION_*</TT>definitions may have the same value.</P><P>Interrupt vectors are usually defined in the variant or platformHALs. The interrupt number space may either be continuous with the VSRnumber space, where they share a vector table (as in the i386) or maybe a separate space where a separate decode stage is used (as in MIPSor PowerPC).</P></LI><LI><P>Declare any static data used by the HAL to handle interrupts andexceptions. This is usually three vectors for interrupts:<TTCLASS="LITERAL">hal_interrupt_handlers[]</TT>,<TTCLASS="LITERAL">hal_interrupt_data[]</TT> and<TTCLASS="LITERAL">hal_interrupt_objects[]</TT>, which are sized accordingto the interrupt vector definitions. In addition a definition for theVSR table, <TTCLASS="LITERAL">hal_vsr_table[]</TT> should be made. Thesevectors are normally defined in either <TTCLASS="FILENAME">vectors.S</TT>or <TTCLASS="FILENAME">hal_misc.c</TT>.</P></LI><LI><P

⌨️ 快捷键说明

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