]> git.sur5r.net Git - cc65/commitdiff
Fixed a problem in mouse_load_driver: The driver was not removed from memory
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sun, 4 Jun 2006 09:48:14 +0000 (09:48 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sun, 4 Jun 2006 09:48:14 +0000 (09:48 +0000)
when the load failed.

git-svn-id: svn://svn.cc65.org/cc65/trunk@3748 b7a2c559-68d2-44c3-8de9-860c34a00d81

asminc/mouse-kernel.inc
include/mouse/mouse-kernel.h
libsrc/mouse/mouse-kernel.s
libsrc/mouse/mouse_load.c

index 61eae0b4e2ae7ce0b330399d3f981f2c3d407370..9e8662895df07f4b57857c29f1a3e8b7f84752fa 100644 (file)
@@ -151,8 +151,10 @@ MOUSE_BTN_RIGHT         = $01
         .global _mouse_info
         .global _mouse_ioctl
 
+       .global _mouse_clear_ptr
+
 ;------------------------------------------------------------------------------
-; Driver entry points
+; Driver entry points (asm callable)
 
         .global mouse_install
         .global mouse_uninstall
index 9455f794915b550bcfa368b4069e04f709df7af1..1bcac64d5fe7ae95b68bb7fe365e4e79dd1c516b 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2003      Ullrich von Bassewitz                                       */
-/*               Römerstraße 52                                              */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 2003-2006, Ullrich von Bassewitz                                      */
+/*                Römerstraße 52                                             */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -49,6 +49,17 @@ extern void*         mouse_drv;              /* Pointer to driver */
 
 
 
+/*****************************************************************************/
+/*                                   Code                                    */
+/*****************************************************************************/
+
+
+
+void mouse_clear_ptr (void);
+/* Clear the mouse_drv pointer */
+
+
+
 /* End of mouse-kernel.h */
 #endif
 
index 9a1fdf1f191e22e256c14fcbdfca551a3e9cf154..bd0e15356637cdbc12f62b28c7b05c3e420bc3c4 100644 (file)
@@ -162,7 +162,7 @@ _mouse_uninstall:
        jsr     uninstall_irq           ; Disable driver interrupts
         jsr     mouse_uninstall         ; Call driver routine
 
-mouse_clear_ptr:                        ; External entry point
+_mouse_clear_ptr:                       ; External entry point
         lda     #0
         sta     _mouse_drv
         sta     _mouse_drv+1            ; Clear the driver pointer
@@ -170,3 +170,4 @@ mouse_clear_ptr:                        ; External entry point
         tax
         rts                             ; Return zero
 
+                  
index cbb7cecba377b72445fc7bfa828b9a5986742ab7..a04a8eaad4b365510273a31a08663575c991e2bd 100644 (file)
@@ -75,9 +75,22 @@ unsigned char __fastcall__ mouse_load_driver (const struct mouse_callbacks* c,
         if (Res == MLOAD_OK) {
 
             /* Check the driver signature, install the driver */
-            return mouse_install (c, ctrl.module);
-
+            Res = mouse_install (c, ctrl.module);
+
+           /* If the driver did not install correctly, remove it from
+            * memory again.
+            */
+           if (Res != MLOAD_OK) { 
+                /* Do not call mouse_uninstall here, since the driver is not
+                 * correctly installed.
+                 */
+                mod_free (mouse_drv);
+                mouse_clear_ptr ();
+            }
         }
+
+        /* Return the error code */
+        return Res;
     }
 
     /* Error loading the driver */