翻译ecos 手册----HAL架构1

这篇内容介绍了eCos的HAL架构,包括四个子类:通用HAL、架构HAL、变体HAL和平台HAL。每个子类都有其特定的功能,如串行驱动、中断处理和内存布局等。对于新HAL的编写,建议遵循一定的命名规范。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

In order to write an eCos HAL it's a good idea to have at least a passing understanding of how the HAL interacts with the rest of the system.

通过修改eCos HAL,可以加深你对HAL与其他系统进行交互的理解。

HAL Classes

The eCos HAL consists of four HAL sub-classes. This table gives a brief description of each class and partly reiterates the description in Chapter 2 . The links refer to the on-line CVS tree (specifically to the sub-HALs used by the PowerPC MBX target).

eCos的HAL由四个HAL的子类构成。 此表给出了每一种类的简要说明:

HAL typeDescriptionFunctionality Overview
Common HAL (hal/common)所有的HAL配置选项和共享的功能通用的调试功能,驱动程序API,eCos与实时监控的调用接口,测试用例。
Architecture HAL(hal/<architecture>/arch)架构相关的特定与通用实现。 以及可被Variant 与Platform  HAL层代码覆写的接口。体系结构的调试器的功能(处理单步执行,异常跳转等),异常/中断向量的定义和处理程序,缓存定义和控制宏,上下文切换代码,汇编功能,早期的系统初始化,配置选项,测试用例。
Variant HAL(hal/<architecture>/<variant>)CPU架构包括的一些变种,例如MIPS的CPU有32位与64位版本之分,变种CPU核心相关内嵌额外功能实现。变异扩展的体系结构的代码(高速缓存,异常/中断),配置选项,变种架构设备的核心驱动程序测试用例。
Platform HAL(hal/<architecture>/<platform>)包含用户平台相关的功能和配置选项。早期的平台初始化代码,平台内存布局规范,配置选项(处理器速度,编译器选项),诊断IO功能,调试IO功能,定制平台外围设备相关的差异化代码(外设中断处理),测试用例。
Auxiliary HAL(hal/<architecture>/<module>)一些的变种有着共同的核心模块。 如:摩托罗拉的PowerPC与QUICC。模块的具体功能(中断控制器,简单的设备驱动程序),测试用例。

File Descriptions

Listed below are the files found in various HALs, with a short description of what each file contains. When looking in existing HALs beware that they do not necessarily follow this naming scheme. If you are writing a new HAL, please try to follow it as closely as possible. Still, no two targets are the same, so sometimes it makes sense to use additional files.

下面列出的是在各种HAL文件,每个文件包含一个简短的描述。 在现有的HAL注意的是,他们并不一定遵循此命名方案。 如果你正在编写一个新的HAL,请尝试尽可能地遵循它。 然而,没有两个目标是相同的,所以有时会使用其他的额外文件。

Common HAL

FileDescription
include/dbg-thread-syscall.hDefines the thread debugging syscall function. This is used by the ROM monitor to access the thread debugging API in the RAM application. .
include/dbg-threads-api.hDefines the thread debugging API. .
include/drv_api.hDefines the driver API.
include/generic-stub.hDefines the generic stub features.
include/hal_if.hDefines the ROM/RAM calling interface API.
include/hal_misc.hDefines miscellaneous helper functions shared by all HALs.
include/hal_stub.hDefines eCos mappings of GDB stub features.
src/dbg-threads-syscall.cThread debugging implementation.
src/drv_api.cDriver API implementation. Depending on configuration this provides either wrappers for the kernel API, or a minimal implementation of these features. This allows drivers to be written relying only on HAL features.
src/dummy.cEmpty dummy file ensuring creation of libtarget.a.
src/generic-stub.cGeneric GDB stub implementation. This provides the communication protocol used to communicate with GDB over a serial device or via the network.
src/hal_if.cROM/RAM calling interface implementation. Provides wrappers from the calling interface API to the eCos features used for the implementation.
src/hal_misc.cVarious helper functions shared by all platforms and architectures.
src/hal_stub.cWrappers from eCos HAL features to the features required by the generic GDB stub.
src/stubrom/stubrom.cThe file used to build eCos GDB stub images. Basically a cyg_start function with a hard coded breakpoint.
src/thread-packets.cMore thread debugging related functions.
src/thread-pkts.hDefines more thread debugging related function.

Architecture HAL

Some architecture HALs may add extra files for architecture specific serial drivers, or for handling interrupts and exceptions if it makes sense.

Note that many of the definitions in these files are only conditionally defined - if the equivalent variant or platform headers provide the definitions, those override the generic architecture definitions.

FileDescription
include/arch.incVarious assembly macros used during system initialization.
include/basetype.hEndian, label, alignment, and type size definitions. These override common defaults in CYGPKG_INFRA.
include/hal_arch.hSaved register frame format, various thread, register and stack related macros.
include/hal_cache.hCache definitions and cache control macros.
include/hal_intr.hException and interrupt definitions. Macros for configuring and controlling interrupts. eCos real-time clock control macros.
include/hal_io.hMacros for accessing IO devices.
include/<arch>_regs.hArchitecture register definitions.
include/<arch>_stub.hArchitecture stub definitions. In particular the register frame layout used by GDB. This may differ from the one used by eCos.
include/<arch>.incArchitecture convenience assembly macros.
src/<arch>.ldLinker macros.
src/context.SFunctions handling context switching and setjmp/longjmp.
src/hal_misc.cException and interrupt handlers in C. Various other utility functions.
src/hal_mk_defs.cUsed to export definitions from C header files to assembler header files.
src/hal_intr.cAny necessary interrupt handling functions.
src/<arch>stub.cArchitecture stub code. Contains functions for translating eCos exceptions to UNIX signals and functions for single-stepping.
src/vectors.SException, interrupt and early initialization code.

Variant HAL

Some variant HALs may add extra files for variant specific serial drivers, or for handling interrupts/exceptions if it makes sense.

Note that these files may be mostly empty if the CPU variant can be controlled by the generic architecture macros. The definitions present are only conditionally defined - if the equivalent platform headers provide the definitions, those override the variant definitions.

FileDescription
include/var_arch.hSaved register frame format, various thread, register and stack related macros.
include/var_cache.hCache related macros.
include/var_intr.hInterrupt related macros.
include/var_regs.hExtra register definitions for the CPU variant.
include/variant.incVarious assembly macros used during system initialization.
src/var_intr.cInterrupt functions if necessary.
src/var_misc.chal_variant_init function and any necessary extra functions.
src/variant.SInterrupt handler table definition.
src/<arch>_<variant>.ldLinker macros.

Platform HAL

Extras files may be added for platform specific serial drivers. Extra files for handling interrupts and exceptions will be present if it makes sense.

FileDescription
include/hal_diag.hDefines functions used for HAL diagnostics output. This would normally be the ROM calling interface wrappers, but may also be the low-level IO functions themselves, saving a little overhead.
include/platform.incPlatform initialization code. This includes memory controller, vectors, and monitor initialization. Depending on the architecture, other things may need defining here as well: interrupt decoding, status register initialization value, etc.
include/plf_cache.hPlatform specific cache handling.
include/plf_intr.hPlatform specific interrupt handling.
include/plf_io.hPCI IO definitions and macros. May also be used to override generic HAL IO macros if the platform endianness differs from that of the CPU.
include/plf_stub.hDefines stub initializer and board reset details.
src/hal_diag.cMay contain the low-level device drivers. But these may also reside in plf_stub.c
src/platform.SMemory controller setup macro, and if necessary interrupt springboard code.
src/plf_misc.cPlatform initialization code.
src/plf_mk_defs.cUsed to export definitions from C header files to assembler header files.
src/plf_stub.cPlatform specific stub initialization and possibly the low-level device driver.

The platform HAL also contains files specifying the platform's memory layout. These files are located in include/pkgconf .

Auxiliary HAL

Auxiliary HALs contain whatever files are necessary to provide the required functionality. There are no predefined set of files required in an auxiliary HAL.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值