Kernelite 0.1.0
Kernelite is a minimalist, educational operating system kernel built from scratch. The project aims to recreate core components of the Linux architecture to explore the fundamentals of operating system design and hardware-software interaction.
Loading...
Searching...
No Matches
utils.h
Go to the documentation of this file.
1
13#ifndef UTILS_UTILS_H
14#define UTILS_UTILS_H
15
16#include <stdbool.h>
17#include <stdint.h>
18
33typedef union mpidr_el1_t {
35 uint64_t raw;
36 struct __attribute__((packed)) {
40 uint32_t aff0 : 8;
41
44 uint32_t aff1 : 8;
45
47 uint32_t aff2 : 8;
48
51 bool mt : 1;
52
54 uint32_t res0_29_25 : 5;
55
58 bool uniprocessor : 1;
59
61 uint32_t res1 : 1;
62
65 uint32_t aff3 : 8;
66
69 uint32_t res0_63_40 : 24;
70 };
72_Static_assert(sizeof(mpidr_el1_t) == 8, "MPIDR_EL1 must be 64 bits");
73
77void print_kernelite_logo(void);
78
83uint32_t get_core_id(void);
84
88void print_current_el(void);
89
99bool setup_page_allocator(const void *fdt_addr);
100
101#endif /* UTILS_UTILS_H */
AArch64 Multiprocessor Affinity Register (MPIDR_EL1, read-only).
Definition utils.h:33
bool uniprocessor
[30] U: Uniprocessor flag. Set to 1 if the implementation is a single PE with no affinity structure.
Definition utils.h:58
uint32_t res0_29_25
[29:25] Reserved.
Definition utils.h:54
uint32_t aff1
[15:8] Aff1: Cluster ID. Groups of cores sharing L2 cache or a cluster block typically share the same...
Definition utils.h:44
uint32_t aff3
[39:32] Aff3: Highest-level affinity (multi-socket or NUMA node). Zero on most embedded/server implem...
Definition utils.h:65
uint32_t res0_63_40
[63:40] RES1 / implementation defined. Mask before use.
Definition utils.h:69
uint32_t aff2
[23:16] Aff2: Higher-level cluster or socket ID.
Definition utils.h:47
uint32_t aff0
[7:0] Aff0: Thread/core ID within a cluster. On most simple systems this is the linear core number....
Definition utils.h:40
uint64_t raw
Raw 64-bit register value.
Definition utils.h:35
bool mt
[24] MT: Multithreading. When 1, Aff0 identifies a thread within a core rather than a core within a c...
Definition utils.h:51
uint32_t res1
[31] RES1: Always reads as 1 at EL1.
Definition utils.h:61
void print_current_el(void)
Prints the current exeception level.
Definition utils.c:196
bool setup_page_allocator(const void *fdt_addr)
Set up the global page allocator.
Definition utils.c:106
void print_kernelite_logo(void)
Prints the Kernelite ASCII art logo and banner to the console.
Definition utils.c:144
uint32_t get_core_id(void)
Gets the core id.
Definition utils.c:189