Re: [edk2] Where are the realize source code of Protocol in UDK2010

Subject: Re: [edk2] Where are the realize source code of Protocol in UDK2010

From: Andrew Fish <>

To: linyao_71 <>

Date: 2013-01-04 14:29:53

On Jan 4, 2013, at 4:30 AM, <> wrote:

Hi Andrew,
Thank you for your reply!
I have noticed that only driver can produce protocol,

Not strictly true as the shell, an application produces protocols too. In EFI the only difference between an application and a driver is the applications memory is freed after it returns. So an application can only publish a protocol for the length of time that it is running. This works in the case of the shell, but not in general. 

but how to locate the dirver (DXE Driver.etc) by protocol GUID?
If the drivers follow the EFI driver model (produces a Driver Binding Protocol) you can look up which driver produced the protocol and there are shell commands that help with this.  But I don't think this is your case. 
What's more, we all know that APs are produced by Initial DXE Driver, do you have some clear ubderstand about APs?

The APs (Architectural Protocols) are the set of platform specific services that are required to produce the EFI Boot and Runtime Services. 

If you are trying to figure out what is happening on a give boot the best thing to do is turn on DEBUG_INFO DEBUG prints in the DXE Core. This will cause a debug print every time a protocol is registered, see

DEBUG_INFO is set in the DSC file (this is an example from the EmulatorPkg):


// Declare bits for PcdDebugPrintErrorLevel and the ErrorLevel parameter of DebugPrint()
#define DEBUG_INIT      0x00000001  // Initialization
#define DEBUG_WARN      0x00000002  // Warnings
#define DEBUG_LOAD      0x00000004  // Load events
#define DEBUG_FS        0x00000008  // EFI File system
#define DEBUG_POOL      0x00000010  // Alloc & Free's
#define DEBUG_PAGE      0x00000020  // Alloc & Free's
#define DEBUG_INFO      0x00000040  // Informational debug messages
#define DEBUG_DISPATCH  0x00000080  // PEI/DXE/SMM Dispatchers
#define DEBUG_VARIABLE  0x00000100  // Variable
#define DEBUG_BM        0x00000400  // Boot Manager
#define DEBUG_BLKIO     0x00001000  // BlkIo Driver
#define DEBUG_NET       0x00004000  // SNI Driver
#define DEBUG_UNDI      0x00010000  // UNDI Driver
#define DEBUG_LOADFILE  0x00020000  // UNDI Driver
#define DEBUG_EVENT     0x00080000  // Event messages
#define DEBUG_GCD       0x00100000  // Global Coherency Database changes
#define DEBUG_CACHE     0x00200000  // Memory range cachability changes
#define DEBUG_VERBOSE   0x00400000  // Detailed debug messages that may significantly impact boot performance
#define DEBUG_ERROR     0x80000000  // Error

So you can see the EmulatorPkg has DEBUG_INFO and DEBUG_ERROR DEBUG prints turned on, and other DEBUG prints turned off. To be clear these match the DEBUG() macros in the code. 

Justin Lin
 2013-01-04 02:30
 Re: [edk2] Where are the realize source code of Protocol in UDK2010

On Jan 3, 2013, at 8:13 AM, <> wrote:

Hi All,
I got a trouble during learing UEFI that when I tried to retrive more information about protocols defined in the path of MdePkg\Include\Protocol, I only see the header files but not find the corresponding file of *.c

Think of the protocol .h file as the public class definition.  The EFI_GUID global extern in the .h file is the name that is set to the #define *_PROTOCOL_GUID value. 

So for example if you look at you can search the code base for gEfiBlockIoProtocolGuid to see the producers and consumers of Block IO protocol.

The modules that produce or consume the Block IO protocol will include gEfiBlockIoProtocolGuid in the [Protocols] section of their INF file and this will cause the build generated AutoGen.c file to contain:

Producers will use gBS->InstallProtocolInterface() or gBS->InstallMultipleProtocolInterfaces() to register the protocol instance(s) that they produce. 
Consumers will use gBS->OpenProtocol(), gBS->HandleProtocol(), or gBS->LocolProtocol() to discover the protocol instance. 

In both the consumers and producers you will see &gEfiBlockIoProtocolGuid passed as an argument.


Andrew Fish

Could you offer me some information about this question?!
I am looking forward to your reply!
Thanks & Best Regards!
Justin Lin
From TJ China
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
edk2-devel mailing list