2 ; Ullrich von Bassewitz, 2012-07-22
4 ; void __fastcall__ tgi_load_driver (const char* name);
5 ; /* Load and install the given driver. */
8 .include "tgi-kernel.inc"
9 .include "tgi-error.inc"
10 .include "modload.inc"
22 ;----------------------------------------------------------------------------
33 ;----------------------------------------------------------------------------
38 .proc _tgi_load_driver
40 ; Check if we do already have a driver loaded. This is an error. Do not
41 ; touch A/X because they contain the file name.
47 @L0: lda #TGI_ERR_INSTALLED
50 ; Push the name onto the C stack and open the file. The parameter will get
52 ; ctrl.callerdata = open (name, O_RDONLY);
57 ldy #4 ; Argument size
59 sta ctrl + MOD_CTRL::CALLERDATA
60 stx ctrl + MOD_CTRL::CALLERDATA+1
62 ; if (ctrl.callerdata >= 0) {
67 ; /* Load the module */
68 ; Res = mod_load (&ctrl);
75 ; /* Close the input file */
76 ; close (ctrl.callerdata);
78 lda ctrl + MOD_CTRL::CALLERDATA
79 ldx ctrl + MOD_CTRL::CALLERDATA+1
82 ; /* Check the return code */
83 ; if (Res == MLOAD_OK) {
87 @L2: lda #TGI_ERR_CANNOT_LOAD
89 ; Set an error and exit
94 ; Check the driver signature, install the driver.
95 ; tgi_install (ctrl.module);
97 @L5: lda ctrl + MOD_CTRL::MODULE
98 ldx ctrl + MOD_CTRL::MODULE+1
101 ; If tgi_install was successful, we're done
106 ; The driver didn't install correctly. Remove it from memory. The error code
111 jsr _mod_free ; Free the driver memory
112 jmp tgi_clear_ptr ; Clear tgi_drv and return