Skip to content
This repository was archived by the owner on Dec 31, 2025. It is now read-only.

Commit d0da406

Browse files
committed
A bunch of more docs 😄
1 parent 9e56e2a commit d0da406

8 files changed

Lines changed: 89 additions & 0 deletions

File tree

kernel/src/lib/bitmap.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
#pragma once
22
#include <stdint.h>
33

4+
/**
5+
* @brief Clears the specified bit in a bitmap.
6+
*
7+
* @param bitmap Pointer to the bitmap.
8+
* @param bit The bit to clear.
9+
*/
410
void bitmap_clear(uint8_t *bitmap, uint64_t bit);
11+
12+
/**
13+
* @brief Sets the specified bit in a bitmap.
14+
*
15+
* @param bitmap Pointer to the bitmap.
16+
* @param bit The bit to set.
17+
*/
518
void bitmap_set(uint8_t *bitmap, uint64_t bit);
19+
20+
/**
21+
* @brief Gets the specified bit in a bitmap.
22+
*
23+
* @param bitmap Pointer to the bitmap.
24+
* @param bit The bit to get.
25+
*/
626
uint8_t bitmap_get(uint8_t *bitmap, uint64_t bit);

kernel/src/lib/string.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#pragma once
22
#include <stddef.h>
33

4+
// Standard C stuff.
5+
46
void *memcpy(void *restrict dest, const void *restrict src, size_t n);
57
void *memset(void *s, int c, size_t n);
68
void *memmove(void *dest, const void *src, size_t n);

kernel/src/mem/mmutil.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ extern uint64_t __limine_requests_start, __limine_requests_end;
1111
#define VIRT_BASE address_request.response->virtual_base
1212
#define PHYS_BASE address_request.response->physical_base
1313

14+
// Makes sure an addess is in the higher half.
1415
#define HIGHER_HALF(addr) \
1516
((void *)((uint64_t)(addr) < HHDM_OFFSET ? (uint64_t)(addr) + HHDM_OFFSET : (uint64_t)(addr)))
17+
// Translate a address in the higher half to physical.
1618
#define PHYSICAL(addr) \
1719
((void *)((uint64_t)(addr) >= HHDM_OFFSET ? (uint64_t)(addr) - HHDM_OFFSET : (uint64_t)(addr)))

kernel/src/mem/pmm.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,28 @@
55

66
#define PAGE_SIZE 0x1000
77

8+
/**
9+
* @brief Initializes the Physical Memory Manager
10+
*
11+
* @param memmap_request Pointer to the Limine memory map request.
12+
* @param hhdm_request Pointer to the Limine HHDM request.
13+
*/
814
void pmm_init(volatile struct limine_memmap_request *memmap_request,
915
volatile struct limine_hhdm_request *hhdm_request);
16+
17+
/**
18+
* @brief Allocates a physical frame
19+
*
20+
* @param n The amount of frames to allocate
21+
* @param higher_half Specifies if the HHDM offset should be added to the pointer returned.
22+
* @return Physical (or virtual if `higher_half` is true) address of the alloacted frame.
23+
*/
1024
void *palloc(size_t n, bool higher_half);
25+
26+
/**
27+
* @brief Frees a physical frame
28+
*
29+
* @param addr The address of the frame (can be either virtual or physical).
30+
* @param n The amount of frames to free.
31+
*/
1132
void pfree(void *addr, size_t n);

kernel/src/mem/vmm.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,16 @@ typedef struct vmm_node_t
3939
struct vmm_node_t *next;
4040
} vmm_node_t;
4141

42+
/**
43+
* @brief Initializes (and allocates) a new VMC.
44+
*
45+
* @param pml4 The pagemap it will use.
46+
* @param flags Flags for the root VMO.
47+
* @return Pointer to the new VMC.
48+
*/
4249
vmm_context_t *vmm_context_init(uint64_t *pml4, uint64_t flags);
50+
51+
/**
52+
* @brief Initializes the Virtual Memory Manager
53+
*/
4354
void vmm_init();

kernel/src/test/test.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
#define TEST_SECTION __attribute__((section(".testcases"), used))
77

8+
/**
9+
* @brief Representing a test result
10+
*/
811
typedef struct
912
{
1013
const char *name;
@@ -16,23 +19,37 @@ typedef struct
1619
uint32_t line;
1720
} test_result_t;
1821

22+
/**
23+
* @brief Representing a test function
24+
*/
1925
typedef void (*test_func_t)(test_result_t *result);
2026

27+
/**
28+
* @brief Representing a test case.
29+
*/
2130
typedef struct
2231
{
2332
const char *name;
2433
const char *group;
2534
test_func_t func;
2635
} test_case_t;
2736

37+
/**
38+
* @brief Macro for easily defining a test case.
39+
*/
2840
#define TEST(GROUP, NAME, BODY) \
2941
static void __test_func_##NAME(test_result_t *result); \
3042
static const test_case_t __test_case_##NAME TEST_SECTION = { \
3143
.name = #NAME, .group = #GROUP, .func = __test_func_##NAME}; \
3244
static void __test_func_##NAME(test_result_t *result) BODY
3345

46+
/**
47+
* @brief Runs every test (if `UNIT_TEST_ENABLED` is defined).
48+
*/
3449
void test_run_all();
3550

51+
// === Basic Testing Things ===
52+
3653
#define ASSERT_TRUE(expr) \
3754
do \
3855
{ \

kernel/src/util/kprintf.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
#pragma once
22
#include <__stdarg_va_list.h>
33

4+
/**
5+
* @brief Initializes `kprintf`
6+
*/
47
void _kprintf_init();
8+
9+
/**
10+
* @brief Prints the specified format to the term and serial devices.
11+
*
12+
* @param fmt The format to print.
13+
* @param ... Other stuff (idk what it is called)
14+
* @return Length of printed buffer (max 1024 bytes) (-1 on fail)
15+
*/
516
int kprintf(const char *fmt, ...);
617
int kvprintf(const char *fmt, va_list args);

kernel/src/util/qemu.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,9 @@
44
#define QEMU_EXIT_SUCCESS 0x10
55
#define QEMU_EXIT_FAILURE 0x11
66

7+
/**
8+
* @brief Exits QEMU.
9+
*
10+
* @param code The error code. Use the above.
11+
*/
712
void qemu_exit(uint8_t code);

0 commit comments

Comments
 (0)