diff options
author | Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org> | 2016-01-16 19:35:43 +0100 |
---|---|---|
committer | Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org> | 2016-01-17 16:32:51 +0100 |
commit | b210d919c61127ca708c8dd117633ac2665f6db9 (patch) | |
tree | 7d90329a1b823a781d63c19ce36e7dafc3204e3e | |
parent | 180ac4fd196d169cd788ab13ccadf365d75d986b (diff) | |
download | powertop-2.0-linaro-android-upstream-rebase.tar.gz |
Apply Android patches and fix them up for Mlinaro-android-upstream-rebase
Change-Id: I18b5eec76213491f041bcb6c44a0d621c8501544
Signed-off-by: Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Android.mk | 49 | ||||
-rw-r--r-- | src/cpu/intel_cpus.h | 1 | ||||
-rw-r--r-- | src/css.h | 269 | ||||
-rw-r--r-- | src/devices/ahci.cpp | 5 | ||||
-rw-r--r-- | src/devices/alsa.cpp | 8 | ||||
-rw-r--r-- | src/devices/network.cpp | 1 | ||||
-rw-r--r-- | src/lib.cpp | 6 | ||||
-rw-r--r-- | src/lib.h | 3 | ||||
-rw-r--r-- | src/main.cpp | 4 | ||||
-rw-r--r-- | src/report/report.cpp | 5 | ||||
-rw-r--r-- | src/tuning/tuningusb.cpp | 1 |
12 files changed, 337 insertions, 16 deletions
@@ -80,7 +80,6 @@ Makefile.in /po/remove-potcdate.sin /po/stamp-po /remove-potcdate.sed -/src/css.h /src/powertop /stamp-h1 /stamp-po @@ -1,17 +1,35 @@ +# Please run this before building +# ./src/csstoh.sh src/powertop.css src/css.h + LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE_TAGS := debug -LOCAL_SHARED_LIBRARIES := libstlport \ - libnl \ - libpci \ - libtraceevnet \ -LOCAL_MODULE := powertop +LOCAL_SHARED_LIBRARIES := libnl + +LOCAL_MODULE := powertop #LOCAL_CFLAGS += -Wall -O2 -g -fno-omit-frame-pointer -fstack-protector -Wshadow -Wformat -D_FORTIFY_SOURCE=2 #LOCAL_CPPFLAGS += -Wall -O2 -g -fno-omit-frame-pointer -LOCAL_C_INCLUDES += external/stlport/stlport/ external/stlport/stlport/stl external/stlport/stlport/using/h/ bionic external/libnl/include/ +LOCAL_CFLAGS += -fexceptions -DHAVE_LIBNL20 +LOCAL_CPPFLAGS += -DPACKAGE_VERSION=\"2.8\" -DPACKAGE=powertop -DHAVE_LIBNL20 -DHAVE_NO_PCI + +LOCAL_C_INCLUDES += bionic external/libnl/include/ + +# ncurses +LOCAL_C_INCLUDES += external/ncurses/include/ +LOCAL_STATIC_LIBRARIES += libncurses + +# pciutils +#LOCAL_C_INCLUDES += external/pciutils/include/ +#LOCAL_STATIC_LIBRARIES += libpci_static + +# libtraceevent +LOCAL_C_INCLUDES += $(LOCAL_PATH)/traceevent/ + +# local includes +LOCAL_C_INCLUDES += $(LOCAL_PATH)/src/ LOCAL_SRC_FILES += \ src/parameters/parameters.cpp \ @@ -21,10 +39,11 @@ LOCAL_SRC_FILES += \ src/process/work.cpp \ src/process/process.cpp \ src/process/timer.cpp \ - src/process/device.cpp \ + src/process/processdevice.cpp \ src/process/interrupt.cpp \ src/process/do_process.cpp \ src/cpu/intel_cpus.cpp \ + src/cpu/intel_gpu.cpp \ src/cpu/cpu.cpp \ src/cpu/cpu_linux.cpp \ src/cpu/cpudevice.cpp \ @@ -34,24 +53,29 @@ LOCAL_SRC_FILES += \ src/cpu/cpu_rapl_device.cpp \ src/cpu/dram_rapl_device.cpp \ src/cpu/rapl/rapl_interface.cpp \ + src/measurement/opal-sensors.cpp \ src/measurement/measurement.cpp \ src/measurement/acpi.cpp \ src/measurement/extech.cpp \ src/measurement/sysfs.cpp \ src/display.cpp \ - src/report.cpp \ + src/report/report.cpp \ + src/report/report-maker.cpp \ + src/report/report-formatter-base.cpp \ + src/report/report-formatter-csv.cpp \ + src/report/report-formatter-html.cpp \ + src/report/report-data-html.cpp \ src/main.cpp \ src/tuning/tuning.cpp \ src/tuning/tuningi2c.cpp \ - src/tuning/usb.cpp \ + src/tuning/tuningusb.cpp \ src/tuning/bluetooth.cpp \ src/tuning/ethernet.cpp \ src/tuning/runtime.cpp \ src/tuning/iw.c \ src/tuning/iw.h \ src/tuning/tunable.cpp \ - src/tuning/sysfs.cpp \ - src/tuning/cpufreq.cpp \ + src/tuning/tuningsysfs.cpp \ src/tuning/wifi.cpp \ src/perf/perf_bundle.cpp \ src/perf/perf.cpp \ @@ -67,12 +91,11 @@ LOCAL_SRC_FILES += \ src/devices/network.cpp \ src/devices/device.cpp \ src/devices/gpu_rapl_device.cpp \ + src/devices/devfreq.cpp \ src/devlist.cpp \ src/calibrate/calibrate.cpp \ src/lib.cpp \ traceevent/event-parse.c \ - traceevent/event-parse.h \ - traceevent/event-utils.h \ traceevent/parse-filter.c \ traceevent/parse-utils.c \ traceevent/trace-seq.c diff --git a/src/cpu/intel_cpus.h b/src/cpu/intel_cpus.h index 0331069..830f06b 100644 --- a/src/cpu/intel_cpus.h +++ b/src/cpu/intel_cpus.h @@ -55,6 +55,7 @@ protected: DIR *dir; public: intel_util(); + virtual ~intel_util() {}; virtual void byt_has_ahci(); virtual int get_byt_ahci_support(); }; diff --git a/src/css.h b/src/css.h new file mode 100644 index 0000000..c8b32ae --- /dev/null +++ b/src/css.h @@ -0,0 +1,269 @@ +#ifndef __INCLUDE_GUARD_CCS_H +#define __INCLUDE_GUARD_CCS_H + +const char css[] = + "<!DOCTYPE html>\n" + "<html lang='en'>\n" + "<head>\n" + "<title>PowerTOP report</title>\n" + "<meta http-equiv='content-type' content='text/html;charset=utf-8'>\n" + "\n" + "<script type='text/javascript'>\n" + "\n" + "var powertop = {\n" + "blocks: {\n" + "summary: 'Summary',\n" + "cpuidle: 'CPU Idle',\n" + "cpufreq: 'CPU Frequency',\n" + "software: 'Software Info',\n" + "devinfo: 'Device Info',\n" + "tuning: 'Tuning',\n" + "ahci: 'AHCI'\n" + "},\n" + "cadd: function(idx, c){\n" + "var el = document.getElementById(idx);\n" + "if (el) {\n" + "var cn = el.className;\n" + "if (cn.indexOf(c) != -1)\n" + "return;\n" + "cn += ' ' + c;\n" + "el.className = cn;\n" + "}\n" + "},\n" + "crm: function(id, c){\n" + "var el = document.getElementById(id);\n" + "if (el) {\n" + "var cn = el.className\n" + "while (cn.indexOf(' ' + c) != -1)\n" + "cn = cn.replace(' ' + c,'');\n" + "el.className = cn;\n" + "}\n" + "},\n" + "newbutton: function(id, txt) {\n" + "var x = document.createElement('div');\n" + "x.id = id + '_button';\n" + "x.className = 'nav_button';\n" + "x.textContent = txt;\n" + "x.innerText = txt;\n" + "x.onclick = function() { powertop.toggle(id); };\n" + "return x;\n" + "},\n" + "setupbuttons: function() {\n" + "var t = document.getElementById('main_menu');\n" + "if (t) {\n" + "for (var b in powertop.blocks) {\n" + "t.appendChild(powertop.newbutton(b, powertop.blocks[b]));\n" + "}\n" + "t.appendChild(powertop.newbutton('all', 'All'));\n" + "}\n" + "},\n" + "toggle: function(b) {\n" + "powertop.baseall();\n" + "if (b == 'all') {\n" + "for (var c in powertop.blocks) {\n" + "powertop.crm(c, 'hide');\n" + "}\n" + "} else {\n" + "powertop.crm(b, 'hide');\n" + "}\n" + "powertop.cadd(b + '_button', 'pressed');\n" + "},\n" + "baseall: function() {\n" + "for (var b in powertop.blocks) {\n" + "powertop.cadd(b, 'hide');\n" + "powertop.crm(b + '_button', 'pressed');\n" + "}\n" + "powertop.cadd('all', 'hide');\n" + "powertop.crm('all_button', 'pressed');\n" + "},\n" + "onload: function() {\n" + "powertop.setupbuttons();\n" + "powertop.toggle('summary');\n" + "}\n" + "}\n" + "</script>\n" + "\n" + "<style type='text/css'>\n" + "/* General CSS */\n" + "*{\n" + "margin:0px;\n" + "padding:0px;\n" + "width: auto;\n" + "}\n" + "\n" + "body {\n" + "background-color: #eee; /* Background color */\n" + "color: #222; /* Font color */\n" + "font-family: Helvetica;\n" + "font-size: 14px;\n" + "}\n" + "\n" + "#main_container{\n" + "margin: 2px auto;\n" + "}\n" + "\n" + "/* Top logo & system table css */\n" + "#main_header{\n" + "min-width: 960px;\n" + "}\n" + "\n" + "img.pwtop_logo{\n" + "float:left;\n" + "height:40%;\n" + "width: 40%;\n" + "padding:20px;\n" + "}\n" + "\n" + ".sys_info\n" + "{\n" + "float: right;\n" + "height:116px;\n" + "width:450px;\n" + "font-size: 12px;\n" + "text-align: left;\n" + "}\n" + "\n" + "th{\n" + "text-align: left;\n" + "}\n" + "\n" + "/* CSS Main Content */\n" + "\n" + ".content_title\n" + "{\n" + "color: #296629;\n" + "padding:0px;\n" + "margin:2px;\n" + "}\n" + "\n" + "#chart_div{\n" + "float: left;\n" + "}\n" + "\n" + ".small\n" + "{\n" + "font-size: 10px;\n" + "}\n" + "\n" + "table.emphasis2\n" + "{\n" + "font-size: 13px;\n" + "max-width:95%;\n" + "}\n" + "\n" + "\n" + "th.emph_title {\n" + "padding:5px;\n" + "}\n" + "\n" + "tr.emph1:nth-child(odd) {\n" + "background: #ffffff;\n" + "}\n" + "\n" + "tr.emph1:nth-child(even) {\n" + "background: #ebebeb;\n" + "}\n" + "\n" + "tr.tune:nth-child(odd) {\n" + "background: #fffcfc;\n" + "}\n" + "tr.tune:nth-child(even) {\n" + "background: #fff0f0;\n" + "}\n" + "\n" + "td.no_wrap:first-child {\n" + "white-space:nowrap;\n" + "}\n" + "\n" + ".side_by_side_left{\n" + "float:left;\n" + "}\n" + ".side_by_side_right{\n" + "float:right;\n" + "}\n" + "\n" + "#device{\n" + "display: inline-block;\n" + "}\n" + ".clear_block{\n" + "clear:both;\n" + "}\n" + "\n" + "td.package{\n" + "background-color: #e0ddfa; /*purple*/\n" + "}\n" + "\n" + "td.core{\n" + "background-color: #d1ddff; /*ccebff; /*blue*/\n" + "}\n" + "\n" + "td.cpu{\n" + "background-color: #ffffeb; /* yellow */\n" + "}\n" + "\n" + "th.title{\n" + "text-align: center;\n" + "/*border-bottom: 1px solid #666;*/\n" + "}\n" + "\n" + "\n" + "li.summary_list\n" + "{\n" + "display: inline;\n" + "padding: 5px;\n" + "background-color: #f6f6f9;\n" + "font-size: 12px;\n" + "}\n" + "\n" + "\n" + "\n" + "/* main menu css*/\n" + "#main_menu {\n" + "clear:both;\n" + "font-weight: bold;\n" + "padding: 5px 0;\n" + "text-align: left;\n" + "background-image: -webkit-gradient(linear, left top, left bottom,\n" + "from(#aaa), to(#eee));\n" + "background: -moz-linear-gradient(top, #aaa, #eee);\n" + "}\n" + "\n" + "\n" + "#main_menu div {\n" + "font-size: 12px;\n" + "font-weight: bold;\n" + "color: white;\n" + "}\n" + "\n" + "#main_menu div.nav_button {\n" + "margin: 0 0.2em;\n" + "display: inline;\n" + "cursor: pointer;\n" + "color: #223232;\n" + "font-size: 13px;\n" + "font-weight: bold;\n" + "padding: 5px;\n" + "text-align: center;\n" + "text-decoration: none;\n" + "}\n" + "\n" + "div.pressed {\n" + "border: -webkit-gradient(linear, left top, left bottom,\n" + "from(#b2ffb2), to(#e0ffe0));\n" + "border-width:0px 8px 0px 8px;\n" + "background: #999;\n" + "background-image: -webkit-gradient(linear, left top, left bottom,\n" + "from(#b2ffb2), to(#e0ffe0));\n" + "background: -moz-linear-gradient(top, #b2ffb2, #e0ffe0);\n" + "}\n" + "\n" + "div.hide {\n" + "display: none;\n" + "}\n" + "</style>\n" + "</head>\n" + "\n" + "<body onload='powertop.onload();'>\n" + "<div id=\"main_container\">\n" +; +#endif diff --git a/src/devices/ahci.cpp b/src/devices/ahci.cpp index b8adf72..29c4c81 100644 --- a/src/devices/ahci.cpp +++ b/src/devices/ahci.cpp @@ -162,7 +162,9 @@ void ahci::start_measurement(void) ifstream file; snprintf(filename, sizeof(filename), "%s/ahci_alpm_active", sysfs_path); +#ifndef ANDROID try { +#endif file.open(filename, ios::in); if (file) { file >> start_active; @@ -187,11 +189,12 @@ void ahci::start_measurement(void) file >> start_devslp; } file.close(); +#ifndef ANDROID } catch (std::ios_base::failure &c) { fprintf(stderr, "%s\n", c.what()); } - +#endif } void ahci::end_measurement(void) diff --git a/src/devices/alsa.cpp b/src/devices/alsa.cpp index 425b58a..a8f8543 100644 --- a/src/devices/alsa.cpp +++ b/src/devices/alsa.cpp @@ -87,7 +87,9 @@ void alsa::start_measurement(void) ifstream file; snprintf(filename, sizeof(filename), "%s/power_off_acct", sysfs_path); +#ifndef ANDROID try { +#endif file.open(filename, ios::in); if (file) { file >> start_inactive; @@ -100,10 +102,12 @@ void alsa::start_measurement(void) file >> start_active; } file.close(); +#ifndef ANDROID } catch (std::ios_base::failure &c) { fprintf(stderr, "%s\n", c.what()); } +#endif } void alsa::end_measurement(void) @@ -113,7 +117,9 @@ void alsa::end_measurement(void) double p; snprintf(filename, sizeof(filename), "%s/power_off_acct", sysfs_path); +#ifndef ANDROID try { +#endif file.open(filename, ios::in); if (file) { file >> end_inactive; @@ -126,10 +132,12 @@ void alsa::end_measurement(void) file >> end_active; } file.close(); +#ifndef ANDROID } catch (std::ios_base::failure &c) { fprintf(stderr, "%s\n", c.what()); } +#endif p = (end_active - start_active) / (0.001 + end_active + end_inactive - start_active - start_inactive) * 100.0; report_utilization(name, p); diff --git a/src/devices/network.cpp b/src/devices/network.cpp index f8f4212..66b8338 100644 --- a/src/devices/network.cpp +++ b/src/devices/network.cpp @@ -237,6 +237,7 @@ static int iface_link(const char *name) } +#define ethtool_cmd_speed(x) (((x)->speed_hi << 16) | (x)->speed) static int iface_speed(const char *name) { int sock; diff --git a/src/lib.cpp b/src/lib.cpp index 56e1681..758cf5c 100644 --- a/src/lib.cpp +++ b/src/lib.cpp @@ -53,7 +53,9 @@ extern "C" { #include <sys/stat.h> #include <dirent.h> #include <locale.h> +#ifdef ENABLE_NLS #include <libintl.h> +#endif #include <limits> #include <math.h> #include <ncurses.h> @@ -262,6 +264,7 @@ string read_sysfs_string(const char *format, const char *param) void align_string(char *buffer, size_t min_sz, size_t max_sz) { size_t sz; + char *buf = buffer; /** mbsrtowcs() allows NULL dst and zero sz, * comparing to mbstowcs(), which causes undefined @@ -274,8 +277,9 @@ void align_string(char *buffer, size_t min_sz, size_t max_sz) buffer[min_sz] = 0x00; return; } + while (sz < min_sz) { - strcat(buffer, " "); + strcat(buf, " "); sz++; } } @@ -25,7 +25,10 @@ #ifndef INCLUDE_GUARD_LIB_H #define INCLUDE_GUARD_LIB_H +#ifdef ENABLE_NLS #include <libintl.h> +#endif + #include <stdint.h> #include <stdlib.h> #include <cstring> diff --git a/src/main.cpp b/src/main.cpp index b60d7b5..af092b7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -45,7 +45,9 @@ #include "perf/perf.h" #include "perf/perf_bundle.h" #include "lib.h" +#ifndef ANDROID #include "../config.h" +#endif #include "devices/device.h" @@ -393,7 +395,9 @@ int main(int argc, char **argv) char workload[PATH_MAX] = {0}; int iterations = 1, auto_tune = 0; +#ifndef ANDROID set_new_handler(out_of_memory); +#endif setlocale (LC_ALL, ""); diff --git a/src/report/report.cpp b/src/report/report.cpp index ddb2e30..2771eac 100644 --- a/src/report/report.cpp +++ b/src/report/report.cpp @@ -38,6 +38,11 @@ #include <limits.h> #include "report-data-html.h" +// not in Android c-lib +#ifdef ANDROID +#define strchrnul strchr +#endif + using namespace std; struct reportstream reportout; diff --git a/src/tuning/tuningusb.cpp b/src/tuning/tuningusb.cpp index 3b7b2b1..9439ff1 100644 --- a/src/tuning/tuningusb.cpp +++ b/src/tuning/tuningusb.cpp @@ -33,6 +33,7 @@ #include <iostream> #include <fstream> #include <limits.h> +#include <ctype.h> #include "../lib.h" |