Lazuli
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 <Lazuli/common.h>
19 #include <Lazuli/config.h>
20 
21 #include <Lazuli/sys/arch/arch.h>
22 #include <Lazuli/sys/linker.h>
23 #include <Lazuli/sys/memory.h>
24 #include <Lazuli/sys/scheduler.h>
25 
34 int
35 main(void);
36 
41 
46 void
48 {
49  /* Initialize the allocation map for the kernel */
50  kernelAllocationMap.baseMem = &_brk;
51  kernelAllocationMap.brk = &_brk;
52  kernelAllocationMap.endMem = &_ramend;
53 
56 
59  }
60 
63  }
64 
65  /* Give hand to user */
66  main();
67 }
68 
69 /* TODO: Find something better to perform this verification... */
70 #ifndef LZ_STATIC_ANALYSIS
71 #if (LZ_CONFIG_ON_PANIC_INFINITE_LOOP + LZ_CONFIG_ON_PANIC_SOFTWARE_RESET) != 1
72 #error "Only one kernel panic configuration must be defined in config.h."
73 #endif
74 #endif
75 
76 NORETURN void
78 {
82  /* TODO: Change this by a watchdog software reset */
84  }
85 }
void Arch_InfiniteLoop(void)
Function that loops forever, never returns.
void Scheduler_Init(void)
Initialize the scheduler prior to running it.
Definition: scheduler.c:613
void Arch_InitIdleCpuMode(void)
Initialize idle CPU modes.
Definition: arch.c:27
void Kernel_Main(void)
This is the kernel entry point.
Definition: kernel.c:47
const bool LZ_CONFIG_INSTRUMENT_CONTEXT_SWITCHES
When set, add instrumentation code to measure context switches.
AllocationMap kernelAllocationMap
The allocation map for the whole kernel.
Definition: kernel.c:40
Memory management API.
Include appropriate config file.
void Arch_InitSerial(void)
Initialize serial line with default configuration at system startup.
Definition: usart.c:480
void * brk
Break position, points to the first location beyond the current end of the heap.
Definition: memory.h:35
Lazuli scheduler interface.
Symbols defined by the linker.
void * baseMem
Base address of the memory region.
Definition: memory.h:29
void Kernel_Panic(void)
Kernel panic.
Definition: kernel.c:77
void Arch_InitInstrumentation(void)
Initialize the context switch instrumentation.
Definition: arch.c:69
const bool LZ_CONFIG_MODULE_SERIAL_USED
Use module "serial": Serial interface configuration.
const bool LZ_CONFIG_ON_PANIC_INFINITE_LOOP
When 1, run an infinite loop on kernel panic.
Represents a map of the allocated memory regions and useful memory handlers for a task or the kernel...
Definition: memory.h:25
const bool LZ_CONFIG_ON_PANIC_SOFTWARE_RESET
When 1, perform a software reset on kernel panic.
void * endMem
End address of the memory region.
Definition: memory.h:40
Basic type definitions and useful macros.
Architecture Abstraction API.
uint8_t _brk
Initial break address.
int main(void)
Main entry point for user tasks.
void Arch_ResetSystem(void)
Reset the whole system.
uint8_t _ramend
Last address of RAM.