aboutsummaryrefslogtreecommitdiffstats
path: root/src/boot.asm
diff options
context:
space:
mode:
authoruser <user@clank>2026-07-15 23:54:13 +0200
committeruser <user@clank>2026-07-15 23:54:13 +0200
commitab3ebbe227c72b745a46f9233fbfbb27477586b8 (patch)
treed71f87605d17c5653f34ebcdef3941f898cd5b91 /src/boot.asm
parentgbos scaffold: working cooperative microkernel (verified ABAB in emulator) (diff)
downloadgbos-ab3ebbe227c72b745a46f9233fbfbb27477586b8.tar.gz
gbos-ab3ebbe227c72b745a46f9233fbfbb27477586b8.tar.xz
gbos-ab3ebbe227c72b745a46f9233fbfbb27477586b8.zip
kernel: implement fork()
- sys_fork: switch to a kernel stack, bump-allocate a cart-RAM bank, copy the parent's 8 KiB bank via a WRAM bounce buffer, plant a switch-in frame so the child returns 0 to the post-fork PC, fill the child PCB (shared ROM text) - add AllocRamBank (bump allocator) + FindFreeSlot helpers - demo: init forks; parent prints P, child prints C (PCPC...); nested fork gives three distinct pids (123...) - README: document the fork mechanism, mark syscall status
Diffstat (limited to '')
-rw-r--r--src/boot.asm12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/boot.asm b/src/boot.asm
index 513c392..73ea860 100644
--- a/src/boot.asm
+++ b/src/boot.asm
@@ -50,18 +50,12 @@ KernelInit:
call CopyHramCode ; move context-switch trampoline into HRAM
call ProcInit ; wipe process table
- ; --- spawn the two demo tasks (text-in-ROM model) ---
- ; task A: entry TaskA, RAM bank 0, u-area WRAM bank 1
- ld hl, TaskA
- ld b, 0 ; RAM bank
+ ; --- spawn the init task (pid 1); it fork()s the rest ---
+ ld hl, TaskInit
+ ld b, 0 ; cart-RAM bank 0
ld c, 1 ; WRAM u-area bank
call ProcCreate
- ld hl, TaskB
- ld b, 1
- ld c, 2
- call ProcCreate
-
call SchedInit ; pick first task, set wCurProc
; interrupts: enable timer for preemption