2 ; Ullrich von Bassewitz, 2002-11-29
4 ; Common functions of the extended memory API.
7 .import return0, em_libref
10 .include "em-kernel.inc"
11 .include "em-error.inc"
14 ;----------------------------------------------------------------------------
19 _em_drv: .res 2 ; Pointer to driver
21 ; Jump table for the driver functions.
24 emd_install: jmp return0
25 emd_uninstall: jmp return0
26 emd_pagecount: jmp return0
29 emd_commit: jmp return0
30 emd_copyfrom: jmp return0
31 emd_copyto: jmp return0
33 ; Driver header signature
35 emd_sig: .byte $65, $6d, $64, EMD_API_VERSION ; "emd", version
38 ;----------------------------------------------------------------------------
39 ; unsigned char __fastcall__ em_install (void* driver);
40 ; /* Install the driver once it is loaded */
49 ; Check the driver signature
51 ldy #.sizeof(emd_sig)-1
58 ; Set the library reference
67 ; Copy the jump vectors
71 @L1: inx ; Skip the JMP opcode
72 jsr copy ; Copy one byte
73 jsr copy ; Copy one byte
74 cpy #(EMD_HDR::JUMPTAB + .sizeof(EMD_HDR::JUMPTAB))
77 jmp emd_install ; Call driver install routine
79 ; Driver signature invalid
82 lda #EM_ERR_INV_DRIVER
86 ; Copy one byte from the jump vectors
94 ;----------------------------------------------------------------------------
95 ; unsigned char em_uninstall (void);
96 ; /* Uninstall the currently loaded driver and return an error code.
97 ; ** Note: This call does not free allocated memory.
101 jsr emd_uninstall ; Call driver routine
103 em_clear_ptr: ; External entry point
106 sta _em_drv+1 ; Clear the driver pointer