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