PUT .word ; PUT routine
STATUS .word ; STATUS routine
IOCTL .word ; IOCTL routine
+ IRQ .word ; IRQ routine
.endstruct
.endstruct
.global ser_put
.global ser_status
.global ser_ioctl
-
+ .global ser_irq
;------------------------------------------------------------------------------
; ASM functions
.word PUT
.word STATUS
.word IOCTL
+ .word IRQ
;----------------------------------------------------------------------------
; I/O definitions
ACIA_STATUS = ACIA+1 ; Status register
ACIA_CMD = ACIA+2 ; Command register
ACIA_CTRL = ACIA+3 ; Control register
-ACIA_CLOCK = ACIA+7 ; Turbo232 external baud-rate generator
;----------------------------------------------------------------------------
;
ldx #>SER_ERR_INV_IOCTL
rts
+;----------------------------------------------------------------------------
+; IRQ: Not used on the C128
+;
+
+IRQ = $0000
+
;----------------------------------------------------------------------------
;
; NMI handler
.word PUT
.word STATUS
.word IOCTL
+ .word IRQ
;----------------------------------------------------------------------------
; I/O definitions
ACIA_STATUS = ACIA+1 ; Status register
ACIA_CMD = ACIA+2 ; Command register
ACIA_CTRL = ACIA+3 ; Control register
-ACIA_CLOCK = ACIA+7 ; Turbo232 external baud-rate generator
;----------------------------------------------------------------------------
;
IOCTL: lda #<SER_ERR_INV_IOCTL ; We don't support ioclts for now
ldx #>SER_ERR_INV_IOCTL
- rts
+ rts
+
+;----------------------------------------------------------------------------
+; IRQ: Not used on the C64
+;
+
+IRQ = $0000
;----------------------------------------------------------------------------
;
; Common functions of the serial drivers
;
- .export ser_clear_ptr
.import return0
.importzp ptr1
+ .condes ser_irq, 2 ; Export as IRQ handler
.include "ser-kernel.inc"
.include "ser-error.inc"
ser_put: jmp return0
ser_status: jmp return0
ser_ioctl: jmp return0
+ser_irq: .byte $60, $00, $00 ; RTS plus two dummy bytes
; Driver header signature
.rodata
cpy #(SER_HDR::JUMPTAB + .sizeof(SER_HDR::JUMPTAB))
bne @L1
- jmp ser_install ; Call driver install routine
+ jsr ser_install ; Call driver install routine
+
+ lda ser_irq+2 ; Check high byte of IRQ vector
+ beq @L2 ; Jump if vector invalid
+ lda #$4C ; Jump opcode
+ sta ser_irq ; Activate IRQ routine
+@L2: rts
; Driver signature invalid
_ser_uninstall:
jsr ser_uninstall ; Call driver routine
-ser_clear_ptr: ; External entry point
+ lda #$60 ; RTS opcode
+ sta ser_irq ; Disable IRQ entry point
+
lda #0
sta _ser_drv
sta _ser_drv+1 ; Clear the driver pointer
ora _ser_drv+1
beq no_driver ; No driver
- jsr ser_uninstall ; Deinstall the driver
-
- lda _ser_drv
- ldx _ser_drv+1
- jsr _mod_free ; Free the driver
-
- jmp ser_clear_ptr ; Clear the driver pointer, return zero
+ lda _ser_drv
+ pha
+ lda _ser_drv+1
+ pha ; Save pointer to driver
+
+ jsr _ser_uninstall ; Deinstall the driver
+
+ pla
+ tax
+ pla ; Get pointer to driver
+ jmp _mod_free ; Free the driver
no_driver:
- tax ; X = 0
- lda #SER_ERR_NO_DRIVER
+ tax ; X = 0
+ lda #<SER_ERR_NO_DRIVER
rts