source: rtems/c/src/lib/libbsp/shared/umon/monlib.c @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 24.0 KB
Line 
1/*
2 *  monlib.c -
3 *  This file is part of the monitor code, but it is actually linked into
4 *  the application.  It is built with (but not linked with) the monitor,
5 *  then the monlib.o file is linked with the application.
6 *  The only requirement on the application is that it know where the address
7 *  of the monCom function is in the monitor's space.
8 *  The monCom function will be accessible in some "well-known" way (processor
9 *  and platform dependent) so that this will not be a problem.
10 *
11 *  This monlib.c file is a replacement for the older mechanism that was
12 *  a bit more error-prone...  A table of function pointers existed at some
13 *  well-known location in the monitor, and the content of that table was
14 *  assumed to also be "well-known".  This new version only assumes that the
15 *  pointer to monCom is well-known; everything else will work based on the
16 *  fact that the monitor and application will share the monlib.h header
17 *  file.
18 *
19 **************************************************************************
20 *  General notice:
21 *  This code is part of a boot-monitor package developed as a generic base
22 *  platform for embedded system designs.  As such, it is likely to be
23 *  distributed to various projects beyond the control of the original
24 *  author.  Please notify the author of any enhancements made or bugs found
25 *  so that all may benefit from the changes.  In addition, notification back
26 *  to the author will allow the new user to pick up changes that may have
27 *  been made by other users after this version of the code was distributed.
28 *
29 *  Note1: the majority of this code was edited with 4-space tabs.
30 *  Note2: as more and more contributions are accepted, the term "author"
31 *         is becoming a mis-representation of credit.
32 *
33 *  Original author:    Ed Sutter
34 *  Email:              esutter@alcatel-lucent.com
35 *  Phone:              908-582-2351
36 **************************************************************************
37 *
38 *  Ed Sutter has been informed that this code is being used in RTEMS.
39 *
40 *  This code was reformatted by Joel Sherrill from OAR Corporation and
41 *  Fernando Nicodemos <fgnicodemos@terra.com.br> from NCB - Sistemas
42 *  Embarcados Ltda. (Brazil) to be more compliant with RTEMS coding
43 *  standards and to eliminate C++ style comments.
44 */
45
46#include <umon/monlib.h>
47
48static int              (*_tfsseek)(int,int,int);
49static int              (*_tfsgetline)(int,char *,int);
50static int              (*_tfsipmod)(char *,char *,int,int);
51static int              (*_tfsinit)(void);
52static int              (*_tfsadd)(char *,char *,char *,unsigned char *,int);
53static int              (*_tfsunlink)(char *);
54static int              (*_tfsrun)(char **,int);
55static int              (*_tfsread)(int,char *,int);
56static int              (*_tfswrite)(int,char *,int);
57static int              (*_tfsopen)(char *,long,char *);
58static int              (*_tfsclose)(int,char *);
59static int              (*_printf)(
60  char *, int,int,int,int,int,int,int,int,int,int,int,int);
61static int              (*_cprintf)(
62  char *, int,int,int,int,int,int,int,int,int,int,int,int);
63static int              (*_sprintf)(
64  char *, char *, int,int,int,int,int,int,int,int,int,int,int,int);
65static int              (*_monrestart)(int);
66static int              (*_rputchar)(unsigned char c);
67static int              (*_getchar)(void);
68static int              (*_gotachar)(void);
69static int              (*_getbytes)(char *,int,int);
70static int              (*_addcommand)(struct monCommand *,char *);
71static int              (*_docommand)(char *,int);
72static int              (*_getline)(char *,int,int);
73static int              (*_tfsfstat)(char *,struct tfshdr *);
74static int              (*_tfseof)(int);
75static int              (*_decompress)(char *,int,char *);
76static int              (*_tfstruncate)(int,long);
77static int              (*_heapextend)(char *,int);
78static int              (*_tfslink)(char *,char *);
79static int              (*_pcicfgwrite)(int,int,int,int,int,unsigned long);
80static int              (*_i2cwrite)(int,int,unsigned char *,int);
81static int              (*_i2cread)(int,int,unsigned char *,int);
82static int              (*_flashwrite)(char *,char *,int);
83static int              (*_flasherase)(int);
84static int              (*_flashinfo)(int,int *,char **);
85static int              (*_flashoverride)(void *,int,int);
86static int              (*_sendenet)(char *,int);
87static int              (*_recvenet)(char *,int);
88static int              (*_printpkt)(char *,int,int);
89static int              (*_setenv)(char *,char *);
90static int              (*_watchdog)(void);
91static int              (*_timeofday)(int,void *);
92static int              (*_montimer)(int cmd, void *arg);
93
94static char             *(*_getenv)(char *);
95static char             *(*_version)(void);
96static char             *(*_getenvp)(void);
97#ifdef MALLOC_DEBUG
98static char             *(*_malloc)(int,char *,int);
99static char             *(*_realloc)(char *buf,int,char *,int);
100#else
101static char             *(*_malloc)(int);
102static char             *(*_realloc)(char *,int);
103#endif
104static char             *(*_getsym)(char *,char *,int);
105
106static void             (*_intsrestore)(unsigned long);
107static void             (*_appexit)(int);
108static void             (*_free)(char *);
109static void             (*_getargv)(int *,char ***);
110static void             (*_profiler)(void *);
111static void             (*_bbc)(char *,int);
112static void             (*_memtrace)(
113  char *, int,int,int,int,int,int,int,int,int,int,int,int);
114static void             (*_appwarmstart)(unsigned long);
115static void             (*_mondelay)(long);
116static void             (*_printmem)(char *,int,int);
117
118static long             (*_tfsctrl)(int,long,long);
119static long             (*_tfstell)(int);
120static long             (*_portcmd)(int,void *);
121
122static struct   tfshdr *(*_tfsnext)(struct tfshdr *);
123static struct   tfshdr *(*_tfsstat)(char *);
124
125static unsigned long    (*_i2cctrl)(int,int,unsigned long,unsigned long);
126static unsigned long    (*_pcicfgread)(int,int,int,int,int);
127static unsigned long    (*_pcictrl)(int,int,unsigned long,unsigned long);
128static unsigned long    (*_crc32)(unsigned char *,unsigned long);
129static unsigned long    (*_intsoff)(void);
130static unsigned long    (*_assign_handler)(long,unsigned long,unsigned long);
131
132static unsigned short   (*_xcrc16)(unsigned char *,unsigned long);
133
134
135static void (*_monlock)(void);
136static void (*_monunlock)(void);
137static int      (*_moncom)(int,void *,void *, void *);
138
139/**************************************************************************
140 *
141 * The following macros support the default monitor lock/unlock mechanism when
142 * they point to monLock and monUnlock.  If something other than the default
143 * is to be used, then simply redefine them here.  Refer to the monitor
144 * app note that discusses multi-tasking access to the monitor API for more
145 * information.
146 *
147 * TFS_MONLOCK/UNLOCK:
148 * Lock/unlock for functions that access TFS flash space:
149 */
150#define TFS_MONLOCK                     monLock
151#define TFS_MONUNLOCK           monUnlock
152
153/* ENV_MONLOCK/UNLOCK:
154 * Lock/unlock for functions that access monitor shell variables:
155 */
156#define ENV_MONLOCK                     monLock
157#define ENV_MONUNLOCK           monUnlock
158
159/* CONSOLE_MONLOCK/UNLOCK:
160 * Lock/unlock for functions in the monitor that deal with console output.
161 */
162#define CONSOLE_MONLOCK         monLock
163#define CONSOLE_MONUNLOCK       monUnlock
164
165/* HEAP_MONLOCK/UNLOCK:
166 * Lock/unlock for functions in the monitor that deal with the heap.
167 */
168#define HEAP_MONLOCK            monLock
169#define HEAP_MONUNLOCK          monUnlock
170
171/* BLOCKING_MONLOCK/UNLOCK:
172 * Lock/unlock for functions in the monitor that block waiting for
173 * console input.
174 */
175#define BLOCKING_MONLOCK        monLock
176#define BLOCKING_MONUNLOCK      monUnlock
177
178/* GENERIC_MONLOCK/UNLOCK:
179 * Lock/unlock for all functions not covered by the above macros.
180 */
181#define GENERIC_MONLOCK         monLock
182#define GENERIC_MONUNLOCK       monUnlock
183
184/**************************************************************************
185 *
186 * monConnect():
187 *      This must be the first call by the application code to talk to the
188 *      monitor.  It is expecting three incoming function pointers:
189 *
190 *      mon:    Points to the monitor's _moncom function;
191 *                      This is a "well-known" address because the monitor and
192 *                      application code (two separately linked binaries) must
193 *                      know it.
194 *      lock:   Points to a function in the application code that will be
195 *                      used by the monitor as a lock-out function (some kind of
196 *                      semaphore in the application).
197 *      unlock: Points to a function in the application code that will be
198 *                      used by the monitor as an un-lock-out function (undo whatever
199 *                      lock-out mechanism was done by lock).
200 */
201int
202monConnect(int (*mon)(int,void *,void *,void *),
203        void (*lock)(void), void (*unlock)(void))
204{
205        int rc = 0;
206
207        /* Assign incoming lock and unlock functions... */
208        _monlock = lock;
209        _monunlock = unlock;
210
211        /* If the mon pointer is non-zero, then make the mon_ connections... */
212        if (mon) {
213
214                _moncom = mon;
215
216                /* Make the connections between "mon_" functions that are                       */
217                /* symbolically accessible by the application and the corresponding     */
218                /* functions that exists in the monitor.                                                        */
219                rc += _moncom(GETMONFUNC_PUTCHAR,&_rputchar,0,0);
220                rc += _moncom(GETMONFUNC_GETCHAR,&_getchar,0,0);
221                rc += _moncom(GETMONFUNC_GOTACHAR,&_gotachar,0,0);
222                rc += _moncom(GETMONFUNC_GETBYTES,&_getbytes,0,0);
223                rc += _moncom(GETMONFUNC_PRINTF,&_printf,0,0);
224                rc += _moncom(GETMONFUNC_CPRINTF,&_cprintf,0,0);
225                rc += _moncom(GETMONFUNC_SPRINTF,&_sprintf,0,0);
226                rc += _moncom(GETMONFUNC_RESTART,&_monrestart,0,0);
227                rc += _moncom(GETMONFUNC_GETENV,&_getenv,0,0);
228                rc += _moncom(GETMONFUNC_SETENV,&_setenv,0,0);
229                rc += _moncom(GETMONFUNC_TFSINIT,&_tfsinit,0,0);
230                rc += _moncom(GETMONFUNC_TFSADD,&_tfsadd,0,0);
231                rc += _moncom(GETMONFUNC_TFSUNLINK,&_tfsunlink,0,0);
232                rc += _moncom(GETMONFUNC_TFSRUN,&_tfsrun,0,0);
233                rc += _moncom(GETMONFUNC_TFSNEXT,&_tfsnext,0,0);
234                rc += _moncom(GETMONFUNC_TFSSTAT,&_tfsstat,0,0);
235                rc += _moncom(GETMONFUNC_TFSREAD,&_tfsread,0,0);
236                rc += _moncom(GETMONFUNC_TFSWRITE,&_tfswrite,0,0);
237                rc += _moncom(GETMONFUNC_TFSOPEN,&_tfsopen,0,0);
238                rc += _moncom(GETMONFUNC_TFSCLOSE,&_tfsclose,0,0);
239                rc += _moncom(GETMONFUNC_TFSSEEK,&_tfsseek,0,0);
240                rc += _moncom(GETMONFUNC_TFSGETLINE,&_tfsgetline,0,0);
241                rc += _moncom(GETMONFUNC_TFSIPMOD,&_tfsipmod,0,0);
242                rc += _moncom(GETMONFUNC_TFSCTRL,&_tfsctrl,0,0);
243                rc += _moncom(GETMONFUNC_ADDCOMMAND,&_addcommand,0,0);
244                rc += _moncom(GETMONFUNC_DOCOMMAND,&_docommand,0,0);
245                rc += _moncom(GETMONFUNC_GETARGV,&_getargv,0,0);
246                rc += _moncom(GETMONFUNC_CRC16,&_xcrc16,0,0);
247                rc += _moncom(GETMONFUNC_CRC32,&_crc32,0,0);
248                rc += _moncom(GETMONFUNC_INTSOFF,&_intsoff,0,0);
249                rc += _moncom(GETMONFUNC_INTSRESTORE,&_intsrestore,0,0);
250                rc += _moncom(GETMONFUNC_APPEXIT,&_appexit,0,0);
251                rc += _moncom(GETMONFUNC_MALLOC,&_malloc,0,0);
252                rc += _moncom(GETMONFUNC_FREE,&_free,0,0);
253                rc += _moncom(GETMONFUNC_GETLINE,&_getline,0,0);
254                rc += _moncom(GETMONFUNC_TFSFSTAT,&_tfsfstat,0,0);
255                rc += _moncom(GETMONFUNC_TFSEOF,&_tfseof,0,0);
256                rc += _moncom(GETMONFUNC_DECOMPRESS,&_decompress,0,0);
257                rc += _moncom(GETMONFUNC_TFSTRUNCATE,&_tfstruncate,0,0);
258                rc += _moncom(GETMONFUNC_HEAPXTEND,&_heapextend,0,0);
259                rc += _moncom(GETMONFUNC_PROFILER,&_profiler,0,0);
260                rc += _moncom(GETMONFUNC_TFSLINK,&_tfslink,0,0);
261                rc += _moncom(GETMONFUNC_BBC,&_bbc,0,0);
262                rc += _moncom(GETMONFUNC_MEMTRACE,&_memtrace,0,0);
263                rc += _moncom(GETMONFUNC_TFSTELL,&_tfstell,0,0);
264                rc += _moncom(GETMONFUNC_VERSION,&_version,0,0);
265                rc += _moncom(GETMONFUNC_WARMSTART,&_appwarmstart,0,0);
266                rc += _moncom(GETMONFUNC_PCICFGREAD,&_pcicfgread,0,0);
267                rc += _moncom(GETMONFUNC_PCICFGWRITE,&_pcicfgwrite,0,0);
268                rc += _moncom(GETMONFUNC_PCICONTROL,&_pcictrl,0,0);
269                rc += _moncom(GETMONFUNC_I2CREAD,&_i2cread,0,0);
270                rc += _moncom(GETMONFUNC_I2CWRITE,&_i2cwrite,0,0);
271                rc += _moncom(GETMONFUNC_I2CCONTROL,&_i2cctrl,0,0);
272                rc += _moncom(GETMONFUNC_MONDELAY,&_mondelay,0,0);
273                rc += _moncom(GETMONFUNC_GETENVP,&_getenvp,0,0);
274                rc += _moncom(GETMONFUNC_REALLOC,&_realloc,0,0);
275                rc += _moncom(GETMONFUNC_SENDENETPKT,&_sendenet,0,0);
276                rc += _moncom(GETMONFUNC_RECVENETPKT,&_recvenet,0,0);
277                rc += _moncom(GETMONFUNC_GETSYM,&_getsym,0,0);
278                rc += _moncom(GETMONFUNC_PRINTPKT,&_printpkt,0,0);
279                rc += _moncom(GETMONFUNC_FLASHWRITE,&_flashwrite,0,0);
280                rc += _moncom(GETMONFUNC_FLASHERASE,&_flasherase,0,0);
281                rc += _moncom(GETMONFUNC_FLASHINFO,&_flashinfo,0,0);
282                rc += _moncom(GETMONFUNC_ASSIGNHDLR,&_assign_handler,0,0);
283                rc += _moncom(GETMONFUNC_WATCHDOG,&_watchdog,0,0);
284                rc += _moncom(GETMONFUNC_PRINTMEM,&_printmem,0,0);
285                rc += _moncom(GETMONFUNC_PORTCMD,&_portcmd,0,0);
286                rc += _moncom(GETMONFUNC_TIMEOFDAY,&_timeofday,0,0);
287                rc += _moncom(GETMONFUNC_TIMER,&_montimer,0,0);
288                rc += _moncom(GETMONFUNC_FLASHOVRRD,&_flashoverride,0,0);
289        }
290        return(rc);
291}
292
293/* ignorelock:
294 * Used as a back-door to disable the monLock()/monUnlock() stuff.
295 * This is useful if the application CLI falls through to the monitor's
296 * CLI and you are using the "call" command in the monitor to execute some
297 * function that has a mon_xxx function in it.  In this case, the fact that
298 * the application has fallen through to the monitor means that the lock
299 * is already active, so when the function tries to call some other mon_xxx
300 * function it won't be able to because of the lock already being set.
301 *
302 * With these functions in the application space, the user can do the
303 * following:
304 *      call %DisableLock
305 *  call %Func_with_monXXX_in_it
306 *  call %EnableLock
307 *
308 * Note that this is NOT to be used by application code, it is simply a
309 * back-door mechanism to allow "call" from the CLI to invoke functions
310 * that have mon_XXX functionality in them.
311 */
312static int ignorelock = 0;
313
314static void
315DisableMonLock(void)
316{
317        ignorelock = 2;
318}
319
320static void
321EnableMonLock(void)
322{
323        ignorelock = 0;
324}
325
326/* monLock() & monUnlock():
327 * Used by all of the wrapper functions below this point to call
328 * the function pointed to by _monlock & _monunlock function pointers
329 * (if set).
330 * These functions must test both the function pointer and the state
331 * of the ignorelock variable.  The function DisableMonLock() sets the
332 * ignorelock variable to 2 because it is being executed through "call"
333 * which means that the lock is active.
334 */
335static void
336monLock(void)
337{
338        if (_monlock) {
339                switch(ignorelock) {
340                        case 1:
341                                break;
342                        case 2:
343                                ignorelock--;
344                                break;
345                        default:
346                                _monlock();
347                                break;
348                }
349        }
350}
351
352static void
353monUnlock(void)
354{
355        if (_monunlock) {
356                switch(ignorelock) {
357                        case 1:
358                                break;
359                        case 2:
360                                ignorelock--;
361                        default:
362                                _monunlock();
363                                break;
364                }
365        }
366}
367
368int
369mon_com(int cmd, void *arg1, void *arg2, void *arg3)
370{
371        int     ret;
372
373        GENERIC_MONLOCK();
374        ret = _moncom(cmd,arg1,arg2,arg3);
375        GENERIC_MONUNLOCK();
376        return(ret);
377}
378
379int
380mon_putchar(char c)
381{
382        int     ret;
383
384        CONSOLE_MONLOCK();
385        ret = _rputchar(c);
386        CONSOLE_MONUNLOCK();
387        return(ret);
388}
389
390int
391mon_getchar(void)
392{
393        int     ret;
394
395        BLOCKING_MONLOCK();
396        ret = _getchar();
397        BLOCKING_MONUNLOCK();
398        return(ret);
399}
400
401int
402mon_gotachar(void)
403{
404        int     ret;
405
406        GENERIC_MONLOCK();
407        ret = _gotachar();
408        GENERIC_MONUNLOCK();
409        return(ret);
410}
411
412int
413mon_getbytes(char *buf,int cnt,int block)
414{
415        int     ret;
416
417        BLOCKING_MONLOCK();
418        ret = _getbytes(buf,cnt,block);
419        BLOCKING_MONUNLOCK();
420        return(ret);
421}
422
423int
424mon_printf(
425  char *fmt,
426  int   a1, int a2, int a3, int a4,  int a5,  int a6,
427  int   a7, int a8, int a9, int a10, int a11, int a12
428)
429{
430        int     ret;
431
432        CONSOLE_MONLOCK();
433        ret = _printf(fmt,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12);
434        CONSOLE_MONUNLOCK();
435        return(ret);
436}
437
438int
439mon_cprintf(
440  char *fmt,
441  int   a1, int a2, int a3, int a4,  int a5,  int a6,
442  int   a7, int a8, int a9, int a10, int a11, int a12
443)
444{
445        int     ret;
446
447        CONSOLE_MONLOCK();
448        ret = _cprintf(fmt,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12);
449        CONSOLE_MONUNLOCK();
450        return(ret);
451}
452
453int
454mon_sprintf(
455  char *buf,
456  char *fmt,
457  int   a1, int a2, int a3, int a4,  int a5,  int a6,
458  int   a7, int a8, int a9, int a10, int a11, int a12
459)
460{
461        int     ret;
462
463        GENERIC_MONLOCK();
464        ret = _sprintf(buf,fmt,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12);
465        GENERIC_MONUNLOCK();
466        return(ret);
467}
468
469int
470mon_restart(int val)
471{
472        int     ret;
473
474        GENERIC_MONLOCK();
475        ret = _monrestart(val);
476        GENERIC_MONUNLOCK();
477        return(ret);
478}
479
480char *
481mon_getenvp(void)
482{
483        char *ret;
484
485        ENV_MONLOCK();
486        ret = _getenvp();
487        ENV_MONUNLOCK();
488        return(ret);
489}
490
491char *
492mon_getenv(char *name)
493{
494        char *ret;
495
496        ENV_MONLOCK();
497        ret = _getenv(name);
498        ENV_MONUNLOCK();
499        return(ret);
500}
501
502int
503mon_setenv(char *name,char *val)
504{
505        int ret;
506
507        ENV_MONLOCK();
508        ret = _setenv(name,val);
509        ENV_MONUNLOCK();
510        return(ret);
511}
512
513char *
514mon_getsym(char *name,char *buf, int bufsize)
515{
516        char *ret;
517
518        ENV_MONLOCK();
519        ret = _getsym(name,buf,bufsize);
520        ENV_MONUNLOCK();
521        return(ret);
522}
523
524int
525mon_tfsinit(void)
526{
527        int     ret;
528
529        TFS_MONLOCK();
530        ret = _tfsinit();
531        TFS_MONUNLOCK();
532        return(ret);
533}
534
535int
536mon_tfsadd(char *name, char *info, char *flags, unsigned char *src, int size)
537{
538        int     ret;
539
540        TFS_MONLOCK();
541        ret = _tfsadd(name,info,flags,src,size);
542        TFS_MONUNLOCK();
543        return(ret);
544}
545
546int
547mon_tfslink(char *src, char *target)
548{
549        int     ret;
550
551        TFS_MONLOCK();
552        ret = _tfslink(src,target);
553        TFS_MONUNLOCK();
554        return(ret);
555}
556
557int
558mon_tfsunlink(char *name)
559{
560        int     ret;
561
562        TFS_MONLOCK();
563        ret = _tfsunlink(name);
564        TFS_MONUNLOCK();
565        return(ret);
566}
567
568int
569mon_tfsrun(char **name,int verbose)
570{
571        int     ret;
572
573        TFS_MONLOCK();
574        ret = _tfsrun(name,verbose);
575        TFS_MONUNLOCK();
576        return(ret);
577}
578
579struct tfshdr *
580mon_tfsnext(struct tfshdr *fp)
581{
582        struct tfshdr *ret;
583
584        TFS_MONLOCK();
585        ret = _tfsnext(fp);
586        TFS_MONUNLOCK();
587        return(ret);
588}
589
590int
591mon_tfstruncate(int tfd, long len)
592{
593        int ret;
594
595        TFS_MONLOCK();
596        ret = _tfstruncate(tfd,len);
597        TFS_MONUNLOCK();
598        return(ret);
599}
600
601int
602mon_tfseof(int tfd)
603{
604        int ret;
605
606        TFS_MONLOCK();
607        ret = _tfseof(tfd);
608        TFS_MONUNLOCK();
609        return(ret);
610}
611
612int
613mon_tfsfstat(char *name, struct tfshdr *fp)
614{
615        int ret;
616
617        TFS_MONLOCK();
618        ret = _tfsfstat(name,fp);
619        TFS_MONUNLOCK();
620        return(ret);
621}
622
623struct tfshdr *
624mon_tfsstat(char *name)
625{
626        struct tfshdr *ret;
627
628        TFS_MONLOCK();
629        ret = _tfsstat(name);
630        TFS_MONUNLOCK();
631        return(ret);
632}
633
634int
635mon_tfsread(int fd, char *buf, int cnt)
636{
637        int     ret;
638
639        TFS_MONLOCK();
640        ret = _tfsread(fd,buf,cnt);
641        TFS_MONUNLOCK();
642        return(ret);
643}
644
645int
646mon_tfswrite(int fd, char *buf, int cnt)
647{
648        int     ret;
649
650        TFS_MONLOCK();
651        ret = _tfswrite(fd,buf,cnt);
652        TFS_MONUNLOCK();
653        return(ret);
654}
655
656int
657mon_tfsopen(char *file,long flagmode,char *buf)
658{
659        int     ret;
660
661        TFS_MONLOCK();
662        ret = _tfsopen(file,flagmode,buf);
663        TFS_MONUNLOCK();
664        return(ret);
665}
666
667int
668mon_tfsclose(int fd,char *info)
669{
670        int     ret;
671
672        TFS_MONLOCK();
673        ret = _tfsclose(fd,info);
674        TFS_MONUNLOCK();
675        return(ret);
676}
677
678int
679mon_tfsseek(int fd, int offset, int whence)
680{
681        int     ret;
682
683        TFS_MONLOCK();
684        ret = _tfsseek(fd,offset,whence);
685        TFS_MONUNLOCK();
686        return(ret);
687}
688
689int
690mon_tfsgetline(int fd,char *bp,int max)
691{
692        int     ret;
693
694        TFS_MONLOCK();
695        ret = _tfsgetline(fd,bp,max);
696        TFS_MONUNLOCK();
697        return(ret);
698}
699
700int
701mon_tfsipmod(char *name,char *buf,int offset,int size)
702{
703        int     ret;
704
705        TFS_MONLOCK();
706        ret = _tfsipmod(name,buf,offset,size);
707        TFS_MONUNLOCK();
708        return(ret);
709}
710
711long
712mon_tfsctrl(int rqst,long arg1,long arg2)
713{
714        long    ret;
715
716        TFS_MONLOCK();
717        ret = _tfsctrl(rqst,arg1,arg2);
718        TFS_MONUNLOCK();
719        return(ret);
720}
721
722long
723mon_tfstell(int fd)
724{
725        long    ret;
726
727        TFS_MONLOCK();
728        ret = _tfstell(fd);
729        TFS_MONUNLOCK();
730        return(ret);
731}
732
733int
734mon_addcommand(struct monCommand *cmdlist, char *cmdlvl)
735{
736        int     ret;
737
738        GENERIC_MONLOCK();
739        ret = _addcommand(cmdlist,cmdlvl);
740        GENERIC_MONUNLOCK();
741        return(ret);
742}
743
744int
745mon_docommand(char *cmdline,int verbose)
746{
747        int     ret;
748
749        GENERIC_MONLOCK();
750        ret = _docommand(cmdline,verbose);
751        GENERIC_MONUNLOCK();
752        return(ret);
753}
754
755void
756mon_getargv(int *argc,char ***argv)
757{
758        GENERIC_MONLOCK();
759        _getargv(argc,argv);
760        GENERIC_MONUNLOCK();
761}
762
763unsigned short
764mon_xcrc16(char *buf,long nbytes)
765{
766        unsigned short ret;
767
768        GENERIC_MONLOCK();
769        ret = _xcrc16((unsigned char *)buf,nbytes);
770        GENERIC_MONUNLOCK();
771        return(ret);
772}
773
774unsigned long
775mon_intsoff(void)
776{
777        unsigned long ret;
778
779        GENERIC_MONLOCK();
780        ret = _intsoff();
781        GENERIC_MONUNLOCK();
782        return(ret);
783}
784
785void
786mon_intsrestore(unsigned long msr)
787{
788        GENERIC_MONLOCK();
789        _intsrestore(msr);
790        GENERIC_MONUNLOCK();
791}
792
793void
794mon_appexit(int val)
795{
796        GENERIC_MONLOCK();
797        _appexit(val);
798        GENERIC_MONUNLOCK();
799}
800
801#ifdef MALLOC_DEBUG
802char *
803mon_malloc(int size,char *fname,int fline)
804{
805        char *ret;
806
807        HEAP_MONLOCK();
808        ret = _malloc(size,fname,fline);
809        HEAP_MONUNLOCK();
810        return(ret);
811}
812
813char *
814mon_realloc(char *buf, int size, char *fname, int fline)
815{
816        char *ret;
817
818        HEAP_MONLOCK();
819        ret = _realloc(buf,size, fname, fline);
820        HEAP_MONUNLOCK();
821        return(ret);
822}
823#else
824char *
825mon_malloc(int size)
826{
827        char *ret;
828
829        HEAP_MONLOCK();
830        ret = _malloc(size);
831        HEAP_MONUNLOCK();
832        return(ret);
833}
834
835char *
836mon_realloc(char *buf, int size)
837{
838        char *ret;
839
840        HEAP_MONLOCK();
841        ret = _realloc(buf,size);
842        HEAP_MONUNLOCK();
843        return(ret);
844}
845#endif
846
847void
848mon_free(char *cp)
849{
850        HEAP_MONLOCK();
851        _free(cp);
852        HEAP_MONUNLOCK();
853}
854
855int
856mon_getline(char *buf,int max,int ledit)
857{
858        int     ret;
859
860        BLOCKING_MONLOCK();
861        ret = _getline(buf,max,ledit);
862        BLOCKING_MONUNLOCK();
863        return(ret);
864}
865
866int
867mon_decompress(char *src,int srcsize,char *dest)
868{
869        int     ret;
870
871        GENERIC_MONLOCK();
872        ret = _decompress(src,srcsize,dest);
873        GENERIC_MONUNLOCK();
874        return(ret);
875}
876
877int
878mon_heapextend(char *base,int size)
879{
880        int     ret;
881
882        GENERIC_MONLOCK();
883        ret = _heapextend(base,size);
884        GENERIC_MONUNLOCK();
885        return(ret);
886}
887
888void
889mon_bbc(char *filename, int lineno)
890{
891        _bbc(filename, lineno);
892}
893
894void
895mon_profiler(void *pdata)
896{
897        _profiler(pdata);
898}
899
900void
901mon_memtrace(
902  char *fmt,
903  int   a1, int a2, int a3, int a4,  int a5,  int a6,
904  int   a7, int a8, int a9, int a10, int a11, int a12
905)
906{
907        _memtrace(fmt,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12);
908}
909
910char *
911mon_version(void)
912{
913        char *ret;
914
915        GENERIC_MONLOCK();
916        ret = _version();
917        GENERIC_MONUNLOCK();
918        return(ret);
919}
920
921void
922mon_warmstart(unsigned long mask)
923{
924        GENERIC_MONLOCK();
925        _appwarmstart(mask);
926        GENERIC_MONUNLOCK();
927}
928
929int
930mon_pcicfgwrite(int interface,int bus,int dev,int func,int reg,
931        unsigned long val)
932{
933        int     retval;
934
935        GENERIC_MONLOCK();
936        retval = _pcicfgwrite(interface,bus,dev,func,reg,val);
937        GENERIC_MONUNLOCK();
938        return(retval);
939}
940
941unsigned long
942mon_pcicfgread(int interface,int bus,int dev, int func,int reg)
943{
944        unsigned long retval;
945
946        GENERIC_MONLOCK();
947        retval = _pcicfgread(interface,bus,dev,func,reg);
948        GENERIC_MONUNLOCK();
949        return(retval);
950}
951
952unsigned long
953mon_pcictrl(int interface, int cmd, unsigned long arg1, unsigned long arg2)
954{
955        unsigned long val;
956
957        GENERIC_MONLOCK();
958        val = _pcictrl(interface,cmd,arg1,arg2);
959        GENERIC_MONUNLOCK();
960        return(val);
961}
962
963unsigned long
964mon_i2cctrl(int interface, int cmd, unsigned long arg1, unsigned long arg2)
965{
966        unsigned long val;
967
968        GENERIC_MONLOCK();
969        val = _i2cctrl(interface,cmd,arg1,arg2);
970        GENERIC_MONUNLOCK();
971        return(val);
972}
973
974int
975mon_i2cwrite(int interface, int bigaddr, unsigned char *data, int len)
976{
977        int     val;
978
979        GENERIC_MONLOCK();
980        val = _i2cwrite(interface,bigaddr,data,len);
981        GENERIC_MONUNLOCK();
982        return(val);
983}
984
985int
986mon_i2cread(int interface, int bigaddr, unsigned char *data, int len)
987{
988        int     val;
989
990        GENERIC_MONLOCK();
991        val = _i2cread(interface,bigaddr,data,len);
992        GENERIC_MONUNLOCK();
993        return(val);
994}
995
996void
997mon_delay(long msec)
998{
999        GENERIC_MONLOCK();
1000        _mondelay(msec);
1001        GENERIC_MONUNLOCK();
1002}
1003
1004int
1005mon_timer(int cmd, void *arg)
1006{
1007        int ret;
1008
1009        GENERIC_MONLOCK();
1010        ret = _montimer(cmd, arg);
1011        GENERIC_MONUNLOCK();
1012        return(ret);
1013}
1014
1015int
1016mon_sendenetpkt(char *pkt,int size)
1017{
1018        int     ret;
1019
1020        GENERIC_MONLOCK();
1021        ret = _sendenet(pkt,size);
1022        GENERIC_MONUNLOCK();
1023        return(ret);
1024}
1025
1026int
1027mon_recvenetpkt(char *pkt,int size)
1028{
1029        int     ret;
1030
1031        GENERIC_MONLOCK();
1032        ret = _recvenet(pkt,size);
1033        GENERIC_MONUNLOCK();
1034        return(ret);
1035}
1036
1037void
1038mon_printpkt(char *buf,int size, int incoming)
1039{
1040        GENERIC_MONLOCK();
1041        _printpkt(buf,size,incoming);
1042        GENERIC_MONUNLOCK();
1043}
1044
1045int
1046mon_flashoverride(void *flashinfo,int get,int bank)
1047{
1048        int     ret;
1049
1050        TFS_MONLOCK();
1051        ret = _flashoverride(flashinfo,get,bank);
1052        TFS_MONUNLOCK();
1053        return(ret);
1054}
1055
1056int
1057mon_flashwrite(char *dest,char *src,int bytecnt)
1058{
1059        int     ret;
1060
1061        TFS_MONLOCK();
1062        ret = _flashwrite(dest,src,bytecnt);
1063        TFS_MONUNLOCK();
1064        return(ret);
1065}
1066
1067int
1068mon_flasherase(int snum)
1069{
1070        int     ret;
1071
1072        TFS_MONLOCK();
1073        ret = _flasherase(snum);
1074        TFS_MONUNLOCK();
1075        return(ret);
1076}
1077
1078int
1079mon_flashinfo(int snum, int *size, char **base)
1080{
1081        int     ret;
1082
1083        TFS_MONLOCK();
1084        ret = _flashinfo(snum,size,base);
1085        TFS_MONUNLOCK();
1086        return(ret);
1087}
1088
1089unsigned long
1090mon_assignhandler(long hnum, unsigned long arg1, unsigned long arg2)
1091{
1092        int     ret;
1093
1094        GENERIC_MONLOCK();
1095        ret = _assign_handler(hnum,arg1,arg2);
1096        GENERIC_MONUNLOCK();
1097        return(ret);
1098}
1099
1100int
1101mon_watchdog(void)
1102{
1103        int     ret;
1104
1105        GENERIC_MONLOCK();
1106        ret = _watchdog();
1107        GENERIC_MONUNLOCK();
1108        return(ret);
1109}
1110
1111void
1112mon_printmem(char *mem, int size, int ascii)
1113{
1114        GENERIC_MONLOCK();
1115        _printmem(mem,size,ascii);
1116        GENERIC_MONUNLOCK();
1117}
1118
1119long
1120mon_portcmd(int cmd, void *arg)
1121{
1122        long ret;
1123
1124        GENERIC_MONLOCK();
1125        ret = _portcmd(cmd,arg);
1126        GENERIC_MONUNLOCK();
1127        return(ret);
1128}
1129
1130int
1131mon_timeofday(int cmd, void *arg)
1132{
1133        int ret;
1134
1135        GENERIC_MONLOCK();
1136        ret = _timeofday(cmd,arg);
1137        GENERIC_MONUNLOCK();
1138        return(ret);
1139}
Note: See TracBrowser for help on using the repository browser.