亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
欧美性色综合网| 欧美日韩视频在线一区二区| 亚洲免费成人av| 日韩欧美久久久| 一本色道久久综合狠狠躁的推荐 | 成人午夜在线免费| 亚洲高清免费观看高清完整版在线观看| 日韩欧美电影一区| 欧美系列亚洲系列| 成人激情av网| 激情另类小说区图片区视频区| 亚洲日本免费电影| 国产蜜臀97一区二区三区| 欧美一区二区免费视频| 色综合天天天天做夜夜夜夜做| 九九九久久久精品| 婷婷中文字幕一区三区| 亚洲人一二三区| 亚洲国产精品ⅴa在线观看| 日韩欧美国产精品| 欧美日韩你懂得| 日本高清视频一区二区| 成人深夜视频在线观看| 激情成人午夜视频| 麻豆国产精品一区二区三区 | 日本不卡一二三| 亚洲午夜久久久久中文字幕久| 国产精品色婷婷久久58| 久久久久久久网| 精品久久久久久久人人人人传媒| 欧美日韩亚洲综合在线| 在线免费视频一区二区| 91尤物视频在线观看| 成人一级片在线观看| 国产成人综合亚洲91猫咪| 国产一区二区在线影院| 精品午夜久久福利影院| 蜜臀av一级做a爰片久久| 日韩精品每日更新| 免费在线看成人av| 午夜影院在线观看欧美| 香蕉久久一区二区不卡无毒影院 | a在线欧美一区| 成人永久免费视频| 不卡高清视频专区| 成人综合婷婷国产精品久久免费| 国产精品综合网| 国产精品一区一区三区| 国产一区二区福利| 国产成人亚洲综合a∨猫咪| 国产成人午夜精品影院观看视频 | 精品国产三级a在线观看| www亚洲一区| 久久综合九色综合欧美就去吻| 久久久综合网站| 欧美国产精品一区| 亚洲三级视频在线观看| 一区二区三区在线看| 亚洲成av人片www| 美女mm1313爽爽久久久蜜臀| 免费在线视频一区| 国产成人av影院| 99国产精品久久久久久久久久久| 91日韩在线专区| 欧美在线看片a免费观看| 91精品久久久久久久91蜜桃| 日韩欧美中文一区二区| 久久九九99视频| 亚洲色图色小说| 偷拍亚洲欧洲综合| 国产一区二区三区免费看| 成人一区在线看| 欧美性大战久久| 精品日韩在线观看| 《视频一区视频二区| 性久久久久久久久久久久| 国产乱码精品一区二区三区av | 欧美国产精品久久| 亚洲国产人成综合网站| 久久se精品一区精品二区| 成人动漫一区二区三区| 777xxx欧美| 日本一区二区不卡视频| 亚洲一区精品在线| 国产麻豆成人精品| 色悠悠亚洲一区二区| 精品国产污网站| 亚洲午夜一二三区视频| 国产精品资源在线| 欧美日韩免费视频| 亚洲国产精品v| 免费一级片91| 色综合久久88色综合天天6 | 亚洲五码中文字幕| 国产高清无密码一区二区三区| 在线亚洲一区二区| 久久久国产精华| 青青草国产成人av片免费| kk眼镜猥琐国模调教系列一区二区 | 亚洲乱码国产乱码精品精小说| 奇米影视在线99精品| 在线视频中文字幕一区二区| 久久综合九色综合欧美就去吻 | 久久久综合网站| 亚洲福利一二三区| 成人免费视频caoporn| 日韩限制级电影在线观看| 亚洲特级片在线| 国产精品一区二区不卡| 欧美一卡2卡3卡4卡| 亚洲在线中文字幕| 成人精品gif动图一区| 精品国产成人在线影院| 亚洲va欧美va国产va天堂影院| 成人一区二区三区中文字幕| 精品电影一区二区三区| 午夜国产不卡在线观看视频| 色综合天天综合狠狠| 国产精品美女久久久久久2018 | 亚洲二区视频在线| caoporn国产精品| 国产欧美一区二区精品仙草咪| 青椒成人免费视频| 国产精品网站在线| 精品一区二区影视| 日韩欧美国产综合| 日韩激情一二三区| 欧美日韩在线播放三区| 亚洲精品水蜜桃| a亚洲天堂av| 亚洲欧美另类小说| 色综合天天做天天爱| 亚洲欧美日韩国产手机在线| 99久久99久久免费精品蜜臀| 中文字幕av不卡| 成人免费观看视频| 亚洲日本丝袜连裤袜办公室| 99久久久国产精品| 亚洲人成亚洲人成在线观看图片| av激情成人网| 亚洲美女一区二区三区| 日本久久电影网| 一区二区欧美精品| 欧美精品一二三四| 日韩av网站在线观看| 欧美一区二区三级| 精品无人区卡一卡二卡三乱码免费卡| 精品日韩av一区二区| 国产精品自产自拍| 国产精品初高中害羞小美女文| av资源网一区| 亚洲综合色在线| 91精品国产综合久久精品app| 视频一区视频二区在线观看| 欧美一区二区三区免费观看视频| 久久电影网站中文字幕| 国产丝袜在线精品| 99久久国产免费看| 五月天中文字幕一区二区| 日韩欧美的一区| 国产黄色精品网站| 亚洲欧美偷拍三级| 欧美人与性动xxxx| 韩国v欧美v日本v亚洲v| 国产精品第13页| 欧美精品自拍偷拍动漫精品| 精品一区二区在线看| 中文字幕一区二区三区精华液| 欧美综合天天夜夜久久| 免费成人av资源网| 亚洲国产成人一区二区三区| 色久优优欧美色久优优| 美腿丝袜亚洲色图| 欧美国产日韩亚洲一区| 欧美日韩免费一区二区三区视频 | 国产成人在线色| 一区二区三区日韩欧美精品| 欧美一级午夜免费电影| 成人精品小蝌蚪| 三级一区在线视频先锋| 亚洲国产精品传媒在线观看| 欧美三级在线播放| 国产河南妇女毛片精品久久久| 亚洲自拍另类综合| 久久精品日韩一区二区三区| 欧美午夜理伦三级在线观看| 狠狠色丁香婷婷综合| 亚洲综合网站在线观看| 久久久久久综合| 欧美久久久久免费| 国产精品一区二区三区四区| 亚洲国产精品嫩草影院| 国产日韩精品久久久| 欧美精品在线一区二区三区| 成人性生交大片免费看中文| 日韩 欧美一区二区三区| 亚洲日韩欧美一区二区在线| 精品国产乱码久久久久久牛牛| 欧美午夜不卡在线观看免费| 成人在线视频一区|