Lazuli
Loading...
Searching...
No Matches
kernel.c
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#include <stdint.h>
19
20#include <Lazuli/common.h>
21#include <Lazuli/config.h>
22
24#include <Lazuli/sys/compiler.h>
25#include <Lazuli/sys/kernel.h>
26#include <Lazuli/sys/linker.h>
27#include <Lazuli/sys/memory.h>
29
38void
39main(void);
40
41/*
42 * Initialized at system startup. Can be usable only after the .data section
43 * have been initialized. So don't access it before.
44 */
46
48
53void
55{
56 /* Initialize the allocation map for the kernel */
60
63
66 }
67
70 }
71
72 /* Give hand to user */
73 main();
74}
75
76/* TODO: Find something better to perform this verification... */
77#ifndef LZ_STATIC_ANALYSIS
78#if (LZ_CONFIG_ON_PANIC_INFINITE_LOOP + LZ_CONFIG_ON_PANIC_SOFTWARE_RESET) != 1
79#error "Only one kernel panic configuration must be defined in config.h."
80#endif
81#endif
82
83void
85{
89 /* TODO: Change this by a watchdog software reset */
91 }
92}
93
94void
96{
98 /* We are running in the kernel */
100 } else {
101 /* We are running in a task */
103 }
104}
void Arch_InitIdleCpuMode(void)
Initialize idle CPU modes.
Definition arch.c:27
void Arch_InitInstrumentation(void)
Initialize the context switch instrumentation.
Definition arch.c:69
Architecture Abstraction API.
void Arch_ResetSystem(void)
Reset the whole system.
void Arch_InfiniteLoop(void)
Function that loops forever, never returns.
Basic type definitions and useful macros.
Macro aliases on compiler facilities.
Include appropriate config file.
const bool LZ_CONFIG_MODULE_SERIAL_USED
Use module "serial": Serial interface configuration.
const bool LZ_CONFIG_INSTRUMENT_CONTEXT_SWITCHES
When set, add instrumentation code to measure context switches.
const bool LZ_CONFIG_ON_PANIC_INFINITE_LOOP
When 1, run an infinite loop on kernel panic.
const bool LZ_CONFIG_ON_PANIC_SOFTWARE_RESET
When 1, perform a software reset on kernel panic.
volatile lz_system_status_t systemStatus
System status "register" (bit field).
Definition kernel.c:45
void Kernel_ManageFailure(void)
Manage a failure that can happen in a function call.
Definition kernel.c:95
void main(void)
Main entry point for user tasks.
void Kernel_Main(void)
This is the kernel entry point.
Definition kernel.c:54
AllocationMap kernelAllocationMap
Allocation map for the kernel.
Definition kernel.c:47
void Kernel_Panic(void)
Kernel panic.
Definition kernel.c:84
Kernel symbols definition.
#define SYSTEM_STATUS_FLAG_IN_KERNEL
The flag constant for the status "in kernel".
Definition kernel.h:39
uint8_t lz_system_status_t
The type used for the system status "register".
Definition kernel.h:29
#define SYSTEM_STATUS_IS_IN_KERNEL
Get a boolean value indicating if the system is curently in kernel mode.
Definition kernel.h:45
Symbols defined by the linker.
uint8_t _ramend
Last address of RAM.
uint8_t _brk
Initial break address.
Memory management API.
void Scheduler_AbortTask(void)
Abort the current running task.
Definition scheduler.c:651
void Scheduler_Init(void)
Initialize the scheduler prior to running it.
Definition scheduler.c:632
Lazuli scheduler interface.
Represents a map of the allocated memory regions and useful memory handlers for a task or the kernel.
Definition memory.h:25
void * endMem
End address of the memory region.
Definition memory.h:40
void * brk
Break position, points to the first location beyond the current end of the heap.
Definition memory.h:35
void * baseMem
Base address of the memory region.
Definition memory.h:29
void Arch_InitSerial(void)
Initialize serial line with default configuration at system startup.
Definition usart.c:480