From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web11.1282.1613523497842379018 for ; Tue, 16 Feb 2021 16:58:18 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=DoMOw6XJ; spf=pass (domain: linux.microsoft.com, ip: 13.77.154.182, mailfrom: mikuback@linux.microsoft.com) Received: from [10.124.238.202] (unknown [131.107.174.202]) by linux.microsoft.com (Postfix) with ESMTPSA id C01D620B6C40; Tue, 16 Feb 2021 16:58:16 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com C01D620B6C40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1613523496; bh=ziRU6CX3PiedUIN1r5LxFnfu2Mb4Gd1R1oFRSJZmhJ8=; h=From:Subject:To:Date:From; b=DoMOw6XJBky2JarSzI/Sw8bVbYfpCbEdRULS/JeLEDpwbUDbVR1t4ZAi8yXk9l/cZ siiaZs8Zxx6HfqFE/sr/sQli69zaCw9jUq9+6gy2Mi0f5CO1hiu5bMcxP9VfAnXTSt cAcqNjBtFzvMZ+bVLEvAyd2Jm9Xo6TI3O4Abdy2A= From: "Michael Kubacki" Subject: [edk2-platforms][RFC] SpiFlashCommonLib Refactor To: "devel@edk2.groups.io" , ray.ni@intel.com, rangasai.v.chaganty@intel.com, chasel.chiu@intel.com, nathaniel.l.desimone@intel.com, heng.luo@intel.com, prince.agyeman@intel.com, gaoliming@byosoft.com.cn, "Dong, Eric" Message-ID: <2a2a1cc0-3de9-fbd5-1bfb-eb5dbc9d1bc6@linux.microsoft.com> Date: Tue, 16 Feb 2021 16:58:16 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Hello, I'm planning to submit support for Standalone MM in SpiFlashCommonLib soon. Currently, there's quite a bit of duplication with SpiFlashCommonLib. I would like to have this Standalone MM support be available in as consistent of a location as possible so I'd like to see if there is anything I can do to help clean this up in the early part of the patch series. The library interface is currently defined in the following header files: 1. Platform\Intel\MinPlatformPkg\Include\Library\SpiFlashCommonLib.h 2. Silicon\Intel\SimicsIch10Pkg\Include\Library\SpiFlashCommonLib.h 3. Silicon\Intel\KabylakeSiliconPkg\Pch\Include\Library\SpiFlashCommonLib.h 4. Silicon\Intel\CoffeelakeSiliconPkg\Pch\Include\Library\SpiFlashCommonLib.h Instances of SmmSpiFlashCommonLib implementation exist in a mix of platform and silicon packages: 1. Silicon\Intel\SimicsIch10Pkg\Library\SmmSpiFlashCommonLib\SmmSpiFlashCommonLib.inf 2. Platform\Intel\TigerlakeOpenBoardPkg\Library\SmmSpiFlashCommonLib\SmmSpiFlashCommonLib.inf 3. Silicon\Intel\KabylakeSiliconPkg\Pch\Library\SmmSpiFlashCommonLib\SmmSpiFlashCommonLib.inf 4. Silicon\Intel\CoffeelakeSiliconPkg\Pch\Library\SmmSpiFlashCommonLib\SmmSpiFlashCommonLib.inf 5. Platform\Intel\MinPlatformPkg\Flash\Library\SpiFlashCommonLibNull\SpiFlashCommonLibNull.inf The library class is currently consumed in the following INFs: 1. Platform\Intel\MinPlatformPkg\Flash\SpiFvbService\SpiFvbServiceSmm.inf 2. Platform\Intel\MinPlatformPkg\Flash\SpiFvbService\SpiFvbServiceStandaloneMm.inf My understanding is: 1. The header file is defined in each silicon package because silicon cannot depend upon platform (i.e. the MinPlatformPkg header). 2. The header is present in each silicon package because the implementation is silicon-specific and these packages cannot depend on one another. 3. The header is defined in MinPlatformPkg because MinPlatformPkg should be silicon vendor agnostic (cannot depend on the silicon packages). 4. The header is needed in MinPlatformPkg because the SpiFvbService there depends on SPI flash operations implemented in SpiFlashCommonLib. Here's an initial proposal: 1. Consolidate the library interface into a single header. In IntelSiliconPkg? 2. Consolidate library implementation into a single instance. In IntelSiliconPkg? 3. Move SpiFvbServiceXyz out of MinPlatformPkg. 3.a. Make a "SPI flash" feature? 3.b. Allow the Intel implementation of this feature to depend on SpiFlashCommonLib defined in IntelSiliconPkg. Intel board packages could then use the SpiFlashCommonLib from IntelSiliconPkg (a generation specific instance could be created if needed) and use the SpiFvbServiceXyz driver from the "SpiFlash" feature. Look forward to your thoughts and feedback. Thanks, Michael