Flanterm can write to fb but page fault before process creation. (BEFORE KHEAP UPDATE)

This commit is contained in:
2026-03-04 12:21:20 +01:00
parent 9df33b49d8
commit a7d9e70a61
10 changed files with 33 additions and 49 deletions

View File

@@ -7,7 +7,6 @@ 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 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
objcopy -O elf64-x86-64 -B i386 -I binary zap-light16.psf zap-light16.o objcopy -O elf64-x86-64 -B i386 -I binary zap-light16.psf zap-light16.o
nasm -f elf64 src/idt/idt.S -o idt_stub.o nasm -f elf64 src/idt/idt.S -o idt_stub.o
nasm -f elf64 src/entry.S -o entry.o
x86_64-elf-ld -o pepperk -T linker.ld *.o x86_64-elf-ld -o pepperk -T linker.ld *.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

View File

@@ -1,6 +1,6 @@
OUTPUT_FORMAT(elf64-x86-64) OUTPUT_FORMAT(elf64-x86-64)
ENTRY(_start) ENTRY(kmain)
PHDRS PHDRS
{ {

View File

@@ -30,7 +30,7 @@
#define KERNEL_STACK_SIZE 65536 #define KERNEL_STACK_SIZE 65536
/* heap */ /* heap */
#define KHEAP_SIZE (16*1024*1024) #define KHEAP_SIZE (32*1024*1024)
/* term */ /* term */
#define TERM_HISTORY_MAX_LINES 256 #define TERM_HISTORY_MAX_LINES 256

View File

@@ -203,9 +203,6 @@ struct cpu_status_t* interrupt_dispatch(struct cpu_status_t* context)
if (ticks % SCHEDULER_QUANTUM == 0) if (ticks % SCHEDULER_QUANTUM == 0)
{ {
return scheduler_schedule(context); return scheduler_schedule(context);
//struct cpu_status_t* current_ctx = scheduler_schedule(context);
//process_switch(current_ctx->iret_rsp, current_ctx->iret_rip);
//SET_INTERRUPTS;
} }
break; break;

View File

@@ -42,7 +42,7 @@ int serial_init()
// Set normal operation mode // Set normal operation mode
outb(PORT + 4, 0x0F); outb(PORT + 4, 0x0F);
DEBUG("serial initialized"); DEBUG("*** Welcome to PepperOS! ***");
return 0; return 0;
} }

File diff suppressed because one or more lines are too long

View File

@@ -56,7 +56,7 @@ void kheap_init()
head->size = PAGE_SIZE - sizeof(struct heap_block_t); head->size = PAGE_SIZE - sizeof(struct heap_block_t);
head->free = true; head->free = true;
head->next = NULL; head->next = NULL;
DEBUG("kheap initialized, head=0x%p, size=%u", head, head->size); DEBUG("kernel heap initialized, head=0x%p, max_size=%u bytes", head, KHEAP_SIZE);
} }
void* kmalloc(size_t size) void* kmalloc(size_t size)

View File

@@ -68,5 +68,6 @@ void vmm_setup_pt_root()
void vmm_init() void vmm_init()
{ {
vmm_setup_pt_root(); // NO U
//vmm_setup_pt_root();
} }

View File

@@ -13,6 +13,9 @@
#include "config.h" #include "config.h"
#include "io/serial/serial.h" #include "io/serial/serial.h"
#include "io/term/flanterm.h"
extern struct flanterm_context* ft_ctx;
struct process_t* processes_list; struct process_t* processes_list;
struct process_t* current_process; struct process_t* current_process;
@@ -139,23 +142,6 @@ struct process_t* process_get_next(struct process_t* process)
return process->next; return process->next;
} }
// (from gdt) This will switch tasks ONLY in ring 0
// KERNEL CS = 0x08
// KERNEL SS = 0x10
__attribute__((naked, noreturn))
void process_switch(uint64_t stack_addr, uint64_t code_addr)
{
asm volatile(" \
push $0x10 \n\
push %0 \n\
push $0x202 \n\
push $0x08 \n\
push %1 \n\
iretq \n\
" :: "r"(stack_addr), "r"(code_addr));
}
// Will be used to clean up resources (if any, when we implement it) // Will be used to clean up resources (if any, when we implement it)
// Just mark as DEAD then idle. Scheduler will delete process at next timer interrupt % quantum. // Just mark as DEAD then idle. Scheduler will delete process at next timer interrupt % quantum.
void process_exit() void process_exit()

View File

@@ -34,7 +34,6 @@ struct process_t* process_create(char* name, void(*function)(void*), void* arg);
void process_add(struct process_t** processes_list, struct process_t* process); void process_add(struct process_t** processes_list, struct process_t* process);
void process_delete(struct process_t** processes_list, struct process_t* process); void process_delete(struct process_t** processes_list, struct process_t* process);
struct process_t* process_get_next(struct process_t* process); struct process_t* process_get_next(struct process_t* process);
void process_switch(uint64_t stack_addr, uint64_t code_addr);
void process_exit(); void process_exit();
void process_display_list(struct process_t* processes_list); void process_display_list(struct process_t* processes_list);