first attempts to read dirent structure

This commit is contained in:
FeralChild64 committed 2021-02-14 20:34:37 +01:00
1 parent 906ec22834
commit f8c8e71f9f
4 files changed
+129 -80

No files matched your search

+2
View File
@@ -94,3 +94,5 @@
!addr SD_CMDFN_BUF = $8100 ; buffer for command and/or file name, 128 bytes, SD card
!addr FD_CMDFN_BUF = $8180 ; buffer for command and/or file name, 128 bytes, floppy
!addr RD_CMDFN_BUF = $8200 ; buffer for command and/or file name, 128 bytes, ram disk
!addr SD_DIRENT = $8280 ; 256 byte buffer for 'dirent' structure
+1 -36
View File
@@ -19,46 +19,11 @@ dev_sd_cmd_OPEN_EOI:
lda SD_CMDFN_BUF
cmp #'$'
beq dev_sd_cmd_OPEN_dir
+beq fs_hvsr_read_dir_open
; XXX implement for file names
jmp dos_EXIT_SEC
dev_sd_cmd_OPEN_dir:
; XXX
; .X = file descriptor
; .Y = page of memory for output
; lda #$11 ; dos_opendir
; sta HTRAP00
; +nop
; Reset status to OK
lda #$00
jsr dos_status_00
; Provide pointer to the header
lda #$20
sta SD_ACPTR_LEN+0
lda #$00
sta SD_ACPTR_LEN+1
lda #<dir_hdr_sd
sta SD_ACPTR_PTR+0
lda #>dir_hdr_sd
sta SD_ACPTR_PTR+1
; Set directory phase to 'file name'
lda #$01
sta SD_DIR_PHASE
; End
jmp dos_EXIT
+3 -44
View File
@@ -10,50 +10,9 @@ dev_sd_cmd_READ:
lda SD_DIR_PHASE
cmp #$01
beq dev_sd_cmd_READ_dir_blocksfree
+beq fs_hvsr_read_dir
cmp #$02
+beq fs_hvsr_read_dir_blocksfree
sec ; mark EOI
rts
dev_sd_cmd_READ_dir:
; Dirent structure:
; - 4 bytes - inode
; - 2 bytes - ('off' - not sure what's this)
; - 4 bytes - ('reclen' - is it file size?)
; - 2 bytes - type
; .X = file descriptor
; .Y = page of memory for output
; lda #$12 ; dos_readdir
; sta HTRAP00
; +nop
dev_sd_cmd_READ_dir_blocksfree:
; Set pointer to '0 BLOCKS FREE.' line
lda #$13
sta SD_ACPTR_LEN+0
lda #$00
sta SD_ACPTR_LEN+1
lda #<dir_end
sta SD_ACPTR_PTR+0
lda #>dir_end
sta SD_ACPTR_PTR+1
; Mark end of directory
lda #$00
sta SD_DIR_PHASE
; .X = file descriptor
; lda #$13 ; dos_closedir
; sta HTRAP00
; +nop
clc
rts
+123
View File
@@ -0,0 +1,123 @@
;
; Hypervisor virtual filesystem - reading directory
;
fs_hvsr_read_dir_open:
; Read dirent structure into $1000 and then copy it to SD_DIRENT
; Starting at $1000 VIC sees chargen, so this should be a safe place
; Content of the original memory location will be preserved
jsr fs_hvsr_dirent_swap
ldx #$00 ; file descriptor; we use $00 for reading directory
ldy #$10 ; target page number
lda #$11 ; dos_opendir
sta HTRAP00
+nop
; XXX handle read errors
jsr fs_hvsr_dirent_swap
; Reset status to OK
lda #$00
jsr dos_status_00
; Provide pointer to the header
lda #$20
sta SD_ACPTR_LEN+0
lda #$00
sta SD_ACPTR_LEN+1
lda #<dir_hdr_sd
sta SD_ACPTR_PTR+0
lda #>dir_hdr_sd
sta SD_ACPTR_PTR+1
; Set directory phase to 'file name'
lda #$01
sta SD_DIR_PHASE
; End
jmp dos_EXIT
fs_hvsr_read_dir:
jsr fs_hvsr_dirent_swap
ldx #$00 ; file descriptor; we use $00 for reading directory
ldy #$10 ; target page number
lda #$12 ; dos_readdir
sta HTRAP00
+nop
; XXX handle read errors
sta $400
stx $401
jsr fs_hvsr_dirent_swap
jmp fs_hvsr_read_dir_blocksfree ; XXX temporary
; Dirent structure:
; - 4 bytes - inode
; - 2 bytes - ('off' - not sure what's this)
; - 4 bytes - ('reclen' - is it file size?)
; - 2 bytes - type
fs_hvsr_read_dir_blocksfree:
; Set pointer to '0 BLOCKS FREE.' line
lda #$13
sta SD_ACPTR_LEN+0
lda #$00
sta SD_ACPTR_LEN+1
lda #<dir_end
sta SD_ACPTR_PTR+0
lda #>dir_end
sta SD_ACPTR_PTR+1
; Mark end of directory
lda #$00
sta SD_DIR_PHASE
; .X = file descriptor
; lda #$13 ; dos_closedir
; sta HTRAP00
; +nop
clc
rts
;
; Helper routines
;
fs_hvsr_dirent_swap:
ldx #$00
@1:
lda $1000, x
ldy SD_DIRENT, x
sta SD_DIRENT, x
sty $1000, x
inx
bne @1
rts