Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland...
[sfrench/cifs-2.6.git] / arch / tile / include / arch / sim_def.h
1 // Copyright 2010 Tilera Corporation. All Rights Reserved.
2 //
3 //   This program is free software; you can redistribute it and/or
4 //   modify it under the terms of the GNU General Public License
5 //   as published by the Free Software Foundation, version 2.
6 //
7 //   This program is distributed in the hope that it will be useful, but
8 //   WITHOUT ANY WARRANTY; without even the implied warranty of
9 //   MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
10 //   NON INFRINGEMENT.  See the GNU General Public License for
11 //   more details.
12
13 //! @file
14 //!
15 //! Some low-level simulator definitions.
16 //!
17
18 #ifndef __ARCH_SIM_DEF_H__
19 #define __ARCH_SIM_DEF_H__
20
21
22 //! Internal: the low bits of the SIM_CONTROL_* SPR values specify
23 //! the operation to perform, and the remaining bits are
24 //! an operation-specific parameter (often unused).
25 //!
26 #define _SIM_CONTROL_OPERATOR_BITS 8
27
28
29 //== Values which can be written to SPR_SIM_CONTROL.
30
31 //! If written to SPR_SIM_CONTROL, stops profiling.
32 //!
33 #define SIM_CONTROL_PROFILER_DISABLE 0
34
35 //! If written to SPR_SIM_CONTROL, starts profiling.
36 //!
37 #define SIM_CONTROL_PROFILER_ENABLE 1
38
39 //! If written to SPR_SIM_CONTROL, clears profiling counters.
40 //!
41 #define SIM_CONTROL_PROFILER_CLEAR 2
42
43 //! If written to SPR_SIM_CONTROL, checkpoints the simulator.
44 //!
45 #define SIM_CONTROL_CHECKPOINT 3
46
47 //! If written to SPR_SIM_CONTROL, combined with a mask (shifted by 8),
48 //! sets the tracing mask to the given mask. See "sim_set_tracing()".
49 //!
50 #define SIM_CONTROL_SET_TRACING 4
51
52 //! If written to SPR_SIM_CONTROL, combined with a mask (shifted by 8),
53 //! dumps the requested items of machine state to the log.
54 //!
55 #define SIM_CONTROL_DUMP 5
56
57 //! If written to SPR_SIM_CONTROL, clears chip-level profiling counters.
58 //!
59 #define SIM_CONTROL_PROFILER_CHIP_CLEAR 6
60
61 //! If written to SPR_SIM_CONTROL, disables chip-level profiling.
62 //!
63 #define SIM_CONTROL_PROFILER_CHIP_DISABLE 7
64
65 //! If written to SPR_SIM_CONTROL, enables chip-level profiling.
66 //!
67 #define SIM_CONTROL_PROFILER_CHIP_ENABLE 8
68
69 //! If written to SPR_SIM_CONTROL, enables chip-level functional mode
70 //!
71 #define SIM_CONTROL_ENABLE_FUNCTIONAL 9
72
73 //! If written to SPR_SIM_CONTROL, disables chip-level functional mode.
74 //!
75 #define SIM_CONTROL_DISABLE_FUNCTIONAL 10
76
77 //! If written to SPR_SIM_CONTROL, enables chip-level functional mode.
78 //! All tiles must perform this write for functional mode to be enabled.
79 //! Ignored in naked boot mode unless --functional is specified.
80 //! WARNING: Only the hypervisor startup code should use this!
81 //!
82 #define SIM_CONTROL_ENABLE_FUNCTIONAL_BARRIER 11
83
84 //! If written to SPR_SIM_CONTROL, combined with a character (shifted by 8),
85 //! writes a string directly to the simulator output.  Written to once for
86 //! each character in the string, plus a final NUL.  Instead of NUL,
87 //! you can also use "SIM_PUTC_FLUSH_STRING" or "SIM_PUTC_FLUSH_BINARY".
88 //!
89 // ISSUE: Document the meaning of "newline", and the handling of NUL.
90 //
91 #define SIM_CONTROL_PUTC 12
92
93 //! If written to SPR_SIM_CONTROL, clears the --grind-coherence state for
94 //! this core.  This is intended to be used before a loop that will
95 //! invalidate the cache by loading new data and evicting all current data.
96 //! Generally speaking, this API should only be used by system code.
97 //!
98 #define SIM_CONTROL_GRINDER_CLEAR 13
99
100 //! If written to SPR_SIM_CONTROL, shuts down the simulator.
101 //!
102 #define SIM_CONTROL_SHUTDOWN 14
103
104 //! If written to SPR_SIM_CONTROL, combined with a pid (shifted by 8),
105 //! indicates that a fork syscall just created the given process.
106 //!
107 #define SIM_CONTROL_OS_FORK 15
108
109 //! If written to SPR_SIM_CONTROL, combined with a pid (shifted by 8),
110 //! indicates that an exit syscall was just executed by the given process.
111 //!
112 #define SIM_CONTROL_OS_EXIT 16
113
114 //! If written to SPR_SIM_CONTROL, combined with a pid (shifted by 8),
115 //! indicates that the OS just switched to the given process.
116 //!
117 #define SIM_CONTROL_OS_SWITCH 17
118
119 //! If written to SPR_SIM_CONTROL, combined with a character (shifted by 8),
120 //! indicates that an exec syscall was just executed. Written to once for
121 //! each character in the executable name, plus a final NUL.
122 //!
123 #define SIM_CONTROL_OS_EXEC 18
124
125 //! If written to SPR_SIM_CONTROL, combined with a character (shifted by 8),
126 //! indicates that an interpreter (PT_INTERP) was loaded.  Written to once
127 //! for each character in "ADDR:PATH", plus a final NUL, where "ADDR" is a
128 //! hex load address starting with "0x", and "PATH" is the executable name.
129 //!
130 #define SIM_CONTROL_OS_INTERP 19
131
132 //! If written to SPR_SIM_CONTROL, combined with a character (shifted by 8),
133 //! indicates that a dll was loaded.  Written to once for each character
134 //! in "ADDR:PATH", plus a final NUL, where "ADDR" is a hexadecimal load
135 //! address starting with "0x", and "PATH" is the executable name.
136 //!
137 #define SIM_CONTROL_DLOPEN 20
138
139 //! If written to SPR_SIM_CONTROL, combined with a character (shifted by 8),
140 //! indicates that a dll was unloaded.  Written to once for each character
141 //! in "ADDR", plus a final NUL, where "ADDR" is a hexadecimal load
142 //! address starting with "0x".
143 //!
144 #define SIM_CONTROL_DLCLOSE 21
145
146 //! If written to SPR_SIM_CONTROL, combined with a flag (shifted by 8),
147 //! indicates whether to allow data reads to remotely-cached
148 //! dirty cache lines to be cached locally without grinder warnings or
149 //! assertions (used by Linux kernel fast memcpy).
150 //!
151 #define SIM_CONTROL_ALLOW_MULTIPLE_CACHING 22
152
153 //! If written to SPR_SIM_CONTROL, enables memory tracing.
154 //!
155 #define SIM_CONTROL_ENABLE_MEM_LOGGING 23
156
157 //! If written to SPR_SIM_CONTROL, disables memory tracing.
158 //!
159 #define SIM_CONTROL_DISABLE_MEM_LOGGING 24
160
161 //! If written to SPR_SIM_CONTROL, changes the shaping parameters of one of
162 //! the gbe or xgbe shims. Must specify the shim id, the type, the units, and
163 //! the rate, as defined in SIM_SHAPING_SPR_ARG.
164 //!
165 #define SIM_CONTROL_SHAPING 25
166
167 //! If written to SPR_SIM_CONTROL, combined with character (shifted by 8),
168 //! requests that a simulator command be executed.  Written to once for each
169 //! character in the command, plus a final NUL.
170 //!
171 #define SIM_CONTROL_COMMAND 26
172
173 //! If written to SPR_SIM_CONTROL, indicates that the simulated system
174 //! is panicking, to allow debugging via --debug-on-panic.
175 //!
176 #define SIM_CONTROL_PANIC 27
177
178 //! If written to SPR_SIM_CONTROL, triggers a simulator syscall.
179 //! See "sim_syscall()" for more info.
180 //!
181 #define SIM_CONTROL_SYSCALL 32
182
183 //! If written to SPR_SIM_CONTROL, combined with a pid (shifted by 8),
184 //! provides the pid that subsequent SIM_CONTROL_OS_FORK writes should
185 //! use as the pid, rather than the default previous SIM_CONTROL_OS_SWITCH.
186 //!
187 #define SIM_CONTROL_OS_FORK_PARENT 33
188
189 //! If written to SPR_SIM_CONTROL, combined with a mPIPE shim number
190 //! (shifted by 8), clears the pending magic data section.  The cleared
191 //! pending magic data section and any subsequently appended magic bytes
192 //! will only take effect when the classifier blast programmer is run.
193 #define SIM_CONTROL_CLEAR_MPIPE_MAGIC_BYTES 34
194
195 //! If written to SPR_SIM_CONTROL, combined with a mPIPE shim number
196 //! (shifted by 8) and a byte of data (shifted by 16), appends that byte
197 //! to the shim's pending magic data section.  The pending magic data
198 //! section takes effect when the classifier blast programmer is run.
199 #define SIM_CONTROL_APPEND_MPIPE_MAGIC_BYTE 35
200
201 //! If written to SPR_SIM_CONTROL, combined with a mPIPE shim number
202 //! (shifted by 8), an enable=1/disable=0 bit (shifted by 16), and a
203 //! mask of links (shifted by 32), enable or disable the corresponding
204 //! mPIPE links.
205 #define SIM_CONTROL_ENABLE_MPIPE_LINK_MAGIC_BYTE 36
206
207 //== Syscall numbers for use with "sim_syscall()".
208
209 //! Syscall number for sim_add_watchpoint().
210 //!
211 #define SIM_SYSCALL_ADD_WATCHPOINT 2
212
213 //! Syscall number for sim_remove_watchpoint().
214 //!
215 #define SIM_SYSCALL_REMOVE_WATCHPOINT 3
216
217 //! Syscall number for sim_query_watchpoint().
218 //!
219 #define SIM_SYSCALL_QUERY_WATCHPOINT 4
220
221 //! Syscall number that asserts that the cache lines whose 64-bit PA
222 //! is passed as the second argument to sim_syscall(), and over a
223 //! range passed as the third argument, are no longer in cache.
224 //! The simulator raises an error if this is not the case.
225 //!
226 #define SIM_SYSCALL_VALIDATE_LINES_EVICTED 5
227
228
229 //== Bit masks which can be shifted by 8, combined with
230 //== SIM_CONTROL_SET_TRACING, and written to SPR_SIM_CONTROL.
231
232 //! @addtogroup arch_sim
233 //! @{
234
235 //! Enable --trace-cycle when passed to simulator_set_tracing().
236 //!
237 #define SIM_TRACE_CYCLES          0x01
238
239 //! Enable --trace-router when passed to simulator_set_tracing().
240 //!
241 #define SIM_TRACE_ROUTER          0x02
242
243 //! Enable --trace-register-writes when passed to simulator_set_tracing().
244 //!
245 #define SIM_TRACE_REGISTER_WRITES 0x04
246
247 //! Enable --trace-disasm when passed to simulator_set_tracing().
248 //!
249 #define SIM_TRACE_DISASM          0x08
250
251 //! Enable --trace-stall-info when passed to simulator_set_tracing().
252 //!
253 #define SIM_TRACE_STALL_INFO      0x10
254
255 //! Enable --trace-memory-controller when passed to simulator_set_tracing().
256 //!
257 #define SIM_TRACE_MEMORY_CONTROLLER 0x20
258
259 //! Enable --trace-l2 when passed to simulator_set_tracing().
260 //!
261 #define SIM_TRACE_L2_CACHE 0x40
262
263 //! Enable --trace-lines when passed to simulator_set_tracing().
264 //!
265 #define SIM_TRACE_LINES 0x80
266
267 //! Turn off all tracing when passed to simulator_set_tracing().
268 //!
269 #define SIM_TRACE_NONE 0
270
271 //! Turn on all tracing when passed to simulator_set_tracing().
272 //!
273 #define SIM_TRACE_ALL (-1)
274
275 //! @}
276
277 //! Computes the value to write to SPR_SIM_CONTROL to set tracing flags.
278 //!
279 #define SIM_TRACE_SPR_ARG(mask) \
280   (SIM_CONTROL_SET_TRACING | ((mask) << _SIM_CONTROL_OPERATOR_BITS))
281
282
283 //== Bit masks which can be shifted by 8, combined with
284 //== SIM_CONTROL_DUMP, and written to SPR_SIM_CONTROL.
285
286 //! @addtogroup arch_sim
287 //! @{
288
289 //! Dump the general-purpose registers.
290 //!
291 #define SIM_DUMP_REGS          0x001
292
293 //! Dump the SPRs.
294 //!
295 #define SIM_DUMP_SPRS          0x002
296
297 //! Dump the ITLB.
298 //!
299 #define SIM_DUMP_ITLB          0x004
300
301 //! Dump the DTLB.
302 //!
303 #define SIM_DUMP_DTLB          0x008
304
305 //! Dump the L1 I-cache.
306 //!
307 #define SIM_DUMP_L1I           0x010
308
309 //! Dump the L1 D-cache.
310 //!
311 #define SIM_DUMP_L1D           0x020
312
313 //! Dump the L2 cache.
314 //!
315 #define SIM_DUMP_L2            0x040
316
317 //! Dump the switch registers.
318 //!
319 #define SIM_DUMP_SNREGS        0x080
320
321 //! Dump the switch ITLB.
322 //!
323 #define SIM_DUMP_SNITLB        0x100
324
325 //! Dump the switch L1 I-cache.
326 //!
327 #define SIM_DUMP_SNL1I         0x200
328
329 //! Dump the current backtrace.
330 //!
331 #define SIM_DUMP_BACKTRACE     0x400
332
333 //! Only dump valid lines in caches.
334 //!
335 #define SIM_DUMP_VALID_LINES   0x800
336
337 //! Dump everything that is dumpable.
338 //!
339 #define SIM_DUMP_ALL (-1 & ~SIM_DUMP_VALID_LINES)
340
341 // @}
342
343 //! Computes the value to write to SPR_SIM_CONTROL to dump machine state.
344 //!
345 #define SIM_DUMP_SPR_ARG(mask) \
346   (SIM_CONTROL_DUMP | ((mask) << _SIM_CONTROL_OPERATOR_BITS))
347
348
349 //== Bit masks which can be shifted by 8, combined with
350 //== SIM_CONTROL_PROFILER_CHIP_xxx, and written to SPR_SIM_CONTROL.
351
352 //! @addtogroup arch_sim
353 //! @{
354
355 //! Use with with SIM_PROFILER_CHIP_xxx to control the memory controllers.
356 //!
357 #define SIM_CHIP_MEMCTL        0x001
358
359 //! Use with with SIM_PROFILER_CHIP_xxx to control the XAUI interface.
360 //!
361 #define SIM_CHIP_XAUI          0x002
362
363 //! Use with with SIM_PROFILER_CHIP_xxx to control the PCIe interface.
364 //!
365 #define SIM_CHIP_PCIE          0x004
366
367 //! Use with with SIM_PROFILER_CHIP_xxx to control the MPIPE interface.
368 //!
369 #define SIM_CHIP_MPIPE         0x008
370
371 //! Reference all chip devices.
372 //!
373 #define SIM_CHIP_ALL (-1)
374
375 //! @}
376
377 //! Computes the value to write to SPR_SIM_CONTROL to clear chip statistics.
378 //!
379 #define SIM_PROFILER_CHIP_CLEAR_SPR_ARG(mask) \
380   (SIM_CONTROL_PROFILER_CHIP_CLEAR | ((mask) << _SIM_CONTROL_OPERATOR_BITS))
381
382 //! Computes the value to write to SPR_SIM_CONTROL to disable chip statistics.
383 //!
384 #define SIM_PROFILER_CHIP_DISABLE_SPR_ARG(mask) \
385   (SIM_CONTROL_PROFILER_CHIP_DISABLE | ((mask) << _SIM_CONTROL_OPERATOR_BITS))
386
387 //! Computes the value to write to SPR_SIM_CONTROL to enable chip statistics.
388 //!
389 #define SIM_PROFILER_CHIP_ENABLE_SPR_ARG(mask) \
390   (SIM_CONTROL_PROFILER_CHIP_ENABLE | ((mask) << _SIM_CONTROL_OPERATOR_BITS))
391
392
393
394 // Shim bitrate controls.
395
396 //! The number of bits used to store the shim id.
397 //!
398 #define SIM_CONTROL_SHAPING_SHIM_ID_BITS 3
399
400 //! @addtogroup arch_sim
401 //! @{
402
403 //! Change the gbe 0 bitrate.
404 //!
405 #define SIM_CONTROL_SHAPING_GBE_0 0x0
406
407 //! Change the gbe 1 bitrate.
408 //!
409 #define SIM_CONTROL_SHAPING_GBE_1 0x1
410
411 //! Change the gbe 2 bitrate.
412 //!
413 #define SIM_CONTROL_SHAPING_GBE_2 0x2
414
415 //! Change the gbe 3 bitrate.
416 //!
417 #define SIM_CONTROL_SHAPING_GBE_3 0x3
418
419 //! Change the xgbe 0 bitrate.
420 //!
421 #define SIM_CONTROL_SHAPING_XGBE_0 0x4
422
423 //! Change the xgbe 1 bitrate.
424 //!
425 #define SIM_CONTROL_SHAPING_XGBE_1 0x5
426
427 //! The type of shaping to do.
428 //!
429 #define SIM_CONTROL_SHAPING_TYPE_BITS 2
430
431 //! Control the multiplier.
432 //!
433 #define SIM_CONTROL_SHAPING_MULTIPLIER 0
434
435 //! Control the PPS.
436 //!
437 #define SIM_CONTROL_SHAPING_PPS 1
438
439 //! Control the BPS.
440 //!
441 #define SIM_CONTROL_SHAPING_BPS 2
442
443 //! The number of bits for the units for the shaping parameter.
444 //!
445 #define SIM_CONTROL_SHAPING_UNITS_BITS 2
446
447 //! Provide a number in single units.
448 //!
449 #define SIM_CONTROL_SHAPING_UNITS_SINGLE 0
450
451 //! Provide a number in kilo units.
452 //!
453 #define SIM_CONTROL_SHAPING_UNITS_KILO 1
454
455 //! Provide a number in mega units.
456 //!
457 #define SIM_CONTROL_SHAPING_UNITS_MEGA 2
458
459 //! Provide a number in giga units.
460 //!
461 #define SIM_CONTROL_SHAPING_UNITS_GIGA 3
462
463 // @}
464
465 //! How many bits are available for the rate.
466 //!
467 #define SIM_CONTROL_SHAPING_RATE_BITS \
468   (32 - (_SIM_CONTROL_OPERATOR_BITS + \
469          SIM_CONTROL_SHAPING_SHIM_ID_BITS + \
470          SIM_CONTROL_SHAPING_TYPE_BITS + \
471          SIM_CONTROL_SHAPING_UNITS_BITS))
472
473 //! Computes the value to write to SPR_SIM_CONTROL to change a bitrate.
474 //!
475 #define SIM_SHAPING_SPR_ARG(shim, type, units, rate) \
476   (SIM_CONTROL_SHAPING | \
477    ((shim) | \
478    ((type) << (SIM_CONTROL_SHAPING_SHIM_ID_BITS)) | \
479    ((units) << (SIM_CONTROL_SHAPING_SHIM_ID_BITS + \
480                 SIM_CONTROL_SHAPING_TYPE_BITS)) | \
481    ((rate) << (SIM_CONTROL_SHAPING_SHIM_ID_BITS + \
482                SIM_CONTROL_SHAPING_TYPE_BITS + \
483                SIM_CONTROL_SHAPING_UNITS_BITS))) << _SIM_CONTROL_OPERATOR_BITS)
484
485
486 //== Values returned when reading SPR_SIM_CONTROL.
487 // ISSUE: These names should share a longer common prefix.
488
489 //! When reading SPR_SIM_CONTROL, the mask of simulator tracing bits
490 //! (SIM_TRACE_xxx values).
491 //!
492 #define SIM_TRACE_FLAG_MASK 0xFFFF
493
494 //! When reading SPR_SIM_CONTROL, the mask for whether profiling is enabled.
495 //!
496 #define SIM_PROFILER_ENABLED_MASK 0x10000
497
498
499 //== Special arguments for "SIM_CONTROL_PUTC".
500
501 //! Flag value for forcing a PUTC string-flush, including
502 //! coordinate/cycle prefix and newline.
503 //!
504 #define SIM_PUTC_FLUSH_STRING 0x100
505
506 //! Flag value for forcing a PUTC binary-data-flush, which skips the
507 //! prefix and does not append a newline.
508 //!
509 #define SIM_PUTC_FLUSH_BINARY 0x101
510
511
512 #endif //__ARCH_SIM_DEF_H__