]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ipf/AccessPsr.s
00de3acaa5a064b04f873771c1c1e807c34734fc
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / EdkIIGlueLib / Library / BaseLib / Ipf / AccessPsr.s
1 /// Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
2 /// This program and the accompanying materials
3 /// are licensed and made available under the terms and conditions of the BSD License
4 /// which accompanies this distribution. The full text of the license may be found at
5 /// http://opensource.org/licenses/bsd-license.php
6 ///
7 /// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
8 /// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
9 ///
10 /// Module Name: AccessPsr.s
11 ///
12 ///
13 /// IPF specific Processor Status Register accessing functions
14 ///
15
16 #define CpuModeMask 0x0000001008020000
17
18 #define CpuInVirtualMode 0x1
19 #define CpuInPhysicalMode 0x0
20 #define CpuInMixMode (0x0 - 0x1)
21
22 //---------------------------------------------------------------------------------
23 //++
24 // AsmReadPsr
25 //
26 // This routine is used to read the current value of Processor Status Register (PSR).
27 //
28 // Arguments :
29 //
30 // On Entry :
31 //
32 // Return Value: The current PSR value.
33 //
34 //--
35 //----------------------------------------------------------------------------------
36 .text
37 .type AsmReadPsr, @function
38 .proc AsmReadPsr
39
40 AsmReadPsr::
41 mov r8 = psr;;
42 br.ret.dpnt b0;;
43 .endp AsmReadPsr
44
45 //---------------------------------------------------------------------------------
46 //++
47 // AsmWritePsr
48 //
49 // This routine is used to write the value of Processor Status Register (PSR).
50 //
51 // Arguments :
52 //
53 // On Entry : The value need to be written.
54 //
55 // Return Value: The value have been written.
56 //
57 //--
58 //----------------------------------------------------------------------------------
59 .text
60 .type AsmWritePsr, @function
61 .proc AsmWritePsr
62 .regstk 1, 0, 0, 0
63
64 AsmWritePsr::
65 mov psr.l = in0
66 mov r8 = in0;;
67 srlz.d;;
68 srlz.i;;
69 br.ret.dpnt b0;;
70 .endp AsmWritePsr
71
72 //---------------------------------------------------------------------------------
73 //++
74 // AsmCpuVirtual
75 //
76 // This routine is used to determines if the CPU is currently executing
77 // in virtual, physical, or mixed mode.
78 //
79 // If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.
80 // If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.
81 // If the CPU is not in physical mode or virtual mode, then it is in mixed mode,
82 // and -1 is returned.
83 //
84 // Arguments:
85 //
86 // On Entry: None
87 //
88 // Return Value: The CPU mode flag
89 // return 1 The CPU is in virtual mode.
90 // return 0 The CPU is in physical mode.
91 // return -1 The CPU is in mixed mode.
92 //
93 //--
94 //----------------------------------------------------------------------------------
95 .text
96 .type AsmCpuVirtual, @function
97 .proc AsmCpuVirtual
98
99 AsmCpuVirtual::
100 mov r29 = psr
101 movl r30 = CpuModeMask;;
102 and r28 = r30, r29;;
103 cmp.eq p6, p7 = r30, r28;;
104 (p6) mov r8 = CpuInVirtualMode;;
105 (p7) cmp.eq p6, p7 = 0x0, r28;;
106 (p6) mov r8 = CpuInPhysicalMode;;
107 (p7) mov r8 = CpuInMixMode;;
108 br.ret.dpnt b0;;
109 .endp AsmCpuVirtual