]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/arm-ds5-gator.git/blobdiff - daemon/Collector.cpp
daemon: Fix counters initialisation
[android-sdk/arm-ds5-gator.git] / daemon / Collector.cpp
index c6f837628f14b30e174bc33ec6471e93390f68d3..7a41198e5cb4e1a7d0a96ea198d076e6ed384698 100644 (file)
@@ -46,10 +46,14 @@ Collector::Collector() {
 
        getCoreName();
 
+       enablePerfCounters();
+
        // Read unchanging keys from driver which are created at insmod'ing of gator.ko
        for (int i = 0; i < MAX_PERFORMANCE_COUNTERS; i++) {
-               snprintf(text, sizeof(text), "events/%s/key", gSessionData->mPerfCounterType[i]);
-               readIntDriver(text, &gSessionData->mPerfCounterKey[i]);
+               if (gSessionData->mPerfCounterEnabled[i]) {
+                       snprintf(text, sizeof(text), "events/%s/key", gSessionData->mPerfCounterType[i]);
+                       readIntDriver(text, &gSessionData->mPerfCounterKey[i]);
+               }
        }
 }
 
@@ -64,6 +68,21 @@ Collector::~Collector() {
 }
 
 void Collector::enablePerfCounters() {
+       char text[sizeof(gSessionData->mPerfCounterType[0]) + 30]; // sufficiently large to hold all /dev/gator/events/<types>/enabled
+       for (int i=0; i<MAX_PERFORMANCE_COUNTERS; i++) {
+               if (!gSessionData->mPerfCounterEnabled[i]) {
+                       continue;
+               }
+               snprintf(text, sizeof(text), "events/%s/enabled", gSessionData->mPerfCounterType[i]);
+               if (writeReadDriver(text, &gSessionData->mPerfCounterEnabled[i])) {
+                       // Disable those events that don't exist on this hardware platform even though they exist in configuration.xml
+                       gSessionData->mPerfCounterEnabled[i] = 0;
+                       continue;
+               }
+       }
+}
+
+void Collector::setupPerfCounters() {
        char base[sizeof(gSessionData->mPerfCounterType[0]) + 10]; // sufficiently large to hold all events/<types>
        char text[sizeof(gSessionData->mPerfCounterType[0]) + 20]; // sufficiently large to hold all events/<types>/<file>
 
@@ -86,10 +105,6 @@ void Collector::enablePerfCounters() {
                                handleException();
                        }
                }
-               snprintf(text, sizeof(text), "%s/enabled", base);
-               if (writeReadDriver(text, &gSessionData->mPerfCounterEnabled[i])) {
-                       gSessionData->mPerfCounterEnabled[i] = 0;
-               }
        }
 }