Example #1
0
s32 wifi_qsap_unload_driver()
{
    s32 ret = eSUCCESS;

    if(system(SDIO_POLLING_ON)) {
        LOGE("Could not turn on the polling...");
    }

    if ( check_driver_loaded(WIFI_DRIVER_MODULE_NAME " ") ) {
        qsap_send_module_down_indication();
        if ( rmmod(WIFI_DRIVER_MODULE_NAME) ) {
            LOGE("Unable to unload the libra_softap driver\n");
            ret = eERR_UNLOAD_FAILED_SOFTAP;
            goto end;
        }
    }

    sched_yield();

    if ( check_driver_loaded(WIFI_SDIO_IF_DRIVER_MODULE_NAME " ") ) {
        if ( rmmod(WIFI_SDIO_IF_DRIVER_MODULE_NAME) ) {
            LOGE("Unable to unload the librasdioif driver\n");
            ret = eERR_UNLOAD_FAILED_SDIO;
            goto end;
        }
    }
end:
    if(system(SDIO_POLLING_OFF)) {
        LOGE("Could not turn off the polling...");
    }

    return ret;
}
Example #2
0
s32 wifi_qsap_unload_wifi_sta_driver(void)
{
    s32    ret = 0;

    if(system(SDIO_POLLING_ON)) {
        LOGE("Could not turn on the polling...");
    }

    if ( check_driver_loaded(WIFI_DRIVER_MODULE_NAME " ") ) {
        qsap_send_module_down_indication();
        if ( rmmod(WIFI_DRIVER_MODULE_NAME) ) {
            LOGE("Unable to unload the station mode wifi driver...\n");
            ret = 1;
            goto end;
        }
    }

    sched_yield();

    if ( check_driver_loaded(WIFI_SDIO_IF_DRIVER_MODULE_NAME " ") ) {
        if ( rmmod(WIFI_SDIO_IF_DRIVER_MODULE_NAME) ) {
            LOGE("Unable to unload the station mode librasdioif driver\n");
            ret = 1;
            goto end;
        }
    }

end:
    if(system(SDIO_POLLING_OFF)) {
        LOGE("Could not turn off the polling...");
    }
    sched_yield();
    return 0;
}
int unloadWimaxDriver()
{
    LOGI("NATIVE::unloadWimaxDriver() - Unloading wimax driver...");
    char pid[PROPERTY_VALUE_MAX];
    int count = 20; /* wait at most 10 seconds for completion */
    property_set("ctl.stop", SERVICE_NAME);
    if (property_get(DRIVER_PROP_NAME, pid, NULL)) {
	LOGI("NATIVE::unloadWimaxDriver() - Killing sequansd...");
        kill(atoi(pid), SIGQUIT);
    }
    sched_yield();
    property_set(DRIVER_PROP_NAME, "");
    if (rmmod(DRIVER_MODULE_NAME) == 0) {
        while (count-- > 0) {
            if (!check_driver_loaded())
                break;
            usleep(500000);
        }
        if (count) {
            return 0;
        }
        return -1;
    } else
        return -1;
}
Example #4
0
static s32 insmod(const s8 *filename, const s8 *args, const s8 * tag)
{
#ifndef SDK_TEST
    void *module;
    s32 size;
    s32 ret = 0;

    if ( check_driver_loaded(tag) ) {
        LOGE("Driver: %s already loaded\n", filename);
        return ret;
    }

    LOGD("Loading Driver: %s %s\n", filename, args);

    module = (void*)load_file(filename, (unsigned int*)&size);

    if (!module) {
        LOGE("Cannot load file: %s\n", filename);
        return -1;
    }

    ret = init_module(module, size, args);

    if ( ret ) {
        LOGE("init_module (%s:%d) failed\n", filename, (int)size);
    }

    free(module);

    return ret;
#else
    return 0;
#endif
}
Example #5
0
int wifi_unload_driver()
{
    int count = 20; /* wait at most 10 seconds for completion */
    char pid_txt[PROPERTY_VALUE_MAX];
    int pid;
   
    if (property_get("wlan.driver.unifi_helper_pid", pid_txt, NULL)) {
        pid = atoi(pid_txt);
        kill(pid, SIGTERM);
        sched_yield();
        property_set("wlan.driver.unifi_helper_pid", NULL);
    }
    if (rmmod(DRIVER_MODULE_NAME) == 0) {
	while (count-- > 0) {
	    if (!check_driver_loaded())
		break;
    	    usleep(500000);
	}
	if (count) {
    	    return 0;
	}
	return -1;
    } else
        return -1;
}
Example #6
0
int wifi_load_driver()
{
    char driver_status[PROPERTY_VALUE_MAX];
    int count = 100; /* wait at most 20 seconds for completion */

    if (check_driver_loaded()) {
        return 0;
    }

    if (insmod(DRIVER_MODULE_PATH) < 0)
        return -1;
      
//    property_set("ctl.start", FIRMWARE_LOADER);
    sched_yield();
    while (count-- > 0) {
        if (property_get(DRIVER_PROP_NAME, driver_status, NULL)) {
            if (strcmp(driver_status, "ok") == 0)
                return 0;
            else if (strcmp(DRIVER_PROP_NAME, "failed") == 0)
                return -1;
        }
        usleep(200000);
    }
    property_set(DRIVER_PROP_NAME, "timeout");
    return -1;
}
Example #7
0
s32 wifi_qsap_load_driver(void)
{
    s32    size;
    s32        ret = 0;
    s32        retry;

    /* Unload the station mode driver first */
    wifi_qsap_unload_wifi_sta_driver();

    if (system(SDIO_POLLING_ON)) {
        LOGE("Could not turn on the polling...");
    }

    if (sizeof(WIFI_SDIO_IF_DRIVER_MODULE_PATH) > 0) {
       ret = insmod(WIFI_SDIO_IF_DRIVER_MODULE_PATH, WIFI_SDIO_IF_DRIVER_MODULE_ARG, WIFI_SDIO_IF_DRIVER_MODULE_NAME " ");

       if ( ret != 0 ) {
          LOGE("init_module failed sdioif\n");
          ret = eERR_LOAD_FAILED_SDIOIF;
          goto end;
      }

      sched_yield();
    }

    ret = insmod(WIFI_DRIVER_MODULE_PATH, WIFI_DRIVER_MODULE_ARG, WIFI_DRIVER_MODULE_NAME " ");

    if ( ret != 0 ) {
        if (sizeof(WIFI_SDIO_IF_DRIVER_MODULE_PATH) > 0) {
            if ( check_driver_loaded(WIFI_SDIO_IF_DRIVER_MODULE_NAME " ") ) {
                    if ( rmmod(WIFI_SDIO_IF_DRIVER_MODULE_NAME) ) {
                        LOGE("Unable to unload the station mode librasdioif driver\n");
              }
            }
        }
        LOGE("init_module failed libra_softap\n");
        ret = eERR_LOAD_FAILED_SOFTAP;
		goto end;
    }

    sched_yield();
    
	ret = eSUCCESS;

end:
    if(system(SDIO_POLLING_OFF)) {
        LOGE("Could not turn off the polling...");
    }

    return ret;
}
Example #8
0
int wifi_load_driver()
{
    char driver_status[PROPERTY_VALUE_MAX];
    int count = 100; /* wait at most 20 seconds for completion */

    if (check_driver_loaded()) {
        return 0;
    }

    if (!strcmp(PRELOADER,"") == 0) {
        LOGW("Starting WIFI pre-loader");
        property_set("ctl.start", PRELOADER);
    }

#ifdef WIFI_EXT_MODULE_PATH
    if (insmod(EXT_MODULE_PATH, EXT_MODULE_ARG) < 0)
        return -1;
    usleep(200000);
#endif

    if (insmod(DRIVER_MODULE_PATH, DRIVER_MODULE_ARG) < 0){
#ifdef WIFI_EXT_MODULE_NAME
        rmmod(EXT_MODULE_NAME);
#endif
        return -1;
    }

    if (strcmp(FIRMWARE_LOADER,"") == 0) {
        usleep(WIFI_DRIVER_LOADER_DELAY);
        property_set(DRIVER_PROP_NAME, "ok");
    }
    else {
        property_set("ctl.start", FIRMWARE_LOADER);
    }
    sched_yield();
    while (count-- > 0) {
        if (property_get(DRIVER_PROP_NAME, driver_status, NULL)) {
            if (strcmp(driver_status, "ok") == 0)
                return 0;
            else if (strcmp(DRIVER_PROP_NAME, "failed") == 0) {
                wifi_unload_driver();
                return -1;
            }
        }
        usleep(200000);
    }
    property_set(DRIVER_PROP_NAME, "timeout");
    wifi_unload_driver();
    return -1;
}
Example #9
0
int wifi_load_driver()
{

    LOGE("zhiyuan add ********* wifi_load_driver() *******return 0 **********");
    
     return 0;

    char driver_status[PROPERTY_VALUE_MAX];
    int count = 100; /* wait at most 20 seconds for completion */

    if (check_driver_loaded()) {

        LOGE("zhiyuan add debug********* wifi_load_driver() ->check_driver_loaded() )fail*****************");
        return 0;
    }

   LOGE("zhiyuan add debug********* wifi_load_driver() ->check_driver_loaded() )OK*****************");

    if (insmod(DRIVER_MODULE_PATH, DRIVER_MODULE_ARG) < 0)
        return -1;

  //  LOGE("zhiyuan add debug*******cancel ** wifi_load_driver() ->insmod () OK*****************");

    if (strcmp(FIRMWARE_LOADER,"") == 0) {
        usleep(WIFI_DRIVER_LOADER_DELAY);
        property_set(DRIVER_PROP_NAME, "ok");
    }
    else {
        property_set("ctl.start", FIRMWARE_LOADER);
    }
    sched_yield();
    while (count-- > 0) {
        if (property_get(DRIVER_PROP_NAME, driver_status, NULL)) {
            if (strcmp(driver_status, "ok") == 0)
                return 0;
            else if (strcmp(DRIVER_PROP_NAME, "failed") == 0) {
                wifi_unload_driver();
                return -1;
            }
        }
        usleep(200000);
    }
    property_set(DRIVER_PROP_NAME, "timeout");
    wifi_unload_driver();
    return -1;
}
Example #10
0
int loadWimaxDriver()
{
    char driver_status[PROPERTY_VALUE_MAX];
    int count = 50; /* wait at most 10 seconds for completion */

	LOGI("NATIVE::loadWimaxDriver() - Checking driver...");
    if (check_driver_loaded()) {
	    LOGI("NATIVE::loadWimaxDriver() - Driver already loaded!");
        return 0;
    }

	LOGI("NATIVE::loadWimaxDriver() - insmod(driver_mod)");
    if (insmod(DRIVER_MODULE_PATH, DRIVER_MODULE_ARG) < 0)
	    LOGI("NATIVE::loadWimaxDriver() - insmod succeeded!");

        sched_yield();
        while (count-- > 0) {
            if (property_get(DRIVER_PROP_NAME, driver_status, NULL)) {
                if (strcmp(driver_status, "") != 0) {
                    usleep(100000);
                    LOGI("NATIVE::loadWimaxDriver() - sleeping to let sequansd die...");
            }
        }
    }

    count = 50;
	LOGI("NATIVE::loadWimaxDriver() - starting sequansd...");
        property_set("ctl.start", SERVICE_NAME);

    while (count-- > 0) {
        if (property_get(DRIVER_PROP_NAME, driver_status, NULL)) {
            if (strcmp(driver_status, "") != 0)
                return 0;
            else {
                unloadWimaxDriver();
                return -1;
            }
        }
        usleep(200000);
    }
    property_set(DRIVER_PROP_NAME, "");
    unloadWimaxDriver();
    return -1;
}
Example #11
0
int wifi_unload_driver()
{

    
    int count = 20; /* wait at most 10 seconds for completion */

    if (rmmod(DRIVER_MODULE_NAME) == 0) {
	while (count-- > 0) {
	    if (!check_driver_loaded())
		break;
    	    usleep(500000);
	}
	if (count) {
    	    return 0;
	}
	return -1;
    } else
        return -1;
}
Example #12
0
int wifi_unload_driver()
{
    int count = 20; /* wait at most 10 seconds for completion */

	LOGD("wifi unload driver.\n");

    if ( (rmmod(DRIVER_MODULE_NAME) == 0) 
#ifdef     NANO_SDIO_WIFI_USED
            && (rmmod(FIRMWARE_MODULE_NAME) == 0) 
#endif
            ) {
    	while (count-- > 0) {
    	    if (!check_driver_loaded())
    		break;
        	    usleep(500000);
    	}
    	if (count) {
        	return 0;
    	}
    	return -1;
    } else
        return -1;

}
Example #13
0
int wifi_unload_driver()
{
    int count = 20; /* wait at most 10 seconds for completion */

    if (rmmod(DRIVER_MODULE_NAME) == 0) {
        while (count-- > 0) {
            if (!check_driver_loaded())
                break;
            usleep(500000);
        }
        if (count) {
#ifdef WIFI_EXT_MODULE_NAME
            if (rmmod(EXT_MODULE_NAME) == 0)
#endif
                if (!strcmp(PRELOADER,"") == 0) {
                    LOGW("Stopping WIFI pre-loader");
                    property_set("ctl.stop", PRELOADER);
                }
            return 0;
        }
        return -1;
    } else
        return -1;
}
Example #14
0
int wifi_load_driver()
{
#ifdef RTL_USB_WIFI_USED

    char driver_status[PROPERTY_VALUE_MAX];
    int count = 100; /* wait at most 20 seconds for completion */
    char supp_status[PROPERTY_VALUE_MAX] = {'\0'};
    
    unsigned char tmp_buf[200] = {0};
    char *p_strstr  = NULL;
    int  ret        = 0;
    FILE *fp        = NULL;
    int sleep_count = 0;
    
    /* Check whether is stopping */
    if (property_get(SUPP_PROP_NAME, supp_status, NULL)
            && strcmp(supp_status, "stopping") == 0) {
        LOGD("[wifiHW] wpa status is stopping!");    	
        LOGD("[wifiHW] try to stop supplicant again...");    	
        wifi_stop_supplicant();
        property_get(SUPP_PROP_NAME, supp_status, NULL);
        LOGD("[wifiHW] supp_status = %s", supp_status);    	
    }    
    
    LOGD("start to isnmod rtl8192cu.ko\n");
    
    if (insmod(DRIVER_MODULE_PATH, DRIVER_MODULE_ARG) < 0) {
        LOGE("insmod rtl8192cu ko failed!");
        #if defined NANO_SDIO_WIFI_USED 
        rmmod(DRIVER_MODULE_NAME);          
        #endif
        return -1;
    }    

    do{
       fp=fopen("/proc/net/wireless", "r");
       if (!fp) {
               LOGE("failed to fopen file /proc/net/wireless\n");
               return -1;
       }
       ret = fread(tmp_buf, 200, 1, fp);
       if (ret==0){
               LOGE("in hardware wifi_load_driver, faied to read proc/net/wireless");
       }
       fclose(fp);

       LOGE("in hardware wifi_load_driver, it is running to insmod wifi driver");
       p_strstr = strstr(tmp_buf, "wlan0");
       if (p_strstr != NULL) {
               break;
       }
       usleep(200000);

   } while (sleep_count++ <=10);

   if(sleep_count > 10) {
       LOGE("in hardware wifi_load_driver, timeout to poll wlan0");
       rmmod(DRIVER_MODULE_NAME); 
       return -1;
   }

   return 0;
    
#else 
	
    char driver_status[PROPERTY_VALUE_MAX];
    int count = 100; /* wait at most 20 seconds for completion */
    char supp_status[PROPERTY_VALUE_MAX] = {'\0'};
    
    if (property_get(SUPP_PROP_NAME, supp_status, NULL)
            && strcmp(supp_status, "stopping") == 0) {
        LOGD("[wifiHW] wpa status is stopping!");    	
        LOGD("[wifiHW] try to stop supplicant again.......");    	
        wifi_stop_supplicant();
        property_get(SUPP_PROP_NAME, supp_status, NULL);
        LOGD("[wifiHW] supp_status = %s", supp_status);    	
    }   
    
    if (check_driver_loaded()) {
        return 0;
    }    
#ifdef NANO_SDIO_WIFI_USED    
    LOGD("begin insmod [nano] wifi firmware!");
    // load firmware, add by weiziheng 2011-06-21
    if(insmod(FIRMWARE_MODULE_PATH,FIRMWARE_MODULE_ARG) < 0) {
        LOGE("insmod [nano] wifi firmware failed!");
        rmmod(DRIVER_MODULE_NAME);
        rmmod(FIRMWARE_MODULE_NAME);
        return -1;
    }
#endif    
    if (insmod(DRIVER_MODULE_PATH, DRIVER_MODULE_ARG) < 0) {
        LOGE("insmod wifi ko failed!");
        #if defined NANO_SDIO_WIFI_USED 
        rmmod(FIRMWARE_MODULE_NAME);          
        #endif
        return -1;
    }
    
    if (strcmp(FIRMWARE_LOADER,"") == 0) {
#ifdef NANO_SDIO_WIFI_USED	    	
		unsigned char tmp_buf[200] = {0};  	
		FILE *profs_entry = NULL;
		int try_time = 0;	
		do {		
			profs_entry = fopen("/proc/net/wireless", "r");
			if(profs_entry == NULL){
				LOGE("[wifiHW] open /proc/net/wireless failed!");
				property_set(DRIVER_PROP_NAME, "failed");
				break;
		    }
		    
	        if( 0 == fread(tmp_buf, 200, 1, profs_entry) ){
	            LOGD("[wifiHW] faied to read proc/net/wireless");
	        }
			
			if(strstr(tmp_buf, "wlan0")) {
				LOGD("[wifiHW] insmod okay,try_time(%d)", try_time);
			    fclose(profs_entry);
			    profs_entry = NULL;
			    property_set(DRIVER_PROP_NAME, "ok");
			    break;			    
			}else {
				LOGD("[wifiHW] nano initial,try_time(%d)",try_time);
				property_set(DRIVER_PROP_NAME, "failed");				    		
			}			
	        fclose(profs_entry);
	        profs_entry = NULL;				
			usleep(200000);
		}while(try_time++ <= 20);// 4 seconds		
#else
        usleep(WIFI_DRIVER_LOADER_DELAY);
        property_set(DRIVER_PROP_NAME, "ok");
#endif		
    }
    else {
        property_set("ctl.start", FIRMWARE_LOADER);
    }
    sched_yield();
    while (count-- > 0) {
        if (property_get(DRIVER_PROP_NAME, driver_status, NULL)) {
            if (strcmp(driver_status, "ok") == 0)
                return 0;
            else if (strcmp(DRIVER_PROP_NAME, "failed") == 0) {
                wifi_unload_driver();
                return -1;
            }
        }
        usleep(200000);
    }
    property_set(DRIVER_PROP_NAME, "timeout");
    wifi_unload_driver();
    return -1;
#endif    
}