Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: gen_test1.C | |
4 | // Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
5 | // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. | |
6 | // | |
7 | // The above named program is free software; you can redistribute it and/or | |
8 | // modify it under the terms of the GNU General Public | |
9 | // License version 2 as published by the Free Software Foundation. | |
10 | // | |
11 | // The above named program is distributed in the hope that it will be | |
12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | // General Public License for more details. | |
15 | // | |
16 | // You should have received a copy of the GNU General Public | |
17 | // License along with this work; if not, write to the Free Software | |
18 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | |
19 | // | |
20 | // ========== Copyright Header End ============================================ | |
21 | /* gen_test1.C | |
22 | * generate an rst record of each type - verify that trconv displays it correctly | |
23 | */ | |
24 | ||
25 | #include <stdio.h> | |
26 | #include <stdlib.h> | |
27 | #include <string.h> | |
28 | #include <assert.h> | |
29 | ||
30 | ||
31 | #include "rstf/rstf.h" | |
32 | ||
33 | const char usage[] = "gen_test1.C > output.rst"; | |
34 | ||
35 | void zeroit(rstf_unionT * pr) | |
36 | { | |
37 | memset(pr, 0, sizeof(rstf_unionT)); | |
38 | } | |
39 | ||
40 | void dumpit(rstf_unionT * pr) | |
41 | { | |
42 | if (fwrite(pr, sizeof(rstf_unionT), 1, stdout) != 1) { | |
43 | perror("gen_test1: error writing to stdout"); | |
44 | } | |
45 | } | |
46 | ||
47 | int main(int argc, char *argv[]) | |
48 | { | |
49 | rstf_unionT ru; | |
50 | assert(sizeof(ru) == 24); | |
51 | ||
52 | zeroit(&ru); | |
53 | ru.header.rtype = RSTHEADER_T; | |
54 | ru.header.majorVer = RSTF_MAJOR_VERSION; | |
55 | ru.header.minorVer = RSTF_MINOR_VERSION; | |
56 | ru.header.percent = '%'; | |
57 | sprintf(ru.header.header_str, "RST Header v%s", RSTF_VERSION_STR); | |
58 | dumpit(&ru); | |
59 | ||
60 | const char desc_string[] = "hex digits F-0: FEDCBA9876543210"; | |
61 | zeroit(&ru); | |
62 | ru.string.rtype = STRCONT_T; | |
63 | memcpy(ru.string.string, desc_string, 23); | |
64 | dumpit(&ru); | |
65 | ru.string.rtype = STRDESC_T; | |
66 | strcpy(ru.string.string, desc_string+23); | |
67 | dumpit(&ru); | |
68 | ||
69 | zeroit(&ru); | |
70 | ru.tlb.rtype = TLB_T; | |
71 | ru.tlb.demap = 0; | |
72 | ru.tlb.tlb_type = 0; // instr | |
73 | ru.tlb.tlb_index = 12; | |
74 | ru.tlb.tlb_no = 1; | |
75 | rstf_tlbT_set_cpuid(&ru.tlb, 593); | |
76 | ru.tlb.tte_tag = 0x00000000ffd00000ull; | |
77 | ru.tlb.tte_data = 0xc000000000e00064ull; | |
78 | dumpit(&ru); | |
79 | ||
80 | zeroit(&ru); | |
81 | ru.tlb.rtype = TLB_T; | |
82 | ru.tlb.demap = 0; | |
83 | ru.tlb.tlb_type = 1; // instr | |
84 | ru.tlb.tlb_index = 137; | |
85 | ru.tlb.tlb_no = 2; | |
86 | rstf_tlbT_set_cpuid(&ru.tlb, 0); | |
87 | ru.tlb.tte_tag = 0x0000030016054000ull; | |
88 | ru.tlb.tte_data = 0x8000000066cd4036ull; | |
89 | dumpit(&ru); | |
90 | ||
91 | zeroit(&ru); | |
92 | ru.preg.rtype = PREG_T; | |
93 | ru.preg.asiReg = 0x80; | |
94 | ru.preg.traplevel = 1; | |
95 | ru.preg.traptype = 13; | |
96 | ru.preg.pstate = 0x16; | |
97 | rstf_pregT_set_cpuid(&ru.preg, 1023); | |
98 | ru.preg.primA = ru.preg.primD = 1432; | |
99 | ru.preg.secD = 0; | |
100 | dumpit(&ru); | |
101 | ||
102 | zeroit(&ru); | |
103 | ru.pavadiff.rtype = PAVADIFF_T; | |
104 | ru.pavadiff.ea_valid = 1; | |
105 | rstf_pavadiffT_set_cpuid(&ru.pavadiff, 347); | |
106 | ru.pavadiff.icontext = ru.pavadiff.dcontext = 1432; | |
107 | ru.pavadiff.pc_pa_va = 0x1300000; | |
108 | ru.pavadiff.ea_pa_va = 0xff00768000; | |
109 | dumpit(&ru); | |
110 | ||
111 | zeroit(&ru); | |
112 | ru.instr.rtype = INSTR_T; | |
113 | ru.instr.ea_valid = 1; | |
114 | ru.instr.tr = 0; | |
115 | ru.instr.hpriv = 1; | |
116 | ru.instr.pr = 0; | |
117 | ru.instr.bt = 0; | |
118 | ru.instr.an = 0; | |
119 | rstf_instrT_set_cpuid(&ru.instr, 347); | |
120 | ru.instr.instr = 0xde0fbfe8; // ldub | |
121 | ru.instr.pc_va = 0xdcba4fcc; | |
122 | ru.instr.ea_va = 0x1047e8; | |
123 | dumpit(&ru); | |
124 | ||
125 | zeroit(&ru); | |
126 | ru.trapping_instr.rtype = TRAPPING_INSTR_T; | |
127 | rstf_trapping_instrT_set_cpuid(&ru.trapping_instr, 347); | |
128 | ru.trapping_instr.hpriv=1; | |
129 | ru.trapping_instr.priv=0; | |
130 | ru.trapping_instr.iftrap = 0; | |
131 | ru.trapping_instr.pc_va = 0x4350fc00; | |
132 | ru.trapping_instr.instr = 0xde0fbfe8; | |
133 | ru.trapping_instr.ea_va_valid = 1; | |
134 | ru.trapping_instr.ea_va = 0x3141590; | |
135 | ru.trapping_instr.ea_pa_valid = 0; | |
136 | dumpit(&ru); | |
137 | ||
138 | zeroit(&ru); | |
139 | ru.trap.rtype = TRAP_T; | |
140 | ru.trap.is_async = 1; | |
141 | ru.trap.tl = 1; | |
142 | rstf_trapT_set_cpuid(&ru.trap, 2); | |
143 | ru.trap.ttype = 76; | |
144 | ru.trap.pstate = 0x16; | |
145 | ru.trap.pc = 0x3643b8; | |
146 | ru.trap.npc = 0x3643bc; | |
147 | dumpit(&ru); | |
148 | ||
149 | } // main() |