aboutsummaryrefslogtreecommitdiffstats
path: root/arch/tile/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-10-26 20:25:38 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-26 20:25:38 -0400
commite404f91ed2180dfecbab15dd4d39c543353385fb (patch)
treec256e29b1c738d5e5b5478f19b369b1fd90bd1e2 /arch/tile/include
parent18a043f9413277523cf5011e594caa1747db4948 (diff)
parente18105c128734b1671739ad4d85e216ebec28c61 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile
* git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile: arch/tile: convert a BUG_ON to BUILD_BUG_ON arch/tile: make ptrace() work properly for TILE-Gx COMPAT mode arch/tile: support new info op generated by compiler arch/tile: minor whitespace/naming changes for string support files arch/tile: enable single-step support for TILE-Gx arch/tile: parameterize system PLs to support KVM port arch/tile: add Tilera's <arch/sim.h> header as an open-source header arch/tile: Bomb C99 comments to C89 comments in tile's <arch/sim_def.h> arch/tile: prevent corrupt top frame from causing backtracer runaway arch/tile: various top-level Makefile cleanups arch/tile: change lower bound on syscall error return to -4095 arch/tile: properly export __mb_incoherent for modules arch/tile: provide a definition of MAP_STACK kmemleak: add TILE to the list of supported architectures. char: hvc: check for error case arch/tile: Add a warning if we try to allocate too much vmalloc memory. arch/tile: update some comments to clarify register usage. arch/tile: use better "punctuation" for VMSPLIT_3_5G and friends arch/tile: Use <asm-generic/syscalls.h> tile: replace some BUG_ON checks with BUILD_BUG_ON checks
Diffstat (limited to 'arch/tile/include')
-rw-r--r--arch/tile/include/arch/sim.h619
-rw-r--r--arch/tile/include/arch/sim_def.h548
-rw-r--r--arch/tile/include/arch/spr_def.h85
-rw-r--r--arch/tile/include/arch/spr_def_32.h39
-rw-r--r--arch/tile/include/asm/backtrace.h5
-rw-r--r--arch/tile/include/asm/compat.h15
-rw-r--r--arch/tile/include/asm/irqflags.h64
-rw-r--r--arch/tile/include/asm/mman.h1
-rw-r--r--arch/tile/include/asm/page.h27
-rw-r--r--arch/tile/include/asm/processor.h11
-rw-r--r--arch/tile/include/asm/ptrace.h4
-rw-r--r--arch/tile/include/asm/syscalls.h73
-rw-r--r--arch/tile/include/asm/system.h14
-rw-r--r--arch/tile/include/asm/traps.h4
-rw-r--r--arch/tile/include/hv/hypervisor.h30
15 files changed, 1128 insertions, 411 deletions
diff --git a/arch/tile/include/arch/sim.h b/arch/tile/include/arch/sim.h
new file mode 100644
index 00000000000..74b7c1624d3
--- /dev/null
+++ b/arch/tile/include/arch/sim.h
@@ -0,0 +1,619 @@
1/*
2 * Copyright 2010 Tilera Corporation. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation, version 2.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11 * NON INFRINGEMENT. See the GNU General Public License for
12 * more details.
13 */
14
15/**
16 * @file
17 *
18 * Provides an API for controlling the simulator at runtime.
19 */
20
21/**
22 * @addtogroup arch_sim
23 * @{
24 *
25 * An API for controlling the simulator at runtime.
26 *
27 * The simulator's behavior can be modified while it is running.
28 * For example, human-readable trace output can be enabled and disabled
29 * around code of interest.
30 *
31 * There are two ways to modify simulator behavior:
32 * programmatically, by calling various sim_* functions, and
33 * interactively, by entering commands like "sim set functional true"
34 * at the tile-monitor prompt. Typing "sim help" at that prompt provides
35 * a list of interactive commands.
36 *
37 * All interactive commands can also be executed programmatically by
38 * passing a string to the sim_command function.
39 */
40
41#ifndef __ARCH_SIM_H__
42#define __ARCH_SIM_H__
43
44#include <arch/sim_def.h>
45#include <arch/abi.h>
46
47#ifndef __ASSEMBLER__
48
49#include <arch/spr_def.h>
50
51
52/**
53 * Return true if the current program is running under a simulator,
54 * rather than on real hardware. If running on hardware, other "sim_xxx()"
55 * calls have no useful effect.
56 */
57static inline int
58sim_is_simulator(void)
59{
60 return __insn_mfspr(SPR_SIM_CONTROL) != 0;
61}
62
63
64/**
65 * Checkpoint the simulator state to a checkpoint file.
66 *
67 * The checkpoint file name is either the default or the name specified
68 * on the command line with "--checkpoint-file".
69 */
70static __inline void
71sim_checkpoint(void)
72{
73 __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_CHECKPOINT);
74}
75
76
77/**
78 * Report whether or not various kinds of simulator tracing are enabled.
79 *
80 * @return The bitwise OR of these values:
81 *
82 * SIM_TRACE_CYCLES (--trace-cycles),
83 * SIM_TRACE_ROUTER (--trace-router),
84 * SIM_TRACE_REGISTER_WRITES (--trace-register-writes),
85 * SIM_TRACE_DISASM (--trace-disasm),
86 * SIM_TRACE_STALL_INFO (--trace-stall-info)
87 * SIM_TRACE_MEMORY_CONTROLLER (--trace-memory-controller)
88 * SIM_TRACE_L2_CACHE (--trace-l2)
89 * SIM_TRACE_LINES (--trace-lines)
90 */
91static __inline unsigned int
92sim_get_tracing(void)
93{
94 return __insn_mfspr(SPR_SIM_CONTROL) & SIM_TRACE_FLAG_MASK;
95}
96
97
98/**
99 * Turn on or off different kinds of simulator tracing.
100 *
101 * @param mask Either one of these special values:
102 *
103 * SIM_TRACE_NONE (turns off tracing),
104 * SIM_TRACE_ALL (turns on all possible tracing).
105 *
106 * or the bitwise OR of these values:
107 *
108 * SIM_TRACE_CYCLES (--trace-cycles),
109 * SIM_TRACE_ROUTER (--trace-router),
110 * SIM_TRACE_REGISTER_WRITES (--trace-register-writes),
111 * SIM_TRACE_DISASM (--trace-disasm),
112 * SIM_TRACE_STALL_INFO (--trace-stall-info)
113 * SIM_TRACE_MEMORY_CONTROLLER (--trace-memory-controller)
114 * SIM_TRACE_L2_CACHE (--trace-l2)
115 * SIM_TRACE_LINES (--trace-lines)
116 */
117static __inline void
118sim_set_tracing(unsigned int mask)
119{
120 __insn_mtspr(SPR_SIM_CONTROL, SIM_TRACE_SPR_ARG(mask));
121}
122
123
124/**
125 * Request dumping of different kinds of simulator state.
126 *
127 * @param mask Either this special value:
128 *
129 * SIM_DUMP_ALL (dump all known state)
130 *
131 * or the bitwise OR of these values:
132 *
133 * SIM_DUMP_REGS (the register file),
134 * SIM_DUMP_SPRS (the SPRs),
135 * SIM_DUMP_ITLB (the iTLB),
136 * SIM_DUMP_DTLB (the dTLB),
137 * SIM_DUMP_L1I (the L1 I-cache),
138 * SIM_DUMP_L1D (the L1 D-cache),
139 * SIM_DUMP_L2 (the L2 cache),
140 * SIM_DUMP_SNREGS (the switch register file),
141 * SIM_DUMP_SNITLB (the switch iTLB),
142 * SIM_DUMP_SNL1I (the switch L1 I-cache),
143 * SIM_DUMP_BACKTRACE (the current backtrace)
144 */
145static __inline void
146sim_dump(unsigned int mask)
147{
148 __insn_mtspr(SPR_SIM_CONTROL, SIM_DUMP_SPR_ARG(mask));
149}
150
151
152/**
153 * Print a string to the simulator stdout.
154 *
155 * @param str The string to be written; a newline is automatically added.
156 */
157static __inline void
158sim_print_string(const char* str)
159{
160 int i;
161 for (i = 0; str[i] != 0; i++)
162 {
163 __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_PUTC |
164 (str[i] << _SIM_CONTROL_OPERATOR_BITS));
165 }
166 __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_PUTC |
167 (SIM_PUTC_FLUSH_STRING << _SIM_CONTROL_OPERATOR_BITS));
168}
169
170
171/**
172 * Execute a simulator command string.
173 *
174 * Type 'sim help' at the tile-monitor prompt to learn what commands
175 * are available. Note the use of the tile-monitor "sim" command to
176 * pass commands to the simulator.
177 *
178 * The argument to sim_command() does not include the leading "sim"
179 * prefix used at the tile-monitor prompt; for example, you might call
180 * sim_command("trace disasm").
181 */
182static __inline void
183sim_command(const char* str)
184{
185 int c;
186 do
187 {
188 c = *str++;
189 __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_COMMAND |
190 (c << _SIM_CONTROL_OPERATOR_BITS));
191 }
192 while (c);
193}
194
195
196
197#ifndef __DOXYGEN__
198
199/**
200 * The underlying implementation of "_sim_syscall()".
201 *
202 * We use extra "and" instructions to ensure that all the values
203 * we are passing to the simulator are actually valid in the registers
204 * (i.e. returned from memory) prior to the SIM_CONTROL spr.
205 */
206static __inline int _sim_syscall0(int val)
207{
208 long result;
209 __asm__ __volatile__ ("mtspr SIM_CONTROL, r0"
210 : "=R00" (result) : "R00" (val));
211 return result;
212}
213
214static __inline int _sim_syscall1(int val, long arg1)
215{
216 long result;
217 __asm__ __volatile__ ("{ and zero, r1, r1; mtspr SIM_CONTROL, r0 }"
218 : "=R00" (result) : "R00" (val), "R01" (arg1));
219 return result;
220}
221
222static __inline int _sim_syscall2(int val, long arg1, long arg2)
223{
224 long result;
225 __asm__ __volatile__ ("{ and zero, r1, r2; mtspr SIM_CONTROL, r0 }"
226 : "=R00" (result)
227 : "R00" (val), "R01" (arg1), "R02" (arg2));
228 return result;
229}
230
231/* Note that _sim_syscall3() and higher are technically at risk of
232 receiving an interrupt right before the mtspr bundle, in which case
233 the register values for arguments 3 and up may still be in flight
234 to the core from a stack frame reload. */
235
236static __inline int _sim_syscall3(int val, long arg1, long arg2, long arg3)
237{
238 long result;
239 __asm__ __volatile__ ("{ and zero, r3, r3 };"
240 "{ and zero, r1, r2; mtspr SIM_CONTROL, r0 }"
241 : "=R00" (result)
242 : "R00" (val), "R01" (arg1), "R02" (arg2),
243 "R03" (arg3));
244 return result;
245}
246
247static __inline int _sim_syscall4(int val, long arg1, long arg2, long arg3,
248 long arg4)
249{
250 long result;
251 __asm__ __volatile__ ("{ and zero, r3, r4 };"
252 "{ and zero, r1, r2; mtspr SIM_CONTROL, r0 }"
253 : "=R00" (result)
254 : "R00" (val), "R01" (arg1), "R02" (arg2),
255 "R03" (arg3), "R04" (arg4));
256 return result;
257}
258
259static __inline int _sim_syscall5(int val, long arg1, long arg2, long arg3,
260 long arg4, long arg5)
261{
262 long result;
263 __asm__ __volatile__ ("{ and zero, r3, r4; and zero, r5, r5 };"
264 "{ and zero, r1, r2; mtspr SIM_CONTROL, r0 }"
265 : "=R00" (result)
266 : "R00" (val), "R01" (arg1), "R02" (arg2),
267 "R03" (arg3), "R04" (arg4), "R05" (arg5));
268 return result;
269}
270
271
272/**
273 * Make a special syscall to the simulator itself, if running under
274 * simulation. This is used as the implementation of other functions
275 * and should not be used outside this file.
276 *
277 * @param syscall_num The simulator syscall number.
278 * @param nr The number of additional arguments provided.
279 *
280 * @return Varies by syscall.
281 */
282#define _sim_syscall(syscall_num, nr, args...) \
283 _sim_syscall##nr( \
284 ((syscall_num) << _SIM_CONTROL_OPERATOR_BITS) | SIM_CONTROL_SYSCALL, args)
285
286
287/* Values for the "access_mask" parameters below. */
288#define SIM_WATCHPOINT_READ 1
289#define SIM_WATCHPOINT_WRITE 2
290#define SIM_WATCHPOINT_EXECUTE 4
291
292
293static __inline int
294sim_add_watchpoint(unsigned int process_id,
295 unsigned long address,
296 unsigned long size,
297 unsigned int access_mask,
298 unsigned long user_data)
299{
300 return _sim_syscall(SIM_SYSCALL_ADD_WATCHPOINT, 5, process_id,
301 address, size, access_mask, user_data);
302}
303
304
305static __inline int
306sim_remove_watchpoint(unsigned int process_id,
307 unsigned long address,
308 unsigned long size,
309 unsigned int access_mask,
310 unsigned long user_data)
311{
312 return _sim_syscall(SIM_SYSCALL_REMOVE_WATCHPOINT, 5, process_id,
313 address, size, access_mask, user_data);
314}
315
316
317/**
318 * Return value from sim_query_watchpoint.
319 */
320struct SimQueryWatchpointStatus
321{
322 /**
323 * 0 if a watchpoint fired, 1 if no watchpoint fired, or -1 for
324 * error (meaning a bad process_id).
325 */
326 int syscall_status;
327
328 /**
329 * The address of the watchpoint that fired (this is the address
330 * passed to sim_add_watchpoint, not an address within that range
331 * that actually triggered the watchpoint).
332 */
333 unsigned long address;
334
335 /** The arbitrary user_data installed by sim_add_watchpoint. */
336 unsigned long user_data;
337};
338
339
340static __inline struct SimQueryWatchpointStatus
341sim_query_watchpoint(unsigned int process_id)
342{
343 struct SimQueryWatchpointStatus status;
344 long val = SIM_CONTROL_SYSCALL |
345 (SIM_SYSCALL_QUERY_WATCHPOINT << _SIM_CONTROL_OPERATOR_BITS);
346 __asm__ __volatile__ ("{ and zero, r1, r1; mtspr SIM_CONTROL, r0 }"
347 : "=R00" (status.syscall_status),
348 "=R01" (status.address),
349 "=R02" (status.user_data)
350 : "R00" (val), "R01" (process_id));
351 return status;
352}
353
354
355/* On the simulator, confirm lines have been evicted everywhere. */
356static __inline void
357sim_validate_lines_evicted(unsigned long long pa, unsigned long length)
358{
359#ifdef __LP64__
360 _sim_syscall(SIM_SYSCALL_VALIDATE_LINES_EVICTED, 2, pa, length);
361#else
362 _sim_syscall(SIM_SYSCALL_VALIDATE_LINES_EVICTED, 4,
363 0 /* dummy */, (long)(pa), (long)(pa >> 32), length);
364#endif
365}
366
367
368#endif /* !__DOXYGEN__ */
369
370
371
372
373/**
374 * Modify the shaping parameters of a shim.
375 *
376 * @param shim The shim to modify. One of:
377 * SIM_CONTROL_SHAPING_GBE_0
378 * SIM_CONTROL_SHAPING_GBE_1
379 * SIM_CONTROL_SHAPING_GBE_2
380 * SIM_CONTROL_SHAPING_GBE_3
381 * SIM_CONTROL_SHAPING_XGBE_0
382 * SIM_CONTROL_SHAPING_XGBE_1
383 *
384 * @param type The type of shaping. This should be the same type of
385 * shaping that is already in place on the shim. One of:
386 * SIM_CONTROL_SHAPING_MULTIPLIER
387 * SIM_CONTROL_SHAPING_PPS
388 * SIM_CONTROL_SHAPING_BPS
389 *
390 * @param units The magnitude of the rate. One of:
391 * SIM_CONTROL_SHAPING_UNITS_SINGLE
392 * SIM_CONTROL_SHAPING_UNITS_KILO
393 * SIM_CONTROL_SHAPING_UNITS_MEGA
394 * SIM_CONTROL_SHAPING_UNITS_GIGA
395 *
396 * @param rate The rate to which to change it. This must fit in
397 * SIM_CONTROL_SHAPING_RATE_BITS bits or a warning is issued and
398 * the shaping is not changed.
399 *
400 * @return 0 if no problems were detected in the arguments to sim_set_shaping
401 * or 1 if problems were detected (for example, rate does not fit in 17 bits).
402 */
403static __inline int
404sim_set_shaping(unsigned shim,
405 unsigned type,
406 unsigned units,
407 unsigned rate)
408{
409 if ((rate & ~((1 << SIM_CONTROL_SHAPING_RATE_BITS) - 1)) != 0)
410 return 1;
411
412 __insn_mtspr(SPR_SIM_CONTROL, SIM_SHAPING_SPR_ARG(shim, type, units, rate));
413 return 0;
414}
415
416#ifdef __tilegx__
417
418/** Enable a set of mPIPE links. Pass a -1 link_mask to enable all links. */
419static __inline void
420sim_enable_mpipe_links(unsigned mpipe, unsigned long link_mask)
421{
422 __insn_mtspr(SPR_SIM_CONTROL,
423 (SIM_CONTROL_ENABLE_MPIPE_LINK_MAGIC_BYTE |
424 (mpipe << 8) | (1 << 16) | ((uint_reg_t)link_mask << 32)));
425}
426
427/** Disable a set of mPIPE links. Pass a -1 link_mask to disable all links. */
428static __inline void
429sim_disable_mpipe_links(unsigned mpipe, unsigned long link_mask)
430{
431 __insn_mtspr(SPR_SIM_CONTROL,
432 (SIM_CONTROL_ENABLE_MPIPE_LINK_MAGIC_BYTE |
433 (mpipe << 8) | (0 << 16) | ((uint_reg_t)link_mask << 32)));
434}
435
436#endif /* __tilegx__ */
437
438
439/*
440 * An API for changing "functional" mode.
441 */
442
443#ifndef __DOXYGEN__
444
445#define sim_enable_functional() \
446 __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_ENABLE_FUNCTIONAL)
447
448#define sim_disable_functional() \
449 __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_DISABLE_FUNCTIONAL)
450
451#endif /* __DOXYGEN__ */
452
453
454/*
455 * Profiler support.
456 */
457
458/**
459 * Turn profiling on for the current task.
460 *
461 * Note that this has no effect if run in an environment without
462 * profiling support (thus, the proper flags to the simulator must
463 * be supplied).
464 */
465static __inline void
466sim_profiler_enable(void)
467{
468 __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_PROFILER_ENABLE);
469}
470
471
472/** Turn profiling off for the current task. */
473static __inline void
474sim_profiler_disable(void)
475{
476 __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_PROFILER_DISABLE);
477}
478
479
480/**
481 * Turn profiling on or off for the current task.
482 *
483 * @param enabled If true, turns on profiling. If false, turns it off.
484 *
485 * Note that this has no effect if run in an environment without
486 * profiling support (thus, the proper flags to the simulator must
487 * be supplied).
488 */
489static __inline void
490sim_profiler_set_enabled(int enabled)
491{
492 int val =
493 enabled ? SIM_CONTROL_PROFILER_ENABLE : SIM_CONTROL_PROFILER_DISABLE;
494 __insn_mtspr(SPR_SIM_CONTROL, val);
495}
496
497
498/**
499 * Return true if and only if profiling is currently enabled
500 * for the current task.
501 *
502 * This returns false even if sim_profiler_enable() was called
503 * if the current execution environment does not support profiling.
504 */
505static __inline int
506sim_profiler_is_enabled(void)
507{
508 return ((__insn_mfspr(SPR_SIM_CONTROL) & SIM_PROFILER_ENABLED_MASK) != 0);
509}
510
511
512/**
513 * Reset profiling counters to zero for the current task.
514 *
515 * Resetting can be done while profiling is enabled. It does not affect
516 * the chip-wide profiling counters.
517 */
518static __inline void
519sim_profiler_clear(void)
520{
521 __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_PROFILER_CLEAR);
522}
523
524
525/**
526 * Enable specified chip-level profiling counters.
527 *
528 * Does not affect the per-task profiling counters.
529 *
530 * @param mask Either this special value:
531 *
532 * SIM_CHIP_ALL (enables all chip-level components).
533 *
534 * or the bitwise OR of these values:
535 *
536 * SIM_CHIP_MEMCTL (enable all memory controllers)
537 * SIM_CHIP_XAUI (enable all XAUI controllers)
538 * SIM_CHIP_MPIPE (enable all MPIPE controllers)
539 */
540static __inline void
541sim_profiler_chip_enable(unsigned int mask)
542{
543 __insn_mtspr(SPR_SIM_CONTROL, SIM_PROFILER_CHIP_ENABLE_SPR_ARG(mask));
544}
545
546
547/**
548 * Disable specified chip-level profiling counters.
549 *
550 * Does not affect the per-task profiling counters.
551 *
552 * @param mask Either this special value:
553 *
554 * SIM_CHIP_ALL (disables all chip-level components).
555 *
556 * or the bitwise OR of these values:
557 *
558 * SIM_CHIP_MEMCTL (disable all memory controllers)
559 * SIM_CHIP_XAUI (disable all XAUI controllers)
560 * SIM_CHIP_MPIPE (disable all MPIPE controllers)
561 */
562static __inline void
563sim_profiler_chip_disable(unsigned int mask)
564{
565 __insn_mtspr(SPR_SIM_CONTROL, SIM_PROFILER_CHIP_DISABLE_SPR_ARG(mask));
566}
567
568
569/**
570 * Reset specified chip-level profiling counters to zero.
571 *
572 * Does not affect the per-task profiling counters.
573 *
574 * @param mask Either this special value:
575 *
576 * SIM_CHIP_ALL (clears all chip-level components).
577 *
578 * or the bitwise OR of these values:
579 *
580 * SIM_CHIP_MEMCTL (clear all memory controllers)
581 * SIM_CHIP_XAUI (clear all XAUI controllers)
582 * SIM_CHIP_MPIPE (clear all MPIPE controllers)
583 */
584static __inline void
585sim_profiler_chip_clear(unsigned int mask)
586{
587 __insn_mtspr(SPR_SIM_CONTROL, SIM_PROFILER_CHIP_CLEAR_SPR_ARG(mask));
588}
589
590
591/*
592 * Event support.
593 */
594
595#ifndef __DOXYGEN__
596
597static __inline void
598sim_event_begin(unsigned int x)
599{
600#if defined(__tile__) && !defined(__NO_EVENT_SPR__)
601 __insn_mtspr(SPR_EVENT_BEGIN, x);
602#endif
603}
604
605static __inline void
606sim_event_end(unsigned int x)
607{
608#if defined(__tile__) && !defined(__NO_EVENT_SPR__)
609 __insn_mtspr(SPR_EVENT_END, x);
610#endif
611}
612
613#endif /* !__DOXYGEN__ */
614
615#endif /* !__ASSEMBLER__ */
616
617#endif /* !__ARCH_SIM_H__ */
618
619/** @} */
diff --git a/arch/tile/include/arch/sim_def.h b/arch/tile/include/arch/sim_def.h
index 6418fbde063..7a17082c377 100644
--- a/arch/tile/include/arch/sim_def.h
+++ b/arch/tile/include/arch/sim_def.h
@@ -1,477 +1,461 @@
1// Copyright 2010 Tilera Corporation. All Rights Reserved. 1/*
2// 2 * Copyright 2010 Tilera Corporation. All Rights Reserved.
3// This program is free software; you can redistribute it and/or 3 *
4// modify it under the terms of the GNU General Public License 4 * This program is free software; you can redistribute it and/or
5// as published by the Free Software Foundation, version 2. 5 * modify it under the terms of the GNU General Public License
6// 6 * as published by the Free Software Foundation, version 2.
7// This program is distributed in the hope that it will be useful, but 7 *
8// WITHOUT ANY WARRANTY; without even the implied warranty of 8 * This program is distributed in the hope that it will be useful, but
9// MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10// NON INFRINGEMENT. See the GNU General Public License for 10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11// more details. 11 * NON INFRINGEMENT. See the GNU General Public License for
12 12 * more details.
13//! @file 13 */
14//! 14
15//! Some low-level simulator definitions. 15/**
16//! 16 * @file
17 *
18 * Some low-level simulator definitions.
19 */
17 20
18#ifndef __ARCH_SIM_DEF_H__ 21#ifndef __ARCH_SIM_DEF_H__
19#define __ARCH_SIM_DEF_H__ 22#define __ARCH_SIM_DEF_H__
20 23
21 24
22//! Internal: the low bits of the SIM_CONTROL_* SPR values specify 25/**
23//! the operation to perform, and the remaining bits are 26 * Internal: the low bits of the SIM_CONTROL_* SPR values specify
24//! an operation-specific parameter (often unused). 27 * the operation to perform, and the remaining bits are
25//! 28 * an operation-specific parameter (often unused).
29 */
26#define _SIM_CONTROL_OPERATOR_BITS 8 30#define _SIM_CONTROL_OPERATOR_BITS 8
27 31
28 32
29//== Values which can be written to SPR_SIM_CONTROL. 33/*
34 * Values which can be written to SPR_SIM_CONTROL.
35 */
30 36
31//! If written to SPR_SIM_CONTROL, stops profiling. 37/** If written to SPR_SIM_CONTROL, stops profiling. */
32//!
33#define SIM_CONTROL_PROFILER_DISABLE 0 38#define SIM_CONTROL_PROFILER_DISABLE 0
34 39
35//! If written to SPR_SIM_CONTROL, starts profiling. 40/** If written to SPR_SIM_CONTROL, starts profiling. */
36//!
37#define SIM_CONTROL_PROFILER_ENABLE 1 41#define SIM_CONTROL_PROFILER_ENABLE 1
38 42
39//! If written to SPR_SIM_CONTROL, clears profiling counters. 43/** If written to SPR_SIM_CONTROL, clears profiling counters. */
40//!
41#define SIM_CONTROL_PROFILER_CLEAR 2 44#define SIM_CONTROL_PROFILER_CLEAR 2
42 45
43//! If written to SPR_SIM_CONTROL, checkpoints the simulator. 46/** If written to SPR_SIM_CONTROL, checkpoints the simulator. */
44//!
45#define SIM_CONTROL_CHECKPOINT 3 47#define SIM_CONTROL_CHECKPOINT 3
46 48
47//! If written to SPR_SIM_CONTROL, combined with a mask (shifted by 8), 49/**
48//! sets the tracing mask to the given mask. See "sim_set_tracing()". 50 * If written to SPR_SIM_CONTROL, combined with a mask (shifted by 8),
49//! 51 * sets the tracing mask to the given mask. See "sim_set_tracing()".
52 */
50#define SIM_CONTROL_SET_TRACING 4 53#define SIM_CONTROL_SET_TRACING 4
51 54
52//! If written to SPR_SIM_CONTROL, combined with a mask (shifted by 8), 55/**
53//! dumps the requested items of machine state to the log. 56 * If written to SPR_SIM_CONTROL, combined with a mask (shifted by 8),
54//! 57 * dumps the requested items of machine state to the log.
58 */
55#define SIM_CONTROL_DUMP 5 59#define SIM_CONTROL_DUMP 5
56 60
57//! If written to SPR_SIM_CONTROL, clears chip-level profiling counters. 61/** If written to SPR_SIM_CONTROL, clears chip-level profiling counters. */
58//!
59#define SIM_CONTROL_PROFILER_CHIP_CLEAR 6 62#define SIM_CONTROL_PROFILER_CHIP_CLEAR 6
60 63
61//! If written to SPR_SIM_CONTROL, disables chip-level profiling. 64/** If written to SPR_SIM_CONTROL, disables chip-level profiling. */
62//!
63#define SIM_CONTROL_PROFILER_CHIP_DISABLE 7 65#define SIM_CONTROL_PROFILER_CHIP_DISABLE 7
64 66
65//! If written to SPR_SIM_CONTROL, enables chip-level profiling. 67/** If written to SPR_SIM_CONTROL, enables chip-level profiling. */
66//!
67#define SIM_CONTROL_PROFILER_CHIP_ENABLE 8 68#define SIM_CONTROL_PROFILER_CHIP_ENABLE 8
68 69
69//! If written to SPR_SIM_CONTROL, enables chip-level functional mode 70/** If written to SPR_SIM_CONTROL, enables chip-level functional mode */
70//!
71#define SIM_CONTROL_ENABLE_FUNCTIONAL 9 71#define SIM_CONTROL_ENABLE_FUNCTIONAL 9
72 72
73//! If written to SPR_SIM_CONTROL, disables chip-level functional mode. 73/** If written to SPR_SIM_CONTROL, disables chip-level functional mode. */
74//!
75#define SIM_CONTROL_DISABLE_FUNCTIONAL 10 74#define SIM_CONTROL_DISABLE_FUNCTIONAL 10
76 75
77//! If written to SPR_SIM_CONTROL, enables chip-level functional mode. 76/**
78//! All tiles must perform this write for functional mode to be enabled. 77 * If written to SPR_SIM_CONTROL, enables chip-level functional mode.
79//! Ignored in naked boot mode unless --functional is specified. 78 * All tiles must perform this write for functional mode to be enabled.
80//! WARNING: Only the hypervisor startup code should use this! 79 * Ignored in naked boot mode unless --functional is specified.
81//! 80 * WARNING: Only the hypervisor startup code should use this!
81 */
82#define SIM_CONTROL_ENABLE_FUNCTIONAL_BARRIER 11 82#define SIM_CONTROL_ENABLE_FUNCTIONAL_BARRIER 11
83 83
84//! If written to SPR_SIM_CONTROL, combined with a character (shifted by 8), 84/**
85//! writes a string directly to the simulator output. Written to once for 85 * If written to SPR_SIM_CONTROL, combined with a character (shifted by 8),
86//! each character in the string, plus a final NUL. Instead of NUL, 86 * writes a string directly to the simulator output. Written to once for
87//! you can also use "SIM_PUTC_FLUSH_STRING" or "SIM_PUTC_FLUSH_BINARY". 87 * each character in the string, plus a final NUL. Instead of NUL,
88//! 88 * you can also use "SIM_PUTC_FLUSH_STRING" or "SIM_PUTC_FLUSH_BINARY".
89// ISSUE: Document the meaning of "newline", and the handling of NUL. 89 */
90// 90/* ISSUE: Document the meaning of "newline", and the handling of NUL. */
91#define SIM_CONTROL_PUTC 12 91#define SIM_CONTROL_PUTC 12
92 92
93//! If written to SPR_SIM_CONTROL, clears the --grind-coherence state for 93/**
94//! this core. This is intended to be used before a loop that will 94 * If written to SPR_SIM_CONTROL, clears the --grind-coherence state for
95//! invalidate the cache by loading new data and evicting all current data. 95 * this core. This is intended to be used before a loop that will
96//! Generally speaking, this API should only be used by system code. 96 * invalidate the cache by loading new data and evicting all current data.
97//! 97 * Generally speaking, this API should only be used by system code.
98 */
98#define SIM_CONTROL_GRINDER_CLEAR 13 99#define SIM_CONTROL_GRINDER_CLEAR 13
99 100
100//! If written to SPR_SIM_CONTROL, shuts down the simulator. 101/** If written to SPR_SIM_CONTROL, shuts down the simulator. */
101//!
102#define SIM_CONTROL_SHUTDOWN 14 102#define SIM_CONTROL_SHUTDOWN 14
103 103
104//! If written to SPR_SIM_CONTROL, combined with a pid (shifted by 8), 104/**
105//! indicates that a fork syscall just created the given process. 105 * If written to SPR_SIM_CONTROL, combined with a pid (shifted by 8),
106//! 106 * indicates that a fork syscall just created the given process.
107 */
107#define SIM_CONTROL_OS_FORK 15 108#define SIM_CONTROL_OS_FORK 15
108 109
109//! If written to SPR_SIM_CONTROL, combined with a pid (shifted by 8), 110/**
110//! indicates that an exit syscall was just executed by the given process. 111 * If written to SPR_SIM_CONTROL, combined with a pid (shifted by 8),
111//! 112 * indicates that an exit syscall was just executed by the given process.
113 */
112#define SIM_CONTROL_OS_EXIT 16 114#define SIM_CONTROL_OS_EXIT 16
113 115
114//! If written to SPR_SIM_CONTROL, combined with a pid (shifted by 8), 116/**
115//! indicates that the OS just switched to the given process. 117 * If written to SPR_SIM_CONTROL, combined with a pid (shifted by 8),
116//! 118 * indicates that the OS just switched to the given process.
119 */
117#define SIM_CONTROL_OS_SWITCH 17 120#define SIM_CONTROL_OS_SWITCH 17
118 121
119//! If written to SPR_SIM_CONTROL, combined with a character (shifted by 8), 122/**
120//! indicates that an exec syscall was just executed. Written to once for 123 * If written to SPR_SIM_CONTROL, combined with a character (shifted by 8),
121//! each character in the executable name, plus a final NUL. 124 * indicates that an exec syscall was just executed. Written to once for
122//! 125 * each character in the executable name, plus a final NUL.
126 */
123#define SIM_CONTROL_OS_EXEC 18 127#define SIM_CONTROL_OS_EXEC 18
124 128
125//! If written to SPR_SIM_CONTROL, combined with a character (shifted by 8), 129/**
126//! indicates that an interpreter (PT_INTERP) was loaded. Written to once 130 * If written to SPR_SIM_CONTROL, combined with a character (shifted by 8),
127//! for each character in "ADDR:PATH", plus a final NUL, where "ADDR" is a 131 * indicates that an interpreter (PT_INTERP) was loaded. Written to once
128//! hex load address starting with "0x", and "PATH" is the executable name. 132 * for each character in "ADDR:PATH", plus a final NUL, where "ADDR" is a
129//! 133 * hex load address starting with "0x", and "PATH" is the executable name.
134 */
130#define SIM_CONTROL_OS_INTERP 19 135#define SIM_CONTROL_OS_INTERP 19
131 136
132//! If written to SPR_SIM_CONTROL, combined with a character (shifted by 8), 137/**
133//! indicates that a dll was loaded. Written to once for each character 138 * If written to SPR_SIM_CONTROL, combined with a character (shifted by 8),
134//! in "ADDR:PATH", plus a final NUL, where "ADDR" is a hexadecimal load 139 * indicates that a dll was loaded. Written to once for each character
135//! address starting with "0x", and "PATH" is the executable name. 140 * in "ADDR:PATH", plus a final NUL, where "ADDR" is a hexadecimal load
136//! 141 * address starting with "0x", and "PATH" is the executable name.
142 */
137#define SIM_CONTROL_DLOPEN 20 143#define SIM_CONTROL_DLOPEN 20
138 144
139//! If written to SPR_SIM_CONTROL, combined with a character (shifted by 8), 145/**
140//! indicates that a dll was unloaded. Written to once for each character 146 * If written to SPR_SIM_CONTROL, combined with a character (shifted by 8),
141//! in "ADDR", plus a final NUL, where "ADDR" is a hexadecimal load 147 * indicates that a dll was unloaded. Written to once for each character
142//! address starting with "0x". 148 * in "ADDR", plus a final NUL, where "ADDR" is a hexadecimal load
143//! 149 * address starting with "0x".
150 */
144#define SIM_CONTROL_DLCLOSE 21 151#define SIM_CONTROL_DLCLOSE 21
145 152
146//! If written to SPR_SIM_CONTROL, combined with a flag (shifted by 8), 153/**
147//! indicates whether to allow data reads to remotely-cached 154 * If written to SPR_SIM_CONTROL, combined with a flag (shifted by 8),
148//! dirty cache lines to be cached locally without grinder warnings or 155 * indicates whether to allow data reads to remotely-cached
149//! assertions (used by Linux kernel fast memcpy). 156 * dirty cache lines to be cached locally without grinder warnings or
150//! 157 * assertions (used by Linux kernel fast memcpy).
158 */
151#define SIM_CONTROL_ALLOW_MULTIPLE_CACHING 22 159#define SIM_CONTROL_ALLOW_MULTIPLE_CACHING 22
152 160
153//! If written to SPR_SIM_CONTROL, enables memory tracing. 161/** If written to SPR_SIM_CONTROL, enables memory tracing. */
154//!
155#define SIM_CONTROL_ENABLE_MEM_LOGGING 23 162#define SIM_CONTROL_ENABLE_MEM_LOGGING 23
156 163
157//! If written to SPR_SIM_CONTROL, disables memory tracing. 164/** If written to SPR_SIM_CONTROL, disables memory tracing. */
158//!
159#define SIM_CONTROL_DISABLE_MEM_LOGGING 24 165#define SIM_CONTROL_DISABLE_MEM_LOGGING 24
160 166
161//! If written to SPR_SIM_CONTROL, changes the shaping parameters of one of 167/**
162//! the gbe or xgbe shims. Must specify the shim id, the type, the units, and 168 * If written to SPR_SIM_CONTROL, changes the shaping parameters of one of
163//! the rate, as defined in SIM_SHAPING_SPR_ARG. 169 * the gbe or xgbe shims. Must specify the shim id, the type, the units, and
164//! 170 * the rate, as defined in SIM_SHAPING_SPR_ARG.
171 */
165#define SIM_CONTROL_SHAPING 25 172#define SIM_CONTROL_SHAPING 25
166 173
167//! If written to SPR_SIM_CONTROL, combined with character (shifted by 8), 174/**
168//! requests that a simulator command be executed. Written to once for each 175 * If written to SPR_SIM_CONTROL, combined with character (shifted by 8),
169//! character in the command, plus a final NUL. 176 * requests that a simulator command be executed. Written to once for each
170//! 177 * character in the command, plus a final NUL.
178 */
171#define SIM_CONTROL_COMMAND 26 179#define SIM_CONTROL_COMMAND 26
172 180
173//! If written to SPR_SIM_CONTROL, indicates that the simulated system 181/**
174//! is panicking, to allow debugging via --debug-on-panic. 182 * If written to SPR_SIM_CONTROL, indicates that the simulated system
175//! 183 * is panicking, to allow debugging via --debug-on-panic.
184 */
176#define SIM_CONTROL_PANIC 27 185#define SIM_CONTROL_PANIC 27
177 186
178//! If written to SPR_SIM_CONTROL, triggers a simulator syscall. 187/**
179//! See "sim_syscall()" for more info. 188 * If written to SPR_SIM_CONTROL, triggers a simulator syscall.
180//! 189 * See "sim_syscall()" for more info.
190 */
181#define SIM_CONTROL_SYSCALL 32 191#define SIM_CONTROL_SYSCALL 32
182 192
183//! If written to SPR_SIM_CONTROL, combined with a pid (shifted by 8), 193/**
184//! provides the pid that subsequent SIM_CONTROL_OS_FORK writes should 194 * If written to SPR_SIM_CONTROL, combined with a pid (shifted by 8),
185//! use as the pid, rather than the default previous SIM_CONTROL_OS_SWITCH. 195 * provides the pid that subsequent SIM_CONTROL_OS_FORK writes should
186//! 196 * use as the pid, rather than the default previous SIM_CONTROL_OS_SWITCH.
197 */
187#define SIM_CONTROL_OS_FORK_PARENT 33 198#define SIM_CONTROL_OS_FORK_PARENT 33
188 199
189//! If written to SPR_SIM_CONTROL, combined with a mPIPE shim number 200/**
190//! (shifted by 8), clears the pending magic data section. The cleared 201 * If written to SPR_SIM_CONTROL, combined with a mPIPE shim number
191//! pending magic data section and any subsequently appended magic bytes 202 * (shifted by 8), clears the pending magic data section. The cleared
192//! will only take effect when the classifier blast programmer is run. 203 * pending magic data section and any subsequently appended magic bytes
204 * will only take effect when the classifier blast programmer is run.
205 */
193#define SIM_CONTROL_CLEAR_MPIPE_MAGIC_BYTES 34 206#define SIM_CONTROL_CLEAR_MPIPE_MAGIC_BYTES 34
194 207
195//! If written to SPR_SIM_CONTROL, combined with a mPIPE shim number 208/**
196//! (shifted by 8) and a byte of data (shifted by 16), appends that byte 209 * If written to SPR_SIM_CONTROL, combined with a mPIPE shim number
197//! to the shim's pending magic data section. The pending magic data 210 * (shifted by 8) and a byte of data (shifted by 16), appends that byte
198//! section takes effect when the classifier blast programmer is run. 211 * to the shim's pending magic data section. The pending magic data
212 * section takes effect when the classifier blast programmer is run.
213 */
199#define SIM_CONTROL_APPEND_MPIPE_MAGIC_BYTE 35 214#define SIM_CONTROL_APPEND_MPIPE_MAGIC_BYTE 35
200 215
201//! If written to SPR_SIM_CONTROL, combined with a mPIPE shim number 216/**
202//! (shifted by 8), an enable=1/disable=0 bit (shifted by 16), and a 217 * If written to SPR_SIM_CONTROL, combined with a mPIPE shim number
203//! mask of links (shifted by 32), enable or disable the corresponding 218 * (shifted by 8), an enable=1/disable=0 bit (shifted by 16), and a
204//! mPIPE links. 219 * mask of links (shifted by 32), enable or disable the corresponding
220 * mPIPE links.
221 */
205#define SIM_CONTROL_ENABLE_MPIPE_LINK_MAGIC_BYTE 36 222#define SIM_CONTROL_ENABLE_MPIPE_LINK_MAGIC_BYTE 36
206 223
207//== Syscall numbers for use with "sim_syscall()".
208 224
209//! Syscall number for sim_add_watchpoint(). 225/*
210//! 226 * Syscall numbers for use with "sim_syscall()".
227 */
228
229/** Syscall number for sim_add_watchpoint(). */
211#define SIM_SYSCALL_ADD_WATCHPOINT 2 230#define SIM_SYSCALL_ADD_WATCHPOINT 2
212 231
213//! Syscall number for sim_remove_watchpoint(). 232/** Syscall number for sim_remove_watchpoint(). */
214//!
215#define SIM_SYSCALL_REMOVE_WATCHPOINT 3 233#define SIM_SYSCALL_REMOVE_WATCHPOINT 3
216 234
217//! Syscall number for sim_query_watchpoint(). 235/** Syscall number for sim_query_watchpoint(). */
218//!
219#define SIM_SYSCALL_QUERY_WATCHPOINT 4 236#define SIM_SYSCALL_QUERY_WATCHPOINT 4
220 237
221//! Syscall number that asserts that the cache lines whose 64-bit PA 238/**
222//! is passed as the second argument to sim_syscall(), and over a 239 * Syscall number that asserts that the cache lines whose 64-bit PA
223//! range passed as the third argument, are no longer in cache. 240 * is passed as the second argument to sim_syscall(), and over a
224//! The simulator raises an error if this is not the case. 241 * range passed as the third argument, are no longer in cache.
225//! 242 * The simulator raises an error if this is not the case.
243 */
226#define SIM_SYSCALL_VALIDATE_LINES_EVICTED 5 244#define SIM_SYSCALL_VALIDATE_LINES_EVICTED 5
227 245
228 246
229//== Bit masks which can be shifted by 8, combined with 247/*
230//== SIM_CONTROL_SET_TRACING, and written to SPR_SIM_CONTROL. 248 * Bit masks which can be shifted by 8, combined with
249 * SIM_CONTROL_SET_TRACING, and written to SPR_SIM_CONTROL.
250 */
231 251
232//! @addtogroup arch_sim 252/**
233//! @{ 253 * @addtogroup arch_sim
254 * @{
255 */
234 256
235//! Enable --trace-cycle when passed to simulator_set_tracing(). 257/** Enable --trace-cycle when passed to simulator_set_tracing(). */
236//!
237#define SIM_TRACE_CYCLES 0x01 258#define SIM_TRACE_CYCLES 0x01
238 259
239//! Enable --trace-router when passed to simulator_set_tracing(). 260/** Enable --trace-router when passed to simulator_set_tracing(). */
240//!
241#define SIM_TRACE_ROUTER 0x02 261#define SIM_TRACE_ROUTER 0x02
242 262
243//! Enable --trace-register-writes when passed to simulator_set_tracing(). 263/** Enable --trace-register-writes when passed to simulator_set_tracing(). */
244//!
245#define SIM_TRACE_REGISTER_WRITES 0x04 264#define SIM_TRACE_REGISTER_WRITES 0x04
246 265
247//! Enable --trace-disasm when passed to simulator_set_tracing(). 266/** Enable --trace-disasm when passed to simulator_set_tracing(). */
248//!
249#define SIM_TRACE_DISASM 0x08 267#define SIM_TRACE_DISASM 0x08
250 268
251//! Enable --trace-stall-info when passed to simulator_set_tracing(). 269/** Enable --trace-stall-info when passed to simulator_set_tracing(). */
252//!
253#define SIM_TRACE_STALL_INFO 0x10 270#define SIM_TRACE_STALL_INFO 0x10
254 271
255//! Enable --trace-memory-controller when passed to simulator_set_tracing(). 272/** Enable --trace-memory-controller when passed to simulator_set_tracing(). */
256//!
257#define SIM_TRACE_MEMORY_CONTROLLER 0x20 273#define SIM_TRACE_MEMORY_CONTROLLER 0x20
258 274
259//! Enable --trace-l2 when passed to simulator_set_tracing(). 275/** Enable --trace-l2 when passed to simulator_set_tracing(). */
260//!
261#define SIM_TRACE_L2_CACHE 0x40 276#define SIM_TRACE_L2_CACHE 0x40
262 277
263//! Enable --trace-lines when passed to simulator_set_tracing(). 278/** Enable --trace-lines when passed to simulator_set_tracing(). */
264//!
265#define SIM_TRACE_LINES 0x80 279#define SIM_TRACE_LINES 0x80
266 280
267//! Turn off all tracing when passed to simulator_set_tracing(). 281/** Turn off all tracing when passed to simulator_set_tracing(). */
268//!
269#define SIM_TRACE_NONE 0 282#define SIM_TRACE_NONE 0
270 283
271//! Turn on all tracing when passed to simulator_set_tracing(). 284/** Turn on all tracing when passed to simulator_set_tracing(). */
272//!
273#define SIM_TRACE_ALL (-1) 285#define SIM_TRACE_ALL (-1)
274 286
275//! @} 287/** @} */
276 288
277//! Computes the value to write to SPR_SIM_CONTROL to set tracing flags. 289/** Computes the value to write to SPR_SIM_CONTROL to set tracing flags. */
278//!
279#define SIM_TRACE_SPR_ARG(mask) \ 290#define SIM_TRACE_SPR_ARG(mask) \
280 (SIM_CONTROL_SET_TRACING | ((mask) << _SIM_CONTROL_OPERATOR_BITS)) 291 (SIM_CONTROL_SET_TRACING | ((mask) << _SIM_CONTROL_OPERATOR_BITS))
281 292
282 293
283//== Bit masks which can be shifted by 8, combined with 294/*
284//== SIM_CONTROL_DUMP, and written to SPR_SIM_CONTROL. 295 * Bit masks which can be shifted by 8, combined with
296 * SIM_CONTROL_DUMP, and written to SPR_SIM_CONTROL.
297 */
285 298
286//! @addtogroup arch_sim 299/**
287//! @{ 300 * @addtogroup arch_sim
301 * @{
302 */
288 303
289//! Dump the general-purpose registers. 304/** Dump the general-purpose registers. */
290//!
291#define SIM_DUMP_REGS 0x001 305#define SIM_DUMP_REGS 0x001
292 306
293//! Dump the SPRs. 307/** Dump the SPRs. */
294//!
295#define SIM_DUMP_SPRS 0x002 308#define SIM_DUMP_SPRS 0x002
296 309
297//! Dump the ITLB. 310/** Dump the ITLB. */
298//!
299#define SIM_DUMP_ITLB 0x004 311#define SIM_DUMP_ITLB 0x004
300 312
301//! Dump the DTLB. 313/** Dump the DTLB. */
302//!
303#define SIM_DUMP_DTLB 0x008 314#define SIM_DUMP_DTLB 0x008
304 315
305//! Dump the L1 I-cache. 316/** Dump the L1 I-cache. */
306//!
307#define SIM_DUMP_L1I 0x010 317#define SIM_DUMP_L1I 0x010
308 318
309//! Dump the L1 D-cache. 319/** Dump the L1 D-cache. */
310//!
311#define SIM_DUMP_L1D 0x020 320#define SIM_DUMP_L1D 0x020
312 321
313//! Dump the L2 cache. 322/** Dump the L2 cache. */
314//!
315#define SIM_DUMP_L2 0x040 323#define SIM_DUMP_L2 0x040
316 324
317//! Dump the switch registers. 325/** Dump the switch registers. */
318//!
319#define SIM_DUMP_SNREGS 0x080 326#define SIM_DUMP_SNREGS 0x080
320 327
321//! Dump the switch ITLB. 328/** Dump the switch ITLB. */
322//!
323#define SIM_DUMP_SNITLB 0x100 329#define SIM_DUMP_SNITLB 0x100
324 330
325//! Dump the switch L1 I-cache. 331/** Dump the switch L1 I-cache. */
326//!
327#define SIM_DUMP_SNL1I 0x200 332#define SIM_DUMP_SNL1I 0x200
328 333
329//! Dump the current backtrace. 334/** Dump the current backtrace. */
330//!
331#define SIM_DUMP_BACKTRACE 0x400 335#define SIM_DUMP_BACKTRACE 0x400
332 336
333//! Only dump valid lines in caches. 337/** Only dump valid lines in caches. */
334//!
335#define SIM_DUMP_VALID_LINES 0x800 338#define SIM_DUMP_VALID_LINES 0x800
336 339
337//! Dump everything that is dumpable. 340/** Dump everything that is dumpable. */
338//!
339#define SIM_DUMP_ALL (-1 & ~SIM_DUMP_VALID_LINES) 341#define SIM_DUMP_ALL (-1 & ~SIM_DUMP_VALID_LINES)
340 342
341// @} 343/** @} */
342 344
343//! Computes the value to write to SPR_SIM_CONTROL to dump machine state. 345/** Computes the value to write to SPR_SIM_CONTROL to dump machine state. */
344//!
345#define SIM_DUMP_SPR_ARG(mask) \ 346#define SIM_DUMP_SPR_ARG(mask) \
346 (SIM_CONTROL_DUMP | ((mask) << _SIM_CONTROL_OPERATOR_BITS)) 347 (SIM_CONTROL_DUMP | ((mask) << _SIM_CONTROL_OPERATOR_BITS))
347 348
348 349
349//== Bit masks which can be shifted by 8, combined with 350/*
350//== SIM_CONTROL_PROFILER_CHIP_xxx, and written to SPR_SIM_CONTROL. 351 * Bit masks which can be shifted by 8, combined with
352 * SIM_CONTROL_PROFILER_CHIP_xxx, and written to SPR_SIM_CONTROL.
353 */
351 354
352//! @addtogroup arch_sim 355/**
353//! @{ 356 * @addtogroup arch_sim
357 * @{
358 */
354 359
355//! Use with with SIM_PROFILER_CHIP_xxx to control the memory controllers. 360/** Use with with SIM_PROFILER_CHIP_xxx to control the memory controllers. */
356//!
357#define SIM_CHIP_MEMCTL 0x001 361#define SIM_CHIP_MEMCTL 0x001
358 362
359//! Use with with SIM_PROFILER_CHIP_xxx to control the XAUI interface. 363/** Use with with SIM_PROFILER_CHIP_xxx to control the XAUI interface. */
360//!
361#define SIM_CHIP_XAUI 0x002 364#define SIM_CHIP_XAUI 0x002
362 365
363//! Use with with SIM_PROFILER_CHIP_xxx to control the PCIe interface. 366/** Use with with SIM_PROFILER_CHIP_xxx to control the PCIe interface. */
364//!
365#define SIM_CHIP_PCIE 0x004 367#define SIM_CHIP_PCIE 0x004
366 368
367//! Use with with SIM_PROFILER_CHIP_xxx to control the MPIPE interface. 369/** Use with with SIM_PROFILER_CHIP_xxx to control the MPIPE interface. */
368//!
369#define SIM_CHIP_MPIPE 0x008 370#define SIM_CHIP_MPIPE 0x008
370 371
371//! Reference all chip devices. 372/** Use with with SIM_PROFILER_CHIP_xxx to control the TRIO interface. */
372//! 373#define SIM_CHIP_TRIO 0x010
374
375/** Reference all chip devices. */
373#define SIM_CHIP_ALL (-1) 376#define SIM_CHIP_ALL (-1)
374 377
375//! @} 378/** @} */
376 379
377//! Computes the value to write to SPR_SIM_CONTROL to clear chip statistics. 380/** Computes the value to write to SPR_SIM_CONTROL to clear chip statistics. */
378//!
379#define SIM_PROFILER_CHIP_CLEAR_SPR_ARG(mask) \ 381#define SIM_PROFILER_CHIP_CLEAR_SPR_ARG(mask) \
380 (SIM_CONTROL_PROFILER_CHIP_CLEAR | ((mask) << _SIM_CONTROL_OPERATOR_BITS)) 382 (SIM_CONTROL_PROFILER_CHIP_CLEAR | ((mask) << _SIM_CONTROL_OPERATOR_BITS))
381 383
382//! Computes the value to write to SPR_SIM_CONTROL to disable chip statistics. 384/** Computes the value to write to SPR_SIM_CONTROL to disable chip statistics.*/
383//!
384#define SIM_PROFILER_CHIP_DISABLE_SPR_ARG(mask) \ 385#define SIM_PROFILER_CHIP_DISABLE_SPR_ARG(mask) \
385 (SIM_CONTROL_PROFILER_CHIP_DISABLE | ((mask) << _SIM_CONTROL_OPERATOR_BITS)) 386 (SIM_CONTROL_PROFILER_CHIP_DISABLE | ((mask) << _SIM_CONTROL_OPERATOR_BITS))
386 387
387//! Computes the value to write to SPR_SIM_CONTROL to enable chip statistics. 388/** Computes the value to write to SPR_SIM_CONTROL to enable chip statistics. */
388//!
389#define SIM_PROFILER_CHIP_ENABLE_SPR_ARG(mask) \ 389#define SIM_PROFILER_CHIP_ENABLE_SPR_ARG(mask) \
390 (SIM_CONTROL_PROFILER_CHIP_ENABLE | ((mask) << _SIM_CONTROL_OPERATOR_BITS)) 390 (SIM_CONTROL_PROFILER_CHIP_ENABLE | ((mask) << _SIM_CONTROL_OPERATOR_BITS))
391 391
392 392
393 393
394// Shim bitrate controls. 394/* Shim bitrate controls. */
395 395
396//! The number of bits used to store the shim id. 396/** The number of bits used to store the shim id. */
397//!
398#define SIM_CONTROL_SHAPING_SHIM_ID_BITS 3 397#define SIM_CONTROL_SHAPING_SHIM_ID_BITS 3
399 398
400//! @addtogroup arch_sim 399/**
401//! @{ 400 * @addtogroup arch_sim
401 * @{
402 */
402 403
403//! Change the gbe 0 bitrate. 404/** Change the gbe 0 bitrate. */
404//!
405#define SIM_CONTROL_SHAPING_GBE_0 0x0 405#define SIM_CONTROL_SHAPING_GBE_0 0x0
406 406
407//! Change the gbe 1 bitrate. 407/** Change the gbe 1 bitrate. */
408//!
409#define SIM_CONTROL_SHAPING_GBE_1 0x1 408#define SIM_CONTROL_SHAPING_GBE_1 0x1
410 409
411//! Change the gbe 2 bitrate. 410/** Change the gbe 2 bitrate. */
412//!
413#define SIM_CONTROL_SHAPING_GBE_2 0x2 411#define SIM_CONTROL_SHAPING_GBE_2 0x2
414 412
415//! Change the gbe 3 bitrate. 413/** Change the gbe 3 bitrate. */
416//!
417#define SIM_CONTROL_SHAPING_GBE_3 0x3 414#define SIM_CONTROL_SHAPING_GBE_3 0x3
418 415
419//! Change the xgbe 0 bitrate. 416/** Change the xgbe 0 bitrate. */
420//!
421#define SIM_CONTROL_SHAPING_XGBE_0 0x4 417#define SIM_CONTROL_SHAPING_XGBE_0 0x4
422 418
423//! Change the xgbe 1 bitrate. 419/** Change the xgbe 1 bitrate. */
424//!
425#define SIM_CONTROL_SHAPING_XGBE_1 0x5 420#define SIM_CONTROL_SHAPING_XGBE_1 0x5
426 421
427//! The type of shaping to do. 422/** The type of shaping to do. */
428//!
429#define SIM_CONTROL_SHAPING_TYPE_BITS 2 423#define SIM_CONTROL_SHAPING_TYPE_BITS 2
430 424
431//! Control the multiplier. 425/** Control the multiplier. */
432//!
433#define SIM_CONTROL_SHAPING_MULTIPLIER 0 426#define SIM_CONTROL_SHAPING_MULTIPLIER 0
434 427
435//! Control the PPS. 428/** Control the PPS. */
436//!
437#define SIM_CONTROL_SHAPING_PPS 1 429#define SIM_CONTROL_SHAPING_PPS 1
438 430
439//! Control the BPS. 431/** Control the BPS. */
440//!
441#define SIM_CONTROL_SHAPING_BPS 2 432#define SIM_CONTROL_SHAPING_BPS 2
442 433
443//! The number of bits for the units for the shaping parameter. 434/** The number of bits for the units for the shaping parameter. */
444//!
445#define SIM_CONTROL_SHAPING_UNITS_BITS 2 435#define SIM_CONTROL_SHAPING_UNITS_BITS 2
446 436
447//! Provide a number in single units. 437/** Provide a number in single units. */
448//!
449#define SIM_CONTROL_SHAPING_UNITS_SINGLE 0 438#define SIM_CONTROL_SHAPING_UNITS_SINGLE 0
450 439
451//! Provide a number in kilo units. 440/** Provide a number in kilo units. */
452//!
453#define SIM_CONTROL_SHAPING_UNITS_KILO 1 441#define SIM_CONTROL_SHAPING_UNITS_KILO 1
454 442
455//! Provide a number in mega units. 443/** Provide a number in mega units. */
456//!
457#define SIM_CONTROL_SHAPING_UNITS_MEGA 2 444#define SIM_CONTROL_SHAPING_UNITS_MEGA 2
458 445
459//! Provide a number in giga units. 446/** Provide a number in giga units. */
460//!
461#define SIM_CONTROL_SHAPING_UNITS_GIGA 3 447#define SIM_CONTROL_SHAPING_UNITS_GIGA 3
462 448
463// @} 449/** @} */
464 450
465//! How many bits are available for the rate. 451/** How many bits are available for the rate. */
466//!
467#define SIM_CONTROL_SHAPING_RATE_BITS \ 452#define SIM_CONTROL_SHAPING_RATE_BITS \
468 (32 - (_SIM_CONTROL_OPERATOR_BITS + \ 453 (32 - (_SIM_CONTROL_OPERATOR_BITS + \
469 SIM_CONTROL_SHAPING_SHIM_ID_BITS + \ 454 SIM_CONTROL_SHAPING_SHIM_ID_BITS + \
470 SIM_CONTROL_SHAPING_TYPE_BITS + \ 455 SIM_CONTROL_SHAPING_TYPE_BITS + \
471 SIM_CONTROL_SHAPING_UNITS_BITS)) 456 SIM_CONTROL_SHAPING_UNITS_BITS))
472 457
473//! Computes the value to write to SPR_SIM_CONTROL to change a bitrate. 458/** Computes the value to write to SPR_SIM_CONTROL to change a bitrate. */
474//!
475#define SIM_SHAPING_SPR_ARG(shim, type, units, rate) \ 459#define SIM_SHAPING_SPR_ARG(shim, type, units, rate) \
476 (SIM_CONTROL_SHAPING | \ 460 (SIM_CONTROL_SHAPING | \
477 ((shim) | \ 461 ((shim) | \
@@ -483,30 +467,36 @@
483 SIM_CONTROL_SHAPING_UNITS_BITS))) << _SIM_CONTROL_OPERATOR_BITS) 467 SIM_CONTROL_SHAPING_UNITS_BITS))) << _SIM_CONTROL_OPERATOR_BITS)
484 468
485 469
486//== Values returned when reading SPR_SIM_CONTROL. 470/*
487// ISSUE: These names should share a longer common prefix. 471 * Values returned when reading SPR_SIM_CONTROL.
472 * ISSUE: These names should share a longer common prefix.
473 */
488 474
489//! When reading SPR_SIM_CONTROL, the mask of simulator tracing bits 475/**
490//! (SIM_TRACE_xxx values). 476 * When reading SPR_SIM_CONTROL, the mask of simulator tracing bits
491//! 477 * (SIM_TRACE_xxx values).
478 */
492#define SIM_TRACE_FLAG_MASK 0xFFFF 479#define SIM_TRACE_FLAG_MASK 0xFFFF
493 480
494//! When reading SPR_SIM_CONTROL, the mask for whether profiling is enabled. 481/** When reading SPR_SIM_CONTROL, the mask for whether profiling is enabled. */
495//!
496#define SIM_PROFILER_ENABLED_MASK 0x10000 482#define SIM_PROFILER_ENABLED_MASK 0x10000
497 483
498 484
499//== Special arguments for "SIM_CONTROL_PUTC". 485/*
486 * Special arguments for "SIM_CONTROL_PUTC".
487 */
500 488
501//! Flag value for forcing a PUTC string-flush, including 489/**
502//! coordinate/cycle prefix and newline. 490 * Flag value for forcing a PUTC string-flush, including
503//! 491 * coordinate/cycle prefix and newline.
492 */
504#define SIM_PUTC_FLUSH_STRING 0x100 493#define SIM_PUTC_FLUSH_STRING 0x100
505 494
506//! Flag value for forcing a PUTC binary-data-flush, which skips the 495/**
507//! prefix and does not append a newline. 496 * Flag value for forcing a PUTC binary-data-flush, which skips the
508//! 497 * prefix and does not append a newline.
498 */
509#define SIM_PUTC_FLUSH_BINARY 0x101 499#define SIM_PUTC_FLUSH_BINARY 0x101
510 500
511 501
512#endif //__ARCH_SIM_DEF_H__ 502#endif /* __ARCH_SIM_DEF_H__ */
diff --git a/arch/tile/include/arch/spr_def.h b/arch/tile/include/arch/spr_def.h
index c8fdbd9a45e..442fcba0d12 100644
--- a/arch/tile/include/arch/spr_def.h
+++ b/arch/tile/include/arch/spr_def.h
@@ -12,8 +12,93 @@
12 * more details. 12 * more details.
13 */ 13 */
14 14
15/*
16 * In addition to including the proper base SPR definition file, depending
17 * on machine architecture, this file defines several macros which allow
18 * kernel code to use protection-level dependent SPRs without worrying
19 * about which PL it's running at. In these macros, the PL that the SPR
20 * or interrupt number applies to is replaced by K.
21 */
22
23#if CONFIG_KERNEL_PL != 1 && CONFIG_KERNEL_PL != 2
24#error CONFIG_KERNEL_PL must be 1 or 2
25#endif
26
27/* Concatenate 4 strings. */
28#define __concat4(a, b, c, d) a ## b ## c ## d
29#define _concat4(a, b, c, d) __concat4(a, b, c, d)
30
15#ifdef __tilegx__ 31#ifdef __tilegx__
16#include <arch/spr_def_64.h> 32#include <arch/spr_def_64.h>
33
34/* TILE-Gx dependent, protection-level dependent SPRs. */
35
36#define SPR_INTERRUPT_MASK_K \
37 _concat4(SPR_INTERRUPT_MASK_, CONFIG_KERNEL_PL,,)
38#define SPR_INTERRUPT_MASK_SET_K \
39 _concat4(SPR_INTERRUPT_MASK_SET_, CONFIG_KERNEL_PL,,)
40#define SPR_INTERRUPT_MASK_RESET_K \
41 _concat4(SPR_INTERRUPT_MASK_RESET_, CONFIG_KERNEL_PL,,)
42#define SPR_INTERRUPT_VECTOR_BASE_K \
43 _concat4(SPR_INTERRUPT_VECTOR_BASE_, CONFIG_KERNEL_PL,,)
44
45#define SPR_IPI_MASK_K \
46 _concat4(SPR_IPI_MASK_, CONFIG_KERNEL_PL,,)
47#define SPR_IPI_MASK_RESET_K \
48 _concat4(SPR_IPI_MASK_RESET_, CONFIG_KERNEL_PL,,)
49#define SPR_IPI_MASK_SET_K \
50 _concat4(SPR_IPI_MASK_SET_, CONFIG_KERNEL_PL,,)
51#define SPR_IPI_EVENT_K \
52 _concat4(SPR_IPI_EVENT_, CONFIG_KERNEL_PL,,)
53#define SPR_IPI_EVENT_RESET_K \
54 _concat4(SPR_IPI_EVENT_RESET_, CONFIG_KERNEL_PL,,)
55#define SPR_IPI_MASK_SET_K \
56 _concat4(SPR_IPI_MASK_SET_, CONFIG_KERNEL_PL,,)
57#define INT_IPI_K \
58 _concat4(INT_IPI_, CONFIG_KERNEL_PL,,)
59
60#define SPR_SINGLE_STEP_CONTROL_K \
61 _concat4(SPR_SINGLE_STEP_CONTROL_, CONFIG_KERNEL_PL,,)
62#define SPR_SINGLE_STEP_EN_K_K \
63 _concat4(SPR_SINGLE_STEP_EN_, CONFIG_KERNEL_PL, _, CONFIG_KERNEL_PL)
64#define INT_SINGLE_STEP_K \
65 _concat4(INT_SINGLE_STEP_, CONFIG_KERNEL_PL,,)
66
17#else 67#else
18#include <arch/spr_def_32.h> 68#include <arch/spr_def_32.h>
69
70/* TILEPro dependent, protection-level dependent SPRs. */
71
72#define SPR_INTERRUPT_MASK_K_0 \
73 _concat4(SPR_INTERRUPT_MASK_, CONFIG_KERNEL_PL, _0,)
74#define SPR_INTERRUPT_MASK_K_1 \
75 _concat4(SPR_INTERRUPT_MASK_, CONFIG_KERNEL_PL, _1,)
76#define SPR_INTERRUPT_MASK_SET_K_0 \
77 _concat4(SPR_INTERRUPT_MASK_SET_, CONFIG_KERNEL_PL, _0,)
78#define SPR_INTERRUPT_MASK_SET_K_1 \
79 _concat4(SPR_INTERRUPT_MASK_SET_, CONFIG_KERNEL_PL, _1,)
80#define SPR_INTERRUPT_MASK_RESET_K_0 \
81 _concat4(SPR_INTERRUPT_MASK_RESET_, CONFIG_KERNEL_PL, _0,)
82#define SPR_INTERRUPT_MASK_RESET_K_1 \
83 _concat4(SPR_INTERRUPT_MASK_RESET_, CONFIG_KERNEL_PL, _1,)
84
19#endif 85#endif
86
87/* Generic protection-level dependent SPRs. */
88
89#define SPR_SYSTEM_SAVE_K_0 \
90 _concat4(SPR_SYSTEM_SAVE_, CONFIG_KERNEL_PL, _0,)
91#define SPR_SYSTEM_SAVE_K_1 \
92 _concat4(SPR_SYSTEM_SAVE_, CONFIG_KERNEL_PL, _1,)
93#define SPR_SYSTEM_SAVE_K_2 \
94 _concat4(SPR_SYSTEM_SAVE_, CONFIG_KERNEL_PL, _2,)
95#define SPR_SYSTEM_SAVE_K_3 \
96 _concat4(SPR_SYSTEM_SAVE_, CONFIG_KERNEL_PL, _3,)
97#define SPR_EX_CONTEXT_K_0 \
98 _concat4(SPR_EX_CONTEXT_, CONFIG_KERNEL_PL, _0,)
99#define SPR_EX_CONTEXT_K_1 \
100 _concat4(SPR_EX_CONTEXT_, CONFIG_KERNEL_PL, _1,)
101#define SPR_INTCTRL_K_STATUS \
102 _concat4(SPR_INTCTRL_, CONFIG_KERNEL_PL, _STATUS,)
103#define INT_INTCTRL_K \
104 _concat4(INT_INTCTRL_, CONFIG_KERNEL_PL,,)
diff --git a/arch/tile/include/arch/spr_def_32.h b/arch/tile/include/arch/spr_def_32.h
index b4fc06864df..bbc1f4c924e 100644
--- a/arch/tile/include/arch/spr_def_32.h
+++ b/arch/tile/include/arch/spr_def_32.h
@@ -56,58 +56,93 @@
56#define SPR_EX_CONTEXT_1_1__ICS_SHIFT 2 56#define SPR_EX_CONTEXT_1_1__ICS_SHIFT 2
57#define SPR_EX_CONTEXT_1_1__ICS_RMASK 0x1 57#define SPR_EX_CONTEXT_1_1__ICS_RMASK 0x1
58#define SPR_EX_CONTEXT_1_1__ICS_MASK 0x4 58#define SPR_EX_CONTEXT_1_1__ICS_MASK 0x4
59#define SPR_EX_CONTEXT_2_0 0x4605
60#define SPR_EX_CONTEXT_2_1 0x4606
61#define SPR_EX_CONTEXT_2_1__PL_SHIFT 0
62#define SPR_EX_CONTEXT_2_1__PL_RMASK 0x3
63#define SPR_EX_CONTEXT_2_1__PL_MASK 0x3
64#define SPR_EX_CONTEXT_2_1__ICS_SHIFT 2
65#define SPR_EX_CONTEXT_2_1__ICS_RMASK 0x1
66#define SPR_EX_CONTEXT_2_1__ICS_MASK 0x4
59#define SPR_FAIL 0x4e09 67#define SPR_FAIL 0x4e09
60#define SPR_INTCTRL_0_STATUS 0x4a07 68#define SPR_INTCTRL_0_STATUS 0x4a07
61#define SPR_INTCTRL_1_STATUS 0x4807 69#define SPR_INTCTRL_1_STATUS 0x4807
70#define SPR_INTCTRL_2_STATUS 0x4607
62#define SPR_INTERRUPT_CRITICAL_SECTION 0x4e0a 71#define SPR_INTERRUPT_CRITICAL_SECTION 0x4e0a
63#define SPR_INTERRUPT_MASK_0_0 0x4a08 72#define SPR_INTERRUPT_MASK_0_0 0x4a08
64#define SPR_INTERRUPT_MASK_0_1 0x4a09 73#define SPR_INTERRUPT_MASK_0_1 0x4a09
65#define SPR_INTERRUPT_MASK_1_0 0x4809 74#define SPR_INTERRUPT_MASK_1_0 0x4809
66#define SPR_INTERRUPT_MASK_1_1 0x480a 75#define SPR_INTERRUPT_MASK_1_1 0x480a
76#define SPR_INTERRUPT_MASK_2_0 0x4608
77#define SPR_INTERRUPT_MASK_2_1 0x4609
67#define SPR_INTERRUPT_MASK_RESET_0_0 0x4a0a 78#define SPR_INTERRUPT_MASK_RESET_0_0 0x4a0a
68#define SPR_INTERRUPT_MASK_RESET_0_1 0x4a0b 79#define SPR_INTERRUPT_MASK_RESET_0_1 0x4a0b
69#define SPR_INTERRUPT_MASK_RESET_1_0 0x480b 80#define SPR_INTERRUPT_MASK_RESET_1_0 0x480b
70#define SPR_INTERRUPT_MASK_RESET_1_1 0x480c 81#define SPR_INTERRUPT_MASK_RESET_1_1 0x480c
82#define SPR_INTERRUPT_MASK_RESET_2_0 0x460a
83#define SPR_INTERRUPT_MASK_RESET_2_1 0x460b
71#define SPR_INTERRUPT_MASK_SET_0_0 0x4a0c 84#define SPR_INTERRUPT_MASK_SET_0_0 0x4a0c
72#define SPR_INTERRUPT_MASK_SET_0_1 0x4a0d 85#define SPR_INTERRUPT_MASK_SET_0_1 0x4a0d
73#define SPR_INTERRUPT_MASK_SET_1_0 0x480d 86#define SPR_INTERRUPT_MASK_SET_1_0 0x480d
74#define SPR_INTERRUPT_MASK_SET_1_1 0x480e 87#define SPR_INTERRUPT_MASK_SET_1_1 0x480e
88#define SPR_INTERRUPT_MASK_SET_2_0 0x460c
89#define SPR_INTERRUPT_MASK_SET_2_1 0x460d
75#define SPR_MPL_DMA_CPL_SET_0 0x5800 90#define SPR_MPL_DMA_CPL_SET_0 0x5800
76#define SPR_MPL_DMA_CPL_SET_1 0x5801 91#define SPR_MPL_DMA_CPL_SET_1 0x5801
92#define SPR_MPL_DMA_CPL_SET_2 0x5802
77#define SPR_MPL_DMA_NOTIFY_SET_0 0x3800 93#define SPR_MPL_DMA_NOTIFY_SET_0 0x3800
78#define SPR_MPL_DMA_NOTIFY_SET_1 0x3801 94#define SPR_MPL_DMA_NOTIFY_SET_1 0x3801
95#define SPR_MPL_DMA_NOTIFY_SET_2 0x3802
79#define SPR_MPL_INTCTRL_0_SET_0 0x4a00 96#define SPR_MPL_INTCTRL_0_SET_0 0x4a00
80#define SPR_MPL_INTCTRL_0_SET_1 0x4a01 97#define SPR_MPL_INTCTRL_0_SET_1 0x4a01
98#define SPR_MPL_INTCTRL_0_SET_2 0x4a02
81#define SPR_MPL_INTCTRL_1_SET_0 0x4800 99#define SPR_MPL_INTCTRL_1_SET_0 0x4800
82#define SPR_MPL_INTCTRL_1_SET_1 0x4801 100#define SPR_MPL_INTCTRL_1_SET_1 0x4801
101#define SPR_MPL_INTCTRL_1_SET_2 0x4802
102#define SPR_MPL_INTCTRL_2_SET_0 0x4600
103#define SPR_MPL_INTCTRL_2_SET_1 0x4601
104#define SPR_MPL_INTCTRL_2_SET_2 0x4602
83#define SPR_MPL_SN_ACCESS_SET_0 0x0800 105#define SPR_MPL_SN_ACCESS_SET_0 0x0800
84#define SPR_MPL_SN_ACCESS_SET_1 0x0801 106#define SPR_MPL_SN_ACCESS_SET_1 0x0801
107#define SPR_MPL_SN_ACCESS_SET_2 0x0802
85#define SPR_MPL_SN_CPL_SET_0 0x5a00 108#define SPR_MPL_SN_CPL_SET_0 0x5a00
86#define SPR_MPL_SN_CPL_SET_1 0x5a01 109#define SPR_MPL_SN_CPL_SET_1 0x5a01
110#define SPR_MPL_SN_CPL_SET_2 0x5a02
87#define SPR_MPL_SN_FIREWALL_SET_0 0x2c00 111#define SPR_MPL_SN_FIREWALL_SET_0 0x2c00
88#define SPR_MPL_SN_FIREWALL_SET_1 0x2c01 112#define SPR_MPL_SN_FIREWALL_SET_1 0x2c01
113#define SPR_MPL_SN_FIREWALL_SET_2 0x2c02
89#define SPR_MPL_SN_NOTIFY_SET_0 0x2a00 114#define SPR_MPL_SN_NOTIFY_SET_0 0x2a00
90#define SPR_MPL_SN_NOTIFY_SET_1 0x2a01 115#define SPR_MPL_SN_NOTIFY_SET_1 0x2a01
116#define SPR_MPL_SN_NOTIFY_SET_2 0x2a02
91#define SPR_MPL_UDN_ACCESS_SET_0 0x0c00 117#define SPR_MPL_UDN_ACCESS_SET_0 0x0c00
92#define SPR_MPL_UDN_ACCESS_SET_1 0x0c01 118#define SPR_MPL_UDN_ACCESS_SET_1 0x0c01
119#define SPR_MPL_UDN_ACCESS_SET_2 0x0c02
93#define SPR_MPL_UDN_AVAIL_SET_0 0x4000 120#define SPR_MPL_UDN_AVAIL_SET_0 0x4000
94#define SPR_MPL_UDN_AVAIL_SET_1 0x4001 121#define SPR_MPL_UDN_AVAIL_SET_1 0x4001
122#define SPR_MPL_UDN_AVAIL_SET_2 0x4002
95#define SPR_MPL_UDN_CA_SET_0 0x3c00 123#define SPR_MPL_UDN_CA_SET_0 0x3c00
96#define SPR_MPL_UDN_CA_SET_1 0x3c01 124#define SPR_MPL_UDN_CA_SET_1 0x3c01
125#define SPR_MPL_UDN_CA_SET_2 0x3c02
97#define SPR_MPL_UDN_COMPLETE_SET_0 0x1400 126#define SPR_MPL_UDN_COMPLETE_SET_0 0x1400
98#define SPR_MPL_UDN_COMPLETE_SET_1 0x1401 127#define SPR_MPL_UDN_COMPLETE_SET_1 0x1401
128#define SPR_MPL_UDN_COMPLETE_SET_2 0x1402
99#define SPR_MPL_UDN_FIREWALL_SET_0 0x3000 129#define SPR_MPL_UDN_FIREWALL_SET_0 0x3000
100#define SPR_MPL_UDN_FIREWALL_SET_1 0x3001 130#define SPR_MPL_UDN_FIREWALL_SET_1 0x3001
131#define SPR_MPL_UDN_FIREWALL_SET_2 0x3002
101#define SPR_MPL_UDN_REFILL_SET_0 0x1000 132#define SPR_MPL_UDN_REFILL_SET_0 0x1000
102#define SPR_MPL_UDN_REFILL_SET_1 0x1001 133#define SPR_MPL_UDN_REFILL_SET_1 0x1001
134#define SPR_MPL_UDN_REFILL_SET_2 0x1002
103#define SPR_MPL_UDN_TIMER_SET_0 0x3600 135#define SPR_MPL_UDN_TIMER_SET_0 0x3600
104#define SPR_MPL_UDN_TIMER_SET_1 0x3601 136#define SPR_MPL_UDN_TIMER_SET_1 0x3601
137#define SPR_MPL_UDN_TIMER_SET_2 0x3602
105#define SPR_MPL_WORLD_ACCESS_SET_0 0x4e00 138#define SPR_MPL_WORLD_ACCESS_SET_0 0x4e00
106#define SPR_MPL_WORLD_ACCESS_SET_1 0x4e01 139#define SPR_MPL_WORLD_ACCESS_SET_1 0x4e01
140#define SPR_MPL_WORLD_ACCESS_SET_2 0x4e02
107#define SPR_PASS 0x4e0b 141#define SPR_PASS 0x4e0b
108#define SPR_PERF_COUNT_0 0x4205 142#define SPR_PERF_COUNT_0 0x4205
109#define SPR_PERF_COUNT_1 0x4206 143#define SPR_PERF_COUNT_1 0x4206
110#define SPR_PERF_COUNT_CTL 0x4207 144#define SPR_PERF_COUNT_CTL 0x4207
145#define SPR_PERF_COUNT_DN_CTL 0x4210
111#define SPR_PERF_COUNT_STS 0x4208 146#define SPR_PERF_COUNT_STS 0x4208
112#define SPR_PROC_STATUS 0x4f00 147#define SPR_PROC_STATUS 0x4f00
113#define SPR_SIM_CONTROL 0x4e0c 148#define SPR_SIM_CONTROL 0x4e0c
@@ -124,6 +159,10 @@
124#define SPR_SYSTEM_SAVE_1_1 0x4901 159#define SPR_SYSTEM_SAVE_1_1 0x4901
125#define SPR_SYSTEM_SAVE_1_2 0x4902 160#define SPR_SYSTEM_SAVE_1_2 0x4902
126#define SPR_SYSTEM_SAVE_1_3 0x4903 161#define SPR_SYSTEM_SAVE_1_3 0x4903
162#define SPR_SYSTEM_SAVE_2_0 0x4700
163#define SPR_SYSTEM_SAVE_2_1 0x4701
164#define SPR_SYSTEM_SAVE_2_2 0x4702
165#define SPR_SYSTEM_SAVE_2_3 0x4703
127#define SPR_TILE_COORD 0x4c17 166#define SPR_TILE_COORD 0x4c17
128#define SPR_TILE_RTF_HWM 0x4e10 167#define SPR_TILE_RTF_HWM 0x4e10
129#define SPR_TILE_TIMER_CONTROL 0x3205 168#define SPR_TILE_TIMER_CONTROL 0x3205
diff --git a/arch/tile/include/asm/backtrace.h b/arch/tile/include/asm/backtrace.h
index 758ca4619d5..f18887d8239 100644
--- a/arch/tile/include/asm/backtrace.h
+++ b/arch/tile/include/asm/backtrace.h
@@ -146,7 +146,10 @@ enum {
146 146
147 CALLER_SP_IN_R52_BASE = 4, 147 CALLER_SP_IN_R52_BASE = 4,
148 148
149 CALLER_SP_OFFSET_BASE = 8 149 CALLER_SP_OFFSET_BASE = 8,
150
151 /* Marks the entry point of certain functions. */
152 ENTRY_POINT_INFO_OP = 16
150}; 153};
151 154
152 155
diff --git a/arch/tile/include/asm/compat.h b/arch/tile/include/asm/compat.h
index 8b60ec8b2d1..c3ae570c0a5 100644
--- a/arch/tile/include/asm/compat.h
+++ b/arch/tile/include/asm/compat.h
@@ -216,15 +216,16 @@ struct compat_siginfo;
216struct compat_sigaltstack; 216struct compat_sigaltstack;
217long compat_sys_execve(const char __user *path, 217long compat_sys_execve(const char __user *path,
218 const compat_uptr_t __user *argv, 218 const compat_uptr_t __user *argv,
219 const compat_uptr_t __user *envp); 219 const compat_uptr_t __user *envp, struct pt_regs *);
220long compat_sys_rt_sigaction(int sig, struct compat_sigaction __user *act, 220long compat_sys_rt_sigaction(int sig, struct compat_sigaction __user *act,
221 struct compat_sigaction __user *oact, 221 struct compat_sigaction __user *oact,
222 size_t sigsetsize); 222 size_t sigsetsize);
223long compat_sys_rt_sigqueueinfo(int pid, int sig, 223long compat_sys_rt_sigqueueinfo(int pid, int sig,
224 struct compat_siginfo __user *uinfo); 224 struct compat_siginfo __user *uinfo);
225long compat_sys_rt_sigreturn(void); 225long compat_sys_rt_sigreturn(struct pt_regs *);
226long compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr, 226long compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr,
227 struct compat_sigaltstack __user *uoss_ptr); 227 struct compat_sigaltstack __user *uoss_ptr,
228 struct pt_regs *);
228long compat_sys_truncate64(char __user *filename, u32 dummy, u32 low, u32 high); 229long compat_sys_truncate64(char __user *filename, u32 dummy, u32 low, u32 high);
229long compat_sys_ftruncate64(unsigned int fd, u32 dummy, u32 low, u32 high); 230long compat_sys_ftruncate64(unsigned int fd, u32 dummy, u32 low, u32 high);
230long compat_sys_pread64(unsigned int fd, char __user *ubuf, size_t count, 231long compat_sys_pread64(unsigned int fd, char __user *ubuf, size_t count,
@@ -255,4 +256,12 @@ long tile_compat_sys_ptrace(compat_long_t request, compat_long_t pid,
255/* Tilera Linux syscalls that don't have "compat" versions. */ 256/* Tilera Linux syscalls that don't have "compat" versions. */
256#define compat_sys_flush_cache sys_flush_cache 257#define compat_sys_flush_cache sys_flush_cache
257 258
259/* These are the intvec_64.S trampolines. */
260long _compat_sys_execve(const char __user *path,
261 const compat_uptr_t __user *argv,
262 const compat_uptr_t __user *envp);
263long _compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr,
264 struct compat_sigaltstack __user *uoss_ptr);
265long _compat_sys_rt_sigreturn(void);
266
258#endif /* _ASM_TILE_COMPAT_H */ 267#endif /* _ASM_TILE_COMPAT_H */
diff --git a/arch/tile/include/asm/irqflags.h b/arch/tile/include/asm/irqflags.h
index a11d4837ee4..641e4ff3d80 100644
--- a/arch/tile/include/asm/irqflags.h
+++ b/arch/tile/include/asm/irqflags.h
@@ -47,53 +47,53 @@
47 int __n = (n); \ 47 int __n = (n); \
48 int __mask = 1 << (__n & 0x1f); \ 48 int __mask = 1 << (__n & 0x1f); \
49 if (__n < 32) \ 49 if (__n < 32) \
50 __insn_mtspr(SPR_INTERRUPT_MASK_SET_1_0, __mask); \ 50 __insn_mtspr(SPR_INTERRUPT_MASK_SET_K_0, __mask); \
51 else \ 51 else \
52 __insn_mtspr(SPR_INTERRUPT_MASK_SET_1_1, __mask); \ 52 __insn_mtspr(SPR_INTERRUPT_MASK_SET_K_1, __mask); \
53} while (0) 53} while (0)
54#define interrupt_mask_reset(n) do { \ 54#define interrupt_mask_reset(n) do { \
55 int __n = (n); \ 55 int __n = (n); \
56 int __mask = 1 << (__n & 0x1f); \ 56 int __mask = 1 << (__n & 0x1f); \
57 if (__n < 32) \ 57 if (__n < 32) \
58 __insn_mtspr(SPR_INTERRUPT_MASK_RESET_1_0, __mask); \ 58 __insn_mtspr(SPR_INTERRUPT_MASK_RESET_K_0, __mask); \
59 else \ 59 else \
60 __insn_mtspr(SPR_INTERRUPT_MASK_RESET_1_1, __mask); \ 60 __insn_mtspr(SPR_INTERRUPT_MASK_RESET_K_1, __mask); \
61} while (0) 61} while (0)
62#define interrupt_mask_check(n) ({ \ 62#define interrupt_mask_check(n) ({ \
63 int __n = (n); \ 63 int __n = (n); \
64 (((__n < 32) ? \ 64 (((__n < 32) ? \
65 __insn_mfspr(SPR_INTERRUPT_MASK_1_0) : \ 65 __insn_mfspr(SPR_INTERRUPT_MASK_K_0) : \
66 __insn_mfspr(SPR_INTERRUPT_MASK_1_1)) \ 66 __insn_mfspr(SPR_INTERRUPT_MASK_K_1)) \
67 >> (__n & 0x1f)) & 1; \ 67 >> (__n & 0x1f)) & 1; \
68}) 68})
69#define interrupt_mask_set_mask(mask) do { \ 69#define interrupt_mask_set_mask(mask) do { \
70 unsigned long long __m = (mask); \ 70 unsigned long long __m = (mask); \
71 __insn_mtspr(SPR_INTERRUPT_MASK_SET_1_0, (unsigned long)(__m)); \ 71 __insn_mtspr(SPR_INTERRUPT_MASK_SET_K_0, (unsigned long)(__m)); \
72 __insn_mtspr(SPR_INTERRUPT_MASK_SET_1_1, (unsigned long)(__m>>32)); \ 72 __insn_mtspr(SPR_INTERRUPT_MASK_SET_K_1, (unsigned long)(__m>>32)); \
73} while (0) 73} while (0)
74#define interrupt_mask_reset_mask(mask) do { \ 74#define interrupt_mask_reset_mask(mask) do { \
75 unsigned long long __m = (mask); \ 75 unsigned long long __m = (mask); \
76 __insn_mtspr(SPR_INTERRUPT_MASK_RESET_1_0, (unsigned long)(__m)); \ 76 __insn_mtspr(SPR_INTERRUPT_MASK_RESET_K_0, (unsigned long)(__m)); \
77 __insn_mtspr(SPR_INTERRUPT_MASK_RESET_1_1, (unsigned long)(__m>>32)); \ 77 __insn_mtspr(SPR_INTERRUPT_MASK_RESET_K_1, (unsigned long)(__m>>32)); \
78} while (0) 78} while (0)
79#else 79#else
80#define interrupt_mask_set(n) \ 80#define interrupt_mask_set(n) \
81 __insn_mtspr(SPR_INTERRUPT_MASK_SET_1, (1UL << (n))) 81 __insn_mtspr(SPR_INTERRUPT_MASK_SET_K, (1UL << (n)))
82#define interrupt_mask_reset(n) \ 82#define interrupt_mask_reset(n) \
83 __insn_mtspr(SPR_INTERRUPT_MASK_RESET_1, (1UL << (n))) 83 __insn_mtspr(SPR_INTERRUPT_MASK_RESET_K, (1UL << (n)))
84#define interrupt_mask_check(n) \ 84#define interrupt_mask_check(n) \
85 ((__insn_mfspr(SPR_INTERRUPT_MASK_1) >> (n)) & 1) 85 ((__insn_mfspr(SPR_INTERRUPT_MASK_K) >> (n)) & 1)
86#define interrupt_mask_set_mask(mask) \ 86#define interrupt_mask_set_mask(mask) \
87 __insn_mtspr(SPR_INTERRUPT_MASK_SET_1, (mask)) 87 __insn_mtspr(SPR_INTERRUPT_MASK_SET_K, (mask))
88#define interrupt_mask_reset_mask(mask) \ 88#define interrupt_mask_reset_mask(mask) \
89 __insn_mtspr(SPR_INTERRUPT_MASK_RESET_1, (mask)) 89 __insn_mtspr(SPR_INTERRUPT_MASK_RESET_K, (mask))
90#endif 90#endif
91 91
92/* 92/*
93 * The set of interrupts we want active if irqs are enabled. 93 * The set of interrupts we want active if irqs are enabled.
94 * Note that in particular, the tile timer interrupt comes and goes 94 * Note that in particular, the tile timer interrupt comes and goes
95 * from this set, since we have no other way to turn off the timer. 95 * from this set, since we have no other way to turn off the timer.
96 * Likewise, INTCTRL_1 is removed and re-added during device 96 * Likewise, INTCTRL_K is removed and re-added during device
97 * interrupts, as is the the hardwall UDN_FIREWALL interrupt. 97 * interrupts, as is the the hardwall UDN_FIREWALL interrupt.
98 * We use a low bit (MEM_ERROR) as our sentinel value and make sure it 98 * We use a low bit (MEM_ERROR) as our sentinel value and make sure it
99 * is always claimed as an "active interrupt" so we can query that bit 99 * is always claimed as an "active interrupt" so we can query that bit
@@ -170,14 +170,14 @@ DECLARE_PER_CPU(unsigned long long, interrupts_enabled_mask);
170 170
171/* Return 0 or 1 to indicate whether interrupts are currently disabled. */ 171/* Return 0 or 1 to indicate whether interrupts are currently disabled. */
172#define IRQS_DISABLED(tmp) \ 172#define IRQS_DISABLED(tmp) \
173 mfspr tmp, INTERRUPT_MASK_1; \ 173 mfspr tmp, SPR_INTERRUPT_MASK_K; \
174 andi tmp, tmp, 1 174 andi tmp, tmp, 1
175 175
176/* Load up a pointer to &interrupts_enabled_mask. */ 176/* Load up a pointer to &interrupts_enabled_mask. */
177#define GET_INTERRUPTS_ENABLED_MASK_PTR(reg) \ 177#define GET_INTERRUPTS_ENABLED_MASK_PTR(reg) \
178 moveli reg, hw2_last(interrupts_enabled_mask); \ 178 moveli reg, hw2_last(interrupts_enabled_mask); \
179 shl16insli reg, reg, hw1(interrupts_enabled_mask); \ 179 shl16insli reg, reg, hw1(interrupts_enabled_mask); \
180 shl16insli reg, reg, hw0(interrupts_enabled_mask); \ 180 shl16insli reg, reg, hw0(interrupts_enabled_mask); \
181 add reg, reg, tp 181 add reg, reg, tp
182 182
183/* Disable interrupts. */ 183/* Disable interrupts. */
@@ -185,18 +185,18 @@ DECLARE_PER_CPU(unsigned long long, interrupts_enabled_mask);
185 moveli tmp0, hw2_last(LINUX_MASKABLE_INTERRUPTS); \ 185 moveli tmp0, hw2_last(LINUX_MASKABLE_INTERRUPTS); \
186 shl16insli tmp0, tmp0, hw1(LINUX_MASKABLE_INTERRUPTS); \ 186 shl16insli tmp0, tmp0, hw1(LINUX_MASKABLE_INTERRUPTS); \
187 shl16insli tmp0, tmp0, hw0(LINUX_MASKABLE_INTERRUPTS); \ 187 shl16insli tmp0, tmp0, hw0(LINUX_MASKABLE_INTERRUPTS); \
188 mtspr INTERRUPT_MASK_SET_1, tmp0 188 mtspr SPR_INTERRUPT_MASK_SET_K, tmp0
189 189
190/* Disable ALL synchronous interrupts (used by NMI entry). */ 190/* Disable ALL synchronous interrupts (used by NMI entry). */
191#define IRQ_DISABLE_ALL(tmp) \ 191#define IRQ_DISABLE_ALL(tmp) \
192 movei tmp, -1; \ 192 movei tmp, -1; \
193 mtspr INTERRUPT_MASK_SET_1, tmp 193 mtspr SPR_INTERRUPT_MASK_SET_K, tmp
194 194
195/* Enable interrupts. */ 195/* Enable interrupts. */
196#define IRQ_ENABLE(tmp0, tmp1) \ 196#define IRQ_ENABLE(tmp0, tmp1) \
197 GET_INTERRUPTS_ENABLED_MASK_PTR(tmp0); \ 197 GET_INTERRUPTS_ENABLED_MASK_PTR(tmp0); \
198 ld tmp0, tmp0; \ 198 ld tmp0, tmp0; \
199 mtspr INTERRUPT_MASK_RESET_1, tmp0 199 mtspr SPR_INTERRUPT_MASK_RESET_K, tmp0
200 200
201#else /* !__tilegx__ */ 201#else /* !__tilegx__ */
202 202
@@ -210,14 +210,14 @@ DECLARE_PER_CPU(unsigned long long, interrupts_enabled_mask);
210 * (making the original code's write of the "high" mask word idempotent). 210 * (making the original code's write of the "high" mask word idempotent).
211 */ 211 */
212#define IRQS_DISABLED(tmp) \ 212#define IRQS_DISABLED(tmp) \
213 mfspr tmp, INTERRUPT_MASK_1_0; \ 213 mfspr tmp, SPR_INTERRUPT_MASK_K_0; \
214 shri tmp, tmp, INT_MEM_ERROR; \ 214 shri tmp, tmp, INT_MEM_ERROR; \
215 andi tmp, tmp, 1 215 andi tmp, tmp, 1
216 216
217/* Load up a pointer to &interrupts_enabled_mask. */ 217/* Load up a pointer to &interrupts_enabled_mask. */
218#define GET_INTERRUPTS_ENABLED_MASK_PTR(reg) \ 218#define GET_INTERRUPTS_ENABLED_MASK_PTR(reg) \
219 moveli reg, lo16(interrupts_enabled_mask); \ 219 moveli reg, lo16(interrupts_enabled_mask); \
220 auli reg, reg, ha16(interrupts_enabled_mask);\ 220 auli reg, reg, ha16(interrupts_enabled_mask); \
221 add reg, reg, tp 221 add reg, reg, tp
222 222
223/* Disable interrupts. */ 223/* Disable interrupts. */
@@ -227,16 +227,16 @@ DECLARE_PER_CPU(unsigned long long, interrupts_enabled_mask);
227 moveli tmp1, lo16(LINUX_MASKABLE_INTERRUPTS) \ 227 moveli tmp1, lo16(LINUX_MASKABLE_INTERRUPTS) \
228 }; \ 228 }; \
229 { \ 229 { \
230 mtspr INTERRUPT_MASK_SET_1_0, tmp0; \ 230 mtspr SPR_INTERRUPT_MASK_SET_K_0, tmp0; \
231 auli tmp1, tmp1, ha16(LINUX_MASKABLE_INTERRUPTS) \ 231 auli tmp1, tmp1, ha16(LINUX_MASKABLE_INTERRUPTS) \
232 }; \ 232 }; \
233 mtspr INTERRUPT_MASK_SET_1_1, tmp1 233 mtspr SPR_INTERRUPT_MASK_SET_K_1, tmp1
234 234
235/* Disable ALL synchronous interrupts (used by NMI entry). */ 235/* Disable ALL synchronous interrupts (used by NMI entry). */
236#define IRQ_DISABLE_ALL(tmp) \ 236#define IRQ_DISABLE_ALL(tmp) \
237 movei tmp, -1; \ 237 movei tmp, -1; \
238 mtspr INTERRUPT_MASK_SET_1_0, tmp; \ 238 mtspr SPR_INTERRUPT_MASK_SET_K_0, tmp; \
239 mtspr INTERRUPT_MASK_SET_1_1, tmp 239 mtspr SPR_INTERRUPT_MASK_SET_K_1, tmp
240 240
241/* Enable interrupts. */ 241/* Enable interrupts. */
242#define IRQ_ENABLE(tmp0, tmp1) \ 242#define IRQ_ENABLE(tmp0, tmp1) \
@@ -246,8 +246,8 @@ DECLARE_PER_CPU(unsigned long long, interrupts_enabled_mask);
246 addi tmp1, tmp0, 4 \ 246 addi tmp1, tmp0, 4 \
247 }; \ 247 }; \
248 lw tmp1, tmp1; \ 248 lw tmp1, tmp1; \
249 mtspr INTERRUPT_MASK_RESET_1_0, tmp0; \ 249 mtspr SPR_INTERRUPT_MASK_RESET_K_0, tmp0; \
250 mtspr INTERRUPT_MASK_RESET_1_1, tmp1 250 mtspr SPR_INTERRUPT_MASK_RESET_K_1, tmp1
251#endif 251#endif
252 252
253/* 253/*
diff --git a/arch/tile/include/asm/mman.h b/arch/tile/include/asm/mman.h
index 4c6811e3e8d..81b8fc348d6 100644
--- a/arch/tile/include/asm/mman.h
+++ b/arch/tile/include/asm/mman.h
@@ -23,6 +23,7 @@
23#define MAP_POPULATE 0x0040 /* populate (prefault) pagetables */ 23#define MAP_POPULATE 0x0040 /* populate (prefault) pagetables */
24#define MAP_NONBLOCK 0x0080 /* do not block on IO */ 24#define MAP_NONBLOCK 0x0080 /* do not block on IO */
25#define MAP_GROWSDOWN 0x0100 /* stack-like segment */ 25#define MAP_GROWSDOWN 0x0100 /* stack-like segment */
26#define MAP_STACK MAP_GROWSDOWN /* provide convenience alias */
26#define MAP_LOCKED 0x0200 /* pages are locked */ 27#define MAP_LOCKED 0x0200 /* pages are locked */
27#define MAP_NORESERVE 0x0400 /* don't check for reservations */ 28#define MAP_NORESERVE 0x0400 /* don't check for reservations */
28#define MAP_DENYWRITE 0x0800 /* ETXTBSY */ 29#define MAP_DENYWRITE 0x0800 /* ETXTBSY */
diff --git a/arch/tile/include/asm/page.h b/arch/tile/include/asm/page.h
index 7d90641cf18..7979a45430d 100644
--- a/arch/tile/include/asm/page.h
+++ b/arch/tile/include/asm/page.h
@@ -199,17 +199,17 @@ static inline __attribute_const__ int get_order(unsigned long size)
199 * If you want more physical memory than this then see the CONFIG_HIGHMEM 199 * If you want more physical memory than this then see the CONFIG_HIGHMEM
200 * option in the kernel configuration. 200 * option in the kernel configuration.
201 * 201 *
202 * The top two 16MB chunks in the table below (VIRT and HV) are 202 * The top 16MB chunk in the table below is unavailable to Linux. Since
203 * unavailable to Linux. Since the kernel interrupt vectors must live 203 * the kernel interrupt vectors must live at ether 0xfe000000 or 0xfd000000
204 * at 0xfd000000, we map all of the bottom of RAM at this address with 204 * (depending on whether the kernel is at PL2 or Pl1), we map all of the
205 * a huge page table entry to minimize its ITLB footprint (as well as 205 * bottom of RAM at this address with a huge page table entry to minimize
206 * at PAGE_OFFSET). The last architected requirement is that user 206 * its ITLB footprint (as well as at PAGE_OFFSET). The last architected
207 * interrupt vectors live at 0xfc000000, so we make that range of 207 * requirement is that user interrupt vectors live at 0xfc000000, so we
208 * memory available to user processes. The remaining regions are sized 208 * make that range of memory available to user processes. The remaining
209 * as shown; after the first four addresses, we show "typical" values, 209 * regions are sized as shown; the first four addresses use the PL 1
210 * since the actual addresses depend on kernel #defines. 210 * values, and after that, we show "typical" values, since the actual
211 * addresses depend on kernel #defines.
211 * 212 *
212 * MEM_VIRT_INTRPT 0xff000000
213 * MEM_HV_INTRPT 0xfe000000 213 * MEM_HV_INTRPT 0xfe000000
214 * MEM_SV_INTRPT (kernel code) 0xfd000000 214 * MEM_SV_INTRPT (kernel code) 0xfd000000
215 * MEM_USER_INTRPT (user vector) 0xfc000000 215 * MEM_USER_INTRPT (user vector) 0xfc000000
@@ -221,9 +221,14 @@ static inline __attribute_const__ int get_order(unsigned long size)
221 */ 221 */
222 222
223#define MEM_USER_INTRPT _AC(0xfc000000, UL) 223#define MEM_USER_INTRPT _AC(0xfc000000, UL)
224#if CONFIG_KERNEL_PL == 1
224#define MEM_SV_INTRPT _AC(0xfd000000, UL) 225#define MEM_SV_INTRPT _AC(0xfd000000, UL)
225#define MEM_HV_INTRPT _AC(0xfe000000, UL) 226#define MEM_HV_INTRPT _AC(0xfe000000, UL)
226#define MEM_VIRT_INTRPT _AC(0xff000000, UL) 227#else
228#define MEM_GUEST_INTRPT _AC(0xfd000000, UL)
229#define MEM_SV_INTRPT _AC(0xfe000000, UL)
230#define MEM_HV_INTRPT _AC(0xff000000, UL)
231#endif
227 232
228#define INTRPT_SIZE 0x4000 233#define INTRPT_SIZE 0x4000
229 234
diff --git a/arch/tile/include/asm/processor.h b/arch/tile/include/asm/processor.h
index ccd5f842568..1747ff3946b 100644
--- a/arch/tile/include/asm/processor.h
+++ b/arch/tile/include/asm/processor.h
@@ -328,18 +328,21 @@ extern int kdata_huge;
328 * Note that assembly code assumes that USER_PL is zero. 328 * Note that assembly code assumes that USER_PL is zero.
329 */ 329 */
330#define USER_PL 0 330#define USER_PL 0
331#define KERNEL_PL 1 331#if CONFIG_KERNEL_PL == 2
332#define GUEST_PL 1
333#endif
334#define KERNEL_PL CONFIG_KERNEL_PL
332 335
333/* SYSTEM_SAVE_1_0 holds the current cpu number ORed with ksp0. */ 336/* SYSTEM_SAVE_K_0 holds the current cpu number ORed with ksp0. */
334#define CPU_LOG_MASK_VALUE 12 337#define CPU_LOG_MASK_VALUE 12
335#define CPU_MASK_VALUE ((1 << CPU_LOG_MASK_VALUE) - 1) 338#define CPU_MASK_VALUE ((1 << CPU_LOG_MASK_VALUE) - 1)
336#if CONFIG_NR_CPUS > CPU_MASK_VALUE 339#if CONFIG_NR_CPUS > CPU_MASK_VALUE
337# error Too many cpus! 340# error Too many cpus!
338#endif 341#endif
339#define raw_smp_processor_id() \ 342#define raw_smp_processor_id() \
340 ((int)__insn_mfspr(SPR_SYSTEM_SAVE_1_0) & CPU_MASK_VALUE) 343 ((int)__insn_mfspr(SPR_SYSTEM_SAVE_K_0) & CPU_MASK_VALUE)
341#define get_current_ksp0() \ 344#define get_current_ksp0() \
342 (__insn_mfspr(SPR_SYSTEM_SAVE_1_0) & ~CPU_MASK_VALUE) 345 (__insn_mfspr(SPR_SYSTEM_SAVE_K_0) & ~CPU_MASK_VALUE)
343#define next_current_ksp0(task) ({ \ 346#define next_current_ksp0(task) ({ \
344 unsigned long __ksp0 = task_ksp0(task); \ 347 unsigned long __ksp0 = task_ksp0(task); \
345 int __cpu = raw_smp_processor_id(); \ 348 int __cpu = raw_smp_processor_id(); \
diff --git a/arch/tile/include/asm/ptrace.h b/arch/tile/include/asm/ptrace.h
index 4a02bb07397..ac6d343129d 100644
--- a/arch/tile/include/asm/ptrace.h
+++ b/arch/tile/include/asm/ptrace.h
@@ -62,8 +62,8 @@ struct pt_regs {
62 pt_reg_t lr; /* aliases regs[TREG_LR] */ 62 pt_reg_t lr; /* aliases regs[TREG_LR] */
63 63
64 /* Saved special registers. */ 64 /* Saved special registers. */
65 pt_reg_t pc; /* stored in EX_CONTEXT_1_0 */ 65 pt_reg_t pc; /* stored in EX_CONTEXT_K_0 */
66 pt_reg_t ex1; /* stored in EX_CONTEXT_1_1 (PL and ICS bit) */ 66 pt_reg_t ex1; /* stored in EX_CONTEXT_K_1 (PL and ICS bit) */
67 pt_reg_t faultnum; /* fault number (INT_SWINT_1 for syscall) */ 67 pt_reg_t faultnum; /* fault number (INT_SWINT_1 for syscall) */
68 pt_reg_t orig_r0; /* r0 at syscall entry, else zero */ 68 pt_reg_t orig_r0; /* r0 at syscall entry, else zero */
69 pt_reg_t flags; /* flags (see below) */ 69 pt_reg_t flags; /* flags (see below) */
diff --git a/arch/tile/include/asm/syscalls.h b/arch/tile/include/asm/syscalls.h
index ce99ffefeac..3b5507c31ea 100644
--- a/arch/tile/include/asm/syscalls.h
+++ b/arch/tile/include/asm/syscalls.h
@@ -32,8 +32,9 @@ extern void *compat_sys_call_table[];
32 32
33/* 33/*
34 * Note that by convention, any syscall which requires the current 34 * Note that by convention, any syscall which requires the current
35 * register set takes an additional "struct pt_regs *" pointer; the 35 * register set takes an additional "struct pt_regs *" pointer; a
36 * sys_xxx() function just adds the pointer and tail-calls to _sys_xxx(). 36 * _sys_xxx() trampoline in intvec*.S just sets up the pointer and
37 * jumps to sys_xxx().
37 */ 38 */
38 39
39/* kernel/sys.c */ 40/* kernel/sys.c */
@@ -43,66 +44,17 @@ long sys32_fadvise64(int fd, u32 offset_lo, u32 offset_hi,
43int sys32_fadvise64_64(int fd, u32 offset_lo, u32 offset_hi, 44int sys32_fadvise64_64(int fd, u32 offset_lo, u32 offset_hi,
44 u32 len_lo, u32 len_hi, int advice); 45 u32 len_lo, u32 len_hi, int advice);
45long sys_flush_cache(void); 46long sys_flush_cache(void);
46long sys_mmap2(unsigned long addr, unsigned long len, 47#ifndef __tilegx__ /* No mmap() in the 32-bit kernel. */
47 unsigned long prot, unsigned long flags, 48#define sys_mmap sys_mmap
48 unsigned long fd, unsigned long pgoff);
49#ifdef __tilegx__
50long sys_mmap(unsigned long addr, unsigned long len,
51 unsigned long prot, unsigned long flags,
52 unsigned long fd, off_t pgoff);
53#endif 49#endif
54 50
55/* kernel/process.c */
56long sys_clone(unsigned long clone_flags, unsigned long newsp,
57 void __user *parent_tid, void __user *child_tid);
58long _sys_clone(unsigned long clone_flags, unsigned long newsp,
59 void __user *parent_tid, void __user *child_tid,
60 struct pt_regs *regs);
61long sys_fork(void);
62long _sys_fork(struct pt_regs *regs);
63long sys_vfork(void);
64long _sys_vfork(struct pt_regs *regs);
65long sys_execve(const char __user *filename,
66 const char __user *const __user *argv,
67 const char __user *const __user *envp);
68long _sys_execve(const char __user *filename,
69 const char __user *const __user *argv,
70 const char __user *const __user *envp, struct pt_regs *regs);
71
72/* kernel/signal.c */
73long sys_sigaltstack(const stack_t __user *, stack_t __user *);
74long _sys_sigaltstack(const stack_t __user *, stack_t __user *,
75 struct pt_regs *);
76long sys_rt_sigreturn(void);
77long _sys_rt_sigreturn(struct pt_regs *regs);
78
79/* platform-independent functions */
80long sys_rt_sigsuspend(sigset_t __user *unewset, size_t sigsetsize);
81long sys_rt_sigaction(int sig, const struct sigaction __user *act,
82 struct sigaction __user *oact, size_t sigsetsize);
83
84#ifndef __tilegx__ 51#ifndef __tilegx__
85/* mm/fault.c */ 52/* mm/fault.c */
86int sys_cmpxchg_badaddr(unsigned long address); 53long sys_cmpxchg_badaddr(unsigned long address, struct pt_regs *);
87int _sys_cmpxchg_badaddr(unsigned long address, struct pt_regs *); 54long _sys_cmpxchg_badaddr(unsigned long address);
88#endif 55#endif
89 56
90#ifdef CONFIG_COMPAT 57#ifdef CONFIG_COMPAT
91long compat_sys_execve(const char __user *path,
92 const compat_uptr_t __user *argv,
93 const compat_uptr_t __user *envp);
94long _compat_sys_execve(const char __user *path,
95 const compat_uptr_t __user *argv,
96 const compat_uptr_t __user *envp,
97 struct pt_regs *regs);
98long compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr,
99 struct compat_sigaltstack __user *uoss_ptr);
100long _compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr,
101 struct compat_sigaltstack __user *uoss_ptr,
102 struct pt_regs *regs);
103long compat_sys_rt_sigreturn(void);
104long _compat_sys_rt_sigreturn(struct pt_regs *regs);
105
106/* These four are not defined for 64-bit, but serve as "compat" syscalls. */ 58/* These four are not defined for 64-bit, but serve as "compat" syscalls. */
107long sys_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg); 59long sys_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg);
108long sys_fstat64(unsigned long fd, struct stat64 __user *statbuf); 60long sys_fstat64(unsigned long fd, struct stat64 __user *statbuf);
@@ -110,4 +62,15 @@ long sys_truncate64(const char __user *path, loff_t length);
110long sys_ftruncate64(unsigned int fd, loff_t length); 62long sys_ftruncate64(unsigned int fd, loff_t length);
111#endif 63#endif
112 64
65/* These are the intvec*.S trampolines. */
66long _sys_sigaltstack(const stack_t __user *, stack_t __user *);
67long _sys_rt_sigreturn(void);
68long _sys_clone(unsigned long clone_flags, unsigned long newsp,
69 void __user *parent_tid, void __user *child_tid);
70long _sys_execve(const char __user *filename,
71 const char __user *const __user *argv,
72 const char __user *const __user *envp);
73
74#include <asm-generic/syscalls.h>
75
113#endif /* _ASM_TILE_SYSCALLS_H */ 76#endif /* _ASM_TILE_SYSCALLS_H */
diff --git a/arch/tile/include/asm/system.h b/arch/tile/include/asm/system.h
index f749be327ce..5388850deeb 100644
--- a/arch/tile/include/asm/system.h
+++ b/arch/tile/include/asm/system.h
@@ -89,6 +89,10 @@
89#define get_cycles_low() __insn_mfspr(SPR_CYCLE) /* just get all 64 bits */ 89#define get_cycles_low() __insn_mfspr(SPR_CYCLE) /* just get all 64 bits */
90#endif 90#endif
91 91
92#if !CHIP_HAS_MF_WAITS_FOR_VICTIMS()
93int __mb_incoherent(void); /* Helper routine for mb_incoherent(). */
94#endif
95
92/* Fence to guarantee visibility of stores to incoherent memory. */ 96/* Fence to guarantee visibility of stores to incoherent memory. */
93static inline void 97static inline void
94mb_incoherent(void) 98mb_incoherent(void)
@@ -97,7 +101,6 @@ mb_incoherent(void)
97 101
98#if !CHIP_HAS_MF_WAITS_FOR_VICTIMS() 102#if !CHIP_HAS_MF_WAITS_FOR_VICTIMS()
99 { 103 {
100 int __mb_incoherent(void);
101#if CHIP_HAS_TILE_WRITE_PENDING() 104#if CHIP_HAS_TILE_WRITE_PENDING()
102 const unsigned long WRITE_TIMEOUT_CYCLES = 400; 105 const unsigned long WRITE_TIMEOUT_CYCLES = 400;
103 unsigned long start = get_cycles_low(); 106 unsigned long start = get_cycles_low();
@@ -161,7 +164,7 @@ extern struct task_struct *_switch_to(struct task_struct *prev,
161/* Helper function for _switch_to(). */ 164/* Helper function for _switch_to(). */
162extern struct task_struct *__switch_to(struct task_struct *prev, 165extern struct task_struct *__switch_to(struct task_struct *prev,
163 struct task_struct *next, 166 struct task_struct *next,
164 unsigned long new_system_save_1_0); 167 unsigned long new_system_save_k_0);
165 168
166/* Address that switched-away from tasks are at. */ 169/* Address that switched-away from tasks are at. */
167extern unsigned long get_switch_to_pc(void); 170extern unsigned long get_switch_to_pc(void);
@@ -214,13 +217,6 @@ int hardwall_deactivate(struct task_struct *task);
214} while (0) 217} while (0)
215#endif 218#endif
216 219
217/* Invoke the simulator "syscall" mechanism (see arch/tile/kernel/entry.S). */
218extern int _sim_syscall(int syscall_num, ...);
219#define sim_syscall(syscall_num, ...) \
220 _sim_syscall(SIM_CONTROL_SYSCALL + \
221 ((syscall_num) << _SIM_CONTROL_OPERATOR_BITS), \
222 ## __VA_ARGS__)
223
224/* 220/*
225 * Kernel threads can check to see if they need to migrate their 221 * Kernel threads can check to see if they need to migrate their
226 * stack whenever they return from a context switch; for user 222 * stack whenever they return from a context switch; for user
diff --git a/arch/tile/include/asm/traps.h b/arch/tile/include/asm/traps.h
index 432a9c15c8a..d06e35f5720 100644
--- a/arch/tile/include/asm/traps.h
+++ b/arch/tile/include/asm/traps.h
@@ -59,4 +59,8 @@ void do_hardwall_trap(struct pt_regs *, int fault_num);
59void do_breakpoint(struct pt_regs *, int fault_num); 59void do_breakpoint(struct pt_regs *, int fault_num);
60 60
61 61
62#ifdef __tilegx__
63void gx_singlestep_handle(struct pt_regs *, int fault_num);
64#endif
65
62#endif /* _ASM_TILE_SYSCALLS_H */ 66#endif /* _ASM_TILE_SYSCALLS_H */
diff --git a/arch/tile/include/hv/hypervisor.h b/arch/tile/include/hv/hypervisor.h
index 9bd303a141b..f672544cd4f 100644
--- a/arch/tile/include/hv/hypervisor.h
+++ b/arch/tile/include/hv/hypervisor.h
@@ -1003,37 +1003,37 @@ int hv_console_write(HV_VirtAddr bytes, int len);
1003 * when these occur in a client's interrupt critical section, they must 1003 * when these occur in a client's interrupt critical section, they must
1004 * be delivered through the downcall mechanism. 1004 * be delivered through the downcall mechanism.
1005 * 1005 *
1006 * A downcall is initially delivered to the client as an INTCTRL_1 1006 * A downcall is initially delivered to the client as an INTCTRL_CL
1007 * interrupt. Upon entry to the INTCTRL_1 vector, the client must 1007 * interrupt, where CL is the client's PL. Upon entry to the INTCTRL_CL
1008 * immediately invoke the hv_downcall_dispatch service. This service 1008 * vector, the client must immediately invoke the hv_downcall_dispatch
1009 * will not return; instead it will cause one of the client's actual 1009 * service. This service will not return; instead it will cause one of
1010 * downcall-handling interrupt vectors to be entered. The EX_CONTEXT 1010 * the client's actual downcall-handling interrupt vectors to be entered.
1011 * registers in the client will be set so that when the client irets, 1011 * The EX_CONTEXT registers in the client will be set so that when the
1012 * it will return to the code which was interrupted by the INTCTRL_1 1012 * client irets, it will return to the code which was interrupted by the
1013 * interrupt. 1013 * INTCTRL_CL interrupt.
1014 * 1014 *
1015 * Under some circumstances, the firing of INTCTRL_1 can race with 1015 * Under some circumstances, the firing of INTCTRL_CL can race with
1016 * the lowering of a device interrupt. In such a case, the 1016 * the lowering of a device interrupt. In such a case, the
1017 * hv_downcall_dispatch service may issue an iret instruction instead 1017 * hv_downcall_dispatch service may issue an iret instruction instead
1018 * of entering one of the client's actual downcall-handling interrupt 1018 * of entering one of the client's actual downcall-handling interrupt
1019 * vectors. This will return execution to the location that was 1019 * vectors. This will return execution to the location that was
1020 * interrupted by INTCTRL_1. 1020 * interrupted by INTCTRL_CL.
1021 * 1021 *
1022 * Any saving of registers should be done by the actual handling 1022 * Any saving of registers should be done by the actual handling
1023 * vectors; no registers should be changed by the INTCTRL_1 handler. 1023 * vectors; no registers should be changed by the INTCTRL_CL handler.
1024 * In particular, the client should not use a jal instruction to invoke 1024 * In particular, the client should not use a jal instruction to invoke
1025 * the hv_downcall_dispatch service, as that would overwrite the client's 1025 * the hv_downcall_dispatch service, as that would overwrite the client's
1026 * lr register. Note that the hv_downcall_dispatch service may overwrite 1026 * lr register. Note that the hv_downcall_dispatch service may overwrite
1027 * one or more of the client's system save registers. 1027 * one or more of the client's system save registers.
1028 * 1028 *
1029 * The client must not modify the INTCTRL_1_STATUS SPR. The hypervisor 1029 * The client must not modify the INTCTRL_CL_STATUS SPR. The hypervisor
1030 * will set this register to cause a downcall to happen, and will clear 1030 * will set this register to cause a downcall to happen, and will clear
1031 * it when no further downcalls are pending. 1031 * it when no further downcalls are pending.
1032 * 1032 *
1033 * When a downcall vector is entered, the INTCTRL_1 interrupt will be 1033 * When a downcall vector is entered, the INTCTRL_CL interrupt will be
1034 * masked. When the client is done processing a downcall, and is ready 1034 * masked. When the client is done processing a downcall, and is ready
1035 * to accept another, it must unmask this interrupt; if more downcalls 1035 * to accept another, it must unmask this interrupt; if more downcalls
1036 * are pending, this will cause the INTCTRL_1 vector to be reentered. 1036 * are pending, this will cause the INTCTRL_CL vector to be reentered.
1037 * Currently the following interrupt vectors can be entered through a 1037 * Currently the following interrupt vectors can be entered through a
1038 * downcall: 1038 * downcall:
1039 * 1039 *