summaryrefslogtreecommitdiffstats
path: root/pcitool
diff options
context:
space:
mode:
authorVasilii Chernov <vchernov@inr.ru>2016-02-24 18:24:22 +0100
committerVasilii Chernov <vchernov@inr.ru>2016-02-24 18:24:22 +0100
commitb0a034e6ef4a958235a56ebde0831c0f30a84d30 (patch)
treea1f46d2d536c692edd6b17efc61ac9fefef2796b /pcitool
parentda842568b94b0e00c1709ae01f441a7424c15b87 (diff)
parent3ea1907f3169e0233d3a32a7d470af3c34b6f967 (diff)
downloadpcitool-b0a034e6ef4a958235a56ebde0831c0f30a84d30.tar.gz
pcitool-b0a034e6ef4a958235a56ebde0831c0f30a84d30.tar.bz2
pcitool-b0a034e6ef4a958235a56ebde0831c0f30a84d30.tar.xz
pcitool-b0a034e6ef4a958235a56ebde0831c0f30a84d30.zip
Merge with Suren branch. Fix memory leaks.
Diffstat (limited to 'pcitool')
-rw-r--r--pcitool/CMakeLists.txt6
-rw-r--r--pcitool/buildinfo.c12
-rw-r--r--pcitool/buildinfo.h6
-rw-r--r--pcitool/cli.c49
4 files changed, 45 insertions, 28 deletions
diff --git a/pcitool/CMakeLists.txt b/pcitool/CMakeLists.txt
index 2f3639f..d8b5a6c 100644
--- a/pcitool/CMakeLists.txt
+++ b/pcitool/CMakeLists.txt
@@ -13,9 +13,9 @@ link_directories(
)
if (NOT DISABLE_PCITOOL)
- add_executable(pci cli.c sysinfo.c formaters.c)
- set(HEADERS ${HEADERS} sysinfo.h formaters.h)
- add_dependencies(pci pcilib)
+ set(HEADERS ${HEADERS} sysinfo.h formaters.h buildinfo.h)
+ add_executable(pci cli.c sysinfo.c formaters.c buildinfo.c)
+ add_dependencies(pci build pcilib)
target_link_libraries(pci pcilib ${FASTWRITER_LIBRARIES})
set_target_properties(pci PROPERTIES
LINK_FLAGS "${CMAKE_THREAD_LIBS_INIT} ${EXTRA_SYSTEM_LIBS}"
diff --git a/pcitool/buildinfo.c b/pcitool/buildinfo.c
new file mode 100644
index 0000000..624a934
--- /dev/null
+++ b/pcitool/buildinfo.c
@@ -0,0 +1,12 @@
+#include <stdio.h>
+#include <string.h>
+#include "pcilib/build.h"
+
+void BuildInfo() {
+ printf("\n");
+ printf("Revision: %s built on %s in %s\n", PCILIB_REVISION, PCILIB_BUILD_DATE, PCILIB_BUILD_DIR);
+ printf("Branch: %s by %s\n", PCILIB_REVISION_BRANCH, PCILIB_REVISION_AUTHOR);
+ if (strlen(PCILIB_REVISION_MODIFICATIONS)) {
+ printf("Modifications: %s - %s\n", PCILIB_LAST_MODIFICATION, PCILIB_REVISION_MODIFICATIONS);
+ }
+}
diff --git a/pcitool/buildinfo.h b/pcitool/buildinfo.h
new file mode 100644
index 0000000..5157a24
--- /dev/null
+++ b/pcitool/buildinfo.h
@@ -0,0 +1,6 @@
+#ifndef _PCITOOL_BUILDINFO_H
+#define _PCITOOL_BUILDINFO_H
+
+void BuildInfo();
+
+#endif /* _PCITOOL_BUILDINFO_H */ \ No newline at end of file
diff --git a/pcitool/cli.c b/pcitool/cli.c
index 0b0c98d..3f1af74 100644
--- a/pcitool/cli.c
+++ b/pcitool/cli.c
@@ -31,18 +31,19 @@
#include "pcitool/sysinfo.h"
#include "pcitool/formaters.h"
+#include "pcitool/buildinfo.h"
#include "views/transform.h"
#include "views/enum.h"
-#include "pci.h"
-#include "plugin.h"
-#include "config.h"
-#include "tools.h"
-#include "kmem.h"
-#include "error.h"
-#include "debug.h"
-#include "model.h"
-#include "locking.h"
+#include "pcilib/pci.h"
+#include "pcilib/plugin.h"
+#include "pcilib/config.h"
+#include "pcilib/tools.h"
+#include "pcilib/kmem.h"
+#include "pcilib/error.h"
+#include "pcilib/debug.h"
+#include "pcilib/model.h"
+#include "pcilib/locking.h"
/* defines */
#define MAX_KBUF 14
@@ -895,6 +896,8 @@ void Version(pcilib_t *handle, const pcilib_model_description_t *model_info) {
PCILIB_VERSION_GET_MICRO(version)
);
}
+
+ BuildInfo();
}
void Info(pcilib_t *handle, const pcilib_model_description_t *model_info, const char *target) {
@@ -1385,7 +1388,7 @@ int ReadData(pcilib_t *handle, ACCESS_MODE mode, FLAGS flags, pcilib_dma_engine_
int ReadRegister(pcilib_t *handle, const pcilib_model_description_t *model_info, const char *bank, const char *reg, const char *view, const char *unit, const char *attr) {
int i;
int err;
- const char *format;
+ const char *format;
pcilib_register_bank_t bank_id;
pcilib_register_bank_addr_t bank_addr = 0;
@@ -1699,23 +1702,19 @@ int WriteRegister(pcilib_t *handle, const pcilib_model_description_t *model_info
err = pcilib_write_register(handle, bank, reg, value);
if (err) Error("Error writting register %s\n", reg);
- if ((model_info->registers[regid].mode&PCILIB_REGISTER_RW) == PCILIB_REGISTER_RW) {
+ if ((model_info->registers[regid].mode&(PCILIB_REGISTER_RW|PCILIB_REGISTER_INCONSISTENT)) == PCILIB_REGISTER_RW) {
const char *format = (val.format?val.format:"%u");
-
- if(!((model_info->registers[regid].mode&PCILIB_REGISTER_INCONSISTENT) == PCILIB_REGISTER_INCONSISTENT))
- {
- err = pcilib_read_register(handle, bank, reg, &verify);
- if (err) Error("Error reading back register %s for verification\n", reg);
-
- if ( verify != value) {
- Error("Failed to write register %s: %lu is written and %lu is read back", reg, value, verify);
- } else {
- printf("%s = ", reg);
- printf(format, verify);
- printf("\n");
- }
- }
+ err = pcilib_read_register(handle, bank, reg, &verify);
+ if (err) Error("Error reading back register %s for verification\n", reg);
+
+ if (verify != value) {
+ Error("Failed to write register %s: %lu is written and %lu is read back", reg, value, verify);
+ } else {
+ printf("%s = ", reg);
+ printf(format, verify);
+ printf("\n");
+ }
} else {
printf("%s is written\n ", reg);
}