This port serves as a template enabling the porting of Sirius RTOS and other products to ARM microprocessors.
All port files for this architecture are listed in the table below:
| File name | Extension | Description |
|---|---|---|
| AR_API | H | Port API File |
| AR_Types | H | Type declarations file |
| AR_ARM | C | Port source file |
| AR_ARMa | S | Port assembly file |
| AR_ARMHooks | C, H | CPU-specific functions |
The internal timer must be configured to generate interrupts for preemption. It is generally configured to provide an interval between 0.1 and 1 millisecond.
A secondary timer should track the number of "ticks" elapsed since startup. This value is returned by the arGetTickCount function to provide system time.
The arLock and arRestore functions perform preemption disabling and re-enabling by modifying the standard interrupt (IRQ) enable state.
The arYield function performs a context switch without utilizing an additional software interrupt.
All tasks execute in Supervisor Mode. When the operating system calls the port-specific arSetPreemptiveHandler function, it does not allocate a new stack or task context for the operating system scheduler. This is because the scheduler executes in IRQ Mode, which possesses its own distinct stack and register set.
Most ARM processors support switching to an idle mode. The arSavePower function is utilized by the operating system to reduce power consumption when no tasks are executing.
To run Sirius RTOS and other SpaceShadow products on a specific ARM microprocessor, the following five CPU-specific functions must be implemented:
The arARMInitHook function must implement platform initialization and enable the timer. This timer must periodically execute the callback function passed as a parameter to realize preemption.
The arARMDeinitHook function is executed during platform deinitialization. This implementation may be skipped if the feature is not required.
The arGetTickCountHook function must return the total number of clock "ticks" elapsed since system startup. To properly manage system time, the number of clock "ticks" per second must be defined in the AR_TICKS_PER_SECOND constant. Using one-millisecond intervals is recommended.
The arIRQHandlerHook function is executed every time preemption occurs. It is used to acknowledge the interrupt (End of Interrupt).
The arSavePowerHook function is called whenever the CPU is idle (not processing any task). It allows switching the CPU to a power-save mode, which resumes execution upon any interrupt. This is often performed by an architecture-specific instruction (e.g., HLT on i386 or HALT on Motorola 68k). If the processor does not provide a method for halting execution, the body of this function should remain empty.
The task context contains all information required to resume the execution of a preempted task. The table below details the 64-byte task context structure for ARM processors:
| Offset | Size | Description |
|---|---|---|
| 0000 | 4 | R15 (PC) register - Task startup procedure |
| 0004 | 4 | R14 register, original Link Register value |
| 0008 | 4 | R12 register |
| 000C | 4 | R11 register |
| 0010 | 4 | R10 register |
| 0014 | 4 | R9 register |
| 0018 | 4 | R8 register |
| 001C | 4 | R7 register |
| 0020 | 4 | R6 register |
| 0024 | 4 | R5 register |
| 0028 | 4 | R4 register |
| 002C | 4 | R3 register |
| 0030 | 4 | R2 register |
| 0034 | 4 | R1 register |
| 0038 | 4 | R0 register |
| 003C | 4 | CPSR (Flags) register |