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