找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 10391|回复: 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,代码如下:
- E/ `+ P/ y4 ?* } EFI_BREAKPOINT( );! _$ N8 \( L1 H
  Status = gBS->OpenProtocol (+ w4 `# f8 @) T0 ^
                  Controller,! B& Q3 n9 f9 g: i
                  &gEfiPciIoProtocolGuid,
- D2 T( e: P2 n                  (VOID **) &PciIo,
1 _0 k$ M, D- m                  This->DriverBindingHandle,; [9 A, h! H" L6 H7 t! W
                  Controller,7 k& d3 `. [( k- U7 R8 A  |
                  EFI_OPEN_PROTOCOL_BY_DRIVER
0 b) R, u. m. Q: X6 Z$ x                  );
$ v1 E  d4 h5 M# q" z  if (EFI_ERROR (Status)) {
" B8 ]  R$ P6 g7 r* O) u    return Status;" I3 R3 D" {! Q' k
1:在NT32下打开一个PCIIO protocal,应该是与硬件没有任何关系的,为什么却fail?用VS studio调试跟踪发现,其实是在执行handle.c 文件中的CoreGetProtocolInterface( )函数时,在 Look at each protocol interface for a match时没有找到匹配protocal返回一个unsupport状态值。
3 e! k6 A3 G2 @3 K, T# A1 k2:当我在用EDK中提供的AtapiScsiPassThruDriverBindingSupported( )测试时,同样会出现此现象。
% Q" R  w; W9 r% Y4 X请问:
  M6 j1 y  ^' B1 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。
0 Y$ c6 t. i: X- G, R1 ]- x0 v
" |$ X1 U5 U) s. s. }* K对一个想管理某种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).; _/ a/ L: ]5 e9 z/ P! ~
! \  o* S2 U% k: b
UEFI 规范中connect all controller的示例程序片断:2 x0 \) D! R- g5 k+ ~5 b
  Status = gBS->LocateHandleBuffer (
1 m, s* N; W% X' w' C+ {- y                  AllHandles,0 H/ D- b* |& S; K; `
                  NULL,
7 y4 b% V2 I* z) ^0 @                  NULL,
. M* j' b) _. A. q  H                  &HandleCount,
. v5 j4 u3 |3 }9 c1 c                  &HandleBuffer
1 u1 f8 T! Z) ~8 p, A% R7 E                  );, P* O* h, |% k9 U7 F, ?. @
  if (EFI_ERROR (Status)) {
6 l% c" k8 t: H/ c4 f    return Status;- G- E8 r, X7 s+ u! q6 ]
  }
8 ]' W; V; ^2 Q# J8 t
' L0 P+ \% y0 s1 h! z  l  for (Index = 0; Index < HandleCount; Index++) {
1 J# a' }9 I* D# a! I    Status = gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);+ K1 A) j: J" ?; `. g) I+ Q* I
  }
回复

使用道具 举报

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

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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