static A_STATUS driver_thread_operation(A_VOID *pCxt) { A_DRIVER_CONTEXT *pDCxt = GET_DRIVER_COMMON(pCxt); union{ A_UINT32 param; }stackU; #define PARAM (stackU.param) #define PTR_REG_MOD ((ATH_REGQUERY*)(pQuery)) switch(PTR_REG_MOD->operation) { case ATH_REG_OP_READ: // read Driver_ReadRegDiag(pCxt, &PTR_REG_MOD->address, &(PTR_REG_MOD->value)); PTR_REG_MOD->value = A_CPU2LE32((PTR_REG_MOD->value)); break; case ATH_REG_OP_WRITE: //write- PTR_REG_MOD->value = A_CPU2LE32((PTR_REG_MOD->value)); Driver_WriteRegDiag(pCxt, &PTR_REG_MOD->address, &(PTR_REG_MOD->value)); break; case ATH_REG_OP_RMW: //read-mod-write if(A_OK != Driver_ReadRegDiag(pCxt, &PTR_REG_MOD->address, &PARAM)){ break; } PARAM = A_CPU2LE32(PARAM); PARAM &= ~PTR_REG_MOD->mask; PARAM |= PTR_REG_MOD->value; PARAM = A_CPU2LE32(PARAM); Driver_WriteRegDiag(pCxt, &PTR_REG_MOD->address, &PARAM); break; } pDCxt->asynchRequest = NULL; reg_query_bool = A_TRUE; CUSTOM_DRIVER_WAKE_USER(pCxt); #undef PTR_REG_MOD #undef PARAM return A_OK; }
/* Driver_ReadDataDiag - Reads a buffer of data starting from address. Length * of data is specified by length. Data is read from a contiguous chip * address memory/register space. * void *pCxt - the driver context. * uint32_t address - the device chip address to start the read. * uint8_t *data - the start of data destination buffer. * uint32_t length - the length of data in bytes. *****************************************************************************/ A_STATUS Driver_ReadDataDiag(void *pCxt, uint32_t address, uint8_t *data, uint32_t length) { uint32_t count; A_STATUS status = A_OK; for (count = 0; count < length; count += 4, address += 4) { if ((status = Driver_ReadRegDiag(pCxt, &address, (uint32_t *)&data[count])) != A_OK) { break; } } return status; }
/* Driver_DumpAssertInfo - Collects assert information from chip and writes * it to stdout. * void *pCxt - the driver context. * uint32_t *pData - buffer to store UINT32 results * uint16_t *pLength - IN/OUT param to store length of buffer for IN and * length of contents for OUT. *****************************************************************************/ A_STATUS Driver_DumpAssertInfo(void *pCxt, uint32_t *pData, uint16_t *pLength) { A_DRIVER_CONTEXT *pDCxt = GET_DRIVER_COMMON(pCxt); uint32_t address; uint32_t regDumpArea = 0; A_STATUS status = A_ERROR; uint32_t regDumpCount = 0; do { if (*pLength < REGISTER_DUMP_LEN_MAX) { break; } /* clear it */ *pLength = 0; /* the reg dump pointer is copied to the host interest area */ address = HOST_INTEREST_ITEM_ADDRESS(hi_failure_state); address = TARG_VTOP(address); if (pDCxt->targetType == TARGET_TYPE_AR4100 || pDCxt->targetType == TARGET_TYPE_AR400X) { regDumpCount = REG_DUMP_COUNT_AR4100; } else { A_ASSERT(0); /* should never happen */ #if DRIVER_CONFIG_DISABLE_ASSERT break; #endif } /* read RAM location through diagnostic window */ if (A_OK != (status = Driver_ReadRegDiag(pCxt, &address, ®DumpArea))) { A_ASSERT(0); /* should never happen */ #if DRIVER_CONFIG_DISABLE_ASSERT break; #endif } regDumpArea = A_LE2CPU32(regDumpArea); if (regDumpArea == 0) { /* no reg dump */ break; } regDumpArea = TARG_VTOP(regDumpArea); /* fetch register dump data */ if (A_OK != (status = Driver_ReadDataDiag(pCxt, regDumpArea, (uint8_t *)&pData[0], regDumpCount * (sizeof(uint32_t))))) { A_ASSERT(0); /* should never happen */ #if DRIVER_CONFIG_DISABLE_ASSERT break; #endif } *pLength = regDumpCount; } while (0); return status; }