* [Patch V3 1/9] MdeModulePkg: Add Universal Payload general defination header file
2021-06-04 9:42 [Patch V3 0/9] Create multiple Hobs for Universal Payload Zhiguang Liu
@ 2021-06-04 9:42 ` Zhiguang Liu
2021-06-08 5:20 ` Wu, Hao A
2021-06-08 16:25 ` Michael D Kinney
2021-06-04 9:42 ` [Patch V3 2/9] MdeModulePkg: Add new structure for the PCI Root Bridge Info Hob Zhiguang Liu
` (7 subsequent siblings)
8 siblings, 2 replies; 22+ messages in thread
From: Zhiguang Liu @ 2021-06-04 9:42 UTC (permalink / raw)
To: devel; +Cc: Michael D Kinney, Liming Gao, Jian J Wang, Hao A Wu
V1:
Add Universal Payload general defination header file according to
Universal Payload’s documentation
V2:
Add a macro funtion to check the Revision
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
---
MdeModulePkg/Include/UniversalPayload/UniversalPayload.h | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/MdeModulePkg/Include/UniversalPayload/UniversalPayload.h b/MdeModulePkg/Include/UniversalPayload/UniversalPayload.h
new file mode 100644
index 0000000000..627b9e880e
--- /dev/null
+++ b/MdeModulePkg/Include/UniversalPayload/UniversalPayload.h
@@ -0,0 +1,33 @@
+/** @file
+ Universal Payload general definations.
+
+Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef __UNIVERSAL_PAYLOAD_H__
+#define __UNIVERSAL_PAYLOAD_H__
+
+#pragma pack(1)
+
+typedef struct {
+ UINT8 Revision;
+ UINT8 Reserved;
+ UINT16 Length;
+} PLD_GENERIC_HEADER;
+
+#pragma pack()
+
+/**
+ Returns the size of a structure of known type, up through and including a specified field.
+
+ @param TYPE The name of the data structure that contains the field specified by Field.
+ @param Field The name of the field in the data structure.
+
+ @return size, in bytes.
+
+**/
+#define PLD_SIZEOF_THROUGH_FIELD(TYPE, Field) (OFFSET_OF(TYPE, Field) + sizeof (((TYPE *) 0)->Field))
+
+#endif // __UNIVERSAL_PAYLOAD_H__
--
2.30.0.windows.2
^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [Patch V3 1/9] MdeModulePkg: Add Universal Payload general defination header file
2021-06-04 9:42 ` [Patch V3 1/9] MdeModulePkg: Add Universal Payload general defination header file Zhiguang Liu
@ 2021-06-08 5:20 ` Wu, Hao A
2021-06-08 16:25 ` Michael D Kinney
1 sibling, 0 replies; 22+ messages in thread
From: Wu, Hao A @ 2021-06-08 5:20 UTC (permalink / raw)
To: Liu, Zhiguang, devel@edk2.groups.io
Cc: Kinney, Michael D, Liming Gao, Wang, Jian J
> -----Original Message-----
> From: Liu, Zhiguang <zhiguang.liu@intel.com>
> Sent: Friday, June 4, 2021 5:42 PM
> To: devel@edk2.groups.io
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao
> <gaoliming@byosoft.com.cn>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao
> A <hao.a.wu@intel.com>
> Subject: [Patch V3 1/9] MdeModulePkg: Add Universal Payload general
> defination header file
s/defination/definition
(multiple occurrences in commit message and source codes)
>
> V1:
> Add Universal Payload general defination header file according to
> Universal Payload’s documentation
Looks like "’" is a non-ascii character, please help to remove it.
Also, please help to add the documentation link in this commit message. Thanks.
> V2:
> Add a macro funtion to check the Revision
funtion -> function
>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
>
> Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
> ---
> MdeModulePkg/Include/UniversalPayload/UniversalPayload.h | 33
> +++++++++++++++++++++++++++++++++
> 1 file changed, 33 insertions(+)
>
> diff --git a/MdeModulePkg/Include/UniversalPayload/UniversalPayload.h
> b/MdeModulePkg/Include/UniversalPayload/UniversalPayload.h
> new file mode 100644
> index 0000000000..627b9e880e
> --- /dev/null
> +++ b/MdeModulePkg/Include/UniversalPayload/UniversalPayload.h
> @@ -0,0 +1,33 @@
> +/** @file
>
> + Universal Payload general definations.
>
> +
>
> +Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
>
> +SPDX-License-Identifier: BSD-2-Clause-Patent
>
> +
Could you help to add the specification reference information in the header file description comment?
You may refer to below file for an example:
MdePkg\Include\IndustryStandard\IpmiFruInformationStorage.h
With these handled:
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
Best Regards,
Hao Wu
>
> +**/
>
> +
>
> +#ifndef __UNIVERSAL_PAYLOAD_H__
>
> +#define __UNIVERSAL_PAYLOAD_H__
>
> +
>
> +#pragma pack(1)
>
> +
>
> +typedef struct {
>
> + UINT8 Revision;
>
> + UINT8 Reserved;
>
> + UINT16 Length;
>
> +} PLD_GENERIC_HEADER;
>
> +
>
> +#pragma pack()
>
> +
>
> +/**
>
> + Returns the size of a structure of known type, up through and including a
> specified field.
>
> +
>
> + @param TYPE The name of the data structure that contains the field
> specified by Field.
>
> + @param Field The name of the field in the data structure.
>
> +
>
> + @return size, in bytes.
>
> +
>
> +**/
>
> +#define PLD_SIZEOF_THROUGH_FIELD(TYPE, Field) (OFFSET_OF(TYPE, Field) +
> sizeof (((TYPE *) 0)->Field))
>
> +
>
> +#endif // __UNIVERSAL_PAYLOAD_H__
>
> --
> 2.30.0.windows.2
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Patch V3 1/9] MdeModulePkg: Add Universal Payload general defination header file
2021-06-04 9:42 ` [Patch V3 1/9] MdeModulePkg: Add Universal Payload general defination header file Zhiguang Liu
2021-06-08 5:20 ` Wu, Hao A
@ 2021-06-08 16:25 ` Michael D Kinney
2021-06-09 2:58 ` [edk2-devel] " Ni, Ray
1 sibling, 1 reply; 22+ messages in thread
From: Michael D Kinney @ 2021-06-08 16:25 UTC (permalink / raw)
To: Liu, Zhiguang, devel@edk2.groups.io, Kinney, Michael D
Cc: Liming Gao, Wang, Jian J, Wu, Hao A
I see use of the abbreviation PLD in this series.
PLD is sometimes interpreted as Programmable Logic Device.
Given this is for Universal Payload, I recommend using UNIVERSAL_PAYLOAD or PAYLOAD as appropriate.
Mike
> -----Original Message-----
> From: Liu, Zhiguang <zhiguang.liu@intel.com>
> Sent: Friday, June 4, 2021 2:42 AM
> To: devel@edk2.groups.io
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>; Wang, Jian J
> <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>
> Subject: [Patch V3 1/9] MdeModulePkg: Add Universal Payload general defination header file
>
> V1:
> Add Universal Payload general defination header file according to
> Universal Payload’s documentation
> V2:
> Add a macro funtion to check the Revision
>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
>
> Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
> ---
> MdeModulePkg/Include/UniversalPayload/UniversalPayload.h | 33 +++++++++++++++++++++++++++++++++
> 1 file changed, 33 insertions(+)
>
> diff --git a/MdeModulePkg/Include/UniversalPayload/UniversalPayload.h
> b/MdeModulePkg/Include/UniversalPayload/UniversalPayload.h
> new file mode 100644
> index 0000000000..627b9e880e
> --- /dev/null
> +++ b/MdeModulePkg/Include/UniversalPayload/UniversalPayload.h
> @@ -0,0 +1,33 @@
> +/** @file
>
> + Universal Payload general definations.
>
> +
>
> +Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
>
> +SPDX-License-Identifier: BSD-2-Clause-Patent
>
> +
>
> +**/
>
> +
>
> +#ifndef __UNIVERSAL_PAYLOAD_H__
>
> +#define __UNIVERSAL_PAYLOAD_H__
>
> +
>
> +#pragma pack(1)
>
> +
>
> +typedef struct {
>
> + UINT8 Revision;
>
> + UINT8 Reserved;
>
> + UINT16 Length;
>
> +} PLD_GENERIC_HEADER;
>
> +
>
> +#pragma pack()
>
> +
>
> +/**
>
> + Returns the size of a structure of known type, up through and including a specified field.
>
> +
>
> + @param TYPE The name of the data structure that contains the field specified by Field.
>
> + @param Field The name of the field in the data structure.
>
> +
>
> + @return size, in bytes.
>
> +
>
> +**/
>
> +#define PLD_SIZEOF_THROUGH_FIELD(TYPE, Field) (OFFSET_OF(TYPE, Field) + sizeof (((TYPE *) 0)->Field))
>
> +
>
> +#endif // __UNIVERSAL_PAYLOAD_H__
>
> --
> 2.30.0.windows.2
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [edk2-devel] [Patch V3 1/9] MdeModulePkg: Add Universal Payload general defination header file
2021-06-08 16:25 ` Michael D Kinney
@ 2021-06-09 2:58 ` Ni, Ray
2021-06-09 3:08 ` Ma, Maurice
0 siblings, 1 reply; 22+ messages in thread
From: Ni, Ray @ 2021-06-09 2:58 UTC (permalink / raw)
To: Ma, Maurice, Dong, Guo, Rangarajan, Ravi P
Cc: Liming Gao, Wang, Jian J, Wu, Hao A, devel@edk2.groups.io,
Kinney, Michael D, Liu, Zhiguang, Zimmer, Vincent
Mike,
Thanks for the recommendation.
Just check https://en.wikipedia.org/wiki/Programmable_logic_device and it seems to me PLD is a very common term in EE world. FPGA is a kind of PLD.
Maurice, Ravi, Guo, comments?
Thanks,
Ray
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Michael
> D Kinney
> Sent: Wednesday, June 9, 2021 12:26 AM
> To: Liu, Zhiguang <zhiguang.liu@intel.com>; devel@edk2.groups.io; Kinney,
> Michael D <michael.d.kinney@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>; Wang, Jian J
> <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>
> Subject: Re: [edk2-devel] [Patch V3 1/9] MdeModulePkg: Add Universal
> Payload general defination header file
>
> I see use of the abbreviation PLD in this series.
>
> PLD is sometimes interpreted as Programmable Logic Device.
>
> Given this is for Universal Payload, I recommend using UNIVERSAL_PAYLOAD
> or PAYLOAD as appropriate.
>
> Mike
>
> > -----Original Message-----
> > From: Liu, Zhiguang <zhiguang.liu@intel.com>
> > Sent: Friday, June 4, 2021 2:42 AM
> > To: devel@edk2.groups.io
> > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao
> <gaoliming@byosoft.com.cn>; Wang, Jian J
> > <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>
> > Subject: [Patch V3 1/9] MdeModulePkg: Add Universal Payload general
> defination header file
> >
> > V1:
> > Add Universal Payload general defination header file according to
> > Universal Payload’s documentation
> > V2:
> > Add a macro funtion to check the Revision
> >
> > Cc: Michael D Kinney <michael.d.kinney@intel.com>
> > Cc: Liming Gao <gaoliming@byosoft.com.cn>
> > Cc: Jian J Wang <jian.j.wang@intel.com>
> > Cc: Hao A Wu <hao.a.wu@intel.com>
> >
> > Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
> > ---
> > MdeModulePkg/Include/UniversalPayload/UniversalPayload.h | 33
> +++++++++++++++++++++++++++++++++
> > 1 file changed, 33 insertions(+)
> >
> > diff --git a/MdeModulePkg/Include/UniversalPayload/UniversalPayload.h
> > b/MdeModulePkg/Include/UniversalPayload/UniversalPayload.h
> > new file mode 100644
> > index 0000000000..627b9e880e
> > --- /dev/null
> > +++ b/MdeModulePkg/Include/UniversalPayload/UniversalPayload.h
> > @@ -0,0 +1,33 @@
> > +/** @file
> >
> > + Universal Payload general definations.
> >
> > +
> >
> > +Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
> >
> > +SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> > +
> >
> > +**/
> >
> > +
> >
> > +#ifndef __UNIVERSAL_PAYLOAD_H__
> >
> > +#define __UNIVERSAL_PAYLOAD_H__
> >
> > +
> >
> > +#pragma pack(1)
> >
> > +
> >
> > +typedef struct {
> >
> > + UINT8 Revision;
> >
> > + UINT8 Reserved;
> >
> > + UINT16 Length;
> >
> > +} PLD_GENERIC_HEADER;
> >
> > +
> >
> > +#pragma pack()
> >
> > +
> >
> > +/**
> >
> > + Returns the size of a structure of known type, up through and including a
> specified field.
> >
> > +
> >
> > + @param TYPE The name of the data structure that contains the field
> specified by Field.
> >
> > + @param Field The name of the field in the data structure.
> >
> > +
> >
> > + @return size, in bytes.
> >
> > +
> >
> > +**/
> >
> > +#define PLD_SIZEOF_THROUGH_FIELD(TYPE, Field) (OFFSET_OF(TYPE,
> Field) + sizeof (((TYPE *) 0)->Field))
> >
> > +
> >
> > +#endif // __UNIVERSAL_PAYLOAD_H__
> >
> > --
> > 2.30.0.windows.2
>
>
>
>
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [edk2-devel] [Patch V3 1/9] MdeModulePkg: Add Universal Payload general defination header file
2021-06-09 2:58 ` [edk2-devel] " Ni, Ray
@ 2021-06-09 3:08 ` Ma, Maurice
2021-06-09 5:45 ` Zhiguang Liu
0 siblings, 1 reply; 22+ messages in thread
From: Ma, Maurice @ 2021-06-09 3:08 UTC (permalink / raw)
To: Ni, Ray, Dong, Guo, Rangarajan, Ravi P
Cc: Liming Gao, Wang, Jian J, Wu, Hao A, devel@edk2.groups.io,
Kinney, Michael D, Liu, Zhiguang, Zimmer, Vincent
Hi, Ray,
Yes, I agree. PLD might cause confusion sometimes.
Maybe we just use the full name UNIVERSAL_PAYLOAD instead ?
Thanks
Maurice
> -----Original Message-----
> From: Ni, Ray <ray.ni@intel.com>
> Sent: Tuesday, June 8, 2021 19:58
> To: Ma, Maurice <maurice.ma@intel.com>; Dong, Guo
> <guo.dong@intel.com>; Rangarajan, Ravi P <ravi.p.rangarajan@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>; Wang, Jian J
> <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;
> devel@edk2.groups.io; Kinney, Michael D <michael.d.kinney@intel.com>;
> Liu, Zhiguang <zhiguang.liu@intel.com>; Zimmer, Vincent
> <vincent.zimmer@intel.com>
> Subject: RE: [edk2-devel] [Patch V3 1/9] MdeModulePkg: Add Universal
> Payload general defination header file
>
> Mike,
> Thanks for the recommendation.
> Just check https://en.wikipedia.org/wiki/Programmable_logic_device and it
> seems to me PLD is a very common term in EE world. FPGA is a kind of PLD.
>
> Maurice, Ravi, Guo, comments?
>
> Thanks,
> Ray
>
> > -----Original Message-----
> > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of
> Michael
> > D Kinney
> > Sent: Wednesday, June 9, 2021 12:26 AM
> > To: Liu, Zhiguang <zhiguang.liu@intel.com>; devel@edk2.groups.io;
> > Kinney, Michael D <michael.d.kinney@intel.com>
> > Cc: Liming Gao <gaoliming@byosoft.com.cn>; Wang, Jian J
> > <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>
> > Subject: Re: [edk2-devel] [Patch V3 1/9] MdeModulePkg: Add Universal
> > Payload general defination header file
> >
> > I see use of the abbreviation PLD in this series.
> >
> > PLD is sometimes interpreted as Programmable Logic Device.
> >
> > Given this is for Universal Payload, I recommend using
> > UNIVERSAL_PAYLOAD or PAYLOAD as appropriate.
> >
> > Mike
> >
> > > -----Original Message-----
> > > From: Liu, Zhiguang <zhiguang.liu@intel.com>
> > > Sent: Friday, June 4, 2021 2:42 AM
> > > To: devel@edk2.groups.io
> > > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao
> > <gaoliming@byosoft.com.cn>; Wang, Jian J
> > > <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>
> > > Subject: [Patch V3 1/9] MdeModulePkg: Add Universal Payload general
> > defination header file
> > >
> > > V1:
> > > Add Universal Payload general defination header file according to
> > > Universal Payload’s documentation
> > > V2:
> > > Add a macro funtion to check the Revision
> > >
> > > Cc: Michael D Kinney <michael.d.kinney@intel.com>
> > > Cc: Liming Gao <gaoliming@byosoft.com.cn>
> > > Cc: Jian J Wang <jian.j.wang@intel.com>
> > > Cc: Hao A Wu <hao.a.wu@intel.com>
> > >
> > > Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
> > > ---
> > > MdeModulePkg/Include/UniversalPayload/UniversalPayload.h | 33
> > +++++++++++++++++++++++++++++++++
> > > 1 file changed, 33 insertions(+)
> > >
> > > diff --git
> > > a/MdeModulePkg/Include/UniversalPayload/UniversalPayload.h
> > > b/MdeModulePkg/Include/UniversalPayload/UniversalPayload.h
> > > new file mode 100644
> > > index 0000000000..627b9e880e
> > > --- /dev/null
> > > +++ b/MdeModulePkg/Include/UniversalPayload/UniversalPayload.h
> > > @@ -0,0 +1,33 @@
> > > +/** @file
> > >
> > > + Universal Payload general definations.
> > >
> > > +
> > >
> > > +Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
> > >
> > > +SPDX-License-Identifier: BSD-2-Clause-Patent
> > >
> > > +
> > >
> > > +**/
> > >
> > > +
> > >
> > > +#ifndef __UNIVERSAL_PAYLOAD_H__
> > >
> > > +#define __UNIVERSAL_PAYLOAD_H__
> > >
> > > +
> > >
> > > +#pragma pack(1)
> > >
> > > +
> > >
> > > +typedef struct {
> > >
> > > + UINT8 Revision;
> > >
> > > + UINT8 Reserved;
> > >
> > > + UINT16 Length;
> > >
> > > +} PLD_GENERIC_HEADER;
> > >
> > > +
> > >
> > > +#pragma pack()
> > >
> > > +
> > >
> > > +/**
> > >
> > > + Returns the size of a structure of known type, up through and
> > > + including a
> > specified field.
> > >
> > > +
> > >
> > > + @param TYPE The name of the data structure that contains the field
> > specified by Field.
> > >
> > > + @param Field The name of the field in the data structure.
> > >
> > > +
> > >
> > > + @return size, in bytes.
> > >
> > > +
> > >
> > > +**/
> > >
> > > +#define PLD_SIZEOF_THROUGH_FIELD(TYPE, Field) (OFFSET_OF(TYPE,
> > Field) + sizeof (((TYPE *) 0)->Field))
> > >
> > > +
> > >
> > > +#endif // __UNIVERSAL_PAYLOAD_H__
> > >
> > > --
> > > 2.30.0.windows.2
> >
> >
> >
> >
> >
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [edk2-devel] [Patch V3 1/9] MdeModulePkg: Add Universal Payload general defination header file
2021-06-09 3:08 ` Ma, Maurice
@ 2021-06-09 5:45 ` Zhiguang Liu
0 siblings, 0 replies; 22+ messages in thread
From: Zhiguang Liu @ 2021-06-09 5:45 UTC (permalink / raw)
To: Ma, Maurice, Ni, Ray, Dong, Guo, Rangarajan, Ravi P
Cc: Liming Gao, Wang, Jian J, Wu, Hao A, devel@edk2.groups.io,
Kinney, Michael D, Zimmer, Vincent
Hi all,
Thanks for the comments.
I agree with the change.
I will update the term in next version of the patch set.
Thanks
Zhiguang
> -----Original Message-----
> From: Ma, Maurice <maurice.ma@intel.com>
> Sent: Wednesday, June 9, 2021 11:08 AM
> To: Ni, Ray <ray.ni@intel.com>; Dong, Guo <guo.dong@intel.com>;
> Rangarajan, Ravi P <ravi.p.rangarajan@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>; Wang, Jian J
> <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;
> devel@edk2.groups.io; Kinney, Michael D <michael.d.kinney@intel.com>;
> Liu, Zhiguang <zhiguang.liu@intel.com>; Zimmer, Vincent
> <vincent.zimmer@intel.com>
> Subject: RE: [edk2-devel] [Patch V3 1/9] MdeModulePkg: Add Universal
> Payload general defination header file
>
> Hi, Ray,
>
> Yes, I agree. PLD might cause confusion sometimes.
> Maybe we just use the full name UNIVERSAL_PAYLOAD instead ?
>
> Thanks
> Maurice
> > -----Original Message-----
> > From: Ni, Ray <ray.ni@intel.com>
> > Sent: Tuesday, June 8, 2021 19:58
> > To: Ma, Maurice <maurice.ma@intel.com>; Dong, Guo
> > <guo.dong@intel.com>; Rangarajan, Ravi P <ravi.p.rangarajan@intel.com>
> > Cc: Liming Gao <gaoliming@byosoft.com.cn>; Wang, Jian J
> > <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;
> > devel@edk2.groups.io; Kinney, Michael D <michael.d.kinney@intel.com>;
> > Liu, Zhiguang <zhiguang.liu@intel.com>; Zimmer, Vincent
> > <vincent.zimmer@intel.com>
> > Subject: RE: [edk2-devel] [Patch V3 1/9] MdeModulePkg: Add Universal
> > Payload general defination header file
> >
> > Mike,
> > Thanks for the recommendation.
> > Just check https://en.wikipedia.org/wiki/Programmable_logic_device and
> > it seems to me PLD is a very common term in EE world. FPGA is a kind of
> PLD.
> >
> > Maurice, Ravi, Guo, comments?
> >
> > Thanks,
> > Ray
> >
> > > -----Original Message-----
> > > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of
> > Michael
> > > D Kinney
> > > Sent: Wednesday, June 9, 2021 12:26 AM
> > > To: Liu, Zhiguang <zhiguang.liu@intel.com>; devel@edk2.groups.io;
> > > Kinney, Michael D <michael.d.kinney@intel.com>
> > > Cc: Liming Gao <gaoliming@byosoft.com.cn>; Wang, Jian J
> > > <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>
> > > Subject: Re: [edk2-devel] [Patch V3 1/9] MdeModulePkg: Add Universal
> > > Payload general defination header file
> > >
> > > I see use of the abbreviation PLD in this series.
> > >
> > > PLD is sometimes interpreted as Programmable Logic Device.
> > >
> > > Given this is for Universal Payload, I recommend using
> > > UNIVERSAL_PAYLOAD or PAYLOAD as appropriate.
> > >
> > > Mike
> > >
> > > > -----Original Message-----
> > > > From: Liu, Zhiguang <zhiguang.liu@intel.com>
> > > > Sent: Friday, June 4, 2021 2:42 AM
> > > > To: devel@edk2.groups.io
> > > > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao
> > > <gaoliming@byosoft.com.cn>; Wang, Jian J
> > > > <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>
> > > > Subject: [Patch V3 1/9] MdeModulePkg: Add Universal Payload
> > > > general
> > > defination header file
> > > >
> > > > V1:
> > > > Add Universal Payload general defination header file according to
> > > > Universal Payload’s documentation
> > > > V2:
> > > > Add a macro funtion to check the Revision
> > > >
> > > > Cc: Michael D Kinney <michael.d.kinney@intel.com>
> > > > Cc: Liming Gao <gaoliming@byosoft.com.cn>
> > > > Cc: Jian J Wang <jian.j.wang@intel.com>
> > > > Cc: Hao A Wu <hao.a.wu@intel.com>
> > > >
> > > > Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
> > > > ---
> > > > MdeModulePkg/Include/UniversalPayload/UniversalPayload.h | 33
> > > +++++++++++++++++++++++++++++++++
> > > > 1 file changed, 33 insertions(+)
> > > >
> > > > diff --git
> > > > a/MdeModulePkg/Include/UniversalPayload/UniversalPayload.h
> > > > b/MdeModulePkg/Include/UniversalPayload/UniversalPayload.h
> > > > new file mode 100644
> > > > index 0000000000..627b9e880e
> > > > --- /dev/null
> > > > +++ b/MdeModulePkg/Include/UniversalPayload/UniversalPayload.h
> > > > @@ -0,0 +1,33 @@
> > > > +/** @file
> > > >
> > > > + Universal Payload general definations.
> > > >
> > > > +
> > > >
> > > > +Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
> > > >
> > > > +SPDX-License-Identifier: BSD-2-Clause-Patent
> > > >
> > > > +
> > > >
> > > > +**/
> > > >
> > > > +
> > > >
> > > > +#ifndef __UNIVERSAL_PAYLOAD_H__
> > > >
> > > > +#define __UNIVERSAL_PAYLOAD_H__
> > > >
> > > > +
> > > >
> > > > +#pragma pack(1)
> > > >
> > > > +
> > > >
> > > > +typedef struct {
> > > >
> > > > + UINT8 Revision;
> > > >
> > > > + UINT8 Reserved;
> > > >
> > > > + UINT16 Length;
> > > >
> > > > +} PLD_GENERIC_HEADER;
> > > >
> > > > +
> > > >
> > > > +#pragma pack()
> > > >
> > > > +
> > > >
> > > > +/**
> > > >
> > > > + Returns the size of a structure of known type, up through and
> > > > + including a
> > > specified field.
> > > >
> > > > +
> > > >
> > > > + @param TYPE The name of the data structure that contains the
> field
> > > specified by Field.
> > > >
> > > > + @param Field The name of the field in the data structure.
> > > >
> > > > +
> > > >
> > > > + @return size, in bytes.
> > > >
> > > > +
> > > >
> > > > +**/
> > > >
> > > > +#define PLD_SIZEOF_THROUGH_FIELD(TYPE, Field) (OFFSET_OF(TYPE,
> > > Field) + sizeof (((TYPE *) 0)->Field))
> > > >
> > > > +
> > > >
> > > > +#endif // __UNIVERSAL_PAYLOAD_H__
> > > >
> > > > --
> > > > 2.30.0.windows.2
> > >
> > >
> > >
> > >
> > >
^ permalink raw reply [flat|nested] 22+ messages in thread
* [Patch V3 2/9] MdeModulePkg: Add new structure for the PCI Root Bridge Info Hob
2021-06-04 9:42 [Patch V3 0/9] Create multiple Hobs for Universal Payload Zhiguang Liu
2021-06-04 9:42 ` [Patch V3 1/9] MdeModulePkg: Add Universal Payload general defination header file Zhiguang Liu
@ 2021-06-04 9:42 ` Zhiguang Liu
2021-06-08 5:20 ` Wu, Hao A
2021-06-04 9:42 ` [Patch V3 3/9] UefiPayloadPkg: UefiPayload retrieve PCI root bridge from Guid Hob Zhiguang Liu
` (6 subsequent siblings)
8 siblings, 1 reply; 22+ messages in thread
From: Zhiguang Liu @ 2021-06-04 9:42 UTC (permalink / raw)
To: devel; +Cc: Michael D Kinney, Liming Gao, Jian J Wang, Hao A Wu
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
---
MdeModulePkg/Include/UniversalPayload/PciRootBridges.h | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MdeModulePkg/MdeModulePkg.dec | 6 ++++++
2 files changed, 95 insertions(+)
diff --git a/MdeModulePkg/Include/UniversalPayload/PciRootBridges.h b/MdeModulePkg/Include/UniversalPayload/PciRootBridges.h
new file mode 100644
index 0000000000..72e8331ede
--- /dev/null
+++ b/MdeModulePkg/Include/UniversalPayload/PciRootBridges.h
@@ -0,0 +1,89 @@
+/** @file
+ This file defines the structure for the PCI Root Bridges.
+
+ Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef __PLD_PCI_ROOT_BRIDGES_H__
+#define __PLD_PCI_ROOT_BRIDGES_H__
+
+#include <UniversalPayload/UniversalPayload.h>
+
+#pragma pack(1)
+
+//
+// (Base > Limit) indicates an aperture is not available.
+//
+typedef struct {
+ //
+ // Base and Limit are the device address instead of host address when
+ // Translation is not zero
+ //
+ UINT64 Base;
+ UINT64 Limit;
+ //
+ // According to UEFI 2.7, Device Address = Host Address + Translation,
+ // so Translation = Device Address - Host Address.
+ // On platforms where Translation is not zero, the subtraction is probably to
+ // be performed with UINT64 wrap-around semantics, for we may translate an
+ // above-4G host address into a below-4G device address for legacy PCIe device
+ // compatibility.
+ //
+ // NOTE: The alignment of Translation is required to be larger than any BAR
+ // alignment in the same root bridge, so that the same alignment can be
+ // applied to both device address and host address, which simplifies the
+ // situation and makes the current resource allocation code in generic PCI
+ // host bridge driver still work.
+ //
+ UINT64 Translation;
+} PLD_PCI_ROOT_BRIDGE_APERTURE;
+
+///
+/// Payload PCI Root Bridge Information HOB
+///
+typedef struct {
+ UINT32 Segment; ///< Segment number.
+ UINT64 Supports; ///< Supported attributes.
+ ///< Refer to EFI_PCI_ATTRIBUTE_xxx used by GetAttributes()
+ ///< and SetAttributes() in EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
+ UINT64 Attributes; ///< Initial attributes.
+ ///< Refer to EFI_PCI_ATTRIBUTE_xxx used by GetAttributes()
+ ///< and SetAttributes() in EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
+ BOOLEAN DmaAbove4G; ///< DMA above 4GB memory.
+ ///< Set to TRUE when root bridge supports DMA above 4GB memory.
+ BOOLEAN NoExtendedConfigSpace; ///< When FALSE, the root bridge supports
+ ///< Extended (4096-byte) Configuration Space.
+ ///< When TRUE, the root bridge supports
+ ///< 256-byte Configuration Space only.
+ UINT64 AllocationAttributes; ///< Allocation attributes.
+ ///< Refer to EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM and
+ ///< EFI_PCI_HOST_BRIDGE_MEM64_DECODE used by GetAllocAttributes()
+ ///< in EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL.
+ PLD_PCI_ROOT_BRIDGE_APERTURE Bus; ///< Bus aperture which can be used by the root bridge.
+ PLD_PCI_ROOT_BRIDGE_APERTURE Io; ///< IO aperture which can be used by the root bridge.
+ PLD_PCI_ROOT_BRIDGE_APERTURE Mem; ///< MMIO aperture below 4GB which can be used by the root bridge.
+ PLD_PCI_ROOT_BRIDGE_APERTURE MemAbove4G; ///< MMIO aperture above 4GB which can be used by the root bridge.
+ PLD_PCI_ROOT_BRIDGE_APERTURE PMem; ///< Prefetchable MMIO aperture below 4GB which can be used by the root bridge.
+ PLD_PCI_ROOT_BRIDGE_APERTURE PMemAbove4G; ///< Prefetchable MMIO aperture above 4GB which can be used by the root bridge.
+ UINT32 HID; ///< PnP hardware ID of the root bridge. This value must match the corresponding
+ ///< _HID in the ACPI name space.
+ UINT32 UID; ///< Unique ID that is required by ACPI if two devices have the same _HID.
+ ///< This value must also match the corresponding _UID/_HID pair in the ACPI name space.
+} PLD_PCI_ROOT_BRIDGE;
+
+typedef struct {
+ PLD_GENERIC_HEADER PldHeader;
+ BOOLEAN ResourceAssigned;
+ UINT8 Count;
+ PLD_PCI_ROOT_BRIDGE RootBridge[0];
+} PLD_PCI_ROOT_BRIDGES;
+
+#pragma pack()
+
+#define PLD_PCI_ROOT_BRIDGES_REVISION 1
+
+extern GUID gPldPciRootBridgeInfoGuid;
+
+#endif // __PLD_PCI_ROOT_BRIDGES_H__
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 8d38383915..671d0f33c8 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -404,6 +404,12 @@
## Include/Guid/MigratedFvInfo.h
gEdkiiMigratedFvInfoGuid = { 0xc1ab12f7, 0x74aa, 0x408d, { 0xa2, 0xf4, 0xc6, 0xce, 0xfd, 0x17, 0x98, 0x71 } }
+ #
+ # GUID defined in UniversalPayload
+ #
+ ## Include/UniversalPayload/PciRootBridges.h
+ gPldPciRootBridgeInfoGuid = { 0xec4ebacb, 0x2638, 0x416e, { 0xbe, 0x80, 0xe5, 0xfa, 0x4b, 0x51, 0x19, 0x01 }}
+
[Ppis]
## Include/Ppi/AtaController.h
gPeiAtaControllerPpiGuid = { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0, 0x7a, 0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }}
--
2.30.0.windows.2
^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [Patch V3 2/9] MdeModulePkg: Add new structure for the PCI Root Bridge Info Hob
2021-06-04 9:42 ` [Patch V3 2/9] MdeModulePkg: Add new structure for the PCI Root Bridge Info Hob Zhiguang Liu
@ 2021-06-08 5:20 ` Wu, Hao A
0 siblings, 0 replies; 22+ messages in thread
From: Wu, Hao A @ 2021-06-08 5:20 UTC (permalink / raw)
To: Liu, Zhiguang, devel@edk2.groups.io
Cc: Kinney, Michael D, Liming Gao, Wang, Jian J
> -----Original Message-----
> From: Liu, Zhiguang <zhiguang.liu@intel.com>
> Sent: Friday, June 4, 2021 5:42 PM
> To: devel@edk2.groups.io
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao
> <gaoliming@byosoft.com.cn>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao
> A <hao.a.wu@intel.com>
> Subject: [Patch V3 2/9] MdeModulePkg: Add new structure for the PCI Root
> Bridge Info Hob
>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
>
> Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
> ---
> MdeModulePkg/Include/UniversalPayload/PciRootBridges.h | 89
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> ++++++++++++++++++++++++
> MdeModulePkg/MdeModulePkg.dec | 6 ++++++
> 2 files changed, 95 insertions(+)
>
> diff --git a/MdeModulePkg/Include/UniversalPayload/PciRootBridges.h
> b/MdeModulePkg/Include/UniversalPayload/PciRootBridges.h
> new file mode 100644
> index 0000000000..72e8331ede
> --- /dev/null
> +++ b/MdeModulePkg/Include/UniversalPayload/PciRootBridges.h
> @@ -0,0 +1,89 @@
> +/** @file
>
> + This file defines the structure for the PCI Root Bridges.
>
> +
>
> + Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
>
> + SPDX-License-Identifier: BSD-2-Clause-Patent
>
> +
Could you help to add the specification reference information in the header file description comment?
With this handled:
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
Best Regards,
Hao Wu
>
> +**/
>
> +
>
> +#ifndef __PLD_PCI_ROOT_BRIDGES_H__
>
> +#define __PLD_PCI_ROOT_BRIDGES_H__
>
> +
>
> +#include <UniversalPayload/UniversalPayload.h>
>
> +
>
> +#pragma pack(1)
>
> +
>
> +//
>
> +// (Base > Limit) indicates an aperture is not available.
>
> +//
>
> +typedef struct {
>
> + //
>
> + // Base and Limit are the device address instead of host address when
>
> + // Translation is not zero
>
> + //
>
> + UINT64 Base;
>
> + UINT64 Limit;
>
> + //
>
> + // According to UEFI 2.7, Device Address = Host Address + Translation,
>
> + // so Translation = Device Address - Host Address.
>
> + // On platforms where Translation is not zero, the subtraction is probably to
>
> + // be performed with UINT64 wrap-around semantics, for we may translate
> an
>
> + // above-4G host address into a below-4G device address for legacy PCIe
> device
>
> + // compatibility.
>
> + //
>
> + // NOTE: The alignment of Translation is required to be larger than any BAR
>
> + // alignment in the same root bridge, so that the same alignment can be
>
> + // applied to both device address and host address, which simplifies the
>
> + // situation and makes the current resource allocation code in generic PCI
>
> + // host bridge driver still work.
>
> + //
>
> + UINT64 Translation;
>
> +} PLD_PCI_ROOT_BRIDGE_APERTURE;
>
> +
>
> +///
>
> +/// Payload PCI Root Bridge Information HOB
>
> +///
>
> +typedef struct {
>
> + UINT32 Segment; ///< Segment number.
>
> + UINT64 Supports; ///< Supported attributes.
>
> + ///< Refer to EFI_PCI_ATTRIBUTE_xxx used by
> GetAttributes()
>
> + ///< and SetAttributes() in
> EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
>
> + UINT64 Attributes; ///< Initial attributes.
>
> + ///< Refer to EFI_PCI_ATTRIBUTE_xxx used by
> GetAttributes()
>
> + ///< and SetAttributes() in
> EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
>
> + BOOLEAN DmaAbove4G; ///< DMA above 4GB memory.
>
> + ///< Set to TRUE when root bridge supports DMA
> above 4GB memory.
>
> + BOOLEAN NoExtendedConfigSpace; ///< When FALSE, the root
> bridge supports
>
> + ///< Extended (4096-byte) Configuration Space.
>
> + ///< When TRUE, the root bridge supports
>
> + ///< 256-byte Configuration Space only.
>
> + UINT64 AllocationAttributes; ///< Allocation attributes.
>
> + ///< Refer to
> EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM and
>
> + ///< EFI_PCI_HOST_BRIDGE_MEM64_DECODE
> used by GetAllocAttributes()
>
> + ///< in
> EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL.
>
> + PLD_PCI_ROOT_BRIDGE_APERTURE Bus; ///< Bus aperture which
> can be used by the root bridge.
>
> + PLD_PCI_ROOT_BRIDGE_APERTURE Io; ///< IO aperture which can
> be used by the root bridge.
>
> + PLD_PCI_ROOT_BRIDGE_APERTURE Mem; ///< MMIO aperture
> below 4GB which can be used by the root bridge.
>
> + PLD_PCI_ROOT_BRIDGE_APERTURE MemAbove4G; ///< MMIO
> aperture above 4GB which can be used by the root bridge.
>
> + PLD_PCI_ROOT_BRIDGE_APERTURE PMem; ///< Prefetchable MMIO
> aperture below 4GB which can be used by the root bridge.
>
> + PLD_PCI_ROOT_BRIDGE_APERTURE PMemAbove4G; ///< Prefetchable
> MMIO aperture above 4GB which can be used by the root bridge.
>
> + UINT32 HID; ///< PnP hardware ID of the root bridge.
> This value must match the corresponding
>
> + ///< _HID in the ACPI name space.
>
> + UINT32 UID; ///< Unique ID that is required by ACPI if
> two devices have the same _HID.
>
> + ///< This value must also match the
> corresponding _UID/_HID pair in the ACPI name space.
>
> +} PLD_PCI_ROOT_BRIDGE;
>
> +
>
> +typedef struct {
>
> + PLD_GENERIC_HEADER PldHeader;
>
> + BOOLEAN ResourceAssigned;
>
> + UINT8 Count;
>
> + PLD_PCI_ROOT_BRIDGE RootBridge[0];
>
> +} PLD_PCI_ROOT_BRIDGES;
>
> +
>
> +#pragma pack()
>
> +
>
> +#define PLD_PCI_ROOT_BRIDGES_REVISION 1
>
> +
>
> +extern GUID gPldPciRootBridgeInfoGuid;
>
> +
>
> +#endif // __PLD_PCI_ROOT_BRIDGES_H__
>
> diff --git a/MdeModulePkg/MdeModulePkg.dec
> b/MdeModulePkg/MdeModulePkg.dec
> index 8d38383915..671d0f33c8 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -404,6 +404,12 @@
> ## Include/Guid/MigratedFvInfo.h
>
> gEdkiiMigratedFvInfoGuid = { 0xc1ab12f7, 0x74aa, 0x408d, { 0xa2, 0xf4, 0xc6,
> 0xce, 0xfd, 0x17, 0x98, 0x71 } }
>
>
>
> + #
>
> + # GUID defined in UniversalPayload
>
> + #
>
> + ## Include/UniversalPayload/PciRootBridges.h
>
> + gPldPciRootBridgeInfoGuid = { 0xec4ebacb, 0x2638, 0x416e, { 0xbe, 0x80,
> 0xe5, 0xfa, 0x4b, 0x51, 0x19, 0x01 }}
>
> +
>
> [Ppis]
>
> ## Include/Ppi/AtaController.h
>
> gPeiAtaControllerPpiGuid = { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0, 0x7a,
> 0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }}
>
> --
> 2.30.0.windows.2
^ permalink raw reply [flat|nested] 22+ messages in thread
* [Patch V3 3/9] UefiPayloadPkg: UefiPayload retrieve PCI root bridge from Guid Hob
2021-06-04 9:42 [Patch V3 0/9] Create multiple Hobs for Universal Payload Zhiguang Liu
2021-06-04 9:42 ` [Patch V3 1/9] MdeModulePkg: Add Universal Payload general defination header file Zhiguang Liu
2021-06-04 9:42 ` [Patch V3 2/9] MdeModulePkg: Add new structure for the PCI Root Bridge Info Hob Zhiguang Liu
@ 2021-06-04 9:42 ` Zhiguang Liu
2021-06-04 9:42 ` [Patch V3 4/9] MdeModulePkg: Add new structure for the Universal Payload SMBios Table Info Hob Zhiguang Liu
` (5 subsequent siblings)
8 siblings, 0 replies; 22+ messages in thread
From: Zhiguang Liu @ 2021-06-04 9:42 UTC (permalink / raw)
To: devel; +Cc: Maurice Ma, Guo Dong, Benjamin You
UefiPayload parse gPldPciRootBridgeInfoGuid Guid Hob to retrieve PCI root bridges
information. gPldPciRootBridgeInfoGuid Guid Hob should be created by Bootloader.
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Guo Dong <guo.dong@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
---
UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridge.h | 40 ++++++++++++++++++++++++++++++++++++++--
UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c | 47 ++++++++++++++++++++++++++++++++++++++++++++---
UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf | 8 +++++++-
UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeSupport.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
UefiPayloadPkg/UefiPayloadPkg.dsc | 2 +-
5 files changed, 162 insertions(+), 8 deletions(-)
diff --git a/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridge.h b/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridge.h
index c2961b3bee..b22703e79e 100644
--- a/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridge.h
+++ b/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridge.h
@@ -2,7 +2,7 @@
Header file of PciHostBridgeLib.
Copyright (C) 2016, Red Hat, Inc.
- Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2016 - 2021, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -11,14 +11,38 @@
#ifndef _PCI_HOST_BRIDGE_H
#define _PCI_HOST_BRIDGE_H
+#include <UniversalPayload/PciRootBridges.h>
+
typedef struct {
ACPI_HID_DEVICE_PATH AcpiDevicePath;
EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
} CB_PCI_ROOT_BRIDGE_DEVICE_PATH;
+/**
+ Scan for all root bridges in platform.
+
+ @param[out] NumberOfRootBridges Number of root bridges detected
+
+ @retval Pointer to the allocated PCI_ROOT_BRIDGE structure array.
+**/
PCI_ROOT_BRIDGE *
ScanForRootBridges (
- UINTN *NumberOfRootBridges
+ OUT UINTN *NumberOfRootBridges
+);
+
+/**
+ Scan for all root bridges from PldPciRootBridgeInfoHob
+
+ @param[in] PciRootBridgeInfo Pointer of PLD PCI Root Bridge Info Hob
+ @param[out] NumberOfRootBridges Number of root bridges detected
+
+ @retval Pointer to the allocated PCI_ROOT_BRIDGE structure array.
+
+**/
+PCI_ROOT_BRIDGE *
+RetrieveRootBridgeInfoFromHob (
+ IN PLD_PCI_ROOT_BRIDGES *PciRootBridgeInfo,
+ OUT UINTN *NumberOfRootBridges
);
/**
@@ -77,4 +101,16 @@ InitRootBridge (
OUT PCI_ROOT_BRIDGE *RootBus
);
+/**
+ Initialize DevicePath for a PCI_ROOT_BRIDGE.
+ @param[in] HID HID for device path
+ @param[in] UID UID for device path
+
+ @retval A pointer to the new created device patch.
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+CreateRootBridgeDevicePath (
+ IN UINT32 HID,
+ IN UINT32 UID
+);
#endif
diff --git a/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c b/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
index 512c3127cc..6aa43e8c7e 100644
--- a/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
+++ b/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
@@ -2,7 +2,7 @@
Library instance of PciHostBridgeLib library class for coreboot.
Copyright (C) 2016, Red Hat, Inc.
- Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2016 - 2021, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -19,6 +19,7 @@
#include <Library/MemoryAllocationLib.h>
#include <Library/PciHostBridgeLib.h>
#include <Library/PciLib.h>
+#include <Library/HobLib.h>
#include "PciHostBridge.h"
@@ -48,7 +49,6 @@ CB_PCI_ROOT_BRIDGE_DEVICE_PATH mRootBridgeDevicePathTemplate = {
}
};
-
/**
Initialize a PCI_ROOT_BRIDGE structure.
@@ -145,6 +145,27 @@ InitRootBridge (
return EFI_SUCCESS;
}
+/**
+ Initialize DevicePath for a PCI_ROOT_BRIDGE.
+ @param[in] HID HID for device path
+ @param[in] UID UID for device path
+
+ @retval A pointer to the new created device patch.
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+CreateRootBridgeDevicePath (
+ IN UINT32 HID,
+ IN UINT32 UID
+)
+{
+ CB_PCI_ROOT_BRIDGE_DEVICE_PATH *DevicePath;
+ DevicePath = AllocateCopyPool (sizeof (mRootBridgeDevicePathTemplate),
+ &mRootBridgeDevicePathTemplate);
+ ASSERT (DevicePath != NULL);
+ DevicePath->AcpiDevicePath.HID = HID;
+ DevicePath->AcpiDevicePath.UID = UID;
+ return (EFI_DEVICE_PATH_PROTOCOL *)DevicePath;
+}
/**
Return all the root bridge instances in an array.
@@ -161,10 +182,30 @@ PciHostBridgeGetRootBridges (
UINTN *Count
)
{
+ PLD_PCI_ROOT_BRIDGES *PciRootBridgeInfo;
+ EFI_HOB_GUID_TYPE *GuidHob;
+ PLD_GENERIC_HEADER *GenericHeader;
+ //
+ // Find PLD PCI Root Bridge Info hob
+ //
+ GuidHob = GetFirstGuidHob (&gPldPciRootBridgeInfoGuid);
+ if (GuidHob != NULL) {
+ GenericHeader = (PLD_GENERIC_HEADER *) GET_GUID_HOB_DATA (GuidHob);
+ if ((sizeof(PLD_GENERIC_HEADER) <= GET_GUID_HOB_DATA_SIZE (GuidHob)) && (GenericHeader->Length <= GET_GUID_HOB_DATA_SIZE (GuidHob))) {
+ if ((GenericHeader->Revision == PLD_PCI_ROOT_BRIDGES_REVISION) && (GenericHeader->Length >= sizeof (PLD_PCI_ROOT_BRIDGES))) {
+ //
+ // PLD_PCI_ROOT_BRIDGES structure is used when Revision equals to PLD_PCI_ROOT_BRIDGES_REVISION
+ //
+ PciRootBridgeInfo = (PLD_PCI_ROOT_BRIDGES *) GET_GUID_HOB_DATA (GuidHob);
+ if (PciRootBridgeInfo->Count <= (GET_GUID_HOB_DATA_SIZE (GuidHob) - sizeof(PLD_PCI_ROOT_BRIDGES)) / sizeof(PLD_PCI_ROOT_BRIDGE)) {
+ return RetrieveRootBridgeInfoFromHob (PciRootBridgeInfo, Count);
+ }
+ }
+ }
+ }
return ScanForRootBridges (Count);
}
-
/**
Free the root bridge instances array returned from
PciHostBridgeGetRootBridges().
diff --git a/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf b/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
index 7896df2416..1c6a47828a 100644
--- a/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
+++ b/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
@@ -2,7 +2,7 @@
# Library instance of PciHostBridgeLib library class for coreboot.
#
# Copyright (C) 2016, Red Hat, Inc.
-# Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2016 - 2021, Intel Corporation. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -39,3 +39,9 @@
DevicePathLib
MemoryAllocationLib
PciLib
+
+[Guids]
+ gPldPciRootBridgeInfoGuid
+
+[Pcd]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration
diff --git a/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeSupport.c b/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeSupport.c
index fffbf04cad..d6d59b6659 100644
--- a/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeSupport.c
+++ b/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeSupport.c
@@ -1,7 +1,7 @@
/** @file
Scan the entire PCI bus for root bridges to support coreboot UEFI payload.
- Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2016 - 2021, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -582,3 +582,74 @@ ScanForRootBridges (
return RootBridges;
}
+
+/**
+ Scan for all root bridges from PldPciRootBridgeInfoHob
+
+ @param[in] PciRootBridgeInfo Pointer of PLD PCI Root Bridge Info Hob
+ @param[out] NumberOfRootBridges Number of root bridges detected
+
+ @retval Pointer to the allocated PCI_ROOT_BRIDGE structure array.
+
+**/
+PCI_ROOT_BRIDGE *
+RetrieveRootBridgeInfoFromHob (
+ IN PLD_PCI_ROOT_BRIDGES *PciRootBridgeInfo,
+ OUT UINTN *NumberOfRootBridges
+)
+{
+ PCI_ROOT_BRIDGE *PciRootBridges;
+ UINTN Size;
+ UINT8 Index;
+
+ ASSERT (PciRootBridgeInfo != NULL);
+ ASSERT (NumberOfRootBridges != NULL);
+ if (PciRootBridgeInfo == NULL) {
+ return NULL;
+ }
+ if (PciRootBridgeInfo->Count == 0) {
+ return NULL;
+ }
+ Size = PciRootBridgeInfo->Count * sizeof (PCI_ROOT_BRIDGE);
+ PciRootBridges = (PCI_ROOT_BRIDGE *) AllocatePool (Size);
+ ASSERT (PciRootBridges != NULL);
+ if (PciRootBridges == NULL) {
+ return NULL;
+ }
+ ZeroMem (PciRootBridges, PciRootBridgeInfo->Count * sizeof (PCI_ROOT_BRIDGE));
+
+ //
+ // Create all root bridges with PciRootBridgeInfoHob
+ //
+ for (Index = 0; Index < PciRootBridgeInfo->Count; Index++) {
+ PciRootBridges[Index].Segment = PciRootBridgeInfo->RootBridge[Index].Segment;
+ PciRootBridges[Index].Supports = PciRootBridgeInfo->RootBridge[Index].Supports;
+ PciRootBridges[Index].Attributes = PciRootBridgeInfo->RootBridge[Index].Attributes;
+ PciRootBridges[Index].DmaAbove4G = PciRootBridgeInfo->RootBridge[Index].DmaAbove4G;
+ PciRootBridges[Index].NoExtendedConfigSpace = PciRootBridgeInfo->RootBridge[Index].NoExtendedConfigSpace;
+ PciRootBridges[Index].ResourceAssigned = PciRootBridgeInfo->ResourceAssigned;
+ PciRootBridges[Index].AllocationAttributes = PciRootBridgeInfo->RootBridge[Index].AllocationAttributes;
+ PciRootBridges[Index].DevicePath = CreateRootBridgeDevicePath(PciRootBridgeInfo->RootBridge[Index].HID, PciRootBridgeInfo->RootBridge[Index].UID);
+ CopyMem(&PciRootBridges[Index].Bus, &PciRootBridgeInfo->RootBridge[Index].Bus, sizeof(PLD_PCI_ROOT_BRIDGE_APERTURE));
+ CopyMem(&PciRootBridges[Index].Io, &PciRootBridgeInfo->RootBridge[Index].Io, sizeof(PLD_PCI_ROOT_BRIDGE_APERTURE));
+ CopyMem(&PciRootBridges[Index].Mem, &PciRootBridgeInfo->RootBridge[Index].Mem, sizeof(PLD_PCI_ROOT_BRIDGE_APERTURE));
+ CopyMem(&PciRootBridges[Index].MemAbove4G, &PciRootBridgeInfo->RootBridge[Index].MemAbove4G, sizeof(PLD_PCI_ROOT_BRIDGE_APERTURE));
+ CopyMem(&PciRootBridges[Index].PMem, &PciRootBridgeInfo->RootBridge[Index].PMem, sizeof(PLD_PCI_ROOT_BRIDGE_APERTURE));
+ CopyMem(&PciRootBridges[Index].PMemAbove4G, &PciRootBridgeInfo->RootBridge[Index].PMemAbove4G, sizeof(PLD_PCI_ROOT_BRIDGE_APERTURE));
+ }
+
+ *NumberOfRootBridges = PciRootBridgeInfo->Count;
+
+ //
+ // Now, this library only supports RootBridge that ResourceAssigned is True
+ //
+ if (PciRootBridgeInfo->ResourceAssigned) {
+ PcdSetBoolS (PcdPciDisableBusEnumeration, TRUE);
+ } else {
+ DEBUG ((DEBUG_ERROR, "There is root bridge whose ResourceAssigned is FALSE\n"));
+ PcdSetBoolS (PcdPciDisableBusEnumeration, FALSE);
+ return NULL;
+ }
+
+ return PciRootBridges;
+}
diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayloadPkg.dsc
index 37ad5a0ae7..e9211adf86 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -323,7 +323,6 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialFifoControl|$(SERIAL_FIFO_CONTROL)
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialExtendedTxFifoSize|$(SERIAL_EXTENDED_TX_FIFO_SIZE)
- gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|TRUE
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|$(UART_DEFAULT_BAUD_RATE)
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits|$(UART_DEFAULT_DATA_BITS)
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity|$(UART_DEFAULT_PARITY)
@@ -363,6 +362,7 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn|100
gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0
gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseSize|0
+ gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|TRUE
################################################################################
#
--
2.30.0.windows.2
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [Patch V3 4/9] MdeModulePkg: Add new structure for the Universal Payload SMBios Table Info Hob
2021-06-04 9:42 [Patch V3 0/9] Create multiple Hobs for Universal Payload Zhiguang Liu
` (2 preceding siblings ...)
2021-06-04 9:42 ` [Patch V3 3/9] UefiPayloadPkg: UefiPayload retrieve PCI root bridge from Guid Hob Zhiguang Liu
@ 2021-06-04 9:42 ` Zhiguang Liu
2021-06-08 5:20 ` Wu, Hao A
2021-06-04 9:42 ` [Patch V3 5/9] MdeModulePkg/Universal/SmbiosDxe: Scan for existing tables Zhiguang Liu
` (4 subsequent siblings)
8 siblings, 1 reply; 22+ messages in thread
From: Zhiguang Liu @ 2021-06-04 9:42 UTC (permalink / raw)
To: devel; +Cc: Michael D Kinney, Liming Gao, Jian J Wang, Hao A Wu
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
---
MdeModulePkg/Include/UniversalPayload/SmbiosTable.h | 28 ++++++++++++++++++++++++++++
MdeModulePkg/MdeModulePkg.dec | 6 ++++++
2 files changed, 34 insertions(+)
diff --git a/MdeModulePkg/Include/UniversalPayload/SmbiosTable.h b/MdeModulePkg/Include/UniversalPayload/SmbiosTable.h
new file mode 100644
index 0000000000..3aaa926396
--- /dev/null
+++ b/MdeModulePkg/Include/UniversalPayload/SmbiosTable.h
@@ -0,0 +1,28 @@
+/** @file
+ Define the structure for the Payload SmBios.
+
+Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _PLD_SMBIOS_TABL_H_
+#define _PLD_SMBIOS_TABL_H_
+
+#include <Uefi.h>
+#include <UniversalPayload/UniversalPayload.h>
+
+#pragma pack (1)
+
+typedef struct {
+ PLD_GENERIC_HEADER PldHeader;
+ EFI_PHYSICAL_ADDRESS SmBiosEntryPoint;
+} PLD_SMBIOS_TABLE;
+
+#pragma pack()
+
+#define PLD_SMBIOS_TABLE_REVISION 1
+
+extern GUID gPldSmbios3TableGuid;
+extern GUID gPldSmbiosTableGuid;
+#endif //_PLD_SMBIOS_TABL_H_
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 671d0f33c8..45324d2e20 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -410,6 +410,12 @@
## Include/UniversalPayload/PciRootBridges.h
gPldPciRootBridgeInfoGuid = { 0xec4ebacb, 0x2638, 0x416e, { 0xbe, 0x80, 0xe5, 0xfa, 0x4b, 0x51, 0x19, 0x01 }}
+ ## Include/UniversalPayload/SmbiosTable.h
+ gPldSmbios3TableGuid = { 0x92b7896c, 0x3362, 0x46ce, { 0x99, 0xb3, 0x4f, 0x5e, 0x3c, 0x34, 0xeb, 0x42 } }
+
+ ## Include/UniversalPayload/SmbiosTable.h
+ gPldSmbiosTableGuid = { 0x590a0d26, 0x06e5, 0x4d20, { 0x8a, 0x82, 0x59, 0xea, 0x1b, 0x34, 0x98, 0x2d } }
+
[Ppis]
## Include/Ppi/AtaController.h
gPeiAtaControllerPpiGuid = { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0, 0x7a, 0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }}
--
2.30.0.windows.2
^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [Patch V3 4/9] MdeModulePkg: Add new structure for the Universal Payload SMBios Table Info Hob
2021-06-04 9:42 ` [Patch V3 4/9] MdeModulePkg: Add new structure for the Universal Payload SMBios Table Info Hob Zhiguang Liu
@ 2021-06-08 5:20 ` Wu, Hao A
0 siblings, 0 replies; 22+ messages in thread
From: Wu, Hao A @ 2021-06-08 5:20 UTC (permalink / raw)
To: Liu, Zhiguang, devel@edk2.groups.io
Cc: Kinney, Michael D, Liming Gao, Wang, Jian J
> -----Original Message-----
> From: Liu, Zhiguang <zhiguang.liu@intel.com>
> Sent: Friday, June 4, 2021 5:42 PM
> To: devel@edk2.groups.io
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao
> <gaoliming@byosoft.com.cn>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao
> A <hao.a.wu@intel.com>
> Subject: [Patch V3 4/9] MdeModulePkg: Add new structure for the Universal
> Payload SMBios Table Info Hob
>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
>
> Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
> ---
> MdeModulePkg/Include/UniversalPayload/SmbiosTable.h | 28
> ++++++++++++++++++++++++++++
> MdeModulePkg/MdeModulePkg.dec | 6 ++++++
> 2 files changed, 34 insertions(+)
>
> diff --git a/MdeModulePkg/Include/UniversalPayload/SmbiosTable.h
> b/MdeModulePkg/Include/UniversalPayload/SmbiosTable.h
> new file mode 100644
> index 0000000000..3aaa926396
> --- /dev/null
> +++ b/MdeModulePkg/Include/UniversalPayload/SmbiosTable.h
> @@ -0,0 +1,28 @@
> +/** @file
>
> + Define the structure for the Payload SmBios.
>
> +
>
> +Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
>
> +SPDX-License-Identifier: BSD-2-Clause-Patent
>
> +
Could you help to add the specification reference information in the header file description comment?
With this handled:
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
Best Regards,
Hao Wu
>
> +**/
>
> +
>
> +#ifndef _PLD_SMBIOS_TABL_H_
>
> +#define _PLD_SMBIOS_TABL_H_
>
> +
>
> +#include <Uefi.h>
>
> +#include <UniversalPayload/UniversalPayload.h>
>
> +
>
> +#pragma pack (1)
>
> +
>
> +typedef struct {
>
> + PLD_GENERIC_HEADER PldHeader;
>
> + EFI_PHYSICAL_ADDRESS SmBiosEntryPoint;
>
> +} PLD_SMBIOS_TABLE;
>
> +
>
> +#pragma pack()
>
> +
>
> +#define PLD_SMBIOS_TABLE_REVISION 1
>
> +
>
> +extern GUID gPldSmbios3TableGuid;
>
> +extern GUID gPldSmbiosTableGuid;
>
> +#endif //_PLD_SMBIOS_TABL_H_
>
> diff --git a/MdeModulePkg/MdeModulePkg.dec
> b/MdeModulePkg/MdeModulePkg.dec
> index 671d0f33c8..45324d2e20 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -410,6 +410,12 @@
> ## Include/UniversalPayload/PciRootBridges.h
>
> gPldPciRootBridgeInfoGuid = { 0xec4ebacb, 0x2638, 0x416e, { 0xbe, 0x80,
> 0xe5, 0xfa, 0x4b, 0x51, 0x19, 0x01 }}
>
>
>
> + ## Include/UniversalPayload/SmbiosTable.h
>
> + gPldSmbios3TableGuid = { 0x92b7896c, 0x3362, 0x46ce, { 0x99, 0xb3, 0x4f,
> 0x5e, 0x3c, 0x34, 0xeb, 0x42 } }
>
> +
>
> + ## Include/UniversalPayload/SmbiosTable.h
>
> + gPldSmbiosTableGuid = { 0x590a0d26, 0x06e5, 0x4d20, { 0x8a, 0x82, 0x59,
> 0xea, 0x1b, 0x34, 0x98, 0x2d } }
>
> +
>
> [Ppis]
>
> ## Include/Ppi/AtaController.h
>
> gPeiAtaControllerPpiGuid = { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0, 0x7a,
> 0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }}
>
> --
> 2.30.0.windows.2
^ permalink raw reply [flat|nested] 22+ messages in thread
* [Patch V3 5/9] MdeModulePkg/Universal/SmbiosDxe: Scan for existing tables
2021-06-04 9:42 [Patch V3 0/9] Create multiple Hobs for Universal Payload Zhiguang Liu
` (3 preceding siblings ...)
2021-06-04 9:42 ` [Patch V3 4/9] MdeModulePkg: Add new structure for the Universal Payload SMBios Table Info Hob Zhiguang Liu
@ 2021-06-04 9:42 ` Zhiguang Liu
2021-06-08 5:21 ` Wu, Hao A
2021-06-08 9:20 ` Patrick Rudolph
2021-06-04 9:42 ` [Patch V3 6/9] UefiPayloadPkg: Creat gPldSmbiosTableGuid Hob Zhiguang Liu
` (3 subsequent siblings)
8 siblings, 2 replies; 22+ messages in thread
From: Zhiguang Liu @ 2021-06-04 9:42 UTC (permalink / raw)
To: devel
Cc: Jian J Wang, Hao A Wu, Dandan Bi, Star Zeng, Zhichao Gao,
Patrick Rudolph
V1:
The default EfiSmbiosProtocol operates on an empty SMBIOS table.
The SMBIOS tables are provided by the bootloader on UefiPayloadPkg.
Scan for existing tables in SmbiosDxe and load them if they seem valid.
This fixes the settings menu not showing any hardware information, instead
only "0 MB RAM" was displayed.
Tests showed that the OS can still see the SMBIOS tables.
V2:
SmbiosDxe will get the SMBIOS from a guid Hob.
Aslo will keep the SmbiosHandle if it is available.
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
---
MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c | 320 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h | 4 +++-
MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf | 5 ++++-
3 files changed, 325 insertions(+), 4 deletions(-)
diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c
index 3cdb0b1ed7..3579c4d890 100644
--- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c
+++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c
@@ -2,7 +2,7 @@
This code produces the Smbios protocol. It also responsible for constructing
SMBIOS table into system table.
-Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -148,6 +148,31 @@ SMBIOS_TABLE_3_0_ENTRY_POINT Smbios30EntryPointStructureData = {
//
0
};
+
+/**
+ Validates a SMBIOS table entry point.
+
+ @param TableEntry The SmBios table entry to validate.
+ @param TableAddress On exit, point to the smbios table addres.
+ @param TableMaximumSize On exit, point to the maximum size of the table.
+
+ @retval TRUE SMBIOS table entry point is valid.
+ @retval FALSE SMBIOS table entry point is malformed.
+
+**/
+typedef
+BOOLEAN
+(* IS_SMBIOS_TABLE_VALID) (
+ IN VOID *TableEntry,
+ OUT VOID **TableAddress,
+ OUT UINTN *TableMaximumSize
+ );
+typedef struct {
+ EFI_GUID *Guid;
+ IS_SMBIOS_TABLE_VALID IsValid;
+} IS_SMBIOS_TABLE_VALID_ENTRY;
+
+
/**
Get the full size of SMBIOS structure including optional strings that follow the formatted structure.
@@ -1408,6 +1433,296 @@ SmbiosTableConstruction (
}
}
+/**
+ Validates a SMBIOS 2.0 table entry point.
+
+ @param TableEntry The SmBios table entry to validate.
+ @param TableAddress On exit, point to the smbios table addres.
+ @param TableMaximumSize On exit, point to the maximum size of the table.
+
+ @retval TRUE SMBIOS table entry point is valid.
+ @retval FALSE SMBIOS table entry point is malformed.
+
+**/
+STATIC
+BOOLEAN
+IsValidSmbios20Table (
+ IN VOID *TableEntry,
+ OUT VOID **TableAddress,
+ OUT UINTN *TableMaximumSize
+ )
+{
+ UINT8 Checksum;
+ SMBIOS_TABLE_ENTRY_POINT *SmbiosTable;
+ SmbiosTable = (SMBIOS_TABLE_ENTRY_POINT *) TableEntry;
+
+ if (CompareMem (SmbiosTable->AnchorString, "_SM_", 4) != 0) {
+ return FALSE;
+ }
+
+ if (CompareMem (SmbiosTable->IntermediateAnchorString, "_DMI_", 5) != 0) {
+ return FALSE;
+ }
+
+ //
+ // The actual value of the EntryPointLength should be 1Fh.
+ // However, it was incorrectly stated in version 2.1 of smbios specification.
+ // Therefore, 0x1F and 0x1E are both accepted.
+ //
+ if (SmbiosTable->EntryPointLength != 0x1E && SmbiosTable->EntryPointLength != sizeof (SMBIOS_TABLE_ENTRY_POINT)) {
+ return FALSE;
+ }
+
+ //
+ // MajorVersion should not be less than 2.
+ //
+ if (SmbiosTable->MajorVersion < 2) {
+ return FALSE;
+ }
+
+ //
+ // The whole struct check sum should be zero
+ //
+ Checksum = CalculateSum8 (
+ (UINT8 *) SmbiosTable,
+ SmbiosTable->EntryPointLength
+ );
+ if (Checksum != 0) {
+ return FALSE;
+ }
+
+ //
+ // The Intermediate Entry Point Structure check sum should be zero.
+ //
+ Checksum = CalculateSum8 (
+ (UINT8 *) SmbiosTable + OFFSET_OF (SMBIOS_TABLE_ENTRY_POINT, IntermediateAnchorString),
+ SmbiosTable->EntryPointLength - OFFSET_OF (SMBIOS_TABLE_ENTRY_POINT, IntermediateAnchorString)
+ );
+ if (Checksum != 0) {
+ return FALSE;
+ }
+
+ *TableAddress = (VOID *) (UINTN) SmbiosTable->TableAddress;
+ *TableMaximumSize = SmbiosTable->TableLength;
+ return TRUE;
+}
+
+/**
+ Validates a SMBIOS 3.0 table entry point.
+
+ @param TableEntry The SmBios table entry to validate.
+ @param TableAddress On exit, point to the smbios table addres.
+ @param TableMaximumSize On exit, point to the maximum size of the table.
+
+ @retval TRUE SMBIOS table entry point is valid.
+ @retval FALSE SMBIOS table entry point is malformed.
+
+**/
+STATIC
+BOOLEAN
+IsValidSmbios30Table (
+ IN VOID *TableEntry,
+ OUT VOID **TableAddress,
+ OUT UINTN *TableMaximumSize
+ )
+{
+ UINT8 Checksum;
+ SMBIOS_TABLE_3_0_ENTRY_POINT *SmbiosTable;
+ SmbiosTable = (SMBIOS_TABLE_3_0_ENTRY_POINT *) TableEntry;
+
+ if (CompareMem (SmbiosTable->AnchorString, "_SM3_", 5) != 0) {
+ return FALSE;
+ }
+ if (SmbiosTable->EntryPointLength < sizeof (SMBIOS_TABLE_3_0_ENTRY_POINT)) {
+ return FALSE;
+ }
+ if (SmbiosTable->MajorVersion < 3) {
+ return FALSE;
+ }
+
+ //
+ // The whole struct check sum should be zero
+ //
+ Checksum = CalculateSum8 (
+ (UINT8 *) SmbiosTable,
+ SmbiosTable->EntryPointLength
+ );
+ if (Checksum != 0) {
+ return FALSE;
+ }
+
+ *TableAddress = (VOID *) (UINTN) SmbiosTable->TableAddress;
+ *TableMaximumSize = SmbiosTable->TableMaximumSize;
+ return TRUE;
+}
+
+/**
+ Parse an existing SMBIOS table and insert it using SmbiosAdd.
+
+ @param ImageHandle The EFI_HANDLE to this driver.
+ @param Smbios The SMBIOS table to parse.
+ @param Length The length of the SMBIOS table.
+
+ @retval EFI_SUCCESS SMBIOS table was parsed and installed.
+ @retval EFI_OUT_OF_RESOURCES Record was not added due to lack of system resources.
+ @retval EFI_INVALID_PARAMETER Smbios is not a correct smbios table
+
+**/
+STATIC
+EFI_STATUS
+ParseAndAddExistingSmbiosTable (
+ IN EFI_HANDLE ImageHandle,
+ IN SMBIOS_STRUCTURE_POINTER Smbios,
+ IN UINTN Length
+ )
+{
+ EFI_STATUS Status;
+ CHAR8 *String;
+ EFI_SMBIOS_HANDLE SmbiosHandle;
+ SMBIOS_STRUCTURE_POINTER SmbiosEnd;
+
+ SmbiosEnd.Raw = Smbios.Raw + Length;
+
+ if (Smbios.Raw >= SmbiosEnd.Raw || Smbios.Raw == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ do {
+ //
+ // Make sure not to access memory beyond SmbiosEnd
+ //
+ if (Smbios.Raw + sizeof (SMBIOS_STRUCTURE) > SmbiosEnd.Raw ||
+ Smbios.Raw + sizeof (SMBIOS_STRUCTURE) < Smbios.Raw) {
+ return EFI_INVALID_PARAMETER;
+ }
+ //
+ // Check for end marker
+ //
+ if (Smbios.Hdr->Type == SMBIOS_TYPE_END_OF_TABLE) {
+ break;
+ }
+ //
+ // Make sure not to access memory beyond SmbiosEnd
+ // Each structure shall be terminated by a double-null (0000h).
+ //
+ if (Smbios.Raw + Smbios.Hdr->Length + 2 * sizeof (UINT8) > SmbiosEnd.Raw ||
+ Smbios.Raw + Smbios.Hdr->Length + 2 * sizeof (UINT8) < Smbios.Raw) {
+ return EFI_INVALID_PARAMETER;
+ }
+ //
+ // Install the table
+ //
+ SmbiosHandle = Smbios.Hdr->Handle;
+ Status = SmbiosAdd (
+ &mPrivateData.Smbios,
+ ImageHandle,
+ &SmbiosHandle,
+ Smbios.Hdr
+ );
+
+ ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ //
+ // Go to the next SMBIOS structure. Each SMBIOS structure may include 2 parts:
+ // 1. Formatted section; 2. Unformatted string section. So, 2 steps are needed
+ // to skip one SMBIOS structure.
+ //
+
+ //
+ // Step 1: Skip over formatted section.
+ //
+ String = (CHAR8 *) (Smbios.Raw + Smbios.Hdr->Length);
+
+ //
+ // Step 2: Skip over unformatted string section.
+ //
+ do {
+ //
+ // Each string is terminated with a NULL(00h) BYTE and the sets of strings
+ // is terminated with an additional NULL(00h) BYTE.
+ //
+ for ( ; *String != 0; String++) {
+ if ((UINTN) String >= (UINTN) SmbiosEnd.Raw - sizeof (UINT8)) {
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
+ if (*(UINT8 *) ++String == 0) {
+ //
+ // Pointer to the next SMBIOS structure.
+ //
+ Smbios.Raw = (UINT8 *) ++String;
+ break;
+ }
+ } while (TRUE);
+ } while (Smbios.Raw < SmbiosEnd.Raw);
+
+ return EFI_SUCCESS;
+}
+
+
+IS_SMBIOS_TABLE_VALID_ENTRY mIsSmbiosTableValid[] = {
+ {&gPldSmbios3TableGuid, IsValidSmbios30Table },
+ {&gPldSmbiosTableGuid, IsValidSmbios20Table }
+};
+
+/**
+ Retrieve SMBIOS from Hob.
+ @param ImageHandle Module's image handle
+
+ @retval EFI_SUCCESS Smbios from Hob is installed.
+ @return EFI_NOT_FOUND Not found Smbios from Hob.
+ @retval Other No Smbios from Hob is installed.
+
+**/
+EFI_STATUS
+RetrieveSmbiosFromHob (
+ IN EFI_HANDLE ImageHandle
+ )
+{
+ EFI_STATUS Status;
+ UINTN Index;
+ SMBIOS_STRUCTURE_POINTER Smbios;
+ EFI_HOB_GUID_TYPE *GuidHob;
+ PLD_SMBIOS_TABLE *SmBiosTableAdress;
+ PLD_GENERIC_HEADER *GenericHeader;
+ VOID *TableAddress;
+ UINTN TableMaximumSize;
+
+ Status = EFI_NOT_FOUND;
+
+ for (Index = 0; Index < ARRAY_SIZE (mIsSmbiosTableValid); Index++) {
+ GuidHob = GetFirstGuidHob (mIsSmbiosTableValid[Index].Guid);
+ if (GuidHob == NULL) {
+ continue;
+ }
+ GenericHeader = (PLD_GENERIC_HEADER *) GET_GUID_HOB_DATA (GuidHob);
+ if ((sizeof (PLD_GENERIC_HEADER) <= GET_GUID_HOB_DATA_SIZE (GuidHob)) && (GenericHeader->Length <= GET_GUID_HOB_DATA_SIZE (GuidHob))) {
+ if (GenericHeader->Revision == PLD_SMBIOS_TABLE_REVISION) {
+ //
+ // PLD_SMBIOS_TABLE structure is used when Revision equals to PLD_SMBIOS_TABLE_REVISION
+ //
+ SmBiosTableAdress = (PLD_SMBIOS_TABLE *) GET_GUID_HOB_DATA (GuidHob);
+ if (GenericHeader->Length >= PLD_SIZEOF_THROUGH_FIELD (PLD_SMBIOS_TABLE, SmBiosEntryPoint)) {
+ if (mIsSmbiosTableValid[Index].IsValid ((VOID *) (UINTN )SmBiosTableAdress->SmBiosEntryPoint, &TableAddress, &TableMaximumSize)) {
+ Smbios.Raw = TableAddress;
+ Status = ParseAndAddExistingSmbiosTable (ImageHandle, Smbios, TableMaximumSize);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "RetrieveSmbiosFromHob: Failed to parse preinstalled tables from gPldSmbios3TableGuid Guid Hob\n"));
+ Status = EFI_UNSUPPORTED;
+ } else {
+ return EFI_SUCCESS;
+ }
+ }
+ }
+ }
+ }
+ }
+ return Status;
+}
+
/**
Driver to produce Smbios protocol and pre-allocate 1 page for the final SMBIOS table.
@@ -1451,5 +1766,6 @@ SmbiosDriverEntryPoint (
&mPrivateData.Smbios
);
- return Status;
+ RetrieveSmbiosFromHob (ImageHandle);
+ return EFI_SUCCESS;
}
diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h
index f97c85ae40..a260cf695e 100644
--- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h
+++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h
@@ -1,7 +1,7 @@
/** @file
This code supports the implementation of the Smbios protocol
-Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -24,6 +24,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/PcdLib.h>
+#include <Library/HobLib.h>
+#include <UniversalPayload/SmbiosTable.h>
#define SMBIOS_INSTANCE_SIGNATURE SIGNATURE_32 ('S', 'B', 'i', 's')
typedef struct {
diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
index f6c036e1dc..63f468936d 100644
--- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
+++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
@@ -1,7 +1,7 @@
## @file
# This driver initializes and installs the SMBIOS protocol, constructs SMBIOS table into system configuration table.
#
-# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -41,6 +41,7 @@
UefiDriverEntryPoint
DebugLib
PcdLib
+ HobLib
[Protocols]
gEfiSmbiosProtocolGuid ## PRODUCES
@@ -48,6 +49,8 @@
[Guids]
gEfiSmbiosTableGuid ## SOMETIMES_PRODUCES ## SystemTable
gEfiSmbios3TableGuid ## SOMETIMES_PRODUCES ## SystemTable
+ gPldSmbios3TableGuid ## CONSUMES ## HOB
+ gPldSmbiosTableGuid ## SOMETIMES_CONSUMES ## HOB
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion ## CONSUMES
--
2.30.0.windows.2
^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [Patch V3 5/9] MdeModulePkg/Universal/SmbiosDxe: Scan for existing tables
2021-06-04 9:42 ` [Patch V3 5/9] MdeModulePkg/Universal/SmbiosDxe: Scan for existing tables Zhiguang Liu
@ 2021-06-08 5:21 ` Wu, Hao A
2021-06-08 9:20 ` Patrick Rudolph
1 sibling, 0 replies; 22+ messages in thread
From: Wu, Hao A @ 2021-06-08 5:21 UTC (permalink / raw)
To: Liu, Zhiguang, devel@edk2.groups.io
Cc: Wang, Jian J, Bi, Dandan, Zeng, Star, Gao, Zhichao,
Patrick Rudolph
> -----Original Message-----
> From: Liu, Zhiguang <zhiguang.liu@intel.com>
> Sent: Friday, June 4, 2021 5:42 PM
> To: devel@edk2.groups.io
> Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;
> Bi, Dandan <dandan.bi@intel.com>; Zeng, Star <star.zeng@intel.com>; Gao,
> Zhichao <zhichao.gao@intel.com>; Patrick Rudolph
> <patrick.rudolph@9elements.com>
> Subject: [Patch V3 5/9] MdeModulePkg/Universal/SmbiosDxe: Scan for
> existing tables
>
> V1:
> The default EfiSmbiosProtocol operates on an empty SMBIOS table.
> The SMBIOS tables are provided by the bootloader on UefiPayloadPkg.
> Scan for existing tables in SmbiosDxe and load them if they seem valid.
>
> This fixes the settings menu not showing any hardware information, instead
> only "0 MB RAM" was displayed.
>
> Tests showed that the OS can still see the SMBIOS tables.
>
> V2:
> SmbiosDxe will get the SMBIOS from a guid Hob.
> Aslo will keep the SmbiosHandle if it is available.
Aslo -> Also
>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Dandan Bi <dandan.bi@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Zhichao Gao <zhichao.gao@intel.com>
> Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
> Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
> ---
> MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c | 320
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> ++++++++++++++++++++++++++++--
> MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h | 4 +++-
> MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf | 5 ++++-
> 3 files changed, 325 insertions(+), 4 deletions(-)
>
> diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c
> b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c
> index 3cdb0b1ed7..3579c4d890 100644
> --- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c
> +++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c
> @@ -2,7 +2,7 @@
> This code produces the Smbios protocol. It also responsible for constructing
>
> SMBIOS table into system table.
>
>
>
> -Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
>
> +Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.<BR>
>
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
>
>
> **/
>
> @@ -148,6 +148,31 @@ SMBIOS_TABLE_3_0_ENTRY_POINT
> Smbios30EntryPointStructureData = {
> //
>
> 0
>
> };
>
> +
>
> +/**
>
> + Validates a SMBIOS table entry point.
>
> +
>
> + @param TableEntry The SmBios table entry to validate.
>
> + @param TableAddress On exit, point to the smbios table addres.
>
> + @param TableMaximumSize On exit, point to the maximum size of the
> table.
>
> +
>
> + @retval TRUE SMBIOS table entry point is valid.
>
> + @retval FALSE SMBIOS table entry point is malformed.
>
> +
>
> +**/
>
> +typedef
>
> +BOOLEAN
>
> +(* IS_SMBIOS_TABLE_VALID) (
>
> + IN VOID *TableEntry,
>
> + OUT VOID **TableAddress,
>
> + OUT UINTN *TableMaximumSize
>
> + );
>
> +typedef struct {
>
> + EFI_GUID *Guid;
>
> + IS_SMBIOS_TABLE_VALID IsValid;
>
> +} IS_SMBIOS_TABLE_VALID_ENTRY;
>
> +
>
> +
Could you help to put the above definitions into file "SmbiosDxe.h"?
>
> /**
>
>
>
> Get the full size of SMBIOS structure including optional strings that follow
> the formatted structure.
>
> @@ -1408,6 +1433,296 @@ SmbiosTableConstruction (
> }
>
> }
>
>
>
> +/**
>
> + Validates a SMBIOS 2.0 table entry point.
>
> +
>
> + @param TableEntry The SmBios table entry to validate.
>
> + @param TableAddress On exit, point to the smbios table addres.
>
> + @param TableMaximumSize On exit, point to the maximum size of the
> table.
>
> +
>
> + @retval TRUE SMBIOS table entry point is valid.
>
> + @retval FALSE SMBIOS table entry point is malformed.
>
> +
>
> +**/
>
> +STATIC
>
> +BOOLEAN
>
> +IsValidSmbios20Table (
>
> + IN VOID *TableEntry,
>
> + OUT VOID **TableAddress,
>
> + OUT UINTN *TableMaximumSize
>
> + )
>
> +{
>
> + UINT8 Checksum;
>
> + SMBIOS_TABLE_ENTRY_POINT *SmbiosTable;
>
> + SmbiosTable = (SMBIOS_TABLE_ENTRY_POINT *) TableEntry;
>
> +
>
> + if (CompareMem (SmbiosTable->AnchorString, "_SM_", 4) != 0) {
>
> + return FALSE;
>
> + }
>
> +
>
> + if (CompareMem (SmbiosTable->IntermediateAnchorString, "_DMI_",
> 5) != 0) {
>
> + return FALSE;
>
> + }
>
> +
>
> + //
>
> + // The actual value of the EntryPointLength should be 1Fh.
>
> + // However, it was incorrectly stated in version 2.1 of smbios specification.
>
> + // Therefore, 0x1F and 0x1E are both accepted.
>
> + //
>
> + if (SmbiosTable->EntryPointLength != 0x1E && SmbiosTable-
> >EntryPointLength != sizeof (SMBIOS_TABLE_ENTRY_POINT)) {
>
> + return FALSE;
>
> + }
>
> +
>
> + //
>
> + // MajorVersion should not be less than 2.
>
> + //
>
> + if (SmbiosTable->MajorVersion < 2) {
>
> + return FALSE;
>
> + }
>
> +
>
> + //
>
> + // The whole struct check sum should be zero
>
> + //
>
> + Checksum = CalculateSum8 (
>
> + (UINT8 *) SmbiosTable,
>
> + SmbiosTable->EntryPointLength
>
> + );
>
> + if (Checksum != 0) {
>
> + return FALSE;
>
> + }
>
> +
>
> + //
>
> + // The Intermediate Entry Point Structure check sum should be zero.
>
> + //
>
> + Checksum = CalculateSum8 (
>
> + (UINT8 *) SmbiosTable + OFFSET_OF
> (SMBIOS_TABLE_ENTRY_POINT, IntermediateAnchorString),
>
> + SmbiosTable->EntryPointLength - OFFSET_OF
> (SMBIOS_TABLE_ENTRY_POINT, IntermediateAnchorString)
>
> + );
>
> + if (Checksum != 0) {
>
> + return FALSE;
>
> + }
>
> +
>
> + *TableAddress = (VOID *) (UINTN) SmbiosTable->TableAddress;
>
> + *TableMaximumSize = SmbiosTable->TableLength;
>
> + return TRUE;
>
> +}
>
> +
>
> +/**
>
> + Validates a SMBIOS 3.0 table entry point.
>
> +
>
> + @param TableEntry The SmBios table entry to validate.
>
> + @param TableAddress On exit, point to the smbios table addres.
>
> + @param TableMaximumSize On exit, point to the maximum size of the
> table.
>
> +
>
> + @retval TRUE SMBIOS table entry point is valid.
>
> + @retval FALSE SMBIOS table entry point is malformed.
>
> +
>
> +**/
>
> +STATIC
>
> +BOOLEAN
>
> +IsValidSmbios30Table (
>
> + IN VOID *TableEntry,
>
> + OUT VOID **TableAddress,
>
> + OUT UINTN *TableMaximumSize
>
> + )
>
> +{
>
> + UINT8 Checksum;
>
> + SMBIOS_TABLE_3_0_ENTRY_POINT *SmbiosTable;
>
> + SmbiosTable = (SMBIOS_TABLE_3_0_ENTRY_POINT *) TableEntry;
>
> +
>
> + if (CompareMem (SmbiosTable->AnchorString, "_SM3_", 5) != 0) {
>
> + return FALSE;
>
> + }
>
> + if (SmbiosTable->EntryPointLength < sizeof
> (SMBIOS_TABLE_3_0_ENTRY_POINT)) {
>
> + return FALSE;
>
> + }
>
> + if (SmbiosTable->MajorVersion < 3) {
>
> + return FALSE;
>
> + }
>
> +
>
> + //
>
> + // The whole struct check sum should be zero
>
> + //
>
> + Checksum = CalculateSum8 (
>
> + (UINT8 *) SmbiosTable,
>
> + SmbiosTable->EntryPointLength
>
> + );
>
> + if (Checksum != 0) {
>
> + return FALSE;
>
> + }
>
> +
>
> + *TableAddress = (VOID *) (UINTN) SmbiosTable->TableAddress;
>
> + *TableMaximumSize = SmbiosTable->TableMaximumSize;
>
> + return TRUE;
>
> +}
>
> +
>
> +/**
>
> + Parse an existing SMBIOS table and insert it using SmbiosAdd.
>
> +
>
> + @param ImageHandle The EFI_HANDLE to this driver.
>
> + @param Smbios The SMBIOS table to parse.
>
> + @param Length The length of the SMBIOS table.
>
> +
>
> + @retval EFI_SUCCESS SMBIOS table was parsed and installed.
>
> + @retval EFI_OUT_OF_RESOURCES Record was not added due to lack of
> system resources.
>
> + @retval EFI_INVALID_PARAMETER Smbios is not a correct smbios table
>
> +
>
> +**/
>
> +STATIC
>
> +EFI_STATUS
>
> +ParseAndAddExistingSmbiosTable (
>
> + IN EFI_HANDLE ImageHandle,
>
> + IN SMBIOS_STRUCTURE_POINTER Smbios,
>
> + IN UINTN Length
>
> + )
>
> +{
>
> + EFI_STATUS Status;
>
> + CHAR8 *String;
>
> + EFI_SMBIOS_HANDLE SmbiosHandle;
>
> + SMBIOS_STRUCTURE_POINTER SmbiosEnd;
>
> +
>
> + SmbiosEnd.Raw = Smbios.Raw + Length;
>
> +
>
> + if (Smbios.Raw >= SmbiosEnd.Raw || Smbios.Raw == NULL) {
>
> + return EFI_INVALID_PARAMETER;
>
> + }
>
> +
>
> + do {
>
> + //
>
> + // Make sure not to access memory beyond SmbiosEnd
>
> + //
>
> + if (Smbios.Raw + sizeof (SMBIOS_STRUCTURE) > SmbiosEnd.Raw ||
>
> + Smbios.Raw + sizeof (SMBIOS_STRUCTURE) < Smbios.Raw) {
>
> + return EFI_INVALID_PARAMETER;
>
> + }
>
> + //
>
> + // Check for end marker
>
> + //
>
> + if (Smbios.Hdr->Type == SMBIOS_TYPE_END_OF_TABLE) {
>
> + break;
>
> + }
>
> + //
>
> + // Make sure not to access memory beyond SmbiosEnd
>
> + // Each structure shall be terminated by a double-null (0000h).
>
> + //
>
> + if (Smbios.Raw + Smbios.Hdr->Length + 2 * sizeof (UINT8) >
> SmbiosEnd.Raw ||
>
> + Smbios.Raw + Smbios.Hdr->Length + 2 * sizeof (UINT8) < Smbios.Raw) {
>
> + return EFI_INVALID_PARAMETER;
>
> + }
>
> + //
>
> + // Install the table
>
> + //
>
> + SmbiosHandle = Smbios.Hdr->Handle;
>
> + Status = SmbiosAdd (
>
> + &mPrivateData.Smbios,
>
> + ImageHandle,
>
> + &SmbiosHandle,
>
> + Smbios.Hdr
>
> + );
>
> +
>
> + ASSERT_EFI_ERROR (Status);
>
> + if (EFI_ERROR (Status)) {
>
> + return Status;
>
> + }
>
> + //
>
> + // Go to the next SMBIOS structure. Each SMBIOS structure may include 2
> parts:
>
> + // 1. Formatted section; 2. Unformatted string section. So, 2 steps are
> needed
>
> + // to skip one SMBIOS structure.
>
> + //
>
> +
>
> + //
>
> + // Step 1: Skip over formatted section.
>
> + //
>
> + String = (CHAR8 *) (Smbios.Raw + Smbios.Hdr->Length);
>
> +
>
> + //
>
> + // Step 2: Skip over unformatted string section.
>
> + //
>
> + do {
>
> + //
>
> + // Each string is terminated with a NULL(00h) BYTE and the sets of strings
>
> + // is terminated with an additional NULL(00h) BYTE.
>
> + //
>
> + for ( ; *String != 0; String++) {
>
> + if ((UINTN) String >= (UINTN) SmbiosEnd.Raw - sizeof (UINT8)) {
>
> + return EFI_INVALID_PARAMETER;
>
> + }
>
> + }
>
> +
>
> + if (*(UINT8 *) ++String == 0) {
>
> + //
>
> + // Pointer to the next SMBIOS structure.
>
> + //
>
> + Smbios.Raw = (UINT8 *) ++String;
>
> + break;
>
> + }
>
> + } while (TRUE);
>
> + } while (Smbios.Raw < SmbiosEnd.Raw);
>
> +
>
> + return EFI_SUCCESS;
>
> +}
>
> +
>
> +
>
> +IS_SMBIOS_TABLE_VALID_ENTRY mIsSmbiosTableValid[] = {
>
> + {&gPldSmbios3TableGuid, IsValidSmbios30Table },
>
> + {&gPldSmbiosTableGuid, IsValidSmbios20Table }
>
> +};
Could you help to put this global variable to the beginning of this file?
With the above 3 format comments handled:
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
Best Regards,
Hao Wu
>
> +
>
> +/**
>
> + Retrieve SMBIOS from Hob.
>
> + @param ImageHandle Module's image handle
>
> +
>
> + @retval EFI_SUCCESS Smbios from Hob is installed.
>
> + @return EFI_NOT_FOUND Not found Smbios from Hob.
>
> + @retval Other No Smbios from Hob is installed.
>
> +
>
> +**/
>
> +EFI_STATUS
>
> +RetrieveSmbiosFromHob (
>
> + IN EFI_HANDLE ImageHandle
>
> + )
>
> +{
>
> + EFI_STATUS Status;
>
> + UINTN Index;
>
> + SMBIOS_STRUCTURE_POINTER Smbios;
>
> + EFI_HOB_GUID_TYPE *GuidHob;
>
> + PLD_SMBIOS_TABLE *SmBiosTableAdress;
>
> + PLD_GENERIC_HEADER *GenericHeader;
>
> + VOID *TableAddress;
>
> + UINTN TableMaximumSize;
>
> +
>
> + Status = EFI_NOT_FOUND;
>
> +
>
> + for (Index = 0; Index < ARRAY_SIZE (mIsSmbiosTableValid); Index++) {
>
> + GuidHob = GetFirstGuidHob (mIsSmbiosTableValid[Index].Guid);
>
> + if (GuidHob == NULL) {
>
> + continue;
>
> + }
>
> + GenericHeader = (PLD_GENERIC_HEADER *) GET_GUID_HOB_DATA
> (GuidHob);
>
> + if ((sizeof (PLD_GENERIC_HEADER) <= GET_GUID_HOB_DATA_SIZE
> (GuidHob)) && (GenericHeader->Length <= GET_GUID_HOB_DATA_SIZE
> (GuidHob))) {
>
> + if (GenericHeader->Revision == PLD_SMBIOS_TABLE_REVISION) {
>
> + //
>
> + // PLD_SMBIOS_TABLE structure is used when Revision equals to
> PLD_SMBIOS_TABLE_REVISION
>
> + //
>
> + SmBiosTableAdress = (PLD_SMBIOS_TABLE *) GET_GUID_HOB_DATA
> (GuidHob);
>
> + if (GenericHeader->Length >= PLD_SIZEOF_THROUGH_FIELD
> (PLD_SMBIOS_TABLE, SmBiosEntryPoint)) {
>
> + if (mIsSmbiosTableValid[Index].IsValid ((VOID *)
> (UINTN )SmBiosTableAdress->SmBiosEntryPoint, &TableAddress,
> &TableMaximumSize)) {
>
> + Smbios.Raw = TableAddress;
>
> + Status = ParseAndAddExistingSmbiosTable (ImageHandle, Smbios,
> TableMaximumSize);
>
> + if (EFI_ERROR (Status)) {
>
> + DEBUG ((DEBUG_ERROR, "RetrieveSmbiosFromHob: Failed to parse
> preinstalled tables from gPldSmbios3TableGuid Guid Hob\n"));
>
> + Status = EFI_UNSUPPORTED;
>
> + } else {
>
> + return EFI_SUCCESS;
>
> + }
>
> + }
>
> + }
>
> + }
>
> + }
>
> + }
>
> + return Status;
>
> +}
>
> +
>
> /**
>
>
>
> Driver to produce Smbios protocol and pre-allocate 1 page for the final
> SMBIOS table.
>
> @@ -1451,5 +1766,6 @@ SmbiosDriverEntryPoint (
> &mPrivateData.Smbios
>
> );
>
>
>
> - return Status;
>
> + RetrieveSmbiosFromHob (ImageHandle);
>
> + return EFI_SUCCESS;
>
> }
>
> diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h
> b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h
> index f97c85ae40..a260cf695e 100644
> --- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h
> +++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h
> @@ -1,7 +1,7 @@
> /** @file
>
> This code supports the implementation of the Smbios protocol
>
>
>
> -Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
>
> +Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.<BR>
>
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
>
>
> **/
>
> @@ -24,6 +24,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> #include <Library/MemoryAllocationLib.h>
>
> #include <Library/UefiBootServicesTableLib.h>
>
> #include <Library/PcdLib.h>
>
> +#include <Library/HobLib.h>
>
> +#include <UniversalPayload/SmbiosTable.h>
>
>
>
> #define SMBIOS_INSTANCE_SIGNATURE SIGNATURE_32 ('S', 'B', 'i', 's')
>
> typedef struct {
>
> diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
> b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
> index f6c036e1dc..63f468936d 100644
> --- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
> +++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
> @@ -1,7 +1,7 @@
> ## @file
>
> # This driver initializes and installs the SMBIOS protocol, constructs SMBIOS
> table into system configuration table.
>
> #
>
> -# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
>
> +# Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.<BR>
>
> #
>
> # SPDX-License-Identifier: BSD-2-Clause-Patent
>
> #
>
> @@ -41,6 +41,7 @@
> UefiDriverEntryPoint
>
> DebugLib
>
> PcdLib
>
> + HobLib
>
>
>
> [Protocols]
>
> gEfiSmbiosProtocolGuid ## PRODUCES
>
> @@ -48,6 +49,8 @@
> [Guids]
>
> gEfiSmbiosTableGuid ## SOMETIMES_PRODUCES ##
> SystemTable
>
> gEfiSmbios3TableGuid ## SOMETIMES_PRODUCES ##
> SystemTable
>
> + gPldSmbios3TableGuid ## CONSUMES ## HOB
>
> + gPldSmbiosTableGuid ## SOMETIMES_CONSUMES ## HOB
>
>
>
> [Pcd]
>
> gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion ## CONSUMES
>
> --
> 2.30.0.windows.2
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Patch V3 5/9] MdeModulePkg/Universal/SmbiosDxe: Scan for existing tables
2021-06-04 9:42 ` [Patch V3 5/9] MdeModulePkg/Universal/SmbiosDxe: Scan for existing tables Zhiguang Liu
2021-06-08 5:21 ` Wu, Hao A
@ 2021-06-08 9:20 ` Patrick Rudolph
2021-06-10 1:56 ` Zhiguang Liu
1 sibling, 1 reply; 22+ messages in thread
From: Patrick Rudolph @ 2021-06-08 9:20 UTC (permalink / raw)
To: Zhiguang Liu
Cc: devel, Jian J Wang, Hao A Wu, Dandan Bi, Star Zeng, Zhichao Gao
On Fri, Jun 4, 2021 at 11:42 AM Zhiguang Liu <zhiguang.liu@intel.com> wrote:
>
> V1:
> The default EfiSmbiosProtocol operates on an empty SMBIOS table.
> The SMBIOS tables are provided by the bootloader on UefiPayloadPkg.
> Scan for existing tables in SmbiosDxe and load them if they seem valid.
>
> This fixes the settings menu not showing any hardware information, instead
> only "0 MB RAM" was displayed.
>
> Tests showed that the OS can still see the SMBIOS tables.
>
> V2:
> SmbiosDxe will get the SMBIOS from a guid Hob.
> Aslo will keep the SmbiosHandle if it is available.
>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Dandan Bi <dandan.bi@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Zhichao Gao <zhichao.gao@intel.com>
> Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
> Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
> ---
> MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c | 320 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
> MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h | 4 +++-
> MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf | 5 ++++-
> 3 files changed, 325 insertions(+), 4 deletions(-)
>
> diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c
> index 3cdb0b1ed7..3579c4d890 100644
> --- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c
> +++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c
> @@ -2,7 +2,7 @@
> This code produces the Smbios protocol. It also responsible for constructing
> SMBIOS table into system table.
>
> -Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.<BR>
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
> **/
> @@ -148,6 +148,31 @@ SMBIOS_TABLE_3_0_ENTRY_POINT Smbios30EntryPointStructureData = {
> //
> 0
> };
> +
> +/**
> + Validates a SMBIOS table entry point.
> +
> + @param TableEntry The SmBios table entry to validate.
> + @param TableAddress On exit, point to the smbios table addres.
> + @param TableMaximumSize On exit, point to the maximum size of the table.
> +
> + @retval TRUE SMBIOS table entry point is valid.
> + @retval FALSE SMBIOS table entry point is malformed.
> +
> +**/
> +typedef
> +BOOLEAN
> +(* IS_SMBIOS_TABLE_VALID) (
> + IN VOID *TableEntry,
> + OUT VOID **TableAddress,
> + OUT UINTN *TableMaximumSize
> + );
> +typedef struct {
> + EFI_GUID *Guid;
> + IS_SMBIOS_TABLE_VALID IsValid;
> +} IS_SMBIOS_TABLE_VALID_ENTRY;
> +
> +
> /**
>
> Get the full size of SMBIOS structure including optional strings that follow the formatted structure.
> @@ -1408,6 +1433,296 @@ SmbiosTableConstruction (
> }
> }
>
> +/**
> + Validates a SMBIOS 2.0 table entry point.
> +
> + @param TableEntry The SmBios table entry to validate.
> + @param TableAddress On exit, point to the smbios table addres.
> + @param TableMaximumSize On exit, point to the maximum size of the table.
> +
> + @retval TRUE SMBIOS table entry point is valid.
> + @retval FALSE SMBIOS table entry point is malformed.
> +
> +**/
> +STATIC
> +BOOLEAN
> +IsValidSmbios20Table (
> + IN VOID *TableEntry,
> + OUT VOID **TableAddress,
> + OUT UINTN *TableMaximumSize
> + )
> +{
> + UINT8 Checksum;
> + SMBIOS_TABLE_ENTRY_POINT *SmbiosTable;
> + SmbiosTable = (SMBIOS_TABLE_ENTRY_POINT *) TableEntry;
> +
> + if (CompareMem (SmbiosTable->AnchorString, "_SM_", 4) != 0) {
> + return FALSE;
> + }
> +
> + if (CompareMem (SmbiosTable->IntermediateAnchorString, "_DMI_", 5) != 0) {
> + return FALSE;
> + }
> +
> + //
> + // The actual value of the EntryPointLength should be 1Fh.
> + // However, it was incorrectly stated in version 2.1 of smbios specification.
> + // Therefore, 0x1F and 0x1E are both accepted.
> + //
> + if (SmbiosTable->EntryPointLength != 0x1E && SmbiosTable->EntryPointLength != sizeof (SMBIOS_TABLE_ENTRY_POINT)) {
> + return FALSE;
> + }
> +
> + //
> + // MajorVersion should not be less than 2.
> + //
> + if (SmbiosTable->MajorVersion < 2) {
> + return FALSE;
> + }
> +
> + //
> + // The whole struct check sum should be zero
> + //
> + Checksum = CalculateSum8 (
> + (UINT8 *) SmbiosTable,
> + SmbiosTable->EntryPointLength
> + );
> + if (Checksum != 0) {
> + return FALSE;
> + }
> +
> + //
> + // The Intermediate Entry Point Structure check sum should be zero.
> + //
> + Checksum = CalculateSum8 (
> + (UINT8 *) SmbiosTable + OFFSET_OF (SMBIOS_TABLE_ENTRY_POINT, IntermediateAnchorString),
> + SmbiosTable->EntryPointLength - OFFSET_OF (SMBIOS_TABLE_ENTRY_POINT, IntermediateAnchorString)
> + );
> + if (Checksum != 0) {
> + return FALSE;
> + }
> +
> + *TableAddress = (VOID *) (UINTN) SmbiosTable->TableAddress;
> + *TableMaximumSize = SmbiosTable->TableLength;
> + return TRUE;
> +}
> +
> +/**
> + Validates a SMBIOS 3.0 table entry point.
> +
> + @param TableEntry The SmBios table entry to validate.
> + @param TableAddress On exit, point to the smbios table addres.
> + @param TableMaximumSize On exit, point to the maximum size of the table.
> +
> + @retval TRUE SMBIOS table entry point is valid.
> + @retval FALSE SMBIOS table entry point is malformed.
> +
> +**/
> +STATIC
> +BOOLEAN
> +IsValidSmbios30Table (
> + IN VOID *TableEntry,
> + OUT VOID **TableAddress,
> + OUT UINTN *TableMaximumSize
> + )
> +{
> + UINT8 Checksum;
> + SMBIOS_TABLE_3_0_ENTRY_POINT *SmbiosTable;
> + SmbiosTable = (SMBIOS_TABLE_3_0_ENTRY_POINT *) TableEntry;
> +
> + if (CompareMem (SmbiosTable->AnchorString, "_SM3_", 5) != 0) {
> + return FALSE;
> + }
> + if (SmbiosTable->EntryPointLength < sizeof (SMBIOS_TABLE_3_0_ENTRY_POINT)) {
> + return FALSE;
> + }
> + if (SmbiosTable->MajorVersion < 3) {
> + return FALSE;
> + }
> +
> + //
> + // The whole struct check sum should be zero
> + //
> + Checksum = CalculateSum8 (
> + (UINT8 *) SmbiosTable,
> + SmbiosTable->EntryPointLength
> + );
> + if (Checksum != 0) {
> + return FALSE;
> + }
> +
> + *TableAddress = (VOID *) (UINTN) SmbiosTable->TableAddress;
> + *TableMaximumSize = SmbiosTable->TableMaximumSize;
> + return TRUE;
> +}
> +
> +/**
> + Parse an existing SMBIOS table and insert it using SmbiosAdd.
> +
> + @param ImageHandle The EFI_HANDLE to this driver.
> + @param Smbios The SMBIOS table to parse.
> + @param Length The length of the SMBIOS table.
> +
> + @retval EFI_SUCCESS SMBIOS table was parsed and installed.
> + @retval EFI_OUT_OF_RESOURCES Record was not added due to lack of system resources.
> + @retval EFI_INVALID_PARAMETER Smbios is not a correct smbios table
> +
> +**/
> +STATIC
> +EFI_STATUS
> +ParseAndAddExistingSmbiosTable (
> + IN EFI_HANDLE ImageHandle,
> + IN SMBIOS_STRUCTURE_POINTER Smbios,
> + IN UINTN Length
> + )
> +{
> + EFI_STATUS Status;
> + CHAR8 *String;
> + EFI_SMBIOS_HANDLE SmbiosHandle;
> + SMBIOS_STRUCTURE_POINTER SmbiosEnd;
> +
> + SmbiosEnd.Raw = Smbios.Raw + Length;
> +
> + if (Smbios.Raw >= SmbiosEnd.Raw || Smbios.Raw == NULL) {
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + do {
> + //
> + // Make sure not to access memory beyond SmbiosEnd
> + //
> + if (Smbios.Raw + sizeof (SMBIOS_STRUCTURE) > SmbiosEnd.Raw ||
> + Smbios.Raw + sizeof (SMBIOS_STRUCTURE) < Smbios.Raw) {
> + return EFI_INVALID_PARAMETER;
> + }
> + //
> + // Check for end marker
> + //
> + if (Smbios.Hdr->Type == SMBIOS_TYPE_END_OF_TABLE) {
> + break;
> + }
> + //
> + // Make sure not to access memory beyond SmbiosEnd
> + // Each structure shall be terminated by a double-null (0000h).
> + //
> + if (Smbios.Raw + Smbios.Hdr->Length + 2 * sizeof (UINT8) > SmbiosEnd.Raw ||
> + Smbios.Raw + Smbios.Hdr->Length + 2 * sizeof (UINT8) < Smbios.Raw) {
> + return EFI_INVALID_PARAMETER;
> + }
> + //
> + // Install the table
> + //
> + SmbiosHandle = Smbios.Hdr->Handle;
> + Status = SmbiosAdd (
> + &mPrivateData.Smbios,
> + ImageHandle,
> + &SmbiosHandle,
> + Smbios.Hdr
> + );
> +
> + ASSERT_EFI_ERROR (Status);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> + //
> + // Go to the next SMBIOS structure. Each SMBIOS structure may include 2 parts:
> + // 1. Formatted section; 2. Unformatted string section. So, 2 steps are needed
> + // to skip one SMBIOS structure.
> + //
> +
> + //
> + // Step 1: Skip over formatted section.
> + //
> + String = (CHAR8 *) (Smbios.Raw + Smbios.Hdr->Length);
> +
> + //
> + // Step 2: Skip over unformatted string section.
> + //
> + do {
> + //
> + // Each string is terminated with a NULL(00h) BYTE and the sets of strings
> + // is terminated with an additional NULL(00h) BYTE.
> + //
> + for ( ; *String != 0; String++) {
> + if ((UINTN) String >= (UINTN) SmbiosEnd.Raw - sizeof (UINT8)) {
> + return EFI_INVALID_PARAMETER;
> + }
> + }
> +
> + if (*(UINT8 *) ++String == 0) {
> + //
> + // Pointer to the next SMBIOS structure.
> + //
> + Smbios.Raw = (UINT8 *) ++String;
> + break;
> + }
> + } while (TRUE);
> + } while (Smbios.Raw < SmbiosEnd.Raw);
> +
> + return EFI_SUCCESS;
> +}
> +
> +
> +IS_SMBIOS_TABLE_VALID_ENTRY mIsSmbiosTableValid[] = {
> + {&gPldSmbios3TableGuid, IsValidSmbios30Table },
> + {&gPldSmbiosTableGuid, IsValidSmbios20Table }
> +};
> +
> +/**
> + Retrieve SMBIOS from Hob.
> + @param ImageHandle Module's image handle
> +
> + @retval EFI_SUCCESS Smbios from Hob is installed.
> + @return EFI_NOT_FOUND Not found Smbios from Hob.
> + @retval Other No Smbios from Hob is installed.
> +
> +**/
> +EFI_STATUS
> +RetrieveSmbiosFromHob (
> + IN EFI_HANDLE ImageHandle
> + )
> +{
> + EFI_STATUS Status;
> + UINTN Index;
> + SMBIOS_STRUCTURE_POINTER Smbios;
> + EFI_HOB_GUID_TYPE *GuidHob;
> + PLD_SMBIOS_TABLE *SmBiosTableAdress;
> + PLD_GENERIC_HEADER *GenericHeader;
> + VOID *TableAddress;
> + UINTN TableMaximumSize;
> +
> + Status = EFI_NOT_FOUND;
> +
> + for (Index = 0; Index < ARRAY_SIZE (mIsSmbiosTableValid); Index++) {
> + GuidHob = GetFirstGuidHob (mIsSmbiosTableValid[Index].Guid);
> + if (GuidHob == NULL) {
> + continue;
> + }
> + GenericHeader = (PLD_GENERIC_HEADER *) GET_GUID_HOB_DATA (GuidHob);
> + if ((sizeof (PLD_GENERIC_HEADER) <= GET_GUID_HOB_DATA_SIZE (GuidHob)) && (GenericHeader->Length <= GET_GUID_HOB_DATA_SIZE (GuidHob))) {
> + if (GenericHeader->Revision == PLD_SMBIOS_TABLE_REVISION) {
> + //
> + // PLD_SMBIOS_TABLE structure is used when Revision equals to PLD_SMBIOS_TABLE_REVISION
> + //
> + SmBiosTableAdress = (PLD_SMBIOS_TABLE *) GET_GUID_HOB_DATA (GuidHob);
> + if (GenericHeader->Length >= PLD_SIZEOF_THROUGH_FIELD (PLD_SMBIOS_TABLE, SmBiosEntryPoint)) {
> + if (mIsSmbiosTableValid[Index].IsValid ((VOID *) (UINTN )SmBiosTableAdress->SmBiosEntryPoint, &TableAddress, &TableMaximumSize)) {
> + Smbios.Raw = TableAddress;
> + Status = ParseAndAddExistingSmbiosTable (ImageHandle, Smbios, TableMaximumSize);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "RetrieveSmbiosFromHob: Failed to parse preinstalled tables from gPldSmbios3TableGuid Guid Hob\n"));
> + Status = EFI_UNSUPPORTED;
> + } else {
> + return EFI_SUCCESS;
> + }
> + }
> + }
> + }
> + }
> + }
> + return Status;
> +}
> +
> /**
>
> Driver to produce Smbios protocol and pre-allocate 1 page for the final SMBIOS table.
> @@ -1451,5 +1766,6 @@ SmbiosDriverEntryPoint (
> &mPrivateData.Smbios
> );
>
> - return Status;
That doesn't compile as Status is written, but never read.
> + RetrieveSmbiosFromHob (ImageHandle);
> + return EFI_SUCCESS;
> }
> diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h
> index f97c85ae40..a260cf695e 100644
> --- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h
> +++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h
> @@ -1,7 +1,7 @@
> /** @file
> This code supports the implementation of the Smbios protocol
>
> -Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.<BR>
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
> **/
> @@ -24,6 +24,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> #include <Library/MemoryAllocationLib.h>
> #include <Library/UefiBootServicesTableLib.h>
> #include <Library/PcdLib.h>
> +#include <Library/HobLib.h>
> +#include <UniversalPayload/SmbiosTable.h>
>
> #define SMBIOS_INSTANCE_SIGNATURE SIGNATURE_32 ('S', 'B', 'i', 's')
> typedef struct {
> diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
> index f6c036e1dc..63f468936d 100644
> --- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
> +++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
> @@ -1,7 +1,7 @@
> ## @file
> # This driver initializes and installs the SMBIOS protocol, constructs SMBIOS table into system configuration table.
> #
> -# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
> +# Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.<BR>
> #
> # SPDX-License-Identifier: BSD-2-Clause-Patent
> #
> @@ -41,6 +41,7 @@
> UefiDriverEntryPoint
> DebugLib
> PcdLib
> + HobLib
>
> [Protocols]
> gEfiSmbiosProtocolGuid ## PRODUCES
> @@ -48,6 +49,8 @@
> [Guids]
> gEfiSmbiosTableGuid ## SOMETIMES_PRODUCES ## SystemTable
> gEfiSmbios3TableGuid ## SOMETIMES_PRODUCES ## SystemTable
> + gPldSmbios3TableGuid ## CONSUMES ## HOB
> + gPldSmbiosTableGuid ## SOMETIMES_CONSUMES ## HOB
>
> [Pcd]
> gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion ## CONSUMES
> --
> 2.30.0.windows.2
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Patch V3 5/9] MdeModulePkg/Universal/SmbiosDxe: Scan for existing tables
2021-06-08 9:20 ` Patrick Rudolph
@ 2021-06-10 1:56 ` Zhiguang Liu
0 siblings, 0 replies; 22+ messages in thread
From: Zhiguang Liu @ 2021-06-10 1:56 UTC (permalink / raw)
To: Patrick Rudolph
Cc: devel@edk2.groups.io, Wang, Jian J, Wu, Hao A, Bi, Dandan,
Zeng, Star, Gao, Zhichao
Hi Patrick
Thanks for catching this issue.
I updated the code, and you can find the code below
https://github.com/LiuZhiguang001/edk2/tree/UniversalPayloadHeaders_v4
Please help confirm.
Thanks
Zhiguang
> -----Original Message-----
> From: Patrick Rudolph <patrick.rudolph@9elements.com>
> Sent: Tuesday, June 8, 2021 5:21 PM
> To: Liu, Zhiguang <zhiguang.liu@intel.com>
> Cc: devel@edk2.groups.io; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A
> <hao.a.wu@intel.com>; Bi, Dandan <dandan.bi@intel.com>; Zeng, Star
> <star.zeng@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>
> Subject: Re: [Patch V3 5/9] MdeModulePkg/Universal/SmbiosDxe: Scan for
> existing tables
>
> On Fri, Jun 4, 2021 at 11:42 AM Zhiguang Liu <zhiguang.liu@intel.com> wrote:
> >
> > V1:
> > The default EfiSmbiosProtocol operates on an empty SMBIOS table.
> > The SMBIOS tables are provided by the bootloader on UefiPayloadPkg.
> > Scan for existing tables in SmbiosDxe and load them if they seem valid.
> >
> > This fixes the settings menu not showing any hardware information,
> > instead only "0 MB RAM" was displayed.
> >
> > Tests showed that the OS can still see the SMBIOS tables.
> >
> > V2:
> > SmbiosDxe will get the SMBIOS from a guid Hob.
> > Aslo will keep the SmbiosHandle if it is available.
> >
> > Cc: Jian J Wang <jian.j.wang@intel.com>
> > Cc: Hao A Wu <hao.a.wu@intel.com>
> > Cc: Dandan Bi <dandan.bi@intel.com>
> > Cc: Star Zeng <star.zeng@intel.com>
> > Cc: Zhichao Gao <zhichao.gao@intel.com>
> > Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
> > Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
> > ---
> > MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c | 320
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> ++++++++++++++++++++++++++++--
> > MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h | 4 +++-
> > MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf | 5 ++++-
> > 3 files changed, 325 insertions(+), 4 deletions(-)
> >
> > diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c
> > b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c
> > index 3cdb0b1ed7..3579c4d890 100644
> > --- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c
> > +++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c
> > @@ -2,7 +2,7 @@
> > This code produces the Smbios protocol. It also responsible for
> constructing
> > SMBIOS table into system table.
> >
> > -Copyright (c) 2009 - 2018, Intel Corporation. All rights
> > reserved.<BR>
> > +Copyright (c) 2009 - 2021, Intel Corporation. All rights
> > +reserved.<BR>
> > SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> > **/
> > @@ -148,6 +148,31 @@ SMBIOS_TABLE_3_0_ENTRY_POINT
> Smbios30EntryPointStructureData = {
> > //
> > 0
> > };
> > +
> > +/**
> > + Validates a SMBIOS table entry point.
> > +
> > + @param TableEntry The SmBios table entry to validate.
> > + @param TableAddress On exit, point to the smbios table addres.
> > + @param TableMaximumSize On exit, point to the maximum size of the
> table.
> > +
> > + @retval TRUE SMBIOS table entry point is valid.
> > + @retval FALSE SMBIOS table entry point is malformed.
> > +
> > +**/
> > +typedef
> > +BOOLEAN
> > +(* IS_SMBIOS_TABLE_VALID) (
> > + IN VOID *TableEntry,
> > + OUT VOID **TableAddress,
> > + OUT UINTN *TableMaximumSize
> > + );
> > +typedef struct {
> > + EFI_GUID *Guid;
> > + IS_SMBIOS_TABLE_VALID IsValid;
> > +} IS_SMBIOS_TABLE_VALID_ENTRY;
> > +
> > +
> > /**
> >
> > Get the full size of SMBIOS structure including optional strings that follow
> the formatted structure.
> > @@ -1408,6 +1433,296 @@ SmbiosTableConstruction (
> > }
> > }
> >
> > +/**
> > + Validates a SMBIOS 2.0 table entry point.
> > +
> > + @param TableEntry The SmBios table entry to validate.
> > + @param TableAddress On exit, point to the smbios table addres.
> > + @param TableMaximumSize On exit, point to the maximum size of the
> table.
> > +
> > + @retval TRUE SMBIOS table entry point is valid.
> > + @retval FALSE SMBIOS table entry point is malformed.
> > +
> > +**/
> > +STATIC
> > +BOOLEAN
> > +IsValidSmbios20Table (
> > + IN VOID *TableEntry,
> > + OUT VOID **TableAddress,
> > + OUT UINTN *TableMaximumSize
> > + )
> > +{
> > + UINT8 Checksum;
> > + SMBIOS_TABLE_ENTRY_POINT *SmbiosTable;
> > + SmbiosTable = (SMBIOS_TABLE_ENTRY_POINT *) TableEntry;
> > +
> > + if (CompareMem (SmbiosTable->AnchorString, "_SM_", 4) != 0) {
> > + return FALSE;
> > + }
> > +
> > + if (CompareMem (SmbiosTable->IntermediateAnchorString, "_DMI_",
> 5) != 0) {
> > + return FALSE;
> > + }
> > +
> > + //
> > + // The actual value of the EntryPointLength should be 1Fh.
> > + // However, it was incorrectly stated in version 2.1 of smbios
> specification.
> > + // Therefore, 0x1F and 0x1E are both accepted.
> > + //
> > + if (SmbiosTable->EntryPointLength != 0x1E && SmbiosTable-
> >EntryPointLength != sizeof (SMBIOS_TABLE_ENTRY_POINT)) {
> > + return FALSE;
> > + }
> > +
> > + //
> > + // MajorVersion should not be less than 2.
> > + //
> > + if (SmbiosTable->MajorVersion < 2) {
> > + return FALSE;
> > + }
> > +
> > + //
> > + // The whole struct check sum should be zero // Checksum =
> > + CalculateSum8 (
> > + (UINT8 *) SmbiosTable,
> > + SmbiosTable->EntryPointLength
> > + );
> > + if (Checksum != 0) {
> > + return FALSE;
> > + }
> > +
> > + //
> > + // The Intermediate Entry Point Structure check sum should be zero.
> > + //
> > + Checksum = CalculateSum8 (
> > + (UINT8 *) SmbiosTable + OFFSET_OF
> (SMBIOS_TABLE_ENTRY_POINT, IntermediateAnchorString),
> > + SmbiosTable->EntryPointLength - OFFSET_OF
> (SMBIOS_TABLE_ENTRY_POINT, IntermediateAnchorString)
> > + );
> > + if (Checksum != 0) {
> > + return FALSE;
> > + }
> > +
> > + *TableAddress = (VOID *) (UINTN) SmbiosTable->TableAddress;
> > + *TableMaximumSize = SmbiosTable->TableLength;
> > + return TRUE;
> > +}
> > +
> > +/**
> > + Validates a SMBIOS 3.0 table entry point.
> > +
> > + @param TableEntry The SmBios table entry to validate.
> > + @param TableAddress On exit, point to the smbios table addres.
> > + @param TableMaximumSize On exit, point to the maximum size of the
> table.
> > +
> > + @retval TRUE SMBIOS table entry point is valid.
> > + @retval FALSE SMBIOS table entry point is malformed.
> > +
> > +**/
> > +STATIC
> > +BOOLEAN
> > +IsValidSmbios30Table (
> > + IN VOID *TableEntry,
> > + OUT VOID **TableAddress,
> > + OUT UINTN *TableMaximumSize
> > + )
> > +{
> > + UINT8 Checksum;
> > + SMBIOS_TABLE_3_0_ENTRY_POINT *SmbiosTable;
> > + SmbiosTable = (SMBIOS_TABLE_3_0_ENTRY_POINT *) TableEntry;
> > +
> > + if (CompareMem (SmbiosTable->AnchorString, "_SM3_", 5) != 0) {
> > + return FALSE;
> > + }
> > + if (SmbiosTable->EntryPointLength < sizeof
> (SMBIOS_TABLE_3_0_ENTRY_POINT)) {
> > + return FALSE;
> > + }
> > + if (SmbiosTable->MajorVersion < 3) {
> > + return FALSE;
> > + }
> > +
> > + //
> > + // The whole struct check sum should be zero // Checksum =
> > + CalculateSum8 (
> > + (UINT8 *) SmbiosTable,
> > + SmbiosTable->EntryPointLength
> > + );
> > + if (Checksum != 0) {
> > + return FALSE;
> > + }
> > +
> > + *TableAddress = (VOID *) (UINTN) SmbiosTable->TableAddress;
> > + *TableMaximumSize = SmbiosTable->TableMaximumSize;
> > + return TRUE;
> > +}
> > +
> > +/**
> > + Parse an existing SMBIOS table and insert it using SmbiosAdd.
> > +
> > + @param ImageHandle The EFI_HANDLE to this driver.
> > + @param Smbios The SMBIOS table to parse.
> > + @param Length The length of the SMBIOS table.
> > +
> > + @retval EFI_SUCCESS SMBIOS table was parsed and installed.
> > + @retval EFI_OUT_OF_RESOURCES Record was not added due to lack of
> system resources.
> > + @retval EFI_INVALID_PARAMETER Smbios is not a correct smbios table
> > +
> > +**/
> > +STATIC
> > +EFI_STATUS
> > +ParseAndAddExistingSmbiosTable (
> > + IN EFI_HANDLE ImageHandle,
> > + IN SMBIOS_STRUCTURE_POINTER Smbios,
> > + IN UINTN Length
> > + )
> > +{
> > + EFI_STATUS Status;
> > + CHAR8 *String;
> > + EFI_SMBIOS_HANDLE SmbiosHandle;
> > + SMBIOS_STRUCTURE_POINTER SmbiosEnd;
> > +
> > + SmbiosEnd.Raw = Smbios.Raw + Length;
> > +
> > + if (Smbios.Raw >= SmbiosEnd.Raw || Smbios.Raw == NULL) {
> > + return EFI_INVALID_PARAMETER;
> > + }
> > +
> > + do {
> > + //
> > + // Make sure not to access memory beyond SmbiosEnd
> > + //
> > + if (Smbios.Raw + sizeof (SMBIOS_STRUCTURE) > SmbiosEnd.Raw ||
> > + Smbios.Raw + sizeof (SMBIOS_STRUCTURE) < Smbios.Raw) {
> > + return EFI_INVALID_PARAMETER;
> > + }
> > + //
> > + // Check for end marker
> > + //
> > + if (Smbios.Hdr->Type == SMBIOS_TYPE_END_OF_TABLE) {
> > + break;
> > + }
> > + //
> > + // Make sure not to access memory beyond SmbiosEnd
> > + // Each structure shall be terminated by a double-null (0000h).
> > + //
> > + if (Smbios.Raw + Smbios.Hdr->Length + 2 * sizeof (UINT8) >
> SmbiosEnd.Raw ||
> > + Smbios.Raw + Smbios.Hdr->Length + 2 * sizeof (UINT8) < Smbios.Raw)
> {
> > + return EFI_INVALID_PARAMETER;
> > + }
> > + //
> > + // Install the table
> > + //
> > + SmbiosHandle = Smbios.Hdr->Handle;
> > + Status = SmbiosAdd (
> > + &mPrivateData.Smbios,
> > + ImageHandle,
> > + &SmbiosHandle,
> > + Smbios.Hdr
> > + );
> > +
> > + ASSERT_EFI_ERROR (Status);
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > + //
> > + // Go to the next SMBIOS structure. Each SMBIOS structure may include
> 2 parts:
> > + // 1. Formatted section; 2. Unformatted string section. So, 2 steps are
> needed
> > + // to skip one SMBIOS structure.
> > + //
> > +
> > + //
> > + // Step 1: Skip over formatted section.
> > + //
> > + String = (CHAR8 *) (Smbios.Raw + Smbios.Hdr->Length);
> > +
> > + //
> > + // Step 2: Skip over unformatted string section.
> > + //
> > + do {
> > + //
> > + // Each string is terminated with a NULL(00h) BYTE and the sets of
> strings
> > + // is terminated with an additional NULL(00h) BYTE.
> > + //
> > + for ( ; *String != 0; String++) {
> > + if ((UINTN) String >= (UINTN) SmbiosEnd.Raw - sizeof (UINT8)) {
> > + return EFI_INVALID_PARAMETER;
> > + }
> > + }
> > +
> > + if (*(UINT8 *) ++String == 0) {
> > + //
> > + // Pointer to the next SMBIOS structure.
> > + //
> > + Smbios.Raw = (UINT8 *) ++String;
> > + break;
> > + }
> > + } while (TRUE);
> > + } while (Smbios.Raw < SmbiosEnd.Raw);
> > +
> > + return EFI_SUCCESS;
> > +}
> > +
> > +
> > +IS_SMBIOS_TABLE_VALID_ENTRY mIsSmbiosTableValid[] = {
> > + {&gPldSmbios3TableGuid, IsValidSmbios30Table },
> > + {&gPldSmbiosTableGuid, IsValidSmbios20Table } };
> > +
> > +/**
> > + Retrieve SMBIOS from Hob.
> > + @param ImageHandle Module's image handle
> > +
> > + @retval EFI_SUCCESS Smbios from Hob is installed.
> > + @return EFI_NOT_FOUND Not found Smbios from Hob.
> > + @retval Other No Smbios from Hob is installed.
> > +
> > +**/
> > +EFI_STATUS
> > +RetrieveSmbiosFromHob (
> > + IN EFI_HANDLE ImageHandle
> > + )
> > +{
> > + EFI_STATUS Status;
> > + UINTN Index;
> > + SMBIOS_STRUCTURE_POINTER Smbios;
> > + EFI_HOB_GUID_TYPE *GuidHob;
> > + PLD_SMBIOS_TABLE *SmBiosTableAdress;
> > + PLD_GENERIC_HEADER *GenericHeader;
> > + VOID *TableAddress;
> > + UINTN TableMaximumSize;
> > +
> > + Status = EFI_NOT_FOUND;
> > +
> > + for (Index = 0; Index < ARRAY_SIZE (mIsSmbiosTableValid); Index++) {
> > + GuidHob = GetFirstGuidHob (mIsSmbiosTableValid[Index].Guid);
> > + if (GuidHob == NULL) {
> > + continue;
> > + }
> > + GenericHeader = (PLD_GENERIC_HEADER *) GET_GUID_HOB_DATA
> (GuidHob);
> > + if ((sizeof (PLD_GENERIC_HEADER) <= GET_GUID_HOB_DATA_SIZE
> (GuidHob)) && (GenericHeader->Length <= GET_GUID_HOB_DATA_SIZE
> (GuidHob))) {
> > + if (GenericHeader->Revision == PLD_SMBIOS_TABLE_REVISION) {
> > + //
> > + // PLD_SMBIOS_TABLE structure is used when Revision equals to
> PLD_SMBIOS_TABLE_REVISION
> > + //
> > + SmBiosTableAdress = (PLD_SMBIOS_TABLE *) GET_GUID_HOB_DATA
> (GuidHob);
> > + if (GenericHeader->Length >= PLD_SIZEOF_THROUGH_FIELD
> (PLD_SMBIOS_TABLE, SmBiosEntryPoint)) {
> > + if (mIsSmbiosTableValid[Index].IsValid ((VOID *)
> (UINTN )SmBiosTableAdress->SmBiosEntryPoint, &TableAddress,
> &TableMaximumSize)) {
> > + Smbios.Raw = TableAddress;
> > + Status = ParseAndAddExistingSmbiosTable (ImageHandle, Smbios,
> TableMaximumSize);
> > + if (EFI_ERROR (Status)) {
> > + DEBUG ((DEBUG_ERROR, "RetrieveSmbiosFromHob: Failed to
> parse preinstalled tables from gPldSmbios3TableGuid Guid Hob\n"));
> > + Status = EFI_UNSUPPORTED;
> > + } else {
> > + return EFI_SUCCESS;
> > + }
> > + }
> > + }
> > + }
> > + }
> > + }
> > + return Status;
> > +}
> > +
> > /**
> >
> > Driver to produce Smbios protocol and pre-allocate 1 page for the final
> SMBIOS table.
> > @@ -1451,5 +1766,6 @@ SmbiosDriverEntryPoint (
> > &mPrivateData.Smbios
> > );
> >
> > - return Status;
>
> That doesn't compile as Status is written, but never read.
>
> > + RetrieveSmbiosFromHob (ImageHandle); return EFI_SUCCESS;
> > }
> > diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h
> > b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h
> > index f97c85ae40..a260cf695e 100644
> > --- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h
> > +++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h
> > @@ -1,7 +1,7 @@
> > /** @file
> > This code supports the implementation of the Smbios protocol
> >
> > -Copyright (c) 2009 - 2018, Intel Corporation. All rights
> > reserved.<BR>
> > +Copyright (c) 2009 - 2021, Intel Corporation. All rights
> > +reserved.<BR>
> > SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> > **/
> > @@ -24,6 +24,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> > #include <Library/MemoryAllocationLib.h> #include
> > <Library/UefiBootServicesTableLib.h>
> > #include <Library/PcdLib.h>
> > +#include <Library/HobLib.h>
> > +#include <UniversalPayload/SmbiosTable.h>
> >
> > #define SMBIOS_INSTANCE_SIGNATURE SIGNATURE_32 ('S', 'B', 'i', 's')
> > typedef struct { diff --git
> > a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
> > b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
> > index f6c036e1dc..63f468936d 100644
> > --- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
> > +++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
> > @@ -1,7 +1,7 @@
> > ## @file
> > # This driver initializes and installs the SMBIOS protocol, constructs SMBIOS
> table into system configuration table.
> > #
> > -# Copyright (c) 2009 - 2018, Intel Corporation. All rights
> > reserved.<BR>
> > +# Copyright (c) 2009 - 2021, Intel Corporation. All rights
> > +reserved.<BR>
> > #
> > # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -41,6 +41,7 @@
> > UefiDriverEntryPoint
> > DebugLib
> > PcdLib
> > + HobLib
> >
> > [Protocols]
> > gEfiSmbiosProtocolGuid ## PRODUCES
> > @@ -48,6 +49,8 @@
> > [Guids]
> > gEfiSmbiosTableGuid ## SOMETIMES_PRODUCES ##
> SystemTable
> > gEfiSmbios3TableGuid ## SOMETIMES_PRODUCES ##
> SystemTable
> > + gPldSmbios3TableGuid ## CONSUMES ## HOB
> > + gPldSmbiosTableGuid ## SOMETIMES_CONSUMES ##
> HOB
> >
> > [Pcd]
> > gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion ## CONSUMES
> > --
> > 2.30.0.windows.2
> >
^ permalink raw reply [flat|nested] 22+ messages in thread
* [Patch V3 6/9] UefiPayloadPkg: Creat gPldSmbiosTableGuid Hob
2021-06-04 9:42 [Patch V3 0/9] Create multiple Hobs for Universal Payload Zhiguang Liu
` (4 preceding siblings ...)
2021-06-04 9:42 ` [Patch V3 5/9] MdeModulePkg/Universal/SmbiosDxe: Scan for existing tables Zhiguang Liu
@ 2021-06-04 9:42 ` Zhiguang Liu
2021-06-04 9:42 ` [Patch V3 7/9] MdeModulePkg: Add new structure for the Universal Payload ACPI Table Info Hob Zhiguang Liu
` (2 subsequent siblings)
8 siblings, 0 replies; 22+ messages in thread
From: Zhiguang Liu @ 2021-06-04 9:42 UTC (permalink / raw)
To: devel; +Cc: Maurice Ma, Guo Dong, Benjamin You
>From SysTableInfo Hob, get Smbios table address, and creat gPldSmbiosTableGuid Hob
to store it. Remove diretly adding smbios table to ConfigurationTable.
Dxe module SmbiosDxe will parse it and install smbios table from it.
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Guo Dong <guo.dong@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Reviewed-by: Guo Dong <guo.dong@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
---
UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c | 11 +----------
UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf | 3 +--
UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c | 12 +++++++++++-
UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h | 3 ++-
UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf | 3 ++-
5 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
index a746d0581e..56b85b8e6d 100644
--- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
+++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
@@ -2,7 +2,7 @@
This driver will report some MMIO/IO resources to dxe core, extract smbios and acpi
tables from bootloader.
- Copyright (c) 2014 - 2020, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -129,15 +129,6 @@ BlDxeEntryPoint (
ASSERT_EFI_ERROR (Status);
}
- //
- // Install Smbios Table
- //
- if (SystemTableInfo->SmbiosTableBase != 0 && SystemTableInfo->SmbiosTableSize != 0) {
- DEBUG ((DEBUG_ERROR, "Install Smbios Table at 0x%lx, length 0x%x\n", SystemTableInfo->SmbiosTableBase, SystemTableInfo->SmbiosTableSize));
- Status = gBS->InstallConfigurationTable (&gEfiSmbiosTableGuid, (VOID *)(UINTN)SystemTableInfo->SmbiosTableBase);
- ASSERT_EFI_ERROR (Status);
- }
-
//
// Find the frame buffer information and update PCDs
//
diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf
index cebc811355..30f41f8c39 100644
--- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf
+++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf
@@ -3,7 +3,7 @@
#
# Report some MMIO/IO resources to dxe core, extract smbios and acpi tables
#
-# Copyright (c) 2014 - 2020, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -43,7 +43,6 @@
[Guids]
gEfiAcpiTableGuid
- gEfiSmbiosTableGuid
gUefiSystemTableInfoGuid
gUefiAcpiBoardInfoGuid
gEfiGraphicsInfoHobGuid
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
index 805f5448d9..7b71d37f94 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (c) 2014 - 2020, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -234,6 +234,7 @@ BuildHobFromBl (
EFI_PEI_GRAPHICS_INFO_HOB *NewGfxInfo;
EFI_PEI_GRAPHICS_DEVICE_INFO_HOB GfxDeviceInfo;
EFI_PEI_GRAPHICS_DEVICE_INFO_HOB *NewGfxDeviceInfo;
+ PLD_SMBIOS_TABLE *SmBiosTableHob;
//
// Parse memory info and build memory HOBs
@@ -276,6 +277,15 @@ BuildHobFromBl (
DEBUG ((DEBUG_INFO, "Detected Acpi Table at 0x%lx, length 0x%x\n", SysTableInfo.AcpiTableBase, SysTableInfo.AcpiTableSize));
DEBUG ((DEBUG_INFO, "Detected Smbios Table at 0x%lx, length 0x%x\n", SysTableInfo.SmbiosTableBase, SysTableInfo.SmbiosTableSize));
}
+ //
+ // Creat SmBios table Hob
+ //
+ SmBiosTableHob = BuildGuidHob (&gPldSmbiosTableGuid, sizeof (PLD_SMBIOS_TABLE));
+ ASSERT (SmBiosTableHob != NULL);
+ SmBiosTableHob->PldHeader.Revision = PLD_SMBIOS_TABLE_REVISION;
+ SmBiosTableHob->PldHeader.Length = sizeof (PLD_SMBIOS_TABLE);
+ SmBiosTableHob->SmBiosEntryPoint = SysTableInfo.SmbiosTableBase;
+ DEBUG ((DEBUG_INFO, "Create smbios table gPldSmbiosTableGuid guid hob\n"));
//
// Create guid hob for acpi board information
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
index 2c84d6ed53..e7d0d15118 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
@@ -1,6 +1,6 @@
/** @file
*
-* Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
+* Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*
@@ -31,6 +31,7 @@
#include <Guid/MemoryMapInfoGuid.h>
#include <Guid/AcpiBoardInfoGuid.h>
#include <Guid/GraphicsInfoHob.h>
+#include <UniversalPayload/SmbiosTable.h>
#define LEGACY_8259_MASK_REGISTER_MASTER 0x21
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
index cc59f1903b..444f39acf3 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
@@ -1,7 +1,7 @@
## @file
# This is the first module for UEFI payload.
#
-# Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -64,6 +64,7 @@
gEfiGraphicsInfoHobGuid
gEfiGraphicsDeviceInfoHobGuid
gUefiAcpiBoardInfoGuid
+ gPldSmbiosTableGuid
[FeaturePcd.IA32]
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode ## CONSUMES
--
2.30.0.windows.2
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [Patch V3 7/9] MdeModulePkg: Add new structure for the Universal Payload ACPI Table Info Hob
2021-06-04 9:42 [Patch V3 0/9] Create multiple Hobs for Universal Payload Zhiguang Liu
` (5 preceding siblings ...)
2021-06-04 9:42 ` [Patch V3 6/9] UefiPayloadPkg: Creat gPldSmbiosTableGuid Hob Zhiguang Liu
@ 2021-06-04 9:42 ` Zhiguang Liu
2021-06-08 5:21 ` Wu, Hao A
2021-06-04 9:42 ` [Patch V3 8/9] MdeModulePkg/ACPI: Install ACPI table from HOB Zhiguang Liu
2021-06-04 9:42 ` [Patch V3 9/9] UefiPayloadPkg: Creat gPldAcpiTableGuid Hob Zhiguang Liu
8 siblings, 1 reply; 22+ messages in thread
From: Zhiguang Liu @ 2021-06-04 9:42 UTC (permalink / raw)
To: devel; +Cc: Michael D Kinney, Liming Gao, Jian J Wang, Hao A Wu
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
---
MdeModulePkg/Include/UniversalPayload/AcpiTable.h | 28 ++++++++++++++++++++++++++++
MdeModulePkg/MdeModulePkg.dec | 3 +++
2 files changed, 31 insertions(+)
diff --git a/MdeModulePkg/Include/UniversalPayload/AcpiTable.h b/MdeModulePkg/Include/UniversalPayload/AcpiTable.h
new file mode 100644
index 0000000000..a85c555d9c
--- /dev/null
+++ b/MdeModulePkg/Include/UniversalPayload/AcpiTable.h
@@ -0,0 +1,28 @@
+/** @file
+ Define the structure for the Payload APCI table.
+
+Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _PLD_ACPI_TABLE_H_
+#define _PLD_ACPI_TABLE_H_
+
+#include <Uefi.h>
+#include <UniversalPayload/UniversalPayload.h>
+
+#pragma pack(1)
+
+typedef struct {
+ PLD_GENERIC_HEADER PldHeader;
+ EFI_PHYSICAL_ADDRESS Rsdp;
+} PLD_ACPI_TABLE;
+
+#pragma pack()
+
+#define PLD_ACPI_TABLE_REVISION 1
+
+extern GUID gPldAcpiTableGuid;
+
+#endif //_PLD_ACPI_TABLE_H_
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 45324d2e20..4da472d7b9 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -416,6 +416,9 @@
## Include/UniversalPayload/SmbiosTable.h
gPldSmbiosTableGuid = { 0x590a0d26, 0x06e5, 0x4d20, { 0x8a, 0x82, 0x59, 0xea, 0x1b, 0x34, 0x98, 0x2d } }
+ ## Include/UniversalPayload/AcpiTable.h
+ gPldAcpiTableGuid = { 0x9f9a9506, 0x5597, 0x4515, { 0xba, 0xb6, 0x8b, 0xcd, 0xe7, 0x84, 0xba, 0x87 } }
+
[Ppis]
## Include/Ppi/AtaController.h
gPeiAtaControllerPpiGuid = { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0, 0x7a, 0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }}
--
2.30.0.windows.2
^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [Patch V3 7/9] MdeModulePkg: Add new structure for the Universal Payload ACPI Table Info Hob
2021-06-04 9:42 ` [Patch V3 7/9] MdeModulePkg: Add new structure for the Universal Payload ACPI Table Info Hob Zhiguang Liu
@ 2021-06-08 5:21 ` Wu, Hao A
0 siblings, 0 replies; 22+ messages in thread
From: Wu, Hao A @ 2021-06-08 5:21 UTC (permalink / raw)
To: Liu, Zhiguang, devel@edk2.groups.io
Cc: Kinney, Michael D, Liming Gao, Wang, Jian J
> -----Original Message-----
> From: Liu, Zhiguang <zhiguang.liu@intel.com>
> Sent: Friday, June 4, 2021 5:42 PM
> To: devel@edk2.groups.io
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao
> <gaoliming@byosoft.com.cn>; Wang, Jian J <jian.j.wang@intel.com>; Wu,
> Hao A <hao.a.wu@intel.com>
> Subject: [Patch V3 7/9] MdeModulePkg: Add new structure for the Universal
> Payload ACPI Table Info Hob
>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
>
> Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
> ---
> MdeModulePkg/Include/UniversalPayload/AcpiTable.h | 28
> ++++++++++++++++++++++++++++
> MdeModulePkg/MdeModulePkg.dec | 3 +++
> 2 files changed, 31 insertions(+)
>
> diff --git a/MdeModulePkg/Include/UniversalPayload/AcpiTable.h
> b/MdeModulePkg/Include/UniversalPayload/AcpiTable.h
> new file mode 100644
> index 0000000000..a85c555d9c
> --- /dev/null
> +++ b/MdeModulePkg/Include/UniversalPayload/AcpiTable.h
> @@ -0,0 +1,28 @@
> +/** @file
>
> + Define the structure for the Payload APCI table.
>
> +
>
> +Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
>
> +SPDX-License-Identifier: BSD-2-Clause-Patent
>
> +
Could you help to add the specification reference information in the header file description comment?
With this handled:
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
Best Regards,
Hao Wu
>
> +**/
>
> +
>
> +#ifndef _PLD_ACPI_TABLE_H_
>
> +#define _PLD_ACPI_TABLE_H_
>
> +
>
> +#include <Uefi.h>
>
> +#include <UniversalPayload/UniversalPayload.h>
>
> +
>
> +#pragma pack(1)
>
> +
>
> +typedef struct {
>
> + PLD_GENERIC_HEADER PldHeader;
>
> + EFI_PHYSICAL_ADDRESS Rsdp;
>
> +} PLD_ACPI_TABLE;
>
> +
>
> +#pragma pack()
>
> +
>
> +#define PLD_ACPI_TABLE_REVISION 1
>
> +
>
> +extern GUID gPldAcpiTableGuid;
>
> +
>
> +#endif //_PLD_ACPI_TABLE_H_
>
> diff --git a/MdeModulePkg/MdeModulePkg.dec
> b/MdeModulePkg/MdeModulePkg.dec
> index 45324d2e20..4da472d7b9 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -416,6 +416,9 @@
> ## Include/UniversalPayload/SmbiosTable.h
>
> gPldSmbiosTableGuid = { 0x590a0d26, 0x06e5, 0x4d20, { 0x8a, 0x82, 0x59,
> 0xea, 0x1b, 0x34, 0x98, 0x2d } }
>
>
>
> + ## Include/UniversalPayload/AcpiTable.h
>
> + gPldAcpiTableGuid = { 0x9f9a9506, 0x5597, 0x4515, { 0xba, 0xb6, 0x8b, 0xcd,
> 0xe7, 0x84, 0xba, 0x87 } }
>
> +
>
> [Ppis]
>
> ## Include/Ppi/AtaController.h
>
> gPeiAtaControllerPpiGuid = { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0, 0x7a,
> 0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }}
>
> --
> 2.30.0.windows.2
^ permalink raw reply [flat|nested] 22+ messages in thread
* [Patch V3 8/9] MdeModulePkg/ACPI: Install ACPI table from HOB.
2021-06-04 9:42 [Patch V3 0/9] Create multiple Hobs for Universal Payload Zhiguang Liu
` (6 preceding siblings ...)
2021-06-04 9:42 ` [Patch V3 7/9] MdeModulePkg: Add new structure for the Universal Payload ACPI Table Info Hob Zhiguang Liu
@ 2021-06-04 9:42 ` Zhiguang Liu
2021-06-08 5:21 ` Wu, Hao A
2021-06-04 9:42 ` [Patch V3 9/9] UefiPayloadPkg: Creat gPldAcpiTableGuid Hob Zhiguang Liu
8 siblings, 1 reply; 22+ messages in thread
From: Zhiguang Liu @ 2021-06-04 9:42 UTC (permalink / raw)
To: devel; +Cc: Jian J Wang, Hao A Wu, Dandan Bi, Liming Gao, Ray Ni
V1:
If HOB contains APCI table information, entry point of AcpiTableDxe.inf
should parse the APCI table from HOB, and install these tables.
We assume the whole ACPI table (starting with EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER)
is contained by a single gEfiAcpiTableGuid HOB.
V2:
If error happens when installing ACPI table, stop installing and removing all the tables that
are already added.
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
---
MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------
MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h | 38 +++++++++++++++++++++++++++++++++++++-
MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf | 8 +++++---
MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c | 171 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
4 files changed, 271 insertions(+), 38 deletions(-)
diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.c b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.c
index 14ced68e64..d98573d613 100644
--- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.c
+++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.c
@@ -1,7 +1,7 @@
/** @file
ACPI Sdt Protocol Driver
- Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved. <BR>
+ Copyright (c) 2010 - 2021, Intel Corporation. All rights reserved. <BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -191,8 +191,7 @@ SdtNotifyAcpiList (
/**
Returns a requested ACPI table.
- The GetAcpiTable() function returns a pointer to a buffer containing the ACPI table associated
- with the Index that was input. The following structures are not considered elements in the list of
+ The following structures are not considered elements in the list of
ACPI tables:
- Root System Description Pointer (RSD_PTR)
- Root System Description Table (RSDT)
@@ -201,42 +200,32 @@ SdtNotifyAcpiList (
member. For tables installed via the EFI_ACPI_TABLE_PROTOCOL.InstallAcpiTable() interface,
the function returns the value of EFI_ACPI_STD_PROTOCOL.AcpiVersion.
- @param[in] Index The zero-based index of the table to retrieve.
- @param[out] Table Pointer for returning the table buffer.
- @param[out] Version On return, updated with the ACPI versions to which this table belongs. Type
- EFI_ACPI_TABLE_VERSION is defined in "Related Definitions" in the
- EFI_ACPI_SDT_PROTOCOL.
- @param[out] TableKey On return, points to the table key for the specified ACPI system definition table.
- This is identical to the table key used in the EFI_ACPI_TABLE_PROTOCOL.
- The TableKey can be passed to EFI_ACPI_TABLE_PROTOCOL.UninstallAcpiTable()
- to uninstall the table.
- @retval EFI_SUCCESS The function completed successfully.
- @retval EFI_NOT_FOUND The requested index is too large and a table was not found.
+ @param[in] AcpiTableInstance ACPI table Instance.
+ @param[in] Index The zero-based index of the table to retrieve.
+ @param[out] Table Pointer for returning the table buffer.
+ @param[out] Version On return, updated with the ACPI versions to which this table belongs. Type
+ EFI_ACPI_TABLE_VERSION is defined in "Related Definitions" in the
+ EFI_ACPI_SDT_PROTOCOL.
+ @param[out] TableKey On return, points to the table key for the specified ACPI system definition table.
+ This is identical to the table key used in the EFI_ACPI_TABLE_PROTOCOL.
+ The TableKey can be passed to EFI_ACPI_TABLE_PROTOCOL.UninstallAcpiTable()
+ to uninstall the table.
+ @retval EFI_SUCCESS The function completed successfully.
+ @retval EFI_NOT_FOUND The requested index is too large and a table was not found.
**/
EFI_STATUS
-EFIAPI
-GetAcpiTable2 (
+SdtGetAcpiTable (
+ IN EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance,
IN UINTN Index,
OUT EFI_ACPI_SDT_HEADER **Table,
OUT EFI_ACPI_TABLE_VERSION *Version,
OUT UINTN *TableKey
)
{
- EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance;
UINTN TableIndex;
LIST_ENTRY *CurrentLink;
LIST_ENTRY *StartLink;
EFI_ACPI_TABLE_LIST *CurrentTable;
-
- ASSERT (Table != NULL);
- ASSERT (Version != NULL);
- ASSERT (TableKey != NULL);
-
- //
- // Get the instance of the ACPI Table
- //
- AcpiTableInstance = SdtGetAcpiTableInstance ();
-
//
// Find the table
//
@@ -270,6 +259,55 @@ GetAcpiTable2 (
return EFI_SUCCESS;
}
+/**
+ Returns a requested ACPI table.
+
+ The GetAcpiTable() function returns a pointer to a buffer containing the ACPI table associated
+ with the Index that was input. The following structures are not considered elements in the list of
+ ACPI tables:
+ - Root System Description Pointer (RSD_PTR)
+ - Root System Description Table (RSDT)
+ - Extended System Description Table (XSDT)
+ Version is updated with a bit map containing all the versions of ACPI of which the table is a
+ member. For tables installed via the EFI_ACPI_TABLE_PROTOCOL.InstallAcpiTable() interface,
+ the function returns the value of EFI_ACPI_STD_PROTOCOL.AcpiVersion.
+
+ @param[in] Index The zero-based index of the table to retrieve.
+ @param[out] Table Pointer for returning the table buffer.
+ @param[out] Version On return, updated with the ACPI versions to which this table belongs. Type
+ EFI_ACPI_TABLE_VERSION is defined in "Related Definitions" in the
+ EFI_ACPI_SDT_PROTOCOL.
+ @param[out] TableKey On return, points to the table key for the specified ACPI system definition table.
+ This is identical to the table key used in the EFI_ACPI_TABLE_PROTOCOL.
+ The TableKey can be passed to EFI_ACPI_TABLE_PROTOCOL.UninstallAcpiTable()
+ to uninstall the table.
+ @retval EFI_SUCCESS The function completed successfully.
+ @retval EFI_NOT_FOUND The requested index is too large and a table was not found.
+**/
+EFI_STATUS
+EFIAPI
+GetAcpiTable2 (
+ IN UINTN Index,
+ OUT EFI_ACPI_SDT_HEADER **Table,
+ OUT EFI_ACPI_TABLE_VERSION *Version,
+ OUT UINTN *TableKey
+ )
+{
+ EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance;
+
+ ASSERT (Table != NULL);
+ ASSERT (Version != NULL);
+ ASSERT (TableKey != NULL);
+
+ //
+ // Get the instance of the ACPI Table
+ //
+ AcpiTableInstance = SdtGetAcpiTableInstance ();
+
+ return SdtGetAcpiTable (AcpiTableInstance, Index, Table, Version, TableKey);
+}
+
+
/**
Register a callback when an ACPI table is installed.
diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h
index 9d7cf7ccfc..0af2d11a1a 100644
--- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h
+++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h
@@ -1,7 +1,7 @@
/** @file
ACPI Table Protocol Driver
- Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -24,6 +24,8 @@
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/PcdLib.h>
+#include <Library/HobLib.h>
+#include <UniversalPayload/AcpiTable.h>
//
// Statements that include other files
@@ -228,6 +230,40 @@ SdtAcpiTableAcpiSdtConstructor (
IN EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance
);
+/**
+ Returns a requested ACPI table.
+
+ The following structures are not considered elements in the list of
+ ACPI tables:
+ - Root System Description Pointer (RSD_PTR)
+ - Root System Description Table (RSDT)
+ - Extended System Description Table (XSDT)
+ Version is updated with a bit map containing all the versions of ACPI of which the table is a
+ member. For tables installed via the EFI_ACPI_TABLE_PROTOCOL.InstallAcpiTable() interface,
+ the function returns the value of EFI_ACPI_STD_PROTOCOL.AcpiVersion.
+
+ @param[in] AcpiTableInstance ACPI table Instance.
+ @param[in] Index The zero-based index of the table to retrieve.
+ @param[out] Table Pointer for returning the table buffer.
+ @param[out] Version On return, updated with the ACPI versions to which this table belongs. Type
+ EFI_ACPI_TABLE_VERSION is defined in "Related Definitions" in the
+ EFI_ACPI_SDT_PROTOCOL.
+ @param[out] TableKey On return, points to the table key for the specified ACPI system definition table.
+ This is identical to the table key used in the EFI_ACPI_TABLE_PROTOCOL.
+ The TableKey can be passed to EFI_ACPI_TABLE_PROTOCOL.UninstallAcpiTable()
+ to uninstall the table.
+ @retval EFI_SUCCESS The function completed successfully.
+ @retval EFI_NOT_FOUND The requested index is too large and a table was not found.
+**/
+EFI_STATUS
+SdtGetAcpiTable (
+ IN EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance,
+ IN UINTN Index,
+ OUT EFI_ACPI_SDT_HEADER **Table,
+ OUT EFI_ACPI_TABLE_VERSION *Version,
+ OUT UINTN *TableKey
+ );
+
//
// export PrivateData symbol, because we need that in AcpiSdtProtol implementation
//
diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
index d341df439e..9e34f8ea41 100644
--- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
@@ -4,7 +4,7 @@
# This driver initializes ACPI tables (Rsdp, Rsdt and Xsdt) and produces UEFI/PI
# services to install/uninstall/manage ACPI tables.
#
-# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -51,10 +51,12 @@
DebugLib
BaseLib
PcdLib
+ HobLib
[Guids]
- gEfiAcpi10TableGuid ## PRODUCES ## SystemTable
- gEfiAcpiTableGuid ## PRODUCES ## SystemTable
+ gEfiAcpi10TableGuid ## PRODUCES ## SystemTable
+ gEfiAcpiTableGuid ## PRODUCES ## SystemTable
+ gPldAcpiTableGuid ## SOMETIMES_CONSUMES ## HOB
[FeaturePcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol ## CONSUMES
diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
index 5a2afdff27..cd79a1082c 100644
--- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
+++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
@@ -1,7 +1,7 @@
/** @file
ACPI Table Protocol Implementation
- Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -30,6 +30,7 @@ STATIC EFI_ALLOCATE_TYPE mAcpiTableAllocType;
@param Table Table to add.
@param Checksum Does the table require checksumming.
@param Version The version of the list to add the table to.
+ @param IsFromHob True, if add Apci Table from Hob List.
@param Handle Pointer for returning the handle.
@return EFI_SUCCESS The function completed successfully.
@@ -44,6 +45,7 @@ AddTableToList (
IN VOID *Table,
IN BOOLEAN Checksum,
IN EFI_ACPI_TABLE_VERSION Version,
+ IN BOOLEAN IsFromHob,
OUT UINTN *Handle
);
@@ -238,6 +240,7 @@ InstallAcpiTable (
AcpiTableBufferConst,
TRUE,
Version,
+ FALSE,
TableKey
);
if (!EFI_ERROR (Status)) {
@@ -472,6 +475,7 @@ FreeTableMemory (
@param Table Table to add.
@param Checksum Does the table require checksumming.
@param Version The version of the list to add the table to.
+ @param IsFromHob True, if add Apci Table from Hob List.
@param Handle Pointer for returning the handle.
@return EFI_SUCCESS The function completed successfully.
@@ -487,6 +491,7 @@ AddTableToList (
IN VOID *Table,
IN BOOLEAN Checksum,
IN EFI_ACPI_TABLE_VERSION Version,
+ IN BOOLEAN IsFromHob,
OUT UINTN *Handle
)
{
@@ -553,12 +558,17 @@ AddTableToList (
// SMM communication ACPI table.
//
ASSERT ((EFI_PAGE_SIZE % 64) == 0);
- Status = gBS->AllocatePages (
- AllocateMaxAddress,
- EfiACPIMemoryNVS,
- EFI_SIZE_TO_PAGES (CurrentTableList->TableSize),
- &AllocPhysAddress
- );
+ if (IsFromHob){
+ AllocPhysAddress = (UINTN)Table;
+ Status = EFI_SUCCESS;
+ } else {
+ Status = gBS->AllocatePages (
+ AllocateMaxAddress,
+ EfiACPIMemoryNVS,
+ EFI_SIZE_TO_PAGES (CurrentTableList->TableSize),
+ &AllocPhysAddress
+ );
+ }
} else if (mAcpiTableAllocType == AllocateAnyPages) {
//
// If there is no allocation limit, there is also no need to use page
@@ -1689,6 +1699,151 @@ ChecksumCommonTables (
return EFI_SUCCESS;
}
+/**
+ This function will find gPldAcpiTableGuid Guid Hob, and install Acpi table from it.
+
+ @param AcpiTableInstance Protocol instance private data.
+
+ @return EFI_SUCCESS The function completed successfully.
+ @return EFI_NOT_FOUND The function doesn't find the gEfiAcpiTableGuid Guid Hob.
+ @return EFI_ABORTED The function could not complete successfully.
+
+**/
+EFI_STATUS
+InstallAcpiTableFromHob (
+ EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance
+ )
+{
+ EFI_HOB_GUID_TYPE *GuidHob;
+ EFI_ACPI_TABLE_VERSION Version;
+ EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp;
+ EFI_ACPI_DESCRIPTION_HEADER *Rsdt;
+ EFI_ACPI_DESCRIPTION_HEADER *ChildTable;
+ UINT64 ChildTableAddress;
+ UINTN Count;
+ UINTN Index;
+ UINTN TableKey;
+ EFI_STATUS Status;
+ UINTN EntrySize;
+ PLD_ACPI_TABLE *AcpiTableAdress;
+ VOID *TableToInstall;
+ EFI_ACPI_SDT_HEADER *Table;
+ PLD_GENERIC_HEADER *GenericHeader;
+
+ TableKey = 0;
+ Version = PcdGet32 (PcdAcpiExposedTableVersions);
+ Status = EFI_SUCCESS;
+ //
+ // HOB only contains the ACPI table in 2.0+ format.
+ //
+ GuidHob = GetFirstGuidHob (&gPldAcpiTableGuid);
+ if (GuidHob == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ GenericHeader = (PLD_GENERIC_HEADER *) GET_GUID_HOB_DATA (GuidHob);
+ if ((sizeof (PLD_GENERIC_HEADER) > GET_GUID_HOB_DATA_SIZE (GuidHob)) || (GenericHeader->Length > GET_GUID_HOB_DATA_SIZE (GuidHob))) {
+ return EFI_NOT_FOUND;
+ }
+ if (GenericHeader->Revision == PLD_ACPI_TABLE_REVISION) {
+ //
+ // PLD_ACPI_TABLE structure is used when Revision equals to PLD_ACPI_TABLE_REVISION
+ //
+ AcpiTableAdress = (PLD_ACPI_TABLE *) GET_GUID_HOB_DATA (GuidHob);
+ if (AcpiTableAdress->PldHeader.Length < PLD_SIZEOF_THROUGH_FIELD (PLD_ACPI_TABLE, Rsdp)) {
+ //
+ // Retrun if can't find the ACPI Info Hob with enough length
+ //
+ return EFI_NOT_FOUND;
+ }
+ Rsdp = (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *) (UINTN) (AcpiTableAdress->Rsdp);
+
+ //
+ // An ACPI-compatible OS must use the XSDT if present.
+ // It shouldn't happen that XsdtAddress points beyond 4G range in 32-bit environment.
+ //
+ ASSERT ((UINTN) Rsdp->XsdtAddress == Rsdp->XsdtAddress);
+
+ EntrySize = sizeof (UINT64);
+ Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->XsdtAddress;
+ if (Rsdt == NULL) {
+ //
+ // XsdtAddress is zero, then we use Rsdt which has 32 bit entry
+ //
+ Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->RsdtAddress;
+ EntrySize = sizeof (UINT32);
+ }
+
+ if (Rsdt->Length <= sizeof (EFI_ACPI_DESCRIPTION_HEADER)) {
+ return EFI_ABORTED;
+ }
+
+ Count = (Rsdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / EntrySize;
+
+ for (Index = 0; Index < Count; Index++){
+ ChildTableAddress = 0;
+ CopyMem (&ChildTableAddress, (UINT8 *) (Rsdt + 1) + EntrySize * Index, EntrySize);
+ //
+ // If the address is of UINT64 while this module runs at 32 bits,
+ // make sure the upper bits are all-zeros.
+ //
+ ASSERT (ChildTableAddress == (UINTN) ChildTableAddress);
+ if (ChildTableAddress != (UINTN) ChildTableAddress) {
+ Status = EFI_ABORTED;
+ break;
+ }
+
+ ChildTable = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) ChildTableAddress;
+ Status = AddTableToList (AcpiTableInstance, ChildTable, TRUE, Version, TRUE, &TableKey);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "InstallAcpiTableFromHob: Fail to add ACPI table at 0x%p\n", ChildTable));
+ ASSERT_EFI_ERROR (Status);
+ break;
+ }
+ if (ChildTable->Signature == EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE){
+ //
+ // Add the FACS and DSDT tables if it is not NULL.
+ //
+ if (((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *) ChildTable)->FirmwareCtrl != 0) {
+ TableToInstall = (VOID *) (UINTN) ((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *) ChildTable)->FirmwareCtrl;
+ Status = AddTableToList (AcpiTableInstance, TableToInstall, TRUE, Version, TRUE, &TableKey);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "InstallAcpiTableFromHob: Fail to add ACPI table FACS\n"));
+ ASSERT_EFI_ERROR (Status);
+ break;
+ }
+ }
+
+ if (((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *) ChildTable)->Dsdt != 0) {
+ TableToInstall = (VOID *) (UINTN) ((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *) ChildTable)->Dsdt;
+ Status = AddTableToList (AcpiTableInstance, TableToInstall, TRUE, Version, TRUE, &TableKey);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "InstallAcpiTableFromHob: Fail to add ACPI table DSDT\n"));
+ ASSERT_EFI_ERROR (Status);
+ break;
+ }
+ }
+ }
+ }
+ } else {
+ return EFI_NOT_FOUND;
+ }
+
+ if (EFI_ERROR (Status)) {
+ //
+ // Error happens when trying to add ACPI table to the list.
+ // Remove all of them from list because at this time, no other tables except from HOB are in the list
+ //
+ while (SdtGetAcpiTable (AcpiTableInstance, 0, &Table, &Version, &TableKey) == EFI_SUCCESS) {
+ RemoveTableFromList (AcpiTableInstance, Version, TableKey);
+ }
+ } else {
+ Status = PublishTables (AcpiTableInstance, Version);
+ }
+
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+}
/**
Constructor for the ACPI table protocol. Initializes instance
@@ -1918,6 +2073,8 @@ AcpiTableAcpiTableConstructor (
ChecksumCommonTables (AcpiTableInstance);
+ InstallAcpiTableFromHob (AcpiTableInstance);
+
//
// Completed successfully
//
--
2.30.0.windows.2
^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [Patch V3 8/9] MdeModulePkg/ACPI: Install ACPI table from HOB.
2021-06-04 9:42 ` [Patch V3 8/9] MdeModulePkg/ACPI: Install ACPI table from HOB Zhiguang Liu
@ 2021-06-08 5:21 ` Wu, Hao A
0 siblings, 0 replies; 22+ messages in thread
From: Wu, Hao A @ 2021-06-08 5:21 UTC (permalink / raw)
To: Liu, Zhiguang, devel@edk2.groups.io
Cc: Wang, Jian J, Bi, Dandan, Liming Gao, Ni, Ray
> -----Original Message-----
> From: Liu, Zhiguang <zhiguang.liu@intel.com>
> Sent: Friday, June 4, 2021 5:42 PM
> To: devel@edk2.groups.io
> Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;
> Bi, Dandan <dandan.bi@intel.com>; Liming Gao
> <gaoliming@byosoft.com.cn>; Ni, Ray <ray.ni@intel.com>
> Subject: [Patch V3 8/9] MdeModulePkg/ACPI: Install ACPI table from HOB.
>
> V1:
> If HOB contains APCI table information, entry point of AcpiTableDxe.inf
> should parse the APCI table from HOB, and install these tables.
> We assume the whole ACPI table (starting with
> EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER)
> is contained by a single gEfiAcpiTableGuid HOB.
>
> V2:
> If error happens when installing ACPI table, stop installing and removing all
> the tables that
> are already added.
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
Best Regards,
Hao Wu
>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Dandan Bi <dandan.bi@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Ray Ni <ray.ni@intel.com>
> Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
> ---
> MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.c | 92
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> +++++++---------------------------
> MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h | 38
> +++++++++++++++++++++++++++++++++++++-
> MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf | 8
> +++++---
> MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c | 171
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> ++++++++++++++++++++++++++++++++++++++++++++++++-------
> 4 files changed, 271 insertions(+), 38 deletions(-)
>
> diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.c
> b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.c
> index 14ced68e64..d98573d613 100644
> --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.c
> +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.c
> @@ -1,7 +1,7 @@
> /** @file
>
> ACPI Sdt Protocol Driver
>
>
>
> - Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved. <BR>
>
> + Copyright (c) 2010 - 2021, Intel Corporation. All rights reserved. <BR>
>
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
>
>
> **/
>
> @@ -191,8 +191,7 @@ SdtNotifyAcpiList (
> /**
>
> Returns a requested ACPI table.
>
>
>
> - The GetAcpiTable() function returns a pointer to a buffer containing the
> ACPI table associated
>
> - with the Index that was input. The following structures are not considered
> elements in the list of
>
> + The following structures are not considered elements in the list of
>
> ACPI tables:
>
> - Root System Description Pointer (RSD_PTR)
>
> - Root System Description Table (RSDT)
>
> @@ -201,42 +200,32 @@ SdtNotifyAcpiList (
> member. For tables installed via the
> EFI_ACPI_TABLE_PROTOCOL.InstallAcpiTable() interface,
>
> the function returns the value of EFI_ACPI_STD_PROTOCOL.AcpiVersion.
>
>
>
> - @param[in] Index The zero-based index of the table to retrieve.
>
> - @param[out] Table Pointer for returning the table buffer.
>
> - @param[out] Version On return, updated with the ACPI versions to
> which this table belongs. Type
>
> - EFI_ACPI_TABLE_VERSION is defined in "Related Definitions"
> in the
>
> - EFI_ACPI_SDT_PROTOCOL.
>
> - @param[out] TableKey On return, points to the table key for the
> specified ACPI system definition table.
>
> - This is identical to the table key used in the
> EFI_ACPI_TABLE_PROTOCOL.
>
> - The TableKey can be passed to
> EFI_ACPI_TABLE_PROTOCOL.UninstallAcpiTable()
>
> - to uninstall the table.
>
> - @retval EFI_SUCCESS The function completed successfully.
>
> - @retval EFI_NOT_FOUND The requested index is too large and a table
> was not found.
>
> + @param[in] AcpiTableInstance ACPI table Instance.
>
> + @param[in] Index The zero-based index of the table to retrieve.
>
> + @param[out] Table Pointer for returning the table buffer.
>
> + @param[out] Version On return, updated with the ACPI versions to
> which this table belongs. Type
>
> + EFI_ACPI_TABLE_VERSION is defined in "Related
> Definitions" in the
>
> + EFI_ACPI_SDT_PROTOCOL.
>
> + @param[out] TableKey On return, points to the table key for the
> specified ACPI system definition table.
>
> + This is identical to the table key used in the
> EFI_ACPI_TABLE_PROTOCOL.
>
> + The TableKey can be passed to
> EFI_ACPI_TABLE_PROTOCOL.UninstallAcpiTable()
>
> + to uninstall the table.
>
> + @retval EFI_SUCCESS The function completed successfully.
>
> + @retval EFI_NOT_FOUND The requested index is too large and a
> table was not found.
>
> **/
>
> EFI_STATUS
>
> -EFIAPI
>
> -GetAcpiTable2 (
>
> +SdtGetAcpiTable (
>
> + IN EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance,
>
> IN UINTN Index,
>
> OUT EFI_ACPI_SDT_HEADER **Table,
>
> OUT EFI_ACPI_TABLE_VERSION *Version,
>
> OUT UINTN *TableKey
>
> )
>
> {
>
> - EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance;
>
> UINTN TableIndex;
>
> LIST_ENTRY *CurrentLink;
>
> LIST_ENTRY *StartLink;
>
> EFI_ACPI_TABLE_LIST *CurrentTable;
>
> -
>
> - ASSERT (Table != NULL);
>
> - ASSERT (Version != NULL);
>
> - ASSERT (TableKey != NULL);
>
> -
>
> - //
>
> - // Get the instance of the ACPI Table
>
> - //
>
> - AcpiTableInstance = SdtGetAcpiTableInstance ();
>
> -
>
> //
>
> // Find the table
>
> //
>
> @@ -270,6 +259,55 @@ GetAcpiTable2 (
> return EFI_SUCCESS;
>
> }
>
>
>
> +/**
>
> + Returns a requested ACPI table.
>
> +
>
> + The GetAcpiTable() function returns a pointer to a buffer containing the
> ACPI table associated
>
> + with the Index that was input. The following structures are not considered
> elements in the list of
>
> + ACPI tables:
>
> + - Root System Description Pointer (RSD_PTR)
>
> + - Root System Description Table (RSDT)
>
> + - Extended System Description Table (XSDT)
>
> + Version is updated with a bit map containing all the versions of ACPI of
> which the table is a
>
> + member. For tables installed via the
> EFI_ACPI_TABLE_PROTOCOL.InstallAcpiTable() interface,
>
> + the function returns the value of EFI_ACPI_STD_PROTOCOL.AcpiVersion.
>
> +
>
> + @param[in] Index The zero-based index of the table to retrieve.
>
> + @param[out] Table Pointer for returning the table buffer.
>
> + @param[out] Version On return, updated with the ACPI versions to
> which this table belongs. Type
>
> + EFI_ACPI_TABLE_VERSION is defined in "Related Definitions"
> in the
>
> + EFI_ACPI_SDT_PROTOCOL.
>
> + @param[out] TableKey On return, points to the table key for the
> specified ACPI system definition table.
>
> + This is identical to the table key used in the
> EFI_ACPI_TABLE_PROTOCOL.
>
> + The TableKey can be passed to
> EFI_ACPI_TABLE_PROTOCOL.UninstallAcpiTable()
>
> + to uninstall the table.
>
> + @retval EFI_SUCCESS The function completed successfully.
>
> + @retval EFI_NOT_FOUND The requested index is too large and a table
> was not found.
>
> +**/
>
> +EFI_STATUS
>
> +EFIAPI
>
> +GetAcpiTable2 (
>
> + IN UINTN Index,
>
> + OUT EFI_ACPI_SDT_HEADER **Table,
>
> + OUT EFI_ACPI_TABLE_VERSION *Version,
>
> + OUT UINTN *TableKey
>
> + )
>
> +{
>
> + EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance;
>
> +
>
> + ASSERT (Table != NULL);
>
> + ASSERT (Version != NULL);
>
> + ASSERT (TableKey != NULL);
>
> +
>
> + //
>
> + // Get the instance of the ACPI Table
>
> + //
>
> + AcpiTableInstance = SdtGetAcpiTableInstance ();
>
> +
>
> + return SdtGetAcpiTable (AcpiTableInstance, Index, Table, Version,
> TableKey);
>
> +}
>
> +
>
> +
>
> /**
>
> Register a callback when an ACPI table is installed.
>
>
>
> diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h
> b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h
> index 9d7cf7ccfc..0af2d11a1a 100644
> --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h
> +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h
> @@ -1,7 +1,7 @@
> /** @file
>
> ACPI Table Protocol Driver
>
>
>
> - Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
>
> + Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>
>
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
>
>
> **/
>
> @@ -24,6 +24,8 @@
> #include <Library/MemoryAllocationLib.h>
>
> #include <Library/UefiBootServicesTableLib.h>
>
> #include <Library/PcdLib.h>
>
> +#include <Library/HobLib.h>
>
> +#include <UniversalPayload/AcpiTable.h>
>
>
>
> //
>
> // Statements that include other files
>
> @@ -228,6 +230,40 @@ SdtAcpiTableAcpiSdtConstructor (
> IN EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance
>
> );
>
>
>
> +/**
>
> + Returns a requested ACPI table.
>
> +
>
> + The following structures are not considered elements in the list of
>
> + ACPI tables:
>
> + - Root System Description Pointer (RSD_PTR)
>
> + - Root System Description Table (RSDT)
>
> + - Extended System Description Table (XSDT)
>
> + Version is updated with a bit map containing all the versions of ACPI of
> which the table is a
>
> + member. For tables installed via the
> EFI_ACPI_TABLE_PROTOCOL.InstallAcpiTable() interface,
>
> + the function returns the value of EFI_ACPI_STD_PROTOCOL.AcpiVersion.
>
> +
>
> + @param[in] AcpiTableInstance ACPI table Instance.
>
> + @param[in] Index The zero-based index of the table to retrieve.
>
> + @param[out] Table Pointer for returning the table buffer.
>
> + @param[out] Version On return, updated with the ACPI versions to
> which this table belongs. Type
>
> + EFI_ACPI_TABLE_VERSION is defined in "Related
> Definitions" in the
>
> + EFI_ACPI_SDT_PROTOCOL.
>
> + @param[out] TableKey On return, points to the table key for the
> specified ACPI system definition table.
>
> + This is identical to the table key used in the
> EFI_ACPI_TABLE_PROTOCOL.
>
> + The TableKey can be passed to
> EFI_ACPI_TABLE_PROTOCOL.UninstallAcpiTable()
>
> + to uninstall the table.
>
> + @retval EFI_SUCCESS The function completed successfully.
>
> + @retval EFI_NOT_FOUND The requested index is too large and a
> table was not found.
>
> +**/
>
> +EFI_STATUS
>
> +SdtGetAcpiTable (
>
> + IN EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance,
>
> + IN UINTN Index,
>
> + OUT EFI_ACPI_SDT_HEADER **Table,
>
> + OUT EFI_ACPI_TABLE_VERSION *Version,
>
> + OUT UINTN *TableKey
>
> + );
>
> +
>
> //
>
> // export PrivateData symbol, because we need that in AcpiSdtProtol
> implementation
>
> //
>
> diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
> b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
> index d341df439e..9e34f8ea41 100644
> --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
> +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
> @@ -4,7 +4,7 @@
> # This driver initializes ACPI tables (Rsdp, Rsdt and Xsdt) and produces
> UEFI/PI
>
> # services to install/uninstall/manage ACPI tables.
>
> #
>
> -# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
>
> +# Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>
>
> # Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
>
> # SPDX-License-Identifier: BSD-2-Clause-Patent
>
> #
>
> @@ -51,10 +51,12 @@
> DebugLib
>
> BaseLib
>
> PcdLib
>
> + HobLib
>
>
>
> [Guids]
>
> - gEfiAcpi10TableGuid ## PRODUCES ## SystemTable
>
> - gEfiAcpiTableGuid ## PRODUCES ## SystemTable
>
> + gEfiAcpi10TableGuid ## PRODUCES ## SystemTable
>
> + gEfiAcpiTableGuid ## PRODUCES ## SystemTable
>
> + gPldAcpiTableGuid ## SOMETIMES_CONSUMES ## HOB
>
>
>
> [FeaturePcd]
>
> gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol ##
> CONSUMES
>
> diff --git
> a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
> b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
> index 5a2afdff27..cd79a1082c 100644
> --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
> +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
> @@ -1,7 +1,7 @@
> /** @file
>
> ACPI Table Protocol Implementation
>
>
>
> - Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
>
> + Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>
>
> Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
>
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
>
>
> @@ -30,6 +30,7 @@ STATIC EFI_ALLOCATE_TYPE mAcpiTableAllocType;
> @param Table Table to add.
>
> @param Checksum Does the table require checksumming.
>
> @param Version The version of the list to add the table to.
>
> + @param IsFromHob True, if add Apci Table from Hob List.
>
> @param Handle Pointer for returning the handle.
>
>
>
> @return EFI_SUCCESS The function completed successfully.
>
> @@ -44,6 +45,7 @@ AddTableToList (
> IN VOID *Table,
>
> IN BOOLEAN Checksum,
>
> IN EFI_ACPI_TABLE_VERSION Version,
>
> + IN BOOLEAN IsFromHob,
>
> OUT UINTN *Handle
>
> );
>
>
>
> @@ -238,6 +240,7 @@ InstallAcpiTable (
> AcpiTableBufferConst,
>
> TRUE,
>
> Version,
>
> + FALSE,
>
> TableKey
>
> );
>
> if (!EFI_ERROR (Status)) {
>
> @@ -472,6 +475,7 @@ FreeTableMemory (
> @param Table Table to add.
>
> @param Checksum Does the table require checksumming.
>
> @param Version The version of the list to add the table to.
>
> + @param IsFromHob True, if add Apci Table from Hob List.
>
> @param Handle Pointer for returning the handle.
>
>
>
> @return EFI_SUCCESS The function completed successfully.
>
> @@ -487,6 +491,7 @@ AddTableToList (
> IN VOID *Table,
>
> IN BOOLEAN Checksum,
>
> IN EFI_ACPI_TABLE_VERSION Version,
>
> + IN BOOLEAN IsFromHob,
>
> OUT UINTN *Handle
>
> )
>
> {
>
> @@ -553,12 +558,17 @@ AddTableToList (
> // SMM communication ACPI table.
>
> //
>
> ASSERT ((EFI_PAGE_SIZE % 64) == 0);
>
> - Status = gBS->AllocatePages (
>
> - AllocateMaxAddress,
>
> - EfiACPIMemoryNVS,
>
> - EFI_SIZE_TO_PAGES (CurrentTableList->TableSize),
>
> - &AllocPhysAddress
>
> - );
>
> + if (IsFromHob){
>
> + AllocPhysAddress = (UINTN)Table;
>
> + Status = EFI_SUCCESS;
>
> + } else {
>
> + Status = gBS->AllocatePages (
>
> + AllocateMaxAddress,
>
> + EfiACPIMemoryNVS,
>
> + EFI_SIZE_TO_PAGES (CurrentTableList->TableSize),
>
> + &AllocPhysAddress
>
> + );
>
> + }
>
> } else if (mAcpiTableAllocType == AllocateAnyPages) {
>
> //
>
> // If there is no allocation limit, there is also no need to use page
>
> @@ -1689,6 +1699,151 @@ ChecksumCommonTables (
> return EFI_SUCCESS;
>
> }
>
>
>
> +/**
>
> + This function will find gPldAcpiTableGuid Guid Hob, and install Acpi table
> from it.
>
> +
>
> + @param AcpiTableInstance Protocol instance private data.
>
> +
>
> + @return EFI_SUCCESS The function completed successfully.
>
> + @return EFI_NOT_FOUND The function doesn't find the
> gEfiAcpiTableGuid Guid Hob.
>
> + @return EFI_ABORTED The function could not complete successfully.
>
> +
>
> +**/
>
> +EFI_STATUS
>
> +InstallAcpiTableFromHob (
>
> + EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance
>
> + )
>
> +{
>
> + EFI_HOB_GUID_TYPE *GuidHob;
>
> + EFI_ACPI_TABLE_VERSION Version;
>
> + EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp;
>
> + EFI_ACPI_DESCRIPTION_HEADER *Rsdt;
>
> + EFI_ACPI_DESCRIPTION_HEADER *ChildTable;
>
> + UINT64 ChildTableAddress;
>
> + UINTN Count;
>
> + UINTN Index;
>
> + UINTN TableKey;
>
> + EFI_STATUS Status;
>
> + UINTN EntrySize;
>
> + PLD_ACPI_TABLE *AcpiTableAdress;
>
> + VOID *TableToInstall;
>
> + EFI_ACPI_SDT_HEADER *Table;
>
> + PLD_GENERIC_HEADER *GenericHeader;
>
> +
>
> + TableKey = 0;
>
> + Version = PcdGet32 (PcdAcpiExposedTableVersions);
>
> + Status = EFI_SUCCESS;
>
> + //
>
> + // HOB only contains the ACPI table in 2.0+ format.
>
> + //
>
> + GuidHob = GetFirstGuidHob (&gPldAcpiTableGuid);
>
> + if (GuidHob == NULL) {
>
> + return EFI_NOT_FOUND;
>
> + }
>
> +
>
> + GenericHeader = (PLD_GENERIC_HEADER *) GET_GUID_HOB_DATA
> (GuidHob);
>
> + if ((sizeof (PLD_GENERIC_HEADER) > GET_GUID_HOB_DATA_SIZE
> (GuidHob)) || (GenericHeader->Length > GET_GUID_HOB_DATA_SIZE
> (GuidHob))) {
>
> + return EFI_NOT_FOUND;
>
> + }
>
> + if (GenericHeader->Revision == PLD_ACPI_TABLE_REVISION) {
>
> + //
>
> + // PLD_ACPI_TABLE structure is used when Revision equals to
> PLD_ACPI_TABLE_REVISION
>
> + //
>
> + AcpiTableAdress = (PLD_ACPI_TABLE *) GET_GUID_HOB_DATA
> (GuidHob);
>
> + if (AcpiTableAdress->PldHeader.Length < PLD_SIZEOF_THROUGH_FIELD
> (PLD_ACPI_TABLE, Rsdp)) {
>
> + //
>
> + // Retrun if can't find the ACPI Info Hob with enough length
>
> + //
>
> + return EFI_NOT_FOUND;
>
> + }
>
> + Rsdp = (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *) (UINTN)
> (AcpiTableAdress->Rsdp);
>
> +
>
> + //
>
> + // An ACPI-compatible OS must use the XSDT if present.
>
> + // It shouldn't happen that XsdtAddress points beyond 4G range in 32-bit
> environment.
>
> + //
>
> + ASSERT ((UINTN) Rsdp->XsdtAddress == Rsdp->XsdtAddress);
>
> +
>
> + EntrySize = sizeof (UINT64);
>
> + Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->XsdtAddress;
>
> + if (Rsdt == NULL) {
>
> + //
>
> + // XsdtAddress is zero, then we use Rsdt which has 32 bit entry
>
> + //
>
> + Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->RsdtAddress;
>
> + EntrySize = sizeof (UINT32);
>
> + }
>
> +
>
> + if (Rsdt->Length <= sizeof (EFI_ACPI_DESCRIPTION_HEADER)) {
>
> + return EFI_ABORTED;
>
> + }
>
> +
>
> + Count = (Rsdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) /
> EntrySize;
>
> +
>
> + for (Index = 0; Index < Count; Index++){
>
> + ChildTableAddress = 0;
>
> + CopyMem (&ChildTableAddress, (UINT8 *) (Rsdt + 1) + EntrySize * Index,
> EntrySize);
>
> + //
>
> + // If the address is of UINT64 while this module runs at 32 bits,
>
> + // make sure the upper bits are all-zeros.
>
> + //
>
> + ASSERT (ChildTableAddress == (UINTN) ChildTableAddress);
>
> + if (ChildTableAddress != (UINTN) ChildTableAddress) {
>
> + Status = EFI_ABORTED;
>
> + break;
>
> + }
>
> +
>
> + ChildTable = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN)
> ChildTableAddress;
>
> + Status = AddTableToList (AcpiTableInstance, ChildTable, TRUE, Version,
> TRUE, &TableKey);
>
> + if (EFI_ERROR (Status)) {
>
> + DEBUG ((DEBUG_ERROR, "InstallAcpiTableFromHob: Fail to add ACPI
> table at 0x%p\n", ChildTable));
>
> + ASSERT_EFI_ERROR (Status);
>
> + break;
>
> + }
>
> + if (ChildTable->Signature ==
> EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE){
>
> + //
>
> + // Add the FACS and DSDT tables if it is not NULL.
>
> + //
>
> + if (((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *) ChildTable)-
> >FirmwareCtrl != 0) {
>
> + TableToInstall = (VOID *) (UINTN)
> ((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *) ChildTable)-
> >FirmwareCtrl;
>
> + Status = AddTableToList (AcpiTableInstance, TableToInstall, TRUE,
> Version, TRUE, &TableKey);
>
> + if (EFI_ERROR (Status)) {
>
> + DEBUG ((DEBUG_ERROR, "InstallAcpiTableFromHob: Fail to add ACPI
> table FACS\n"));
>
> + ASSERT_EFI_ERROR (Status);
>
> + break;
>
> + }
>
> + }
>
> +
>
> + if (((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *) ChildTable)-
> >Dsdt != 0) {
>
> + TableToInstall = (VOID *) (UINTN)
> ((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *) ChildTable)->Dsdt;
>
> + Status = AddTableToList (AcpiTableInstance, TableToInstall, TRUE,
> Version, TRUE, &TableKey);
>
> + if (EFI_ERROR (Status)) {
>
> + DEBUG ((DEBUG_ERROR, "InstallAcpiTableFromHob: Fail to add ACPI
> table DSDT\n"));
>
> + ASSERT_EFI_ERROR (Status);
>
> + break;
>
> + }
>
> + }
>
> + }
>
> + }
>
> + } else {
>
> + return EFI_NOT_FOUND;
>
> + }
>
> +
>
> + if (EFI_ERROR (Status)) {
>
> + //
>
> + // Error happens when trying to add ACPI table to the list.
>
> + // Remove all of them from list because at this time, no other tables
> except from HOB are in the list
>
> + //
>
> + while (SdtGetAcpiTable (AcpiTableInstance, 0, &Table, &Version,
> &TableKey) == EFI_SUCCESS) {
>
> + RemoveTableFromList (AcpiTableInstance, Version, TableKey);
>
> + }
>
> + } else {
>
> + Status = PublishTables (AcpiTableInstance, Version);
>
> + }
>
> +
>
> + ASSERT_EFI_ERROR (Status);
>
> + return Status;
>
> +}
>
>
>
> /**
>
> Constructor for the ACPI table protocol. Initializes instance
>
> @@ -1918,6 +2073,8 @@ AcpiTableAcpiTableConstructor (
>
>
> ChecksumCommonTables (AcpiTableInstance);
>
>
>
> + InstallAcpiTableFromHob (AcpiTableInstance);
>
> +
>
> //
>
> // Completed successfully
>
> //
>
> --
> 2.30.0.windows.2
^ permalink raw reply [flat|nested] 22+ messages in thread
* [Patch V3 9/9] UefiPayloadPkg: Creat gPldAcpiTableGuid Hob
2021-06-04 9:42 [Patch V3 0/9] Create multiple Hobs for Universal Payload Zhiguang Liu
` (7 preceding siblings ...)
2021-06-04 9:42 ` [Patch V3 8/9] MdeModulePkg/ACPI: Install ACPI table from HOB Zhiguang Liu
@ 2021-06-04 9:42 ` Zhiguang Liu
8 siblings, 0 replies; 22+ messages in thread
From: Zhiguang Liu @ 2021-06-04 9:42 UTC (permalink / raw)
To: devel; +Cc: Maurice Ma, Guo Dong, Benjamin You, Ray Ni
>From SysTableInfo Hob, get ACPI table address, and creat gPldAcpiTableGuid Hob
to store it. Remove diretly adding ACPI table to ConfigurationTable.
Dxe ACPI driver will parse it and install ACPI table from Guid Hob.
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Guo Dong <guo.dong@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
---
UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c | 17 -----------------
UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h | 5 +----
UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf | 1 -
UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c | 11 +++++++++++
UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h | 2 +-
UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf | 1 +
UefiPayloadPkg/UefiPayloadPkg.fdf | 4 ++++
7 files changed, 18 insertions(+), 23 deletions(-)
diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
index 56b85b8e6d..ffd3427fb3 100644
--- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
+++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
@@ -99,7 +99,6 @@ BlDxeEntryPoint (
{
EFI_STATUS Status;
EFI_HOB_GUID_TYPE *GuidHob;
- SYSTEM_TABLE_INFO *SystemTableInfo;
EFI_PEI_GRAPHICS_INFO_HOB *GfxInfo;
ACPI_BOARD_INFO *AcpiBoardInfo;
@@ -113,22 +112,6 @@ BlDxeEntryPoint (
Status = ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFED00000, SIZE_1KB, 0, ImageHandle); // HPET
ASSERT_EFI_ERROR (Status);
- //
- // Find the system table information guid hob
- //
- GuidHob = GetFirstGuidHob (&gUefiSystemTableInfoGuid);
- ASSERT (GuidHob != NULL);
- SystemTableInfo = (SYSTEM_TABLE_INFO *)GET_GUID_HOB_DATA (GuidHob);
-
- //
- // Install Acpi Table
- //
- if (SystemTableInfo->AcpiTableBase != 0 && SystemTableInfo->AcpiTableSize != 0) {
- DEBUG ((DEBUG_ERROR, "Install Acpi Table at 0x%lx, length 0x%x\n", SystemTableInfo->AcpiTableBase, SystemTableInfo->AcpiTableSize));
- Status = gBS->InstallConfigurationTable (&gEfiAcpiTableGuid, (VOID *)(UINTN)SystemTableInfo->AcpiTableBase);
- ASSERT_EFI_ERROR (Status);
- }
-
//
// Find the frame buffer information and update PCDs
//
diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h
index 512105fafd..3332a30eae 100644
--- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h
+++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h
@@ -1,7 +1,7 @@
/** @file
The header file of bootloader support DXE.
-Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -19,12 +19,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/IoLib.h>
#include <Library/HobLib.h>
-#include <Guid/Acpi.h>
#include <Guid/SmBios.h>
#include <Guid/SystemTableInfoGuid.h>
#include <Guid/AcpiBoardInfoGuid.h>
#include <Guid/GraphicsInfoHob.h>
-#include <IndustryStandard/Acpi.h>
-
#endif
diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf
index 30f41f8c39..1ccb250991 100644
--- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf
+++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf
@@ -42,7 +42,6 @@
HobLib
[Guids]
- gEfiAcpiTableGuid
gUefiSystemTableInfoGuid
gUefiAcpiBoardInfoGuid
gEfiGraphicsInfoHobGuid
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
index 7b71d37f94..14b7a732da 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
@@ -235,6 +235,7 @@ BuildHobFromBl (
EFI_PEI_GRAPHICS_DEVICE_INFO_HOB GfxDeviceInfo;
EFI_PEI_GRAPHICS_DEVICE_INFO_HOB *NewGfxDeviceInfo;
PLD_SMBIOS_TABLE *SmBiosTableHob;
+ PLD_ACPI_TABLE *AcpiTableHob;
//
// Parse memory info and build memory HOBs
@@ -287,6 +288,16 @@ BuildHobFromBl (
SmBiosTableHob->SmBiosEntryPoint = SysTableInfo.SmbiosTableBase;
DEBUG ((DEBUG_INFO, "Create smbios table gPldSmbiosTableGuid guid hob\n"));
+ //
+ // Creat ACPI table Hob
+ //
+ AcpiTableHob = BuildGuidHob (&gPldAcpiTableGuid, sizeof (PLD_ACPI_TABLE));
+ ASSERT (AcpiTableHob != NULL);
+ AcpiTableHob->PldHeader.Revision = PLD_ACPI_TABLE_REVISION;
+ AcpiTableHob->PldHeader.Length = sizeof (PLD_ACPI_TABLE);
+ AcpiTableHob->Rsdp = SysTableInfo.AcpiTableBase;
+ DEBUG ((DEBUG_INFO, "Create smbios table gPldAcpiTableGuid guid hob\n"));
+
//
// Create guid hob for acpi board information
//
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
index e7d0d15118..a4c9da128e 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
@@ -32,7 +32,7 @@
#include <Guid/AcpiBoardInfoGuid.h>
#include <Guid/GraphicsInfoHob.h>
#include <UniversalPayload/SmbiosTable.h>
-
+#include <UniversalPayload/AcpiTable.h>
#define LEGACY_8259_MASK_REGISTER_MASTER 0x21
#define LEGACY_8259_MASK_REGISTER_SLAVE 0xA1
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
index 444f39acf3..01388b8831 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
@@ -65,6 +65,7 @@
gEfiGraphicsDeviceInfoHobGuid
gUefiAcpiBoardInfoGuid
gPldSmbiosTableGuid
+ gPldAcpiTableGuid
[FeaturePcd.IA32]
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode ## CONSUMES
diff --git a/UefiPayloadPkg/UefiPayloadPkg.fdf b/UefiPayloadPkg/UefiPayloadPkg.fdf
index 8fc509024b..ed7fbcaddb 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.fdf
+++ b/UefiPayloadPkg/UefiPayloadPkg.fdf
@@ -175,6 +175,10 @@ INF MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
INF MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf
INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
+#
+# ACPI Support
+#
+INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
#
# Shell
--
2.30.0.windows.2
^ permalink raw reply related [flat|nested] 22+ messages in thread