A_STATUS FMIDone(HIF_DEVICE *device) { A_STATUS status; struct flash_cmd_s cmd; if (fmiDone) { AR_DEBUG_PRINTF(DBG_FMI, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(DBG_FMI, ("FMI Done: Enter (device: 0x%p)\n", device)); fmiDone = TRUE; cmd.command = FLASH_DONE; status = bmiBufferSend(device, (A_UCHAR *) &cmd, sizeof(cmd)); if (status != A_OK) { AR_DEBUG_PRINTF(DBG_FMI, ("Unable to write to the device\n")); return A_ERROR; } AR_DEBUG_PRINTF(DBG_FMI, ("FMI Done: Exit\n")); return A_OK; }
A_STATUS FMIPartInitFlash(HIF_DEVICE *device, A_UINT32 address) { struct part_init_cmd_s cmd; A_STATUS status; if (fmiDone) { AR_DEBUG_PRINTF(DBG_FMI, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(DBG_FMI, ("FMI Part Init Flash: Enter (device: 0x%p, address 0x%08x)\n", device, address)); cmd.command = FLASH_PART_INIT; cmd.address = address; status = bmiBufferSend(device, (A_UCHAR *) &cmd, sizeof(cmd)); if (status != A_OK) { AR_DEBUG_PRINTF(DBG_FMI, ("Unable to write to the device\n")); return A_ERROR; } AR_DEBUG_PRINTF(DBG_FMI, ("FMI Part Init Flash: Exit\n")); return A_OK; }
A_STATUS BMIGetTargetId(HIF_DEVICE *device, A_UINT32 *id) { A_STATUS status; A_UINT32 cid; if (bmiDone) { BMI_DEBUG_PRINTF(ATH_LOG_ERR,"Command disallowed\n"); return A_ERROR; } BMI_DEBUG_PRINTF(ATH_LOG_INF,"BMI Get Target ID: Enter (device: 0x%p)\n", device); cid = BMI_GET_TARGET_ID; status = bmiBufferSend(device, (A_UCHAR *)&cid, sizeof(cid)); if (status != A_OK) { BMI_DEBUG_PRINTF(ATH_LOG_ERR,"Unable to write to the device\n"); return A_ERROR; } status = bmiBufferReceive(device, (A_UCHAR *)id, sizeof(*id)); if (status != A_OK) { BMI_DEBUG_PRINTF(ATH_LOG_ERR,"Unable to read from the device\n"); return A_ERROR; } BMI_DEBUG_PRINTF(ATH_LOG_INF,"BMI Get Target ID: Exit (ID: 0x%x)\n", *id); 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 FMIPartialEraseFlash(HIF_DEVICE *device, A_UINT32 address, A_UINT32 length) { struct partial_erase_cmd_s cmd; A_STATUS status; if (fmiDone) { AR_DEBUG_PRINTF(DBG_FMI, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(DBG_FMI, ("FMI Partial Erase Flash: Enter (device: 0x%p)\n", device)); cmd.command = FLASH_PARTIAL_ERASE; cmd.address = address; cmd.length = length; status = bmiBufferSend(device, (A_UCHAR *) &cmd, sizeof(cmd)); if (status != A_OK) { AR_DEBUG_PRINTF(DBG_FMI, ("Unable to write to the device\n")); return A_ERROR; } AR_DEBUG_PRINTF(DBG_FMI, ("FMI Partial Erase Flash: Exit\n")); return A_OK; }
int BMIDone(struct hif_device *device) { int status; u32 cid; if (bmiDone) { AR_DEBUG_PRINTF (ATH_DEBUG_BMI, ("BMIDone skipped\n")); return 0; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Done: Enter (device: 0x%p)\n", device)); bmiDone = true; cid = BMI_DONE; status = bmiBufferSend(device, (u8 *)&cid, sizeof(cid)); if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); return A_ERROR; } if (pBMICmdCredits) { A_FREE(pBMICmdCredits); pBMICmdCredits = NULL; } if (pBMICmdBuf) { A_FREE(pBMICmdBuf); pBMICmdBuf = NULL; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Done: Exit\n")); return 0; }
A_STATUS BMIDone(A_VOID *pCxt) { A_STATUS status; A_UINT32 cid; if (bmiDone) { return A_OK; } bmiDone = TRUE; cid = A_CPU2LE32(BMI_DONE); status = bmiBufferSend(pCxt, (A_UCHAR *)&cid, sizeof(cid)); if (status != A_OK) { return A_ERROR; } if (pBMICmdCredits) { A_FREE(pBMICmdCredits, MALLOC_ID_TEMPORARY); pBMICmdCredits = NULL; } if (pBMICmdBuf) { A_FREE(pBMICmdBuf, MALLOC_ID_TEMPORARY); pBMICmdBuf = NULL; } 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 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 FMIEraseFlash(HIF_DEVICE *device) { struct erase_cmd_s cmd; A_STATUS status; if (fmiDone) { AR_DEBUG_PRINTF(DBG_FMI, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(DBG_FMI, ("FMI Erase Flash: Enter (device: 0x%p)\n", device)); cmd.command = FLASH_ERASE; cmd.magic_cookie = FLASH_ERASE_COOKIE; status = bmiBufferSend(device, (A_UCHAR *) &cmd, sizeof(cmd)); if (status != A_OK) { AR_DEBUG_PRINTF(DBG_FMI, ("Unable to write to the device\n")); return A_ERROR; } AR_DEBUG_PRINTF(DBG_FMI, ("FMI Erase Flash: Exit\n")); 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; }
int BMIGetTargetInfo(struct hif_device *device, struct bmi_target_info *targ_info) { int status; u32 cid; if (bmiDone) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Get Target Info: Enter (device: 0x%p)\n", device)); cid = BMI_GET_TARGET_INFO; status = bmiBufferSend(device, (u8 *)&cid, sizeof(cid)); if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); return A_ERROR; } status = bmiBufferReceive(device, (u8 *)&targ_info->target_ver, sizeof(targ_info->target_ver), true); if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read Target Version from the device\n")); return A_ERROR; } if (targ_info->target_ver == TARGET_VERSION_SENTINAL) { /* Determine how many bytes are in the Target's targ_info */ status = bmiBufferReceive(device, (u8 *)&targ_info->target_info_byte_count, sizeof(targ_info->target_info_byte_count), true); if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read Target Info Byte Count from the device\n")); return A_ERROR; } /* * The Target's targ_info doesn't match the Host's targ_info. * We need to do some backwards compatibility work to make this OK. */ A_ASSERT(targ_info->target_info_byte_count == sizeof(*targ_info)); /* Read the remainder of the targ_info */ status = bmiBufferReceive(device, ((u8 *)targ_info)+sizeof(targ_info->target_info_byte_count), sizeof(*targ_info)-sizeof(targ_info->target_info_byte_count), true); if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read Target Info (%d bytes) from the device\n", targ_info->target_info_byte_count)); return A_ERROR; } } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Get Target Info: Exit (ver: 0x%x type: 0x%x)\n", targ_info->target_ver, targ_info->target_type)); return 0; }
int BMIrompatchInstall(struct hif_device *device, u32 ROM_addr, u32 RAM_addr, u32 nbytes, u32 do_activate, u32 *rompatch_id) { u32 cid; int status; u32 offset; A_ASSERT(BMI_COMMAND_FITS(sizeof(cid) + sizeof(ROM_addr) + sizeof(RAM_addr) + sizeof(nbytes) + sizeof(do_activate))); memset(pBMICmdBuf, 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; memcpy(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); offset += sizeof(cid); memcpy(&(pBMICmdBuf[offset]), &ROM_addr, sizeof(ROM_addr)); offset += sizeof(ROM_addr); memcpy(&(pBMICmdBuf[offset]), &RAM_addr, sizeof(RAM_addr)); offset += sizeof(RAM_addr); memcpy(&(pBMICmdBuf[offset]), &nbytes, sizeof(nbytes)); offset += sizeof(nbytes); memcpy(&(pBMICmdBuf[offset]), &do_activate, sizeof(do_activate)); offset += sizeof(do_activate); 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(*rompatch_id), true); if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to read from the device\n")); return A_ERROR; } memcpy(rompatch_id, pBMICmdBuf, sizeof(*rompatch_id)); AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI rompatch Install: (rompatch_id=%d)\n", *rompatch_id)); return 0; }
int BMIReadMemory(struct hif_device *device, u32 address, u8 *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; memcpy(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); offset += sizeof(cid); memcpy(&(pBMICmdBuf[offset]), &address, sizeof(address)); offset += sizeof(address); 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; } 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 BMIGetTargetInfo(A_VOID *pCxt, struct bmi_target_info *targ_info) { A_UINT32 cid; if (bmiDone) { return A_ERROR; } cid = A_CPU2LE32(BMI_GET_TARGET_INFO); if(A_OK != bmiBufferSend(pCxt, (A_UCHAR *)&cid, sizeof(cid))){ return A_ERROR; } if(A_OK != bmiBufferReceive(pCxt, (A_UCHAR *)&targ_info->target_ver, sizeof(targ_info->target_ver), TRUE)){ return A_ERROR; } targ_info->target_ver = A_LE2CPU32(targ_info->target_ver); if (targ_info->target_ver == TARGET_VERSION_SENTINAL) { /* Determine how many bytes are in the Target's targ_info */ if(A_OK != bmiBufferReceive(pCxt, (A_UCHAR *)&targ_info->target_info_byte_count, sizeof(targ_info->target_info_byte_count), TRUE)){ return A_ERROR; } targ_info->target_info_byte_count = A_LE2CPU32(targ_info->target_info_byte_count); /* * The Target's targ_info doesn't match the Host's targ_info. * We need to do some backwards compatibility work to make this OK. */ A_ASSERT(targ_info->target_info_byte_count == sizeof(*targ_info)); /* Read the remainder of the targ_info */ if(A_OK != bmiBufferReceive(pCxt, ((A_UCHAR *)targ_info)+sizeof(targ_info->target_info_byte_count), sizeof(*targ_info)-sizeof(targ_info->target_info_byte_count), TRUE)){ return A_ERROR; } targ_info->target_ver = A_LE2CPU32(targ_info->target_ver); targ_info->target_type = A_LE2CPU32(targ_info->target_type); } else { return A_ERROR; } 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(struct hif_device *device, u8 *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; memcpy(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); offset += sizeof(cid); memcpy(&(pBMICmdBuf[offset]), &txlen, sizeof(txlen)); offset += sizeof(txlen); 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; }
int BMIExecute(struct 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; memcpy(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); offset += sizeof(cid); memcpy(&(pBMICmdBuf[offset]), &address, sizeof(address)); offset += sizeof(address); 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; } memcpy(param, pBMICmdBuf, sizeof(*param)); AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Execute: Exit (param: %d)\n", *param)); return 0; }
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; }
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; }
int BMIReadSOCRegister(HIF_DEVICE *device, u32 address, u32 *param) { u32 cid; int status; u32 offset; A_ASSERT(BMI_COMMAND_FITS(sizeof(cid) + sizeof(address))); memset (pBMICmdBuf, 0, 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 Read SOC Register: Enter (device: 0x%p, address: 0x%x)\n", device, address)); cid = BMI_READ_SOC_REGISTER; offset = 0; A_MEMCPY(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); offset += sizeof(cid); A_MEMCPY(&(pBMICmdBuf[offset]), &address, sizeof(address)); offset += sizeof(address); 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), true); 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 Read SOC Register: Exit (value: %d)\n", *param)); return 0; }
A_STATUS FMIWriteFlash(HIF_DEVICE *device, A_UINT32 address, A_UCHAR *buffer, A_UINT32 length) { struct write_cmd_s cmd; A_STATUS status; A_UINT32 remaining, txlen; const A_UINT32 header = sizeof(cmd); A_UCHAR data[FMI_DATASZ_WMAX + header]; if (fmiDone) { AR_DEBUG_PRINTF(DBG_FMI, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(DBG_FMI, ("FMI Write Flash: Enter (device: 0x%p, address: 0x%x, length: %d)\n", device, address, length)); cmd.command = FLASH_WRITE; remaining = length; while (remaining) { txlen = (remaining < (FMI_DATASZ_WMAX - header)) ? remaining : (FMI_DATASZ_WMAX - header); cmd.address = address; cmd.length = txlen; A_MEMCPY(&data[0], &cmd, sizeof(cmd)); A_MEMCPY(&data[sizeof(cmd)], &buffer[length - remaining], txlen); status = bmiBufferSend(device, data, txlen + sizeof(cmd)); if (status != A_OK) { AR_DEBUG_PRINTF(DBG_FMI, ("Unable to write to the device\n")); return A_ERROR; } remaining -= txlen; address += txlen; } AR_DEBUG_PRINTF(DBG_FMI, ("FMI Write Flash: Exit\n")); return A_OK; }
static int _BMIrompatchChangeActivation(struct hif_device *device, u32 rompatch_count, u32 *rompatch_list, u32 do_activate) { u32 cid; int status; u32 offset; u32 length; A_ASSERT(BMI_COMMAND_FITS(BMI_DATASZ_MAX + sizeof(cid) + sizeof(rompatch_count))); memset(pBMICmdBuf, 0, BMI_DATASZ_MAX + sizeof(cid) + sizeof(rompatch_count)); if (bmiDone) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Change rompatch Activation: Enter (device: 0x%p, count: %d)\n", device, rompatch_count)); cid = do_activate ? BMI_ROMPATCH_ACTIVATE : BMI_ROMPATCH_DEACTIVATE; offset = 0; memcpy(&(pBMICmdBuf[offset]), &cid, sizeof(cid)); offset += sizeof(cid); memcpy(&(pBMICmdBuf[offset]), &rompatch_count, sizeof(rompatch_count)); offset += sizeof(rompatch_count); length = rompatch_count * sizeof(*rompatch_list); memcpy(&(pBMICmdBuf[offset]), rompatch_list, length); offset += length; status = bmiBufferSend(device, pBMICmdBuf, offset); if (status) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unable to write to the device\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Change rompatch Activation: Exit\n")); return 0; }
static A_STATUS _BMIrompatchChangeActivation(HIF_DEVICE *device, A_UINT32 rompatch_count, A_UINT32 *rompatch_list, A_UINT32 do_activate) { A_UINT32 cid; A_STATUS status; A_UINT32 offset; static A_UCHAR data[BMI_DATASZ_MAX + sizeof(cid) + sizeof(rompatch_count)]; A_UINT32 length; memset (&data, 0, BMI_DATASZ_MAX + sizeof(cid) + sizeof(rompatch_count)); if (bmiDone) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Command disallowed\n")); return A_ERROR; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Change rompatch Activation: Enter (device: 0x%p, count: %d)\n", device, rompatch_count)); cid = do_activate ? BMI_ROMPATCH_ACTIVATE : BMI_ROMPATCH_DEACTIVATE; offset = 0; A_MEMCPY(&data[offset], &cid, sizeof(cid)); offset += sizeof(cid); A_MEMCPY(&data[offset], &rompatch_count, sizeof(rompatch_count)); offset += sizeof(rompatch_count); length = rompatch_count * sizeof(*rompatch_list); A_MEMCPY(&data[offset], rompatch_list, length); offset += 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; } AR_DEBUG_PRINTF(ATH_DEBUG_BMI, ("BMI Change rompatch Activation: Exit\n")); return A_OK; }
A_STATUS BMIReadSOCRegister(HIF_DEVICE *device, A_UINT32 address, A_UINT32 *param) { 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 Read SOC Register: Enter (device: 0x%p, address: 0x%x)\n", device, address); cid = BMI_READ_SOC_REGISTER; 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; } status = bmiBufferReceive(device, data, sizeof(*param)); if (status != A_OK) { BMI_DEBUG_PRINTF(ATH_LOG_ERR,"Unable to read from the device\n"); return A_ERROR; } A_MEMCPY(param, data, sizeof(*param)); BMI_DEBUG_PRINTF(ATH_LOG_INF,"BMI Read SOC Register: Exit (value: %d)\n", *param); return A_OK; }