Add VFS mount

This commit is contained in:
pjht 2023-09-17 11:02:33 -05:00
parent b79ceb0cb1
commit 263555b151
Signed by: pjht
GPG Key ID: 7B5F6AFBEC7EE78E
2 changed files with 123 additions and 49 deletions

155
init.z80
View File

@ -11,11 +11,11 @@ ld d, h
ld c, 8 ld c, 8
bp_call_sf: bp_call_sf:
call set_frame call set_frame
; ld iy, vfs_name ; Load and run the initrd driver ld iy, vfs_name ; Load and run the initrd driver
; call run_file call run_file
; vfs_loaded: vfs_loaded:
; call yield ; Yield to let the initrd driver initialize call yield ; Yield to let the initrd driver initialize
; vfs_returned: vfs_returned:
ld iy, initrd_driver_name ; Load and run the initrd driver ld iy, initrd_driver_name ; Load and run the initrd driver
call run_file call run_file
initrd_driver_loaded: initrd_driver_loaded:
@ -45,32 +45,22 @@ pop de
ld c, 0xA ld c, 0xA
call set_frame call set_frame
frame_done: frame_done:
; Set up an open message to the initrd FS for "init.elf" ; Set up a register FS message to the VFS for "a" at mailbox 1
ld hl, (mailbox_num) ld hl, (mailbox_num)
ld (0xA000), hl ld (0xA000), hl
ld a, 0x0 ; Open operation ld a, 0x0 ; Register FS operation
ld (0xA002), a ld (0xA002), a
ld a, 0x69 ; i ld a, 0x61 ; 'a'
ld (0xA003), a ld (0xA003), a
ld a, 0x6e ; n ld a, 0x0 ; '\0'
ld (0xA004), a ld (0xA004), a
ld a, 0x69 ; i ld a, 0x1
ld (0xA005), a ld (0xA011), a
ld a, 0x74 ; t ld a, 0x0
ld (0xA006), a ld (0xA012), a
ld a, 0x2e ; .
ld (0xA007), a
ld a, 0x65 ; e
ld (0xA008), a
ld a, 0x6c ; l
ld (0xA009), a
ld a, 0x66 ; f
ld (0xA00a), a
ld a, 0x0 ; NUL
ld (0xA00b), a
push de push de
push bc push bc
ld de, 1 ; Get the mailbox number for the initrd driver ld de, 2 ; Get the mailbox number for the VFS
call proc_map_get call proc_map_get
pmg_done: pmg_done:
pop bc pop bc
@ -89,35 +79,118 @@ cp 0
jp nz, loop jp nz, loop
ld a, (0xA001) ld a, (0xA001)
ld c, a ld c, a
open_done: register_done:
; Set up a read message to the initrd FS for init.elf starting at 0x10 and reading 0x50 bytes ; Set up a mount message to the VFS for "" on "/" with fs "a" at mailbox 1
ld hl, (mailbox_num) ld hl, (mailbox_num)
ld (0xA000), hl ld (0xA000), hl
ld a, 0x1 ; Read operation ld a, 0x1 ; Mount operation
ld (0xA002), a ld (0xA002), a
ld a, c ; FD ld a, 0x2F ; '/'
ld (0xA003), a ld (0xA003), a
ld hl, 0x10 ld a, 0x0 ; '\0'
ld (0xA004), hl ; File offset ld (0xA004), a
ld hl, 0x50 ld a, 0x0 ; '\0'
ld (0xA006), hl ; Read length ld (0xA0FF), a
ld de, 1 ; Get the mailbox number for the initrd driver ld a, 0x61 ; 'a'
ld (0xA1FF), a
ld a, 0x0 ; '\0'
ld (0xA200), a
push de
push bc
ld de, 2 ; Get the mailbox number for the VFS
call proc_map_get call proc_map_get
read_pmg_done: mount_pmg_done:
ld a, (msg_phys_addr) pop bc
ld c, a pop de
ld de, (msg_phys_addr+1) ld c, b ; Send the message
ld ix, 0x0000 ld ix, 0x0000
call mb_send call mb_send
read_loop: mount_loop:
call yield call yield
read_loop_yield_done: mount_loop_yield_done:
ld hl, (mailbox_num) ld hl, (mailbox_num)
call mb_read ; Read a message call mb_read ; Read a message
read_mb_read_done: 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, read_loop jp nz, loop
ld a, (0xA001)
ld c, a
mount_done:
; Set up an open message to the initrd FS for "init.elf"
; ld hl, (mailbox_num)
; ld (0xA000), hl
; ld a, 0x0 ; Open operation
; ld (0xA002), a
; ld a, 0x69 ; i
; ld (0xA003), a
; ld a, 0x6e ; n
; ld (0xA004), a
; ld a, 0x69 ; i
; ld (0xA005), a
; ld a, 0x74 ; t
; ld (0xA006), a
; ld a, 0x2e ; .
; ld (0xA007), a
; ld a, 0x65 ; e
; ld (0xA008), a
; ld a, 0x6c ; l
; ld (0xA009), a
; ld a, 0x66 ; f
; ld (0xA00a), a
; ld a, 0x0 ; NUL
; ld (0xA00b), a
; push de
; push bc
; ld de, 1 ; Get the mailbox number for the initrd driver
; call proc_map_get
; pmg_done:
; pop bc
; pop de
; ld c, b ; Send the message
; ld ix, 0x0000
; call mb_send
; loop:
; call yield
; loop_yield_done:
; ld hl, (mailbox_num)
; call mb_read ; Read a message
; mb_read_done:
; ld a, b ; Loop if there is no message
; cp 0
; jp nz, loop
; ld a, (0xA001)
; ld c, a
; open_done:
; ; Set up a read message to the initrd FS for init.elf starting at 0x10 and reading 0x50 bytes
; ld hl, (mailbox_num)
; ld (0xA000), hl
; ld a, 0x1 ; Read operation
; ld (0xA002), a
; ld a, c ; FD
; ld (0xA003), a
; ld hl, 0x10
; ld (0xA004), hl ; File offset
; ld hl, 0x50
; ld (0xA006), hl ; Read length
; ld de, 1 ; Get the mailbox number for the initrd driver
; call proc_map_get
; read_pmg_done:
; ld a, (msg_phys_addr)
; ld c, a
; ld de, (msg_phys_addr+1)
; ld ix, 0x0000
; call mb_send
; read_loop:
; call yield
; read_loop_yield_done:
; ld hl, (mailbox_num)
; call mb_read ; Read a message
; read_mb_read_done:
; ld a, b ; Loop if there is no message
; cp 0
; jp nz, read_loop
halt halt

17
vfs.z80
View File

@ -23,7 +23,7 @@ ld (hl), 0x0
ldir ldir
call get_free_mailbox call get_free_mailbox
push hl push hl
ld de, 1 ld de, 2
call proc_map_set call proc_map_set
pop hl pop hl
ld (vfs_mailbox_num), hl ld (vfs_mailbox_num), hl
@ -84,7 +84,7 @@ ldir
ld a, (fs_count) ld a, (fs_count)
inc a inc a
ld (fs_count), a ld (fs_count), a
ret jp operation_done
; String pointer 1 in IX, 2 in IY ; String pointer 1 in IX, 2 in IY
; Return in A ; Return in A
@ -122,9 +122,6 @@ push de
ld hl, 0xB003 ld hl, 0xB003
ld bc, 252 ld bc, 252
ldir ldir
ld a, (mount_count)
inc a
ld (mount_count), a
; FS type at 0xB1FF ; FS type at 0xB1FF
ld a, (fs_count) ld a, (fs_count)
ld b, a ld b, a
@ -133,7 +130,7 @@ ld de, 0x10
mount_loop1: mount_loop1:
push hl push hl
pop ix pop ix
ld iy, 0xB0FF ld iy, 0xB1FF
push bc push bc
call strcmp call strcmp
pop bc pop bc
@ -155,6 +152,7 @@ ld (ix+1), d
push ix push ix
ld a, 0x2 ld a, 0x2
ld (0x8000), a ld (0x8000), a
push de
ld hl, 0xB0FF ld hl, 0xB0FF
ld de, 0x8001 ld de, 0x8001
ld bc, 256 ld bc, 256
@ -163,6 +161,7 @@ ld a, (send_page_addr)
ld c, a ld c, a
ld de, (send_page_addr+1) ld de, (send_page_addr+1)
ld ix, 0x0 ld ix, 0x0
pop hl
call mb_send call mb_send
mount_wait_loop: mount_wait_loop:
call yield call yield
@ -176,8 +175,10 @@ ld a, (0x8000)
ld (ix+2), a ld (ix+2), a
ld a, (0x8001) ld a, (0x8001)
ld (ix+3), a ld (ix+3), a
ld a, (mount_count)
ret inc a
ld (mount_count), a
jp operation_done
; String pointer 1 in IX, 2 in IY ; String pointer 1 in IX, 2 in IY
; Return in A ; Return in A