找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 10405|回复: 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,代码如下:
3 Z7 n8 ?  l2 ~5 i; t/ y EFI_BREAKPOINT( );
8 A6 g  O' \8 r' G0 A  Status = gBS->OpenProtocol (5 R! Z4 k3 w3 }3 c" P+ k' s$ s& r
                  Controller,, x# Y! M3 R2 O3 N4 R! M/ z
                  &gEfiPciIoProtocolGuid,
( @. I0 E2 L0 \5 C3 [- l5 u                  (VOID **) &PciIo,* y- ?% c1 S! A8 x
                  This->DriverBindingHandle," ^) S3 c6 _' _* A3 l0 u
                  Controller,1 ~2 X/ x. h5 ^6 L7 L( s) r
                  EFI_OPEN_PROTOCOL_BY_DRIVER2 A2 |! ^$ e8 b' o2 |  A  l! s
                  );, e2 @/ [# c" X( X, S, h+ K
  if (EFI_ERROR (Status)) {
1 H2 O% z+ S8 U8 f  }9 q6 y/ W/ S$ D; _    return Status;5 @  {; A4 N8 ], X6 P) h0 O% P( V
1:在NT32下打开一个PCIIO protocal,应该是与硬件没有任何关系的,为什么却fail?用VS studio调试跟踪发现,其实是在执行handle.c 文件中的CoreGetProtocolInterface( )函数时,在 Look at each protocol interface for a match时没有找到匹配protocal返回一个unsupport状态值。) K1 s0 E4 t! V1 g+ T
2:当我在用EDK中提供的AtapiScsiPassThruDriverBindingSupported( )测试时,同样会出现此现象。' X/ X$ B1 I; w' H6 z, I
请问:
' G; B" o+ ?8 K当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。
$ M# J, d# {& S* c) i0 i% o3 ]  C, h8 N& ~1 [" F9 k9 F$ g  I
对一个想管理某种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).
, h. o* `1 e: l! d2 ~) a9 ?
( ]% C0 o' [; Z7 MUEFI 规范中connect all controller的示例程序片断:+ V0 q  ?/ l9 m
  Status = gBS->LocateHandleBuffer (
3 H2 I0 e$ x5 W, c2 A2 w                  AllHandles,
! `2 L; z2 Y8 s/ U                  NULL,
' Z/ n% V8 `7 @+ F) C                  NULL,
. N# J/ m: N, D/ G  E/ m                  &HandleCount,7 n1 ^( `: V2 X- d: g
                  &HandleBuffer
# u) c5 F" {- G# d2 c9 H                  );
2 m7 x6 H9 g. ]& Y! ?  if (EFI_ERROR (Status)) {) y+ s$ ?# T0 ?
    return Status;& I; m$ o# _4 j! |) w
  }
/ z( b2 W' e4 U2 X8 P+ \. U1 ]) [& ]+ x3 I. T
  for (Index = 0; Index < HandleCount; Index++) {, G! S4 ~3 m8 X$ Y8 ]& M4 h
    Status = gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);: r- E! L5 \- u3 S( P
  }
回复

使用道具 举报

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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-6-17 15:08 , Processed in 0.116250 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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