diff options
Diffstat (limited to 'pcilib/xml.c')
-rw-r--r-- | pcilib/xml.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/pcilib/xml.c b/pcilib/xml.c index 50aaa35..b980a83 100644 --- a/pcilib/xml.c +++ b/pcilib/xml.c @@ -40,6 +40,7 @@ #include "xml.h" #include "error.h" #include "view.h" +#include "py.h" #include "views/enum.h" #include "views/transform.h" @@ -48,11 +49,11 @@ #define REGISTERS_PATH ((xmlChar*)"./register") /**< all standard registers nodes */ #define BIT_REGISTERS_PATH ((xmlChar*)"./field") /**< all bits registers nodes */ #define REGISTER_VIEWS_PATH ((xmlChar*)"./view") /**< supported register & field views */ -#define TRANSFORM_VIEWS_PATH ((xmlChar*)"/model/transform") /**< path to complete nodes of views */ +#define TRANSFORM_VIEWS_PATH ((xmlChar*)"/model/transform") /**< path to complete nodes of views */ #define ENUM_VIEWS_PATH ((xmlChar*)"/model/enum") /**< path to complete nodes of views */ #define ENUM_ELEMENTS_PATH ((xmlChar*)"./name") /**< all elements in the enum */ #define UNITS_PATH ((xmlChar*)"/model/unit") /**< path to complete nodes of units */ -#define UNIT_TRANSFORMS_PATH ((xmlChar*)"./transform") /**< all transforms of the unit */ +#define UNIT_TRANSFORMS_PATH ((xmlChar*)"./transform") /**< all transforms of the unit */ @@ -492,6 +493,8 @@ static int pcilib_xml_parse_view(pcilib_t *ctx, xmlXPathContextPtr xpath, xmlDoc xmlAttrPtr cur; const char *value, *name; + int inconsistent = (desc->mode & PCILIB_ACCESS_INCONSISTENT); + for (cur = node->properties; cur != NULL; cur = cur->next) { if (!cur->children) continue; if (!xmlNodeIsText(cur->children)) continue; @@ -537,8 +540,14 @@ static int pcilib_xml_parse_view(pcilib_t *ctx, xmlXPathContextPtr xpath, xmlDoc pcilib_error("Invalid access mode (%s) is specified in the XML register description", value); return PCILIB_ERROR_INVALID_DATA; } - } + } else if (!strcasecmp(name, "write_verification")) { + if (strcmp(value, "0")) inconsistent = 0; + else inconsistent = 1; + } } + + if (inconsistent) desc->mode |= PCILIB_ACCESS_INCONSISTENT; + else desc->mode &= ~PCILIB_ACCESS_INCONSISTENT; return 0; } @@ -585,10 +594,12 @@ static int pcilib_xml_create_transform_view(pcilib_t *ctx, xmlXPathContextPtr xp } desc.write_to_reg = value; if ((value)&&(*value)) mode |= PCILIB_ACCESS_W; - } + } else if (!strcasecmp(name, "script")) { + desc.script = value; + break; + } } - - desc.base.mode &= mode; + desc.base.mode &= (~PCILIB_ACCESS_RW)|mode; err = pcilib_add_views_custom(ctx, 1, (pcilib_view_description_t*)&desc, &view_ctx); if (err) return err; @@ -597,7 +608,6 @@ static int pcilib_xml_create_transform_view(pcilib_t *ctx, xmlXPathContextPtr xp return 0; } - static int pcilib_xml_parse_value_name(pcilib_t *ctx, xmlXPathContextPtr xpath, xmlDocPtr doc, xmlNodePtr node, pcilib_register_value_name_t *desc) { xmlAttr *cur; char *value, *name; @@ -605,7 +615,7 @@ static int pcilib_xml_parse_value_name(pcilib_t *ctx, xmlXPathContextPtr xpath, int min_set = 0, max_set = 0; pcilib_register_value_t val; - + for (cur = node->properties; cur != NULL; cur = cur->next) { if(!cur->children) continue; if(!xmlNodeIsText(cur->children)) continue; @@ -703,7 +713,7 @@ static int pcilib_xml_create_enum_view(pcilib_t *ctx, xmlXPathContextPtr xpath, pcilib_error("No names is defined for enum view (%s)", desc.base.name); return PCILIB_ERROR_INVALID_DATA; } - + memset(desc.names, 0, (nodeset->nodeNr + 1) * sizeof(pcilib_register_value_name_t)); for (i = 0; i < nodeset->nodeNr; i++) { err = pcilib_xml_parse_value_name(ctx, xpath, doc, nodeset->nodeTab[i], &desc.names[i]); @@ -713,11 +723,9 @@ static int pcilib_xml_create_enum_view(pcilib_t *ctx, xmlXPathContextPtr xpath, return err; } } - memset(&desc.names[nodeset->nodeNr], 0, sizeof(pcilib_register_value_name_t)); xmlXPathFreeObject(nodes); - err = pcilib_add_views_custom(ctx, 1, (pcilib_view_description_t*)&desc, &view_ctx); if (err) { free(desc.names); |