1 /* 2 * Copyright (C) 2025 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 APPSPAWN_ERROR_H 17 #define APPSPAWN_ERROR_H 18 19 #include <stdint.h> 20 #include <stdio.h> 21 #include <stdlib.h> 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif // __cplusplus 26 27 // 错误码定义规范:子系统ID(27-21位)| 特性(20位) 0:appspawn,1:init| 模块ID(19-16位)| 具体错误ID(15-0位) 28 #define OHOS_SUBSYS_STARTUP_ID 39 29 #define OHOS_SUBSYSTEM_BIT_NUM 21 30 #define OHOS_MODULE_BIT_NUM 16 31 #define OHOS_SUBMODULE_BIT_NUM 12 32 33 // appspawn特性中模块码定义 34 #define DECLARE_APPSPAWN_ERRORCODE_BASE(module) \ 35 ((uint32_t)(((module) & 0x0f) << OHOS_MODULE_BIT_NUM) | (OHOS_SUBSYS_STARTUP_ID << OHOS_SUBSYSTEM_BIT_NUM)) 36 37 #define DECLARE_APPSPAWN_ERRORCODE_SUBMODULE_BASE(module, submodule) \ 38 ((uint32_t)(DECLARE_APPSPAWN_ERRORCODE_BASE(module) | (((submodule) & 0x0f) << OHOS_SUBMODULE_BIT_NUM))) 39 40 #define DECLARE_APPSPAWN_ERRORCODE(module, submodule, error) \ 41 ((uint32_t)(DECLARE_APPSPAWN_ERRORCODE_SUBMODULE_BASE((module), (submodule)) | ((error) & 0x0fff))) 42 43 /* 错误码与模块映射关系: 44 * APPSPAWN_UTILS: 0x04E00000 ~ 0x04E0FFFF appspawn公共调试日志错误码范围 45 * APPSPAWN_SPAWNER: 0x04E10000 ~ 0x04E1FFFF 孵化器调试日志错误码范围 46 * APPSPAWN_SANDBOX: 0x04E20000 ~ 0x04E2FFFF 沙箱调试日志错误码范围 47 * APPSPAWN_HNP: 0x04E30000 ~ 0x04E3FFFF hnp调试日志错误码范围 48 * APPSPAWN_DEVICE_DEBUG: 0x04E40000 ~ 0x04E4FFFF devicedebug调试日志错误码范围 49 */ 50 51 typedef enum { 52 APPSPAWN_UTILS = 0, // 公共模块 53 APPSPAWN_SPAWNER, // spawner模块 54 APPSPAWN_SANDBOX, // 沙箱模块 55 APPSPAWN_HNP, // hnp模块 56 APPSPAWN_DEVICE_DEBUG, // devicedebug模块 57 } AppSpawnErrorCodeModuleType; 58 59 typedef enum { 60 APPSPAWN_UTILS_COMMON = 0, // utils-common 模块 61 APPSPAWN_UTILS_ARCH, 62 APPSPAWN_SUB_MODULE_UTILS_COUNT 63 } AppSpawnSubModuleUtils; 64 65 typedef enum { 66 APPSPAWN_SPAWNER_COMMON = 0, // spawner-common 模块 67 APPSPAWN_SUB_MODULE_SPAWNER_COUNT 68 } AppSpawnSubModuleSpawner; 69 70 typedef enum { 71 APPSPAWN_SANDBOX_COMMON = 0, // sandbox-common 模块 72 APPSPAWN_SUB_MODULE_SANDBOX_COUNT 73 } AppSpawnSubModuleSandbox; 74 75 typedef enum { 76 APPSPAWN_HNP_COMMON = 0, // hnp-common 模块 77 APPSPAWN_SUB_MODULE_HNP_COUNT 78 } AppSpawnSubModuleHnp; 79 80 typedef enum { 81 APPSPAWN_DEVICEDEBUG_COMMON = 0, // devicedebug-common 模块 82 APPSPAWN_SUB_MODULE_DEVICEDEBUG_COUNT 83 } AppSpawnSubModuleDeviceDebug; 84 85 typedef enum { 86 APPSPAWN_ERROR_MSG_TO_LONG = DECLARE_APPSPAWN_ERRORCODE(APPSPAWN_SPAWNER, APPSPAWN_UTILS_COMMON, 0x0000), 87 APPSPAWN_ERROR_MSG_INVALID, 88 } SpawnerErrorCode; 89 90 typedef enum { 91 SANDBOX_ERROR_ARGS_INVALID = DECLARE_APPSPAWN_ERRORCODE(APPSPAWN_SANDBOX, APPSPAWN_SANDBOX_COMMON, 0x0000), 92 SANDBOX_ERROR_MSG_INVALID, 93 } SandboxErrorCode; 94 95 #ifdef __cplusplus 96 } 97 #endif // __cplusplus 98 99 #endif // APPSPAWN_ERROR_H