2 /// IPF specific Processor Status Register accessing functions
4 /// Copyright (c) 2006, Intel Corporation
5 /// All rights reserved. This program and the accompanying materials
6 /// are licensed and made available under the terms and conditions of the BSD License
7 /// which accompanies this distribution. The full text of the license may be found at
8 /// http://opensource.org/licenses/bsd-license.php
10 /// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 /// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 /// Module Name: AccessPsr.s
17 #define CpuModeMask 0x0000001008020000
19 #define CpuInVirtualMode 0x1
20 #define CpuInPhysicalMode 0x0
21 #define CpuInMixMode (0x0 - 0x1)
23 //---------------------------------------------------------------------------------
27 // This routine is used to read the current value of Processor Status Register (PSR).
33 // Return Value: The current PSR value.
36 //----------------------------------------------------------------------------------
38 .type AsmReadPsr, @function
46 //---------------------------------------------------------------------------------
50 // This routine is used to write the value of Processor Status Register (PSR).
54 // On Entry : The value need to be written.
56 // Return Value: The value have been written.
59 //----------------------------------------------------------------------------------
61 .type AsmWritePsr, @function
73 //---------------------------------------------------------------------------------
77 // This routine is used to determines if the CPU is currently executing
78 // in virtual, physical, or mixed mode.
80 // If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.
81 // If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.
82 // If the CPU is not in physical mode or virtual mode, then it is in mixed mode,
83 // and -1 is returned.
89 // Return Value: The CPU mode flag
90 // return 1 The CPU is in virtual mode.
91 // return 0 The CPU is in physical mode.
92 // return -1 The CPU is in mixed mode.
95 //----------------------------------------------------------------------------------
97 .type AsmCpuVirtual, @function
102 movl r30 = CpuModeMask;;
104 cmp.eq p6, p7 = r30, r28;;
105 (p6) mov r8 = CpuInVirtualMode;;
106 (p7) cmp.eq p6, p7 = 0x0, r28;;
107 (p6) mov r8 = CpuInPhysicalMode;;
108 (p7) mov r8 = CpuInMixMode;;