2 ; Ullrich von Bassewitz, 2003-04-15
4 ; Common functions of the serial drivers
9 .interruptor ser_irq, 29 ; Export as high priority IRQ handler
11 .include "ser-kernel.inc"
12 .include "ser-error.inc"
15 ;----------------------------------------------------------------------------
20 _ser_drv: .res 2 ; Pointer to driver
22 ; Jump table for the driver functions.
25 ser_install: jmp return0
26 ser_uninstall: jmp return0
28 ser_close: jmp return0
31 ser_status: jmp return0
32 ser_ioctl: jmp return0
33 ser_irq: .byte $60, $00, $00 ; RTS plus two dummy bytes
35 ; Driver header signature
37 ser_sig: .byte $73, $65, $72, SER_API_VERSION ; "ser", version
41 ;----------------------------------------------------------------------------
42 ; unsigned char __fastcall__ ser_install (void* driver);
43 ; /* Install the driver once it is loaded */
52 ; Check the driver signature
54 ldy #.sizeof(ser_sig)-1
61 ; Copy the jump vectors
65 @L1: inx ; Skip the JMP opcode
66 jsr copy ; Copy one byte
67 jsr copy ; Copy one byte
68 cpy #(SER_HDR::JUMPTAB + .sizeof(SER_HDR::JUMPTAB))
71 jsr ser_install ; Call driver install routine
73 ldy ser_irq+2 ; Check high byte of IRQ vector
74 beq @L2 ; Jump if vector invalid
75 ldy #$4C ; Jump opcode
76 sty ser_irq ; Activate IRQ routine
79 ; Driver signature invalid
82 lda #SER_ERR_INV_DRIVER
86 ; Copy one byte from the jump vectors
94 ;----------------------------------------------------------------------------
95 ; unsigned char ser_uninstall (void);
96 ; /* Uninstall the currently loaded driver and return an error code.
97 ; * Note: This call does not free allocated memory.
101 jsr ser_uninstall ; Call driver routine
103 lda #$60 ; RTS opcode
104 sta ser_irq ; Disable IRQ entry point
106 _ser_clear_ptr: ; External entry point
109 sta _ser_drv+1 ; Clear the driver pointer