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.4866.1587643541659756499 for ; Thu, 23 Apr 2020 05:05:42 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=UFFfN+6t; spf=pass (domain: nuviainc.com, ip: 209.85.221.68, mailfrom: leif@nuviainc.com) Received: by mail-wr1-f68.google.com with SMTP id x18so6548328wrq.2 for ; Thu, 23 Apr 2020 05:05:41 -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=ruPUUsgapDgDtSX63mhpm4oofKuVuPaWAYpqYKaeza8=; b=UFFfN+6tixUyHdI0Sxt/qbkuRr3jFfxvXtIMYaXwUIKb3FvhBGeBSgBbCz77tWf4YQ 5uIKvVyRkW+wDOPC+jtDlaldUMkg3SmQo/F9ZR3TcCUE/ObfWxqa4bDUoEr3yDUMAgpI 1E82/jKsRKbp4C5/nd5lFvMasGwQhtte13mxWWSbVwCQIEkyMFnkuegC9YcaPzJtRDp9 Dy1C3yLmH3epufwNrn+RgZx3dtzW5vsybt6P2Uws5QekSEKD3zC7saxNMDQp1DvWVTh7 6suIFOKqCLWQ9A+oBylo1DTRGi2QWMoXxvgGkkvZEKplHvDmaDun4KfZarx6qdbbGwzm VpYQ== 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=ruPUUsgapDgDtSX63mhpm4oofKuVuPaWAYpqYKaeza8=; b=Z1w/N2/i0XWffGh56nlmy4gyflW+vGN9XRV43J6Sbe226+VhUiJKdkVM8kPS/SZ1JK ib5cXgGn0wPMgKisGO7PdxeUahvtg5XxOHKDyalBK/nvBg0PCB7SfxWhyHzktsuTGBMG kxYy78WETySSX5/UM6q0IVHPyq1ZXH4eA4BbVzGNFaCLb8qIXFK0YpXOFozVTg8o/JtJ yCHc8pzQlxnga90uQI9OWaEKqzX1DQfmyQDUKqAW3w9xh4DeVmC+LgqZSOtwiBsgeW5w p7B+INnktQLzAjNx6UJE1NtnXpuYndNq+law2Too5itaOTubTR40ASDgLc9tN0a3RUCX 0N2A== X-Gm-Message-State: AGi0PuZhb65ZSFTwrtxgRf3amppMaHyiP/u9HDa+Tm5WuwF3bkWL5tb6 sYHhKBznNykUiMAJK7BsQlIi2w== X-Google-Smtp-Source: APiQypIi8N/t4MselqMX0lBFEzzKxyXvLNb6YYOhE2rjkX8AxQRFGVhR1xcRGaixc0suHlz6VOYCfg== X-Received: by 2002:a05:6000:1044:: with SMTP id c4mr4919095wrx.57.1587643540099; Thu, 23 Apr 2020 05:05:40 -0700 (PDT) Return-Path: Received: from vanye ([2001:470:1f09:12f0:b26e:bfff:fea9:f1b8]) by smtp.gmail.com with ESMTPSA id n131sm3495864wmf.35.2020.04.23.05.05.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Apr 2020 05:05:39 -0700 (PDT) Date: Thu, 23 Apr 2020 13:05:37 +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: <20200423120537.GC14075@vanye> References: <20200415121342.9246-1-pankaj.bansal@oss.nxp.com> <20200415121342.9246-17-pankaj.bansal@oss.nxp.com> <20200423102714.GW14075@vanye> <20200423115707.GB14075@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 12:02:16 +0000, Pankaj Bansal (OSS) wrote: > > > > -----Original Message----- > > From: Leif Lindholm > > Sent: Thursday, April 23, 2020 5:27 PM > > To: Pankaj Bansal (OSS) > > Cc: Meenakshi Aggarwal ; Michael D Kinney > > ; devel@edk2.groups.io; Varun Sethi > > ; Samer El-Haj-Mahmoud > Mahmoud@arm.com>; Jon Nettleton ; Ard Biesheuvel > > > > Subject: Re: [PATCH edk2-platforms v3 16/24] Silicon/NXP: Add Chassis2 > > Package > > > > 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. > > You mean put ChassisLibConstructor() call in SerialPortInitialize () ? Or before the call to SerialPortInitialize in ChassisInit. / Leif > > > > > / > > 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 > > > > > > >