feat: hello-world user-mode app loaded from initrd via VFS

- Created apps/hello-world/hello-world.S: AT&T assembly user program that
  calls SYS_WRITE to print 'Hello, World' then SYS_EXIT(0)
- Created apps/user.ld: linker script for user apps at 0x08048000
- Created scripts/build_apps.sh: builds each app dir into flat binary
- Updated CMakeLists.txt: added apps build target in ISO pipeline
- Updated gen_initrd.sh: packs built binaries from build/apps_bin/
- Updated kernel.c: replaced inline machine code with VFS-based loading
  of hello-world from /initrd/hello-world via cpio_find()

Verified: hello-world binary (49 bytes) loads from CPIO initrd,
prints 'Hello, World', and exits with code 0.
This commit is contained in:
AI
2026-02-23 12:30:36 +00:00
parent 0c5aa72fd3
commit a6e6e3d8ca
6 changed files with 141 additions and 63 deletions

View File

@@ -1,14 +1,16 @@
#!/bin/sh
# Generate CPIO initial ramdisk from apps directory
# Usage: gen_initrd.sh <apps_dir> <output_file>
# Generate CPIO initial ramdisk from built application binaries.
# Usage: gen_initrd.sh <binaries_dir> <output_file>
# Packs all files in <binaries_dir> into a newc-format CPIO archive.
set -e
APPS_DIR="$1"
BIN_DIR="$1"
OUTPUT="$2"
# Ensure output directory exists
mkdir -p "$(dirname "$OUTPUT")"
cd "$APPS_DIR"
find . -not -name '.' | cpio -o -H newc > "$OUTPUT" 2>/dev/null
cd "$BIN_DIR"
# Only pack actual binary files (no .o, .elf intermediates)
find . -maxdepth 1 -type f ! -name '*.o' ! -name '*.elf' | cpio -o -H newc > "$OUTPUT" 2>/dev/null
echo "Generated initrd: $(wc -c < "$OUTPUT") bytes"