Re: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new EfiFindAcpiTableBySignature() API

2018-09-05 Thread Zeng, Star
After offline discussion with Jiewen and Ray, we agree to follow S1 that will 
make the consumer easier for single ACPI table case.
I will update patches and send new V2 series.

Thanks for all the feedbacks.

Star
-Original Message-
From: Ni, Ruiyu 
Sent: Monday, September 3, 2018 2:33 PM
To: Yao, Jiewen ; Zeng, Star ; 
Kinney, Michael D 
Cc: edk2-devel@lists.01.org; Younas khan ; Gao, 
Liming 
Subject: RE: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new 
EfiFindAcpiTableBySignature() API

I prefer S2.
Single interface is more easy for consumer to remember how to use.

Thanks/Ray

> -Original Message-
> From: Yao, Jiewen
> Sent: Monday, September 3, 2018 2:15 PM
> To: Zeng, Star ; Ni, Ruiyu ; 
> Kinney, Michael D 
> Cc: edk2-devel@lists.01.org; Younas khan ; 
> Gao, Liming 
> Subject: RE: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new
> EfiFindAcpiTableBySignature() API
> 
> I prefer S1.
> I believe that the EfiLocateNextAcpiTable() can also be used in S1.
> 
> 
> > -Original Message-
> > From: Zeng, Star
> > Sent: Monday, September 3, 2018 2:12 PM
> > To: Ni, Ruiyu ; Yao, Jiewen 
> > ; Kinney, Michael D 
> > 
> > Cc: edk2-devel@lists.01.org; Younas khan
> ;
> > Gao, Liming ; Zeng, Star 
> > Subject: RE: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new
> > EfiFindAcpiTableBySignature() API
> >
> > Thanks.
> > Ok, please help and we can have good and flexible interface(s) for 
> > both producer and consumer.
> >
> > First, there are two cases we need to consider.
> > 1. Single table, like FADT, FACS, DSDT, etc.
> > 2. Multiple tables, like SSDT, etc.
> >
> > Then, we have two solutions.
> > S1:
> > One interface for single table case, consumer only needs input 
> > Signature, has no need input previous returned Table. Like
> GetFirstGuidHob?
> > One interface for multiple table case, consumer needs input 
> > Signature and previous returned Table. Like GetNextGuidHob? Could we 
> > add it later based on real request?
> > S2:
> > One interface for both single table and multiple table cases, 
> > consumer needs input Signature and previous returned Table. Does 
> > consumer need input the table header stored in configuration table 
> > by itself(getting
> configuration table)?
> >
> >
> > If we like S2, the interface should be like below?
> >
> > /**
> >   This function locates next ACPI table based on Signature and 
> > previous returned Table.
> >   If the input previous returned Table is NULL, this function will 
> > locate next
> table
> >   in gEfiAcpi20TableGuid system configuration table first, and then 
> > gEfiAcpi10TableGuid
> >   system configuration table.
> >   If the input previous returned Table is not NULL and could be located in
> >   gEfiAcpi20TableGuid system configuration table, this function will 
> > just locate next
> >   table in gEfiAcpi20TableGuid system configuration table, otherwise 
> > gEfiAcpi10TableGuid
> >   system configuration table.
> >
> >   @param Signature  ACPI table signature.
> >   @param Table  Pointer to previous returned Table, or NULL to locate
> > first table.
> >
> >   @return Next ACPI table or NULL if not found.
> >
> > **/
> > EFI_ACPI_COMMON_HEADER *
> > EFIAPI
> > EfiLocateNextAcpiTable (
> >   IN UINT32          Signature,
> >   IN EFI_ACPI_COMMON_HEADER  *Table
> >   )
> >
> >
> >
> > Thanks,
> > Star
> > -Original Message-
> > From: Ni, Ruiyu
> > Sent: Monday, September 3, 2018 1:09 PM
> > To: Zeng, Star ; Yao, Jiewen 
> > ; Kinney, Michael D 
> > 
> > Cc: edk2-devel@lists.01.org; Younas khan
> ;
> > Gao, Liming 
> > Subject: RE: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new
> > EfiFindAcpiTableBySignature() API
> >
> > That's fine to be in UefiLib. It's already a combo library.
> >
> > But I do recommend we think about how to handle multiple tables with 
> > same signature.
> > When we are adding new APIs, we not only need to evaluate the 
> > existing real case, but also we need to generalize the real cases 
> > and try to think about the more flexible interface.
> >
> >
> > Thanks/Ray
> >
> > > -Original Message-
> > > From: Zeng, Star
> > > Sent: Monday, September 3, 2018 11:26 AM
> > > To: Yao, Jiewen ; Ni, Ruiyu 
> > > ; Kinney, Michael D 
> > > 
> > > Cc: edk2-devel@lists.01.org; Younas khan 
> > > ; Gao, Liming ; 
> > > Zeng, Star 
&g

Re: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new EfiFindAcpiTableBySignature() API

2018-09-03 Thread Ni, Ruiyu
I prefer S2.
Single interface is more easy for consumer to remember how to use.

Thanks/Ray

> -Original Message-
> From: Yao, Jiewen
> Sent: Monday, September 3, 2018 2:15 PM
> To: Zeng, Star ; Ni, Ruiyu ;
> Kinney, Michael D 
> Cc: edk2-devel@lists.01.org; Younas khan ;
> Gao, Liming 
> Subject: RE: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new
> EfiFindAcpiTableBySignature() API
> 
> I prefer S1.
> I believe that the EfiLocateNextAcpiTable() can also be used in S1.
> 
> 
> > -Original Message-
> > From: Zeng, Star
> > Sent: Monday, September 3, 2018 2:12 PM
> > To: Ni, Ruiyu ; Yao, Jiewen
> > ; Kinney, Michael D 
> > Cc: edk2-devel@lists.01.org; Younas khan
> ;
> > Gao, Liming ; Zeng, Star 
> > Subject: RE: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new
> > EfiFindAcpiTableBySignature() API
> >
> > Thanks.
> > Ok, please help and we can have good and flexible interface(s) for
> > both producer and consumer.
> >
> > First, there are two cases we need to consider.
> > 1. Single table, like FADT, FACS, DSDT, etc.
> > 2. Multiple tables, like SSDT, etc.
> >
> > Then, we have two solutions.
> > S1:
> > One interface for single table case, consumer only needs input
> > Signature, has no need input previous returned Table. Like
> GetFirstGuidHob?
> > One interface for multiple table case, consumer needs input Signature
> > and previous returned Table. Like GetNextGuidHob? Could we add it
> > later based on real request?
> > S2:
> > One interface for both single table and multiple table cases, consumer
> > needs input Signature and previous returned Table. Does consumer need
> > input the table header stored in configuration table by itself(getting
> configuration table)?
> >
> >
> > If we like S2, the interface should be like below?
> >
> > /**
> >   This function locates next ACPI table based on Signature and
> > previous returned Table.
> >   If the input previous returned Table is NULL, this function will locate 
> > next
> table
> >   in gEfiAcpi20TableGuid system configuration table first, and then
> > gEfiAcpi10TableGuid
> >   system configuration table.
> >   If the input previous returned Table is not NULL and could be located in
> >   gEfiAcpi20TableGuid system configuration table, this function will
> > just locate next
> >   table in gEfiAcpi20TableGuid system configuration table, otherwise
> > gEfiAcpi10TableGuid
> >   system configuration table.
> >
> >   @param Signature  ACPI table signature.
> >   @param Table  Pointer to previous returned Table, or NULL to locate
> > first table.
> >
> >   @return Next ACPI table or NULL if not found.
> >
> > **/
> > EFI_ACPI_COMMON_HEADER *
> > EFIAPI
> > EfiLocateNextAcpiTable (
> >   IN UINT32      Signature,
> >   IN EFI_ACPI_COMMON_HEADER  *Table
> >   )
> >
> >
> >
> > Thanks,
> > Star
> > -Original Message-
> > From: Ni, Ruiyu
> > Sent: Monday, September 3, 2018 1:09 PM
> > To: Zeng, Star ; Yao, Jiewen
> > ; Kinney, Michael D 
> > Cc: edk2-devel@lists.01.org; Younas khan
> ;
> > Gao, Liming 
> > Subject: RE: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new
> > EfiFindAcpiTableBySignature() API
> >
> > That's fine to be in UefiLib. It's already a combo library.
> >
> > But I do recommend we think about how to handle multiple tables with
> > same signature.
> > When we are adding new APIs, we not only need to evaluate the existing
> > real case, but also we need to generalize the real cases and try to
> > think about the more flexible interface.
> >
> >
> > Thanks/Ray
> >
> > > -Original Message-
> > > From: Zeng, Star
> > > Sent: Monday, September 3, 2018 11:26 AM
> > > To: Yao, Jiewen ; Ni, Ruiyu
> > > ; Kinney, Michael D 
> > > Cc: edk2-devel@lists.01.org; Younas khan
> > > ; Gao, Liming ;
> > > Zeng, Star 
> > > Subject: RE: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new
> > > EfiFindAcpiTableBySignature() API
> > >
> > > Good idea.
> > >
> > > I did consider DSDT and multiple SSDTs cases. But I did not find any
> > > real case for them.
> > > So I made the code simply for current cases, and the code can be
> > > easily enhanced later for DSDT, a new API can be added later for
> > > multiple
> > SSDTs.
> > >
> > > About adding the new 

Re: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new EfiFindAcpiTableBySignature() API

2018-09-03 Thread Yao, Jiewen
I prefer S1.
I believe that the EfiLocateNextAcpiTable() can also be used in S1.


> -Original Message-
> From: Zeng, Star
> Sent: Monday, September 3, 2018 2:12 PM
> To: Ni, Ruiyu ; Yao, Jiewen ; 
> Kinney,
> Michael D 
> Cc: edk2-devel@lists.01.org; Younas khan ;
> Gao, Liming ; Zeng, Star 
> Subject: RE: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new
> EfiFindAcpiTableBySignature() API
> 
> Thanks.
> Ok, please help and we can have good and flexible interface(s) for both 
> producer
> and consumer.
> 
> First, there are two cases we need to consider.
> 1. Single table, like FADT, FACS, DSDT, etc.
> 2. Multiple tables, like SSDT, etc.
> 
> Then, we have two solutions.
> S1:
> One interface for single table case, consumer only needs input Signature, has 
> no
> need input previous returned Table. Like GetFirstGuidHob?
> One interface for multiple table case, consumer needs input Signature and
> previous returned Table. Like GetNextGuidHob? Could we add it later based on
> real request?
> S2:
> One interface for both single table and multiple table cases, consumer needs
> input Signature and previous returned Table. Does consumer need input the
> table header stored in configuration table by itself(getting configuration 
> table)?
> 
> 
> If we like S2, the interface should be like below?
> 
> /**
>   This function locates next ACPI table based on Signature and previous 
> returned
> Table.
>   If the input previous returned Table is NULL, this function will locate 
> next table
>   in gEfiAcpi20TableGuid system configuration table first, and then
> gEfiAcpi10TableGuid
>   system configuration table.
>   If the input previous returned Table is not NULL and could be located in
>   gEfiAcpi20TableGuid system configuration table, this function will just 
> locate
> next
>   table in gEfiAcpi20TableGuid system configuration table, otherwise
> gEfiAcpi10TableGuid
>   system configuration table.
> 
>   @param Signature  ACPI table signature.
>   @param Table  Pointer to previous returned Table, or NULL to locate
> first table.
> 
>   @return Next ACPI table or NULL if not found.
> 
> **/
> EFI_ACPI_COMMON_HEADER *
> EFIAPI
> EfiLocateNextAcpiTable (
>   IN UINT32  Signature,
>   IN EFI_ACPI_COMMON_HEADER  *Table
>   )
> 
> 
> 
> Thanks,
> Star
> -----Original Message-----
> From: Ni, Ruiyu
> Sent: Monday, September 3, 2018 1:09 PM
> To: Zeng, Star ; Yao, Jiewen ;
> Kinney, Michael D 
> Cc: edk2-devel@lists.01.org; Younas khan ;
> Gao, Liming 
> Subject: RE: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new
> EfiFindAcpiTableBySignature() API
> 
> That's fine to be in UefiLib. It's already a combo library.
> 
> But I do recommend we think about how to handle multiple tables with same
> signature.
> When we are adding new APIs, we not only need to evaluate the existing real
> case, but also we need to generalize the real cases and try to think about the
> more flexible interface.
> 
> 
> Thanks/Ray
> 
> > -Original Message-
> > From: Zeng, Star
> > Sent: Monday, September 3, 2018 11:26 AM
> > To: Yao, Jiewen ; Ni, Ruiyu
> > ; Kinney, Michael D 
> > Cc: edk2-devel@lists.01.org; Younas khan ;
> > Gao, Liming ; Zeng, Star 
> > Subject: RE: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new
> > EfiFindAcpiTableBySignature() API
> >
> > Good idea.
> >
> > I did consider DSDT and multiple SSDTs cases. But I did not find any
> > real case for them.
> > So I made the code simply for current cases, and the code can be
> > easily enhanced later for DSDT, a new API can be added later for multiple
> SSDTs.
> >
> > About adding the new API in UefiLib VS new library class, I did also
> > consider it and even created code for new library class
> > (g...@github.com:lzeng14/edk2.git branch
> > FindAcpiTableBySignature_UefiAcpiTableLib).
> > But I remember I did discuss it with Mike and Jiewen, we recommended
> > UefiLib as it will do not require any platform change.
> >
> >
> >
> > Thanks,
> > Star
> > -Original Message-
> > From: Yao, Jiewen
> > Sent: Saturday, September 1, 2018 7:04 AM
> > To: Ni, Ruiyu 
> > Cc: Zeng, Star ; edk2-devel@lists.01.org; Kinney,
> > Michael D ; Younas khan
> > ; Gao, Liming 
> > Subject: RE: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new
> > EfiFindAcpiTableBySignature() API
> >
> > Good idea on LocateNextAcpiTable().
> >
> >
> > > -Original Message-
> > > From: Ni, Ruiyu
> > > Sent: Saturday, September 1, 2018 12:29 AM
&g

Re: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new EfiFindAcpiTableBySignature() API

2018-09-03 Thread Zeng, Star
Thanks.
Ok, please help and we can have good and flexible interface(s) for both 
producer and consumer.

First, there are two cases we need to consider.
1. Single table, like FADT, FACS, DSDT, etc.
2. Multiple tables, like SSDT, etc.

Then, we have two solutions.
S1:
One interface for single table case, consumer only needs input Signature, has 
no need input previous returned Table. Like GetFirstGuidHob?
One interface for multiple table case, consumer needs input Signature and 
previous returned Table. Like GetNextGuidHob? Could we add it later based on 
real request?
S2:
One interface for both single table and multiple table cases, consumer needs 
input Signature and previous returned Table. Does consumer need input the table 
header stored in configuration table by itself(getting configuration table)?


If we like S2, the interface should be like below?

/**
  This function locates next ACPI table based on Signature and previous 
returned Table.
  If the input previous returned Table is NULL, this function will locate next 
table
  in gEfiAcpi20TableGuid system configuration table first, and then 
gEfiAcpi10TableGuid
  system configuration table.
  If the input previous returned Table is not NULL and could be located in
  gEfiAcpi20TableGuid system configuration table, this function will just 
locate next
  table in gEfiAcpi20TableGuid system configuration table, otherwise 
gEfiAcpi10TableGuid
  system configuration table.

  @param Signature  ACPI table signature.
  @param Table  Pointer to previous returned Table, or NULL to locate first 
table.

  @return Next ACPI table or NULL if not found.

**/
EFI_ACPI_COMMON_HEADER *
EFIAPI
EfiLocateNextAcpiTable (
  IN UINT32  Signature,
  IN EFI_ACPI_COMMON_HEADER  *Table
  )



Thanks,
Star
-Original Message-
From: Ni, Ruiyu 
Sent: Monday, September 3, 2018 1:09 PM
To: Zeng, Star ; Yao, Jiewen ; 
Kinney, Michael D 
Cc: edk2-devel@lists.01.org; Younas khan ; Gao, 
Liming 
Subject: RE: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new 
EfiFindAcpiTableBySignature() API

That's fine to be in UefiLib. It's already a combo library.

But I do recommend we think about how to handle multiple tables with same 
signature.
When we are adding new APIs, we not only need to evaluate the existing real 
case, but also we need to generalize the real cases and try to think about the 
more flexible interface.


Thanks/Ray

> -Original Message-
> From: Zeng, Star
> Sent: Monday, September 3, 2018 11:26 AM
> To: Yao, Jiewen ; Ni, Ruiyu 
> ; Kinney, Michael D 
> Cc: edk2-devel@lists.01.org; Younas khan ; 
> Gao, Liming ; Zeng, Star 
> Subject: RE: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new
> EfiFindAcpiTableBySignature() API
> 
> Good idea.
> 
> I did consider DSDT and multiple SSDTs cases. But I did not find any 
> real case for them.
> So I made the code simply for current cases, and the code can be 
> easily enhanced later for DSDT, a new API can be added later for multiple 
> SSDTs.
> 
> About adding the new API in UefiLib VS new library class, I did also 
> consider it and even created code for new library class 
> (g...@github.com:lzeng14/edk2.git branch 
> FindAcpiTableBySignature_UefiAcpiTableLib).
> But I remember I did discuss it with Mike and Jiewen, we recommended 
> UefiLib as it will do not require any platform change.
> 
> 
> 
> Thanks,
> Star
> -Original Message-
> From: Yao, Jiewen
> Sent: Saturday, September 1, 2018 7:04 AM
> To: Ni, Ruiyu 
> Cc: Zeng, Star ; edk2-devel@lists.01.org; Kinney, 
> Michael D ; Younas khan 
> ; Gao, Liming 
> Subject: RE: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new
> EfiFindAcpiTableBySignature() API
> 
> Good idea on LocateNextAcpiTable().
> 
> 
> > -Original Message-
> > From: Ni, Ruiyu
> > Sent: Saturday, September 1, 2018 12:29 AM
> > To: Yao, Jiewen 
> > Cc: Zeng, Star ; edk2-devel@lists.01.org; 
> > Kinney, Michael D ; Younas khan 
> > ; Gao, Liming 
> > Subject: Re: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new
> > EfiFindAcpiTableBySignature() API
> >
> > I think LocateNextAcpiTable() is more proper to handle the multiple 
> > tables with same signature. It will carry three parameters, one is 
> > the table header stored in configuration table, one is the 
> > signature, another is
> the previous located table.
> > Can we return a common table header other than void*?
> >
> > Is there better place other than UefiLib?
> > Do we need to add a new library class like AcpiLib?
> >
> > 发自我的 iPhone
> >
> > > 在 2018年8月31日,下午8:00,Yao, Jiewen 
> 写
> > 道:
> > >
> > > Good enhancement.
> > >
> > > I have 2 additional thought:
> > >
> > > 1) How to handle DSDT?
> > >

Re: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new EfiFindAcpiTableBySignature() API

2018-09-02 Thread Ni, Ruiyu
That's fine to be in UefiLib. It's already a combo library.

But I do recommend we think about how to handle multiple tables with same 
signature.
When we are adding new APIs, we not only need to evaluate the existing real 
case, but also
we need to generalize the real cases and try to think about the more flexible 
interface.


Thanks/Ray

> -Original Message-
> From: Zeng, Star
> Sent: Monday, September 3, 2018 11:26 AM
> To: Yao, Jiewen ; Ni, Ruiyu ;
> Kinney, Michael D 
> Cc: edk2-devel@lists.01.org; Younas khan ;
> Gao, Liming ; Zeng, Star 
> Subject: RE: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new
> EfiFindAcpiTableBySignature() API
> 
> Good idea.
> 
> I did consider DSDT and multiple SSDTs cases. But I did not find any real case
> for them.
> So I made the code simply for current cases, and the code can be easily
> enhanced later for DSDT, a new API can be added later for multiple SSDTs.
> 
> About adding the new API in UefiLib VS new library class, I did also consider 
> it
> and even created code for new library class
> (g...@github.com:lzeng14/edk2.git branch
> FindAcpiTableBySignature_UefiAcpiTableLib).
> But I remember I did discuss it with Mike and Jiewen, we recommended
> UefiLib as it will do not require any platform change.
> 
> 
> 
> Thanks,
> Star
> -Original Message-
> From: Yao, Jiewen
> Sent: Saturday, September 1, 2018 7:04 AM
> To: Ni, Ruiyu 
> Cc: Zeng, Star ; edk2-devel@lists.01.org; Kinney,
> Michael D ; Younas khan
> ; Gao, Liming 
> Subject: RE: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new
> EfiFindAcpiTableBySignature() API
> 
> Good idea on LocateNextAcpiTable().
> 
> 
> > -Original Message-
> > From: Ni, Ruiyu
> > Sent: Saturday, September 1, 2018 12:29 AM
> > To: Yao, Jiewen 
> > Cc: Zeng, Star ; edk2-devel@lists.01.org; Kinney,
> > Michael D ; Younas khan
> > ; Gao, Liming 
> > Subject: Re: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new
> > EfiFindAcpiTableBySignature() API
> >
> > I think LocateNextAcpiTable() is more proper to handle the multiple
> > tables with same signature. It will carry three parameters, one is the
> > table header stored in configuration table, one is the signature, another is
> the previous located table.
> > Can we return a common table header other than void*?
> >
> > Is there better place other than UefiLib?
> > Do we need to add a new library class like AcpiLib?
> >
> > 发自我的 iPhone
> >
> > > 在 2018年8月31日,下午8:00,Yao, Jiewen 
> 写
> > 道:
> > >
> > > Good enhancement.
> > >
> > > I have 2 additional thought:
> > >
> > > 1) How to handle DSDT?
> > > We have special code to handle FACS, but no DSDT.
> > >
> > > 2) How to handle SSDT or other multiple ACPI tables?
> > > We may have multiple SSDT. Usually, it is identified as OEMID.
> > > Do we want to provide similar function for them?
> > >
> > > Anyway, just *additional* thought. :-) Current implementation is
> > > good enough for check in.
> > >
> > > Reviewed-by: jiewen....@intel.com
> > >
> > > Thank you
> > > Yao Jiewen
> > >
> > >
> > >> -Original Message-
> > >> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf
> > >> Of
> > Star
> > >> Zeng
> > >> Sent: Friday, August 31, 2018 7:29 PM
> > >> To: edk2-devel@lists.01.org
> > >> Cc: Kinney, Michael D ; Younas khan
> > >> ; Yao, Jiewen
> ;
> > Gao,
> > >> Liming ; Zeng, Star 
> > >> Subject: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new
> > >> EfiFindAcpiTableBySignature() API
> > >>
> > >> https://bugzilla.tianocore.org/show_bug.cgi?id=967
> > >> Request to add a library function for GetAcpiTable() in order to
> > >> get ACPI table using signature as input.
> > >>
> > >> After evaluation, we found there are many duplicated code to find
> > >> ACPI table by signature in different modules.
> > >>
> > >> This patch adds new EfiFindAcpiTableBySignature() API in UefiLib
> > >> for the request and also the following patch to remove the
> > >> duplicated code.
> > >>
> > >> Cc: Younas khan 
> > >> Cc: Michael D Kinney 
> > >> Cc: Liming Gao 
> > >> Cc: Jiewen Yao 
> > >> Contributed-under: TianoCore Contribution Agreement 1.1
> > >> Signed-off-by: Star Zeng 
> > >> ---
> > &

Re: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new EfiFindAcpiTableBySignature() API

2018-09-02 Thread Zeng, Star
Good idea.

I did consider DSDT and multiple SSDTs cases. But I did not find any real case 
for them.
So I made the code simply for current cases, and the code can be easily 
enhanced later for DSDT, a new API can be added later for multiple SSDTs.

About adding the new API in UefiLib VS new library class, I did also consider 
it and even created code for new library class 
(g...@github.com:lzeng14/edk2.git branch 
FindAcpiTableBySignature_UefiAcpiTableLib).
But I remember I did discuss it with Mike and Jiewen, we recommended UefiLib as 
it will do not require any platform change.



Thanks,
Star
-Original Message-
From: Yao, Jiewen 
Sent: Saturday, September 1, 2018 7:04 AM
To: Ni, Ruiyu 
Cc: Zeng, Star ; edk2-devel@lists.01.org; Kinney, Michael 
D ; Younas khan ; Gao, 
Liming 
Subject: RE: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new 
EfiFindAcpiTableBySignature() API

Good idea on LocateNextAcpiTable().


> -Original Message-
> From: Ni, Ruiyu
> Sent: Saturday, September 1, 2018 12:29 AM
> To: Yao, Jiewen 
> Cc: Zeng, Star ; edk2-devel@lists.01.org; Kinney, 
> Michael D ; Younas khan 
> ; Gao, Liming 
> Subject: Re: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new
> EfiFindAcpiTableBySignature() API
> 
> I think LocateNextAcpiTable() is more proper to handle the multiple 
> tables with same signature. It will carry three parameters, one is the 
> table header stored in configuration table, one is the signature, another is 
> the previous located table.
> Can we return a common table header other than void*?
> 
> Is there better place other than UefiLib?
> Do we need to add a new library class like AcpiLib?
> 
> 发自我的 iPhone
> 
> > 在 2018年8月31日,下午8:00,Yao, Jiewen  写
> 道:
> >
> > Good enhancement.
> >
> > I have 2 additional thought:
> >
> > 1) How to handle DSDT?
> > We have special code to handle FACS, but no DSDT.
> >
> > 2) How to handle SSDT or other multiple ACPI tables?
> > We may have multiple SSDT. Usually, it is identified as OEMID.
> > Do we want to provide similar function for them?
> >
> > Anyway, just *additional* thought. :-) Current implementation is 
> > good enough for check in.
> >
> > Reviewed-by: jiewen@intel.com
> >
> > Thank you
> > Yao Jiewen
> >
> >
> >> -Original Message-
> >> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf 
> >> Of
> Star
> >> Zeng
> >> Sent: Friday, August 31, 2018 7:29 PM
> >> To: edk2-devel@lists.01.org
> >> Cc: Kinney, Michael D ; Younas khan 
> >> ; Yao, Jiewen ;
> Gao,
> >> Liming ; Zeng, Star 
> >> Subject: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new
> >> EfiFindAcpiTableBySignature() API
> >>
> >> https://bugzilla.tianocore.org/show_bug.cgi?id=967
> >> Request to add a library function for GetAcpiTable() in order to 
> >> get ACPI table using signature as input.
> >>
> >> After evaluation, we found there are many duplicated code to find 
> >> ACPI table by signature in different modules.
> >>
> >> This patch adds new EfiFindAcpiTableBySignature() API in UefiLib 
> >> for the request and also the following patch to remove the 
> >> duplicated code.
> >>
> >> Cc: Younas khan 
> >> Cc: Michael D Kinney 
> >> Cc: Liming Gao 
> >> Cc: Jiewen Yao 
> >> Contributed-under: TianoCore Contribution Agreement 1.1
> >> Signed-off-by: Star Zeng 
> >> ---
> >> MdePkg/Include/Library/UefiLib.h   |  17 +++
> >> MdePkg/Library/UefiLib/Acpi.c  | 226
> >> +
> >> MdePkg/Library/UefiLib/UefiLib.inf |   3 +
> >> 3 files changed, 246 insertions(+)
> >> create mode 100644 MdePkg/Library/UefiLib/Acpi.c
> >>
> >> diff --git a/MdePkg/Include/Library/UefiLib.h
> >> b/MdePkg/Include/Library/UefiLib.h
> >> index f80067f11103..8dd25f324fd2 100644
> >> --- a/MdePkg/Include/Library/UefiLib.h
> >> +++ b/MdePkg/Include/Library/UefiLib.h
> >> @@ -1595,4 +1595,21 @@ EfiOpenFileByDevicePath (
> >>  IN UINT64OpenMode,
> >>  IN UINT64Attributes
> >>  );
> >> +
> >> +/**
> >> +  This function finds ACPI table by signature.
> >> +  It will find the table in gEfiAcpi20TableGuid system 
> >> +configuration table
> first,
> >> +  and then gEfiAcpi10TableGuid system configuration table.
> >> +
> >> +  @param Signature  ACPI table signature.
> >> +
> >> +  @return ACPI table or 

Re: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new EfiFindAcpiTableBySignature() API

2018-08-31 Thread Yao, Jiewen
Good idea on LocateNextAcpiTable().


> -Original Message-
> From: Ni, Ruiyu
> Sent: Saturday, September 1, 2018 12:29 AM
> To: Yao, Jiewen 
> Cc: Zeng, Star ; edk2-devel@lists.01.org; Kinney, Michael
> D ; Younas khan
> ; Gao, Liming 
> Subject: Re: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new
> EfiFindAcpiTableBySignature() API
> 
> I think LocateNextAcpiTable() is more proper to handle the multiple tables 
> with
> same signature. It will carry three parameters, one is the table header 
> stored in
> configuration table, one is the signature, another is the previous located 
> table.
> Can we return a common table header other than void*?
> 
> Is there better place other than UefiLib?
> Do we need to add a new library class like AcpiLib?
> 
> 发自我的 iPhone
> 
> > 在 2018年8月31日,下午8:00,Yao, Jiewen  写
> 道:
> >
> > Good enhancement.
> >
> > I have 2 additional thought:
> >
> > 1) How to handle DSDT?
> > We have special code to handle FACS, but no DSDT.
> >
> > 2) How to handle SSDT or other multiple ACPI tables?
> > We may have multiple SSDT. Usually, it is identified as OEMID.
> > Do we want to provide similar function for them?
> >
> > Anyway, just *additional* thought. :-)
> > Current implementation is good enough for check in.
> >
> > Reviewed-by: jiewen@intel.com
> >
> > Thank you
> > Yao Jiewen
> >
> >
> >> -Original Message-
> >> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Star
> >> Zeng
> >> Sent: Friday, August 31, 2018 7:29 PM
> >> To: edk2-devel@lists.01.org
> >> Cc: Kinney, Michael D ; Younas khan
> >> ; Yao, Jiewen ;
> Gao,
> >> Liming ; Zeng, Star 
> >> Subject: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new
> >> EfiFindAcpiTableBySignature() API
> >>
> >> https://bugzilla.tianocore.org/show_bug.cgi?id=967
> >> Request to add a library function for GetAcpiTable() in order
> >> to get ACPI table using signature as input.
> >>
> >> After evaluation, we found there are many duplicated code to
> >> find ACPI table by signature in different modules.
> >>
> >> This patch adds new EfiFindAcpiTableBySignature() API in UefiLib
> >> for the request and also the following patch to remove the
> >> duplicated code.
> >>
> >> Cc: Younas khan 
> >> Cc: Michael D Kinney 
> >> Cc: Liming Gao 
> >> Cc: Jiewen Yao 
> >> Contributed-under: TianoCore Contribution Agreement 1.1
> >> Signed-off-by: Star Zeng 
> >> ---
> >> MdePkg/Include/Library/UefiLib.h   |  17 +++
> >> MdePkg/Library/UefiLib/Acpi.c  | 226
> >> +
> >> MdePkg/Library/UefiLib/UefiLib.inf |   3 +
> >> 3 files changed, 246 insertions(+)
> >> create mode 100644 MdePkg/Library/UefiLib/Acpi.c
> >>
> >> diff --git a/MdePkg/Include/Library/UefiLib.h
> >> b/MdePkg/Include/Library/UefiLib.h
> >> index f80067f11103..8dd25f324fd2 100644
> >> --- a/MdePkg/Include/Library/UefiLib.h
> >> +++ b/MdePkg/Include/Library/UefiLib.h
> >> @@ -1595,4 +1595,21 @@ EfiOpenFileByDevicePath (
> >>  IN UINT64OpenMode,
> >>  IN UINT64Attributes
> >>  );
> >> +
> >> +/**
> >> +  This function finds ACPI table by signature.
> >> +  It will find the table in gEfiAcpi20TableGuid system configuration table
> first,
> >> +  and then gEfiAcpi10TableGuid system configuration table.
> >> +
> >> +  @param Signature  ACPI table signature.
> >> +
> >> +  @return ACPI table or NULL if not found.
> >> +
> >> +**/
> >> +VOID *
> >> +EFIAPI
> >> +EfiFindAcpiTableBySignature (
> >> +  IN UINT32 Signature
> >> +  );
> >> +
> >> #endif
> >> diff --git a/MdePkg/Library/UefiLib/Acpi.c b/MdePkg/Library/UefiLib/Acpi.c
> >> new file mode 100644
> >> index ..5cb93966b59f
> >> --- /dev/null
> >> +++ b/MdePkg/Library/UefiLib/Acpi.c
> >> @@ -0,0 +1,226 @@
> >> +/** @file
> >> +  This module provides help function for finding ACPI table.
> >> +
> >> +  Copyright (c) 2018, Intel Corporation. All rights reserved.
> >> +  This program and the accompanying materials
> >> +  are licensed and made available under the terms and conditions of the
> BSD
> >> License
> >> +  

Re: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new EfiFindAcpiTableBySignature() API

2018-08-31 Thread Ni, Ruiyu
I think LocateNextAcpiTable() is more proper to handle the multiple tables with 
same signature. It will carry three parameters, one is the table header stored 
in configuration table, one is the signature, another is the previous located 
table. Can we return a common table header other than void*?

Is there better place other than UefiLib?
Do we need to add a new library class like AcpiLib?

发自我的 iPhone

> 在 2018年8月31日,下午8:00,Yao, Jiewen  写道:
> 
> Good enhancement.
> 
> I have 2 additional thought:
> 
> 1) How to handle DSDT?
> We have special code to handle FACS, but no DSDT.
> 
> 2) How to handle SSDT or other multiple ACPI tables?
> We may have multiple SSDT. Usually, it is identified as OEMID.
> Do we want to provide similar function for them?
> 
> Anyway, just *additional* thought. :-)
> Current implementation is good enough for check in.
> 
> Reviewed-by: jiewen@intel.com
> 
> Thank you
> Yao Jiewen
> 
> 
>> -Original Message-
>> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Star
>> Zeng
>> Sent: Friday, August 31, 2018 7:29 PM
>> To: edk2-devel@lists.01.org
>> Cc: Kinney, Michael D ; Younas khan
>> ; Yao, Jiewen ; Gao,
>> Liming ; Zeng, Star 
>> Subject: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new
>> EfiFindAcpiTableBySignature() API
>> 
>> https://bugzilla.tianocore.org/show_bug.cgi?id=967
>> Request to add a library function for GetAcpiTable() in order
>> to get ACPI table using signature as input.
>> 
>> After evaluation, we found there are many duplicated code to
>> find ACPI table by signature in different modules.
>> 
>> This patch adds new EfiFindAcpiTableBySignature() API in UefiLib
>> for the request and also the following patch to remove the
>> duplicated code.
>> 
>> Cc: Younas khan 
>> Cc: Michael D Kinney 
>> Cc: Liming Gao 
>> Cc: Jiewen Yao 
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Star Zeng 
>> ---
>> MdePkg/Include/Library/UefiLib.h   |  17 +++
>> MdePkg/Library/UefiLib/Acpi.c  | 226
>> +
>> MdePkg/Library/UefiLib/UefiLib.inf |   3 +
>> 3 files changed, 246 insertions(+)
>> create mode 100644 MdePkg/Library/UefiLib/Acpi.c
>> 
>> diff --git a/MdePkg/Include/Library/UefiLib.h
>> b/MdePkg/Include/Library/UefiLib.h
>> index f80067f11103..8dd25f324fd2 100644
>> --- a/MdePkg/Include/Library/UefiLib.h
>> +++ b/MdePkg/Include/Library/UefiLib.h
>> @@ -1595,4 +1595,21 @@ EfiOpenFileByDevicePath (
>>   IN UINT64OpenMode,
>>   IN UINT64Attributes
>>   );
>> +
>> +/**
>> +  This function finds ACPI table by signature.
>> +  It will find the table in gEfiAcpi20TableGuid system configuration table 
>> first,
>> +  and then gEfiAcpi10TableGuid system configuration table.
>> +
>> +  @param Signature  ACPI table signature.
>> +
>> +  @return ACPI table or NULL if not found.
>> +
>> +**/
>> +VOID *
>> +EFIAPI
>> +EfiFindAcpiTableBySignature (
>> +  IN UINT32 Signature
>> +  );
>> +
>> #endif
>> diff --git a/MdePkg/Library/UefiLib/Acpi.c b/MdePkg/Library/UefiLib/Acpi.c
>> new file mode 100644
>> index ..5cb93966b59f
>> --- /dev/null
>> +++ b/MdePkg/Library/UefiLib/Acpi.c
>> @@ -0,0 +1,226 @@
>> +/** @file
>> +  This module provides help function for finding ACPI table.
>> +
>> +  Copyright (c) 2018, Intel Corporation. All rights reserved.
>> +  This program and the accompanying materials
>> +  are licensed and made available under the terms and conditions of the BSD
>> License
>> +  which accompanies this distribution.  The full text of the license may be
>> found at
>> +  http://opensource.org/licenses/bsd-license.php.
>> +
>> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
>> BASIS,
>> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
>> EXPRESS OR IMPLIED.
>> +
>> +**/
>> +
>> +#include "UefiLibInternal.h"
>> +#include 
>> +#include 
>> +
>> +/**
>> +  This function scans ACPI table in RSDT.
>> +
>> +  @param Rsdt   ACPI RSDT
>> +  @param Signature  ACPI table signature
>> +
>> +  @return ACPI table or NULL if not found.
>> +
>> +**/
>> +VOID *
>> +ScanTableInRSDT (
>> +  IN EFI_ACPI_DESCRIPTION_HEADER*Rsdt,
>> +  IN UINT32 Signature
>> +  )

Re: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new EfiFindAcpiTableBySignature() API

2018-08-31 Thread Ni, Ruiyu
I think LocateNextAcpiTable() is more proper to handle the multiple tables with 
same signature. It will carry three parameters, one is the table header stored 
in configuration table, one is the signature, another is the previous located 
table. Can we return a common table header other than void*?

Is there better place other than UefiLib?
Do we need to add a new library class like AcpiLib?

发自我的 iPhone

> 在 2018年8月31日,下午8:00,Yao, Jiewen  写道:
> 
> Good enhancement.
> 
> I have 2 additional thought:
> 
> 1) How to handle DSDT?
> We have special code to handle FACS, but no DSDT.
> 
> 2) How to handle SSDT or other multiple ACPI tables?
> We may have multiple SSDT. Usually, it is identified as OEMID.
> Do we want to provide similar function for them?
> 
> Anyway, just *additional* thought. :-)
> Current implementation is good enough for check in.
> 
> Reviewed-by: jiewen@intel.com
> 
> Thank you
> Yao Jiewen
> 
> 
>> -Original Message-
>> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Star
>> Zeng
>> Sent: Friday, August 31, 2018 7:29 PM
>> To: edk2-devel@lists.01.org
>> Cc: Kinney, Michael D ; Younas khan
>> ; Yao, Jiewen ; Gao,
>> Liming ; Zeng, Star 
>> Subject: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new
>> EfiFindAcpiTableBySignature() API
>> 
>> https://bugzilla.tianocore.org/show_bug.cgi?id=967
>> Request to add a library function for GetAcpiTable() in order
>> to get ACPI table using signature as input.
>> 
>> After evaluation, we found there are many duplicated code to
>> find ACPI table by signature in different modules.
>> 
>> This patch adds new EfiFindAcpiTableBySignature() API in UefiLib
>> for the request and also the following patch to remove the
>> duplicated code.
>> 
>> Cc: Younas khan 
>> Cc: Michael D Kinney 
>> Cc: Liming Gao 
>> Cc: Jiewen Yao 
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Star Zeng 
>> ---
>> MdePkg/Include/Library/UefiLib.h   |  17 +++
>> MdePkg/Library/UefiLib/Acpi.c  | 226
>> +
>> MdePkg/Library/UefiLib/UefiLib.inf |   3 +
>> 3 files changed, 246 insertions(+)
>> create mode 100644 MdePkg/Library/UefiLib/Acpi.c
>> 
>> diff --git a/MdePkg/Include/Library/UefiLib.h
>> b/MdePkg/Include/Library/UefiLib.h
>> index f80067f11103..8dd25f324fd2 100644
>> --- a/MdePkg/Include/Library/UefiLib.h
>> +++ b/MdePkg/Include/Library/UefiLib.h
>> @@ -1595,4 +1595,21 @@ EfiOpenFileByDevicePath (
>>  IN UINT64OpenMode,
>>  IN UINT64Attributes
>>  );
>> +
>> +/**
>> +  This function finds ACPI table by signature.
>> +  It will find the table in gEfiAcpi20TableGuid system configuration table 
>> first,
>> +  and then gEfiAcpi10TableGuid system configuration table.
>> +
>> +  @param Signature  ACPI table signature.
>> +
>> +  @return ACPI table or NULL if not found.
>> +
>> +**/
>> +VOID *
>> +EFIAPI
>> +EfiFindAcpiTableBySignature (
>> +  IN UINT32 Signature
>> +  );
>> +
>> #endif
>> diff --git a/MdePkg/Library/UefiLib/Acpi.c b/MdePkg/Library/UefiLib/Acpi.c
>> new file mode 100644
>> index ..5cb93966b59f
>> --- /dev/null
>> +++ b/MdePkg/Library/UefiLib/Acpi.c
>> @@ -0,0 +1,226 @@
>> +/** @file
>> +  This module provides help function for finding ACPI table.
>> +
>> +  Copyright (c) 2018, Intel Corporation. All rights reserved.
>> +  This program and the accompanying materials
>> +  are licensed and made available under the terms and conditions of the BSD
>> License
>> +  which accompanies this distribution.  The full text of the license may be
>> found at
>> +  http://opensource.org/licenses/bsd-license.php.
>> +
>> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
>> BASIS,
>> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
>> EXPRESS OR IMPLIED.
>> +
>> +**/
>> +
>> +#include "UefiLibInternal.h"
>> +#include 
>> +#include 
>> +
>> +/**
>> +  This function scans ACPI table in RSDT.
>> +
>> +  @param Rsdt   ACPI RSDT
>> +  @param Signature  ACPI table signature
>> +
>> +  @return ACPI table or NULL if not found.
>> +
>> +**/
>> +VOID *
>> +ScanTableInRSDT (
>> +  IN EFI_ACPI_DESCRIPTION_HEADER*Rsdt,
>> +  IN UINT32 Signature
>> +  )

Re: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new EfiFindAcpiTableBySignature() API

2018-08-31 Thread Yao, Jiewen
Good enhancement.

I have 2 additional thought:

1) How to handle DSDT?
We have special code to handle FACS, but no DSDT.

2) How to handle SSDT or other multiple ACPI tables?
We may have multiple SSDT. Usually, it is identified as OEMID.
Do we want to provide similar function for them?

Anyway, just *additional* thought. :-)
Current implementation is good enough for check in.

Reviewed-by: jiewen@intel.com

Thank you
Yao Jiewen


> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Star
> Zeng
> Sent: Friday, August 31, 2018 7:29 PM
> To: edk2-devel@lists.01.org
> Cc: Kinney, Michael D ; Younas khan
> ; Yao, Jiewen ; Gao,
> Liming ; Zeng, Star 
> Subject: [edk2] [PATCH 1/6] MdePkg UefiLib: Add new
> EfiFindAcpiTableBySignature() API
> 
> https://bugzilla.tianocore.org/show_bug.cgi?id=967
> Request to add a library function for GetAcpiTable() in order
> to get ACPI table using signature as input.
> 
> After evaluation, we found there are many duplicated code to
> find ACPI table by signature in different modules.
> 
> This patch adds new EfiFindAcpiTableBySignature() API in UefiLib
> for the request and also the following patch to remove the
> duplicated code.
> 
> Cc: Younas khan 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Jiewen Yao 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng 
> ---
>  MdePkg/Include/Library/UefiLib.h   |  17 +++
>  MdePkg/Library/UefiLib/Acpi.c  | 226
> +
>  MdePkg/Library/UefiLib/UefiLib.inf |   3 +
>  3 files changed, 246 insertions(+)
>  create mode 100644 MdePkg/Library/UefiLib/Acpi.c
> 
> diff --git a/MdePkg/Include/Library/UefiLib.h
> b/MdePkg/Include/Library/UefiLib.h
> index f80067f11103..8dd25f324fd2 100644
> --- a/MdePkg/Include/Library/UefiLib.h
> +++ b/MdePkg/Include/Library/UefiLib.h
> @@ -1595,4 +1595,21 @@ EfiOpenFileByDevicePath (
>IN UINT64OpenMode,
>IN UINT64Attributes
>);
> +
> +/**
> +  This function finds ACPI table by signature.
> +  It will find the table in gEfiAcpi20TableGuid system configuration table 
> first,
> +  and then gEfiAcpi10TableGuid system configuration table.
> +
> +  @param Signature  ACPI table signature.
> +
> +  @return ACPI table or NULL if not found.
> +
> +**/
> +VOID *
> +EFIAPI
> +EfiFindAcpiTableBySignature (
> +  IN UINT32 Signature
> +  );
> +
>  #endif
> diff --git a/MdePkg/Library/UefiLib/Acpi.c b/MdePkg/Library/UefiLib/Acpi.c
> new file mode 100644
> index ..5cb93966b59f
> --- /dev/null
> +++ b/MdePkg/Library/UefiLib/Acpi.c
> @@ -0,0 +1,226 @@
> +/** @file
> +  This module provides help function for finding ACPI table.
> +
> +  Copyright (c) 2018, Intel Corporation. All rights reserved.
> +  This program and the accompanying materials
> +  are licensed and made available under the terms and conditions of the BSD
> License
> +  which accompanies this distribution.  The full text of the license may be
> found at
> +  http://opensource.org/licenses/bsd-license.php.
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#include "UefiLibInternal.h"
> +#include 
> +#include 
> +
> +/**
> +  This function scans ACPI table in RSDT.
> +
> +  @param Rsdt   ACPI RSDT
> +  @param Signature  ACPI table signature
> +
> +  @return ACPI table or NULL if not found.
> +
> +**/
> +VOID *
> +ScanTableInRSDT (
> +  IN EFI_ACPI_DESCRIPTION_HEADER*Rsdt,
> +  IN UINT32 Signature
> +  )
> +{
> +  UINTN  Index;
> +  UINT32 EntryCount;
> +  UINT32 *EntryPtr;
> +  EFI_ACPI_DESCRIPTION_HEADER*Table;
> +
> +  if (Rsdt == NULL) {
> +return NULL;
> +  }
> +
> +  EntryCount = (Rsdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) /
> sizeof(UINT32);
> +
> +  EntryPtr = (UINT32 *)(Rsdt + 1);
> +  for (Index = 0; Index < EntryCount; Index ++, EntryPtr ++) {
> +Table = (EFI_ACPI_DESCRIPTION_HEADER *)((UINTN)(*EntryPtr));
> +if (Table->Signature == Signature) {
> +  return Table;
> +}
> +  }
> +
> +  return NULL;
> +}
> +
> +/**
> +  This function scans ACPI table in XSDT.
> +
> +  @param Xsdt   ACPI XSDT
> +  @param Signature  ACPI table signature
> +
> +  @return ACPI table or NULL if not found.
> +
> +**/
> +VOID *
> 

[edk2] [PATCH 1/6] MdePkg UefiLib: Add new EfiFindAcpiTableBySignature() API

2018-08-31 Thread Star Zeng
https://bugzilla.tianocore.org/show_bug.cgi?id=967
Request to add a library function for GetAcpiTable() in order
to get ACPI table using signature as input.

After evaluation, we found there are many duplicated code to
find ACPI table by signature in different modules.

This patch adds new EfiFindAcpiTableBySignature() API in UefiLib
for the request and also the following patch to remove the
duplicated code.

Cc: Younas khan 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Jiewen Yao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
---
 MdePkg/Include/Library/UefiLib.h   |  17 +++
 MdePkg/Library/UefiLib/Acpi.c  | 226 +
 MdePkg/Library/UefiLib/UefiLib.inf |   3 +
 3 files changed, 246 insertions(+)
 create mode 100644 MdePkg/Library/UefiLib/Acpi.c

diff --git a/MdePkg/Include/Library/UefiLib.h b/MdePkg/Include/Library/UefiLib.h
index f80067f11103..8dd25f324fd2 100644
--- a/MdePkg/Include/Library/UefiLib.h
+++ b/MdePkg/Include/Library/UefiLib.h
@@ -1595,4 +1595,21 @@ EfiOpenFileByDevicePath (
   IN UINT64OpenMode,
   IN UINT64Attributes
   );
+
+/**
+  This function finds ACPI table by signature.
+  It will find the table in gEfiAcpi20TableGuid system configuration table 
first,
+  and then gEfiAcpi10TableGuid system configuration table.
+
+  @param Signature  ACPI table signature.
+
+  @return ACPI table or NULL if not found.
+
+**/
+VOID *
+EFIAPI
+EfiFindAcpiTableBySignature (
+  IN UINT32 Signature
+  );
+
 #endif
diff --git a/MdePkg/Library/UefiLib/Acpi.c b/MdePkg/Library/UefiLib/Acpi.c
new file mode 100644
index ..5cb93966b59f
--- /dev/null
+++ b/MdePkg/Library/UefiLib/Acpi.c
@@ -0,0 +1,226 @@
+/** @file
+  This module provides help function for finding ACPI table.
+
+  Copyright (c) 2018, Intel Corporation. All rights reserved.
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php.
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include "UefiLibInternal.h"
+#include 
+#include 
+
+/**
+  This function scans ACPI table in RSDT.
+
+  @param Rsdt   ACPI RSDT
+  @param Signature  ACPI table signature
+
+  @return ACPI table or NULL if not found.
+
+**/
+VOID *
+ScanTableInRSDT (
+  IN EFI_ACPI_DESCRIPTION_HEADER*Rsdt,
+  IN UINT32 Signature
+  )
+{
+  UINTN  Index;
+  UINT32 EntryCount;
+  UINT32 *EntryPtr;
+  EFI_ACPI_DESCRIPTION_HEADER*Table;
+
+  if (Rsdt == NULL) {
+return NULL;
+  }
+
+  EntryCount = (Rsdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / 
sizeof(UINT32);
+
+  EntryPtr = (UINT32 *)(Rsdt + 1);
+  for (Index = 0; Index < EntryCount; Index ++, EntryPtr ++) {
+Table = (EFI_ACPI_DESCRIPTION_HEADER *)((UINTN)(*EntryPtr));
+if (Table->Signature == Signature) {
+  return Table;
+}
+  }
+
+  return NULL;
+}
+
+/**
+  This function scans ACPI table in XSDT.
+
+  @param Xsdt   ACPI XSDT
+  @param Signature  ACPI table signature
+
+  @return ACPI table or NULL if not found.
+
+**/
+VOID *
+ScanTableInXSDT (
+  IN EFI_ACPI_DESCRIPTION_HEADER*Xsdt,
+  IN UINT32 Signature
+  )
+{
+  UINTN  Index;
+  UINT32 EntryCount;
+  UINT64 EntryPtr;
+  UINTN  BasePtr;
+  EFI_ACPI_DESCRIPTION_HEADER*Table;
+
+  if (Xsdt == NULL) {
+return NULL;
+  }
+
+  EntryCount = (Xsdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / 
sizeof(UINT64);
+
+  BasePtr = (UINTN)(Xsdt + 1);
+  for (Index = 0; Index < EntryCount; Index ++) {
+CopyMem (, (VOID *)(BasePtr + Index * sizeof(UINT64)), 
sizeof(UINT64));
+Table = (EFI_ACPI_DESCRIPTION_HEADER *)((UINTN)(EntryPtr));
+if (Table->Signature == Signature) {
+  return Table;
+}
+  }
+
+  return NULL;
+}
+
+/**
+  To find Facs in FADT.
+
+  @param Fadt   FADT table pointer
+
+  @return Facs table pointer or NULL if not found.
+
+**/
+EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *
+FindAcpiFacsFromFadt (
+  IN EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE  *Fadt
+  )
+{
+  EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE  *Facs;
+  UINT64Data64;
+
+  if (Fadt == NULL) {
+return NULL;
+  }
+
+  if (Fadt->Header.Revision < 
EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION) {
+Facs = (EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE 
*)(UINTN)Fadt->FirmwareCtrl;
+  } else {
+CopyMem (, >XFirmwareCtrl, sizeof(UINT64));
+if (Data64 != 0) {
+  Facs =