コード例 #1
0
ファイル: htc.c プロジェクト: ShawnOfMisfit/ambarella
/* registered target arrival callback from the HIF layer */
HTC_HANDLE HTCCreate(void *hHIF, HTC_INIT_INFO *pInfo)
{
    A_STATUS    status = A_OK;
    HTC_TARGET  *target = NULL;
    
    do {
        
        if ((target = (HTC_TARGET *)A_MALLOC(sizeof(HTC_TARGET))) == NULL) {
            AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("HTC : Unable to allocate memory\n"));
            status = A_ERROR;
            break;
        }    
        
        A_MEMCPY(&target->HTCInitInfo,pInfo,sizeof(HTC_INIT_INFO));


        adf_os_mem_zero(target, sizeof(HTC_TARGET));

        adf_os_spinlock_init(&target->HTCLock);
        adf_os_spinlock_init(&target->HTCRxLock);
        adf_os_spinlock_init(&target->HTCTxLock);

        /* setup HIF layer callbacks */
        adf_os_mem_zero(&htcCallbacks, sizeof(completion_callbacks_t));
        htcCallbacks.Context = target;
        htcCallbacks.rxCompletionHandler = HTCRxCompletionHandler;
        htcCallbacks.txCompletionHandler = HTCTxCompletionHandler;

        HIFPostInit(hHIF, target, &htcCallbacks);
        
        target->hif_dev = hHIF;

        adf_os_init_mutex(&target->htc_rdy_mutex);
        adf_os_mutex_acquire(&target->htc_rdy_mutex);

        /* Get HIF default pipe for HTC message exchange */
        pEndpoint = &target->EndPoint[ENDPOINT0];
        HIFGetDefaultPipe(hHIF, &pEndpoint->UL_PipeID, &pEndpoint->DL_PipeID);
        adf_os_print("[Default Pipe]UL: %x, DL: %x\n", pEndpoint->UL_PipeID, pEndpoint->DL_PipeID);


        
        /* TODO : other init */
        
    } while (FALSE);


    target->host_handle = htcInfo.pContext;
   /* TODO INTEGRATION supply from host os handle for any os specific calls*/

    target->os_handle = NULL;

    if (A_FAILED(status)) {
        HTCCleanup(target); 
        target = NULL;
    }
    
    return (HTC_HANDLE)target;
}
コード例 #2
0
ファイル: fwd.c プロジェクト: KHATEEBNSIT/AP
A_STATUS
fwd_device_inserted(HIF_HANDLE hif, adf_os_handle_t os_hdl)
{
    fwd_softc_t    *sc;
    HTC_CALLBACKS   fwd_cb;

    sc = adf_os_mem_alloc(os_hdl, sizeof(fwd_softc_t));
    if (!sc) {
      adf_os_print("FWD: No memory for fwd context\n");
      return -1;
    }

//    adf_os_print("fwd  : ctx allocation done = %p\n",sc);

    adf_os_mem_set(sc, 0, sizeof(fwd_softc_t));

    sc->hif_handle = hif;

    adf_os_timer_init(NULL, &sc->tmr, fwd_timer_expire, sc);
    HIFGetDefaultPipe(hif, &sc->rx_pipe, &sc->tx_pipe);

    sc->image                   = (a_uint8_t *)zcFwImage;
    sc->size                    = zcFwImageSize;
    sc->target_upload_addr      = fw_target_addr;

    fwd_cb.Context              = sc;
    fwd_cb.rxCompletionHandler  = fwd_recv;
    fwd_cb.txCompletionHandler  = fwd_txdone;

    sc->hif_handle              = hif;

adf_os_print("%s, hif: 0x%08x\n", __FUNCTION__, (a_uint32_t)hif);

    HIFPostInit(hif, NULL, &fwd_cb);

adf_os_print("%s, hif: 0x%08x\n", __FUNCTION__, (a_uint32_t)hif);

    hif_boot_start(hif);

    adf_os_print("Downloading\t");

    fwd_start_upload(sc);

    return A_STATUS_OK;
}
コード例 #3
0
ファイル: fwd.c プロジェクト: KHATEEBNSIT/AP
hif_status_t
fwd_device_inserted(HIF_HANDLE hif, adf_os_handle_t  os_hdl)
{
    fwd_softc_t    *sc;
    HTC_CALLBACKS   fwd_cb = {0};

    sc = adf_os_mem_alloc(os_hdl ,sizeof(fwd_softc_t));
    if (!sc) {
      adf_os_print("FWD: No memory for fwd context\n");
      return -1;
    }

//    adf_os_print("fwd  : ctx allocation done = %p\n",sc);

    adf_os_mem_set(sc, 0, sizeof(fwd_softc_t));

    sc->hif_handle = hif;

    /*adf_os_timer_init(NULL, &sc->tmr, fwd_timer_expire, sc);*/
    HIFGetDefaultPipe(hif, &sc->rx_pipe, &sc->tx_pipe);

    sc->image                   = (a_uint8_t *)zcFwImage;
    sc->size                    = zcFwImageSize;
    /* #ifdef MDIO_BOOT_LOAD    */
	sc->target_upload_addr      = fw_load_addr;
    /* #else */
    /* sc->target_upload_addr      = fw_target_addr; */
    /* #endif */
    fwd_cb.Context              = sc;
    fwd_cb.rxCompletionHandler  = fwd_recv;
    fwd_cb.txCompletionHandler  = fwd_txdone;

    sc->hif_handle              = hif;

    hif_boot_start(hif);
    
	HIFPostInit(hif, sc, &fwd_cb);

    adf_os_print("Downloading\t");

    fwd_start_upload(sc);

    return HIF_OK;
}
コード例 #4
0
ファイル: htc.c プロジェクト: KHATEEBNSIT/AP
/* registered target arrival callback from the HIF layer */
HTC_HANDLE HTCCreate(void *hHIF, HTC_INIT_INFO *pInfo, adf_os_device_t osdev)
{
    MSG_BASED_HIF_CALLBACKS htcCallbacks;
    HTC_ENDPOINT            *pEndpoint=NULL;
    HTC_TARGET              *target = NULL;
    int                     i;

    AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("+HTCCreate ..  HIF :%p \n",hHIF));

    A_REGISTER_MODULE_DEBUG_INFO(htc);

    if ((target = (HTC_TARGET *)A_MALLOC(sizeof(HTC_TARGET))) == NULL) {
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("HTC : Unable to allocate memory\n"));
        return NULL;
    }

    A_MEMZERO(target, sizeof(HTC_TARGET));

    adf_os_spinlock_init(&target->HTCLock);
    adf_os_spinlock_init(&target->HTCRxLock);
    adf_os_spinlock_init(&target->HTCTxLock);

    do {
        A_MEMCPY(&target->HTCInitInfo,pInfo,sizeof(HTC_INIT_INFO));
        target->host_handle = pInfo->pContext;
		target->osdev = osdev;

        ResetEndpointStates(target);

        INIT_HTC_PACKET_QUEUE(&target->ControlBufferTXFreeList);

        for (i = 0; i < HTC_PACKET_CONTAINER_ALLOCATION; i++) {
            HTC_PACKET *pPacket = (HTC_PACKET *)A_MALLOC(sizeof(HTC_PACKET));
            if (pPacket != NULL) {
                A_MEMZERO(pPacket,sizeof(HTC_PACKET));
                FreeHTCPacketContainer(target,pPacket);
            }
        }

#ifdef TODO_FIXME
        for (i = 0; i < NUM_CONTROL_TX_BUFFERS; i++) {
            pPacket = BuildHTCTxCtrlPacket();
            if (NULL == pPacket) {
                break;
            }
            HTCFreeControlTxPacket(target,pPacket);
        }
#endif

        /* setup HIF layer callbacks */
        A_MEMZERO(&htcCallbacks, sizeof(MSG_BASED_HIF_CALLBACKS));
        htcCallbacks.Context = target;
        htcCallbacks.rxCompletionHandler = HTCRxCompletionHandler;
        htcCallbacks.txCompletionHandler = HTCTxCompletionHandler;
        htcCallbacks.txResourceAvailHandler = HTCTxResourceAvailHandler;
        htcCallbacks.fwEventHandler = HTCFwEventHandler;
        target->hif_dev = hHIF;

        /* Get HIF default pipe for HTC message exchange */
        pEndpoint = &target->EndPoint[ENDPOINT_0];

        HIFPostInit(hHIF, target, &htcCallbacks);
        HIFGetDefaultPipe(hHIF, &pEndpoint->UL_PipeID, &pEndpoint->DL_PipeID);

    } while (FALSE);

    HTCRecvInit(target);

    AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("-HTCCreate (0x%p) \n", target));

    return (HTC_HANDLE)target;
}