simon
驱动牛犊
驱动牛犊
  • 注册日期2001-08-13
  • 最后登录2003-03-28
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:2584回复:7

求教:PCI卡的安装

楼主#
更多 发布于:2001-08-13 13:13
    我是新手,在这看了几天,发现这人气挺足,特来请教。
    本人欲在win98及win2000下使用一PCI卡,应用程序通过WDM driver得到PCI卡的Memory Base。我用DriverWorks写好了一个WDM driver,在win98下安装和使用都正常,在win2000下安装时也没有报告错误,但相同的应用程序在调完几个SetupAPI后,执行到CreateFile时就报告不能打开错误。我想,既然能在win98下用,WDM驱动程序应该没有问题, 有可能是WDM驱动程序在win2000下安装不对,是不是这样?哪位大侠给点提示?
    这是我在win2000下用的INF文件,请大家帮我看看有没有问题。

如蒙赐教,不胜感激涕零!


;--------- Version Section ---------------------------------[Version]
Signature="$Windows NT$"
Provider=%ProviderName%

; If device fits one of the standard classes, use the
; name and GUID here, otherwise create your own as
; this example shows.

Class=NewDeviceClass
ClassGUID={ff646f80-8def-11d2-9449-00105a075f6b}

DriverVer = 08/10/2001,8.0.0.1


;--------- DestinationDirs Section -------------------------[DestinationDirs]
DefaultDestDir = 10,System32\Drivers

;--------- Manufacturer and Models Sections ----------------[Manufacturer]
%MfgName%=Mfg0

[Mfg0]

;
%DeviceDesc%=Pciwdm_DDI.NT, PCI\VEN_4005&DEV_1000

;---------- DDInstall Sections -----------------------------
[Pciwdm_DDI.NT]
CopyFiles=Pciwdm_Files_Driver

[Pciwdm_DDI.NT.Services]
Addservice = Pciwdm, 0x00000002, Pciwdm_AddService

[Pciwdm_AddService]
DisplayName    = %SvcDesc%
ServiceType    = 1                  ; SERVICE_KERNEL_DRIVER
StartType      = 3                  ; SERVICE_DEMAND_START
ErrorControl   = 1                  ; SERVICE_ERROR_NORMAL
ServiceBinary  = %10%\System32\Drivers\Pciwdm.sys

; --------- Files (common) -------------

[Pciwdm_Files_Driver]
Pciwdm.sys

;--------- Strings Section ---------------------------------

[Strings]
ProviderName="sample"
MfgName="sample"
DeviceDesc="Sample Device"
DeviceClassName="sample"
SvcDesc="Description of NT service here"

最新喜欢:

hapihapi
drinkeryj
驱动老牛
驱动老牛
  • 注册日期2001-03-23
  • 最后登录2006-05-16
  • 粉丝0
  • 关注0
  • 积分15分
  • 威望2点
  • 贡献值0点
  • 好评度1点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2001-08-13 17:19
我也遇到过类似问题,后来发现问题出在INF文件上.我不知道你写出来的INF文件是不是完整的,如果是完整的,我觉得和我的相比好象缺了点东西,和注册表相关,同时也少了有关PCI信息的部分.以下是我写的一个.INF文件,希望对你有帮助:
;; PCI2040.inf


;--------- Version Section ---------------------------------------------------

[Version]
Signature="$Windows 95$"
Provider=%ProviderName%

; If device fits one of the standard classes, use the name and GUID here,
; otherwise create your own device class and GUID as this example shows.

;Class=NewDeviceClass
;ClassGUID={ff646f80-8def-11d2-9449-00105a075f6b}
Class=PCI2040DeviceClass   //我的类
ClassGUID={78C6E7F1-FBB8-4C60-B9F3-8AEA5B8CD2C0}  //我的GUID

;--------- SourceDiskNames and SourceDiskFiles Section -----------------------

; These sections identify source disks and files for installation.  They are
; shown here as an example, but commented out.

;[SourceDisksNames]
;1 = "Install Disk",Disk1,,

;[SourceDisksFiles]
;PCI2040.sys = 1,,

;--------- ClassInstall/ClassInstall32 Section -------------------------------

; Not necessary if using a standard class

; 9X Style
[ClassInstall]
Addreg=PCI2040DeviceClass_AddReg   //和注册表相关的类注册

; NT Style
[ClassInstall32]
Addreg=PCI2040DeviceClass_AddReg  //和注册表相关的类注册

[Class_AddReg]
HKR,,,,%DeviceClassName%
HKR,,Icon,,"-18"

;--------- DestinationDirs Section -------------------------------------------

[DestinationDirs]
PCI2040_Files_Driver = 10,System32\Drivers

;--------- Manufacturer and Models Sections ----------------------------------

[Manufacturer]
%MfgName%=Mfg0

[Mfg0]

; PCI hardware IDs use the form
;   PCI\VEN_aaaa&DEV_bbbb&SUBSYS_cccccccc&REV_dd
;
%DeviceDesc%=PCI2040_DDI, PCI\VEN_104C&DEV_AC60&SUBSYS_00010508&REV_00  //PCI的信息

;---------- DDInstall Sections -----------------------------------------------
; --------- Windows 9X -----------------

; Experimentation has shown that DDInstall root names greater than 19 characters
; cause problems in Windows 98

[PCI2040_DDI]
CopyFiles=PCI2040_Files_Driver
AddReg=PCI2040_9X_AddReg

[PCI2040_9X_AddReg]
HKR,,DevLoader,,*ntkern
HKR,,NTMPDriver,,PCI2040.sys
HKR, "Parameters", "PCI2040Entry", 0x00010001, 0

; --------- Windows NT -----------------

[PCI2040_DDI.NT]
CopyFiles=PCI2040_Files_Driver
AddReg=PCI2040_NT_AddReg

[PCI2040_DDI.NT.Services]
Addservice = PCI2040, 0x00000002, PCI2040_AddService

[PCI2040_AddService]
DisplayName    = %SvcDesc%
ServiceType    = 1                  ; SERVICE_KERNEL_DRIVER
StartType      = 3                  ; SERVICE_DEMAND_START
ErrorControl   = 1                  ; SERVICE_ERROR_NORMAL
ServiceBinary  = %10%\System32\Drivers\PCI2040.sys

[PCI2040_NT_AddReg]
HKLM, "System\CurrentControlSet\Services\PCI2040\Parameters",\
"PCI2040Entry", 0x00010001, 0


; --------- Files (common) -------------

[PCI2040_Files_Driver]
PCI2040.sys

;--------- Strings Section ---------------------------------------------------

[Strings]
ProviderName="YangJun Driver Studio"
MfgName="YangJun Driver Studio"
DeviceDesc="PCI Device for 2040"
DeviceClassName="PCI2040DeviceClass"
SvcDesc="PCI2040 NT Service"


这是DRIVERWORKS生成的,我改了一点,是可以用的.
以后怎么办? [img]http://www.driverdevelop.com/forum/upload/Xman/2004-04-05_2004324183110706.jpg[/img]
simon
驱动牛犊
驱动牛犊
  • 注册日期2001-08-13
  • 最后登录2003-03-28
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2001-08-14 17:22
用你的INF,还是不行,我快晕到了!
drinkeryj
驱动老牛
驱动老牛
  • 注册日期2001-03-23
  • 最后登录2006-05-16
  • 粉丝0
  • 关注0
  • 积分15分
  • 威望2点
  • 贡献值0点
  • 好评度1点
  • 原创分0分
  • 专家分0分
地板#
发布于:2001-08-14 19:25
你先把你改的INF文件贴出来,我不知道你是怎么改的。另外如果你是用Driverworks生成的驱动,它应该自动生成INF文件。你可以在WIN2000下用Driverworks向导生成一个驱动框架,然后只用它的INF文件,当然有些东西要修改,我贴出来的INF文件已经改过了。
以后怎么办? [img]http://www.driverdevelop.com/forum/upload/Xman/2004-04-05_2004324183110706.jpg[/img]
simon
驱动牛犊
驱动牛犊
  • 注册日期2001-08-13
  • 最后登录2003-03-28
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
地下室#
发布于:2001-08-15 09:39

首先谢谢drinkeryj的热情帮助!

因为driverWork生成的INF我在2000上装不上,所以我才改来改去。我在你的INF文件上只改动了几处,主要是ClassGUID和[Mfg0] 中的VenderID和DeviceID,如下所示,请帮我看看对不对?另外我把应用程序对driver的调用代码也贴在后面,把WDM driver也附上,请帮我试试看有没有什么问题,谢谢!



;; PCI2040.inf


;--------- Version Section ---------------------------------------------------

[Version]
Signature="$Windows 95$"
Provider=%ProviderName%

; If device fits one of the standard classes, use the name and GUID here,
; otherwise create your own device class and GUID as this example shows.

;Class=NewDeviceClass
;ClassGUID={ff646f80-8def-11d2-9449-00105a075f6b}
Class=PCI2040DeviceClass
; //我的类
;ClassGUID={78C6E7F1-FBB8-4C60-B9F3-8AEA5B8CD2C0} //我的GUID
ClassGUID={ff646f80-8def-11d2-9449-00105a075f6b}

;--------- SourceDiskNames and SourceDiskFiles Section -----------------------

; These sections identify source disks and files for installation. They are
; shown here as an example, but commented out.

;[SourceDisksNames]
;1 = "Install Disk",Disk1,,

;[SourceDisksFiles]
;PCI2040.sys = 1,,

;--------- ClassInstall/ClassInstall32 Section -------------------------------

; Not necessary if using a standard class

; 9X Style
[ClassInstall]
Addreg=PCI2040DeviceClass_AddReg
; //和注册表相关的类注册

; NT Style
[ClassInstall32]
Addreg=PCI2040DeviceClass_AddReg
;//和注册表相关的类注册

[Class_AddReg]
HKR,,,,%DeviceClassName%
HKR,,Icon,,"-18"

;--------- DestinationDirs Section -------------------------------------------

[DestinationDirs]
PCI2040_Files_Driver = 10,System32\Drivers

;--------- Manufacturer and Models Sections ----------------------------------

[Manufacturer]
%MfgName%=Mfg0

[Mfg0]

; PCI hardware IDs use the form
; PCI\VEN_aaaa&DEV_bbbb&SUBSYS_cccccccc&REV_dd
;
;%DeviceDesc%=PCI2040_DDI, PCI\VEN_104C&DEV_AC60&SUBSYS_00010508&REV_00 //PCI的信息
%DeviceDesc%=PCI2040_DDI, PCI\VEN_4005&DEV_1000&SUBSYS_00000000&REV_02;
 //PCI的信息

;---------- DDInstall Sections -----------------------------------------------
; --------- Windows 9X -----------------

; Experimentation has shown that DDInstall root names greater than 19 characters
; cause problems in Windows 98

[PCI2040_DDI]
CopyFiles=PCI2040_Files_Driver
AddReg=PCI2040_9X_AddReg

[PCI2040_9X_AddReg]
HKR,,DevLoader,,*ntkern
HKR,,NTMPDriver,,PCI2040.sys
HKR, "Parameters", "PCI2040Entry", 0x00010001, 0

; --------- Windows NT -----------------

[PCI2040_DDI.NT]
CopyFiles=PCI2040_Files_Driver
AddReg=PCI2040_NT_AddReg

[PCI2040_DDI.NT.Services]
Addservice = PCI2040, 0x00000002, PCI2040_AddService

[PCI2040_AddService]
DisplayName = %SvcDesc%
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 3 ; SERVICE_DEMAND_START
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
ServiceBinary = %10%\System32\Drivers\PCI2040.sys

[PCI2040_NT_AddReg]
首先谢谢

HKLM, "System\CurrentControlSet\Services\PCI2040\Parameters",\
"PCI2040Entry", 0x00010001, 0


; --------- Files (common) -------------

[PCI2040_Files_Driver]
PCI2040.sys

;--------- Strings Section ---------------------------------------------------

[Strings]
ProviderName="MY Driver "
MfgName="My driver"
DeviceDesc="My PCI Device"
DeviceClassName="PCI2040DeviceClass"
SvcDesc="PCI2040 NT Service


应用程序部分:
/////////////////////////////////////////////////////
/////////////////////////////////////////////////////
PCI_CONFIG_HEADER_0 ConfigData;

void WDMGetDeviceInformation()
{

CString csErr;
// setup device interface
HDEVINFO info = SetupDiGetClassDevs((LPGUID) &GUID_RA3911EMU, NULL,
                                        NULL, DIGCF_PRESENT |
                                        DIGCF_INTERFACEDEVICE);

    if (info == INVALID_HANDLE_VALUE)
    {
        csErr.Format("Error %d trying to open enumeration handle for GUID_RA3911EMU\n", GetLastError());
AfxMessageBox(csErr, MB_ICONERROR|MB_OK);
        exit(1);
    }

SP_INTERFACE_DEVICE_DATA ifdata;
    ifdata.cbSize = sizeof(ifdata);
    
if (!SetupDiEnumDeviceInterfaces(info, NULL, (LPGUID) &GUID_RA3911EMU,
                                     0, &ifdata))
    {
        csErr.Format("Error %d trying to enumerate interfaces\n",
            GetLastError());
        SetupDiDestroyDeviceInfoList(info);
AfxMessageBox(csErr, MB_ICONERROR|MB_OK);
        exit(1);
     }

DWORD needed;
    SetupDiGetDeviceInterfaceDetail(info, &ifdata, NULL, 0, &needed, NULL);
    PSP_INTERFACE_DEVICE_DETAIL_DATA detail = (PSP_INTERFACE_DEVICE_DETAIL_DATA) malloc(needed);

if (!detail)
    {
        csErr.Format("Error %d trying to get memory for interface detail\n", GetLastError());
        SetupDiDestroyDeviceInfoList(info);
AfxMessageBox(csErr, MB_ICONERROR|MB_OK);
        exit(1);
    }

    detail->cbSize = sizeof(SP_INTERFACE_DEVICE_DETAIL_DATA);
    if (!SetupDiGetDeviceInterfaceDetail(info, &ifdata, detail, needed, NULL, NULL))
    {
        csErr.Format("Error %d getting interface detail\n", GetLastError());
        free((PVOID) detail);
        SetupDiDestroyDeviceInfoList(info);
AfxMessageBox(csErr, MB_ICONERROR|MB_OK);
        exit(1);
    }

    char name[MAX_PATH];
    strncpy(name, detail->DevicePath, sizeof(name));
    free((PVOID) detail);
    SetupDiDestroyDeviceInfoList(info);

AfxMessageBox("Call CreateFile now");


//open pciwdm.sys
    HANDLE hfile = CreateFile(name, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
    if (hfile == INVALID_HANDLE_VALUE)
    {
AfxMessageBox("Call CreateFile failure!");

        csErr.Format("Error %d trying to open %s\n", GetLastError(), name);
AfxMessageBox(csErr, MB_ICONERROR|MB_OK);
        exit(1);
    }

AfxMessageBox("Call CreateFile success!");

DWORD junk;
    //Send IOCTL_RA3911_GET_PCICONFIG control code
if(!DeviceIoControl(hfile,IOCTL_RA3911_GET_PCICONFIG,
NULL,0,
&ConfigData,sizeof(ConfigData),
&junk,NULL))
    {
csErr.Format("Direct IOCTL failed with code %d\n", GetLastError());
AfxMessageBox(csErr, MB_ICONERROR|MB_OK);
        exit(1);

}
CloseHandle(hfile);
}



drinkeryj
驱动老牛
驱动老牛
  • 注册日期2001-03-23
  • 最后登录2006-05-16
  • 粉丝0
  • 关注0
  • 积分15分
  • 威望2点
  • 贡献值0点
  • 好评度1点
  • 原创分0分
  • 专家分0分
5楼#
发布于:2001-08-16 20:22
你改的不对,你的驱动名字是Pciwdm.sys罢,而你却没把我写的INF文件中的有关驱动程序的名称该过来.PCI2040是我用的PCI总线控制芯片,PCI2040DeviceClass是我的驱动程序类名.
你现在还是用DRIVERSTUDIO生成一个框架,然后按照我的INF中改动的办法再改一下,注意PCI2040是我的驱动程序名称,你也必须把你的INF文件中的相应的地方改掉.
应用程序部分也尽可以用DRIVERSTUDIO自动生成的测试程序,它写得很好.
以后怎么办? [img]http://www.driverdevelop.com/forum/upload/Xman/2004-04-05_2004324183110706.jpg[/img]
simon
驱动牛犊
驱动牛犊
  • 注册日期2001-08-13
  • 最后登录2003-03-28
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
6楼#
发布于:2001-08-17 17:14
    其实我已把我的驱动程序的名字改为pci2040.sys了。
    今天用driverworks生成了一个框架,用生成的INF文件,什么也没改,只改了GUID,问题依然如故,即在98下可用,在2000下不可用。
    我又试了用2000DDK来编绎生成驱动程序也不行!在应用程序部分中,把CreateFile打开driver的方法从GUID法改为符号链接法也不行!
    各位高手,救救我吧!我都快给boss逼疯了!

hswqs
驱动小牛
驱动小牛
  • 注册日期2001-03-27
  • 最后登录2012-03-31
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望2点
  • 贡献值0点
  • 好评度2点
  • 原创分0分
  • 专家分0分
7楼#
发布于:2001-10-12 15:25
remove "&SUBSYS_00000000&REV_02",
try it.
游客

返回顶部