📄 hal.sgml
字号:
<PARA> Hints to the cache that the region is going to be read from in the near future. This may cause the region to be speculatively read into the cache. </PARA> </LISTITEM> </VARLISTENTRY> <VARLISTENTRY> <TERM>HAL_DCACHE_WRITE_HINT() </TERM> <LISTITEM> <PARA> Hints to the cache that the region is going to be written to in the near future. This may have the identical behavior to HAL_DCACHE_READ_HINT(). </PARA> </LISTITEM> </VARLISTENTRY> <VARLISTENTRY> <TERM>HAL_DCACHE_ZERO()</TERM> <LISTITEM> <PARA> Allocates and zeroes lines in the cache for the given region without reading memory. This is useful if a large area of memory is to be cleared. </PARA> </LISTITEM> </VARLISTENTRY></VARIABLELIST></SECTION></SECTION><!-- }}} --><!-- {{{ Linker Scripts --><SECTION id="hal-linker-scripts"><TITLE><!-- <xref> -->Linker Scripts</TITLE><para>When an eCos application is linked it must be done under the controlof a linker script. This script defines the memory areas, addressesand sized, into which the code and data are to be put, and allocatesthe various sections generated by the compiler to these.</para><para>The linker script actually used is in<filename>lib/target.ld</filename> in the install directory. This isactually manufactured out of two other files: a base linker script andan <literal>.ldi</literal> file that was generated by the memorylayout tool.</para><para>The base linker script is usually supplied either by the architectureHAL or the variant HAL. It consists of a set of linker scriptfragments, in the form of C preprocessor macros, that define the majoroutput sections to be generated by the link operation. The<literal>.ldi</literal> file, which is <literal>#include'ed</literal>by the base linker script, uses these macro definitions to assign theoutput sections to the required memory areas and link addresses.</para><para>The <literal>.ldi</literal> file is supplied by the platform HAL, andcontains knowledge of the memory layout of the target platform. Thesefiles generally conform to a standard naming convention, each filebeing of the form:</para><para><filename>pkgconf/mlt_<architecture>_<variant>_<platform>_<startup>.ldi</filename></para><para>where <literal><architecture></literal>,<literal><variant></literal> and<literal><platform></literal> are the respective HAL packagenames and <literal><startup></literal> is the startup type whichis usually one of <literal>ROM</literal>, <literal>RAM</literal> or<literal>ROMRAM</literal>.</para><para>In addition to the <literal>.ldi</literal> file, there is also acongruously name <literal>.h</literal> file. This may be used by theapplication to access information defined in the<literal>.ldi</literal> file. Specifically it contains the memorylayout defined there, together with any additional section namesdefined by the user. Examples of the latter are heap areas or PCI busmemory access windows.</para><para>The <literal>.ldi</literal> is manufactured by the <application>MemoryLayout Tool</application> (MLT). The <application>MLT</application> saves the memoryconfiguration into a file named</para><para><filename>include/pkgconf/mlt_<architecture>_<variant>_<platform>_<startup>.mlt</filename></para><para>in the platform HAL. This file is used by the<application>MLT</application> to manufacture both the<literal>.ldi</literal> and <literal>.h</literal> files. Users shouldbeware that direct edits the either of these files may be overwrittenif the <application>MLT</application> is run and regenerates them from the<literal>.mlt</literal> file.</para><para>The names of the <literal>.ldi</literal> and <literal>.h</literal>files are defined by macro definitions in<FILENAME>pkgconf/system.h</FILENAME>. These are<literal>CYGHWR_MEMORY_LAYOUT_LDI</literal> and<literal>CYGHWR_MEMORY_LAYOUT_H</literal> respectively. While therewill be little need for the application to refer to the<literal>.ldi</literal> file directly, it may include the<literal>.h</literal> file as follows:</para><programlisting>#include CYGHWR_MEMORY_LAYOUT_H</programlisting></SECTION><!-- }}} --><!-- {{{ Diagnostic Support --><SECTION id="hal-diagnostic-support"><TITLE>Diagnostic Support</TITLE><para>The HAL provides support for low level diagnostic IO. This isparticularly useful during early development as an aid to bringing upa new platform. Usually this diagnostic channel is a UART or someother serial IO device, but it may equally be a a memorybuffer, a simulator supported output channel, a ROM emulator virtualUART, and LCD panel, a memory mapped video buffer or any other outputdevice.</para><PARA><FUNCTION>HAL_DIAG_INIT()</FUNCTION> performs any initializationrequired on the device being used to generate diagnostic output. Thismay include, for a UART, setting baud rate, and stop, parity andcharacter bits. For other devices it may include initializing acontroller or establishing contact with a remote device.</PARA><PARA><FUNCTION>HAL_DIAG_WRITE_CHAR(c)</FUNCTION> writesthe character supplied to the diagnostic output device.</PARA><PARA><FUNCTION>HAL_DIAG_READ_CHAR(c)</FUNCTION> reads a character from thediagnostic device into the supplied variable. This is not supportedfor all diagnostic devices.</PARA><para>These macros are defined in the header file<filename>cyg/hal/hal_diag.h</filename>. This file is usually suppliedby the variant or platform HAL, depending on where the IO device beingused is located. For example for on-chip UARTs it would be in thevariant HAL, but for a board-level LCD panel it would be in theplatform HAL.</para></section><!-- }}} --><!-- {{{ SMP Support --><section id="hal-smp-support"><TITLE>SMP Support</TITLE><para>eCos contains support for limited Symmetric Multi-Processing(SMP). This is only available on selected architectures and platforms.</para><section><title>Target Hardware Limitations</title><para>To allow a reasonable implementation of SMP, and to reduce thedisruption to the existing source base, a number of assumptions havebeen made about the features of the target hardware.</para><itemizedlist><listitem><para>Modest multiprocessing. The typical number of CPUs supported is twoto four, with an upper limit around eight. While there are noinherent limits in the code, hardware and algorithmic limitationswill probably become significant beyond this point.</para></listitem><listitem><para>SMP synchronization support. The hardware must supply a mechanism toallow software on two CPUs to synchronize. This is normally providedas part of the instruction set in the form of test-and-set,compare-and-swap or load-link/store-conditional instructions. Analternative approach is the provision of hardware semaphoreregisters which can be used to serialize implementations of theseoperations. Whatever hardware facilities are available, they areused in eCos to implement spinlocks.</para></listitem><listitem><para>Coherent caches. It is assumed that no extra effort will be requiredto access shared memory from any processor. This means that eitherthere are no caches, they are shared by all processors, or aremaintained in a coherent state by the hardware. It would be toodisruptive to the eCos sources if every memory access had to bebracketed by cache load/flush operations. Any hardware that requiresthis is not supported.</para></listitem><listitem><para>Uniform addressing. It is assumed that all memory that isshared between CPUs is addressed at the same location from allCPUs. Like non-coherent caches, dealing with CPU-specific addresstranslation is considered too disruptive to the eCos sourcebase. This does not, however, preclude systems with non-uniformaccess costs for different CPUs.</para></listitem><listitem><para>Uniform device addressing. As with access to memory, it is assumedthat all devices are equally accessible to all CPUs. Since deviceaccess is often made from thread contexts, it is not possible torestrict access to device control registers to certain CPUs, sincethere is currently no support for binding or migrating threads to CPUs.</para></listitem><listitem><para>Interrupt routing. The target hardware must have an interruptcontroller that can route interrupts to specific CPUs. It isacceptable for all interrupts to be delivered to just one CPU, orfor some interrupts to be bound to specific CPUs, or for someinterrupts to be local to each CPU. At present dynamic routing,where a different CPU may be chosen each time an interrupt isdelivered, is not supported. ECos cannot support hardware where allinterrupts are delivered to all CPUs simultaneously with theexpectation that software will resolve any conflicts.</para></listitem><listitem><para>Inter-CPU interrupts. A mechanism to allow one CPU to interruptanother is needed. This is necessary so that events on one CPU cancause rescheduling on other CPUs.</para></listitem><listitem><para>CPU Identifiers. Code running on a CPU must be able to determinewhich CPU it is running on. The CPU Id is usually provided either ina CPU status register, or in a register associated with theinter-CPU interrupt delivery subsystem. ECos expects CPU Ids to besmall positive integers, although alternative representations, suchas bitmaps, can be converted relatively easily. Complex mechanismsfor getting the CPU Id cannot be supported. Getting the CPU Id mustbe a cheap operation, since it is done often, and in performancecritical places such as interrupt handlers and the scheduler.</para></listitem></itemizedlist></section> <section><title>HAL Support</title><para>SMP support in any platform depends on the HAL supplying theappropriate operations. All HAL SMP support is defined in the<filename>cyg/hal/hal_smp.h</filename> header. Variant and platformspecific definitions will be in <filename>cyg/hal/var_smp.h</filename>and <filename>cyg/hal/plf_smp.h</filename> respectively. These filesare include automatically by this header, so need not be includedexplicitly.</para><para>SMP support falls into a number of functional groups.</para><section><title>CPU Control</title><para>This group consists of descriptive and control macros for managing theCPUs in an SMP system.</para><variablelist><varlistentry><term><literal>HAL_SMP_CPU_TYPE</literal></term><listitem><para>A type that can contain a CPU id. A CPU id isusually a small integer that is used to indexarrays of variables that are managed on anper-CPU basis.</para></listitem></varlistentry><varlistentry><term><literal>HAL_SMP_CPU_MAX</literal></term><listitem><para>The maximum number of CPUs that can besupported. This is used to provide the size ofany arrays that have an element per CPU.</para></listitem></varlistentry><varlistentry><term><literal>HAL_SMP_CPU_COUNT()</literal></term><listitem><para>Returns the number of CPUs currentlyoperational. This may differ fromHAL_SMP_CPU_MAX depending on the runtimeenvironment.</para></listitem></varlistentry><varlistentry><term><literal>HAL_SMP_CPU_THIS()</literal></term><listitem><para>Returns the CPU id of the current CPU.</para></listitem></varlistentry><varlistentry><term><literal>HAL_SMP_CPU_NONE</literal></term><listitem><para>A value that does not match any real CPUid. This is uses where a CPU type variablemust be set to a null value.</para></listitem></varlistentry><varlistentry><term><literal>HAL_SMP_CPU_START( cpu )</literal></term><listitem><para>Starts the given CPU executing at a definedHAL entry point. After performing any HALlevel initialization, the CPU calls up intothe kernel at <function>cyg_kernel_cpu_startup()</function>.</para></listitem></varlistentry><varlistentry><term><literal>HAL_SMP_CPU_RESCHEDULE_INTERRUPT( cpu, wait )</literal></term><listitem><para>Sends the CPU a reschedule interrupt, and if<parameter>wait</parameter> is non-zero, waits for anacknowledgment. The interrupted CPU should call<function>cyg_scheduler_set_need_reschedule()</function> in its DSR tocause the reschedule to occur.</para></listitem></varlistentry><varlistentry><term><literal>HAL_SMP_CPU_TIMESLICE_INTERRUPT( cpu, wait )</literal></term><listitem><para>Sends the CPU a timeslice interrupt, and if<parameter>wait</parameter> is non-zero, waits for anacknowledgment. The interrupted CPU should call<function>cyg_scheduler_timeslice_cpu()</function> to cause thetimeslice event to be processed.</para></list
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -