Commit b60d3a70 authored by Jeffrey Lee's avatar Jeffrey Lee Committed by ROOL
Browse files

OS_FindMemMapEntries now uses logical_to_physical

Reduce the number of routines which directly examine the page tables, by
changing OS_FindMemMapEntries to use logical_to_physical.
parent ca69793c
......@@ -466,88 +466,53 @@ FindMemMapEntries_Code ROUT
; Code for expanded CAM map version
Push "r0, r9, r14"
Push "r0, r3-r5,r7-r9, r14"
LDR r14, =ZeroPage
LDR r9, [r14, #MaxCamEntry]
LDR r14, [r14, #CamEntriesPointer] ; r14 -> start of cam map
ADD r9, r14, r9, LSL #CAM_EntrySizeLog2 ; r9 -> first word of last entry in cam map
LDR r7, [r14, #MaxCamEntry]
LDR r12, [r14, #CamEntriesPointer] ; r12 -> start of cam map
10
LDR r10, [r0, #0] ; r10 = guess page number (or -1)
CMP r10, #-1 ; if -1 then end of list
Pull "r0, r9, r14", EQ ; so restore registers
LDR r3, [r0, #0] ; r3 = guess page number (or -1)
CMP r3, #-1 ; if -1 then end of list
Pull "r0, r3-r5,r7-r9, r14", EQ ; so restore registers
ExitSWIHandler EQ ; and exit
LDR r11, [r0, #4] ; r11 = logical address
LDR r4, [r0, #4] ; r4 = logical address
[ AMB_LazyMapIn
;may need AMB to make mapping honest (as if not lazy), if page is in currently mapped app
Push "r0, lr"
MOV r0, r11 ; logical address to make honest
Push "r0"
MOV r0, r4 ; logical address to make honest
BL AMB_MakeHonestLA ; note, quickly dismisses non app space addresses
Pull "r0, lr"
Pull "r0"
]
ADD r10, r14, r10, LSL #CAM_EntrySizeLog2 ; form address with 'guess' page
CMP r10, r9 ; if off end of CAM
CMP r3, r7 ; if off end of CAM
BHI %FT20 ; then don't try to use the guess
LDR r12, [r10, #CAM_LogAddr] ; load address from guessed page
TEQ r11, r12 ; compare address
ADD r10, r12, r3, LSL #CAM_EntrySizeLog2
LDR lr, [r10, #CAM_LogAddr] ; load address from guessed page
TEQ r4, lr ; compare address
BEQ %FT60 ; if equal, then guessed page was OK
20
; for now, cheat by looking in L2PT, to see if we can speed things up
Push "r5-r8" ; need some registers here!
LDR r10, =L2PT
MOV r8, r11, LSR #12 ; r8 = logical page number
ADD r8, r10, r8, LSL #2 ; r8 -> L2PT entry for log.addr
MOV r5, r8, LSR #12 ; r5 = page offset to L2PT entry for log.addr
LDR r5, [r10, r5, LSL #2] ; r5 = L2PT entry for L2PT entry for log.addr
TST r5, #3 ; if page not there
SUBEQ r10, r9, #CAM_EntrySize ; then invalid page so go from last one
BEQ %FT45
LDR r8, [r8] ; r8 = L2PT entry for log.addr
MOV r8, r8, LSR #12 ; r8 = physaddr / 4K
LDR r5, =ZeroPage+PhysRamTable
SUB r10, r14, #CAM_EntrySize
30
CMP r10, r9 ; have we run out of RAM banks?
BCS %FT40 ; then fail
LDMIA r5!, {r6,r7} ; load next address, size
SUB r6, r8, r6, LSR #12 ; number of pages into this bank
CMP r6, r7, LSR #12 ; if more than there are
ASSERT CAM_EntrySizeLog2 <= 16
BICCS r7, r7, #&F00
ADDCS r10, r10, r7, LSR #12-CAM_EntrySizeLog2 ; then advance CAM entry position
BCS %BT30 ; and loop to next bank
ADD r10, r10, r6, LSL #CAM_EntrySizeLog2 ; advance by 2 words for each page in this bank
40
SUBCS r10, r9, #CAM_EntrySize ; search from last one, to fail quickly (if CS)
45
Pull "r5-r8"
50
CMP r10, r9 ; if not just done last one,
ASSERT CAM_LogAddr=0
LDRNE r12, [r10, #CAM_EntrySize]! ; then get logical address
TEQNE r11, r12 ; compare address
BNE %BT50 ; loop if not same and not at end
; either found page or run out of pages
TEQ r11, r12 ; see if last one matched
; (we always load at least one!)
; use the page tables to perform a logical -> physical (-> page no.) conversion
BL logical_to_physical ; r5 corrupt, r8,r9 = phys
BLCC physical_to_ppn ; r5,r10-r11 corrupt, r3 = page
; If we found a page, double-check that the logical address is a match
; (means we can never find the second mapping of doubly-mapped regions
; - is that intentional?)
ADDCC r10, r12, r3, LSL #CAM_EntrySizeLog2
LDRCC lr, [r10, #CAM_LogAddr]
SUBCS lr, r4, #1
TEQ r4, lr ; page found?
60
LDREQ r12, [r10, #CAM_PageFlags] ; if match, then r12 = PPL
SUBEQ r10, r10, r14 ; and page number=(r10-r14)>>3
MOVEQ r10, r10, LSR #CAM_EntrySizeLog2
LDREQ lr, [r10, #CAM_PageFlags] ; if match, then lr = PPL
MOVNE r10, #-1 ; else unknown page number indicator
MOVNE r12, #3 ; and PPL=3 (no user access)
MOVNE r3, #-1 ; else unknown page number indicator
MOVNE lr, #3 ; and PPL=3 (no user access)
STMIA r0!, {r10-r12} ; store all 3 words
STMIA r0!, {r3,r4,lr} ; store all 3 words
B %BT10 ; and go back for another one
;**************************************************************************
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment