Add open to the VFS
This commit is contained in:
parent
75754cfb7f
commit
f3530d5528
38
init.z80
38
init.z80
@ -74,9 +74,43 @@ mount_mb_read_done:
|
|||||||
ld a, b ; Loop if there is no message
|
ld a, b ; Loop if there is no message
|
||||||
cp 0
|
cp 0
|
||||||
jp nz, mount_loop
|
jp nz, mount_loop
|
||||||
ld a, (0xA001)
|
|
||||||
ld c, a
|
|
||||||
mount_done:
|
mount_done:
|
||||||
|
; Set up an open message to the VFS for "/test"
|
||||||
|
ld hl, (mailbox_num)
|
||||||
|
ld (0xA000), hl
|
||||||
|
ld a, 0x2 ; Open operation
|
||||||
|
ld (0xA002), a
|
||||||
|
ld a, 0x2F ; '/'
|
||||||
|
ld (0xA003), a
|
||||||
|
ld a, 0x74 ; 't'
|
||||||
|
ld (0xA004), a
|
||||||
|
ld a, 0x65 ; 'e'
|
||||||
|
ld (0xA005), a
|
||||||
|
ld a, 0x73 ; 's'
|
||||||
|
ld (0xA006), a
|
||||||
|
ld a, 0x74 ; 't'
|
||||||
|
ld (0xA007), a
|
||||||
|
ld a, 0x0 ; '\0'
|
||||||
|
ld (0xA008), a
|
||||||
|
push de
|
||||||
|
push bc
|
||||||
|
ld de, 2 ; Get the mailbox number for the VFS
|
||||||
|
call proc_map_get
|
||||||
|
open_pmg_done:
|
||||||
|
pop bc
|
||||||
|
pop de
|
||||||
|
ld ix, 0x0000 ; Send the message
|
||||||
|
call mb_send
|
||||||
|
open_loop:
|
||||||
|
call yield
|
||||||
|
open_loop_yield_done:
|
||||||
|
ld hl, (mailbox_num)
|
||||||
|
call mb_read ; Read a message
|
||||||
|
open_mb_read_done:
|
||||||
|
ld a, b ; Loop if there is no message
|
||||||
|
cp 0
|
||||||
|
jp nz, open_loop
|
||||||
|
open_done:
|
||||||
halt
|
halt
|
||||||
|
|
||||||
mailbox_num: .ds.b 2
|
mailbox_num: .ds.b 2
|
||||||
|
11
test_fs.z80
11
test_fs.z80
@ -82,13 +82,18 @@ call mb_send
|
|||||||
jp msg_loop
|
jp msg_loop
|
||||||
|
|
||||||
open:
|
open:
|
||||||
jp z, operation_done
|
halt
|
||||||
|
ld a, 0xAA
|
||||||
|
ld (0xB000), a
|
||||||
|
ld a, 0x55
|
||||||
|
ld (0xB001), a
|
||||||
|
jp operation_done
|
||||||
|
|
||||||
read:
|
read:
|
||||||
jp z, operation_done
|
jp operation_done
|
||||||
|
|
||||||
mount:
|
mount:
|
||||||
jp z, operation_done
|
jp operation_done
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
101
vfs.z80
101
vfs.z80
@ -114,15 +114,13 @@ mount:
|
|||||||
ld a, (mount_count)
|
ld a, (mount_count)
|
||||||
ld l, 0x0
|
ld l, 0x0
|
||||||
ld h, a
|
ld h, a
|
||||||
ld de, data_mount_offset
|
ld de, 0x9000 + data_mount_offset
|
||||||
add hl, de
|
|
||||||
ld de, 0x9000
|
|
||||||
add hl, de
|
add hl, de
|
||||||
push hl
|
push hl
|
||||||
pop de
|
pop de
|
||||||
push de
|
push de
|
||||||
ld hl, 0xB003
|
ld hl, 0xB003
|
||||||
ld bc, 252
|
ld bc, 0xFC
|
||||||
ldir
|
ldir
|
||||||
; FS type at 0xB1FF
|
; FS type at 0xB1FF
|
||||||
ld a, (fs_count)
|
ld a, (fs_count)
|
||||||
@ -141,21 +139,27 @@ jp mount_loop1_done
|
|||||||
add hl, de
|
add hl, de
|
||||||
djnz mount_loop1
|
djnz mount_loop1
|
||||||
mount_loop1_done:
|
mount_loop1_done:
|
||||||
|
; hl -> pointer to fs type info
|
||||||
|
; top of stack -> pointer to open mount info slot
|
||||||
ld de, 14
|
ld de, 14
|
||||||
add hl, de
|
add hl, de
|
||||||
pop ix
|
pop ix
|
||||||
ld de, 252
|
; hl -> pointer to byte 15 of fs type info
|
||||||
|
; ix -> pointer to open mount info slot
|
||||||
|
ld de, 0xFD
|
||||||
add ix, de
|
add ix, de
|
||||||
|
; ix -> pointer to offset 0xFD of mount info
|
||||||
|
; fs info word starting at 0xE -> mount info word starting at 0xFD
|
||||||
ld e, (hl)
|
ld e, (hl)
|
||||||
inc hl
|
inc hl
|
||||||
ld d, (hl)
|
ld d, (hl)
|
||||||
ld (ix), e
|
ld (ix), e
|
||||||
ld (ix+1), d
|
ld (ix+1), d
|
||||||
push ix
|
|
||||||
ld hl, (fs_mailbox_num)
|
ld hl, (fs_mailbox_num)
|
||||||
ld (0x8000), hl
|
ld (0x8000), hl
|
||||||
ld a, 0x2
|
ld a, 0x2
|
||||||
ld (0x8002), a
|
ld (0x8002), a
|
||||||
|
push ix
|
||||||
push de
|
push de
|
||||||
ld hl, 0xB0FF
|
ld hl, 0xB0FF
|
||||||
ld de, 0x8003
|
ld de, 0x8003
|
||||||
@ -175,10 +179,9 @@ ld a, b ; Loop if there is no message
|
|||||||
cp 0
|
cp 0
|
||||||
jp nz, mount_wait_loop
|
jp nz, mount_wait_loop
|
||||||
pop ix
|
pop ix
|
||||||
|
; response byte 1 -> mount info byte at offset 0xFF
|
||||||
ld a, (0x8000)
|
ld a, (0x8000)
|
||||||
ld (ix+2), a
|
ld (ix+2), a
|
||||||
ld a, (0x8001)
|
|
||||||
ld (ix+3), a
|
|
||||||
ld a, (mount_count)
|
ld a, (mount_count)
|
||||||
inc a
|
inc a
|
||||||
ld (mount_count), a
|
ld (mount_count), a
|
||||||
@ -192,21 +195,99 @@ ld a, (iy)
|
|||||||
ld b, a
|
ld b, a
|
||||||
ld a, (ix)
|
ld a, (ix)
|
||||||
cp b
|
cp b
|
||||||
|
jp nz, vfsstrcmp_loopend
|
||||||
cp 0
|
cp 0
|
||||||
ret z
|
ret z
|
||||||
jp nz, vfsstrcmp_loopend
|
|
||||||
inc ix
|
inc ix
|
||||||
inc iy
|
inc iy
|
||||||
jp vfsstrcmp_loop
|
jp vfsstrcmp_loop
|
||||||
vfsstrcmp_loopend:
|
vfsstrcmp_loopend:
|
||||||
|
ld a, (ix)
|
||||||
|
cp 0
|
||||||
|
ret z
|
||||||
ld a, (iy)
|
ld a, (iy)
|
||||||
ld b, a
|
ld b, a
|
||||||
ld a, (ix)
|
ld a, (ix)
|
||||||
sub b
|
sub b
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; TODO open
|
|
||||||
open:
|
open:
|
||||||
|
; Scan mountpoints for largest prefix matching path
|
||||||
|
ld hl, data_mount_offset + 0x9000
|
||||||
|
ld bc, 0
|
||||||
|
ld de, 0
|
||||||
|
open_mount_scan:
|
||||||
|
ld a, (hl)
|
||||||
|
cp 0
|
||||||
|
jp z, open_mount_scan_done
|
||||||
|
push hl
|
||||||
|
pop ix
|
||||||
|
ld iy, 0xB003
|
||||||
|
push bc
|
||||||
|
call vfsstrcmp
|
||||||
|
pop bc
|
||||||
|
cp 0
|
||||||
|
jp nz, open_no_prefix
|
||||||
|
push hl
|
||||||
|
pop de
|
||||||
|
call strlen
|
||||||
|
open_no_prefix:
|
||||||
|
ld a, h
|
||||||
|
inc a
|
||||||
|
ld h, a
|
||||||
|
ld l, 0
|
||||||
|
jp open_mount_scan
|
||||||
|
open_mount_scan_done:
|
||||||
|
; Send open request to FS w/ path-prefix and mount ID
|
||||||
|
ld hl, 0xB003
|
||||||
|
add hl, bc
|
||||||
|
push de
|
||||||
|
; mountpoint path -> 0x8003-0x8103 (exclusive end)
|
||||||
|
ld de, 0x8003
|
||||||
|
ld bc, 0x100
|
||||||
|
ldir
|
||||||
|
pop de
|
||||||
|
; mount info byte 0xFF -> 0x8103
|
||||||
|
ld e, 0xFF
|
||||||
|
ld a, (de)
|
||||||
|
ld (0x8103), a
|
||||||
|
; imm 0x0 -> 0x8002
|
||||||
|
ld a, 0x0
|
||||||
|
ld (0x8002), a
|
||||||
|
; fs_mailbox_num (16bit) -> 0x8000,0x8001
|
||||||
|
ld hl, 0x8000
|
||||||
|
ld bc, (fs_mailbox_num)
|
||||||
|
ld (hl), c
|
||||||
|
inc hl
|
||||||
|
ld (hl), b
|
||||||
|
; mount info word 0xFD -> hl
|
||||||
|
ld e, 0xFD
|
||||||
|
ld a, (de)
|
||||||
|
ld l, a
|
||||||
|
inc de
|
||||||
|
ld a, (de)
|
||||||
|
ld h, a
|
||||||
|
push hl
|
||||||
|
ld a, (send_page_addr)
|
||||||
|
ld c, a
|
||||||
|
ld de, (send_page_addr+1)
|
||||||
|
ld ix, 0x0
|
||||||
|
call mb_send
|
||||||
|
; Get request back, pass on to caller (add in alt MB id support?)
|
||||||
|
open_wait_loop:
|
||||||
|
call yield
|
||||||
|
ld hl, (fs_mailbox_num)
|
||||||
|
call mb_read ; Read a message
|
||||||
|
ld a, b ; Loop if there is no message
|
||||||
|
cp 0
|
||||||
|
jp nz, open_wait_loop
|
||||||
|
pop hl
|
||||||
|
ld (0xB002), hl
|
||||||
|
; word at 0x8000 -> 0xB000
|
||||||
|
ld a, (0x8000)
|
||||||
|
ld (0xB000), a
|
||||||
|
ld a, (0x8001)
|
||||||
|
ld (0xB001), a
|
||||||
jp operation_done
|
jp operation_done
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user