A_STATUS BMISetAppStart(HIF_DEVICE *device, A_UINT32 address) { A_UINT32 cid; A_STATUS status; A_UINT32 offset; A_UCHAR data[sizeof(cid) + sizeof(address)]; if (bmiDone) { BMI_DEBUG_PRINTF(ATH_LOG_ERR,"Command disallowed\n"); return A_ERROR; } BMI_DEBUG_PRINTF(ATH_LOG_INF, "BMI Set App Start: Enter (device: 0x%p, address: 0x%x)\n", device, address); cid = BMI_SET_APP_START; offset = 0; A_MEMCPY(&data[offset], &cid, sizeof(cid)); offset += sizeof(cid); A_MEMCPY(&data[offset], &address, sizeof(address)); offset += sizeof(address); status = bmiBufferSend(device, data, offset); if (status != A_OK) { BMI_DEBUG_PRINTF(ATH_LOG_ERR,"Unable to write to the device\n"); return A_ERROR; } BMI_DEBUG_PRINTF(ATH_LOG_INF,"BMI Set App Start: Exit\n"); return A_OK; }
A_STATUS BMILZStreamStart(HIF_DEVICE *device, A_UINT32 address) { A_UINT32 cid; A_STATUS status; A_UINT32 offset; static A_UCHAR data[sizeof(cid) + sizeof(address)]; if (bmiDone) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI LZ Stream Start: Enter (device: 0x%p, address: 0x%x)\n", device, address)); cid = BMI_LZ_STREAM_START; offset = 0; A_MEMCPY(&data[offset], &cid, sizeof(cid)); offset += sizeof(cid); A_MEMCPY(&data[offset], &address, sizeof(address)); offset += sizeof(address); status = bmiBufferSend(device, data, offset); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to Start LZ Stream to the device\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI LZ Stream Start: Exit\n")); return A_OK; }
A_STATUS BMIWriteSOCRegister(A_VOID *pCxt, A_UINT32 address, A_UINT32 param) { A_UINT32 cid; A_STATUS status; A_UINT32 offset, temp; A_ASSERT(BMI_COMMAND_FITS(sizeof(cid) + sizeof(address) + sizeof(param))); memset (pBMICmdBuf, 0, sizeof(cid) + sizeof(address) + sizeof(param)); if (bmiDone) { return A_ERROR; } cid = A_CPU2LE32(BMI_WRITE_SOC_REGISTER); offset = 0; A_MEMCPY(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); offset += sizeof(cid); temp = A_CPU2LE32(address); A_MEMCPY(&(pBMICmdBuf[offset]), &temp, sizeof(address)); offset += sizeof(address); A_MEMCPY(&(pBMICmdBuf[offset]), ¶m, sizeof(param)); offset += sizeof(param); status = bmiBufferSend(pCxt, pBMICmdBuf, offset); if (status != A_OK) { return A_ERROR; } return A_OK; }
A_STATUS BMIrompatchUninstall(HIF_DEVICE *device, A_UINT32 rompatch_id) { A_UINT32 cid; A_STATUS status; A_UINT32 offset; static A_UCHAR data[sizeof(cid) + sizeof(rompatch_id)]; memset (&data, 0, sizeof(cid) + sizeof(rompatch_id)); if (bmiDone) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI rompatch Uninstall: Enter (device: 0x%p, rompatch_id: %d)\n", device, rompatch_id)); cid = BMI_ROMPATCH_UNINSTALL; offset = 0; A_MEMCPY(&data[offset], &cid, sizeof(cid)); offset += sizeof(cid); A_MEMCPY(&data[offset], &rompatch_id, sizeof(rompatch_id)); offset += sizeof(rompatch_id); status = bmiBufferSend(device, data, offset); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI rompatch UNinstall: (rompatch_id=0x%x)\n", rompatch_id)); return A_OK; }
A_STATUS BMIWriteMemory(A_VOID *pCxt, A_UINT32 address, A_UCHAR *buffer, A_UINT32 length) { A_UINT32 cid; A_UINT32 remaining, txlen, temp; const A_UINT32 header = sizeof(cid) + sizeof(address) + sizeof(length); //A_UCHAR alignedBuffer[BMI_DATASZ_MAX]; A_UCHAR *src; A_UINT8 *ptr; A_ASSERT(BMI_COMMAND_FITS(BMI_DATASZ_MAX + header)); memset (pBMICmdBuf, 0, BMI_DATASZ_MAX + header); if (bmiDone) { return A_ERROR; } cid = A_CPU2LE32(BMI_WRITE_MEMORY); remaining = length; while (remaining) { src = &buffer[length - remaining]; if (remaining < (BMI_DATASZ_MAX - header)) { if (remaining & 3) { /* align it with 4 bytes */ remaining = remaining + (4 - (remaining & 3)); //memcpy(alignedBuffer, src, remaining); //src = alignedBuffer; } txlen = remaining; } else { txlen = (BMI_DATASZ_MAX - header); } ptr = pBMICmdBuf; A_MEMCPY(ptr, &cid, sizeof(cid)); ptr += sizeof(cid); temp = A_CPU2LE32(address); A_MEMCPY(ptr, &temp, sizeof(address)); ptr += sizeof(address); temp = A_CPU2LE32(txlen); A_MEMCPY(ptr, &temp, sizeof(txlen)); ptr += sizeof(txlen); A_MEMCPY(ptr, src, txlen); ptr += txlen; if(A_OK != bmiBufferSend(pCxt, pBMICmdBuf, (A_UINT32)(ptr-pBMICmdBuf))){ return A_ERROR; } remaining -= txlen; address += txlen; } return A_OK; }
static void NewLinkEvent(ATH_BT_FILTER_INSTANCE *pInstance, struct nlmsghdr *h, int len) { struct ifinfomsg *ifi; struct rtattr * attr; int attrlen, nlmsg_len, rta_len; ATHBT_FILTER_INFO *pInfo = (ATHBT_FILTER_INFO *)pInstance->pContext; ABF_WLAN_INFO *pAbfWlanInfo = (ABF_WLAN_INFO *)pInfo->pWlanInfo; if (len < sizeof(*ifi)) { A_DEBUG("packet too short\n"); return; } ifi = NLMSG_DATA(h); nlmsg_len = NLMSG_ALIGN(sizeof(struct ifinfomsg)); attrlen = h->nlmsg_len - nlmsg_len; if (attrlen < 0) { A_DEBUG("bad attrlen\n"); return; } attr = (struct rtattr *) (((char *) ifi) + nlmsg_len); rta_len = RTA_ALIGN(sizeof(struct rtattr)); while (RTA_OK(attr, attrlen)) { if (attr->rta_type == IFLA_WIRELESS) { /* * We need to ensure that the event is from the WLAN instance * that we are interested in TODO */ WirelessEvent(pInstance, ((char*)attr) + rta_len, attr->rta_len - rta_len); } else if (attr->rta_type == IFLA_IFNAME) { /* * Shall be used to get the socket descriptor. Also we should do * it only until we get the adapter we are interested in */ if (!pAbfWlanInfo->Handle) { A_DEBUG("WLAN Adapter Interface: %s, Len: %d\n", (((char *)attr) + rta_len), attr->rta_len - rta_len); A_MEMCPY(pAbfWlanInfo->IfName, ((char *)attr + rta_len), attr->rta_len - rta_len); pAbfWlanInfo->IfIndex = if_nametoindex(pAbfWlanInfo->IfName); } else if (ifi->ifi_change && pAbfWlanInfo->IfIndex == ifi->ifi_index) { A_CHAR ifName[IFNAMSIZ]; A_MEMCPY(ifName, ((char *)attr + rta_len), attr->rta_len - rta_len); if (A_MEMCMP(pAbfWlanInfo->IfName, ifName, sizeof(ifName))!=0) { A_MEMCPY(pAbfWlanInfo->IfName, ifName, sizeof(ifName)); } } } attr = RTA_NEXT(attr, attrlen); } }
A_STATUS Abf_WlanIssueFrontEndConfig(ATHBT_FILTER_INFO * pInfo) { WMI_SET_BTCOEX_FE_ANT_CMD btcoexFeAntCmd; WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMD btcoexCoLocatedBtCmd; A_UINT32 buf_fe_ant_cmd[sizeof(A_UINT32) + sizeof(WMI_SET_BTCOEX_FE_ANT_CMD)]; A_UINT32 buf_co_located_bt_cmd[sizeof(A_UINT32) + sizeof(WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMD)]; A_STATUS status; /* Set co-located bt type to 1, generic for any PTA based bluetooth */ buf_co_located_bt_cmd[0] = AR6000_XIOCTL_WMI_SET_BTCOEX_COLOCATED_BT_DEV; if (pInfo->Flags & ABF_BT_CHIP_IS_QCOM) { btcoexCoLocatedBtCmd.btcoexCoLocatedBTdev = 2; } else { btcoexCoLocatedBtCmd.btcoexCoLocatedBTdev = 1; } A_MEMCPY(&buf_co_located_bt_cmd[1], (void *)&btcoexCoLocatedBtCmd, sizeof(WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMD)); status = Abf_WlanDispatchIO(pInfo, AR6000_IOCTL_EXTENDED, (void *)buf_co_located_bt_cmd, (sizeof(WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMD) + sizeof(A_UINT32))); if (A_FAILED(status)) { A_ERR("[%s] Failed to issue Co-located BT configuration\n", __FUNCTION__); return A_ERROR; } if(pInfo->Flags & ABF_FE_ANT_IS_SA) { /* Indicate front end antenna configuration as single antenna */ A_INFO("FLAGS = %x, Issue FE antenna configuration as single \n", pInfo->Flags); btcoexFeAntCmd.btcoexFeAntType = WMI_BTCOEX_FE_ANT_SINGLE; }else { A_INFO("FLAGS = %x, Issue FE antenna configuration as dual \n", pInfo->Flags); btcoexFeAntCmd.btcoexFeAntType = WMI_BTCOEX_FE_ANT_DUAL; } buf_fe_ant_cmd[0] = AR6000_XIOCTL_WMI_SET_BTCOEX_FE_ANT; A_MEMCPY(&buf_fe_ant_cmd[1], (void *)&btcoexFeAntCmd, sizeof(WMI_SET_BTCOEX_FE_ANT_CMD)); status = Abf_WlanDispatchIO(pInfo, AR6000_IOCTL_EXTENDED, (void *)buf_fe_ant_cmd, (sizeof(WMI_SET_BTCOEX_FE_ANT_CMD) + sizeof(A_UINT32))); if (A_FAILED(status)) { A_ERR("[%s] Failed to issue FE ant configuration\n", __FUNCTION__); return A_ERROR; } return A_OK; }
int BMIReadMemory(HIF_DEVICE *device, u32 address, A_UCHAR *buffer, u32 length) { u32 cid; int status; u32 offset; u32 remaining, rxlen; A_ASSERT(BMI_COMMAND_FITS(BMI_DATASZ_MAX + sizeof(cid) + sizeof(address) + sizeof(length))); memset (pBMICmdBuf, 0, BMI_DATASZ_MAX + sizeof(cid) + sizeof(address) + sizeof(length)); if (bmiDone) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Read Memory: Enter (device: 0x%p, address: 0x%x, length: %d)\n", device, address, length)); cid = BMI_READ_MEMORY; remaining = length; while (remaining) { rxlen = (remaining < BMI_DATASZ_MAX) ? remaining : BMI_DATASZ_MAX; offset = 0; A_MEMCPY(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); offset += sizeof(cid); A_MEMCPY(&(pBMICmdBuf[offset]), &address, sizeof(address)); offset += sizeof(address); A_MEMCPY(&(pBMICmdBuf[offset]), &rxlen, sizeof(rxlen)); offset += sizeof(length); status = bmiBufferSend(device, pBMICmdBuf, offset); if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); return A_ERROR; } status = bmiBufferReceive(device, pBMICmdBuf, rxlen, true); if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read from the device\n")); return A_ERROR; } A_MEMCPY(&buffer[length - remaining], pBMICmdBuf, rxlen); remaining -= rxlen; address += rxlen; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Read Memory: Exit\n")); return 0; }
A_STATUS BMIReadMemory(HIF_DEVICE *device, A_UINT32 address, A_UCHAR *buffer, A_UINT32 length) { A_UINT32 cid; A_STATUS status; A_UINT32 offset; A_UINT32 remaining, rxlen; static A_UCHAR data[BMI_DATASZ_MAX + sizeof(cid) + sizeof(address) + sizeof(length)]; memset (&data, 0, BMI_DATASZ_MAX + sizeof(cid) + sizeof(address) + sizeof(length)); if (bmiDone) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Read Memory: Enter (device: 0x%p, address: 0x%x, length: %d)\n", device, address, length)); cid = BMI_READ_MEMORY; remaining = length; while (remaining) { rxlen = (remaining < BMI_DATASZ_MAX) ? remaining : BMI_DATASZ_MAX; offset = 0; A_MEMCPY(&data[offset], &cid, sizeof(cid)); offset += sizeof(cid); A_MEMCPY(&data[offset], &address, sizeof(address)); offset += sizeof(address); A_MEMCPY(&data[offset], &rxlen, sizeof(rxlen)); offset += sizeof(length); status = bmiBufferSend(device, data, offset); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); return A_ERROR; } status = bmiBufferReceive(device, data, rxlen, TRUE); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read from the device\n")); return A_ERROR; } A_MEMCPY(&buffer[length - remaining], data, rxlen); remaining -= rxlen; address += rxlen; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Read Memory: Exit\n")); return A_OK; }
A_STATUS BMIrompatchInstall(HIF_DEVICE *device, A_UINT32 ROM_addr, A_UINT32 RAM_addr, A_UINT32 nbytes, A_UINT32 do_activate, A_UINT32 *rompatch_id) { A_UINT32 cid; A_STATUS status; A_UINT32 offset; static A_UCHAR data[sizeof(cid) + sizeof(ROM_addr) + sizeof(RAM_addr) + sizeof(nbytes) + sizeof(do_activate)]; memset (&data, 0, sizeof(cid) + sizeof(ROM_addr) + sizeof(RAM_addr) + sizeof(nbytes) + sizeof(do_activate)); if (bmiDone) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI rompatch Install: Enter (device: 0x%p, ROMaddr: 0x%x, RAMaddr: 0x%x length: %d activate: %d)\n", device, ROM_addr, RAM_addr, nbytes, do_activate)); cid = BMI_ROMPATCH_INSTALL; offset = 0; A_MEMCPY(&data[offset], &cid, sizeof(cid)); offset += sizeof(cid); A_MEMCPY(&data[offset], &ROM_addr, sizeof(ROM_addr)); offset += sizeof(ROM_addr); A_MEMCPY(&data[offset], &RAM_addr, sizeof(RAM_addr)); offset += sizeof(RAM_addr); A_MEMCPY(&data[offset], &nbytes, sizeof(nbytes)); offset += sizeof(nbytes); A_MEMCPY(&data[offset], &do_activate, sizeof(do_activate)); offset += sizeof(do_activate); status = bmiBufferSend(device, data, offset); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); return A_ERROR; } status = bmiBufferReceive(device, (A_UCHAR *)rompatch_id, sizeof(*rompatch_id), TRUE); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read from the device\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI rompatch Install: (rompatch_id=%d)\n", *rompatch_id)); return A_OK; }
A_STATUS BMIWriteMemory(HIF_DEVICE *device, A_UINT32 address, A_UCHAR *buffer, A_UINT32 length) { A_UINT32 cid; A_STATUS status; A_UINT32 offset; A_UINT32 remaining, txlen; A_UCHAR data[BMI_DATASZ_MAX + sizeof(cid) + sizeof(address) + sizeof(length)]; A_UINT32 header=sizeof(cid) + sizeof(address) + sizeof(length); if (bmiDone) { BMI_DEBUG_PRINTF(ATH_LOG_ERR,"Command disallowed\n"); return A_ERROR; } BMI_DEBUG_PRINTF(ATH_LOG_INF, "BMI Write Memory: Enter (device: 0x%p, address: 0x%x, length: %d)\n", device, address, length); cid = BMI_WRITE_MEMORY; #ifdef ONLY_16BIT length = length + (length % 2); #endif remaining = length; while (remaining) { txlen = (remaining < (BMI_DATASZ_MAX - header)) ? remaining : (BMI_DATASZ_MAX - header); offset = 0; A_MEMCPY(&data[offset], &cid, sizeof(cid)); offset += sizeof(cid); A_MEMCPY(&data[offset], &address, sizeof(address)); offset += sizeof(address); A_MEMCPY(&data[offset], &txlen, sizeof(txlen)); offset += sizeof(txlen); A_MEMCPY(&data[offset], &buffer[length - remaining], txlen); offset += txlen; status = bmiBufferSend(device, data, offset); if (status != A_OK) { BMI_DEBUG_PRINTF(ATH_LOG_ERR,"Unable to write to the device\n"); return A_ERROR; } remaining -= txlen; address += txlen; } BMI_DEBUG_PRINTF(ATH_LOG_INF,"BMI Write Memory: Exit\n"); return A_OK; }
A_STATUS BMILZData(HIF_DEVICE *device, A_UCHAR *buffer, A_UINT32 length, struct ol_ath_softc_net80211 *scn) { A_UINT32 cid; A_STATUS status; A_UINT32 offset; A_UINT32 remaining, txlen; const A_UINT32 header = sizeof(cid) + sizeof(length); A_UCHAR *pBMICmdBuf = scn->pBMICmdBuf; ASSERT(BMI_COMMAND_FITS(BMI_DATASZ_MAX+header)); memset (pBMICmdBuf, 0, BMI_DATASZ_MAX+header); if (scn->bmiDone) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Send LZ Data: Enter (device: 0x%p, length: %d)\n", device, length)); cid = BMI_LZ_DATA; remaining = length; while (remaining) { txlen = (remaining < (BMI_DATASZ_MAX - header)) ? remaining : (BMI_DATASZ_MAX - header); offset = 0; A_MEMCPY(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); offset += sizeof(cid); A_MEMCPY(&(pBMICmdBuf[offset]), &txlen, sizeof(txlen)); offset += sizeof(txlen); A_MEMCPY(&(pBMICmdBuf[offset]), &buffer[length - remaining], txlen); offset += txlen; status = HIFExchangeBMIMsg(device, pBMICmdBuf, offset, NULL, NULL, 0); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); return A_ERROR; } remaining -= txlen; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI LZ Data: Exit\n")); return A_OK; }
A_STATUS BMIReadMemory(A_VOID *pCxt, A_UINT32 address, A_UCHAR *buffer, A_UINT32 length) { A_UINT32 cid; A_STATUS status; A_UINT32 offset; A_UINT32 remaining, rxlen, temp; A_ASSERT(BMI_COMMAND_FITS(BMI_DATASZ_MAX + sizeof(cid) + sizeof(address) + sizeof(length))); memset (pBMICmdBuf, 0, BMI_DATASZ_MAX + sizeof(cid) + sizeof(address) + sizeof(length)); if (bmiDone) { return A_ERROR; } cid = A_CPU2LE32(BMI_READ_MEMORY); remaining = length; while (remaining) { //rxlen = (remaining < BMI_DATASZ_MAX) ? remaining : BMI_DATASZ_MAX; rxlen = (remaining < 4) ? remaining : 4; offset = 0; A_MEMCPY(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); offset += sizeof(cid); temp = A_CPU2LE32(address); A_MEMCPY(&(pBMICmdBuf[offset]), &temp, sizeof(address)); offset += sizeof(address); temp = A_CPU2LE32(rxlen); A_MEMCPY(&(pBMICmdBuf[offset]), &temp, sizeof(rxlen)); offset += sizeof(length); status = bmiBufferSend(pCxt, pBMICmdBuf, offset); if (status != A_OK) { return A_ERROR; } status = bmiBufferReceive(pCxt, pBMICmdBuf, rxlen, TRUE); if (status != A_OK) { return A_ERROR; } A_MEMCPY(&buffer[length - remaining], pBMICmdBuf, rxlen); remaining -= rxlen; address += rxlen; } return A_OK; }
int BMILZData(HIF_DEVICE *device, A_UCHAR *buffer, u32 length) { u32 cid; int status; u32 offset; u32 remaining, txlen; const u32 header = sizeof(cid) + sizeof(length); A_ASSERT(BMI_COMMAND_FITS(BMI_DATASZ_MAX+header)); memset (pBMICmdBuf, 0, BMI_DATASZ_MAX+header); if (bmiDone) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Send LZ Data: Enter (device: 0x%p, length: %d)\n", device, length)); cid = BMI_LZ_DATA; remaining = length; while (remaining) { txlen = (remaining < (BMI_DATASZ_MAX - header)) ? remaining : (BMI_DATASZ_MAX - header); offset = 0; A_MEMCPY(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); offset += sizeof(cid); A_MEMCPY(&(pBMICmdBuf[offset]), &txlen, sizeof(txlen)); offset += sizeof(txlen); A_MEMCPY(&(pBMICmdBuf[offset]), &buffer[length - remaining], txlen); offset += txlen; status = bmiBufferSend(device, pBMICmdBuf, offset); if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); return A_ERROR; } remaining -= txlen; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI LZ Data: Exit\n")); return 0; }
A_STATUS BMILZData(HIF_DEVICE *device, A_UCHAR *buffer, A_UINT32 length) { A_UINT32 cid; A_STATUS status; A_UINT32 offset; A_UINT32 remaining, txlen; const A_UINT32 header = sizeof(cid) + sizeof(length); static A_UCHAR data[BMI_DATASZ_MAX + sizeof(cid) + sizeof(length)]; memset (&data, 0, BMI_DATASZ_MAX+header); if (bmiDone) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Send LZ Data: Enter (device: 0x%p, length: %d)\n", device, length)); cid = BMI_LZ_DATA; remaining = length; while (remaining) { txlen = (remaining < (BMI_DATASZ_MAX - header)) ? remaining : (BMI_DATASZ_MAX - header); offset = 0; A_MEMCPY(&data[offset], &cid, sizeof(cid)); offset += sizeof(cid); A_MEMCPY(&data[offset], &txlen, sizeof(txlen)); offset += sizeof(txlen); A_MEMCPY(&data[offset], &buffer[length - remaining], txlen); offset += txlen; status = bmiBufferSend(device, data, offset); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); return A_ERROR; } remaining -= txlen; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI LZ Data: Exit\n")); return A_OK; }
void CAR6KMini::removeNewStation(A_UINT8 *mac) { A_INT8 i; A_UINT8 sta_mac[6] = {0}; A_MEMCPY(sta_mac,mac,ETHERNET_MAC_ADDRESS_LENGTH); if(IS_MAC_NULL(sta_mac)) { return ; } for(i=0; i < AP_MAX_NUM_STA; i++) { if(A_MEMCMP(m_staList[i].mac, sta_mac, 6)==0) { /* Zero out the state fields */ A_MEMZERO(m_staList[i].mac, 6); A_MEMZERO(m_staList[i].wpa_ie, IEEE80211_MAX_IE); m_staList[i].aid = 0; m_staList[i].flags = 0; m_staList[i].m_keyState = 0; m_staList[i].PTKlength = 0; m_staList[i].hnd_shk_completed = FALSE; A_MEMZERO(m_staList[i].ANonce, sizeof (m_staList[i].ANonce)); A_MEMZERO(m_staList[i].SNonce, sizeof (m_staList[i].SNonce)); A_MEMZERO(m_staList[i].PTK, sizeof (m_staList[i].PTK)); m_staListIndex = m_staListIndex & ~(1 << i); flushNdisPacketQ(&(m_staList[i].ucastq)); m_AP_conn_sta -- ; } } }
/* Initializes the HTC layer */ A_STATUS HTCInit(HTC_INIT_INFO *pInitInfo) { HTC_CALLBACKS htcCallbacks; AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCInit: Enter\n")); if (HTCInitialized) { AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCInit: Exit\n")); return A_OK; } A_MEMCPY(&HTCInitInfo,pInitInfo,sizeof(HTC_INIT_INFO)); A_MEMZERO(&htcCallbacks, sizeof(HTC_CALLBACKS)); /* setup HIF layer callbacks */ htcCallbacks.deviceInsertedHandler = HTCTargetInsertedHandler; htcCallbacks.deviceRemovedHandler = HTCTargetRemovedHandler; /* the device layer handles these */ htcCallbacks.rwCompletionHandler = DevRWCompletionHandler; htcCallbacks.dsrHandler = DevDsrHandler; HIFInit(&htcCallbacks); HTCInitialized = TRUE; AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCInit: Exit\n")); return A_OK; }
void DumpAR6KDevState(AR6K_DEVICE *pDev) { int status; AR6K_IRQ_ENABLE_REGISTERS regs; AR6K_IRQ_PROC_REGISTERS procRegs; LOCK_AR6K(pDev); /* copy into our temp area */ A_MEMCPY(®s,&pDev->IrqEnableRegisters,AR6K_IRQ_ENABLE_REGS_SIZE); UNLOCK_AR6K(pDev); /* load the register table from the device */ status = HIFReadWrite(pDev->HIFDevice, HOST_INT_STATUS_ADDRESS, (u8 *)&procRegs, AR6K_IRQ_PROC_REGS_SIZE, HIF_RD_SYNC_BYTE_INC, NULL); if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("DumpAR6KDevState : Failed to read register table (%d) \n",status)); return; } DevDumpRegisters(pDev,&procRegs,®s); if (pDev->GMboxInfo.pStateDumpCallback != NULL) { pDev->GMboxInfo.pStateDumpCallback(pDev->GMboxInfo.pProtocolContext); } /* dump any bus state at the HIF layer */ HIFConfigureDevice(pDev->HIFDevice,HIF_DEVICE_DEBUG_BUS_STATE,NULL,0); }
A_STATUS BMIDone(HIF_DEVICE *device) { A_STATUS status; A_UINT32 cid; if (bmiDone) { AR_DEBUG_PRINTF (ATH_DEBUG_BMI, ("BMIDone skipped\n")); return A_OK; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Done: Enter (device: 0x%p)\n", device)); bmiDone = TRUE; cid = BMI_DONE; A_MEMCPY(pBMICmdBuf,&cid,sizeof(cid)); status = HIFExchangeBMIMsg(device, pBMICmdBuf, sizeof(cid), NULL, NULL, 0); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); return A_ERROR; } if (pBMICmdBuf) { A_FREE(pBMICmdBuf); pBMICmdBuf = NULL; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Done: Exit\n")); return A_OK; }
A_STATUS _qcom_p2p_event_persistent_list(A_UINT8 device_id, A_UINT8 * pEvtBuffer, int len) { if (p2p_msg_area_ptr) { A_UINT32 status; if (pEvtBuffer) { /* Copy to common message area and then call tx_queue_send to wake up the * thread waiting on receive. No need for locking the message area. Race * condition between application threads is prevented by having a check on * tx_queue_create. If queue is already created (and in use), API will * return an error */ A_MEMCPY(p2p_msg_area_ptr, pEvtBuffer, P2P_NETWORK_LIST_SIZE); status = 1; } else { status = 0; } if (p2p_msg_queue.tx_queue_id == TX_QUEUE_ID) { tx_queue_send(&p2p_msg_queue, &status, TX_NO_WAIT); } return A_OK; } return A_ERROR; }
A_STATUS BMIExecute(HIF_DEVICE *device, A_UINT32 address, A_UINT32 *param, struct ol_ath_softc_net80211 *scn) { A_UINT32 cid; A_STATUS status; A_UINT32 offset; A_UINT32 paramLen; A_UCHAR *pBMICmdBuf = scn->pBMICmdBuf; A_UCHAR *pBMIRspBuf = scn->pBMIRspBuf; ASSERT(BMI_COMMAND_FITS(sizeof(cid) + sizeof(address) + sizeof(param))); memset (pBMICmdBuf, 0, sizeof(cid) + sizeof(address) + sizeof(param)); memset (pBMIRspBuf, 0, sizeof(cid) + sizeof(address) + sizeof(param)); if (scn->bmiDone) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Execute: Enter (device: 0x%p, address: 0x%x, param: %d)\n", device, address, *param)); cid = BMI_EXECUTE; offset = 0; A_MEMCPY(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); offset += sizeof(cid); A_MEMCPY(&(pBMICmdBuf[offset]), &address, sizeof(address)); offset += sizeof(address); A_MEMCPY(&(pBMICmdBuf[offset]), param, sizeof(*param)); offset += sizeof(*param); paramLen = sizeof(*param); status = HIFExchangeBMIMsg(device, pBMICmdBuf, offset, pBMIRspBuf, ¶mLen, 0); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read from the device\n")); return A_ERROR; } A_MEMCPY(param, pBMIRspBuf, sizeof(*param)); AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Execute: Exit (param: %d)\n", *param)); return A_OK; }
int BMIExecute(HIF_DEVICE *device, u32 address, u32 *param) { u32 cid; int status; u32 offset; A_ASSERT(BMI_COMMAND_FITS(sizeof(cid) + sizeof(address) + sizeof(param))); memset (pBMICmdBuf, 0, sizeof(cid) + sizeof(address) + sizeof(param)); if (bmiDone) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Execute: Enter (device: 0x%p, address: 0x%x, param: %d)\n", device, address, *param)); cid = BMI_EXECUTE; offset = 0; A_MEMCPY(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); offset += sizeof(cid); A_MEMCPY(&(pBMICmdBuf[offset]), &address, sizeof(address)); offset += sizeof(address); A_MEMCPY(&(pBMICmdBuf[offset]), param, sizeof(*param)); offset += sizeof(*param); status = bmiBufferSend(device, pBMICmdBuf, offset); if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); return A_ERROR; } status = bmiBufferReceive(device, pBMICmdBuf, sizeof(*param), false); if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read from the device\n")); return A_ERROR; } A_MEMCPY(param, pBMICmdBuf, sizeof(*param)); AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Execute: Exit (param: %d)\n", *param)); return 0; }
A_STATUS BMIGetTargetInfo(HIF_DEVICE *device, struct bmi_target_info *targ_info, struct ol_ath_softc_net80211 *scn) { #ifndef HIF_MESSAGE_BASED #else A_STATUS status; A_UCHAR *pBMICmdBuf = scn->pBMICmdBuf; A_UCHAR *pBMIRspBuf = scn->pBMIRspBuf; #endif if (scn->bmiDone) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("BMI Get Target Info Command disallowed\n")); return A_ERROR; } #ifndef HIF_MESSAGE_BASED /* getting the target ID requires special handling because of the variable length * message */ return HIFRegBasedGetTargetInfo(device,targ_info); #else { A_UINT32 cid; A_UINT32 length; cid = BMI_GET_TARGET_INFO; A_MEMCPY(pBMICmdBuf,&cid,sizeof(cid)); length = sizeof(struct bmi_target_info); status = HIFExchangeBMIMsg(device, pBMICmdBuf, sizeof(cid), (A_UINT8 *)pBMIRspBuf, &length, BMI_EXCHANGE_TIMEOUT_MS); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to get target information from the device\n")); return A_ERROR; } A_MEMCPY(targ_info, pBMIRspBuf, length); return status; } #endif }
/* registered target arrival callback from the HIF layer */ HTC_HANDLE HTCCreate(void *hHIF, HTC_INIT_INFO *pInfo) { A_STATUS status = A_OK; HTC_TARGET *target = NULL; do { if ((target = (HTC_TARGET *)A_MALLOC(sizeof(HTC_TARGET))) == NULL) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("HTC : Unable to allocate memory\n")); status = A_ERROR; break; } A_MEMCPY(&target->HTCInitInfo,pInfo,sizeof(HTC_INIT_INFO)); adf_os_mem_zero(target, sizeof(HTC_TARGET)); adf_os_spinlock_init(&target->HTCLock); adf_os_spinlock_init(&target->HTCRxLock); adf_os_spinlock_init(&target->HTCTxLock); /* setup HIF layer callbacks */ adf_os_mem_zero(&htcCallbacks, sizeof(completion_callbacks_t)); htcCallbacks.Context = target; htcCallbacks.rxCompletionHandler = HTCRxCompletionHandler; htcCallbacks.txCompletionHandler = HTCTxCompletionHandler; HIFPostInit(hHIF, target, &htcCallbacks); target->hif_dev = hHIF; adf_os_init_mutex(&target->htc_rdy_mutex); adf_os_mutex_acquire(&target->htc_rdy_mutex); /* Get HIF default pipe for HTC message exchange */ pEndpoint = &target->EndPoint[ENDPOINT0]; HIFGetDefaultPipe(hHIF, &pEndpoint->UL_PipeID, &pEndpoint->DL_PipeID); adf_os_print("[Default Pipe]UL: %x, DL: %x\n", pEndpoint->UL_PipeID, pEndpoint->DL_PipeID); /* TODO : other init */ } while (FALSE); target->host_handle = htcInfo.pContext; /* TODO INTEGRATION supply from host os handle for any os specific calls*/ target->os_handle = NULL; if (A_FAILED(status)) { HTCCleanup(target); target = NULL; } return (HTC_HANDLE)target; }
A_STATUS DevEnableInterrupts(AR6K_DEVICE *pDev) { A_STATUS status; AR6K_IRQ_ENABLE_REGISTERS regs; LOCK_AR6K(pDev); /* Enable all the interrupts except for the internal AR6000 CPU interrupt */ pDev->IrqEnableRegisters.int_status_enable = INT_STATUS_ENABLE_ERROR_SET(0x01) | INT_STATUS_ENABLE_CPU_SET(0x01) | INT_STATUS_ENABLE_COUNTER_SET(0x01); if (NULL == pDev->GetPendingEventsFunc) { pDev->IrqEnableRegisters.int_status_enable |= INT_STATUS_ENABLE_MBOX_DATA_SET(0x01); } else { /* The HIF layer provided us with a pending events function which means that * the detection of pending mbox messages is handled in the HIF layer. * This is the case for the SPI2 interface. * In the normal case we enable MBOX interrupts, for the case * with HIFs that offer this mechanism, we keep these interrupts * masked */ pDev->IrqEnableRegisters.int_status_enable &= ~INT_STATUS_ENABLE_MBOX_DATA_SET(0x01); } /* Set up the CPU Interrupt Status Register */ pDev->IrqEnableRegisters.cpu_int_status_enable = CPU_INT_STATUS_ENABLE_BIT_SET(0x00); /* Set up the Error Interrupt Status Register */ pDev->IrqEnableRegisters.error_status_enable = ERROR_STATUS_ENABLE_RX_UNDERFLOW_SET(0x01) | ERROR_STATUS_ENABLE_TX_OVERFLOW_SET(0x01); /* Set up the Counter Interrupt Status Register (only for debug interrupt to catch fatal errors) */ pDev->IrqEnableRegisters.counter_int_status_enable = COUNTER_INT_STATUS_ENABLE_BIT_SET(AR6K_TARGET_DEBUG_INTR_MASK); /* copy into our temp area */ A_MEMCPY(®s,&pDev->IrqEnableRegisters,AR6K_IRQ_ENABLE_REGS_SIZE); UNLOCK_AR6K(pDev); /* always synchronous */ status = HIFReadWrite(pDev->HIFDevice, INT_STATUS_ENABLE_ADDRESS, ®s.int_status_enable, AR6K_IRQ_ENABLE_REGS_SIZE, HIF_WR_SYNC_BYTE_INC, NULL); if (status != A_OK) { /* Can't write it for some reason */ AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to update interrupt control registers err: %d\n", status)); } return status; }
A_STATUS BMIExecute(HIF_DEVICE *device, A_UINT32 address, A_UINT32 *param) { A_UINT32 cid; A_STATUS status; A_UINT32 offset; static A_UCHAR data[sizeof(cid) + sizeof(address) + sizeof(*param)]; memset (&data, 0, sizeof(cid) + sizeof(address) + sizeof(*param)); if (bmiDone) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Execute: Enter (device: 0x%p, address: 0x%x, param: %d)\n", device, address, *param)); cid = BMI_EXECUTE; offset = 0; A_MEMCPY(&data[offset], &cid, sizeof(cid)); offset += sizeof(cid); A_MEMCPY(&data[offset], &address, sizeof(address)); offset += sizeof(address); A_MEMCPY(&data[offset], param, sizeof(*param)); offset += sizeof(*param); status = bmiBufferSend(device, data, offset); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); return A_ERROR; } status = bmiBufferReceive(device, data, sizeof(*param), FALSE); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read from the device\n")); return A_ERROR; } A_MEMCPY(param, data, sizeof(*param)); AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Execute: Exit (param: %d)\n", *param)); return A_OK; }
void CAR6KMini::addNewStation(A_UINT8 *mac,A_UINT16 aid,A_UINT8 *wpaie,A_UINT8 ielen) { A_INT8 free_slot=-1,i; for(i=0;i<AP_MAX_NUM_STA;i++) { if(A_MEMCMP(m_staList[i].mac,mac,6) == 0) { NDIS_DEBUG_PRINTF(ATH_LOG_TRC,"AR6K: Station Already Available"); return ; /* Station already available cond. */ } if(!((1 << i) & m_staListIndex)) { free_slot = i; break; } } if(free_slot >= 0) { A_MEMCPY(m_staList[free_slot].mac,mac,6); A_MEMCPY(m_staList[free_slot].wpa_ie,wpaie,ielen); m_staList[free_slot].aid = aid; m_staList[free_slot].hnd_shk_completed = FALSE; m_staList[i].m_keyState = 0; m_staList[i].PTKlength = 0; A_MEMZERO(m_staList[i].ANonce, sizeof (m_staList[i].ANonce)); A_MEMZERO(m_staList[i].SNonce, sizeof (m_staList[i].SNonce)); A_MEMZERO(m_staList[i].PTK, sizeof (m_staList[i].PTK)); m_staListIndex = m_staListIndex | (1 << free_slot); InitializeListHead(&m_staList[free_slot].ucastq); m_AP_conn_sta ++; } else { NDIS_DEBUG_PRINTF(ATH_LOG_TRC,"AR6K: Error Adding New Station"); } if (m_AP_conn_sta == 1) { NdisMIndicateStatus (m_MiniportAdapterHandle, NDIS_STATUS_MEDIA_CONNECT, 0, 0); NdisMIndicateStatusComplete (m_MiniportAdapterHandle); } }
/* * Add len # of bytes to the beginning of the network buffer * pointed to by bufPtr and also fill with data */ A_STATUS a_netbuf_push_data(void *bufPtr, char *srcPtr, A_INT32 len) { skb_push((struct sk_buff *) bufPtr, len); A_MEMCPY(((struct sk_buff *)bufPtr)->data, srcPtr, len); return A_OK; }
/* * Removes specified number of bytes from the beginning of the buffer * and return the data */ A_STATUS a_netbuf_pull_data(void *bufPtr, char *dstPtr, A_INT32 len) { A_MEMCPY(dstPtr, ((struct sk_buff *)bufPtr)->data, len); skb_pull((struct sk_buff *)bufPtr, len); return A_OK; }
A_STATUS FMIReadFlash(HIF_DEVICE *device, A_UINT32 address, A_UCHAR *buffer, A_UINT32 length) { struct read_cmd_s cmd; A_STATUS status; A_UINT32 remaining, rxlen; const A_UINT32 header = sizeof(cmd); A_UCHAR data[FMI_DATASZ_RMAX + header]; if (fmiDone) { AR_DEBUG_PRINTF(DBG_FMI, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(DBG_FMI, ("FMI Read Flash: Enter (device: 0x%p, address: 0x%x, length: %d)\n", device, address, length)); remaining = length; while (remaining) { rxlen = (remaining < FMI_DATASZ_RMAX) ? remaining : FMI_DATASZ_RMAX; cmd.command = FLASH_READ; cmd.address = address; cmd.length = rxlen; A_MEMCPY(&data[0], &cmd, sizeof(cmd)); status = bmiBufferSend(device, data, sizeof(cmd)); if (status != A_OK) { AR_DEBUG_PRINTF(DBG_FMI, ("Unable to write to the device\n")); return A_ERROR; } status = bmiBufferReceive(device, data, rxlen, TRUE); if (status != A_OK) { AR_DEBUG_PRINTF(DBG_FMI, ("Unable to read from the device\n")); return A_ERROR; } A_MEMCPY(&buffer[length - remaining], data, rxlen); remaining -= rxlen; address += rxlen; } AR_DEBUG_PRINTF(DBG_FMI, ("FMI Read Flash: Exit\n")); return A_OK; }