commit 66ebcaf3bf8d2bcb995589d20be048785ce07454 Author: Kelvin Sherlock Date: Tue Aug 11 18:56:19 2015 -0400 not quite initial version... diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5761abc --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.o diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6de4abb --- /dev/null +++ b/Makefile @@ -0,0 +1,24 @@ + + +SOURCES = main.aii volume.aii get_file_info.aii \ + id_disk.aii stubs.aii tables.aii device.aii + +OBJECTS=$(SOURCES:.aii=.o) + +LD=mpw linkIIgs +ASM=mpw asmIIgs +#ASMFLAGS=-d DEBUG_S16 -d DebugSymbols +ASMFLAGS=-d DebugSymbols +LDFLAGS= + +minix.fst : Makefile $(OBJECTS) + $(LD) $(LDFLAGS) -t \$$BD -at \$$0000 $(OBJECTS) -o $@ + + +clean: + rm -f $(OBJECTS) + + +#.aii.o: +%.o : %.aii + $(ASM) $(ASMFLAGS) $< -o $@ \ No newline at end of file diff --git a/device.aii b/device.aii new file mode 100644 index 0000000..097394d --- /dev/null +++ b/device.aii @@ -0,0 +1,38 @@ + include 'gsos.equ' + + +device_rw proc + + ; inputs: a = call num + ; outputs: carry, a + + with dev_parms + + sta dev_callnum + +loop + jsl dev_dispatcher + bcc exit + cmp #drvr_disk_sw + beq loop + cmp #drvr_busy + beq loop + sec + +exit + rts + endp + +device_read proc export + + lda #drvr_read + bra device_rw + endp + +device_write proc export + lda #drvr_write + bra device_rw + endp + + end + diff --git a/fst.equ b/fst.equ new file mode 100644 index 0000000..b851477 --- /dev/null +++ b/fst.equ @@ -0,0 +1,78 @@ + + ; my direct page. +dp record $0080 + +io_buffer ds.l 1 +ptr ds.l 1 ; misc ptr + +my_vcr ds.l 1 +my_fcr ds.l 1 +call_class ds.w 1 + + + +device ds.w 1 ; device for id_disk. +tool_error ds.w 1 + + +inode ds.w 1 +parent_inode ds.w 1 + +disk_inode ds v1_inode + + + IF *>=$d4 THEN + AERROR 'dp -- too large.' + ENDIF + endr + + +fcr record 0 +ref_num ds.w 1 +path_name ds.l 1 +fst_id ds.w 1 +vol_id ds.w 1 +level ds.w 1 +newline ds.l 1 +newline_length ds.w 1 +mask ds.w 1 +access ds.w 1 + + ; fst-specific items + +ino ds.w 1 +inode ds v1_inode +dirty ds.w 1 + +mark ds.l 1 ; current position + + + +sizeof equ * + endr + +vcr record 0 +id ds.w 1 +name ds.l 1 +status ds.w 1 +open_count ds.w 1 +fst_id ds.w 1 +device ds.w 1 +fst_ptr ds.l 1 + + ; fst-specific items + + + ; super block elements. + +super ds v1_super +first_inode_block ds.w 1 +first_imap_block ds.w 1 +first_zmap_block ds.w 1 + +sizeof equ * + endr + + + +fst_id equ 'mx' \ No newline at end of file diff --git a/fst.macros b/fst.macros new file mode 100644 index 0000000..76bc763 --- /dev/null +++ b/fst.macros @@ -0,0 +1,209 @@ + + + ; dispatch table for variable-pcount structures. + + MACRO +&lab dispatch &table + +&lab +@loop + ldy &table,x + jsr (&table+2,x) + dex + dex + dex + dex + bpl @loop + + MEND + + + MACRO + str.&size ; &arg, ... + + lclc &str + lcla &i, &l + +&str setc &setting('string') + STRING asis + + if &size<>'' THEN + dc.&size @end-@start + ENDIF + +@start + +&i seta 1 +&l seta &nbr(&syslist) + + WHILE &i<=&l DO + dc.b &syslist[&i] +&i seta &i+1 + ENDWHILE + +@end + + STRING &str + + MEND + + + MACRO + long &p1,&p2 + + lcla &bits +&bits seta %00000000 +;&p1 setc &lc(&p1) +;&p2 setc &lc(&p2) + + if &p1='m' OR &p2='m' THEN +&bits seta &bits+%00100000 + longa on + ENDIF + + if &p1='x' OR &p2='x' THEN +&bits seta &bits+%00010000 + longi on + ENDIF + + IF &bits<>0 THEN + rep #&bits + ENDIF + + MEND + + + MACRO + short &p1,&p2 + + lcla &bits +&bits seta %00000000 +;&p1 setc &lc(&p1) +;&p2 setc &lc(&p2) + + if &p1='m' OR &p2='m' THEN +&bits seta &bits+%00100000 + longa off + ENDIF + + if &p1='x' OR &p2='x' THEN +&bits seta &bits+%00010000 + longi off + ENDIF + + IF &bits<>0 THEN + sep #&bits + ENDIF + + MEND + + + macro +&l ~ConvSeconds &p1,&p2,&p3 +&l ph2 &p1 + ph4 &p2 + ph4 &p3 + ldx #$3703 + jsl $E10000 + mend + + macro +&l ~Long2Hex &p1,&p2,&p3 +&l ph4 &p1 + ph4 &p2 + ph2 &p3 + ldx #$230B + jsl $E10000 + mend + + macro +&l ~Int2Hex &p1,&p2,&p3 +&l ph2 &p1 + ph4 &p2 + ph2 &p3 + ldx #$220B + jsl $E10000 + mend + + + macro +&l _DebugHexDump +&l ldx #$0fff + jsl $e10000 + mend + + + macro +&l ~DebugHexDump &p1,&p2 +&l ph4 &p1 + ph2 &p2 + ldx #$0fff + jsl $e10000 + mend + + + macro +&l _DebugSetTrace +&l ldx #$10ff + jsl $e10000 + mend + + + macro +&l ~DebugSetTrace &p1 +&l ph2 &p1 + ldx #$10ff + jsl $e10000 + mend + + + ; borrowed from orca/m + ; mpw's pushword/pushlong have bugs and generally sucks + MACRO + ph2 &n1 + + IF &n1='*' THEN + MEXIT + ENDIF + + IF &n1[1:1]='#' THEN + pea &n1[2:255] + MEXIT + ENDIF + + IF &n1[1:1]='<' THEN + pei &n1 + MEXIT + ENDIF + + lda &n1 + pha + + MEND + + MACRO + ph4 &n1 + + IF &n1='*' THEN + MEXIT + ENDIF + + IF &n1[1:1]='#' THEN + pea |(&n1[2:255])>>16 + pea |&n1[2:255] + MEXIT + ENDIF + + IF &n1[1:1]='<' THEN + pei &n1+2 + pei &n1 + MEXIT + ENDIF + + + lda &n1+2 + pha + lda &n1 + pha + + MEND \ No newline at end of file diff --git a/get_file_info.aii b/get_file_info.aii new file mode 100644 index 0000000..d41b641 --- /dev/null +++ b/get_file_info.aii @@ -0,0 +1,520 @@ + + + include 'gsos.equ' + include 'minix.equ' + include 'fst.equ' + + include 'fst.macros' + + include 'M16.Debug' + + + +TimeRec RECORD 0 +second DS.B 1 +minute DS.B 1 +hour DS.B 1 +year DS.B 1 +day DS.B 1 +month DS.B 1 +extra DS.B 1 +weekDay DS.B 1 + ENDR + +FileInfoRecGS RECORD 0 +pCount DS.W 1 +pathname DS.L 1 +access DS.W 1 +fileType DS.W 1 +auxType DS.L 1 +storageType DS.W 1 +createDateTime DS TimeRec +modDateTime DS TimeRec +optionList DS.L 1 +eof DS.L 1 +blocksUsed DS.L 1 +resourceEOF DS.L 1 +resourceBlocks DS.L 1 + ENDR + + +FileRec RECORD 0 +pathname DS.B 4 +fAccess DS.B 2 +fileType DS.B 2 +auxType DS.B 4 +storageType DS.B 2 +createDate DS.B 2 +createTime DS.B 2 +modDate DS.B 2 +modTime DS.B 2 +blocksUsed DS.B 4 + ENDR + + entry path_to_inode + import id_disk + import device_read + + +get_file_info procname export + + with fst_parms + with dev_parms + with dp + + + jsr path_to_inode + bcc @inode + rtl +@inode + ; we have an inode. and my_vcr is valid. + ; we need to actually _load_ the inode. + + ; todo -- check if inode # is valid? + ; todo -- check if bit set in imap? + + ;pha ; space + ;~DebugSetTrace #1 + ;pla ; prev value + + + ldy #vcr.first_inode_block + lda [my_vcr],y + asl a ; x 2 + sta dev_blk_num + + ; 32 inodes per block. + ; however, I'd rather read half-block chunks, with means + ; 16 inodes per half-block. + lda inode + dec a ; inode 1 is offset 0. + lsr a ; / 2 + lsr a ; / 4 + lsr a ; / 8 + lsr a ; / 16 + ;lsr a ; / 32 + + clc + adc dev_blk_num + sta dev_blk_num + + lda #512 + sta dev_req_cnt + + + lda device + sta dev_num + + jsr device_read + bcc ok + rtl +ok + + ; find the inode... + lda inode + dec a ; inode 1 is offset 0. + and #$0f + ; multiply by 32 + asl a ; x 2 + asl a ; x 4 + asl a ; x 8 + asl a ; x 16 + asl a ; x 32 + clc + adc io_buffer + sta ptr + lda #0 + adc io_buffer+2 + sta ptr+2 + + ; copy to dp + ldy #0 + ldx #0 +@loop + lda [ptr],y + sta disk_inode,x + inx + inx + iny + iny + cpy #v1_inode.sizeof + blt @loop + + + ;pha ; space + ;~DebugSetTrace #0 + ;pla ; prev value + + + lda >8 + phb + lda #