From 3e888ffa65ec779175bac134bba141746de8c330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kyle=20J=C2=A0Cardoza?= Date: Sun, 7 Jul 2024 20:50:53 -0400 Subject: [PATCH] =?UTF-8?q?IRQ=C2=A0work=20in=20BIOS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/{boot => }/65c816.h | 8 +- include/{bios => }/macros.h | 0 include/{boot => }/sentinel65x.h | 0 include/{boot => }/vera.h | 0 include/{boot => }/w65c265s.h | 0 src/bios/cstartup.s | 2 +- src/bios/irq.c | 126 +++++++++++++++ src/bios/irq_trampoline.s | 258 +++++++++++++++++++++++++++---- src/boot/boot.s | 2 +- 9 files changed, 357 insertions(+), 39 deletions(-) rename include/{boot => }/65c816.h (87%) rename include/{bios => }/macros.h (100%) rename include/{boot => }/sentinel65x.h (100%) rename include/{boot => }/vera.h (100%) rename include/{boot => }/w65c265s.h (100%) diff --git a/include/boot/65c816.h b/include/65c816.h similarity index 87% rename from include/boot/65c816.h rename to include/65c816.h index 33aa099..227d779 100644 --- a/include/boot/65c816.h +++ b/include/65c816.h @@ -23,9 +23,7 @@ long_i \ pha \ phx \ - phy \ - short_a \ - long_i + phy #define restore_registers \ long_a \ @@ -33,6 +31,4 @@ ply \ plx \ pla \ - plp \ - short_a \ - long_i + plp diff --git a/include/bios/macros.h b/include/macros.h similarity index 100% rename from include/bios/macros.h rename to include/macros.h diff --git a/include/boot/sentinel65x.h b/include/sentinel65x.h similarity index 100% rename from include/boot/sentinel65x.h rename to include/sentinel65x.h diff --git a/include/boot/vera.h b/include/vera.h similarity index 100% rename from include/boot/vera.h rename to include/vera.h diff --git a/include/boot/w65c265s.h b/include/w65c265s.h similarity index 100% rename from include/boot/w65c265s.h rename to include/w65c265s.h diff --git a/src/bios/cstartup.s b/src/bios/cstartup.s index 2b8bbb3..ae34b86 100644 --- a/src/bios/cstartup.s +++ b/src/bios/cstartup.s @@ -16,7 +16,7 @@ .extern _NearBaseAddress #endif -#include "bios/macros.h" +#include "macros.h" ;;; *************************************************************************** ;;; diff --git a/src/bios/irq.c b/src/bios/irq.c index 0ad9704..127fadc 100644 --- a/src/bios/irq.c +++ b/src/bios/irq.c @@ -5,3 +5,129 @@ // // Copyright © 2024 Kyle J Cardoza +#include + +// Return values from handlers, if any, should be stored in +// DP[0] for the C register, DP[4] for the X register, and +// DP[6] for the Y register. +extern uint16_t Dp[4]; + +void irq_handler(void) { + return; +} + +void brk_irq_handler(void) { + return; +} + +void abort_irq_handler(void) { + return; +} + +void nmi_handler(void) { + return; +} + +void timer0_irq_handler(void) { + return; +} + +void timer1_irq_handler(void) { + return; +} + +void timer2_irq_handler(void) { + return; +} + +void timer3_irq_handler(void) { + return; +} + +void timer4_irq_handler(void) { + return; +} + +void timer5_irq_handler(void) { + return; +} + +void timer6_irq_handler(void) { + return; +} + +void timer7_irq_handler(void) { + return; +} + +void pe56_irq_handler(void) { + return; +} + +void ne57_irq_handler(void) { + return; +} + +void pe60_irq_handler(void) { + return; +} + +void pe62_irq_handler(void) { + return; +} + +void ne64_irq_handler(void) { + return; +} + +void ne66_irq_handler(void) { + return; +} + +void pib_irq_handler(void) { + return; +} + +void level_irq_handler(void) { + return; +} + +void uart_0_rx_irq_handler(void) { + return; +} + +void uart_0_tx_irq_handler(void) { + return; +} + +void uart_1_rx_irq_handler(void) { + return; +} + +void uart_1_tx_irq_handler(void) { + return; +} + +void uart_2_rx_irq_handler(void) { + return; +} + +void uart_2_tx_irq_handler(void) { + return; +} + +void uart_3_rx_irq_handler(void) { + return; +} + +void uart_3_tx_irq_handler(void) { + return; +} + +void cop_handler(uint16_t arg_c, uint16_t arg_x, uint16_t arg_y) { + (void) arg_c; + (void) arg_x; + (void) arg_y; + return; +} + diff --git a/src/bios/irq_trampoline.s b/src/bios/irq_trampoline.s index 9fffc87..a61a05e 100644 --- a/src/bios/irq_trampoline.s +++ b/src/bios/irq_trampoline.s @@ -10,95 +10,291 @@ //; //; Copyright © 2024 Kyle J Cardoza +#include "macros.h" +#include "sentinel65x.h" + + .extern _Dp + + .extern irq_handler + ; This section gets copied to 0x00F000 .section irq_trampolines - + reserved_irq: - rti + phb + phd + rep #0b00110000 + pha + phx + phy + jump interrupt_return timer0_irq: - rti + phb + phd + rep #0b00110000 + pha + phx + phy + jump interrupt_return timer1_irq: - rti + phb + phd + rep #0b00110000 + pha + phx + phy + jump interrupt_return timer2_irq: - rti + phb + phd + rep #0b00110000 + pha + phx + phy + jump interrupt_return timer3_irq: - rti + phb + phd + rep #0b00110000 + pha + phx + phy + jump interrupt_return timer4_irq: - rti + phb + phd + rep #0b00110000 + pha + phx + phy + jump interrupt_return timer5_irq: - rti + phb + phd + rep #0b00110000 + pha + phx + phy + jump interrupt_return timer6_irq: - rti + phb + phd + rep #0b00110000 + pha + phx + phy + jump interrupt_return timer7_irq: - rti + phb + phd + rep #0b00110000 + pha + phx + phy + jump interrupt_return pe56_irq: - rti + phb + phd + rep #0b00110000 + pha + phx + phy + jump interrupt_return ne57_irq: - rti + phb + phd + rep #0b00110000 + pha + phx + phy + jump interrupt_return pe60_irq: - rti + phb + phd + rep #0b00110000 + pha + phx + phy + jump interrupt_return pe62_irq: - rti + phb + phd + rep #0b00110000 + pha + phx + phy + jump interrupt_return ne64_irq: - rti + phb + phd + rep #0b00110000 + pha + phx + phy + jump interrupt_return ne66_irq: - rti + phb + phd + rep #0b00110000 + pha + phx + phy + jump interrupt_return pib_irq: - rti + phb + phd + rep #0b00110000 + pha + phx + phy + jump interrupt_return + +level_irq: + phb + phd + rep #0b00110000 + pha + phx + phy + + call long:irq_handler + jump interrupt_return -level_irq: - rti uart_0_rx_irq: - rti + phb + phd + rep #0b00110000 + pha + phx + phy + jump interrupt_return uart_0_tx_irq: - rti + phb + phd + rep #0b00110000 + pha + phx + phy + jump interrupt_return uart_1_rx_irq: - rti + phb + phd + rep #0b00110000 + pha + phx + phy + jump interrupt_return uart_1_tx_irq: - rti + phb + phd + rep #0b00110000 + pha + phx + phy + jump interrupt_return uart_2_rx_irq: - rti + phb + phd + rep #0b00110000 + pha + phx + phy + jump interrupt_return uart_2_tx_irq: - rti + phb + phd + rep #0b00110000 + pha + phx + phy + jump interrupt_return uart_3_rx_irq: - rti + phb + phd + rep #0b00110000 + pha + phx + phy + jump interrupt_return uart_3_tx_irq: - rti + phb + phd + rep #0b00110000 + pha + phx + phy + jump interrupt_return cop_irq: - rti + phb + phd + rep #0b00110000 + pha + phx + phy + jump interrupt_return brk_irq: - rti + phb + phd + rep #0b00110000 + pha + phx + phy + jump interrupt_return abort_irq: - rti + phb + phd + rep #0b00110000 + pha + phx + phy + jump interrupt_return nmi_irq: - rti + phb + phd + rep #0b00110000 + pha + phx + phy + .extern nmi_handler + long_a + call long:nmi_handler + jump interrupt_return + +interrupt_return: + rep #0b00110000 + ply + plx + pla + pld + plb + jump interrupt_return ; This section gets copied to 0x00FF80 .section irq_vectors diff --git a/src/boot/boot.s b/src/boot/boot.s index ec78cc9..ee08379 100644 --- a/src/boot/boot.s +++ b/src/boot/boot.s @@ -5,7 +5,7 @@ //; //; Copyright © 2024 Kyle J Cardoza -#include "boot/sentinel65x.h" +#include "sentinel65x.h" .section code, noreorder .pubweak __program_root_section