mirror of
https://github.com/elliotnunn/mac-rom.git
synced 2025-01-01 11:29:27 +00:00
233 lines
9.1 KiB
Plaintext
233 lines
9.1 KiB
Plaintext
;-----------------------------------------------------------------------------------
|
|
;
|
|
; File: GetReal.a
|
|
;
|
|
; Written by: Carl C. Hewitt
|
|
;
|
|
; Copyright: © 1991-1993 by Apple Computer, Inc., all rights reserved.
|
|
;
|
|
; Change History (most recent first):
|
|
;
|
|
; <SM10> 10/14/93 pdw (CCH) Split PowerPC EDiskProtect code into seperate routine.
|
|
; Added EDisk support for PDM.
|
|
; <SM9> 6/21/93 kc Fix vm test in GetMMUInfo.
|
|
; <SM8> 6/14/93 SAM Clarified the comments related to the isVMRunnning check in
|
|
; GetMMUInfo.
|
|
; <SM7> 6/14/93 kc Roll in Ludwig.
|
|
; <LW5> 4/23/93 MR Add code to check VMInstalled flag inside VM's globals. This
|
|
; fixes bug #1076279. Reviewed by Clinton Bauder
|
|
; <LW4> 3/25/93 MR Remove GetMMUInfoQ. Instead put a hack inside VM to set
|
|
; VMGlobals($B78) to -1 when calling GetPhysical at VM
|
|
; initialization time.
|
|
; <LW3> 3/16/93 MR Created GetMMUInfoQ which is identical to GetMMUInfo except it
|
|
; does not check for VM. This is an EMERGENCY FIX for the
|
|
; RAMDISK/VM bug that broke Ludwig B3. Will be merged in the
|
|
; future with GetMMUInfo. GetMMUInfoQ is only called by
|
|
; MemoryDispatch routines (i.e. LockMemory,GetPhysical etc).
|
|
; <SM6> 2/23/93 kc Fix bug introduced in last check in.
|
|
; <SM5> 2/20/93 SAM Added LogicalToPhysical code for EMMU machines. Placed a few
|
|
; Supports24Bit's around some things. Removed a trap call or two
|
|
; where possible. If it works at all, it should be faster for
|
|
; everyone.
|
|
; <SM4> 2/5/93 SAM Adjusted PDMs temporary Log2Phys. Removed several Gestalt calls
|
|
; from GetReal. Removed all the 24bit stuff for ROM builds of
|
|
; this file in GetReal.
|
|
; <SM3> 10/18/92 CCH Fixed EDiskProtect to abort if an MMU is not present.
|
|
; <SM2> 5/17/92 kc Roll in Horror sources.
|
|
; <SM0> 5/17/92 kc Fix bug in translate040. We were puting phisical address into the wrong register.
|
|
; <H3> 12/12/91 CCH Changed method of checking for VM in GetMMUInfo, since VM calls
|
|
; GetPageDesc after it sets up it's globals, but before taking
|
|
; over the MMU.
|
|
; <H2> 11/14/91 jmp (CCH) Removed redundant physical-to-logical conversion in
|
|
; translate030 routine. Made EDiskProtect return a result. Also
|
|
; removed Gestalt calls in favor of checks of lo-mem. This is
|
|
; necessary since, in ROM, this routine can get called before
|
|
; Gestalt is.
|
|
; <SM2> 2/12/92 JSM Moved this file to MMU folder, keeping all the old revisions;
|
|
; remove some unused equates.
|
|
; <SM1> 12/31/91 RB first checked in
|
|
; <T10> 7/11/91 CCH Fixed a bug in translate040, and saved D1 in GetReal.
|
|
; <T9> 7/9/91 HJR Added overpatch space
|
|
; <T8> 5/29/91 CCH Moved the call to getMMUInfo to ensure it will always be called
|
|
; in 32-bit mode.
|
|
; <T7> 5/24/91 CCH Added call to enter supervisor mode, if necessary, and flushed
|
|
; the ATC in the EDiskProtect routine.
|
|
; <T6> 5/10/91 CCH Added the EDiskProtect routine.
|
|
; <T5> 4/2/91 djw fixed GetRealProc trashing reg D4. This is crashing A/ROSE on
|
|
; Tim.
|
|
; <T4> 3/18/91 CCH Changed check for Gestalt to check for existence of ExpandMem
|
|
; instead of trap address.
|
|
; <T3> 3/18/91 CCH Fixed to not call Gestalt if it's not around. Also made 040
|
|
; translation routine aware of non logical = physical memory.
|
|
; <T2> 1/24/91 CCH Ensured a logical 32-bit mode address for page descriptors on
|
|
; 030's.
|
|
; <T1> 1/24/91 CCH first checked in
|
|
;
|
|
;----------------------------------------------------------------------------------
|
|
|
|
MACHINE MC68030
|
|
PRINT OFF
|
|
LOAD 'StandardEqu.d'
|
|
INCLUDE 'HardwareEqu.a'
|
|
INCLUDE 'MMUEqu.a'
|
|
INCLUDE 'GestaltEqu.a'
|
|
PRINT ON
|
|
|
|
;----------------
|
|
; Misc Equates
|
|
;----------------
|
|
TTEnable EQU 15 ; transparent translation enable bit
|
|
VMTrap EQU $A05C ; VM trap number
|
|
VMGlobals EQU $0B78 ; VM globals ptr
|
|
VMInstalled equ $0101 ; VMInstalled offset inside VM's globals <LW5>
|
|
|
|
;----------------------------------------------------------------------------------
|
|
; GetReal 7c50 - Translates a logical address into a physical address. The address
|
|
; translation is performed in the MMU mode at the time of the call.
|
|
;
|
|
; input: a0.l = logical address to be translated
|
|
;
|
|
; output: a0.l = corresponding physical address
|
|
; d0.w = result code
|
|
;
|
|
; destroys: a1-a2
|
|
;----------------------------------------------------------------------------------
|
|
GetRealRegs REG d1-d4 ; <t5> djw <t10> cch
|
|
|
|
GetRealVars RECORD 0,decrement
|
|
oldA6 ds.l 1 ; old A6 value
|
|
theTC ds.l 1 ; TC reg (32-bit for 851/030, 16-bit for 040)
|
|
theSRP ds.l 1 ; root pointer of tables to use
|
|
theCRP ds.l 1 ; limit and flags long for 68851 and 68030 MMUs
|
|
myPhys2Log ds.l 1 ; offset to convert root ptr to logical addr
|
|
initShift ds.b 1 ; initial shift bits (IS)
|
|
levelFour ds.b 1 ; width of fourth level offset field (TID)
|
|
levelThree ds.b 1 ; width of third level offset field (TIC)
|
|
levelTwo ds.b 1 ; width of second level offset field (TIB)
|
|
levelOne ds.b 1 ; width of first level offset field (TIA)
|
|
ds.b 1 ; padding
|
|
GetRealSize equ *
|
|
ENDR
|
|
|
|
GetRealProc PROC EXPORT
|
|
WITH GetRealVars,MemDispGlobals
|
|
EXPORT GetMMUInfo
|
|
|
|
; Do Logical to Physical Translation for machines with EMMUs. <SM5> SAM
|
|
|
|
MOVEM.L A2/D1/D2,-(SP) ; Save some regs
|
|
|
|
MOVE.L LockMemCt,A2 ; Get the MemDispatch globals
|
|
MOVE.L mdLog2PageSize(A2),D1 ; Get the Log2 page size
|
|
|
|
MOVE.L A0,D0 ; Copy the log addr
|
|
MOVE.L A0,D2 ; Make another copy (Shitty addressing modes)
|
|
|
|
LSR.L D1,D0 ; Turn the Addr into a logical page number
|
|
MOVE.L D0,A0 ; Put the page number back into A0
|
|
|
|
_nkMMUGetPhysicalPage ; Get the physical page in D0
|
|
|
|
LSL.L D1,D0 ; Turn the Phys page number into an Address
|
|
MOVE.L mdPageSize(A2),D1 ; Get the page size
|
|
SUBQ.L #1,D1 ; Turn the log2 page size into a mask
|
|
AND.L D1,D2 ; Mask out the upper 12 bits of the logical addr
|
|
OR.L D2,D0 ; Combine the phys page & logcal offset to make phys addr
|
|
|
|
MOVE.L D0,A0 ; Put the physical address into A0
|
|
MOVEQ #0,D0 ; Signal no error
|
|
|
|
MOVEM.L (SP)+,A2/D1/D2 ; Restore regs
|
|
* BRA.S @Done ; -> Exit
|
|
RTS
|
|
|
|
|
|
;----------------------------------------------------------------------------------
|
|
; GetMMUInfo 7c7e - Fills the global area with MMU-specific table information.
|
|
;
|
|
; input: a6.l = pointer to global area
|
|
;
|
|
; output: none (globals are set up)
|
|
;
|
|
; destroys: a0-a1/d0/d3-d4
|
|
;----------------------------------------------------------------------------------
|
|
ISOffset equ 12 ; bit offset into 851/030 TC of IS field
|
|
pageSizeBit equ 14 ; bit number of page size bit in 68040 TC
|
|
|
|
GetMMUInfo
|
|
@VMisOn clr.l myPhys2log(a6) ; VM is on. No phys2log translation
|
|
@done rts ; return
|
|
|
|
ENDWITH
|
|
ENDP
|
|
|
|
|
|
;----------------------------------------------------------------------------------
|
|
; EDiskProtectPPC 7c90 - Protects or unprotects the EDisk as specified for PowerPC.
|
|
;
|
|
; input: d0[15:0] = HwPriv selector #8
|
|
; d0[16] = set to protect specified area, clear to unprotect it
|
|
; a0.l = 32-bit base address of area to protect/unprotect
|
|
; a1.l = length of area to protext/unprotect
|
|
;
|
|
; output: a0.l = pointer to the 1st-level table descriptor for the eDisk
|
|
; d0.w = result code
|
|
;
|
|
; destroys: d1/a1
|
|
;----------------------------------------------------------------------------------
|
|
EMMUWrProtBit EQU 16
|
|
EMMUWrProtMask EQU $00010000
|
|
wrBit EQU 2
|
|
|
|
ProtectRegsPPC REG d2-d4
|
|
|
|
EDiskProtectPPC PROC EXPORT
|
|
WITH GetRealVars
|
|
|
|
movem.l ProtectRegsPPC,-(sp) ; save working registers
|
|
|
|
;ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
; PowerPC EDisk Write Protect Code
|
|
;ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
move.l #12,d4 ; number of bits in page size
|
|
move.l a1,d2 ; get byte length in d2
|
|
lsr.l d4,d2 ; convert byte length to page count
|
|
addq.l #1,d2 ; always round up by one
|
|
|
|
move.l a0,d1 ; get the base address in d1
|
|
lsr.l d4,d1 ; convert base address to page number
|
|
|
|
move.l d0,d3 ; get a copy of the protect bit into d3
|
|
and.l #EMMUWrProtMask,d3 ; isolate write protect flag
|
|
move.l #EMMUWrProtBit-wrBit,d4 ; number of bits to shift protect bit
|
|
lsr.l d4,d3 ; shift the bit into place so we can OR.L it in
|
|
|
|
@protectLoop ; LOOP (to protect/unprotect pages in Edisk)
|
|
move.l d1,a0 ; Put the page number in A0
|
|
_nkGetPTEntryGivenPage ; Get the 030+ PTE from the nk
|
|
|
|
bclr #wrBit,d0 ; Clear the W bit
|
|
or.l d3,d0 ; Clear/set the write-protect flag
|
|
|
|
move.l d0,a0 ; Move the PTE to A0
|
|
move.l d1,a1 ; Put the page number in A1
|
|
_nkSetPTEntryGivenPage ; Set the 030+ PTE
|
|
|
|
addq.l #1,d1 ; bump the page number by 1
|
|
dbra d2,@protectLoop ; END
|
|
|
|
moveq #noErr,d0 ; return successful
|
|
movem.l (sp)+,ProtectRegsPPC ; restore working registers
|
|
@return rts
|
|
|
|
ENDWITH
|
|
;ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
; That's all folks.
|
|
;ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
|
|
|
|
ENDP
|
|
|
|
|
|
END
|