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 #include "pm_state_c.h"
17 
18 #undef LOG_TAG
19 #define LOG_TAG "PurgeableMemC: state"
20 
21 static const char * const PMStateNames[PM_ERR_TYPES] = {
22     "OK",
23     "BuilderPtrNULL",
24     "MmapPurgMemFail",
25     "MmapUxptFail",
26     "UnmapPurgMemSucc",
27     "UnmapPurgMemFail",
28     "UnmapUxptFail",
29     "UxpteOutOfRange",
30     "UxptePresentDataPurged",
31     "UxpteNoPresent",
32     "LockInitFail",
33     "ReadLockSucc",
34     "ReadLockFail",
35     "WriteLockFail",
36     "ReadUnlockFail",
37     "WriteUnlockFail",
38     "DataPurged",
39     "DataNoPurged",
40     "BuilderBuildAllSucc",
41     "BuilderBuildAllFail",
42     "BuilderDestoryFailed",
43 };
44 
GetPMStateName(PMState state)45 const char *GetPMStateName(PMState state)
46 {
47     if (state < 0 || state >= PM_ERR_TYPES) {
48         return "NONE";
49     }
50     return PMStateNames[state];
51 }
52