From 83d15869b5ff498076eb875c214693fb56474462 Mon Sep 17 00:00:00 2001 From: Matt Harlum Date: Wed, 30 Oct 2024 06:31:39 +0000 Subject: [PATCH] Replace mungerom.c with a python script --- bootrom/.gitignore | 3 ++- bootrom/Makefile | 8 ++------ bootrom/atbusrom.ld | 6 +++++- bootrom/mungerom.c | 33 --------------------------------- bootrom/mungerom.py | 26 ++++++++++++++++++++++++++ bootrom/rom.ld | 4 ++++ 6 files changed, 39 insertions(+), 41 deletions(-) delete mode 100644 bootrom/mungerom.c create mode 100755 bootrom/mungerom.py diff --git a/bootrom/.gitignore b/bootrom/.gitignore index cb945c0..fb1694a 100644 --- a/bootrom/.gitignore +++ b/bootrom/.gitignore @@ -5,4 +5,5 @@ at **/*.out **/*.device **/*.hunk -**/*.adf \ No newline at end of file +**/*.adf +*.pyc \ No newline at end of file diff --git a/bootrom/Makefile b/bootrom/Makefile index 8723e05..89ac038 100644 --- a/bootrom/Makefile +++ b/bootrom/Makefile @@ -14,10 +14,6 @@ OBJS = $(SRCS:%.S=$(OBJDIR)/%.o) all: ../$(PROJECT).rom ../$(PROJECT)-atbus.rom ../$(PROJECT)-word.rom -$(OBJDIR)/mungerom: mungerom.c - @mkdir -p $(OBJDIR) - $(CC) $< -Wall -o $@ - # Nibble-wide boot loader with Byte-wide driver $(OBJDIR)/%.o: %.S @mkdir -p $(OBJDIR) @@ -34,9 +30,9 @@ $(OBJDIR)/bootldr: $(OBJDIR)/bootldr.o $(OBJDIR)/bootldr-word: $(OBJDIR)/bootldr-word.o $(LINKER) $(LINKFLAGS) -o $@ $^ -$(OBJDIR)/bootnibbles: $(OBJDIR)/bootldr $(OBJDIR)/mungerom +$(OBJDIR)/bootnibbles: $(OBJDIR)/bootldr mungerom.py @mkdir -p $(OBJDIR) - ./obj/mungerom + ./mungerom.py $(OBJDIR)/assets.o: assets.S $(OBJDIR)/bootnibbles ../lide.device diff --git a/bootrom/atbusrom.ld b/bootrom/atbusrom.ld index 65ecf89..53beef7 100644 --- a/bootrom/atbusrom.ld +++ b/bootrom/atbusrom.ld @@ -2,8 +2,12 @@ SECTIONS { rom = .; .bootldr 0x00: { *(BOOTLDR); - RESERVE(0x1000-.); + RESERVE(0x800-.); } = 0xFFFF + .reserved 0x800: { + FILL8(0xFF); + RESERVE(0x1000-.); + } .device 0x1000 : { *(DEVICE) } diff --git a/bootrom/mungerom.c b/bootrom/mungerom.c deleted file mode 100644 index 55b32f9..0000000 --- a/bootrom/mungerom.c +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include -#include - -// Chop up the bootrom section into nibbles for Z2 nibblewise bootrom - Kick 1.3 and below don't support DAC_BYTEWIDE :( -// The device driver will be loaded bytewise by reloc -int main () { - FILE *fh = fopen("obj/bootldr","r"); - - char *src,*dst = NULL; - - src = malloc(2048); - dst = malloc(4096); - - int len = fread(src,1,2048,fh); - fclose(fh); - for (int i=0; i size_limit: + print(f"{c_bright_red}bootldr too large, Size: {romSize} Limit: {size_limit}{c_reset}") + sys.exit(1) + + rom = s.read() + + with open("obj/bootnibbles","wb") as d: + for b in rom: + d.write(bytes([(b & 0xF0) | 0x0F])) + d.write(bytes([((b << 4) & 0xF0) | 0x0F])) diff --git a/bootrom/rom.ld b/bootrom/rom.ld index 7e3a409..31aaefa 100644 --- a/bootrom/rom.ld +++ b/bootrom/rom.ld @@ -5,6 +5,10 @@ SECTIONS { } = 0xFFFF .bootldr 0x04: { *(BOOTLDR); + RESERVE(0x800-.); + } + .reserved 0x800: { + FILL8(0xFF); RESERVE(0x1000-.); } .device 0x1000 : {