Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a5c149c8 authored by Chris Metcalf's avatar Chris Metcalf
Browse files

arch/tile: sync up with <arch/sim.h> and <arch/sim_def.h> changes



These headers are used by Linux but are maintained upstream.
This change incorporates a few minor fixes to these headers,
including a new sim_print() function, cleaner support for the
sim_syscall() API, and a sim_query_cpu_speed() method.

Signed-off-by: default avatarChris Metcalf <cmetcalf@tilera.com>
parent ed54d38f
Loading
Loading
Loading
Loading
+36 −12
Original line number Original line Diff line number Diff line
@@ -152,16 +152,33 @@ sim_dump(unsigned int mask)
/**
/**
 * Print a string to the simulator stdout.
 * Print a string to the simulator stdout.
 *
 *
 * @param str The string to be written; a newline is automatically added.
 * @param str The string to be written.
 */
static __inline void
sim_print(const char* str)
{
  for ( ; *str != '\0'; str++)
  {
    __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_PUTC |
                 (*str << _SIM_CONTROL_OPERATOR_BITS));
  }
  __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_PUTC |
               (SIM_PUTC_FLUSH_BINARY << _SIM_CONTROL_OPERATOR_BITS));
}


/**
 * Print a string to the simulator stdout.
 *
 * @param str The string to be written (a newline is automatically added).
 */
 */
static __inline void
static __inline void
sim_print_string(const char* str)
sim_print_string(const char* str)
{
{
  int i;
  for ( ; *str != '\0'; str++)
  for (i = 0; str[i] != 0; i++)
  {
  {
    __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_PUTC |
    __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_PUTC |
                 (str[i] << _SIM_CONTROL_OPERATOR_BITS));
                 (*str << _SIM_CONTROL_OPERATOR_BITS));
  }
  }
  __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_PUTC |
  __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_PUTC |
               (SIM_PUTC_FLUSH_STRING << _SIM_CONTROL_OPERATOR_BITS));
               (SIM_PUTC_FLUSH_STRING << _SIM_CONTROL_OPERATOR_BITS));
@@ -203,7 +220,7 @@ sim_command(const char* str)
 * we are passing to the simulator are actually valid in the registers
 * we are passing to the simulator are actually valid in the registers
 * (i.e. returned from memory) prior to the SIM_CONTROL spr.
 * (i.e. returned from memory) prior to the SIM_CONTROL spr.
 */
 */
static __inline int _sim_syscall0(int val)
static __inline long _sim_syscall0(int val)
{
{
  long result;
  long result;
  __asm__ __volatile__ ("mtspr SIM_CONTROL, r0"
  __asm__ __volatile__ ("mtspr SIM_CONTROL, r0"
@@ -211,7 +228,7 @@ static __inline int _sim_syscall0(int val)
  return result;
  return result;
}
}


static __inline int _sim_syscall1(int val, long arg1)
static __inline long _sim_syscall1(int val, long arg1)
{
{
  long result;
  long result;
  __asm__ __volatile__ ("{ and zero, r1, r1; mtspr SIM_CONTROL, r0 }"
  __asm__ __volatile__ ("{ and zero, r1, r1; mtspr SIM_CONTROL, r0 }"
@@ -219,7 +236,7 @@ static __inline int _sim_syscall1(int val, long arg1)
  return result;
  return result;
}
}


static __inline int _sim_syscall2(int val, long arg1, long arg2)
static __inline long _sim_syscall2(int val, long arg1, long arg2)
{
{
  long result;
  long result;
  __asm__ __volatile__ ("{ and zero, r1, r2; mtspr SIM_CONTROL, r0 }"
  __asm__ __volatile__ ("{ and zero, r1, r2; mtspr SIM_CONTROL, r0 }"
@@ -233,7 +250,7 @@ static __inline int _sim_syscall2(int val, long arg1, long arg2)
   the register values for arguments 3 and up may still be in flight
   the register values for arguments 3 and up may still be in flight
   to the core from a stack frame reload. */
   to the core from a stack frame reload. */


static __inline int _sim_syscall3(int val, long arg1, long arg2, long arg3)
static __inline long _sim_syscall3(int val, long arg1, long arg2, long arg3)
{
{
  long result;
  long result;
  __asm__ __volatile__ ("{ and zero, r3, r3 };"
  __asm__ __volatile__ ("{ and zero, r3, r3 };"
@@ -244,7 +261,7 @@ static __inline int _sim_syscall3(int val, long arg1, long arg2, long arg3)
  return result;
  return result;
}
}


static __inline int _sim_syscall4(int val, long arg1, long arg2, long arg3,
static __inline long _sim_syscall4(int val, long arg1, long arg2, long arg3,
                                  long arg4)
                                  long arg4)
{
{
  long result;
  long result;
@@ -256,7 +273,7 @@ static __inline int _sim_syscall4(int val, long arg1, long arg2, long arg3,
  return result;
  return result;
}
}


static __inline int _sim_syscall5(int val, long arg1, long arg2, long arg3,
static __inline long _sim_syscall5(int val, long arg1, long arg2, long arg3,
                                  long arg4, long arg5)
                                  long arg4, long arg5)
{
{
  long result;
  long result;
@@ -268,7 +285,6 @@ static __inline int _sim_syscall5(int val, long arg1, long arg2, long arg3,
  return result;
  return result;
}
}



/**
/**
 * Make a special syscall to the simulator itself, if running under
 * Make a special syscall to the simulator itself, if running under
 * simulation. This is used as the implementation of other functions
 * simulation. This is used as the implementation of other functions
@@ -281,7 +297,8 @@ static __inline int _sim_syscall5(int val, long arg1, long arg2, long arg3,
 */
 */
#define _sim_syscall(syscall_num, nr, args...) \
#define _sim_syscall(syscall_num, nr, args...) \
  _sim_syscall##nr( \
  _sim_syscall##nr( \
    ((syscall_num) << _SIM_CONTROL_OPERATOR_BITS) | SIM_CONTROL_SYSCALL, args)
    ((syscall_num) << _SIM_CONTROL_OPERATOR_BITS) | SIM_CONTROL_SYSCALL, \
    ##args)




/* Values for the "access_mask" parameters below. */
/* Values for the "access_mask" parameters below. */
@@ -365,6 +382,13 @@ sim_validate_lines_evicted(unsigned long long pa, unsigned long length)
}
}




/* Return the current CPU speed in cycles per second. */
static __inline long
sim_query_cpu_speed(void)
{
  return _sim_syscall(SIM_SYSCALL_QUERY_CPU_SPEED, 0);
}

#endif /* !__DOXYGEN__ */
#endif /* !__DOXYGEN__ */




+3 −0
Original line number Original line Diff line number Diff line
@@ -243,6 +243,9 @@
 */
 */
#define SIM_SYSCALL_VALIDATE_LINES_EVICTED 5
#define SIM_SYSCALL_VALIDATE_LINES_EVICTED 5


/** Syscall number for sim_query_cpu_speed(). */
#define SIM_SYSCALL_QUERY_CPU_SPEED 6



/*
/*
 * Bit masks which can be shifted by 8, combined with
 * Bit masks which can be shifted by 8, combined with