From 9e0fe043ed7e5289118b06f8a00717c9cf422fff Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Thu, 12 Jul 2018 21:54:57 -0400 Subject: [PATCH] minor tweaks, pre-kfest. 1. deref vcr after fcr is created, in case it moved. 2. fcr and vcr go hand-in-hand, so no need to check each in the action table 3. add boot loader (not quite working yet) --- Makefile | 10 +- boot.aii | 322 +++++++++++++++ host.driver.aii.lst | 929 -------------------------------------------- host.fst.aii | 52 ++- 4 files changed, 353 insertions(+), 960 deletions(-) create mode 100644 boot.aii delete mode 100644 host.driver.aii.lst diff --git a/Makefile b/Makefile index 239ebe2..46756e8 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ ASMFLAGS=-case on -l LDFLAGS= -all : host.driver host.fst +all : host.driver host.fst boot.sys host.fst : host.fst.o $(LD) -t \$$BD -at \$$0000 $< -o $@ @@ -22,9 +22,15 @@ host.driver.o : host.driver.aii gsos.equ host.fst.o : host.fst.aii gsos.equ fst.equ records.equ fst.macros +boot: boot.o + $(LD) $< -o $@ + +boot.sys: boot + mpw makebiniigs -p $< -o $@ -t \$$FF + .PHONY : clean clean : - $(RM) -- host.fst host.driver *.o + $(RM) -- host.fst host.driver boot.sys boot *.o %.o : %.aii $(ASM) $(ASMFLAGS) $< -o $@ diff --git a/boot.aii b/boot.aii new file mode 100644 index 0000000..850d6cd --- /dev/null +++ b/boot.aii @@ -0,0 +1,322 @@ +; +; Host FST boot loader. +; +; +; +; +; + + string asis + case on + + include 'gsos.equ' + include 'fst.macros' + include 'records.equ' + + + macro +&lab call_host +&lab dc.b $42, $ff + endm + + macro +&lab host_print +&lab dc.b $42, $fe + endm + + macro +&lab host_hexdump +&lab dc.b $42, $fd + endm + +gbuffer equ $9a00 + + +header proc org $2000 + + import startup + import readfile + import getbootname + import getfstname + + export aux_value + + jmp startup + nop + dc.w readfile + dc.w getbootname + dc.w getfstname + dc.w startup-header +aux_value dc.w 0 + endp + + +; getfst_name(name*) +; +getfstname proc +nameptr equ $0 + + plx ; rts + pla + sta '' 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 - -MPW IIGS Assembler - Ver 1.2 18-Feb-17 Page 6 -Copyright Apple Computer, Inc. 1987-1990 - -Loc SLoc Object Code Addr T M Source Statement - - - - 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 _DebugGetTrace - &l ldx #$10ff - jsl $e10000 - mend - - macro - &l ~DebugGetTrace - &l ldx #$10ff - jsl $e10000 - mend - - - macro - &l _DebugSetTrace - &l ldx #$11ff - jsl $e10000 - mend - - - macro - &l ~DebugSetTrace &p1 - &l ph2 &p1 - ldx #$11ff - jsl $e10000 - mend - - - -MPW IIGS Assembler - Ver 1.2 18-Feb-17 Page 7 -Copyright Apple Computer, Inc. 1987-1990 - -Loc SLoc Object Code Addr T M Source Statement - - ; 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 - - - ; _rts.cc -> return iff carry clear - macro - &l _rts.&cond - - if &cond='cc' THEN - bcs @ok - ENDIF - - if &cond='cs' THEN - bcc @ok - ENDIF - - if &cond='eq' THEN - bne @ok - ENDIF - - if &cond='ne' THEN - beq @ok - ENDIF - - if &cond='mi' THEN - bpl @ok - -MPW IIGS Assembler - Ver 1.2 18-Feb-17 Page 8 -Copyright Apple Computer, Inc. 1987-1990 - -Loc SLoc Object Code Addr T M Source Statement - - ENDIF - - if &cond='pl' THEN - bmi @ok - ENDIF - - if &cond='vs' THEN - bvc @ok - ENDIF - - if &cond='vc' THEN - bvs @ok - ENDIF - - rts - @ok - mend - - ; reverse subtract. - macro - &l rsb &target - eor #$ffff - sec - adc &target - mend - - - - - entry entry, startup, open, close, read, write, flush, status, control, shutdown - - ;entry open_flag, ss_count, status_word - - - - string asis -00000 0000 header proc -00000 0000 0006 dc.w dib-header -00002 0002 0001 dc.w 1 ; 1 device -00004 0004 0000 dc.w 0 ; no config list -00006 0006 -00006 0006 -00006 0006 00000000 dib dc.l 0 ;Link pointer to next DIB -0000A 000A 00000000 dc.l entry ;Entry pointer -0000E 000E 0FE0 dc.w %0000111111100000 ;Characteristics -00010 0010 00000000 dc.l 0 ;Block count -00014 0014 str.b 'HOST' ;Device name with length -00014 0014 1 -00014 0014 1 lclc &str -00014 0014 1 lcla &i, &l -00014 0014 1 -00014 0014 1 &str setc &setting('string') -00014 0014 1 STRING asis -00014 0014 1 -00014 0014 1 if &size<>'' THEN -00014 0014 04 1 dc.b @end-@start -00015 0015 1 ENDIF -00015 0015 1 -00015 0015 1 @start -00015 0015 1 -00015 0015 1 &i seta 1 -00015 0015 1 &l seta &nbr(&syslist) -00015 0015 1 -00015 0015 1 WHILE &i<=&l DO -00015 0015 484F5354 1 dc.b 'HOST' -00019 0019 1 &i seta &i+1 -00019 0019 1 ENDWHILE -00019 0019 1 WHILE &i<=&l DO -00019 0019 1 ENDWHILE -00019 0019 1 -00019 0019 1 @end -00019 0019 1 -00019 0019 1 STRING ASIS -00019 0019 1 - -MPW IIGS Assembler - Ver 1.2 18-Feb-17 Page 9 -Copyright Apple Computer, Inc. 1987-1990 - -Loc SLoc Object Code Addr T M Source Statement - -00019 0019 202020202020 dcb.b 32-5,$20 -00034 0034 8007 dc.w $8007 ;Slot number -00036 0036 0001 dc.w 1 ;Unit number -00038 0038 1000 dc.w $1000 ;Version number -0003A 003A 0010 dc.w $0010 ;ID # file server -0003C 003C 0000 dc.w 0 ;No header link -0003E 003E 0000 dc.w 0 ;No forward link -00040 0040 00000000 dc.l 0 ;extended dib ptr -00044 0044 0000 dc.w 0 ;Device number -00046 0046 -00046 0046 endp - - - -00046 0000 entry proc -00046 0000 -00046 0000 longa on -00046 0000 longi on -00046 0000 -00046 0000 8B 3 phb ;Save the GS/OS bank register -00047 0001 -00047 0001 4B 3 phk -00048 0002 AB 4 plb -00049 0003 -00049 0003 C9 0009 3 cmp #8+1 ;Max command number -0004C 0006 90 05 00053 2 bcc @dispatch -0004E 0008 A9 0020 3 lda #drvr_bad_req -00051 000B 80 05 00058 3 bra exit -00053 000D -00053 000D @dispatch -00053 000D 0A 2 asl a -00054 000E AA 2 tax -00055 000F FC FFFF 8 jsr (table,x) -00058 0012 -00058 0012 -00058 0012 exit -00058 0012 AB 4 plb -00059 0013 C9 0001 3 cmp #1 -0005C 0016 6B 6 rtl -0005D 0017 -0005D 0017 table -0005D 0017 0000 dc.w startup -0005F 0019 0000 dc.w open -00061 001B 0000 dc.w read -00063 001D 0000 dc.w write -00065 001F 0000 dc.w close -00067 0021 0000 dc.w status -00069 0023 0000 dc.w control -0006B 0025 0000 dc.w flush -0006D 0027 0000 dc.w shutdown -0006F 0029 -0006F 0029 endp - - -0006F 0000 data record -0006F 0000 export ss_count, open_flag, status_word -0006F 0000 -0006F 0000 0000 ss_count dc.w 0 -00071 0002 0000 open_flag dc.w 0 -00073 0004 -00073 0004 ; copied via get_device_status -00073 0004 0010 status_word dc.w $0010 -00075 0006 00000000 blocks dc.l 0 -00079 000A endr - -00079 0000 flush proc -00079 0000 A9 0000 3 lda #no_error -0007C 0003 60 6 rts -0007D 0004 endp - -0007D 0000 read proc -0007D 0000 with dev_parms -0007D 0000 -0007D 0000 ; todo - disk switch error logic.... - -MPW IIGS Assembler - Ver 1.2 18-Feb-17 Page 10 -Copyright Apple Computer, Inc. 1987-1990 - -Loc SLoc Object Code Addr T M Source Statement - -0007D 0000 -0007D 0000 64 0C 4 stz dev_xfer_cnt -0007F 0002 64 0E 4 stz dev_xfer_cnt+2 -00081 0004 A5 08 4 lda dev_req_cnt -00083 0006 05 0A 4 ora dev_req_cnt+2 -00085 0008 F0 03 0008A 2 beq exit -00087 000A -00087 000A A9 0088 3 lda #network_error -0008A 000D exit -0008A 000D 60 6 rts -0008B 000E endp - -0008B 0000 write proc -0008B 0000 with dev_parms -0008B 0000 -0008B 0000 ; todo - disk switch error logic.... -0008B 0000 -0008B 0000 64 0C 4 stz dev_xfer_cnt -0008D 0002 64 0E 4 stz dev_xfer_cnt+2 -0008F 0004 A5 08 4 lda dev_req_cnt -00091 0006 05 0A 4 ora dev_req_cnt+2 -00093 0008 F0 03 00098 2 beq exit -00095 000A -00095 000A A9 0088 3 lda #network_error -00098 000D exit -00098 000D 60 6 rts -00099 000E endp - - -00099 0000 startup proc -00099 0000 9C FFFF 5 stz open_flag -0009C 0003 EE FFFF 8 inc ss_count -0009F 0006 A9 0000 3 lda #no_error -000A2 0009 60 6 rts -000A3 000A endp - -000A3 0000 shutdown proc -000A3 0000 9C FFFF 5 stz ss_count -000A6 0003 A9 0000 3 lda #no_error -000A9 0006 60 6 rts -000AA 0007 endp - -000AA 0000 open proc -000AA 0000 -000AA 0000 A9 0000 3 lda #no_error -000AD 0003 60 6 rts -000AE 0004 -000AE 0004 endp - -000AE 0000 close proc -000AE 0000 -000AE 0000 A9 0000 3 lda #no_error -000B1 0003 60 6 rts -000B2 0004 -000B2 0004 endp - - -000B2 0000 status proc -000B2 0000 with dev_parms -000B2 0000 -000B2 0000 A5 16 4 lda >8 @@ -468,10 +456,10 @@ max_app_call equ *-app_table-2 - -fcr_used equ $8000 -vcr_used equ $4000 -path_used equ $2000 +; insight - vcr and fcr always go together. +vcr_used equ $8000 +fcr_used equ $0000 +path_used equ $4000 table ; stores max pcount + 1 dc.w 0 @@ -1064,6 +1052,12 @@ open proc sty my_fcr+2 ; need to re-deref the vcr? + ldx vcr_ptr + ldy vcr_ptr+2 + jsl deref + stx my_vcr + sty my_vcr+2 + ldy #vcr.open_count lda [my_vcr],y