2 ;DEBUGX equ 1 ;Requires silly CPU (680[01]0)
3 ;WaitDbg equ 1 ;Wait for RMB after each debug message
4 ;ModDebug equ 1 ;Do (Abs|Img)Module debugging
54 _LVOAddBootNode equ _LVOexpansionUnused
58 ;Word NULL - LongAlign#
62 ;ResCmds SegLists+checksums#
63 ;NULL - stop of ResCmds#
64 ;Resident SegLists+checksums#
67 ;ResidentList successor
68 ;KickMemHeader successor
69 ;KickMemHeader(w/o successor)#
76 MyFORBID macro ;[exec]
80 addq.b #1,TDNestCnt(a6)
83 rsreset ;FileChain for ReadFiles
84 FC_MinNode rs.b MLN_SIZE
85 FC_FileSize rs.b 0 ;FileSize (1 Long)
86 FC_DirList rs.b MLH_SIZE
87 FC_ProtBits rs.b 1 ;Protection Bits (b7=1 -> dir)
88 FC_FileName rs.b 0 ;FileName (ASCIIZ)
89 FC_SIZEOF rs.b 0 ;w/o FileName
92 RFC_FileSize rs.l 1 ;Size of file/dir in bytes
93 RFC_ProtBits rs.b 1 ;Protection bits (b7=1 -> dir)
94 RFC_FileName rs.b 0 ;FileName (ASCIIZ)
95 RFC_SIZEOF rs.b 0 ;w/o FileName
97 rsreset ;Resident chain
98 RC_Next rs.l 1 ;^Next chain or NULL
99 RC_Type rs.w 1 ;Type RCT_#?
100 RC_CmdName rs.b 0 ;RCT_Cmd -> ^FileName of the PathName
101 RC_Resident rs.b 0 ;!=RCT_Cmd -> ^ResidentTag
102 RC_Tracker rs.l 1 ;File tracker
103 RC_CheckSum rs.b 0 ;Segment values sum (LONG)
104 RC_CheckSummed rs.w 1 ;BOOL value for summing
105 RC_Hunks rs.w 1 ;# of hunks
106 RC_SIZEOF rs.b 0 ;w/o (hunk sizes|hunk pointers)
112 dbuf Anchor,ap_SIZEOF+PathLen
113 dv.l AnyTrk ;A! - Must be first
115 dv.l ResMemory ;A! - Tracker of handler's memory
116 dbuf Root,FC_SIZEOF+1
118 dv.l ResList ;Fwd-Linked list of residents
123 dv.l InhibitEnd ;Address of terminating 0/':' or NULL
126 HunkBuf equ EOFRegs ;Size=20 bytes
137 put.l pr_CurrentDir(a0),OldCurDir
142 VerbParseMLoop move.b (a2)+,d0
147 VerbParseCLoop move.b (a1)+,d1
149 dtl <Unrecognised VERBOSE char: ''%c''>,a0
150 move.w d3,-(sp) ;I hope RawDoFmt'll ignore b8-b15...
153 VerbParseChar cmp.b (a1)+,d0
158 and.b d1,d2 ;Clear if 254 (None)
161 VerbParseDone put.l d2,Arg_Verbose
162 NoneVerbose geta BootPri+4,a4
168 BootPriStd move.l d1,-(a4)
172 dtl <BootPri value %ld out of range (-128..127)>,a0
174 move.l #RT_SIZE+2+ResidentCode+ResidentVars+12+ML_SIZE+ME_SIZE+RFC_SIZEOF+1,d6 ;RAM disk size
178 moveq #LDF_DEVICES!LDF_READ,d1
179 moveq #LDF_DEVICES!LDF_READ,d3
185 dt InvalidName,<Invalid device name "%s">
188 TestDevNameLoop tst.b (a2)
191 bne.s TestDevNameLoop
194 TestDevError moveq #LDF_DEVICES!LDF_READ,d1
197 ErrorSSA4 move.l a4,a1
200 TestDevTerm sub.l (a4),d6
201 add.l a2,d6 ;ASCIIZ name length
202 clr.b -(a2) ;Cut out ':'
207 dt DevExists,<Device %s: already exists>
214 FindFreeNum move.l 4.w,a6
216 move.l KickTagPtr(a6),d0
218 DevNumTagLoop bclr.l #31,d0
220 DevNumTgLoop move.l (a0)+,d0
224 move.l RT_NAME(a1),a1
225 moveq #ResNumOne-ResName-1,d0
227 ResNameLoop move.b (a1)+,d1
238 DevNumNoTags call Permit
242 DevNumDigit cmp.b #'9',d5
246 dt MaxDisks,<Max. # of RES disks reached>
250 DevNumDigitH addq.b #1,d4
252 DevNumDigitL addq.b #1,d5
255 DeviceStd move.l a3,-(a4)
256 move.l MyDiskTypeAddr(pc),(a3)
257 DevNumLoop bsr.s DevNumDigit
264 DevNum1Null cmp.b d4,d5
266 Digit2Force move.b d5,(a2)
267 Digit2Null move.l a3,d2
272 DevNumOkay move.l a3,a2
273 DevNumLength tst.b (a2)+
277 DevStdOkay moveq #LDF_DEVICES!LDF_READ,d1
286 move.l #'ResR',(a1)+ ;Standard volume name
289 VolNameEnd move.b (a2)+,(a1)+
291 VolumeCustom move.l a0,-(a4)
292 TestVolName tst.b (a0)+
298 lsl.l #6,d0 ;4KBytes Quantum
299 moveq #MEMF_PUBLIC,d1
305 bsr InitDir ;@A4=Parent/Current dir
307 move.l #(APF_DOWILD!APF_DODOT)<<24!PathLen,ap_Flags(a0)
312 cmp.l #ERROR_NO_MORE_ENTRIES,d0
316 dtl <No files match %s>,a0
317 ErrorA1SS move.l sp,a1
318 ErrorSS jump ss,ExitError
320 ErrorScan dtl <Error scanning files %s>,a0
322 SSDosErrorA1 move.l sp,a1
325 PrintDirName btstv.b #VerbB_Dirs,Arg_Verbose+3
328 dtl <Scanning directory %s ...',13,$9B,'K>,a0
331 ReturnSPinc addq #4,sp
334 FileScanFirst get.l Anchor+ap_Current,a0
335 move.l an_Lock(a0),d1
344 FileScanLoop tstv.l Anchor+ap_Info+fib_DirEntryType
346 btstv.b #VerbB_Files,Arg_Verbose+3
350 FileVerbOff tstv.b Anchor+ap_Info+fib_Protection+3
358 FileHeader geta Anchor+ap_Buf,a0
363 IsDir bclrv.b #APB_DIDDIR,Anchor+ap_Flags
365 bsetv.b #APB_DODIR,Anchor+ap_Flags
366 tstv.b Anchor+ap_Info+fib_FileName
372 ClimbedUp bsr PrintDirName
374 NextFile call ss,TestBreak
379 cmp.l ErrNoMorePtr(pc),d0
383 beq ListPreNull ;No resident modules -> No detaching
384 ;Calculate size of the parts for detaching
386 ListPreSize move.l d3,a2
387 move.l (a2)+,d3 ;RC_Next
388 addq #RC_Hunks-RC_Type,a2
389 move.w (a2)+,d0 ;RC_Hunks
392 HunkSize move.l (a2)+,d1
398 HunkSizeChip add.l d1,-(a0)
399 HunkSizeInto dbra d0,HunkSize
402 ;Allocate detach part
406 dt PublicMsg,<PUBLIC>
410 addq.l #ME_SIZE,d6 ;(Any|Chip)Detach entry
418 NoPart subq.l #MEMF_CHIP,d1 ;CHIP,void
420 ;Fill in hunk pointers
422 NextPtrMain move.l d2,a0
423 move.l (a0)+,d2 ;RC_Next
424 addq #RC_Hunks-RC_Type,a0
426 geta ResMemory,a2 ;Trashed long
429 HunkPtrsLoop move.l (a0),d1
434 HunkPtrsAny move.l (a3),a1
445 HunkPtrsInto dbra d0,HunkPtrsLoop
448 addq #8,sp ;Trash destination addresses
450 vmovev.l ResList,EOFRegs
451 LoadSegLoop get.l EOFRegs,a4 ;previously D2
452 addq.l #8,d6 ;SegList+Checksum
453 move.l (a4)+,d4 ;RC_Next
454 move.w (a4)+,d3 ;RC_Type
456 addq.l #4,d6 ;^ResidentTag
457 LoadSegCmd move.l (a4),a2 ;RC_Tracker
460 btstv.b #VerbB_LoadFiles,Arg_Verbose+3
461 beq.s SkipLoadSegInfo
463 dtl <LoadSeg of the file %s ...',13,$9B,'K>,a0
465 SkipLoadSegInfo move.l (a2),a0 ;trk_ext
466 move.l -(a2),d2 ;trk_data
472 addq #RC_SIZEOF-RC_Tracker,a4
473 movemv.l d2-d6/a2/a4/a6/sp,EOFRegs
476 ;A4=Hunk pointer table
480 ;D4=Current hunk #*4 - modifiable
481 ;D5=Ptr to current hunk - (A2,D4.l) or NULL for no current hunk - modifiable
482 HunkMainLoop movemv.l d4/d5,EOFRegs+2*4
483 vmovem.l EOFRegs+5*4,a2/a4/a6
485 move.l a0,bh_eofhook(a2)
488 move.l a0,bh_eofhook(a2)
489 bclr.l #HUNKB_ADVISORY,d0
493 cmp.w #HUNK_RELRELOC32-HUNK_NAME+1,d0
496 move.w HunkTable(pc,d0.w),d1
500 jsr HunkTable(pc,d1.w)
503 hunk macro ;HUNK_#?[,<routine>]
505 fail Mismatched hunk numbers!
508 dc.w BadHunk-HunkTable
510 dc.w hunk_\2-HunkTable
516 hunk HUNK_NAME,skipcnt ;1000
517 hunk HUNK_CODE,main ;1001
518 hunk HUNK_DATA,main ;1002
519 hunk HUNK_BSS,main ;1003
520 hunk HUNK_RELOC32,rel32 ;1004
521 hunk HUNK_RELOC16 ;1005
522 hunk HUNK_RELOC8 ;1006
524 hunk HUNK_SYMBOL,symbol ;1008
525 hunk HUNK_DEBUG,skipcnt ;1009
526 hunk HUNK_END,end ;1010
527 hunk HUNK_HEADER ;1011
529 hunk HUNK_OVERLAY ;1013
530 hunk HUNK_BREAK ;1014
531 hunk HUNK_DREL32,rel16 ;1015
532 hunk HUNK_DREL16 ;1016
533 hunk HUNK_DREL8 ;1017
535 hunk HUNK_INDEX ;1019
536 hunk HUNK_RELOC32SHORT,rel16 ;1020
537 hunk HUNK_RELRELOC32,rrel16 ;1021
538 ifne _hunk-HUNK_RELRELOC32-1
539 fail Invalid number of hunks!
542 FileEnd vmovem.l EOFRegs,d2-d6/a2/a4/a6/sp
547 cmp.w -(a4),d4 ;RC_Hunks
549 subq #RC_Hunks-RC_Tracker,a4
550 move.l (a4),a0 ;RC_Tracker
551 call FreeObject ;Non-buffered tracker
556 FindResInto dbra d4,FindResLoop
558 dtl <No resident tag found in file "%s">,a0
561 LoadEndCmd move.l bh_name(a2),d1
563 move.l d0,(a4)+ ;RC_CmdName
566 FindResLoop move.l (a3)+,a0
567 move.l -8(a0),d0 ;Size of the hunk
574 FindResTag1 cmp.w #RTC_MATCHWORD,(a0)+
575 FindResTag2 dbeq d1,FindResTag1
584 move.b RT_FLAGS-RT_MATCHTAG(a0),d0
586 or.b #RTF_AFTERDOS,d0
587 move.b d0,RT_FLAGS-RT_MATCHTAG(a0)
588 move.b #-128,RT_PRI-RT_MATCHTAG(a0)
589 KickMod move.l (a0),(a4)+ ;RC_Resident
597 CalcSumMod move.l (a3)+,a0
604 CalcSumIt add.l (a0)+,d3
607 CalcSumModInto dbra d7,CalcSumMod
610 CalcNoSum move.l d3,(a4)+ ;RC_CheckSum
618 ListPreNull move.l d6,d2
625 move.w #RTC_MATCHWORD,(a1)+ ;RT_MATCHWORD
626 move.l #(RTF_COLDSTART<<24)!(1<<16),d7 ;RT_[FVTP]#?
627 lea ResName-ResidentPart+RT_SIZE-RT_MATCHTAG+2(a1),a0
629 lea ResID-ResidentPart+RT_SIZE-RT_MATCHTAG+2(a1),a2
630 lea ResInit-ResidentPart+RT_SIZE-RT_MATCHTAG+2(a1),a3
631 movem.l d0/d4/d7/a0/a2/a3,(a1)
632 lea RT_SIZE-RT_MATCHTAG+2(a1),a1
633 lea ResidentPart(pc),a0
634 move.l #ResidentCode,d0
635 lea ResidentCode+ResidentVars(a1),a3
637 get.w UnitNum,ResNumOne-V-ResidentVars(a3)
638 get.w UnitNum,ResNumTwo-V-ResidentVars(a3)
639 lea -ds_SIZEOF(a3),a2
641 call dos,DateStamp ;dosbase used below!
644 Cmds1Loop move.l d0,a0
645 move.l (a0)+,d0 ;RC_Next
648 addq #RC_SIZEOF-RC_CmdName,a0
649 move.l (a0),(a3)+ ;RC_SIZEOF - SegList
650 move.l -(a0),(a3)+ ;RC_CheckSum
656 Libs2Loop move.l d0,a0
657 move.l (a0)+,d0 ;RC_Next
660 addq #RC_SIZEOF-RC_Resident,a0
661 move.l (a0),(a3)+ ;SegList
662 move.l -(a0),(a3)+ ;LibChkSum
665 NoList3 push a3 ;STACK=^Resident list
666 move.l a3,-(a2) ;ResListPtr
667 move.l d5,(a3)+ ;My resident struct
671 Libs1Loop move.l d0,a0
672 move.l (a0)+,d0 ;RC_Next
675 move.l (a0),(a3)+ ;RC_Resident
678 NoList2 move.l a3,-(a2) ;ResListSucc
681 push a3 ;STACK=^Resident list succ
683 move.w #NT_KICKMEM<<8,(a3)+ ;LN_TYPE+LN_PRI
684 move.l d2,(a3)+ ;LN_NAME
685 get.w MEntries,(a3)+ ;ME_NUMENTRIES
688 MEntryLoop move.l (a0)+,d1
691 move.l trk_data(a4),(a3)+ ;ME_ADDR
692 move.l trk_ext(a4),(a3)+ ;ME_LENGTH
693 NoMEntry dbra d0,MEntryLoop
694 move.l a3,-(a2) ;RootPtr
695 clr.l -(a2) ;NumLocks
696 clr.l -(a2) ;VolumeNode
697 move.l MyDiskTypeAddr(pc),-(a2) ;id_DiskType
700 move.l d0,-(a2) ;id_BytesPerBlock
702 move.l -(a1),d0 ;Length
706 lsr.l #1,d0 ;BlockSize=512
708 move.l d0,-(a2) ;id_NumBlocksUsed
709 move.l d0,-(a2) ;id_NumBlocks
710 moveq #ID_WRITE_PROTECTED,d0
711 move.l d0,-(a2) ;id_DiskState
712 clr.l -(a2) ;id_UnitNumber
713 clr.l -(a2) ;id_NumSoftErrors
723 move.l a3,-(a2) ;DosHName
726 LenDosHName tst.b (a0)+
735 CopyDosHNameL move.b (a0)+,(a3)+
736 CopyDosHNameI dbra d0,CopyDosHNameL
738 move.l a3,-(a2) ;VolumeName
739 move.l -(a1),a0 ;VolName
740 CopyVolName move.b (a0)+,(a3)+
743 move.l a3,-(a2) ;CmdsNames
746 CmdNamesLoop move.l d0,a0
750 move.l (a0)+,a0 ;RC_CmdName
751 CopyCmdName move.b (a0)+,(a3)+
757 move.w #(RT_SIZE+2+ResidentCode)>>2-1,d1
759 GenSumMain sub.l (a0)+,d0
762 GenSumMainE sub.l (a0)+,d0
765 move.l d0,-(a2) ;AnySum
766 get.l BootPri,-(a2) ;VarBootPri
768 ;### Write out the AbsModule (if wished) ###
769 ;-HEADER- 00000000 00000001 00000000 00000000 *Length* --CODE--
770 ;*Length* 74Ln6014 0000ABCD 00000000 00000000 00000000 00000000
772 pop a4 ;-(A4)=KickMem, ResListSucc
775 btstv.b #VerbB_SizeMod,Arg_Verbose+3
778 dtl <Writing AbsModule to the file %s ...>,a0
784 NoModVerb move.l d0,a0
790 move.l HeaderPtr(pc),(a0)
792 moveq #AbsHdrLength+3,d0
795 move.l #$60147400!(21+AbsRawLength>>2),d2
796 OutAbsLenLoop tst.l (a2)+
800 OutAbsLenInto dbra d1,OutAbsLenLoop
804 move.w #HUNK_CODE,26(a0)
811 move.l #AbsRawLength,d0
813 lea _LVOBPutLong(a6),a1
815 move.l #HUNK_END,(a0)+
816 move.l #HUNK_OVERLAY,(a0)+
819 move.l #HUNK_BREAK,(a0)+
826 ;### Generate AbsModule to the disk (if wished) ###
827 GenDisk get.l Arg_GenDisk,d2
829 moveq #LDF_DEVICES+LDF_READ,d1
834 moveq #LDF_DEVICES,d3
835 NextChar move.b (a3)+,d0
844 move.l dn_Startup(a0),d0
848 push (a0)+ ;fssm_Unit
849 push (a0)+ ;fssm_Device
850 move.l (a0)+,d0 ;fssm_Environ
851 push (a0) ;fssm_Flags
854 move.l (a0)+,d6 ;de_TableSize
855 cmp.l #128,(a0) ;de_SizeBlock
857 push de_HighCyl-de_SizeBlock(a0)
858 push de_LowCyl-de_SizeBlock(a0)
859 push de_Surfaces-de_SizeBlock(a0)
860 moveq #MEMF_PUBLIC,d0
864 move.l de_BufMemType-de_SizeBlock(a0),d0
865 NoBufMemType put.l d0,sv_memattr
866 move.l de_BlocksPerTrack-de_SizeBlock(a0),d0
867 moveq #3,d1 ;Min. are 3 Blocks/Track
872 move.l d0,d6 ;TrackBuffer size
874 lea _LVOUMult32(a0),a0
878 move.l d0,d7 ;Cylinder size
880 exg.l d0,d7 ;Position offset<->Cylinder size
886 lsl.l #3,d5 ;BootBlock size 512
889 LoopDiskTrk move.l (a0)+,d1
894 NoDiskTrk dbra d3,LoopDiskTrk
897 dtl <Not enough disk space on the device %s (size %luB, needed %luB)>,a0
902 NoDosEntry moveq #LDF_DEVICES+LDF_READ,d1
905 DiskError moveq #err_lock,d0
907 subq.l #LDF_DEVICES,d3
919 dtl.lc <Insert disk for the boot image>,a0
920 dt.lc <into drive %s>
921 dt.l <All data on it will be overwritten!>
924 call ss,SimpleRequest
929 SkipDiskReq btstv.b #VerbB_SizeMod,Arg_Verbose+3
931 dtl <Generating boot image to the drive %s ...>,a0
935 NoDiskModVerb addq #4,sp
939 call ss,TrackBufHandle
941 lea RawDiskWrite(pc),a0
942 move.l a0,bh_writefunc(a3)
943 mpop d1/a0 ;fssm_Flags,fssm_Device
951 move.l d1,bh_handle(a3)
952 move.w #TD_FORMAT,IO_COMMAND(a1)
953 move.l d7,IO_OFFSET(a1)
954 lea _LVOBPutLong(a6),a1
955 moveq #(ImgResList-BootImage)>>2,d0
963 moveq #512-(ImgResList-BootImage)-4,d3
972 ;### Prepare handler to be resident ###
973 PrepHandler pop a3 ;^ResList
977 NoReboot tstv.l Arg_NoRun
982 WellReboot geta AnyTrk,a0
984 KillMemTrks move.l (a0)+,d0
988 NoMemTrk dbra d1,KillMemTrks
990 lea KickMemPtr(a6),a2
992 move.l (a2),-(a4) ;KickMemPtr
994 move.l (a2),d0 ;KickTagPtr
997 NoNextReses move.l d0,-(a4)
1001 EXIT jump ss,ExitCleanup
1008 GenerateEnd geta HunkBuf,a0
1015 OutAddrLoop move.l (a2)+,d0
1018 move.l trk_ext(a3),(a0)+
1019 move.l trk_data(a3),(a0)+
1020 OutAddrNo dbra d7,OutAddrLoop
1024 ClosenCleanup geta AnyTrk,a2
1026 OutDataLoop move.l (a2)+,d0
1029 move.l trk_ext(a0),d0
1031 move.l trk_data(a0),a0
1034 OutNoTrk dbra d7,OutDataLoop
1035 btstv.b #VerbB_SizeMod,Arg_Verbose+3
1045 dtl.l < %lu bytes (%luKB)>,a0
1048 NoModSizeVerb move.l a3,a0
1051 ;Inputs: A2=Source A3=Destination
1052 ReadFiles tst.l (a2)
1055 ReadFilesRout move.l a3,a4 ;As ptr where to fill in DirSize
1056 lea FC_FileSize(a2),a1
1059 PutLongA rol.l #8,d2
1062 addq #MLH_SIZE-MLH_TAIL,a1
1065 CopyReadName move.b (a1)+,(a3)+
1067 tst.b FC_ProtBits(a2) ;FileSize (-1 for dir)
1069 btstv.b #VerbB_LoadFiles,Arg_Verbose+3
1073 dtl <Loading data file %s ...',13,$9B,'K>,a0
1076 SkipLoadInfo moveq #OPEN_OLD,d0
1078 move.l d1,a0 ;Copy tracker for ChkRead
1079 move.l d2,d0 ;Prepare FileSize
1080 move.l d1,d2 ;Copy tracker for FreeObject
1081 move.l a3,a1 ;Get dest
1082 add.l d0,a3 ;Add FileSize to dest
1086 NextObject move.l (a2),a2
1089 CopyDir call TestStack
1090 moveq #ACCESS_READ,d0
1104 PutLongB rol.l #8,d0
1106 dbra d2,PutLongB ;DirSize filled
1113 IsFile moveq #-1,d3 ;Do checksumming flag
1114 geta Anchor+ap_Info+fib_Comment,a2
1116 PreCommentLoop tst.b (a2)
1119 bne.s PreCommentLoop
1125 CommentSpcLoop cmp.b #' ',(a2)+
1126 beq.s CommentSpcLoop
1129 CommentEndLoop tst.b (a2)
1132 bne.s CommentEndLoop
1134 moveq #0,d3 ;'!'=>No checksumming
1135 CommentEndOK tst.b (a0)
1137 dt FullExtTable,<Data>
1138 dt PureCmdMsg,<ResCmd> ;RCT_Cmd
1139 dt MinExtTable,<Library> ;RCT_Lib
1140 dt <Device> ;RCT_Lib
1141 dt.c <KickMod> ;RCT_KickMod
1143 gett FullExtTable,a3
1152 GetExtNum move.l a0,a2
1154 GetExtNumLoop move.l a3,a0
1160 SkipExtName tst.b (a3)+
1166 CommentEnd moveq #FIBF_PURE!FIBF_EXECUTE,d0
1167 vand.b Anchor+ap_Info+fib_Protection+3,d0
1172 geta Anchor+ap_Info+fib_FileName,a0
1173 call ss,GetExtension
1179 ChecknCorrect shi d0
1180 add.b d0,d5 ;Library=Device
1181 CheckResident geta Anchor+ap_Buf,a2
1185 CopyOpen move.b (a2)+,(a0)+
1188 get.l Anchor+ap_Last,a0
1189 move.l an_Lock(a0),d1
1191 geta Anchor+ap_Info+fib_FileName,a0
1196 move.l d2,trk_ext(a0) ;Full PathName of the file
1204 cmp.l #HUNK_HEADER,(a2)+
1222 addq.l #RC_SIZEOF-8,d1
1226 move.l (a2),(a1)+ ;RC_Next
1227 move.w d5,(a1)+ ;RC_Type
1228 move.l (sp),(a1)+ ;RC_Tracker
1229 move.w d3,(a1)+ ;RC_CheckSummed
1230 move.w d4,(a1)+ ;RC_Hunks
1239 moveq #8,d1 ;SegList+CheckSum
1242 TestHunkFlg move.l (a0)+,d0
1252 btstv.b #VerbB_LoadSeg,Arg_Verbose+3
1259 HeaderWritten bsr.s WriteFileInfo
1260 dtl <; LoadSeg=%lu; Hunks=%u>,a0
1264 vcmp.l Anchor+ap_Info+fib_Size,d0
1265 bls.s LoadSegSqueeze
1266 dtl <; Large BSS part!!!>,a0
1268 LoadSegSqueeze addq #2,sp
1274 DoMsgCR bsr.s WriteOutCR
1276 bpl.s NotCmdIsNoName
1277 geta Anchor+ap_Info+fib_FileName,a0
1279 TestResNameLen tst.b (a0)+
1280 bne.s TestResNameLen
1283 NotCmdIsNoName addq #4,sp ;Discard the file tracker
1286 WriteOutCR gett WordNull,a0
1289 WriteFileInfo move.l a3,a0
1293 dtl < (don''t checksum)>,a0
1295 HasChkSum dtl <; Size=%lu>,a0
1296 geta Anchor+ap_Info+fib_Size,a1
1299 LinAlloc move.l a2,a0
1300 TestGlobLen tst.b (a0)+
1304 LinAllocInt get.l LinPool,a0
1305 jump ss,LinearAlloc ;1/3 may be LinearAllocN, but ...
1312 gett FullExtTable,a3
1315 NoFileVerbose bsr.s AllocateFC
1316 get.l Anchor+ap_Info+fib_Size,(a1) ;FC_FileSize
1320 AllocateFC geta Anchor+ap_Info+fib_FileName,a2
1325 lea FC_ProtBits(a1),a2
1327 lea FC_DirList-FC_ProtBits(a2),a1
1329 get.b Anchor+ap_Info+fib_Protection+3,(a2)+
1330 geta Anchor+ap_Info+fib_FileName,a0
1331 CopyFileNameA move.b (a0)+,(a2)+
1335 addq.l #RFC_ProtBits,d6
1336 rts ;A1=FC_FileSize/FC_DirList
1338 WasDir tstv.b Anchor+ap_Info+fib_FileName
1340 tstv.l Arg_EmptyDirs
1342 cmp.l LH_TAILPRED(a4),a4 ;Is list empty?
1343 beq.s RemoveThatNode
1344 ClimbUp move.l a4,a0
1345 lea DirItemCmp(pc),a1
1348 geta Anchor+ap_Buf,a2
1356 LongerPath move.l d0,a0
1360 RemoveThatNode lea -FC_DirList(a4),a1
1362 lea FC_FileName-FC_DirList(a4),a0
1363 DirNameLength tst.b (a0)+
1367 addq.l #FC_SIZEOF-FC_DirList-RFC_SIZEOF,d6
1370 ;Inputs: A1=FC_DirList
1371 InitDir move.l a1,a4
1379 ;Inputs: A0=^^Node1 A1=^^Node2, Results: D0=-1/0/1 (Node1<=>Node2)
1380 DirItemCmp move.l (a0),a0
1382 lea FC_ProtBits(a0),a0
1383 lea FC_ProtBits(a1),a1
1394 CompareString push a6
1395 call utility,Stricmp
1399 AllocMemTop moveq #0,d1
1400 AllocMemTopF addqv.w #1,MEntries
1402 addq.l #MEM_BLOCKMASK,d2
1403 and.w #~MEM_BLOCKMASK,d2
1404 or.l #MEMF_PUBLIC!MEMF_REVERSE!MEMF_KICK,d1
1406 bclrv.b #err_memory,sv_errsw+3
1408 call ss,TrackAllocMem
1409 bsetv.b #err_memory,sv_errsw+3
1414 eor.w #MEMF_KICK!MEMF_LOCAL,d1
1416 AllocMemTopE addq #4,sp
1418 btstv.b #VerbB_Mem,Arg_Verbose+3
1423 dt.c DetachMsg,<Detachable >
1424 dt.l BlockMsg,<%s memory block allocated at $%08lx, size $%08lx>
1430 NoMemVerbose addq #8,d0
1433 FlushStdout get.l stdout,d1
1436 Cleanup get.l OldCurDir,d1
1441 call MatchEnd ;after CurrentDir!
1447 C_NoVerb get.l InhibitEnd,d0
1451 get.l Arg_GenDisk,d1
1462 cmp.l #(HUNK_BSS-HUNK_NAME)<<17,(sp)+
1474 CPUClearLoop clr.l (a3)+
1475 CPUClearInto dbra d0,CPUClearLoop
1476 dbra d6,CPUClearLoop
1481 moveq #0,d5 ;No CurrHunk
1482 addq.l #4,d4 ;HunkNum+=4
1485 hunk_rrel16 moveq #-1,d0
1487 hunk_rel16 moveq #1,d0
1489 hunk_rel32 moveq #0,d0
1495 move.l d0,d2 ;RelocType
1496 lea _LVOBGetLong(a6),a1
1499 MainRelocLoop jsr (a1)
1517 NotRelRel add.l d3,(a0)
1518 RelocInto dbra d2,RelocLoop1
1523 RelocDone call BTell
1528 hunk_symbol call BGetLong
1535 BadHunk tstv.b Advisory
1537 hunk_skipcnt call BGetLong
1538 RelSeekLongs lsl.l #2,d0
1541 HunkError moveq #err_read,d0
1542 get.l EOFRegs+5*4,a0 ;A2=BufFH
1543 move.l bh_name(a0),a1
1544 ReportSS jump ss,ReportError
1546 RawDiskWrite move.l bh_bufsize(a0),d1
1550 RDW_Larger move.l a1,d1
1552 bset.b #0,bh_arg1+3(a0)
1553 bne.s RDW_OtherWrite
1556 RDW_SumLoop add.l (a1)+,d0
1559 RDW_SkipX dbra d2,RDW_SumLoop
1562 RDW_OtherWrite move.l bh_handle(a0),a1 ;DeviceTracker
1563 move.l trk_data(a1),a2 ;IoRequest
1564 move.l d1,IO_DATA(a2) ;^Buffer
1565 move.l (sp),IO_LENGTH(a2)
1569 add.l d0,IO_OFFSET(a2)
1573 ;### AbsModule header ###
1574 AbsModule ;D2=Position in file to seek/2
1575 AbsModFH equ AbsModule-16
1577 lea AbsDosName(pc),a1
1578 call exec,OldOpenLibrary
1581 move.l GV_DosBase(a2),d6
1583 move.l AbsModFH(pc),d7
1584 moveq #OFFSET_BEGINNING,d3
1592 lea AbsModTab(pc),a3
1595 AbsAllocLoop move.l (a3)+,d0
1611 AbsExitErrFree pop d0
1615 bra.s AbsExitErrFree
1617 AbsExitErr moveq #-1,d0
1620 AbsAllocFail moveq #103,d1
1622 bra.s AbsExitErrFree
1624 EndMainInit move.l a3,(a2)+
1630 AbsAllocEnd move.l d5,sp
1632 lea KickMemPtr(a6),a2
1634 move.l AbsKickSucc(pc),a0
1635 move.l (a2),-(a0) ;KickMemPtr
1637 move.l (a2),d0 ;KickTagPtr
1638 beq.s AbsNoNextReses
1640 AbsNoNextReses move.l d0,-(a0)
1641 move.l AbsResList(pc),a3
1644 AbsNextRes move.l (a3)+,d0
1647 move.l RT_NAME(a2),d2
1653 lea DeviceList(a6),a0
1660 AbsChkList move.l d2,a1
1669 AbsNoNextRes moveq #0,d0
1673 AbsDosName dc.b 'dos.library',0
1677 AbsResList equ *+(*-AbsModule)&2
1678 AbsKickSucc equ AbsResList+4
1679 AbsModTab equ AbsKickSucc+4
1681 AbsHdrLength equ (AbsResList-AbsModule+24)>>2
1682 AbsRawLength equ AbsResList-AbsModule
1684 ;### BootBlock of the bootimage disk ###
1686 BootImage dc.l 'DOS'<<8,0,0
1687 move.l a1,d4 ;IoRequest
1688 move.w #CMD_READ,IO_COMMAND(a1)
1689 move.l #1024,IO_OFFSET(a1)
1690 lea ImgModTab(pc),a3
1691 lea BootImage+512(pc),a4
1692 lea BootImage+1024(pc),a5
1694 ImgAllocLoop move.l (a3)+,d0
1709 ImgCopyBuf move.l a4,a0
1722 lea BootImage+512(pc),a4
1725 lsl.l #3,d3 ;One sector
1735 ImgReadDisk move.l d4,a1
1736 move.l d2,IO_DATA(a1)
1738 move.l d3,IO_LENGTH(a1)
1741 move.l IO_OFFSET(a1),d1
1742 add.l d3,IO_OFFSET(a1)
1747 lea ImgReadFailMsg(pc),a0
1750 ImgAllocFail mpush d2/d3
1751 lea ImgAllocFailMsg(pc),a0
1752 ;A0=Printf-string, SP=Printf-data
1753 ImgDoAlert move.l sp,a1
1756 lea ImgAlertHdr(pc),a2
1757 ImgAlertPrefix move.b (a2)+,(a3)+
1758 bne.s ImgAlertPrefix
1768 lea ImgIntuiName(pc),a1
1778 ImgAllocEnd lea KickMemPtr(a6),a2
1779 move.l ImgKickSucc(pc),a0
1781 move.l (a2),-(a0) ;KickMemPtr
1783 move.l (a2),d0 ;KickTagPtr
1784 beq.s ImgNoNextReses
1786 ImgNoNextReses move.l d0,-(a0)
1787 move.l ImgResList(pc),(a2)+
1791 ImgRebootNow jump ColdReboot
1793 ImgReadFailMsg dc.b 'Read(offs=%lu, len=%lu) error %ld!',0
1794 ImgAlertHdr dc.b 16,'ResRAM boot: ',0
1795 ImgPutChar move.b d0,(a3)+
1799 ImgAllocFailMsg dc.b 'AllocAbs($%08lx,$%08lx) fail!',0
1800 ImgIntuiName dc.b 'intuition.library',0
1802 ImgResList equ *+(4-(*-BootImage)&3)&3
1803 ImgKickSucc equ ImgResList+4
1804 ImgModTab equ ImgKickSucc+4
1806 ifgt ImgResList-BootImage+36-512
1807 fail <Bootblock too big!>
1810 ;### Code, which will be copied to the resident memory ###
1812 moveq #255-ERROR_\1,d1
1815 ResidentPart dc.l 16
1819 amsg <Entering handler''s code>
1822 move.l ThisTask(a6),a0
1823 lea pr_MsgPort(a0),a0
1824 move.l a0,(v) ;ProcPort
1830 move.l (v),dn_Task(a0)
1835 amsg <Startup packet replied>
1840 beq DoOpenDOSAlert ;ZF=1!
1843 moveq #DLT_VOLUME,d2
1845 lea HInitFail1(pc),a3
1854 addq #dl_VolumeDate-dl_Task,a0
1855 movem.l GDateStamp(v),d0/d2-d3
1856 movem.l d0/d2-d3,(a0)
1857 move.l -(a1),dl_DiskType-dl_VolumeDate(a0) ;id_DiskType
1860 amsg <Volume node added>
1863 lea SkipCmdName(pc),a3 ;Okay, we may ignore it
1864 geta FirstSegment,a4
1865 AddSegLoop move.l (a4),d2
1867 amsg <Adding one resident command>
1868 addq #8,a4 ;Skip ResCmd checksum
1870 moveq #CMD_INTERNAL,d3
1873 SkipCmdName tst.b (a2)+
1877 OpenUtil lea UtilName(pc),a1
1878 call exec,OldOpenLibrary
1879 addq.l #AO_UtilityLib-AO_DOSLib,d7
1880 lea HInitFail2(pc),a3 ;VolumeNode from DosList
1882 put.l d0,UTILITYbase
1884 MainLoop pea MainLoop(pc)
1886 amsg <Calling GetPacket>
1888 amsg <Packet received>
1889 lea FuncTable(pc),a2
1890 TableLoop move.w (a2)+,d7
1896 amsg <Packet is known>
1897 NotInTable jmp (a2,d7.w)
1899 ;Returns: D0/A1=ExecMsg, A2=DosPacket, D1=dp_Type, D2-D4=dp_Arg[1-3]
1900 GetLoop move.l (v),a0
1902 GetPacket move.l (v),a0
1903 GetPacketInt call GetMsg
1907 move.l LN_NAME(a0),a0
1908 move.l dp_Type(a0),d1
1909 movem.l dp_Arg1(a0),d2-d4
1914 F_INFO ;(lock,info):bool
1922 F_DISK_INFO ;(info):bool
1926 movem.l MyInfoData(v),d0-d7/a1
1927 movem.l d0-d7/a1,(a0)
1929 F_IS_FILESYSTEM ;():bool
1930 amsg <IS_FILESYSTEM>
1931 ReplyF0 moveq #-1,d0
1934 ReplyPacket mpush d0/d1
1936 amsg <Packet value: $%08lx, $%08lx>
1938 ReplyInt amsg <Replying packet>
1940 move.l (a2),a1 ;dp_Link (ExecMsg)
1941 ReplyDie move.l d0,dp_Res1(a2)
1942 move.l d1,dp_Res2(a2)
1943 move.l dp_Port(a2),a0 ;Port for replying
1944 move.l (v),dp_Port(a2)
1947 F_CURRENT_VOLUME ;(arg1):volume
1949 amsg <CURRENT_VOLUME(>,0
1956 F_SAME_LOCK ;(lock1,lock2):bool
1967 move.l fl_Key(a0),d0
1979 amsg <ERROR_ACTION_NOT_KNOWN: #%d>
1982 lerr ACTION_NOT_KNOWN
1987 F_FINDOUTPUT ;(fh,lock,name):bool
1988 F_DELETE_OBJECT ;(lock,name):bool
1989 F_CREATE_DIR ;(lock,name):lock
1990 F_SET_PROTECT ;(,lock,name,mask):bool
1991 F_SET_COMMENT ;(,lock,name,comment):bool
1992 F_RENAME_OBJECT ;(slock,sname,dlock,dname):bool
1993 F_RENAME_DISK ;(name):bool
1994 F_SET_DATE ;(,lock,name,stamp):bool
1995 F_SET_OWNER ;(,,lock,userinf):bool
1996 F_MAKE_LINK ;(lock,name,dest!#,soft):bool
1997 lerr DISK_WRITE_PROTECTED
2000 F_FINDUPDATE ;(fh,lock,name):bool
2004 F_FINDINPUT ;(fh,lock,name):bool
2007 FindUpdateJmp push d2
2012 JumpFhFromLock ;D0=arg1 A1=fh, A0=^DiskObject
2013 tst.b RFC_ProtBits(a0)
2017 ObjWrongType lerr OBJECT_WRONG_TYPE
2020 FindInputFile add.l a1,a1
2022 clr.l fh_Interactive(a1)
2023 move.l d0,fh_Arg1(a1)
2026 F_FREE_LOCK ;(lock):bool
2036 FreeLockMain subqv.l #1,NumLocks
2041 F_LOCATE_OBJECT ;(lock,name,mode):lock
2042 amsg <LOCATE_OBJECT>
2044 addq.l #-ACCESS_READ,d4
2048 ;Inputs: D2=^Lock D3=Name D6=FindUpdate?
2049 LocateMainNoUpd moveq #0,d6
2052 amsg <LocateMain(>,0
2062 CopyDbgLoop move.b (a0)+,(a1)+
2063 CopyDbgInto dbra d0,CopyDbgLoop
2079 ColLoop cmp.b #':',(a0)+
2080 ColInto dbeq d0,ColLoop
2088 amsg <Lock in UserDir>
2090 move.l fl_Key(a2),a0
2091 LockInRoot tst.b RFC_ProtBits(a0)
2092 bpl.s ObjWrongType ;Given lock is to file
2094 NextComponent amsg <NextComponent:>
2095 moveq #108,d4 ;Name buffer size
2098 lerr INVALID_COMPONENT_NAME
2101 NameLoop move.b (a1)+,d5
2107 NameLoopInto dbra d3,NameLoop
2108 amsg <End of FilePath reached>
2111 amsg <Locking file in CurrDir>
2113 amsg <FindDirItem returned>
2115 ;Inputs: A0=^Object, Results: D0=Lock (BPTR)
2116 LockInternal mpush d1/a0-a1
2118 amsg <LockInternal(>,0
2125 moveq #MEMF_PUBLIC,d1
2127 moveq #ERROR_NO_FREE_STORE,d1
2132 clr.l (a0)+ ;fl_Link
2133 move.l 4(sp),(a0)+ ;fl_Key
2134 moveq #ACCESS_READ,d1
2135 move.l d1,(a0)+ ;fl_Access
2136 move.l (v),(a0)+ ;fl_Task
2137 get.l VolumeNode,(a0) ;VolumeNode->fl_Volume
2140 amsg <LockInternal end>
2143 ;End>Empty>Lock CurrDir (A0)
2144 ; Else >Lock FileName in CurrDir
2145 ;/ >Empty>Parent of CurrDir->A0
2146 ; Else >Find FileName in CurrDir->A0 (must be DIR)
2148 SlashFound amsg <SlashFound:>
2151 amsg <Getting Parent>
2152 bsr.s GetEntryParent
2154 amsg <GetEntryParent returned>
2157 NoParent amsg <Switching to sub-directory>
2159 amsg <FindDirItem returned>
2163 ;Inputs: A2=^End of filename A4=^NameBuffer A0=CurrDir D6=FindUpdate?
2164 ;Results: D0/A0=^DirEntry D5=Size A4=LastDir, Destroys: D2/D4
2165 FindDirItem clr.b (a2)
2170 amsg <FindDirItem(%s,>,0
2177 GetLongC lsl.l #8,d5
2180 tst.b (a0)+ ;RFC_ProtBits
2182 SkipNameB tst.b (a0)+
2187 FindFileLoop cmp.l d4,a0 ;D4=Address after current dir
2189 lerr DISK_WRITE_PROTECTED
2192 ObjNotFound lerr OBJECT_NOT_FOUND
2195 StillInDir move.l a0,d0
2197 GetLongA lsl.l #8,d5
2200 addq #RFC_FileName-RFC_ProtBits,a0
2201 mpush d0-d1/a0-a1/a6
2203 call UTILITY,Stricmp
2206 SkipNameC tst.b (a0)+
2214 ;Inputs: A0=^Entry, Results: A0=^Parent entry, ZF=EQ if no parent
2215 GetEntryParent mpush d0-d2/a1-a2
2217 sub.l a1,a1 ;Parent of Root is 0
2218 NextEntry amsg <NextEntry:>
2223 GetLongB lsl.l #8,d1
2226 move.b (a2)+,d0 ;RFC_ProtBits
2227 ReachEndName tst.b (a2)+
2233 amsg <Obj is directory>
2236 amsg <Walking into...>
2238 move.l d2,a1 ;Current is parent
2241 ParentReturn amsg <ParentReturn:>
2247 F_FH_FROM_LOCK ;(fh,lock):bool
2250 F_PARENT_FH ;(arg1):lock
2252 F_PARENT ;(lock):lock
2254 F_COPY_DIR_FH ;(arg1):lock
2256 F_COPY_DIR ;(lock):lock
2264 move.l fl_Key(a0),a0
2268 beq.s DoCopyDir ;COPY_DIR(|_FH)
2269 amsg <Getting parent of the lock> ;PARENT(|_FH)
2270 bsr.s GetEntryParent
2272 amsg <GetEntryParent returned>
2273 DoCopyDir bsr LockInternal
2274 amsg <PARENT/COPY_DIR locked>
2275 cmp.w #ACTION_FH_FROM_LOCK,d1
2280 F_SEEK ;(arg1,pos,mode):oldpos/-1
2282 F_READ ;(arg1,&buf,len):len/-1
2290 move.l (a1)+,d5 ;fl_Link - Current position
2291 move.l (a1),a0 ;fl_Key
2293 GetLongD lsl.l #8,d0
2296 tst.b (a0)+ ;RFC_ProtBits
2299 lerr OBJECT_WRONG_TYPE
2301 ReplyFX moveq #-1,d0
2304 F_WRITE ;(arg1,&buf,len):len
2305 lerr DISK_WRITE_PROTECTED
2308 ObjIsFile cmp.w #ACTION_SEEK,d1
2310 sub.l d5,d0 ;D0=Remaining bytes
2311 SkipNameA tst.b (a0)+
2313 add.l d5,a0 ;a0=^1st byte for copy
2316 amsg <Read in range>
2318 DoReadFile add.l d0,-(a1)
2326 ActionIsSeek lerr SEEK_ERROR
2328 beq.s SeekDone ;OFFSET_BEGINNING=-1
2330 beq.s SeekCurrent ;OFFSET_CURRENT=0
2332 bne.s ReplyFXN ;OFFSET_END=1
2334 add.l d0,d3 ;End-of-File
2335 SeekDone cmp.l d3,d0
2337 move.l -(a1),d0 ;Old position
2338 move.l d3,(a1) ;fl_Link
2341 SeekCurrent amsg <SeekCurrent:>
2342 add.l d5,d3 ;fl_Link
2345 F_EXAMINE_FH ;(arg1,fib):bool
2347 F_EXAMINE_OBJECT ;(lock,fib):bool
2348 amsg <EXAMINE_OBJECT>
2349 F_EXAMINE_NEXT ;(lock,fib):bool
2351 amsg <EXAMINE_NEXT(>,0
2359 move.l fl_Key(a0),a2
2361 cmp.w #ACTION_EXAMINE_NEXT,d1
2363 lerr NO_MORE_ENTRIES
2364 move.l (a1),d3 ;fib_DiskKey
2365 beq Reply0XN ;ExNext without Examine
2367 GetLongF lsl.l #8,d0
2370 tst.b (a2)+ ;RFC_ProtBits
2372 SkipNameD tst.b (a2)+
2374 add.l a2,d0 ;D0=End of this directory
2376 beq.s FirstEntryIn ;A2=Entry to process
2379 GetLongG lsl.l #8,d3
2382 addq #RFC_FileName-RFC_ProtBits,a2
2383 SkipNameE tst.b (a2)+
2386 FirstEntryIn cmp.l a2,d0
2387 beq Reply0XN ;No more entries
2389 ;Inputs: A2=^DirEntry A1=^FileInfoBlock
2390 ExamineMain move.l a2,(a1)+ ;fib_DiskKey
2392 GetLongE lsl.l #8,d0
2405 moveq #0,d0 ;Size of directory is zero...
2406 moveq #1,d4 ;... but the block size is 1 <- Magic
2407 moveq #ST_USERDIR,d1
2412 EntryTypeDone move.l d1,(a1)+ ;fib_DirEntryType
2413 lea fib_Protection-fib_FileName(a1),a3
2415 TestNameLength tst.b (a2)+
2416 bne.s TestNameLength
2420 CopyFileNameB move.b (a2)+,(a1)+ ;RFC_FileName->fib_FileName
2422 move.l d2,(a3)+ ;fib_Protection /vvv-MORE MAGIC!!!
2423 move.l d1,(a3)+ ;fib_EntryType (=fib_DirEntryType???)
2424 move.l d0,(a3)+ ;fib_Size
2425 move.l d4,(a3)+ ;fib_NumBlocks
2427 move.l (a0)+,(a3)+ ;GDateStamp->fib_DateStamp
2430 clr.b (a3) ;fib_Comment
2438 amsg <Replying the DIE packet to my killer>
2442 amsg <Death packet replied, closing UtilLib>
2443 get.l UTILITYbase,a1
2444 call exec,CloseLibrary
2445 HInitFail2 moveq #LDF_VOLUMES!LDF_WRITE,d1
2446 call DOS,LockDosList
2447 amsg <LockDosList OK>
2451 amsg <Calling RemDosEntry>
2453 amsg <VolumeNode removed>
2454 moveq #LDF_VOLUMES!LDF_WRITE,d1
2456 amsg <DosList freed>
2457 HInitFail1 amsg <Forbidding>
2459 amsg <DieResMod regs load>
2463 move.l ResModules(a6),d0
2465 DieResModChunk amsg <DieResModChunk:>
2467 DieResModLoop amsg <DieResModLoop:>
2472 bne.s DieResModChunk
2473 amsg <Resident pointer>
2476 amsg <Resident is mine>
2480 DieResModEnd amsg <DieTag regs load>
2481 get.l ResListSucc,a1
2482 lea KickTagPtr(a6),a0
2485 amsg <Empty KickTagPtr>
2486 DieTagNotFound amsg <DieTagNotFound:>
2487 and.w #$7FFF,KickTagPtr(a6)
2489 lea KickMemPtr(a6),a0
2490 DieMemLoop amsg <DieMemLoop:>
2491 move.l (a0),d0 ;LN_SUCC
2498 DieTagFound amsg <DieTagFound:>
2500 bra.s DieTagNotFound
2502 DieTagLoop amsg <DieTagLoop:>
2504 beq.s DieTagNotFound
2507 DieTagInto amsg <DieTagInto:>
2513 DieMemFound amsg <DieMemFound:>
2515 DieSumKick call SumKickData
2516 move.l d0,KickCheckSum(a6)
2518 amsg <KickCheckSum rewritten>
2519 DiePortLoop amsg <DiePortLoop:>
2524 amsg <Some packet got>
2525 move.l d0,a1 ;ExecMsg
2526 move.l LN_NAME(a1),a2 ;DosPacket
2532 amsg <ReplyDie returned>
2535 DiePortOK amsg <DiePortOK:>
2538 clr.l dn_SegList(a0)
2539 amsg <dn_(Task|SegList) cleared>
2541 amsg <Permit succeeded>
2544 call DOS,FreeDosEntry
2545 amsg <VolumeNode deallocated>
2547 call exec,CloseLibrary
2548 amsg <DosLib closed>
2551 amsg <The Final Forbid>
2554 move.l -(a0),d0 ;ME_LENGTH
2555 move.l -(a0),a1 ;ME_ADDR
2556 amsg <Calling FreeMem for myself>
2558 amsg <Running in non-allocated memory!>
2560 amsg <Final RTS... shutting down....>
2564 func macro ;Function
2565 dc.w F_\1-*-4,ACTION_\1
2568 ; ACTION_#? ;Arg1 Arg2 Arg3 Res1
2569 ; --------------------------------------------
2570 ; STARTUP ;? startup devnode bool
2571 func FINDINPUT ;fh lock name bool
2572 func FINDUPDATE ;fh lock name bool
2573 func READ ;arg1 &buf len len
2575 func SEEK ;arg1 pos mode oldpos
2576 func EXAMINE_NEXT ;lock fib bool
2577 func EXAMINE_OBJECT ;lock fib bool
2578 func INFO ;lock info bool
2579 func DISK_INFO ;info bool
2580 func PARENT ;lock lock
2581 func LOCATE_OBJECT ;lock name mode lock
2582 func COPY_DIR ;lock lock
2583 func FREE_LOCK ;lock bool
2584 func CURRENT_VOLUME ;arg1 volume
2585 func SAME_LOCK ;lock1 lock2 bool
2586 func IS_FILESYSTEM ; bool
2587 func FH_FROM_LOCK ;fh lock bool
2588 func PARENT_FH ;arg1 lock
2589 func EXAMINE_FH ;arg1 fib bool
2590 func COPY_DIR_FH ;arg1 lock
2591 ;Write-protected functions
2592 func WRITE ;arg1 &buf len len
2593 func FINDOUTPUT ;fh lock name bool
2594 func DELETE_OBJECT ;lock name bool
2595 func CREATE_DIR ;lock name lock
2596 func SET_PROTECT ; lock name mask bool
2597 func SET_COMMENT ; lock name comment bool
2598 func RENAME_OBJECT ;slock sname dlock dname bool
2599 func RENAME_DISK ;name bool
2600 func SET_DATE ; lock name stamp bool
2601 func SET_OWNER ; lock userinf bool
2602 func MAKE_LINK ;lock name dest!# soft bool
2605 func NIL ;End-of-table mark
2607 ;A0=Module with the checksum error
2608 SumError mpush a0/a6
2609 lea ResIntuiName(pc),a1
2610 call exec,OldOpenLibrary
2611 move.l #AT_DeadEnd!AG_OpenLib!AO_Intuition,d7
2618 SumErrLoop1 move.b (a0)+,(a1)+
2625 moveq #(SumErrMsgEnd-SumErrMsg)>>2-1,d1
2626 lea SumErrMsgEnd(pc),a0
2627 SumErrLoop2 push -(a0)
2629 move.b d0,SumErrCenter-SumErrMsg(sp)
2631 moveq #0,d0 ;Recovery
2640 UserReboot move.l 4.w,a6
2645 ResInit mpush d6/d7/a2/a3/a6
2649 amsg <ResidentInit started>
2651 move.l ResListSucc+V(pc),a0
2652 move.l (a0)+,d0 ;ResListSucc
2653 add.l (a0),d0 ;KickMemSucc
2654 lea ResidentPart-2-RT_SIZE(pc),a1
2655 move.w #(RT_SIZE+2+ResidentCode)>>2-1,d1
2656 ResSumLoop sub.l (a1)+,d0
2658 move.l RootPtr+V(pc),a0
2659 move.l -(a0),d1 ;ME_LENGTH
2660 add.l -(a0),d1 ;ME_ADDR
2662 clr.l VolumeNode-AnySum(a1)
2663 clr.l NumLocks-AnySum(a1)
2664 ResSumLoopE sub.l (a1)+,d0
2672 ResSumOkay amsg <ResRAM checksumming passed, checksumming ResCmds...>
2673 lea FirstSegment+V(pc),a2
2674 move.l CmdsNames+V(pc),a0
2675 CmdSumsLoop move.l (a2)+,d0
2678 SkipResCmdName tst.b (a0)+
2679 bne.s SkipResCmdName
2686 amsg <CheckSumming module "%s">
2692 amsg <This ResModule HAS checksum>
2693 SumOneModule lsl.l #2,d0
2702 SumOneHunkLoop add.l (a1)+,d7
2703 dbra d6,SumOneHunkLoop
2704 dbra d1,SumOneHunkLoop
2705 SumOneHunkEnd tst.l d0
2710 SumIncRet cmp.l (a2)+,d7
2712 amsg <CheckSum okay!>
2715 CmdSumsDone amsg <Checksumming libraries and kickmods...>
2716 move.l ResListPtr+V(pc),a3
2717 addq #4,a3 ;Skip ^MyResident struct
2718 ResSumsLoop move.l (a3)+,d0
2721 move.l RT_NAME(a0),a0
2726 ResSumsDone amsg <All checksums done!>
2727 move.l DosHName+V(pc),a2
2731 moveq #MEMF_PUBLIC,d1
2733 lea ResInitFail(pc),a3
2735 amsg <DosHandler name allocated>
2740 DosNCopy move.b (a2)+,(a0)+
2743 amsg <DosHandler name copied>
2745 moveq #(DeviceNode_SIZEOF+FileSysStartupMsg_SIZEOF+de_Baud+1+DeviceNameEnd-DeviceName)>>1,d0
2747 move.l #MEMF_PUBLIC!MEMF_CLEAR,d1
2750 amsg <DeviceNode allocated>
2753 lea dn_StackSize+2(a0),a0
2754 move.w #StdStackSize,(a0)+ ;dn_StackSize
2756 addq.l #StdTaskPri-8,(a0)+ ;dn_Priority
2757 lea DeviceNode_SIZEOF-dn_Startup(a0),a1
2760 move.l d1,(a0)+ ;dn_Startup
2761 lea ResSegList(pc),a1
2762 move.l d6,DevNode+V-ResSegList(a1)
2765 move.l d1,(a0)+ ;dn_SegList
2766 not.l (a0)+ ;dn_GlobalVec
2768 move.l d0,(a0) ;dn_Name
2769 addq #DeviceNode_SIZEOF-dn_Name+fssm_Device-FileSysStartupMsg,a0
2770 lea FileSysStartupMsg_SIZEOF-fssm_Device+de_Baud-DosEnvec(a0),a1
2773 move.l d0,(a0)+ ;fssm_Unit
2774 lea FileSysStartupMsg_SIZEOF-fssm_Environ+DosEnvec(a0),a1
2777 move.l d0,(a0) ;fssm_Environ
2778 moveq #DE_DOSTYPE,d0
2779 move.l d0,(a1)+ ;de_TableSize
2780 lsl.l #3,d0 ;DE_DOSTYPE(=16)<<3=128
2781 move.l d0,(a1) ;de_SizeBlock
2782 addq #de_Surfaces-de_SizeBlock,a1
2783 addq.l #1,(a1)+ ;de_Surfaces
2784 addq.l #1,(a1)+ ;de_SectorPerBlock
2785 addq.l #1,(a1) ;de_BlocksPerTrack
2786 lea de_HighCyl-de_BlocksPerTrack(a1),a0
2787 move.l MyInfoData+id_NumBlocks+V(pc),(a0)
2788 subq.l #1,(a0)+ ;de_HighCyl
2789 addq.l #5,(a0)+ ;de_NumBuffers
2790 addq.l #MEMF_PUBLIC,(a0)+ ;de_BufMemType
2791 move.l #1<<31-1,(a0)+ ;de_MaxTransfer
2792 not.l (a0)+ ;de_Mask
2793 move.l VarBootPri+V(pc),(a0)+ ;de_BootPri
2794 move.l #'RES'<<8,(a0)+ ;de_DosType
2795 MyDiskTypeAddr equ *-4
2796 lea DeviceName(pc),a1
2797 CopyDevName move.b (a1)+,(a0)+
2799 amsg <DeviceNode filled>
2803 move.l #AG_OpenLib!AO_ExpansionLib,d7
2806 amsg <Expansion opened>
2809 lea ResInitCFail(pc),a3
2811 amsg <AllocConfigDev succeeded>
2814 move.l a0,LN_NAME(a1)
2815 move.b #ERT_NEWBOARD!ERTF_DIAGVALID,cd_Rom+er_Type(a1)
2816 lea MyDiagArea(pc),a0
2817 move.l a0,cd_Rom+er_Reserved0c(a1) ;er_Reserved0[c-f]
2818 amsg <ConfigDev filled>
2821 move.b VarBootPri+3+V(pc),d0
2822 moveq #ADNF_STARTPROC,d1
2825 amsg <AddBootNode succeeded>
2826 ResInitCFail move.l a6,a1
2827 call exec,CloseLibrary
2828 ResInitFail amsg <Initialization finished>
2832 ;### Debug part of the detach zone ###
2835 DPrintf mpush d0-d1/a0-a3/a6
2839 lea _LVORawPutChar(a6),a2
2844 Wait1 btst.b #2,$dff016
2846 Wait2 btst.b #2,$dff016
2853 PrintLockName tst.l d2
2864 PrintLockNameX add.l a0,a0
2866 move.l fl_Key(a0),a0
2868 ;Inputs: A0=^Object, Destroys: A0-A2 !!! VERY BIG STACK !!!
2869 PrintObjName lea -30(sp),sp
2871 lea RFC_FileName(a0),a1
2873 CopyName move.b (a1)+,(a2)+
2883 ReachedRoot lea DPrintf(pc),a1
2892 ; ### MyDiagArea - ptr to it is in ConfigDev structure ###
2893 MyDiagArea dc.b DAC_BOOTTIME,0 ;da_Config,da_Flags
2894 dc.w DiagAreaEnd-MyDiagArea ;da_Size
2895 dc.w 0,DiagBootUp-MyDiagArea ;da_DiagPoint,da_BootPoint
2896 dc.w ResName-MyDiagArea ;da_Name
2897 dc.w 0,0 ;da_Reserved01,da_Reserved02
2899 AlertD0Mem moveq #AG_NoMemory>>16,d7
2908 DiagBootUp amsg <DiagBootUp started>
2910 call exec,FindResident
2911 DoOpenDOSAlert move.l #AT_DeadEnd!AG_OpenLib!AO_DOSLib,d7
2914 move.l RT_INIT(a0),a0
2915 amsg <DiagBootUp - Initializing DOS>
2917 DosName dc.b 'dos.library',0
2919 ResName dc.b 'ResRAM-Handler'
2923 ResNumOne dc.b 0,0,0
2927 ResID dc.b 'ResRAM-Handler 1.0 (5.2.95)',0
2928 ExpName dc.b 'expansion.library',0
2929 UtilName dc.b 'utility.library',0
2930 DeviceName dc.b DeviceNameEnd-DeviceName-2,'none.device',0
2932 ifne (DeviceNode_SIZEOF+FileSysStartupMsg_SIZEOF+de_Baud+1+DeviceNameEnd-DeviceName)&1
2935 ResIntuiName dc.b 'intuition.library',0
2937 SumErrMsg dc.b 0,96,28,'!! SYSTEM IS NOW UNRELIABLE -'
2938 dc.b ' COLD REBOOT RECOMMENDED !!',0,-1
2939 dc.b 0,32,48,'LMB - Continue',0,-1
2940 dc.b 480>>8,480&$FF,48,'RMB - ColdReboot',0,-1,0
2941 SumErrCenter dc.b 0,16,'ResRAM #'
2942 ifne (*-SumErrMsg)&1
2945 ResNumTwo dc.b 0,0,': Invalid checksum on '
2947 ifne (SumErrMsgEnd-SumErrMsg)&3
2948 fail <SumErr not long aligned!!>
2950 V equ ResidentPart+(*-ResidentPart+3)&~3
2951 ResidentCode equ V-ResidentPart
2952 SYSCNTold equ SYSCNT
2963 dv.l AnySum ;Checksum of the main part
2964 dv.l CmdsNames ;^1st name of Resident Command
2965 dv.l VolumeName ;APTR to ASCIIZ of volume name
2966 dv.l DosHName ;APTR to BSTR of dos handler name
2967 dbuf MyInfoData,id_SIZEOF
2968 VolumeNode equ MyInfoData+id_VolumeNode ;BPTR
2969 NumLocks equ MyInfoData+id_InUse
2970 dv.l RootPtr ;APTR to root entry
2971 dv.l ResListSucc ;ResidentList successor
2972 dv.l ResListPtr ;^^MyResidentStruct
2973 dbuf GDateStamp,ds_SIZEOF ;Global DateStamp
2974 dbuf FirstSegment,0 ;Label of seg of first ResCmd
2976 ResidentVars equ SYSCNT
2977 SYSCNT set SYSCNTold
2979 VerbOpt macro ;<name>,<letter>,<description>
2986 VerbB_\1 equ _VerbOpt
2987 VerbF_\1 equ 1<<_VerbOpt
2988 _VerbOpt set _VerbOpt+1
2991 dt.c <',VerbF_\1,'\2>
2997 template <FILES/A,DEVICE,NAME,PRI=BOOTPRI/N/K,EMPTYDIRS/S,GENABS/K,GENDISK/K,NODISKREQ/S,NORUN/S,REBOOT/S,VERBOSE/K>
3010 dc.b 'Resident RAM-Disk loader v1.0 --- (c) 1995 Short Software',10,10
3011 dc.b 'FILES - Directory/pattern for files to load',10
3012 dc.b ' (Wildcards in directory names aren''t supported)',10
3013 dc.b 'DEVICE - DOS device name of RES-Disk (def. RES:)',10
3014 dc.b 'NAME - Volume name of RES-Disk (def. ResRAM)',10
3015 dc.b 'BOOTPRI - Boot priority (def. 15)',10
3016 dc.b 'EMPTYDIRS - Don''t discard empty directories',10
3017 dc.b 'GENABS - Filename where an AbsModule should be written',10
3018 dc.b 'GENDISK - DOS device name for a boot image (e.g. DF0:)',10
3019 dc.b 'NODISKREQ - Suppress ''Insert disk...'' requester (only for GENDISK)',10
3020 dc.b 'NORUN - Don''t mount RES-Disk',10
3021 dc.b 'REBOOT - Reboot machine when the load succeeds',10
3022 dc.b ' (Doesn''t apply to AbsModules or boot images)',10
3023 dc.b 'VERBOSE - Verbosity switches (seq. of following letters):',10
3024 dt.c VerbParseTab,<>
3025 VerbOpt All,A,<Turn all switches on>
3026 VerbOpt None,N,<Turn all switches off>
3027 VerbOpt Dirs,D,<Scanned directories>
3028 VerbOpt Files,F,<Scanned file names & types>
3029 VerbOpt LoadSeg,I,<Scan phase LoadSeg info>
3030 VerbOpt LoadFiles,L,<Files being loaded>
3031 VerbOpt Mem,M,<Memory being allocated>
3032 VerbOpt SizeMod,G,<Sizes of modules being generated>