107f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh/*
207f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh**
307f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh** Copyright 2015, The Android Open Source Project
407f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh**
507f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh** Licensed under the Apache License, Version 2.0 (the "License");
607f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh** you may not use this file except in compliance with the License.
707f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh** You may obtain a copy of the License at
807f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh**
907f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh**     http://www.apache.org/licenses/LICENSE-2.0
1007f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh**
1107f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh** Unless required by applicable law or agreed to in writing, software
1207f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh** distributed under the License is distributed on an "AS IS" BASIS,
1307f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1407f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh** See the License for the specific language governing permissions and
1507f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh** limitations under the License.
1607f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh*/
1707f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh
1807f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh//
1907f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh// Helper class to perform cpu setup (if needed) prior to a profile collection.
2007f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh//
2107f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntoshclass HardwireCpuHelper {
2207f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh public:
2307f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh
2407f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh  // The constructor for this class checks to see if the 'mpdecision'
2507f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh  // service is running; if so (and if 'perform' is TRUE), then it
2607f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh  // disables the service and on-lines all of the available cores/cpus
2707f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh  // (anything listed in /sys/devices/system/cpu/possible). The
2807f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh  // destructor will re-enable the mpdecision service if it was
2907f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh  // previously disabled.
3028304eec2d815c3d92c65e7be822c3751a412d9eChih-Hung Hsieh  explicit HardwireCpuHelper(bool perform);
3107f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh  virtual ~HardwireCpuHelper();
3207f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh
3307f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh private:
3407f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh  bool mpdecision_stopped_;
3507f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh
3607f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh  // Collect the number of available cpus/cores from /sys/devices/system/cpu/possible
3707f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh  int GetNumCores();
3807f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh
3907f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh  // Returns TRUE if the system service 'mpdecision' is running
4007f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh  bool GetMpdecisionRunning();
4107f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh
4207f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh  // Online/offline the specified cpu
4307f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh  void OnlineCore(int whichCore, int onoff);
4407f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh
4507f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh  // Enable/disable the mpdecision service via the equivalent of
4607f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh  //   setprop ctl.start mpdecision
4707f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh  //   setprop ctl.stop mpdecision
4807f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh  void StopMpdecision();
4907f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh  void RestartMpdecision();
5007f00fd438a0c10bc6b2487352d09eb0a648db40Than McIntosh};
51