2 ; Ullrich von Bassewitz, 2002-11-29
4 ; Common functions of the extended memory API.
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 ; Copy the jump vectors
62 @L1: inx ; Skip the JMP opcode
63 jsr copy ; Copy one byte
64 jsr copy ; Copy one byte
65 cpy #(EMD_HDR::JUMPTAB + .sizeof(EMD_HDR::JUMPTAB))
68 jmp emd_install ; Call driver install routine
70 ; Driver signature invalid
73 lda #EM_ERR_INV_DRIVER
77 ; Copy one byte from the jump vectors
85 ;----------------------------------------------------------------------------
86 ; unsigned char em_uninstall (void);
87 ; /* Uninstall the currently loaded driver and return an error code.
88 ; * Note: This call does not free allocated memory.
92 jsr emd_uninstall ; Call driver routine
94 em_clear_ptr: ; External entry point
97 sta _em_drv+1 ; Clear the driver pointer