From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by mx.groups.io with SMTP id smtpd.web10.4749.1587643031860480251 for ; Thu, 23 Apr 2020 04:57:12 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=rnQU0tu5; spf=pass (domain: nuviainc.com, ip: 209.85.221.68, mailfrom: leif@nuviainc.com) Received: by mail-wr1-f68.google.com with SMTP id j1so6519126wrt.1 for ; Thu, 23 Apr 2020 04:57:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Fkm7Q4i22u9G7RCVGX+3WSZwKMzhHi9TuQvRa/NRwN4=; b=rnQU0tu5Ov3jcpbV1knb9vFNNTXMiBxIDHxlJ5xihs4fG6ySXejXX4Fmd+10bfV70O yk4Rmj0WP1FncwIyeHOUObQZZ19uRNsG8YH+bpmszPVCSS35txZ9b8mmqHR23GtMWzJH XtwRV/Jwa0x78QLwa53JcCGSHcE6+2WSdOc2MMrADdclSSeuntZthyzuxIVamecFMK1G b1SRNxoGZJZiHg2O5QaG6NhOZrB+fO8q+mvuyTK39iFXEJyQnfc6F2kbpuir9938MZIS Dl66xmPoh+azIBqin4J27EnrSKXgGsDJn8fw5qvWw/nsuJ1kLw1cnNs1VqvSUWNHQUKH KgRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Fkm7Q4i22u9G7RCVGX+3WSZwKMzhHi9TuQvRa/NRwN4=; b=IwEnsrz9Maw8NavYJY1xWgl4sqoif3/YXjVZ/dfrq6Ro4gVUpnz7xyyNYy8AX0yelD DzOGVczbYsw/RNHjA7cyGGTgwq/ildF2khBrH07aL2TH//m934lwLXzHptqJ4GXwT/97 wfyCHKbRZ/PwhqJ3EDetHy2Xift+pFP15B6JtwxprvhY9beXxHKax5CPF2cipCbjhG7k c/8sySZK1209XK3R6ph1NnzHaWzT/vdtB7ssifxoFDgNJir8ZCbrCdQHTAuA+X42B88j MCYZ0aPjvjv5dwWigf5ZuKIz61BCGFsiVXP/0qPriG+VuSYdAScOJ6C4ExxnY7jtUxvJ aUFw== X-Gm-Message-State: AGi0PubUPSYT/pc72UsIVtHMk6T/R1m3HQfcTameZVGBof4kIgVst0bV /1zLywmMzaB6/ISxzzL6KZDfRg== X-Google-Smtp-Source: APiQypJiHVOHmw6TNnrZcSLLNbejSW/iODtSR68EGusBRMBWA3Klb8J5k0H5SVtpIEEKl8VvHLdd/w== X-Received: by 2002:adf:f844:: with SMTP id d4mr4490950wrq.362.1587643030406; Thu, 23 Apr 2020 04:57:10 -0700 (PDT) Return-Path: Received: from vanye ([2001:470:1f09:12f0:b26e:bfff:fea9:f1b8]) by smtp.gmail.com with ESMTPSA id n2sm3761130wrq.74.2020.04.23.04.57.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Apr 2020 04:57:09 -0700 (PDT) Date: Thu, 23 Apr 2020 12:57:07 +0100 From: "Leif Lindholm" To: "Pankaj Bansal (OSS)" Cc: Meenakshi Aggarwal , Michael D Kinney , "devel@edk2.groups.io" , Varun Sethi , Samer El-Haj-Mahmoud , Jon Nettleton , Ard Biesheuvel Subject: Re: [PATCH edk2-platforms v3 16/24] Silicon/NXP: Add Chassis2 Package Message-ID: <20200423115707.GB14075@vanye> References: <20200415121342.9246-1-pankaj.bansal@oss.nxp.com> <20200415121342.9246-17-pankaj.bansal@oss.nxp.com> <20200423102714.GW14075@vanye> MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Apr 23, 2020 at 11:38:12 +0000, Pankaj Bansal (OSS) wrote: > > > + > > > + @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) If this is a problem (and I recall Ard pointing out some shortcomings in the dependency handling in the past), we can solve this with an explicit initialisation call in the SoC or platform init code. / Leif > > > 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 > > >