aboutsummaryrefslogtreecommitdiff
path: root/tuning
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@linux.intel.com>2010-11-26 14:14:10 -0800
committerArjan van de Ven <arjan@linux.intel.com>2010-11-26 14:14:10 -0800
commit7d136e896093c7bf71c3f15cafc55761b255296b (patch)
tree7981348ba55ceb2471d8c2880caddb337878b01c /tuning
parent89859fd990c8f73e246b83f2405ef7bc5250049b (diff)
downloadpowertop-7d136e896093c7bf71c3f15cafc55761b255296b.tar.gz
start sysfs tunables...
Diffstat (limited to 'tuning')
-rw-r--r--tuning/sysfs.cpp35
-rw-r--r--tuning/sysfs.h39
-rw-r--r--tuning/tunable.cpp16
-rw-r--r--tuning/tunable.h36
4 files changed, 118 insertions, 8 deletions
diff --git a/tuning/sysfs.cpp b/tuning/sysfs.cpp
new file mode 100644
index 0000000..26d5c88
--- /dev/null
+++ b/tuning/sysfs.cpp
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2010, Intel Corporation
+ *
+ * This file is part of PowerTOP
+ *
+ * This program file is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program in a file named COPYING; if not, write to the
+ * Free Software Foundation, Inc,
+ * 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ * or just google for it.
+ *
+ * Authors:
+ * Arjan van de Ven <arjan@linux.intel.com>
+ */
+
+#include "tuning.h"
+#include "tunable.h"
+#include "sysfs.h"
+#include <string.h>
+
+
+sysfs_tunable::sysfs_tunable(const char *str, const char *sysfs_path, const char *target_content)
+{
+ tunable::tunable(str, 1.0, "Good", "Bad", "Unknown");
+}
diff --git a/tuning/sysfs.h b/tuning/sysfs.h
new file mode 100644
index 0000000..e37b711
--- /dev/null
+++ b/tuning/sysfs.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2010, Intel Corporation
+ *
+ * This file is part of PowerTOP
+ *
+ * This program file is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program in a file named COPYING; if not, write to the
+ * Free Software Foundation, Inc,
+ * 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ * or just google for it.
+ *
+ * Authors:
+ * Arjan van de Ven <arjan@linux.intel.com>
+ */
+#ifndef _INCLUDE_GUARD_SYSFS_TUNE_H
+#define _INCLUDE_GUARD_SYSFS_TUNE_H
+
+#include <vector>
+
+#include "tunable.h"
+
+using namespace std;
+
+class sysfs_tunable : tunable {
+public:
+ sysfs_tunable(const char *str, const char *sysfs_path, const char *target_content);
+};
+
+#endif
diff --git a/tuning/tunable.cpp b/tuning/tunable.cpp
index a561ad9..41f9eae 100644
--- a/tuning/tunable.cpp
+++ b/tuning/tunable.cpp
@@ -28,9 +28,21 @@
#include <string.h>
-tunable::tunable(const char *str, bool _value, double _score)
+tunable::tunable(const char *str, double _score, const char *good, const char *bad, const char *neutral)
{
- value = _value;
score = _score;
strcpy(desc, str);
+ strcpy(good_string, good);
+ strcpy(bad_string, bad);
+ strcpy(neutral_string, neutral);
}
+
+
+tunable::tunable(void)
+{
+ score = 0;
+ desc[0] = 0;
+ strcpy(good_string, "Good");
+ strcpy(bad_string, "Bad");
+ strcpy(neutral_string, "Unknown");
+} \ No newline at end of file
diff --git a/tuning/tunable.h b/tuning/tunable.h
index ebe59a4..883331b 100644
--- a/tuning/tunable.h
+++ b/tuning/tunable.h
@@ -29,18 +29,42 @@
using namespace std;
+#define TUNE_GOOD 1
+#define TUNE_BAD -1
+#define TUNE_UNKNOWN 0
+#define TUNE_NEUTRAL 0
+
class tunable {
- double score;
- bool value;
char desc[4096];
- void *toggle_data;
+ char good_string[128];
+ char bad_string[128];
+ char neutral_string[128];
public:
- tunable(const char *str, bool _value, double _score);
+ double score;
+
+ tunable(void);
+ tunable(const char *str, double _score, const char *good = "", const char *bad = "", const char *neutral ="");
+
+ virtual int good_bad(void) { return TUNE_NEUTRAL; }
+
+ virtual char *result_string(void)
+ {
+ switch (good_bad()) {
+ case TUNE_GOOD:
+ return good_string;
+ case TUNE_BAD:
+ return bad_string;
+ }
+ return neutral_string;
+ }
+
+
+ virtual const char *description(void) { return desc; };
- const char *description(void);
+ virtual void toggle(void) { };
};
-vector<class tunable *> all_tunables;
+extern vector<class tunable *> all_tunables;
#endif