summaryrefslogtreecommitdiffstats
path: root/pcilib
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2015-10-18 04:28:43 +0200
committerSuren A. Chilingaryan <csa@suren.me>2015-10-18 04:28:43 +0200
commit1c52a32779de1569ea41267ac6fc8f51c5a8b7fd (patch)
tree7e2e19d50109b5e38fdfcf47fb1c41a9bee4cc98 /pcilib
parentc8628b2a715a7cfaaccbd7e403cd1c6c76b918cd (diff)
downloadpcitool-1c52a32779de1569ea41267ac6fc8f51c5a8b7fd.tar.gz
pcitool-1c52a32779de1569ea41267ac6fc8f51c5a8b7fd.tar.bz2
pcitool-1c52a32779de1569ea41267ac6fc8f51c5a8b7fd.tar.xz
pcitool-1c52a32779de1569ea41267ac6fc8f51c5a8b7fd.zip
Support XML properties
Diffstat (limited to 'pcilib')
-rw-r--r--pcilib/property.c11
-rw-r--r--pcilib/py.c2
-rw-r--r--pcilib/view.h2
-rw-r--r--pcilib/xml.c21
4 files changed, 27 insertions, 9 deletions
diff --git a/pcilib/property.c b/pcilib/property.c
index 23c92d1..1db6dd3 100644
--- a/pcilib/property.c
+++ b/pcilib/property.c
@@ -20,7 +20,6 @@ int pcilib_add_register_properties(pcilib_t *ctx, size_t n, const pcilib_registe
pcilib_register_t i;
pcilib_view_t cur_view = ctx->num_views;
- pcilib_view_context_t *view_ctx;
if (!n)
return PCILIB_ERROR_INVALID_ARGUMENT;
@@ -59,6 +58,7 @@ int pcilib_add_register_properties(pcilib_t *ctx, size_t n, const pcilib_registe
v.base.name = view_name;
v.base.description = registers[i].description;
v.base.mode = registers[i].mode&mode;
+ v.base.flags |= PCILIB_VIEW_FLAG_PROPERTY;
v.reg = registers[i].name;
v.bank = b->name;
@@ -68,9 +68,10 @@ int pcilib_add_register_properties(pcilib_t *ctx, size_t n, const pcilib_registe
pcilib_clean_views(ctx, cur_view);
return err;
}
-
- view_ctx = pcilib_find_view_context_by_name(ctx, v.base.name);
+/*
+ pcilib_view_context_t *view_ctx = pcilib_find_view_context_by_name(ctx, v.base.name);
view_ctx->flags |= PCILIB_VIEW_FLAG_PROPERTY;
+*/
}
return 0;
@@ -100,7 +101,7 @@ pcilib_property_info_t *pcilib_get_property_list(pcilib_t *ctx, const char *bran
const char *subname = v->name + name_offset;
const char *suffix;
- if (!(view_ctx->flags&PCILIB_VIEW_FLAG_PROPERTY)) continue;
+ if (!(v->flags&PCILIB_VIEW_FLAG_PROPERTY)) continue;
if ((branch)&&(strncasecmp(branch, v->name, strlen(branch)))) continue;
suffix = strchr(subname, '/');
@@ -134,7 +135,7 @@ pcilib_property_info_t *pcilib_get_property_list(pcilib_t *ctx, const char *bran
const pcilib_view_description_t *v = ctx->views[view_ctx->view];
const char *subname = v->name + name_offset;
- if (!(view_ctx->flags&PCILIB_VIEW_FLAG_PROPERTY)) continue;
+ if (!(v->flags&PCILIB_VIEW_FLAG_PROPERTY)) continue;
if ((branch)&&(strncasecmp(branch, v->name, strlen(branch)))) continue;
if (!strchr(subname, '/')) {
diff --git a/pcilib/py.c b/pcilib/py.c
index 3a4fd96..def050e 100644
--- a/pcilib/py.c
+++ b/pcilib/py.c
@@ -108,7 +108,7 @@ static char *pcilib_py_parse_string(pcilib_t *ctx, const char *codestr, pcilib_v
// find the end of the register name
reg++;
- for (i = 0; isalnum(reg[i]); i++);
+ for (i = 0; isalnum(reg[i])||(reg[i] == '_'); i++);
save = reg[i];
reg[i] = 0;
diff --git a/pcilib/view.h b/pcilib/view.h
index 6287942..606a688 100644
--- a/pcilib/view.h
+++ b/pcilib/view.h
@@ -27,6 +27,7 @@ typedef struct {
struct pcilib_view_description_s {
const pcilib_view_api_description_t *api;
+ pcilib_view_flags_t flags; /**< Flags specifying type of the view */
pcilib_value_type_t type; /**< The default data type returned by operation, PCILIB_VIEW_TYPE_STRING is supported by all operations */
pcilib_access_mode_t mode; /**< Specifies if the view is read/write-only */
const char *unit; /**< Returned unit (if any) */
@@ -37,7 +38,6 @@ struct pcilib_view_description_s {
struct pcilib_view_context_s {
const char *name;
pcilib_view_t view;
- pcilib_view_flags_t flags; /**< Flags specifying type of the view */
UT_hash_handle hh;
};
diff --git a/pcilib/xml.c b/pcilib/xml.c
index 4df0d2d..4ecd16d 100644
--- a/pcilib/xml.c
+++ b/pcilib/xml.c
@@ -488,7 +488,12 @@ static int pcilib_xml_parse_view(pcilib_t *ctx, xmlXPathContextPtr xpath, xmlDoc
if (!value) continue;
if (!strcasecmp(name, "name")) {
- desc->name = value;
+ // Overriden by path
+ if (!desc->name)
+ desc->name = value;
+ } else if (!strcasecmp(name, "path")) {
+ desc->name = value;
+ desc->flags |= PCILIB_VIEW_FLAG_PROPERTY;
} else if (!strcasecmp((char*)name, "description")) {
desc->description = value;
} else if (!strcasecmp((char*)name, "unit")) {
@@ -529,10 +534,22 @@ static int pcilib_xml_create_transform_view(pcilib_t *ctx, xmlXPathContextPtr xp
if (!value) continue;
if (!strcasecmp(name, "read_from_register")) {
+ if (desc.base.flags&PCILIB_VIEW_FLAG_PROPERTY) {
+ if (strstr(value, "$value")) {
+ pcilib_error("Invalid transform specified in XML property (%s). The properties can't reference $value (%s)", desc.base.name, value);
+ return PCILIB_ERROR_INVALID_DATA;
+ }
+ }
desc.read_from_reg = value;
if ((value)&&(*value)) desc.base.mode |= PCILIB_ACCESS_R;
} else if (!strcasecmp(name, "write_to_register")) {
- desc.write_to_reg = value;
+ if (desc.base.flags&PCILIB_VIEW_FLAG_PROPERTY) {
+ if (strstr(value, "$value")) {
+ pcilib_error("Invalid transform specified in XML property (%s). The properties can't reference $value (%s)", desc.base.name, value);
+ return PCILIB_ERROR_INVALID_DATA;
+ }
+ }
+ desc.write_to_reg = value;
if ((value)&&(*value)) desc.base.mode |= PCILIB_ACCESS_W;
}
}