1 | /** @file wlan_mac_mailbox_util.h |
---|
2 | * @brief Mailbox Framework |
---|
3 | * |
---|
4 | * This contains code common to both CPU_LOW and CPU_HIGH that allows them |
---|
5 | * to pass messages to one another through the mailbox. |
---|
6 | * |
---|
7 | * @copyright Copyright 2013-2019, Mango Communications. All rights reserved. |
---|
8 | * Distributed under the Mango Communications Reference Design License |
---|
9 | * See LICENSE.txt included in the design archive or |
---|
10 | * at http://mangocomm.com/802.11/license |
---|
11 | * |
---|
12 | * This file is part of the Mango 802.11 Reference Design (https://mangocomm.com/802.11) |
---|
13 | */ |
---|
14 | #ifndef WLAN_MAC_MAILBOX_UTIL_H_ |
---|
15 | #define WLAN_MAC_MAILBOX_UTIL_H_ |
---|
16 | |
---|
17 | #include "xil_types.h" |
---|
18 | #include "xmbox.h" |
---|
19 | |
---|
20 | //----------------------------------------------- |
---|
21 | // Hardware defines |
---|
22 | // |
---|
23 | |
---|
24 | // Define the largest possible mailbox message, used by the upper/lower frameworks |
---|
25 | // for their ipc_msg_*_payload[] variables. 50 words is big enough for all |
---|
26 | // the IPC messages used by the MAC frameworks. It is still possible for |
---|
27 | // a LOW_PARAM or MEM_<READ,WRITE>_LOW command to exceed this. If this happens |
---|
28 | // the mailbox util code will print an error and drop the message |
---|
29 | #define MAILBOX_MSG_MAX_NUM_WORDS 50 |
---|
30 | |
---|
31 | //----------------------------------------------- |
---|
32 | // Mailbox Message ID delimiter |
---|
33 | // - Appended to each message ID to allow for error checking of |
---|
34 | // the start of a message |
---|
35 | // |
---|
36 | #define IPC_MBOX_MSG_ID_DELIM 0xF000 |
---|
37 | |
---|
38 | |
---|
39 | #define CPU_STATUS_REASON_BOOTED 0 |
---|
40 | #define CPU_STATUS_REASON_RESPONSE 1 |
---|
41 | #define CPU_STATUS_REASON_EXCEPTION 2 |
---|
42 | |
---|
43 | |
---|
44 | |
---|
45 | //----------------------------------------------- |
---|
46 | // IPC Message IDs |
---|
47 | // |
---|
48 | #define IPC_MBOX_RX_PKT_BUF_READY 0 |
---|
49 | #define IPC_MBOX_TX_PKT_BUF_READY 1 |
---|
50 | #define IPC_MBOX_TXRX_BEACON_CONFIG 2 |
---|
51 | #define IPC_MBOX_TX_PKT_BUF_DONE 3 |
---|
52 | #define IPC_MBOX_PHY_TX_REPORT 4 |
---|
53 | #define IPC_MBOX_CPU_STATUS 5 |
---|
54 | #define IPC_MBOX_CONFIG_CHANNEL 7 |
---|
55 | #define IPC_MBOX_CONFIG_DSSS_EN 8 |
---|
56 | #define IPC_MBOX_TX_BEACON_DONE 9 |
---|
57 | #define IPC_MBOX_MCAST_BUFFER_ENABLE 10 |
---|
58 | #define IPC_MBOX_SET_MAC_TIME 11 |
---|
59 | #define IPC_MBOX_CONFIG_RX_ANT_MODE 12 |
---|
60 | #define IPC_MBOX_CONFIG_TX_CTRL_POW 13 |
---|
61 | #define IPC_MBOX_CONFIG_RX_FILTER 14 |
---|
62 | #define IPC_MBOX_MEM_READ_WRITE 15 |
---|
63 | #define IPC_MBOX_LOW_PARAM 16 |
---|
64 | #define IPC_MBOX_LOW_RANDOM_SEED 17 |
---|
65 | #define IPC_MBOX_SET_RADIO_TX_POWER 18 |
---|
66 | |
---|
67 | |
---|
68 | //----------------------------------------------- |
---|
69 | // Macros to Add / Remove delimiter to message ID |
---|
70 | // |
---|
71 | #define IPC_MBOX_MSG_ID(id) (IPC_MBOX_MSG_ID_DELIM | ((id) & 0xFFF)) |
---|
72 | #define IPC_MBOX_MSG_ID_TO_MSG(id) ((id) & 0xFFF) |
---|
73 | |
---|
74 | |
---|
75 | //----------------------------------------------- |
---|
76 | // Mailbox status codes |
---|
77 | // |
---|
78 | #define IPC_MBOX_SUCCESS 0 |
---|
79 | #define IPC_MBOX_INVALID_MSG -1 |
---|
80 | #define IPC_MBOX_NO_MSG_AVAIL -2 |
---|
81 | |
---|
82 | |
---|
83 | //----------------------------------------------- |
---|
84 | // IPC_MBOX_MEM_READ_WRITE arg0 defines |
---|
85 | // |
---|
86 | #define IPC_REG_READ_MODE 0 |
---|
87 | #define IPC_REG_WRITE_MODE 1 |
---|
88 | |
---|
89 | |
---|
90 | |
---|
91 | /*********************** Global Structure Definitions ************************/ |
---|
92 | |
---|
93 | //----------------------------------------------- |
---|
94 | // IPC Message structure |
---|
95 | // - msg_id - Any of the message IDs defined above |
---|
96 | // - num_payload_words - Number of u32 words in the payload |
---|
97 | // - arg0 - Used to pass a single u8 argument as part of the message |
---|
98 | // - payload_ptr - Pointer to payload (can be array of u32 or structure defined below) |
---|
99 | // |
---|
100 | typedef struct wlan_ipc_msg_t{ |
---|
101 | u16 msg_id; |
---|
102 | u8 num_payload_words; |
---|
103 | u8 arg0; |
---|
104 | u32* payload_ptr; |
---|
105 | } wlan_ipc_msg_t; |
---|
106 | |
---|
107 | |
---|
108 | //----------------------------------------------- |
---|
109 | // IPC_MBOX_MEM_READ_WRITE payload structure |
---|
110 | // - Must be u32 aligned |
---|
111 | // |
---|
112 | typedef struct ipc_reg_read_write_t{ |
---|
113 | u32 baseaddr; |
---|
114 | u32 num_words; |
---|
115 | } ipc_reg_read_write_t; |
---|
116 | |
---|
117 | /*************************** Function Prototypes *****************************/ |
---|
118 | |
---|
119 | XMbox* init_mailbox(); |
---|
120 | |
---|
121 | int read_mailbox_msg(wlan_ipc_msg_t* msg); |
---|
122 | int write_mailbox_msg(wlan_ipc_msg_t* msg); |
---|
123 | int send_msg(u16 msg_id, u8 arg, u8 num_words, u32* payload); |
---|
124 | |
---|
125 | #endif /* WLAN_MAC_MAILBOX_UTIL_H_ */ |
---|