mirror of
https://github.com/elliotnunn/mac-rom.git
synced 2025-01-09 02:30:13 +00:00
4325cdcc78
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.
162 lines
6.7 KiB
Plaintext
162 lines
6.7 KiB
Plaintext
;
|
|
; File: BTreePrivate.a
|
|
;
|
|
; Contains: B*tree private EQUs.
|
|
;
|
|
; Written by: Kenny SC. Tung
|
|
;
|
|
; Copyright: © 1989-1991 by Apple Computer, Inc., all rights reserved.
|
|
;
|
|
; Change History (most recent first):
|
|
;
|
|
; <SM1> 4/1/92 kc Changed the name prefex used to distinguish
|
|
; routines used by the external B-Tree manager
|
|
; from the versions used by the File System.
|
|
; ¥ Pre-SuperMario comments follow ¥
|
|
; <12> 9/13/91 JSM Cleanup header.
|
|
; <11> 12/18/90 KST With Bill B.: Adding DoAlloc.
|
|
; <10> 12/11/90 KST With Bill B.: Change DoAlloc to DoSetEOF.
|
|
; <9> 8/1/90 KST Adding an opcode for DoFlushFile.
|
|
; <8> 4/11/90 KST Increase B*Tree private stack size.
|
|
; <7> 4/11/90 KST Adding RAM version of the btMaxDepth and related equates.
|
|
; <6> 3/29/90 KST btAsyncBit has been changed to the wrong bit.
|
|
; <5> 3/13/90 KST Documentation change and code cleanup.
|
|
; <4> 2/22/90 KST Documentation change and code cleanup.
|
|
; <3> 1/22/90 KST Added support for access control.
|
|
; <1.8> 11/22/89 KST B*Tree error code changed from -400 to -410.
|
|
; <1.7> 10/2/89 KST Code cleanup.
|
|
; <1.6> 9/28/89 KST Documentation change.
|
|
; <1.5> 9/17/89 KST New buffer scheme. No more cache buffer now.
|
|
; <1.4> 9/7/89 dnf Moved extended btree equates to hfs70equ.a
|
|
; <1.3> 8/7/89 KST Code cleanup.
|
|
; <1.2> 7/6/89 KST Added BTFlush call, changed MaxbtTrap from 9 to 10.
|
|
; <1.1> 6/15/89 KST Move maxKeyLen from BTreePrivate.a to BTreeEqu.a
|
|
; <1.0> 6/15/89 KST Created BTreePrivate.a EQU file.
|
|
;
|
|
|
|
;; Now we keep the log2 of the nodesize in BTCB at BTOpen so that we know how to
|
|
;; convert from node number to byte position without assuming a fixed node size.
|
|
|
|
;; At BTOpen we need to read the header of the B*Tree in order to get BTCB on disk
|
|
;; data. We can assume the header is in the first block of the file. (even we
|
|
;; change the nodesize, BTH data should be remained compatible)
|
|
btHdrNSize EQU 512
|
|
|
|
btNSftCnt EQU 9 ; node size shift count when nodesize = 512
|
|
; used in BTInit
|
|
|
|
maxOccur EQU maxKeyLen ; max. number of occurrence
|
|
btErrConst EQU 447 ; error code conversion constant
|
|
; btbadHdr = 37 - 447 = notBtree (-410)
|
|
|
|
;; Btree types: 0 is HFS CAT/EXT file, 1~127 are AppleShare B*Tree files, 128~254 unused
|
|
hfsBtreeType EQU 0 ; control file
|
|
validBTType EQU $80 ; user btree type starts from 128
|
|
userBT1Type EQU $FF ; 255 is our Btree type. Used by BTInit and BTPatch
|
|
|
|
;; key descriptor offset stored in the "User Record" of header node:
|
|
kdPtr EQU lenBTH+lenND ; key descriptor starts here in header node
|
|
kdBytesPerKey EQU 2 ; each field consumes 2 bytes in KD
|
|
kdBytesStr EQU 1 ; String consumes 1 more byte in KD
|
|
kdBytesFLStr EQU 2 ; FLString consumes 2 more bytes in KD
|
|
|
|
;; Btree vars definition:
|
|
btVQHdr EQU 0 ; BT request queue header (word)
|
|
btVQFlag EQU 0 ; busy flag (word)
|
|
btQBusyBit EQU 0 ; bit
|
|
btAsyncRetd EQU 7 ; bit
|
|
btAsyncBit EQU 10 ; bit (ASYNC call) <29Mar90>
|
|
|
|
btVQHead EQU 2 ; queue head (long)
|
|
btVQTail EQU 6 ; queue tail (long)
|
|
btVParam EQU 10 ; private ioParam (long)
|
|
; ¥¥ Note: AppleShare relies on btVParam EQU 10 <10Dec90>
|
|
btBufQHdr EQU 14 ; BT buffer QHeader (long)
|
|
btVSptr EQU 18 ; current stack pointer (long)
|
|
btVSTop EQU 22 ; stack base (long)
|
|
btVNextUID EQU 26 ; next UID to assigned (long)
|
|
btVRsrv EQU 30 ; reserved (long)
|
|
btVtotal EQU btVRsrv+4 ; total bytes
|
|
|
|
;; B*tree memory map: (param, buffers and stack are allocated in one chunk)
|
|
; +-- btVQHdr (Low mem)
|
|
; +-- btVQHead
|
|
; +-- btVQTail
|
|
; +-- BT param
|
|
; +-- BufQHdr --+-- buffer index (word) ; current free buffer index (starts with 0)
|
|
; | +-- buffer size (word) ; buffer size at INIT time
|
|
; | +-- BT buffers ; N buffers follow
|
|
; | ... (buffers)
|
|
; +-- stack Ptr +-- + ^
|
|
; | ... (stack) | ^
|
|
; +-- stack top (btVSTop) --+-^
|
|
; +-- btVadQHdr (another queue for access denied requests)
|
|
; +-- btVadQHead
|
|
; +-- btVadQTail
|
|
|
|
;; QHeader consists of CurrentIndex, BufferSize, and then followed by N buffers,
|
|
btQCIndex EQU 0 ; word for saving current index
|
|
btQBSize EQU 2 ; word for saving INIT buffer size
|
|
btQBStart EQU 4 ; buffer starts from here
|
|
|
|
;; each buffer has header and data area ------------
|
|
btBHFlags EQU 0 ; (byte) stauts
|
|
;cbhdirty EQU 7 ; ...buffer dirty flag
|
|
;cbhinuse EQU 6 ; ...buffer in use flag
|
|
;cbhempty EQU 5 ; ...buffer is empty
|
|
|
|
btBHRsved EQU 1 ; (byte) not used
|
|
btBHRefNum EQU 2 ; (word) file refnum
|
|
btBHNSize EQU 4 ; (word) node size
|
|
btBHFilePos EQU 6 ; (long) file position
|
|
btBHData EQU 10 ; start of data buffer
|
|
lenBTBH EQU btBHData ; length of btBuf Header
|
|
lenBTBuf EQU lenBTBH+btNodeSize ; buffer + header length
|
|
|
|
;; private cache buffers and stack ---------------------------
|
|
btBufferN EQU 3 ; number of private buffers
|
|
btBufLen EQU lenBTBuf*btBufferN+btQBStart ; N buffers + index + size
|
|
btParamLen EQU BTioParamSize ; use the larger one
|
|
btStkLen EQU 1024 ; Allocate a decent-sized chunk of memory for stack
|
|
btTmpSize EQU btBufLen+btParamLen+btStkLen ; Total additional space for Btree
|
|
|
|
NRMapNode EQU 1 ; number of record in map node
|
|
NRHdrNode EQU 3 ; number of record in header node
|
|
LenUser EQU 128 ; user record (byte) in header node
|
|
|
|
; size (in byte) of the bitmap record in the header node: (256 bytes)
|
|
LenBMapHdr EQU btNodesize-((NRHdrNode+1)*2)-(lenND+LenBTH+LenUser)
|
|
|
|
; size (in byte) of the bitmap record in the map node: (494 bytes)
|
|
LenBMapMN EQU btNodesize-((NRMapNode+1)*2)-lenND
|
|
|
|
NHmapnode EQU LenBMapHdr*8 ; number of nodes in header bitmap
|
|
NMmapnode EQU LenBMapMN*8 ; number of nodes in map node bitmap
|
|
MaxRecSize EQU (btnodesize - lenND - 6)/2
|
|
|
|
;; for async file system calls issued from BTreeMgr :
|
|
DoAlloc EQU 0 ; put this back <18Dec90 #11>
|
|
DoOPEN EQU 1
|
|
DoClose EQU 2
|
|
DoRead EQU 3
|
|
DoWrite EQU 4
|
|
DoFlushFile EQU 5
|
|
DoSetEOF EQU 6 ; and adding this <18Dec90 #11>
|
|
DoMaxNum EQU DoSetEOF ; update last <18Dec90 #11>
|
|
|
|
;; BTHint definition in BTioParam:
|
|
ioBTHint1 EQU 52 ; (long) write count
|
|
ioBTHint2 EQU 56 ; (long) node number
|
|
ioBTHint3 EQU 60 ; (word) node index
|
|
ioBTHint4 EQU 62 ; (word) reserved
|
|
ioBTHint5 EQU 64 ; (long) reserved
|
|
|
|
noWrite EQU 1 ; no write permission (used by ExtIsBtree)
|
|
write EQU 0 ; ask for write permission
|
|
|
|
btADAndWait EQU 2 ; access denied and busywait for a SYNC call
|
|
|
|
;; For A9 build, use my own maxDepth <11Apr90>
|
|
ExtbtMaxDepth EQU 16 ; max tree depth <SM1>
|
|
ExtlenTPT EQU lenTPR*ExtbtMaxDepth ; length of Tree Path Table <SM1>
|
|
ExtbtVRecord EQU btVTPTable+ExtlenTPT ; record buffer <SM1> |