⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usrlib.c

📁 VXWORKS基本shell命令源码
💻 C
📖 第 1 页 / 共 5 页
字号:
	 != taskClassId) &&         (vxMemProbe ((char *)((OBJ_ID)objId)->pObjClass,VX_READ,4,(char *)&bb)	  == ERROR)))	{	printf ("Object not found.\n");	}    else if (objShow ((OBJ_ID) objId, level) != OK)	{	if (errno == S_objLib_OBJ_NO_METHOD)	    printf("Show routine of this object not configured into system.\n");	else	    printf ("Object not found.\n");	}    }/********************************************************************************* ts - suspend a task** This command suspends the execution of a specified task.  It simply calls* taskSuspend().** RETURNS: N/A** SEE ALSO: tr(), taskSuspend(),* .pG "Target Shell,"* windsh,* .tG "Shell"*/void ts    (    int taskNameOrId		/* task name or task ID */    )    {    int tid = taskIdFigure (taskNameOrId);    if (tid == ERROR)		/* no ID found */	{	printErr ("Task not found.\n");	return;	}    if (tid == 0)		/* default task ID never set */	printf ("sorry, the shell can't suspend itself.\n");    else if (taskSuspend (tid) != OK)	printErrno (0);    }/********************************************************************************* tr - resume a task** This command resumes the execution of a suspended task.  It simply calls* taskResume().** RETURNS: N/A** SEE ALSO: ts(), taskResume(),* .pG "Target Shell,"* windsh,* .tG "Shell"*/void tr    (    int taskNameOrId		/* task name or task ID */    )    {    int tid = taskIdFigure (taskNameOrId);    if (tid == ERROR)		/* no ID found */	printErr ("Task not found.\n");    else if (taskResume (tid) != OK)	printErrno (0);    }/********************************************************************************* td - delete a task** This command deletes a specified task.  It simply calls taskDelete().** RETURNS: N/A** SEE ALSO: taskDelete(),* .pG "Target Shell,"* windsh,* .tG "Shell"*/void td    (    int taskNameOrId		/* task name or task ID */    )    {    int tid = taskIdFigure (taskNameOrId);    if (tid == ERROR)		/* no such task ID */	printErr ("Task not found.\n");    else if (tid == 0)	printf ("sorry, the shell can't delete itself.\n");    else if (taskDelete (tid) != OK)	printErrno (0);    }/********************************************************************************* version - print VxWorks version information** This command prints the VxWorks version number, the date this copy of* VxWorks was made, and other pertinent information.** EXAMPLE* .CS* -> version* VxWorks (for Mizar 7170) version 5.1* Kernel: WIND version 2.1.* Made on Tue Jul 27 20:26:23 CDT 1997.* Boot line:* enp(0,0)host:/usr/wpwr/target/config/mz7170/vxWorks e=90.0.0.50 h=90.0.0.4 u=target* value = 1 = 0x1* .CE** RETURNS: N/A** SEE ALSO:* .pG "Target Shell,"* windsh,* .tG "Shell"*/void version (void)    {    printf ("%s (for %s) version %s.\n", runtimeName, sysModel (), 	    runtimeVersion);    printf ("Kernel: %s.\n", kernelVersion ());    printf ("Made on %s.\n", creationDate);    printf ("Boot line:\n%s\n", sysBootLine);    }/********************************************************************************* getHex - convert a hex string into a 64 bit value** This function converts a string containing hex digits into a binary value.* The values is returned in the locations pointed to by pHiValue and pLoValue.* These values can be concatenated together to produce a 64 bit value.** RETURNS: OK or ERROR** INTERNALS: Ideally this function should be replaced by a version of scanf* that supports long longs.* This function is derived from scanNum in fioLib.c** NOMANUAL*/LOCAL STATUS getHex    (    char *pStr,		/* string to parse */    ULONG *pHiValue,	/* where to store high part of result */    ULONG *pLoValue	/* where to store low part of result */    )    {    int         dig;                    /* current digit */    BOOL        neg     = FALSE;        /* negative or positive? */    FAST char * pCh     = pStr;         /* pointer to current character */    FAST int    ch      = *pCh;         /* current character */    FAST ULONG  hiValue = 0;		/* high part of value accumulator */    FAST ULONG  loValue = 0;		/* low part of value accumulator */     /* check for sign */     if (ch == '+' || (neg = (ch == '-')))	ch = *++pCh;      /* check for optional or 0x */     if (ch == '0')	{	ch = *++pCh;	if (ch == 'x' || ch == 'X')	    ch = *++pCh;	}     /* scan digits */    while (ch != '\0')        {        if (isdigit (ch))            dig = ch - '0';        else if (islower (ch))            dig = ch - 'a' + 10;        else if (isupper (ch))            dig = ch - 'A' + 10;        else            break;         if (dig >= 16)            break; 	/* assume that accumulator parts are 32 bits long */	hiValue = (hiValue * 16) + (loValue >> 28);	loValue = loValue * 16 + dig;         ch = *++pCh;        }      /* check that we scanned at least one character */     if (pCh == pStr) {        return (ERROR);	}     /* return value to caller */     if (neg) {	/* assume 2's complement arithmetic */	hiValue = ~hiValue;	loValue = ~loValue;	if (++loValue == 0)	    hiValue++;	}    *pHiValue = hiValue;    *pLoValue = loValue;    return (ch != '\0' ? ERROR : OK);    }/********************************************************************************* m - modify memory** This command prompts the user for modifications to memory in byte, short* word, or long word specified by <width>, starting at the specified address.* It prints each address and the current contents of that address, in turn.* If <adrs> or <width> is zero or absent, it defaults to the previous value.* The user can respond in one of several ways:* .iP RETURN 11* Do not change this address, but continue, prompting at the next address.* .iP <number>* Set the content of this address to <number>.* .iP ". (dot)"* Do not change this address, and quit.* .iP EOF* Do not change this address, and quit.* .LP* All numbers entered and displayed are in hexadecimal.** RETURNS: N/A** SEE ALSO: mRegs(),* .pG "Target Shell,"* windsh,* .tG "Shell"** INTERNAL: further improvement needed.  Add an additional paramater indicating*            whether a read should be done or not before writing.*/void m    (    void *adrs,		/* address to change */    int  width 		/* width of unit to be modified (1, 2, 4, 8) */    )    {    static void *lastAdrs;	/* last location modified */    static int  lastWidth = 2;	/* last width - default to 2 */    char line[MAXLINE + 1];	/* leave room for EOS */    char *pLine;		/* ptr to current position in line */    ULONG hiValue;		/* high part of value found in line */    ULONG loValue;		/* low part of value found in line */    if (adrs != 0)		/* set default address */	lastAdrs = adrs;    if (width != 0)		/* check valid width and set the default */	{	if (width != 1 && width != 2 && width != 4 && width != 8)	    width = 1;	lastWidth = width;	}    /* round down to appropriate boundary */    lastAdrs = (void *)((int)lastAdrs & ~(lastWidth - 1));    for (;; lastAdrs = (void *)((int)lastAdrs + lastWidth))	{	/* prompt for substitution according to width */	switch (lastWidth)	    {	    case 1:	    	printf ("%08x:  %02x-", (int) lastAdrs, *(UINT8 *)lastAdrs);	    break;	    	case 2:		printf ("%08x:  %04x-", (int) lastAdrs, *(USHORT *)lastAdrs);		break;	    case 4:		printf ("%08x:  %08lx-", (int) lastAdrs, *(ULONG *)lastAdrs);		break;	    case 8:#if _BYTE_ORDER==_LITTLE_ENDIAN		printf ("%08x:  %08lx%08lx-", (int) lastAdrs, *((ULONG *)lastAdrs+1),*(ULONG *)lastAdrs);#endif#if _BYTE_ORDER==_BIG_ENDIAN		printf ("%08x:  %08lx%08lx-", (int) lastAdrs, *(ULONG *)lastAdrs, *((ULONG *)lastAdrs+1));#endif		break;	    default:		printf ("%08x:  %08x-", (int) lastAdrs, *(UINT8 *)lastAdrs);		break;	    }	/* get substitution value:	 *   skip empty lines (CR only);	 *   quit on end of file or invalid input;	 *   otherwise put specified value at address	 */	if (fioRdString (STD_IN, line, MAXLINE) == EOF)	    break;	line[MAXLINE] = EOS;	/* make sure input line has EOS */	for (pLine = line; isspace (*(u_char *)pLine); ++pLine)		/* skip leading spaces*/	    ;	if (*pLine == EOS)			/* skip field if just CR */	    continue;        if (getHex (pLine, &hiValue, &loValue) != OK)	    break;	/* assign new value */	switch (lastWidth)	    {	    case 1:		*(UINT8 *)lastAdrs = (UINT8) loValue;		break;	    case 2:		*(USHORT *)lastAdrs = (USHORT) loValue;		break;	    case 4:		*(ULONG *)lastAdrs = (ULONG) loValue;		break;	    case 8:#if _BYTE_ORDER==_LITTLE_ENDIAN		*(ULONG *)lastAdrs = (ULONG) loValue;		*((ULONG *)lastAdrs+1) = (ULONG) hiValue;#endif#if _BYTE_ORDER==_BIG_ENDIAN		*(ULONG *)lastAdrs = (ULONG) hiValue;		*((ULONG *)lastAdrs+1) = (ULONG) loValue;#endif		break;	    default:		*(UINT8 *)lastAdrs = (UINT8) loValue;		break;	    }	}    printf ("\n");    }/********************************************************************************* d - display memory** This command displays the contents of memory, starting at <adrs>.* If <adrs> is omitted or zero, d() displays the next memory block, starting* from where the last d() command completed.** Memory is displayed in units specified by <width>.  If <nunits> is omitted* or zero, the number of units displayed defaults to last use.  If* <nunits> is non-zero, that number of units is displayed and that number* then becomes the default.  If <width> is omitted or zero, it defaults* to the previous value.  If <width> is an invalid number, it is set to 1.* The valid values for <width> are 1, 2, 4, and 8.  The number of units d()* displays is rounded up to the nearest number of full lines.** RETURNS: N/A** SEE ALSO: m(),* .pG "Target Shell,"* windsh,* .tG "Shell"*/void d    (    FAST void *adrs,	/* address to display (if 0, display next block */    int nunits,		/* number of units to print (if 0, use default) */    int width 		/* width of displaying unit (1, 2, 4, 8) */    )    {    static int dNitems = 0x80;	/* default number of item to display */    static int dWidth  = 2;	/* default width */    static void *last_adrs = 0;	/* last location displayed */    FAST int item;		/* item counter displayed per line */    char ascii [MAX_BYTES_PER_LINE + 1]; /* ascii buffer for displaying */    int ix;			/* temporary count */    UINT8 *pByte;		/* byte pointer for filling ascii buffer */    UINT8 *tmpByte;		/* temporary byte pointer */    USHORT *tmpShort;		/* temporary short word pointer */    ULONG *tmpLong;		/* temporary long word pointer */    ascii [MAX_BYTES_PER_LINE] = EOS;	/* put an EOS on the string */    if (nunits == 0)	nunits = dNitems;	/* no count specified: use default count */    else	dNitems = nunits;	/* change default count */    if (width == 0)	width = dWidth;    else	{			/* check for valid width */	if (width != 1 && width != 2 && width != 4 && width != 8)	    width = 1;	dWidth = width;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -