Variant hal porting, Hal variant porting process – Comtrol eCos User Manual
Page 339

Chapter 11. Porting Guide
bool cyg_hal_plf_serial_getc_nonblock(void* __ch_data, cyg_uint8* ch)
This function tests the device and if a character is available, places it in
*ch
and returns
TRUE
. If no character
is available, then the function returns
FALSE
immediately.
int cyg_hal_plf_serial_control(void *__ch_data, __comm_control_cmd_t __func, ...)
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
__COMMCTL_IRQ_ENABLE
and
__COMMCTL_IRQ_DISABLE
cases to enable/disable interrupts.
int cyg_hal_plf_serial_isr(void *__ch_data, int* __ctrlc, CYG_ADDRWORD __vector, CYG_ADDRWORD
__data)
This interrupt handler, called from the spurious interrupt vector, is specifically for dealing with
Ctrl-C
interrupts from GDB. When called this function should do the following:
1. Check
for
an
incoming
character.
The
code
here
is
very
similar
to
that
in
cyg_hal_plf_serial_getc_nonblock()
.
2. Read the character and call
cyg_hal_is_break()
.
3. If result is true, set
*__ctrlc
to
1
.
4. Return
CYG_ISR_HANDLED
.
void cyg_hal_plf_serial_init()
Initialize each of the serial channels. First call
cyg_hal_plf_serial_init_channel()
for each channel.
Then call the
CYGACC_COMM_IF_*
macros for each channel. This latter set of calls are identical for all chan-
nels, so the best way to do this is to copy and edit an existing example.
Variant HAL Porting
A variant port can be a fairly limited job, but can also require quite a lot of work. A variant HAL describes how
a specific CPU variant differs from the generic CPU architecture. The variant HAL can re-define cache, MMU,
interrupt, and other features which override the default implementation provided by the architecture HAL.
Doing a variant port requires a preexisting architecture HAL port. It is also likely that a platform port will have to
be done at the same time if it is to be tested.
HAL Variant Porting Process
The easiest way to make a new variant HAL is simply to copy an existing variant HAL and change all the files to
match the new variant. If this is the first variant for an architecture, it may be hard to decide which parts should be
put in the variant - knowledge of other variants of the architecture is required.
Looking at existing variant HALs (e.g., MIPS tx39, tx49) may be a help - usually things such as caching, interrupt
and exception handling differ between variants. Initialization code, and code for handling various core components
(FPU, DSP, MMU, etc.) may also differ or be missing altogether on some variants. Linker scripts may also require
specific variant versions.
235