2 ; Ullrich von Bassewitz, 2002-11-29
4 ; Common functions of the extended memory API.
11 .include "em-kernel.inc"
12 .include "em-error.inc"
15 ;----------------------------------------------------------------------------
20 _em_drv: .res 2 ; Pointer to driver
22 ; Jump table for the driver functions.
25 emd_install: jmp return0
26 emd_uninstall: jmp return0
27 emd_pagecount: jmp return0
30 emd_commit: jmp return0
31 emd_copyfrom: jmp return0
32 emd_copyto: jmp return0
34 ; Driver header signature
36 emd_sig: .byte $65, $6d, $64, EMD_API_VERSION ; "emd", version
39 ;----------------------------------------------------------------------------
40 ; unsigned char __fastcall__ em_install (void* driver);
41 ; /* Install the driver once it is loaded */
50 ; Check the driver signature
52 ldy #.sizeof(emd_sig)-1
59 ; Copy the jump vectors
63 @L1: inx ; Skip the JMP opcode
64 jsr copy ; Copy one byte
65 jsr copy ; Copy one byte
66 cpy #(EMD_HDR::JUMPTAB + .sizeof(EMD_HDR::JUMPTAB))
69 jmp emd_install ; Call driver install routine
71 ; Driver signature invalid
74 lda #EM_ERR_INV_DRIVER
78 ; Copy one byte from the jump vectors
86 ;----------------------------------------------------------------------------
87 ; unsigned char em_uninstall (void);
88 ; /* Uninstall the currently loaded driver and return an error code.
89 ; * Note: This call does not free allocated memory.
93 jsr emd_uninstall ; Call driver routine
95 em_clear_ptr: ; External entry point
98 sta _em_drv+1 ; Clear the driver pointer