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_
19 #include <sys/types.h>
21 #include <general_both.h>
23 #include <data_tables.h>
24 #include <config_data.h>
26 #ifdef __SKEL_EXTEST__
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"
67 oprid_t id
; //!< operator ID (one of @ref oprid_t)
68 char name
[16]; //!< Human form
69 char help
[32]; //!< help string
74 Separator
= 0, //!< [\t\n\r ,]
75 Operator
= 1, //!< [!#&*+-/:;<=>?]
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]
91 * Example: 'oprd min 5 0x400' is formed by 4 atoms
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
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
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
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 */
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_ */