simcall.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /*
  2. * simcall.h - Simulator call numbers
  3. *
  4. * Software that runs on a simulated Xtensa processor using
  5. * the instruction set simulator (ISS) can invoke simulator
  6. * services using the SIMCALL instruction. The a2 register
  7. * is set prior to executing SIMCALL to a "simcall number",
  8. * indicating which service to invoke. This file defines the
  9. * simcall numbers defined and/or supported by the Xtensa ISS.
  10. *
  11. * IMPORTANT NOTE: These numbers are highly subject to change!
  12. *
  13. * Copyright (c) 2002-2007 by Tensilica Inc. ALL RIGHTS RESERVED.
  14. * These coded instructions, statements, and computer programs are the
  15. * copyrighted works and confidential proprietary information of Tensilica Inc.
  16. * They may not be modified, copied, reproduced, distributed, or disclosed to
  17. * third parties in any manner, medium, or form, in whole or in part, without
  18. * the prior written consent of Tensilica Inc.
  19. */
  20. #ifndef SIMCALL_INCLUDED
  21. #define SIMCALL_INCLUDED
  22. /*
  23. * System call like services offered by the simulator host.
  24. * These are modeled after the Linux 2.4 kernel system calls
  25. * for Xtensa processors. However not all system calls and
  26. * not all functionality of a given system call are implemented,
  27. * or necessarily have well defined or equivalent semantics in
  28. * the context of a simulation (as opposed to a Unix kernel).
  29. *
  30. * These services behave largely as if they had been invoked
  31. * as a task in the simulator host's operating system
  32. * (eg. files accessed are those of the simulator host).
  33. * However, these SIMCALLs model a virtual operating system
  34. * so that various definitions, bit assignments etc
  35. * (eg. open mode bits, errno values, etc) are independent
  36. * of the host operating system used to run the simulation.
  37. * Rather these definitions are specific to the Xtensa ISS.
  38. * This way Xtensa ISA code written to use these SIMCALLs
  39. * can (in principle) be simulated on any host.
  40. *
  41. * Up to 6 parameters are passed in registers a3 to a8
  42. * (note the 6th parameter isn't passed on the stack,
  43. * unlike windowed function calling conventions).
  44. * The return value is in a2. A negative value in the
  45. * range -4096 to -1 indicates a negated error code to be
  46. * reported in errno with a return value of -1, otherwise
  47. * the value in a2 is returned as is.
  48. */
  49. /* These #defines need to match what's in Xtensa/OS/vxworks/xtiss/simcalls.c */
  50. #define SYS_nop 0 /* n/a - setup; used to flush register windows */
  51. #define SYS_exit 1 /*x*/
  52. #define SYS_fork 2
  53. #define SYS_read 3 /*x*/
  54. #define SYS_write 4 /*x*/
  55. #define SYS_open 5 /*x*/
  56. #define SYS_close 6 /*x*/
  57. #define SYS_rename 7 /*x 38 - waitpid */
  58. #define SYS_creat 8 /*x*/
  59. #define SYS_link 9 /*x (not implemented on WIN32) */
  60. #define SYS_unlink 10 /*x*/
  61. #define SYS_execv 11 /* n/a - execve */
  62. #define SYS_execve 12 /* 11 - chdir */
  63. #define SYS_pipe 13 /* 42 - time */
  64. #define SYS_stat 14 /* 106 - mknod */
  65. #define SYS_chmod 15
  66. #define SYS_chown 16 /* 202 - lchown */
  67. #define SYS_utime 17 /* 30 - break */
  68. #define SYS_wait 18 /* n/a - oldstat */
  69. #define SYS_lseek 19 /*x*/
  70. #define SYS_getpid 20
  71. #define SYS_isatty 21 /* n/a - mount */
  72. #define SYS_fstat 22 /* 108 - oldumount */
  73. #define SYS_time 23 /* 13 - setuid */
  74. #define SYS_gettimeofday 24 /*x 78 - getuid (not implemented on WIN32) */
  75. #define SYS_times 25 /*X 43 - stime (Xtensa-specific implementation) */
  76. #define SYS_socket 26
  77. #define SYS_sendto 27
  78. #define SYS_recvfrom 28
  79. #define SYS_select_one 29 /* not compitible select, one file descriptor at the time */
  80. #define SYS_bind 30
  81. #define SYS_ioctl 31
  82. /*
  83. * Other...
  84. */
  85. #define SYS_iss_argc 1000 /* returns value of argc */
  86. #define SYS_iss_argv_size 1001 /* bytes needed for argv & arg strings */
  87. #define SYS_iss_set_argv 1002 /* saves argv & arg strings at given addr */
  88. #define SYS_memset 1004 /* fill a range of memory (fast) */
  89. /*
  90. * SIMCALLs for the ferret memory debugger. All are invoked by
  91. * libferret.a ... ( Xtensa/Target-Libs/ferret )
  92. */
  93. #define SYS_ferret 1010
  94. #define SYS_malloc 1011
  95. #define SYS_free 1012
  96. #define SYS_more_heap 1013
  97. #define SYS_no_heap 1014
  98. #define SYS_enter_ferret 1015
  99. #define SYS_leave_ferret 1016
  100. /*
  101. * SIMCALLs for ISS client commands
  102. */
  103. #define SYS_profile_enable 1020
  104. #define SYS_profile_disable 1021
  105. #define SYS_trace_level 1022
  106. #define SYS_client_command 1023
  107. /*
  108. * SIMCALL for simulation mode switching
  109. */
  110. #define SYS_sim_mode_switch 1030
  111. /*
  112. * SIMCALLs for XTMP/XTSC event notify and core stall
  113. */
  114. #define SYS_event_fire 1040
  115. #define SYS_event_stall 1041
  116. /*
  117. * SIMCALLs for callbacks registered in XTMP/XTSC
  118. */
  119. #define SYS_callback_first 100
  120. #define SYS_callback_last 999
  121. /*
  122. * User defined simcall
  123. */
  124. #define SYS_user_simcall 100
  125. #define SYS_xmpa_errinfo 200
  126. #define SYS_xmpa_proc_status 201
  127. #define SYS_xmpa_proc_start 202
  128. #define SYS_xmpa_proc_stop 203
  129. #define SYS_xmpa_proc_mem_read 204
  130. #define SYS_xmpa_proc_mem_write 205
  131. #define SYS_xmpa_proc_mem_fill 206
  132. #define SYS_xmpa_proc_reg_read 207
  133. #define SYS_xmpa_proc_reg_write 208
  134. /*
  135. * Extra SIMCALLs for GDB:
  136. */
  137. #define SYS_gdb_break -1 /* invoked by XTOS on user exceptions if EPC points
  138. to a break.n/break, regardless of cause! */
  139. #define SYS_xmon_out -2 /* invoked by XMON: ... */
  140. #define SYS_xmon_in -3 /* invoked by XMON: ... */
  141. #define SYS_xmon_flush -4 /* invoked by XMON: ... */
  142. #define SYS_gdb_abort -5 /* invoked by XTOS in _xtos_panic() */
  143. #define SYS_gdb_illegal_inst -6 /* invoked by XTOS for illegal instructions (too deeply) */
  144. #define SYS_xmon_init -7 /* invoked by XMON: ... */
  145. #define SYS_gdb_enter_sktloop -8 /* invoked by XTOS on debug exceptions */
  146. #define SYS_unhandled_kernel_exc -9 /* invoked by XTOS for unhandled kernel exceptions */
  147. #define SYS_unhandled_user_exc -10 /* invoked by XTOS for unhandled user exceptions */
  148. #define SYS_unhandled_double_exc -11 /* invoked by XTOS for unhandled double exceptions */
  149. #define SYS_unhandled_highpri_interrupt -12 /* invoked by XTOS for unhandled high-priority interrupts */
  150. #define SYS_xmon_close -13 /* invoked by XMON: ... */
  151. /*
  152. * SIMCALLs for vxWorks xtiss BSP:
  153. */
  154. #define SYS_setup_ppp_pipes -83
  155. #define SYS_log_msg -84
  156. /*
  157. * SYS_select_one specifiers
  158. */
  159. #define XTISS_SELECT_ONE_READ 1
  160. #define XTISS_SELECT_ONE_WRITE 2
  161. #define XTISS_SELECT_ONE_EXCEPT 3
  162. /*
  163. * SIMCALL for client calling arbitrary code in a client plug in.
  164. * see clients/xcc_instr to see how this works.
  165. */
  166. #define SYS_client 0xC0DECAFE
  167. #endif /* !SIMCALL_INCLUDED */