mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-23 20:08:05 +11:00
blockdev: make selection structure opaque
I'm about to change that structure and I don't want fs to be messed up by this. I'm proceeding step by step...
This commit is contained in:
parent
c85ed474d7
commit
63473cc2e3
@ -26,7 +26,7 @@ look like:
|
||||
im 1
|
||||
call aciaInit
|
||||
xor a
|
||||
ld de, BLOCKDEV_GETC
|
||||
ld de, BLOCKDEV_SEL
|
||||
call blkSel
|
||||
call stdioInit
|
||||
call shellInit
|
||||
|
@ -59,15 +59,12 @@
|
||||
; Pointer to the selected block device. A block device is a 8 bytes block of
|
||||
; memory with pointers to GetC, PutC, Seek and Tell routines, in that order.
|
||||
; 0 means unsupported.
|
||||
.equ BLOCKDEV_GETC BLOCKDEV_RAMSTART
|
||||
.equ BLOCKDEV_PUTC BLOCKDEV_GETC+2
|
||||
.equ BLOCKDEV_SEEK BLOCKDEV_PUTC+2
|
||||
.equ BLOCKDEV_TELL BLOCKDEV_SEEK+2
|
||||
.equ BLOCKDEV_RAMEND BLOCKDEV_TELL+2
|
||||
.equ BLOCKDEV_SEL BLOCKDEV_RAMSTART
|
||||
.equ BLOCKDEV_RAMEND BLOCKDEV_SEL+8
|
||||
|
||||
; *** CODE ***
|
||||
; Select block index specified in A and place them in routine pointers at (DE).
|
||||
; For example, for a "regular" blkSel, you will want to set DE to BLOCKDEV_GETC.
|
||||
; For example, for a "regular" blkSel, you will want to set DE to BLOCKDEV_SEL.
|
||||
blkSel:
|
||||
push af
|
||||
push de
|
||||
@ -120,13 +117,13 @@ blkSel:
|
||||
; Sets Z according to whether read was successful: Set if successful, unset
|
||||
; if not.
|
||||
blkGetC:
|
||||
ld ix, (BLOCKDEV_GETC)
|
||||
ld ix, (BLOCKDEV_SEL)
|
||||
jp (ix)
|
||||
|
||||
; Reads B chars from blkGetC and copy them in (HL).
|
||||
; Sets Z if successful, unset Z if there was an error.
|
||||
blkRead:
|
||||
ld ix, (BLOCKDEV_GETC)
|
||||
ld ix, (BLOCKDEV_SEL)
|
||||
_blkRead:
|
||||
push hl
|
||||
push bc
|
||||
@ -145,16 +142,20 @@ _blkRead:
|
||||
; Writes character in A in current position in the selected device. Sets Z
|
||||
; according to whether the operation was successful.
|
||||
blkPutC:
|
||||
ld ix, (BLOCKDEV_PUTC)
|
||||
ld ix, (BLOCKDEV_SEL+2)
|
||||
jp (ix)
|
||||
|
||||
; Writes B chars to blkPutC from (HL).
|
||||
; Sets Z if successful, unset Z if there was an error.
|
||||
blkWrite:
|
||||
ld ix, (BLOCKDEV_PUTC)
|
||||
ld ix, (BLOCKDEV_SEL)
|
||||
_blkWrite:
|
||||
push ix
|
||||
push hl
|
||||
push bc
|
||||
; make IX point to PutC
|
||||
inc ix
|
||||
inc ix
|
||||
.loop:
|
||||
ld a, (hl)
|
||||
call callIX
|
||||
@ -165,6 +166,7 @@ _blkWrite:
|
||||
.end:
|
||||
pop bc
|
||||
pop hl
|
||||
pop ix
|
||||
ret
|
||||
|
||||
; Seeks the block device in one of 5 modes, which is the A argument:
|
||||
@ -184,8 +186,8 @@ _blkWrite:
|
||||
; If the device is "growable", it's possible that seeking to end when calling
|
||||
; PutC doesn't necessarily result in a failure.
|
||||
blkSeek:
|
||||
ld ix, (BLOCKDEV_SEEK)
|
||||
ld iy, (BLOCKDEV_TELL)
|
||||
ld ix, (BLOCKDEV_SEL+4)
|
||||
ld iy, (BLOCKDEV_SEL+6)
|
||||
_blkSeek:
|
||||
; we preserve DE so that it's possible to call blkSeek in mode != 0
|
||||
; while not discarding our current DE value.
|
||||
@ -234,7 +236,7 @@ _blkSeek:
|
||||
; Returns the current position of the selected device in HL (low) and DE (high).
|
||||
blkTell:
|
||||
ld de, 0 ; in case device ignores DE.
|
||||
ld ix, (BLOCKDEV_TELL)
|
||||
ld ix, (BLOCKDEV_SEL+6)
|
||||
jp (ix)
|
||||
|
||||
; This label is at the end of the file on purpose: the glue file should include
|
||||
|
@ -8,7 +8,7 @@ blkBselCmd:
|
||||
cp BLOCKDEV_COUNT
|
||||
jr nc, .error ; if selection >= device count, error
|
||||
push de
|
||||
ld de, BLOCKDEV_GETC
|
||||
ld de, BLOCKDEV_SEL
|
||||
call blkSel
|
||||
pop de
|
||||
xor a
|
||||
|
@ -369,7 +369,7 @@ fsblkPutC:
|
||||
|
||||
fsblkWrite:
|
||||
push ix
|
||||
ld ix, (FS_PUTC)
|
||||
ld ix, (FS_GETC) ; we have to point to blkdev's beginning
|
||||
call _blkWrite
|
||||
pop ix
|
||||
ret
|
||||
@ -523,7 +523,7 @@ fsOn:
|
||||
push bc
|
||||
; We have to set blkdev routines early before knowing whether the
|
||||
; mounting succeeds because methods like fsReadMeta uses fsblk* methods.
|
||||
ld hl, BLOCKDEV_GETC
|
||||
ld hl, BLOCKDEV_SEL
|
||||
ld de, FS_GETC
|
||||
ld bc, 8 ; we have 8 bytes to copy
|
||||
ldir ; copy!
|
||||
|
@ -72,7 +72,7 @@ init:
|
||||
ld (SHELL_CMDHOOK), hl
|
||||
|
||||
xor a
|
||||
ld de, BLOCKDEV_GETC
|
||||
ld de, BLOCKDEV_SEL
|
||||
call blkSel
|
||||
|
||||
ei
|
||||
|
@ -99,7 +99,7 @@ init:
|
||||
ld (SHELL_CMDHOOK), hl
|
||||
|
||||
xor a
|
||||
ld de, BLOCKDEV_GETC
|
||||
ld de, BLOCKDEV_SEL
|
||||
call blkSel
|
||||
|
||||
ei
|
||||
|
@ -47,7 +47,6 @@
|
||||
.dw stdinGetC, stdinPutC, stdinSeek, stdinTell
|
||||
.dw mmapGetC, mmapPutC, mmapSeek, mmapTell
|
||||
|
||||
#include "blockdev_cmds.asm"
|
||||
|
||||
.equ MMAP_RAMSTART BLOCKDEV_RAMEND
|
||||
.equ MMAP_START 0xe000
|
||||
@ -59,7 +58,6 @@
|
||||
.equ FS_RAMSTART STDIO_RAMEND
|
||||
.equ FS_HANDLE_COUNT 2
|
||||
#include "fs.asm"
|
||||
#include "fs_cmds.asm"
|
||||
|
||||
.equ SHELL_RAMSTART FS_RAMEND
|
||||
.equ SHELL_EXTRA_CMD_COUNT 9
|
||||
@ -67,11 +65,14 @@
|
||||
.dw blkBselCmd, blkSeekCmd, blkLoadCmd, blkSaveCmd
|
||||
.dw fsOnCmd, flsCmd, fnewCmd, fdelCmd, fopnCmd
|
||||
|
||||
#include "blockdev_cmds.asm"
|
||||
#include "fs_cmds.asm"
|
||||
|
||||
.equ PGM_RAMSTART SHELL_RAMEND
|
||||
.equ PGM_CODEADDR USERCODE
|
||||
#include "pgm.asm"
|
||||
|
||||
.out PGM_RAMEND
|
||||
;.out PGM_RAMEND
|
||||
|
||||
init:
|
||||
di
|
||||
@ -84,7 +85,7 @@ init:
|
||||
call mmapInit
|
||||
call fsInit
|
||||
ld a, 0 ; select fsdev
|
||||
ld de, BLOCKDEV_GETC
|
||||
ld de, BLOCKDEV_SEL
|
||||
call blkSel
|
||||
call fsOn
|
||||
call shellInit
|
||||
|
@ -49,7 +49,7 @@ init:
|
||||
ld hl, 0xffff
|
||||
ld sp, hl
|
||||
ld a, 2 ; select fsdev
|
||||
ld de, BLOCKDEV_GETC
|
||||
ld de, BLOCKDEV_SEL
|
||||
call blkSel
|
||||
call fsOn
|
||||
ld hl, .zasmArgs
|
||||
|
Loading…
Reference in New Issue
Block a user