summaryrefslogtreecommitdiff
path: root/dumpstate
diff options
context:
space:
mode:
authorSteven Moreland <smoreland@google.com>2016-12-15 16:21:29 -0800
committerFelipe Leme <felipeal@google.com>2017-01-09 17:47:14 -0800
commit5de636642b2352d0f43a15cddff0bfbcd37c639a (patch)
treed8b783ea7dcccadbb08b9e22381de65fc6c6fa50 /dumpstate
parentb1ff0c0a6a57cae814c6eb50f8f6d344ff614422 (diff)
downloadbullhead-5de636642b2352d0f43a15cddff0bfbcd37c639a.tar.gz
Dumpstate: convert to hidl implementation.
Bug: 31982882 Test: bug report runs on device Change-Id: Ic14a3f325c41f064eb45d7584cd286d283cb51bf
Diffstat (limited to 'dumpstate')
-rw-r--r--dumpstate/Android.mk29
-rw-r--r--dumpstate/DumpstateDevice.cpp74
-rw-r--r--dumpstate/DumpstateDevice.h50
-rw-r--r--dumpstate/NOTICE2
-rw-r--r--dumpstate/android.hardware.dumpstate@1.0-service.bullhead.rc4
-rw-r--r--dumpstate/dumpstate.cpp41
-rw-r--r--dumpstate/service.cpp35
7 files changed, 185 insertions, 50 deletions
diff --git a/dumpstate/Android.mk b/dumpstate/Android.mk
index 10b8725..7cb9c88 100644
--- a/dumpstate/Android.mk
+++ b/dumpstate/Android.mk
@@ -1,4 +1,4 @@
-# Copyright (C) 2015 The Android Open Source Project
+# Copyright (C) 2016 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -12,15 +12,28 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_STATIC_LIBRARIES := libdumpstateheaders
+LOCAL_PATH := $(call my-dir)
-LOCAL_SRC_FILES := dumpstate.cpp
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.dumpstate@1.0-service.bullhead
+LOCAL_INIT_RC := android.hardware.dumpstate@1.0-service.bullhead.rc
+LOCAL_MODULE_RELATIVE_PATH := hw
+LOCAL_SRC_FILES := \
+ DumpstateDevice.cpp \
+ service.cpp
-LOCAL_MODULE := libdumpstate.bullhead
+LOCAL_SHARED_LIBRARIES := \
+ android.hardware.dumpstate@1.0 \
+ libbase \
+ libcutils \
+ libdumpstateutil \
+ libhidlbase \
+ libhidltransport \
+ libhwbinder \
+ liblog \
+ libutils
LOCAL_MODULE_TAGS := optional
+LOCAL_PROPRIETARY_MODULE := true
-include $(BUILD_STATIC_LIBRARY)
+include $(BUILD_EXECUTABLE)
diff --git a/dumpstate/DumpstateDevice.cpp b/dumpstate/DumpstateDevice.cpp
new file mode 100644
index 0000000..e349679
--- /dev/null
+++ b/dumpstate/DumpstateDevice.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "dumpstate"
+
+#include "DumpstateDevice.h"
+
+#include <log/log.h>
+
+#include "DumpstateUtil.h"
+
+using android::os::dumpstate::CommandOptions;
+using android::os::dumpstate::DumpFileToFd;
+using android::os::dumpstate::RunCommandToFd;
+
+namespace android {
+namespace hardware {
+namespace dumpstate {
+namespace V1_0 {
+namespace implementation {
+
+// Methods from ::android::hardware::dumpstate::V1_0::IDumpstateDevice follow.
+Return<void> DumpstateDevice::dumpstateBoard(const hidl_handle& handle) {
+ if (handle->numFds < 1) {
+ ALOGE("no FDs\n");
+ return Void();
+ }
+
+ int fd = handle->data[0];
+ if (fd < 0) {
+ ALOGE("invalid FD: %d\n", handle->data[0]);
+ return Void();
+ }
+
+ DumpFileToFd(fd, "INTERRUPTS", "/proc/interrupts");
+ DumpFileToFd(fd, "RPM Stats", "/d/rpm_stats");
+ DumpFileToFd(fd, "Power Management Stats", "/d/rpm_master_stats");
+ RunCommandToFd(fd, "SUBSYSTEM TOMBSTONES", {"ls", "-l", "/data/tombstones/ramdump"} , CommandOptions::AS_ROOT);
+ DumpFileToFd(fd, "BAM DMUX Log", "/d/ipc_logging/bam_dmux/log");
+ DumpFileToFd(fd, "SMD Log", "/d/ipc_logging/smd/log");
+ DumpFileToFd(fd, "SMD PKT Log", "/d/ipc_logging/smd_pkt/log");
+ DumpFileToFd(fd, "IPC Router Log", "/d/ipc_logging/ipc_router/log");
+ RunCommandToFd(fd, "ION HEAPS", {"/system/bin/sh", "-c", "for d in $(ls -d /d/ion/*); do for f in $(ls $d); do echo --- $d/$f; cat $d/$f; done; done"});
+ DumpFileToFd(fd, "dmabuf info", "/d/dma_buf/bufinfo");
+ DumpFileToFd(fd, "Battery Type", "/sys/class/power_supply/bms/battery_type");
+ RunCommandToFd(fd, "Temperatures", {"/system/bin/sh", "-c", "for f in emmc_therm msm_therm pa_therm0 xo_therm ; do echo -n \"$f : \" ; cat /sys/class/hwmon/hwmon2/device/$f ; done ; for f in `ls /sys/class/thermal` ; do type=`cat /sys/class/thermal/$f/type` ; temp=`cat /sys/class/thermal/$f/temp` ; echo \"$type: $temp\" ; done"}, CommandOptions::AS_ROOT);
+ DumpFileToFd(fd, "dmesg-ramoops-0", "/sys/fs/pstore/dmesg-ramoops-0");
+ DumpFileToFd(fd, "dmesg-ramoops-1", "/sys/fs/pstore/dmesg-ramoops-1");
+ DumpFileToFd(fd, "LITTLE cluster time-in-state", "/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state");
+ RunCommandToFd(fd, "LITTLE cluster cpuidle", {"/system/bin/sh", "-c", "for d in $(ls -d /sys/devices/system/cpu/cpu0/cpuidle/state*); do echo \"$d: `cat $d/name` `cat $d/desc` `cat $d/time` `cat $d/usage`\"; done"}, CommandOptions::AS_ROOT);
+ DumpFileToFd(fd, "big cluster time-in-state", "/sys/devices/system/cpu/cpu4/cpufreq/stats/time_in_state");
+ RunCommandToFd(fd,"big cluster cpuidle", {"/system/bin/sh", "-c", "for d in $(ls -d /sys/devices/system/cpu/cpu4/cpuidle/state*); do echo \"$d: `cat $d/name` `cat $d/desc` `cat $d/time` `cat $d/usage`\"; done"}, CommandOptions::AS_ROOT);
+
+ return Void();
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace dumpstate
+} // namespace hardware
+} // namespace android
diff --git a/dumpstate/DumpstateDevice.h b/dumpstate/DumpstateDevice.h
new file mode 100644
index 0000000..f8585f5
--- /dev/null
+++ b/dumpstate/DumpstateDevice.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef ANDROID_HARDWARE_DUMPSTATE_V1_0_DUMPSTATEDEVICE_H
+#define ANDROID_HARDWARE_DUMPSTATE_V1_0_DUMPSTATEDEVICE_H
+
+#include <android/hardware/dumpstate/1.0/IDumpstateDevice.h>
+#include <hidl/MQDescriptor.h>
+#include <hidl/Status.h>
+
+namespace android {
+namespace hardware {
+namespace dumpstate {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::dumpstate::V1_0::IDumpstateDevice;
+using ::android::hardware::hidl_array;
+using ::android::hardware::hidl_handle;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::sp;
+
+struct DumpstateDevice : public IDumpstateDevice {
+ // Methods from ::android::hardware::dumpstate::V1_0::IDumpstateDevice follow.
+ Return<void> dumpstateBoard(const hidl_handle& h) override;
+
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace dumpstate
+} // namespace hardware
+} // namespace android
+
+#endif // ANDROID_HARDWARE_DUMPSTATE_V1_0_DUMPSTATEDEVICE_H
diff --git a/dumpstate/NOTICE b/dumpstate/NOTICE
index 1a5b8e4..e48dd6b 100644
--- a/dumpstate/NOTICE
+++ b/dumpstate/NOTICE
@@ -1,5 +1,5 @@
- Copyright (C) 2015 The Android Open Source Project
+ Copyright (C) 2016 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/dumpstate/android.hardware.dumpstate@1.0-service.bullhead.rc b/dumpstate/android.hardware.dumpstate@1.0-service.bullhead.rc
new file mode 100644
index 0000000..b114311
--- /dev/null
+++ b/dumpstate/android.hardware.dumpstate@1.0-service.bullhead.rc
@@ -0,0 +1,4 @@
+service dumpstate-1-0 /vendor/bin/hw/android.hardware.dumpstate@1.0-service.bullhead
+ class hal
+ user system
+ group system
diff --git a/dumpstate/dumpstate.cpp b/dumpstate/dumpstate.cpp
deleted file mode 100644
index 74c2f06..0000000
--- a/dumpstate/dumpstate.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <dumpstate.h>
-
-void dumpstate_board()
-{
- Dumpstate& ds = Dumpstate::GetInstance();
-
- ds.DumpFile("INTERRUPTS", "/proc/interrupts");
- ds.DumpFile("RPM Stats", "/d/rpm_stats");
- ds.DumpFile("Power Management Stats", "/d/rpm_master_stats");
- ds.RunCommand("SUBSYSTEM TOMBSTONES", {"ls", "-l", "/data/tombstones/ramdump"} , CommandOptions::AS_ROOT_5);
- ds.DumpFile("BAM DMUX Log", "/d/ipc_logging/bam_dmux/log");
- ds.DumpFile("SMD Log", "/d/ipc_logging/smd/log");
- ds.DumpFile("SMD PKT Log", "/d/ipc_logging/smd_pkt/log");
- ds.DumpFile("IPC Router Log", "/d/ipc_logging/ipc_router/log");
- ds.RunCommand("ION HEAPS", {"/system/bin/sh", "-c", "for d in $(ls -d /d/ion/*); do for f in $(ls $d); do echo --- $d/$f; cat $d/$f; done; done"});
- ds.DumpFile("dmabuf info", "/d/dma_buf/bufinfo");
- ds.DumpFile("Battery Type", "/sys/class/power_supply/bms/battery_type");
- ds.RunCommand("Temperatures", {"/system/bin/sh", "-c", "for f in emmc_therm msm_therm pa_therm0 xo_therm ; do echo -n \"$f : \" ; cat /sys/class/hwmon/hwmon2/device/$f ; done ; for f in `ls /sys/class/thermal` ; do type=`cat /sys/class/thermal/$f/type` ; temp=`cat /sys/class/thermal/$f/temp` ; echo \"$type: $temp\" ; done"}, CommandOptions::AS_ROOT_5);
- ds.DumpFile("dmesg-ramoops-0", "/sys/fs/pstore/dmesg-ramoops-0");
- ds.DumpFile("dmesg-ramoops-1", "/sys/fs/pstore/dmesg-ramoops-1");
- ds.DumpFile("LITTLE cluster time-in-state", "/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state");
- ds.RunCommand("LITTLE cluster cpuidle", {"/system/bin/sh", "-c", "for d in $(ls -d /sys/devices/system/cpu/cpu0/cpuidle/state*); do echo \"$d: `cat $d/name` `cat $d/desc` `cat $d/time` `cat $d/usage`\"; done"}, CommandOptions::AS_ROOT_5);
- ds.DumpFile("big cluster time-in-state", "/sys/devices/system/cpu/cpu4/cpufreq/stats/time_in_state");
- ds.RunCommand("big cluster cpuidle", {"/system/bin/sh", "-c", "for d in $(ls -d /sys/devices/system/cpu/cpu4/cpuidle/state*); do echo \"$d: `cat $d/name` `cat $d/desc` `cat $d/time` `cat $d/usage`\"; done"}, CommandOptions::AS_ROOT_5);
-};
diff --git a/dumpstate/service.cpp b/dumpstate/service.cpp
new file mode 100644
index 0000000..06bb5fb
--- /dev/null
+++ b/dumpstate/service.cpp
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#define LOG_TAG "android.hardware.dumpstate@1.0-service.bullhead"
+
+#include <hidl/HidlSupport.h>
+#include <hidl/HidlTransportSupport.h>
+
+#include "DumpstateDevice.h"
+
+using ::android::hardware::configureRpcThreadpool;
+using ::android::hardware::dumpstate::V1_0::IDumpstateDevice;
+using ::android::hardware::dumpstate::V1_0::implementation::DumpstateDevice;
+using ::android::hardware::joinRpcThreadpool;
+using ::android::sp;
+
+
+int main(int /* argc */, char* /* argv */ []) {
+ sp<IDumpstateDevice> dumpstate = new DumpstateDevice;
+ configureRpcThreadpool(1, true);
+ dumpstate->registerAsService("dumpstate");
+ joinRpcThreadpool();
+}