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 9 #ifndef MESSAGE_DISPATCHER_H 10 #define MESSAGE_DISPATCHER_H 11 #include "osal/osal_mutex.h" 12 #include "hdf_wlan_priority_queue.h" 13 #include "shared_obj.h" 14 #include "sidecar.h" 15 #include "message_config.h" 16 17 #define BAD_DISPATCHER_ID 255 18 #define DISPATCHER_ID_AUTO 254 19 20 #define MAX_PRI_LEVEL_COUNT 3 21 22 struct MessageDispatcher; 23 24 #define INHERT_MESSAGE_DISPATCHER \ 25 SHARED_OBJ(MessageDispatcher); \ 26 OSAL_DECLARE_MUTEX(mutex); \ 27 ErrorCode (*AppendMessage)(struct MessageDispatcher *, const uint8_t priority, MessageContext * context); \ 28 ErrorCode (*Start)(struct MessageDispatcher * dispatcher); \ 29 void (*Shutdown)(struct MessageDispatcher * dispatcher); \ 30 PriorityQueue *messageQueue 31 32 typedef struct MessageDispatcher { 33 INHERT_MESSAGE_DISPATCHER; 34 } MessageDispatcher; 35 36 void ReleaseMessageMapper(struct ServiceDef *mapper); 37 void ReleaseMessageContext(MessageContext *context); 38 void SetToResponse(MessageContext *context); 39 40 struct MessageDef *GetMsgDef(const struct ServiceDef *serviceDef, uint32_t commandId); 41 42 ErrorCode CreateLocalDispatcher(MessageDispatcher **dispatcher, const DispatcherConfig *config); 43 44 #endif 45