vmod/vmodttl: fixed bug related to luns not ordered and/or not starting from zero.
[ht-drivers.git] / xmem / lib / diag / Cmds.h
blobbd2a99841fc0fd827e605970a689a2fba9e8b527
1 /**************************************************************************/
2 /* Command line stuff */
3 /**************************************************************************/
5 int Illegal(); /* llegal command */
7 int Quit(); /* Quit test program */
8 int Help(); /* Help on commands */
9 int History(); /* History */
10 int Shell(); /* Shell command */
11 int Sleep(); /* Sleep seconds */
12 int Pause(); /* Pause keyboard */
13 int Atoms(); /* Atom list commands */
15 int RegisterCallback();
16 int GetAllNodeIds();
17 int GetNodeName();
18 int GetNodeId();
19 int GetAllTableIds();
20 int GetTableName();
21 int GetTableId();
22 int GetTableDesc();
23 int Wait();
24 int Poll();
25 int SendTable();
26 int RecvTable();
27 int SendMessage();
28 int CheckTables();
29 int LoadTable();
30 int SaveTable();
31 int EditSharedMemory();
32 int Init();
34 int ShowDaemonEventLog();
35 int ShowDaemonEventHistory();
36 int ClearDaemonEventLog();
37 int KillDaemon();
39 typedef enum {
41 CmdNOCM, /* llegal command */
43 CmdQUIT, /* Quit test program */
44 CmdHELP, /* Help on commands */
45 CmdHIST, /* History */
46 CmdSHELL, /* Shell command */
47 CmdSLEEP, /* Sleep seconds */
48 CmdPAUSE, /* Pause keyboard */
49 CmdATOMS, /* Atom list commands */
51 CmdRGCB, /* Register/Unregister callback */
53 CmdNDS, /* Show all nodes */
54 CmdTDS,
56 CmdWAIT,
57 CmdPOLL,
59 CmdSNDT,
60 CmdRCVT,
62 CmdSMS,
64 CmdCHKT,
66 CmdLDT, /* Load table from disc */
67 CmdSVT, /* Save table to dsic */
69 CmdESHM, /* Edit table in shared memory */
71 CmdSDEL,
72 CmdSDEH,
73 CmdCDEL,
74 CmdKILD,
75 CmdINIT, /* Execute initialize protocol */
77 CmdCMDS } CmdId;
79 typedef struct {
80 CmdId Id;
81 char *Name;
82 char *Help;
83 char *Optns;
84 int (*Proc)(); } Cmd;
86 static Cmd cmds[CmdCMDS] = {
88 { CmdNOCM, "???", "Illegal command" ,"" ,Illegal },
90 { CmdQUIT, "q" , "Quit test program" ,"" ,Quit },
91 { CmdHELP, "h" , "Help on commands" ,"" ,Help },
92 { CmdHIST, "his", "History" ,"" ,History},
93 { CmdSHELL, "sh", "Shell command" ,"UnixCmd" ,Shell },
94 { CmdSLEEP, "s" , "Sleep seconds" ,"Seconds" ,Sleep },
95 { CmdPAUSE, "z" , "Pause keyboard" ,"" ,Pause },
96 { CmdATOMS, "a" , "Atom list commands" ,"" ,Atoms },
98 { CmdRGCB,"rgcb","Register callback again" ,"?|<EvtMask>" ,RegisterCallback },
99 { CmdNDS, "nds" ,"Get all node Ids" ,"" ,GetAllNodeIds },
100 { CmdTDS, "tds" ,"Get table description" ,"<TbIdMsk>" ,GetTableDesc },
101 { CmdWAIT,"wait","Wait for callback" ,"" ,Wait },
102 { CmdPOLL,"poll","Poll for callback" ,"" ,Poll },
103 { CmdSNDT,"wsh" ,"Write shmem to xmem" ,"<TbId>" ,SendTable },
104 { CmdRCVT,"rsh" ,"Read shmem from xmem" ,"<TbId>" ,RecvTable },
105 { CmdSMS, "sms" ,"Send message" ,"?|<Type><NdIdMsk><Data>",SendMessage },
106 { CmdCHKT,"chkt","Check for table updates" ,"" ,CheckTables },
107 { CmdLDT, "ldsh","Load shmem table from disc","<TbId>" ,LoadTable },
108 { CmdSVT, "svsh","Save shmem table to disc" ,"<TbId>" ,SaveTable },
109 { CmdESHM,"esh" ,"Edit table shared memory" ,"<TbId>" ,EditSharedMemory },
110 { CmdSDEL,"sdel","Show daemon event log" ,"" ,ShowDaemonEventLog },
111 { CmdSDEH,"sdeh","Show daemon event history" ,"<NdId>" ,ShowDaemonEventHistory },
112 { CmdCDEL,"cdel","Clear daemon event log" ,"" ,ClearDaemonEventLog },
113 { CmdKILD,"kd" ,"Kill daemons" ,"<NdIdMsk>" ,KillDaemon },
114 { CmdINIT,"init","Start Initialize protocol" ,"" ,Init }
117 typedef enum {
119 OprNOOP,
121 OprNE, OprEQ, OprGT, OprGE, OprLT , OprLE, OprAS,
122 OprPL, OprMI, OprTI, OprDI, OprAND, OprOR, OprXOR,
123 OprNOT, OprNEG, OprLSH, OprRSH, OprINC, OprDECR, OprPOP,
124 OprSTM,
126 OprOPRS } OprId;
128 typedef struct {
129 OprId Id;
130 char *Name;
131 char *Help; } Opr;
133 static Opr oprs[OprOPRS] = {
134 { OprNOOP, "?" ,"Not an operator" },
135 { OprNE, "#" ,"Not equal" },
136 { OprEQ, "=" ,"Equal" },
137 { OprGT, ">" ,"Greater than" },
138 { OprGE, ">=" ,"Greater than or equal" },
139 { OprLT, "<" ,"Less than" },
140 { OprLE, "<=" ,"Less than or equal" },
141 { OprAS, ":=" ,"Becomes equal" },
142 { OprPL, "+" ,"Add" },
143 { OprMI, "-" ,"Subtract" },
144 { OprTI, "*" ,"Multiply" },
145 { OprDI, "/" ,"Divide" },
146 { OprAND, "&" ,"AND" },
147 { OprOR, "!" ,"OR" },
148 { OprXOR, "!!" ,"XOR" },
149 { OprNOT, "##" ,"Ones Compliment" },
150 { OprNEG, "#-" ,"Twos compliment" },
151 { OprLSH, "<<" ,"Left shift" },
152 { OprRSH, ">>" ,"Right shift" },
153 { OprINC, "++" ,"Increment" },
154 { OprDECR, "--" ,"Decrement" },
155 { OprPOP, ";" ,"POP" },
156 { OprSTM, "->" ,"PUSH" } };
158 static char atomhash[256] = {
159 10,9,9,9,9,9,9,9,9,0,0,9,9,0,9 ,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
160 0 ,1,9,1,9,4,1,9,2,3,1,1,0,1,11,1,5,5,5,5,5,5,5,5,5,5,1,1,1,1,1,1,
161 10,6,6,6,6,6,6,6,6,6,6,6,6,6,6 ,6,6,6,6,6,6,6,6,6,6,6,6,7,9,8,9,6,
162 9 ,6,6,6,6,6,6,6,6,6,6,6,6,6,6 ,6,6,6,6,6,6,6,6,6,6,6,6,9,9,9,9,9,
163 9 ,9,9,9,9,9,9,9,9,9,9,9,9,9,9 ,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
164 9 ,9,9,9,9,9,9,9,9,9,9,9,9,9,9 ,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
165 9 ,9,9,9,9,9,9,9,9,9,9,9,9,9,9 ,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
166 9 ,9,9,9,9,9,9,9,9,9,9,9,9,9,9 ,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9 };
168 typedef enum {
169 Seperator=0,Operator=1,Open=2,Close=3,Comment=4,Numeric=5,Alpha=6,
170 Open_index=7,Close_index=8,Illegal_char=9,Terminator=10,Bit=11,
171 } AtomType;
173 #define MAX_ARG_LENGTH 32
174 #define MAX_ARG_COUNT 16
175 #define MAX_ARG_HISTORY 16
177 typedef struct {
178 int Pos;
179 int Number;
180 AtomType Type;
181 char Text[MAX_ARG_LENGTH];
182 CmdId CId;
183 OprId OId;
184 } ArgVal;
186 static int pcnt = 0;
187 static ArgVal val_bufs[MAX_ARG_HISTORY][MAX_ARG_COUNT];
188 static ArgVal *vals = val_bufs[0];
190 #define True 1
191 #define False 0