Atomic types, Architecture characterization, Register save format – Comtrol eCos User Manual

Page 282: Thread context initialization

Advertising
background image

Chapter 9. HAL Interfaces

These macros define the C base types that should be used to define variables of the given size. They only need to
be defined if the default types specified in

cyg/infra/cyg_type.h

cannot be used. Note that these are only the

base types, they will be composed with

signed

and

unsigned

to form full type specifications.

Atomic types

cyg_halatomic CYG_ATOMIC

These types are guaranteed to be read or written in a single uninterruptible operation. It is architecture defined what
size this type is, but it will be at least a byte.

Architecture Characterization

These are definition that are related to the basic architecture of the CPU. These include the CPU context save
format, context switching, bit twiddling, breakpoints, stack sizes and address translation.

Most of these definition are found in

cyg/hal/hal_arch.h

. This file is supplied by the architecture HAL.

If there are variant or platform specific definitions then these will be found in

cyg/hal/var_arch.h

or

cyg/hal/plf_arch.h

. These files are include automatically by this header, so need not be included explicitly.

Register Save Format

typedef struct HAL_SavedRegisters

{

/* architecture-dependent list of registers to be saved */

} HAL_SavedRegisters;

This structure describes the layout of a saved machine state on the stack. Such states are saved during thread context
switches, interrupts and exceptions. Different quantities of state may be saved during each of these, but usually a
thread context state is a subset of the interrupt state which is itself a subset of an exception state. For debugging
purposes, the same structure is used for all three purposes, but where these states are significantly different, this
structure may contain a union of the three states.

Thread Context Initialization

HAL_THREAD_INIT_CONTEXT( sp, arg, entry, id )

This macro initializes a thread’s context so that it may be switched to by

HAL_THREAD_SWITCH_CONTEXT()

. The

arguments are:

sp

A location containing the current value of the thread’s stack pointer. This should be a variable or a structure

field. The SP value will be read out of here and an adjusted value written back.

178

Advertising