]> git.sur5r.net Git - cc65/commitdiff
Added an IRQ vector
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sun, 14 Dec 2003 17:39:22 +0000 (17:39 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sun, 14 Dec 2003 17:39:22 +0000 (17:39 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@2753 b7a2c559-68d2-44c3-8de9-860c34a00d81

asminc/ser-kernel.inc
libsrc/c128/c128-swlink.s
libsrc/c64/c64-swlink.s
libsrc/serial/ser-kernel.s
libsrc/serial/ser_unload.s

index c099b81737baab000a9928512c21440f10afbec7..debae78fc0469d8fe4cf0aa5b20bdae9e8e80a02 100644 (file)
@@ -48,6 +48,7 @@
             PUT         .word   ; PUT routine
             STATUS      .word   ; STATUS routine
             IOCTL       .word   ; IOCTL routine
+           IRQ         .word   ; IRQ routine
         .endstruct
 .endstruct
 
@@ -138,7 +139,7 @@ SER_STATUS_DSR              =       $40     ; NOT data set ready
         .global ser_put
         .global ser_status
         .global ser_ioctl
-
+       .global ser_irq
 
 ;------------------------------------------------------------------------------
 ; ASM functions
index 3194cf02d86e9aa7a96c510c4fcfd5df519270c1..558d80db84c8d62dce9b4b834e8ddbcbc483feba 100644 (file)
@@ -47,6 +47,7 @@
         .word   PUT
         .word   STATUS
         .word   IOCTL
+       .word   IRQ
 
 ;----------------------------------------------------------------------------
 ; I/O definitions
@@ -56,7 +57,6 @@ ACIA_DATA       = ACIA+0        ; Data register
 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
 
 ;----------------------------------------------------------------------------
 ;
@@ -397,6 +397,12 @@ IOCTL:  lda     #<SER_ERR_INV_IOCTL     ; We don't support ioclts for now
         ldx     #>SER_ERR_INV_IOCTL
         rts
 
+;----------------------------------------------------------------------------
+; IRQ: Not used on the C128
+;
+
+IRQ     = $0000
+
 ;----------------------------------------------------------------------------
 ;
 ; NMI handler
index 4e7730b56ae90fe74a9a8899cb35c9c5a073cee9..9f1b23c5b45a177cecb113395458a2486997248a 100644 (file)
@@ -47,6 +47,7 @@
         .word   PUT
         .word   STATUS
         .word   IOCTL
+        .word   IRQ
 
 ;----------------------------------------------------------------------------
 ; I/O definitions
@@ -56,7 +57,6 @@ ACIA_DATA       = ACIA+0        ; Data register
 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
 
 ;----------------------------------------------------------------------------
 ;
@@ -368,7 +368,13 @@ STATUS: lda        ACIA_STATUS
 
 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
 
 ;----------------------------------------------------------------------------
 ;
index a0285f6c3940dbae284a878194ec9c5f95a10269..5e76358becb05e88e96e646c2986aca2a622cdb2 100644 (file)
@@ -4,9 +4,9 @@
 ; 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"
@@ -30,6 +30,7 @@ ser_get:        jmp     return0
 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
@@ -66,7 +67,13 @@ _ser_install:
         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
 
@@ -92,7 +99,9 @@ copy:   lda     (ptr1),y
 _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
index 64ffb99bc77b441433c5acf0a463d0547ef884ff..70e8abbd51f278c395c2b4f6d5f88a90acf158f6 100644 (file)
@@ -17,16 +17,20 @@ _ser_unload:
        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