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