找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 10889|回复: 2

EDK:open PCI IO PROTOCAL fail

[复制链接]
发表于 2009-3-17 13:50:56 | 显示全部楼层 |阅读模式
在EDK中做SCSI driver,环境是NT32,要在driver binding protocal support( )中打开pciio协议,当编译的时候发现open pciio protocal fail,代码如下:
2 ]" y2 g  G0 P% f1 W/ u5 ^- H EFI_BREAKPOINT( );$ f7 r$ W# g+ E$ V3 B  w( E5 u
  Status = gBS->OpenProtocol ($ ^! O$ Y" H4 c! t1 U
                  Controller,
- C/ m2 j* ~7 q$ z7 @                  &gEfiPciIoProtocolGuid,1 S5 h9 e/ D( m7 r& `3 s# A4 j
                  (VOID **) &PciIo,2 L7 |8 V( u- P- r, b
                  This->DriverBindingHandle,7 J7 v& g1 {5 s3 d
                  Controller,4 U! ~" I5 Z# |5 b' o
                  EFI_OPEN_PROTOCOL_BY_DRIVER0 ^6 F) q# D9 ?/ @
                  );  B0 ?( B5 w$ ^) ^' @2 i# w
  if (EFI_ERROR (Status)) {; r1 m6 Y" |0 K$ Y! Q
    return Status;+ n1 @# d- j1 m3 k1 ]8 h2 D
1:在NT32下打开一个PCIIO protocal,应该是与硬件没有任何关系的,为什么却fail?用VS studio调试跟踪发现,其实是在执行handle.c 文件中的CoreGetProtocolInterface( )函数时,在 Look at each protocol interface for a match时没有找到匹配protocal返回一个unsupport状态值。
1 z$ b" Y$ h. m; I  L9 p2:当我在用EDK中提供的AtapiScsiPassThruDriverBindingSupported( )测试时,同样会出现此现象。  I. n9 e3 ]7 M+ Y; C0 D
请问:1 v3 {0 x8 m% y8 c$ ^
当invoke support( )时传递的controller参数需要硬件支持吗?如果不需要为什么会fail掉呢
发表于 2009-3-17 14:57:51 | 显示全部楼层
Driver Binding Protcol.support()用来支持将driver和要管理的device动态匹配起来,driver不能对传入的handle有任何假定,传入的handle有可能是device handle或者是和硬件无关的image handle和service handle。driver在support()函数中判断传入的handle是不是自己要管理的device的handle。
% F* v1 d& u- r3 Y0 l! }8 F! T
! T/ a) O7 y, _, ^对一个想管理某种PCI device的driver来说传入的handle没有PCI IO Protocl是正常的。没有PCI IO Protcol说明这个handle不是PCI device handle,甚至根本就不是device handle。(PCI bus driver在enumeration的时候会有发现的每个PCI device创建一个device handle,并在此handle上安装PCI IO Protocol).
" ~# X) @' N9 g# p3 b2 P  f2 m6 t2 Z' m; k: Z, E1 @& |- P
UEFI 规范中connect all controller的示例程序片断:3 Q  Y# W: ?/ k6 D6 x9 i% O
  Status = gBS->LocateHandleBuffer (* X) \, O* k. J$ T8 f
                  AllHandles," j' q8 b! d( e0 ], {1 a) T/ z4 @
                  NULL,; ]0 o# @! z( [; \- G0 r' [5 ?1 w
                  NULL,
1 t2 `+ M) S  q                  &HandleCount,
1 I2 z+ J: d9 g+ f' m/ C: z                  &HandleBuffer/ u* l. Y* E" F+ ]# d8 {
                  );0 l# Q4 r$ l. K
  if (EFI_ERROR (Status)) {
! H5 {7 K2 c# M1 b. j    return Status;$ B7 t& D  f$ |; @) |
  }
7 i+ ]+ X; o# C9 l  x
7 T& B% o& G9 n& y, n) l  for (Index = 0; Index < HandleCount; Index++) {
5 M9 M3 o# K1 W9 U4 U9 I  g7 B    Status = gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
( W: B# v- C* f  x6 `  }
回复

使用道具 举报

 楼主| 发表于 2009-3-23 17:37:16 | 显示全部楼层
多谢,后来追踪一下代码是这样的,在connect controller to a driver时,会调用Status = DriverBinding->supported(  ),如果controller支持该driver的话,接下来会调用Status = DriverBinding->Start ( )去执行driver的start( ).
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 加入计匠网

本版积分规则

Archiver|手机版|小黑屋|计匠网

GMT+8, 2026-9-18 20:08 , Processed in 0.540673 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表