Lazuli
arch.h
Go to the documentation of this file.
1 /*
2  * SPDX-License-Identifier: GPL-3.0-only
3  * This file is part of Lazuli.
4  */
5 
18 #ifndef LAZULI_SYS_ARCH_ARCH_H
19 #define LAZULI_SYS_ARCH_ARCH_H
20 
21 #include <stdint.h>
22 
23 #include <Lazuli/common.h>
24 #include <Lazuli/list.h>
25 #include <Lazuli/serial.h>
26 #include <Lazuli/sys/compiler.h>
27 
29 
33 NORETURN void
34 Arch_InfiniteLoop(void);
35 
39 void
40 Arch_ResetSystem(void);
41 
53 void
55 
68 void
69 Arch_StartRunning(void *stackPointer, size_t offsetOfPc);
70 
78 void
79 Arch_LoadFromProgmem(const void * source,
80  void * destination,
81  const size_t size);
82 
92 uint8_t
93 Arch_LoadU8FromProgmem(const void *source);
94 
104 uint16_t
105 Arch_LoadU16FromProgmem(const void *source);
106 
115 void *
116 Arch_LoadPointerFromProgmem(const void *source);
117 
133 void (*Arch_LoadFunctionPointerFromProgmem(const void *source)) (void);
134 
138 void
140 
144 void
146 
147 /* TODO: This is machine specific!!! */
155 
161 InterruptsStatus
163 
169 void
170 Arch_RestoreInterruptsStatus(const InterruptsStatus interruptsStatus);
171 
178 bool
180 
184 void
186 
190 void
191 Arch_CpuSleep(void);
192 
196 void
198 
205 void
207 
211 void
213 
228 bool
229 Arch_TryAcquireLock(volatile uint8_t * const lock);
230 
242 void
244 
251 void
252 Arch_SetSerialConfiguration(const Lz_SerialConfiguration * const configuration);
253 
257 void
258 Arch_InitSerial(void);
259 
263 typedef struct {
267 
283 Arch_Divide_U16(uint16_t numerator, uint16_t denominator);
284 
288 
289 #endif /* LAZULI_SYS_ARCH_ARCH_H */
void Arch_SetSerialConfiguration(const Lz_SerialConfiguration *const configuration)
Configure the seria line according to the parameter.
Definition: usart.c:451
void Arch_InfiniteLoop(void)
Function that loops forever, never returns.
uint8_t InterruptsStatus
Define the type used to store interrupts status.
Definition: arch.h:154
void Arch_InitSystemTimer(void)
Initialize the system timer.
void Arch_InitIdleCpuMode(void)
Initialize idle CPU modes.
Definition: arch.c:27
Represents the result of a uin16_t division.
Definition: arch.h:263
void * Arch_LoadPointerFromProgmem(const void *source)
Return a pointer stored in program memory.
#define _EXTERN_C_DECL_BEGIN
Open C++ header file declarations.
Definition: common.h:37
void Arch_DisableInterrupts(void)
Disable all interrupts.
void Arch_EnableInterrupts(void)
Enable all interrupts.
void Arch_RestoreContextAndReturnFromInterrupt(void *stackPointer)
Restore the context of a previously saved task, and run it by returning from interrupt.
U16DivisionResult Arch_Divide_U16(uint16_t numerator, uint16_t denominator)
Perform the Euclidean division between two uint16_t operands.
bool Arch_TryAcquireLock(volatile uint8_t *const lock)
Try to acquire a lock by atomically changing the value pointed by the lock parameter.
Macro aliases on compiler facilities.
InterruptsStatus Arch_DisableInterruptsGetStatus(void)
Disable all interrupts and return the previous interrupts status.
void Arch_RestoreInterruptsStatus(const InterruptsStatus interruptsStatus)
Restore a previously saved interrupts status.
void Arch_GetSerialConfiguration(Lz_SerialConfiguration *const configuration)
Retrieve the current configuration of the serial line.
Definition: usart.c:441
uint16_t remainder
The remainder of the division.
Definition: arch.h:264
unsigned int uint16_t
Represents a unsigned integer type with width of exactly 16 bits.
Definition: stdint.h:94
uint16_t Arch_LoadU16FromProgmem(const void *source)
Return a double-byte word stored in program memory.
bool Arch_AreInterruptsEnabled(void)
Obtain a value indicating if global interrupts are enabled.
void Arch_InitInstrumentation(void)
Initialize the context switch instrumentation.
Definition: arch.c:69
Doubly linked lists interface.
void(*)(void) Arch_LoadFunctionPointerFromProgmem(const void *source)
Return a function pointer stored in program memory.
Definition: arch.h:133
Serial port configuration interface.
void Arch_LoadFromProgmem(const void *source, void *destination, const size_t size)
Copy bytes from program memory to RAM.
unsigned char uint8_t
Represents a unsigned integer type with width of exactly 8 bits.
Definition: stdint.h:89
void Arch_CpuSleep(void)
Put the CPU to sleep according to the sleep settings.
Definition: arch.c:60
Represents the configuration of a serial interface.
Definition: serial.h:222
void Arch_InitSerial(void)
Initialize serial line with default configuration at system startup.
Definition: usart.c:480
Basic type definitions and useful macros.
uint16_t quotient
The quotient of the division.
Definition: arch.h:265
#define _EXTERN_C_DECL_END
Close C++ header file declarations.
Definition: common.h:42
void Arch_ResetSystem(void)
Reset the whole system.
void Arch_StartSystemTimer(void)
Start the system timer.
uint8_t Arch_LoadU8FromProgmem(const void *source)
Return a byte stored in program memory.
void Arch_StartRunning(void *stackPointer, size_t offsetOfPc)
Start running the scheduler for the first time with the specified context.