[edk2-devel] [PATCH edk2-platforms v3 16/24] Silicon/NXP: Add Chassis2 Package

Pankaj Bansal pankaj.bansal at nxp.com
Thu Apr 23 11:38:12 UTC 2020


> > +
> > +  @return The value read.
> > +**/
> > +UINT32
> > +EFIAPI
> > +DcfgRead32 (
> > +  IN  UINTN     Address
> > +  )
> > +{
> > +  MMIO_OPERATIONS_32  *DcfgOps;
> > +
> > +  DcfgOps = GetMmioOperations32 (FeaturePcdGet (PcdDcfgBigEndian));
> > +
> > +  return DcfgOps->Read32 (Address);
> > +}
> 
> The intended usage model for IoAccessLib is to retrieve the function
> pointer struct once and then always refer to it. Since this is a
> library, we could have a CONSTRUCTOR function (specified in the .inf)

I had thought of this, but decided against it because of this reason:
    The order of Library constructor call for a module cannot be guaranteed.
    https://edk2.groups.io/g/devel/message/57254  is an good example of this.
    BaseDebugLibSerialPortConstructor would need to depend on ChassisLibConstructor,
    to retrieve the UART clock frequency. If the constructor calls are not guaranteed, BaseDebugLibSerialPortConstructor
    would fail and it would cause ASSERT due to ASSERT_RETURN_ERROR (Status)

> and do something like:
> 
> STATIC MMIO_OPERATIONS mDcfgOps;
> 
> /**
>   Read Dcfg register
> 
>   @param  Address The MMIO register to read.
> 
>   @return The value read.
> **/
> UINT32
> EFIAPI
> DcfgRead32 (
>   IN  UINTN     Address
>   )
> {
>   return mDcfgOps->Read32 (Address);
> }
> 
> /**
>   Write Dcfg register
> 
>   @param  Address The MMIO register to write.
>   @param  Value   The value to write to the MMIO register.
> 
>   @return Value.
> 
> **/
> UINT32
> EFIAPI
> DcfgWrite32 (
>   IN      UINTN                     Address,
>   IN      UINT32                    Value
>   )
> {
>   return mDcfgOps->Write32 (Address, Value);
> }
> 
> ...
> 
> /**
>   The constructor function initializes the IoAccessLib
>   function pointer structure.
> 
>   @retval RETURN_SUCCESS   The constructor always returns EFI_SUCCESS.
> 
> **/
> EFI_STATUS
> EFIAPI
> ChassisLibConstructor (
>   VOID
>   )
> {
>   mDcfgOps = GetMmioOperations (FeaturePcdGet (PcdDcfgBigEndian));
> 
>   return EFI_SUCCESS;
> }
> 
> /
>     Leif
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#57960): https://edk2.groups.io/g/devel/message/57960
Mute This Topic: https://groups.io/mt/73008827/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-





More information about the edk2-devel-archive mailing list