gonzui


Format: Advanced Search

tkernel_2/monitor/include/tmonitor.hbare sourcepermlink (0.04 seconds)

Search this content:

    1: /*
    2:  *----------------------------------------------------------------------
    3:  *    T-Kernel 2.0 Software Package
    4:  *
    5:  *    Copyright 2011 by Ken Sakamura.
    6:  *    This software is distributed under the latest version of T-License 2.x.
    7:  *----------------------------------------------------------------------
    8:  *
    9:  *    Released by T-Engine Forum(http://www.t-engine.org/) at 2011/05/17.
   10:  *    Modified by T-Engine Forum at 2013/03/01.
   11:  *    Modified by TRON Forum(http://www.tron.org/) at 2015/06/01.
   12:  *
   13:  *----------------------------------------------------------------------
   14:  */
   15: 
   16: /*
   17:  *      tmonitor.h
   18:  *
   19:  *       T-Monitor internal common definitions
   20:  */
   21: 
   22: #ifndef __MONITOR_TMONITOR_H__
   23: #define __MONITOR_TMONITOR_H__
   24: 
   25: #include <basic.h>
   26: #include <tk/errno.h>
   27: #include "device.h"
   28: 
   29: /* CPU-dependent definitions */
   30: #if CPU_ARM
   31: #  include "arm/cpudepend.h"
   32: #endif
   33: 
   34: /*
   35:  * console display
   36:  */
   37: #define DSP_S(s)        putString(s)
   38: #define DSP_LF          putChar('\n')
   39: #define DSP_SP          putChar(' ')
   40: #define DSP_CH(c)       putChar(c)
   41: #define DSP_02X(x)      putHex2(x)
   42: #define DSP_04X(x)      putHex4(x)
   43: #define DSP_08X(x)      putHex8(x)
   44: #define DSP_D(x)        putDec(x)
   45: #define DSP_F1(f0, a0)  \
   46:         {DSP_##f0(a0);}
   47: #define DSP_F2(f0, a0, f1, a1)  \
   48:         {DSP_##f0(a0); DSP_##f1(a1);}
   49: #define DSP_F3(f0, a0, f1, a1, f2, a2)  \
   50:         {DSP_##f0(a0); DSP_##f1(a1); DSP_##f2(a2);}
   51: #define DSP_F4(f0, a0, f1, a1, f2, a2, f3, a3)  \
   52:         {DSP_##f0(a0); DSP_##f1(a1); DSP_##f2(a2); DSP_##f3(a3);}
   53: #define DSP_F5(f0, a0, f1, a1, f2, a2, f3, a3, f4, a4)  \
   54:         {DSP_##f0(a0); DSP_##f1(a1); DSP_##f2(a2); DSP_##f3(a3); DSP_##f4(a4);}
   55: 
   56: /*
   57:  * error code
   58:  *       common error codes with T-Kernel (the following is used)
   59:  *      E_OK, E_MACV, E_PAR, E_LIMIT, E_NOSPT, E_NOEXS, E_IO, E_RONLY
   60:  */
   61:         /* original error code */
   62: #define E_END           (-1000)
   63: #define E_LESS          (-1001)
   64: #define E_CMD           (-1002)
   65: #define E_RANGE         (-1003)
   66: #define E_EMPTY         (-1004)
   67: #define E_ILREG         (-1005)
   68: #define E_PC            (-1006)
   69: #define E_BOOT          (-1007)
   70: #define E_ROM           (-1008)
   71: #define E_PROTECT       (-1009)
   72:         /* LOAD command and friends */
   73: #define E_PROTO         (-1010)
   74: #define E_NOADDR        (-1011)
   75: #define E_LOADFMT       (-1012)
   76: #define E_LOAD          (-1013)
   77: #define E_CANCEL        (-1014)
   78: #define E_XMODEM        (-1015)
   79:         /* BREAK command and friends */
   80: #define E_BPATR         (-1020)
   81: #define E_BPBAD         (-1021)
   82: #define E_BPDSLT        (-1022)
   83: #define E_BPROM         (-1023)
   84: #define E_BPCMD         (-1024)
   85: #define E_BPUDF         (-1025)
   86: #define E_HBPOVR        (-1026)
   87: #define E_SBPOVR        (-1027)
   88: 
   89: #define E_ONOEXS        (-1030)
   90: 
   91: IMPORT char const Version[];            /* version number */
   92: IMPORT char const * const Title[];       /* boot message */
   93: 
   94: /* ------------------------------------------------------------------------ */
   95: 
   96: /*
   97:  * service call function code
   98:  */
   99: #define TM_MONITOR      0
  100: #define TM_GETCHAR      1
  101: #define TM_PUTCHAR      2
  102: #define TM_GETLINE      3
  103: #define TM_PUTSTRING    4
  104: #define TM_COMMAND      5
  105: #define TM_READDISK     6
  106: #define TM_WRITEDISK    7
  107: #define TM_INFODISK     8
  108: #define TM_EXIT         9
  109: 
  110: #define TM_EXTSVC       255
  111: 
  112: /* ======================================================================== */
  113: /*
  114:  *       hardware dependent processing (hwdepend)function
  115:  */
  116: 
  117: /*
  118:  * system basic set up
  119:  *       boot    1 : boot is in progress
  120:  *               0 : reset is in progress
  121:  */
  122: IMPORT void resetSystem( W boot );
  123: 
  124: /*
  125:  * system termination
  126:  *       reset    0 : power off
  127:  *               -1 : reboot
  128:  *               other: machine-dependent
  129:  */
  130: IMPORT void sysExit( W reset );
  131: 
  132: /*
  133:  * processing at monitor entry and exit
  134:  *       info and return value is defined in machine-dependent manner.
  135:  */
  136: IMPORT W enterMonitor( UW info );       /* entry */
  137: IMPORT W leaveMonitor( UW info );       /* exit */
  138: 
  139: /*
  140:  * EIT processing
  141:  *       return value      0 : monitor should keep on running
  142:  *                         1 : return from the interrupt handler
  143:  */
  144: IMPORT W procEIT( UW vec );
  145: 
  146: /*
  147:  * Obtain boot selection information
  148:  */
  149: IMPORT W bootSelect( void );
  150: 
  151: /* bootSelect() return value */
  152: #define BS_MONITOR      0    /* boot monitor */
  153: #define BS_AUTO         1      /* automatic boot */
  154: 
  155: /*
  156:  * boot device following the standard boot order
  157:  *       return the device name that is the 'no'-th device in the standard boot order.
  158:  *
  159:  *       if no such device name exists (when 'no' is given as a value larger or equal to the last number), it is NULL.
  160:  */
  161: IMPORT const UB* bootDevice( W no );
  162: 
  163: IMPORT const UH BootSignature;  /* boot block signature */
  164: IMPORT UB* const PBootAddr;     /* primary boot loader address */
  165: 
  166: /*
  167:  * list of disk drives
  168:  *       returns the disk drive device name, indicated by 'no' ( 0 - : a consecutive number )
  169:  *       if no such device name exists (when 'no' is given as a value larger or equal to the last number), it is NULL.
  170:  *       if attr is not NULL, disk driver attribute returns in `attr' )
  171:  */
  172: IMPORT const UB* diskList( W no, UW *attr );
  173: 
  174: /*
  175:  * obtain switch status
  176:  */
  177: IMPORT UW getDipSw( void );
  178: 
  179: /*
  180:  * set LED
  181:  *       lower 16 bits of val value (1:ON 0:OFF)
  182:  *       upper 16 bits of val mask (1: keep, 0: change)
  183:  */
  184: IMPORT void cpuLED( UW val );
  185: 
  186: /*
  187:  * micro wait for a small amount of time
  188:  *       wait time is not that accurate.
  189:  */
  190: IMPORT void waitMsec( UW msec );        /* milliseconds */
  191: IMPORT void waitUsec( UW usec );        /* microseconds */
  192: IMPORT void waitNsec( UW nsec );        /* nanoseconds */
  193: 
  194: /*
  195:  *       cache control
  196:  *       acts on the whole address space.
  197:  */
  198: IMPORT void FlushCache( void );         /* writeback and invalidate */
  199: IMPORT void EnableCache( void );        /* enable cache */
  200: IMPORT void DisableCache( void );       /* disable cache */
  201: 
  202: /* ------------------------------------------------------------------------ */
  203: 
  204: /*
  205:  *       memory region definition
  206:  *       the location of end is NOT included in the region. ((end - top) is the region size)
  207:  *       end = 0x00000000, by the way, means 0x100000000.
  208:  */
  209: typedef struct {
  210:         UW     top;                /* area start address */
  211:         UW     end;                /* area end address */
  212:         UW     attr;               /* attribute */
  213: #if (CPU_ARM|CPU_I386) && VIRTUAL_ADDRESS
  214:         UW     pa;         /* physical address | page attribute */
  215: #endif
  216: } MEMSEG;
  217: 
  218: /*
  219:  * attribute attr
  220:  *       if MSA_WRK is defined, make it so that it is found before MSA_OS.
  221:  */
  222: #define MSA_ROM         0x0001 /* ROM       (read-only) */
  223: #define MSA_FROM        0x0002 /* Flash ROM (write_enabled) */
  224: #define MSA_RAM         0x0004 /* RAM */
  225: #define MSA_ERAM        0x0008 /* extended RAM */
  226: #define MSA_IO          0x0010  /* I/O */
  227: #define MSA_SRAM        0x0020 /* SRAM */
  228: #define MSA_HW          0x0fff  /* attribute related to hardware */
  229: 
  230: #define MSA_MON         0x1000 /* monitor area        (area inside MSA_ROM/FROM ) */
  231: #define MSA_OS          0x2000  /* OS area        (area in MSA_RAM ) */
  232: #define MSA_WRK         0x4000 /* special work area (used by LH7A400) */
  233: 
  234: #define MSA_RDA         0x10000        /* ROM disk area (area in MSA_FROM ) */
  235: #define MSA_RDB         0x20000        /* RAM disk area */
  236: 
  237: /* page attribute (ARM) 1st level page table */
  238: #if CPU_ARM
  239: #if CPU_ARMv6
  240: #define PGA_RW          0x00402 /* Kernel/RW (effective section, AP0='1') */
  241: #define PGA_RO          0x08402 /* Kernel/RO (effective section) AP0='1') */
  242: #define PGA_XN          0x00010 /* code execution prohibited */
  243: #define PGA_C           0x0100c  /* TEX0:C:B='111', Normal, WB/WA  */
  244: #define PGA_NC          0x01000 /* TEX0:C:B='100', Normal, CacheOff */
  245: #define PGA_D           0x00004  /* TEX0:C:B='001', Device, CacheOff */
  246: #define PGA_S           0x10000  /* shareable */
  247: #endif  /*CPU_ARMv6*/
  248: #endif  /*CPU_ARM*/
  249: 
  250: /*
  251:  * obtaining memory region information
  252:  *       no = 1 - (and up)
  253:  *       'no'-th information in the region specified by the attr is returned.
  254:  *       if attr = 0, no matter what the attribute is, 'no'-th information is returned unconditionally.
  255:  *       if no such information is found, return NULL.
  256:  */
  257: IMPORT MEMSEG* MemArea( UW attr, W no );
  258: 
  259: /*
  260:  * obtaining memory region information (specify address)
  261:  *       within the region specified by `attr', return the information that surrounds the position specified by `addr'.
  262:  *
  263:  *       if no such information is found, return NULL.
  264:  */
  265: IMPORT MEMSEG* AddrMatchMemArea( UW addr, UW attr );
  266: 
  267: /*
  268:  * Decide whether two memory regions are included in another.
  269:  *      if the region, from `top' to `end', is completely included in the region specified by `attr',
  270:  *      TRUE
  271:  *       the location of end is NOT included in the region (end - top) is the region size
  272:  *       end = 0x00000000, by the way, means 0x100000000.
  273:  */
  274: IMPORT BOOL inMemArea( UW top, UW end, UW attr );
  275: 
  276: /*
  277:  * Decide whether two memory regions overlap with each other
  278:  *       if the area, from top to end, is included even partially in the region specified by `attr' - 'end',
  279:  *       it is TRUE
  280:  *       the location of end is NOT included in the region. ((end - top) is the region size)
  281:  *       end = 0x00000000, by the way, means 0x100000000.
  282:  */
  283: IMPORT BOOL isOverlapMemArea( UW top, UW end, UW attr );
  284: 
  285: /* ======================================================================== */
  286: /*
  287:  *       command / SVC processing (cmdsvc) function
  288:  */
  289: 
  290: /*
  291:  * console output
  292:  *       XON/XOFF flow control
  293:  *       check for CTRL-C input
  294:  *       return value       0 : normal
  295:  *                         -1 : CTRL-C input exists
  296:  */
  297: IMPORT W putChar( W c );
  298: IMPORT W putString( const UB *str );
  299: 
  300: /*
  301:  * console output (hexadecimal: 2, 4, or 8 columns)
  302:  *       XON/XOFF flow control
  303:  *       check for CTRL-C input
  304:  *       return value       0 : normal
  305:  *                         -1 : CTRL-C input exists
  306:  */
  307: IMPORT W putHex2( UB val );
  308: IMPORT W putHex4( UH val );
  309: IMPORT W putHex8( UW val );
  310: 
  311: /*
  312:  * console output (decimal: 10 columns/zero-suppress supported)
  313:  *       XON/XOFF flow control
  314:  *       check for CTRL-C input
  315:  *       return value       0 : normal
  316:  *                         -1 : CTRL-C input exists
  317:  */
  318: IMPORT W putDec( UW val );
  319: 
  320: /*
  321:  * console input (one character)
  322:  *       if wait = TRUE, wait for input if FALSE, do not wait.
  323:  *       return value       >= 0 : character
  324:  *                            -1 : no input
  325:  */
  326: IMPORT W getChar( BOOL wait );
  327: 
  328: /*
  329:  * console input (character string)
  330:  *       line input with editing
  331:  *       return value      >= 0 : number of input characters
  332:  *                           -1 : CTRL-C was detected
  333:  */
  334: IMPORT W getString( UB *str );
  335: 
  336: /*
  337:  * detect CTRL-C
  338:  *       check if there is a history of control-C input to the console
  339:  *       history is cleared
  340:  *      return value      TRUE  : CTRL-C input exists
  341:  *                        FALSE : CTRL-C input is absent
  342:  */
  343: IMPORT BOOL checkAbort( void );
  344: 
  345: /*
  346:  *       memory & I/O access
  347:  *       len     number of bytes
  348:  *       unit    access unit (1=B 2=H 4=W)
  349:  *       return value number of bytes really accessed
  350:  *                    return 0 when there was an error or exception
  351:  *
  352:  *       writeMem() becomes fill operation if (unit | 0x10) is given. (only writeMem)
  353:  *       in this case, the only leading data in buf is used.
  354:  */
  355: IMPORT W readMem( UW addr, void *buf, W len, W unit );
  356: IMPORT W writeMem( UW addr, void *buf, W len, W unit );
  357: IMPORT W readIO( UW addr, UW *data, W unit );
  358: IMPORT W writeIO( UW addr, UW data, W unit );
  359: 
  360: /*
  361:  * read character string
  362:  *       read byte string up to maximum len bytes from addr to buf.
  363:  *       return the length read (excluding the terminating '\0').
  364:  *       if an error occurs (including the string longer than len bytes), return -1.
  365:  */
  366: IMPORT W readMemStr( UW addr, void *buf, W len );
  367: 
  368: /*
  369:  * initialize breakpoint
  370:  */
  371: IMPORT void initBreak( void );
  372: 
  373: /*
  374:  * Invoking user reset initialization routine
  375:  */
  376: IMPORT void callUserResetInit( void );
  377: 
  378: /* ======================================================================== */
  379: /*
  380:  *      Standard string / memory operations used for t-monitor
  381:  */
  382: 
  383: IMPORT  void*    memset( void *s, int c, size_t n );
  384: IMPORT  int      memcmp( const void *s1, const void *s2, size_t n );
  385: IMPORT  void*    memcpy( void *dst, const void *src, size_t n );
  386: IMPORT  void*    memmove( void *dst, const void *src, size_t n );
  387: IMPORT  size_t   strlen( const char *s );
  388: IMPORT  int      strcmp( const char *s1, const char *s2 );
  389: IMPORT  int      strncmp( const char *s1, const char *s2, size_t n );
  390: IMPORT  char*    strcpy( char *dst, const char *src );
  391: IMPORT  char*    strncpy( char *dst, const char *src, size_t n );
  392: 
  393: /* ======================================================================== */
  394: 
  395: #endif /* __MONITOR_TMONITOR_H__ */