找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 10912|回复: 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,代码如下:9 G; v7 D; M/ n' n
EFI_BREAKPOINT( );0 \8 o, Y6 {' }2 i0 R# Q; J7 u
  Status = gBS->OpenProtocol (8 T0 H, k- p- j5 A' y
                  Controller,
' S6 [" }1 y; \8 ~/ K                  &gEfiPciIoProtocolGuid,: t: N9 |: B' Q5 h# \( }% y
                  (VOID **) &PciIo,
) R$ [) k0 {+ d* A6 \                  This->DriverBindingHandle,' K- \/ L: x( L8 [9 M" f' Y8 n
                  Controller,+ k, u# }( u  R  U
                  EFI_OPEN_PROTOCOL_BY_DRIVER
. l( f0 L: o5 E7 J9 E' n8 J                  );
/ [7 ^, r8 z9 R8 M: E+ B9 E  if (EFI_ERROR (Status)) {% A% J0 M9 ]: |- O
    return Status;
7 O' R% J, R$ P( _1:在NT32下打开一个PCIIO protocal,应该是与硬件没有任何关系的,为什么却fail?用VS studio调试跟踪发现,其实是在执行handle.c 文件中的CoreGetProtocolInterface( )函数时,在 Look at each protocol interface for a match时没有找到匹配protocal返回一个unsupport状态值。$ ]: Z* L8 J' E( M; K
2:当我在用EDK中提供的AtapiScsiPassThruDriverBindingSupported( )测试时,同样会出现此现象。
+ ~, t6 }4 {9 k; s" Y  }) U% ?. ?请问:& O6 r' u7 o0 n) L. F) e6 v
当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。6 {/ S" k% w  ~. r9 U

8 U7 U# d, g2 C, A+ |% }对一个想管理某种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)." P0 P0 U& W2 R. c2 H9 ?% E1 B+ F
3 ]( P7 ?$ V& _
UEFI 规范中connect all controller的示例程序片断:
4 @2 |+ d* v; X; l  Status = gBS->LocateHandleBuffer ($ A9 \) @% R% a" u
                  AllHandles,
$ w# G& F- x0 V3 T! x. o                  NULL,
' F6 E6 E) U4 I, }9 K                  NULL,
: [& i: c8 K/ ^/ `9 {                  &HandleCount,+ y6 l- s* u6 d4 ^! k6 P
                  &HandleBuffer5 H. D* {' ~' f0 c" t2 {9 C
                  );
# N( n$ v6 V) V4 U$ V, [  if (EFI_ERROR (Status)) {
: ?& ^# M; G/ c4 L" p1 D' _    return Status;6 R; u; h1 q% ^- ?1 H+ ?' }0 N
  }5 f0 k2 u2 D6 B
: W2 {% W) A5 O; \5 e
  for (Index = 0; Index < HandleCount; Index++) {
( y; e+ V% ~6 l3 Z0 V8 ]* ~) ]    Status = gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);2 w8 Y+ K1 O' Z/ r6 |7 d5 O
  }
回复

使用道具 举报

 楼主| 发表于 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-6-4 16:19 , Processed in 0.367889 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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