/** @file wlan_mac_mailbox_util.h * @brief Mailbox Framework * * This contains code common to both CPU_LOW and CPU_HIGH that allows them * to pass messages to one another through the mailbox. * * @copyright Copyright 2013-2019, Mango Communications. All rights reserved. * Distributed under the Mango Communications Reference Design License * See LICENSE.txt included in the design archive or * at http://mangocomm.com/802.11/license * * This file is part of the Mango 802.11 Reference Design (https://mangocomm.com/802.11) */ #ifndef WLAN_MAC_MAILBOX_UTIL_H_ #define WLAN_MAC_MAILBOX_UTIL_H_ #include "xil_types.h" #include "xmbox.h" //----------------------------------------------- // Hardware defines // // Define the largest possible mailbox message, used by the upper/lower frameworks // for their ipc_msg_*_payload[] variables. 50 words is big enough for all // the IPC messages used by the MAC frameworks. It is still possible for // a LOW_PARAM or MEM__LOW command to exceed this. If this happens // the mailbox util code will print an error and drop the message #define MAILBOX_MSG_MAX_NUM_WORDS 50 //----------------------------------------------- // Mailbox Message ID delimiter // - Appended to each message ID to allow for error checking of // the start of a message // #define IPC_MBOX_MSG_ID_DELIM 0xF000 #define CPU_STATUS_REASON_BOOTED 0 #define CPU_STATUS_REASON_RESPONSE 1 #define CPU_STATUS_REASON_EXCEPTION 2 //----------------------------------------------- // IPC Message IDs // #define IPC_MBOX_RX_PKT_BUF_READY 0 #define IPC_MBOX_TX_PKT_BUF_READY 1 #define IPC_MBOX_TXRX_BEACON_CONFIG 2 #define IPC_MBOX_TX_PKT_BUF_DONE 3 #define IPC_MBOX_PHY_TX_REPORT 4 #define IPC_MBOX_CPU_STATUS 5 #define IPC_MBOX_CONFIG_CHANNEL 7 #define IPC_MBOX_CONFIG_DSSS_EN 8 #define IPC_MBOX_TX_BEACON_DONE 9 #define IPC_MBOX_MCAST_BUFFER_ENABLE 10 #define IPC_MBOX_SET_MAC_TIME 11 #define IPC_MBOX_CONFIG_RX_ANT_MODE 12 #define IPC_MBOX_CONFIG_TX_CTRL_POW 13 #define IPC_MBOX_CONFIG_RX_FILTER 14 #define IPC_MBOX_MEM_READ_WRITE 15 #define IPC_MBOX_LOW_PARAM 16 #define IPC_MBOX_LOW_RANDOM_SEED 17 #define IPC_MBOX_SET_RADIO_TX_POWER 18 //----------------------------------------------- // Macros to Add / Remove delimiter to message ID // #define IPC_MBOX_MSG_ID(id) (IPC_MBOX_MSG_ID_DELIM | ((id) & 0xFFF)) #define IPC_MBOX_MSG_ID_TO_MSG(id) ((id) & 0xFFF) //----------------------------------------------- // Mailbox status codes // #define IPC_MBOX_SUCCESS 0 #define IPC_MBOX_INVALID_MSG -1 #define IPC_MBOX_NO_MSG_AVAIL -2 //----------------------------------------------- // IPC_MBOX_MEM_READ_WRITE arg0 defines // #define IPC_REG_READ_MODE 0 #define IPC_REG_WRITE_MODE 1 /*********************** Global Structure Definitions ************************/ //----------------------------------------------- // IPC Message structure // - msg_id - Any of the message IDs defined above // - num_payload_words - Number of u32 words in the payload // - arg0 - Used to pass a single u8 argument as part of the message // - payload_ptr - Pointer to payload (can be array of u32 or structure defined below) // typedef struct wlan_ipc_msg_t{ u16 msg_id; u8 num_payload_words; u8 arg0; u32* payload_ptr; } wlan_ipc_msg_t; //----------------------------------------------- // IPC_MBOX_MEM_READ_WRITE payload structure // - Must be u32 aligned // typedef struct ipc_reg_read_write_t{ u32 baseaddr; u32 num_words; } ipc_reg_read_write_t; /*************************** Function Prototypes *****************************/ XMbox* init_mailbox(); int read_mailbox_msg(wlan_ipc_msg_t* msg); int write_mailbox_msg(wlan_ipc_msg_t* msg); int send_msg(u16 msg_id, u8 arg, u8 num_words, u32* payload); #endif /* WLAN_MAC_MAILBOX_UTIL_H_ */