Feat: CPU Exceptions and load errors are now shown.
This commit is contained in:
@@ -1,12 +1,71 @@
|
||||
#!/bin/sh
|
||||
export PATH=/usr/local/cross/bin:$PATH
|
||||
#!/bin/bash
|
||||
# Complete build script for SoraOS with 2-stage bootloader
|
||||
|
||||
# 1. Assemble raw binary
|
||||
echo ">>> Assembling boot.asm to boot.bin..."
|
||||
set -e # Exit on any error
|
||||
|
||||
echo "==================================="
|
||||
echo " SoraOS Build System v1.0"
|
||||
echo "==================================="
|
||||
|
||||
# Colors
|
||||
GREEN='\033[0;32m'
|
||||
BLUE='\033[0;34m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m'
|
||||
|
||||
# Step 1: Assemble Stage 1 bootloader (MBR - 512 bytes)
|
||||
echo -e "${BLUE}[1/6]${NC} Assembling Stage 1 bootloader (MBR)..."
|
||||
nasm -f bin boot.asm -o boot.bin
|
||||
|
||||
# 2. Run QEMU as a raw disk drive
|
||||
echo ">>> Running QEMU with boot.bin..."
|
||||
qemu-system-x86_64 -drive format=raw,file=boot.bin
|
||||
# Step 2: Assemble Stage 2 bootloader (extended loader)
|
||||
echo -e "${BLUE}[2/6]${NC} Assembling Stage 2 bootloader..."
|
||||
nasm -f bin elevator.asm -o elevator.bin
|
||||
|
||||
echo "Done!"
|
||||
# Step 3: Assemble kernel entry point
|
||||
echo -e "${BLUE}[3/6]${NC} Assembling kernel entry..."
|
||||
nasm -f elf64 kernel.asm -o kernel.asm.o
|
||||
|
||||
# Step 4: Compile kernel C code
|
||||
echo -e "${BLUE}[4/6]${NC} Compiling kernel..."
|
||||
gcc -ffreestanding -c kernel.c -o kernel.c.o -mcmodel=large -mno-red-zone -fno-pic -fno-pie -static -fno-stack-protector -nostdlib -mno-mmx -mno-sse -mno-sse2 -m64
|
||||
|
||||
# Step 5: Link kernel
|
||||
echo -e "${BLUE}[5/6]${NC} Linking kernel..."
|
||||
ld -T linker.ld -o kernel.bin kernel.asm.o kernel.c.o --oformat binary
|
||||
|
||||
# Step 6: Create OS image
|
||||
echo -e "${BLUE}[6/6]${NC} Creating OS image..."
|
||||
cat boot.bin elevator.bin kernel.bin > os-image.bin
|
||||
|
||||
# Pad to floppy size (1.44MB)
|
||||
truncate -s 1440K os-image.bin
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}✓ Build complete!${NC}"
|
||||
echo ""
|
||||
echo "==================================="
|
||||
echo "File Layout:"
|
||||
echo "==================================="
|
||||
echo "Sector 1: Stage 1 (MBR)"
|
||||
echo "Sectors 2-6: Stage 2 (Extended Bootloader)"
|
||||
echo "Sectors 7+: Kernel"
|
||||
echo ""
|
||||
|
||||
# Show sizes
|
||||
echo "File Sizes:"
|
||||
printf "%-15s %10s\n" "File" "Size"
|
||||
printf "%-15s %10s\n" "----" "----"
|
||||
printf "%-15s %10d bytes\n" "boot.bin" $(stat -f%z boot.bin 2>/dev/null || stat -c%s stage1.bin 2>/dev/null)
|
||||
printf "%-15s %10d bytes\n" "elevator.bin" $(stat -f%z elevator.bin 2>/dev/null || stat -c%s stage2.bin 2>/dev/null)
|
||||
printf "%-15s %10d bytes\n" "kernel.bin" $(stat -f%z kernel.bin 2>/dev/null || stat -c%s kernel.bin 2>/dev/null)
|
||||
printf "%-15s %10d bytes\n" "os-image.bin" $(stat -f%z os-image.bin 2>/dev/null || stat -c%s os-image.bin 2>/dev/null)
|
||||
echo ""
|
||||
|
||||
echo -e "${YELLOW}Running QEMU...${NC}"
|
||||
echo "==================================="
|
||||
echo "Press Ctrl+C to exit QEMU"
|
||||
echo ""
|
||||
qemu-system-x86_64 -drive format=raw,file=os-image.bin -no-reboot -d cpu_reset
|
||||
|
||||
|
||||
echo -e "${GREEN}Done!${NC}"
|
||||
|
||||
Reference in New Issue
Block a user