On 09/30/16 18:36, Cohen, Eugene wrote:
> Laszlo,
> 
>> As far as I know:
>> - the DXE and SMM protocol databases are distinct,
>> - the same protocol GUID may or may not be installed (on one or more)
>> handle(s) in either,
>> - even if a protocol GUID exists uniquely in exactly one of those databases,
>> the locator function would have to return which database the GUID was
>> found.
>>
>> My point is that every wrapper function that returns a protocol interface (or
>> several protocol interfaces), or handles, each such return value will likely
>> have to be qualified with the database where it was found.
> 
> The intent here is to only search the UEFI DB from a DXE/UEFI driver
> and the SMM DB from an SMM driver and not to cross between.  So which
> protocol DB is searched is purely a function of the module type (i.e.
> what instance of the ProtocolLib it was linked against).  This is
> analogous to what is done with MemoryAllocationLib which either
> allocates from the UEFI memory pools for UEFI/DXE modules
> (UefiMemoryAllocationLib instance) or from the SMM memory pools for
> SMM modules (SmmMemoryAllocationLib).
> 
> Sorry I wasn't more clear initially.

I believe I understood this. However, in the entry point function of an
SMM driver, it is permitted to look for, and invoke member functions of,
both SMM and DXE protocols [1]. If the library instance that is supposed
to be linked into SMM drivers is tied to the SMM protocol database
solely, then it won't be able to serve the use case when an SMM driver
looks for a DXE protocol in its entry point function.

(Note I'm not speaking about "Combination SMM/DXE Drivers", just purely
SMM drivers.)

[1] "Vol4_SMM_1_4_Errata_A.pdf", section "1.7 SMM Driver Initialization":

    During SMM Driver initialization, SMM Drivers have access to two
    sets of protocols: UEFI and SMM. UEFI protocols are those which are
    installed and discovered using the UEFI Boot Services. UEFI
    protocols can be located and used by SMM drivers only during SMM
    Initialization. SMM protocols are those which are installed and
    discovered using the System Management Services Table (SMST). SMM
    protocols can be discovered by SMM drivers during initialization
    time and accessed while inside of SMM.

    [...]

... Actually, I believe this applies even to MemoryAllocationLib. In an
SMM driver, the SMM-tailored MemoryAllocationLib instance only allocates
SMRAM, which is mostly fine. However, it is unsuitable for allocating
(for example) EfiBootServicesData type memory, even though that too is
permitted in the SMM driver's entry point function, I think. For that,
gBS->AllocatePool() or gBS->AllocatePages() have to be called explicitly.

Thanks
Laszlo
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to