找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 10991|回复: 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,代码如下:
' u2 L6 \  I7 [: d" T EFI_BREAKPOINT( );
0 \- [* k* z+ c6 _3 {* g; a# Y  Status = gBS->OpenProtocol (* W7 {' o. |' \  s7 B
                  Controller,
  {9 b; k5 R+ y+ k1 ^                  &gEfiPciIoProtocolGuid,/ Z# d6 H) w. ]5 G( T
                  (VOID **) &PciIo,+ k' f( l" L$ Z& h9 `) J2 r$ }6 h
                  This->DriverBindingHandle,
1 E6 }2 f0 Y$ C) o/ H                  Controller,
! u9 L0 H9 c; f" b                  EFI_OPEN_PROTOCOL_BY_DRIVER1 u9 P$ C3 j& T2 Q0 \# ^! t
                  );
0 n/ A6 B; j4 D& p$ a  if (EFI_ERROR (Status)) {: W: Y$ J4 W. e( J+ K: \1 [
    return Status;
4 ]0 G8 {7 L: n/ k/ f+ |3 W2 P1:在NT32下打开一个PCIIO protocal,应该是与硬件没有任何关系的,为什么却fail?用VS studio调试跟踪发现,其实是在执行handle.c 文件中的CoreGetProtocolInterface( )函数时,在 Look at each protocol interface for a match时没有找到匹配protocal返回一个unsupport状态值。
9 a+ R, m" u) d: g* R2:当我在用EDK中提供的AtapiScsiPassThruDriverBindingSupported( )测试时,同样会出现此现象。
% F- |4 V9 ?9 M: u8 P3 `请问:
6 K; o. p, X" t9 F+ I当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。! _* R1 b+ K) z
6 Q& d5 m& L/ O4 s! X1 }( q
对一个想管理某种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).  `4 E  {' D1 @% H* n4 j4 l
7 n( T4 m" t0 Y) y
UEFI 规范中connect all controller的示例程序片断:
6 w9 N+ \5 E% y! F7 }4 g( a, Z  Status = gBS->LocateHandleBuffer (
6 I+ y6 W5 ^$ @4 w5 V: O                  AllHandles,
) R; n: e# I- O- v" w) H5 e                  NULL,: A, o/ e7 ^& r
                  NULL,7 E. b( H7 ]4 ?5 @6 ]3 a$ b$ |
                  &HandleCount,
  ?9 ~+ R: `5 e                  &HandleBuffer
3 C- A( C% {3 U' X) ]% x; a                  );- ]# Z6 }) y7 W' R3 C9 j
  if (EFI_ERROR (Status)) {4 R0 W# e- E# b# U8 V1 h# S5 U
    return Status;) Y5 ^3 |  k% f. l' [
  }
; s/ k( I4 x$ F( g6 N  p2 @4 p3 U5 f, j
  for (Index = 0; Index < HandleCount; Index++) {
* u8 K9 e  I& P( [0 i2 N2 w    Status = gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);# Z% E1 a& k' w5 r6 K
  }
回复

使用道具 举报

 楼主| 发表于 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-11-2 22:26 , Processed in 0.050854 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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