2002-11-29 14:46:56 +00:00
|
|
|
;
|
|
|
|
; Ullrich von Bassewitz, 2002-11-29
|
|
|
|
;
|
|
|
|
; Common functions of the extended memory API.
|
|
|
|
;
|
|
|
|
|
2013-05-31 22:11:31 +00:00
|
|
|
.import return0, em_libref
|
2002-11-29 14:46:56 +00:00
|
|
|
.importzp ptr1
|
|
|
|
|
|
|
|
.include "em-kernel.inc"
|
|
|
|
.include "em-error.inc"
|
|
|
|
|
|
|
|
|
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
; Variables
|
|
|
|
|
|
|
|
|
|
|
|
.bss
|
2013-05-09 11:56:54 +00:00
|
|
|
_em_drv: .res 2 ; Pointer to driver
|
2002-11-29 14:46:56 +00:00
|
|
|
|
|
|
|
; Jump table for the driver functions.
|
|
|
|
.data
|
|
|
|
emd_vectors:
|
2013-05-09 11:56:54 +00:00
|
|
|
emd_install: jmp return0
|
|
|
|
emd_uninstall: jmp return0
|
2002-12-05 18:57:53 +00:00
|
|
|
emd_pagecount: jmp return0
|
|
|
|
emd_map: jmp return0
|
|
|
|
emd_use: jmp return0
|
|
|
|
emd_commit: jmp return0
|
2013-05-09 11:56:54 +00:00
|
|
|
emd_copyfrom: jmp return0
|
2002-12-05 18:57:53 +00:00
|
|
|
emd_copyto: jmp return0
|
2002-11-29 14:46:56 +00:00
|
|
|
|
|
|
|
; Driver header signature
|
|
|
|
.rodata
|
2013-05-09 11:56:54 +00:00
|
|
|
emd_sig: .byte $65, $6d, $64, EMD_API_VERSION ; "emd", version
|
2002-11-29 14:46:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
; unsigned char __fastcall__ em_install (void* driver);
|
|
|
|
; /* Install the driver once it is loaded */
|
|
|
|
|
|
|
|
|
|
|
|
_em_install:
|
2013-05-09 11:56:54 +00:00
|
|
|
sta _em_drv
|
|
|
|
sta ptr1
|
|
|
|
stx _em_drv+1
|
|
|
|
stx ptr1+1
|
2002-11-29 14:46:56 +00:00
|
|
|
|
|
|
|
; Check the driver signature
|
|
|
|
|
2003-12-16 21:08:13 +00:00
|
|
|
ldy #.sizeof(emd_sig)-1
|
2002-11-29 14:46:56 +00:00
|
|
|
@L0: lda (ptr1),y
|
|
|
|
cmp emd_sig,y
|
|
|
|
bne inv_drv
|
|
|
|
dey
|
|
|
|
bpl @L0
|
|
|
|
|
2013-05-31 22:11:31 +00:00
|
|
|
; Set the library reference
|
|
|
|
|
|
|
|
ldy #EMD_HDR::LIBREF
|
|
|
|
lda #<em_libref
|
|
|
|
sta (ptr1),y
|
|
|
|
iny
|
|
|
|
lda #>em_libref
|
|
|
|
sta (ptr1),y
|
|
|
|
|
2002-11-29 14:46:56 +00:00
|
|
|
; Copy the jump vectors
|
|
|
|
|
2003-12-16 21:08:13 +00:00
|
|
|
ldy #EMD_HDR::JUMPTAB
|
2002-11-29 14:46:56 +00:00
|
|
|
ldx #0
|
|
|
|
@L1: inx ; Skip the JMP opcode
|
|
|
|
jsr copy ; Copy one byte
|
|
|
|
jsr copy ; Copy one byte
|
2003-12-16 21:08:13 +00:00
|
|
|
cpy #(EMD_HDR::JUMPTAB + .sizeof(EMD_HDR::JUMPTAB))
|
2002-11-29 14:46:56 +00:00
|
|
|
bne @L1
|
|
|
|
|
|
|
|
jmp emd_install ; Call driver install routine
|
|
|
|
|
|
|
|
; Driver signature invalid
|
|
|
|
|
|
|
|
inv_drv:
|
|
|
|
lda #EM_ERR_INV_DRIVER
|
|
|
|
ldx #0
|
|
|
|
rts
|
|
|
|
|
|
|
|
; Copy one byte from the jump vectors
|
|
|
|
|
|
|
|
copy: lda (ptr1),y
|
2003-02-11 12:36:18 +00:00
|
|
|
sta emd_vectors,x
|
2002-11-29 14:46:56 +00:00
|
|
|
iny
|
|
|
|
inx
|
|
|
|
rts
|
|
|
|
|
|
|
|
;----------------------------------------------------------------------------
|
2012-03-04 13:08:54 +00:00
|
|
|
; unsigned char em_uninstall (void);
|
2003-02-10 23:01:13 +00:00
|
|
|
; /* Uninstall the currently loaded driver and return an error code.
|
2014-06-30 09:10:35 +00:00
|
|
|
; ** Note: This call does not free allocated memory.
|
|
|
|
; */
|
2002-11-29 14:46:56 +00:00
|
|
|
|
2003-02-10 23:01:13 +00:00
|
|
|
_em_uninstall:
|
|
|
|
jsr emd_uninstall ; Call driver routine
|
2002-11-29 14:46:56 +00:00
|
|
|
|
2003-02-10 23:01:13 +00:00
|
|
|
em_clear_ptr: ; External entry point
|
|
|
|
lda #0
|
|
|
|
sta _em_drv
|
|
|
|
sta _em_drv+1 ; Clear the driver pointer
|
2002-11-29 14:46:56 +00:00
|
|
|
|
2003-02-10 23:01:13 +00:00
|
|
|
tax
|
|
|
|
rts ; Return zero
|