From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web10.1374.1632867959356298557 for ; Tue, 28 Sep 2021 15:26:03 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=j1V+OMmq; spf=temperror, err=temporary DNS error (domain: hpe.com, ip: 148.163.147.86, mailfrom: prvs=09052a8ab2=brian.johnson@hpe.com) Received: from pps.filterd (m0148663.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 18SM2AN5028653; Tue, 28 Sep 2021 22:25:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=subject : to : cc : references : from : message-id : date : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pps0720; bh=xfl1cmXnE8oLuFAtviiDACodElnKuqv2yAbVp2QZqAw=; b=j1V+OMmqanzpnTITIc1iDLUdxwDDAHCc2CGDDR+xeXF7JTKybwvshRZVOJc3G8E84Han a4tvdXtr2wYXLnFKOMCPz7yJ8uAu4U+9fsEbg727llgDoFvvZqsd9XcVzDEsAxLqzNOr PHSuEeMsxPAC76kPqFZF/gBIsMUJdf/Vd2VdHhBmGIOBstWnvDrM9Uu9BH6GJGVK/FX6 ySJFiVQN/bkxjpvplDY6QahVBqpj/+MqMnVudHd5FhGR1mt6YtuD0fmsF2k1pfh922Am pkoW2sZTCVPjLZgSbirX5mhEtNyJTkTWS9XPrnZZ0ieBv3QZ1LwEAOabxyxgBLPCpJ86 WQ== Received: from g9t5009.houston.hpe.com (g9t5009.houston.hpe.com [15.241.48.73]) by mx0a-002e3701.pphosted.com with ESMTP id 3bbxpd70p3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Sep 2021 22:25:43 +0000 Received: from g9t2301.houston.hpecorp.net (g9t2301.houston.hpecorp.net [16.220.97.129]) by g9t5009.houston.hpe.com (Postfix) with ESMTP id AC28C58; Tue, 28 Sep 2021 22:25:42 +0000 (UTC) Received: from [16.99.198.201] (unknown [16.99.198.201]) by g9t2301.houston.hpecorp.net (Postfix) with ESMTP id 98B454D; Tue, 28 Sep 2021 22:25:41 +0000 (UTC) Subject: Re: [edk2-devel] RFC: Add BaseLib/QuickSort in MdePkg To: devel@edk2.groups.io, ray.ni@intel.com, =?UTF-8?Q?Marvin_H=c3=a4user?= , "fanjianfeng@byosoft.com.cn" , 'gaoliming' , "Chan, Amy" , 'Andrew Fish' Cc: "Kinney, Michael D" , "'Gao, Liming'" , "Liu, Zhiguang" , "Wang, Jian J" , "Gao, Zhichao" References: <001a01d7aa99$d744af80$85ce0e80$@byosoft.com.cn> <003401d7aaa1$c7166830$55433890$@byosoft.com.cn> <16A70FAC1585C7C1.27516@groups.io> <00cf01d7b27a$59145d20$0b3d1760$@byosoft.com.cn> <2021092708451371303013@byosoft.com.cn> <7c260e5d-363e-8579-5a38-3cc5e2336bdb@posteo.de> <2021092716501903570820@byosoft.com.cn> <57dc418a-6620-629c-c448-777994c280d6@posteo.de> From: "Brian J. Johnson" Message-ID: <7d30e188-38b1-76cb-2e55-6f3a82338473@hpe.com> Date: Tue, 28 Sep 2021 17:25:40 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 In-Reply-To: X-Proofpoint-GUID: NcAEf1qX8ednYbsxNFuLzQXxwuu4OhzH X-Proofpoint-ORIG-GUID: NcAEf1qX8ednYbsxNFuLzQXxwuu4OhzH X-Proofpoint-UnRewURL: 3 URL's were un-rewritten MIME-Version: 1.0 X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-09-28_10,2021-09-28_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 malwarescore=0 impostorscore=0 priorityscore=1501 clxscore=1011 adultscore=0 phishscore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2109280130 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable I'll add my agreement to Marvin and Jeff: a low-level sort routine like=20 this should let the caller be in charge of memory allocation, so it can=20 be used in the widest variety of contexts (SEC, exception handlers, APs,=20 etc.) So let's make the BufferOneElement parameter mandatory. Brian J. Johnson -------- Original Message -------- From: Ni, Ray [mailto:ray.ni@intel.com] Sent: Monday, September 27, 2021, 8:49 PM To: Marvin H=C3=A4user , fanjianfeng@byosoft.com.cn=20 , devel@edk2.groups.io=20 , 'gaoliming' , Chan,=20 Amy , 'Andrew Fish' Cc: Kinney, Michael D , 'Gao, Liming'=20 , Liu, Zhiguang , Wang,=20 Jian J , Gao, Zhichao Subject: [edk2-devel] RFC: Add BaseLib/QuickSort in MdePkg Marvin, I agree with your concerns, in a certain level. But I didn't treat it as a very big problem of having caller pass the BufferOneElement "intelligently". I am ok to use your option 1), making BufferOneElement mandatory. Caller should always supply the buffer that's sufficient to hold one element. By the way, I don't want to propose "swap-without-using-temporary-value" method to avoid using the "BufferOneElement"? Because that makes the simple thing complicated! Thanks, Ray > -----Original Message----- > From: Marvin H=C3=A4user > Sent: Monday, September 27, 2021 5:09 PM > To: fanjianfeng@byosoft.com.cn; devel@edk2.groups.io; Ni, Ray ; 'gaoliming' > ; Chan, Amy ; 'Andrew Fish'= > Cc: Kinney, Michael D ; 'Gao, Liming' ; Liu, Zhiguang > ; Wang, Jian J ; Gao, Zhic= hao > Subject: Re: [edk2-devel] RFC: Add BaseLib/QuickSort in MdePkg > > On 27/09/2021 10:50, fanjianfeng@byosoft.com.cn wrote: >> For former caller, they could still keep as is to call the old API in >> MdeModulePkg. I think Ray's design is compatible change for existing cod= e. >> Only when the existing code wants to remove the dependency on >> MdeModuelPkg, they could migrate to the new API in baselib. >> >> I=C2=A0agree with=C2=A0one=C2=A0split-API desgin what you mentioned. >> But my=C2=A0point=C2=A0is=C2=A0to define one API in baselib and=C2=A0to = make the baselib >> not depend on memory allocation. And another wrapper API could be >> designed to be placed in any other class. > > Oh sure, it could totally live in another class. I'd just like to have > those two models (caller- and callee-owned buffer) strictly separate, I > personally do not mind where exactly they are implemented. Thanks! > > Best regards, > Marvin > >> >> ------------------------------------------------------------------------ >> Jeff >> fanjianfeng@byosoft.com.cn >> >> *From:* Marvin H=C3=A4user >> *Date:*=C2=A02021-09-27=C2=A016:14 >> *To:* fanjianfeng@byosoft.com.cn >> ; devel@edk2.groups.io >> ; Ni, Ray ; >> 'gaoliming' ; Chan, Amy >> ; 'Andrew Fish' >> *CC:* Kinney, Michael D ; 'Gao, >> Liming' ; Liu, Zhiguang >> ; Wang, Jian J >> ; Gao, Zhichao >> >> *Subject:*=C2=A0Re: [edk2-devel] RFC: Add BaseLib/QuickSort in MdeP= kg >> On 27/09/2021 02:45, fanjianfeng@byosoft.com.cn wrote: >> > Making baselib implementation depend on MemoryAllocationLib >> > (indirectly on Pei Service and gBS), it may prevent >> > this=C2=A0base=C2=A0API=C2=A0using=C2=A0at some=C2=A0seneraio. i = don't think it's better. >> That is why I asked about a split-API scenario, one of which does n= ot >> depend on dynamic memory allocation (SetVariable-like) and one does >> (wrapper-like). >> > Add this parameter and make this parameter is optional, >> > 1, when NULL, use the local 256 bytes stack >> > 2, if 256 bytes stack is not enough, return RETURE_BUFFER_TOO_SAM= LL, >> > 3, caller check the return status, to do nothing=C2=A0or to alloc= ate >> enough >> > buffer for retry >> > >> > This is just like SetVariable()'s implementation. >> Yes, and because that is SetVariable's implementation, we have >> library >> functions to make it less error-prone and more convenient [1]. As a >> matter of fact, we have a (semi-lax) policy in our codebases to avo= id >> such functions like the plague and use those library wrappers >> where-ever >> it can make sense. The only super-rare exceptions I can think of ar= e >> when we know the size of the element ahead of time. Also >> SetVariable has >> no arbitrary constraint on when it may work the first time, and >> there is >> code that will fail when the first return is not EFI_BUFFER_TOO_SMA= LL. >> This solution honestly yields even more problems, because it >> introduces >> a Status return which was not there before. For common code safety >> and >> quality policy, this requires the value *must* be retrieved and >> checked >> in some fashion. So all callers, no matter the prior knowledge of t= he >> element size, now need either a runtime check and handling for a >> status >> that they (may) know can never be returned, or ASSERTs if the >> function >> spec really imposes the arbitrary 256 Bytes constraint. Latter >> doesn't >> really work I think. What if someone wants to sort in SEC and notic= ed >> they only have 64 Bytes on the stack to work with, realistically? A= ny >> code depending on the 256 Byte constraint, passing NULL and not doi= ng >> additional handling, would seize to work. Former is too >> complicated, see >> wrappers. In my opinion, the memory must *either* be fully managed = by >> the caller *or* the callee (and you may have both in separate >> functions, >> as I suggested), but not sometimes here, sometimes there. >> Best regards, >> Marvin >> [1] >> > https://github.com/tianocore/edk2/blob/46b4606ba23498d3d0e66b53e498eb3d5d= 592586/MdePkg/Library/UefiLib/UefiLib.c#L > 1309-L1360 >> > >> > >> -------------------------------------------------------------------= ----- >> > Jeff >> > fanjianfeng@byosoft.com.cn >> > >> >=C2=A0=C2=A0=C2=A0=C2=A0 *From:* Marvin H=C3=A4user >> >=C2=A0=C2=A0=C2=A0=C2=A0 *Date:*=C2=A02021-09-26=C2=A019:20 >> >=C2=A0=C2=A0=C2=A0=C2=A0 *To:* devel = ; ray.ni >> >=C2=A0=C2=A0=C2=A0=C2=A0 ; gaoliming >> >=C2=A0=C2=A0=C2=A0=C2=A0 ; Chan, = Amy >> >=C2=A0=C2=A0=C2=A0=C2=A0 ; 'Andrew Fish= ' >> >> >=C2=A0=C2=A0=C2=A0=C2=A0 *CC:* Kinney, Michael D ; >> 'Gao, >> >=C2=A0=C2=A0=C2=A0=C2=A0 Liming' ; Li= u, Zhiguang >> >=C2=A0=C2=A0=C2=A0=C2=A0 ; Wang, Ji= an J >> >=C2=A0=C2=A0=C2=A0=C2=A0 ; Gao, Zhic= hao >> >=C2=A0=C2=A0=C2=A0=C2=A0 >> >=C2=A0=C2=A0=C2=A0=C2=A0 *Subject:*=C2=A0Re: [edk2-devel] RFC: Add= BaseLib/QuickSort in MdePkg >> >=C2=A0=C2=A0=C2=A0=C2=A0 Hey Ray, >> >=C2=A0=C2=A0=C2=A0=C2=A0 In my opinion that spec is too complicate= d. For some cases it is >> >=C2=A0=C2=A0=C2=A0=C2=A0 obvious, but I think the last anyone want= s to see is a >> >=C2=A0=C2=A0=C2=A0=C2=A0 (STATIC_)ASSERT >> >=C2=A0=C2=A0=C2=A0=C2=A0 before most QuickSort calls to ensure the= element size >> *really* is <=3D >> >=C2=A0=C2=A0=C2=A0=C2=A0 256 Bytes. In my opinion, there are two r= oads: >> >=C2=A0=C2=A0=C2=A0=C2=A0 1) Make the parameter required (I think t= his is what Liming >> >=C2=A0=C2=A0=C2=A0=C2=A0 suggested). >> >=C2=A0=C2=A0=C2=A0=C2=A0 The caller would always need to provide s= aid buffer, and it >> can do >> >=C2=A0=C2=A0=C2=A0=C2=A0 as it >> >=C2=A0=C2=A0=C2=A0=C2=A0 sees fit - on the stack, in a pool, in a = page, who knows. >> >=C2=A0=C2=A0=C2=A0=C2=A0 2) Remove the parameter entirely. The lib= rary would depend on >> >=C2=A0=C2=A0=C2=A0=C2=A0 MemoryAllocationLib again, but also would= have an >> optimisation by >> >=C2=A0=C2=A0=C2=A0=C2=A0 choosing stack vs pool based on ElementSi= ze. >> >=C2=A0=C2=A0=C2=A0=C2=A0 Usually I would prefer 2), as it is less = prone to caller >> errors, but >> >=C2=A0=C2=A0=C2=A0=C2=A0 considering the low-level nature of edk2,= I can totally see the >> >=C2=A0=C2=A0=C2=A0=C2=A0 point to >> >=C2=A0=C2=A0=C2=A0=C2=A0 allow the caller to control whether there= are dynamic memory >> >=C2=A0=C2=A0=C2=A0=C2=A0 allocations >> >=C2=A0=C2=A0=C2=A0=C2=A0 made or not as possible with 1). 2) could= technically also be a >> >=C2=A0=C2=A0=C2=A0=C2=A0 wrapper >> >=C2=A0=C2=A0=C2=A0=C2=A0 for 1) if you want granular control and c= onvenience/safety >> (why not >> >=C2=A0=C2=A0=C2=A0=C2=A0 actually?). >> >=C2=A0=C2=A0=C2=A0=C2=A0 Both approaches have the advantage that i= t is crystal-clear >> what the >> >=C2=A0=C2=A0=C2=A0=C2=A0 caller's job is - to always or to never a= llocate the buffer. >> >=C2=A0=C2=A0=C2=A0=C2=A0 Best regards, >> >=C2=A0=C2=A0=C2=A0=C2=A0 Marvin >> >=C2=A0=C2=A0=C2=A0=C2=A0 On 26/09/2021 04:24, Ni, Ray wrote: >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > Liming, >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > The purpose of the optional BufferOneEl= ement is to ease >> consumer=E2=80=99s >> >=C2=A0=C2=A0=C2=A0=C2=A0 > life assuming most of the time the elem= ent size should be >> >=C2=A0=C2=A0=C2=A0=C2=A0 smaller than >> >=C2=A0=C2=A0=C2=A0=C2=A0 > 256. >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > Are you saying that it=E2=80=99s a bit = hard to calculate the actual >> >=C2=A0=C2=A0=C2=A0=C2=A0 value of >> >=C2=A0=C2=A0=C2=A0=C2=A0 > sizeof (Element) when writing code? >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > I recommend consumer always allocates m= emory if it=E2=80=99s hard >> to judge >> >=C2=A0=C2=A0=C2=A0=C2=A0 > sizeof (Element) < 256. >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > Searching edk2 code, I can find below c= ode using >> PerformQuickSort(): >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0 1. ShellPkg/UefiShellCommandLib: = It=E2=80=99s sorting array of >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 (EFI_DEVICE_PAT= H_PROTOCOL *). >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0 2. UefiCpuPkg/CpuCacheInfoLib: It= =E2=80=99s sorting array of >> >=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0CPU_CACHE_INFO. >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0 3. MinPlatformPkg/AcpiTables: It= =E2=80=99s sorting array of >> >=C2=A0=C2=A0=C2=A0=C2=A0 EFI_CPU_ID_ORDER_MAP. >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0 4. MdeModulePkg/UefiBootManagerLi= b: It=E2=80=99s sorting array of >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 EFI_BOOT_MANAGE= R_LOAD_OPTION. >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0 5. MdeModulePkg/CapsuleApp: It=E2= =80=99s sorting array of >> (EFI_FILE_INFO *) >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0 6. CryptoPkg/CrtWrapper: It=E2=80= =99s sorting array of (unknown >> type). >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0 7. RedfishPkg/RedfishCrtLib: It= =E2=80=99s sorting array of >> (unknown type). >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > For 1~5, it=E2=80=99s easy to know that= the size of the element is >> smaller >> >=C2=A0=C2=A0=C2=A0=C2=A0 > than 256. The AllocatePool() can be ski= pped. >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > Thanks, >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > Ray >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *From:*gaoliming >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *Sent:* Sunday, September 26, 2021 10:0= 1 AM >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *To:* Ni, Ray ; devel= @edk2.groups.io; >> Chan, Amy >> >=C2=A0=C2=A0=C2=A0=C2=A0 > ; 'Andrew Fish' >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *Cc:* Kinney, Michael D ; >> 'Gao, Liming' >> >=C2=A0=C2=A0=C2=A0=C2=A0 > ; Liu, Zhiguang >> ; >> >=C2=A0=C2=A0=C2=A0=C2=A0 Wang, >> >=C2=A0=C2=A0=C2=A0=C2=A0 > Jian J ; Gao, Zh= ichao >> >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *Subject:* =E5=9B=9E=E5=A4=8D: [edk2-de= vel] RFC: Add BaseLib/QuickSort in >> MdePkg >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > Ray: >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > I may suggest to always require BufferO= neElement. The >> consumer code >> >=C2=A0=C2=A0=C2=A0=C2=A0 > may not know ElementSize. To avoid the = error, the consumer >> must >> >=C2=A0=C2=A0=C2=A0=C2=A0 > allocate buffer for BufferOneElement. I= f so, >> BufferOneElement is >> >=C2=A0=C2=A0=C2=A0=C2=A0 the >> >=C2=A0=C2=A0=C2=A0=C2=A0 > required parameter. >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > Thanks >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > Liming >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *=E5=8F=91=E4=BB=B6=E4=BA=BA**:*Ni, Ray= > > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *=E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4:*= 2021=E5=B9=B49=E6=9C=8824=E6=97=A5 11:53 >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *=E6=94=B6=E4=BB=B6=E4=BA=BA:* devel@ed= k2.groups.io ; >> Ni, >> >=C2=A0=C2=A0=C2=A0=C2=A0 Ray >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >; Chan, Amy >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >; gaoliming >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >; >> >=C2=A0=C2=A0=C2=A0=C2=A0 'Andrew >> >=C2=A0=C2=A0=C2=A0=C2=A0 > Fish' > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *=E6=8A=84=E9=80=81:* Kinney, Michael D= > >=C2=A0=C2=A0=C2=A0=C2=A0 > >; '= Gao, Liming' >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >; Liu, >> Zhiguang >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >; >> Wang, >> >=C2=A0=C2=A0=C2=A0=C2=A0 Jian J >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >; Gao, >> >=C2=A0=C2=A0=C2=A0=C2=A0 Zhichao >> >=C2=A0=C2=A0=C2=A0=C2=A0 > > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *=E4=B8=BB=E9=A2=98:* RE: [edk2-devel] = RFC: Add BaseLib/QuickSort in MdePkg >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > More details on new QuickSort() API: >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > The new API needs to carry additional p= arameter >> =E2=80=9CBufferOneElement=E2=80=9D. >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > This parameter gives QuickSort() the te= mporary buffer for >> >=C2=A0=C2=A0=C2=A0=C2=A0 swapping in >> >=C2=A0=C2=A0=C2=A0=C2=A0 > sorting. >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > It=E2=80=99s to avoid BaseLib depends o= n MemoryAllocationLib. >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > =E2=80=A6 >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > @param [in] BufferOneElement =C2=A0When= ElementSize > 256, caller >> >=C2=A0=C2=A0=C2=A0=C2=A0 needs to >> >=C2=A0=C2=A0=C2=A0=C2=A0 > provide a buffer whose size >> >=C2=A0=C2=A0=C2=A0=C2=A0 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0equals to Elem= entSize. It=E2=80=99s >> used by >> >=C2=A0=C2=A0=C2=A0=C2=A0 > QuickSort() for swapping in sorting. >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > When ElementSize <=3D 256, QuickSort() = uses a local stack >> 256-byte >> >=C2=A0=C2=A0=C2=A0=C2=A0 buffer. >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > @retval EFI_INVALID_PARAMETER When (Ele= mentSize > 256) and >> >=C2=A0=C2=A0=C2=A0=C2=A0 > (BufferOneElement =3D=3D NULL). >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > =E2=80=A6 >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > VOID >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > EFIAPI >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > QuickSort=C2=A0( >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > =C2=A0=C2=A0IN=C2=A0OUT VOID=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0*BufferTo= Sort, >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > =C2=A0=C2=A0IN=C2=A0CONST=C2=A0UINTN El= ementCount, >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > =C2=A0=C2=A0IN=C2=A0CONST=C2=A0UINTN El= ementSize, >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > =C2=A0=C2=A0IN=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0SORT_COMPARE CompareFunction, >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > IN VOID *BufferOneElement OPTIONAL >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > ); >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > Any comments? >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *From:*devel@edk2.groups.io >> >=C2=A0=C2=A0=C2=A0=C2=A0 > > *On >> Behalf Of >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *Ni, Ray >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *Sent:* Wednesday, September 22, 2021 2= :04 PM >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *To:* Chan, Amy > >; >> >=C2=A0=C2=A0=C2=A0=C2=A0 > gaoliming > >=C2=A0=C2=A0=C2=A0=C2=A0 > >; 'An= drew Fish' >> > >=C2=A0=C2=A0=C2=A0=C2=A0 > >; 'edk2-devel-= groups-io' >> >=C2=A0=C2=A0=C2=A0=C2=A0 > > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *Cc:* Kinney, Michael D > >=C2=A0=C2=A0=C2=A0=C2=A0 > >; '= Gao, Liming' >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >; Liu, >> Zhiguang >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >; >> Wang, >> >=C2=A0=C2=A0=C2=A0=C2=A0 Jian J >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >; Gao, >> >=C2=A0=C2=A0=C2=A0=C2=A0 Zhichao >> >=C2=A0=C2=A0=C2=A0=C2=A0 > > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *Subject:* Re: [edk2-devel] RFC: Add Ba= seLib/QuickSort in >> MdePkg >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > I don=E2=80=99t see objection so far. >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > So, the final solution is: >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0 1. Add QuickSort() API to BaseLib= in MdePkg. >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0 2. Update existing=C2=A0MdeModule= Pkg/SortLib to use >> QuickSort() in the >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 implementation = (proposed by Andrew Fish and Liming Gao) >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0 3. Update UefiCpuPkg to use Quick= SortLib to remove improper >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 dependency on M= deModulePkg >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > Thanks, >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > Ray >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *From:*Ni, Ray >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *Sent:* Thursday, September 16, 2021 10= :48 AM >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *To:* Chan, Amy > >; >> >=C2=A0=C2=A0=C2=A0=C2=A0 > gaoliming > >=C2=A0=C2=A0=C2=A0=C2=A0 > >; 'An= drew Fish' >> > >=C2=A0=C2=A0=C2=A0=C2=A0 > >; 'edk2-devel-= groups-io' >> >=C2=A0=C2=A0=C2=A0=C2=A0 > > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *Cc:* Kinney, Michael D > >=C2=A0=C2=A0=C2=A0=C2=A0 > >; '= Gao, Liming' >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >; Liu, >> Zhiguang >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >; >> Wang, >> >=C2=A0=C2=A0=C2=A0=C2=A0 Jian J >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >; Gao, >> >=C2=A0=C2=A0=C2=A0=C2=A0 Zhichao >> >=C2=A0=C2=A0=C2=A0=C2=A0 > > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *Subject:* RE: [edk2-devel] RFC: Add Ba= seLib/QuickSort in >> MdePkg >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > Amy, >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > No. We only Add QuickSort() function AP= I into BaseLib.h. >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *From:*Chan, Amy > > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *Sent:* Thursday, September 16, 2021 10= :46 AM >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *To:* gaoliming > >=C2=A0=C2=A0=C2=A0=C2=A0 > >; 'An= drew Fish' >> > >=C2=A0=C2=A0=C2=A0=C2=A0 > >; 'edk2-devel-= groups-io' >> >=C2=A0=C2=A0=C2=A0=C2=A0 > > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *Cc:* Ni, Ray > >; Kinney, >> >=C2=A0=C2=A0=C2=A0=C2=A0 > Michael D > >=C2=A0=C2=A0=C2=A0=C2=A0 > >; '= Gao, Liming' >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >; Liu, >> Zhiguang >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >; >> Wang, >> >=C2=A0=C2=A0=C2=A0=C2=A0 Jian J >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >; Gao, >> >=C2=A0=C2=A0=C2=A0=C2=A0 Zhichao >> >=C2=A0=C2=A0=C2=A0=C2=A0 > > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *Subject:* RE: [edk2-devel] RFC: Add Ba= seLib/QuickSort in >> MdePkg >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > Just to double confirm, will we have th= e null instance of >> >=C2=A0=C2=A0=C2=A0=C2=A0 QuickSort in >> >=C2=A0=C2=A0=C2=A0=C2=A0 > MdePkg? >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > Regards, >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > Amy >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *From:*gaoliming > >=C2=A0=C2=A0=C2=A0=C2=A0 > > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *Sent:* Thursday, September 16, 2021 10= :23 AM >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *To:* 'Andrew Fish' > >; >> >=C2=A0=C2=A0=C2=A0=C2=A0 > 'edk2-devel-groups-io' > >=C2=A0=C2=A0=C2=A0=C2=A0 > > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *Cc:* Ni, Ray > >; Kinney, >> >=C2=A0=C2=A0=C2=A0=C2=A0 > Michael D > >=C2=A0=C2=A0=C2=A0=C2=A0 > >; '= Gao, Liming' >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >; Liu, >> Zhiguang >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >; >> Wang, >> >=C2=A0=C2=A0=C2=A0=C2=A0 Jian J >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >; Gao, >> >=C2=A0=C2=A0=C2=A0=C2=A0 Zhichao >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >; >> Chan, Amy >> >=C2=A0=C2=A0=C2=A0=C2=A0 > > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *Subject:* =E5=9B=9E=E5=A4=8D: [edk2-de= vel] RFC: Add BaseLib/QuickSort in >> MdePkg >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > Andrew: >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > Thanks for your suggestion. I think you= r idea is better. >> We add new >> >=C2=A0=C2=A0=C2=A0=C2=A0 > QuickSort() API to BaseLib, and update = SortLib library >> instance to >> >=C2=A0=C2=A0=C2=A0=C2=A0 > consume BaseLib QuickSort() API. This w= ay has no change in >> current >> >=C2=A0=C2=A0=C2=A0=C2=A0 > SortLib library class. It is the compat= ible solution. >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > Thanks >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > Liming >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *=E5=8F=91=E4=BB=B6=E4=BA=BA**:*Andrew = Fish > > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *=E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4:*= 2021=E5=B9=B49=E6=9C=8816=E6=97=A5 10:13 >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *=E6=94=B6=E4=BB=B6=E4=BA=BA:* edk2-dev= el-groups-io > >=C2=A0=C2=A0=C2=A0=C2=A0 > >; Liming = Gao >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >=C2=A0=C2=A0=C2=A0=C2=A0 > > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *=E6=8A=84=E9=80=81:* Ni, Ray > >; Mike >> >=C2=A0=C2=A0=C2=A0=C2=A0 > Kinney > >=C2=A0=C2=A0=C2=A0=C2=A0 > >; G= ao, Liming >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >; Liu, >> Zhiguang >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >; >> Wang, >> >=C2=A0=C2=A0=C2=A0=C2=A0 Jian J >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >; Gao, >> >=C2=A0=C2=A0=C2=A0=C2=A0 Zhichao >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >; >> Chan, Amy >> >=C2=A0=C2=A0=C2=A0=C2=A0 > > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > *=E4=B8=BB=E9=A2=98:* Re: [edk2-devel] = RFC: Add BaseLib/QuickSort in MdePkg >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 On Sep 15, 2021= , at 6:26 PM, gaoliming >> > >=C2=A0=C2=A0=C2=A0=C2=A0 > > wrot= e: >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 Ray: >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 SortLib has bee= n added since 2015. I would suggest to >> still keep >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 this library cl= ass. To resolve the package dependency, my >> >=C2=A0=C2=A0=C2=A0=C2=A0 proposal >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 is to move the = library class header file SortLib.h from >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 MdeModulePkg to= MdePkg, and still keep the library >> instance in >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 MdeModulePkg. T= his proposal has no impact on the existing >> >=C2=A0=C2=A0=C2=A0=C2=A0 platform. >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > If we add QuickSort() API to the BaseLi= b can we not just >> port the >> >=C2=A0=C2=A0=C2=A0=C2=A0 > existing=C2=A0MdeModulePkg/SortLib to u= se QuickSort() in the >> >=C2=A0=C2=A0=C2=A0=C2=A0 > implementation? Or is there some other = way to add the new >> thing >> >=C2=A0=C2=A0=C2=A0=C2=A0 in a >> >=C2=A0=C2=A0=C2=A0=C2=A0 > backward compatible way. >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > Thanks, >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > Andrew Fish >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 Thanks >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 Liming >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 *=E5=8F=91=E4= =BB=B6=E4=BA=BA**:*devel@edk2.groups.io >> >=C2=A0=C2=A0=C2=A0=C2=A0 > > >=C2=A0=C2=A0=C2=A0=C2=A0 > >*=E4=BB= =A3=E8=A1=A8***Ni, Ray >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 *=E5=8F=91=E9= =80=81=E6=97=B6=E9=97=B4:*2021=E5=B9=B49=E6=9C=8814=E6=97=A514:15 >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 *=E6=94=B6=E4= =BB=B6=E4=BA=BA:*Kinney, Michael D > >=C2=A0=C2=A0=C2=A0=C2=A0 > >; G= ao, Liming >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 >; Liu, >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 Zhiguang > >=C2=A0=C2=A0=C2=A0=C2=A0 >; >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 Wang, Jian J > >=C2=A0=C2=A0=C2=A0=C2=A0 > >; Gao, Z= hichao >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 *=E6=8A=84=E9= =80=81:*devel@edk2.groups.io ; >> >=C2=A0=C2=A0=C2=A0=C2=A0 Chan, Amy >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 *=E4=B8=BB=E9= =A2=98:*[edk2-devel] RFC: Add BaseLib/QuickSort in MdePkg >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 Hi package main= tainers of MdePkg, MdeModulePkg and >> ShellPkg, >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 community, >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 A commit (UefiC= puPkg/CpuCacheInfoLib: Sort >> CpuCacheInfo array >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> > >> ) >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 to UefiCpuPkg l= et >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 UefiCpuPkg depe= nd on MdeModulePkg because the SortLib >> class and >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 instances are a= ll in MdeModulePkg. >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 UefiCpuPkg depe= nding on MdeModulePkg breaks the rule that >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 =E2=80=9CUefiCp= uPkg should ONLY depend on MdePkg=E2=80=9D. >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 To address this= issue, there are two approaches: >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 1. Duplic= ate the sort logic in UefiCpuPkg to not >> depend on >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 MdeModulePkg/SortLib >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 2. Add Qu= ickSort() API to BaseLib in MdePkg. >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 Approach #2 (Md= ePkg/BaseLib/QuickSort) makes more >> sense because >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 quick sort is a= standard algorithm. >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 We encourage co= nsumers to update their code to use the >> quick >> >=C2=A0=C2=A0=C2=A0=C2=A0 sort >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 in MdePkg and g= radually deprecate today=E2=80=99s >> MdeModulePkg/SortLib. >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 If you don=E2= =80=99t have concerns, I plan to: >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 1. =E2=80= =9CAdd QuickSort() to BaseLib=E2=80=9D and update all existing >> >=C2=A0=C2=A0=C2=A0=C2=A0 consumers >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 to use this API instead. >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 VOID >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 EFIAPI >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 QuickSort=C2=A0= ( >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > =C2=A0=C2=A0IN=C2=A0OUT=C2=A0VOID=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0*BufferToSort, >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0IN= =C2=A0CONST=C2=A0UINTN Count, >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0IN= =C2=A0CONST=C2=A0UINTN ElementSize, >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > =C2=A0=C2=A0IN=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0SORT_COMPARE=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0CompareFunction >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0); >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 2. =E2=80= =9CAdd new ShellPkg/SortCompareLib=E2=80=9D >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 Background: She= llPkg requires to sort >> devicepath/string so 3 >> >=C2=A0=C2=A0=C2=A0=C2=A0 APIs >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 in UefiSortLib = (DevicePathCompare, StringNoCaseCompare, >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 StringCompare) = are provided for Shell usage. we can >> move the 3 >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 APIs to the Sor= tCompareLib and update Shell code to use >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 BaseLib/QuickSo= rt directly, with the sort compare >> function from >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 SortCompareLib. >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 Any concerns? >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 Thanks, >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0 Ray >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> >=C2=A0=C2=A0=C2=A0=C2=A0 > >> > >> > >> =20 >> --=20 Brian -------------------------------------------------------------------- "Remember that ignorance is expensive." -- From LLIB