⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 atheros_2_0_function.patch

📁 openmoko 使用的sdio wifi驱动源码
💻 PATCH
📖 第 1 页 / 共 5 页
字号:
+     */+    if (skipflash)+    {+        ar6000_reset_device_skipflash(ar->arHifDevice);+            }++    BMIInit();+    {+        struct bmi_target_info targ_info;++        if (BMIGetTargetInfo(ar->arHifDevice, &targ_info) != A_OK) {+            return;+        }++        ar->arVersion.target_ver = targ_info.target_ver;+        ar->arTargetType = targ_info.target_type;+    }++    if (enableuartprint) {+        A_UINT32 param;+        param = 1;+        if (BMIWriteMemory(ar->arHifDevice,+                           HOST_INTEREST_ITEM_ADDRESS(ar, hi_serial_enable),+                           (A_UCHAR *)&param,+                           4)!= A_OK)+        {+             AR_DEBUG_PRINTF("BMIWriteMemory for enableuartprint failed \n");+             return ;+        }+        AR_DEBUG_PRINTF("Serial console prints enabled\n");+    }+#ifdef CONFIG_HOST_TCMD_SUPPORT+    if(testmode) {+        ar->arTargetMode = AR6000_TCMD_MODE;+    }else {+        ar->arTargetMode = AR6000_WLAN_MODE;+    }+#endif+    if (enabletimerwar) {+        A_UINT32 param;++        if (BMIReadMemory(ar->arHifDevice,+            HOST_INTEREST_ITEM_ADDRESS(ar, hi_option_flag),+            (A_UCHAR *)&param,+            4)!= A_OK)+        {+            AR_DEBUG_PRINTF("BMIReadMemory for enabletimerwar failed \n");+            return;+        }++        param |= HI_OPTION_TIMER_WAR;++        if (BMIWriteMemory(ar->arHifDevice,+            HOST_INTEREST_ITEM_ADDRESS(ar, hi_option_flag),+            (A_UCHAR *)&param,+            4) != A_OK)+        {+            AR_DEBUG_PRINTF("BMIWriteMemory for enabletimerwar failed \n");+            return;+        }+        AR_DEBUG_PRINTF("Timer WAR enabled\n");+    }+++        /* since BMIInit is called in the driver layer, we have to set the block+         * size here for the target */++    if (A_FAILED(ar6000_SetHTCBlockSize(ar))) {+        return;+    }++    spin_lock_init(&ar->arLock);++    /* Don't install the init function if BMI is requested */+    if(!bmienable)+    {+        dev->init = ar6000_init;+    } else {+        AR_DEBUG_PRINTF(" BMI enabled \n");+    }++    dev->open = &ar6000_open;+    dev->stop = &ar6000_close;+    dev->hard_start_xmit = &ar6000_data_tx;+    dev->get_stats = &ar6000_get_stats;++    /* dev->tx_timeout = ar6000_tx_timeout; */+    dev->do_ioctl = &ar6000_ioctl;+    dev->watchdog_timeo = AR6000_TX_TIMEOUT;+    ar6000_ioctl_iwsetup(&ath_iw_handler_def);+    dev->wireless_handlers = &ath_iw_handler_def;+    ath_iw_handler_def.get_wireless_stats = ar6000_get_iwstats; /*Displayed via proc fs */++    /*+     * We need the OS to provide us with more headroom in order to+     * perform dix to 802.3, WMI header encap, and the HTC header+     */+    dev->hard_header_len = ETH_HLEN + sizeof(ATH_LLC_SNAP_HDR) ++        sizeof(WMI_DATA_HDR) + HTC_HEADER_LEN;++    /* This runs the init function */+    if (register_netdev(dev)) {+        AR_DEBUG_PRINTF("ar6000_avail: register_netdev failed\n");+        ar6000_destroy(dev, 0);+        return;+    }++    HTCSetInstance(ar->arHtcTarget, ar);++    /* We only register the device in the global list if we succeed. */+    /* If the device is in the global list, it will be destroyed     */+    /* when the module is unloaded.                                  */+    ar6000_devices[device_index] = dev;++    AR_DEBUG_PRINTF("ar6000_avail: name=%s htcTarget=0x%x, dev=0x%x (%d), ar=0x%x\n",+                    dev->name, (A_UINT32)HTCHandle, (A_UINT32)dev, device_index,+                    (A_UINT32)ar);+}++static void ar6000_target_failure(void *Instance, A_STATUS Status)+{+    AR_SOFTC_T *ar = (AR_SOFTC_T *)Instance;+    WMI_TARGET_ERROR_REPORT_EVENT errEvent;+    static A_BOOL sip = FALSE;++    if (Status != A_OK) {+        if (timer_pending(&ar->arHBChallengeResp.timer)) {+            A_UNTIMEOUT(&ar->arHBChallengeResp.timer);+        }++        /* try dumping target assertion information (if any) */+        ar6000_dump_target_assert_info(ar->arHifDevice,ar->arTargetType);++        /*+         * Fetch the logs from the target via the diagnostic+         * window.+         */+        ar6000_dbglog_get_debug_logs(ar);++        /* Report the error only once */+        if (!sip) {+            sip = TRUE;+            errEvent.errorVal = WMI_TARGET_COM_ERR |+                                WMI_TARGET_FATAL_ERR;+            ar6000_send_event_to_app(ar, WMI_ERROR_REPORT_EVENTID,+                                     (A_UINT8 *)&errEvent,+                                     sizeof(WMI_TARGET_ERROR_REPORT_EVENT));+        }+    }+}++static void+ar6000_unavail_ev(void *Instance)+{+    AR_SOFTC_T *ar = (AR_SOFTC_T *)Instance;+        /* NULL out it's entry in the global list */+    ar6000_devices[ar->arDeviceIndex] = NULL;+    ar6000_destroy(ar->arNetDev, 1);+}++/*+ * We need to differentiate between the surprise and planned removal of the+ * device because of the following consideration:+ * - In case of surprise removal, the hcd already frees up the pending+ *   for the device and hence there is no need to unregister the function+ *   driver inorder to get these requests. For planned removal, the function+ *   driver has to explictly unregister itself to have the hcd return all the+ *   pending requests before the data structures for the devices are freed up.+ *   Note that as per the current implementation, the function driver will+ *   end up releasing all the devices since there is no API to selectively+ *   release a particular device.+ * - Certain commands issued to the target can be skipped for surprise+ *   removal since they will anyway not go through.+ */+static void+ar6000_destroy(struct net_device *dev, unsigned int unregister)+{+    AR_SOFTC_T *ar;++    AR_DEBUG_PRINTF("+ar6000_destroy \n");++    if((dev == NULL) || ((ar = netdev_priv(dev)) == NULL))+    {+        AR_DEBUG_PRINTF("%s(): Failed to get device structure.\n", __func__);+        return;+    }++    /* Stop the transmit queues */+    netif_stop_queue(dev);++    /* Disable the target and the interrupts associated with it */+    if (ar->arWmiReady == TRUE)+    {+        if (!bypasswmi)+        {+            if (ar->arConnected == TRUE || ar->arConnectPending == TRUE)+            {+                AR_DEBUG_PRINTF("%s(): Disconnect\n", __func__);+                AR6000_SPIN_LOCK(&ar->arLock, 0);+                ar6000_init_profile_info(ar);+                AR6000_SPIN_UNLOCK(&ar->arLock, 0);+                wmi_disconnect_cmd(ar->arWmi);+            }++            ar6000_dbglog_get_debug_logs(ar);+            ar->arWmiReady  = FALSE;+            ar->arConnected = FALSE;+            ar->arConnectPending = FALSE;+            wmi_shutdown(ar->arWmi);+            ar->arWmiEnabled = FALSE;+            ar->arWmi = NULL;+            ar->arWlanState = WLAN_ENABLED;+#ifdef USER_KEYS+            ar->user_savedkeys_stat = USER_SAVEDKEYS_STAT_INIT;+            ar->user_key_ctrl      = 0;+#endif+        }++         AR_DEBUG_PRINTF("%s(): WMI stopped\n", __func__);+    }+    else+    {+        AR_DEBUG_PRINTF("%s(): WMI not ready 0x%08x 0x%08x\n",+            __func__, (unsigned int) ar, (unsigned int) ar->arWmi);++        /* Shut down WMI if we have started it */+        if(ar->arWmiEnabled == TRUE)+        {+            AR_DEBUG_PRINTF("%s(): Shut down WMI\n", __func__);+            wmi_shutdown(ar->arWmi);+            ar->arWmiEnabled = FALSE;+            ar->arWmi = NULL;+        }+    }++    /* stop HTC */+    HTCStop(ar->arHtcTarget);++    /* set the instance to NULL so we do not get called back on remove incase we+     * we're explicity destroyed by module unload */+    HTCSetInstance(ar->arHtcTarget, NULL);++    if (resetok) {+        /* try to reset the device if we can+         * The driver may have been configure NOT to reset the target during+         * a debug session */+        AR_DEBUG_PRINTF(" Attempting to reset target on instance destroy.... \n");+        ar6000_reset_device(ar->arHifDevice, ar->arTargetType);+    } else {+        AR_DEBUG_PRINTF(" Host does not want target reset. \n");+    }++       /* Done with cookies */+    ar6000_cookie_cleanup(ar);++    /* Cleanup BMI */+    BMIInit();++    /* Clear the tx counters */+    memset(tx_attempt, 0, sizeof(tx_attempt));+    memset(tx_post, 0, sizeof(tx_post));+    memset(tx_complete, 0, sizeof(tx_complete));+++    /* Free up the device data structure */+    if (unregister)+	    unregister_netdev(dev);+#ifndef free_netdev+    kfree(dev);+#else+    free_netdev(dev);+#endif++    AR_DEBUG_PRINTF("-ar6000_destroy \n");+}++static void ar6000_detect_error(unsigned long ptr)+{+    struct net_device *dev = (struct net_device *)ptr;+    AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;+    WMI_TARGET_ERROR_REPORT_EVENT errEvent;++    AR6000_SPIN_LOCK(&ar->arLock, 0);++    if (ar->arHBChallengeResp.outstanding) {+        ar->arHBChallengeResp.missCnt++;+    } else {+        ar->arHBChallengeResp.missCnt = 0;+    }++    if (ar->arHBChallengeResp.missCnt > ar->arHBChallengeResp.missThres) {+        /* Send Error Detect event to the application layer and do not reschedule the error detection module timer */+        ar->arHBChallengeResp.missCnt = 0;+        ar->arHBChallengeResp.seqNum = 0;+        errEvent.errorVal = WMI_TARGET_COM_ERR | WMI_TARGET_FATAL_ERR;+        AR6000_SPIN_UNLOCK(&ar->arLock, 0);+        ar6000_send_event_to_app(ar, WMI_ERROR_REPORT_EVENTID,+                                 (A_UINT8 *)&errEvent,+                                 sizeof(WMI_TARGET_ERROR_REPORT_EVENT));+        return;+    }++    /* Generate the sequence number for the next challenge */+    ar->arHBChallengeResp.seqNum++;+    ar->arHBChallengeResp.outstanding = TRUE;++    AR6000_SPIN_UNLOCK(&ar->arLock, 0);++    /* Send the challenge on the control channel */+    if (wmi_get_challenge_resp_cmd(ar->arWmi, ar->arHBChallengeResp.seqNum, DRV_HB_CHALLENGE) != A_OK) {+        AR_DEBUG_PRINTF("Unable to send heart beat challenge\n");+    }+++    /* Reschedule the timer for the next challenge */+    A_TIMEOUT_MS(&ar->arHBChallengeResp.timer, ar->arHBChallengeResp.frequency * 1000, 0);+}++void ar6000_init_profile_info(AR_SOFTC_T *ar)+{+    ar->arSsidLen            = 0;+    A_MEMZERO(ar->arSsid, sizeof(ar->arSsid));+    ar->arNetworkType        = INFRA_NETWORK;+    ar->arDot11AuthMode      = OPEN_AUTH;+    ar->arAuthMode           = NONE_AUTH;+    ar->arPairwiseCrypto     = NONE_CRYPT;+    ar->arPairwiseCryptoLen  = 0;+    ar->arGroupCrypto        = NONE_CRYPT;+    ar->arGroupCryptoLen     = 0;+    A_MEMZERO(ar->arWepKeyList, sizeof(ar->arWepKeyList));+    A_MEMZERO(ar->arReqBssid, sizeof(ar->arReqBssid));+    A_MEMZERO(ar->arBssid, sizeof(ar->arBssid));+    ar->arBssChannel = 0;+}++static void+ar6000_init_control_info(AR_SOFTC_T *ar)+{+    ar->arWmiEnabled         = FALSE;+    ar6000_init_profile_info(ar);+    ar->arDefTxKeyIndex      = 0;+    A_MEMZERO(ar->arWepKeyList, sizeof(ar->arWepKeyList));+    ar->arChannelHint        = 0;+    ar->arListenInterval     = MAX_LISTEN_INTERVAL;+    ar->arVersion.host_ver   = AR6K_SW_VERSION;+    ar->arRssi               = 0;+    ar->arTxPwr              = 0;+    ar->arTxPwrSet           = FALSE;+    ar->arSkipScan           = 0;+    ar->arBeaconInterval     = 0;+    ar->arBitRate            = 0;+    ar->arMaxRetries         = 0;+    ar->arWmmEnabled         = TRUE;+}++static int+ar6000_open(struct net_device *dev)+{+    /* Wake up the queues */+    netif_wake_queue(dev);++    return 0;+}++static int+ar6000_close(struct net_device *dev)+{+    netif_stop_queue(dev);++    return 0;+}++/* connect to a service */+static A_STATUS ar6000_connectservice(AR_SOFTC_T               *ar,+                                      HTC_SERVICE_CONNECT_REQ  *pConnect,+                                      WMI_PRI_STREAM_ID        WmiStreamID,+                                      char                     *pDesc)+{+    A_STATUS                 status;+    HTC_SERVICE_CONNECT_RESP response;++    do {++        A_MEMZERO(&response,sizeof(response));++        status = HTCConnectService(ar->arHtcTarget,+                                   pConnect,+                                   &response);++        if (A_FAILED(status)) {+            AR_DEBUG_PRINTF(" Failed to connect to %s service status:%d \n", pDesc, status);+            break;+        }++        if (WmiStreamID == WMI_NOT_MAPPED) {+                /* done */+            break;+        }++            /* set endpoint mapping for the WMI stream in the driver layer */+        arSetWMIStream2EndpointIDMap(ar,WmiStreamID,response.Endpoint);++    } while (FALSE);++    return status;+}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -