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

📄 usrlib.c

📁 VXWORKS基本shell命令源码
💻 C
📖 第 1 页 / 共 5 页
字号:
/* usrLib.c - user interface subroutine library *//* Copyright 1984-2002 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------09d,14may02,fmk  add support for common symbols and load flags to ld09c,10may02,pcm  changed sp help message from opt=0 to opt=0x1909b,08mar02,jn   add error message for ld failing due to undefined symbols09a,16oct01,jn   use symFindSymbol for symbol lookup (SPR #7453)08z,16oct01,gls  update printLogo() copyright notice to 2002                 changed printLogo() and version() to use 		 runtimeName and runtimeVersion08y,01oct01,dcb  Fix SPR 21134.  Change code to remove compiler warnings.08x,03apr01,kab  Fixed _WRS_ALTIVEC_SUPPORT08w,28mar01,dtr  Putting in #if _WRS_ALTIVEC_SUPPORT.08v,19mar01,dtr  Changing header file name altiVecLib.h .08u,29jan01,dtr  Adding support for altivec register set.08v,18feb99,jpd  Changed 1998 to 1999 in printLogo08u,13nov98,cdp  make periodRun, repeatRun force Thumb state for all ARM CPUs		 with ARM_THUMB==TRUE.08v,27feb01,hk   update printLogo() copyright notice to cover 2001.08u,21jun00,rsh  upgrade to dosFs 2.009d,31jul99,jkf  T2 merge, tidiness & spelling, 1998-2000.09c,29sep98,lrn  merge DosFs 2.0 changes into T2.0 base09b,14jul98,lrn  removed all RT-11 references, rt11FsLib is obsolete,		 refuning configuration issues09a,30jun98,lrn  moved I/O functions to usrFsLib.c, fixed warnings08s,08mar98,ms   Changed 1997 to 1998 in printLogo08r,14jul97,dgp  doc: add windsh x-ref to bootChange(), cd(), help(), ls(), 		      mRegs(), & printErrno(), change ^D to CTRL-D in copy()08t,09oct97,cdp  added ARM7TDMI_T (Thumb) support.08s,26feb97,p_m  Changed 1996 to 1997 in printLogo (SPR# 8068).		 removed pre 1995 history.08r,10jan97,cdp  changed copyright to 1997.08q,28nov96,cdp  added ARM support.08p,13aug96,dbt  added test in changeFpReg to exit if string = "." (SPR #6740).08o,09aug96,dbt  modified copy to correctly close file descriptors (SPR #1308).08n,19jun96,dgp  doc: changed note on ll() with netDrv (SPR #6560), fixed 		 rev nos.08m,09may96,myz  removed #if statement for i960 in checkStack routine08l,17jan96,kkk	 changed copyright year from 1995 to 1996.08k,06oct95,jdi  doc: changed Debugging .pG's to .tG "Shell", updated pathnames		 for Tornado.08j,12jun95,p_m  added reference to spyLib in man pages.08i,27may95,p_m  added spy(), spyHelp(), spyReport(), spyClkStart()		 spyClkStop(), spyStop() and spyTask().08h,01may95,kkk	 fixed incorrect modifications of mRegs (SPR #4241)08g,30mar95,kdl  removed obsolete stat structure fields; removed unused d() var.08f,24mar95,tpr  removed INTERRUPT line in checkStack() for the 060 (SPR #4107).08e,20mar95,jdi  doc tweaks to d() and l().08d,03mar95,jdi  fixed typo in man page for sp().08c,10feb95,jdi  doc format tweaks.  Made substrcmp() NOMANUAL.08b,18jan95,rhp  Doc: explain cd() does no checking for paths over netDrv.08a,06jan95,kdl  Changed copyright to 1995.*//*This library consists of routines meant to be executed from the VxWorksshell.  It provides useful utilities for task monitoring and execution,system information, symbol table management, etc.Many of the routines here are simply command-oriented interfaces to moregeneral routines contained elsewhere in VxWorks.  Users should feel freeto modify or extend this library, and may find it preferable to customizecapabilities by creating a new private library, using this one as a model,and appropriately linking the new one into the system.Some routines here have optional parameters.  If those parameters are zero,which is what the shell supplies if no argument is typed, defaultvalues are typically assumed.A number of the routines in this module take an optional task name or IDas an argument.  If this argument is omitted or zero, the "current" taskis used.  The current task (or "default" task) is the last taskreferenced.  The usrLib library uses taskIdDefault() to set and get thelast-referenced task ID, as do many other VxWorks routines.INCLUDE FILES: usrLib.hSEE ALSO: usrFsLib, tarLib, spyLib,.pG "Target Shell,"windsh,.tG "Shell"*//* LINTLIBRARY */#include "vxWorks.h"#if CPU_FAMILY!=I960#include "a_out.h"#else	/* CPU_FAMILY!=I960 */#include "b_out.h"#endif	/* CPU_FAMILY!=I960 */#include "ctype.h"#include "stdio.h"#include "ioLib.h"#include "loadLib.h"#include "memLib.h"#include "remLib.h"#include "string.h"#include "symLib.h"#include "ftpLib.h"#include "sysLib.h"#include "sysSymTbl.h"#include "usrLib.h"#include "version.h"#include "fppLib.h"#include "dirent.h"#include "sys/stat.h"#include "errnoLib.h"#include "fcntl.h"#include "unistd.h"#include "fioLib.h"#include "shellLib.h"#include "vxLib.h"#include "hostLib.h"#include "pathLib.h"#include "iosLib.h"#include "taskArchLib.h"#include "kernelLib.h"#include "logLib.h"#include "usrLib.h"#include "objLib.h"#include "private/cplusLibP.h"#include "netDrv.h"#include "smObjLib.h"#include "time.h"#include "private/taskLibP.h"#include "private/funcBindP.h"#include "nfsLib.h"#include "dosFsLib.h"#ifdef _WRS_ALTIVEC_SUPPORT#include "altivecLib.h"#endif /* _WRS_ALTIVEC_SUPPORT */#define MAX_BYTES_PER_LINE       16#define MAXLINE         80	/* max line length for input to 'm' routine */#define MAX_DSP_TASKS	500	/* max tasks that can be displayed */#define MAX_DATE_STRING 21	/* dates have 21 characters */#define SPY_NOT_SUPPORTED_MSG   "spy not configured into this system.\n"#define USR_DEMANGLE_PRINT_LEN 256  /* Num chars of demangled names to print *//* sp parameters: change the help message, if these change! */int spTaskPriority	= 100;int spTaskOptions	= VX_SUPERVISOR_MODE | VX_FP_TASK | VX_STDIO;int spTaskStackSize	= 20000;/* other globals */BOOL ldCommonMatchAll = TRUE;/* symbol types in system symbol table */LOCAL char *typeName [] =    {    "????",    "abs",    "text",    "data",    "bss",    };/* things used by lkAddr, lkAddrFind & lkAddrNext */#define NUM_SYMBLS	3typedef struct		/* SYMBL - symbol table entry used by lkAddr */    {    unsigned int addr;	/* address associated with symbol */    char *name;		/* points to name in system symbol table */    SYM_TYPE type;	/* type of this symbol table entry */    } SYMBL;typedef struct		/* LKADDR_ARG */    {    int count;			/* number of entries printed by lkAddr */    unsigned int addr;		/* target address */    SYMBL symbl[NUM_SYMBLS];    } LKADDR_ARG;/* externals */IMPORT int sysClkRateGet (void);IMPORT char * vxRegIntStackBase;	/* base of register interrupt stack */IMPORT char * vxMemIntStackBase;	/* base of memory interrupt stack */#if (CPU_FAMILY == ARM)IMPORT char *vxSvcIntStackBase;		/* SVC-mode stack for int code */IMPORT char *vxSvcIntStackEnd;IMPORT char *vxIrqIntStackBase;		/* IRQ-mode stack for int code */IMPORT char *vxIrqIntStackEnd;#endif /* CPU_FAMILY == ARM *//* forward declarations */LOCAL BOOL lkAddrFind (char *name, unsigned int value, SYM_TYPE type,		       LKADDR_ARG *arg);LOCAL BOOL lkAddrNext (char *name, unsigned int value, SYM_TYPE type,		       LKADDR_ARG *arg);LOCAL BOOL lkAddrPrintSame (char *name, unsigned int value, SYM_TYPE type,		            LKADDR_ARG *arg);LOCAL void printStackSummary (TASK_DESC *pTd);LOCAL void printSTE (unsigned int addr, char *name, SYM_TYPE type);LOCAL STATUS changeFpReg (char *pPrompt, double value, double *pValue);STATUS changeReg (char *pPrompt, void *value, int width);/********************************************************************************* help - print a synopsis of selected routines** This command prints the following list of the calling sequences for* commonly used routines, mostly contained in usrLib.* .CS* help                       Print this list* ioHelp                     Print I/O utilities help info* dbgHelp                    Print debug help info* nfsHelp                    Print nfs help info* netHelp                    Print network help info* spyHelp                    Print task histogrammer help info* timexHelp                  Print execution timer help info* h         [n]              Print (or set) shell history* i         [task]           Summary of tasks' TCBs* ti        task             Complete info on TCB for task* sp        adr,args...      Spawn a task, pri=100, opt=0x19, stk=20000* taskSpawn name,pri,opt,stk,adr,args... Spawn a task* td        task             Delete a task* ts        task             Suspend a task* tr        task             Resume a task* d         [adr[,nunits[,width]]]   Display memory* m         adr[,width]      Modify memory* mRegs     [reg[,task]]     Modify a task's registers interactively* pc        [task]           Return task's program counter* version                    Print VxWorks version info, and boot line* iam     "user"[,"passwd"]  Set user name and passwd* whoami                     Print user name* devs                       List devices* ld        [syms[,noAbort][,"name"]] Load std in into memory*                              (syms = add symbols to table:*                               -1 = none, 0 = globals, 1 = all)* lkup      ["substr"]       List symbols in system symbol table* lkAddr    address          List symbol table entries near address* checkStack  [task]         List task stack sizes and usage* printErrno  value          Print the name of a status value* period    secs,adr,args... Spawn task to call function periodically* repeat    n,adr,args...    Spawn task to call function n times*                              (0=forever)* \&NOTE:  Arguments specifying <task> can be either task ID or name.* .CE** RETURNS: N/A** SEE ALSO:* .pG "Target Shell"* windsh,* .tG "Shell"*/void help (void)    {    static char *help_msg [] = {    /* page 1 */    "help                           Print this list",    "ioHelp                         Print I/O utilities help info",    "dbgHelp                        Print debugger help info",    "nfsHelp                        Print nfs help info",    "netHelp                        Print network help info",    "spyHelp                        Print task histogrammer help info",    "timexHelp                      Print execution timer help info",    "h         [n]                  Print (or set) shell history",    "i         [task]               Summary of tasks' TCBs",    "ti        task                 Complete info on TCB for task",    "sp        adr,args...          Spawn a task, pri=100, opt=0x19, stk=20000",    "taskSpawn name,pri,opt,stk,adr,args... Spawn a task",    "td        task                 Delete a task",    "ts        task                 Suspend a task",    "tr        task                 Resume a task",    "d         [adr[,nunits[,width]]] Display memory",    "m         adr[,width]          Modify memory",    "mRegs     [reg[,task]]         Modify a task's registers interactively",    "pc        [task]               Return task's program counter",    "iam       \"user\"[,\"passwd\"]  	Set user name and passwd",    "whoami                         Print user name",    /* page 2 */    "devs                           List devices",    "ld        [syms[,noAbort][,\"name\"]] Load stdin, or file, into memory",    "                               (syms = add symbols to table:",    "                               -1 = none, 0 = globals, 1 = all)",    "lkup      [\"substr\"]         List symbols in system symbol table",    "lkAddr    address              List symbol table entries near address",    "checkStack  [task]             List task stack sizes and usage",    "printErrno  value              Print the name of a status value",    "period    secs,adr,args... Spawn task to call function periodically",    "repeat    n,adr,args...    Spawn task to call function n times (0=forever)",    "version                        Print VxWorks version info, and boot line",    "",    "NOTE:  Arguments specifying 'task' can be either task ID or name.",    NULL    };    FAST int ix;    char ch;    printf ("\n");    for (ix = 0; help_msg [ix] != NULL; ix++)	{	if ((ix+1) % 20 == 0)	    {	    printf ("\nType <CR> to continue, Q<CR> to stop: ");	    fioRdString (STD_IN, &ch, 1);	    if (ch == 'q' || ch == 'Q')		break;	    else		printf ("\n");	    }	printf ("%s\n", help_msg [ix]);	}    printf ("\n");    }/********************************************************************************* netHelp - print a synopsis of network routines** This command prints a brief synopsis of network facilities that are* typically called from the shell.* .CS* hostAdd      "hostname","inetaddr" - add a host to remote host table;*                                      "inetaddr" must be in standard*                                      Internet address format e.g. "90.0.0.4"* hostShow                           - print current remote host table* netDevCreate "devname","hostname",protocol*                                    - create an I/O device to access*                                      files on the specified host*                                      (protocol 0=rsh, 1=ftp)* routeAdd     "destaddr","gateaddr" - add route to route table* routeDelete  "destaddr","gateaddr" - delete route from route table* routeShow                          - print current route table* iam          "usr"[,"passwd"]      - specify the user name by which*                                      you will be known to remote*                                      hosts (and optional password)* whoami                             - print the current remote ID* rlogin       "host"                - log in to a remote host;*                                      "host" can be inet address or*                                      host name in remote host table** ifShow       ["ifname"]            - show info about network interfaces* inetstatShow                       - show all Internet protocol sockets* tcpstatShow                        - show statistics for TCP* udpstatShow                        - show statistics for UDP* ipstatShow                         - show statistics for IP* icmpstatShow                       - show statistics for ICMP* arptabShow                         - show a list of known ARP entries* mbufShow                           - show mbuf statistics** \&EXAMPLE:  -> hostAdd "wrs", "90.0.0.2"*           -> netDevCreate "wrs:", "wrs", 0*           -> iam "fred"*           -> copy <wrs:/etc/passwd   /@ copy file from host "wrs" @/*           -> rlogin "wrs"            /@ rlogin to host "wrs"      @/* .CE** RETURNS: N/A** SEE ALSO:* .pG "Target Shell"*/void netHelp (void)    { static char *help_msg [] = {    /* page 1 */ "hostAdd   \"hostname\",\"inetaddr\"    - add a host to remote host table;", "                                     \"inetaddr\" must be in standard", "                                     Internet address format e.g. \"90.0.0.4\"", "hostShow                           - print current remote host table", "netDevCreate \"devname\",\"hostname\",protocol", "                                   - create an I/O device to access files", "                                     on the specified host", "                                     (protocol 0=rsh, 1=ftp)", "routeAdd     \"destaddr\",\"gateaddr\" - add route to route table", "routeDelete  \"destaddr\",\"gateaddr\" - delete route from route table", "", "routeShow                          - print current route table", "iam          \"usr\"[,\"passwd\"]      - specify the user name by which you", "                                     will be known to remote hosts", "                                     (and optional password)", "whoami                             - print the current remote ID", "rlogin       \"host\"                - log in to a remote host;", "                                     \"host\" can be inet address or", "                                     host name in remote host table", "", "", /* page 2 */ "ifShow       [\"ifname\"]            - show info about network interfaces", "inetstatShow                       - show all Internet protocol sockets", "tcpstatShow                        - show statistics for TCP", "udpstatShow                        - show statistics for UDP", "ipstatShow                         - show statistics for IP", "icmpstatShow                       - show statistics for ICMP", "arptabShow                         - show a list of known ARP entries", "mbufShow                           - show mbuf statistics", "", "EXAMPLE:   -> hostAdd \"wrs\", \"90.0.0.2\"", "           -> netDevCreate \"wrs:\", \"wrs\", 0", "           -> iam \"fred\"", "           -> copy <wrs:/etc/passwd   /* copy file from host \"wrs\" */", "           -> rlogin \"wrs\"            /* rlogin to host \"wrs\" */", NULL };    FAST int i;    char ch;    printf ("\n\n");

⌨️ 快捷键说明

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