142103316Sopenharmony_ci/* 242103316Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd. 342103316Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 442103316Sopenharmony_ci * you may not use this file except in compliance with the License. 542103316Sopenharmony_ci * You may obtain a copy of the License at 642103316Sopenharmony_ci * 742103316Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 842103316Sopenharmony_ci * 942103316Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1042103316Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1142103316Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1242103316Sopenharmony_ci * See the License for the specific language governing permissions and 1342103316Sopenharmony_ci * limitations under the License. 1442103316Sopenharmony_ci */ 1542103316Sopenharmony_ci 1642103316Sopenharmony_ci#ifndef HILOG_WRAPPER_H 1742103316Sopenharmony_ci#define HILOG_WRAPPER_H 1842103316Sopenharmony_ci 1942103316Sopenharmony_ci#define CONFIG_HILOG 2042103316Sopenharmony_ci#ifdef CONFIG_HILOG 2142103316Sopenharmony_ci#include "hilog/log.h" 2242103316Sopenharmony_cinamespace OHOS { 2342103316Sopenharmony_cinamespace USB { 2442103316Sopenharmony_ci#define USBFILENAME (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) 2542103316Sopenharmony_ci 2642103316Sopenharmony_ci#ifdef USB_HILOGF 2742103316Sopenharmony_ci#undef USB_HILOGF 2842103316Sopenharmony_ci#endif 2942103316Sopenharmony_ci 3042103316Sopenharmony_ci#ifdef USB_HILOGE 3142103316Sopenharmony_ci#undef USB_HILOGE 3242103316Sopenharmony_ci#endif 3342103316Sopenharmony_ci 3442103316Sopenharmony_ci#ifdef USB_HILOGW 3542103316Sopenharmony_ci#undef USB_HILOGW 3642103316Sopenharmony_ci#endif 3742103316Sopenharmony_ci 3842103316Sopenharmony_ci#ifdef USB_HILOGI 3942103316Sopenharmony_ci#undef USB_HILOGI 4042103316Sopenharmony_ci#endif 4142103316Sopenharmony_ci 4242103316Sopenharmony_ci#ifdef USB_HILOGD 4342103316Sopenharmony_ci#undef USB_HILOGD 4442103316Sopenharmony_ci#endif 4542103316Sopenharmony_ci 4642103316Sopenharmony_cistruct UsbLable { 4742103316Sopenharmony_ci uint32_t domainId; 4842103316Sopenharmony_ci const char* tag; 4942103316Sopenharmony_ci}; 5042103316Sopenharmony_ci 5142103316Sopenharmony_ci// param of log interface, such as USB_HILOGF. 5242103316Sopenharmony_cienum UsbMgrSubModule { 5342103316Sopenharmony_ci MODULE_INNERKIT = 0, 5442103316Sopenharmony_ci MODULE_SERVICE, 5542103316Sopenharmony_ci MODULE_USB_INNERKIT, // below used by usb service 5642103316Sopenharmony_ci MODULE_USB_SERVICE, 5742103316Sopenharmony_ci MODULE_USBD, 5842103316Sopenharmony_ci MODULE_COMMON, 5942103316Sopenharmony_ci MODULE_JS_NAPI, 6042103316Sopenharmony_ci MODULE_JAVAKIT, // java kit used, define to avoid repeat used domain 6142103316Sopenharmony_ci MODULE_JNI, 6242103316Sopenharmony_ci USBMGR_MODULE_BUTT, 6342103316Sopenharmony_ci}; 6442103316Sopenharmony_ci 6542103316Sopenharmony_ci// 0xD002900: subsystem:Usb module:Usb, reserved 8 bit. 6642103316Sopenharmony_ciconstexpr unsigned int BASE_USB_DOMAIN_ID = 0xD002A00; 6742103316Sopenharmony_ci 6842103316Sopenharmony_cienum UsbMgrDomainId { 6942103316Sopenharmony_ci USBMGR_INNERKIT_DOMAIN = BASE_USB_DOMAIN_ID + MODULE_INNERKIT + 1, 7042103316Sopenharmony_ci USBMGR_SERVICE_DOMAIN, //0xD002A02 7142103316Sopenharmony_ci USB_INNERKIT_DOMAIN, //0xD002A03 7242103316Sopenharmony_ci USB_SERVICE_DOMAIN, //0xD002A04 7342103316Sopenharmony_ci USBD_DOMAIN, //0xD002A05 7442103316Sopenharmony_ci COMMON_DOMAIN, //0xD002A06 7542103316Sopenharmony_ci USB_JS_NAPI, //0xD002A07 7642103316Sopenharmony_ci USBMGR_JAVAKIT_DOMAIN, 7742103316Sopenharmony_ci USB_BUTT, 7842103316Sopenharmony_ci}; 7942103316Sopenharmony_ci 8042103316Sopenharmony_cistatic const UsbLable USB_MGR_LABEL[USBMGR_MODULE_BUTT] = { 8142103316Sopenharmony_ci {USBMGR_INNERKIT_DOMAIN, "UsbMgrClient"}, 8242103316Sopenharmony_ci {USBMGR_SERVICE_DOMAIN, "UsbMgrService"}, 8342103316Sopenharmony_ci {USB_INNERKIT_DOMAIN, "UsbSrvClient"}, 8442103316Sopenharmony_ci {USB_SERVICE_DOMAIN, "UsbService"}, 8542103316Sopenharmony_ci {USBD_DOMAIN, "Usbd"}, 8642103316Sopenharmony_ci {COMMON_DOMAIN, "UsbMgrCommon"}, 8742103316Sopenharmony_ci {USB_JS_NAPI, "UsbMgrJSNAPI"}, 8842103316Sopenharmony_ci {USBMGR_JAVAKIT_DOMAIN, "UsbMgrJavaService"}, 8942103316Sopenharmony_ci {USBMGR_INNERKIT_DOMAIN, "UsbMgrJni"}, 9042103316Sopenharmony_ci}; 9142103316Sopenharmony_ci 9242103316Sopenharmony_ci// In order to improve performance, do not check the module range, module should less than USBMGR_MODULE_BUTT. 9342103316Sopenharmony_ci#define USB_HILOGF(module, ...) \ 9442103316Sopenharmony_ci ((void)HILOG_IMPL(LOG_CORE, LOG_FATAL, USB_MGR_LABEL[module].domainId, USB_MGR_LABEL[module].tag, ##__VA_ARGS__)) 9542103316Sopenharmony_ci#define USB_HILOGE(module, ...) \ 9642103316Sopenharmony_ci ((void)HILOG_IMPL(LOG_CORE, LOG_ERROR, USB_MGR_LABEL[module].domainId, USB_MGR_LABEL[module].tag, ##__VA_ARGS__)) 9742103316Sopenharmony_ci#define USB_HILOGW(module, ...) \ 9842103316Sopenharmony_ci ((void)HILOG_IMPL(LOG_CORE, LOG_WARN, USB_MGR_LABEL[module].domainId, USB_MGR_LABEL[module].tag, ##__VA_ARGS__)) 9942103316Sopenharmony_ci#define USB_HILOGI(module, ...) \ 10042103316Sopenharmony_ci ((void)HILOG_IMPL(LOG_CORE, LOG_INFO, USB_MGR_LABEL[module].domainId, USB_MGR_LABEL[module].tag, ##__VA_ARGS__)) 10142103316Sopenharmony_ci#define USB_HILOGD(module, ...) \ 10242103316Sopenharmony_ci ((void)HILOG_IMPL(LOG_CORE, LOG_DEBUG, USB_MGR_LABEL[module].domainId, USB_MGR_LABEL[module].tag, ##__VA_ARGS__)) 10342103316Sopenharmony_ci} // namespace USB 10442103316Sopenharmony_ci} // namespace OHOS 10542103316Sopenharmony_ci 10642103316Sopenharmony_ci#else 10742103316Sopenharmony_ci 10842103316Sopenharmony_ci#define USB_HILOGF(...) 10942103316Sopenharmony_ci#define USB_HILOGE(...) 11042103316Sopenharmony_ci#define USB_HILOGW(...) 11142103316Sopenharmony_ci#define USB_HILOGI(...) 11242103316Sopenharmony_ci#define USB_HILOGD(...) 11342103316Sopenharmony_ci 11442103316Sopenharmony_ci#endif // CONFIG_HILOG 11542103316Sopenharmony_ci 11642103316Sopenharmony_ci#endif // HILOG_WRAPPER_H 117