tkernel_2/monitor/cmdsvc/src/cmdsvc.h | bare source | permlink (0.04 seconds) |
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: * cmdsvc.h 18: * 19: * T-Monitor command / SVC common processing definitions 20: */ 21: 22: #include <tmonitor.h> 23: #include <tm/tmonitor.h> 24: 25: #if CPU_ARMv6 26: # include "armv6/cpudep.h" 27: #endif 28: 29: /* ======================================================================== */ 30: /* 31: * Hardware-independent 32: */ 33: 34: #define L_LINE 256 /* number of characters per line */ 35: IMPORT UB lineBuf[L_LINE]; /* line buffer */ 36: 37: #define WRKBUF_SZ 1024 /* must be larger than or equal to 1024 */ 38: IMPORT UB wrkBuf[WRKBUF_SZ]; /* work buffer for various operations */ 39: 40: #define L_BPCMD 80 /* breakpooint command length */ 41: 42: IMPORT W errinfo; /* error information */ 43: 44: /* 45: * display boot message 46: */ 47: IMPORT void dispTitle( void ); 48: 49: /* 50: * command execution 51: * cmd command string 52: * if it is NULL, we are wainting for command input 53: * fin = 0 : execute cmd and then wait for command input 54: * > 0 : execute cmd and return 55: * < 0 : execute cmd and return (ignore execution such as GO,STEP, etc.) 56: * if cmd = NULL, fin is ignored. (equivalent to fin = 0) 57: */ 58: IMPORT void procCommand( UB *cmd, W fin ); 59: 60: /* 61: * loading from serial line 62: * proto [P_XMODEM] | [P_SFORM] (other protocols are ignored) 63: * P_XMODEM XMODEM 64: * not specified no control sequence 65: * P_SFORM S-Record format 66: * not specficied memory image (binary data) 67: * addr load address 68: * In the case of P_SFORM, the initial ooad address is set to addr. 69: * Loading is done with the above adjustment. If addr = 0, adjustment is not madem, but 70: * load it to data address. 71: * range valid load range 72: * range[0] start address of the valid load range 73: * range[1] end address of the valid load range 74: * range[2] load offset 75: * load offset is valid only when P_SFORM is used and addr = 0. 76: * Its value is the sum of the load address added with the range[2] offset value. 77: * This is where loading takes place. 78: * range[0] and range[1] will return the final starting and loading address after the loading. 79: * 80: * if range = NULL, below is assumed. 81: * range[0] = 0x00000000 82: * range[1] = 0xffffffff 83: * range[2] = 0 84: * return value error code 85: */ 86: IMPORT ER doLoading( W proto, UW addr, UW range[3] ); 87: 88: /* load option (LOAD commands, etc.) */ 89: #define P_XMODEM 0x20 /* XMODEM */ 90: #define P_TEXT 0x10 /* no protocol */ 91: #define P_SFORM 0x02 /* S-Format */ 92: #define P_MEMIMG 0x01 /* memory image */ 93: 94: /* 95: * Flash ROM disk write 96: * blksz = 0 set up 97: * Prepare writing to ROM disk and return the maximum ROM size 98: * in sz (bytes). 99: * Return the address to which the data to be written to ROM disk should be loaded. 100: * blksz > 0 written 101: * blksz ROM disk block size 102: * sz number of written blocks 103: * return value error code 104: */ 105: IMPORT W writeRda( UW blksz, UW *sz ); 106: 107: /* 108: * disk boot 109: * devnm device name (possibly with the partition number) 110: * if it is NULL, the standard search order is used to look for a bootable device. 111: * return value error code 112: */ 113: IMPORT ER bootDisk( const UB *devnm ); 114: 115: /* 116: * monitor service call 117: * fno function code 118: * p1-p4 parameters 119: * return value return value of the service call 120: */ 121: IMPORT W procSVC( W fno, W p1, W p2, W p3, W p4 ); 122: 123: /* ======================================================================== */ 124: /* 125: * Hardware-dependent 126: */ 127: 128: /* 129: * disassember 130: * saddr pass the address where the instruction to be disassembled is. 131: * returns the adjusted address that points at the start of the instruction. 132: * naddr returns the address of the next instruction. (if it is NULL, value is not returned) 133: * str the buffer to store the disassembled instruction string (must be long enough) 134: * return value error code 135: */ 136: IMPORT ER disAssemble( UW *saddr, UW *naddr, UB *str ); 137: 138: /* 139: * examine and obtain the breakpoint attribute 140: * examine the breakpoint attribute string specified by `name', and if it is legal, 141: * return its attribute code as return value. 142: * In the case of illegal attribute string, return an error (E_BPATR). 143: */ 144: IMPORT W getBreakAtr( UB *name ); 145: 146: /* 147: * set breakpoint 148: * addr address where breakpoint is set 149: * atr breakpoint attribute 150: * cmd command that is to be executed at the breakpoint (valid only when cmdlen > 0) 151: * cmdlen cmd length 152: * return value error code 153: */ 154: IMPORT ER setBreak( UW addr, W atr, UB *cmd, W cmdlen ); 155: 156: /* 157: * release breakpoint 158: * addr address where breakpoint is to be released 159: * if it is 0, then release all breakpoints 160: * return value error code 161: */ 162: IMPORT ER clearBreak( UW addr ); 163: 164: /* 165: * list all breakpoints 166: */ 167: IMPORT void dspBreak( void ); 168: 169: /* 170: * release breakpoint temporarily (monitor entry) 171: * return value if the current PC is not a breakpoint, returns 0. 172: * if it is a breakpoint, returns non-zero value. 173: */ 174: IMPORT W resetBreak( UW vec ); 175: 176: /* 177: * set breakpoints (monitor exit) 178: */ 179: IMPORT void setupBreak( void ); 180: 181: /* 182: * forcibly stop trace 183: */ 184: IMPORT void stopTrace( void ); 185: 186: /* 187: * trace or normal execution 188: * trace 0 : GO command 189: * 1 : STEP command 190: * 2 : NEXT command 191: * pc execution start address 192: * par in the case of GO 193: * tempoary breakpoint address (if 0, then no temporary breakpoionts) 194: * in the case of STEP/NEXT 195: * number of steps (0 is regarded as 1) 196: * return value error code 197: */ 198: IMPORT ER goTrace( W trace, UW pc, UW par ); 199: 200: /* 201: * break processing 202: * bpflg return the value returned by resetBreak() as is. 203: * cmd return the command to be executed at the breakpoint. 204: * return value 0 : return monitor immediately and contineu executing the user program. 205: * 1 : enter command processing of the monitor and execute cmd. 206: */ 207: IMPORT W procBreak( W bpflg, UB **cmd ); 208: 209: /* 210: * search register 211: * Return the register number (0 and upward) for the register name `name'. 212: * grp 0 : exclude group names from the search. 213: * 1 : include the group names in the search/ 214: * name is L_REGNM bytes long, and if the result is not long enough, the remaining part is filled with space. 215: * L_REGNM is machine-dependent, but should be less than or equal to L_SYMBOL. 216: * if the name is invalid (not found), return -1. 217: */ 218: IMPORT W searchRegister( UB *name, W grp ); 219: 220: /* 221: * obtain / set register value 222: * regno register number 223: * val value to set 224: * return value obtained set value(if there is an error, 0). 225: * * set : error code 226: */ 227: IMPORT UW getRegister( W regno ); 228: IMPORT ER setRegister( W regno, UW val ); 229: 230: /* 231: * display register value 232: * display the register or register group specified by `regno'. 233: * if regno < 0, thendisplay the default register group. 234: */ 235: IMPORT void dispRegister( W regno ); 236: 237: /* 238: * obtain / set the current PC register 239: */ 240: IMPORT UW getCurPC( void ); 241: IMPORT void setCurPC( UW val ); 242: 243: /* 244: * prepare to execute the boot program 245: * pass boot info to a boot program and start it from the address, `start'. 246: * 247: * It means that we don't execute ROM kernel immediately, but we prepare so that upon return from the ordinary monitor, 248: * it gets executed. 249: */ 250: IMPORT void setUpBoot( void *start, BootInfo *bootinfo ); 251: 252: /* 253: * Prepare ROM kernel execution 254: * It means that we don't execute ROM kernel immediately, but we prepare so that upon return from the ordinary monitor, 255: * it gets executed. 256: */ 257: IMPORT ER bootROM( void ); 258: 259: /* 260: * Initialize address check data (executed upon monitor entry) 261: */ 262: IMPORT void initChkAddr( void ); 263: 264: /* 265: * validate memory address 266: * check whether access to area starting from logical address, addr, and has the length of len bytes, 267: * return the corresponding physical address of addr in pa. 268: * rw = 0 for read / rw = 1 for write is checked for the access right check. 269: * Returns the length of accessible bytes for a consecutive region that starts from addr. 270: * if addr is inaccessible, then the size for the accesible region is 0. 271: * So, 0 is returned. In this case, error code is set to a global variable errinfo. 272: * the address returned to pa is machine-depdenent, and may not be a physical address always. 273: */ 274: IMPORT W chkMemAddr( UW addr, UW *pa, W len, W rw ); 275: 276: /* 277: * validate I/O address 278: * heck whether we can access a region from an I/O address (logical address in the case of memory mapped I/O), with the len bytes length, 279: * the I/O address (physical address if memory mapped I/O is used) is returned 280: * in pa. 281: * Returns the length of accessible bytes for a consecutive region that starts from addr. 282: * if addr is inaccessible, then the size for the accesible region is 0. 283: * So, 0 is returned. 284: * * the address returned to pa is machine-depdenent, and, in the case of memory mapped I/O. 285: * may not be a physical address always. if memory mapped I/O is not used, 286: * generally speaking, pa will return addr unmodiifed. 287: */ 288: IMPORT W chkIOAddr( UW addr, UW *pa, W len ); 289: 290: /* 291: * Validate PC address 292: * If addr is valid then return 0, otherwise return -1. 293: */ 294: IMPORT W invalidPC( UW addr ); 295: 296: /* 297: * Check whehter kill command can be executed 298: * If it can be executed, return 0, and if not, return -1. 299: */ 300: IMPORT W isKillValid( void ); 301: 302: /* 303: * calling an external program 304: */ 305: IMPORT W callExtProg( FP entry ); 306: 307: /* ------------------------------------------------------------------------ */