source: rtems/bsps/powerpc/haleakala/start/mmu_405asm.S @ b80be135

5
Last change on this file since b80be135 was 0b60c54, checked in by Sebastian Huber <sebastian.huber@…>, on 04/25/18 at 12:50:36

bsp/haleakala: Move assembler files to bsps

This patch is a part of the BSP source reorganization.

Update #3285.

  • Property mode set to 100644
File size: 2.1 KB
Line 
1/*
2
3Low-level interface to the PPC405 MMU
4
5M.Hamel ADInstruments 2008
6
7*/
8
9#include <rtems/asm.h>
10
11/* Useful MMU SPR values */
12
13#define SPR_ZPR         0x3B0
14#define SPR_PID         0x3B1
15
16                        .text
17
18/* void MMU_ClearTLBs(); */
19                        PUBLIC_VAR(MMU_ClearTLBs)
20SYM (MMU_ClearTLBs):
21                        tlbia
22                        isync
23                        lis             r3,0x5555               // *** Gratuitous fiddle of ZPR to 0101010101 to take it out of
24                        mtspr   SPR_ZPR,r3              // the picture
25                        blr
26                       
27/* void MMU_SetTLBEntry(UInt8 index, UInt32 tagword, UInt32 dataword, UInt8 SPR_PID) */
28                        PUBLIC_VAR(MMU_SetTLBEntry)
29SYM (MMU_SetTLBEntry):
30                        mfspr   r7,SPR_PID              // Save the current SPR_PID
31                        mtspr   SPR_PID,r6              // Write to SPR_PID
32                        tlbwehi r4,r3                   // Write hiword
33                        mtspr   SPR_PID,r7              // Restore the SPR_PID
34                        tlbwelo r5,r3                   // Write loword
35                        isync
36                        blr
37
38/* void MMU_GetTLBEntry(UInt8 index, UInt32& tagword, UInt32& dataword, UInt8& SPR_PID) */
39                        PUBLIC_VAR(MMU_GetTLBEntry)
40SYM (MMU_GetTLBEntry):         
41                        mfspr   r7,SPR_PID              // Save the current SPR_PID
42                        tlbrehi r8,r3                   // Read hiword & SPR_PID
43                        mfspr   r9,SPR_PID              // Copy the SPR_PID
44                        mtspr   SPR_PID,r7              // Restore original SPR_PID so we can proceed
45                        stw             r8,0(r4)                // Write to r4 pointer
46                        stb             r9,0(r6)                // Write to r6 pointer
47                        tlbrelo r8,r3                   // Read loword
48                        stw             r8,0(r5)                // Write to r5 pointer
49                        blr
50                       
51/* SInt16 MMU_FindTLBEntry(UInt32 address) */
52/* Returns index of covering TLB entry (0..63), or -1 if there isn't one */
53                        PUBLIC_VAR(MMU_FindTLBEntry)
54SYM (MMU_FindTLBEntry):         
55                        tlbsx.  r3,0,r3
56                        beqlr
57                        li              r3,0xFFFFFFFF
58                        blr
59
60/* bool         mmu_enable_code(bool enable); */
61                        PUBLIC_VAR(mmu_enable_code)
62SYM (mmu_enable_code): 
63                        li              r5,0x20 // IR bit
64                        b               msrbits
65                       
66/* bool         mmu_enable_data(bool enable); */
67                        PUBLIC_VAR(mmu_enable_data)
68SYM (mmu_enable_data): 
69                        li              r5,0x10         // DR bit
70msrbits:        cmpwi   r3,0                    // Common code: parameter 0?
71                        mfmsr   r4                              // r4 = MSR state
72                        beq             clrBit
73                        or              r6,r4,r5                // If 1, r6 = MSR with bit set
74                        b               setmsr
75clrBit:         andc    r6,r4,r5                // If 0 r6 = MSR with bit clear
76setmsr:         mtmsr   r6                              // Write new MSR
77                        and.    r3,r4,r5                // Result = old MSR bit
78                        beqlr                                           // If zero return zero
79                        li              r3,0xFF         // If nonzero return byte -1
80                        blr
81       
82                       
83                       
Note: See TracBrowser for help on using the repository browser.