~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to arch/tile/include/arch/sim.h

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
152
152
/**
153
153
 * Print a string to the simulator stdout.
154
154
 *
155
 
 * @param str The string to be written; a newline is automatically added.
 
155
 * @param str The string to be written.
 
156
 */
 
157
static __inline void
 
158
sim_print(const char* str)
 
159
{
 
160
  for ( ; *str != '\0'; str++)
 
161
  {
 
162
    __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_PUTC |
 
163
                 (*str << _SIM_CONTROL_OPERATOR_BITS));
 
164
  }
 
165
  __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_PUTC |
 
166
               (SIM_PUTC_FLUSH_BINARY << _SIM_CONTROL_OPERATOR_BITS));
 
167
}
 
168
 
 
169
 
 
170
/**
 
171
 * Print a string to the simulator stdout.
 
172
 *
 
173
 * @param str The string to be written (a newline is automatically added).
156
174
 */
157
175
static __inline void
158
176
sim_print_string(const char* str)
159
177
{
160
 
  int i;
161
 
  for (i = 0; str[i] != 0; i++)
 
178
  for ( ; *str != '\0'; str++)
162
179
  {
163
180
    __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_PUTC |
164
 
                 (str[i] << _SIM_CONTROL_OPERATOR_BITS));
 
181
                 (*str << _SIM_CONTROL_OPERATOR_BITS));
165
182
  }
166
183
  __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_PUTC |
167
184
               (SIM_PUTC_FLUSH_STRING << _SIM_CONTROL_OPERATOR_BITS));
203
220
 * we are passing to the simulator are actually valid in the registers
204
221
 * (i.e. returned from memory) prior to the SIM_CONTROL spr.
205
222
 */
206
 
static __inline int _sim_syscall0(int val)
 
223
static __inline long _sim_syscall0(int val)
207
224
{
208
225
  long result;
209
226
  __asm__ __volatile__ ("mtspr SIM_CONTROL, r0"
211
228
  return result;
212
229
}
213
230
 
214
 
static __inline int _sim_syscall1(int val, long arg1)
 
231
static __inline long _sim_syscall1(int val, long arg1)
215
232
{
216
233
  long result;
217
234
  __asm__ __volatile__ ("{ and zero, r1, r1; mtspr SIM_CONTROL, r0 }"
219
236
  return result;
220
237
}
221
238
 
222
 
static __inline int _sim_syscall2(int val, long arg1, long arg2)
 
239
static __inline long _sim_syscall2(int val, long arg1, long arg2)
223
240
{
224
241
  long result;
225
242
  __asm__ __volatile__ ("{ and zero, r1, r2; mtspr SIM_CONTROL, r0 }"
233
250
   the register values for arguments 3 and up may still be in flight
234
251
   to the core from a stack frame reload. */
235
252
 
236
 
static __inline int _sim_syscall3(int val, long arg1, long arg2, long arg3)
 
253
static __inline long _sim_syscall3(int val, long arg1, long arg2, long arg3)
237
254
{
238
255
  long result;
239
256
  __asm__ __volatile__ ("{ and zero, r3, r3 };"
244
261
  return result;
245
262
}
246
263
 
247
 
static __inline int _sim_syscall4(int val, long arg1, long arg2, long arg3,
 
264
static __inline long _sim_syscall4(int val, long arg1, long arg2, long arg3,
248
265
                                  long arg4)
249
266
{
250
267
  long result;
256
273
  return result;
257
274
}
258
275
 
259
 
static __inline int _sim_syscall5(int val, long arg1, long arg2, long arg3,
 
276
static __inline long _sim_syscall5(int val, long arg1, long arg2, long arg3,
260
277
                                  long arg4, long arg5)
261
278
{
262
279
  long result;
268
285
  return result;
269
286
}
270
287
 
271
 
 
272
288
/**
273
289
 * Make a special syscall to the simulator itself, if running under
274
290
 * simulation. This is used as the implementation of other functions
281
297
 */
282
298
#define _sim_syscall(syscall_num, nr, args...) \
283
299
  _sim_syscall##nr( \
284
 
    ((syscall_num) << _SIM_CONTROL_OPERATOR_BITS) | SIM_CONTROL_SYSCALL, args)
 
300
    ((syscall_num) << _SIM_CONTROL_OPERATOR_BITS) | SIM_CONTROL_SYSCALL, \
 
301
    ##args)
285
302
 
286
303
 
287
304
/* Values for the "access_mask" parameters below. */
365
382
}
366
383
 
367
384
 
 
385
/* Return the current CPU speed in cycles per second. */
 
386
static __inline long
 
387
sim_query_cpu_speed(void)
 
388
{
 
389
  return _sim_syscall(SIM_SYSCALL_QUERY_CPU_SPEED, 0);
 
390
}
 
391
 
368
392
#endif /* !__DOXYGEN__ */
369
393
 
370
394