1 | /************************************************************************** |
---|
2 | * |
---|
3 | * Copyright (c) 2013 Alcatel-Lucent |
---|
4 | * |
---|
5 | * Alcatel Lucent licenses this file to You under the Apache License, |
---|
6 | * Version 2.0 (the "License"); you may not use this file except in |
---|
7 | * compliance with the License. A copy of the License is contained the |
---|
8 | * file LICENSE at the top level of this repository. |
---|
9 | * You may also obtain a copy of the License at: |
---|
10 | * |
---|
11 | * http://www.apache.org/licenses/LICENSE-2.0 |
---|
12 | * |
---|
13 | * Unless required by applicable law or agreed to in writing, software |
---|
14 | * distributed under the License is distributed on an "AS IS" BASIS, |
---|
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
16 | * See the License for the specific language governing permissions and |
---|
17 | * limitations under the License. |
---|
18 | * |
---|
19 | ************************************************************************** |
---|
20 | * |
---|
21 | * monlib.h: |
---|
22 | * |
---|
23 | * This header file is used by both the monitor and the application that |
---|
24 | * may reside on top of the monitor. |
---|
25 | * |
---|
26 | * Original author: Ed Sutter (ed.sutter@alcatel-lucent.com) |
---|
27 | * |
---|
28 | */ |
---|
29 | #ifndef _MONLIB_H_ |
---|
30 | #define _MONLIB_H_ |
---|
31 | |
---|
32 | #include "tfs.h" |
---|
33 | #include "cli.h" |
---|
34 | |
---|
35 | #ifdef __cplusplus |
---|
36 | extern "C" { |
---|
37 | #endif |
---|
38 | |
---|
39 | #ifndef SHOWVARARGS |
---|
40 | #define SHOWVARARGS 1 |
---|
41 | #endif |
---|
42 | |
---|
43 | |
---|
44 | extern int monConnect(int (*monptr)(int,void *,void *,void *), |
---|
45 | void (*lock)(void),void (*unlock)(void)); |
---|
46 | extern void mon_getargv(int *argc,char ***argv); |
---|
47 | extern void mon_intsrestore(unsigned long oldval); |
---|
48 | extern void mon_appexit(int exit_value); |
---|
49 | extern void mon_free(char *buffer); |
---|
50 | extern void mon_profiler(void *pdata); |
---|
51 | extern void mon_bbc(char *filename, int linenum); |
---|
52 | extern void mon_warmstart(unsigned long mask); |
---|
53 | extern void mon_delay(long msec); |
---|
54 | extern void mon_printpkt(char *buf, int size, int incoming); |
---|
55 | extern void mon_printmem(char *mem, int size, int ascii); |
---|
56 | |
---|
57 | |
---|
58 | extern int mon_com(int cmd,void *arg1,void *arg2,void *arg3); |
---|
59 | extern int mon_timer(int cmd, void * arg); |
---|
60 | extern int mon_setenv(char *varname,char *value); |
---|
61 | extern int mon_putchar(char c); |
---|
62 | extern int mon_getchar(void); |
---|
63 | extern int mon_gotachar(void); |
---|
64 | extern int mon_getbytes(char *buf,int count,int block); |
---|
65 | extern int mon_restart(int restart_value); |
---|
66 | extern int mon_tfsinit(void); |
---|
67 | extern int mon_tfsunlink(char *filename); |
---|
68 | extern int mon_tfslink(char *source, char *target); |
---|
69 | extern int mon_tfsrun(char **arglist,int verbosity); |
---|
70 | extern int mon_tfsfstat(char *filename,struct tfshdr *tfp); |
---|
71 | extern int mon_tfseof(int file_descriptor); |
---|
72 | extern int mon_tfstruncate(int file_descriptor,long length); |
---|
73 | extern int mon_tfsread(int file_descriptor,char *buffer,int size); |
---|
74 | extern int mon_tfswrite(int file_descriptor,char *buffer,int size); |
---|
75 | extern int mon_tfsopen(char *filename,long mode,char *buffer); |
---|
76 | extern int mon_tfsclose(int file_descriptor,char *info); |
---|
77 | extern int mon_tfsseek(int file_descriptor,int offset,int whence); |
---|
78 | extern int mon_tfsgetline(int file_descriptor,char *buffer,int bufsize); |
---|
79 | extern int mon_tfsipmod(char *name,char *buffer,int offset,int size); |
---|
80 | extern int mon_addcommand(struct monCommand *command_list,char *); |
---|
81 | extern int mon_docommand(char *cmdline,int verbosity); |
---|
82 | extern int mon_getline(char *buffer,int max,int ledit); |
---|
83 | extern int mon_decompress(char *src,int srcsize,char *dest); |
---|
84 | extern int mon_heapextend(char *base,int size); |
---|
85 | extern int mon_pcicfgwrite(int interface,int bus,int dev,int func,int reg, |
---|
86 | unsigned long val); |
---|
87 | extern int mon_tfsadd(char *filename, char *info, char *flags, |
---|
88 | unsigned char *src, int size); |
---|
89 | extern int mon_i2cwrite(int interface, int bigaddr, unsigned char *data, |
---|
90 | int len); |
---|
91 | extern int mon_i2cread(int interface, int bigaddr, unsigned char *data, |
---|
92 | int len); |
---|
93 | extern int mon_sendenetpkt(char *pkt, int len); |
---|
94 | extern int mon_recvenetpkt(char *pkt, int len); |
---|
95 | extern int mon_flashoverride(void *flashinfo, int get, int bank); |
---|
96 | extern int mon_flasherase(int snum); |
---|
97 | extern int mon_flashwrite(char *dest,char *src, int bytecnt); |
---|
98 | extern int mon_flashinfo(int snum,int *size, char **base); |
---|
99 | extern int mon_watchdog(void); |
---|
100 | extern int mon_timeofday(int cmd, void *arg); |
---|
101 | |
---|
102 | extern char *mon_getsym(char *symname, char *buf, int bufsize); |
---|
103 | extern char *mon_getenv(char *varname); |
---|
104 | extern char *mon_getenvp(void); |
---|
105 | extern char *mon_version(void); |
---|
106 | #ifdef MALLOC_DEBUG |
---|
107 | extern char *mon_malloc(int size,char *file, int line); |
---|
108 | extern char *mon_realloc(char *buf,int size,char *file, int line); |
---|
109 | #else |
---|
110 | extern char *mon_malloc(int size); |
---|
111 | extern char *mon_realloc(char *buf,int size); |
---|
112 | #endif |
---|
113 | |
---|
114 | extern long mon_tfsctrl(int command,long arg1,long arg2); |
---|
115 | extern long mon_tfstell(int file_descriptor); |
---|
116 | extern long mon_portcmd(int cmd, void *arg); |
---|
117 | |
---|
118 | extern unsigned short mon_xcrc16(char *buffer,long length); |
---|
119 | extern unsigned long mon_crc32(char *buffer,long length); |
---|
120 | |
---|
121 | extern unsigned long mon_intsoff(void); |
---|
122 | |
---|
123 | extern unsigned long mon_pcicfgread(int interface,int bus,int dev, |
---|
124 | int func,int reg); |
---|
125 | |
---|
126 | extern unsigned long mon_pcictrl(int interface, int cmd, |
---|
127 | unsigned long arg1, unsigned long arg2); |
---|
128 | |
---|
129 | extern unsigned long mon_i2cctrl(int interface, int cmd, |
---|
130 | unsigned long arg1, unsigned long arg2); |
---|
131 | |
---|
132 | extern unsigned long mon_assignhandler(long hnum, |
---|
133 | unsigned long arg1,unsigned long arg2); |
---|
134 | |
---|
135 | extern struct tfshdr *mon_tfsnext(struct tfshdr *tfp); |
---|
136 | extern struct tfshdr *mon_tfsstat(char *filename); |
---|
137 | |
---|
138 | #if SHOWVARARGS |
---|
139 | extern void mon_memtrace(char *fmt, ...); |
---|
140 | extern int mon_printf(char *fmt, ...); |
---|
141 | extern int mon_cprintf(char *fmt, ...); |
---|
142 | extern int mon_sprintf(char *,char *fmt, ...); |
---|
143 | #else |
---|
144 | extern void mon_memtrace(); |
---|
145 | extern int mon_printf(); |
---|
146 | extern int mon_cprintf(); |
---|
147 | extern int mon_sprintf(); |
---|
148 | #endif |
---|
149 | |
---|
150 | #ifdef __cplusplus |
---|
151 | } |
---|
152 | #endif |
---|
153 | |
---|
154 | |
---|
155 | /* defines used by monConnect(): |
---|
156 | */ |
---|
157 | #define GETMONFUNC_PUTCHAR 1 |
---|
158 | #define GETMONFUNC_GETCHAR 2 |
---|
159 | #define GETMONFUNC_GOTACHAR 3 |
---|
160 | #define GETMONFUNC_GETBYTES 4 |
---|
161 | #define GETMONFUNC_PRINTF 5 |
---|
162 | #define GETMONFUNC_CPRINTF 6 |
---|
163 | #define GETMONFUNC_SPRINTF 7 |
---|
164 | #define GETMONFUNC_RESTART 8 |
---|
165 | #define GETMONFUNC_GETENV 9 |
---|
166 | #define GETMONFUNC_SETENV 10 |
---|
167 | #define GETMONFUNC_TFSINIT 11 |
---|
168 | #define GETMONFUNC_TFSADD 12 |
---|
169 | #define GETMONFUNC_TFSUNLINK 13 |
---|
170 | #define GETMONFUNC_TFSRUN 14 |
---|
171 | #define GETMONFUNC_TFSNEXT 15 |
---|
172 | #define GETMONFUNC_TFSSTAT 16 |
---|
173 | #define GETMONFUNC_TFSREAD 17 |
---|
174 | #define GETMONFUNC_TFSWRITE 18 |
---|
175 | #define GETMONFUNC_TFSOPEN 19 |
---|
176 | #define GETMONFUNC_TFSCLOSE 20 |
---|
177 | #define GETMONFUNC_TFSSEEK 21 |
---|
178 | #define GETMONFUNC_TFSGETLINE 22 |
---|
179 | #define GETMONFUNC_TFSIPMOD 23 |
---|
180 | #define GETMONFUNC_TFSCTRL 24 |
---|
181 | #define GETMONFUNC_ADDCOMMAND 25 |
---|
182 | #define GETMONFUNC_DOCOMMAND 26 |
---|
183 | #define GETMONFUNC_GETARGV 27 |
---|
184 | #define GETMONFUNC_CRC16 28 |
---|
185 | #define GETMONFUNC_CRC32 29 |
---|
186 | #define GETMONFUNC_PIOGET 30 /* NA (removed as of 1.0) */ |
---|
187 | #define GETMONFUNC_PIOSET 31 /* NA (removed as of 1.0) */ |
---|
188 | #define GETMONFUNC_PIOCLR 32 /* NA (removed as of 1.0) */ |
---|
189 | #define GETMONFUNC_INTSOFF 33 |
---|
190 | #define GETMONFUNC_INTSRESTORE 34 |
---|
191 | #define GETMONFUNC_APPEXIT 35 |
---|
192 | #define GETMONFUNC_MALLOC 36 |
---|
193 | #define GETMONFUNC_FREE 37 |
---|
194 | #define GETMONFUNC_GETLINE 38 |
---|
195 | #define GETMONFUNC_TFSFSTAT 39 |
---|
196 | #define GETMONFUNC_TFSEOF 40 |
---|
197 | #define GETMONFUNC_DECOMPRESS 41 |
---|
198 | #define GETMONFUNC_TFSTRUNCATE 42 |
---|
199 | #define GETMONFUNC_HEAPXTEND 43 |
---|
200 | #define GETMONFUNC_PROFILER 44 |
---|
201 | #define GETMONFUNC_TFSLINK 45 |
---|
202 | #define GETMONFUNC_BBC 46 |
---|
203 | #define GETMONFUNC_MEMTRACE 47 |
---|
204 | #define GETMONFUNC_TFSTELL 48 |
---|
205 | #define GETMONFUNC_VERSION 49 |
---|
206 | #define GETMONFUNC_WARMSTART 50 |
---|
207 | #define GETMONFUNC_PCICFGREAD 51 |
---|
208 | #define GETMONFUNC_PCICFGWRITE 52 |
---|
209 | #define GETMONFUNC_PCICONTROL 53 |
---|
210 | #define GETMONFUNC_I2CREAD 54 |
---|
211 | #define GETMONFUNC_I2CWRITE 55 |
---|
212 | #define GETMONFUNC_I2CCONTROL 56 |
---|
213 | #define GETMONFUNC_MONDELAY 57 |
---|
214 | #define GETMONFUNC_GETENVP 58 |
---|
215 | #define GETMONFUNC_REALLOC 59 |
---|
216 | #define GETMONFUNC_SENDENETPKT 60 |
---|
217 | #define GETMONFUNC_RECVENETPKT 61 |
---|
218 | #define GETMONFUNC_GETSYM 62 |
---|
219 | #define GETMONFUNC_PRINTPKT 63 |
---|
220 | #define GETMONFUNC_FLASHWRITE 64 |
---|
221 | #define GETMONFUNC_FLASHERASE 65 |
---|
222 | #define GETMONFUNC_FLASHINFO 66 |
---|
223 | #define GETMONFUNC_ASSIGNHDLR 67 |
---|
224 | #define GETMONFUNC_WATCHDOG 68 |
---|
225 | #define GETMONFUNC_PRINTMEM 69 |
---|
226 | #define GETMONFUNC_PORTCMD 70 |
---|
227 | #define GETMONFUNC_TIMEOFDAY 71 |
---|
228 | #define GETMONFUNC_TIMER 72 |
---|
229 | #define GETMONFUNC_FLASHOVRRD 73 |
---|
230 | |
---|
231 | #define CACHEFTYPE_DFLUSH 200 |
---|
232 | #define CACHEFTYPE_IINVALIDATE 201 |
---|
233 | |
---|
234 | #define CHARFUNC_PUTCHAR 300 |
---|
235 | #define CHARFUNC_GETCHAR 301 |
---|
236 | #define CHARFUNC_GOTACHAR 302 |
---|
237 | #define CHARFUNC_RAWMODEON 303 |
---|
238 | #define CHARFUNC_RAWMODEOFF 304 |
---|
239 | |
---|
240 | #define ASSIGNFUNC_GETUSERLEVEL 400 |
---|
241 | #define ASSIGNFUNC_WATCHDOG 401 |
---|
242 | |
---|
243 | |
---|
244 | /* Defines used by mon_warmstart(): |
---|
245 | */ |
---|
246 | #define WARMSTART_IOINIT 0x00000001 |
---|
247 | #define WARMSTART_BSSINIT 0x00000002 |
---|
248 | #define WARMSTART_RUNMONRC 0x00000004 |
---|
249 | #define WARMSTART_MONHEADER 0x00000008 |
---|
250 | #define WARMSTART_TFSAUTOBOOT 0x00000010 |
---|
251 | #define WARMSTART_BOARDINFO 0x00000020 |
---|
252 | #define WARMSTART_ALL 0xffffffff |
---|
253 | #endif |
---|