Build folder + coding style guidelines

This commit is contained in:
2026-03-11 14:59:20 +01:00
parent b9c77a316a
commit 1dd4e728d4
5 changed files with 98 additions and 34 deletions

3
.gitignore vendored
View File

@@ -10,4 +10,5 @@ iso_root
.gdb_history .gdb_history
symbols.map symbols.map
symbols.S symbols.S
*.log *.log
build/

View File

@@ -1,24 +0,0 @@
up to doom:
- Return from pedicel_main() normally (to idle)
** Checkpoint: ring0 process working
- VFS layer (open/read/write/...) with USTar filesystem (for initrd)
** Checkpoint: files not linked to but accessible by the kernel
- Ring3 memory mappings
- Ring3 privilege switch
** Checkpoint: welcome to userland
- Syscall interface
- Implement syscalls needed for doom
** Checkpoint: can run simple programs, ring 3, loaded from filesystem
- Properly handle the keyboard interrupt (keyboard buffer)
- Port DOOMgeneric (few functions with Framebuffer/ticks/etc.)
** Achievement: It runs doom!

View File

@@ -1,16 +1,21 @@
SOURCES = src/debug/misc.c src/io/term/flanterm_backends/fb.c src/io/term/flanterm.c src/debug/panic.c src/debug/stacktrace.c src/boot/boot.c src/sched/scheduler.c src/sched/process.c src/mem/heap/kheap.c src/mem/paging/vmm.c src/mem/paging/paging.c src/mem/paging/pmm.c src/string/string.c src/io/kbd/ps2.c src/io/serial/serial.c src/io/term/printf.c src/io/term/term.c src/idt/idt.c src/mem/gdt/gdt.c src/mem/misc/utils.c src/time/timer.c src/kmain.c SOURCES = src/debug/misc.c src/io/term/flanterm_backends/fb.c src/io/term/flanterm.c src/debug/panic.c src/debug/stacktrace.c src/boot/boot.c src/sched/scheduler.c src/sched/process.c src/mem/heap/kheap.c src/mem/paging/vmm.c src/mem/paging/paging.c src/mem/paging/pmm.c src/string/string.c src/io/kbd/ps2.c src/io/serial/serial.c src/io/term/printf.c src/io/term/term.c src/idt/idt.c src/mem/gdt/gdt.c src/mem/misc/utils.c src/time/timer.c src/kmain.c
PROBLEMATIC_FLAGS=-Wno-unused-parameter -Wno-unused-variable CC_FLAGS=-Wall -Wextra -std=gnu99 -nostdlib -ffreestanding -fno-stack-protector -fno-omit-frame-pointer -fno-stack-check -fno-PIC -ffunction-sections -fdata-sections -mcmodel=kernel
CC_PROBLEMATIC_FLAGS=-Wno-unused-parameter -Wno-unused-variable
.PHONY: build build-iso debug debug2 run clean
build: build:
rm -f *.o mkdir -p build
x86_64-elf-gcc -g -c -Isrc $(SOURCES) $(PROBLEMATIC_FLAGS) -Wall -Wextra -std=gnu99 -nostdlib -ffreestanding -fno-stack-protector -fno-omit-frame-pointer -fno-stack-check -fno-PIC -ffunction-sections -fdata-sections -mcmodel=kernel rm -f *.o build/*.o
nasm -f elf64 src/idt/idt.S -o idt_stub.o x86_64-elf-gcc -g -c -Isrc $(SOURCES) $(CC_PROBLEMATIC_FLAGS) $(CC_FLAGS)
x86_64-elf-ld -o pepperk -T linker.ld *.o mv *.o build/
nasm -f elf64 src/idt/idt.S -o build/idt_stub.o
x86_64-elf-ld -o pepperk -T linker.ld build/*.o
nm -n pepperk | awk '$$2 ~ /[TtDdBbRr]/ {print $$1, $$3}' > symbols.map nm -n pepperk | awk '$$2 ~ /[TtDdBbRr]/ {print $$1, $$3}' > symbols.map
python3 symbols.py python3 symbols.py
nasm -f elf64 symbols.S -o symbols.o nasm -f elf64 symbols.S -o build/symbols.o
x86_64-elf-ld -o pepperk -T linker.ld *.o x86_64-elf-ld -o pepperk -T linker.ld build/*.o
limine/limine: limine/limine:
rm -rf limine rm -rf limine
@@ -46,4 +51,4 @@ run: build-iso
/usr/bin/qemu-system-x86_64 -cdrom pepper.iso -serial stdio /usr/bin/qemu-system-x86_64 -cdrom pepper.iso -serial stdio
clean: clean:
rm -rf *.o symbols.map symbols.S pepperk iso_root pepper.iso limine rm -rf *.o symbols.map symbols.S pepperk iso_root pepper.iso limine build/*.o

83
docs/STYLE.md Normal file
View File

@@ -0,0 +1,83 @@
# Pepper kernel coding style
This document describes the coding style for the Pepper kernel. It is used as a guideline across all source files.
## Indentation
Indentations should be 4 characters long.
## Line length
Lines should not be more than 100 characters long.
## Variables
Variables should be declared at most once per line.
## Braces
Non-function statement blocks should have an opening brace last on the line, and a closing brace first. Exception is made for `else`, `else if` statements and the like:
```c
if (something) {
do_something();
} else if (something_else) {
do_something_else();
}
```
Functions should have their opening brace on a separate line, and the same goes for the closing brace:
```c
void function()
{
do_something();
}
```
## Spaces
Use a space after `if, switch, case, for, do, while` keywords, but not for `sizeof, typeof, alignof, __attribute__` and the like.
For pointers, the asterisk should always be placed adjacent to the type name, like `char* str;`.
## Naming
Functions should be named with whole words, beginning with the corresponding name of the module in the kernel (the parent folder). Words should be spaced with underscores, like so:
```c
serial_init(void* ptr, char* str, int foo);
```
Constants should be named in all caps, separated by underscores:
```c
#define MAX_HEAP_SIZE 0x1000
```
Global variables need to have descriptive names. Local variables can be kept short (especially for loop counters).
## Typedefs
Structures should not be `typedef`'d.
## Functions
Functions should be short, simple, and only do one thing.
Function prototypes should include parameter names and their data types.
## Commenting
Comments should describe what a function does and why, not how it does it.
```c
/*
* This is the preferred style for multi-line
* comments in the Pepper kernel
*/
```
### Resources
Some of the elements here are inspired by the [Linux kernel coding style](https://www.kernel.org/doc/html/v4.10/process/coding-style.html).

View File

@@ -1 +0,0 @@
<EFBFBD>ュ゙<EFBFBD>