找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 11068|回复: 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,代码如下:. B3 y& P$ b& c( ?" [2 c
EFI_BREAKPOINT( );
5 V+ ]7 Y! P0 w$ K- L; x& L  Status = gBS->OpenProtocol (
3 A" N2 U' a/ D' t6 {' P, L                  Controller,& Z5 J" h2 F% z7 |1 f
                  &gEfiPciIoProtocolGuid,
# k" l$ M. }9 K* X                  (VOID **) &PciIo,2 b5 @& Q6 x) l% E/ d& L* U
                  This->DriverBindingHandle,
5 D6 W* t' y5 v5 c# J3 d                  Controller,
6 p5 C9 n' h6 }                  EFI_OPEN_PROTOCOL_BY_DRIVER5 f' a' _% i4 t, ]( q
                  );
$ k4 e- H5 p' P/ v* T8 K- K5 G  U9 o  if (EFI_ERROR (Status)) {
+ o# [5 f* _7 P    return Status;4 O3 }2 t+ i2 f6 J- S) e
1:在NT32下打开一个PCIIO protocal,应该是与硬件没有任何关系的,为什么却fail?用VS studio调试跟踪发现,其实是在执行handle.c 文件中的CoreGetProtocolInterface( )函数时,在 Look at each protocol interface for a match时没有找到匹配protocal返回一个unsupport状态值。
$ z4 c( F2 D) j) ~  S5 P! T. j5 L2:当我在用EDK中提供的AtapiScsiPassThruDriverBindingSupported( )测试时,同样会出现此现象。
' O6 p4 l3 p" A) L* G6 O请问:
4 Y9 `5 U2 M/ q2 E) _当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。. \( ?4 s2 w4 E

+ S' _) H' |% j& h4 Y3 `对一个想管理某种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).
' _( @1 z5 e5 w* B4 p1 S5 B" K3 P# }! A* _1 W3 j- M
UEFI 规范中connect all controller的示例程序片断:8 \* ?9 \  r/ j: z0 Y6 [+ H
  Status = gBS->LocateHandleBuffer (# Y/ T' h! A' |$ @
                  AllHandles,
! W9 D0 W( j. K1 d3 Q6 v! N                  NULL,3 i" l) c9 O) K% M5 j& ]
                  NULL,/ J8 f. i! w5 @( q- I
                  &HandleCount,
% {/ [. _" I% j' L$ C: u! n; t7 \                  &HandleBuffer
8 g! y5 t3 a- W( d/ b                  );
) F9 n; M  M1 ]3 d  if (EFI_ERROR (Status)) {$ Y  F  P* \  _7 ]/ g- q4 g
    return Status;& X7 ]" M; Q2 o+ u1 ]; B$ @% }3 x+ _' x
  }
$ e$ q$ Q3 U: H. W& z; `% k* u! e# O+ m- p, r. _
  for (Index = 0; Index < HandleCount; Index++) {
) D4 m! K9 Y+ ~, a/ r! y    Status = gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);$ {! M8 H, B) `/ Z
  }
回复

使用道具 举报

 楼主| 发表于 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-7-21 22:15 , Processed in 0.040730 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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