blockdev: remove one layer of indirection
The approach used for shell extra commands also works for blockdev. Much simpler and tighter this way.
This commit is contained in:
parent
a27da6f41a
commit
21eb64f751
@ -17,46 +17,31 @@ BLOCKDEV_ERR_OUT_OF_BOUNDS .equ 0x03
|
|||||||
BLOCKDEV_ERR_UNSUPPORTED .equ 0x04
|
BLOCKDEV_ERR_UNSUPPORTED .equ 0x04
|
||||||
|
|
||||||
; *** VARIABLES ***
|
; *** VARIABLES ***
|
||||||
; A memory pointer to a device table. A device table is a list of addresses
|
|
||||||
; pointing to GetC, PutC and Seek routines.
|
|
||||||
BLOCKDEV_TBL .equ BLOCKDEV_RAMSTART
|
|
||||||
; Pointer to the selected block device. A block device is a 6 bytes block of
|
; Pointer to the selected block device. A block device is a 6 bytes block of
|
||||||
; memory with pointers to GetC, PutC and Seek routines, in that order. 0 means
|
; memory with pointers to GetC, PutC and Seek routines, in that order. 0 means
|
||||||
; unsupported.
|
; unsupported.
|
||||||
BLOCKDEV_SEL .equ BLOCKDEV_TBL+(BLOCKDEV_COUNT*2)
|
BLOCKDEV_SEL .equ BLOCKDEV_RAMSTART
|
||||||
BLOCKDEV_RAMEND .equ BLOCKDEV_SEL+2
|
BLOCKDEV_RAMEND .equ BLOCKDEV_SEL+2
|
||||||
|
|
||||||
; *** CODE ***
|
; *** CODE ***
|
||||||
; set DE to point to the table entry at index A.
|
; Select block index specified in A
|
||||||
blkFind:
|
blkSel:
|
||||||
ld de, BLOCKDEV_TBL
|
push af
|
||||||
|
push hl
|
||||||
|
ld hl, blkDevTbl
|
||||||
cp 0
|
cp 0
|
||||||
ret z ; index is zero? don't loop
|
jr z, .afterloop ; index is zero? don't loop
|
||||||
push bc
|
push bc
|
||||||
ld b, a
|
ld b, a
|
||||||
.loop:
|
.loop:
|
||||||
inc de
|
ld a, 6
|
||||||
inc de
|
call addHL
|
||||||
djnz .loop
|
djnz .loop
|
||||||
pop bc
|
pop bc
|
||||||
ret
|
.afterloop:
|
||||||
|
ld (BLOCKDEV_SEL), hl
|
||||||
; Set the pointer of device id A to the value in HL
|
pop Hl
|
||||||
blkSet:
|
pop af
|
||||||
call blkFind
|
|
||||||
call writeHLinDE
|
|
||||||
ret
|
|
||||||
|
|
||||||
; Select block index specified in A
|
|
||||||
blkSel:
|
|
||||||
push de
|
|
||||||
push hl
|
|
||||||
call blkFind
|
|
||||||
ld hl, BLOCKDEV_SEL
|
|
||||||
ex hl, de
|
|
||||||
ldi
|
|
||||||
pop hl
|
|
||||||
pop de
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
blkBselCmd:
|
blkBselCmd:
|
||||||
@ -140,3 +125,8 @@ blkSeek:
|
|||||||
ld iyl, 4
|
ld iyl, 4
|
||||||
jr _blkCall
|
jr _blkCall
|
||||||
|
|
||||||
|
; This label is at the end of the file on purpose: the glue file should include
|
||||||
|
; a list of device routine table entries just after the include. Each line
|
||||||
|
; has 3 word addresses: GetC, PutC and Seek. An entry could look like:
|
||||||
|
; .dw mmapGetC, mmapPutC, mmapSeek
|
||||||
|
blkDevTbl:
|
||||||
|
Loading…
Reference in New Issue
Block a user