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

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

?? pci_sample.c

?? PCI驅動代碼實例
?? C
?? 第 1 頁 / 共 3 頁
字號:
///////////////////////////////////////////////////////////////////////////////
//
//    (C) Copyright 1995 - 1997 OSR Open Systems Resources, Inc.
//    All Rights Reserved
//
//    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.
//
//    OSR Open Systems Resources, Inc.
//    105 Route 101A Suite 19
//    Amherst, NH 03031  (603) 595-6500 FAX: (603) 595-6503
//    email bugs to: bugs@osr.com
//
//
//    This driver is the example Busmaster DMA 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:
//
//        PCI_SAMPLE.C
//
//    ABSTRACT:
//
//      This file contains the initial entry point for the OSR Sample
//      PCI Busmaster DMA device driver for the AMCC 5933 chip.
//
//    AUTHOR(S):
//
//        OSR Open Systems Resources, Inc.
// 
//    REVISION:   
//
//          V1.1    Fix to typo in OsrWrite() to correctly set cancel
//                  routine to NULL when completing a request that's
//                  been cancelled very early in its processing.
//
//
///////////////////////////////////////////////////////////////////////////////

//#include <ntddk.h>
#include "osr-pci.h"

//
// Forward Declarations
//
NTSTATUS
DriverEntry(PDRIVER_OBJECT DriverObj, PUNICODE_STRING RegistryPath);
static VOID OsrUnload(PDRIVER_OBJECT DriverObject);
static VOID OsrReturnPool(PPCI_COMMON_CONFIG  configInfo, PDEVICE_DESCRIPTION
            deviceDescription,  PCM_RESOURCE_LIST resources);

#if DBG
static VOID OsrPrintResourceList(PCM_RESOURCE_LIST);
static VOID OsrPrintConfig(PPCI_COMMON_CONFIG  configInfo);
#endif


//
// The following pragma allows the DriverEntry code to be discarded once
// initialization is completed
//
#pragma alloc_text(INIT,DriverEntry)

///////////////////////////////////////////////////////////////////////////////
//
//  DriverEntry
//
//      This routine is called by NT when the driver is first loaded.  It is the
//    responsibility of this routine to find it's device and create whatever
//    device objects it needs.
//
//  INPUTS:
//
//      DriverObj - Address of the DRIVER_OBJECT created by NT for this driver.
//
//      RegistryPath - UNICODE_STRING which represents this drivers KEY in the
//                   Registry.  
//
//  OUTPUTS:
//
//      None.
//
//  RETURNS:
//
//      STATUS_SUCCESS. Otherwise an error indicating why the driver could not
//                    Load.
//
//  IRQL:
//
//    This routine is called at IRQL_PASSIVE_LEVEL.
//
//  NOTES:
//
//
///////////////////////////////////////////////////////////////////////////////
NTSTATUS
DriverEntry(PDRIVER_OBJECT DriverObj, PUNICODE_STRING RegistryPath)
{
    NTSTATUS code;
    PPCI_COMMON_CONFIG  configInfo = NULL;
    ULONG busNumber;
    ULONG deviceNumber;
    ULONG AddressSpace;
    PCI_SLOT_NUMBER slotNumber;
    ULONG length;
    BOOLEAN moreBuses;
    BOOLEAN adapterFound;
    ULONG index;
    ULONG addressSpace;
    PHYSICAL_ADDRESS address;
    POSR_DEVICE_EXT devExt;
    PDEVICE_OBJECT devObj;
    UNICODE_STRING devName, linkName;
    PDEVICE_DESCRIPTION deviceDescription = NULL;
    PCM_RESOURCE_LIST resources = NULL;
    ULONG interruptLevel;
    ULONG interruptVector;
    ULONG mappedSystemVector;
    PHYSICAL_ADDRESS portStart;
    ULONG portLength;
    KIRQL irql;
    KAFFINITY affinity;
    
    DbgPrint("\nOSR PCI Sample Driver -- Compiled %s %s\n",__DATE__, __TIME__);
    DbgPrint("(c) 1997 OSR Open Systems Resources, Inc.\n\n");

    //
    // Establish dispatch entry points for the functions we support
    //

    DriverObj->MajorFunction[IRP_MJ_CREATE]         =  OsrCreateClose;
    DriverObj->MajorFunction[IRP_MJ_CLOSE]          =  OsrCreateClose;

    DriverObj->MajorFunction[IRP_MJ_READ]           =  OsrRead;
    DriverObj->MajorFunction[IRP_MJ_WRITE]          =  OsrWrite;
    DriverObj->MajorFunction[IRP_MJ_DEVICE_CONTROL] =  OsrDeviceControl;
    
    //
    // Unload function
    //
    DriverObj->DriverUnload = OsrUnload;

    
    //
    // Allocate space for a configuration information structure
    //
    configInfo = ExAllocatePoolWithTag(PagedPool,
                                       sizeof(PCI_COMMON_CONFIG),
                                       'pRSO');

    if (!configInfo) {

        //
        // Clean up the mess
        //
        OsrReturnPool(configInfo, deviceDescription, resources);

        //
        // Indicate load failure to the I/O manager
        //
        return(STATUS_INSUFFICIENT_RESOURCES);
    }

    //
    // Search for our device on all the PCI busses in the system
    //
    // We do this by ennumerating the configuration information for each
    // slot on each PCI bus in the system, until we find a device with
    // our Vendor ID and Device ID.
    //
    // Since this sample driver supports only a single card, we stop looking as
    // soon as we find one device.  Drivers that support multiple cards would
    // ennumerate all the busses and slots, finding as many devices as exist.
    //
    // Since our device is not a PCI "multifunction" device, we don't search
    // each function in each slot.
    //
    //
    adapterFound = FALSE;
    moreBuses = TRUE;

    for (busNumber = 0; !adapterFound && moreBuses; busNumber++) {
    
        //
        // Ennumerate all the devices on this bus
        //
        for (deviceNumber = 0; 
             !adapterFound && deviceNumber < PCI_MAX_DEVICES;
             deviceNumber++)  {

            //
            // For PCI buses, the logical slot number is a PCI_SLOT_NUMBER
            // structure, comprising a combination of the device number and the
            // function number on the card.  The Reserved section MUST be set
            // to zero.
            //
            // Note that since we're not a multifunction device, we only look
            // at FunctionNumber 0 in each slot.
            //
            slotNumber.u.bits.Reserved = 0;
            slotNumber.u.bits.DeviceNumber = deviceNumber;
            slotNumber.u.bits.FunctionNumber = 0;
            
            //
            // Get the configuration space for the adapter in this slot
            //
            length = HalGetBusData(PCIConfiguration,
                                   busNumber,
                                   slotNumber.u.AsULONG,
                                   configInfo,
                                   sizeof(PCI_COMMON_CONFIG) );

            //
            // A return value of zero indicates no more PCI buses on the system
            //                       
            if (length == 0) {
#if DBG
                DbgPrint("Reached end of PCI bus list\n");
#endif
                moreBuses = FALSE;
                break;
            }

            //
            // If there's nothing in this slot, PCI_INVALID_VENDORID is returned
            // as the vendor ID.  If this is the case, just continue running
            // the bus.
            //
            if (configInfo->VendorID == PCI_INVALID_VENDORID)  {
                
                continue;
            }

            //
            // Dump out information about the device found.
            //
#if DBG
            DbgPrint("Found a PCI device at Bus %d. Device %d.\n",
                          busNumber,
                          deviceNumber);

            DbgPrint("Vendor id = 0x%0x, Device id = 0x%0x\n", 
                          (int)configInfo->VendorID,
                          (int)configInfo->DeviceID);
#endif   // DBG
            
            //
            // Is this the PCI device for which we've been searching?  It is 
            // if both the vendor and device ID match
            //
            if ( (configInfo->VendorID == OSR_PCI_VID) &&
                  (configInfo->DeviceID == OSR_PCI_DID) )  {
                    
                ULONG index;
                
                //
                // FOUND IT!  No need to keep searching.  We support only
                // one device.
                //
                adapterFound = TRUE;

#if DBG
                DbgPrint("*** Found OUR PCI ADAPTER ***");
                
                //
                // Just for the sake of interest, let's dump some of the
                // configuration information for our device.
                //
                OsrPrintConfig(configInfo);
#endif
            }

        }

    }

    //
    // If we didn't find our adapter, we bail out here, thereby aborting
    // the driver load process.  The I/O Manager will delete our driver
    // object.
    //
    if (!adapterFound) {

#if DBG
        DbgPrint("OSR PCI Sample device was not found!? -- EXITING.\n");
#endif
        //
        // Clean up the mess
        //
        OsrReturnPool(configInfo, deviceDescription, resources);

        //
        // Indicate load failure to the I/O manager; driver image is deleted...
        //
        return(STATUS_NO_SUCH_DEVICE);
    }
    
    //
    // ***************************************************************
    //
    // Hooray!  We've found our device!
    //
    // Lets create a device object for it
    //

    //
    // Initialize the UNICODE device name.  This will be the "native NT" name
    // for our device.
    //
    RtlInitUnicodeString(&devName, L"\\Device\\OSRPCI");

    //
    // Ask the I/O Manager to create the device object and
    // device extension
    //
    code = IoCreateDevice(DriverObj,
                          sizeof(OSR_DEVICE_EXT),
                          &devName,
                          FILE_DEVICE_OSR,
                          0,       
                          FALSE,
                          &devObj);

        
    if(!NT_SUCCESS(code))  {
        
#if DBG
        DbgPrint("IoCreateDevice failed.  Status = 0x%0x\n", code);
#endif
        return(STATUS_UNSUCCESSFUL);
    }    

    //
    // Get a pointer to our device extension
    //
    devExt = (POSR_DEVICE_EXT)devObj->DeviceExtension;
    
    //
    // Zero out the device extension.  While not strictly necessary
    // (the documentation says the device extension is zeroed) it's
    // better to be safe.
    //
    RtlZeroMemory(devExt, sizeof(OSR_DEVICE_EXT));

    //
    // Save the device object pointer away for future reference
    //
    devExt->DeviceObject = devObj;

    //
    // Store the bus and slot number away for the device we found
    //
    devExt->BusNumber = busNumber-1;
    devExt->SlotNumber = slotNumber;

    //
    // Next, make the device accessible from user-mode applications.
    // Note that this name can be either the same or different from
    // the native "kernel mode" name of the device object, given above.
    //
    RtlInitUnicodeString(&linkName, L"\\??\\OSRPCI");

    code = IoCreateSymbolicLink(&linkName, &devName);
    
    if (!NT_SUCCESS(code))
    {

#if DBG
        DbgPrint("IoCreateSymbolicLink failed.  Status = 0x%x\n", code);
#endif
        //
        // Clean up the mess
        //
        OsrReturnPool(configInfo, deviceDescription, resources);

        OsrUnload(DriverObj);

        //
        // Indicate load failure to the I/O manager; driver image is deleted...
        //
        return(code);
    }


    //
    // Initialize our IRP queues
    //
    InitializeListHead(&devExt->ReadQueue);
    InitializeListHead(&devExt->WriteQueue);
    
    //
    // Initialize our Spin Locks
    //
    KeInitializeSpinLock(&devExt->ReadQueueLock);
    KeInitializeSpinLock(&devExt->WriteQueueLock);
    
    //
    // Ask the I/O Manager to use describe user read/write buffers using MDLs
    //
    devObj->Flags |= DO_DIRECT_IO;

    //
    // Next, get the HAL to tell us about the resources the device will use. 
    // These resources include ports, shared memory regions, interrupts, and
    // the like.  The resources will be resevered for us in the registry (so
    // we do not have to call either IoReportResourceUsage or IoAssignResources).
    //
    code = HalAssignSlotResources(RegistryPath,
                                  NULL,
                                  DriverObj,
                                  devObj,
                                  PCIBus,
                                  devExt->BusNumber,
                                  devExt->SlotNumber.u.AsULONG,
                                  &resources);

    //
    // On return from this call, all resources are identified and assigned for
    // use by our device.
    //
    if (!NT_SUCCESS(code)) {

        //
        // log an appropriate error string.
        //
#if DBG
        DbgPrint("HalAssignSlotResourced failed!  Status = 0x%0x", code);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品福利视频一区二区三区| 免费一级片91| 久久精品亚洲乱码伦伦中文 | 国产成人精品在线看| 久久精品噜噜噜成人88aⅴ| 日日夜夜免费精品| 蜜臀99久久精品久久久久久软件| 男男gaygay亚洲| 久久99精品久久久久| 国产91在线看| 色av成人天堂桃色av| 欧美午夜精品一区| 欧美成人一区二区三区在线观看| xfplay精品久久| 国产精品午夜在线观看| 亚洲国产一区二区视频| 蜜桃久久精品一区二区| 国产精品一线二线三线| 99久久精品免费看| 4hu四虎永久在线影院成人| 精品久久久久久久久久久久包黑料| 欧美久久久久久久久| 欧美精品一区二区三区四区| 中文字幕亚洲区| 日本少妇一区二区| 国产mv日韩mv欧美| 欧美日韩dvd在线观看| 久久蜜桃一区二区| 亚洲午夜私人影院| 国产成人精品免费网站| 欧美日韩一区在线| 欧美国产激情二区三区| 性做久久久久久免费观看| 国产一区二区三区香蕉| 欧美亚洲国产一区二区三区| 久久久久久久久久久久久女国产乱 | 国产在线精品一区二区| 91免费国产在线观看| 精品国产伦理网| 婷婷久久综合九色综合绿巨人| 久久国产综合精品| 在线欧美小视频| 国产午夜精品久久| 青青草一区二区三区| 色婷婷国产精品| 国产精品区一区二区三区| 免费观看日韩av| 欧美色图12p| 亚洲欧美日韩国产一区二区三区| 老司机免费视频一区二区| 色噜噜狠狠一区二区三区果冻| 久久久.com| 国产毛片一区二区| 日韩欧美美女一区二区三区| 亚洲一区二区三区四区的| a级精品国产片在线观看| 精品sm在线观看| 日本欧美大码aⅴ在线播放| 在线欧美日韩精品| 一区二区三区日韩欧美| 99精品热视频| 亚洲色图在线视频| 99re亚洲国产精品| 亚洲欧美日韩电影| 91小视频免费观看| 国产精品色哟哟| 成人av在线电影| 国产精品久久久久久久久久免费看 | 亚洲一区二区三区美女| 99精品一区二区| 欧美国产成人在线| 成人午夜电影网站| 久久精品人人做人人爽97| 免费成人小视频| 日韩欧美国产小视频| 精品亚洲国内自在自线福利| 久久一夜天堂av一区二区三区| 麻豆一区二区三| 久久久亚洲国产美女国产盗摄| 国内一区二区在线| 国产精品私人自拍| 色综合天天综合网天天看片| 一区二区三区国产精华| 在线观看中文字幕不卡| 日韩 欧美一区二区三区| 国产午夜精品久久久久久免费视 | 国产精品午夜在线观看| 国产91精品久久久久久久网曝门| 欧美激情在线看| 色噜噜狠狠色综合欧洲selulu| 亚洲午夜成aⅴ人片| 日韩欧美一二三区| 国产aⅴ精品一区二区三区色成熟| 欧美激情综合五月色丁香 | 亚洲国产日日夜夜| 欧美一区二区高清| 国产精品一区二区免费不卡| 亚洲欧洲三级电影| 欧美视频一区在线| 国产一区二区三区日韩| 一区视频在线播放| 欧美一区二区三区小说| 国产成人精品亚洲日本在线桃色| 日韩理论片网站| 欧美一卡二卡三卡| 99re热视频精品| 美日韩一区二区三区| 最新日韩在线视频| 日韩一级免费观看| 91在线精品一区二区三区| 日韩黄色免费电影| 国产精品电影一区二区| 91精品国产综合久久小美女| 99精品在线观看视频| 激情国产一区二区 | 美女视频一区二区| 亚洲视频网在线直播| 精品国产一区二区三区久久影院 | 国产成人在线免费观看| 亚洲一区二区在线免费观看视频| 久久综合狠狠综合久久综合88| 91丨porny丨蝌蚪视频| 国产夫妻精品视频| 美女一区二区在线观看| 亚洲免费在线观看| 国产日本欧洲亚洲| 日韩欧美成人一区二区| 欧美亚洲自拍偷拍| 日韩午夜精品电影| 欧洲视频一区二区| av亚洲精华国产精华精| 久久成人羞羞网站| 日韩电影在线看| 亚洲人亚洲人成电影网站色| 2019国产精品| 日韩丝袜美女视频| 欧美久久高跟鞋激| 欧美日韩中文一区| 91一区在线观看| 97久久久精品综合88久久| 国产美女精品人人做人人爽| 老司机免费视频一区二区三区| 亚洲bdsm女犯bdsm网站| 一区二区三区精品视频在线| 综合分类小说区另类春色亚洲小说欧美| 久久尤物电影视频在线观看| 欧美三级电影精品| 色视频成人在线观看免| 99re视频精品| 色综合久久久久网| 91成人在线观看喷潮| 99久久久久久99| 欧美在线色视频| 欧美日本一区二区在线观看| 欧美日本一区二区三区四区 | 精品国产成人系列| 精品蜜桃在线看| 精品少妇一区二区三区在线播放| 欧美妇女性影城| 欧美精品久久一区二区三区| 欧美三区在线视频| 制服丝袜在线91| 91精品国产免费| 日韩精品一区二区三区视频在线观看 | 亚洲国产精品一区二区www| 亚洲一卡二卡三卡四卡无卡久久| 玉米视频成人免费看| 亚洲一区二区三区小说| 天堂av在线一区| 国产在线国偷精品产拍免费yy| 韩国av一区二区三区在线观看| 日本免费新一区视频| 国产精品亚洲一区二区三区在线 | 日韩欧美国产一区二区三区| 久久婷婷久久一区二区三区| 综合电影一区二区三区| 免费在线视频一区| 成人国产在线观看| 欧美日韩激情在线| 国产亚洲一区二区在线观看| 亚洲激情五月婷婷| 老司机免费视频一区二区| 成人一二三区视频| 色视频欧美一区二区三区| 日韩区在线观看| 日韩美女啊v在线免费观看| 天天色综合天天| 丰满白嫩尤物一区二区| 欧美色倩网站大全免费| 国产亚洲福利社区一区| 亚洲不卡在线观看| 不卡av在线网| 日韩丝袜情趣美女图片| 亚洲欧美一区二区三区久本道91| 日韩va亚洲va欧美va久久| 91一区二区三区在线观看| 欧美成人a视频| 午夜日韩在线电影| 99久久久国产精品免费蜜臀| 久久综合久久鬼色中文字|