2 ; Ullrich von Bassewitz, 2003-04-15
4 ; Common functions of the serial drivers
9 .condes ser_irq, 2 ; Export as 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
40 ;----------------------------------------------------------------------------
41 ; unsigned char __fastcall__ ser_install (void* driver);
42 ; /* Install the driver once it is loaded */
51 ; Check the driver signature
53 ldy #.sizeof(ser_sig)-1
60 ; Copy the jump vectors
64 @L1: inx ; Skip the JMP opcode
65 jsr copy ; Copy one byte
66 jsr copy ; Copy one byte
67 cpy #(SER_HDR::JUMPTAB + .sizeof(SER_HDR::JUMPTAB))
70 jsr ser_install ; Call driver install routine
72 ldy ser_irq+2 ; Check high byte of IRQ vector
73 beq @L2 ; Jump if vector invalid
74 ldy #$4C ; Jump opcode
75 sty ser_irq ; Activate IRQ routine
78 ; Driver signature invalid
81 lda #SER_ERR_INV_DRIVER
85 ; Copy one byte from the jump vectors
93 ;----------------------------------------------------------------------------
94 ; unsigned char __fastcall__ ser_uninstall (void);
95 ; /* Uninstall the currently loaded driver and return an error code.
96 ; * Note: This call does not free allocated memory.
100 jsr ser_uninstall ; Call driver routine
102 lda #$60 ; RTS opcode
103 sta ser_irq ; Disable IRQ entry point
107 sta _ser_drv+1 ; Clear the driver pointer