hal-porting-platform.html
来自「有关ecos2。0介绍了实时嵌入式的结构以及线程调度的实现和内存的管理等」· HTML 代码 · 共 1,675 行 · 第 1/3 页
HTML
1,675 行
description " Enable this option if this program is to be used as a ROM monitor, i.e. applications will be loaded into RAM on the board, and this ROM monitor may process exceptions or interrupts generated from the application. This enables features such as utilizing a separate interrupt stack when exceptions are generated."}</PRE></TD></TR></TABLE><P>The latter option is accompanied by a special build rule thatextends the generic ROM monitor build rule in the common HAL:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">cdl_option CYGBLD_BUILD_GDB_STUBS { display "Build GDB stub ROM image" default_value 0 requires { CYG_HAL_STARTUP == "ROM" } requires CYGSEM_HAL_ROM_MONITOR requires CYGBLD_BUILD_COMMON_GDB_STUBS requires CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS requires ! CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT requires ! CYGDBG_HAL_DEBUG_GDB_THREAD_SUPPORT requires ! CYGDBG_HAL_COMMON_INTERRUPTS_SAVE_MINIMUM_CONTEXT requires ! CYGDBG_HAL_COMMON_CONTEXT_SAVE_MINIMUM no_define description " This option enables the building of the GDB stubs for the board. The common HAL controls takes care of most of the build process, but the final conversion from ELF image to binary data is handled by the platform CDL, allowing relocation of the data if necessary." make -priority 320 { <PREFIX>/bin/gdb_module.bin : <PREFIX>/bin/gdb_module.img $(OBJCOPY) -O binary $< $@ }}</PRE></TD></TR></TABLE><P>Most platforms support RedBoot, and some options are needed toconfigure for RedBoot.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING"> cdl_component CYGPKG_REDBOOT_HAL_OPTIONS { display "Redboot HAL options" flavor none no_define parent CYGPKG_REDBOOT active_if CYGPKG_REDBOOT description " This option lists the target's requirements for a valid Redboot configuration." cdl_option CYGBLD_BUILD_REDBOOT_BIN { display "Build Redboot ROM binary image" active_if CYGBLD_BUILD_REDBOOT default_value 1 no_define description "This option enables the conversion of the Redboot ELF image to a binary image suitable for ROM programming." make -priority 325 { <PREFIX>/bin/redboot.bin : <PREFIX>/bin/redboot.elf $(OBJCOPY) --strip-debug $< $(@:.bin=.img) $(OBJCOPY) -O srec $< $(@:.bin=.srec) $(OBJCOPY) -O binary $< $@ } } }</PRE></TD></TR></TABLE><P>The important part here is the <TTCLASS="LITERAL">make</TT> command in the<TTCLASS="LITERAL">CYGBLD_BUILD_REDBOOT_BIN</TT> option which emitsmakefile commands to translate the <TTCLASS="FILENAME">.elf</TT> filegenerated by the link phase into both a binary file and an S-Recordfile. If a different format is required by a PROM programmer or ROMmonitor, then different output formats would need to be generated here.</P></DIV></DIV><DIVCLASS="SECTION"><H2CLASS="SECTION"><ANAME="HAL-PORTING-PLATFORM-MEMORY-LAYOUT">Platform Memory Layout</H2><P>The platform memory layout is defined using the MemoryConfiguration Window in the Configuration Tool.</P><DIVCLASS="NOTE"><BLOCKQUOTECLASS="NOTE"><P><B>Note: </B>If you do not have access to a Windows machine, you canhand edit the <TTCLASS="FILENAME">.h</TT> and <TTCLASS="FILENAME">.ldi</TT> files to match theproperties of your platform. If you want to contribute your port backto the eCos community, ask someone on the list to make proper memorymap files for you.</P></BLOCKQUOTE></DIV><DIVCLASS="SECTION"><H3CLASS="SECTION"><ANAME="AEN9615">Layout Files</H3><P>The memory configuration details are saved in three files:</P><P></P><DIVCLASS="VARIABLELIST"><DL><DT><TTCLASS="FILENAME">.mlt</TT></DT><DD><P>This is the Configuration Tool save-file. It is only used by the Configuration Tool.</P></DD><DT><TTCLASS="FILENAME">.ldi</TT></DT><DD><P>This is the linker script fragment. It defines the memory and location of sections by way of macros defined in the architecture or variant linker script.</P></DD><DT><TTCLASS="FILENAME">.h</TT></DT><DD><P>This file describes some of the memory region details as C macros, allowing eCos or the application adapt the memory layout of a specific configuration.</P></DD></DL></DIV><P>These three files are generated for each startup-type, since thememory details usually differ.</P></DIV><DIVCLASS="SECTION"><H3CLASS="SECTION"><ANAME="AEN9635">Reserved Regions</H3><P>Some areas of the memory space are reserved for specificpurposes, making room for exception vectors and various tables. RAMstartup configurations also need to reserve some space at the bottomof the memory map for the ROM monitor.</P><P>These reserved areas are named with the prefix "reserved_" which ishandled specially by the Configuration Tool: instead of referring to alinker macro, the start of the area is labeled and a gap left in thememory map.</P></DIV></DIV><DIVCLASS="SECTION"><H2CLASS="SECTION"><ANAME="AEN9639">Platform Serial Device Support</H2><P>The first step is to set up the CDL definitions. The configurationoptions that need to be set are the following:</P><P></P><DIVCLASS="VARIABLELIST"><DL><DT><TTCLASS="LITERAL">CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS</TT></DT><DD><P>The number of channels, usually 0, 1 or 2.</P></DD><DT><TTCLASS="LITERAL">CYGNUM_HAL_VIRTUAL_VECTOR_DEBUG_CHANNEL</TT></DT><DD><P>The channel to use for GDB.</P></DD><DT><TTCLASS="LITERAL">CYGNUM_HAL_VIRTUAL_VECTOR_DEBUG_CHANNEL_BAUD</TT></DT><DD><P>Initial baud rate for debug channel.</P></DD><DT><TTCLASS="LITERAL">CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL</TT></DT><DD><P>The channel to use for the console.</P></DD><DT><TTCLASS="LITERAL">CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD</TT></DT><DD><P>The initial baud rate for the console channel.</P></DD><DT><TTCLASS="LITERAL">CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_DEFAULT</TT></DT><DD><P>The default console channel.</P></DD></DL></DIV><P>The code in <TTCLASS="FILENAME">hal_diag.c</TT> need to be converted tosupport the new serial device.If this the same as a device already supported, copy that.</P><P>The following functions and types need to be rewritten to support a new serialdevice.</P><P></P><DIVCLASS="VARIABLELIST"><DL><DT><TTCLASS="LITERAL">struct channel_data_t;</TT></DT><DD><P> Structure containing base address, timeout and ISR vector number for each serial device supported. Extra fields my be added if necessary for the device. For example some devices have write-only control registers, so keeping a shadow of the last value written here can be useful. </P></DD><DT><TTCLASS="LITERAL">xxxx_ser_channels[];</TT></DT><DD><P> Array of <TTCLASS="LITERAL">channel_data_t</TT>, initialized with parameters of each channel. The index into this array is the channel number used in the CDL options above and is used by the virtual vector mechanism to refer to each channel. </P></DD><DT><TTCLASS="LITERAL">void cyg_hal_plf_serial_init_channel(void *__ch_data)</TT></DT><DD><P> Initialize the serial device. The parameter is actually a pointer to a <TTCLASS="LITERAL">channel_data_t</TT> and should be cast back to this type before use. This function should use the CDL definition for the baud rate for the channel it is initializing. </P></DD><DT><TTCLASS="LITERAL">void cyg_hal_plf_serial_putc(void * __ch_data, char *c)</TT></DT><DD><P> Send a character to the serial device. This function should poll for the device being ready to send and then write the character. Since this is intended to be a diagnostic/debug channel, it is often also a good idea to poll for end of transmission too. This ensures that as much data gets out of the system as possible. </P></DD><DT><TTCLASS="LITERAL">bool cyg_hal_plf_serial_getc_nonblock(void* __ch_data, cyg_uint8* ch)</TT></DT><DD><P> This function tests the device and if a character is available, places it in <TTCLASS="PARAMETER"><I>*ch</I></TT> and returns <TTCLASS="LITERAL">TRUE</TT>. If no character is available, then the function returns <TTCLASS="LITERAL">FALSE</TT> immediately. </P></DD><DT><TTCLASS="LITERAL">int cyg_hal_plf_serial_control(void *__ch_data, __comm_control_cmd_t __func, ...)</TT></DT><DD><P> This is an IOCTL-like function for controlling various aspects of the serial device. The only part in which you may need to do some work initially is in the <TTCLASS="LITERAL">__COMMCTL_IRQ_ENABLE</TT> and <TTCLASS="LITERAL">__COMMCTL_IRQ_DISABLE</TT> cases to enable/disable interrupts. </P></DD><DT><TTCLASS="LITERAL">int cyg_hal_plf_serial_isr(void *__ch_data, int* __ctrlc, CYG_ADDRWORD __vector, CYG_ADDRWORD __data)</TT></DT><DD><P> This interrupt handler, called from the spurious interrupt vector, is specifically for dealing with <TTCLASS="LITERAL">Ctrl-C</TT> interrupts from GDB. When called this function should do the following: <P></P><OLTYPE="1"><LI><P>Check for an incoming character. The code here is very similar to that in <TTCLASS="FUNCTION">cyg_hal_plf_serial_getc_nonblock()</TT>. </P></LI><LI><P> Read the character and call <TTCLASS="FUNCTION">cyg_hal_is_break()</TT>. </P></LI><LI><P> If result is true, set <TTCLASS="PARAMETER"><I>*__ctrlc</I></TT> to <TTCLASS="LITERAL">1</TT>. </P></LI><LI><P> Return <TTCLASS="LITERAL">CYG_ISR_HANDLED</TT>. </P></LI></OL> </P></DD><DT><TTCLASS="LITERAL">void cyg_hal_plf_serial_init()</TT></DT><DD><P> Initialize each of the serial channels. First call <TTCLASS="FUNCTION">cyg_hal_plf_serial_init_channel()</TT> for each channel. Then call the <TTCLASS="LITERAL">CYGACC_COMM_IF_*</TT> macros for each channel. This latter set of calls are identical for all channels, so the best way to do this is to copy and edit an existing example. </P></DD></DL></DIV></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-coding-conventions.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-porting-variant.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">HAL Coding Conventions</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="hal-porting-guide.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Variant HAL Porting</TD></TR></TABLE></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?