--- /dev/null
+/// @file\r
+/// IPF specific Processor Status Register accessing functions\r
+///\r
+/// Copyright (c) 2006, Intel Corporation\r
+/// All rights reserved. This program and the accompanying materials\r
+/// are licensed and made available under the terms and conditions of the BSD License\r
+/// which accompanies this distribution. The full text of the license may be found at\r
+/// http://opensource.org/licenses/bsd-license.php\r
+///\r
+/// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+/// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+///\r
+/// Module Name: AccessPsr.s\r
+///\r
+///\r
+\r
+#define CpuModeMask 0x0000001008020000\r
+\r
+#define CpuInVirtualMode 0x1\r
+#define CpuInPhysicalMode 0x0\r
+#define CpuInMixMode (0x0 - 0x1)\r
+\r
+//---------------------------------------------------------------------------------\r
+//++\r
+// AsmReadPsr\r
+//\r
+// This routine is used to read the current value of Processor Status Register (PSR).\r
+//\r
+// Arguments :\r
+//\r
+// On Entry :\r
+//\r
+// Return Value: The current PSR value.\r
+//\r
+//--\r
+//----------------------------------------------------------------------------------\r
+.text\r
+.type AsmReadPsr, @function\r
+.proc AsmReadPsr\r
+\r
+AsmReadPsr::\r
+ mov r8 = psr;;\r
+ br.ret.dpnt b0;;\r
+.endp AsmReadPsr\r
+\r
+//---------------------------------------------------------------------------------\r
+//++\r
+// AsmWritePsr\r
+//\r
+// This routine is used to write the value of Processor Status Register (PSR).\r
+//\r
+// Arguments :\r
+//\r
+// On Entry : The value need to be written.\r
+//\r
+// Return Value: The value have been written.\r
+//\r
+//--\r
+//----------------------------------------------------------------------------------\r
+.text\r
+.type AsmWritePsr, @function\r
+.proc AsmWritePsr\r
+.regstk 1, 0, 0, 0\r
+\r
+AsmWritePsr::\r
+ mov psr.l = in0\r
+ mov r8 = in0;;\r
+ srlz.d;;\r
+ srlz.i;;\r
+ br.ret.dpnt b0;;\r
+.endp AsmWritePsr\r
+\r
+//---------------------------------------------------------------------------------\r
+//++\r
+// AsmCpuVirtual\r
+//\r
+// This routine is used to determines if the CPU is currently executing\r
+// in virtual, physical, or mixed mode.\r
+//\r
+// If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.\r
+// If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.\r
+// If the CPU is not in physical mode or virtual mode, then it is in mixed mode,\r
+// and -1 is returned.\r
+//\r
+// Arguments:\r
+//\r
+// On Entry: None\r
+//\r
+// Return Value: The CPU mode flag\r
+// return 1 The CPU is in virtual mode.\r
+// return 0 The CPU is in physical mode.\r
+// return -1 The CPU is in mixed mode.\r
+//\r
+//--\r
+//----------------------------------------------------------------------------------\r
+.text\r
+.type AsmCpuVirtual, @function\r
+.proc AsmCpuVirtual\r
+\r
+AsmCpuVirtual::\r
+ mov r29 = psr\r
+ movl r30 = CpuModeMask;;\r
+ and r28 = r30, r29;;\r
+ cmp.eq p6, p7 = r30, r28;;\r
+(p6) mov r8 = CpuInVirtualMode;;\r
+(p7) cmp.eq p6, p7 = 0x0, r28;;\r
+(p6) mov r8 = CpuInPhysicalMode;;\r
+(p7) mov r8 = CpuInMixMode;;\r
+ br.ret.dpnt b0;;\r
+.endp AsmCpuVirtual
\ No newline at end of file