VRAM modification

This commit is contained in:
aramya 2021-09-30 15:59:48 +01:00
parent 090102b47a
commit a0ab1dfe98
8 changed files with 61 additions and 22 deletions

View File

@ -14,12 +14,12 @@ bootinfo.txt: load.fth
echo "<chrp-boot><boot-script>" >> bootinfo.txt
cat load.fth >> bootinfo.txt
echo "</boot-script></chrp-boot>" >> 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:

View File

@ -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 :

27
boot.c
View File

@ -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++;
}
}

View File

@ -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/

View File

@ -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

6
memory.h Normal file
View File

@ -0,0 +1,6 @@
#define beige_vram 0x80000000
#define mac99_vram 0x81000000
unsigned char IO_TYPE;
unsigned char* vram_ptr;

6
memorymap.h Normal file
View File

@ -0,0 +1,6 @@
#define beige_vram 0x80000000
#define mac99_vram 0x81000000
unsigned char IO_TYPE;
unsigned char* vram_ptr;

View File