diff --git a/Makefile b/Makefile index ff2e14d..a228d27 100644 --- a/Makefile +++ b/Makefile @@ -14,12 +14,12 @@ bootinfo.txt: load.fth echo "" >> bootinfo.txt cat load.fth >> bootinfo.txt echo "" >> bootinfo.txt -kernel.elf: boot0.elf boot1.elf - $(PPC)-ld -Ttext=0x200000 boot0.elf boot1.elf -o kernel.elf -boot1.elf: boot.c - $(PPC)-gcc -c boot.c -o boot1.elf -boot0.elf: boot.S - $(PPC)-as -c boot.S -o boot0.elf +kernel.elf: start.elf boot.elf + $(PPC)-ld -Ttext=0x200000 start.elf boot.elf -o kernel.elf +boot.elf: boot.c memory.h + $(PPC)-gcc -c boot.c -o boot.elf +start.elf: start.s + $(PPC)-as -c start.s -o start.elf clean: rm DISK.APM *elf *txt run: diff --git a/README.md b/README.md index ad66d56..257424a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # powerpc-ofw-boot Boots through OpenFirmware. -Produces a HFS+ disk image formatted with Apple Partition Map partition scheme, compatible with old PowerPC-based Macs. +Produces a HFS+ disk image formatted with Apple Partition Map partition scheme, compatible with PowerPC-based Macs. Run it with QEMU : diff --git a/boot.c b/boot.c index 5d186da..5f68c3e 100644 --- a/boot.c +++ b/boot.c @@ -1,9 +1,30 @@ +#include "memory.h" +#define beige 0xBE +#define mac99 0x5A + void begin(void) { - unsigned char type; unsigned char *ptr_beige = 0x80000000; unsigned char *ptr_mac99 = 0x81000000; - if (*ptr_beige == 0xBE) type = 0xBE; - if (*ptr_mac99 == 0x5A) type = 0x5A; + if (*ptr_beige == beige) IO_TYPE = beige; + if (*ptr_mac99 == mac99) IO_TYPE = mac99; + init_ptr(); + clearscreen(); for(;;); } + +void init_ptr(void) +{ + if (IO_TYPE == beige) vram_ptr = beige_vram; + if (IO_TYPE == mac99) vram_ptr = mac99_vram; +} + +void clearscreen(void) +{ + for (int i = 0; i<10000000; i++) + { + *vram_ptr = 0xFF; + i++; + vram_ptr++; + } +} diff --git a/kpartx.sh b/kpartx.sh index 7273ae4..42535fd 100755 --- a/kpartx.sh +++ b/kpartx.sh @@ -1,5 +1,4 @@ #!/bin/sh - LOOP=$(sudo kpartx -s -a -v DISK.APM | awk -F'[ ]' '{print $3}' | tail -n1 ) sudo mkfs.hfsplus /dev/mapper/$LOOP sudo mount -o loop /dev/mapper/$LOOP /mnt/ diff --git a/load.fth b/load.fth index 97efc0f..5493228 100644 --- a/load.fth +++ b/load.fth @@ -1,14 +1,21 @@ ." powerpc-ofw-boot : Booting through OpenFirmware..." cr \ storing 0xBE for beige, 0x5A for mac99 -\ cannot use superior / inferior symbols (bootinfo.txt) -: superior - dup abs = ; -: inferior dup superior 1 + ; -frame-buffer-adr 80000000 = if -." Beige" cr -10000 0 do BE i 80000000 + c! BE 1 i + 80000000 + c! 2 +loop -then -frame-buffer-adr 81000000 = if -." mac99" cr -10000 0 do 5A i 81000000 + c! 5A 1 i + 81000000 + c! 2 +loop -then +\ cannot use superior, inferior, different symbols (bootinfo.txt) +: sup - dup abs = ; +: inf dup sup 1 + ; +: diff = if 0 else -1 then ; + +: fba frame-buffer-adr ; +: beige-vram 80000000 ; : mac99-vram 81000000 ; + +variable run +-1 run ! + +fba beige-vram = if ." Beige" cr 7000 0 do 0BE i beige-vram + c! loop then +fba mac99-vram = if ." mac99" cr 7000 0 do 05A i mac99-vram + c! loop then +fba beige-vram diff fba mac99-vram diff and if ." Hardware not supported." cr 0 run ! then + +run @ 0 = if 1 0 do 0 +loop then + + boot hd:,\boot\kernel.elf diff --git a/memory.h b/memory.h new file mode 100644 index 0000000..e3191a0 --- /dev/null +++ b/memory.h @@ -0,0 +1,6 @@ +#define beige_vram 0x80000000 +#define mac99_vram 0x81000000 + +unsigned char IO_TYPE; + +unsigned char* vram_ptr; diff --git a/memorymap.h b/memorymap.h new file mode 100644 index 0000000..e3191a0 --- /dev/null +++ b/memorymap.h @@ -0,0 +1,6 @@ +#define beige_vram 0x80000000 +#define mac99_vram 0x81000000 + +unsigned char IO_TYPE; + +unsigned char* vram_ptr; diff --git a/boot.S b/start.s similarity index 100% rename from boot.S rename to start.s