1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-23 04:30:10 +00:00

An already loaded driver is an error in ser_load_driver, because the library

cannot know if it was dynamically loaded or statically linked.


git-svn-id: svn://svn.cc65.org/cc65/trunk@5794 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2012-07-22 19:54:04 +00:00
parent e7ed3b374f
commit dcff1d0774
3 changed files with 32 additions and 27 deletions

View File

@ -6,10 +6,10 @@
;* *
;* *
;* *
;*(C) 2003 Ullrich von Bassewitz *
;* Römerstrasse 52 *
;* D-70794 Filderstadt *
;*EMail: uz@cc65.org *
;* (C) 2003-2012, Ullrich von Bassewitz *
;* Roemerstrasse 52 *
;* D-70794 Filderstadt *
;* EMail: uz@cc65.org *
;* *
;* *
;*This software is provided 'as-is', without any expressed or implied *
@ -36,15 +36,19 @@
;------------------------------------------------------------------------------
; Error codes
SER_ERR_OK = $00 ; Not an error - relax
SER_ERR_NO_DRIVER = $01 ; No driver available
SER_ERR_CANNOT_LOAD = $02 ; Error loading driver
SER_ERR_INV_DRIVER = $03 ; Invalid driver
SER_ERR_NO_DEVICE = $04 ; Device (hardware) not found
SER_ERR_BAUD_UNAVAIL = $05 ; Baud rate not available
SER_ERR_NO_DATA = $06 ; Nothing to read
SER_ERR_OVERFLOW = $07 ; No room in send buffer
SER_ERR_INIT_FAILED = $08 ; Initialization failed
SER_ERR_INV_IOCTL = $09 ; IOCTL not supported
.enum
SER_ERR_OK ; Not an error - relax
SER_ERR_NO_DRIVER ; No driver available
SER_ERR_CANNOT_LOAD ; Error loading driver
SER_ERR_INV_DRIVER ; Invalid driver
SER_ERR_NO_DEVICE ; Device (hardware) not found
SER_ERR_BAUD_UNAVAIL ; Baud rate not available
SER_ERR_NO_DATA ; Nothing to read
SER_ERR_OVERFLOW ; No room in send buffer
SER_ERR_INIT_FAILED ; Initialization failed
SER_ERR_INV_IOCTL ; IOCTL not supported
SER_ERR_INSTALLED ; A driver is already installed
SER_ERR_COUNT ; Special: Number of error codes
.endenum

View File

@ -6,7 +6,7 @@
/* */
/* */
/* */
/* (C) 2003-2011, Ullrich von Bassewitz */
/* (C) 2003-2012, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
@ -110,6 +110,7 @@
#define SER_ERR_OVERFLOW 0x07 /* No room in send buffer */
#define SER_ERR_INIT_FAILED 0x08 /* Initialization failed */
#define SER_ERR_INV_IOCTL 0x09 /* IOCTL not supported */
#define SER_ERR_INSTALLED 0x0A /* A driver is already installed */
/* Struct containing parameters for the serial port */
struct ser_params {

View File

@ -37,22 +37,22 @@ ctrl: .addr _read
.proc _ser_load_driver
; Save name on the C stack. We will need it later as parameter passed to open()
; Check if we do already have a driver loaded. This is an error. Do not
; touch A/X because they contain the file name.
jsr pushax
; Check if we do already have a driver loaded. If so, remove it.
lda _ser_drv
ora _ser_drv+1
ldy _ser_drv
bne @L0
ldy _ser_drv+1
beq @L1
jsr _ser_uninstall
@L0: lda #SER_ERR_INSTALLED
bne @L4
; Open the file. The name parameter is already on stack and will get removed
; by open().
; Push the name onto the C stack and open the file. The parameter will get
; removed by open().
; ctrl.callerdata = open (name, O_RDONLY);
@L1: lda #<O_RDONLY
@L1: jsr pushax
lda #<O_RDONLY
jsr pusha0
ldy #4 ; Argument size
jsr _open
@ -113,7 +113,7 @@ ctrl: .addr _read
; Open or mod_load failed. Return an error code.
@L3: lda #<SER_ERR_CANNOT_LOAD
ldx #>SER_ERR_CANNOT_LOAD
@L4: ldx #0
rts
.endproc