Compare commits
8 Commits
spinlock
...
ccc8985d4c
| Author | SHA1 | Date | |
|---|---|---|---|
| ccc8985d4c | |||
|
0482f594ef
|
|||
|
b02a4b5284
|
|||
|
32f3889565
|
|||
|
803ac0879b
|
|||
|
9fc55f98d8
|
|||
|
11bd628821
|
|||
| 80d8b49560 |
48
Makefile
48
Makefile
@@ -1,31 +1,41 @@
|
|||||||
SOURCES = src/sched/spinlock.c 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/term.c src/idt/idt.c src/mem/gdt/gdt.c src/mem/misc/utils.c src/time/timer.c src/kmain.c
|
|
||||||
|
|
||||||
|
BUILDDIR := build
|
||||||
|
ELFFILE := pepperk
|
||||||
|
SRC := src
|
||||||
|
SOURCES := $(shell find src -name '*.c')
|
||||||
|
OBJFILES := $(patsubst $(SRC)/%.c, $(BUILDDIR)/%.o, $(SOURCES))
|
||||||
|
|
||||||
|
CC := x86_64-elf-gcc
|
||||||
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_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
|
CC_PROBLEMATIC_FLAGS=-Wno-unused-parameter -Wno-unused-variable
|
||||||
|
|
||||||
.PHONY: build build-iso debug debug2 run clean
|
LD := x86_64-elf-ld
|
||||||
|
|
||||||
build:
|
$(ELFFILE): $(BUILDDIR) $(OBJFILES)
|
||||||
mkdir -p build
|
nasm -f elf64 src/idt/idt.S -o $(BUILDDIR)/idt_stub.o
|
||||||
rm -f *.o build/*.o
|
$(LD) -o $(ELFFILE) -T linker.ld $(OBJFILES) $(BUILDDIR)/idt_stub.o
|
||||||
x86_64-elf-gcc -g -c -Isrc $(SOURCES) $(CC_PROBLEMATIC_FLAGS) $(CC_FLAGS)
|
# Get the symbols for debugging
|
||||||
mv *.o build/
|
nm -n $(ELFFILE) | awk '$$2 ~ /[TtDdBbRr]/ {print $$1, $$3}' > symbols.map
|
||||||
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
|
|
||||||
python3 symbols.py
|
python3 symbols.py
|
||||||
nasm -f elf64 symbols.S -o build/symbols.o
|
nasm -f elf64 symbols.S -o $(BUILDDIR)/symbols.o
|
||||||
x86_64-elf-ld -o pepperk -T linker.ld build/*.o
|
$(LD) -o $(ELFFILE) -T linker.ld $(OBJFILES) $(BUILDDIR)/idt_stub.o
|
||||||
|
|
||||||
|
$(BUILDDIR):
|
||||||
|
@mkdir -p $(BUILDDIR)
|
||||||
|
|
||||||
|
$(BUILDDIR)/%.o: $(SRC)/%.c
|
||||||
|
mkdir -p $(dir $@)
|
||||||
|
$(CC) -g -c -Isrc $< $(CC_PROBLEMATIC_FLAGS) $(CC_FLAGS) -o $@
|
||||||
|
|
||||||
limine/limine:
|
limine/limine:
|
||||||
rm -rf limine
|
rm -rf limine
|
||||||
git clone https://github.com/limine-bootloader/limine.git --branch=v9.x-binary --depth=1
|
git clone https://github.com/limine-bootloader/limine.git --branch=v9.x-binary --depth=1
|
||||||
$(MAKE) -C limine
|
$(MAKE) -C limine
|
||||||
|
|
||||||
build-iso: limine/limine build
|
build-iso: limine/limine $(ELFFILE)
|
||||||
rm -rf iso_root
|
rm -rf iso_root
|
||||||
mkdir -p iso_root/boot
|
mkdir -p iso_root/boot
|
||||||
cp -v pepperk iso_root/boot
|
cp -v $(ELFFILE) iso_root/boot
|
||||||
mkdir -p iso_root/boot/limine
|
mkdir -p iso_root/boot/limine
|
||||||
cp -v limine.conf iso_root/boot/limine
|
cp -v limine.conf iso_root/boot/limine
|
||||||
mkdir -p iso_root/EFI/BOOT
|
mkdir -p iso_root/EFI/BOOT
|
||||||
@@ -39,16 +49,20 @@ build-iso: limine/limine build
|
|||||||
iso_root -o pepper.iso
|
iso_root -o pepper.iso
|
||||||
./limine/limine bios-install pepper.iso
|
./limine/limine bios-install pepper.iso
|
||||||
|
|
||||||
|
.PHONY: debug
|
||||||
debug:
|
debug:
|
||||||
/usr/bin/qemu-system-x86_64 -drive file=pepper.iso -s -S -d int -D qemu.log -no-reboot -no-shutdown &
|
/usr/bin/qemu-system-x86_64 -drive file=pepper.iso -s -S -d int -D qemu.log -no-reboot -no-shutdown &
|
||||||
gdb pepperk --command=debug.gdb
|
gdb $(ELFFILE) --command=debug.gdb
|
||||||
|
|
||||||
|
.PHONY: debug2
|
||||||
debug2:
|
debug2:
|
||||||
/usr/bin/qemu-system-x86_64 -drive file=pepper.iso -s -S -d int -no-reboot -no-shutdown &
|
/usr/bin/qemu-system-x86_64 -drive file=pepper.iso -s -S -d int -no-reboot -no-shutdown &
|
||||||
pwndbg pepperk --command=debug.gdb
|
pwndbg $(ELFFILE) --command=debug.gdb
|
||||||
|
|
||||||
|
.PHONY: run
|
||||||
run: build-iso
|
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
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
rm -rf *.o symbols.map symbols.S pepperk iso_root pepper.iso limine build/*.o
|
rm -rf $(BUILDDIR) symbols.map symbols.S $(ELFFILE) iso_root pepper.iso limine
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
#define PEPPEROS_VERSION_MAJOR "0"
|
#define PEPPEROS_VERSION_MAJOR "0"
|
||||||
#define PEPPEROS_VERSION_MINOR "0"
|
#define PEPPEROS_VERSION_MINOR "0"
|
||||||
#define PEPPEROS_VERSION_PATCH "58"
|
#define PEPPEROS_VERSION_PATCH "58"
|
||||||
#define PEPPEROS_SPLASH "\x1b[38;5;196mPepperOS\x1b[0m version "PEPPEROS_VERSION_MAJOR"."PEPPEROS_VERSION_MINOR"."PEPPEROS_VERSION_PATCH"\n"
|
#define PEPPEROS_SPLASH "\x1b[38;5;196mPepperOS\x1b[0m version \x1b[38;5;220m"PEPPEROS_VERSION_MAJOR"."PEPPEROS_VERSION_MINOR"."PEPPEROS_VERSION_PATCH"\x1b[0m built on \x1b[38;5;40m"__DATE__" "__TIME__"\x1b[0m\n"
|
||||||
|
|
||||||
/* process */
|
/* process */
|
||||||
#define PROCESS_NAME_MAX 64
|
#define PROCESS_NAME_MAX 64
|
||||||
|
|||||||
@@ -61,8 +61,8 @@ int serial_init()
|
|||||||
// Set normal operation mode
|
// Set normal operation mode
|
||||||
outb(PORT + 4, 0x0F);
|
outb(PORT + 4, 0x0F);
|
||||||
|
|
||||||
DEBUG("*** Welcome to PepperOS! ***");
|
|
||||||
init.serial = true;
|
init.serial = true;
|
||||||
|
DEBUG("*** Welcome to PepperOS! (built @ %s %s) ***", __DATE__, __TIME__);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -136,8 +136,8 @@ void term_init()
|
|||||||
{
|
{
|
||||||
uint32_t bgColor = 0x252525;
|
uint32_t bgColor = 0x252525;
|
||||||
ft_ctx = flanterm_fb_init(
|
ft_ctx = flanterm_fb_init(
|
||||||
kmalloc,
|
NULL,
|
||||||
flanterm_free_wrapper,
|
NULL,
|
||||||
boot_ctx.fb->address, boot_ctx.fb->width, boot_ctx.fb->height, boot_ctx.fb->pitch,
|
boot_ctx.fb->address, boot_ctx.fb->width, boot_ctx.fb->height, boot_ctx.fb->pitch,
|
||||||
boot_ctx.fb->red_mask_size, boot_ctx.fb->red_mask_shift,
|
boot_ctx.fb->red_mask_size, boot_ctx.fb->red_mask_shift,
|
||||||
boot_ctx.fb->green_mask_size, boot_ctx.fb->green_mask_shift,
|
boot_ctx.fb->green_mask_size, boot_ctx.fb->green_mask_shift,
|
||||||
|
|||||||
@@ -94,15 +94,16 @@ void kmain()
|
|||||||
CLEAR_INTERRUPTS;
|
CLEAR_INTERRUPTS;
|
||||||
if (!LIMINE_BASE_REVISION_SUPPORTED) hcf();
|
if (!LIMINE_BASE_REVISION_SUPPORTED) hcf();
|
||||||
|
|
||||||
serial_init();
|
|
||||||
timer_init();
|
|
||||||
|
|
||||||
// Populate boot context
|
// Populate boot context
|
||||||
boot_ctx.fb = framebuffer_request.response ? framebuffer_request.response->framebuffers[0] : NULL;
|
boot_ctx.fb = framebuffer_request.response ? framebuffer_request.response->framebuffers[0] : NULL;
|
||||||
boot_ctx.mmap = memmap_request.response ? memmap_request.response : NULL;
|
boot_ctx.mmap = memmap_request.response ? memmap_request.response : NULL;
|
||||||
boot_ctx.hhdm = hhdm_request.response ? hhdm_request.response : NULL;
|
boot_ctx.hhdm = hhdm_request.response ? hhdm_request.response : NULL;
|
||||||
boot_ctx.kaddr = kerneladdr_request.response ? kerneladdr_request.response : NULL;
|
boot_ctx.kaddr = kerneladdr_request.response ? kerneladdr_request.response : NULL;
|
||||||
|
|
||||||
|
term_init();
|
||||||
|
serial_init();
|
||||||
|
timer_init();
|
||||||
|
|
||||||
boot_mem_display();
|
boot_mem_display();
|
||||||
pmm_init(boot_ctx);
|
pmm_init(boot_ctx);
|
||||||
|
|
||||||
@@ -112,8 +113,6 @@ void kmain()
|
|||||||
|
|
||||||
keyboard_init(FR);
|
keyboard_init(FR);
|
||||||
|
|
||||||
term_init();
|
|
||||||
|
|
||||||
gdt_init();
|
gdt_init();
|
||||||
idt_init();
|
idt_init();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user