• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef SOC_PERF_HANDLER_H
17 #define SOC_PERF_HANDLER_H
18 
19 #include <unistd.h>
20 #include <unordered_map>
21 #include <stdlib.h>
22 #include <algorithm>
23 #include <climits>
24 #include "event_handler.h"
25 #include "event_runner.h"
26 #include "socperf_common.h"
27 
28 namespace OHOS {
29 namespace SOCPERF {
30 class SocPerfHandler : public AppExecFwk::EventHandler {
31 public:
32     explicit SocPerfHandler(const std::shared_ptr<AppExecFwk::EventRunner>& runner);
33     virtual ~SocPerfHandler() override;
34     virtual void ProcessEvent(const AppExecFwk::InnerEvent::Pointer& event) override;
35 
36 private:
37     std::unordered_map<int, std::shared_ptr<ResNode>> resNodeInfo;
38     std::unordered_map<int, std::shared_ptr<GovResNode>> govResNodeInfo;
39     std::unordered_map<int, std::shared_ptr<ResStatus>> resStatusInfo;
40     bool powerLimitBoost = false;
41     bool thermalLimitBoost = false;
42 
43 private:
44     void UpdateResActionList(int resId, std::shared_ptr<ResAction> resAction, bool delayed);
45     void UpdateCandidatesValue(int resId, int type);
46     void ArbitrateCandidate(int resId);
47     void ArbitratePairRes(int resId);
48     void UpdatePairResValue(int minResId, int minResValue, int maxResId, int maxResValue);
49     void UpdateCurrentValue(int resId, int value);
50     void WriteNode(std::string path, std::string value);
51     bool ExistNoCandidate(int resId, std::shared_ptr<ResStatus> resStatus, int perf, int power, int thermal);
52     bool IsGovResId(int resId);
53     bool IsValidResId(int resId);
54 };
55 } // namespace SOCPERF
56 } // namespace OHOS
57 
58 #endif