From 4c7408f1ae82995d04f748559ae23312efed84b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A8=8A=E6=99=AF=E4=B9=90?= Date: Sat, 15 Mar 2025 11:26:11 +0800 Subject: [PATCH] fix: add appspawn error code ruler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 樊景乐 --- util/include/appspawn_error.h | 99 +++++++++++++++++++++++++++++++++++ util/include/appspawn_utils.h | 1 + 2 files changed, 100 insertions(+) create mode 100644 util/include/appspawn_error.h diff --git a/util/include/appspawn_error.h b/util/include/appspawn_error.h new file mode 100644 index 00000000..7ed9e6b2 --- /dev/null +++ b/util/include/appspawn_error.h @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + #ifndef APPSPAWN_ERROR_H + #define APPSPAWN_ERROR_H + + #include + #include + #include + + #ifdef __cplusplus + extern "C" { + #endif // __cplusplus + + // 错误码定义规范:子系统ID(27-21位)| 特性(20位) 0:appspawn,1:init| 模块ID(19-16位)| 具体错误ID(15-0位) + #define OHOS_SUBSYS_STARTUP_ID 39 + #define OHOS_SUBSYSTEM_BIT_NUM 21 + #define OHOS_MODULE_BIT_NUM 16 + #define OHOS_SUBMODULE_BIT_NUM 12 + + // appspawn特性中模块码定义 + #define DECLARE_APPSPAWN_ERRORCODE_BASE(module) \ + ((uint32_t)(((module) & 0x0f) << OHOS_MODULE_BIT_NUM) | (OHOS_SUBSYS_STARTUP_ID << OHOS_SUBSYSTEM_BIT_NUM)) + + #define DECLARE_APPSPAWN_ERRORCODE_SUBMODULE_BASE(module, submodule) \ + ((uint32_t)(DECLARE_APPSPAWN_ERRORCODE_BASE(module) | (((submodule) & 0x0f) << OHOS_SUBMODULE_BIT_NUM))) + + #define DECLARE_APPSPAWN_ERRORCODE(module, submodule, error) \ + ((uint32_t)(DECLARE_APPSPAWN_ERRORCODE_SUBMODULE_BASE((module), (submodule)) | ((error) & 0x0fff))) + + /* 错误码与模块映射关系: + * APPSPAWN_UTILS: 0x04E00000 ~ 0x04E0FFFF appspawn公共调试日志错误码范围 + * APPSPAWN_SPAWNER: 0x04E10000 ~ 0x04E1FFFF 孵化器调试日志错误码范围 + * APPSPAWN_SANDBOX: 0x04E20000 ~ 0x04E2FFFF 沙箱调试日志错误码范围 + * APPSPAWN_HNP: 0x04E30000 ~ 0x04E3FFFF hnp调试日志错误码范围 + * APPSPAWN_DEVICE_DEBUG: 0x04E40000 ~ 0x04E4FFFF devicedebug调试日志错误码范围 + */ + + typedef enum { + APPSPAWN_UTILS = 0, // 公共模块 + APPSPAWN_SPAWNER, // spawner模块 + APPSPAWN_SANDBOX, // 沙箱模块 + APPSPAWN_HNP, // hnp模块 + APPSPAWN_DEVICE_DEBUG, // devicedebug模块 + } AppSpawnErrorCodeModuleType; + + typedef enum { + APPSPAWN_UTILS_COMMON = 0, // utils-common 模块 + APPSPAWN_UTILS_ARCH, + APPSPAWN_SUB_MODULE_UTILS_COUNT + } AppSpawnSubModuleUtils; + + typedef enum { + APPSPAWN_SPAWNER_COMMON = 0, // spawner-common 模块 + APPSPAWN_SUB_MODULE_SPAWNER_COUNT + } AppSpawnSubModuleSpawner; + + typedef enum { + APPSPAWN_SANDBOX_COMMON = 0, // sandbox-common 模块 + APPSPAWN_SUB_MODULE_SANDBOX_COUNT + } AppSpawnSubModuleSandbox; + + typedef enum { + APPSPAWN_HNP_COMMON = 0, // hnp-common 模块 + APPSPAWN_SUB_MODULE_HNP_COUNT + } AppSpawnSubModuleHnp; + + typedef enum { + APPSPAWN_DEVICEDEBUG_COMMON = 0, // devicedebug-common 模块 + APPSPAWN_SUB_MODULE_DEVICEDEBUG_COUNT + } AppSpawnSubModuleDeviceDebug; + + typedef enum { + APPSPAWN_ERROR_MSG_TO_LONG = DECLARE_APPSPAWN_ERRORCODE(APPSPAWN_SPAWNER, APPSPAWN_UTILS_COMMON, 0x0000), + APPSPAWN_ERROR_MSG_INVAILD, + } SpawnerErrorCode; + + typedef enum { + SANDBOX_ERROR_ARGS_INVAILD = DECLARE_APPSPAWN_ERRORCODE(APPSPAWN_SANDBOX, APPSPAWN_SANDBOX_COMMON, 0x0000), + SANDBOX_ERROR_MSG_INVAILD, + } SandboxErrorCode; + + #ifdef __cplusplus + } + #endif // __cplusplus + + #endif // APPSPAWN_ERROR_H \ No newline at end of file diff --git a/util/include/appspawn_utils.h b/util/include/appspawn_utils.h index 5e9d7263..d7c9cc1b 100755 --- a/util/include/appspawn_utils.h +++ b/util/include/appspawn_utils.h @@ -29,6 +29,7 @@ #include #include "hilog/log.h" +#include "appspawn_error.h" #ifdef __cplusplus extern "C" { -- Gitee