From 5c072c64809884984d3945b86bdd8f909f31f472 Mon Sep 17 00:00:00 2001 From: zhizhimeimei6 Date: Mon, 14 Feb 2022 17:05:42 +0800 Subject: [PATCH] zerohung: open zerohung feature ohos inclusion category: feature issue: #I4PJDN CVE: NA ----------------- zerohung is used to detect and upload kernel event. Signed-off-by: zhizhimeimei6 --- drivers/staging/Kconfig | 2 + drivers/staging/Makefile | 1 + drivers/staging/zerohung/Kconfig | 6 + drivers/staging/zerohung/Makefile | 2 + drivers/staging/zerohung/watchpoint/Makefile | 2 + .../zerohung/watchpoint/hung_wp_screen.c | 283 +++++++++++++++++ drivers/staging/zerohung/zrhung_event.c | 299 ++++++++++++++++++ drivers/video/backlight/backlight.c | 10 + include/dfx/hung_wp_screen.h | 36 +++ include/dfx/zrhung.h | 23 ++ 10 files changed, 664 insertions(+) create mode 100644 drivers/staging/zerohung/Kconfig create mode 100644 drivers/staging/zerohung/Makefile create mode 100644 drivers/staging/zerohung/watchpoint/Makefile create mode 100644 drivers/staging/zerohung/watchpoint/hung_wp_screen.c create mode 100644 drivers/staging/zerohung/zrhung_event.c create mode 100644 include/dfx/hung_wp_screen.h create mode 100644 include/dfx/zrhung.h diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index d47ee7199bfc..d9ace574ad9d 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -122,6 +122,8 @@ source "drivers/staging/hilog/Kconfig" source "drivers/staging/hievent/Kconfig" +source "drivers/staging/zerohung/Kconfig" + source "drivers/staging/hungtask/Kconfig" source "drivers/staging/blackbox/Kconfig" diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index b0fe6f912da6..3883281dbe7a 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -51,5 +51,6 @@ obj-$(CONFIG_WFX) += wfx/ obj-y += hikey9xx/ obj-$(CONFIG_HILOG) += hilog/ obj-$(CONFIG_HIEVENT) += hievent/ +obj-$(CONFIG_DFX_ZEROHUNG) += zerohung/ obj-$(CONFIG_DFX_HUNGTASK) += hungtask/ obj-$(CONFIG_BLACKBOX) += blackbox/ diff --git a/drivers/staging/zerohung/Kconfig b/drivers/staging/zerohung/Kconfig new file mode 100644 index 000000000000..3f575f72bfb8 --- /dev/null +++ b/drivers/staging/zerohung/Kconfig @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0 +config DFX_ZEROHUNG + bool "zerohung driver" + default n + help + This feature support to catch hung log diff --git a/drivers/staging/zerohung/Makefile b/drivers/staging/zerohung/Makefile new file mode 100644 index 000000000000..3727a0e91dca --- /dev/null +++ b/drivers/staging/zerohung/Makefile @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_DFX_ZEROHUNG) += zrhung_event.o watchpoint/ diff --git a/drivers/staging/zerohung/watchpoint/Makefile b/drivers/staging/zerohung/watchpoint/Makefile new file mode 100644 index 000000000000..1cb8d7f99417 --- /dev/null +++ b/drivers/staging/zerohung/watchpoint/Makefile @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_DFX_ZEROHUNG) += hung_wp_screen.o diff --git a/drivers/staging/zerohung/watchpoint/hung_wp_screen.c b/drivers/staging/zerohung/watchpoint/hung_wp_screen.c new file mode 100644 index 000000000000..9b295fed067d --- /dev/null +++ b/drivers/staging/zerohung/watchpoint/hung_wp_screen.c @@ -0,0 +1,283 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. All rights reserved. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#define pr_fmt(fmt) "zrhung " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define TIME_CONVERT_UNIT 1000 +#define DEFAULT_TIMEOUT 10 + +#define LPRESSEVENT_TIME 5 +#define POWERKEYEVENT_MAX_COUNT 10 +#define POWERKEYEVENT_DEFAULT_COUNT 3 +#define POWERKEYEVENT_DEFAULT_TIMEWINDOW 5 +#define POWERKEYEVENT_DEFAULT_LIMIT_MS 300 +#define POWERKEYEVENT_DEFAULT_REPORT_MIN 2 +#define POWERKEYEVENT_TIME_LEN (POWERKEYEVENT_MAX_COUNT + 2) + +struct hung_wp_screen_data { + struct timer_list timer; + struct timer_list long_press_timer; + struct workqueue_struct *workq; + struct work_struct send_work; + spinlock_t lock; + int fb_blank; + int check_id; + int tag_id; +}; + +static bool init_done; +static struct hung_wp_screen_data g_hung_data; +static unsigned int lastreport_time; +static unsigned int lastprkyevt_time; +static unsigned int powerkeyevent_time[POWERKEYEVENT_TIME_LEN] = {0}; +static unsigned int newevt; +static unsigned int headevt; +static int *check_off_point; +struct work_struct powerkeyevent_sendwork; +struct work_struct lpressevent_sendwork; + + +static void zrhung_lpressevent_send_work(struct work_struct *work) +{ + pr_info("LONGPRESS_EVENT send to zerohung\n"); + zrhung_send_event(WP_SCREEN_DOMAIN, WP_SCREEN_LPRESS_NAME, "none"); +} + +static void zrhung_wp_lpress_send(struct timer_list *t) +{ + int *check_off = check_off_point; + + del_timer(&g_hung_data.long_press_timer); + *check_off = 0; + queue_work(g_hung_data.workq, &lpressevent_sendwork); +} + +static void zrhung_powerkeyevent_send_work(struct work_struct *work) +{ + pr_info("POWERKEY_EVENT send to zerohung\n"); + zrhung_send_event(WP_SCREEN_DOMAIN, WP_SCREEN_PWK_NAME, "none"); +} + +static void zrhung_powerkeyevent_report(unsigned int dur, unsigned int end) +{ + unsigned int send_interval; + + send_interval = end > lastreport_time ? + ((end - lastreport_time) / TIME_CONVERT_UNIT) : POWERKEYEVENT_DEFAULT_REPORT_MIN; + if (unlikely(lastreport_time == 0)) { + lastreport_time = end; + } else if (send_interval < POWERKEYEVENT_DEFAULT_REPORT_MIN) { + pr_info("powerkeyevent too fast to report: %d\n", end); + return; + } + lastreport_time = end; + queue_work(g_hung_data.workq, &powerkeyevent_sendwork); +} + +static unsigned int refresh_prkyevt_index(unsigned int event) +{ + unsigned int evt = event; + + if (evt < POWERKEYEVENT_MAX_COUNT) + evt++; + else + evt = 0; + return evt; +} + +static void zrhung_new_powerkeyevent(unsigned int tmescs) +{ + unsigned int prkyevt_interval; + unsigned int evt_index; + int diff; + + powerkeyevent_time[newevt] = tmescs; + evt_index = (newevt >= headevt) ? + (newevt - headevt) : (newevt + POWERKEYEVENT_MAX_COUNT + 1 - headevt); + if (evt_index < (POWERKEYEVENT_DEFAULT_COUNT - 1)) { + pr_info("powerkeyevent not enough-%d\n", POWERKEYEVENT_DEFAULT_COUNT); + } else { + diff = powerkeyevent_time[newevt] - powerkeyevent_time[headevt]; + if (diff < 0) { + pr_info("powerkeyevent sth wrong in record time\n"); + return; + } + + prkyevt_interval = (unsigned int)(diff / TIME_CONVERT_UNIT); + if (prkyevt_interval <= POWERKEYEVENT_DEFAULT_TIMEWINDOW) + zrhung_powerkeyevent_report(prkyevt_interval, tmescs); + headevt = refresh_prkyevt_index(headevt); + } + newevt = refresh_prkyevt_index(newevt); +} + +static void zrhung_powerkeyevent_handler(void) +{ + unsigned int curtime; + unsigned long curjiff; + + pr_info("powerkeyevent check start"); + curjiff = jiffies; + curtime = jiffies_to_msecs(curjiff); + if (unlikely(lastprkyevt_time > curtime)) { + pr_info("powerkeyevent check but time overflow"); + lastprkyevt_time = curtime; + return; + } else if ((curtime - lastprkyevt_time) < POWERKEYEVENT_DEFAULT_LIMIT_MS) { + pr_info("powerkeyevent user press powerkey too fast-time:%d", curtime); + return; + } + lastprkyevt_time = curtime; + zrhung_new_powerkeyevent(curtime); +} + +void hung_wp_screen_setblank(int blank) +{ + unsigned long flags; + + if (!init_done) + return; + + spin_lock_irqsave(&(g_hung_data.lock), flags); + g_hung_data.fb_blank = blank; + if (((g_hung_data.check_id == ZRHUNG_WP_SCREENON) && (blank == 0)) || + ((g_hung_data.check_id == ZRHUNG_WP_SCREENOFF) && (blank != 0))) { + pr_info("check_id=%d, blank=%d", g_hung_data.check_id, g_hung_data.fb_blank); + del_timer(&g_hung_data.timer); + g_hung_data.check_id = ZRHUNG_WP_NONE; + } + spin_unlock_irqrestore(&(g_hung_data.lock), flags); +} + +static void hung_wp_screen_send_work(struct work_struct *work) +{ + unsigned long flags = 0; + + show_state_filter(TASK_UNINTERRUPTIBLE); + + if (g_hung_data.check_id == 1) + zrhung_send_event(WP_SCREEN_DOMAIN, WP_SCREEN_ON_NAME, "none"); + else + zrhung_send_event(WP_SCREEN_DOMAIN, WP_SCREEN_OFF_NAME, "none"); + pr_info("send event: %d\n", g_hung_data.check_id); + spin_lock_irqsave(&(g_hung_data.lock), flags); + g_hung_data.check_id = ZRHUNG_WP_NONE; + spin_unlock_irqrestore(&(g_hung_data.lock), flags); +} + +static void hung_wp_screen_send(struct timer_list *t) +{ + del_timer(&g_hung_data.timer); + pr_info("hung_wp_screen_%d end\n", g_hung_data.tag_id); + queue_work(g_hung_data.workq, &g_hung_data.send_work); +} + +static void hung_wp_screen_start(int check_id) +{ + if (g_hung_data.check_id != ZRHUNG_WP_NONE) { + pr_info("already in check_id: %d\n", g_hung_data.check_id); + return; + } + + g_hung_data.check_id = check_id; + if (timer_pending(&g_hung_data.timer)) + del_timer(&g_hung_data.timer); + + g_hung_data.timer.expires = jiffies + msecs_to_jiffies(DEFAULT_TIMEOUT * TIME_CONVERT_UNIT); + add_timer(&g_hung_data.timer); + pr_info("going to check ID=%d timeout=%d\n", check_id, DEFAULT_TIMEOUT); + + return; +} + +void hung_wp_screen_powerkey_ncb(int event) +{ + static int check_off; + unsigned long flags = 0; + + if (!init_done) + return; + + spin_lock_irqsave(&(g_hung_data.lock), flags); + if (event == WP_SCREEN_PWK_PRESS) { + pr_info("hung_wp_screen_%d start! fb_blank=%d", + ++g_hung_data.tag_id, g_hung_data.fb_blank); + check_off = 0; + if (g_hung_data.fb_blank != 0) { + hung_wp_screen_start(ZRHUNG_WP_SCREENON); + } else { + check_off = 1; + pr_info("start longpress test timer\n"); + check_off_point = &check_off; + g_hung_data.long_press_timer.expires = jiffies + + msecs_to_jiffies(LPRESSEVENT_TIME * TIME_CONVERT_UNIT); + if (!timer_pending(&g_hung_data.long_press_timer)) + add_timer(&g_hung_data.long_press_timer); + } + zrhung_powerkeyevent_handler(); + } else if (check_off) { + check_off = 0; + del_timer(&g_hung_data.long_press_timer); + if (event == WP_SCREEN_PWK_RELEASE && g_hung_data.fb_blank == 0) + hung_wp_screen_start(ZRHUNG_WP_SCREENOFF); + } + spin_unlock_irqrestore(&(g_hung_data.lock), flags); +} + +static int __init hung_wp_screen_init(void) +{ + init_done = false; + pr_info("%s start\n", __func__); + g_hung_data.fb_blank = 0; + g_hung_data.tag_id = 0; + g_hung_data.check_id = ZRHUNG_WP_NONE; + spin_lock_init(&(g_hung_data.lock)); + + timer_setup(&g_hung_data.timer, hung_wp_screen_send, 0); + timer_setup(&g_hung_data.long_press_timer, zrhung_wp_lpress_send, 0); + + g_hung_data.workq = create_workqueue("hung_wp_screen_workq"); + if (g_hung_data.workq == NULL) { + pr_err("create workq failed\n"); + return -EFAULT; + } + INIT_WORK(&g_hung_data.send_work, hung_wp_screen_send_work); + INIT_WORK(&powerkeyevent_sendwork, zrhung_powerkeyevent_send_work); + INIT_WORK(&lpressevent_sendwork, zrhung_lpressevent_send_work); + + init_done = true; + pr_info("%s done\n", __func__); + return 0; +} + +module_init(hung_wp_screen_init); + +MODULE_AUTHOR("OHOS"); +MODULE_DESCRIPTION("Reporting the frozen screen alarm event"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/zerohung/zrhung_event.c b/drivers/staging/zerohung/zrhung_event.c new file mode 100644 index 000000000000..0ad2d9abb31d --- /dev/null +++ b/drivers/staging/zerohung/zrhung_event.c @@ -0,0 +1,299 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. All rights reserved. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#define pr_fmt(fmt) "zrhung " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MINUTE_TO_SECS 60 +#define SEC_TO_MILLISEC 1000 +#define MILLISEC_TO_NANOSEC (1000 * 1000) +#define TIME_ZONE_LEN 6 +#define HISYSEVENT_MAX_STR_LEN 1024 +#define HISYSEVENT_INFO_BUF_LEN 1024 +#define HISYSEVENT_WRITER_DEV "/dev/bbox" +static int CHECK_CODE = 0x7BCDABCD; + +#define BUF_POINTER_FORWARD \ +do { \ + if (tmp_len >= 0 && tmp_len < len) { \ + tmp += tmp_len; \ + len -= tmp_len; \ + } else { \ + pr_err("string over length"); \ + tmp += len; \ + len = 0; \ + } \ +} while (0) + +struct hisysevent { + char *domain; + char *event_name; + unsigned int type; + long long time; + char *tz; + unsigned int pid; + unsigned int tid; + unsigned int uid; + char *msg; +}; + +int hisysevent_set_time(struct hisysevent *event) +{ + struct timespec64 ts; + struct timezone tz = sys_tz; + int tz_index = 0; + char time_zone[TIME_ZONE_LEN]; + int tz_hour; + int tz_min; + long long millisecs = 0; + + if (!event) { + pr_err("invalid event"); + return -EINVAL; + } + + ktime_get_real_ts64(&ts); + millisecs = ts.tv_sec * SEC_TO_MILLISEC + ts.tv_nsec / MILLISEC_TO_NANOSEC; + event->time = millisecs; + tz_hour = (-tz.tz_minuteswest) / MINUTE_TO_SECS; + time_zone[tz_index++] = tz_hour >= 0 ? '+' : '-'; + tz_min = (-tz.tz_minuteswest) % MINUTE_TO_SECS; + sprintf(&time_zone[tz_index], "%02u%02u", abs(tz_hour), abs(tz_min)); + time_zone[TIME_ZONE_LEN - 1] = '\0'; + event->tz = kstrdup(time_zone, GFP_ATOMIC); + + return 0; +} + +int hisysevent_set_msg(struct hisysevent *event, const char *msg_buf) +{ + int len; + + if (!event) { + pr_err("invalid event"); + return -EINVAL; + } + + len = strlen(msg_buf); + if ((!msg_buf) || (msg_buf[0] == 0) || len > HISYSEVENT_MAX_STR_LEN) { + pr_err("invalid msg_buf"); + return -EINVAL; + } + + event->msg = kstrdup(msg_buf, GFP_ATOMIC); + + return 0; +} + +struct hisysevent *create_hisysevent(const char *domain, const char *event_name) +{ + struct hisysevent *event = NULL; + + event = vmalloc(sizeof(*event)); + if (!event) { + pr_err("failed to vmalloc for event"); + return -ENOMEM; + } + + memset(event, 0, sizeof(*event)); + + if ((!domain) || (domain[0] == 0)) { + pr_err("valid domain"); + vfree(event); + return NULL; + } + event->domain = kstrdup(domain, GFP_ATOMIC); + + if ((!event_name) || (event_name[0] == 0)) { + pr_err("valid event_name"); + kfree(event->domain); + vfree(event); + return NULL; + } + event->event_name = kstrdup(event_name, GFP_ATOMIC); + event->type = ZRHUNG_EVENT_TYPE; + + pr_info("create hisysevent succ, domain=%s, event_name=%s, type=%u", event->domain, + event->event_name, event->type); + + return (void *)event; +} + +struct hisysevent *inner_build_hisysevent(const char *domain, const char *event_name, + const char *msg_buf) +{ + struct hisysevent *event = NULL; + + event = create_hisysevent(domain, event_name); + hisysevent_set_time(event); + event->pid = current->pid; + event->tid = current->tgid; + event->uid = current_uid().val; + hisysevent_set_msg(event, msg_buf); + + return (void *)event; +} + +void zrhung_hisysevent_destroy(struct hisysevent *event) +{ + if (!event->domain) { + kfree(event->domain); + event->domain = NULL; + } + if (!event->event_name) { + kfree(event->event_name); + event->event_name = NULL; + } + if (!event->tz) { + kfree(event->tz); + event->tz = NULL; + } + if (!event->msg) { + kfree(event->msg); + event->msg = NULL; + } + + vfree(event); +} + +int hisysevent_convert_string(struct hisysevent *event, char **buf_ptr) +{ + int len; + char *tmp; + int tmp_len; + int base_index = 0; + static const char * const base_param_keys[] = {"domain_", "name_", "type_", "time_", "tz_", + "pid_", "tid_", "uid_", "MSG"}; + int buf_len = HISYSEVENT_INFO_BUF_LEN; + char *buf = vmalloc(buf_len); + + if (!buf) { + pr_err("failed to malloc buff for convert_string"); + return -ENOMEM; + } + memset(buf, 0, buf_len); + + len = buf_len; + tmp = buf; + + tmp_len = snprintf(tmp, len, "{\"%s\":\"%s\",", base_param_keys[base_index++], event->domain); + BUF_POINTER_FORWARD; + + tmp_len = snprintf(tmp, len, "\"%s\":\"%s\",", base_param_keys[base_index++], event->event_name); + BUF_POINTER_FORWARD; + + tmp_len = snprintf(tmp, len, "\"%s\":%u,", base_param_keys[base_index++], event->type); + BUF_POINTER_FORWARD; + + tmp_len = snprintf(tmp, len, "\"%s\":%lld,", base_param_keys[base_index++], event->time); + BUF_POINTER_FORWARD; + + tmp_len = snprintf(tmp, len, "\"%s\":\"%s\",", base_param_keys[base_index++], event->tz); + BUF_POINTER_FORWARD; + + tmp_len = snprintf(tmp, len, "\"%s\":%u,", base_param_keys[base_index++], event->pid); + BUF_POINTER_FORWARD; + + tmp_len = snprintf(tmp, len, "\"%s\":%u,", base_param_keys[base_index++], event->tid); + BUF_POINTER_FORWARD; + + tmp_len = snprintf(tmp, len, "\"%s\":%u,", base_param_keys[base_index++], event->uid); + BUF_POINTER_FORWARD; + + tmp_len = snprintf(tmp, len, "\"%s\":\"%s\"}", base_param_keys[base_index++], event->msg); + BUF_POINTER_FORWARD; + + *buf_ptr = buf; + + return (HISYSEVENT_INFO_BUF_LEN - len); +} + +int zrhung_hisysevent_write(struct hisysevent *event) +{ + struct iov_iter iter; + mm_segment_t oldfs; + char *data = NULL; + struct file *filp = NULL; + struct iovec vec[3]; + unsigned long vcount = 0; + int ret; + + hisysevent_convert_string(event, &data); + if (!data) { + pr_err("failed to convert string"); + return -EINVAL; + } + + filp = filp_open(HISYSEVENT_WRITER_DEV, O_WRONLY, 0); + + if ((!filp) || IS_ERR(filp)) { + ret = PTR_ERR(filp); + pr_err("access '%s' failed, res=%d", HISYSEVENT_WRITER_DEV, ret); + vfree(data); + return -ENODEV; + } + + vec[vcount].iov_base = &CHECK_CODE; + vec[vcount++].iov_len = sizeof(CHECK_CODE); + vec[vcount].iov_base = data; + vec[vcount++].iov_len = strlen(data) + 1; + + oldfs = get_fs(); + set_fs(KERNEL_DS); + iov_iter_init(&iter, WRITE, vec, vcount, iov_length(vec, vcount)); + ret = vfs_iter_write(filp, &iter, &filp->f_pos, 0); + set_fs(oldfs); + + if (ret < 0) { + pr_err("write '%s' failed, res=%d", HISYSEVENT_WRITER_DEV, ret); + ret = -EIO; + goto out; + } + +out: + filp_close(filp, NULL); + vfree(data); + return ret; +} + +int zrhung_send_event(const char *domain, const char *event_name, const char *msg_buf) +{ + struct hisysevent *event = NULL; + int ret = 0; + + event = inner_build_hisysevent(domain, event_name, msg_buf); + + if (!event) { + pr_err("failed to build event"); + return -EINVAL; + } + + ret = zrhung_hisysevent_write(event); + zrhung_hisysevent_destroy(event); + return ret; +} diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c index 537fe1b376ad..4bda5fc5e624 100644 --- a/drivers/video/backlight/backlight.c +++ b/drivers/video/backlight/backlight.c @@ -22,6 +22,10 @@ #include #endif +#ifdef CONFIG_DFX_ZEROHUNG +#include +#endif + /** * DOC: overview * @@ -120,6 +124,9 @@ static int fb_notifier_callback(struct notifier_block *self, bd->props.state &= ~BL_CORE_FBBLANK; bd->props.fb_blank = FB_BLANK_UNBLANK; backlight_update_status(bd); +#ifdef CONFIG_DFX_ZEROHUNG + hung_wp_screen_setblank(fb_blank); +#endif } } else if (fb_blank != FB_BLANK_UNBLANK && bd->fb_bl_on[node]) { bd->fb_bl_on[node] = false; @@ -127,6 +134,9 @@ static int fb_notifier_callback(struct notifier_block *self, bd->props.state |= BL_CORE_FBBLANK; bd->props.fb_blank = fb_blank; backlight_update_status(bd); +#ifdef CONFIG_DFX_ZEROHUNG + hung_wp_screen_setblank(fb_blank); +#endif } } out: diff --git a/include/dfx/hung_wp_screen.h b/include/dfx/hung_wp_screen.h new file mode 100644 index 000000000000..88bb62435d6a --- /dev/null +++ b/include/dfx/hung_wp_screen.h @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. All rights reserved. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef HUNG_WP_SCREEN_H +#define HUNG_WP_SCREEN_H + +#define WP_SCREEN_PWK_RELEASE 0 +#define WP_SCREEN_PWK_PRESS 1 + +#define ZRHUNG_WP_NONE 0 +#define ZRHUNG_WP_SCREENON 1 +#define ZRHUNG_WP_SCREENOFF 2 + +#define WP_SCREEN_DOMAIN "KERNEL_VENDOR" +#define WP_SCREEN_PWK_NAME "POWERKEY" +#define WP_SCREEN_LPRESS_NAME "LONGPRESS" +#define WP_SCREEN_ON_NAME "SCREEN_ON" +#define WP_SCREEN_OFF_NAME "SCREEN_OFF" + +void hung_wp_screen_powerkey_ncb(int event); +void hung_wp_screen_setblank(int blank); +int hung_wp_screen_getbl(void); + +#endif /* HUNG_WP_SCREEN_H */ diff --git a/include/dfx/zrhung.h b/include/dfx/zrhung.h new file mode 100644 index 000000000000..9d54df21c817 --- /dev/null +++ b/include/dfx/zrhung.h @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. All rights reserved. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef ZRHUNG_H +#define ZRHUNG_H + +#define ZRHUNG_EVENT_TYPE 1 + +int zrhung_send_event(const char *domain, const char *event_name, const char *msg_buf); + +#endif /* ZRHUNG_H */ -- Gitee