Subject: Re: [edk2] EFI_BLOCK_IO_PROTOCOL questions |
From: rangasai C |
Date: 8/26/2010 11:02 AM |
To: edk2-devel@lists.sourceforge.net |
The PCI Bus Driver will read the PE/COFF image from the Option ROM and start it during PCI enumeration. This is done by calling LoadImage() and StartImage().
A UEFI Driver that follows the UEFI Driver Model will only register a Driver Binding Protocol in the entry point of the driver, so no connect operations will be performed when the driver is started by the PCI Bus Driver.
The Boot Manager (BDS Phase) is responsible for connecting the devices required to establish console(s) and connect the devices required for booting. The Boot Manager does this through calls to ConnectController(). ConnectController() calls the Supported() and Start() functions in drivers that have registered Driver Binding Protocols.
The EFI Shell command “connect –r” will force all drivers to be connected to all devices.
If your driver is not showing up in the “drivers” command list, then the driver is not be loaded from the PCI Option ROM. If you manually load the driver from the shell, do you see your driver in the “drivers” list? If so, then you may have an issue with the PCI Option ROM format or programming.
When you load your driver from the Shell, are Block I/O Protocols produced? If not, then you may have some issues with your Supported() or Start() functions.
The “dh –d <HandleNumber>” is a useful command to see what devices a driver is managing or the state of a device that is being managed by a driver.
The “openinfo” command is useful for debugging the use of the OpenProtocol() API to make sure the state of your controller and any child devices follows the UEFI Spec.
Other useful commands are “devices” and “devtree”.
Best regards,
Mike
I am curious to know what would the host BIOS do when
1. It finds an option ROM for a bootable device, reads the first few LBAs and finds no valid data ( garbage). Will it try to still boot ? or try for some time and give up? or unload the driver ?
2. It finds an option ROM for a bootable device, tries to do a read but the Read() function returns a EFI_DEVICE_ERROR or EFI_NO_MEDIA ?
Thanks,
Sai
On Fri, Jul 30, 2010 at 10:24 AM, rangasai C <rangasaic@gmail.com> wrote:
I don't see my driver in the Shell, when I type "drivers" command in shell (and I am not sure why). Although, if I don't install the BLOCK_IO protocol ( i.e comment that line in the code). I do see my driver in the shell (ofcourse it won't do anything).
It's interesting to know that the driver won't be connected automatically. My understand was (and please correct me if I am wrong here), in general, during PCI enumeration, the BIOS allocates resources and checks for option ROMs. If it detects option ROM image (after verifying the signature bytes), it shadows the image and jumps to it's entry point and starts executing it. Is shadowing not similar to loading the image and executing not analogous to connecting the driver ?
On Fri, Jul 30, 2010 at 10:12 AM, Andrew Fish <afish@apple.com> wrote:
Can you see your driver in the shell drivers command?
You driver will not get connected (have its Supported() and Stop() functions called) automatically. It will only get connected in specific places, like when the shell loads, or if you do a connect command from the shell.
Andrew Fish
On Jul 30, 2010, at 10:08 AM, rangasai C wrote:
Tian,
I am using DUET only for obtaining shell environment. So basically I have formatted my USB key to a DUET disk to boot a 64bit shell..My driver, on the other hand, is built under EDK1.05 framework and doesn't use of the DUET files or libraries.
Also, I am able to see my debug messages otherwise. It's just that after I install the block Io Protocol, I don't see any messages that I have printed in my read() write(), reset() and Flush () functions.
Basically I can say that for some reason, the BIOS is not calling the functions of EFI_BLOCK_IO_PROTOCOL, even though the interface has been published by my driver.
Thanks,
Sai
On Thu, Jul 29, 2010 at 8:16 PM, Tian, Feng <feng.tian@intel.com> wrote:
Hi, Sai
Could you ensure the debug lib instance of your Pcie device driver is chosen correctly?
In DuetPkg, because of the size limitation, most of drivers are assigned to use BaseDebugLibNull instance which will cause no debug info output.
If you want to see the DEUBG message for your module, you should add such rule in DuetPkgX64.dsc
Path to your Pcie device driver/xxx.inf {
<PcdsFixedAtBuild>
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F
gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000042
<LibraryClasses>
DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf
}
Because your case is hard to root-cause by description, so using debug message to debugging seems the only wayJ
Thanks
Tian Feng
From: rangasai C [mailto:rangasaic@gmail.com]
Sent: Friday, July 30, 2010 7:47 AM
To: edk2-devel@lists.sourceforge.net
Subject: Re: [edk2] EFI_BLOCK_IO_PROTOCOL questions
I agree. These kind of issues is hard to explain or guess via emails but I will try to provide as much information I can.
Basically I am using EDK1.05 framework. I am installing the Driver Binding protocol as a global variable, in my driver entry point
return INSTALL_ALL_DRIVER_PROTOCOLS_OR_PROTOCOLS2 (
ImageHandle,
SystemTable,
&gMyDriverBinding,
ImageHandle,
&gMyDriverComponentName,
NULL,
NULL
);
Where gMyDriverBinding is a global variable
EFI_DRIVER_BINDING_PROTOCOL gMyDriverBinding = {
MyDriverBindingSupported,
MyDriverBindingStart,
MyDriverBindingStop,
0x15,
NULL,
NULL
};
and gMyDriverComponentName is also a global variable
EFI_COMPONENT_NAME2_PROTOCOL gMyDriverComponentName = {
MyDriverComponentNameGetDriverName,
MyDriverComponentNameGetControllerName,
LANGUAGE_CODE_ENGLISH
};
On Thu, Jul 29, 2010 at 4:15 PM, Andrew Fish <afish@apple.com> wrote:
OK Hard to guess at what is wrong? Are you allocating your protocol as a local variable on the stack so it no longer exists when your driver entry point returns?
Andrew Fish
On Jul 29, 2010, at 3:40 PM, rangasai C wrote:
You are right. Since this is a device driver, I am installing EFI_DRIVER_BINDING_PROTOCOL. The start() function first initializes the controller and before exiting, it installs EFI_BLOCK_IO_PROTOCOL. For debugging purpose I modified the Read(), Write(), Flush() and Reset() functions such that it just prints a debug message (something like DEBUG((EFI_D_ERROR,"Entered Read function \n")); ) and returns EFI_SUCCESS. I dont' see those messages in my hyperterminal.
On Thu, Jul 29, 2010 at 3:33 PM, Andrew Fish <afish@apple.com> wrote:
You should be installing an EFI_DRIVER_BINDING_PROTOCOL and the Start() function should install an instance of the EFI_BLOCK_IO protocol.
Sent from my iPad
On Jul 29, 2010, at 2:19 PM, rangasai C <rangasaic@gmail.com> wrote:
> Hi All,
> I have written a PCIe device driver which, after initializing the controller, installs a EFI_BLOCK_IO protocol. I don't have a debugger but with DEBUG() macro and DUET, I could verify that Initialization code works and gBS->InstallMultipleProtocolInterfaces () returns Success after I install (or produce) EFI_BLOCK_IO protocol. At this point I would expect that the host BIOS should call the EFI_BLOCK_IO protocol function (Read(), Write(), Reset() and Flush()). However, I see the system hangs. The last message I see in my hyper terminal is the return status of gBS->InstallMultipleProtocolInterfaces, which is EFI_SUCCESS.
>
> Has anyone seen this kind of behavior ? Is there anything, I should be doing here ?.. By the way, I tested my driver by loading through the shell before I converted into option ROM. It works fine in the shell environment.
>
> I am not sure where to look in order to debug this issue !
>
> Thanks in advance.
> Regards,
> Sai> ------------------------------------------------------------------------------
> The Palm PDK Hot Apps Program offers developers who use the
> Plug-In Development Kit to bring their C/C++ apps to Palm for a share
> of $1 Million in cash or HP Products. Visit us here for more details:
> http://p.sf.net/sfu/dev2dev-palm
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel
------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel
------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel
------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel
------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel
------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel
------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel
------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel
------------------------------------------------------------------------------ Sell apps to millions through the Intel(R) Atom(Tm) Developer Program Be part of this innovative community and reach millions of netbook users worldwide. Take advantage of special opportunities to increase revenue and speed time-to-market. Join now, and jumpstart your future. http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________ edk2-devel mailing list edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel