vmod/vmodttl: fixed bug related to luns not ordered and/or not starting from zero.
[ht-drivers.git] / mttn / test / Cmds.h
blob311814229ac1bb006896bfa312045b6c484c97e0
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 News(); /* Show GMT test news */
10 int History(); /* History */
11 int Shell(); /* Shell command */
12 int Sleep(); /* Sleep seconds */
13 int Pause(); /* Pause keyboard */
14 int Atoms(); /* Atom list commands */
16 int ChangeEditor(); /* Switch text editor */
17 int ChangeDirectory(); /* Change configuration path */
19 int GetSetSwDeb(); /* Get/Set driver debug level */
20 int GetVersion(); /* Get all version data */
21 int GetSetQue(); /* Get/Set the queue flag */
22 int GetSetModule(); /* Get/Set the working module */
23 int NextModule(); /* Select the next module */
24 int PrevModule(); /* Select the previous module */
25 int GetSetCableId(); /* Get/Set the cable ID */
26 int GetSetTmo(); /* Get/Set the timeout value */
27 int WaitInterrupt(); /* Connect and wait for an interrupt */
28 int SimulateInterrupt(); /* Simulate an interrupt */
29 int ListClients(); /* List connected clients */
30 int GetSetEnable(); /* Get/Set event output enable */
31 int Reset(); /* Reset the module */
32 int GetSetUtcSending(); /* Get/Set UTC sending */
33 int GetSetExt1Khz(); /* Get/Set 1KHz external clock selection */
34 int GetSetOutDelay(); /* Get/Set the output delay */
35 int GetSetSyncPeriod(); /* Get/Set the sync period */
36 int GetSetUtc(); /* Get/Set the UTC time */
37 int GetStatus(); /* Get the module status */
38 int SendEvent(); /* Send and event out now */
40 int GetSetTask(); /* Get/Set the working task */
41 int NextTask(); /* Select the next task */
42 int PrevTask(); /* Select the previous task */
44 int StartTasks(); /* Start tasks */
45 int StopTasks(); /* Stop tasks */
46 int ContTask(); /* Continue tasks */
47 int GetRunningTasks(); /* Get the list of running tasks */
48 int SaveRunningTasks(); /* Save all running tasks and registers */
50 int GetTcb(); /* Get the working tasks TCB */
51 int GetSetLa(); /* Get/Set working tasks load address */
52 int GetSetIc(); /* Get/Set working tasks instruction count */
53 int GetSetPs(); /* Get/Set working tasks PC Start address */
54 int GetSetPo(); /* Get/Set working tasks PC Offset */
55 int GetSetPc(); /* Get/Set working tasks PC */
56 int GetSetTaskName(); /* Get/Set working tasks Name */
57 int EditLreg(); /* Edit the working tasks local register */
59 int EditGreg(); /* Edit global registers */
61 int GetProgram(); /* Read program from working module */
62 int SetProgram(); /* Write program to working module */
63 int GetTaskProgram(); /* Get program for a given task */
64 int Asm(); /* Edit and assemble program */
65 int DisAsm(); /* Disassemble program */
66 int EmuProg(); /* Emulate program object */
68 int CompileTable(); /* Compile an event table */
69 int FilterTable(); /* Filter the CTR event history by table */
71 int ReloadJtag(); /* Upload VHDL bit stream */
72 int MemIo(); /* Raw IO */
74 int CtrTest(); /* Ctr hardware test program */
75 int TimTest(); /* TimLib test program */
77 int LaunchVideo(); /* Launch Video displays */
79 int ListFiles(); /* Execute ls -l in CWD */
81 int MakeCtfTable(); /* Make a CTF timing table */
83 static void IErr();
85 /* Jtag backend to public code */
87 FILE *jtag_input;
89 void setPort(short p, short val);
90 void readByte();
91 unsigned char readTDOBit();
92 void waitTime();
93 void pulseClock();
95 typedef enum {
97 CmdNOCM, /* llegal command */
99 CmdQUIT, /* Quit test program */
100 CmdHELP, /* Help on commands */
101 CmdNEWS, /* Show GMT test news */
102 CmdHIST, /* History */
103 CmdSHELL, /* Shell command */
104 CmdSLEEP, /* Sleep seconds */
105 CmdPAUSE, /* Pause keyboard */
106 CmdATOMS, /* Atom list commands */
108 CmdCE, /* Switch text editor */
109 CmdCD, /* Change configuration path */
110 CmdVID, /* Launch Video displays */
112 CmdDEBUG, /* Get/Set driver debug level */
113 CmdVER, /* Get all version data */
114 CmdQFL, /* Get/Set the queue flag */
115 CmdMOD, /* Get/Set the working module */
116 CmdNMOD, /* Select the next module */
117 CmdPMOD, /* Select the previous module */
118 CmdCABLE, /* Get/Set the cable ID */
119 CmdTMO, /* Get/Set the timeout value */
120 CmdWAIT, /* Connect and wait for an interrupt */
121 CmdSIM, /* Simulate an interrupt */
122 CmdCLIST, /* List connected clients */
123 CmdENABLE, /* Get/Set event output enable */
124 CmdRESET, /* Reset the module */
125 CmdUTCSND, /* Get/Set UTC sending */
126 CmdEX1KHZ, /* Get/Set 1KHz external clock selection */
127 CmdODLY, /* Get/Set the output delay */
128 CmdSYNCP, /* Get/Set the sync period */
129 CmdUTC, /* Get/Set the UTC time */
130 CmdSTATUS, /* Get the module status */
131 CmdSEND, /* Send and event out now */
133 CmdTASK, /* Get/Set the working task */
134 CmdNTASK, /* Select the next task */
135 CmdPTASK, /* Select the previous task */
137 CmdSTART, /* Start tasks */
138 CmdSTOP, /* Stop tasks */
139 CmdCONT, /* Continue tasks */
140 CmdRUNING, /* Get the list of running tasks */
141 CmdSAVERUN, /* Save running tasks and registers */
143 CmdTCB, /* Get the working tasks TCB */
144 CmdLA, /* Get/Set task LoadAddrs */
145 CmdIC, /* Get/Set task InstCount */
146 CmdPCS, /* Get/Set task PcStart */
147 CmdPCO, /* Get/Set task PcOffset */
148 CmdPC, /* Get/Set task PC */
149 CmdTNAME, /* Get/Set task name */
150 CmdLREG, /* Get/Set the working tasks local register */
152 CmdGREG, /* Get/Set global registers */
154 CmdREADP, /* Read program from working module */
155 CmdWRITEP, /* Write program to working module */
156 CmdREADT, /* Read program for task */
157 CmdASM, /* Edit/Assemble program */
158 CmdDASM, /* Disassemble program */
159 CmdEMUL, /* Emulate program binary */
160 CmdCOMPLE, /* Compile event table */
161 CmdFILTER, /* Filter CTR event history by table */
162 CmdCTFT, /* Build a CTF timing table */
164 CmdJTAG, /* Upload VHDL bit stream */
165 CmdRIO, /* Raw IO */
167 CmdCTRT, /* Launch ctrtest hardware test program */
168 CmdTIMT, /* Launch timtest timlib test program */
170 CmdLSF, /* List files */
172 CmdCMDS } CmdId;
174 typedef struct {
175 CmdId Id;
176 char *Name;
177 char *Help;
178 char *Optns;
179 int (*Proc)(); } Cmd;
181 static Cmd cmds[CmdCMDS] = {
183 { CmdNOCM, "???", "Illegal command" ,"" ,Illegal },
185 { CmdQUIT, "q" , "Quit test program" ,"" ,Quit },
186 { CmdHELP, "h" , "Help on commands" ,"" ,Help },
187 { CmdNEWS, "news", "Show GMT test news" ,"" ,News },
188 { CmdHIST, "his", "History" ,"" ,History },
189 { CmdSHELL, "sh", "Shell command" ,"UnixCmd" ,Shell },
190 { CmdSLEEP, "s" , "Sleep seconds" ,"Seconds" ,Sleep },
191 { CmdPAUSE, "z" , "Pause keyboard" ,"" ,Pause },
192 { CmdATOMS, "a" , "Atom list commands" ,"" ,Atoms },
194 { CmdCE, "ce", "Change text editor used" ,"" ,ChangeEditor },
195 { CmdCD, "cd", "Change working directory" ,"" ,ChangeDirectory },
196 { CmdVID, "vid", "Launch display programs" ,"Machine" ,LaunchVideo },
198 { CmdDEBUG, "deb", "Get/Set driver debug mode","1|2|4/0" ,GetSetSwDeb },
199 { CmdVER, "ver", "Get versions" ,"" ,GetVersion },
200 { CmdQFL, "qf", "Queue flag on off" ,"1/0" ,GetSetQue },
201 { CmdMOD, "mo", "Select/Show modules" ,"Module" ,GetSetModule },
202 { CmdNMOD, "nm", "Next module" ,"" ,NextModule },
203 { CmdPMOD, "pm", "Previous module" ,"" ,PrevModule },
204 { CmdCABLE, "id", "Get/Set cable ID" ,"Id" ,GetSetCableId },
205 { CmdTMO, "tmo", "Timeout control" ,"Timeout" ,GetSetTmo },
206 { CmdWAIT, "wi", "Wait for interrupt" ,"Msk|?" ,WaitInterrupt },
207 { CmdSIM, "si", "Simulate interrupt" ,"Msk|?" ,SimulateInterrupt },
208 { CmdCLIST, "cl", "List clients" ,"" ,ListClients },
209 { CmdENABLE, "eno", "GetSet output enable" ,"1/0" ,GetSetEnable },
210 { CmdRESET, "reset", "Reset module" ,"" ,Reset },
211 { CmdUTCSND, "autc", "Get/Set auto UTC sending" ,"1/0" ,GetSetUtcSending },
212 { CmdEX1KHZ, "khz", "Khz clock source" ,"1/0" ,GetSetExt1Khz },
213 { CmdODLY, "dly", "Output delay" ,"Delay" ,GetSetOutDelay },
214 { CmdSYNCP, "bp", "Get/Set basic-period" ,"Period" ,GetSetSyncPeriod },
215 { CmdUTC, "utc", "Get/Set UTC time" ,"1" ,GetSetUtc },
216 { CmdSTATUS, "rst", "Get status" ,"" ,GetStatus },
217 { CmdSEND, "sev", "Send and event out now" ,"Frame" ,SendEvent },
219 { CmdTASK, "tn", "Get/Set the working task" ,"Task" ,GetSetTask },
220 { CmdNTASK, "nt", "Select the next task" ,"" ,NextTask },
221 { CmdPTASK, "pt", "Select the previous task" ,"" ,PrevTask },
223 { CmdSTART, "start", "Start tasks" ,"T|Msk" ,StartTasks },
224 { CmdSTOP, "stop", "Stop tasks" ,"T|Msk" ,StopTasks },
225 { CmdCONT, "cont", "Continue tasks" ,"T|Msk" ,ContTask },
226 { CmdRUNING, "rnt", "Get list of running tasks","" ,GetRunningTasks },
227 { CmdSAVERUN, "srnt", "Save running tasks & regs","FileNmae" ,SaveRunningTasks},
229 { CmdTCB, "tcb", "Get the task TCB" ,"Task" ,GetTcb },
230 { CmdLA, "la", "Get/Set task LoadAddrs" ,"Address" ,GetSetLa },
231 { CmdIC, "ic", "Get/Set task InstCount" ,"Count" ,GetSetIc },
232 { CmdPCS, "pcs", "Get/Set task PcStart" ,"Address" ,GetSetPs },
233 { CmdPCO, "pco", "Get/Set task PcOffset" ,"Address" ,GetSetPo },
234 { CmdPC, "pc", "Get/Set task PC" ,"Address" ,GetSetPc },
235 { CmdTNAME, "tname", "Get/Set task Name" ,"Name|clear" ,GetSetTaskName },
236 { CmdLREG, "lr", "Edit task registers" ,"RegId" ,EditLreg },
238 { CmdGREG, "gr", "Edit global registers" ,"RegId" ,EditGreg },
240 { CmdREADP, "rp", "Read program" ,"Address,Count" ,GetProgram },
241 { CmdWRITEP, "wp", "Write program" ,"Task,Address,FileName" ,SetProgram },
242 { CmdREADT, "rtp", "Read program for task" ,"Task" ,GetTaskProgram },
243 { CmdASM, "as", "Edit/Assemble program" ,"FileName" ,Asm },
244 { CmdDASM, "ds", "Disassemble program" ,"FileName" ,DisAsm },
245 { CmdEMUL, "em", "Emulate program binary" ,"FileName" ,EmuProg },
246 { CmdCOMPLE, "ct", "Compile event table" ,"FileName" ,CompileTable },
247 { CmdFILTER, "ft", "Look for table in history","FileName" ,FilterTable },
248 { CmdCTFT, "ctf", "Build a CTF timing table" ,"Prod,Meas,Intv" ,MakeCtfTable },
250 { CmdJTAG, "jtag", "Jtag, VHDL reload" ,"FileName" ,ReloadJtag },
251 { CmdRIO, "rio", "Raw memory IO" ,"Address" ,MemIo },
253 { CmdCTRT, "ctrt", "ctr hardware test prog" ,"" ,CtrTest },
254 { CmdTIMT, "timt", "timtest timlib test prog" ,"" ,TimTest },
256 { CmdLSF, "ls", "List files in CWD" ,"" ,ListFiles }
260 typedef enum {
262 OprNOOP,
264 OprNE, OprEQ, OprGT, OprGE, OprLT , OprLE, OprAS,
265 OprPL, OprMI, OprTI, OprDI, OprAND, OprOR, OprXOR,
266 OprNOT, OprNEG, OprLSH, OprRSH, OprINC, OprDECR, OprPOP,
267 OprSTM,
269 OprOPRS } OprId;
271 typedef struct {
272 OprId Id;
273 char *Name;
274 char *Help; } Opr;
276 static Opr oprs[OprOPRS] = {
277 { OprNOOP, "?" ,"??? Not an operator" },
278 { OprNE, "#" ,"Test: Not equal" },
279 { OprEQ, "=" ,"Test: Equal" },
280 { OprGT, ">" ,"Test: Greater than" },
281 { OprGE, ">=" ,"Test: Greater than or equal" },
282 { OprLT, "<" ,"Test: Less than" },
283 { OprLE, "<=" ,"Test: Less than or equal" },
284 { OprAS, ":=" ,"Assign: Becomes equal" },
285 { OprPL, "+" ,"Arith: Add" },
286 { OprMI, "-" ,"Arith: Subtract" },
287 { OprTI, "*" ,"Arith: Multiply" },
288 { OprDI, "/" ,"Arith: Divide" },
289 { OprAND, "&" ,"Bits: AND" },
290 { OprOR, "!" ,"Bits: OR" },
291 { OprXOR, "!!" ,"Bits: XOR" },
292 { OprNOT, "##" ,"Bits: Ones Compliment" },
293 { OprNEG, "#-" ,"Arith: Twos compliment" },
294 { OprLSH, "<<" ,"Bits: Left shift" },
295 { OprRSH, ">>" ,"Bits: Right shift" },
296 { OprINC, "++" ,"Arith: Increment" },
297 { OprDECR, "--" ,"Arith: Decrement" },
298 { OprPOP, ";" ,"Stack: POP" },
299 { OprSTM, "->" ,"Stack: PUSH" } };
301 static char atomhash[256] = {
302 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,
303 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,
304 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,
305 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,
306 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,
307 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,
308 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,
309 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 };
311 typedef enum {
312 Seperator=0,Operator=1,Open=2,Close=3,Comment=4,Numeric=5,Alpha=6,
313 Open_index=7,Close_index=8,Illegal_char=9,Terminator=10,Bit=11,
314 } AtomType;
316 #define MAX_ARG_LENGTH 32
317 #define MAX_ARG_COUNT 16
318 #define MAX_ARG_HISTORY 16
320 typedef struct {
321 int Pos;
322 int Number;
323 AtomType Type;
324 char Text[MAX_ARG_LENGTH];
325 CmdId CId;
326 OprId OId;
327 } ArgVal;
329 static int pcnt = 0;
330 static ArgVal val_bufs[MAX_ARG_HISTORY][MAX_ARG_COUNT];
331 static ArgVal *vals = val_bufs[0];
333 #ifndef True
334 #define True 1
335 #define False 0
336 #endif
338 #define MAX_OP_CODE_STRING_LENGTH 8
339 #define MAX_REGISTER_STRING_LENGTH 8