• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 CODE_SIGN_ATTR_UTILS_H
17 #define CODE_SIGN_ATTR_UTILS_H
18 
19 #include <stdint.h>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 #define MAX_OWNERID_LEN 64
26 #if defined(__LP64__)
27 #define XPM_REGION_LEN 0x100000000
28 #else
29 #define XPM_REGION_LEN 0x10000000
30 #endif
31 
32 #define MAX_OWNERID_LEN 64
33 
34 #define OWNERID_SYSTEM_TAG "SYSTEM_LIB_ID"
35 #define OWNERID_DEBUG_TAG  "DEBUG_LIB_ID"
36 #define OWNERID_SHARED_TAG "SHARED_LIB_ID"
37 #define OWNERID_COMPAT_TAG "COMPAT_LIB_ID"
38 
39 enum FileOwneridType {
40     FILE_OWNERID_UNINT = 0,
41     FILE_OWNERID_SYSTEM,
42     FILE_OWNERID_APP,
43     FILE_OWNERID_DEBUG,
44     FILE_OWNERID_SHARED,
45     FILE_OWNERID_COMPAT,
46     FILE_OWNERID_MAX
47 };
48 
49 /* process and file ownerid types need to correspond to each other */
50 enum ProcessOwneridType {
51     PROCESS_OWNERID_UNINIT = FILE_OWNERID_UNINT,
52     PROCESS_OWNERID_SYSTEM = FILE_OWNERID_SYSTEM,
53     PROCESS_OWNERID_APP    = FILE_OWNERID_APP,
54     PROCESS_OWNERID_DEBUG  = FILE_OWNERID_DEBUG,
55     PROCESS_OWNERID_COMPAT = FILE_OWNERID_COMPAT,
56     PROCESS_OWNERID_EXTEND,
57     PROCESS_OWNERID_MAX
58 };
59 
60 struct XpmConfig {
61     uint64_t regionAddr;
62     uint64_t regionLength;
63 
64     uint32_t idType;
65     char ownerId[MAX_OWNERID_LEN];
66 };
67 
68 int InitXpmRegion(void);
69 
70 int SetXpmOwnerId(uint32_t idType, const char *ownerId);
71 
72 #ifdef __cplusplus
73 }
74 #endif
75 
76 #endif // CODE_SIGN_ATTR_UTILS_H
77