wwd_result_t wwd_bus_write_wifi_firmware_image( void ) { uint32_t offset = 0; uint32_t total_size; uint32_t reset_inst = 0; uint32_t size_read; total_size = (uint32_t) resource_get_size( &wifi_firmware_image ); resource_read ( &wifi_firmware_image, 0, 4, &size_read, &reset_inst ); while ( total_size > offset ) { resource_read ( &wifi_firmware_image, 0, WLAN_MEMORY_SIZE, &size_read, (uint8_t *)(WLAN_ADDR+offset) ); offset += size_read; } /* * copy reset vector to FLOPS * WLAN Address = {Programmable Register[31:18], * Current Transaction's HADDR[17:0]} */ write_reset_instruction( reset_inst ); return WWD_SUCCESS; }
wwd_result_t host_platform_resource_size( wwd_resource_t resource, uint32_t* size_out ) { if ( resource == WWD_RESOURCE_WLAN_FIRMWARE ) { *size_out = (uint32_t) resource_get_size( &wifi_firmware_image ); } else { *size_out = NVRAM_SIZE; } return WWD_SUCCESS; }
wwd_result_t wwd_process_clm_data(void) { wwd_result_t ret = WWD_SUCCESS; uint32_t clm_blob_size; uint32_t datalen; unsigned int size2alloc, data_offset; unsigned char *chunk_buf; uint16_t dl_flag = DL_BEGIN; unsigned int cumulative_len = 0; unsigned int chunk_len; uint32_t size_read; /* clm file size is the initial datalen value which is decremented */ clm_blob_size = resource_get_size( &wifi_firmware_clm_blob ); datalen = clm_blob_size; data_offset = offsetof(wl_dload_data_t, data); size2alloc = data_offset + MAX_CHUNK_LEN; if ((chunk_buf = (unsigned char *)malloc(size2alloc)) != NULL) { memset(chunk_buf, 0, size2alloc); do { if (datalen >= MAX_CHUNK_LEN) chunk_len = MAX_CHUNK_LEN; else chunk_len = datalen; // check size_read is full value also and resource read return if ((ret = resource_read(&wifi_firmware_clm_blob, cumulative_len, chunk_len, &size_read, chunk_buf + data_offset)) != WWD_SUCCESS) { break; } if (size_read != chunk_len) { wiced_assert("During CLM download, resource_read() returned less of the file than should be available\n", 1 == 0); ret = WWD_CLM_BLOB_DLOAD_ERROR; break; } cumulative_len += chunk_len; if (datalen - chunk_len == 0) dl_flag |= DL_END; ret = wwd_download2dongle(WWD_STA_INTERFACE, IOVAR_STR_CLMLOAD, dl_flag, DL_TYPE_CLM, chunk_buf, data_offset + chunk_len); dl_flag &= (uint16_t)~DL_BEGIN; datalen = datalen - chunk_len; } while ((datalen > 0) && (ret == WWD_SUCCESS)); free(chunk_buf); if ( ret != WWD_SUCCESS ) { wwd_result_t ret_clmload_status; wiced_buffer_t buffer; wiced_buffer_t response; void *data; WPRINT_WWD_DEBUG(("clmload (%ld byte file) failed with return %d; ", clm_blob_size, ret)); data = (int*)wwd_sdpcm_get_iovar_buffer( &buffer, 4, IOVAR_STR_CLMLOAD_STATUS ); CHECK_IOCTL_BUFFER( data ); ret_clmload_status = wwd_sdpcm_send_iovar( SDPCM_GET, buffer, &response, WWD_STA_INTERFACE ); if ( ret_clmload_status != WWD_SUCCESS ) { WPRINT_WWD_DEBUG(("clmload_status failed with return %d\n", ret_clmload_status)); } else { uint32_t *clmload_status = (uint32_t *)host_buffer_get_current_piece_data_pointer( response ); if ( clmload_status != NULL ) { WPRINT_WWD_DEBUG(("clmload_status is %lu\n", *clmload_status)); host_buffer_release( response, WWD_NETWORK_RX ); } } } } else { ret = WWD_MALLOC_FAILURE; } return ret; }