1 /* 2 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 3 * 4 * HDF is dual licensed: you can use it either under the terms of 5 * the GPL, or the BSD license, at your option. 6 * See the LICENSE file in the root of this repository for complete details. 7 */ 8 #ifndef OSAL_SYSEVENT_H 9 #define OSAL_SYSEVENT_H 10 11 #include "hdf_dlist.h" 12 13 #define HDF_SYSEVENT 0xFADE 14 15 /* hdf sys event class definition */ 16 #define HDF_SYSEVENT_CLASS_POWER 0x00000001 17 #define HDF_SYSEVENT_CLASS_MODULE 0x00000002 18 19 /* hdf power event definition */ 20 enum PowerKeventId { 21 KEVENT_POWER_SUSPEND, 22 KEVENT_POWER_DISPLAY_OFF, 23 KEVENT_POWER_RESUME, 24 KEVENT_POWER_DISPLAY_ON, 25 KEVENT_POWER_EVENT_MAX, 26 }; 27 28 /* hdf power event definition */ 29 enum DriverModuleKeventId { 30 KEVENT_MODULE_INSTALL, 31 KEVENT_MODULE_REMOVE, 32 KEVENT_MODULE_EVENT_MAX, 33 }; 34 35 struct HdfSysEvent { 36 uint64_t eventClass; 37 uint64_t syncToken; 38 uint32_t eventid; 39 uint32_t reserved; 40 }; 41 42 struct HdfSysEventNotifyNode; 43 44 typedef int32_t (*HdfSysEventNotifierFn)( 45 struct HdfSysEventNotifyNode *self, uint64_t eventClass, uint32_t event, const char *content); 46 47 struct HdfSysEventNotifyNode { 48 HdfSysEventNotifierFn callback; 49 struct DListHead listNode; 50 uint64_t classFilter; 51 }; 52 53 int32_t HdfSysEventNotifyRegister(struct HdfSysEventNotifyNode *notifierNode, uint64_t classSet); 54 void HdfSysEventNotifyUnregister(struct HdfSysEventNotifyNode *notifierNode); 55 56 __attribute__((weak)) int32_t HdfSysEventSend(uint64_t eventClass, uint32_t event, const char *content, bool sync); 57 58 #endif // #ifndef OSAL_SYSEVENT_H