VOID CuCommon_Destroy(THandle hCuCommon) { CuCommon_t* pCuCommon = (CuCommon_t*)hCuCommon; if(pCuCommon->hIpcSta) IpcSta_Destroy(pCuCommon->hIpcSta); os_MemoryFree(pCuCommon); }
/* Return '0' if success */ S32 init_driver( PS8 adapter_name, PS8 eeprom_file_name, PS8 init_file_name, PS8 firmware_file_name ) { PVOID f1 = NULL, f2 = NULL, f3 = NULL; S32 eeprom_image_length = 0; S32 init_file_length = 0; S32 firmware_image_length = 0; U32 req_size = 0; TLoaderFilesData *init_info = NULL; S32 rc = -1; THandle hIpcSta; if( !adapter_name || !*adapter_name ) return rc; os_error_printf(CU_MSG_INFO1, (PS8)"+---------------------------+\n"); os_error_printf(CU_MSG_INFO1, (PS8)"| wlan_loader: initializing |\n"); os_error_printf(CU_MSG_INFO1, (PS8)"+---------------------------+\n"); hIpcSta = IpcSta_Create(adapter_name); if (hIpcSta == NULL) { os_error_printf (CU_MSG_ERROR, (PS8)"wlan_loader: cant allocate IpcSta context\n", eeprom_file_name); goto init_driver_end; } /* Send init request to the driver */ if ( (NULL != eeprom_file_name) && (f1 = os_fopen (eeprom_file_name, OS_FOPEN_READ)) != NULL) { eeprom_image_length = os_getFileSize(f1); if (-1 == eeprom_image_length) { os_error_printf(CU_MSG_ERROR, (PS8)"Cannot get eeprom image file length <%s>\n", eeprom_file_name); goto init_driver_end; } } if ( (NULL != firmware_file_name) && (f2 = os_fopen (firmware_file_name, OS_FOPEN_READ)) != NULL) { firmware_image_length = os_getFileSize(f2); if (-1 == firmware_image_length) { os_error_printf(CU_MSG_ERROR, (PS8)"Cannot get firmware image file length <%s>\n", firmware_file_name); goto init_driver_end; } } if ( (NULL != init_file_name) && (f3 = os_fopen (init_file_name, OS_FOPEN_READ)) != NULL) { init_file_length = os_getFileSize(f3); if (-1 == init_file_length) { os_error_printf(CU_MSG_ERROR, (PS8)"Cannot get init file length <%s>\n", init_file_name); goto init_driver_end; } } /* Now when we can calculate the request length. allocate it and read the files */ req_size = sizeof(TLoaderFilesData) + eeprom_image_length + (init_file_length+1) + firmware_image_length; init_info = (TLoaderFilesData *)os_MemoryAlloc(req_size); if (!init_info) { os_error_printf(CU_MSG_ERROR, (PS8)"No memory to allocate init request (%d bytes)\n", req_size); goto init_driver_end; } init_info->uNvsFileLength = eeprom_image_length; init_info->uFwFileLength = firmware_image_length; init_info->uIniFileLength = init_file_length; if (!f1 || (eeprom_image_length && os_fread(&init_info->data[0], 1, eeprom_image_length, f1)<eeprom_image_length)) { } else os_error_printf(CU_MSG_INFO1, (PS8)"**** nvs file found %s **** \n", eeprom_file_name); if (!f2 || (firmware_image_length && os_fread(&init_info->data[eeprom_image_length], 1, firmware_image_length, f2)<firmware_image_length)) { os_error_printf(CU_MSG_ERROR, (PS8)"Error reading firmware image %s - Aborting...\n", firmware_file_name); goto init_driver_end; } if (!f3 || (init_file_length && os_fread(&init_info->data[eeprom_image_length+firmware_image_length], 1, init_file_length, f3)<init_file_length)) { os_error_printf(CU_MSG_ERROR, (PS8)"Warning: Error in reading init_file %s - Using defaults\n", init_file_name); } /* Load driver defaults */ if(EOALERR_IPC_STA_ERROR_SENDING_WEXT == IPC_STA_Private_Send(hIpcSta, DRIVER_INIT_PARAM, init_info, req_size, NULL, 0)) { os_error_printf(CU_MSG_ERROR, (PS8)"Wlan_loader: Error sending init command (DRIVER_INIT_PARAM) to driver\n"); goto init_driver_end; } /* No Error Found */ rc = 0; init_driver_end: if (f1) os_fclose(f1); if (f2) os_fclose(f2); if (f3) os_fclose(f3); if (init_info) os_MemoryFree(init_info); if (hIpcSta) IpcSta_Destroy(hIpcSta); return rc; }