diff --git a/sw/boot/Makefile b/sw/bios/Makefile similarity index 92% rename from sw/boot/Makefile rename to sw/bios/Makefile index a8b4fde..caa77c0 100644 --- a/sw/boot/Makefile +++ b/sw/bios/Makefile @@ -2,12 +2,8 @@ CC=cl65 CFLAGS=-T -t none -I. --cpu "65C02" test: CFLAGS=-T -t sim65c02 -I. LDFLAGS=-C link.ld -m $(NAME).map -SIM=sim65 -SIMARGS=-v -c -x 1000000 +NAME=bios -NAME=bootrom - -TEST_BIN=test.bin BIN=$(NAME).bin HEX=$(NAME).hex diff --git a/sw/boot/boot.s b/sw/bios/boot.s similarity index 57% rename from sw/boot/boot.s rename to sw/bios/boot.s index 1cd5448..4a26770 100644 --- a/sw/boot/boot.s +++ b/sw/bios/boot.s @@ -1,11 +1,8 @@ -; We need to to read the boot sector from the -; SD card, verify the last 2 bytes, then jump to the -; beginning of it. - .include "zeropage.inc" .segment "STARTUP" +.export _init .import _load_bootsect _init: ldx #$ff diff --git a/sw/bios/devices/interrupt.s b/sw/bios/devices/interrupt.s new file mode 100644 index 0000000..f555c1c --- /dev/null +++ b/sw/bios/devices/interrupt.s @@ -0,0 +1,55 @@ +.include "io.inc65" + +.export _irq_int, _nmi_int + +.importzp sreg, ptr1 + +.segment "CODE" + +; IRQ +_irq_int: + jmp (irqmap,x) + +_nmi_int: + rti + +irqmap: + .addr handle_invalid + .addr handle_sd_read + +handle_invalid: + rti + +; sreg is the pointer to store the data +; a/y is the block address +; send command 17 with the block address of 00/y/a +handle_sd_read: + sta SD_ARG ; send command + sty SD_ARG+1 + stz SD_ARG+2 + stz SD_ARG+3 + lda #$11 + sta SD_CMD + +@1: lda SD_CMD ; wait for status flag + and #$01 + beq @1 + +@2: lda SD_CMD ; wait for data + and #$02 + beq @2 + + ldy #$00 +@loop: lda SD_DATA ; copy first 256 bytes + sta (sreg),y + iny + bne @loop + + ldy #$00 ; copy second 256 bytes + inc sreg+1 +@loop2: lda SD_DATA + sta (sreg),y + iny + bne @loop2 + + rti \ No newline at end of file diff --git a/sw/boot/devices/io.inc65 b/sw/bios/devices/io.inc65 similarity index 100% rename from sw/boot/devices/io.inc65 rename to sw/bios/devices/io.inc65 diff --git a/sw/boot/devices/sd_card.c b/sw/bios/devices/sd_card.c similarity index 100% rename from sw/boot/devices/sd_card.c rename to sw/bios/devices/sd_card.c diff --git a/sw/boot/devices/sd_card.h b/sw/bios/devices/sd_card.h similarity index 100% rename from sw/boot/devices/sd_card.h rename to sw/bios/devices/sd_card.h diff --git a/sw/boot/devices/sd_card_asm.s b/sw/bios/devices/sd_card_asm.s similarity index 100% rename from sw/boot/devices/sd_card_asm.s rename to sw/bios/devices/sd_card_asm.s diff --git a/sw/boot/link.ld b/sw/bios/link.ld similarity index 91% rename from sw/boot/link.ld rename to sw/bios/link.ld index 33de787..0fe59b7 100644 --- a/sw/boot/link.ld +++ b/sw/bios/link.ld @@ -14,5 +14,6 @@ SEGMENTS { ONCE: load = ROM, type = ro, optional = yes; CODE: load = ROM, type = ro; RODATA: load = ROM, type = ro; + VECTORS: load = ROM, type = ro, start = $FFFA; } diff --git a/sw/boot/load_bootsect.c b/sw/bios/load_bootsect.c similarity index 100% rename from sw/boot/load_bootsect.c rename to sw/bios/load_bootsect.c diff --git a/sw/bios/vectors.s b/sw/bios/vectors.s new file mode 100644 index 0000000..81ae6e0 --- /dev/null +++ b/sw/bios/vectors.s @@ -0,0 +1,14 @@ +; --------------------------------------------------------------------------- +; vectors.s +; --------------------------------------------------------------------------- +; +; Defines the interrupt vector table. + +.import _init +.import _nmi_int, _irq_int + +.segment "VECTORS" + +.addr _nmi_int ; NMI vector +.addr _init ; Reset vector +.addr _irq_int ; IRQ/BRK vector \ No newline at end of file