Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:43

0001 /**
0002  *  @file
0003  *
0004  *  @ingroup shared_monlib
0005  *
0006  *  @brief Used by both the monitor and the application that
0007  *  may reside on top of the monitor
0008  */
0009 
0010 /*  Based upon code from MicroMonitor 1.17 from http://www.umonfw.com/
0011  *  which includes this notice:
0012  *
0013  **************************************************************************
0014  *  General notice:
0015  *  This code is part of a boot-monitor package developed as a generic base
0016  *  platform for embedded system designs.  As such, it is likely to be
0017  *  distributed to various projects beyond the control of the original
0018  *  author.  Please notify the author of any enhancements made or bugs found
0019  *  so that all may benefit from the changes.  In addition, notification back
0020  *  to the author will allow the new user to pick up changes that may have
0021  *  been made by other users after this version of the code was distributed.
0022  *
0023  *  Note1: the majority of this code was edited with 4-space tabs.
0024  *  Note2: as more and more contributions are accepted, the term "author"
0025  *         is becoming a mis-representation of credit.
0026  *
0027  *  Original author:    Ed Sutter
0028  *  Email:              esutter@alcatel-lucent.com
0029  *  Phone:              908-582-2351
0030  **************************************************************************
0031  *
0032  *  Ed Sutter has been informed that this code is being used in RTEMS.
0033  *
0034  *  This code was reformatted by Joel Sherrill from OAR Corporation and
0035  *  Fernando Nicodemos <fgnicodemos@terra.com.br> from NCB - Sistemas
0036  *  Embarcados Ltda. (Brazil) to be more compliant with RTEMS coding
0037  *  standards and to eliminate C++ style comments.
0038  */
0039 
0040 #ifndef _MONLIB_H_
0041 #define _MONLIB_H_
0042 
0043 #include <umon/tfs.h>
0044 #include <umon/cli.h>
0045 
0046 #ifdef __cplusplus
0047 extern "C" {
0048 #endif
0049 
0050 /**
0051  *  @defgroup shared_umon MicroMonitor
0052  *
0053  *  @ingroup RTEMSBSPsShared
0054  *
0055  *  @brief shared_umon MicroMonitor (uMon) Bootloader Support
0056  */
0057 
0058 /**
0059  *  @defgroup shared_monlib MONLIB Support
0060  *
0061  *  @ingroup shared_umon
0062  *
0063  *  @brief MONLIB Support Package
0064  */
0065 
0066 extern int monConnect(int (*monptr)(int,void *,void *,void *),
0067         void (*lock)(void),void (*unlock)(void));
0068 extern void mon_getargv(int *argc,char ***argv);
0069 extern void mon_intsrestore(unsigned long oldval);
0070 extern void mon_appexit(int exit_value);
0071 extern void mon_free(char *buffer);
0072 extern void mon_profiler(void *pdata);
0073 extern void mon_bbc(char *filename, int linenum);
0074 extern void mon_warmstart(unsigned long mask);
0075 extern void mon_delay(long msec);
0076 extern void mon_printpkt(char *buf, int size, int incoming);
0077 extern void mon_printmem(char *mem, int size, int ascii);
0078 
0079 
0080 extern int mon_com(int cmd,void *arg1,void *arg2,void *arg3);
0081 extern int mon_timer(int cmd, void * arg);
0082 extern int mon_setenv(char *varname,char *value);
0083 extern int mon_putchar(char c);
0084 extern int mon_getchar(void);
0085 extern int mon_gotachar(void);
0086 extern int mon_getbytes(char *buf,int count,int block);
0087 extern int mon_restart(int restart_value);
0088 extern int mon_tfsinit(void);
0089 extern int mon_tfsunlink(char *filename);
0090 extern int mon_tfslink(char *source, char *target);
0091 extern int mon_tfsrun(char **arglist,int verbosity);
0092 extern int mon_tfsfstat(char *filename,struct tfshdr *tfp);
0093 extern int mon_tfseof(int file_descriptor);
0094 extern int mon_tfstruncate(int file_descriptor,long length);
0095 extern int mon_tfsread(int file_descriptor,char *buffer,int size);
0096 extern int mon_tfswrite(int file_descriptor,char *buffer,int size);
0097 extern int mon_tfsopen(char *filename,long mode,char *buffer);
0098 extern int mon_tfsclose(int file_descriptor,char *info);
0099 extern int mon_tfsseek(int file_descriptor,int offset,int whence);
0100 extern int mon_tfsgetline(int file_descriptor,char *buffer,int bufsize);
0101 extern int mon_tfsipmod(char *name,char *buffer,int offset,int size);
0102 extern int mon_addcommand(struct monCommand *command_list,char *);
0103 extern int mon_docommand(char *cmdline,int verbosity);
0104 extern int mon_getline(char *buffer,int max,int ledit);
0105 extern int mon_decompress(char *src,int srcsize,char *dest);
0106 extern int mon_heapextend(char *base,int size);
0107 extern int mon_pcicfgwrite(int interface,int bus,int dev,int func,int reg,
0108         unsigned long val);
0109 extern int mon_tfsadd(char *filename, char *info, char *flags,
0110         unsigned char *src, int size);
0111 extern int mon_i2cwrite(int interface, int bigaddr, unsigned char *data,
0112         int len);
0113 extern int mon_i2cread(int interface, int bigaddr, unsigned char *data,
0114         int len);
0115 extern int mon_sendenetpkt(char *pkt, int len);
0116 extern int mon_recvenetpkt(char *pkt, int len);
0117 extern int mon_flashoverride(void *flashinfo, int get, int bank);
0118 extern int mon_flasherase(int snum);
0119 extern int mon_flashwrite(char *dest,char *src, int bytecnt);
0120 extern int mon_flashinfo(int snum,int *size, char **base);
0121 extern int mon_watchdog(void);
0122 extern int mon_timeofday(int cmd, void *arg);
0123 
0124 extern char *mon_getsym(char *symname, char *buf, int bufsize);
0125 extern char *mon_getenv(char *varname);
0126 extern char *mon_getenvp(void);
0127 extern char *mon_version(void);
0128 #ifdef MALLOC_DEBUG
0129 extern char *mon_malloc(int size,char *file, int line);
0130 extern char *mon_realloc(char *buf,int size,char *file, int line);
0131 #else
0132 extern char *mon_malloc(int size);
0133 extern char *mon_realloc(char *buf,int size);
0134 #endif
0135 
0136 extern long mon_tfsctrl(int command,long arg1,long arg2);
0137 extern long mon_tfstell(int file_descriptor);
0138 extern long mon_portcmd(int cmd, void *arg);
0139 
0140 extern unsigned short mon_xcrc16(char *buffer,long length);
0141 
0142 extern unsigned long mon_intsoff(void);
0143 
0144 extern unsigned long mon_pcicfgread(int interface,int bus,int dev,
0145         int func,int reg);
0146 
0147 extern unsigned long mon_pcictrl(int interface, int cmd,
0148         unsigned long arg1, unsigned long arg2);
0149 
0150 extern unsigned long mon_i2cctrl(int interface, int cmd,
0151         unsigned long arg1, unsigned long arg2);
0152 
0153 extern unsigned long mon_assignhandler(long hnum,
0154         unsigned long arg1,unsigned long arg2);
0155 
0156 extern struct tfshdr *mon_tfsnext(struct tfshdr *tfp);
0157 extern struct tfshdr *mon_tfsstat(char *filename);
0158 
0159 /*
0160  * The external caller should see these as variable argument methods but
0161  * they are not implemented that way, so let monlib.c prototype them internally
0162  * when building that file.
0163  */
0164 #ifndef _INSIDE_MONLIB
0165 extern void mon_memtrace(char *fmt, ...);
0166 extern int mon_printf(char *fmt, ...);
0167 extern int mon_cprintf(char *fmt, ...);
0168 extern int mon_sprintf(char *,char *fmt, ...);
0169 #endif
0170 
0171 #ifdef __cplusplus
0172 }
0173 #endif
0174 
0175 
0176 /* defines used by monConnect():
0177  */
0178 #define GETMONFUNC_PUTCHAR              1
0179 #define GETMONFUNC_GETCHAR              2
0180 #define GETMONFUNC_GOTACHAR             3
0181 #define GETMONFUNC_GETBYTES             4
0182 #define GETMONFUNC_PRINTF               5
0183 #define GETMONFUNC_CPRINTF              6
0184 #define GETMONFUNC_SPRINTF              7
0185 #define GETMONFUNC_RESTART              8
0186 #define GETMONFUNC_GETENV               9
0187 #define GETMONFUNC_SETENV               10
0188 #define GETMONFUNC_TFSINIT              11
0189 #define GETMONFUNC_TFSADD               12
0190 #define GETMONFUNC_TFSUNLINK            13
0191 #define GETMONFUNC_TFSRUN               14
0192 #define GETMONFUNC_TFSNEXT              15
0193 #define GETMONFUNC_TFSSTAT              16
0194 #define GETMONFUNC_TFSREAD              17
0195 #define GETMONFUNC_TFSWRITE             18
0196 #define GETMONFUNC_TFSOPEN              19
0197 #define GETMONFUNC_TFSCLOSE             20
0198 #define GETMONFUNC_TFSSEEK              21
0199 #define GETMONFUNC_TFSGETLINE           22
0200 #define GETMONFUNC_TFSIPMOD             23
0201 #define GETMONFUNC_TFSCTRL              24
0202 #define GETMONFUNC_ADDCOMMAND           25
0203 #define GETMONFUNC_DOCOMMAND            26
0204 #define GETMONFUNC_GETARGV              27
0205 #define GETMONFUNC_CRC16                28
0206 #define GETMONFUNC_CRC32                29
0207 #define GETMONFUNC_PIOGET               30  /* NA (removed as of 1.0) */
0208 #define GETMONFUNC_PIOSET               31  /* NA (removed as of 1.0) */
0209 #define GETMONFUNC_PIOCLR               32  /* NA (removed as of 1.0) */
0210 #define GETMONFUNC_INTSOFF              33
0211 #define GETMONFUNC_INTSRESTORE          34
0212 #define GETMONFUNC_APPEXIT              35
0213 #define GETMONFUNC_MALLOC               36
0214 #define GETMONFUNC_FREE                 37
0215 #define GETMONFUNC_GETLINE              38
0216 #define GETMONFUNC_TFSFSTAT             39
0217 #define GETMONFUNC_TFSEOF               40
0218 #define GETMONFUNC_DECOMPRESS           41
0219 #define GETMONFUNC_TFSTRUNCATE          42
0220 #define GETMONFUNC_HEAPXTEND            43
0221 #define GETMONFUNC_PROFILER             44
0222 #define GETMONFUNC_TFSLINK              45
0223 #define GETMONFUNC_BBC                  46
0224 #define GETMONFUNC_MEMTRACE             47
0225 #define GETMONFUNC_TFSTELL              48
0226 #define GETMONFUNC_VERSION              49
0227 #define GETMONFUNC_WARMSTART            50
0228 #define GETMONFUNC_PCICFGREAD           51
0229 #define GETMONFUNC_PCICFGWRITE          52
0230 #define GETMONFUNC_PCICONTROL           53
0231 #define GETMONFUNC_I2CREAD              54
0232 #define GETMONFUNC_I2CWRITE             55
0233 #define GETMONFUNC_I2CCONTROL           56
0234 #define GETMONFUNC_MONDELAY             57
0235 #define GETMONFUNC_GETENVP              58
0236 #define GETMONFUNC_REALLOC              59
0237 #define GETMONFUNC_SENDENETPKT          60
0238 #define GETMONFUNC_RECVENETPKT          61
0239 #define GETMONFUNC_GETSYM               62
0240 #define GETMONFUNC_PRINTPKT             63
0241 #define GETMONFUNC_FLASHWRITE           64
0242 #define GETMONFUNC_FLASHERASE           65
0243 #define GETMONFUNC_FLASHINFO            66
0244 #define GETMONFUNC_ASSIGNHDLR           67
0245 #define GETMONFUNC_WATCHDOG             68
0246 #define GETMONFUNC_PRINTMEM             69
0247 #define GETMONFUNC_PORTCMD              70
0248 #define GETMONFUNC_TIMEOFDAY            71
0249 #define GETMONFUNC_TIMER                72
0250 #define GETMONFUNC_FLASHOVRRD           73
0251 
0252 #define CACHEFTYPE_DFLUSH               200
0253 #define CACHEFTYPE_IINVALIDATE          201
0254 
0255 #define CHARFUNC_PUTCHAR                300
0256 #define CHARFUNC_GETCHAR                301
0257 #define CHARFUNC_GOTACHAR               302
0258 #define CHARFUNC_RAWMODEON              303
0259 #define CHARFUNC_RAWMODEOFF             304
0260 
0261 #define ASSIGNFUNC_GETUSERLEVEL         400
0262 
0263 
0264 /* Defines used by mon_warmstart():
0265  */
0266 #define WARMSTART_IOINIT            0x00000001
0267 #define WARMSTART_BSSINIT           0x00000002
0268 #define WARMSTART_RUNMONRC          0x00000004
0269 #define WARMSTART_MONHEADER         0x00000008
0270 #define WARMSTART_TFSAUTOBOOT       0x00000010
0271 #define WARMSTART_BOARDINFO         0x00000020
0272 #define WARMSTART_ALL               0xffffffff
0273 #endif