[M120 Migration][VD] Enable direct rendering for TVPlus
[platform/framework/web/chromium-efl.git] / components / power_metrics / smc_internal_types_mac.h
1 // Copyright 2021 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_POWER_METRICS_SMC_INTERNAL_TYPES_MAC_H_
6 #define COMPONENTS_POWER_METRICS_SMC_INTERNAL_TYPES_MAC_H_
7
8 #import <Foundation/Foundation.h>
9 #include <stdint.h>
10
11 // List of known SMC key identifiers.
12 //
13 // This is a good reference: https://logi.wiki/index.php/SMC_Sensor_Codes
14 // Additional keys can be discovered with
15 // https://github.com/theopolis/smc-fuzzer
16 enum class SMCKeyIdentifier : uint32_t {
17   TotalPower = 'PSTR',      // Power: System Total Rail (watts)
18   CPUPower = 'PCPC',        // Power: CPU Package CPU (watts)
19   iGPUPower = 'PCPG',       // Power: CPU Package GPU (watts)
20   GPU0Power = 'PG0R',       // Power: GPU 0 Rail (watts)
21   GPU1Power = 'PG1R',       // Power: GPU 1 Rail (watts)
22   CPUTemperature = 'TC0F',  // Temperature: CPU Die PECI (Celsius)
23 };
24
25 // Types from PowerManagement/pmconfigd/PrivateLib.c
26 // (https://opensource.apple.com/source/PowerManagement/PowerManagement-494.1.2/pmconfigd/PrivateLib.c.auto.html)
27 struct SMCVersion {
28   unsigned char major;
29   unsigned char minor;
30   unsigned char build;
31   unsigned char reserved;
32   unsigned short release;
33 };
34
35 struct SMCPLimitData {
36   uint16_t version;
37   uint16_t length;
38   uint32_t cpuPLimit;
39   uint32_t gpuPLimit;
40   uint32_t memPLimit;
41 };
42
43 enum class SMCDataType : uint32_t {
44   flt = 'flt ',   // Floating point
45   sp78 = 'sp78',  // Fixed point: SIIIIIIIFFFFFFFF
46   sp87 = 'sp87',  // Fixed point: SIIIIIIIIFFFFFFF
47   spa5 = 'spa5',  // Fixed point: SIIIIIIIIIIFFFFF
48 };
49
50 struct SMCKeyInfoData {
51   IOByteCount dataSize;
52   SMCDataType dataType;
53   uint8_t dataAttributes;
54 };
55
56 struct SMCParamStruct {
57   SMCKeyIdentifier key;
58   SMCVersion vers;
59   SMCPLimitData pLimitData;
60   SMCKeyInfoData keyInfo;
61   uint8_t result;
62   uint8_t status;
63   uint8_t data8;
64   uint32_t data32;
65   uint8_t bytes[32];
66 };
67
68 enum {
69   kSMCUserClientOpen = 0,
70   kSMCUserClientClose = 1,
71   kSMCHandleYPCEvent = 2,
72   kSMCReadKey = 5,
73   kSMCWriteKey = 6,
74   kSMCGetKeyCount = 7,
75   kSMCGetKeyFromIndex = 8,
76   kSMCGetKeyInfo = 9
77 };
78
79 #endif  // COMPONENTS_POWER_METRICS_SMC_INTERNAL_TYPES_MAC_H_