Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * OpenSPARC T2 Processor File: cpuid.c | |
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 | #include "cpuid.h" | |
24 | ||
25 | int getRstCpuID(rstf_unionT* rst) { | |
26 | int cpuid = -1; | |
27 | ||
28 | switch (rst->proto.rtype) { | |
29 | case INSTR_T: | |
30 | cpuid = rst->instr.cpuid; | |
31 | break; | |
32 | case TLB_T: | |
33 | cpuid = rst->tlb.cpuid; | |
34 | break; | |
35 | case REGVAL_T: | |
36 | cpuid = rst->regval.cpuid; | |
37 | break; | |
38 | case PREG_T: | |
39 | cpuid = rst->preg.cpuid; | |
40 | break; | |
41 | case TRAP_T: | |
42 | cpuid = rst->trap.cpuid; | |
43 | break; | |
44 | case TRAPEXIT_T: | |
45 | cpuid = rst->trapexit.cpuid; | |
46 | break; | |
47 | case CPU_T: | |
48 | cpuid = rst->cpu.cpu; | |
49 | break; | |
50 | case PAVADIFF_T: | |
51 | cpuid = rst->pavadiff.cpuid; | |
52 | break; | |
53 | default: | |
54 | cpuid = -1; | |
55 | } | |
56 | ||
57 | return cpuid; | |
58 | } | |
59 | ||
60 | // use the set cpuid function from rstf.h instead of accessing the cpuid field directly | |
61 | rstf_unionT* setRstCpuID(rstf_unionT* rst, int cpuid) { | |
62 | switch (rst->proto.rtype) { | |
63 | case INSTR_T: | |
64 | // rst->instr.cpuid = cpuid; | |
65 | rstf_instrT_set_cpuid(&rst->instr, cpuid); | |
66 | break; | |
67 | case TLB_T: | |
68 | // rst->tlb.cpuid = cpuid; | |
69 | rstf_tlbT_set_cpuid(&rst->tlb, cpuid); | |
70 | break; | |
71 | case REGVAL_T: | |
72 | // rst->regval.cpuid = cpuid; | |
73 | rstf_regvalT_set_cpuid(&rst->regval, cpuid); | |
74 | break; | |
75 | case PREG_T: | |
76 | // rst->preg.cpuid = cpuid; | |
77 | rstf_pregT_set_cpuid(&rst->preg, cpuid); | |
78 | break; | |
79 | case TRAP_T: | |
80 | // rst->trap.cpuid = cpuid; | |
81 | rstf_trapT_set_cpuid(&rst->trap, cpuid); | |
82 | break; | |
83 | case TRAPEXIT_T: | |
84 | // rst->trapexit.cpuid = cpuid; | |
85 | rstf_trapexitT_set_cpuid(&rst->trapexit, cpuid); | |
86 | break; | |
87 | case CPU_T: | |
88 | rst->cpu.cpu = cpuid; | |
89 | break; | |
90 | case PAVADIFF_T: | |
91 | // rst->pavadiff.cpuid = cpuid; | |
92 | rstf_pavadiffT_set_cpuid(&rst->pavadiff, cpuid); | |
93 | break; | |
94 | } | |
95 | ||
96 | return rst; | |
97 | } |