亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? read_write.c

?? PCI硬件的驅動程序范例
?? C
?? 第 1 頁 / 共 2 頁
字號:
//
//  NOTES:
//      *** Called (and returns) with the WriteQueueLock held.
//
///////////////////////////////////////////////////////////////////////////////
VOID
OsrStartReadIrp(PDEVICE_OBJECT DeviceObject, PIRP Irp)
{
    POSR_DEVICE_EXT devExt = DeviceObject->DeviceExtension;
    PIO_STACK_LOCATION ioStack;
    ULONG mapRegsNeeded;

    ioStack = IoGetCurrentIrpStackLocation(Irp);

    //
    // In progress IRPs cannot be cancelled
    //
    IoSetCancelRoutine(Irp, NULL);

#if DBG
    DbgPrint("OsrRead: Transfer length %d.\n",
                                ioStack->Parameters.Read.Length);
#endif

    //
    // There is no in-progress request.  Start this request on the
    // device.
    //
    devExt->CurrentReadIrp = Irp;

    devExt->ReadTotalLength = ioStack->Parameters.Read.Length;

    devExt->ReadSoFar = 0;

    devExt->ReadStartingOffset = 0;

    //
    // Start the watchdog timer on this IRP
    //
    (ULONG)Irp->Tail.Overlay.DriverContext[0] = OSR_WATCHDOG_INTERVAL;

    //
    // Flush the requestor's buffer back from cache on non-dma coherent
    // machines.
    //
    KeFlushIoBuffers(Irp->MdlAddress, TRUE, TRUE);

    //
    // Determine number of map registers required by this read
    //
    mapRegsNeeded = 
        ADDRESS_AND_SIZE_TO_SPAN_PAGES(MmGetMdlVirtualAddress(Irp->MdlAddress),
                                        ioStack->Parameters.Read.Length);
        
#if DBG
    DbgPrint("StartReadIrp: %d. map regs needed\n", mapRegsNeeded);
#endif

    //
    // Limit the number of map registers used to the maximum allowed by the
    // HAL.  We determined this max when we called HalGetAdapter() during
    // our DriverEntry processing.
    //
    devExt->MapRegsThisRead = ((mapRegsNeeded > devExt->ReadMapRegsGot) ? 
                              devExt->ReadMapRegsGot : mapRegsNeeded);

#if DBG
    DbgPrint("StartReadIrp: %d. map regs this xfer\n", devExt->MapRegsThisRead);
#endif

    IoAllocateAdapterChannel(devExt->ReadAdapter,
                             DeviceObject, 
                             devExt->MapRegsThisRead,
                             OsrAdapterControlRead,
                             Irp);
}

///////////////////////////////////////////////////////////////////////////////
//
//  OsrAdapterControlRead
//
//    This is routine is called by the I/O Manager when the Adapter resources
//    (such as map registers) requested by the OsrStartReadIrp function are
//    available for our use.
//
//  INPUTS:
//
//      DeviceObject - Address of the DEVICE_OBJECT for our device.
//  
//      MapRegisterBase - Base address of the Map registers that have been
//                        reserved for us use.
//
//       Context - address of the Read Irp for the operation to be started
//
//  OUTPUTS:
//
//      None.
//
//  RETURNS:
//
//    DeallocateObjectKeepRegisters - indicates that the Mapping Registers that
//              were allocated to us should not be deallocated at this time.  We
//              will deallocate them from the DpcForIsr when the Read completes.
//
//  IRQL:
//
//    This routine is called at IRQL_DISPATCH_LEVEL.
//
//  NOTES:
//
///////////////////////////////////////////////////////////////////////////////
IO_ALLOCATION_ACTION 
OsrAdapterControlRead(IN PDEVICE_OBJECT DeviceObject, IN PIRP NotUsed, 
                                  IN PVOID MapRegisterBase, IN PVOID Context)
{
    PIRP irp = (PIRP) Context;
    PIO_STACK_LOCATION ioStack;
    POSR_DEVICE_EXT devExt;
    PUCHAR baseVa;

#if DBG
    DbgPrint("AdapterControlRead: Irp = 0x%0x\n", irp);
    DbgPrint("AdapterControlRead: Map Register Base = 0x%0x\n", MapRegisterBase);
#endif

    devExt = DeviceObject->DeviceExtension;
    
    ioStack = IoGetCurrentIrpStackLocation(irp);

    devExt->ReadLength = ioStack->Parameters.Read.Length - devExt->ReadSoFar;

#if DBG
    DbgPrint("AdapterControlRead: Length remaining = %d. \n", devExt->ReadLength);
#endif

    //
    // Get set-up for the transfer
    //
    devExt->ReadMapRegBase = MapRegisterBase;

    devExt->ReadStartingOffset =  devExt->ReadSoFar;

    //
    // Get requestor's virtual address of the buffer.  This is used by
    // IoMapTransfer() as an index into the buffer to track the progress
    // of the map operation.
    //
    baseVa = MmGetMdlVirtualAddress(irp->MdlAddress);

    //
    // Get the logical base address and length of a fragment of the 
    // requestor's buffer.
    //
    // Even though we are a Busmaster device, our device does not support
    // scatter/gather.  Thus, we can only use a single base address and length
    // at a time.  If the requestor's buffer has more fragments, we will
    // do additional DMA operations (one for each fragment) until the entire
    // transfer has been completed.
    //
    devExt->ReadPaToDevice = IoMapTransfer(NULL,
                                   irp->MdlAddress,
                                   MapRegisterBase,
                                   baseVa+(devExt->ReadSoFar),
                                   &devExt->ReadLength,
                                   FALSE);  // FALSE = READ from device


    //
    // Track the length of the requestor's buffer we've read so far.
    //
    devExt->ReadSoFar += devExt->ReadLength;

    //
    // Start the request on the device -- Base Address and Length
    // of this fragment are stored in the device extension
    //
    (VOID)KeSynchronizeExecution(devExt->InterruptObject,
                            OsrStartReadOnDevice,
                            DeviceObject);

    return(DeallocateObjectKeepRegisters);
}        


///////////////////////////////////////////////////////////////////////////////
//
//  OsrAdapterControlWrite
//
//    This is routine is called by the I/O Manager when the Adapter resources
//    (such as map registers) requested by the OsrStartWriteIrp function are
//    available for our use.
//
//  INPUTS:
//
//      DeviceObject - Address of the DEVICE_OBJECT for our device.
//  
//      MapRegisterBase - Base address of the Map registers that have been
//                      reserved by the I/O Manager and HAL for our use.
//
//      Context - address of the Write Irp for the operation to be started on the 
//              device.
//
//  OUTPUTS:
//
//      None.
//
//  RETURNS:
//
//    DeallocateObjectKeepRegisters - indicates that the map registers that
//            were allocated to us should not be deallocated at this time.
//            We will deallocate them with the Read operation completes.
//
//  IRQL:
//
//    This routine is called at IRQL_DISPATCH_LEVEL.
//
//  NOTES:
//
///////////////////////////////////////////////////////////////////////////////
IO_ALLOCATION_ACTION 
OsrAdapterControlWrite(IN PDEVICE_OBJECT DeviceObject, IN PIRP NotUsed, 
                                  IN PVOID MapRegisterBase, IN PVOID Context)
{
    PIRP irp = (PIRP) Context;
    PIO_STACK_LOCATION ioStack;
    POSR_DEVICE_EXT devExt;
    PUCHAR baseVa;

#if DBG
    DbgPrint("AdapterControlWrite: Irp = 0x%0x\n", irp);
#endif

    devExt = DeviceObject->DeviceExtension;

    ioStack = IoGetCurrentIrpStackLocation(irp);

    devExt->WriteLength = ioStack->Parameters.Write.Length - devExt->WriteSoFar;

#if DBG
    DbgPrint("AdapterControlWrite: Length remaining = %d. \n", devExt->WriteLength);
#endif

    //
    // Get set-up for the transfer
    //
    devExt->WriteMapRegBase = MapRegisterBase;

    baseVa = MmGetMdlVirtualAddress(irp->MdlAddress);

    devExt->WriteStartingOffset =  devExt->WriteSoFar;

    //
    // Get the base address and length of the segment to write.
    //
    devExt->WritePaToDevice = IoMapTransfer(NULL,
                                   irp->MdlAddress,
                                   MapRegisterBase,
                                   baseVa+(devExt->WriteSoFar),
                                   &devExt->WriteLength,
                                   TRUE);      // WriteToDevice

    //
    // Update the length transfered so far
    //
    devExt->WriteSoFar += devExt->WriteLength;

    //
    // Put the request on the device
    //
    (VOID)KeSynchronizeExecution(devExt->InterruptObject,
                            OsrStartWriteOnDevice,
                            DeviceObject);

    return(DeallocateObjectKeepRegisters);
}        


///////////////////////////////////////////////////////////////////////////////
//
//  OsrStartReadOnDevice
//
//      This function performs all the actual hardware manipulation to initiate
//      a new read request on the AMCC device.  When called, all resources
//      (mapping registers) have been allocated for the operation, and we have
//      a base address and length of a buffer fragment to be DMA'ed.
//
//  INPUTS:
//
//      DeviceObject - Address of the DEVICE_OBJECT for our device.
//  
//      BaseAddress  - Logical base address of the requestor's buffer fragment
//                      to be used as the base address of the transfer
//
//      Length - Length in bytes of this fragment to be transfered.
//
//  OUTPUTS:
//
//      None.
//
//  RETURNS:
//
//      None.
//
//  IRQL:
//
//      This routine is called at IRQL_DISPATCH_LEVEL.
//
//  NOTES:
//
//      When this routine is called, no other Read operations are in progress on
//      the device.
//
///////////////////////////////////////////////////////////////////////////////
BOOLEAN
OsrStartReadOnDevice(IN PVOID SynchronizeContext)
{
    ULONG temp;
    PDEVICE_OBJECT deviceObject = (PDEVICE_OBJECT)SynchronizeContext;
    PHYSICAL_ADDRESS baseAddress;
    ULONG length;
    POSR_DEVICE_EXT devExt = deviceObject->DeviceExtension;

    baseAddress = devExt->ReadPaToDevice;
    length = devExt->ReadLength;

#if DBG
    DbgPrint("StartReadOnDev: Reading BA = 0x%0x, Length = %d.\n",
                        baseAddress.LowPart, length);
#endif

    //
    // Pass the device the Physical Base Address of the buffer
    //
    ASSERT(!baseAddress.HighPart);

    WRITE_PORT_ULONG(devExt->AmccBaseRegisterAddress+MWAR_OFF,
                     baseAddress.LowPart);

    //
    // ...and the length of the read
    //
    WRITE_PORT_ULONG(devExt->AmccBaseRegisterAddress+MWTC_OFF, length);

    //
    // Tell the device to interrupt when the read is complete.
    //
    // NOTE: In this particular device, "read" operations from the
    // device are called "WRITE" operations... since they write to
    // MEMORY.  Thus, we set the INT_ON_WRITE bit in the Interrupt
    // CSR.
    //
    temp = READ_PORT_ULONG(devExt->AmccBaseRegisterAddress+ICSR_OFF);

#if DBG
    DbgPrint("StartDmaRead: Current INTCSR State:\n");
    OsrPrintIntcsr(temp);
#endif

    temp &= ~AMCC_INT_ACK_BITS;
    temp |= AMCC_INT_INT_ON_WRITE;
    
    WRITE_PORT_ULONG(devExt->AmccBaseRegisterAddress+ICSR_OFF, temp);

    //
    // Yeeeeha!  Start the request by settting the "Write Enable"
    // bit in the master CSR
    //
    temp = READ_PORT_ULONG(devExt->AmccBaseRegisterAddress+MCSR_OFF);
    temp &= (AMCC_MCSR_READ_ENABLE        |
                AMCC_MCSR_READ_FIFO_MGMT  |
                AMCC_MCSR_READ_PRIORITY   |
                AMCC_MCSR_WRITE_ENABLE    |
                AMCC_MCSR_WRITE_FIFO_MGMT |
                AMCC_MCSR_WRITE_PRIORITY);

    temp |= AMCC_MCSR_WRITE_ENABLE;

    WRITE_PORT_ULONG(devExt->AmccBaseRegisterAddress+MCSR_OFF, temp); 

    return(TRUE);
}    

///////////////////////////////////////////////////////////////////////////////
//
//  OsrStartWriteOnDevice
//
//      This function performs all the actual hardware manipulation to initiate
//      a new read request on the AMCC device.  When called, all resources
//      (mapping registers) have been allocated for the operation, and we have
//      a base address and length of a buffer fragment to be DMA'ed.
//
//  INPUTS:
//
//      DeviceObject - Address of the DEVICE_OBJECT for our device.
//  
//      BaseAddress  - Logical base address of the requestor's buffer fragment
//                      to be used as the base address of the transfer
//
//      Length - Length in bytes of this fragment to be transfered.
//
//  OUTPUTS:
//
//      None.
//
//  RETURNS:
//
//    None.
//
//  IRQL:
//
//    This routine is called at IRQL_DISPATCH_LEVEL.
//
//  NOTES:
//
//    When this routine is called, no other Write operations are in progress on
//    the device.
//
///////////////////////////////////////////////////////////////////////////////
BOOLEAN
OsrStartWriteOnDevice(IN PVOID SynchronizeContext)
{
    ULONG temp;
    PDEVICE_OBJECT deviceObject = (PDEVICE_OBJECT)SynchronizeContext;
    PHYSICAL_ADDRESS baseAddress;
    ULONG length;
    POSR_DEVICE_EXT devExt = deviceObject->DeviceExtension;

    baseAddress = devExt->WritePaToDevice;
    length = devExt->WriteLength;

#if DBG
    DbgPrint("StartWriteOnDev: Writing BA = 0x%0x, Length = %d.\n",
                        baseAddress.LowPart, length);
#endif

    //
    // Pass the device the Physical Base Address of the buffer...
    //
    ASSERT(!baseAddress.HighPart);

    WRITE_PORT_ULONG(devExt->AmccBaseRegisterAddress+MRAR_OFF,
                     baseAddress.LowPart);

    //
    // ...and the length of the write operation
    //
    WRITE_PORT_ULONG(devExt->AmccBaseRegisterAddress+MRTC_OFF, length);

    //
    // Request the device interrupt when the write operation is complete
    //
    temp = READ_PORT_ULONG(devExt->AmccBaseRegisterAddress+ICSR_OFF);

#if DBG
    DbgPrint("StartWriteOnDev: Current INTCSR State:\n");
    OsrPrintIntcsr(temp);
#endif

    temp &= ~AMCC_INT_ACK_BITS;
    temp |= AMCC_INT_INT_ON_READ;
    WRITE_PORT_ULONG(devExt->AmccBaseRegisterAddress+ICSR_OFF, temp);

    //
    // Yeeeeha!  Start the request by setting the appropriate enable bit.
    //
    temp = READ_PORT_ULONG(devExt->AmccBaseRegisterAddress+MCSR_OFF);
    temp &= (AMCC_MCSR_READ_ENABLE|
                AMCC_MCSR_READ_FIFO_MGMT|
                AMCC_MCSR_READ_PRIORITY|
                AMCC_MCSR_WRITE_ENABLE|
                AMCC_MCSR_WRITE_FIFO_MGMT|
                AMCC_MCSR_WRITE_PRIORITY);

    temp |= AMCC_MCSR_READ_ENABLE;

    WRITE_PORT_ULONG(devExt->AmccBaseRegisterAddress+MCSR_OFF, temp); 

    return(TRUE);
}    

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲成人资源网| 成人精品视频一区二区三区 | 日韩欧美国产综合在线一区二区三区| 日韩综合一区二区| 日韩国产一二三区| 免费成人深夜小野草| 日本欧美一区二区| 久久福利视频一区二区| 国产在线精品一区二区夜色| 国产福利91精品| 91高清视频免费看| 制服丝袜av成人在线看| 精品一区二区成人精品| 99久久婷婷国产综合精品| 成人性色生活片免费看爆迷你毛片| 国产日韩欧美一区二区三区综合| av电影一区二区| 91麻豆swag| 国产亚洲一区二区三区四区| 国产伦精品一区二区三区免费 | 久久99精品久久久久久国产越南| 亚洲精品在线免费观看视频| 成人免费毛片高清视频| 亚洲你懂的在线视频| 在线播放91灌醉迷j高跟美女 | 亚洲色图另类专区| 亚洲18影院在线观看| 国产黄色91视频| 91久久一区二区| 3d动漫精品啪啪1区2区免费| 中文字幕一区二区三区在线播放 | 久久综合狠狠综合久久激情| 中文字幕av资源一区| 亚洲精品成a人| 91麻豆视频网站| 国产拍揄自揄精品视频麻豆| 国产精品一色哟哟哟| 日韩精品中文字幕一区二区三区 | 亚洲乱码中文字幕| 午夜国产精品影院在线观看| 色婷婷久久久亚洲一区二区三区| 久久久噜噜噜久久人人看 | 丁香亚洲综合激情啪啪综合| 色噜噜偷拍精品综合在线| 在线免费观看不卡av| 日韩免费观看高清完整版在线观看| 日韩视频中午一区| 天涯成人国产亚洲精品一区av| 欧美妇女性影城| 欧美色成人综合| 欧美一区日本一区韩国一区| 中文字幕一区二区三区四区| 日韩一区二区电影| 欧美专区亚洲专区| jlzzjlzz亚洲女人18| 国产一区二区三区电影在线观看| 亚洲成人一区二区在线观看| 一区精品在线播放| 美女视频一区二区| 亚洲一区在线播放| 欧美性生交片4| 日韩高清不卡在线| 久久亚洲二区三区| 91视频精品在这里| 日本美女一区二区三区视频| 国产区在线观看成人精品| 97成人超碰视| 日韩精品亚洲一区二区三区免费| 亚洲精品一区二区三区99| 国产高清不卡一区二区| 亚洲欧美自拍偷拍| 91精品国产综合久久小美女| 国产 日韩 欧美大片| 亚洲超碰精品一区二区| 久久久美女毛片| 69久久夜色精品国产69蝌蚪网| 国产一区二区三区免费看| 最新国产精品久久精品| 欧美精品一区男女天堂| 欧美高清视频不卡网| 成人av免费观看| 美女高潮久久久| 五月激情六月综合| 国产精品国模大尺度视频| 欧美日韩激情在线| 91福利资源站| 岛国精品在线观看| 色综合久久久久| 国产aⅴ综合色| 午夜在线成人av| 日韩欧美一级二级| 日韩一区和二区| 亚洲福利一二三区| 欧美岛国在线观看| 日本免费在线视频不卡一不卡二| 天天亚洲美女在线视频| 日本va欧美va精品| 国产在线一区观看| av亚洲产国偷v产偷v自拍| 91久久香蕉国产日韩欧美9色| 欧美在线|欧美| 欧美一区二区久久久| 久久日韩精品一区二区五区| 国产精品久久久久一区二区三区 | 国产成人精品免费看| 日本不卡视频一二三区| 日韩国产欧美在线观看| 秋霞午夜鲁丝一区二区老狼| 免费三级欧美电影| 久久疯狂做爰流白浆xx| 国产做a爰片久久毛片| 不卡av免费在线观看| 在线视频亚洲一区| 欧美一区二区三区视频在线| 久久精品这里都是精品| 国产精品久久久久9999吃药| 亚洲欧美日韩久久精品| 日韩精品电影一区亚洲| 国产夫妻精品视频| 91丨porny丨在线| 欧美一级一区二区| 中文字幕av不卡| 老司机一区二区| 一本久久a久久免费精品不卡| 日韩一区二区在线观看视频播放| 久久精品一区四区| 日本午夜精品一区二区三区电影| 麻豆精品一区二区三区| 色老头久久综合| 欧美国产日韩精品免费观看| 精品无人码麻豆乱码1区2区| 99久久精品情趣| 一区二区三区欧美激情| 看电视剧不卡顿的网站| 欧美日韩一区二区三区高清| 天天色 色综合| 91福利在线看| 精品国产伦一区二区三区免费| 欧美无砖砖区免费| 中文字幕亚洲精品在线观看| 狠狠色狠狠色综合| 欧美一区二区三区四区视频| 99国产一区二区三精品乱码| 国产成人av网站| 国产成人一级电影| 国产麻豆精品久久一二三| 欧美调教femdomvk| 亚洲美女一区二区三区| 国产99久久久久| xf在线a精品一区二区视频网站| 亚洲午夜在线观看视频在线| 91日韩在线专区| 亚洲特级片在线| 99国产精品久| 中文一区在线播放| 欧美日韩在线三级| 日韩电影免费一区| 欧美精品一区视频| av成人免费在线| 美国十次了思思久久精品导航| 777精品伊人久久久久大香线蕉| 亚洲va韩国va欧美va精品| 欧美精品九九99久久| 久久电影网站中文字幕| 久久综合九色综合欧美亚洲| 成人av免费在线播放| 亚洲一区二区三区四区不卡| 欧美一区二区三区日韩视频| 国产精品一区二区黑丝| 亚洲天堂精品在线观看| 日韩一级黄色片| 国产黄色91视频| 日韩成人精品在线观看| 国产精品无人区| 3atv一区二区三区| 色婷婷av一区二区三区软件| 日本不卡一二三| 亚洲欧美激情插| 欧美国产精品v| 日韩免费高清av| 欧美午夜精品久久久久久孕妇| 三级亚洲高清视频| 一区二区三区美女| 国产精品理论片| 久久久99免费| 亚洲美女在线国产| 中文字幕va一区二区三区| 久久精品男人的天堂| 亚洲精品成人悠悠色影视| 一区二区在线电影| 免费高清视频精品| 亚洲裸体xxx| 91麻豆精品国产91久久久久久久久 | 蜜芽一区二区三区| 日韩丝袜情趣美女图片| 高清国产一区二区| 一区二区三区四区亚洲| 日韩一区二区免费电影| 国产成人在线网站| 亚洲在线视频一区|