亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
美女一区二区视频| 盗摄精品av一区二区三区| 亚洲精品欧美专区| 亚洲福利视频三区| 精品在线观看视频| 色婷婷综合久久久久中文 | 91精品国产入口在线| 久久综合九色综合欧美98| 成人欧美一区二区三区1314| 亚洲一区二区精品3399| 精品一区二区三区免费毛片爱| 欧美视频在线一区二区三区 | 国产高清精品久久久久| 91视频www| 日韩欧美黄色影院| 亚洲一区二区三区中文字幕| 老司机一区二区| 精品日韩一区二区三区免费视频| 椎名由奈av一区二区三区| 日本亚洲电影天堂| 欧美性做爰猛烈叫床潮| 国产精品视频观看| 丰满白嫩尤物一区二区| 欧美va日韩va| 久草中文综合在线| 欧美一区二区在线免费播放| 亚洲精品中文在线观看| jvid福利写真一区二区三区| 久久久久久亚洲综合影院红桃| 国产一区二区精品在线观看| 色婷婷久久综合| 亚洲国产日韩a在线播放性色| av一区二区不卡| 亚洲欧洲综合另类在线| 91小视频在线免费看| 日韩毛片精品高清免费| 在线精品国精品国产尤物884a| 国产精品久久毛片a| 91在线视频免费91| 亚洲高清免费一级二级三级| 欧美日韩午夜在线视频| 日本大胆欧美人术艺术动态| 日韩美女视频在线| 国产精品一区二区三区乱码| 2014亚洲片线观看视频免费| 成人黄色在线看| 亚洲午夜久久久久久久久久久| 在线不卡中文字幕播放| 狠狠色2019综合网| 一卡二卡三卡日韩欧美| 日韩午夜电影在线观看| 成人黄色在线视频| 91麻豆国产福利在线观看| 日日摸夜夜添夜夜添亚洲女人| 日韩欧美中文字幕公布| 日本道在线观看一区二区| 国精产品一区一区三区mba桃花| 国产精品国产三级国产aⅴ原创| 精品污污网站免费看| 不卡免费追剧大全电视剧网站| 免费视频最近日韩| 亚洲成a人在线观看| 国产精品青草综合久久久久99| 欧美人与禽zozo性伦| 91看片淫黄大片一级在线观看| 精东粉嫩av免费一区二区三区| 五月天视频一区| 亚洲免费在线观看视频| 国产精品久久精品日日| 久久先锋影音av鲁色资源| 欧美一区二区黄| 欧美精品1区2区3区| 欧美视频一二三区| 精品视频在线免费观看| 91久久免费观看| 欧美日韩一区二区欧美激情| 色综合久久久久久久久| 日本道精品一区二区三区| 色综合天天综合网天天看片| av在线免费不卡| 久久久久久久综合日本| 精品久久久久香蕉网| 国产亚洲福利社区一区| 久久综合久色欧美综合狠狠| 日韩美女视频一区二区在线观看| 中文字幕在线免费不卡| 亚洲色图一区二区| 亚洲国产精品一区二区尤物区| 视频一区在线播放| 国产老妇另类xxxxx| 不卡区在线中文字幕| 91国产丝袜在线播放| 69p69国产精品| 国产精品婷婷午夜在线观看| 国产精品国产精品国产专区不片| 麻豆中文一区二区| 成人av午夜电影| 欧美一级黄色片| 亚洲少妇屁股交4| 久久99精品网久久| 日本精品免费观看高清观看| 日韩欧美国产小视频| 中文字幕在线不卡一区| 久久超碰97人人做人人爱| 成人蜜臀av电影| 欧美二区在线观看| 一区二区在线观看视频 | 欧美日韩视频专区在线播放| 亚洲精品一区二区在线观看| 亚洲二区在线视频| 91福利资源站| 亚洲女爱视频在线| 国产毛片精品视频| 日韩午夜在线观看视频| 日本亚洲最大的色成网站www| 成人精品视频一区二区三区| 亚洲成人av中文| 色综合视频在线观看| 国产精品你懂的在线欣赏| 精品一区二区三区在线视频| 欧美一区二区三区免费大片| 亚洲成人av一区二区三区| 色视频一区二区| 伊人夜夜躁av伊人久久| 色婷婷激情综合| 亚洲午夜av在线| 欧美一区二区日韩一区二区| 午夜不卡av免费| 日韩美女在线视频| 国产老肥熟一区二区三区| 国产清纯在线一区二区www| 懂色av一区二区三区免费看| 国产精品久久三区| 色激情天天射综合网| 日本午夜精品一区二区三区电影| 91精品国产综合久久福利软件 | 国产精品香蕉一区二区三区| 国产肉丝袜一区二区| 在线中文字幕一区二区| 亚洲 欧美综合在线网络| 精品盗摄一区二区三区| caoporn国产一区二区| 亚洲综合在线第一页| 久久久久久免费| 欧美色偷偷大香| 国产福利一区在线| 五月婷婷另类国产| 国产精品伦理在线| 日韩限制级电影在线观看| 国产成人亚洲精品青草天美| 亚洲一区二区视频在线观看| 26uuu亚洲综合色欧美| 色老汉av一区二区三区| 国产不卡在线视频| 蜜臀av性久久久久蜜臀aⅴ | 欧美视频在线观看一区| 国产盗摄一区二区| 日本成人超碰在线观看| 亚洲欧美一区二区久久| 国产精品视频免费看| 久久亚洲精华国产精华液| 88在线观看91蜜桃国自产| 97aⅴ精品视频一二三区| 国产九九视频一区二区三区| 美女视频网站久久| 久久精品国产精品亚洲精品| 国产成人av一区二区三区在线| 日韩av中文字幕一区二区| 亚洲国产成人av网| 亚洲一本大道在线| 视频一区视频二区中文| 蜜臀av一区二区三区| 日本欧美一区二区三区| 精品亚洲成a人| 国产激情偷乱视频一区二区三区| 国产麻豆精品95视频| 成人永久免费视频| 91在线观看美女| 色国产精品一区在线观看| 欧美日韩亚洲不卡| 精品999在线播放| 欧美激情一区二区三区在线| 中文字幕一区免费在线观看| 亚洲综合在线免费观看| 日本亚洲电影天堂| 国产不卡视频在线播放| 色综合久久99| xf在线a精品一区二区视频网站| 日本一区二区三区国色天香| 亚洲在线一区二区三区| 日本亚洲三级在线| 99久久免费视频.com| 欧美日韩免费电影| 亚洲精品一区二区三区蜜桃下载| 精品国产伦一区二区三区免费| 337p亚洲精品色噜噜狠狠| 国产亚洲欧洲一区高清在线观看| 蜜臀av国产精品久久久久| 日韩精品在线一区| 国产一区二区精品在线观看|