Lines Matching defs:pAdapter
122 static void hptmv_free_edma_queues(IAL_ADAPTER_T *pAdapter);
123 static void hptmv_free_channel(IAL_ADAPTER_T *pAdapter, MV_U8 channelNum);
125 static int hptmv_init_channel(IAL_ADAPTER_T *pAdapter, MV_U8 channelNum);
127 static void fRegisterVdevice(IAL_ADAPTER_T *pAdapter);
128 static int hptmv_allocate_edma_queues(IAL_ADAPTER_T *pAdapter);
131 static int start_channel(IAL_ADAPTER_T *pAdapter, MV_U8 channelNum);
132 static void init_vdev_params(IAL_ADAPTER_T *pAdapter, MV_U8 channel);
151 IAL_ADAPTER_T *pAdapter;
215 hptmv_free_channel(IAL_ADAPTER_T *pAdapter, MV_U8 channelNum)
218 pAdapter->mvSataAdapter.sataChannel[channelNum] = NULL;
224 IAL_ADAPTER_T *pAdapter = (IAL_ADAPTER_T *)_vbus_p->OsExt;
234 if (pAdapter->ver_601==2 && !pAdapter->beeping) {
235 pAdapter->beeping = 1;
236 BeepOn(pAdapter->mvSataAdapter.adapterIoBaseAddress);
237 set_fail_led(&pAdapter->mvSataAdapter, pVDev->u.disk.mv->channelNumber, 1);
283 * pAdapter - pointer to the emulated adapter data structure
288 hptmv_init_channel(IAL_ADAPTER_T *pAdapter, MV_U8 channelNum)
297 pAdapter->mvSataAdapter.adapterId, channelNum);
301 pMvSataChannel = &gMvSataChannels[pAdapter->mvSataAdapter.adapterId][channelNum];
302 pAdapter->mvSataAdapter.sataChannel[channelNum] = pMvSataChannel;
308 (pAdapter->requestsArrayBaseAlignedAddr + (channelNum * MV_EDMA_REQUEST_QUEUE_SIZE));
309 req_dma_addr = pAdapter->requestsArrayBaseDmaAlignedAddr + (channelNum * MV_EDMA_REQUEST_QUEUE_SIZE);
318 " dma_addr=%llx channel=%d\n", pAdapter->mvSataAdapter.adapterId,
325 pAdapter->mvSataAdapter.adapterId, channelNum,
328 (pAdapter->responsesArrayBaseAlignedAddr + (channelNum * MV_EDMA_RESPONSE_QUEUE_SIZE));
329 rsp_dma_addr = pAdapter->responsesArrayBaseDmaAlignedAddr + (channelNum * MV_EDMA_RESPONSE_QUEUE_SIZE);
336 pAdapter->mvSataAdapter.adapterId, channelNum, (HPT_U64)(ULONG_PTR)rsp_dma_addr);
342 pAdapter->mvSataAdapter.adapterId, channelNum,
345 pAdapter->mvChannel[channelNum].online = MV_TRUE;
417 init_vdev_params(IAL_ADAPTER_T *pAdapter, MV_U8 channel)
419 PVDevice pVDev = &pAdapter->VDevices[channel];
420 MV_SATA_CHANNEL *pMvSataChannel = pAdapter->mvSataAdapter.sataChannel[channel];
427 pVDev->u.disk.pVBus = &pAdapter->VBus;
428 pVDev->pVBus = &pAdapter->VBus;
445 pAdapter->mvChannel[channel].maxPioModeSupported - MV_ATA_TRANSFER_PIO_0;
447 if (pAdapter->mvChannel[channel].maxUltraDmaModeSupported!=0xFF) {
449 pAdapter->mvChannel[channel].maxUltraDmaModeSupported - MV_ATA_TRANSFER_UDMA_0 + 8;
453 static void device_change(IAL_ADAPTER_T *pAdapter , MV_U8 channelIndex, int plugged)
456 MV_SATA_ADAPTER *pMvSataAdapter = &pAdapter->mvSataAdapter;
463 pVDev = &(pAdapter->VDevices[channelIndex]);
464 init_vdev_params(pAdapter, channelIndex);
489 if (pAdapter->beeping) {
490 pAdapter->beeping = 0;
491 BeepOff(pAdapter->mvSataAdapter.adapterIoBaseAddress);
498 pVDev = &(pAdapter->VDevices[channelIndex]);
504 start_channel(IAL_ADAPTER_T *pAdapter, MV_U8 channelNum)
506 MV_SATA_ADAPTER *pMvSataAdapter = &pAdapter->mvSataAdapter;
508 MV_CHANNEL *pChannelInfo = &(pAdapter->mvChannel[channelNum]);
638 pAdapter->mvChannel[channelNum].maxPioModeSupported = pioMode;
790 IAL_ADAPTER_T *pAdapter = (IAL_ADAPTER_T *)data;
791 MV_SATA_ADAPTER *pMvSataAdapter = &pAdapter->mvSataAdapter;
797 switch(pAdapter->sataEvents[channelIndex])
805 hptmv_init_channel(pAdapter, channelIndex);
810 hptmv_free_channel(pAdapter, channelIndex);
815 if (start_channel( pAdapter, channelIndex))
819 hptmv_free_channel(pAdapter, channelIndex);
823 device_change(pAdapter, channelIndex, TRUE);
826 pAdapter->sataEvents[channelIndex] = SATA_EVENT_NO_CHANGE;
838 _VBUS_INST(&pAdapter->VBus)
843 hptmv_free_channel(pAdapter, channelIndex);
847 if (pAdapter->outstandingCommands==0 && DPC_Request_Nums==0)
848 Check_Idle_Call(pAdapter);
855 pAdapter->sataEvents[channelIndex] = SATA_EVENT_NO_CHANGE;
887 IAL_ADAPTER_T *pAdapter = pMvSataAdapter->IALData;
897 pAdapter->sataEvents[channel] = SATA_EVENT_CHANNEL_CONNECTED;
901 pAdapter->event_timer_connect = timeout(hptmv_handle_event_connect, pAdapter, 10*hz);
905 pAdapter->sataEvents[channel] = SATA_EVENT_CHANNEL_DISCONNECTED;
908 device_change(pAdapter, channel, FALSE);
910 /*pAdapter->event_timer_disconnect = timeout(hptmv_handle_event_disconnect, pAdapter, 10*hz); */
912 hptmv_handle_event_disconnect(pAdapter);
937 hptmv_allocate_edma_queues(IAL_ADAPTER_T *pAdapter)
939 pAdapter->requestsArrayBaseAddr = (MV_U8 *)contigmalloc(REQUESTS_ARRAY_SIZE,
941 if (pAdapter->requestsArrayBaseAddr == NULL)
944 " queues\n", pAdapter->mvSataAdapter.adapterId);
947 pAdapter->requestsArrayBaseDmaAddr = fOsPhysicalAddress(pAdapter->requestsArrayBaseAddr);
948 pAdapter->requestsArrayBaseAlignedAddr = pAdapter->requestsArrayBaseAddr;
949 pAdapter->requestsArrayBaseAlignedAddr += MV_EDMA_REQUEST_QUEUE_SIZE;
950 pAdapter->requestsArrayBaseAlignedAddr = (MV_U8 *)
951 (((ULONG_PTR)pAdapter->requestsArrayBaseAlignedAddr) & ~(ULONG_PTR)(MV_EDMA_REQUEST_QUEUE_SIZE - 1));
952 pAdapter->requestsArrayBaseDmaAlignedAddr = pAdapter->requestsArrayBaseDmaAddr;
953 pAdapter->requestsArrayBaseDmaAlignedAddr += MV_EDMA_REQUEST_QUEUE_SIZE;
954 pAdapter->requestsArrayBaseDmaAlignedAddr &= ~(ULONG_PTR)(MV_EDMA_REQUEST_QUEUE_SIZE - 1);
956 if ((pAdapter->requestsArrayBaseDmaAlignedAddr - pAdapter->requestsArrayBaseDmaAddr) !=
957 (pAdapter->requestsArrayBaseAlignedAddr - pAdapter->requestsArrayBaseAddr))
960 pAdapter->mvSataAdapter.adapterId);
961 contigfree(pAdapter->requestsArrayBaseAddr, REQUESTS_ARRAY_SIZE, M_DEVBUF);
965 pAdapter->responsesArrayBaseAddr = (MV_U8 *)contigmalloc(RESPONSES_ARRAY_SIZE,
967 if (pAdapter->responsesArrayBaseAddr == NULL)
970 " queues\n", pAdapter->mvSataAdapter.adapterId);
971 contigfree(pAdapter->requestsArrayBaseAddr, RESPONSES_ARRAY_SIZE, M_DEVBUF);
974 pAdapter->responsesArrayBaseDmaAddr = fOsPhysicalAddress(pAdapter->responsesArrayBaseAddr);
975 pAdapter->responsesArrayBaseAlignedAddr = pAdapter->responsesArrayBaseAddr;
976 pAdapter->responsesArrayBaseAlignedAddr += MV_EDMA_RESPONSE_QUEUE_SIZE;
977 pAdapter->responsesArrayBaseAlignedAddr = (MV_U8 *)
978 (((ULONG_PTR)pAdapter->responsesArrayBaseAlignedAddr) & ~(ULONG_PTR)(MV_EDMA_RESPONSE_QUEUE_SIZE - 1));
979 pAdapter->responsesArrayBaseDmaAlignedAddr = pAdapter->responsesArrayBaseDmaAddr;
980 pAdapter->responsesArrayBaseDmaAlignedAddr += MV_EDMA_RESPONSE_QUEUE_SIZE;
981 pAdapter->responsesArrayBaseDmaAlignedAddr &= ~(ULONG_PTR)(MV_EDMA_RESPONSE_QUEUE_SIZE - 1);
983 if ((pAdapter->responsesArrayBaseDmaAlignedAddr - pAdapter->responsesArrayBaseDmaAddr) !=
984 (pAdapter->responsesArrayBaseAlignedAddr - pAdapter->responsesArrayBaseAddr))
987 pAdapter->mvSataAdapter.adapterId);
988 contigfree(pAdapter->requestsArrayBaseAddr, REQUESTS_ARRAY_SIZE, M_DEVBUF);
989 contigfree(pAdapter->responsesArrayBaseAddr, RESPONSES_ARRAY_SIZE, M_DEVBUF);
996 hptmv_free_edma_queues(IAL_ADAPTER_T *pAdapter)
998 contigfree(pAdapter->requestsArrayBaseAddr, REQUESTS_ARRAY_SIZE, M_DEVBUF);
999 contigfree(pAdapter->responsesArrayBaseAddr, RESPONSES_ARRAY_SIZE, M_DEVBUF);
1003 AllocatePRDTable(IAL_ADAPTER_T *pAdapter)
1006 if (pAdapter->pFreePRDLink) {
1007 KdPrint(("pAdapter->pFreePRDLink:%p\n",pAdapter->pFreePRDLink));
1008 ret = pAdapter->pFreePRDLink;
1009 pAdapter->pFreePRDLink = *(void**)ret;
1016 FreePRDTable(IAL_ADAPTER_T *pAdapter, PVOID PRDTable)
1018 *(void**)PRDTable = pAdapter->pFreePRDLink;
1019 pAdapter->pFreePRDLink = PRDTable;
1025 fRegisterVdevice(IAL_ADAPTER_T *pAdapter)
1032 pPhysical = &(pAdapter->VDevices[i]);
1042 pVBus = &pAdapter->VBus;
1068 IAL_ADAPTER_T *pAdapter = (IAL_ADAPTER_T *)pArray->pVBus->OsExt;
1076 pVDevice = &pAdapter->VDevices[i];
1140 IAL_ADAPTER_T *pAdapter = pSataAdapter->IALData;
1141 MV_CHANNEL *channelInfo = &(pAdapter->mvChannel[channelIndex]);
1183 IAL_ADAPTER_T *pAdapter = pSataAdapter->IALData;
1184 MV_CHANNEL *channelInfo = &(pAdapter->mvChannel[channelIndex]);
1222 IAL_ADAPTER_T *pAdapter = pSataAdapter->IALData;
1223 MV_CHANNEL *channelInfo = &(pAdapter->mvChannel[channelIndex]);
1274 dmamap_get(struct IALAdapter * pAdapter)
1276 PBUS_DMAMAP p = pAdapter->pbus_dmamap_list;
1278 pAdapter->pbus_dmamap_list = p-> next;
1285 p->next = p->pAdapter->pbus_dmamap_list;
1286 p->pAdapter->pbus_dmamap_list = p;
1303 init_adapter(IAL_ADAPTER_T *pAdapter)
1305 PVBus _vbus_p = &pAdapter->VBus;
1313 pAdapter->next = 0;
1316 gIal_Adapter = pAdapter;
1320 pCurAdapter->next = pAdapter;
1321 pCurAdapter = pAdapter;
1324 pAdapter->outstandingCommands = 0;
1326 pMvSataAdapter = &(pAdapter->mvSataAdapter);
1327 _vbus_p->OsExt = (void *)pAdapter;
1328 pMvSataAdapter->IALData = pAdapter;
1330 if (bus_dma_tag_create(bus_get_dma_tag(pAdapter->hpt_dev),/* parent */
1344 &pAdapter->io_dma_parent /* tag */))
1350 if (hptmv_allocate_edma_queues(pAdapter))
1359 if (!(pAdapter->mem_res = bus_alloc_resource(pAdapter->hpt_dev, SYS_RES_MEMORY, &rid,
1362 !(pMvSataAdapter->adapterIoBaseAddress = rman_get_virtual(pAdapter->mem_res)))
1365 hptmv_free_edma_queues(pAdapter);
1376 pMvSataAdapter->pciConfigRevisionId = pci_read_config(pAdapter->hpt_dev, PCIR_REVID, 1);
1377 pMvSataAdapter->pciConfigDeviceId = pci_get_device(pAdapter->hpt_dev);
1394 bus_release_resource(pAdapter->hpt_dev, SYS_RES_MEMORY, rid, pAdapter->mem_res);
1395 hptmv_free_edma_queues(pAdapter);
1399 pAdapter->ver_601 = pMvSataAdapter->pcbVersion;
1408 pAdapter->pCommandBlocks =
1410 KdPrint(("pCommandBlocks:%p\n",pAdapter->pCommandBlocks));
1411 if (!pAdapter->pCommandBlocks) {
1417 FreeCommand(_VBUS_P &(pAdapter->pCommandBlocks[i]));
1421 pAdapter->pbus_dmamap = (PBUS_DMAMAP)malloc (sizeof(struct _BUS_DMAMAP) * MAX_QUEUE_COMM, M_DEVBUF, M_NOWAIT);
1422 if(!pAdapter->pbus_dmamap) {
1424 free(pAdapter->pCommandBlocks, M_DEVBUF);
1428 memset((void *)pAdapter->pbus_dmamap, 0, sizeof(struct _BUS_DMAMAP) * MAX_QUEUE_COMM);
1429 pAdapter->pbus_dmamap_list = 0;
1431 PBUS_DMAMAP pmap = &(pAdapter->pbus_dmamap[i]);
1432 pmap->pAdapter = pAdapter;
1435 if(bus_dmamap_create(pAdapter->io_dma_parent, 0, &pmap->dma_map)) {
1437 free(pAdapter->pCommandBlocks, M_DEVBUF);
1438 free(pAdapter->pbus_dmamap, M_DEVBUF);
1445 pAdapter->pFreePRDLink = 0;
1447 pAdapter->prdTableAddr = (PUCHAR)contigmalloc(
1450 KdPrint(("prdTableAddr:%p\n",pAdapter->prdTableAddr));
1451 if (!pAdapter->prdTableAddr) {
1455 pAdapter->prdTableAlignedAddr = (PUCHAR)(((ULONG_PTR)pAdapter->prdTableAddr + 0x1f) & ~(ULONG_PTR)0x1fL);
1457 PUCHAR PRDTable = pAdapter->prdTableAlignedAddr;
1460 /* KdPrint(("i=%d,pAdapter->pFreePRDLink=%p\n",i,pAdapter->pFreePRDLink)); */
1461 FreePRDTable(pAdapter, PRDTable);
1471 pAdapter->mvChannel[channel].online = MV_FALSE;
1478 if (hptmv_init_channel(pAdapter, channel) == 0)
1484 hptmv_free_channel(pAdapter, channel);
1488 if (start_channel(pAdapter, channel))
1493 hptmv_free_channel(pAdapter, channel);
1495 pAdapter->mvChannel[channel].online = MV_TRUE;
1502 KdPrint(("pAdapter->mvChannel[channel].online:%x, channel:%d\n",
1503 pAdapter->mvChannel[channel].online, channel));
1517 init_vdev_params(pAdapter, channel);
1518 IdeRegisterVDevice(&pAdapter->VDevices[channel].u.disk);
1525 fRegisterVdevice(pAdapter);
1547 IAL_ADAPTER_T *pAdapter = (IAL_ADAPTER_T *)pMvSataAdapter->IALData;
1558 hptmv_free_channel(pAdapter, channel);
1567 hptmv_free_channel(pAdapter, channel);
1575 hptmv_free_channel(pAdapter, channel);
1603 pAdapter->mvChannel[channel].maxPioModeSupported, 0, 0, 0) == MV_FALSE) ||
1606 pAdapter->mvChannel[channel].maxUltraDmaModeSupported, 0, 0, 0) == MV_FALSE) )
1609 hptmv_free_channel(pAdapter, channel);
1616 hptmv_free_channel(pAdapter, channel);
2033 IAL_ADAPTER_T * pAdapter = device_get_softc(dev);
2041 if (!pAdapter)
2043 pAdapter = (IAL_ADAPTER_T *)malloc(sizeof (IAL_ADAPTER_T), M_DEVBUF, M_NOWAIT);
2045 device_set_softc(dev, (void *)pAdapter);
2047 device_set_driver(dev, (driver_t *)pAdapter);
2051 if (!pAdapter) return (ENOMEM);
2052 bzero(pAdapter, sizeof(IAL_ADAPTER_T));
2054 pAdapter->hpt_dev = dev;
2056 rid = init_adapter(pAdapter);
2061 if ((pAdapter->hpt_irq = bus_alloc_resource(pAdapter->hpt_dev, SYS_RES_IRQ, &rid, 0, ~0ul, 1, RF_SHAREABLE | RF_ACTIVE)) == NULL)
2068 if (bus_setup_intr(pAdapter->hpt_dev, pAdapter->hpt_irq, INTR_TYPE_CAM,
2069 hpt_intr, pAdapter, &pAdapter->hpt_intr))
2071 if (bus_setup_intr(pAdapter->hpt_dev, pAdapter->hpt_irq, INTR_TYPE_CAM,
2072 NULL, hpt_intr, pAdapter, &pAdapter->hpt_intr))
2076 free(pAdapter, M_DEVBUF);
2105 pAdapter, device_get_unit(pAdapter->hpt_dev), 1, 8, devq);
2108 pAdapter, device_get_unit(pAdapter->hpt_dev), &Giant, 1, 8, devq);
2126 if(xpt_create_path(&pAdapter->path, /*periph */ NULL,
2136 xpt_setup_ccb(&(ccb->ccb_h), pAdapter->path, /*priority*/5);
2177 IAL_ADAPTER_T *pAdapter = (IAL_ADAPTER_T *)arg;
2181 if (mvSataInterruptServiceRoutine(&pAdapter->mvSataAdapter) == MV_TRUE)
2183 _VBUS_INST(&pAdapter->VBus)
2212 FlushAdapter(IAL_ADAPTER_T *pAdapter)
2220 PVDevice pVDev = pAdapter->VBus.pVDevice[i];
2228 IAL_ADAPTER_T *pAdapter;
2230 pAdapter = device_get_softc(dev);
2231 if (pAdapter == NULL)
2234 EVENTHANDLER_DEREGISTER(shutdown_final, pAdapter->eh);
2235 FlushAdapter(pAdapter);
2243 Check_Idle_Call(IAL_ADAPTER_T *pAdapter)
2245 _VBUS_INST(&pAdapter->VBus)
2259 hpt_queue_dpc((HPT_DPC)hpt_rebuild_data_block, pAdapter, pArray, DUPLICATE);
2266 while(pAdapter->pending_Q!= NULL)
2268 _VBUS_INST(&pAdapter->VBus)
2269 union ccb *ccb = (union ccb *)pAdapter->pending_Q->ccb_h.ccb_ccb_ptr;
2270 hpt_free_ccb(&pAdapter->pending_Q, ccb);
2279 IAL_ADAPTER_T * pAdapter = pmap->pAdapter;
2285 pAdapter->outstandingCommands--;
2287 if (pAdapter->outstandingCommands == 0)
2290 Check_Idle_Call(pAdapter);
2305 IAL_ADAPTER_T * pAdapter = (IAL_ADAPTER_T *) cam_sim_softc(sim);
2307 _VBUS_INST(&pAdapter->VBus)
2324 pAdapter->VBus.pVDevice[ccb->ccb_h.target_id]==0) {
2331 if (pAdapter->outstandingCommands==0 && DPC_Request_Nums==0)
2332 Check_Idle_Call(pAdapter);
2334 pmap = dmamap_get(pAdapter);
2340 hpt_queue_ccb(&pAdapter->pending_Q, ccb);
2496 p.dpc(p.pAdapter, p.arg, p.flags);
2502 if (p.pAdapter->outstandingCommands == 0) {
2503 _VBUS_INST(&p.pAdapter->VBus);
2504 Check_Idle_Call(p.pAdapter);
2522 IAL_ADAPTER_T *pAdapter;
2526 pAdapter = gIal_Adapter;
2528 while(pAdapter != 0){
2530 _vbus_p = &pAdapter->VBus;
2543 pAdapter = pAdapter->next;
2724 _VBUS_INST(&((PBUS_DMAMAP)((union ccb *)arg)->ccb_adapter)->pAdapter->VBus)
2737 IAL_ADAPTER_T *pAdapter = pmap->pAdapter;
2738 PVDevice pVDev = pAdapter->VBus.pVDevice[ccb_h->target_id];
2760 bus_dmamap_sync(pAdapter->io_dma_parent, pmap->dma_map,
2764 bus_dmamap_sync(pAdapter->io_dma_parent, pmap->dma_map,
2780 IAL_ADAPTER_T *pAdapter = pmap->pAdapter;
2783 PVDevice pVDev = pAdapter->VBus.pVDevice[ccb_h->target_id];
2792 pAdapter->outstandingCommands++;
2954 error = bus_dmamap_load_ccb(pAdapter->io_dma_parent,
2966 pAdapter->outstandingCommands--;
2987 IAL_ADAPTER_T *pAdapter = pmap->pAdapter;
3018 bus_dmamap_sync(pAdapter->io_dma_parent, pmap->dma_map, BUS_DMASYNC_POSTREAD);
3021 bus_dmamap_sync(pAdapter->io_dma_parent, pmap->dma_map, BUS_DMASYNC_POSTWRITE);
3024 bus_dmamap_unload(pAdapter->io_dma_parent, pmap->dma_map);
3031 hpt_queue_dpc(HPT_DPC dpc, IAL_ADAPTER_T * pAdapter, void *arg, UCHAR flags)
3042 DpcQueue[DpcQueue_Last].pAdapter = pAdapter;