1 /*
2  *            Debugger
3  *
4  *    Copyright 1990-2005
5  *    Green Hills Software, Inc.
6  *
7  *    This program is the property of Green Hills Software, Inc,
8  *    its contents are proprietary information and no part of it
9  *    is to be disclosed to anyone except employees of Green Hills
10  *    Software, Inc., or as agreed in writing signed by the President
11  *    of Green Hills Software, Inc.
12  */
13 
14 /* This file contains definitions required for emulated embedded system
15    call support */
16 
17 /*
18  *  System Call ID codes.
19  *
20  *  These ID codes are used both in the MULTI <--> server protocol and the
21  *  monserv <--> monitor protocol.
22  *
23  *  When using the Green Hills cross libraries, these codes are passed as the
24  *  first argument to the function __ghs_syscall in the appropriate indsyscl.*
25  *  module of the libraries.  The codes are 32-bit values, with the low 16 bits
26  *  containing the call number, and the high 16 bits containing the
27  *  argument count (including the first argument, the code number itself).
28  *
29  *  When implementing System Call support in a debug server, these codes
30  *  are stored as the first argument in the argument list pointed to by
31  *  the XTRA_STAT syscall.args field.
32  *
33  *  Codes that have an argument count of zero are handled internally by the
34  *  target or its debug server and must not be passed to MULTI via XTRA_STAT.
35  *  For these calls, the argument list is defined at the time the call number
36  *  is assigned, and the target knows how many arguments there should be by
37  *  looking at the call number itself.
38  *
39  *  Note that function names beginning with '__' don't really exist; they
40  *  are called internally by the libraries or debug servers and do not
41  *  correspond directly to any well-known system calls.
42  */
43 
44 /*****************************************************************************/
45 /* Begin general purpose System Call ID codes                                */
46 /*****************************************************************************/
47 #define SYSCALL_READ    0x40000    /* read(fd, buf, n) */
48 #define SYSCALL_WRITE   0x40001    /* write(fd, buf, n) */
49 #define SYSCALL_OPEN    0x30004    /* open(fname, flags) */
50 #define SYSCALL_OPEN2   0x40004    /* open(fname, flags, mode) */
51 #define SYSCALL_CLOSE   0x20005    /* close(fd) */
52 #define SYSCALL_CREAT   0x30006    /* creat(fname, flags) */
53 #define SYSCALL_LSEEK   0x40007    /* lseek(fd, offset, origin) */
54 #define SYSCALL_UNLINK  0x20008    /* unlink(fname) */
55 #define SYSCALL_RENAME  0x30009    /* rename(old, new) */
56 #define SYSCALL_SYSTEM  0x2000A    /* system(string) */
57 #define SYSCALL_ACCESS  0x3000B    /* access(fname, flags) */
58 #define SYSCALL_TIME    0x1000E    /* __time(), host synchronization request */
59 #define SYSCALL_MODTIME 0x20010    /* __modtime(fname) */
60 /*#define SYSCALL_MEV_TRACE 0x30011 [* MEVTrace(buf, size) *] */
61 #define SYSCALL_FCNTL   0x40012    /* fcntl(fd, cmd, arg) */
62 #define SYSCALL_REMAP   0x40013    /* remap(target, source, length) */
63 #define SYSCALL_BYTES_TO_READ 0x20015 /* number of bytes to read on given fd */
64 #define SYSCALL_SOCKEMULATE 0x3000F/* __socket_emulation(Params, CallerID) */
65 #define SYSCALL_MEMDEV  0x40016   /* Shared memory communication device */
66 /*#define SYSCALL_DBGTRAP 0x30017   [* ghs_debug_trap(cmd, arg) *] */
67 #define SYSCALL_GETFDATTR 0x40018  /* __getfdattr(fd, buf, flags) */
68 #define SYSCALL_GETFNATTR 0x40019  /* __getfnattr(fd, buf, flags) */
69 #define SYSCALL_SETFDATTR 0x4001A  /* __setfdattr(fname, buf, flags) */
70 #define SYSCALL_SETFNATTR 0x4001B  /* __setfnattr(fname, buf, flags) */
71 #define SYSCALL_FSYNC     0x2001C  /* fsync(fd) */
72 #define SYSCALL_GETDENTS  0x4001D  /* __getdents(fd, buf, flags) */
73 #define SYSCALL_MKDIR     0x3001E  /* mkdir(path, mode) */
74 #define SYSCALL_RMDIR     0x2001F  /* rkdir(path) */
75 #define SYSCALL_RUNMODE   0x40020  /* run-mode partner request to debugger */
76 #define SYSCALL_READ2     0x40021  /* read2(fd, buf, n) */
77 #define SYSCALL_WRITE2    0x40022  /* write2(fd, buf, n) */
78 /*****************************************************************************/
79 /* End general purpose System Calls                                          */
80 /*****************************************************************************/
81 
82 
83 /*****************************************************************************/
84 /* Begin flags for SYSCALL_{GET,SET}{FD,FN}ATTR                              */
85 /*****************************************************************************/
86 #define SYSCALL_ATTR_BF0SZMSK (0x7f)  /* specifies sizeof(buf[0]) */
87 #define SYSCALL_ATTR_FORLINK  (1<<7)  /* if set, lstat(), else stat() */
88 #define SYSCALL_ATTR_SIZE     (1<<8)
89 #define SYSCALL_ATTR_MODE     (1<<9)
90 /*****************************************************************************/
91 /* End flags for SYSCALL_{GET,SET}{FD,FN}ATTR                                */
92 /*****************************************************************************/
93 
94 /*****************************************************************************/
95 /* Begin flags for SYSCALL_ATTR_MODE                                         */
96 /*****************************************************************************/
97 #define SYSCALL_ATTR_MODE_IFCHR   0x2000
98 #define SYSCALL_ATTR_MODE_IFDIR   0x4000
99 #define SYSCALL_ATTR_MODE_IFBLK   0x6000
100 #define SYSCALL_ATTR_MODE_IFREG   0x8000
101 #define SYSCALL_ATTR_MODE_IFLNK   0xA000
102 
103 #define SYSCALL_ATTR_MODE_MASK    0xE000
104 /*****************************************************************************/
105 /* End flags for SYSCALL_ATTR_MODE                                           */
106 /*****************************************************************************/
107 
108 
109 /*****************************************************************************/
110 /* Begin flags for SYSCALL_GETDENTS                                          */
111 /*****************************************************************************/
112 #define SYSCALL_GETDENTS_NUMENT_SHIFT   0
113 #define SYSCALL_GETDENTS_NUMENT_MASK    0xff
114 #define SYSCALL_GETDENTS_WORDSIZE_SHIFT 8
115 #define SYSCALL_GETDENTS_WORDSIZE_MASK  0xff
116 #define SYSCALL_GETDENTS_ENTSIZE_SHIFT  16
117 #define SYSCALL_GETDENTS_ENTSIZE_MASK   0xffff
118 /*****************************************************************************/
119 /* End flags for SYSCALL_GETDENTS                                            */
120 /*****************************************************************************/
121 
122 /*****************************************************************************/
123 /* Begin flags for SYSCALL_GETDENTS_DTYPE                                    */
124 /*****************************************************************************/
125 #define SYSCALL_GETDENTS_DTYPE_CHR  0x2
126 #define SYSCALL_GETDENTS_DTYPE_DIR  0x4
127 #define SYSCALL_GETDENTS_DTYPE_BLK  0x6
128 #define SYSCALL_GETDENTS_DTYPE_REG  0x8
129 
130 #define SYSCALL_GETDENTS_DTYPE_MASK 0xE
131 /*****************************************************************************/
132 /* End flags for SYSCALL_GETDENTS_DTYPE                                      */
133 /*****************************************************************************/
134 
135 
136 /*****************************************************************************/
137 /* Begin target internal calls                                               */
138 /*****************************************************************************/
139 #define SYSCALL_EXIT    2       /* exit(status) */
140 #define SYSCALL_SETUP   3       /* 68K monitor specific */
141 #define SYSCALL_HANDLER 12      /* __handler(interruptfunc) */
142 #define SYSCALL_TIMEOUT 13      /* __timeout(microseconds) */
143 #define SYSCALL_MONTIME 14      /* __time(), fetches internal monitor time */
144 #define SYSCALL_BRK     15      /* brk(addr) */
145 /* __cachesetting(flags), enables CPU specific caching options if available. */
146 /* This is intended for running benchmarks on boards with the monitor. */
147 /* See Init_IO in indio.c */
148 #define SYSCALL_CACHESET 16     /* __cachesetting(flags) */
149 /* __manprof(buf, cnt), manual profiling call supported by some debug servers */
150 /* This call is currently reserved for experimental use with hpserv targets.  */
151 #define SYSCALL_MANPROF 17      /* __manprof(buf, cnt) */
152 #define SYSCALL_HELLO   20      /* hello(), always succeeds */
153 /* moncycles() returns the number of cycles elapsed since program start. */
154 /* This is for benchmarking from the simulator */
155 /* This call is currently reserved for experimental INTERNAL use only. */
156 #define SYSCALL_CYCLES  30      /* moncycles() */
157 /* Experimental system call to relay information from a trap handler to MULTI */
158 #define SYSCALL_TRAPINFO 40
159 #define SYSCALL_RESERVED1 21    /* Reserved for Green Hills use */
160 #define SYSCALL_RESERVED2 22    /* Reserved for Green Hills use */
161 /*****************************************************************************/
162 /* End target internal calls                                                 */
163 /*****************************************************************************/
164