Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | # ========== Copyright Header Begin ========================================== |
2 | # | |
3 | # OpenSPARC T2 Processor File: SamCmdMap.py | |
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 | """ | |
22 | class list all commands intended for blaze in a blaze-riesling | |
23 | environment | |
24 | """ | |
25 | import sys, types | |
26 | ||
27 | import sam | |
28 | ||
29 | class SamCmdMap: | |
30 | """ | |
31 | """ | |
32 | ||
33 | def __init__ (self, blaze=None): | |
34 | """ | |
35 | """ | |
36 | self.blaze = blaze | |
37 | self.cmdMap = [ | |
38 | 'conf', | |
39 | 'connect', | |
40 | 'console-send', | |
41 | 'device', | |
42 | 'diskdelay', | |
43 | 'dbg', | |
44 | 'dump', | |
45 | 'file', | |
46 | # 'help', | |
47 | 'ioa', | |
48 | 'ldm', | |
49 | 'load', | |
50 | 'mem', | |
51 | 'memdump', | |
52 | 'memseg', | |
53 | 'mips', | |
54 | 'mmi', | |
55 | 'mod', | |
56 | 'on', | |
57 | # 5/25/05: penable/pdisable will update CMP registers and step() will check | |
58 | # core_running_status before execution, so blaze has no need to handle penable/ | |
59 | # pdisable any more, it should consider all strands are enabled at all time, | |
60 | # and let riesling strand.step() decide whenther it should step or not. | |
61 | # 'pdisable', | |
62 | # 'penable', | |
63 | # 9/2/05: pmask is used to control which blaze cpus will be enabled, this is | |
64 | # to work around CMP to get user a better control of cpu execution. | |
65 | 'pmask', | |
66 | 'rdt', | |
67 | 'regs', | |
68 | 'rstrace', | |
69 | 'run', | |
70 | 'scsi_ctrl', | |
71 | 'scsi_disk', | |
72 | 'setreg', | |
73 | 'stepi', | |
74 | 'stepim', | |
75 | 'stept', | |
76 | 'stop', | |
77 | 'sync', | |
78 | 'time', | |
79 | 'tlbdump', | |
80 | 'uldm', | |
81 | 'write', | |
82 | 'ssi', # riesling command, turn it to nop in sam | |
83 | 'runfast', # riesling command, ditto | |
84 | 'vdebug', | |
85 | 'load_symbols', | |
86 | 'unload_symbols', | |
87 | 'sym', | |
88 | 'where', | |
89 | 'tlbs' | |
90 | ] | |
91 | ||
92 | ||
93 | def issueCmd (self, cmd, output, riesReposit): | |
94 | """ | |
95 | """ | |
96 | tokens = cmd.split() | |
97 | if tokens[0] in self.cmdMap: | |
98 | if tokens[0] == 'file': | |
99 | # process the file line-by-line | |
100 | return 'execfile("%s")' % (tokens[1]) | |
101 | else: | |
102 | if ((tokens[0] == 'ssi') or (tokens[0] == 'runfast')): | |
103 | sys.stderr.write('ERROR: command %s is not supported in SAM, use "stepi N" or "run N" instead\n' % (tokens[0])) | |
104 | return None | |
105 | elif (tokens[0] == 'run'): | |
106 | if (len(tokens) > 1): | |
107 | # 'run' is a non-blocking call, if we see 'run N', | |
108 | # convert that to 'stepi N' | |
109 | cmd = 'stepi ' + ' '.join(tokens[1:]) | |
110 | else: | |
111 | # 'run' alone becomes a non-blocking call, we should | |
112 | # get UI prompt back right the way | |
113 | cmd = tokens[0] | |
114 | elif (tokens[0] == 'pmask'): | |
115 | if len(tokens) == 1: | |
116 | # query current pmask | |
117 | sys.stderr.write('%#x\n' % riesReposit.pmask) | |
118 | return None | |
119 | else: | |
120 | if not sam.is_stopped(): | |
121 | sys.stderr.write('Simulator is running, issue "stop" before changing pmask\n') | |
122 | return None | |
123 | # set blaze penable accordingly | |
124 | newMask = long(tokens[1], 16) | |
125 | toDisable = riesReposit.pmask & (~newMask & 0xffffffffffffffffL) | |
126 | toEnable = (~riesReposit.pmask & 0xffffffffffffffffL) & newMask | |
127 | #sys.stderr.write('DBX: newMask=%#x toDisable=%#x toEnable=%#x\n' % (newMask, toDisable, toEnable)) | |
128 | # disable currently enabled, but to be disabled strands | |
129 | for i in range(riesReposit.blazeNumcpu): | |
130 | if ((toDisable >> i) &0x1) == 0x1: | |
131 | cmd = 'pdisable th%d' % i | |
132 | #sys.stderr.write('DBX: cmd=%s\n' % cmd) | |
133 | #self.blaze.command(cmd) | |
134 | sam.ui_exec(cmd); | |
135 | # disable currently disabled, but to be enabled strands | |
136 | for i in range(riesReposit.blazeNumcpu): | |
137 | if ((toEnable >> i) &0x1) == 0x1: | |
138 | cmd = 'penable th%d' % i | |
139 | #sys.stderr.write('DBX: cmd=%s\n' % cmd) | |
140 | #self.blaze.command(cmd) | |
141 | sam.ui_exec(cmd); | |
142 | # update to the new mask | |
143 | riesReposit.pmask = newMask | |
144 | return None | |
145 | ||
146 | if type(output) is types.ListType: | |
147 | #output = output.append(self.blaze.command(cmd)) | |
148 | sam.ui_exec(cmd); | |
149 | else: | |
150 | #self.blaze.command(cmd) | |
151 | sam.ui_exec(cmd); | |
152 | ||
153 | ||
154 | if cmd == 'run': | |
155 | riesReposit.running = 1 | |
156 | #print "start running...." | |
157 | #sys.ps1 = 'run>' | |
158 | #elif (cmd == 'stop') or (cmd.startswith('stepi ')): | |
159 | elif cmd == 'stop': | |
160 | # don't check 'stepi' here. If we first do 'run', then | |
161 | # enter either 'run N' or 'stepi N', blaze will issue | |
162 | # 'is running' and return without doing anything, at this | |
163 | # time blaze is still in the first 'run', so we cannot | |
164 | # set running to 0 for 'run N' or 'stepi N', as they may | |
165 | # not be executed at all. | |
166 | riesReposit.running = 0 | |
167 | #print "stop command was issued." | |
168 | #sys.ps1 = 'stop>' | |
169 | ||
170 | if len(tokens) > 2 and (tokens[0] == 'mod' and | |
171 | tokens[1] == 'load'): | |
172 | # mod load xxx yyy, register 'xxx' as a command prefix, as all | |
173 | # module 'yyy' related commands will use that prefix | |
174 | if not tokens[2] in self.cmdMap: | |
175 | self.cmdMap.append(tokens[2]) | |
176 | return None | |
177 | else: | |
178 | return cmd | |
179 | ||
180 | ||
181 | def showCmd (self): | |
182 | """ | |
183 | """ | |
184 | print self.cmdMap | |
185 | ||
186 | ||
187 | """self-testing | |
188 | """ | |
189 | if __name__ == "__main__": | |
190 | pass |