Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
bcc5473
update README
chrisdedman Sep 23, 2025
18354ac
[FIX] fix param name in gettime
chrisdedman Sep 25, 2025
b8303e7
[UPDATE] updated printf param to const
chrisdedman Sep 25, 2025
6674fed
[ADD] kernel halt and panic for unexpected behaviors
chrisdedman Sep 26, 2025
6383205
refactor + added discard commands + reserve spaces for page table
chrisdedman Sep 26, 2025
16848e6
[REFACTOR] consolidate irq files to interrupt file
chrisdedman Sep 26, 2025
341be3f
[refactor] updated the way we handled irq testing
chrisdedman Sep 26, 2025
582167b
update function documentation
chrisdedman Sep 26, 2025
1394ac2
[ADD] custom division operation
chrisdedman Sep 26, 2025
e8d4c3c
added more macros + moved the irq handlers from irq file to interrupt…
chrisdedman Sep 26, 2025
b812201
added mapping file for linker instruction address mapping
chrisdedman Sep 26, 2025
ae908ba
fix documentation mismatch + add .data init
chrisdedman Sep 26, 2025
3b98104
move the attribute noreturn order
chrisdedman Sep 26, 2025
0cb891f
updated panic to use more modern C standard (C23)
chrisdedman Sep 27, 2025
8d687f0
Updated stack start and end + added proper heap start and end
chrisdedman Sep 27, 2025
9c733c8
enforce std=C23
chrisdedman Sep 27, 2025
1bb8a20
update mapping with no debu mode
chrisdedman Sep 27, 2025
0e4548e
updated doc with updated stack name
chrisdedman Sep 27, 2025
f76a639
Updated header documentation for Doxygen auto generated docs
chrisdedman Oct 1, 2025
6598063
Updated implementation documentation for Doxygen auto generated docum…
chrisdedman Oct 1, 2025
405bf32
Added config file for Doxygen.
chrisdedman Oct 1, 2025
b136ecb
remove MAN generated documentation from Doxygen config
chrisdedman Oct 1, 2025
5e70375
Added Doxygen documentation generator to makefile
chrisdedman Oct 1, 2025
c51f5fa
added README as main page
chrisdedman Oct 1, 2025
cc96309
update formatting
chrisdedman Oct 1, 2025
372b587
init implementation of kernel malloc
chrisdedman Oct 1, 2025
d5f3d19
added init of kernel malloc to main kernel
chrisdedman Oct 1, 2025
558b3b4
added docs to gitignore
chrisdedman Oct 1, 2025
9c4e829
refactor codebase structure to move kernel/ and user/ directories to …
chrisdedman Oct 1, 2025
37e751d
Switch ifndef to pragam once
chrisdedman Oct 22, 2025
1d8c8ec
added easy open documentation
chrisdedman Oct 22, 2025
5421419
updated variables
chrisdedman Oct 22, 2025
6660349
Added testing for memory
chrisdedman Oct 22, 2025
c21f049
Refactor printf file by simplifiying printf parameters handling
chrisdedman Oct 23, 2025
53f300f
Added documentation for doxygen + FSM for printf function
chrisdedman Oct 23, 2025
a98be34
Added testing for printf
chrisdedman Oct 23, 2025
3040b6f
mapp update
chrisdedman Oct 23, 2025
eaf84e5
Merge branch 'main' into Develop
chrisdedman Oct 23, 2025
2e04877
Merge branch 'main' into Develop
chrisdedman Oct 27, 2025
421a45e
Merge branch 'main' into Develop
chrisdedman Oct 27, 2025
dee25b4
remove map_file.map do VC
chrisdedman Oct 30, 2025
f0cab5f
Added debugging make command to makefile
chrisdedman Oct 30, 2025
53aaedd
Added todo for printf file to refactor the file
chrisdedman Oct 30, 2025
7ca198b
added more testing for malloc on kernel.c
chrisdedman Oct 30, 2025
1c124a0
added structure definition for linked list kmalloc
chrisdedman Oct 30, 2025
e21f048
Move from linear kmalloc to dynamic kmalloc using linked list.
chrisdedman Oct 30, 2025
bfd869b
Merge branch 'main' into Develop
chrisdedman Oct 30, 2025
0775036
Merge branch 'main' into Develop
chrisdedman Oct 30, 2025
bf0a560
Added doxygen docs deployement badge to readme
chrisdedman Oct 30, 2025
cb693b9
refatored kmalloc to separate the split block + added doxygem
chrisdedman Nov 5, 2025
a8a619a
added todo comment for memory file testing section
chrisdedman Nov 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/build
.DS_Store
/docs
/docs
map_file.map
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,7 @@ docs:
doc:
open "docs/html/index.html"

debug:
make KFLAGS="-DUSE_KTESTS"

.PHONY: all clean qemu docker docs
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# AstraKernel ~ A minimal ARM kernel for QEMU

[![GitHub release (including pre-releases)](https://img.shields.io/github/v/release/sandbox-science/AstraKernel?include_prereleases)](https://github.com/sandbox-science/AstraKernel/releases)
[![Doxygen Docs](https://github.com/sandbox-science/AstraKernel/actions/workflows/static.yml/badge.svg?branch=main)](https://github.com/sandbox-science/AstraKernel/actions/workflows/static.yml)

AstraKernel is a minimal experimental kernel written in modern C and ARM assembly, designed to run on
**QEMU’s Versatile AB/PB board with a Cortex‑A8 CPU override (-cpu cortex-a8)**. This setup keeps the
Expand Down
32 changes: 29 additions & 3 deletions include/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,37 @@
extern "C"
{
#endif
/**
* @enum block_state
* @brief Enumeration of block states in the memory allocator.
*
* This enum defines the possible states of a memory block in the
* kernel memory allocator.
*/
enum block_state {
BLOCK_FREE = 0, /**< Block is free and available for allocation. */
BLOCK_USED /**< Block is currently allocated and in use. */
};

void kmalloc_init(void *start, void *limit);
void* kmalloc(size_t size);
size_t kmalloc_remaining(void);
/**
* @brief Header structure for memory blocks in the allocator.
*
* Each allocated or free block in the kernel memory allocator is
* preceded by a header that contains metadata about the block.
*/
struct header {
size_t size; /**< Size of the memory block (excluding header). */
enum block_state state; /**< State of the block (free or used). */
struct header *next; /**< Pointer to the next block in the linked list. */
struct header *prev; /**< Pointer to the previous block in the linked list. */
};

struct header *kmalloc_get_head(void);

void kmalloc_init(void *start, void *limit);
void* kmalloc(size_t size);
void kfree(void *block);
int kmalloc_test(void);
#ifdef __cplusplus
}
#endif
Expand Down
18 changes: 12 additions & 6 deletions src/kernel/kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ void not_main(void)
void *p2 = kmalloc(48);
printf("kmalloc(10) addr: %p\n", p);
printf("kmalloc(48) addr: %p\n", p2);
struct header *h = (struct header *)p - 1;
struct header *h2 = (struct header *)p2 - 1;
printf("size of kmalloc(10) %d\nsize of kmalloc(48) %d\n", h->size, h2->size);
kfree(p);
kfree(p2);

char *buf = kmalloc(1);
if (buf)
Expand Down Expand Up @@ -114,20 +119,21 @@ void not_main(void)
#define TIMER_TICK_TEST not_main()
#define SANITY_CHECK irq_sanity_check()
#define CALL_SVC_0 __asm__ volatile ("svc #0")
#define KMALLOC_TEST kmalloc_test()

// Entry point for the kernel
void kernel_main(void)
{
clear();
kmalloc_init(&__heap_start__, &__heap_end__);
kmalloc_remaining();

/* TESTS */
#ifdef USE_KTESTS
SANITY_CHECK;
CALL_SVC_0;
TIMER_TICK_TEST;
#endif
#ifdef USE_KTESTS
SANITY_CHECK;
CALL_SVC_0;
KMALLOC_TEST;
TIMER_TICK_TEST;
#endif

/* Back to normal operations */
init_message();
Expand Down
Loading