Generic ARM port

This port is a template that allows porting Sirius RTOSand other products on ARM microprocessors.

Source files

All port files for this architecture are listed in the table below:

File nameExtensionDescription
AR_TypesHTypes declarations file
AR_ARMCPort source file
AR_ARMaSPort assembly file
AR_ARMHooksC, HCPU-specific functions

General description

The internal timer should be configured to provide the interrupt for preemption realization. It is generally configured to provide a 0.1 - 1 millisecond interval.

The other timer should provide the number of "ticks", counted from startup time, that is returned by arGetTickCount function to provide a system time.

The arLock/arRestore performs preemption disabling/re-enabling by changing a normal interrupt (IRQ) enable state.

The arYield function performs context switch without the use of additional software interrupt.

All of the tasks are running in Supervisor Mode. When the operating system calls a port-specific arSetPreemptiveHandler function, this will not allocate new stack and task context for an operating system scheduler, because it will be running in the IRQ Mode that has an individual stack and set of registers.

Most of ARM processors allow switching to idle mode. The arSavePowerfunction is used by operating system to reduce power consumption when no one task is performing.

Architecture specific code

To run Sirius RTOS and other SpaceShadow products on your ARM microprocessor, you must implement five of the CPU-specific functions:

  • arARMInitHook
  • arARMDeinitHook
  • arGetTickCountHook
  • arIRQHandlerHook
  • arSavePowerHook

The arARMInitHook function must implement platform initialization and has to enable the timer, that periodically will execute function passed through the parameter. It is expected to realize the preemption.

The arARMDeinitHook function is executed during platform deinitialization. It may be skipped, when this feature is not used.

The arGetTickCountHook must return the number of clock "ticks" counted from the startup time. The number of clock "ticks" in a single second, must be defined in AR_TICKS_PER_SECONDconstant to properly manage system time. It is recommended to use one-millisecond intervals.

The arIRQHandlerHook function is executed every time when the preemption occurs. It is used to mark the end of interrupt.

The arSavePowerHook function is called whenever the CPU is not used by any task. It allows switching the CPU to a power-save mode, which resumes the CPU on every interrupt. This is often performed by architecture specific instruction, (like HLT in i386 or HALT in Motorola 68k). When the processor does not provide a method for disabling the CPU execution, the body of this function should be empty.

Task context

The task context contains all information excepted for resuming execution of preempted task. Below table shows all 64 bytes of the task context for ARM processors:

00004R15 (PC) register - Task startup procedure
00044R14 register, original Link Register value
00084R12 register
000C4R11 register
00104R10 register
00144R9 register
00184R8 register
001C4R7 register
00204R6 register
00244R5 register
00284R4 register
002C4R3 register
00304R2 register
00344R1 register
00384R0 register
003C4CPSR (Flags) register

SpaceShadow documentation