]> git.sur5r.net Git - cc65/commitdiff
An already loaded driver is an error in ser_load_driver, because the library
authoruz <uz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sun, 22 Jul 2012 19:54:04 +0000 (19:54 +0000)
committeruz <uz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sun, 22 Jul 2012 19:54:04 +0000 (19:54 +0000)
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

asminc/ser-error.inc
include/serial.h
libsrc/serial/ser_load.s

index e6057a64124dcf86df6d8075ce08f37b75ac3749..f1592876b617ef7886a3d0fd3a29ff09499d36d0 100644 (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       *
 ;------------------------------------------------------------------------------
 ; 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
 
index 04b5144a2c7f3d92085adcb8ba19561769d40040..b5601170e4166ba1ff2661f6d32983fe00c2eaf2 100644 (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                                                */
 #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 {
index d711a74b1464363ff46cb78f3046900827cad5fc..069327d7fb3a030b23f2763237b31c5d63eb6f49 100644 (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