Fixed an error in the load routine: The driver was not removed from memory
when the install routine failed. git-svn-id: svn://svn.cc65.org/cc65/trunk@3750 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -6,10 +6,10 @@
|
|||||||
;* *
|
;* *
|
||||||
;* *
|
;* *
|
||||||
;* *
|
;* *
|
||||||
;*(C) 2003 Ullrich von Bassewitz *
|
;*(C) 2003-2006, Ullrich von Bassewitz *
|
||||||
;* R<EFBFBD>merstrasse 52 *
|
;* R<EFBFBD>merstrasse 52 *
|
||||||
;* D-70794 Filderstadt *
|
;* D-70794 Filderstadt *
|
||||||
;*EMail: uz@cc65.org *
|
;*EMail: uz@cc65.org *
|
||||||
;* *
|
;* *
|
||||||
;* *
|
;* *
|
||||||
;*This software is provided 'as-is', without any expressed or implied *
|
;*This software is provided 'as-is', without any expressed or implied *
|
||||||
@@ -142,7 +142,7 @@ SER_STATUS_DSR = $40 ; NOT data set ready
|
|||||||
.global ser_irq
|
.global ser_irq
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
; ASM functions
|
; C callable functions
|
||||||
|
|
||||||
.global _ser_unload
|
.global _ser_unload
|
||||||
.global _ser_install
|
.global _ser_install
|
||||||
@@ -154,4 +154,5 @@ SER_STATUS_DSR = $40 ; NOT data set ready
|
|||||||
.global _ser_status
|
.global _ser_status
|
||||||
.global _ser_ioctl
|
.global _ser_ioctl
|
||||||
|
|
||||||
|
.global _ser_clear_ptr
|
||||||
|
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ _ser_uninstall:
|
|||||||
lda #$60 ; RTS opcode
|
lda #$60 ; RTS opcode
|
||||||
sta ser_irq ; Disable IRQ entry point
|
sta ser_irq ; Disable IRQ entry point
|
||||||
|
|
||||||
|
_ser_clear_ptr: ; External entry point
|
||||||
lda #0
|
lda #0
|
||||||
sta _ser_drv
|
sta _ser_drv
|
||||||
sta _ser_drv+1 ; Clear the driver pointer
|
sta _ser_drv+1 ; Clear the driver pointer
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2003 Ullrich von Bassewitz */
|
/* (C) 2003-2006, Ullrich von Bassewitz */
|
||||||
/* R<>merstrasse 52 */
|
/* R<EFBFBD>merstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@@ -50,6 +50,9 @@
|
|||||||
/* Pointer to serial driver, exported from ser-kernel.s */
|
/* Pointer to serial driver, exported from ser-kernel.s */
|
||||||
extern void* ser_drv;
|
extern void* ser_drv;
|
||||||
|
|
||||||
|
/* Function that clears the driver pointer (ser-kernel.s) */
|
||||||
|
void ser_clear_ptr (void);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -58,6 +61,11 @@ extern void* ser_drv;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Use static local variables, since the module is not reentrant anyway */
|
||||||
|
#pragma staticlocals (on);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
unsigned char __fastcall__ ser_load_driver (const char* name)
|
unsigned char __fastcall__ ser_load_driver (const char* name)
|
||||||
/* Load a serial driver and return an error code */
|
/* Load a serial driver and return an error code */
|
||||||
{
|
{
|
||||||
@@ -85,8 +93,21 @@ unsigned char __fastcall__ ser_load_driver (const char* name)
|
|||||||
if (Res == MLOAD_OK) {
|
if (Res == MLOAD_OK) {
|
||||||
|
|
||||||
/* Check the driver signature, install the driver */
|
/* Check the driver signature, install the driver */
|
||||||
return ser_install (ctrl.module);
|
Res = ser_install (ctrl.module);
|
||||||
|
|
||||||
|
/* If the driver did not install correctly, remove it from
|
||||||
|
* memory again.
|
||||||
|
*/
|
||||||
|
if (Res != SER_ERR_OK) {
|
||||||
|
/* Do not call ser_uninstall here, since the driver is not
|
||||||
|
* correctly installed.
|
||||||
|
*/
|
||||||
|
mod_free (ser_drv);
|
||||||
|
ser_clear_ptr ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the error code */
|
||||||
|
return Res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user