mirror of
https://github.com/elliotnunn/mac-rom.git
synced 2024-09-07 09:54:37 +00:00
Resource forks are included only for .rsrc files. These are DeRezzed into their data fork. 'ckid' resources, from the Projector VCS, are not included. The Tools directory, containing mostly junk, is also excluded.
346 lines
14 KiB
Plaintext
346 lines
14 KiB
Plaintext
;
|
|
; File: DiskCachePriv.a
|
|
;
|
|
; Contains: Private equates for the RAM cache
|
|
;
|
|
; Written by: Kenny SC. Tung
|
|
;
|
|
; Copyright: © 1985-1992 by Apple Computer, Inc., all rights reserved.
|
|
;
|
|
; Change History (most recent first):
|
|
;
|
|
; <2> 3/3/92 kc Remove ForROM code because we now use the new cache.
|
|
; <12> 12/3/91 KST Added some documentation.
|
|
; <11> 8/21/91 JSM Clean up header.
|
|
; <10> 7/8/91 JSM Remove obsolete SysVers conditionals.
|
|
; <9> 1/30/91 gbm sab, #38: Change the Ôalready including this fileÕ variable to
|
|
; all uppercase (for security reasons)
|
|
; <8> 1/2/91 KST Adding some new defs.
|
|
; <7> 10/29/90 KST Set minimum number of buckets of the device hash table to be 16.
|
|
; <6> 8/27/90 KST Move some equates to fsPrivate.a
|
|
; <5> 8/7/90 KST Changed number of file queues from 40 to 50. And made this file
|
|
; works for ROM build.
|
|
; <4> 8/6/90 KST Major rewrite for 7.0. Changing and adding lots of new equates.
|
|
; <3> 7/26/90 gbm can't use dirtyBit... changing it to cacheDirtyBit
|
|
; <1.0> 3/20/89 CCH Adding to EASE from System build.
|
|
; 11/20/87 JB Added cache var 'CacheMinZn' which functionally replaces the
|
|
; constant 'minApplZone'. Parameter is now settable via cache
|
|
; control trap.
|
|
; 9/14/87 JB Changed minApplZone to 384k to allow more application space on 1
|
|
; megabyte systems. (S272)
|
|
; 12/2/86 LAK Added equate for CacheRegs (regs saved over cache adjust).
|
|
; Changed TFSDebug to new CacheDebug message with message.
|
|
; 8/4/86 DLD Added macro definiton for _AssumeEq, _TFSDebug, and and
|
|
; TFSDebug.
|
|
; 7/23/86 DLD Converted source to MPW.
|
|
; 12/4/85 LAK Added global age field, and age field to cache buffer headers.
|
|
; Added FHBufMax, FHAttrib, FHExtra, FHFlType, FHParDID, FHRWIPMax
|
|
; fields to file queue headers for better cache control, and to
|
|
; allow writing of blocks belonging to a closed file. Added
|
|
; CacheCom, noRWIPBit equates for external control of cache. Moved
|
|
; CacheVars, CacheCom, noRWIPBit equates to TFSEQU.
|
|
; 11/29/85 LAK New today.
|
|
;
|
|
|
|
IF &TYPE('__INCLUDINGDISKCACHEPRIV__') = 'UNDEFINED' THEN
|
|
__INCLUDINGDISKCACHEPRIV__ SET 1
|
|
|
|
if &type('ktDebugCache') = 'UNDEFINED' then
|
|
ktDebugCache equ 0
|
|
endif
|
|
|
|
;_______________________________________;
|
|
;
|
|
; MACRO definitions
|
|
;_______________________________________;
|
|
|
|
|
|
BLANKS ON
|
|
STRING ASIS
|
|
|
|
MACRO ; replace a jump vector
|
|
InstJV
|
|
PEA &Syslst[1]
|
|
MOVE.L (SP)+,&Syslst[2]
|
|
ENDM
|
|
|
|
CacheRegs REG D0-D7/A0-A2/A4-A6 ;<02Dec86> save all but A3
|
|
AllRegs REG D0-D7/A0-A6 ;<02Dec86> save all
|
|
minCache EQU $8000 ;<02Dec86> use 32K min cache
|
|
minApplZone EQU $60000 ;<14Sep87> use 384K min appl zone
|
|
;_______________________________________;
|
|
;
|
|
; Additional global equates
|
|
;_______________________________________;
|
|
|
|
FKeepOK EQU $90E ; 'OK' when FKeepIn is valid
|
|
FKeepIn EQU $90C ; positive when Keeper is installed
|
|
SwitchVars EQU $282 ; positive when Switcher is installed
|
|
|
|
CacheConfig EQU $20A ; size configuration byte
|
|
CacheEnable EQU $20B ; bit 5=1 when enabled
|
|
|
|
FileQHdr EQU SysVolCPtr ; use old 2-block vol cache for
|
|
; cache queue headers
|
|
FreeQHdr EQU SysBMCPtr ; use old bitmap cache for free queue
|
|
;_______________________________________;
|
|
;
|
|
; Cache Locals Definitions ($394)
|
|
;_______________________________________;
|
|
|
|
CacheVCnt EQU 8 ; 8 cache vectors to replace
|
|
|
|
SegVectSave EQU 0 ; (long) previous SegLoader vector
|
|
OldBufPtr EQU 4 ; (long) set to pre-cache value of BufPtr
|
|
NewBufPtr EQU 8 ; (long) set to bottom of cache
|
|
BufStart EQU $C ; (long)
|
|
CBHdrStart EQU $10 ; (long) <20Apr90>
|
|
TotalBufN EQU $14 ; (word) <20Apr90>
|
|
CurConfig EQU $16 ; (byte) equal to CacheConfig, last adjust
|
|
CurEnable EQU $17 ; (byte) $FF if enabled, $00 otherwise
|
|
CacheByteLim EQU $18 ; (long) bytesize max of requests to cache
|
|
CacheAge EQU $1C ; (long) starts at -1, counts down
|
|
CacheMinZn EQU $20 ; (long) min application zone size <20Nov87>
|
|
|
|
INITSegVect EQU $24 ; (long)
|
|
CacheIOBlk EQU $28 ; (long) ptr to I/O blk used to sync with fs
|
|
CacheRoutine EQU $2C ; (long) routine to call after sync'ing
|
|
SavedHook EQU $30 ; (long) saved ExtFS hook
|
|
|
|
LcDevHTPtr EQU $34 ; (long) device hash table ptr <24May90>
|
|
LcReserved1 EQU $38 ; (byte) TrashVBlks counter (called 3 times)
|
|
LcReserved2 EQU $39 ; (byte) not used
|
|
LcGBinCache EQU $3A ; (word) set if buffer is not newly allocated,
|
|
; ie., found in the cache. Used by cacheRdIP
|
|
LcGBinFQueue EQU $3A ; (byte) set if the block is found in file queue
|
|
LcGBinDHTable EQU $3B ; (byte) set if the block is found in free queue
|
|
LcXCacheKey EQU $3C ; (long) translation cache key (buffer)
|
|
LcXCacheData EQU $40 ; (long) translation cache data (header)
|
|
LcFreeMemSize EQU $44 ; (word) free memory above OldBufPtr
|
|
CacheLclLen EQU LcFreeMemSize+2 ; end of locals
|
|
|
|
; The story w.r.t. BufPtr, NewBufPtr, and OldBufPtr is as follows:
|
|
;
|
|
; (1) OldBufPtr ³ NewBufPtr ³ BufPtr, always.
|
|
; (2) OldBufPtr - NewBufPtr = buffer space currently owned by the cache.
|
|
; (3) If NewBufPtr = BufPtr, cache space is at bottom of buffer and may be
|
|
; adjusted (if neither Switcher nor FinderKeeper are installed).
|
|
; (4) OldBufPtr, NewBufPtr are initialized to BufPtr when the cache is
|
|
; installed. NewBufPtr is then lowered by the amount specified
|
|
; in parameter RAM at the first launch.
|
|
|
|
FLink EQU 0 ; generic queue forward link offset
|
|
BLink EQU 4 ; generic queue backward link offset
|
|
QCount EQU 8 ; generic queue element count (hdr only)
|
|
|
|
; File Queue Header (top cache data structure).
|
|
;
|
|
; This is the queue header for all the file headers.
|
|
|
|
FQHFlink EQU 0 ; (long) CQ forward link pointer
|
|
FQHBlink EQU 4 ; (long) CQ backward link pointer
|
|
FQHFileCnt EQU 8 ; (word) number of file headers
|
|
FQHExtra EQU 10 ; (word) extra
|
|
|
|
FQHlength EQU 12 ; length of FQH
|
|
|
|
fileHdrCnt EQU 50 ; support up to 40 files for now
|
|
; try 50 for now
|
|
; Free Queue Header (free blocks).
|
|
;
|
|
; The Free Block Queue is where trashed blocks go (and where all
|
|
; blocks are initially put). These blocks are recycled before any
|
|
; other blocks.
|
|
|
|
FreeQFlink EQU 0 ; (long) free queue forward link
|
|
FreeQBlink EQU 4 ; (long) free queue backward link
|
|
FreeQBufCnt EQU 8 ; (word) free queue buffer count
|
|
TotalBufCnt EQU 10 ; (word) total number of buffers in cache
|
|
FreeQHlen EQU 12 ; length of FQH
|
|
|
|
; File Header (one per file fork with blocks cached).
|
|
;
|
|
; There is also one queue per volume with volume blocks cached. For TFS
|
|
; volumes, only the MDB and volume map blocks would be found in the volume
|
|
; queue. For MDS volumes, directory blocks would also go into the volume
|
|
; queue.
|
|
|
|
FHFlink EQU 0 ; (long) File Queue forward link
|
|
FHBlink EQU 4 ; (long) File Queue backward link
|
|
FHMQHFlink EQU 8 ; (long) Cache Buffer Queue forward link
|
|
FHMQHBlink EQU 12 ; (long) Cache Buffer Queue backward link
|
|
FHBufCnt EQU 16 ; (word) cache buffer count
|
|
FHBufMax EQU 18 ; (word) max buffer cnt for this file (not yet used)
|
|
FHFlags EQU 20 ; (byte) flags
|
|
noFlushBit EQU 7 ; 1=avoid intermediate flushes
|
|
mruSrchBit EQU 6 ; 1=use mru order for GetBlock search
|
|
fqDirtyBit EQU 5 ; 1=a buffer in the FILE queue is dirty <25Apr90>
|
|
|
|
FHFkType EQU 21 ; (byte) $00 = data fork (or vol blk)
|
|
; $FF = resource fork
|
|
FHAttrib EQU 22 ; (byte) copied from attributes (used for tags)
|
|
FHExtra EQU 23 ; (byte) reserved for future use
|
|
FHFlType EQU 24 ; (long) file type (TFS files) for HD20 file tags
|
|
FHVCBPtr EQU 28 ; (long) VCB pointer (0 if free) <30May90>
|
|
FHDQHFLink EQU 32 ; (long) Disk Queue forward link <30May90>
|
|
FHDQHBLink EQU 36 ; (long) Disk Queue backward link <30May90>
|
|
FHFlNum EQU 40 ; (long) file number (0 for vol blks) <30May90>
|
|
FHParDID EQU 44 ; (long) parent Dir ID (TFS files) for HD20 file tags
|
|
FHlength EQU 48 ; length of File Header (HT = 256-48=208/8=26 buckets)
|
|
|
|
; File Header as MRU Queue Header
|
|
|
|
MQHFlink EQU 0 ; (long) Cache Buffer Queue forward link
|
|
MQHBlink EQU 4 ; (long) Cache Buffer Queue backward link
|
|
MQHBufCnt EQU 8 ; (word) cache buffer count
|
|
MQHBufMax EQU 10 ; (word) max buffer cnt for this file (not yet used)
|
|
MQHFlags EQU 12 ; (byte) flags
|
|
MQHFkType EQU 13 ; (byte) $00 = data fork (or vol blk)
|
|
; $FF = resource fork
|
|
MQHAttrib EQU 14 ; (byte) copied from attributes (used for tags)
|
|
MQHExtra EQU 15 ; (byte) reserved for future use
|
|
MQHFlType EQU 16 ; (long) file type (TFS files) for HD20 file tags
|
|
MQHVCBPtr EQU 20 ; (long) VCB pointer (0 if free)
|
|
|
|
MQHDQHFLink EQU 24 ; (long) Disk Queue forward link
|
|
MQHDQHBLink EQU 28 ; (long) Disk Queue backward link
|
|
MQHFlNum EQU 32 ; (long) file number (0 for vol blks)
|
|
MQHParDID EQU 36 ; (long) parent Dir ID (TFS files) for HD20 file tags
|
|
;MQHashTbl EQU 40 ; (long) hash table start <12Jun90>
|
|
|
|
; File Header as File-ordered Queue Header (used to be Disk-ordered, ergo the 'D')
|
|
|
|
DQHMQHFlink EQU -24 ; (long) Cache Buffer Queue forward link
|
|
DQHMQHBlink EQU -20 ; (long) Cache Buffer Queue backward link
|
|
DQHBufCnt EQU -16 ; (word) cache buffer count
|
|
DQHBufMax EQU -14 ; (word) max buffer cnt for this file (not yet used)
|
|
DQHFlags EQU -12 ; (byte) flags
|
|
DQHFkType EQU -11 ; (byte) $00 = data fork (or vol blk)
|
|
; $FF = resource fork
|
|
DQHAttrib EQU -10 ; (byte) copied from attributes (used for tags)
|
|
DQHExtra EQU -9 ; (byte) reserved for future use
|
|
DQHFlType EQU -8 ; (long) file type (TFS files) for HD20 file tags
|
|
DQHVCBPtr EQU -4 ; (long) VCB pointer (0 if free)
|
|
DQHFLink EQU 0 ; (long) Disk Queue forward link
|
|
DQHBLink EQU 4 ; (long) Disk Queue backward link
|
|
DQHFlNum EQU 8 ; (long) file number (0 for vol blks)
|
|
DQHParDID EQU 12 ; (long) parent Dir ID (TFS files) for HD20 file tags
|
|
;DQHashTbl EQU 16 ; (long) hash table start <12Jun90>
|
|
|
|
|
|
; Cache Block Header (one per cache block).
|
|
;
|
|
; Since the File Cache Header contains VCB, File Number, and fork
|
|
; type information, this is omitted for the cache block header.
|
|
; This may need to be expanded for multiblock r/w support.
|
|
|
|
; MRU-ordered Cache Block Header
|
|
|
|
MCBFlink EQU 0 ; (long) Cache Buffer Queue forward link
|
|
MCBBlink EQU 4 ; (long) Cache Buffer Queue backward link
|
|
|
|
MCBHashqFlink EQU 8 ; (long) hash queue forword link <30May90>
|
|
MCBHashqBlink EQU 12 ; (long) hash queue backword link <30May90>
|
|
|
|
MCBFlags EQU 16 ; (byte) flags
|
|
MCBExtra EQU 17 ; (byte) extra (not used)
|
|
MCBFkType EQU MCBExtra ; (byte) resource type <11Jun90>
|
|
MCBRefNum EQU 18 ; (word) last refnum used (debug use only?) =>cbHqVRfn
|
|
MCBAge EQU 20 ; (long) used for aging this block =>cbHqDevNum
|
|
MCBDQFlink EQU 24 ; (long) CBQ flink, in file order
|
|
MCBDQBlink EQU 28 ; (long) CBQ blink, in file order
|
|
MCBDBlk EQU 32 ; (long) disk blk num =>cbHqDevBlk
|
|
MCBFlBlk EQU 36 ; (long) file blk num (=MCBDBlk for volblks)=>cbHqFilBlk
|
|
MCBFQPtr EQU 40 ; (long) ptr to queue header
|
|
MCBFileNum EQU 44 ; (long) file number used by hash<11Jun90> =>cbHqFilNum
|
|
MCBDataPtr EQU 48 ; (long) pointer to data
|
|
MCBHLength EQU 52 ; length of cache block header <30May90>
|
|
|
|
cacheDirtyBit EQU 7 ; ...buffer dirty flag
|
|
inuseBit EQU 6 ; ...buffer in use flag
|
|
emptyBit EQU 5 ; ...buffer is empty
|
|
|
|
DCBFlags EQU -8 ; (byte) flags
|
|
DCBExtra EQU -7 ; (byte) extra
|
|
DCBRefNum EQU -6 ; (word) last refnum used
|
|
DCDAge EQU -4 ; (long) used for aging this block
|
|
DCBFlink EQU 0 ; (long) CBQ flink, in file order
|
|
DCBBlink EQU 4 ; (long) CBQ blink, in file order
|
|
DCBDBlk EQU 8 ; (long) disk blk num
|
|
DCBFlBlk EQU 12 ; (long) file blk num (=MCBDBlk for vol blks)
|
|
DCBFQPtr EQU 16 ; (long) ptr to queue header
|
|
DCBFileNum EQU 20 ; (long) file number <11Jun90>
|
|
DCBData EQU 24 ; start of data (or pointer) <30May90>
|
|
; fortunately, this is not used <30May90>
|
|
|
|
|
|
IF &Type('CacheDebug')='Undefined' THEN
|
|
CacheDebug EQU 0 ; default debug code out
|
|
ENDIF
|
|
|
|
; MACRO
|
|
; _AssumeEq
|
|
; IF &EVAL(&SysList[1]) <> &EVAL(&SysList[2]) THEN
|
|
; ERR ; Invalid statement - will cause error
|
|
; ENDIF
|
|
; ENDM
|
|
|
|
MACRO
|
|
_CacheDebug &msg
|
|
IF CacheDebug THEN
|
|
PEA &msg ; pass string255
|
|
DC.W $ABFF ; invoke Macsbug
|
|
ENDIF
|
|
ENDM
|
|
|
|
MACRO
|
|
_CodeCheck
|
|
IF CacheDebug THEN
|
|
DC.W $A9FF ; invoke Macsbug
|
|
ENDIF
|
|
ENDM
|
|
|
|
Byteto32K EQU 15 ; convert to 32K multiple <8>
|
|
kMinBootSize EQU 16*1024 ; at least 16K to boot <8>
|
|
n32K EQU 32*1024 ; 32K constant <8>
|
|
n256K EQU 256*1024 ; 256K constant <8>
|
|
|
|
log2Bsize EQU 9 ; log2 of 512 when BufSiz = 512 <20Apr90>
|
|
kMinCacheSize EQU $8000 ; current minimum is 32K if DiskCache is not enabled on 7.0
|
|
|
|
|
|
;; hash table structure:
|
|
htKeyMask EQU 0 ; (word) key mask (# of buckets - 1)
|
|
htCount EQU 2 ; (word) # of elements in the hash table
|
|
htReserved EQU 4 ; (long) unused (# of buckets for debugging only)
|
|
htStart EQU 8 ; table starts
|
|
|
|
htEntrysize EQU 8 ; each entry is 8 bytes
|
|
htEntryLog2 EQU 3 ; log 2 of htEntrysize
|
|
|
|
DevHTsize EQU 3 ; log2 of device hash table size (= bufcount/8)
|
|
maxDHTnum EQU 512 ; max = 512 buckets for DHT
|
|
minDHTnum EQU 16 ; min = 16 buckets for DHT
|
|
|
|
SaveinHash EQU 'haSh' ; flag to keep buffer in DHT
|
|
fromWriteIP EQU 'WrIP' ; called from writeIP
|
|
|
|
;; ¥¥ The usage of MCBAge: MCBDevNum = cbHqDevNum = MCBAge. -- <KSCT #12>
|
|
;; When a buffer is in the file queue, MCBAge = age stamp,
|
|
;; When a buffer is in the free queue and is empty, MCBDevNum = MCBAge = 0,
|
|
;; When a buffer is in the free queue but is not empty, MCBDevNum = MCBAge = Vol RefNum.
|
|
;; In the last case, the buffer is also added in the hash table.
|
|
|
|
MCBDevNum EQU MCBAge ; (word) device number (was MCBAge)
|
|
MCBHashKey EQU MCBAge+2 ; (word) bucket number (for debugging)
|
|
|
|
;; Block header points at hashqFlink on the hash queue:
|
|
cbHqVRfn EQU MCBRefNum - MCBHashqFlink ; volume refnum
|
|
cbHqDevBlk EQU MCBDBlk - MCBHashqFlink ; dev. block
|
|
cbHqFilBlk EQU MCBFlBlk - MCBHashqFlink ; file block
|
|
cbHqFilNum EQU MCBFileNum - MCBHashqFlink ; file number
|
|
cbHqDevNum EQU MCBDevNum - MCBHashqFlink ; MCBage
|
|
|
|
|
|
ENDIF ; ...already included
|