1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef _STORAGED_INFO_H_
18 #define _STORAGED_INFO_H_
19 
20 #include <string.h>
21 
22 #define FRIEND_TEST(test_case_name, test_name) \
23 friend class test_case_name##_##test_name##_Test
24 
25 using namespace std;
26 
27 class storage_info_t {
28 protected:
29     FRIEND_TEST(storaged_test, storage_info_t);
30     uint16_t eol;                   // pre-eol (end of life) information
31     uint16_t lifetime_a;            // device life time estimation (type A)
32     uint16_t lifetime_b;            // device life time estimation (type B)
33     string version;                 // version string
34     void publish();
35 public:
storage_info_t()36     storage_info_t() : eol(0), lifetime_a(0), lifetime_b(0) {}
~storage_info_t()37     virtual ~storage_info_t() {}
38     virtual bool report() = 0;
39 };
40 
41 class emmc_info_t : public storage_info_t {
42 private:
43     const string emmc_sysfs = "/sys/bus/mmc/devices/mmc0:0001/";
44     const string emmc_debugfs = "/d/mmc0/mmc0:0001/ext_csd";
45     const char* emmc_ver_str[9] = {
46         "4.0", "4.1", "4.2", "4.3", "Obsolete", "4.41", "4.5", "5.0", "5.1"
47     };
48 public:
~emmc_info_t()49     virtual ~emmc_info_t() {}
50     bool report();
51     bool report_sysfs();
52     bool report_debugfs();
53 };
54 
55 class ufs_info_t : public storage_info_t {
56 private:
57     const string health_file = "/sys/devices/soc/624000.ufshc/health";
58 public:
~ufs_info_t()59     virtual ~ufs_info_t() {}
60     bool report();
61 };
62 
63 void report_storage_health();
64 
65 #endif /* _STORAGED_INFO_H_ */
66