11bd4fe43Sopenharmony_ci/* 21bd4fe43Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd. 31bd4fe43Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 41bd4fe43Sopenharmony_ci * you may not use this file except in compliance with the License. 51bd4fe43Sopenharmony_ci * You may obtain a copy of the License at 61bd4fe43Sopenharmony_ci * 71bd4fe43Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 81bd4fe43Sopenharmony_ci * 91bd4fe43Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 101bd4fe43Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 111bd4fe43Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 121bd4fe43Sopenharmony_ci * See the License for the specific language governing permissions and 131bd4fe43Sopenharmony_ci * limitations under the License. 141bd4fe43Sopenharmony_ci */ 151bd4fe43Sopenharmony_ci 161bd4fe43Sopenharmony_ci#ifndef BLACKBOX_H 171bd4fe43Sopenharmony_ci#define BLACKBOX_H 181bd4fe43Sopenharmony_ci 191bd4fe43Sopenharmony_ci#ifdef __cplusplus 201bd4fe43Sopenharmony_ci#if __cplusplus 211bd4fe43Sopenharmony_ciextern "C" { 221bd4fe43Sopenharmony_ci#endif //__cplusplus 231bd4fe43Sopenharmony_ci#endif //__cplusplus 241bd4fe43Sopenharmony_ci 251bd4fe43Sopenharmony_ci#ifndef __user 261bd4fe43Sopenharmony_ci#define __user 271bd4fe43Sopenharmony_ci#endif 281bd4fe43Sopenharmony_ci 291bd4fe43Sopenharmony_ci#define ERROR_INFO_HEADER "#### error info ####\r\n" 301bd4fe43Sopenharmony_ci#define ERROR_INFO_HEADER_FORMAT "event: %s\r\nmodule: %s\r\nerrorDesc: %s\r\n" 311bd4fe43Sopenharmony_ci#define ERROR_INFO_MAX_LEN 768 321bd4fe43Sopenharmony_ci#define Min(a, b) (((a) > (b)) ? (b) : (a)) 331bd4fe43Sopenharmony_ci 341bd4fe43Sopenharmony_ci#define PATH_MAX_LEN 256 351bd4fe43Sopenharmony_ci#define EVENT_MAX_LEN 32 361bd4fe43Sopenharmony_ci#define MODULE_MAX_LEN 32 371bd4fe43Sopenharmony_ci#define ERROR_DESC_MAX_LEN 512 381bd4fe43Sopenharmony_ci#define MODULE_SYSTEM "SYSTEM" 391bd4fe43Sopenharmony_ci#define EVENT_SYSREBOOT "SYSREBOOT" 401bd4fe43Sopenharmony_ci#define EVENT_LONGPRESS "LONGPRESS" 411bd4fe43Sopenharmony_ci#define EVENT_COMBINATIONKEY "COMBINATIONKEY" 421bd4fe43Sopenharmony_ci#define EVENT_SUBSYSREBOOT "SUBSYSREBOOT" 431bd4fe43Sopenharmony_ci#define EVENT_POWEROFF "POWEROFF" 441bd4fe43Sopenharmony_ci#define EVENT_PANIC "PANIC" 451bd4fe43Sopenharmony_ci#define EVENT_SYS_WATCHDOG "SYSWATCHDOG" 461bd4fe43Sopenharmony_ci#define EVENT_HUNGTASK "HUNGTASK" 471bd4fe43Sopenharmony_ci#define EVENT_BOOTFAIL "BOOTFAIL" 481bd4fe43Sopenharmony_ci 491bd4fe43Sopenharmony_cistruct ErrorInfo { 501bd4fe43Sopenharmony_ci char event[EVENT_MAX_LEN]; 511bd4fe43Sopenharmony_ci char module[MODULE_MAX_LEN]; 521bd4fe43Sopenharmony_ci char errorDesc[ERROR_DESC_MAX_LEN]; 531bd4fe43Sopenharmony_ci}; 541bd4fe43Sopenharmony_ci 551bd4fe43Sopenharmony_cistruct ModuleOps { 561bd4fe43Sopenharmony_ci char module[MODULE_MAX_LEN]; 571bd4fe43Sopenharmony_ci void (*Dump)(const char *logDir, struct ErrorInfo *info); 581bd4fe43Sopenharmony_ci void (*Reset)(struct ErrorInfo *info); 591bd4fe43Sopenharmony_ci int (*GetLastLogInfo)(struct ErrorInfo *info); 601bd4fe43Sopenharmony_ci int (*SaveLastLog)(const char *logDir, struct ErrorInfo *info); 611bd4fe43Sopenharmony_ci}; 621bd4fe43Sopenharmony_ci 631bd4fe43Sopenharmony_ciint BBoxRegisterModuleOps(struct ModuleOps *ops); 641bd4fe43Sopenharmony_ciint BBoxNotifyError(const char event[EVENT_MAX_LEN], 651bd4fe43Sopenharmony_ci const char module[MODULE_MAX_LEN], 661bd4fe43Sopenharmony_ci const char errorDesc[ERROR_DESC_MAX_LEN], 671bd4fe43Sopenharmony_ci int needSysReset); 681bd4fe43Sopenharmony_ciint BBoxDriverInit(void); 691bd4fe43Sopenharmony_ci 701bd4fe43Sopenharmony_ci#ifdef __cplusplus 711bd4fe43Sopenharmony_ci#if __cplusplus 721bd4fe43Sopenharmony_ci} 731bd4fe43Sopenharmony_ci#endif //__cplusplus 741bd4fe43Sopenharmony_ci#endif //__cplusplus 751bd4fe43Sopenharmony_ci 761bd4fe43Sopenharmony_ci#endif 77