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