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

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

?? ide.c

?? 硬盤驅動的例子
?? C
?? 第 1 頁 / 共 4 頁
字號:

                        //
                        // And set the Status and Infomration fields
                        //
                        Irp->IoStatus.Information = tempSize;
                        Irp->IoStatus.Status = STATUS_SUCCESS;

                    }

                    //
                    // Free the buffer holding the partition table information
                    // allocated by IoReadPartitionTable()
                    //
                    ExFreePool(partitionList);
                }
            }

            break ;

        //
        // Update the disk with new partition information.
        //
        case IOCTL_DISK_SET_DRIVE_LAYOUT: 

            //
            // For this sample, we assume a single partition and no
            // alterations... Sorry!
            //
#if DBG
            DbgPrint("IdeDispatchDeviceControl: IOCTL_DISK_SET_DRIVE_LAYOUT unsupported\n");
#endif
            Irp->IoStatus.Information = 0;

            Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;

            break;


        //
        // Is this disk writable?
        //
        case IOCTL_DISK_IS_WRITABLE:

            //
            // SURE it is!
            //
            Irp->IoStatus.Information = 0;

            Irp->IoStatus.Status = STATUS_SUCCESS;
            break;

        //
        // Here's another request that class driver's get.
        // Is the media removable from this device?
        //
        case IOCTL_DISK_MEDIA_REMOVAL:

            //
            // No, it is not.
            //
            Irp->IoStatus.Information = 0;

            Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;
            break;


        default: 

            //
            // The supplied operation is not supported by this driver
            //
#if DBG
            DbgPrint("IdeDispatchDeviceControl: Unrecognized IOCTL %x\n",
                    ioStack->Parameters.DeviceIoControl.IoControlCode);
#endif
            Irp->IoStatus.Information = 0;
            Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;
            break;

    }

    //
    // Finish up and complete the IRP
    //
    ntStatus = Irp->IoStatus.Status;

    IoCompleteRequest(Irp, IO_NO_INCREMENT);

    return(ntStatus);
}



///////////////////////////////////////////////////////////////////////////////
//
//  IdeDispatchReadWrite
//
//  This is the dispatch entry point for IRP_MJ_READ and IRP_MJ_WRITE requests.
//  All we do here is validate the IRP, and if it's valid mark it pending
//  and call IoStartPacket() to start the request on the device.
//
//
//  INPUTS:
//
//    DeviceObject      - pointer to our device object
//    Irp               - pointer to the IRP
//
//  OUTPUTS:
//  
//    None.
//
//  RETURNS:
//
//    STATUS_PENDING, otherwise STATUS_INVALID_PARAMETER
//
//      IRQL:
//
//    IRQL_PASSIVE_LEVEL
//
//  NOTES:
//
//
///////////////////////////////////////////////////////////////////////////////
NTSTATUS
IdeDispatchReadWrite(IN PDEVICE_OBJECT DeviceObject,
                     IN OUT PIRP Irp)
{
    PPARTITION_DATA partitionData = (PPARTITION_DATA)DeviceObject->DeviceExtension;
    PIDE_DEV_EXT devExt = partitionData->Partition0;
    PIO_STACK_LOCATION ioStack;
    ULONG firstSectorOfRequest;
    LONGLONG byteOffset;
    LONGLONG partitionLength;
    ULONG transferLength;

    partitionLength = partitionData->Pi.PartitionLength.QuadPart;

    //
    // Get a pointer to the current I/O stack location
    //
    ioStack = IoGetCurrentIrpStackLocation(Irp);

    //
    // Pick up some handy parameters from the current I/O Stack.
    // NOTE that although we access the parameters from the READ union,
    // we could be processing EITHER a READ or a WRITE operation. The parameters
    // are at the same locations in both I/O Stacks.
    //
    byteOffset = ioStack->Parameters.Read.ByteOffset.QuadPart;
    transferLength = ioStack->Parameters.Read.Length;

    //
    // Validate the IRP
    //
    // Here we check to see if the parameters are valid with respect to the
    // device.  Specifically:
    //
    //      - The transfer size must not be zero.
    //      - The transfer size must not be > MAXIMUM_TRANSFER_LENGTH bytes
    //      - The transfer must be entirely within one disk partition
    //      - The transfer size must be an even multiple of the sector size
    //
    if ((transferLength == 0) ||
        (transferLength > MAXIMUM_TRANSFER_LENGTH) ||
        ((byteOffset + transferLength) > partitionLength) ||
        (transferLength % devExt->BytesPerSector)) {

        //
        // One of the parameters is not valid
        //
        Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
        Irp->IoStatus.Information = 0;

#if DBG
        DbgPrint("DispatchReadWrite: Invalid Parameter!\n");
        DbgPrint("Major Func = 0x%0x\n", ioStack->MajorFunction);
        DbgPrint("\t\tLength = %d.\n", transferLength);
        DbgPrint("\t\tPartition Length = %d.\n", partitionLength);
#endif

        IoCompleteRequest(Irp, IO_NO_INCREMENT);

        return(STATUS_INVALID_PARAMETER);
    }

    //
    // The IRP is valid.  We will therefore be returning with the IRP
    // pending.
    //
    IoMarkIrpPending(Irp);

    //
    // Convert the partition-relative request to one relative to the
    // start of the disk, and store it back in the IRP for later use.
    //
    byteOffset += partitionData->Pi.StartingOffset.QuadPart;
    ioStack->Parameters.Read.ByteOffset.QuadPart = byteOffset;

    //
    // Determine the sector at which the request starts
    //
    firstSectorOfRequest = (ULONG)(byteOffset >> devExt->ByteShiftToSector);

    //
    // Attempt to start the request.
    //
    // NOTE that we sort the queue of IRPs based on the starting sector
    // of the request.  Since requests are processed quickly on the disk,
    // we do not make them cancellable.
    //
    IoStartPacket(devExt->DeviceObject,
                  Irp,
                  &firstSectorOfRequest,
                  NULL);

    //
    // Return with the request queued
    //
    return(STATUS_PENDING);
}


///////////////////////////////////////////////////////////////////////////////
//
//  IdeStartIo
//
//    This routine is called to start processing the next packet. 
//
//  INPUTS:
//
//    DeviceObject      - pointer to our device object
//    Irp               - pointer to the IRP
//
//  OUTPUTS:
//  
//    None.
//
//  RETURNS:
//
//    STATUS_SUCCESS
//
//      IRQL:
//
//    IRQL_DISPATCH_LEVEL
//
//  NOTES:
//
//    Since we have a single controller and disk, access to the
//    devExt is allowed, but NOT to the controllerData structure
//
//
///////////////////////////////////////////////////////////////////////////////
VOID
IdeStartIo(IN PDEVICE_OBJECT DeviceObject,
           IN PIRP Irp)
{
    PIDE_DEV_EXT devExt = (PIDE_DEV_EXT)DeviceObject->DeviceExtension;
    PIO_STACK_LOCATION ioStack;

    //
    // Get a pointer to the current I/O Stack Location
    //
    ioStack = IoGetCurrentIrpStackLocation(Irp);

    //
    // Set up the major function, length and starting sector of the transfer
    // in the device extension.  They'll be quicker to get at from the ISR
    // in the devExt than if we leave them in the IRP.
    //
    devExt->OperationType = ioStack->MajorFunction;

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

    devExt->FirstSectorOfRequest = 
                (ULONG)(ioStack->Parameters.Read.ByteOffset.QuadPart >>
                                devExt->ByteShiftToSector);
    //
    // Check if we're retrying this irp.
    //
    if (devExt->PacketIsBeingRetried) {

#if DBG
        DbgPrint("IdeStartIo: Retrying IRP: %x\n", Irp);
#endif
        devExt->PacketIsBeingRetried = FALSE;
        //
        // Increment the retry count. The DpcForIsr limits the number
        // of retries
        //
        devExt->IrpRetryCount++;

    } else {

        devExt->IrpRetryCount = 0;
    }

    //
    // This driver uses Direct I/O for transfer operations.
    // Map the requestor's buffer into system address space.
    //
    ASSERT(Irp->MdlAddress);
    devExt->CurrentAddress = MmGetSystemAddressForMdl(Irp->MdlAddress);

    //
    // let folks know of our intent
    //
#if DBG
    DbgPrint("IdeStartIo: Irp: 0x%0x, Func: 0x%0x VA: 0x%0x, Length: 0x%0x\n",
                Irp,
                ioStack->MajorFunction,
                devExt->CurrentAddress,
                devExt->RemainingTransferLength);
#endif
    //
    // We start the request on this device at DIRQL so seralize
    // access to the data structures and the HW registers
    //
    (VOID)KeSynchronizeExecution(devExt->ControllerData->InterruptObject,
                               IdeStartThisRequestOnDevice,
                               devExt);

    return;
}




///////////////////////////////////////////////////////////////////////////////
//
//  IdeStartThisRequestOnDevice
//
//    This routine is will start the specified request on the device
//
//  INPUTS:
//
//    Context           - actually, the devExt structure
//
//  OUTPUTS:
//  
//    None.
//
//  RETURNS:
//
//    TRUE, unless the hardware fails
//
//      IRQL:
//
//    DIRQL
//
//  NOTES:
//
//    Because this is called at DIRQL, we have access to all structures
//    in the devExt and controllerData and we can actually touch the
//    registers
//
///////////////////////////////////////////////////////////////////////////////

BOOLEAN
IdeStartThisRequestOnDevice(IN OUT PVOID Context)
{
    PIDE_DEV_EXT devExt;
    PCONTROLLER_DATA controllerData;
    NTSTATUS ntStatus;
    UCHAR controllerStatus;
    UCHAR       sectorCount, sectorNumber, cylinderLow, cylinderHigh, driveHead;

    //
    // set some locals
    //
    devExt = Context;
    controllerData = devExt->ControllerData;

    //  
    // get the current state of the controller
    //
    controllerStatus =
        READ_PORT_UCHAR(devExt->ControllerData->ControllerAddress + STATUS_REGISTER);

    //
    // We will soon cause an interrupt that will require servicing by
    // the DPC, so set the flag to note that we require a DPC.
    //
    controllerData->InterruptRequiresDpc = TRUE;

    //
    // Determine the parameters for the controller 
    //
    sectorCount = (UCHAR)(devExt->RemainingTransferLength / devExt->BytesPerSector);

    sectorNumber = (UCHAR)((devExt->FirstSectorOfRequest % 
                                                 devExt->SectorsPerTrack) + 1);

    cylinderLow = (UCHAR)(devExt->FirstSectorOfRequest /
                                    (devExt->SectorsPerTrack *
                                             devExt->TracksPerCylinder)) & 0xff;

    cylinderHigh = (UCHAR)(devExt->FirstSectorOfRequest /
                                       (devExt->SectorsPerTrack *
                                               devExt->TracksPerCylinder) >> 8);

    driveHead = (UCHAR) (((devExt->FirstSectorOfRequest /
                                        devExt->SectorsPerTrack) %
                                             devExt->TracksPerCylinder) |
                                                           devExt->DeviceUnit);

#if DBG
    DbgPrint(
        "IdeStartThisRequestOnDevice: sectorCount %x sectorNumber %x cylinderLow %x high %x driveHead %x\n",
        sectorCount, sectorNumber, cylinderLow, cylinderHigh, driveHead);
#endif

    //
    // Give the controller the cylinder and head of the start of the transfer.
    // Also tell it how many sectors we want to transfer.
    //
    WRITE_PORT_UCHAR(controllerData->ControllerAddress + SECTOR_COUNT_REGISTER,
                                                             sectorCount);

    WRITE_PORT_UCHAR(controllerData->ControllerAddress + SECTOR_NUMBER_REGISTER,
                                                             sectorNumber);

    WRITE_PORT_UCHAR(controllerData->ControllerAddress + CYLINDER_LOW_REGISTER,
                                                             cylinderLow);

    WRITE_PORT_UCHAR(controllerData->ControllerAddress + CYLINDER_HIGH_REGISTER,
                                                             cylinderHigh);

    WRITE_PORT_UCHAR(controllerData->ControllerAddress + DRIVE_HEAD_REGISTER,
                                                             driveHead);
    //
    // Actually start the request, based on the direction of the transfer.
    // Note that we've already stored that length and starting VA of
    // the transfer in the device extension (in the StartIo routine).
    //
    switch (devExt->OperationType) {

        case IRP_MJ_READ:

#if DBG
            DbgPrint("Starting a READ\n");
#endif

            //
            // Tell the controller to do a read.
            //
            // The controller will interrupt when it has a complete sector
            // of data for us to retrieve from it.
            //
            WRITE_PORT_UCHAR(controllerData->ControllerAddress + COMMAND_REGISTER,
                                                devExt->ReadCommand);

            break;

        case IRP_MJ_WRITE:

#if DBG
            DbgPrint("Starting a WRITE\n");
#endif

            //
            // Set the write precomp -- Like it matters?
            //
            WRITE_PORT_UCHAR(
                  controllerData->ControllerAddress + WRITE_PRECOMP_REGISTER,
                                              (UCHAR)(devExt->WritePrecomp));
            //
            // Give the controller the WRITE command
            //
            WRITE_PORT_UCHAR(controllerData->ControllerAddress + COMMAND_REGISTER,
                                            devExt->WriteCommand);

            //
            // The way writes work is that afer giving the controller the WRITE
            // command, we stuff a sector's worth of data into it.  BUT, before
            // we can start stuffing, the controller has to drop it's BUSY
            // status, and assert DATA_REQUEST_STATUS.  That's our signal to
            // load 'er up!
            //
            ntStatus = IdeWaitControllerReady(controllerData, 10, 5000);

            if (!NT_SUCCESS(ntStatus)) {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品国产三级国产| 日韩欧美在线影院| 国产精品日韩成人| 成人av在线网站| 亚洲免费成人av| 欧美日韩一区在线观看| 日韩av不卡一区二区| 久久伊人中文字幕| 成人激情免费网站| 亚洲一区二区欧美激情| 日韩视频永久免费| 粗大黑人巨茎大战欧美成人| 亚洲色图视频网站| 欧美福利视频一区| 国产福利91精品| 亚洲精品久久久久久国产精华液| 欧美精品日日鲁夜夜添| 九九热在线视频观看这里只有精品| 国产清纯在线一区二区www| 色狠狠桃花综合| 麻豆91精品视频| 亚洲同性同志一二三专区| 欧美剧在线免费观看网站| 经典三级视频一区| 亚洲乱码国产乱码精品精小说| 51精品国自产在线| 成人污视频在线观看| 亚洲丶国产丶欧美一区二区三区| 欧美v亚洲v综合ⅴ国产v| 99视频精品免费视频| 日本人妖一区二区| 国产精品欧美综合在线| 欧美福利一区二区| av动漫一区二区| 视频一区二区欧美| 国产精品视频你懂的| 欧美精品aⅴ在线视频| 丁香桃色午夜亚洲一区二区三区| 亚洲成人激情av| 综合欧美一区二区三区| 日韩免费性生活视频播放| 91福利精品第一导航| 国产成人在线电影| 青青草伊人久久| 亚洲成人午夜影院| 中文字幕成人网| 久久香蕉国产线看观看99| 欧美男男青年gay1069videost | 亚洲一区中文在线| 久久亚洲精华国产精华液| 欧美视频精品在线观看| 91麻豆视频网站| 风流少妇一区二区| 久久精品国产澳门| 日本中文在线一区| 亚洲超丰满肉感bbw| 亚洲蜜桃精久久久久久久| 国产女人18水真多18精品一级做 | 欧美一卡二卡三卡| 欧美亚洲尤物久久| 色哟哟一区二区在线观看| 成人动漫精品一区二区| 国产综合色精品一区二区三区| 婷婷综合五月天| 调教+趴+乳夹+国产+精品| 樱桃国产成人精品视频| 亚洲欧美在线aaa| 国产日韩欧美a| 欧美激情一区三区| 国产精品毛片久久久久久| 日本一区二区在线不卡| 久久蜜臀精品av| 久久新电视剧免费观看| 精品久久久久久无| 精品久久久久香蕉网| 欧美成人一区二区三区在线观看| 欧美一区二区三区不卡| 日韩一区二区在线看片| 日韩欧美电影一区| 欧美成人在线直播| 久久久久国产成人精品亚洲午夜 | 91成人国产精品| 日本精品免费观看高清观看| 色综合久久综合网97色综合| 色悠久久久久综合欧美99| 在线视频国内自拍亚洲视频| 欧美无乱码久久久免费午夜一区| 欧美日韩一区精品| 日韩三级.com| 久久久久9999亚洲精品| 亚洲欧洲日本在线| 亚洲综合成人在线| 日韩在线一区二区| 狠狠色伊人亚洲综合成人| 国产成人精品免费看| 91影视在线播放| 欧美精品亚洲二区| 欧美精品一区二区不卡| 欧美激情中文字幕| 亚洲小说欧美激情另类| 免费成人在线观看视频| 国产aⅴ综合色| 91久久国产综合久久| 欧美一区二区成人6969| 国产视频911| 亚洲一区在线播放| 国内外成人在线| 色婷婷一区二区三区四区| 欧美猛男男办公室激情| 国产欧美一区二区三区沐欲| 洋洋成人永久网站入口| 国产一区二区三区黄视频| 一本大道久久a久久精品综合| 欧美日韩激情一区| 久久女同精品一区二区| 亚洲精品日韩一| 狠狠色狠狠色综合日日91app| 91小视频在线| 欧美电视剧免费全集观看| 国产精品国产三级国产有无不卡| 午夜欧美在线一二页| 丰满少妇在线播放bd日韩电影| 欧美日韩国产一二三| 国产精品网曝门| 午夜电影网一区| 99久久综合色| 久久久综合视频| 日韩中文字幕av电影| 色婷婷国产精品| 国产日本一区二区| 日本午夜精品一区二区三区电影| 99在线精品一区二区三区| 久久综合国产精品| 天堂成人国产精品一区| av亚洲精华国产精华精| 久久久蜜臀国产一区二区| 午夜日韩在线电影| 色呦呦国产精品| 中文在线一区二区| 国产精品一区二区x88av| 日韩亚洲欧美高清| 亚洲国产视频一区二区| 99视频热这里只有精品免费| 久久久亚洲国产美女国产盗摄| 婷婷一区二区三区| 欧美色图片你懂的| 一级做a爱片久久| 成+人+亚洲+综合天堂| 国产亚洲一区二区三区| 免费视频最近日韩| 制服丝袜亚洲网站| 香港成人在线视频| 欧美性xxxxx极品少妇| 亚洲欧美激情插| 色综合久久久久综合体桃花网| 中文字幕乱码久久午夜不卡 | 蜜臀av性久久久久蜜臀aⅴ四虎| 色婷婷香蕉在线一区二区| 中文字幕日韩精品一区| 成人在线视频一区二区| 久久精品一区二区三区不卡牛牛| 精品一区二区精品| 日韩欧美国产精品一区| 卡一卡二国产精品 | 色猫猫国产区一区二在线视频| 国产亚洲美州欧州综合国| 国产精品1区2区3区| 国产午夜一区二区三区| 国产精品资源在线看| 国产偷国产偷精品高清尤物| 国产一区激情在线| 国产片一区二区| 99这里只有久久精品视频| 亚洲伦理在线免费看| 色国产精品一区在线观看| 亚洲影视在线观看| 555夜色666亚洲国产免| 久久99精品一区二区三区三区| 精品毛片乱码1区2区3区| 国产一区二区成人久久免费影院 | 5月丁香婷婷综合| 精品一区二区久久| 国产精品三级av| 91蜜桃在线免费视频| 亚洲成a人v欧美综合天堂下载| 欧美日本免费一区二区三区| 青青草一区二区三区| 国产三级欧美三级日产三级99| 国产成人免费在线| 有码一区二区三区| 日韩午夜激情av| 成人免费看黄yyy456| 亚洲成人动漫av| 久久久久97国产精华液好用吗 | 欧美特级限制片免费在线观看| 亚洲mv大片欧洲mv大片精品| 精品av久久707| 一本一道久久a久久精品| 美女www一区二区| 国产精品看片你懂得|