u/Dhrubo_sayinghi

been working on x86 kernel called baSic_ for the past few months. thought Id share some of the nastier problems i ran into.

but first..whats in it till now:

custom MBR bootloader, stage2 GDT + protected mode transition, VGA text driver, IDT/PIC/IRQ, PIT at 1000Hz, PS/2 keyboard, CMOS RTC, physical memory manager (bitmap yk), two level x86 paging, free list heap, VFS + ramfs, FAT12, round robin scheduler, interactive shell with some built ins(3/4 will fail rn. working on the bugs), a very basic text editor and a space shooter game.

the problems worth talking about:

ATA secondary bus detection in QEMU is a mess imo. primary master works fine byt putting a data disk on index=1 or index=2 gets you status 0x41 (DRDY+ERR) regardless of what you do. ended up embedding the init config directly in the kernel binary fn and will try revisit on real hardware. if anyone has gotten ATA slave detection working reliably in QEMU id actually like to know how.

VGA blink bit: on real hardware if your background color is >= 8 the hardware blink bit fires and you get visible flicker. have to clear bit 3 of attribute controller register 0x10 at init. cost me an embarrassing amount of time.

FAT12 cluster math: the 12-bit entry unpacking with the cluster+cluster/2 offset ig trips everyone up the first time. odd clusters shift right 4, even clusters mask the high nibble. obvious in hindsight.

signal table sizing: had SIGCHLD defined as 17 with SIG_MAX at 8. silent out of bounds write on every child exit. no crash, just corruption.

fork() ~: in a kernel with no perprocess address space is a fun exercise in "what does fork even mean here." copied the kernel stack, fixed up esp relative to the child's own stack buffer, set eax=0 in the saved context. works but it's definitely not real fork.

source: github.com/dhrubo-10/baSic_

contributions, ideas and bug fixes are welcome. currently working on history persistence,some shell utilities, and eventually a real userspace with the shell moved out of ring 0.

u/Dhrubo_sayinghi — 16 days ago
▲ 1 r/osdev

for baSic_ .. wiring persistent shell config. reading directives from a FAT12 disk at boot, parsing in kernel C, applying before shell launches. current approach is a flat key=value file, INIT.CFG, parsed line by line in disksync_run_init(). supports motd=, env= right now, adding alias= and path=.

it works. but parsing strings in kernel space before the shell even exists, storing aliases in a static table, zero error recovery. it kinda feel like im doing this in the wrong layer entirely.

flat file feels wrong in kernel space but i have no userspace yet to push it to. what's the actual pattern here / does everyone just do the ugly thing and move on?

reddit.com
u/Dhrubo_sayinghi — 18 days ago

If you're building a VCS in C.

What are Git's architectural or UX decisions you genuinely wish were done differently. not just 'it's confusing', but why it's confusing at the design level?

reddit.com
u/Dhrubo_sayinghi — 20 days ago