driver-gen: New properties (type, chan) added in xml module description file
[driver-gen.git] / access.c
blobe8e26f6a25a2286ddcce7255cd90c410b98214ae
1 /**
2 * @file access.c
4 * @brief DataBase access to get hw module description is here.
6 * @author Copyright (c) 2003 - 2010 CERN. Georgievskiy Yury
8 * @date Created on 14/12/2009
9 */
10 #include <stdio.h>
11 #include "driverGen.h"
12 #include "utilities.h"
14 /* dbrtAccess.c */
15 extern int DBGetRegisterConfig(char*, RegisterDef_t*, BlockDef_t*, int, char*);
16 extern int DBGetBlockConfig(char*, BlockDef_t*, char*);
17 extern rstat DBGetPciInfo(char*, PciInfo_t*);
18 extern rstat DBGetVmeInfo(char*, VmeInfo_t*);
20 /* xmlAccess.c */
21 extern int XMLGetRegisterConfig(char*, RegisterDef_t*, BlockDef_t*, int, char*);
22 extern int XMLGetBlockConfig(char*, BlockDef_t*, char*);
23 extern rstat XMLGetPciInfo(char*, PciInfo_t*);
24 extern rstat XMLGetVmeInfo(char*, VmeInfo_t*);
26 /**
27 * @brief Get register description from the DataBase.
29 * @param moduleName -- DataBase Module Name
30 * @param defs -- register description to put
31 * @param blks -- block description
32 * @param numBlks -- number of blocks
33 * @param prog -- program name
35 * Registers are prepared for the further use. If MAX allowed register amount
36 * reached - printout error message and exits.
38 * @return number of registers, defined in the DB.
40 int GetRegisterConfig(char *moduleName, RegisterDef_t *defs,
41 BlockDef_t *blks, int numBlks, char *prog)
43 #ifdef ACCESS_DB
44 return DBGetRegisterConfig(moduleName, defs, blks, numBlks, prog);
45 #else
46 return XMLGetRegisterConfig(moduleName, defs, blks, numBlks, prog);
47 #endif
50 /**
51 * @brief Get block configuration from the DataBase.
53 * @param moduleName -- DataBase Module Name
54 * @param defs -- results will go here
55 * @param prog -- program name
57 * prepare results for the further use. If MAX allowed block amount
58 * reached - printout error message and exits.
60 * @return number of defined blocks
62 int GetBlockConfig(char *moduleName, BlockDef_t * defs, char *prog)
64 #ifdef ACCESS_DB
65 return DBGetBlockConfig(moduleName, defs, prog);
66 #else
67 return XMLGetBlockConfig(moduleName, defs, prog);
68 #endif
71 /**
72 * @brief Get PCI board information from the database.
74 * @param moduleName -- DataBase Module Name
75 * @param pciInfo -- results will go here
77 * @return DRIVER_GEN_OK - if PCI board info is obtained.
78 * @return DRIVER_GEN_BAD - othervise.
80 rstat GetPciInfo(char *moduleName, PciInfo_t * pciInfo)
82 #ifdef ACCESS_DB
83 return DBGetPciInfo(moduleName, pciInfo);
84 #else
85 return XMLGetPciInfo(moduleName, pciInfo);
86 #endif
89 /**
90 * @brief Get VME board information from the database.
92 * @param moduleName -- DataBase Module Name
93 * @param vmeInfo -- results will go here
95 * @return DRIVER_GEN_OK - if VME board info is obtained.
96 * @return DRIVER_GEN_BAD - othervise.
98 rstat GetVmeInfo(char *moduleName, VmeInfo_t *vmeInfo)
100 #ifdef ACCESS_DB
101 return DBGetVmeInfo(moduleName, vmeInfo);
102 #else
103 return XMLGetVmeInfo(moduleName, vmeInfo);
104 #endif