public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Tomas Pilar (tpilar)" <tpilar@solarflare.com>
To: "Kinney, Michael D" <michael.d.kinney@intel.com>,
	"Gao, Liming" <liming.gao@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: Re: FmpDeviceLib
Date: Wed, 28 Nov 2018 10:43:34 +0000	[thread overview]
Message-ID: <e3c883fc-2ac5-7ab3-e111-5b700415482e@solarflare.com> (raw)
In-Reply-To: <E92EE9817A31E24EB0585FDF735412F5B8B37115@ORSMSX113.amr.corp.intel.com>

Hi Mike,

Thanks for looking at this. I was actually thinking of how I could contribute. I was thinking of drafting the following patches:

1. Move FmpDxe data storage into heap allocated FMP_DATA struct, retrieve using standard CR against the protocol treatment. Allocated by FmpInstall(). This might need registering FmpRemove() however. Alternatively register a ExitBootServices callback that uninstalls the FMP.
2. Create FmpDeviceInstanceLib prototype that works like FmpDeviceLib but passes a context parameter to each function.
3. Implement FmpDeviceInstanceGlobal library that pulls in FmpDeviceLib and produces a FmpDeviceInstanceLib
4. Change over FmpDxe from FmpDeviceLib to depend on FmpDeviceInstanceLib.

This is not particularly urgent, but we are trying to implement FMP for our optionROM driver and it would be nice to be able to use the upstream cleanly rather than forking it in our driver.

If you think the way forward seems okay, I am happy to put in the work.

Cheers,
Tom

On 28/11/2018 01:15, Kinney, Michael D wrote:
> Tom,
>
> Thanks for noticing this issue.  I need a little 
> time to evaluate this use case and see what changes
> are required to make this work for a UEFI driver
> that manages many controllers.
>
> Thanks,
>
> Mike
>
>> -----Original Message-----
>> From: edk2-devel [mailto:edk2-devel-
>> bounces@lists.01.org] On Behalf Of Tomas Pilar (tpilar)
>> Sent: Tuesday, November 27, 2018 7:29 AM
>> To: Gao, Liming <liming.gao@intel.com>; edk2-
>> devel@lists.01.org
>> Subject: Re: [edk2] FmpDeviceLib
>>
>> Okay, so I just noticed that FmpDxe is full of module
>> globals including the image descriptor, so it
>> necessarily requires that the driver that includes it as
>> a library can only ever control one controller.
>>
>> Cheers,
>> Tom
>>
>> On 27/11/2018 15:23, Tomas Pilar (tpilar) wrote:
>>> On 27/11/2018 14:33, Gao, Liming wrote:
>>>> Tom:
>>>>   FmpDeviceLib can use UEFI driver model/driver
>> binding protocol so it can install FMP on its device
>> handle during the BDS/Device connection phase. It can
>> implement RegisterFmpInstaller() to install FMP protocol
>> in its device handle. In this way, FmpDeviceLib is like
>> UEFI driver with UEFI driver binding protocol.
>>>> Thanks
>>>> Liming
>>> Hi Liming,
>>>
>>> Sure, so now I can install FMP onto my
>> ControllerHandle. Say that someone gets the FMP and
>> calls GetImageSize. The FmpDxeLib does some checks and
>> then it calls FmpDeviceLibGetImageSize() with no context
>> parameter. This method is supposed to be implemented by
>> me, the driver writer, but how is the code in this
>> method meant to know which Controller are we getting the
>> image size from?
>>> So maybe I can define some module globals, declare
>> them in a cross include file, include that in my driver
>> and and have the driver populate the module globals
>> during probe. This immediately limits the usefulness by
>> requiring that each driver only ever drives one
>> controller.
>>> And then you consider how to do a SetImage without
>> being even given the Handle of the Controller. Do you
>> stuff the controller handle into a module global
>> parameter that gets populated during the BDS phase?
>>> I guess you could enumerate all FMP instances, see
>> which one of them advertises your ImageTypeId and get
>> the handle that the FMP is installed on that way. But
>> that seems rather insane and would cause issues if you
>> have two of the same device in the platform, unless you
>> check the HardwareInstance as well? This seems insane.
>>> Cheers,
>>> Tom
>>>
>>>>> -----Original Message-----
>>>>> From: edk2-devel [mailto:edk2-devel-
>> bounces@lists.01.org] On Behalf Of Tomas Pilar (tpilar)
>>>>> Sent: Tuesday, November 27, 2018 9:26 PM
>>>>> To: edk2-devel@lists.01.org
>>>>> Subject: [edk2] FmpDeviceLib
>>>>>
>>>>> Hi all,
>>>>>
>>>>> I am looking at using FmpDxeLib so I need to
>> implement the FmpDeviceLib. However, it seems like the
>> library functions do not take any
>>>>> private struct as a parameter, so I am struggling to
>> figure out how to read information off the hardware.
>> FmpDxe does not even pass its
>>>>> created protocol instance when calling the library
>> functions, leading me to believe that the only way to do
>> this is to assign a pointer to
>>>>> private struct during library construction, but that
>> means that a driver that uses the code can only ever
>> service a single controller.
>>>>> Can you offer any insights?
>>>>>
>>>>> Cheers,
>>>>> Tom
>>>>> _______________________________________________
>>>>> edk2-devel mailing list
>>>>> edk2-devel@lists.01.org
>>>>> https://lists.01.org/mailman/listinfo/edk2-devel
>> _______________________________________________
>> edk2-devel mailing list
>> edk2-devel@lists.01.org
>> https://lists.01.org/mailman/listinfo/edk2-devel



      reply	other threads:[~2018-11-28 10:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-27 13:25 FmpDeviceLib Tomas Pilar (tpilar)
2018-11-27 14:33 ` FmpDeviceLib Gao, Liming
2018-11-27 15:23   ` FmpDeviceLib Tomas Pilar (tpilar)
2018-11-27 15:28     ` FmpDeviceLib Tomas Pilar (tpilar)
2018-11-28  1:15       ` FmpDeviceLib Kinney, Michael D
2018-11-28 10:43         ` Tomas Pilar (tpilar) [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e3c883fc-2ac5-7ab3-e111-5b700415482e@solarflare.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox