Compare commits

...

3 Commits

Author SHA1 Message Date
Kyle J Cardoza 436b86aa2a code cleanup 2024-07-11 19:29:48 -04:00
Kyle J Cardoza 535d348893 code cleanup 2024-07-11 19:29:16 -04:00
Kyle J Cardoza 28d7e2d1f1 Combined boot and kernel modules into one 2024-07-11 01:51:39 -04:00
6 changed files with 60 additions and 398 deletions

View File

@ -11,7 +11,7 @@ build/$(TARGET).bin: build/kernel.bin
#Create an empty .bin file. #Create an empty .bin file.
@dd if=/dev/zero of=$@ bs=1024 count=512 @dd if=/dev/zero of=$@ bs=1024 count=512
# Add the bios module at offset 0x000000 # Add the kernel module at offset 0x000000
@dd if=build/kernel.bin of=$@ conv=notrunc @dd if=build/kernel.bin of=$@ conv=notrunc
.PHONY: clean .PHONY: clean

View File

@ -9,16 +9,17 @@
(section heap) (section heap)
) )
(memory BOOT (memory LOROM
(address (#x008000 . #x0082FF)) (address (#x008000 . #x00FFFF))
(scatter-to boot_rom) (scatter-to low_rom)
(section boot) (section (boot #x008000))
(section irq_handlers)
) )
(memory ROM (memory ROM
(address (#xC00000 . #xC0FFFF)) (address (#xC00000 . #xC0FFFF))
(section (boot_rom #xC08000)) (section (low_rom #xC08000))
(section (code #xC08300)) (section code)
(section farcode) (section farcode)
(section cdata) (section cdata)
(section switch) (section switch)
@ -27,8 +28,6 @@
(section chuge) (section chuge)
(section ihuge) (section ihuge)
(section data_init_table) (section data_init_table)
(section (irq_trampolines #xC0F000))
(section (irq_vectors #xC0FF80))
) )
(memory Stack (memory Stack

View File

@ -7,6 +7,8 @@
#include "sentinel65x.h" #include "sentinel65x.h"
.extern __program_root_section
.section boot, noreorder .section boot, noreorder
.asciz "WDC" .asciz "WDC"
w65c265s_init: w65c265s_init:
@ -54,4 +56,4 @@ delay_y
w65c265s_sram_off w65c265s_sram_off
// And we are booted enough to jump to high ROM. // And we are booted enough to jump to high ROM.
jmp long:0xC08300 jmp long:__program_root_section

View File

@ -0,0 +1,28 @@
#include "macros.h"
.section znear,bss
cop_handler_result_c:
.space 2
cop_handler_result_x:
.space 2
cop_handler_result_y:
.space 2
.section `$$interruptVector_0x00ffb4`,text
.public cop_trampoline
.word cop_trampoline
.section irq_handlers,text
.extern cop_handler
cop_trampoline:
rep #48
; Simple calling convention: first argument in C, the rest on the stack.
phx
phy
call cop_handler
; And fetch the results:
lda cop_handler_result_c
ldx cop_handler_result_x
ldy cop_handler_result_y
rti

View File

@ -7,23 +7,30 @@
#include <stdint.h> #include <stdint.h>
// 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];
#pragma clang diagnostic push #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter" #pragma clang diagnostic ignored "-Wunused-parameter"
#pragma clang diagnostic ignored "-Wunused-variable"
#pragma clang section text="irq_handlers"
void cop_handler(uint16_t arg_c, uint16_t arg_x, uint16_t arg_y) { // These are used by the COP trampoline to put the results
switch (arg_c & 0x00FF) { // into the C, X, and Y registers.
extern uint16_t cop_handler_result_c;
extern uint16_t cop_handler_result_x;
extern uint16_t cop_handler_result_y;
__attribute__((simple_call))
void cop_handler(uint16_t function,
uint16_t arg_x,
uint16_t arg_y) {
switch (function) {
case 0: case 0:
//soft_reset();
break; break;
default: default:
//cop_error_invalid_call();
break; break;
} }
return;
} }
void irq_handler(void) { void irq_handler(void) {

View File

@ -1,374 +0,0 @@
//; SPDX-License-Identifier: MIT
//;
//; bios/irq_trampoline.s
//; IRQ trampoline code for Sentinel 65X
//;
//; The two sections below are visible in ROM when the CPU's
//; on-chip ROM is disabled. They must be copied to RAM if
//; on-board ROM is to be disabled.
//;
//;
//; Copyright © 2024 Kyle J Cardoza <Kyle.Cardoza@icloud.com>
#include "macros.h"
#include "sentinel65x.h"
.extern _Dp
.extern irq_handler
.extern cop_handler
; This section gets copied to 0x00F000
.section irq_trampolines
reserved_irq:
phb
phd
rep #0b00110000
pha
phx
phy
jump interrupt_return
timer0_irq:
phb
phd
rep #0b00110000
pha
phx
phy
jump interrupt_return
timer1_irq:
phb
phd
rep #0b00110000
pha
phx
phy
jump interrupt_return
timer2_irq:
phb
phd
rep #0b00110000
pha
phx
phy
jump interrupt_return
timer3_irq:
phb
phd
rep #0b00110000
pha
phx
phy
jump interrupt_return
timer4_irq:
phb
phd
rep #0b00110000
pha
phx
phy
jump interrupt_return
timer5_irq:
phb
phd
rep #0b00110000
pha
phx
phy
jump interrupt_return
timer6_irq:
phb
phd
rep #0b00110000
pha
phx
phy
jump interrupt_return
timer7_irq:
phb
phd
rep #0b00110000
pha
phx
phy
jump interrupt_return
pe56_irq:
phb
phd
rep #0b00110000
pha
phx
phy
jump interrupt_return
ne57_irq:
phb
phd
rep #0b00110000
pha
phx
phy
jump interrupt_return
pe60_irq:
phb
phd
rep #0b00110000
pha
phx
phy
jump interrupt_return
pe62_irq:
phb
phd
rep #0b00110000
pha
phx
phy
jump interrupt_return
ne64_irq:
phb
phd
rep #0b00110000
pha
phx
phy
jump interrupt_return
ne66_irq:
phb
phd
rep #0b00110000
pha
phx
phy
jump interrupt_return
pib_irq:
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
uart_0_rx_irq:
phb
phd
rep #0b00110000
pha
phx
phy
jump interrupt_return
uart_0_tx_irq:
phb
phd
rep #0b00110000
pha
phx
phy
jump interrupt_return
uart_1_rx_irq:
phb
phd
rep #0b00110000
pha
phx
phy
jump interrupt_return
uart_1_tx_irq:
phb
phd
rep #0b00110000
pha
phx
phy
jump interrupt_return
uart_2_rx_irq:
phb
phd
rep #0b00110000
pha
phx
phy
jump interrupt_return
uart_2_tx_irq:
phb
phd
rep #0b00110000
pha
phx
phy
jump interrupt_return
uart_3_rx_irq:
phb
phd
rep #0b00110000
pha
phx
phy
jump interrupt_return
uart_3_tx_irq:
phb
phd
rep #0b00110000
pha
phx
phy
jump interrupt_return
cop_irq:
phb
phd
rep #0b00110000
stx _Dp+4
sty _Dp+6
call cop_handler
rep #0b00110000
lda _Dp+0
ldx _Dp+4
ldy _Dp+6
pld
plb
rti
brk_irq:
phb
phd
rep #0b00110000
pha
phx
phy
jump interrupt_return
abort_irq:
phb
phd
rep #0b00110000
pha
phx
phy
jump interrupt_return
nmi_irq:
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
; Native mode IRQ vectors
.word .word0(timer0_irq)
.word .word0(timer1_irq)
.word .word0(timer2_irq)
.word .word0(timer3_irq)
.word .word0(timer4_irq)
.word .word0(timer5_irq)
.word .word0(timer6_irq)
.word .word0(timer7_irq)
.word .word0(pe56_irq)
.word .word0(ne57_irq)
.word .word0(pe60_irq)
.word .word0(pe62_irq)
.word .word0(ne64_irq)
.word .word0(ne66_irq)
.word .word0(pib_irq)
.word .word0(level_irq)
.word .word0(uart_0_rx_irq)
.word .word0(uart_0_tx_irq)
.word .word0(uart_1_rx_irq)
.word .word0(uart_1_tx_irq)
.word .word0(uart_2_rx_irq)
.word .word0(uart_2_tx_irq)
.word .word0(uart_3_rx_irq)
.word .word0(uart_3_tx_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)
.word .word0(cop_irq)
.word .word0(brk_irq)
.word .word0(abort_irq)
.word .word0(nmi_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)
; Emulation mode is not supported right now.
.word .word0(reserved_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)
.word .word0(reserved_irq)