找回密码
 加入计匠网
搜索
热搜: BIOS ACPI CPU Windows
查看: 10913|回复: 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,代码如下:
7 C" I# O; _( k6 s1 F( ~& K EFI_BREAKPOINT( );3 r2 ~/ f2 B" L7 e+ _7 T! e
  Status = gBS->OpenProtocol (
7 n' n$ k0 F5 {$ }                  Controller,
5 E5 W6 a- V1 w7 _& Z                  &gEfiPciIoProtocolGuid,
& I2 ]1 ~& e. n; B' L& C3 S                  (VOID **) &PciIo,3 u2 H& L- t5 R% t% i2 j5 Z% |. q1 c
                  This->DriverBindingHandle,
7 L) M5 P8 D0 t& Y                  Controller,
- F' b& ?6 s/ I) G$ q% f0 D                  EFI_OPEN_PROTOCOL_BY_DRIVER9 w( B3 I( C: P% s
                  );4 s( `& M2 S" D" W" O  b, f, A
  if (EFI_ERROR (Status)) {
! L4 B* m7 m6 e5 D0 z) u    return Status;( r$ c! f2 j# a; S2 s$ z+ W
1:在NT32下打开一个PCIIO protocal,应该是与硬件没有任何关系的,为什么却fail?用VS studio调试跟踪发现,其实是在执行handle.c 文件中的CoreGetProtocolInterface( )函数时,在 Look at each protocol interface for a match时没有找到匹配protocal返回一个unsupport状态值。
; F1 t5 O' z8 _/ X  a2:当我在用EDK中提供的AtapiScsiPassThruDriverBindingSupported( )测试时,同样会出现此现象。
. ~0 I& g* ]8 d5 ~请问:
" A( I, z+ L4 c2 p当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。
" |; t8 z/ }# l& a
. v6 X% b8 F- z6 H* d对一个想管理某种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).3 }  P* _7 B, E) d
8 y) S- P# k5 y: b  F9 Z! n
UEFI 规范中connect all controller的示例程序片断:+ ?: _0 N3 D. G; \
  Status = gBS->LocateHandleBuffer (
" ?& w) V) P6 R+ P9 y                  AllHandles,
9 ]$ j! f# h  m2 q" u* ~; O                  NULL,
+ u7 H- M. W) M                  NULL,! c* w' `& v7 H8 U5 S/ A
                  &HandleCount,
" Q7 h5 ?& r& {4 K% U- D                  &HandleBuffer9 b. _6 i) ?/ V) `' S" C: |% n' w
                  );
; @* I5 v) Y  z) ?% \  if (EFI_ERROR (Status)) {; y/ ~& A5 L  K) ?2 c
    return Status;% ~) L' T7 J+ b
  }
; V" a; }+ I( U* R) p2 e
9 z$ |, t8 s7 {1 s  for (Index = 0; Index < HandleCount; Index++) {
  y' L* d' g! `5 k. d    Status = gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);; X+ R' S+ g/ P0 ~9 L: p+ G& L) k( 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, 2026-6-4 22:30 , Processed in 0.061609 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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