vmod/vmodttl: fixed bug related to luns not ordered and/or not starting from zero.
[ht-drivers.git] / utils / extest / extest_common.h
blobac42d4d5c60e6655588d7f7eeee8606d167fcfbb
1 /**
2 * @file extest_common.h
4 * @brief Common header file for extest's programs
6 * @author Copyright (C) 2009 CERN CO/HT Emilio G. Cota
7 * <emilio.garcia.cota@cern.ch>
8 * @author Copyright (C) 2008 CERN CO/HT Yury Georgievskiy
9 * <yury.georgievskiy@cern.ch>
11 * @section license_sec License
12 * Released under the GPL v2. (and only v2, not any later version)
14 #ifndef _EXTEST_COMMON_H_
15 #define _EXTEST_COMMON_H_
17 #include <stdio.h>
18 #include <string.h>
19 #include <sys/types.h>
21 #include <general_both.h>
22 #include <list.h>
23 #include <data_tables.h>
24 #include <config_data.h>
26 #ifdef __SKEL_EXTEST__
27 #include <skeluser.h>
28 #include <skel.h>
29 #endif /* __SKEL_EXTEST__ */
31 #define MAX_ARG_COUNT 256 //!< maximum command line arguments
32 #define MAX_ARG_LENGTH 128 //!< max characters per argument
33 #define F_CLOSED (-1) //!< file closed
35 #define WHITE_ON_BLACK "\033[40m\033[1;37m"
36 #define DEFAULT_COLOR "\033[m"
38 //! Operator ID's
39 typedef enum {
40 OprNOOP,
41 OprNE,
42 OprEQ,
43 OprGT,
44 OprGE,
45 OprLT,
46 OprLE,
47 OprAS,
48 OprPL,
49 OprMI,
50 OprTI,
51 OprDI,
52 OprAND,
53 OprOR,
54 OprXOR,
55 OprNOT,
56 OprNEG,
57 OprLSH,
58 OprRSH,
59 OprINC,
60 OprDECR,
61 OprPOP,
62 OprSTM,
63 OprOPRS
64 } oprid_t;
66 struct operator {
67 oprid_t id; //!< operator ID (one of @ref oprid_t)
68 char name[16]; //!< Human form
69 char help[32]; //!< help string
72 //!< atom types
73 typedef enum {
74 Separator = 0, //!< [\t\n\r ,]
75 Operator = 1, //!< [!#&*+-/:;<=>?]
76 Open = 2, //!< [(]
77 Close = 3, //!< [)]
78 Comment = 4, //!< [%]
79 Numeric = 5, //!< [0-9]
80 Alpha = 6, //!< [a-zA-Z_]
81 Open_index = 7, //!< [\[]
82 Close_index = 8, //!< [\]]
83 Illegal_char = 9, //!< all the rest in the ASCII table
84 Terminator = 10, //!< [@\0]
85 Bit = 11, //!< [.]
86 String = 12 //!< ["]
87 } atom_t;
88 #define Quotes String
90 /*! atom container
91 * Example: 'oprd min 5 0x400' is formed by 4 atoms
93 struct atom {
94 unsigned int pos; //!< position if @av_type is @Alpha or @Operator
95 int val; //!< value if @av_type is @Numeric
96 atom_t type; //!< atom type
97 char text[MAX_ARG_LENGTH]; //!< string representation
98 unsigned int cmd_id; //!< command id (might be built-in or user-defined)
99 oprid_t oid; //!< operator id (if any)
102 /*! @name Default commands for every test program
104 * Some default commands use ioctl calls to access the driver.
105 * The user should provide these ioctl numbers to use these commands.
106 * If a particular ioctl number is not provided, its command won't be issued.
107 * IOCTL numbers can be obtained using @b debugfs
109 enum def_cmd_id {
110 CmdNOCM = 0, //!< llegal command
111 _CmdSRVDBG, //!< Service entry (for debugging purposes)
112 CmdQUIT, //!< Quit test program
113 CmdHELP, //!< Help on commands
114 CmdATOMS, //!< Atom list commands
115 CmdHIST, //!< History
116 CmdSLEEP, //!< Sleep
117 CmdSHELL, //!< Shell command
119 CmdCONNECT, //!< Connect/show connections <=> ioctl
120 CmdCLIENTS, //!< Show list of clients <=> ioctl
121 CmdDEBUG, //!< Get Set debug mode <=> ioctl
122 CmdENABLE, //!< Enable/Disable module <=> ioctl
123 CmdMAPS, //!< Print module mappings <=> ioctl
124 CmdMODULE, //!< Module selection <=> ioctl
125 CmdNEXT, //!< Select next module <=> ioctl
126 CmdQUEUE, //!< Get/Set queue flag <=> ioctl
127 CmdRAWIO, //!< Raw memory IO <=> ioctl
128 CmdRESET, //!< Reset module <=> ioctl
129 CmdSINTR, //!< Simulate interrupt <=> ioctl
130 CmdSTATUS, //!< Get status <=> ioctl
131 CmdTIMEOUT, //!< Get/Set timeout <=> ioctl
132 CmdVER, //!< Get versions <=> ioctl
133 CmdWINTR, //!< Wait for interrupt <=> ioctl
134 CmdJTAG, //!< JTAG VHDL files into FPGA <=> 4 ioctls
135 CmdUSR //!< first available command for the user
138 //!< Command description
139 struct cmd_desc {
140 int valid; //!< show command to the user? (1 - yes, 0 - no)
141 int id; //!< id (user-defined && @def_cmd_id)
142 char *name; //!< spelling
143 char *help; //!< short help string
144 char *opt; //!< options (if any)
145 int comp; //!< amount of compulsory options
146 int (*handle)(struct cmd_desc *, struct atom *); //!< handler
147 int pa; //!< number of arguments to be passed to the handler
148 struct list_head list; //!< linked list
151 DECLARE_GLOB_LIST_HEAD(tcmd_glob_list); //!< test command list
153 //!< Global test data */
154 struct tst_data {
155 int mod; //!< current active module (starting from one)
156 int ma; //!< amount of controlled modules
157 int fd; //!< driver node descriptor (F_CLOSED if not opened)
158 InsLibModlDesc descr[MAX_DEV_SUPP]; //!< module description
161 //!< General Test data
162 _DECL struct tst_data tst_glob_d _INIT({ .fd = F_CLOSED });
164 #endif /* _EXTEST_COMMON_H_ */