diff --git a/s/MemMap2 b/s/MemMap2 index 19424f5cbdc1e67bd85c1a8451b6ccae3e734f55..8c8668345f2f5e5931011cbd4e72ab05847fa9a9 100644 --- a/s/MemMap2 +++ b/s/MemMap2 @@ -15,64 +15,37 @@ ; in: r0 = logical address where page is now -GetPageFlagsForR0IntoR6 Entry "R0-R2, R4-R5, R7" -; -; code from MoveCAMatR0toR3 -; - LDR r5, =L2PT - ADD r4, r5, r0, LSR #10 ; r4 -> L2PT for log addr r0 - MOV r2, r4, LSR #12 - LDR r2, [r5, r2, LSL #2] ; r2 = L2PT entry for r4 - TST r2, #3 ; if no page there - BEQ %FT90 ; then cam corrupt - - LDR r4, [r4] ; r4 = L2PT entry for r0 - TST r4, #3 ; check entry is valid too - BEQ %FT91 - MOV r4, r4, LSR #12 ; r4 = phys addr >> 12 - - LDR r2, =ZeroPage - LDR r6, [r2, #MaxCamEntry] - ADD r5, r2, #PhysRamTable - [ ZeroPage <> 0 - MOV r2, #0 - ] -10 - CMP r2, r6 ; if page we've got to is > max - BHI %FT92 ; then corrupt - LDMIA r5!, {r7, lr} ; get phys.addr, size - SUB r7, r4, r7, LSR #12 ; number of pages into this bank - CMP r7, lr, LSR #12 ; if too many - ADDCS r2, r2, lr, LSR #12 ; then advance physical page no. - BCS %BT10 ; and loop - - ADD r2, r2, r7 ; add on number of pages within bank -; -; code from BangCamUpdate -; - LDR r1, =ZeroPage - LDR r1, [r1, #CamEntriesPointer] - ADD r1, r1, r2, LSL #CAM_EntrySizeLog2 ; point at cam entry (logaddr, PPL) - ASSERT CAM_LogAddr=0 - ASSERT CAM_PageFlags=4 - LDMIA r1, {r0, r6} ; r0 = current logaddress, r6 = current PPL +GetPageFlagsForR0IntoR6 Entry "r3-r5,r8-r11" + MOV r4, r0 + BL logical_to_physical + BCS %FT91 + LDR r4, =ZeroPage + LDR r7, [r4, #MaxCamEntry] + BL physical_to_ppn + BCS %FT92 + ; r3 = page number + LDR r4, [r4, #CamEntriesPointer] + ADD r4, r4, r3, LSL #CAM_EntrySizeLog2 + LDR r6, [r4, #CAM_PageFlags] EXIT 90 - ADR lr, NoL2ForPageBeingRemovedError ; NB don't corrupt r0 yet - we need that in block as evidence + ADR r11, NoL2ForPageBeingRemovedError ; NB don't corrupt r0 yet - we need that in block as evidence 95 - STR lr, [sp] ; update returned r0 + Push "r1" BL StoreDebugRegs + Pull "r1" + MOV r0, r11 PullEnv ; seriously broken memory SETV MOV pc, lr 91 - ADR lr, PageBeingRemovedNotPresentError + ADR r11, PageBeingRemovedNotPresentError B %BT95 92 - ADR lr, PhysicalAddressNotFoundError + ADR r11, PhysicalAddressNotFoundError B %BT95 ; *********************************************************************************** @@ -112,35 +85,21 @@ MovePageAtR0ToR1WithAccessR6ReturnPageNumber Entry "r3-r5,r11" ; r0,r1,r3,r6-r12 preserved ; r4,r5 corrupted -MoveCAMatR0toR3 Entry "r0,r1,r6,r7" - LDR r5, =L2PT - ADD r4, r5, r0, LSR #10 ; r4 -> L2PT for log addr r0 - MOV r2, r4, LSR #12 - LDR r2, [r5, r2, LSL #2] ; r2 = L2PT entry for r4 - TST r2, #3 ; if no page there - BEQ %FT90 ; then cam corrupt - - LDR r4, [r4] ; r4 = L2PT entry for r0 - TST r4, #3 ; check entry is valid too - BEQ %FT91 - MOV r4, r4, LSR #12 ; r4 = phys addr >> 12 - - LDR r2, =ZeroPage - LDR r6, [r2, #MaxCamEntry] - ADD r5, r2, #PhysRamTable - [ ZeroPage <> 0 - MOV r2, #0 - ] -10 - CMP r2, r6 ; if page we've got to is > max - BHI %FT92 ; then corrupt - LDMIA r5!, {r7, lr} ; get phys.addr, size - SUB r7, r4, r7, LSR #12 ; number of pages into this bank - CMP r7, lr, LSR #12 ; if too many - ADDCS r2, r2, lr, LSR #12 ; then advance physical page no. - BCS %BT10 ; and loop - - ADD r2, r2, r7 ; add on number of pages within bank +MoveCAMatR0toR3 + Entry "r0,r1,r6,r7" + Push "r3,r8-r11" + ; Get page number of R0, so we know what we're dealing with + MOV r4, r0 + BL logical_to_physical + BCS %FT91 + LDR r4, =ZeroPage + LDR r7, [r4, #MaxCamEntry] + BL physical_to_ppn + ; r3 = page number + MOVCC r2, r3 + Pull "r3,r8-r11" + BCS %FT92 + ; r2, r3, r9, r11 are ready for BangCamUpdate BL BangCamUpdate CLRV EXIT @@ -155,6 +114,7 @@ MoveCAMatR0toR3 Entry "r0,r1,r6,r7" MOV pc, lr 91 + Pull "r3,r8-r11" ADR lr, PageBeingRemovedNotPresentError B %BT95