RTEMS  5.1
monlib.h
Go to the documentation of this file.
1 
10 /* Based upon code from MicroMonitor 1.17 from http://www.umonfw.com/
11  * which includes this notice:
12  *
13  **************************************************************************
14  * General notice:
15  * This code is part of a boot-monitor package developed as a generic base
16  * platform for embedded system designs. As such, it is likely to be
17  * distributed to various projects beyond the control of the original
18  * author. Please notify the author of any enhancements made or bugs found
19  * so that all may benefit from the changes. In addition, notification back
20  * to the author will allow the new user to pick up changes that may have
21  * been made by other users after this version of the code was distributed.
22  *
23  * Note1: the majority of this code was edited with 4-space tabs.
24  * Note2: as more and more contributions are accepted, the term "author"
25  * is becoming a mis-representation of credit.
26  *
27  * Original author: Ed Sutter
28  * Email: esutter@alcatel-lucent.com
29  * Phone: 908-582-2351
30  **************************************************************************
31  *
32  * Ed Sutter has been informed that this code is being used in RTEMS.
33  *
34  * This code was reformatted by Joel Sherrill from OAR Corporation and
35  * Fernando Nicodemos <fgnicodemos@terra.com.br> from NCB - Sistemas
36  * Embarcados Ltda. (Brazil) to be more compliant with RTEMS coding
37  * standards and to eliminate C++ style comments.
38  */
39 
40 #ifndef _MONLIB_H_
41 #define _MONLIB_H_
42 
43 #include <umon/tfs.h>
44 #include <umon/cli.h>
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
66 extern int monConnect(int (*monptr)(int,void *,void *,void *),
67  void (*lock)(void),void (*unlock)(void));
68 extern void mon_getargv(int *argc,char ***argv);
69 extern void mon_intsrestore(unsigned long oldval);
70 extern void mon_appexit(int exit_value);
71 extern void mon_free(char *buffer);
72 extern void mon_profiler(void *pdata);
73 extern void mon_bbc(char *filename, int linenum);
74 extern void mon_warmstart(unsigned long mask);
75 extern void mon_delay(long msec);
76 extern void mon_printpkt(char *buf, int size, int incoming);
77 extern void mon_printmem(char *mem, int size, int ascii);
78 
79 
80 extern int mon_com(int cmd,void *arg1,void *arg2,void *arg3);
81 extern int mon_timer(int cmd, void * arg);
82 extern int mon_setenv(char *varname,char *value);
83 extern int mon_putchar(char c);
84 extern int mon_getchar(void);
85 extern int mon_gotachar(void);
86 extern int mon_getbytes(char *buf,int count,int block);
87 extern int mon_restart(int restart_value);
88 extern int mon_tfsinit(void);
89 extern int mon_tfsunlink(char *filename);
90 extern int mon_tfslink(char *source, char *target);
91 extern int mon_tfsrun(char **arglist,int verbosity);
92 extern int mon_tfsfstat(char *filename,struct tfshdr *tfp);
93 extern int mon_tfseof(int file_descriptor);
94 extern int mon_tfstruncate(int file_descriptor,long length);
95 extern int mon_tfsread(int file_descriptor,char *buffer,int size);
96 extern int mon_tfswrite(int file_descriptor,char *buffer,int size);
97 extern int mon_tfsopen(char *filename,long mode,char *buffer);
98 extern int mon_tfsclose(int file_descriptor,char *info);
99 extern int mon_tfsseek(int file_descriptor,int offset,int whence);
100 extern int mon_tfsgetline(int file_descriptor,char *buffer,int bufsize);
101 extern int mon_tfsipmod(char *name,char *buffer,int offset,int size);
102 extern int mon_addcommand(struct monCommand *command_list,char *);
103 extern int mon_docommand(char *cmdline,int verbosity);
104 extern int mon_getline(char *buffer,int max,int ledit);
105 extern int mon_decompress(char *src,int srcsize,char *dest);
106 extern int mon_heapextend(char *base,int size);
107 extern int mon_pcicfgwrite(int interface,int bus,int dev,int func,int reg,
108  unsigned long val);
109 extern int mon_tfsadd(char *filename, char *info, char *flags,
110  unsigned char *src, int size);
111 extern int mon_i2cwrite(int interface, int bigaddr, unsigned char *data,
112  int len);
113 extern int mon_i2cread(int interface, int bigaddr, unsigned char *data,
114  int len);
115 extern int mon_sendenetpkt(char *pkt, int len);
116 extern int mon_recvenetpkt(char *pkt, int len);
117 extern int mon_flashoverride(void *flashinfo, int get, int bank);
118 extern int mon_flasherase(int snum);
119 extern int mon_flashwrite(char *dest,char *src, int bytecnt);
120 extern int mon_flashinfo(int snum,int *size, char **base);
121 extern int mon_watchdog(void);
122 extern int mon_timeofday(int cmd, void *arg);
123 
124 extern char *mon_getsym(char *symname, char *buf, int bufsize);
125 extern char *mon_getenv(char *varname);
126 extern char *mon_getenvp(void);
127 extern char *mon_version(void);
128 #ifdef MALLOC_DEBUG
129 extern char *mon_malloc(int size,char *file, int line);
130 extern char *mon_realloc(char *buf,int size,char *file, int line);
131 #else
132 extern char *mon_malloc(int size);
133 extern char *mon_realloc(char *buf,int size);
134 #endif
135 
136 extern long mon_tfsctrl(int command,long arg1,long arg2);
137 extern long mon_tfstell(int file_descriptor);
138 extern long mon_portcmd(int cmd, void *arg);
139 
140 extern unsigned short mon_xcrc16(char *buffer,long length);
141 
142 extern unsigned long mon_intsoff(void);
143 
144 extern unsigned long mon_pcicfgread(int interface,int bus,int dev,
145  int func,int reg);
146 
147 extern unsigned long mon_pcictrl(int interface, int cmd,
148  unsigned long arg1, unsigned long arg2);
149 
150 extern unsigned long mon_i2cctrl(int interface, int cmd,
151  unsigned long arg1, unsigned long arg2);
152 
153 extern unsigned long mon_assignhandler(long hnum,
154  unsigned long arg1,unsigned long arg2);
155 
156 extern struct tfshdr *mon_tfsnext(struct tfshdr *tfp);
157 extern struct tfshdr *mon_tfsstat(char *filename);
158 
159 /*
160  * The external caller should see these as variable argument methods but
161  * they are not implemented that way, so let monlib.c prototype them internally
162  * when building that file.
163  */
164 #ifndef _INSIDE_MONLIB
165 extern void mon_memtrace(char *fmt, ...);
166 extern int mon_printf(char *fmt, ...);
167 extern int mon_cprintf(char *fmt, ...);
168 extern int mon_sprintf(char *,char *fmt, ...);
169 #endif
170 
171 #ifdef __cplusplus
172 }
173 #endif
174 
175 
176 /* defines used by monConnect():
177  */
178 #define GETMONFUNC_PUTCHAR 1
179 #define GETMONFUNC_GETCHAR 2
180 #define GETMONFUNC_GOTACHAR 3
181 #define GETMONFUNC_GETBYTES 4
182 #define GETMONFUNC_PRINTF 5
183 #define GETMONFUNC_CPRINTF 6
184 #define GETMONFUNC_SPRINTF 7
185 #define GETMONFUNC_RESTART 8
186 #define GETMONFUNC_GETENV 9
187 #define GETMONFUNC_SETENV 10
188 #define GETMONFUNC_TFSINIT 11
189 #define GETMONFUNC_TFSADD 12
190 #define GETMONFUNC_TFSUNLINK 13
191 #define GETMONFUNC_TFSRUN 14
192 #define GETMONFUNC_TFSNEXT 15
193 #define GETMONFUNC_TFSSTAT 16
194 #define GETMONFUNC_TFSREAD 17
195 #define GETMONFUNC_TFSWRITE 18
196 #define GETMONFUNC_TFSOPEN 19
197 #define GETMONFUNC_TFSCLOSE 20
198 #define GETMONFUNC_TFSSEEK 21
199 #define GETMONFUNC_TFSGETLINE 22
200 #define GETMONFUNC_TFSIPMOD 23
201 #define GETMONFUNC_TFSCTRL 24
202 #define GETMONFUNC_ADDCOMMAND 25
203 #define GETMONFUNC_DOCOMMAND 26
204 #define GETMONFUNC_GETARGV 27
205 #define GETMONFUNC_CRC16 28
206 #define GETMONFUNC_CRC32 29
207 #define GETMONFUNC_PIOGET 30 /* NA (removed as of 1.0) */
208 #define GETMONFUNC_PIOSET 31 /* NA (removed as of 1.0) */
209 #define GETMONFUNC_PIOCLR 32 /* NA (removed as of 1.0) */
210 #define GETMONFUNC_INTSOFF 33
211 #define GETMONFUNC_INTSRESTORE 34
212 #define GETMONFUNC_APPEXIT 35
213 #define GETMONFUNC_MALLOC 36
214 #define GETMONFUNC_FREE 37
215 #define GETMONFUNC_GETLINE 38
216 #define GETMONFUNC_TFSFSTAT 39
217 #define GETMONFUNC_TFSEOF 40
218 #define GETMONFUNC_DECOMPRESS 41
219 #define GETMONFUNC_TFSTRUNCATE 42
220 #define GETMONFUNC_HEAPXTEND 43
221 #define GETMONFUNC_PROFILER 44
222 #define GETMONFUNC_TFSLINK 45
223 #define GETMONFUNC_BBC 46
224 #define GETMONFUNC_MEMTRACE 47
225 #define GETMONFUNC_TFSTELL 48
226 #define GETMONFUNC_VERSION 49
227 #define GETMONFUNC_WARMSTART 50
228 #define GETMONFUNC_PCICFGREAD 51
229 #define GETMONFUNC_PCICFGWRITE 52
230 #define GETMONFUNC_PCICONTROL 53
231 #define GETMONFUNC_I2CREAD 54
232 #define GETMONFUNC_I2CWRITE 55
233 #define GETMONFUNC_I2CCONTROL 56
234 #define GETMONFUNC_MONDELAY 57
235 #define GETMONFUNC_GETENVP 58
236 #define GETMONFUNC_REALLOC 59
237 #define GETMONFUNC_SENDENETPKT 60
238 #define GETMONFUNC_RECVENETPKT 61
239 #define GETMONFUNC_GETSYM 62
240 #define GETMONFUNC_PRINTPKT 63
241 #define GETMONFUNC_FLASHWRITE 64
242 #define GETMONFUNC_FLASHERASE 65
243 #define GETMONFUNC_FLASHINFO 66
244 #define GETMONFUNC_ASSIGNHDLR 67
245 #define GETMONFUNC_WATCHDOG 68
246 #define GETMONFUNC_PRINTMEM 69
247 #define GETMONFUNC_PORTCMD 70
248 #define GETMONFUNC_TIMEOFDAY 71
249 #define GETMONFUNC_TIMER 72
250 #define GETMONFUNC_FLASHOVRRD 73
251 
252 #define CACHEFTYPE_DFLUSH 200
253 #define CACHEFTYPE_IINVALIDATE 201
254 
255 #define CHARFUNC_PUTCHAR 300
256 #define CHARFUNC_GETCHAR 301
257 #define CHARFUNC_GOTACHAR 302
258 #define CHARFUNC_RAWMODEON 303
259 #define CHARFUNC_RAWMODEOFF 304
260 
261 #define ASSIGNFUNC_GETUSERLEVEL 400
262 
263 
264 /* Defines used by mon_warmstart():
265  */
266 #define WARMSTART_IOINIT 0x00000001
267 #define WARMSTART_BSSINIT 0x00000002
268 #define WARMSTART_RUNMONRC 0x00000004
269 #define WARMSTART_MONHEADER 0x00000008
270 #define WARMSTART_TFSAUTOBOOT 0x00000010
271 #define WARMSTART_BOARDINFO 0x00000020
272 #define WARMSTART_ALL 0xffffffff
273 #endif
Header file for TFS transactions, used by both application and monnitor.
Definition: cli.h:54
Definition: tfs.h:142
Header file for Command Line Interface related stuff.
unsigned size
Definition: tte.h:74
Definition: mongoose.c:442