read_config.h

Go to the documentation of this file.
00001 #ifndef READ_CONFIG_H
00002 #define READ_CONFIG_H
00003 /*
00004  *   MODULE: READ_CONFIG.H
00005  *
00006  *   VERSION: X-14
00007  *
00008  *      ©1996, 1997, 1998 by Digital Equipment Corporation.  All Rights Reserved.
00009  *
00010  *      This is the include file for the READ_CONFIG.C program.  It has
00011  *      various things that are useful to other modules that wish to build
00012  *      against READ_CONFIG.C
00013  *
00014  *      Revision history
00015  *
00016  *      X-14                    David Fairbanks                 2-Oct-2001
00017  *              Add new CISS cflag.
00018  *
00019  *      X-13    RTS049          Bob Silver                      07-Jan-1998
00020  *              Remove cmdBOOT_ULP and ioc$lookup_ulp references.  Using the
00021  *              existing cmdBOOT_CLASS for the boot ulp instead.
00022  *
00023  *      X-12    RTS026  Bob Silver               7-Nov-1997
00024  *              - Add new BOOT_ULP cmd, FIBRE and ULP cflags.
00025  *              - Change BOOT_CLASS match length from 5 to 7 so that new
00026  *                BOOT_ULP field can be matched correctly.
00027  *              - Add declaration for new IOC$LOOKUP_ULP routine.
00028  *              - Move macros to lowercase config routine names from
00029  *                IOC_ROUTINES.H into this module.
00030  *
00031  *              See Fibre Channel Configure spec at STAR::DOCD$:[EVMS.PRO-
00032  *              JECT_DOCUMENTS]DS-FC_CONFIGURE.MEM for further information
00033  *              on these changes.
00034  *
00035  *      X-11    FGK     Fred Kleinsorge         18-Sep-1996
00036  *              o Add dummy IFILEIO routines in USERMODE version.
00037  *
00038  *              o Add new bit - ISA_ON_EISA to prevent string compression on EISA bus.
00039  *
00040  *      X-9A1   FGK     Fred Kleinsorge         11-Sep-1996
00041  *              Add error message for bad numeric value, and change #ifdef
00042  *              for old version compiles for testing.
00043  *
00044  *      X-9     FGK     Fred Kleinsorge         20-Aug-1996
00045  *              Add the macro file_as_is to set the as_is
00046  *              flag when compiled for exec_init use.
00047  *
00048  *      X-8     FGK     Fred Kleinsorge         10-Jul-1996
00049  *              Add extended ID bit
00050  *
00051  *      X-7     FGK     Fred Kleinsorge         10-May-1996
00052  *              Change prototype for build_config_table and remove
00053  *              TPB filename default
00054  *
00055  *      X-6     FGK     Fred Kleinsorge         05-Apr-1996
00056  *              o Moved the error strings into the READ_CONFIG
00057  *                C module.  Made the tables in here static - this
00058  *                is to allow both the IOC and IOGEN versions to be
00059  *                linked in the same module.
00060  *
00061  *                Note: When doing this for a ICBM, the ICBM will
00062  *                need to define the IFILEIO routines as null routines
00063  *                in order to link -- or it needs to pull in all the
00064  *                primitive file system junk.
00065  *
00066  *      X-5/2   FGK     Fred Kleinsorge         00-May-1996
00067  *              o Various changes as the code evolved prior to checkin.
00068  *
00069  *      X-1     FGK     Fred Kleinsorge         00-Dec-1995
00070  *              o Create
00071  *
00072  */
00073 
00074 #ifndef DEBUG_FLAG_DEFAULT
00075 #define DEBUG_FLAG_DEFAULT 0
00076 #endif
00077 
00078 /*
00079  *   This file contains tables, various defines, etc.  Use this include
00080  *   file to reference the tables used by read_config.c.
00081  */
00082 
00083 #include "config_table.h"
00084 
00085 
00086 /*
00087  *   defines that can be changed at compile time
00088  */
00089 #ifndef CONFIG_FILE
00090 #define CONFIG_FILE "SYS$SYSROOT:[SYSEXE]SYS$CONFIG.DAT"
00091 #endif
00092 
00093 #ifndef USER_CONFIG_FILE
00094 #define USER_CONFIG_FILE "SYS$SYSROOT:[SYSEXE]SYS$USER_CONFIG.DAT"
00095 #endif
00096 
00097 #ifndef MAX_CONFIG_CACHE
00098 #define MAX_CONFIG_CACHE 64
00099 #endif
00100 
00101 #ifndef STRING_MAX
00102 #define STRING_MAX  256
00103 #endif
00104 
00105 #ifndef MEDIUM_STRING
00106 #define MEDIUM_STRING  128
00107 #endif
00108 
00109 #ifndef SMALL_STRING
00110 #define SMALL_STRING 32
00111 #endif
00112 
00113 #ifndef TOKEN_MAX
00114 #define TOKEN_MAX 64
00115 #endif
00116 
00117 #define END_OF_TABLE -1
00118 
00119 typedef struct _names {
00120    int   bits;
00121    char *name;
00122    int   match_length;
00123 } NAMES;
00124 
00125 
00126 /*
00127  *  The following values and table defines the keywords in
00128  *  the config file that are supported (parsed).
00129  *
00130  */
00131   enum COMMAND_VALUE {
00132     cmdDEVICE,
00133     cmdEND_DEVICE,
00134     cmdDRIVER,
00135     cmdADAPTER, 
00136     cmdNAME,
00137     cmdID,
00138     cmdFLAGS,
00139     cmdUNITS,
00140     cmdVECS,
00141     cmdVECALIGN,
00142     cmdASSOC,
00143     cmdTYPE,
00144     cmdPRIVATE,
00145     cmdBEGIN_PRIVATE,
00146     cmdEND_PRIVATE,
00147     cmdBOOT_FLAGS,
00148     cmdBOOT_CLASS,
00149     cmdEND_CONFIG
00150   };
00151 
00152 static NAMES cmd[] = {
00153 
00154  // Command Value       String       Match Length
00155 
00156     cmdDEVICE,          "DEVICE",        4,
00157     cmdEND_DEVICE,      "END_DEVICE",    5,
00158     cmdDRIVER,          "DRIVER",        4,
00159     cmdADAPTER,         "ADAPTER",       4,
00160     cmdNAME,            "NAME",          4,
00161     cmdID,              "ID",            2,
00162     cmdFLAGS,           "FLAGS",         4,
00163     cmdUNITS,           "UNITS",         4,
00164     cmdVECS,            "NUM_VECTORS",   7,
00165     cmdVECALIGN,        "ALIGN_VECTOR",  9,
00166     cmdASSOC,           "ASSOC_DRIVERS", 5,
00167     cmdTYPE,            "TYPE",          4,
00168     cmdPRIVATE,         "PRIVATE",       4,
00169     cmdBEGIN_PRIVATE,   "BEGIN_PRIVATE", 7,
00170     cmdEND_PRIVATE,     "END_PRIVATE",   5,
00171     cmdBOOT_FLAGS,      "BOOT_FLAGS",    7,
00172     cmdBOOT_CLASS,      "BOOT_CLASS",    7,
00173     cmdEND_CONFIG,      "END_CONFIG",    5,
00174     END_OF_TABLE,       "LAST_ENTRY",    0
00175   };
00176 
00177 //
00178 //  Define the adapter strings...  note the aliases
00179 //
00180 static NAMES adapters[] = {
00181  // ADAPTER             String          Match Length
00182     0,                  "NONE",              4,
00183     AT$_ISA,            "ISA",               3,
00184     AT$_EISA,           "EISA",              4,
00185     AT$_TC,             "TC",                2,
00186     AT$_PCI,            "PCI",               3,
00187     AT$_XMI,            "XMI",               3,
00188     AT$_FBUS,           "FBUS",              4,
00189     AT$_KA0202_LBUS,    "KA0202_LBUS",      10,
00190     AT$_COREIO,         "COREIO",            4,
00191     AT$_XBUS,           "XBUS",              4,
00192     AT$_PCMCIA,         "PCMCIA",            4,
00193     AT$_VTI_COMBO,      "VTI_COMBO",         4,
00194     AT$_TC,             "TURBOCHANNEL",      5,
00195     END_OF_TABLE,       "UNKNOWN/ALL",       0
00196 };
00197 
00198 /*
00199  *  This table is used strictly for printing, not all these adapters
00200  *  are busses or supported for devices... but it's handy when in debug
00201  *  
00202  */
00203 static NAMES adapter_print_names[] = {
00204  // ADAPTER             String          Match Length (not used)
00205     0,                  "ALL",               1,
00206     AT$_ISA,            "ISA",               1,
00207     AT$_EISA,           "EISA",              1,
00208     AT$_TC,             "TURBOChannel",      1,
00209     AT$_PCI,            "PCI",               1,
00210     AT$_MULTIFUNCTION_PCI, "Multi-function PCI", 1,
00211     AT$_XMI,            "XMI",               1,
00212     AT$_FBUS,           "FutureBus",         1,
00213     AT$_KA0202_LBUS,    "LBUS",              1,
00214     AT$_COREIO,         "Flamingo COREIO",   1,
00215     AT$_XBUS,           "XBUS",              1,
00216     AT$_PCMCIA,         "PCMCIA",            1,
00217     AT$_VTI_COMBO,      "Jensen VTI 82C106 COMBO", 1,
00218     AT$_MULTIFUNCTION_ISA, "Multi-function ISA", 1,
00219     AT$_LMCP,           "Laser reflective memory", 1,
00220     AT$_AHA_1742A,      "Adaptec aha1742a",     1,
00221     AT$_KA0202,         "Cobra System ADP",  1,
00222     AT$_KA0302,         "Laser System ADP",  1,
00223     AT$_KA0402,         "Flamingo System ADP", 1,
00224     AT$_KA0602,         "Jensen System ADP", 1,
00225     AT$_KA0702,         "Pelican System ADP", 1,
00226     AT$_KA0902,         "Sable System ADP",  1,
00227     AT$_KA1102,         "Mikasa System ADP",  1,
00228     AT$_KA1402,         "EB64+ System ADP",  1,
00229     AT$_KA0F05,         "Alcor System ADP",  1,
00230     AT$_KA1504,         "AlphaBOOK System ADP", 1,
00231     AT$_KA0302,         "Laser System ADP",  1,
00232     AT$_KA0C05,         "TurboLaser System ADP", 1,
00233     AT$_TIOP,           "TurboLaser TIOP ADP", 1,
00234     AT$_ITIOP,          "TurboLaser ITIOP ADP", 1,
00235     AT$_HPC,            "TurboLaser HPC ADP", 1,
00236 //  V7.1 and later
00237 #ifdef AT$_KA1A05
00238     AT$_KA1B02,         "Norittake  System ADP", 1,
00239     AT$_KA1802,         "Lynx (EV4) System ADP", 1,
00240     AT$_KA1805,         "Lynx (EV5) System ADP", 1,
00241     AT$_MEMCHAN,        "Memory Channel",    1,
00242     AT$_KA1A05,         "EB164 System ADP",  1,
00243     AT$_KA1605,         "Rawhide System ADP", 1,
00244     AT$_MC_BUS,         "Rawhide System Bus ADP",  1,
00245     AT$_KA1105,         "Pinnacle/Mikasa System ADP", 1,
00246     AT$_KA1B02,         "Pinnacle/Norittake System ADP", 1,
00247 #endif
00248     END_OF_TABLE,       "UNKNOWN",           0
00249 };
00250 
00251 /*
00252  *  Flags.  These are bits that will get set in the table, and are
00253  *  interpreted by the consumer of the table.
00254  *
00255  */
00256 /*
00257  *  These are the currently supported flag bits...
00258  */ 
00259 static NAMES cflags[] = {
00260 // FLAG_BITS                   String       Match Length
00261    IOGEN_CFG_TBL$M_MSCP,       "MSCP",            4,
00262    IOGEN_CFG_TBL$M_SCSI,       "SCSI",            4,
00263    IOGEN_CFG_TBL$M_NOVECTOR,   "NOVECTOR",        5,
00264    IOGEN_CFG_TBL$M_CLASS,      "CLASS",           5,
00265    IOGEN_CFG_TBL$M_PORT,       "PORT",            3,
00266    IOGEN_CFG_TBL$M_BOOT,       "BOOT",            4,
00267    IOGEN_CFG_TBL$M_DISK,       "DISK",            4,
00268    IOGEN_CFG_TBL$M_NETWORK,    "NETWORK",         3,
00269    IOGEN_CFG_TBL$M_PSEUDO,     "PSEUDO",          3,
00270    IOGEN_CFG_TBL$M_CASE_BLIND, "CASE_BLIND",      6,
00271 
00272 #ifndef IOGEN_CFG_TBL$M_EXTENDED_ID
00273 #define IOGEN_CFG_TBL$M_EXTENDED_ID (IOGEN_CFG_TBL$M_NO_TABLE << 1)
00274 #endif
00275    IOGEN_CFG_TBL$M_EXTENDED_ID, "EXTENDED_ID",   11,
00276 
00277 #ifndef IOGEN_CFG_TBL$M_ISA_ON_EISA
00278 #define IOGEN_CFG_TBL$M_ISA_ON_EISA (IOGEN_CFG_TBL$M_NO_TABLE << 2)
00279 #endif
00280    IOGEN_CFG_TBL$M_ISA_ON_EISA, "ISA_ON_EISA",    7,
00281    IOGEN_CFG_TBL$M_FIBRE,      "FIBRE",           3,
00282    IOGEN_CFG_TBL$M_ULP,        "ULP",             3,
00283    IOGEN_CFG_TBL$M_CISS,       "CISS",            4,
00284 
00285    END_OF_TABLE,               "UNKNOWN",         0
00286 };
00287 
00288 /*
00289  *  Boot Flags.  These are bits that will get set in the table, and are
00290  *  interpreted by the consumer of the table.
00291  *
00292  */
00293 /*
00294  *  These are the currently supported boot flag bits...
00295  */ 
00296 static NAMES bflags[] = {
00297 // FLAG_BITS                       String       Match Length
00298    IOGEN_CFG_TBL$M_SYS_DEV,     "SYS_DEV",           7,
00299    IOGEN_CFG_TBL$M_REMOTE,      "REMOTE",            4,
00300    IOGEN_CFG_TBL$M_NO_CTRL_LTR, "NO_CTRL_LTR",       8,
00301    IOGEN_CFG_TBL$M_HW_CTRL_LTR, "HW_CTRL_LTR",       8,
00302    IOGEN_CFG_TBL$M_UNIT_0,      "UNIT_0",            6,
00303    IOGEN_CFG_TBL$M_CTRL_LTR_A,  "CTRL_LTR_A",        4,
00304    IOGEN_CFG_TBL$M_ALT_PREFIX,  "ALT_PREFIX",        8,
00305    IOGEN_CFG_TBL$M_CREATE_DEV,  "CREATE_DEV",        8,
00306    END_OF_TABLE,                "UNKNOWN",           0
00307 };
00308 
00309 /*
00310  *  Define the internal error messages codes
00311  */
00312 enum ERROR_TYPES {
00313         FIRST_MESSAGE,
00314         BAD_HWID,
00315         BAD_NUMBER,
00316         NOFILE,              
00317         UNKNOWN_COMMAND,     
00318         MISSING_INFO,        
00319         NOT_ADDED,        
00320         MISSING_END_DEVICE,  
00321         INSFARGS,            
00322         NOEQUALS,            
00323         NOSTRING,            
00324         NEEDVALUE,           
00325         BADUNITS,            
00326         UNKNOWN_ADP,         
00327         MISSINGADP,
00328         UNKNOWN_FLAG,        
00329         NOMEMORY,
00330         NULL_HW_ID,
00331         ID_NOT_STRING,
00332         BAD_EISA_ID,
00333         CHECK_ISA_ON_EISA,
00334         FOUND_CACHED,
00335         NEW_TABLE,
00336         BUILD_ERROR,
00337         TABLE_EXISTS,
00338         CHECKING_ADP, 
00339         NO_TABLE,
00340         UNKNOWN_TABLE,
00341         DELETE_TABLE,
00342         REPLACED_TABLE,
00343         FOUND_FILE,
00344         FOUND_ENTRIES,
00345         FOUND_MEMORY_ENTRIES,
00346         FOUND_ENTRY,
00347         NO_ENTRY,
00348         FOUND_CLASS,
00349         NO_CLASS,
00350         NO_CONFIG,
00351         BUILT_CONFIG_TABLE,
00352         BUILT_SUBCONFIG_TABLE,
00353         CONFIG_ADP_TYPE,    
00354         ALLOC_MEMORY,
00355         DISPLAY_ADAPTER,    
00356         DEALLOC_MEMORY,
00357         DEREF_MEMORY,
00358         NO_SYSTEM_CONFIG,
00359         NO_CONFIG_FILE,
00360         BUS_ENTRY,
00361         MERGED_TABLES,
00362         LINE_TRUNCATED,
00363         NOT_IN_DEVICE,
00364         NOT_IN_PRIVATE,
00365         TOOMANYARGS,
00366         DISPLINE,
00367         DUPLICATE_ID,
00368         NOAUTOCONFIG,
00369         COMMAND_REPEAT,
00370         LAST_MESSAGE
00371 };
00372 
00373 /*
00374  *  Flags for the edit_string routine
00375  */
00376 #define UPCASE                 0x01
00377 #define STRIP_LEAD_WHITESPACE  0x02
00378 #define STRIP_TRAIL_SPACES     0x04
00379 #define STRIP_QUOTES           0x08
00380 #define COMPRESS_SPACES        0x10
00381 #define COMPRESS_TABS          0x20
00382 #define STRIP_COMMENTS         0x40
00383 #define STRIP_SEMI_COMMENTS    0x80
00384 
00385 //
00386 //  Make sure this is defined...  I had problems linking the
00387 //  result for system use when I pulled the definition from the
00388 //  include file - this is because the include file references
00389 //  a routine that is not in the base image... and for obscure
00390 //  reasons, even though it's not actually called - it gets pulled
00391 //  in during the link (probably a weak reference issue).
00392 //
00393 //  In any case, the macro is *easy* to just define here.
00394 //
00395 #ifndef _toupper
00396 #define _toupper(c)      (((c) >= 'a' && (c) <= 'z') \
00397                                     ? (c) & 0xDF : (c))
00398 #endif
00399 
00400 /*
00401    VMS system routine entry points are defined externally using uppercase names.
00402    The following macros allow the usage of the lowercase versions of these
00403    names even in the presence of the /NAME=AS_IS compiler switch.
00404 */
00405 #define     ioc$build_config_table      IOC$BUILD_CONFIG_TABLE
00406 #define     ioc$lookup_id               IOC$LOOKUP_ID
00407 #define     ioc$init_adp_config         IOC$INIT_ADP_CONFIG
00408 #define     ioc$init_and_return_all     IOC$INIT_AND_RETURN_ALL
00409 #define     ioc$lookup_class            IOC$LOOKUP_CLASS
00410 #define     ioc$delete_config_table     IOC$DELETE_CONFIG_TABLE
00411 #define     ioc$display_entry           IOC$DISPLAY_ENTRY
00412 #define     ioc$read_config_debug       IOC$READ_CONFIG_DEBUG
00413 #define     ioc$find_device             IOC$FIND_DEVICE
00414 #define     ioc$print_config_error      IOC$PRINT_CONFIG_ERROR
00415 #define     ioc$create_config_subtable  IOC$CREATE_CONFIG_SUBTABLE
00416 #define     ioc$merge_config_tables     IOC$MERGE_CONFIG_TABLES
00417 
00418 
00419 #ifdef USERMODE
00420 
00421 extern int  iogen$build_config_table(const int adp_type, CONFIG_TABLE **config, ...);
00422 extern int  iogen$lookup_id(IOGEN_CFG_TBL *config_entry, BUSARRAYENTRY  *ba, ADP *adp, int *retindex, char **retdevnam);
00423 extern int  iogen$debug_adp_config(void);
00424 extern int  iogen$lookup_class(IOGEN_CFG_TBL *config_entry, int *retindex, char *devnam);
00425 extern int  iogen$delete_config_table(CONFIG_TABLE *config_table);
00426 extern int  iogen$display_entry(IOGEN_CFG_TBL *config_entry, int index);
00427 extern void iogen$read_config_debug(const int flag);
00428 extern int  iogen$find_device(IOGEN_CFG_TBL *config_entry, BUSARRAYENTRY  *ba, ADP *adp, int *retindex, char *devnam);
00429 extern int  iogen$print_config_error(int error_number, int *error_return, int print_flag, ...);
00430 extern int  iogen$create_config_subtable(const int adp_type, CONFIG_TABLE *full_config, CONFIG_TABLE **config);
00431 extern int  iogen$merge_config_tables(const int adp_type, CONFIG_TABLE **new_config_table, ...);
00432 
00433 #define _PRINT_ERROR iogen$print_config_error
00434 
00435 #define FILE_POINTER FILE
00436 #define FILE_OPEN(_FILENAME, _ACCESS) fopen(_FILENAME, _ACCESS)
00437 #define FILE_CLOSE(_FILE) fclose(_FILE)
00438 #define FILE_GET_STRING(_STRING, _MAX, _FILE) fgets(_STRING, _MAX, _FILE)
00439 #define FILE_AS_IS(_FILE)
00440 
00441 //
00442 //  Define dummy ifileio routines.  This allows both the IOC and IOGEN objects
00443 //  to be linked in the same executable.  These routines would normally be found
00444 //  in IFILEIO.C which uses the primitive file system... which user mode code
00445 //  should *not* do.
00446 //
00447 #ifdef DUMMY_IFILEIO
00448 
00449 int ifopen() {
00450   return 0;  
00451 }
00452 
00453 int ifclose() {
00454   return 0;
00455 }
00456 
00457 int ifgets() {
00458   return 0;
00459 }
00460 #endif
00461 
00462 #else
00463 
00464 #include "ifileio.h"
00465 
00466 extern int  ioc$build_config_table(const int adp_type, CONFIG_TABLE **config, ...);
00467 extern int  ioc$lookup_id(IOGEN_CFG_TBL *config_entry, BUSARRAYENTRY  *ba, ADP *adp, int *retindex, char **retdevnam);
00468 extern int  ioc$init_adp_config(CONFIG_TABLE *full_config);
00469 extern int  ioc$init_and_return_all(CONFIG_TABLE **config);
00470 extern int  ioc$lookup_class(IOGEN_CFG_TBL *config_entry, int *retindex, char *devnam);
00471 extern int  ioc$delete_config_table(CONFIG_TABLE *config_table);
00472 extern int  ioc$display_entry(IOGEN_CFG_TBL *config_entry, int index);
00473 extern void ioc$read_config_debug(const int flag);
00474 extern int  ioc$find_device(IOGEN_CFG_TBL *config_entry, BUSARRAYENTRY  *ba, ADP *adp, int *retindex, char *devnam);
00475 extern int  ioc$print_config_error(int error_number, int *error_return, int print_flag, ...);
00476 extern int  ioc$create_config_subtable(const int adp_type, CONFIG_TABLE *full_config, CONFIG_TABLE **config);
00477 extern int  ioc$merge_config_tables(const int adp_type, CONFIG_TABLE **new_config_table, ...);
00478 
00479 #define _PRINT_ERROR ioc$print_config_error
00480 
00481 #define FILE_POINTER IFILE
00482 #define FILE_OPEN(_FILENAME, _ACCESS) ifopen(_FILENAME, _ACCESS)
00483 #define FILE_CLOSE(_FILE) ifclose(_FILE)
00484 #define FILE_GET_STRING(_STRING, _MAX, _FILE) ifgets(_STRING, _MAX, _FILE)
00485 #define FILE_AS_IS(_FILE) _FILE->as_is = 1
00486 
00487 #endif /* #ifndef USERMODE */
00488 
00489 #endif /* READ_CONFIG_H */

SourceForge.net Logo
Project space on SourceForge.net