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

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

?? config.c

?? 硬盤驅動程序, 硬盤驅動程序,硬盤驅動程序
?? C
?? 第 1 頁 / 共 2 頁
字號:
///////////////////////////////////////////////////////////////////////////////
//
//  (C) Copyright 1995 - 1998 OSR Open Systems Resources, Inc.
//	All Rights Reserved
//      Based on a previous work by Microsoft Corporation
//      Copyright (c) 1991, 1992, 1993  Microsoft Corporation
//
//    This sofware is supplied for instructional purposes only.
//
//      OSR Open Systems Resources, Inc. (OSR) expressly disclaims any warranty
//      for this software.  THIS SOFTWARE IS PROVIDED  "AS IS" WITHOUT WARRANTY
//      OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION,
//      THE IMPLIED WARRANTIES OF MECHANTABILITY OR FITNESS FOR A PARTICULAR
//      PURPOSE.  THE ENTIRE RISK ARISING FROM THE USE OF THIS SOFTWARE REMAINS
//      WITH YOU.  OSR's entire liability and your exclusive remedy shall not
//      exceed the price paid for this material.  In no event shall OSR or its
//      suppliers be liable for any damages whatsoever (including, without
//      limitation, damages for loss of business profit, business interruption,
//      loss of business information, or any other pecuniary loss) arising out
//      of the use or inability to use this software, even if OSR has been
//      advised of the possibility of such damages.  Because some states/
//      jurisdictions do not allow the exclusion or limitation of liability for
//      consequential or incidental damages, the above limitation may not apply
//      to you.
//
//    This driver is the example Programmed I/O device driver that
//    accompanies the book Windows NT Device Driver Development, by
//    Peter Viscarola and W. Anthony Mason, (c) 1998 OSR Open Systems
//    Resources, Inc. and published by MacMillan Technical Publishing
//    ISBN 1578700582.  
//
//
//	MODULE:
//
//		$Workfile: config.c $
//
//	ABSTRACT:
//
//    This module handles the gathering of the configruation information 
//    for the IDE sample driver
//
//	AUTHOR:
//
//		Open Systems Resources, Inc.
// 
//	REVISION:   
//
//
///////////////////////////////////////////////////////////////////////////////

#include "ntddk.h"                      // main NT include
#include "ntdddisk.h"                   // disk driver IOCTL definitions
#include "hw.h"                         // the access macro/definitions
#include "ide.h"                        // general declarations/structures
#include "config.h"                     // configuration declarations

//
// device defaults
//

#define DEFAULT_INTERFACE_TYPE  Isa
#define DEFAULT_BUS_NUMBER      0
#define DEFAULT_IRQL            14
#define DEFAULT_BASE_ADDRESS    0x01f0;
#define DEFAULT_PORT_ADDRESS    0x03f6;

//
// forward delcarations of static routines
//

static VOID
UpdateWithBios(
PCONFIG_DATA ConfigData,
ULONG ParameterTableOffset
);

static BOOLEAN
ReconcileWithRegistry(
PDRIVER_OBJECT DriverObject,
PCONFIG_DATA ConfigData
);

static BOOLEAN
IssueIdentify(
PCONFIG_DATA ConfigData,
PUCHAR Buffer
);

//
// This is the structure of the information returned after an
// IDENTIFY command has been issued on the IDE drive
//

typedef struct _IDENTIFY_DATA {
    USHORT GeneralConfiguration;            // 00
    USHORT NumberOfCylinders;               // 01
    USHORT Reserved1;                       // 02
    USHORT NumberOfHeads;                   // 03
    USHORT UnformattedBytesPerTrack;        // 04
    USHORT UnformattedBytesPerSector;       // 05
    USHORT SectorsPerTrack;                 // 06
    USHORT VendorUnique1[3];                // 07
    USHORT SerialNumber[10];                // 10
    USHORT BufferType;                      // 20
    USHORT BufferSectorSize;                // 21
    USHORT NumberOfEccBytes;                // 22
    USHORT FirmwareRevision[4];             // 23
    USHORT ModelNumber[20];                 // 27
    UCHAR  MaximumBlockTransfer;            // 47 low byte
    UCHAR  VendorUnique2;                   // 47 high byte
    USHORT DoubleWordIo;                    // 48
    USHORT Capabilities;                    // 49
    USHORT Reserved2;                       // 50
    UCHAR  VendorUnique3;                   // 51 low byte
    UCHAR  PioCycleTimingMode;              // 51 high byte
    UCHAR  VendorUnique4;                   // 52 low byte
    UCHAR  DmaCycleTimingMode;              // 52 high byte
    USHORT TranslationFieldsValid;          // 53 (low bit)
    USHORT NumberOfCurrentCylinders;        // 54
    USHORT NumberOfCurrentHeads;            // 55
    USHORT CurrentSectorsPerTrack;          // 56
    ULONG  CurrentSectorCapacity;           // 57 & 58
    UCHAR  MultiSectorCount;                // 59 low
    UCHAR  MultiSectorSettingValid;         // 59 high (low bit)
    ULONG  TotalUserAddressableSectors;     // 60 & 61
    UCHAR  SingleDmaModesSupported;         // 62 low byte
    UCHAR  SingleDmaTransferActive;         // 62 high byte
    UCHAR  MultiDmaModesSupported;          // 63 low byte
    UCHAR  MultiDmaTransferActive;          // 63 high byte
    USHORT Reserved4[192];                  // 64
} 
IDENTIFY_DATA, *PIDENTIFY_DATA;


///////////////////////////////////////////////////////////////////////////////
//
//	IdeGetConfigData
//
//    This routine obtains the primary configuration information for the
//    device, including the bus and port addresses.  Note that many of
//    the values are assumed, as #defin'ed by the DEFAULT_ values, while
//    some are actually defined by checking into the ROM (some geometry).
//
//	INPUTS:
//
//    DriverObject      - driver object for this driver
//    RegistryPath      - this driver's service node in the registry
//    ConfigData        - allocated, zero'ed buffer that describes the
//                        controller and disk
//
//	OUTPUTS:
//	
//    ConfigData        - filled up with info
//
//	RETURNS:
//
//    STATUS_SUCCESS if we have a disk, otherwise STATUS_NO_SUCH_DEVICE
//
//      IRQL:
//
//    IRQL_PASSIVE_LEVEL
//
//	NOTES:
//
//    The steps followed are:
//
//      - call IoGetConfigurationInformation to get the primary AtDisk Address
//      - translate the ControllerBase and ControlPort addresses
//      - connect the interrupt
//      - make sure our controller is really there 
//      - claim the AtDisk primary address
//      - issue an IDENTIFY to get retrieve disk information from the contoller
//      - map the BIOS and get more configruation information
//      - check the configuration information with the registry
//
///////////////////////////////////////////////////////////////////////////////

NTSTATUS
IdeGetConfigData(IN PDRIVER_OBJECT DriverObject,
                 IN PUNICODE_STRING RegistryPath,
                 IN OUT PCONFIG_DATA ConfigData)
{
    PCONFIGURATION_INFORMATION configurationInformation;
    UCHAR               driveTypes, tmp;
    UCHAR               buffer[512];            // for IssueIdentify
    LARGE_INTEGER       tmpPtr;                 // for BIOS delving
    PUSHORT             paramVector;            // for BIOS delving
    PHYSICAL_ADDRESS    translatedAddress;      // for address translation
    ULONG               addressSpace;           // for address translation
    PHYSICAL_ADDRESS        phys_tmp;
    NTSTATUS            ntStatus;

    //
    // Get the current configuration manager information.
    //
    configurationInformation = IoGetConfigurationInformation();

    //
    // store the pointer to the hard disk count
    //
    ConfigData->HardDiskCount = &configurationInformation->DiskCount;

    //
    // We grab the primary AtDisk address at all costs. If we can't have it,
    // we just take our disk and go home... I mean, we refuse to load.
    //
    if (configurationInformation->AtDiskPrimaryAddressClaimed) {

#if DBG
        DbgPrint("IdeGetDiskConfig: Primary address already claimed!\n");
#endif


        return(STATUS_DEVICE_CONFIGURATION_ERROR);
    }



    //
    // Fill in some controller information.
    //
    ConfigData->InterfaceType = DEFAULT_INTERFACE_TYPE;
    ConfigData->BusNumber = DEFAULT_BUS_NUMBER;
    ConfigData->OriginalControllerIrql = DEFAULT_IRQL;

    phys_tmp.QuadPart = 0;

    //
    // store the default ControllerBase address and range
    //
    phys_tmp.LowPart = DEFAULT_BASE_ADDRESS;
    ConfigData->OriginalControllerBaseAddress = phys_tmp;
    ConfigData->RangeOfControllerBase = 8;

    //
    // store the default ControlPortAddress and range
    //
    phys_tmp.LowPart = DEFAULT_PORT_ADDRESS;
    ConfigData->OriginalControlPortAddress = phys_tmp;
    ConfigData->RangeOfControlPort = 1;

    //
    // set the interrupt vector to the same as the irql
    //
    ConfigData->OriginalControllerVector = ConfigData->OriginalControllerIrql;

    //
    // Translate the ControllerBase address
    //

    //
    // First, note that this is a port address
    //
    addressSpace = 0x01;

    //
    // Translate the Controller Base Address
    //
    if (!HalTranslateBusAddress(DEFAULT_INTERFACE_TYPE,
                            DEFAULT_BUS_NUMBER,
                            ConfigData->OriginalControllerBaseAddress,
                            &addressSpace,
                            &translatedAddress))  {

        //
        // We couldn't do the translation, so bail
        //
#if DBG
        DbgPrint("IdeGetDiskConfig: HalTranslateBusAddress failure for ControllerBase\n");
#endif

        return(STATUS_NO_SUCH_DEVICE);

    }

    //
    // The address was translated, so now check if the mapping 
    // of the addreess puts the address in memory space or I/O space
    //
    if (addressSpace == 0x0)  {

        //
        // We're in memory space, so we have to Map this address into
        // system space
        //
        ConfigData->ControllerBaseAddress = MmMapIoSpace(translatedAddress,
                                              ConfigData->RangeOfControllerBase,
                                              FALSE);

        //
        // if we didn't get an address, we have to quit
        //
        if (!ConfigData->ControllerBaseAddress) {

#if DBG
            DbgPrint("IdeGetDiskConfig: MmMapIoSpace failure for ControllerBase\n");
#endif
            return STATUS_NO_SUCH_DEVICE;

        }

        //
        // note that the ControllerBase is mapped
        //
        ConfigData->ControllerBaseMapped = TRUE;

    } else {

        //
        // The addresss is in I/O space, so we just need the low part
        // of the translated address
        //
        ConfigData->ControllerBaseMapped = FALSE;

        ConfigData->ControllerBaseAddress = (PVOID)translatedAddress.LowPart;
    }


    //
    // Next, Translate the ControlPort address
    //
    addressSpace = 0x01;

    //
    // Translate the address
    //
    if (!HalTranslateBusAddress( DEFAULT_INTERFACE_TYPE,
                                DEFAULT_BUS_NUMBER,
                                ConfigData->OriginalControlPortAddress,
                                &addressSpace,
                                &translatedAddress)) {
        //
        // We couldn't do the translation, so bail out
        //
#if DBG
        DbgPrint("IdeGetDiskConfig: HalTranslateBusAddress failure for ControlPort\n");
#endif

        //
        // If the controller's base address was mapped, we need to unmap it
        // before we leave.
        //
        if(ConfigData->ControllerBaseMapped) {

            MmUnmapIoSpace(ConfigData->ControllerBaseAddress,
                                     ConfigData->RangeOfControllerBase);
        }

        //
        // return error status
        //
        return(STATUS_NO_SUCH_DEVICE);

    }

    //
    // The address was translated, so now check if the mapping 
    // of the addreess puts the address in memory space or I/O space
    //
    if (addressSpace == 0x0) {

        //
        // We in memory space, so we have to Map this address into
        // system space
        //
        ConfigData->ControlPortAddress = MmMapIoSpace(translatedAddress,
                                        ConfigData->RangeOfControlPort,
                                        FALSE);

        //
        // if we didn't get an address, we have to quit
        //
        if (!ConfigData->ControlPortAddress) {

#if DBG
            DbgPrint("IdeGetDiskConfig: MmMapIoSpace failure for ControlPort\n");
#endif

            //
            // Unmap the controllerBase
            //

            if (ConfigData->ControllerBaseMapped) {
                MmUnmapIoSpace(ConfigData->ControllerBaseAddress,
                                        ConfigData->RangeOfControllerBase);
            }

            //
            // return failure status
            //
            return(STATUS_NO_SUCH_DEVICE);

        }

        //
        // note that the ControlPort is mapped
        //
        ConfigData->ControlPortMapped = TRUE;

    } else {

        //
        // The addresss is in I/O space, so we just need the
        // translated address
        //
        ConfigData->ControlPortMapped = FALSE;

        ConfigData->ControlPortAddress = (PVOID)translatedAddress.LowPart;
    }

    //
    // get the interrupt vector
    //
    ConfigData->ControllerVector = HalGetInterruptVector(ConfigData->InterfaceType,
                                            ConfigData->BusNumber,
                                            ConfigData->OriginalControllerIrql,
                                            ConfigData->OriginalControllerVector,
                                            &ConfigData->ControllerIrql,
                                            &ConfigData->ProcessorNumber);


    //
    // Check if the controller exists by writing 0xaa to the COUNT register and
    // attempting to read it back.  Crude, but effective.
    //
    WRITE_PORT_UCHAR(ConfigData->ControllerBaseAddress + SECTOR_COUNT_REGISTER, 0xaa);

    tmp = READ_PORT_UCHAR(ConfigData->ControllerBaseAddress + SECTOR_COUNT_REGISTER);

    //
    // Did we get 0xaa back from the count register?
    //
    if (tmp != 0xaa) {

        //
        // No, we didn't.  Hmmmmm... I don't know what we've got, but it's
        // either an IDE controller that's not there or something else.
        //
        // We're outa here in either case.
        //
#if DBG
        DbgPrint("IdeGetDiskConfig: Unable to verify controller existance\n");
#endif

        //
        // Unmap the ControllerBase
        //
        if (ConfigData->ControllerBaseMapped) {

            MmUnmapIoSpace(ConfigData->ControllerBaseAddress,
                                    ConfigData->RangeOfControllerBase);
        }

        //
        // Unmap the ControlPort
        //
        if (ConfigData->ControlPortMapped) {

            MmUnmapIoSpace(ConfigData->ControlPortAddress,
                                            ConfigData->RangeOfControlPort);
        }

        //
        // return failure status
        //
        return(STATUS_NO_SUCH_DEVICE);
    }

    //
    // The controller exists, so claim the AtDisk primary IO 
    // address range.
    //
    configurationInformation->AtDiskPrimaryAddressClaimed = TRUE;

    ConfigData->OkToUseThisController = TRUE;

    //
    // Check CMOS for drive types for the disk
    //
    WRITE_PORT_UCHAR(CFGMEM_QUERY_PORT, CFGMEM_FIRST_CONTROLLER_DRIVE_TYPES);

    KeStallExecutionProcessor(1L);

    driveTypes = READ_PORT_UCHAR(CFGMEM_DATA_PORT);

    ConfigData->Disk.DriveType = (UCHAR)
                                  (driveTypes & CFGMEM_DRIVES_FIRST_DRIVE_MASK);

    //
    // If there is no drive, then we have to quit.
    //
    if (!ConfigData->Disk.DriveType) {

#if DBG
        DbgPrint("IdeGetDiskConfig: Unable to read drive configuration\n");
#endif

        //
        // Unmap the ControllerBase
        //

        if (ConfigData->ControllerBaseMapped) {

            MmUnmapIoSpace(ConfigData->ControllerBaseAddress,
                                        ConfigData->RangeOfControllerBase);
        }

        //
        // Unmap the ControlPort
        //
        if (ConfigData->ControlPortMapped) {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
在线免费亚洲电影| 成人性生交大合| 在线播放日韩导航| 视频一区二区欧美| 欧美一区二区网站| 国产麻豆日韩欧美久久| 久久午夜羞羞影院免费观看| 国产福利91精品| 亚洲欧美日韩国产一区二区三区 | 欧美成人aa大片| 国产在线精品一区在线观看麻豆| www国产成人| 成人国产精品免费观看| 亚洲一区二区在线视频| 欧美一级一区二区| 国产乱人伦偷精品视频不卡| 中文字幕国产一区二区| 在线看不卡av| 国产精品一卡二| 亚洲最大成人综合| 欧美一卡二卡在线| fc2成人免费人成在线观看播放| 一区二区三区在线视频免费 | 欧美成人a在线| youjizz久久| 日韩在线观看一区二区| 久久久久久久综合色一本| 色综合天天综合在线视频| 免费在线欧美视频| 中文字幕人成不卡一区| 日韩欧美一区二区在线视频| 成人免费视频视频在线观看免费 | 久久久久久免费毛片精品| 91在线观看成人| 免费视频最近日韩| 中文字幕在线观看不卡| 91精品国产一区二区三区| av在线播放一区二区三区| 日日噜噜夜夜狠狠视频欧美人 | 日韩高清在线观看| 国产精品视频麻豆| 欧美成人在线直播| 日本高清不卡一区| 韩日欧美一区二区三区| 亚洲国产乱码最新视频| 国产精品不卡视频| 精品美女被调教视频大全网站| 91国偷自产一区二区使用方法| 激情综合色播激情啊| 亚洲123区在线观看| 国产精品美女久久久久av爽李琼| 欧美久久久久免费| 91官网在线免费观看| 成人免费精品视频| 国产精品一线二线三线| 久久国产综合精品| 视频一区国产视频| 亚洲第四色夜色| 亚洲黄色免费电影| 中文字幕一区二区三中文字幕| 久久女同性恋中文字幕| 欧美一区二区日韩| 这里只有精品视频在线观看| 欧美视频自拍偷拍| 日本精品一区二区三区四区的功能| 国产电影一区二区三区| 精品一区二区三区免费毛片爱| 日韩精品久久久久久| 亚洲成a人片综合在线| 一区二区久久久久| 亚洲精选视频在线| 亚洲日本在线观看| 极品少妇xxxx精品少妇| 久久国产福利国产秒拍| 看片的网站亚洲| 免费在线观看视频一区| 蜜桃精品视频在线观看| 麻豆一区二区99久久久久| 免费观看在线综合| 精品一区二区国语对白| 经典一区二区三区| 国产不卡免费视频| 成人综合婷婷国产精品久久| youjizz国产精品| 色综合久久综合| 欧美日韩一二三| 欧美一区二区不卡视频| 欧美不卡视频一区| 国产人久久人人人人爽| 中文字幕中文在线不卡住| 亚洲视频一区二区免费在线观看| 亚洲女人****多毛耸耸8| 亚洲一区二区三区自拍| 日本在线观看不卡视频| 精品一区二区在线播放| 成人a级免费电影| 欧美调教femdomvk| 欧美不卡一区二区| 中文字幕亚洲成人| 亚洲成av人片| 国产在线不卡一区| 91美女福利视频| 欧美日韩视频第一区| 精品伦理精品一区| 亚洲色欲色欲www在线观看| 亚洲成人资源网| 国内精品在线播放| 91在线一区二区三区| 欧美精品久久久久久久多人混战 | 久久精品在线免费观看| 中文字幕在线一区免费| 亚洲成人在线网站| 国产成人免费视频| 欧美精品一卡两卡| 久久精品人人做人人综合| 亚洲精品精品亚洲| 久久精品噜噜噜成人88aⅴ| va亚洲va日韩不卡在线观看| 欧美日韩在线精品一区二区三区激情| 精品国产自在久精品国产| 中文字幕一区二区三区色视频| 日韩在线一区二区三区| 99久久综合国产精品| 日韩欧美视频在线| 一区二区三区四区亚洲| 国产在线播放一区二区三区| 欧美系列一区二区| 国产精品福利影院| 国产一区二区中文字幕| 欧美日韩在线播| 18成人在线视频| 国产精品一区免费视频| 3d动漫精品啪啪| 亚洲精品免费看| 国产精品一区三区| 日韩欧美一二三| 五月婷婷欧美视频| 色噜噜久久综合| 国产精品欧美极品| 国产一区二区精品久久91| 欧美日韩国产一级二级| 日韩一区中文字幕| 成人精品小蝌蚪| 久久亚洲私人国产精品va媚药| 五月天激情综合| 在线日韩一区二区| 亚洲精品欧美综合四区| 成人精品免费看| 国产亚洲一区二区在线观看| 久国产精品韩国三级视频| 欧美美女黄视频| 亚洲第一电影网| 欧美三级中文字幕| 亚洲一区在线视频观看| av午夜一区麻豆| 国产精品久久久久久久久久免费看| 寂寞少妇一区二区三区| 日韩一区二区三区在线视频| 五月天亚洲精品| 欧美猛男超大videosgay| 一区二区三区高清在线| 色综合夜色一区| 亚洲精品videosex极品| 99免费精品在线观看| 亚洲欧美综合在线精品| 91丨porny丨最新| 亚洲免费av在线| 一本到不卡精品视频在线观看| 亚洲男人的天堂在线观看| 91香蕉视频mp4| 夜夜爽夜夜爽精品视频| 欧美日韩在线三区| 免费看欧美女人艹b| 91精品国产色综合久久久蜜香臀| 日韩va亚洲va欧美va久久| 精品久久久久久综合日本欧美 | 国产欧美日韩中文久久| 国产成人在线观看| 国产区在线观看成人精品| 97久久精品人人做人人爽50路| 亚洲欧美色图小说| 欧美日韩在线免费视频| 免费精品99久久国产综合精品| 日韩精品一区二区三区四区| 国产精品亚洲成人| 中文字幕日韩av资源站| 欧美日韩在线三区| 精品一区二区免费在线观看| 国产欧美一区二区三区沐欲| 色哟哟在线观看一区二区三区| 亚洲国产精品天堂| 欧美成人免费网站| 波多野结衣中文字幕一区| 亚洲一级在线观看| 久久午夜电影网| 色婷婷综合激情| 蜜桃视频一区二区三区| 国产欧美日韩综合精品一区二区| 日本乱码高清不卡字幕| 激情欧美日韩一区二区|