summaryrefslogtreecommitdiffstats
path: root/pcilib/pci.c
diff options
context:
space:
mode:
authornicolas.zilio@hotmail.fr <>2015-09-14 11:56:38 +0200
committernicolas.zilio@hotmail.fr <>2015-09-14 11:56:38 +0200
commit2dfb23016c39a331bf5ed4111b630dffa330edbb (patch)
tree995c98cf6c329aaf8996bb57bb95b44198b4a984 /pcilib/pci.c
parent60c6bf9f6916b6ae2c05a499675ff54480256ece (diff)
downloadpcitool-2dfb23016c39a331bf5ed4111b630dffa330edbb.tar.gz
pcitool-2dfb23016c39a331bf5ed4111b630dffa330edbb.tar.bz2
pcitool-2dfb23016c39a331bf5ed4111b630dffa330edbb.tar.xz
pcitool-2dfb23016c39a331bf5ed4111b630dffa330edbb.zip
views working fine, units in progress
Diffstat (limited to 'pcilib/pci.c')
-rw-r--r--pcilib/pci.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/pcilib/pci.c b/pcilib/pci.c
index 8c178f6..2742240 100644
--- a/pcilib/pci.c
+++ b/pcilib/pci.c
@@ -145,19 +145,24 @@ pcilib_t *pcilib_open(const char *device, const char *model) {
ctx->register_ctx = (pcilib_register_context_t *)malloc(PCILIB_DEFAULT_REGISTER_SPACE * sizeof(pcilib_register_context_t));
ctx->enum_views = (pcilib_view_enum2_t *)malloc(PCILIB_DEFAULT_VIEW_SPACE * sizeof(pcilib_view_enum2_t));
ctx->formula_views = (pcilib_view_formula_t*)malloc(PCILIB_DEFAULT_VIEW_SPACE * sizeof(pcilib_view_formula_t));
+ ctx->alloc_units=PCILIB_DEFAULT_UNIT_SPACE;
+ ctx->units=(pcilib_unit_t*)malloc(PCILIB_DEFAULT_UNIT_SPACE * sizeof(pcilib_unit_t));
+
+
if ((!ctx->registers)||(!ctx->register_ctx)) {
pcilib_error("Error allocating memory for register model");
pcilib_close(ctx);
return NULL;
}
- if((!ctx->enum_views)||(!ctx->formula_views)){
- pcilib_error("Error allocating memory for views");
- pcilib_close(ctx);
- return NULL;
+ /* i think we need a better error handling here, because, it's not that a problem to not have views working, but how to block the use if the memory here was not good?, and we could have only one type of views that is working*/
+ if((!ctx->enum_views)||(!ctx->formula_views) || (!ctx->units)){
+ pcilib_warning("Error allocating memory for views");
}
+
+
memset(ctx->registers, 0, sizeof(pcilib_register_description_t));
memset(ctx->banks, 0, sizeof(pcilib_register_bank_description_t));
memset(ctx->ranges, 0, sizeof(pcilib_register_range_t));
@@ -166,6 +171,7 @@ pcilib_t *pcilib_open(const char *device, const char *model) {
memset(ctx->enum_views,0,sizeof(pcilib_view_enum2_t));
memset(ctx->formula_views,0,sizeof(pcilib_view_formula_t));
+ memset(ctx->units,0,sizeof(pcilib_unit_t));
for (i = 0; pcilib_protocols[i].api; i++);
memcpy(ctx->protocols, pcilib_protocols, i * sizeof(pcilib_register_protocol_description_t));