Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / rst / rstzip3 / rstzip_v2 / pstate.H
CommitLineData
920dae64
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: pstate.H
5* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
6* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
7*
8* The above named program is free software; you can redistribute it and/or
9* modify it under the terms of the GNU General Public
10* License version 2 as published by the Free Software Foundation.
11*
12* The above named program is distributed in the hope that it will be
13* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15* General Public License for more details.
16*
17* You should have received a copy of the GNU General Public
18* License along with this work; if not, write to the Free Software
19* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20*
21* ========== Copyright Header End ============================================
22*/
23// ========== Copyright Header Begin ==========================================
24//
25// OpenSPARC T2 Processor File: pstate.H
26// Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
27// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
28//
29// The above named program is free software; you can redistribute it and/or
30// modify it under the terms of the GNU General Public
31// License version 2 as published by the Free Software Foundation.
32//
33// The above named program is distributed in the hope that it will be
34// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
35// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
36// General Public License for more details.
37//
38// You should have received a copy of the GNU General Public
39// License along with this work; if not, write to the Free Software
40// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
41//
42// ========== Copyright Header End ============================================
43enum {
44 PSTATE_CLE = 2,
45 PSTATE_TLE,
46 PSTATE_MM,
47 PSTATE_RED,
48 PSTATE_PEF,
49 PSTATE_AM,
50 PSTATE_PRIV,
51 PSTATE_IE,
52 PSTATE_AG
53};
54
55class Pstate {
56public:
57 uint32_t pstate;
58
59 Pstate() {
60 pstate = 0x0; // PSTATE.AM == 0
61 }
62
63 int getField(int field) {
64 int pstate_field;
65
66 switch (field) {
67 case PSTATE_CLE:
68 pstate_field = (pstate << 22) >> 31;
69 break;
70 case PSTATE_TLE:
71 pstate_field = (pstate << 23) >> 31;
72 break;
73 case PSTATE_MM:
74 pstate_field = (pstate << 24) >> 30;
75 break;
76 case PSTATE_RED:
77 pstate_field = (pstate << 26) >> 31;
78 break;
79 case PSTATE_PEF:
80 pstate_field = (pstate << 27) >> 31;
81 break;
82 case PSTATE_AM:
83 pstate_field = (pstate << 28) >> 31;
84 break;
85 case PSTATE_PRIV:
86 pstate_field = (pstate << 29) >> 31;
87 break;
88 case PSTATE_IE:
89 pstate_field = (pstate << 30) >> 31;
90 break;
91 case PSTATE_AG:
92 pstate_field = (pstate << 31) >> 31;
93 break;
94 default:
95 fprintf(stderr, "Warning: invalid field param passed to Pstate::getField() (field=%d)\n", field);
96 }
97
98 return pstate_field;
99 }
100}; // Pstate