Commits (11)
  • Robert Sprowson's avatar
    Delete erroneous debug · d13f0444
    Robert Sprowson authored
    FSBash shouldn't stop after 65536 goes, it should continue until the drive is full or Escape pressed.
    Not tagged.
  • Jeffrey Lee's avatar
    Try harder when looking for buffer space · da5cf16c
    Jeffrey Lee authored
      s/FileCore30 - Update FindBuffer so that if it failed to find enough spare memory for the buffer (and the RMA is allowed) it will try and grow the RMA dynamic area (current code just aims to use the spare heap space without expanding the DA).
      Tested on Raspberry Pi
      Fixes "No room for buffer" error being generated in some situations, following the removal of Wimp_ClaimFreeMemory/free pool locking
    Version 3.67. Tagged as 'FileCore-3_67'
  • Robert Sprowson's avatar
    Refactor unaligned STM in old style error return · e7f8277a
    Robert Sprowson authored
    Don't rely on an STM with either of the bottom 2 bits set to store on a word aligned boundary any more.
    Fixes abort when an old style error is reported to FileCore on ARMv7.
    Spotted by Jon Abbott, ref
    Version 3.68. Tagged as 'FileCore-3_68'
  • Jeffrey Lee's avatar
    Avoid unnecessary remainder calculations · 9b4c1ccf
    Jeffrey Lee authored
      s/BigDirCode, s/Identify - Avoid unnecessary remainder calculation in DivRem macro
      Tested on Cortex-A15
    Version 3.69. Tagged as 'FileCore-3_69'
  • Robert Sprowson's avatar
    Build fix · 74902d1e
    Robert Sprowson authored
    Module_Title->Module_TitleStr from Kernel-5_54.
    Version 3.70. Tagged as 'FileCore-3_70'
  • Robert Sprowson's avatar
    Fix for nonsense sector offsets (and abort) with *Map of old map disc · 8f7b5469
    Robert Sprowson authored
    For new map discs NextFs returns the address of the map zone in R10, which was being used to lookup entries in the disc record. However, for old map discs R10 is a multiple-of-3 offset into the free space map. This was aborting on the 2nd call due to an unaligned LDR at line 3205.
    Even on platforms that permit unaligned loads the printed results were wrong because the disc address for an old map disc is in bytes but the value printed out was shifted up by Log2SectorSize. A DD floppy disc could have free space fragments starting at 7M - nonsense.
    Fixed by checking the DiscFlags and only reading from the map zone/sector shifting for new map.
    Tested with an ADFS-L floppy disc.
    Version 3.71. Tagged as 'FileCore-3_71'
  • Robert Sprowson's avatar
    [415] Report dir full when hitting dir size limit · 9361961f
    Robert Sprowson authored
    FileCore would allow objects to be added to BigDir extensible directories until eventually failing and leaving an unopenable broken directory behind.
    In fact, the on disc directory was sound, but after updating the parent in GrowBigDir it would reload the child into the dir cache with FindDir, FindDir called SanityCheckBigDirHeader which was rejecting BigDir's of exactly 4MB that was created moments earlier.
    Now, during the initial attempt grow, a check is made for exceeding BigDirMaxSize before trying to enlarge the dynamic area (while it would be possible to translate the error from maxing out the dynamic area, there could be situations where there genuinely isn't enough memory to enlarge the area) and a more polite "Dir full" error returned.
    Tested with an initially empty drive (so the dynamic area must grow) and with one that previously created a maximal directory (dynamic area already large enough).
    Also tightened up a couple of places loading byte wide variables using LDR, relying on the modulo 31 properties of LSR/LSL, when we can simply load the value as a byte for the same cost.
    Version 3.72. Tagged as 'FileCore-3_72'
  • ROOL's avatar
    Fix to sort dirs correctly when no territory is loaded · 549666f4
    ROOL authored
      FileCore is defined as a case insensitive FS (ie. MyFile can't coexist in the same directory as mYfILE).
      Prior to a territory being selected the BigDir binary chop sort would (via the Internat_UpperCase macro) abandon a directory search once it mismatched, and so would never find !Territory in order to select the territory in the first place.
      Have Internat_UpperCase use ASCII uppercase until that time.
      Based on a submission from Colin Granville, with modifications.
    Version 3.73. Tagged as 'FileCore-3_73'
  • Robert Sprowson's avatar
    Fixes in BigSectors option · 5a07a9e0
    Robert Sprowson authored
    Previous testing with RAMFS was limited by the size of RAM disc, and hence complexity of layout, meaning some cases with BigSectors were missed.
    FileCore20.s: During mount, when loading the defect list from the boot block at &C00, take care to round down the source sector address to account for it only being aligned up to 1k sectors (but not for 2k and 4k).
    FileCore25.s: When loading the head of a BigDir (to find out its actual size) and finding it to be > 2k, skip loading the bit from 2k-4k, since that was already loaded when the head was read in, and reading it a second time offset by 2k fails the head/tail check.
    FileCore31.s: When building a table to decide which zones to compact, use FindBuffer() to get some temporary store if too large to fit into ScratchSpace.
    Identify.s: Comment updated.
    BigDirCode.s: (Unrelated) Fix for bad error pointer being passed back, due to R0 being restored on encountering an error during directory rename.
    FSBashed for 300k cycles on Titanium with an assortment of manufacturer drives, capacities, and sector sizes.
    Version 3.74. Tagged as 'FileCore-3_74'
  • Robert Sprowson's avatar
    Comments improved · bfa71eec
    Robert Sprowson authored
  • Robert Sprowson's avatar
    Increase upper range of idlen to 21 bits · 45dadad2
    Robert Sprowson authored
    When 'BigMap' support was added drive sizes were such that (see table and discussion in Doc/BigDisc/BigDiscs) an upper maximum of 19 bits for idlen was appropriate. Now that drives of 2^29 sectors are readily available (the limit of 'BigDisc' support) the idlen limit of 19 has meant the minimum object size has grown too. This change uses the remaining 2 indirect disc address bits to get a factor x4 reduction in minimum object size, at the expense of a 4x larger map.
    Defns.s: Parameterise idlen for big and small maps. Small's limit remains 15, big's limit raised from 19 to 21.
    Identify.s: When mounting, use the parameterised idlen upper limits to decide whether it's a valid disc or not.
    FileCore32.s: Adjust the BIC masks to knock out the extra 2 bits when forming the hash of the object id. Fix long standing bug updating the wrong entry in the hash table (due to LSL #2 giving 5x the entry index, rather than 3x).
    FileCore15.s: Take care not to shift b20 of idlen into C as a side effect of a flags changing opcode. An audit of FileCore showed this to be the only site where the subsequent condition code(s) depended on C.
    Tools/basic/DispMap: Updated to support BigMaps at all, previously it only worked with NewMap discs.
    Tested with an assortment of drives with FSBash for 300k cycles of scrambling for idlen = 17, 19, 20 & 21.
    Version 3.75. Tagged as 'FileCore-3_75'
......@@ -684,7 +684,6 @@ int main( int argc, char *argv[] )
if(i==65536) break;//131 wierd file x{5}PG
logprintf( "current open files are:\nHandle Name\n" );
No preview for this file type
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "3.66"
Module_Version SETA 366
Module_MajorVersion SETS "3.75"
Module_Version SETA 375
Module_MinorVersion SETS ""
Module_Date SETS "28 Mar 2015"
Module_ApplicationDate SETS "28-Mar-15"
Module_Date SETS "06 Jul 2017"
Module_ApplicationDate SETS "06-Jul-17"
Module_ComponentName SETS "FileCore"
Module_ComponentPath SETS "castle/RiscOS/Sources/FileSys/FileCore"
Module_FullVersion SETS "3.66"
Module_HelpVersion SETS "3.66 (28 Mar 2015)"
Module_FullVersion SETS "3.75"
Module_HelpVersion SETS "3.75 (06 Jul 2017)"
/* (3.66)
/* (3.75)
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
#define Module_MajorVersion_CMHG 3.66
#define Module_MajorVersion_CMHG 3.75
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 28 Mar 2015
#define Module_Date_CMHG 06 Jul 2017
#define Module_MajorVersion "3.66"
#define Module_Version 366
#define Module_MajorVersion "3.75"
#define Module_Version 375
#define Module_MinorVersion ""
#define Module_Date "28 Mar 2015"
#define Module_Date "06 Jul 2017"
#define Module_ApplicationDate "28-Mar-15"
#define Module_ApplicationDate "06-Jul-17"
#define Module_ComponentName "FileCore"
#define Module_ComponentPath "castle/RiscOS/Sources/FileSys/FileCore"
#define Module_FullVersion "3.66"
#define Module_HelpVersion "3.66 (28 Mar 2015)"
#define Module_LibraryVersionInfo "3:66"
#define Module_FullVersion "3.75"
#define Module_HelpVersion "3.75 (06 Jul 2017)"
#define Module_LibraryVersionInfo "3:75"
......@@ -116,11 +116,13 @@ SanityCheckBigDirHeader ROUT
MOVS r1, lr, LSR #22
ASSERT BigDirMaxSize = 1:SHL:22
SUB r1, lr, #1 ; can be equal to BigDirMaxSize though
MOVS r1, r1, LSR #22
[ DebugX
DLINE "Failed at BigDirSize too large"
DLINE "Failed at BigDirSize too large (or zero)"
......@@ -867,7 +869,7 @@ LookUpBigDir ROUT
DREG r4, "r4 : "
DivRem r8, lr, r9, r4 ; r8 = offset into dir
DivRem r8, lr, r9, r4, norem ; r8 = offset into dir
[ DebugXb
DREG r8, "init offset: "
......@@ -1439,7 +1441,10 @@ GrowBigDir ROUT
; first of all, ensure have enough memory for dir of required size
SUB R4, R6, R5 ; current dir size
ADD R4, R4, #BigDirMinSize ; add a bit to it
BL TryGrowDirBuf
CMP R4, #BigDirMaxSize ; clear V
MOVHI R0, #DirFullErr
BLVC TryGrowDirBuf
; loop back to here when need to move more files
......@@ -1450,8 +1455,8 @@ GrowBigDir ROUT
SUB R4, R6, R5
ADD R4, R4, #BigDirMinSize ; size required
BL DiscAddToRec ;(R3->LR) get disc record
LDR R7, [LR, #DiscRecord_Log2SectorSize] ; sector size
LDR LR, [LR, #DiscRecord_BigMap_ShareSize] ; share size
LDRB R7, [LR, #DiscRecord_Log2SectorSize] ; sector size
LDRB LR, [LR, #DiscRecord_BigMap_ShareSize] ; share size
ADD R7, R7, LR
MOV R11, #1
RSB R11, R11,R11,LSL R7
......@@ -1481,7 +1486,7 @@ GrowBigDir ROUT
TEQS R5, #0
BEQ %FT25 ;end of list marker found
MOVS R5, R5, LSR #9 ;link bits
MOVS R5, R5, LSR #9 ;link bits from word 1 bits 9-31
ADDCS R5, R5, R3, LSR #8
RSBCC R5, R5, R3, LSR #8
[ DebugXg
......@@ -2461,6 +2466,7 @@ DoOsFunRenameBigDir ROUT
BL CanBigDirShrink
BLEQ ShrinkBigDir
Pull "R0,R1,R2,R3,R4,R6,R7,PC"
......@@ -3131,7 +3131,7 @@ Map_Code ROUT
; r0 = 0 - not a new filecore disc
; r0 = 1 - big dirs, small map
; r0 = 2 - big map, small dirs, this case is only valid for IdLen=16
; r0 = 3 - bit map, big dirs
; r0 = 3 - big map, big dirs
TEQS r0, #1
baddr r0, MC4, EQ ;( start, length) new map, big directories
......@@ -3199,10 +3199,15 @@ Map_Code ROUT
[ BigDisc ; SBP: Thu 15th December 1994 - walked thru, doesn't seem
; to support >4G discs. Changed to support them.
Push "R1,R2"
LDR R1, [R10, #ZoneHead+DiscRecord_BigMap_DiscSize2] ; discsize2 field
BL DiscAddToRec ;(R3->LR)
LDRB R1, [LR, #DiscFlags]
TSTS R1, #OldMapFlag
BNE %FT18 ; old map, indirect disc addresses are in bytes already
LDR R1, [LR, #DiscRecord_BigMap_DiscSize2]
LDRB LR, [LR, #DiscRecord_Log2SectorSize]
BEQ %FT18 ; small disc
LDRB LR,[R10,#ZoneHead+DiscRecord_Log2SectorSize] ; sector size
RSB LR, LR, #32
......@@ -3221,13 +3226,7 @@ Map_Code ROUT
SUBS R0, R0, #1
MOV R0, R1
BL PutHex2
B %FT19
; here when small disc
LDRB LR,[R10,#ZoneHead+DiscRecord_Log2SectorSize] ; sector size
BL PutHex2
; here when finished address and want to do length
......@@ -3553,7 +3552,7 @@ Verify_Code ROUT
MOV r9,r0
BL MapPtrToDiscAdd
SUB r4,r0,r2
LDR lr,[r10,#ZoneHead+DiscRecord_Log2SectorSize]
LDRB lr,[r10,#ZoneHead+DiscRecord_Log2SectorSize]
MOV r4,r4,LSL lr
MOV r0,r9
CMP r4,#1024*1024*1024
......@@ -182,7 +182,12 @@ DrvsFsMap aw 4 ;ptr to free space maps
BadFs bit 31 ;set if corrupt on disc
EmptyFs bit 30 ;set if FS map buffer empty for old maps
FsMapMaxSize * 4*1024*1024
FsMapMaxObjects * 1:SHL:MaxIdLenBigMap
FsMapMinObjBits * MaxIdLenBigMap+1
FsMapZoneSpareBits * 64*8192 ; a lavish ZoneSpare and NZones value
; only relevant in the maximal map case
FsMapMaxBits * (FsMapMinObjBits * FsMapMaxObjects) + FsMapZoneSpareBits
FsMapMaxSize * FsMapMaxBits:SHR:3
[ DynamicMaps
MemErrorFs bit 29 ;set if failed to load FSmap due to errors with dynamic areas
NewHiFsBits * BadFs :OR: EmptyFs
......@@ -259,6 +264,8 @@ Check1 # 1 ;checksum on sector 1
; New map
MaxFreeLinkBits * 15 ; Though 'BigMaps' extend this limit
MaxIdLenSmlMap * 15
MaxIdLenBigMap * 21
ZoneDiscRecSz * 60 ;reserve additional bytes
Zone0Bits * ZoneDiscRecSz*8
......@@ -433,6 +433,7 @@ GenIndDiscOp
DREG r3," disc address is "
Pull "r0"
AND r3, r3, #DiscBits ;with IdLen=21 be careful to not set C during TEQ
TEQ lr, r3, LSR #(32-3)
......@@ -776,8 +776,10 @@ MountDiscOnDrive ROUT
ASSERT DiscRecord_DiscName = DiscRecord_DiscId + 2
STR lr, [r5, #DiscRecord_DiscId]
[ BigDisc
; DiscSize2
STR lr, [r5,#DiscRecord_BigMap_DiscSize2]
[ BigShare
; ShareSize
STR lr, [r5,#DiscRecord_BigMap_ShareSize]
......@@ -1798,11 +1800,16 @@ Mount
MOV r2, #DefectListDiscAdd
[ BigSectors
DefectListDiscAligned * (DefectListDiscAdd:SHR:12):SHL:12 ; Round DLDA down to nearest whole sector
DefectListDiscAligned * (DefectListDiscAdd:SHR:10):SHL:10 ; Round DLDA down to nearest whole sector
MOV r2, #DefectListDiscAligned
ORR r2, r2, r1, ASL #(32-3)
EOR r2, r2, #bit31
MOV r3, #ScratchSpace
MOV r4, #SzDefectList
LDR r4, =DefectListDiscAdd - DefectListDiscAligned + SzDefectList
[ DebugL
......@@ -1838,12 +1845,14 @@ Mount
Push "r0,r1"
MOV r0, #ScratchSpace
ADD r0, r0, #DefectListDiscAdd - DefectListDiscAligned
MOV r1, #SzDefectList
BL CheckSum
; Pick up heads/sectorsize/secspertrk/density/lowsector/DiscSize from read block
MOV r4, #ScratchSpace
ADD r4, r4, #DefectListDiscAdd - DefectListDiscAligned
ADD r4, r4, #DefectStruc
; Density <= DensityOctal
......@@ -1864,11 +1873,15 @@ Mount
STRB lr, [r5, #DiscRecord_SecsPerTrk]
; 256 <= SectorSize <= 1024
; 256 <= SectorSize <= upper limit
LDRB lr, [r4, #DiscRecord_Log2SectorSize]
CMP lr, #8
CMP lr, #10
[ BigSectors
CMP lr, #12 ; upper limit 4k
CMP lr, #10 ; upper limit 1k
STRB lr, [r5, #DiscRecord_Log2SectorSize]
......@@ -217,25 +217,13 @@ FindDirCommon
MOV R7, R3 ;save dir disc address
MOV R8, R5 ;save dir buffer ptr
[ Debug6
[ BigDir
CMP R4, #0
DREG R5, "Going to read dir to start, end:",cc
DREG R6, ","
[ BigDir
[ BigDir
; if it's big dir, then things get a lil' harder
CMP R4, #0
MOV R4, #NewDirSize ; get the first 2048 bytes
MOV R4, #BigDirMinSize ; get the first 2048 bytes
ADD r6,r4,r5 ; end
......@@ -278,7 +266,16 @@ FindDirCommon
MOV r5, #NewDirSize ; start offset
MOV r5, #BigDirMinSize ; start offset
[ BigSectors
MOV lr, r7, LSR #(32-3)
DiscRecPtr lr, lr
LDRB lr, [lr, #DiscRecord_Log2SectorSize]
MOV r5, r5, LSR lr
MOV r5, r5, LSL lr ; round down to nearest sector for DiscOp
MOV r3, r3, LSR lr
MOV r3, r3, LSL lr ; round dir buf offset similarly
SUBS r4, r4, r5 ; amount of data to read
......@@ -301,6 +298,11 @@ FindDirCommon
[ Debug6
DREG R5, "Going to read dir to start, end:",cc
DREG R6, ","
MOV R2, R3
MOV R3, R5
......@@ -346,6 +346,53 @@ FindBuffer ROUT
; With modern kernels not supporting free pool locking, our original
; tactic of just claiming free space without actively growing DAs isn't
; going to work, because we no longer have the free pool to fall back on
; as a source of 'infinite' free memory.
; So if we've failed to find enough free space, and claiming from the
; RMA is allowed, try growing the RMA to be large enough and then give
; it another chance.
CMP R11, R5 ;failed to get min length
CMPLO R9, #1 ;and haven't claimed any yet
TST R4, #1 :SHL: UseRmaHeap ;and RMA available
; Try and limit max claim to 1MB so that we don't completely empty the
; free pool. I.e. claim max(min(1MB,max_length),min_length)
CMP R6, #1 :SHL: 20
MOVHS R1, #1 :SHL: 20
CMP R1, R5
; Round up to size multiple
ADD R1, R1, R7
BIC R1, R1, R7
; Add safety net to ensure background claimants have a little bit of
; free memory to work with
ADD R1, R1, #4096
; Grow dynamic area (will probably leave us with more space than we
; need, but will avoid us claiming all the spare heap space and causing
; issues for background claimants)
MOV R0, #1
[ DebugD
DREG R1, "trying to grow RMA by "
SWI XOS_ChangeDynamicArea
[ DebugD
DREG R1, "managed to grow RMA by "
; Check RMA again if any grow was performed
CMP R1, #0
MOV R0, #ModHandReason_RMADesc
BL OnlyXOS_Module ;(R0->R0,R2,R3,V)
SUBS r2, r2, #2048
MOVGT R0, #UseRmaHeap
TSTS R4, #DiscOp_Op_ScatterList_Flag
TEQS R11,#0 ;scatter case, claim any
......@@ -444,7 +491,7 @@ Sink
MOV R0, #FSControl_StartApplication ; Start parent module up as application
baddr R1, anull ; command tail
LDR R2, ParentBase ; CAO pointer
LDR R3, [R2, #Module_Title] ; command name
LDR R3, [R2, #Module_TitleStr] ; command name
BL OnlyXOS_FSControl
MOV R1, #AppSpaceStart
BIC R4, R4, #1 :SHL: UseApplicArea
......@@ -1310,8 +1357,7 @@ InternalFromParent
; Error occurred - let's convert (if necessary) from old scheme to new.
LDR LR, FS_Flags
TSTS LR, #CreateFlag_NewErrorSupport
Pull "R1,PC",NE
BNE %FT95 ; Child returns new style errors
TSTS R0, #DiscErrorBit
TSTS R0, #ExternalErrorBit
......@@ -1347,9 +1393,9 @@ InternalFromParent
MOV R4, R4, LSL R3
ASSERT NewDiscErrorBit < bit2 ; STM ignores bits 0 and 1 :)
ADR R0, ConvDiscErr+NewDiscErrorBit
STMIA R0, {R2, R4, LR}
ADR R0, ConvDiscErr
STMIA R0, {R2, R4, LR} ; Fabricated new style error
ORR R0, R0, #NewDiscErrorBit
Pull "R2-R4"
RestPSR R1,,f
......@@ -122,14 +122,14 @@ NewClaimFree ROUT
TEQS R5, #0
BEQ %FT06 ;end of list marker found
MOVS R5, R5, LSR #9 ;link bits
MOVS R5, R5, LSR #9 ;link bits from word 1 bits 9-31
LDRB R4, [R8] ;index in dir
LDRB R0, [R8,#1] ;sharing offset in frag
LDR R5, [R8],#4
TEQS R5, #0
BEQ %FT06 ;end of list marker found
MOVS R5, R5, LSR #17 ;link bits
MOVS R5, R5, LSR #17 ;link bits from bits 17-31
ADDCS R5, R5, R3, LSR #8
RSBCC R5, R5, R3, LSR #8
......@@ -404,12 +404,30 @@ MultiBit bit 30
BL Log2AllocBits ;(->LR)
ASSERT ?ScratchSpace>=16*K
MOV R0, #ScratchSpace
LDRB R1, [R10,#ZoneHead+DiscRecord_Log2SectorSize]
MOV R5, #8*2
[ BigSectors
CMP R1, #?ScratchSpace
MOVLS R0, #ScratchSpace
BLS %FT28 ;table can fit in scratch space
Push "R2-R3"
MOV R3, R1 ;search for a buffer (not ScratchSpace, of course)
MOV R2, R1
MOV R0, #(1:SHL:UseSpareScreen) :OR: (1:SHL:UseWimpFree) :OR: \
(1:SHL:UseRmaHeap) :OR: (1:SHL:UseSysHeap)
BL FindBuffer ;(R0-R3->R0-R3,V)
Pull "R2-R3"
ASSERT ?ScratchSpace>=16*K
MOV R0, #ScratchSpace
BL ZeroRam ;init tables of gap frequencies
ADD R1, R0, R1,LSR #1
MOV R5, #0 ;init total gaps between ptrs
......@@ -432,9 +450,11 @@ PreFirstGap # 4
FirstGap # 4
LastGap # 4
LastSize # 4
FoundBuffer # 4
AllocWork2 # 0
Push "R3, R6-R12" ;save dir & reserve 28 bytes stack space
Push "R0" ;save buffer (for ReturnBuffer)
Push "R3,R6-R12" ;save dir & reserve stack space
BL NextFree ;(R10,R11->R9, R11,Z,C)
[ BigMaps
BLNE FreeRdLenBits ;(R10,R11->R7)
......@@ -528,7 +548,8 @@ AllocWork2 # 0
42 ;IF R9 short of total
MOV R7, R9, LSR R2
SUB LR, R1, R7
CMPS LR, #ScratchSpace
LDR R0, FoundBuffer
LDRGTB R0, [R1, R7]
TEQGTS R0, LR ;AND unused gap of size R9 exists (GT preserves N=V=0)
......@@ -572,7 +593,7 @@ AllocWork2 # 0
LDR R0, FirstGap+(2*4) ;calc map ptr diff+zone diff*2^24
LDR R1, LastGap+(2*4)
SUB R9, R1, R0
LDR R3, [R10,#ZoneHead+DiscRecord_Log2SectorSize]
LDRB R3, [R10,#ZoneHead+DiscRecord_Log2SectorSize]
ADD R3, R3, #3 ;log2 bits in a zone
MOV R0, R0, LSR R3
MOV R1, R1, LSR R3
......@@ -723,6 +744,11 @@ AllocWork2 # 0
MOV R0, #0
[ BigSectors
LDR LR, FoundBuffer ;if FindBuffer used, free it
TEQ LR, #ScratchSpace
BLNE ReturnBuffer
ADD SP, SP, #:INDEX:AllocWork2
B %FT93
......@@ -730,6 +756,11 @@ AllocWork2 # 0
BIC R6, R6, #WasteBit
ADD R1, R4, R6 ;gap length in map bits
LDR R6, PreBestPtr
[ BigSectors
LDR LR, FoundBuffer ;if FindBuffer used, free it
TEQ LR, #ScratchSpace
BLNE ReturnBuffer
ADD SP, SP, #:INDEX:AllocWork2
BL DefFindIdThenClaim ;(R3,R4,R6,R10->R2,R5,R11)
......@@ -64,9 +64,9 @@ PostId * 12
PostFrag * 16 ;map offset of start of fragment after gap
GapOff * 20 ;map offset of start of gap
JoinNext * 24
GapEntrySz * 28
GapEntrySz * 28
GapFrags # MaxGaps*GapEntrySz
;entry of 7 words for each gap, used to choose which fragment to move with
;entry of 8 words for each gap, used to choose which fragment to move with
;eventual aim of causing two gaps to join
;IF JoinNext<=2 this gap can't be joined to next gap by moving fragments to
;earlier gap since it is either first/last gap or defects separate them
......@@ -184,8 +184,8 @@ CompactZone ROUT
BLS %FT14 ;if defect or out of zone
[ BigMaps
ASSERT IdHashLen=6*K
BIC R0, R5, #&FF000
BIC R0, R0, # &800
BIC R0, R5, #&3F0000
BIC R0, R0, # &F800
ADD R0, R0, R0, LSL #1 ; multiply by three, to address entry in table
ADD R0, R0, #IdHash
LDRB R1, [R0,#0] ; then get first value
......@@ -270,9 +270,9 @@ CompactZone ROUT
[ BigMaps
ASSERT IdHashLen=6*K
BIC R0, R8, #&FF000
BIC R0, R0, #&00800
ADD R0, R0, R0, LSL #2
BIC R0, R8, #&3F0000
BIC R0, R0, #&00F800
ADD R0, R0, R0, LSL #1
ADD R0, R0, #IdHash
LDRB R1, [R0]
LDRB LR, [R0, #1]
......@@ -342,7 +342,7 @@ CompactZone ROUT
LDRB LR, [R5], #1
ORR R3, R3, LR, LSL #16
LDR R3, [R5],#4
......@@ -384,11 +384,11 @@ CompactZone ROUT
Stacked1 * 10*4
Push "R1-R5,R7-R9,R11,LR"
[ BigMaps
MOV R3, R3, LSL #(32-19) ;mask to bottom 19 bits
MOV R3, R3, LSR #(32-19)
MOV R3, R3, LSL #(32-MaxIdLenBigMap) ;mask id bits
MOV R3, R3, LSR #(32-MaxIdLenBigMap)
MOV R3, R3, LSL #17 ;mask to bottom 15 bits
MOV R3, R3, LSR #17
MOV R3, R3, LSL #(32-MaxIdLenSmlMap) ;mask id bits
MOV R3, R3, LSR #(32-MaxIdLenSmlMap)
MOV R7, #GapFrags
......@@ -1773,7 +1773,7 @@ DoCompMoves ROUT
Pull "R0-R2,R4-R11,PC"
| ; Optimised version of DoCompMoves below
; ===========
; DoCompMoves
......@@ -1825,11 +1825,11 @@ DoCompMoves ROUT
LDR R3, [R3,#DiscRecord_Root]
MOV R4, R9
[ BigDisc
; get the zone base address from the first move, and squirrel
; it away. Also place it in a spare register to help with
; generation of offsets.
[ BigDisc
LDR R11,[R4,#MoveDest] ; get a move address
BL MapPtrToZoneBase ; get base address of zone
ADR LR, DoCompZoneBase ;
......@@ -486,7 +486,7 @@ DoOsFileCreateDir ROUT
BVS %FT99 ; don't yet know how to grow big dirs!
BL BeforeAlterFsMap ; (R3->R0,V)
MOV R10, #NewDirSize ; minimum size of a big dir is NewDirSize
MOV R10, #BigDirMinSize ; minimum size of a big dir
BL ClaimFreeSpace ; (R3,R10->R0,R2,V)
BVS %FT95 ; couldn't claim free space
BL TryCacheDirBuf ; (R3) we'll create dir in the dir buffer
......@@ -632,8 +632,7 @@ SaveCreate ROUT
BL TestBigDir ;test if it's a bigdir
BL IsBigDirFull ;(R1,R3,R5->R0,V)
BVC %FT02 ;dir has space
BL GrowBigDir ;try to grow the directory
BLVS GrowBigDir ;try to grow the directory if no space
B %FT02
BL IsDirFull ;(R3,R5,R6->R0,V)
......@@ -730,23 +730,23 @@ SanityCheckEDiscRecord ROUT
[ BigMaps
; Check 0 < idlen < 20
; Check idlen <= MaxIdLenBigMap
LDRB r0, [sp, #DiscRecord_IdLen]
CMP r0, #19
CMP r0, #MaxIdLenBigMap
[ DebugL
DLINE "Failed on idlen >= 20"
DLINE "Failed on idlen valid for big map"
; Check 0 < idlen < 16
; Check idlen <= MaxIdLenSmlMap
LDRB r0, [sp, #DiscRecord_IdLen]
CMP r0, #15
CMP r0, #MaxIdLenSmlMap
[ DebugL
DLINE "Failed on idlen >= 16"
DLINE "Failed on idlen valid for small map"
......@@ -769,7 +769,7 @@ SanityCheckEDiscRecord ROUT
SUB r1, r1, r0, LSR #16 ; map bits per sector
LDRB r0, [sp, #DiscRecord_IdLen]
ADD r0, r0, #1
DivRem r2, r1, r0, lr ; r2 = max objects per zone
DivRem r2, r1, r0, lr, norem ; r2 = max objects per zone
[ BigMaps
LDRB r0, [sp, #DiscRecord_NZones]
LDRB r1, [sp, #DiscRecord_BigMap_NZones2] ; r1 is the target for the MUL below
......@@ -801,8 +801,8 @@ SanityCheckEDiscRecord ROUT
[ BigMaps
; if BigMaps then idlen can be more than MaxFreeLink, so test against
; MaxFreeLink (we're being paranoid here, since maximum sector is 1024
; bytes, needing 13 link bits)
; MaxFreeLink (we're being paranoid here, since maximum sector is 4096
; bytes, needing 15 link bits)
CMP r2, #MaxFreeLinkBits
MOVHI r2, #MaxFreeLinkBits
......@@ -833,8 +833,8 @@ SanityCheckEDiscRecord ROUT
[ BigMaps
LDRB r1, [sp, #DiscRecord_IdLen]
CMP r1, #15
CMP r1, #MaxIdLenSmlMap
BHI %FT10 ; tests for BigMap
LDRB r1, [sp, #DiscRecord_BigDir_DiscVersion]
TEQS r1, #0
......@@ -382,8 +382,7 @@ InitEntry ROUT ; NO REENTRANCY CHECK NEEDED
[ DynamicMaps
; if we're using dynamic areas for the free space maps, then the
; map for each configured drive is created as a dynamic area, with
; a maximum size of 4096K
; map for each configured drive is created as a dynamic area
SUB SP, SP, #256+4
......@@ -635,7 +634,7 @@ DieEntry
; Delete the parent of this incarnation (eg ADFS)
LDR R1, ParentBase
LDR R0, [R1,#Module_Title]
LDR R0, [R1,#Module_TitleStr]
ADD R1, R1, R0
MOV R0, #ModHandReason_Delete
SWI XOS_Module
......@@ -223,6 +223,10 @@ CaseConvertType SETS "$Type"
ASSERT CaseConvertType = "Upper"
CMP $UR, #BadPtr
LDRNEB $Reg, [$UR, $Reg]
ASCII_UpperCase $Reg, $UR
MOV $UR, #BadPtr ; Restore $UR after use as a temp register