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