* [edk2-platforms] [PATCH 01/11] MinPlatformPkg: Add BDS Hook Point Guids
2019-12-14 1:32 [edk2-platforms] [PATCH 00/11] Add BDS Hook Points Agyeman, Prince
@ 2019-12-14 1:32 ` Agyeman, Prince
2019-12-16 1:31 ` Chiu, Chasel
` (2 more replies)
2019-12-14 1:32 ` [edk2-platforms] [PATCH 02/11] BoardModulePkg: Add BDS Hook Library Agyeman, Prince
` (10 subsequent siblings)
11 siblings, 3 replies; 45+ messages in thread
From: Agyeman, Prince @ 2019-12-14 1:32 UTC (permalink / raw)
To: devel; +Cc: Michael Kubacki, Chasel Chiu, Nate DeSimone
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
Added BDS hook point guids as defined in the
Minimum Platform specification. These GUIDs
shall be used in the identification of three
of the BDS hook point event groups.
These event groups are Before Console After Trusted,
Before Console Before End Of Dxe and After Console Ready
Before BootOption events.
See https://edk2-docs.gitbooks.io/edk-ii-minimum-platform-specification,
under Appendix A.3 BDS Hook Points, for more details
Cc: Michael Kubacki <michael.a.kubacki@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
---
Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
index 7f74ac9380..5bec4eee3a 100644
--- a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
+++ b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
@@ -46,6 +46,11 @@
gDefaultDataFileGuid = {0x1ae42876, 0x008f, 0x4161, {0xb2, 0xb7, 0x1c, 0x0d, 0x15, 0xc5, 0xef, 0x43}}
gDefaultDataOptSizeFileGuid = {0x003e7b41, 0x98a2, 0x4be2, {0xb2, 0x7a, 0x6c, 0x30, 0xc7, 0x65, 0x52, 0x25}}
+ # BDS Hook point event Guids
+ gBdsEventBeforeConsoleAfterTrustedConsoleGuid = {0x51e49ff5, 0x28a9, 0x4159, { 0xac, 0x8a, 0xb8, 0xc4, 0x88, 0xa7, 0xfd, 0xee}}
+ gBdsEventBeforeConsoleBeforeEndOfDxeGuid = {0xfcf26e41, 0xbda6, 0x4633, { 0xb5, 0x73, 0xd4, 0xb8, 0x0e, 0x6d, 0xd0, 0x78}}
+ gBdsEventAfterConsoleReadyBeforeBootOptionGuid = {0x8eb3d5dc, 0xf4e7, 0x4b57, { 0xa9, 0xe7, 0x27, 0x39, 0x10, 0xf2, 0x18, 0x9f}}
+
[LibraryClasses]
PeiLib|Include/Library/PeiLib.h
--
2.19.1.windows.1
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Re: [edk2-platforms] [PATCH 01/11] MinPlatformPkg: Add BDS Hook Point Guids
2019-12-14 1:32 ` [edk2-platforms] [PATCH 01/11] MinPlatformPkg: Add BDS Hook Point Guids Agyeman, Prince
@ 2019-12-16 1:31 ` Chiu, Chasel
2019-12-16 8:50 ` [edk2-devel] " Ni, Ray
2019-12-18 1:31 ` Nate DeSimone
2019-12-21 2:36 ` Kubacki, Michael A
2 siblings, 1 reply; 45+ messages in thread
From: Chiu, Chasel @ 2019-12-16 1:31 UTC (permalink / raw)
To: Agyeman, Prince, devel@edk2.groups.io
Cc: Kubacki, Michael A, Desimone, Nathaniel L
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
> -----Original Message-----
> From: Agyeman, Prince <prince.agyeman@intel.com>
> Sent: Saturday, December 14, 2019 9:32 AM
> To: devel@edk2.groups.io
> Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Chiu, Chasel
> <chasel.chiu@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>
> Subject: [edk2-platforms] [PATCH 01/11] MinPlatformPkg: Add BDS Hook
> Point Guids
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
>
> Added BDS hook point guids as defined in the Minimum Platform
> specification. These GUIDs shall be used in the identification of three of the
> BDS hook point event groups.
>
> These event groups are Before Console After Trusted, Before Console Before
> End Of Dxe and After Console Ready Before BootOption events.
>
> See https://edk2-docs.gitbooks.io/edk-ii-minimum-platform-specification,
> under Appendix A.3 BDS Hook Points, for more details
>
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
>
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
> Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
> b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
> index 7f74ac9380..5bec4eee3a 100644
> --- a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
> +++ b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
> @@ -46,6 +46,11 @@
> gDefaultDataFileGuid = {0x1ae42876, 0x008f, 0x4161,
> {0xb2, 0xb7, 0x1c, 0x0d, 0x15, 0xc5, 0xef, 0x43}}
> gDefaultDataOptSizeFileGuid = {0x003e7b41, 0x98a2, 0x4be2,
> {0xb2, 0x7a, 0x6c, 0x30, 0xc7, 0x65, 0x52, 0x25}}
>
> + # BDS Hook point event Guids
> + gBdsEventBeforeConsoleAfterTrustedConsoleGuid = {0x51e49ff5,
> 0x28a9, 0x4159, { 0xac, 0x8a, 0xb8, 0xc4, 0x88, 0xa7, 0xfd, 0xee}}
> + gBdsEventBeforeConsoleBeforeEndOfDxeGuid = {0xfcf26e41,
> 0xbda6, 0x4633, { 0xb5, 0x73, 0xd4, 0xb8, 0x0e, 0x6d, 0xd0, 0x78}}
> + gBdsEventAfterConsoleReadyBeforeBootOptionGuid = {0x8eb3d5dc,
> 0xf4e7,
> + 0x4b57, { 0xa9, 0xe7, 0x27, 0x39, 0x10, 0xf2, 0x18, 0x9f}}
> +
> [LibraryClasses]
>
> PeiLib|Include/Library/PeiLib.h
> --
> 2.19.1.windows.1
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [edk2-devel] [edk2-platforms] [PATCH 01/11] MinPlatformPkg: Add BDS Hook Point Guids
2019-12-16 1:31 ` Chiu, Chasel
@ 2019-12-16 8:50 ` Ni, Ray
2019-12-17 23:58 ` Kubacki, Michael A
0 siblings, 1 reply; 45+ messages in thread
From: Ni, Ray @ 2019-12-16 8:50 UTC (permalink / raw)
To: Kubacki, Michael A
Cc: Desimone, Nathaniel L, devel@edk2.groups.io, Chiu, Chasel,
Agyeman, Prince
Using event for callbacks has a limitation: The event callback has to run at TPL >= TPL_CALLBACK.
Some of the services like gBS->LoadImage()/StartImage(), SimpleTextIn->ReadKeyStroke(),
FormBrowser->SendForm() can ONLY be called at TPL_APPLICATION.
So those services cannot be called from the event callback.
Is that ok to the min-platform?
Thanks,
Ray
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Chiu,
> Chasel
> Sent: Monday, December 16, 2019 9:32 AM
> To: Agyeman, Prince <prince.agyeman@intel.com>; devel@edk2.groups.io
> Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Desimone, Nathaniel
> L <nathaniel.l.desimone@intel.com>
> Subject: Re: [edk2-devel] [edk2-platforms] [PATCH 01/11] MinPlatformPkg:
> Add BDS Hook Point Guids
>
>
> Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
>
> > -----Original Message-----
> > From: Agyeman, Prince <prince.agyeman@intel.com>
> > Sent: Saturday, December 14, 2019 9:32 AM
> > To: devel@edk2.groups.io
> > Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Chiu, Chasel
> > <chasel.chiu@intel.com>; Desimone, Nathaniel L
> > <nathaniel.l.desimone@intel.com>
> > Subject: [edk2-platforms] [PATCH 01/11] MinPlatformPkg: Add BDS Hook
> > Point Guids
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
> >
> > Added BDS hook point guids as defined in the Minimum Platform
> > specification. These GUIDs shall be used in the identification of three of the
> > BDS hook point event groups.
> >
> > These event groups are Before Console After Trusted, Before Console
> Before
> > End Of Dxe and After Console Ready Before BootOption events.
> >
> > See https://edk2-docs.gitbooks.io/edk-ii-minimum-platform-specification,
> > under Appendix A.3 BDS Hook Points, for more details
> >
> > Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> > Cc: Chasel Chiu <chasel.chiu@intel.com>
> > Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> >
> > Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> > ---
> > Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
> > b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
> > index 7f74ac9380..5bec4eee3a 100644
> > --- a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
> > +++ b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
> > @@ -46,6 +46,11 @@
> > gDefaultDataFileGuid = {0x1ae42876, 0x008f, 0x4161,
> > {0xb2, 0xb7, 0x1c, 0x0d, 0x15, 0xc5, 0xef, 0x43}}
> > gDefaultDataOptSizeFileGuid = {0x003e7b41, 0x98a2, 0x4be2,
> > {0xb2, 0x7a, 0x6c, 0x30, 0xc7, 0x65, 0x52, 0x25}}
> >
> > + # BDS Hook point event Guids
> > + gBdsEventBeforeConsoleAfterTrustedConsoleGuid = {0x51e49ff5,
> > 0x28a9, 0x4159, { 0xac, 0x8a, 0xb8, 0xc4, 0x88, 0xa7, 0xfd, 0xee}}
> > + gBdsEventBeforeConsoleBeforeEndOfDxeGuid = {0xfcf26e41,
> > 0xbda6, 0x4633, { 0xb5, 0x73, 0xd4, 0xb8, 0x0e, 0x6d, 0xd0, 0x78}}
> > + gBdsEventAfterConsoleReadyBeforeBootOptionGuid = {0x8eb3d5dc,
> > 0xf4e7,
> > + 0x4b57, { 0xa9, 0xe7, 0x27, 0x39, 0x10, 0xf2, 0x18, 0x9f}}
> > +
> > [LibraryClasses]
> >
> > PeiLib|Include/Library/PeiLib.h
> > --
> > 2.19.1.windows.1
>
>
>
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [edk2-devel] [edk2-platforms] [PATCH 01/11] MinPlatformPkg: Add BDS Hook Point Guids
2019-12-16 8:50 ` [edk2-devel] " Ni, Ray
@ 2019-12-17 23:58 ` Kubacki, Michael A
2019-12-18 0:11 ` Ni, Ray
0 siblings, 1 reply; 45+ messages in thread
From: Kubacki, Michael A @ 2019-12-17 23:58 UTC (permalink / raw)
To: Ni, Ray
Cc: Desimone, Nathaniel L, devel@edk2.groups.io, Chiu, Chasel,
Agyeman, Prince
Hi Ray,
There could be usage of SimpleTextIn->ReadKeyStroke () in PlatformBootManagerWaitCallback () and PlatformBootManagerUnableToBoot (). The PlatformBootManagerLib instance introduced in MinPlatformPkg simply forwards those calls to a library instance of BoardBootManagerLib implemented in the board package so they will still be invoked at TPL_APPLICATION.
A specific use case that requires TPL_APPLICATION (the restriction is relatively minimal) has not been identified in the analysis of use cases that led to the event hook points introduced in PlatformBootManagerLib.
Thanks,
Michael
> -----Original Message-----
> From: Ni, Ray <ray.ni@intel.com>
> Sent: Monday, December 16, 2019 12:50 AM
> To: Kubacki, Michael A <michael.a.kubacki@intel.com>
> Cc: Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>;
> devel@edk2.groups.io; Chiu, Chasel <chasel.chiu@intel.com>; Agyeman,
> Prince <prince.agyeman@intel.com>
> Subject: RE: [edk2-devel] [edk2-platforms] [PATCH 01/11] MinPlatformPkg:
> Add BDS Hook Point Guids
>
> Using event for callbacks has a limitation: The event callback has to run at TPL
> >= TPL_CALLBACK.
>
> Some of the services like gBS->LoadImage()/StartImage(), SimpleTextIn-
> >ReadKeyStroke(),
> FormBrowser->SendForm() can ONLY be called at TPL_APPLICATION.
> So those services cannot be called from the event callback.
>
> Is that ok to the min-platform?
>
> Thanks,
> Ray
>
>
> > -----Original Message-----
> > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Chiu,
> > Chasel
> > Sent: Monday, December 16, 2019 9:32 AM
> > To: Agyeman, Prince <prince.agyeman@intel.com>; devel@edk2.groups.io
> > Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Desimone,
> > Nathaniel L <nathaniel.l.desimone@intel.com>
> > Subject: Re: [edk2-devel] [edk2-platforms] [PATCH 01/11] MinPlatformPkg:
> > Add BDS Hook Point Guids
> >
> >
> > Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
> >
> > > -----Original Message-----
> > > From: Agyeman, Prince <prince.agyeman@intel.com>
> > > Sent: Saturday, December 14, 2019 9:32 AM
> > > To: devel@edk2.groups.io
> > > Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Chiu, Chasel
> > > <chasel.chiu@intel.com>; Desimone, Nathaniel L
> > > <nathaniel.l.desimone@intel.com>
> > > Subject: [edk2-platforms] [PATCH 01/11] MinPlatformPkg: Add BDS Hook
> > > Point Guids
> > >
> > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
> > >
> > > Added BDS hook point guids as defined in the Minimum Platform
> > > specification. These GUIDs shall be used in the identification of
> > > three of the BDS hook point event groups.
> > >
> > > These event groups are Before Console After Trusted, Before Console
> > Before
> > > End Of Dxe and After Console Ready Before BootOption events.
> > >
> > > See
> > > https://edk2-docs.gitbooks.io/edk-ii-minimum-platform-specification,
> > > under Appendix A.3 BDS Hook Points, for more details
> > >
> > > Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> > > Cc: Chasel Chiu <chasel.chiu@intel.com>
> > > Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> > >
> > > Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> > > ---
> > > Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec | 5 +++++
> > > 1 file changed, 5 insertions(+)
> > >
> > > diff --git a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
> > > b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
> > > index 7f74ac9380..5bec4eee3a 100644
> > > --- a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
> > > +++ b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
> > > @@ -46,6 +46,11 @@
> > > gDefaultDataFileGuid = {0x1ae42876, 0x008f, 0x4161,
> > > {0xb2, 0xb7, 0x1c, 0x0d, 0x15, 0xc5, 0xef, 0x43}}
> > > gDefaultDataOptSizeFileGuid = {0x003e7b41, 0x98a2, 0x4be2,
> > > {0xb2, 0x7a, 0x6c, 0x30, 0xc7, 0x65, 0x52, 0x25}}
> > >
> > > + # BDS Hook point event Guids
> > > + gBdsEventBeforeConsoleAfterTrustedConsoleGuid = {0x51e49ff5,
> > > 0x28a9, 0x4159, { 0xac, 0x8a, 0xb8, 0xc4, 0x88, 0xa7, 0xfd, 0xee}}
> > > + gBdsEventBeforeConsoleBeforeEndOfDxeGuid = {0xfcf26e41,
> > > 0xbda6, 0x4633, { 0xb5, 0x73, 0xd4, 0xb8, 0x0e, 0x6d, 0xd0, 0x78}}
> > > + gBdsEventAfterConsoleReadyBeforeBootOptionGuid = {0x8eb3d5dc,
> > > 0xf4e7,
> > > + 0x4b57, { 0xa9, 0xe7, 0x27, 0x39, 0x10, 0xf2, 0x18, 0x9f}}
> > > +
> > > [LibraryClasses]
> > >
> > > PeiLib|Include/Library/PeiLib.h
> > > --
> > > 2.19.1.windows.1
> >
> >
> >
>
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [edk2-devel] [edk2-platforms] [PATCH 01/11] MinPlatformPkg: Add BDS Hook Point Guids
2019-12-17 23:58 ` Kubacki, Michael A
@ 2019-12-18 0:11 ` Ni, Ray
0 siblings, 0 replies; 45+ messages in thread
From: Ni, Ray @ 2019-12-18 0:11 UTC (permalink / raw)
To: Kubacki, Michael A
Cc: Desimone, Nathaniel L, devel@edk2.groups.io, Chiu, Chasel,
Agyeman, Prince
Michael,
I had misunderstanding earlier. Thanks for the explanation.
Thanks,
Ray
> -----Original Message-----
> From: Kubacki, Michael A <michael.a.kubacki@intel.com>
> Sent: Wednesday, December 18, 2019 7:58 AM
> To: Ni, Ray <ray.ni@intel.com>
> Cc: Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; devel@edk2.groups.io; Chiu, Chasel
> <chasel.chiu@intel.com>; Agyeman, Prince <prince.agyeman@intel.com>
> Subject: RE: [edk2-devel] [edk2-platforms] [PATCH 01/11] MinPlatformPkg: Add BDS Hook Point Guids
>
> Hi Ray,
>
> There could be usage of SimpleTextIn->ReadKeyStroke () in PlatformBootManagerWaitCallback () and
> PlatformBootManagerUnableToBoot (). The PlatformBootManagerLib instance introduced in MinPlatformPkg simply
> forwards those calls to a library instance of BoardBootManagerLib implemented in the board package so they will still be
> invoked at TPL_APPLICATION.
>
> A specific use case that requires TPL_APPLICATION (the restriction is relatively minimal) has not been identified in the
> analysis of use cases that led to the event hook points introduced in PlatformBootManagerLib.
>
> Thanks,
> Michael
>
> > -----Original Message-----
> > From: Ni, Ray <ray.ni@intel.com>
> > Sent: Monday, December 16, 2019 12:50 AM
> > To: Kubacki, Michael A <michael.a.kubacki@intel.com>
> > Cc: Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>;
> > devel@edk2.groups.io; Chiu, Chasel <chasel.chiu@intel.com>; Agyeman,
> > Prince <prince.agyeman@intel.com>
> > Subject: RE: [edk2-devel] [edk2-platforms] [PATCH 01/11] MinPlatformPkg:
> > Add BDS Hook Point Guids
> >
> > Using event for callbacks has a limitation: The event callback has to run at TPL
> > >= TPL_CALLBACK.
> >
> > Some of the services like gBS->LoadImage()/StartImage(), SimpleTextIn-
> > >ReadKeyStroke(),
> > FormBrowser->SendForm() can ONLY be called at TPL_APPLICATION.
> > So those services cannot be called from the event callback.
> >
> > Is that ok to the min-platform?
> >
> > Thanks,
> > Ray
> >
> >
> > > -----Original Message-----
> > > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Chiu,
> > > Chasel
> > > Sent: Monday, December 16, 2019 9:32 AM
> > > To: Agyeman, Prince <prince.agyeman@intel.com>; devel@edk2.groups.io
> > > Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Desimone,
> > > Nathaniel L <nathaniel.l.desimone@intel.com>
> > > Subject: Re: [edk2-devel] [edk2-platforms] [PATCH 01/11] MinPlatformPkg:
> > > Add BDS Hook Point Guids
> > >
> > >
> > > Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
> > >
> > > > -----Original Message-----
> > > > From: Agyeman, Prince <prince.agyeman@intel.com>
> > > > Sent: Saturday, December 14, 2019 9:32 AM
> > > > To: devel@edk2.groups.io
> > > > Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Chiu, Chasel
> > > > <chasel.chiu@intel.com>; Desimone, Nathaniel L
> > > > <nathaniel.l.desimone@intel.com>
> > > > Subject: [edk2-platforms] [PATCH 01/11] MinPlatformPkg: Add BDS Hook
> > > > Point Guids
> > > >
> > > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
> > > >
> > > > Added BDS hook point guids as defined in the Minimum Platform
> > > > specification. These GUIDs shall be used in the identification of
> > > > three of the BDS hook point event groups.
> > > >
> > > > These event groups are Before Console After Trusted, Before Console
> > > Before
> > > > End Of Dxe and After Console Ready Before BootOption events.
> > > >
> > > > See
> > > > https://edk2-docs.gitbooks.io/edk-ii-minimum-platform-specification,
> > > > under Appendix A.3 BDS Hook Points, for more details
> > > >
> > > > Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> > > > Cc: Chasel Chiu <chasel.chiu@intel.com>
> > > > Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> > > >
> > > > Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> > > > ---
> > > > Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec | 5 +++++
> > > > 1 file changed, 5 insertions(+)
> > > >
> > > > diff --git a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
> > > > b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
> > > > index 7f74ac9380..5bec4eee3a 100644
> > > > --- a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
> > > > +++ b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
> > > > @@ -46,6 +46,11 @@
> > > > gDefaultDataFileGuid = {0x1ae42876, 0x008f, 0x4161,
> > > > {0xb2, 0xb7, 0x1c, 0x0d, 0x15, 0xc5, 0xef, 0x43}}
> > > > gDefaultDataOptSizeFileGuid = {0x003e7b41, 0x98a2, 0x4be2,
> > > > {0xb2, 0x7a, 0x6c, 0x30, 0xc7, 0x65, 0x52, 0x25}}
> > > >
> > > > + # BDS Hook point event Guids
> > > > + gBdsEventBeforeConsoleAfterTrustedConsoleGuid = {0x51e49ff5,
> > > > 0x28a9, 0x4159, { 0xac, 0x8a, 0xb8, 0xc4, 0x88, 0xa7, 0xfd, 0xee}}
> > > > + gBdsEventBeforeConsoleBeforeEndOfDxeGuid = {0xfcf26e41,
> > > > 0xbda6, 0x4633, { 0xb5, 0x73, 0xd4, 0xb8, 0x0e, 0x6d, 0xd0, 0x78}}
> > > > + gBdsEventAfterConsoleReadyBeforeBootOptionGuid = {0x8eb3d5dc,
> > > > 0xf4e7,
> > > > + 0x4b57, { 0xa9, 0xe7, 0x27, 0x39, 0x10, 0xf2, 0x18, 0x9f}}
> > > > +
> > > > [LibraryClasses]
> > > >
> > > > PeiLib|Include/Library/PeiLib.h
> > > > --
> > > > 2.19.1.windows.1
> > >
> > >
> > >
> >
>
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [edk2-platforms] [PATCH 01/11] MinPlatformPkg: Add BDS Hook Point Guids
2019-12-14 1:32 ` [edk2-platforms] [PATCH 01/11] MinPlatformPkg: Add BDS Hook Point Guids Agyeman, Prince
2019-12-16 1:31 ` Chiu, Chasel
@ 2019-12-18 1:31 ` Nate DeSimone
2019-12-21 2:36 ` Kubacki, Michael A
2 siblings, 0 replies; 45+ messages in thread
From: Nate DeSimone @ 2019-12-18 1:31 UTC (permalink / raw)
To: Agyeman, Prince; +Cc: devel@edk2.groups.io, Kubacki, Michael A, Chiu, Chasel
Hi Prince,
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
Thanks,
Nate
On Sat, Dec 14, 2019 at 01:32:27AM +0000, Agyeman, Prince wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
>
> Added BDS hook point guids as defined in the
> Minimum Platform specification. These GUIDs
> shall be used in the identification of three
> of the BDS hook point event groups.
>
> These event groups are Before Console After Trusted,
> Before Console Before End Of Dxe and After Console Ready
> Before BootOption events.
>
> See https://edk2-docs.gitbooks.io/edk-ii-minimum-platform-specification,
> under Appendix A.3 BDS Hook Points, for more details
>
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
>
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
> Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
> index 7f74ac9380..5bec4eee3a 100644
> --- a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
> +++ b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
> @@ -46,6 +46,11 @@
> gDefaultDataFileGuid = {0x1ae42876, 0x008f, 0x4161, {0xb2, 0xb7, 0x1c, 0x0d, 0x15, 0xc5, 0xef, 0x43}}
> gDefaultDataOptSizeFileGuid = {0x003e7b41, 0x98a2, 0x4be2, {0xb2, 0x7a, 0x6c, 0x30, 0xc7, 0x65, 0x52, 0x25}}
>
> + # BDS Hook point event Guids
> + gBdsEventBeforeConsoleAfterTrustedConsoleGuid = {0x51e49ff5, 0x28a9, 0x4159, { 0xac, 0x8a, 0xb8, 0xc4, 0x88, 0xa7, 0xfd, 0xee}}
> + gBdsEventBeforeConsoleBeforeEndOfDxeGuid = {0xfcf26e41, 0xbda6, 0x4633, { 0xb5, 0x73, 0xd4, 0xb8, 0x0e, 0x6d, 0xd0, 0x78}}
> + gBdsEventAfterConsoleReadyBeforeBootOptionGuid = {0x8eb3d5dc, 0xf4e7, 0x4b57, { 0xa9, 0xe7, 0x27, 0x39, 0x10, 0xf2, 0x18, 0x9f}}
> +
> [LibraryClasses]
>
> PeiLib|Include/Library/PeiLib.h
> --
> 2.19.1.windows.1
>
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [edk2-platforms] [PATCH 01/11] MinPlatformPkg: Add BDS Hook Point Guids
2019-12-14 1:32 ` [edk2-platforms] [PATCH 01/11] MinPlatformPkg: Add BDS Hook Point Guids Agyeman, Prince
2019-12-16 1:31 ` Chiu, Chasel
2019-12-18 1:31 ` Nate DeSimone
@ 2019-12-21 2:36 ` Kubacki, Michael A
2 siblings, 0 replies; 45+ messages in thread
From: Kubacki, Michael A @ 2019-12-21 2:36 UTC (permalink / raw)
To: Agyeman, Prince, devel@edk2.groups.io; +Cc: Chiu, Chasel, Desimone, Nathaniel L
Reviewed-by: Michael Kubacki <michael.a.kubacki@intel.com>
> -----Original Message-----
> From: Agyeman, Prince <prince.agyeman@intel.com>
> Sent: Friday, December 13, 2019 5:32 PM
> To: devel@edk2.groups.io
> Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Chiu, Chasel
> <chasel.chiu@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>
> Subject: [edk2-platforms] [PATCH 01/11] MinPlatformPkg: Add BDS Hook
> Point Guids
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
>
> Added BDS hook point guids as defined in the Minimum Platform
> specification. These GUIDs shall be used in the identification of three of the
> BDS hook point event groups.
>
> These event groups are Before Console After Trusted, Before Console
> Before End Of Dxe and After Console Ready Before BootOption events.
>
> See https://edk2-docs.gitbooks.io/edk-ii-minimum-platform-specification,
> under Appendix A.3 BDS Hook Points, for more details
>
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
>
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
> Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
> b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
> index 7f74ac9380..5bec4eee3a 100644
> --- a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
> +++ b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
> @@ -46,6 +46,11 @@
> gDefaultDataFileGuid = {0x1ae42876, 0x008f, 0x4161, {0xb2, 0xb7,
> 0x1c, 0x0d, 0x15, 0xc5, 0xef, 0x43}}
> gDefaultDataOptSizeFileGuid = {0x003e7b41, 0x98a2, 0x4be2, {0xb2,
> 0x7a, 0x6c, 0x30, 0xc7, 0x65, 0x52, 0x25}}
>
> + # BDS Hook point event Guids
> + gBdsEventBeforeConsoleAfterTrustedConsoleGuid = {0x51e49ff5, 0x28a9,
> 0x4159, { 0xac, 0x8a, 0xb8, 0xc4, 0x88, 0xa7, 0xfd, 0xee}}
> + gBdsEventBeforeConsoleBeforeEndOfDxeGuid = {0xfcf26e41, 0xbda6,
> 0x4633, { 0xb5, 0x73, 0xd4, 0xb8, 0x0e, 0x6d, 0xd0, 0x78}}
> + gBdsEventAfterConsoleReadyBeforeBootOptionGuid = {0x8eb3d5dc,
> 0xf4e7,
> + 0x4b57, { 0xa9, 0xe7, 0x27, 0x39, 0x10, 0xf2, 0x18, 0x9f}}
> +
> [LibraryClasses]
>
> PeiLib|Include/Library/PeiLib.h
> --
> 2.19.1.windows.1
^ permalink raw reply [flat|nested] 45+ messages in thread
* [edk2-platforms] [PATCH 02/11] BoardModulePkg: Add BDS Hook Library
2019-12-14 1:32 [edk2-platforms] [PATCH 00/11] Add BDS Hook Points Agyeman, Prince
2019-12-14 1:32 ` [edk2-platforms] [PATCH 01/11] MinPlatformPkg: Add BDS Hook Point Guids Agyeman, Prince
@ 2019-12-14 1:32 ` Agyeman, Prince
2019-12-18 1:19 ` Nate DeSimone
2019-12-21 2:36 ` Kubacki, Michael A
2019-12-14 1:32 ` [edk2-platforms] [PATCH 03/11] BoardModulePkg: Add BDS Hook DXE Driver Agyeman, Prince
` (9 subsequent siblings)
11 siblings, 2 replies; 45+ messages in thread
From: Agyeman, Prince @ 2019-12-14 1:32 UTC (permalink / raw)
To: devel; +Cc: Michael Kubacki, Chasel Chiu, Nate DeSimone
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
Added a generic board BDS hook library that implements
BDS hook points as defined in the Minimum platform specification.
This library implements callbacks for the three MinPlatformPkg
BDS event groups, namely gBdsEventBeforeConsoleAfterTrustedConsoleGuid,
gBdsEventBeforeConsoleBeforeEndOfDxeGuid and
gBdsEventAfterConsoleReadyBeforeBootOptionGuid.
This Library also implements callbacks for pre-existing event groups:
gEfiEndOfDxeEventGroupGuid, gEfiPciEnumerationCompleteProtocolGuid,
gEfiDxeSmmReadyToLockProtocolGuid.
These callbacks can be registered to their respective event groups,
through other libraries or DXE drivers
Cc: Michael Kubacki <michael.a.kubacki@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
---
.../Include/Library/BoardBdsHookLib.h | 100 ++
.../Library/BoardBdsHookLib/BoardBdsHook.h | 211 +++
.../Library/BoardBdsHookLib/BoardBdsHookLib.c | 1390 +++++++++++++++++
.../BoardBdsHookLib/BoardBdsHookLib.inf | 95 ++
.../Library/BoardBdsHookLib/BoardBootOption.c | 598 +++++++
.../Library/BoardBdsHookLib/BoardMemoryTest.c | 83 +
6 files changed, 2477 insertions(+)
create mode 100644 Platform/Intel/BoardModulePkg/Include/Library/BoardBdsHookLib.h
create mode 100644 Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook.h
create mode 100644 Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
create mode 100644 Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
create mode 100644 Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBootOption.c
create mode 100644 Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardMemoryTest.c
diff --git a/Platform/Intel/BoardModulePkg/Include/Library/BoardBdsHookLib.h b/Platform/Intel/BoardModulePkg/Include/Library/BoardBdsHookLib.h
new file mode 100644
index 0000000000..ba351b7bf4
--- /dev/null
+++ b/Platform/Intel/BoardModulePkg/Include/Library/BoardBdsHookLib.h
@@ -0,0 +1,100 @@
+/** @file
+Header file for BDS Hook Library
+
+Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _BDS_HOOK_LIB_H_
+#define _BDS_HOOK_LIB_H_
+
+#include <Library/UefiLib.h>
+
+
+/**
+ This is the callback function for Bds Ready To Boot event.
+
+ @param Event Pointer to this event
+ @param Context Event hanlder private data
+
+ @retval None.
+**/
+VOID
+EFIAPI
+BdsReadyToBootCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ );
+
+
+/**
+ This is the callback function for Smm Ready To Lock event.
+
+ @param[in] Event The Event this notify function registered to.
+ @param[in] Context Pointer to the context data registered to the Event.
+**/
+VOID
+EFIAPI
+BdsSmmReadyToLockCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ );
+
+
+/**
+ This is the callback function for PCI ENUMERATION COMPLETE.
+
+ @param[in] Event The Event this notify function registered to.
+ @param[in] Context Pointer to the context data registered to the Event.
+**/
+VOID
+EFIAPI
+BdsPciEnumCompleteCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ );
+
+
+/**
+ Before console after trusted console event callback
+
+ @param[in] Event The Event this notify function registered to.
+ @param[in] Context Pointer to the context data registered to the Event.
+**/
+VOID
+EFIAPI
+BdsBeforeConsoleAfterTrustedConsoleCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ );
+
+
+/**
+ Before console before end of DXE event callback
+
+ @param[in] Event The Event this notify function registered to.
+ @param[in] Context Pointer to the context data registered to the Event.
+**/
+VOID
+EFIAPI
+BdsBeforeConsoleBeforeEndOfDxeGuidCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ );
+
+
+/**
+ After console ready before boot option event callback
+
+ @param[in] Event The Event this notify function registered to.
+ @param[in] Context Pointer to the context data registered to the Event.
+**/
+VOID
+EFIAPI
+BdsAfterConsoleReadyBeforeBootOptionCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ );
+
+#endif
diff --git a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook.h b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook.h
new file mode 100644
index 0000000000..748385499b
--- /dev/null
+++ b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook.h
@@ -0,0 +1,211 @@
+/** @file
+ Header file for BDS Hook Library
+
+Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _BDS_HOOK_H_
+#define _BDS_HOOK_H_
+
+#include <PiDxe.h>
+#include <Protocol/DevicePath.h>
+#include <Protocol/SimpleNetwork.h>
+#include <Protocol/PciRootBridgeIo.h>
+#include <Protocol/LoadFile.h>
+#include <Protocol/PciIo.h>
+#include <Protocol/CpuIo2.h>
+#include <Protocol/LoadedImage.h>
+#include <Protocol/DiskInfo.h>
+#include <Protocol/GraphicsOutput.h>
+#include <Protocol/UgaDraw.h>
+#include <Protocol/GenericMemoryTest.h>
+#include <Protocol/DevicePathToText.h>
+#include <Protocol/FirmwareVolume2.h>
+#include <Protocol/SimpleFileSystem.h>
+
+#include <Guid/CapsuleVendor.h>
+#include <Guid/MemoryTypeInformation.h>
+#include <Guid/GlobalVariable.h>
+#include <Guid/MemoryOverwriteControl.h>
+#include <Guid/FileInfo.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/BaseLib.h>
+#include <Library/PcdLib.h>
+#include <Library/PlatformBootManagerLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/UefiLib.h>
+#include <Library/HobLib.h>
+#include <Library/DxeServicesLib.h>
+#include <Library/DxeServicesTableLib.h>
+#include <Library/PrintLib.h>
+#include <Library/HiiLib.h>
+#include <Library/CapsuleLib.h>
+#include <Library/PerformanceLib.h>
+
+#include <IndustryStandard/Pci30.h>
+#include <IndustryStandard/PciCodeId.h>
+#include <Protocol/PciEnumerationComplete.h>
+
+///
+/// ConnectType
+///
+#define CONSOLE_OUT 0x00000001
+#define STD_ERROR 0x00000002
+#define CONSOLE_IN 0x00000004
+#define CONSOLE_ALL (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)
+
+extern EFI_GUID gUefiShellFileGuid;
+extern EFI_BOOT_MODE gBootMode;
+
+#define gPciRootBridge \
+ { \
+ { \
+ ACPI_DEVICE_PATH, \
+ ACPI_DP, \
+ { \
+ (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \
+ (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \
+ }, \
+ }, \
+ EISA_PNP_ID (0x0A03), \
+ 0 \
+ }
+
+#define gEndEntire \
+ { \
+ END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { END_DEVICE_PATH_LENGTH, 0 } \
+ }
+
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ UINTN ConnectType;
+} BDS_CONSOLE_CONNECT_ENTRY;
+
+//
+// Platform Root Bridge
+//
+typedef struct {
+ ACPI_HID_DEVICE_PATH PciRootBridge;
+ EFI_DEVICE_PATH_PROTOCOL End;
+} PLATFORM_ROOT_BRIDGE_DEVICE_PATH;
+
+//
+// Below is the platform console device path
+//
+typedef struct {
+ ACPI_HID_DEVICE_PATH PciRootBridge;
+ PCI_DEVICE_PATH IsaBridge;
+ ACPI_HID_DEVICE_PATH Keyboard;
+ EFI_DEVICE_PATH_PROTOCOL End;
+} PLATFORM_KEYBOARD_DEVICE_PATH;
+
+typedef struct {
+ ACPI_HID_DEVICE_PATH PciRootBridge;
+ PCI_DEVICE_PATH PciDevice;
+ EFI_DEVICE_PATH_PROTOCOL End;
+} PLATFORM_ONBOARD_CONTROLLER_DEVICE_PATH;
+
+typedef struct {
+ ACPI_HID_DEVICE_PATH PciRootBridge;
+ PCI_DEVICE_PATH Pci0Device;
+ EFI_DEVICE_PATH_PROTOCOL End;
+} PLATFORM_PEG_ROOT_CONTROLLER_DEVICE_PATH;
+
+typedef struct {
+ ACPI_HID_DEVICE_PATH PciRootBridge;
+ PCI_DEVICE_PATH PciBridge;
+ PCI_DEVICE_PATH PciDevice;
+ EFI_DEVICE_PATH_PROTOCOL End;
+} PLATFORM_PCI_CONTROLLER_DEVICE_PATH;
+
+//
+// Below is the boot option device path
+//
+
+#define CLASS_HID 3
+#define SUBCLASS_BOOT 1
+#define PROTOCOL_KEYBOARD 1
+
+typedef struct {
+ USB_CLASS_DEVICE_PATH UsbClass;
+ EFI_DEVICE_PATH_PROTOCOL End;
+} USB_CLASS_FORMAT_DEVICE_PATH;
+
+extern USB_CLASS_FORMAT_DEVICE_PATH gUsbClassKeyboardDevicePath;
+
+//
+// Platform BDS Functions
+//
+
+
+/**
+ Perform the memory test base on the memory test intensive level,
+ and update the memory resource.
+
+ @param Level The memory test intensive level.
+
+ @retval EFI_STATUS Success test all the system memory and update
+ the memory resource
+
+**/
+EFI_STATUS
+MemoryTest (
+ IN EXTENDMEM_COVERAGE_LEVEL Level
+ );
+
+/**
+ Connect with predeined platform connect sequence,
+ the OEM/IBV can customize with their own connect sequence.
+
+ @param[in] BootMode Boot mode of this boot.
+**/
+VOID
+ConnectSequence (
+ IN EFI_BOOT_MODE BootMode
+ );
+
+
+/**
+ Compares boot priorities of two boot options
+
+ @param Left The left boot option
+ @param Right The right boot option
+
+ @return The difference between the Left and Right
+ boot options
+ **/
+INTN
+EFIAPI
+CompareBootOption (
+ CONST VOID *Left,
+ CONST VOID *Right
+ );
+
+/**
+ This function is called after all the boot options are enumerated and ordered properly.
+**/
+VOID
+RegisterStaticHotkey (
+ VOID
+ );
+
+
+/**
+ Registers/Unregisters boot option hotkey
+
+ @param OptionNumber The boot option number for the key option.
+ @param Key The the key input
+ @param Add Flag to indicate to add or remove a key
+**/
+VOID
+RegisterDefaultBootOption (
+ VOID
+ );
+
+#endif
diff --git a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.c b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
new file mode 100644
index 0000000000..9d42a8c27f
--- /dev/null
+++ b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
@@ -0,0 +1,1390 @@
+/** @file
+ This library registers Bds callbacks. It is a default library
+ implementation instance of the BDS hook library
+
+ Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Guid/EventGroup.h>
+
+#include <Library/IoLib.h>
+#include <Library/PciLib.h>
+#include <Library/UefiBootManagerLib.h>
+#include <Library/Tcg2PhysicalPresenceLib.h>
+
+#include <Protocol/BlockIo.h>
+#include <Protocol/UsbIo.h>
+#include <Protocol/PciEnumerationComplete.h>
+
+#include "BoardBdsHook.h"
+
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_BOOT_MODE gBootMode;
+BOOLEAN gPPRequireUIConfirm;
+extern UINTN mBootMenuOptionNumber;
+
+
+GLOBAL_REMOVE_IF_UNREFERENCED USB_CLASS_FORMAT_DEVICE_PATH gUsbClassKeyboardDevicePath = {
+ {
+ {
+ MESSAGING_DEVICE_PATH,
+ MSG_USB_CLASS_DP,
+ {
+ (UINT8) (sizeof (USB_CLASS_DEVICE_PATH)),
+ (UINT8) ((sizeof (USB_CLASS_DEVICE_PATH)) >> 8)
+ }
+ },
+ 0xffff, // VendorId
+ 0xffff, // ProductId
+ CLASS_HID, // DeviceClass
+ SUBCLASS_BOOT, // DeviceSubClass
+ PROTOCOL_KEYBOARD // DeviceProtocol
+ },
+ gEndEntire
+};
+
+
+//
+// BDS Platform Functions
+//
+BOOLEAN
+IsMorBitSet (
+ VOID
+ )
+{
+ UINTN MorControl;
+ EFI_STATUS Status;
+ UINTN DataSize;
+
+ //
+ // Check if the MOR bit is set.
+ //
+ DataSize = sizeof (MorControl);
+ Status = gRT->GetVariable (
+ MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME,
+ &gEfiMemoryOverwriteControlDataGuid,
+ NULL,
+ &DataSize,
+ &MorControl
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_INFO, " gEfiMemoryOverwriteControlDataGuid doesn't exist!!***\n"));
+ MorControl = 0;
+ } else {
+ DEBUG ((DEBUG_INFO, " Get the gEfiMemoryOverwriteControlDataGuid = %x!!***\n", MorControl));
+ }
+
+ return (BOOLEAN) (MorControl & 0x01);
+}
+
+
+/**
+ Prints device paths.
+ @param Name The device name.
+ @param DevicePath The device path to be printed
+**/
+VOID
+EFIAPI
+DumpDevicePath (
+ IN CHAR16 *Name,
+ IN EFI_DEVICE_PATH *DevicePath
+ )
+{
+ CHAR16 *Str;
+ Str = ConvertDevicePathToText (DevicePath, TRUE, TRUE);
+ DEBUG ((DEBUG_INFO, "%s: %s\n", Name, Str));
+ if (Str != NULL) {
+ FreePool (Str);
+ }
+}
+
+/**
+ Return whether the device is trusted console.
+
+ @param Device The device to be tested.
+
+ @retval TRUE The device can be trusted.
+ @retval FALSE The device cannot be trusted.
+**/
+BOOLEAN
+IsTrustedConsole (
+ IN CONSOLE_TYPE ConsoleType,
+ IN EFI_DEVICE_PATH_PROTOCOL *Device
+ )
+{
+ VOID *TrustedConsoleDevicepath;
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *Instance;
+ UINTN Size;
+ EFI_DEVICE_PATH_PROTOCOL *ConsoleDevice;
+
+ if (Device == NULL) {
+ return FALSE;
+ }
+
+ ConsoleDevice = DuplicateDevicePath (Device);
+
+ TrustedConsoleDevicepath = NULL;
+
+ switch (ConsoleType) {
+ case ConIn:
+ TrustedConsoleDevicepath = PcdGetPtr (PcdTrustedConsoleInputDevicePath);
+ break;
+ case ConOut:
+ //
+ // Check GOP and remove last node
+ //
+ TempDevicePath = ConsoleDevice;
+ while (!IsDevicePathEndType (TempDevicePath)) {
+ if (DevicePathType (TempDevicePath) == ACPI_DEVICE_PATH &&
+ DevicePathSubType (TempDevicePath) == ACPI_ADR_DP) {
+ SetDevicePathEndNode (TempDevicePath);
+ break;
+ }
+ TempDevicePath = NextDevicePathNode (TempDevicePath);
+ }
+
+ TrustedConsoleDevicepath = PcdGetPtr (PcdTrustedConsoleOutputDevicePath);
+ break;
+ default:
+ ASSERT (FALSE);
+ break;
+ }
+
+ TempDevicePath = TrustedConsoleDevicepath;
+ do {
+ Instance = GetNextDevicePathInstance (&TempDevicePath, &Size);
+ if (Instance == NULL) {
+ break;
+ }
+
+ if (CompareMem (ConsoleDevice, Instance, Size - END_DEVICE_PATH_LENGTH) == 0) {
+ FreePool (Instance);
+ FreePool (ConsoleDevice);
+ return TRUE;
+ }
+
+ FreePool (Instance);
+ } while (TempDevicePath != NULL);
+
+ FreePool (ConsoleDevice);
+
+ return FALSE;
+}
+
+
+/**
+ Return whether the USB device path is in a short form.
+
+ @param DevicePath The device path to be tested.
+
+ @retval TRUE The device path is in short form.
+ @retval FALSE The device path is not in short form.
+**/
+BOOLEAN
+IsUsbShortForm (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+{
+ if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&
+ ((DevicePathSubType (DevicePath) == MSG_USB_CLASS_DP) ||
+ (DevicePathSubType (DevicePath) == MSG_USB_WWID_DP)) ) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/**
+ Connect the USB short form device path.
+
+ @param DevicePath USB short form device path
+
+ @retval EFI_SUCCESS Successfully connected the USB device
+ @retval EFI_NOT_FOUND Cannot connect the USB device
+ @retval EFI_INVALID_PARAMETER The device path is invalid.
+**/
+EFI_STATUS
+ConnectUsbShortFormDevicePath (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+{
+ EFI_STATUS Status;
+ EFI_HANDLE *Handles;
+ UINTN HandleCount;
+ UINTN Index;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ UINT8 Class[3];
+ BOOLEAN AtLeastOneConnected;
+
+ //
+ // Check the passed in parameters
+ //
+ if (DevicePath == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (!IsUsbShortForm (DevicePath)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Find the usb host controller firstly, then connect with the remaining device path
+ //
+ AtLeastOneConnected = FALSE;
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiPciIoProtocolGuid,
+ NULL,
+ &HandleCount,
+ &Handles
+ );
+ for (Index = 0; Index < HandleCount; Index++) {
+ Status = gBS->HandleProtocol (
+ Handles[Index],
+ &gEfiPciIoProtocolGuid,
+ (VOID **) &PciIo
+ );
+ if (!EFI_ERROR (Status)) {
+ //
+ // Check whether the Pci device is the wanted usb host controller
+ //
+ Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0x09, 3, &Class);
+ if (!EFI_ERROR (Status) &&
+ ((PCI_CLASS_SERIAL == Class[2]) && (PCI_CLASS_SERIAL_USB == Class[1]))) {
+ Status = gBS->ConnectController (
+ Handles[Index],
+ NULL,
+ DevicePath,
+ FALSE
+ );
+ if (!EFI_ERROR(Status)) {
+ AtLeastOneConnected = TRUE;
+ }
+ }
+ }
+ }
+
+ return AtLeastOneConnected ? EFI_SUCCESS : EFI_NOT_FOUND;
+}
+
+
+/**
+ Return whether the Handle is a vga handle.
+
+ @param Handle The handle to be tested.
+
+ @retval TRUE The handle is a vga handle.
+ @retval FALSE The handle is not a vga handle..
+**/
+BOOLEAN
+IsVgaHandle (
+ IN EFI_HANDLE Handle
+ )
+{
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ PCI_TYPE00 Pci;
+ EFI_STATUS Status;
+
+ Status = gBS->HandleProtocol (
+ Handle,
+ &gEfiPciIoProtocolGuid,
+ (VOID **)&PciIo
+ );
+ if (!EFI_ERROR (Status)) {
+ Status = PciIo->Pci.Read (
+ PciIo,
+ EfiPciIoWidthUint32,
+ 0,
+ sizeof (Pci) / sizeof (UINT32),
+ &Pci
+ );
+ if (!EFI_ERROR (Status)) {
+ if (IS_PCI_VGA (&Pci) || IS_PCI_OLD_VGA (&Pci)) {
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+
+
+/**
+ Return whether the device path points to a video controller.
+
+ @param DevicePath The device path to be tested.
+
+ @retval TRUE The device path points to a video controller.
+ @retval FALSE The device path does not point to a video controller.
+**/
+EFI_HANDLE
+IsVideoController (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+{
+ EFI_DEVICE_PATH_PROTOCOL *DupDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
+ EFI_STATUS Status;
+ EFI_HANDLE DeviceHandle;
+
+ DupDevicePath = DuplicateDevicePath (DevicePath);
+ ASSERT (DupDevicePath != NULL);
+ if (DupDevicePath == NULL) {
+ return NULL;
+ }
+
+ TempDevicePath = DupDevicePath;
+ Status = gBS->LocateDevicePath (
+ &gEfiDevicePathProtocolGuid,
+ &TempDevicePath,
+ &DeviceHandle
+ );
+ FreePool (DupDevicePath);
+ if (EFI_ERROR (Status)) {
+ return NULL;
+ }
+
+ if (IsVgaHandle (DeviceHandle)) {
+ return DeviceHandle;
+ } else {
+ return NULL;
+ }
+}
+
+
+/**
+ Return whether the device path is a GOP device path.
+
+ @param DevicePath The device path to be tested.
+
+ @retval TRUE The device path is a GOP device path.
+ @retval FALSE The device on the device path is not a GOP device path.
+**/
+BOOLEAN
+IsGopDevicePath (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+{
+ while (!IsDevicePathEndType (DevicePath)) {
+ if (DevicePathType (DevicePath) == ACPI_DEVICE_PATH &&
+ DevicePathSubType (DevicePath) == ACPI_ADR_DP) {
+ return TRUE;
+ }
+ DevicePath = NextDevicePathNode (DevicePath);
+ }
+ return FALSE;
+}
+
+
+/**
+ Remove all GOP device path instance from DevicePath and add the Gop to the DevicePath.
+
+ @param DevicePath The device path to be removed
+ @param Gop The device path to be added.
+
+ @retval Return The updated device path.
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+UpdateGopDevicePath (
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ EFI_DEVICE_PATH_PROTOCOL *Gop
+ )
+{
+ UINTN Size;
+ UINTN GopSize;
+ EFI_DEVICE_PATH_PROTOCOL *Temp;
+ EFI_DEVICE_PATH_PROTOCOL *Return;
+ EFI_DEVICE_PATH_PROTOCOL *Instance;
+ BOOLEAN Exist;
+
+ Exist = FALSE;
+ Return = NULL;
+ GopSize = GetDevicePathSize (Gop);
+ do {
+ Instance = GetNextDevicePathInstance (&DevicePath, &Size);
+ if (Instance == NULL) {
+ break;
+ }
+ if (!IsGopDevicePath (Instance) ||
+ (Size == GopSize && CompareMem (Instance, Gop, GopSize) == 0)
+ ) {
+ if (Size == GopSize && CompareMem (Instance, Gop, GopSize) == 0) {
+ Exist = TRUE;
+ }
+ Temp = Return;
+ Return = AppendDevicePathInstance (Return, Instance);
+ if (Temp != NULL) {
+ FreePool (Temp);
+ }
+ }
+ FreePool (Instance);
+ } while (DevicePath != NULL);
+
+ if (!Exist) {
+ Temp = Return;
+ Return = AppendDevicePathInstance (Return, Gop);
+ if (Temp != NULL) {
+ FreePool (Temp);
+ }
+ }
+ return Return;
+}
+
+
+/**
+ Get Graphics Controller Handle.
+
+ @param NeedTrustedConsole The flag to determine if trusted console
+ or non trusted console should be returned
+
+ @retval NULL Console not found
+ @retval PciHandles Successfully located
+**/
+EFI_HANDLE
+EFIAPI
+GetGraphicsController (
+ IN BOOLEAN NeedTrustedConsole
+ )
+{
+ EFI_STATUS Status;
+ UINTN Index;
+ EFI_HANDLE *PciHandles;
+ UINTN PciHandlesSize;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiPciIoProtocolGuid,
+ NULL,
+ &PciHandlesSize,
+ &PciHandles
+ );
+ if (EFI_ERROR (Status)) {
+ return NULL;
+ }
+
+ for (Index = 0; Index < PciHandlesSize; Index++) {
+ Status = gBS->HandleProtocol (
+ PciHandles[Index],
+ &gEfiDevicePathProtocolGuid,
+ (VOID **) &DevicePath
+ );
+ if (EFI_ERROR(Status)) {
+ continue;
+ }
+ if (!IsVgaHandle (PciHandles[Index])) {
+ continue;
+ }
+ if ((NeedTrustedConsole && IsTrustedConsole (ConOut, DevicePath)) ||
+ ((!NeedTrustedConsole) && (!IsTrustedConsole (ConOut, DevicePath)))) {
+ return PciHandles[Index];
+ }
+ }
+
+ return NULL;
+}
+
+
+/**
+ Updates Graphic ConOut variable.
+
+ @param NeedTrustedConsole The flag that determines if trusted console
+ or non trusted console should be returned
+**/
+VOID
+UpdateGraphicConOut (
+ IN BOOLEAN NeedTrustedConsole
+ )
+{
+ EFI_HANDLE GraphicsControllerHandle;
+ EFI_DEVICE_PATH_PROTOCOL *GopDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *ConOutDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *UpdatedConOutDevicePath;
+
+ //
+ // Update ConOut variable
+ //
+ GraphicsControllerHandle = GetGraphicsController (NeedTrustedConsole);
+ if (GraphicsControllerHandle != NULL) {
+ //
+ // Connect the GOP driver
+ //
+ gBS->ConnectController (GraphicsControllerHandle, NULL, NULL, TRUE);
+
+ //
+ // Get the GOP device path
+ // NOTE: We may get a device path that contains Controller node in it.
+ //
+ GopDevicePath = EfiBootManagerGetGopDevicePath (GraphicsControllerHandle);
+ if (GopDevicePath != NULL) {
+ GetEfiGlobalVariable2 (L"ConOut", (VOID **)&ConOutDevicePath, NULL);
+ UpdatedConOutDevicePath = UpdateGopDevicePath (ConOutDevicePath, GopDevicePath);
+ if (ConOutDevicePath != NULL) {
+ FreePool (ConOutDevicePath);
+ }
+ FreePool (GopDevicePath);
+ gRT->SetVariable (
+ L"ConOut",
+ &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ GetDevicePathSize (UpdatedConOutDevicePath),
+ UpdatedConOutDevicePath
+ );
+ }
+ }
+}
+
+
+/**
+ The function connects the trusted consoles.
+**/
+VOID
+ConnectTrustedConsole (
+ VOID
+ )
+{
+ EFI_DEVICE_PATH_PROTOCOL *Consoles;
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *Instance;
+ EFI_DEVICE_PATH_PROTOCOL *Next;
+ UINTN Size;
+ UINTN Index;
+ EFI_HANDLE Handle;
+ EFI_STATUS Status;
+ CHAR16 *ConsoleVar[] = {L"ConIn", L"ConOut"};
+ VOID *TrustedConsoleDevicepath;
+
+ TrustedConsoleDevicepath = PcdGetPtr (PcdTrustedConsoleInputDevicePath);
+ DumpDevicePath (L"TrustedConsoleIn", TrustedConsoleDevicepath);
+ TrustedConsoleDevicepath = PcdGetPtr (PcdTrustedConsoleOutputDevicePath);
+ DumpDevicePath (L"TrustedConsoleOut", TrustedConsoleDevicepath);
+
+ for (Index = 0; Index < sizeof (ConsoleVar) / sizeof (ConsoleVar[0]); Index++) {
+
+ GetEfiGlobalVariable2 (ConsoleVar[Index], (VOID **)&Consoles, NULL);
+
+ TempDevicePath = Consoles;
+ do {
+ Instance = GetNextDevicePathInstance (&TempDevicePath, &Size);
+ if (Instance == NULL) {
+ break;
+ }
+ if (IsTrustedConsole (Index, Instance)) {
+ if (IsUsbShortForm (Instance)) {
+ ConnectUsbShortFormDevicePath (Instance);
+ } else {
+ for (Next = Instance; !IsDevicePathEnd (Next); Next = NextDevicePathNode (Next)) {
+ if (DevicePathType (Next) == ACPI_DEVICE_PATH && DevicePathSubType (Next) == ACPI_ADR_DP) {
+ break;
+ } else if (DevicePathType (Next) == HARDWARE_DEVICE_PATH &&
+ DevicePathSubType (Next) == HW_CONTROLLER_DP &&
+ DevicePathType (NextDevicePathNode (Next)) == ACPI_DEVICE_PATH &&
+ DevicePathSubType (NextDevicePathNode (Next)) == ACPI_ADR_DP
+ ) {
+ break;
+ }
+ }
+ if (!IsDevicePathEnd (Next)) {
+ SetDevicePathEndNode (Next);
+ Status = EfiBootManagerConnectDevicePath (Instance, &Handle);
+ if (!EFI_ERROR (Status)) {
+ gBS->ConnectController (Handle, NULL, NULL, TRUE);
+ }
+ } else {
+ EfiBootManagerConnectDevicePath (Instance, NULL);
+ }
+ }
+ }
+ FreePool (Instance);
+ } while (TempDevicePath != NULL);
+
+ if (Consoles != NULL) {
+ FreePool (Consoles);
+ }
+ }
+}
+
+
+/**
+ The function connects the trusted Storages.
+**/
+VOID
+ConnectTrustedStorage (
+ VOID
+ )
+{
+ VOID *TrustedStorageDevicepath;
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *Instance;
+ UINTN Size;
+ EFI_DEVICE_PATH_PROTOCOL *TempStorageDevicePath;
+ EFI_STATUS Status;
+ EFI_HANDLE DeviceHandle;
+
+ TrustedStorageDevicepath = PcdGetPtr (PcdTrustedStorageDevicePath);
+ DumpDevicePath (L"TrustedStorage", TrustedStorageDevicepath);
+
+ TempDevicePath = TrustedStorageDevicepath;
+ do {
+ Instance = GetNextDevicePathInstance (&TempDevicePath, &Size);
+ if (Instance == NULL) {
+ break;
+ }
+
+ EfiBootManagerConnectDevicePath (Instance, NULL);
+
+ TempStorageDevicePath = Instance;
+
+ Status = gBS->LocateDevicePath (
+ &gEfiDevicePathProtocolGuid,
+ &TempStorageDevicePath,
+ &DeviceHandle
+ );
+ if (!EFI_ERROR (Status)) {
+ gBS->ConnectController (DeviceHandle, NULL, NULL, FALSE);
+ }
+
+ FreePool (Instance);
+ } while (TempDevicePath != NULL);
+}
+
+
+/**
+ Check if current BootCurrent variable is internal shell boot option.
+
+ @retval TRUE BootCurrent is internal shell.
+ @retval FALSE BootCurrent is not internal shell.
+**/
+BOOLEAN
+BootCurrentIsInternalShell (
+ VOID
+ )
+{
+ UINTN VarSize;
+ UINT16 BootCurrent;
+ CHAR16 BootOptionName[16];
+ UINT8 *BootOption;
+ UINT8 *Ptr;
+ BOOLEAN Result;
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *LastDeviceNode;
+ EFI_GUID *GuidPoint;
+
+ BootOption = NULL;
+ Result = FALSE;
+
+ //
+ // Get BootCurrent variable
+ //
+ VarSize = sizeof (UINT16);
+ Status = gRT->GetVariable (
+ L"BootCurrent",
+ &gEfiGlobalVariableGuid,
+ NULL,
+ &VarSize,
+ &BootCurrent
+ );
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+
+ //
+ // Create boot option Bootxxxx from BootCurrent
+ //
+ UnicodeSPrint (BootOptionName, sizeof(BootOptionName), L"Boot%04X", BootCurrent);
+
+ GetEfiGlobalVariable2 (BootOptionName, (VOID **) &BootOption, &VarSize);
+ if (BootOption == NULL || VarSize == 0) {
+ return FALSE;
+ }
+
+ Ptr = BootOption;
+ Ptr += sizeof (UINT32);
+ Ptr += sizeof (UINT16);
+ Ptr += StrSize ((CHAR16 *) Ptr);
+ TempDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) Ptr;
+ LastDeviceNode = TempDevicePath;
+ while (!IsDevicePathEnd (TempDevicePath)) {
+ LastDeviceNode = TempDevicePath;
+ TempDevicePath = NextDevicePathNode (TempDevicePath);
+ }
+ GuidPoint = EfiGetNameGuidFromFwVolDevicePathNode (
+ (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) LastDeviceNode
+ );
+ if ((GuidPoint != NULL) &&
+ ((CompareGuid (GuidPoint, &gUefiShellFileGuid)))) {
+ //
+ // if this option is internal shell, return TRUE
+ //
+ Result = TRUE;
+ }
+
+ if (BootOption != NULL) {
+ FreePool (BootOption);
+ BootOption = NULL;
+ }
+
+ return Result;
+}
+
+/**
+ This function will change video resolution and text mode
+ for internl shell when internal shell is launched.
+
+ @param None.
+
+ @retval EFI_SUCCESS Mode is changed successfully.
+ @retval Others Mode failed to changed.
+**/
+EFI_STATUS
+EFIAPI
+ChangeModeForInternalShell (
+ VOID
+ )
+{
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;
+ UINTN SizeOfInfo;
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
+ UINT32 MaxGopMode;
+ UINT32 MaxTextMode;
+ UINT32 ModeNumber;
+ UINTN HandleCount;
+ EFI_HANDLE *HandleBuffer;
+ EFI_STATUS Status;
+ UINTN Index;
+ UINTN CurrentColumn;
+ UINTN CurrentRow;
+
+ //
+ // Internal shell mode
+ //
+ UINT32 mShellModeColumn;
+ UINT32 mShellModeRow;
+ UINT32 mShellHorizontalResolution;
+ UINT32 mShellVerticalResolution;
+
+
+ //
+ // Get user defined text mode for internal shell only once.
+ //
+ mShellHorizontalResolution = PcdGet32 (PcdSetupVideoHorizontalResolution);
+ mShellVerticalResolution = PcdGet32 (PcdSetupVideoVerticalResolution);
+ mShellModeColumn = PcdGet32 (PcdSetupConOutColumn);
+ mShellModeRow = PcdGet32 (PcdSetupConOutRow);
+
+
+ Status = gBS->HandleProtocol (
+ gST->ConsoleOutHandle,
+ &gEfiGraphicsOutputProtocolGuid,
+ (VOID**)&GraphicsOutput
+ );
+ if (EFI_ERROR (Status)) {
+ GraphicsOutput = NULL;
+ }
+
+ Status = gBS->HandleProtocol (
+ gST->ConsoleOutHandle,
+ &gEfiSimpleTextOutProtocolGuid,
+ (VOID**)&SimpleTextOut
+ );
+ if (EFI_ERROR (Status)) {
+ SimpleTextOut = NULL;
+ }
+
+ if ((GraphicsOutput == NULL) || (SimpleTextOut == NULL)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ MaxGopMode = GraphicsOutput->Mode->MaxMode;
+ MaxTextMode = SimpleTextOut->Mode->MaxMode;
+
+ //
+ // 1. If current video resolution is same with new video resolution,
+ // video resolution need not be changed.
+ // 1.1. If current text mode is same with new text mode, text mode need not be change.
+ // 1.2. If current text mode is different with new text mode, text mode need be change to new text mode.
+ // 2. If current video resolution is different with new video resolution, we need restart whole console drivers.
+ //
+ for (ModeNumber = 0; ModeNumber < MaxGopMode; ModeNumber++) {
+ Status = GraphicsOutput->QueryMode (
+ GraphicsOutput,
+ ModeNumber,
+ &SizeOfInfo,
+ &Info
+ );
+ if (!EFI_ERROR (Status)) {
+ if ((Info->HorizontalResolution == mShellHorizontalResolution) &&
+ (Info->VerticalResolution == mShellVerticalResolution)) {
+ if ((GraphicsOutput->Mode->Info->HorizontalResolution == mShellHorizontalResolution) &&
+ (GraphicsOutput->Mode->Info->VerticalResolution == mShellVerticalResolution)) {
+ //
+ // If current video resolution is same with new resolution,
+ // then check if current text mode is same with new text mode.
+ //
+ Status = SimpleTextOut->QueryMode (SimpleTextOut, SimpleTextOut->Mode->Mode, &CurrentColumn, &CurrentRow);
+ ASSERT_EFI_ERROR (Status);
+ if (CurrentColumn == mShellModeColumn && CurrentRow == mShellModeRow) {
+ //
+ // Current text mode is same with new text mode, text mode need not be change.
+ //
+ FreePool (Info);
+ return EFI_SUCCESS;
+ } else {
+ //
+ // Current text mode is different with new text mode, text mode need be change to new text mode.
+ //
+ for (Index = 0; Index < MaxTextMode; Index++) {
+ Status = SimpleTextOut->QueryMode (SimpleTextOut, Index, &CurrentColumn, &CurrentRow);
+ if (!EFI_ERROR(Status)) {
+ if ((CurrentColumn == mShellModeColumn) && (CurrentRow == mShellModeRow)) {
+ //
+ // New text mode is supported, set it.
+ //
+ Status = SimpleTextOut->SetMode (SimpleTextOut, Index);
+ ASSERT_EFI_ERROR (Status);
+ //
+ // Update text mode PCD.
+ //
+ Status = PcdSet32S (PcdConOutColumn, mShellModeColumn);
+ ASSERT_EFI_ERROR (Status);
+
+ Status = PcdSet32S (PcdConOutRow, mShellModeRow);
+ ASSERT_EFI_ERROR (Status);
+
+ FreePool (Info);
+ return EFI_SUCCESS;
+ }
+ }
+ }
+ if (Index == MaxTextMode) {
+ //
+ // If new text mode is not supported, return error.
+ //
+ FreePool (Info);
+ return EFI_UNSUPPORTED;
+ }
+ }
+ } else {
+ FreePool (Info);
+ //
+ // If current video resolution is not same with the new one, set new video resolution.
+ // In this case, the driver which produces simple text out need be restarted.
+ //
+ Status = GraphicsOutput->SetMode (GraphicsOutput, ModeNumber);
+ if (!EFI_ERROR (Status)) {
+ //
+ // Set PCD to restart GraphicsConsole and Consplitter to change video resolution
+ // and produce new text mode based on new resolution.
+ //
+ Status = PcdSet32S (PcdVideoHorizontalResolution, mShellHorizontalResolution);
+ ASSERT_EFI_ERROR (Status);
+
+ Status = PcdSet32S (PcdVideoVerticalResolution, mShellVerticalResolution);
+ ASSERT_EFI_ERROR (Status);
+
+ Status = PcdSet32S (PcdConOutColumn, mShellModeColumn);
+ ASSERT_EFI_ERROR (Status);
+
+ Status = PcdSet32S (PcdConOutRow, mShellModeRow);
+ ASSERT_EFI_ERROR (Status);
+
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiSimpleTextOutProtocolGuid,
+ NULL,
+ &HandleCount,
+ &HandleBuffer
+ );
+ if (!EFI_ERROR (Status)) {
+ for (Index = 0; Index < HandleCount; Index++) {
+ gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);
+ }
+ for (Index = 0; Index < HandleCount; Index++) {
+ gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
+ }
+ if (HandleBuffer != NULL) {
+ FreePool (HandleBuffer);
+ }
+ break;
+ }
+ }
+ }
+ }
+ FreePool (Info);
+ }
+ }
+
+ if (ModeNumber == MaxGopMode) {
+ //
+ // If the new resolution is not supported, return error.
+ //
+ return EFI_UNSUPPORTED;
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+/**
+ The function connects the trusted consoles and then call the PP processing library interface.
+**/
+VOID
+ProcessTcgPp (
+ VOID
+ )
+{
+ gPPRequireUIConfirm |= Tcg2PhysicalPresenceLibNeedUserConfirm();
+
+ if (gPPRequireUIConfirm) {
+ ConnectTrustedConsole ();
+ }
+
+ Tcg2PhysicalPresenceLibProcessRequest (NULL);
+}
+
+
+/**
+ The function connects the trusted storage to perform TPerReset.
+**/
+VOID
+ProcessTcgMor (
+ VOID
+ )
+{
+ if (IsMorBitSet ()) {
+ ConnectTrustedConsole();
+ ConnectTrustedStorage();
+ }
+}
+
+
+/**
+ Update the ConIn variable with USB Keyboard device path,if its not already exists in ConIn
+**/
+VOID
+EnumUsbKeyboard (
+ VOID
+ )
+{
+ DEBUG ((DEBUG_INFO, "[EnumUsbKeyboard]\n"));
+ EfiBootManagerUpdateConsoleVariable (ConIn, (EFI_DEVICE_PATH_PROTOCOL *) &gUsbClassKeyboardDevicePath, NULL);
+ //
+ // Append Usb Keyboard short form DevicePath into "ConInDev"
+ //
+ EfiBootManagerUpdateConsoleVariable (ConInDev, (EFI_DEVICE_PATH_PROTOCOL *) &gUsbClassKeyboardDevicePath, NULL);
+}
+
+
+/**
+ Connect with predeined platform connect sequence,
+ the OEM/IBV can customize with their own connect sequence.
+
+ @param[in] BootMode Boot mode of this boot.
+**/
+VOID
+ConnectSequence (
+ IN EFI_BOOT_MODE BootMode
+ )
+{
+ EfiBootManagerConnectAll ();
+}
+
+
+/**
+ The function is to consider the boot order which is not in our expectation.
+ In the case that we need to re-sort the boot option.
+
+ @retval TRUE Need to sort Boot Option.
+ @retval FALSE Don't need to sort Boot Option.
+**/
+BOOLEAN
+IsNeedSortBootOption (
+ VOID
+ )
+{
+ EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
+ UINTN BootOptionCount;
+
+ BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);
+
+ //
+ // If setup is the first priority in boot option, we need to sort boot option.
+ //
+ if ((BootOptionCount > 1) &&
+ (((StrnCmp (BootOptions->Description, L"Enter Setup", StrLen (L"Enter Setup"))) == 0) ||
+ ((StrnCmp (BootOptions->Description, L"BootManagerMenuApp", StrLen (L"BootManagerMenuApp"))) == 0))) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+/**
+ Connects Root Bridge
+ **/
+VOID
+ConnectRootBridge (
+ BOOLEAN Recursive
+ )
+{
+ UINTN RootBridgeHandleCount;
+ EFI_HANDLE *RootBridgeHandleBuffer;
+ UINTN RootBridgeIndex;
+
+ RootBridgeHandleCount = 0;
+ gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiPciRootBridgeIoProtocolGuid,
+ NULL,
+ &RootBridgeHandleCount,
+ &RootBridgeHandleBuffer
+ );
+ for (RootBridgeIndex = 0; RootBridgeIndex < RootBridgeHandleCount; RootBridgeIndex++) {
+ gBS->ConnectController (RootBridgeHandleBuffer[RootBridgeIndex], NULL, NULL, Recursive);
+ }
+}
+
+VOID
+AddConsoleVariable (
+ IN CONSOLE_TYPE ConsoleType,
+ IN EFI_DEVICE_PATH *ConsoleDevicePath
+ )
+{
+ EFI_DEVICE_PATH *TempDevicePath;
+ EFI_DEVICE_PATH *Instance;
+ UINTN Size;
+ EFI_HANDLE GraphicsControllerHandle;
+ EFI_DEVICE_PATH *GopDevicePath;
+
+ TempDevicePath = ConsoleDevicePath;
+ do {
+ Instance = GetNextDevicePathInstance (&TempDevicePath, &Size);
+ if (Instance == NULL) {
+ break;
+ }
+
+ switch (ConsoleType) {
+ case ConIn:
+ if (IsUsbShortForm (Instance)) {
+ //
+ // Append Usb Keyboard short form DevicePath into "ConInDev"
+ //
+ EfiBootManagerUpdateConsoleVariable (ConInDev, Instance, NULL);
+ }
+ EfiBootManagerUpdateConsoleVariable (ConsoleType, Instance, NULL);
+ break;
+ case ConOut:
+ GraphicsControllerHandle = IsVideoController (Instance);
+ if (GraphicsControllerHandle == NULL) {
+ EfiBootManagerUpdateConsoleVariable (ConsoleType, Instance, NULL);
+ } else {
+ //
+ // Connect the GOP driver
+ //
+ gBS->ConnectController (GraphicsControllerHandle, NULL, NULL, TRUE);
+ //
+ // Get the GOP device path
+ // NOTE: We may get a device path that contains Controller node in it.
+ //
+ GopDevicePath = EfiBootManagerGetGopDevicePath (GraphicsControllerHandle);
+ if (GopDevicePath != NULL) {
+ EfiBootManagerUpdateConsoleVariable (ConsoleType, GopDevicePath, NULL);
+ }
+ }
+ break;
+ default:
+ ASSERT(FALSE);
+ break;
+ }
+
+ FreePool (Instance);
+ } while (TempDevicePath != NULL);
+}
+
+
+/**
+ This is the callback function for PCI ENUMERATION COMPLETE.
+
+ @param[in] Event The Event this notify function registered to.
+ @param[in] Context Pointer to the context data registered to the Event.
+**/
+VOID
+EFIAPI
+BdsPciEnumCompleteCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status;
+ VOID *ProtocolPointer;
+ EFI_DEVICE_PATH_PROTOCOL *VarConOut;
+ EFI_DEVICE_PATH_PROTOCOL *VarConIn;
+
+ Status = EFI_SUCCESS;
+
+ //
+ // Check if this is first time called by EfiCreateProtocolNotifyEvent() or not,
+ // if it is, we will skip it until real event is triggered
+ //
+ Status = gBS->LocateProtocol (&gEfiPciEnumerationCompleteProtocolGuid, NULL, (VOID **) &ProtocolPointer);
+ if (EFI_SUCCESS != Status) {
+ return;
+ }
+ //gBS->CloseEvent (Event);
+
+
+ DEBUG ((DEBUG_INFO, "Event BdsPciEnumCompleteCallback callback starts\n"));
+
+ gBootMode = GetBootModeHob ();
+
+ //
+ // Connect Root Bridge to make PCI BAR resource allocated and all PciIo created
+ //
+ ConnectRootBridge (FALSE);
+
+ //
+ // Fill ConIn/ConOut in Full Configuration boot mode
+ //
+ DEBUG ((DEBUG_INFO, "PlatformBootManagerInit - %x\n", gBootMode));
+
+
+ if (gBootMode == BOOT_WITH_FULL_CONFIGURATION ||
+ gBootMode == BOOT_WITH_DEFAULT_SETTINGS ||
+ gBootMode == BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS ||
+ gBootMode == BOOT_IN_RECOVERY_MODE) {
+
+ GetEfiGlobalVariable2 (L"ConOut", (VOID **)&VarConOut, NULL);
+ if (VarConOut != NULL) {
+ FreePool (VarConOut);
+ }
+
+ GetEfiGlobalVariable2 (L"ConIn", (VOID **)&VarConIn, NULL);
+ if (VarConIn != NULL) {
+ FreePool (VarConIn);
+ }
+
+ //
+ // Only fill ConIn/ConOut when ConIn/ConOut is empty because we may drop to Full Configuration boot mode in non-first boot
+ //
+ if (VarConOut == NULL || VarConIn == NULL) {
+ if (PcdGetSize (PcdTrustedConsoleOutputDevicePath) >= sizeof(EFI_DEVICE_PATH_PROTOCOL)) {
+ AddConsoleVariable (ConOut, PcdGetPtr (PcdTrustedConsoleOutputDevicePath));
+ }
+ if (PcdGetSize (PcdTrustedConsoleInputDevicePath) >= sizeof(EFI_DEVICE_PATH_PROTOCOL)) {
+ AddConsoleVariable (ConIn, PcdGetPtr (PcdTrustedConsoleInputDevicePath));
+ }
+ }
+ }
+
+}
+
+/**
+ This is the callback function for Smm Ready To Lock.
+
+ @param[in] Event The Event this notify function registered to.
+ @param[in] Context Pointer to the context data registered to the Event.
+**/
+VOID
+EFIAPI
+BdsSmmReadyToLockCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ VOID *ProtocolPointer;
+ EFI_STATUS Status;
+ //
+ // Check if this is first time called by EfiCreateProtocolNotifyEvent() or not,
+ // if it is, we will skip it until real event is triggered
+ //
+ Status = gBS->LocateProtocol (&gEfiDxeSmmReadyToLockProtocolGuid, NULL, (VOID **) &ProtocolPointer);
+ if (EFI_SUCCESS != Status) {
+ return;
+ }
+
+ DEBUG ((DEBUG_INFO, "Event gEfiDxeSmmReadyToLockProtocolGuid callback starts\n"));
+
+ //
+ // Dispatch the deferred 3rd party images.
+ //
+ EfiBootManagerDispatchDeferredImages ();
+
+ //
+ // For non-trusted console it must be handled here.
+ //
+ UpdateGraphicConOut (FALSE);
+}
+
+/**
+ ReadyToBoot callback to set video and text mode for internal shell boot.
+ That will not connect USB controller while CSM and FastBoot are disabled, we need to connect them
+ before booting to Shell for showing USB devices in Shell.
+
+ When FastBoot is enabled and Windows Console is the chosen Console behavior, input devices will not be connected
+ by default. Hence, when booting to EFI shell, connecting input consoles are required.
+
+ @param Event Pointer to this event
+ @param Context Event hanlder private data
+
+ @retval None.
+**/
+VOID
+EFIAPI
+BdsReadyToBootCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ DEBUG ((DEBUG_INFO, "BdsReadyToBootCallback\n"));
+
+ if (BootCurrentIsInternalShell ()) {
+
+ ChangeModeForInternalShell ();
+ EfiBootManagerConnectAllDefaultConsoles ();
+ gDS->Dispatch ();
+ }
+}
+
+
+/**
+ Before console after trusted console event callback
+
+ @param[in] Event The Event this notify function registered to.
+ @param[in] Context Pointer to the context data registered to the Event.
+**/
+VOID
+BdsBeforeConsoleAfterTrustedConsoleCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ DEBUG ((DEBUG_INFO, "Event gBdsEventBeforeConsoleBeforeEndOfDxeGuid callback starts\n"));
+
+ //
+ // Enumerate USB keyboard
+ //
+ EnumUsbKeyboard ();
+
+ //
+ // For trusted console it must be handled here.
+ //
+ UpdateGraphicConOut (TRUE);
+
+ //
+ // Register Boot Options
+ //
+ RegisterDefaultBootOption ();
+
+ //
+ // Register Static Hot keys
+ //
+ RegisterStaticHotkey ();
+
+ //
+ // Process Physical Preo
+ //
+ PERF_START_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7010);
+ if (PcdGetBool (PcdTpm2Enable)) {
+ ProcessTcgPp ();
+ ProcessTcgMor ();
+ }
+ PERF_END_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7011);
+
+ //
+ // Perform memory test
+ // We should make all UEFI memory and GCD information populated before ExitPmAuth.
+ // SMM may consume these information.
+ //
+ MemoryTest((EXTENDMEM_COVERAGE_LEVEL) PcdGet32 (PcdPlatformMemoryCheckLevel));
+}
+
+
+/**
+ Before console before end of DXE event callback
+
+ @param[in] Event The Event this notify function registered to.
+ @param[in] Context Pointer to the context data registered to the Event.
+**/
+VOID
+BdsBeforeConsoleBeforeEndOfDxeGuidCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ DEBUG ((DEBUG_INFO, "Event gBdsBeforeConsoleBeforeEndOfDxeGuid callback starts\n"));
+
+}
+
+
+/**
+ After console ready before boot option event callback
+
+ @param[in] Event The Event this notify function registered to.
+ @param[in] Context Pointer to the context data registered to the Event.
+**/
+VOID
+BdsAfterConsoleReadyBeforeBootOptionCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_BOOT_MODE LocalBootMode;
+
+ DEBUG ((DEBUG_INFO, "Event gBdsAfterConsoleReadyBeforeBootOptionEvent callback starts\n"));
+ //
+ // Get current Boot Mode
+ //
+ LocalBootMode = gBootMode;
+ DEBUG ((DEBUG_INFO, "Current local bootmode - %x\n", LocalBootMode));
+
+ //
+ // Go the different platform policy with different boot mode
+ // Notes: this part code can be change with the table policy
+ //
+ switch (LocalBootMode) {
+ case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:
+ case BOOT_WITH_MINIMAL_CONFIGURATION:
+ case BOOT_ON_S4_RESUME:
+ //
+ // Perform some platform specific connect sequence
+ //
+ PERF_START_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7050);
+ ConnectSequence (LocalBootMode);
+ PERF_END_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7051);
+
+ break;
+
+ case BOOT_WITH_FULL_CONFIGURATION:
+ case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:
+ case BOOT_WITH_DEFAULT_SETTINGS:
+ default:
+ //
+ // Perform some platform specific connect sequence
+ //
+ ConnectSequence (LocalBootMode);
+
+ //
+ // Only in Full Configuration boot mode we do the enumeration of boot device
+ //
+ //
+ // Dispatch all but Storage Oprom explicitly, because we assume Int13Thunk driver is there.
+ //
+
+ //
+ // PXE boot option may appear after boot option enumeration
+ //
+ break;
+ }
+
+ Print (L"Press F7 for BootMenu!\n");
+
+ EfiBootManagerRefreshAllBootOption ();
+
+ if (IsNeedSortBootOption()) {
+ EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot, CompareBootOption);
+ }
+}
diff --git a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
new file mode 100644
index 0000000000..69f3fcb552
--- /dev/null
+++ b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
@@ -0,0 +1,95 @@
+### @file
+# Module Information file for the Bds Hook Library.
+#
+# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+###
+
+[Defines]
+ INF_VERSION = 0x00010017
+ BASE_NAME = BoardBdsHookLib
+ FILE_GUID = 649A7502-7301-4E3A-A99B-EA91AD6DD7A8
+ VERSION_STRING = 1.0
+ MODULE_TYPE = DXE_DRIVER
+ LIBRARY_CLASS = BoardBdsHookLib|DXE_DRIVER
+
+[LibraryClasses]
+ BaseLib
+ MemoryAllocationLib
+ UefiBootServicesTableLib
+ UefiRuntimeServicesTableLib
+ BaseMemoryLib
+ DebugLib
+ PcdLib
+ PrintLib
+ DevicePathLib
+ UefiLib
+ HobLib
+ DxeServicesLib
+ DxeServicesTableLib
+ HiiLib
+ UefiBootManagerLib
+ PerformanceLib
+ TimerLib
+ Tcg2PhysicalPresenceLib
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ SecurityPkg/SecurityPkg.dec
+ MinPlatformPkg/MinPlatformPkg.dec
+ BoardModulePkg/BoardModulePkg.dec
+
+[Pcd]
+ gMinPlatformPkgTokenSpaceGuid.PcdTpm2Enable ## CONSUMES
+ gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut ## PRODUCES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution ## PRODUCES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution ## PRODUCES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow ## PRODUCES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn ## PRODUCES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutColumn ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutRow ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand ## PRODUCES
+ gMinPlatformPkgTokenSpaceGuid.PcdPlatformMemoryCheckLevel ## CONSUMES
+ gMinPlatformPkgTokenSpaceGuid.PcdBootToShellOnly ## CONSUMES
+ gMinPlatformPkgTokenSpaceGuid.PcdTrustedConsoleInputDevicePath ## CONSUMES
+ gMinPlatformPkgTokenSpaceGuid.PcdTrustedConsoleOutputDevicePath ## CONSUMES
+ gMinPlatformPkgTokenSpaceGuid.PcdTrustedStorageDevicePath ## CONSUMES
+
+[Sources]
+ BoardBdsHook.h
+ BoardBdsHookLib.c
+ BoardMemoryTest.c
+ BoardBootOption.c
+
+[Protocols]
+ gEfiPciRootBridgeIoProtocolGuid ## CONSUMES
+ gEfiPciIoProtocolGuid ## CONSUMES
+ gEfiCpuIo2ProtocolGuid ## CONSUMES
+ gEfiDxeSmmReadyToLockProtocolGuid ## PRODUCES
+ gEfiGenericMemTestProtocolGuid ## CONSUMES
+ gEfiDiskInfoProtocolGuid ## CONSUMES
+ gEfiDevicePathToTextProtocolGuid ## CONSUMES
+ gEfiSimpleTextInputExProtocolGuid ## CONSUMES
+ gEfiFirmwareVolume2ProtocolGuid ## CONSUMES
+ gEfiFormBrowser2ProtocolGuid ## CONSUMES
+ gEfiGenericMemTestProtocolGuid ## CONSUMES
+ gEfiDxeSmmReadyToLockProtocolGuid
+
+[Guids]
+ gEfiGlobalVariableGuid ## PRODUCES
+ gEfiMemoryOverwriteControlDataGuid ## PRODUCES
+ gEfiEndOfDxeEventGroupGuid ## CONSUMES
+ gBdsEventBeforeConsoleAfterTrustedConsoleGuid
+ gBdsEventBeforeConsoleBeforeEndOfDxeGuid
+ gBdsEventAfterConsoleReadyBeforeBootOptionGuid
+
+[Depex.common.DXE_DRIVER]
+ gEfiVariableArchProtocolGuid
+
+[Depex]
+ TRUE
diff --git a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBootOption.c b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBootOption.c
new file mode 100644
index 0000000000..87138bdd79
--- /dev/null
+++ b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBootOption.c
@@ -0,0 +1,598 @@
+/** @file
+ Driver for Platform Boot Options support.
+
+Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "BoardBdsHook.h"
+
+BOOLEAN mContinueBoot = FALSE;
+BOOLEAN mBootMenuBoot = FALSE;
+BOOLEAN mPxeBoot = FALSE;
+BOOLEAN mHotKeypressed = FALSE;
+EFI_EVENT HotKeyEvent = NULL;
+
+UINTN mBootMenuOptionNumber;
+
+
+/**
+ This function will create a SHELL BootOption to boot.
+
+ @return Shell Device path for booting.
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+BdsCreateShellDevicePath (
+ VOID
+ )
+{
+ UINTN FvHandleCount;
+ EFI_HANDLE *FvHandleBuffer;
+ UINTN Index;
+ EFI_STATUS Status;
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
+ UINTN Size;
+ UINT32 AuthenticationStatus;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ VOID *Buffer;
+
+ DevicePath = NULL;
+ Status = EFI_SUCCESS;
+
+ DEBUG ((DEBUG_INFO, "BdsCreateShellDevicePath\n"));
+ gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiFirmwareVolume2ProtocolGuid,
+ NULL,
+ &FvHandleCount,
+ &FvHandleBuffer
+ );
+
+ for (Index = 0; Index < FvHandleCount; Index++) {
+ gBS->HandleProtocol (
+ FvHandleBuffer[Index],
+ &gEfiFirmwareVolume2ProtocolGuid,
+ (VOID **) &Fv
+ );
+
+ Buffer = NULL;
+ Size = 0;
+ Status = Fv->ReadSection (
+ Fv,
+ &gUefiShellFileGuid,
+ EFI_SECTION_PE32,
+ 0,
+ &Buffer,
+ &Size,
+ &AuthenticationStatus
+ );
+ if (EFI_ERROR (Status)) {
+ //
+ // Skip if no shell file in the FV
+ //
+ continue;
+ } else {
+ //
+ // Found the shell
+ //
+ break;
+ }
+ }
+
+ if (EFI_ERROR (Status)) {
+ //
+ // No shell present
+ //
+ if (FvHandleCount) {
+ FreePool (FvHandleBuffer);
+ }
+ return NULL;
+ }
+ //
+ // Build the shell boot option
+ //
+ DevicePath = DevicePathFromHandle (FvHandleBuffer[Index]);
+
+ if (FvHandleCount) {
+ FreePool (FvHandleBuffer);
+ }
+
+ return DevicePath;
+}
+
+
+EFI_STATUS
+CreateFvBootOption (
+ EFI_GUID *FileGuid,
+ CHAR16 *Description,
+ EFI_BOOT_MANAGER_LOAD_OPTION *BootOption,
+ UINT32 Attributes,
+ UINT8 *OptionalData, OPTIONAL
+ UINT32 OptionalDataSize
+ )
+{
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
+ MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
+ UINT32 AuthenticationStatus;
+ VOID *Buffer;
+ UINTN Size;
+
+ if ((BootOption == NULL) || (FileGuid == NULL) || (Description == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);
+
+ if (!CompareGuid (&gUefiShellFileGuid, FileGuid)) {
+ Status = gBS->HandleProtocol (
+ gImageHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID **) &LoadedImage
+ );
+ if (!EFI_ERROR (Status)) {
+ Status = gBS->HandleProtocol (
+ LoadedImage->DeviceHandle,
+ &gEfiFirmwareVolume2ProtocolGuid,
+ (VOID **) &Fv
+ );
+ if (!EFI_ERROR (Status)) {
+ Buffer = NULL;
+ Size = 0;
+ Status = Fv->ReadSection (
+ Fv,
+ FileGuid,
+ EFI_SECTION_PE32,
+ 0,
+ &Buffer,
+ &Size,
+ &AuthenticationStatus
+ );
+ if (Buffer != NULL) {
+ FreePool (Buffer);
+ }
+ }
+ }
+ if (EFI_ERROR (Status)) {
+ return EFI_NOT_FOUND;
+ }
+
+ DevicePath = AppendDevicePathNode (
+ DevicePathFromHandle (LoadedImage->DeviceHandle),
+ (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
+ );
+ } else {
+ DevicePath = AppendDevicePathNode (
+ BdsCreateShellDevicePath (),
+ (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
+ );
+ }
+
+ Status = EfiBootManagerInitializeLoadOption (
+ BootOption,
+ LoadOptionNumberUnassigned,
+ LoadOptionTypeBoot,
+ Attributes,
+ Description,
+ DevicePath,
+ OptionalData,
+ OptionalDataSize
+ );
+ FreePool (DevicePath);
+ return Status;
+}
+
+EFI_GUID mUiFile = {
+ 0x462CAA21, 0x7614, 0x4503, { 0x83, 0x6E, 0x8A, 0xB6, 0xF4, 0x66, 0x23, 0x31 }
+};
+EFI_GUID mBootMenuFile = {
+ 0xEEC25BDC, 0x67F2, 0x4D95, { 0xB1, 0xD5, 0xF8, 0x1B, 0x20, 0x39, 0xD1, 0x1D }
+};
+
+
+/**
+ Return the index of the load option in the load option array.
+
+ The function consider two load options are equal when the
+ OptionType, Attributes, Description, FilePath and OptionalData are equal.
+
+ @param Key Pointer to the load option to be found.
+ @param Array Pointer to the array of load options to be found.
+ @param Count Number of entries in the Array.
+
+ @retval -1 Key wasn't found in the Array.
+ @retval 0 ~ Count-1 The index of the Key in the Array.
+**/
+INTN
+PlatformFindLoadOption (
+ IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Key,
+ IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Array,
+ IN UINTN Count
+ )
+{
+ UINTN Index;
+
+ for (Index = 0; Index < Count; Index++) {
+ if ((Key->OptionType == Array[Index].OptionType) &&
+ (Key->Attributes == Array[Index].Attributes) &&
+ (StrCmp (Key->Description, Array[Index].Description) == 0) &&
+ (CompareMem (Key->FilePath, Array[Index].FilePath, GetDevicePathSize (Key->FilePath)) == 0) &&
+ (Key->OptionalDataSize == Array[Index].OptionalDataSize) &&
+ (CompareMem (Key->OptionalData, Array[Index].OptionalData, Key->OptionalDataSize) == 0)) {
+ return (INTN) Index;
+ }
+ }
+
+ return -1;
+}
+
+
+/**
+ Registers a boot option
+
+ @param FileGuid Boot file GUID
+ @param Description Boot option discription
+ @param Position Position of the new load option to put in the ****Order variable.
+ @param Attributes Boot option attributes
+ @param OptionalData Optional data of the boot option.
+ @param OptionalDataSize Size of the optional data of the boot option
+
+ @return boot option number
+**/
+UINTN
+RegisterFvBootOption (
+ EFI_GUID *FileGuid,
+ CHAR16 *Description,
+ UINTN Position,
+ UINT32 Attributes,
+ UINT8 *OptionalData, OPTIONAL
+ UINT32 OptionalDataSize
+ )
+{
+ EFI_STATUS Status;
+ UINTN OptionIndex;
+ EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
+ EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
+ UINTN BootOptionCount;
+
+ NewOption.OptionNumber = LoadOptionNumberUnassigned;
+ Status = CreateFvBootOption (FileGuid, Description, &NewOption, Attributes, OptionalData, OptionalDataSize);
+ if (!EFI_ERROR (Status)) {
+ BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);
+
+ OptionIndex = PlatformFindLoadOption (&NewOption, BootOptions, BootOptionCount);
+
+ if (OptionIndex == -1) {
+ Status = EfiBootManagerAddLoadOptionVariable (&NewOption, Position);
+ ASSERT_EFI_ERROR (Status);
+ } else {
+ NewOption.OptionNumber = BootOptions[OptionIndex].OptionNumber;
+ }
+ EfiBootManagerFreeLoadOption (&NewOption);
+ EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
+ }
+
+ return NewOption.OptionNumber;
+}
+
+
+/**
+ Boot manager wait callback
+
+ @param TimeoutRemain The remaingin timeout period
+**/
+VOID
+EFIAPI
+PlatformBootManagerWaitCallback (
+ UINT16 TimeoutRemain
+ )
+{
+ EFI_STATUS Status;
+ EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TxtInEx;
+ EFI_KEY_DATA KeyData;
+ BOOLEAN PausePressed;
+
+ //
+ // Pause on PAUSE key
+ //
+ Status = gBS->HandleProtocol (gST->ConsoleInHandle, &gEfiSimpleTextInputExProtocolGuid, (VOID **) &TxtInEx);
+ ASSERT_EFI_ERROR (Status);
+
+ PausePressed = FALSE;
+
+ while (TRUE) {
+ Status = TxtInEx->ReadKeyStrokeEx (TxtInEx, &KeyData);
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+
+ if (KeyData.Key.ScanCode == SCAN_PAUSE) {
+ PausePressed = TRUE;
+ break;
+ }
+ }
+
+ //
+ // Loop until non-PAUSE key pressed
+ //
+ while (PausePressed) {
+ Status = TxtInEx->ReadKeyStrokeEx (TxtInEx, &KeyData);
+ if (!EFI_ERROR (Status)) {
+ DEBUG ((
+ DEBUG_INFO, "[PauseCallback] %x/%x %x/%x\n",
+ KeyData.Key.ScanCode, KeyData.Key.UnicodeChar,
+ KeyData.KeyState.KeyShiftState, KeyData.KeyState.KeyToggleState
+ ));
+ PausePressed = (BOOLEAN) (KeyData.Key.ScanCode == SCAN_PAUSE);
+ }
+ }
+}
+
+
+EFI_GUID gUefiShellFileGuid = { 0x7C04A583, 0x9E3E, 0x4f1c, { 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 } };
+
+#define INTERNAL_UEFI_SHELL_NAME L"Internal UEFI Shell 2.0"
+#define UEFI_HARD_DRIVE_NAME L"UEFI Hard Drive"
+
+/**
+ Registers default boot option
+**/
+
+VOID
+RegisterDefaultBootOption (
+ VOID
+ )
+{
+ UINT16 *ShellData;
+ UINT32 ShellDataSize;
+
+ ShellData = NULL;
+ ShellDataSize = 0;
+ RegisterFvBootOption (&gUefiShellFileGuid, INTERNAL_UEFI_SHELL_NAME, (UINTN) -1, LOAD_OPTION_ACTIVE, (UINT8 *)ShellData, ShellDataSize);
+
+ //
+ // Boot Menu
+ //
+ mBootMenuOptionNumber = RegisterFvBootOption (&mBootMenuFile, L"Boot Device List", (UINTN) -1, LOAD_OPTION_CATEGORY_APP | LOAD_OPTION_ACTIVE | LOAD_OPTION_HIDDEN, NULL, 0);
+
+ if (mBootMenuOptionNumber == LoadOptionNumberUnassigned) {
+ DEBUG ((DEBUG_INFO, "BootMenuOptionNumber (%d) should not be same to LoadOptionNumberUnassigned(%d).\n", mBootMenuOptionNumber, LoadOptionNumberUnassigned));
+ }
+#if 0
+ //
+ // Boot Manager Menu
+ //
+ EfiInitializeFwVolDevicepathNode (&FileNode, &mUiFile);
+
+ gBS->HandleProtocol (
+ gImageHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID **) &LoadedImage
+ );
+ DevicePath = AppendDevicePathNode (DevicePathFromHandle (LoadedImage->DeviceHandle), (EFI_DEVICE_PATH_PROTOCOL *) &FileNode);
+#endif
+
+}
+
+/**
+ Registers/Unregisters boot option hotkey
+
+ @param OptionNumber The boot option number for the key option.
+ @param Key The the key input
+ @param Add Flag to indicate to add or remove a key
+**/
+VOID
+RegisterBootOptionHotkey (
+ UINT16 OptionNumber,
+ EFI_INPUT_KEY *Key,
+ BOOLEAN Add
+ )
+{
+ EFI_STATUS Status;
+
+ if (!Add) {
+ //
+ // No enter hotkey when force to setup or there is no boot option
+ //
+ Status = EfiBootManagerDeleteKeyOptionVariable (NULL, 0, Key, NULL);
+ ASSERT (Status == EFI_SUCCESS || Status == EFI_NOT_FOUND);
+ } else {
+ //
+ // Register enter hotkey for the first boot option
+ //
+ Status = EfiBootManagerAddKeyOptionVariable (NULL, OptionNumber, 0, Key,NULL);
+ ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
+ }
+}
+
+
+/**
+ Detect key press callback
+
+ @param The key data
+
+ @retval EFI_SUCCESS
+**/
+EFI_STATUS
+EFIAPI
+DetectKeypressCallback (
+ IN EFI_KEY_DATA *KeyData
+)
+{
+ mHotKeypressed = TRUE;
+
+ if (HotKeyEvent != NULL) {
+ gBS->SignalEvent(HotKeyEvent);
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This function is called after all the boot options are enumerated and ordered properly.
+**/
+VOID
+RegisterStaticHotkey (
+ VOID
+ )
+{
+
+ EFI_INPUT_KEY Enter;
+ EFI_KEY_DATA F2;
+ EFI_KEY_DATA F7;
+ BOOLEAN EnterSetup;
+ EFI_STATUS Status;
+ EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
+
+ EnterSetup = FALSE;
+
+ //
+ // [Enter]
+ //
+ mContinueBoot = !EnterSetup;
+ if (mContinueBoot) {
+ Enter.ScanCode = SCAN_NULL;
+ Enter.UnicodeChar = CHAR_CARRIAGE_RETURN;
+ EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL);
+ }
+
+
+ //
+ // [F2]/[F7]
+ //
+ F2.Key.ScanCode = SCAN_F2;
+ F2.Key.UnicodeChar = CHAR_NULL;
+ F2.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID;
+ F2.KeyState.KeyToggleState = 0;
+ Status = EfiBootManagerGetBootManagerMenu (&BootOption);
+ ASSERT_EFI_ERROR (Status);
+ RegisterBootOptionHotkey ((UINT16) BootOption.OptionNumber, &F2.Key, TRUE);
+ EfiBootManagerFreeLoadOption (&BootOption);
+
+ F7.Key.ScanCode = SCAN_F7;
+ F7.Key.UnicodeChar = CHAR_NULL;
+ F7.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID;
+ F7.KeyState.KeyToggleState = 0;
+ mBootMenuBoot = !EnterSetup;
+ RegisterBootOptionHotkey ((UINT16) mBootMenuOptionNumber, &F7.Key, mBootMenuBoot);
+
+}
+
+
+
+/**
+ Returns the boot option type of a device
+
+ @param DevicePath The path of device whose boot option type
+ to be returned
+ @retval -1 Device type not found
+ @retval > -1 Device type found
+**/
+UINT8
+BootOptionType (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+{
+ EFI_DEVICE_PATH_PROTOCOL *Node;
+ EFI_DEVICE_PATH_PROTOCOL *NextNode;
+
+ for (Node = DevicePath; !IsDevicePathEndType (Node); Node = NextDevicePathNode (Node)) {
+ if (DevicePathType (Node) == MESSAGING_DEVICE_PATH) {
+ //
+ // Make sure the device path points to the driver device.
+ //
+ NextNode = NextDevicePathNode (Node);
+ if (DevicePathSubType(NextNode) == MSG_DEVICE_LOGICAL_UNIT_DP) {
+ //
+ // if the next node type is Device Logical Unit, which specify the Logical Unit Number (LUN),
+ // skip it
+ //
+ NextNode = NextDevicePathNode (NextNode);
+ }
+ if (IsDevicePathEndType (NextNode)) {
+ if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH)) {
+ return DevicePathSubType (Node);
+ } else {
+ return MSG_SATA_DP;
+ }
+ }
+ }
+ }
+
+ return (UINT8) -1;
+}
+
+/**
+ Returns the priority number.
+ OptionType EFI
+ ------------------------------------
+ PXE 2
+ DVD 4
+ USB 6
+ NVME 7
+ HDD 8
+ EFI Shell 9
+ Others 100
+
+ @param BootOption
+**/
+UINTN
+BootOptionPriority (
+ CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOption
+ )
+{
+ //
+ // EFI boot options
+ //
+ switch (BootOptionType (BootOption->FilePath)) {
+ case MSG_MAC_ADDR_DP:
+ case MSG_VLAN_DP:
+ case MSG_IPv4_DP:
+ case MSG_IPv6_DP:
+ return 2;
+
+ case MSG_SATA_DP:
+ case MSG_ATAPI_DP:
+ case MSG_UFS_DP:
+ case MSG_NVME_NAMESPACE_DP:
+ return 4;
+
+ case MSG_USB_DP:
+ return 6;
+
+ }
+ if (StrCmp (BootOption->Description, INTERNAL_UEFI_SHELL_NAME) == 0) {
+ if (PcdGetBool (PcdBootToShellOnly)) {
+ return 0;
+ }
+ return 9;
+ }
+ if (StrCmp (BootOption->Description, UEFI_HARD_DRIVE_NAME) == 0) {
+ return 8;
+ }
+ return 100;
+}
+
+/**
+ Compares boot priorities of two boot options
+
+ @param Left The left boot option
+ @param Right The right boot option
+
+ @return The difference between the Left and Right
+ boot options
+ **/
+INTN
+EFIAPI
+CompareBootOption (
+ CONST VOID *Left,
+ CONST VOID *Right
+ )
+{
+ return BootOptionPriority ((EFI_BOOT_MANAGER_LOAD_OPTION *) Left) -
+ BootOptionPriority ((EFI_BOOT_MANAGER_LOAD_OPTION *) Right);
+}
+
diff --git a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardMemoryTest.c b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardMemoryTest.c
new file mode 100644
index 0000000000..e3650721fe
--- /dev/null
+++ b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardMemoryTest.c
@@ -0,0 +1,83 @@
+/** @file
+ Perform the platform memory test
+
+Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "BoardBdsHook.h"
+#include <Protocol/GenericMemoryTest.h>
+
+/**
+ Perform the memory test base on the memory test intensive level,
+ and update the memory resource.
+
+ @param Level The memory test intensive level.
+
+ @retval EFI_STATUS Success test all the system memory and update
+ the memory resource
+
+**/
+EFI_STATUS
+MemoryTest (
+ IN EXTENDMEM_COVERAGE_LEVEL Level
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN RequireSoftECCInit;
+ EFI_GENERIC_MEMORY_TEST_PROTOCOL *GenMemoryTest;
+ UINT64 TestedMemorySize;
+ UINT64 TotalMemorySize;
+ BOOLEAN ErrorOut;
+ BOOLEAN TestAbort;
+
+ TestedMemorySize = 0;
+ TotalMemorySize = 0;
+ ErrorOut = FALSE;
+ TestAbort = FALSE;
+
+ RequireSoftECCInit = FALSE;
+
+ Status = gBS->LocateProtocol (
+ &gEfiGenericMemTestProtocolGuid,
+ NULL,
+ (VOID **) &GenMemoryTest
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_SUCCESS;
+ }
+
+ Status = GenMemoryTest->MemoryTestInit (
+ GenMemoryTest,
+ Level,
+ &RequireSoftECCInit
+ );
+ if (Status == EFI_NO_MEDIA) {
+ //
+ // The PEI codes also have the relevant memory test code to check the memory,
+ // it can select to test some range of the memory or all of them. If PEI code
+ // checks all the memory, this BDS memory test will has no not-test memory to
+ // do the test, and then the status of EFI_NO_MEDIA will be returned by
+ // "MemoryTestInit". So it does not need to test memory again, just return.
+ //
+ return EFI_SUCCESS;
+ }
+
+ do {
+ Status = GenMemoryTest->PerformMemoryTest (
+ GenMemoryTest,
+ &TestedMemorySize,
+ &TotalMemorySize,
+ &ErrorOut,
+ TestAbort
+ );
+ if (ErrorOut && (Status == EFI_DEVICE_ERROR)) {
+ ASSERT (0);
+ }
+ } while (Status != EFI_NOT_FOUND);
+
+ Status = GenMemoryTest->Finished (GenMemoryTest);
+
+ return EFI_SUCCESS;
+}
--
2.19.1.windows.1
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Re: [edk2-platforms] [PATCH 02/11] BoardModulePkg: Add BDS Hook Library
2019-12-14 1:32 ` [edk2-platforms] [PATCH 02/11] BoardModulePkg: Add BDS Hook Library Agyeman, Prince
@ 2019-12-18 1:19 ` Nate DeSimone
2019-12-21 2:36 ` Kubacki, Michael A
1 sibling, 0 replies; 45+ messages in thread
From: Nate DeSimone @ 2019-12-18 1:19 UTC (permalink / raw)
To: Agyeman, Prince; +Cc: devel@edk2.groups.io, Chiu, Chasel, Kubacki, Michael A
Hi Prince,
Feedback inline.
Sat, Dec 14, 2019 at 01:32:28AM +0000, Agyeman, Prince wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
>
> Added a generic board BDS hook library that implements
> BDS hook points as defined in the Minimum platform specification.
>
> This library implements callbacks for the three MinPlatformPkg
> BDS event groups, namely gBdsEventBeforeConsoleAfterTrustedConsoleGuid,
> gBdsEventBeforeConsoleBeforeEndOfDxeGuid and
> gBdsEventAfterConsoleReadyBeforeBootOptionGuid.
>
> This Library also implements callbacks for pre-existing event groups:
> gEfiEndOfDxeEventGroupGuid, gEfiPciEnumerationCompleteProtocolGuid,
> gEfiDxeSmmReadyToLockProtocolGuid.
>
> These callbacks can be registered to their respective event groups,
> through other libraries or DXE drivers
>
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
>
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
> .../Include/Library/BoardBdsHookLib.h | 100 ++
> .../Library/BoardBdsHookLib/BoardBdsHook.h | 211 +++
> .../Library/BoardBdsHookLib/BoardBdsHookLib.c | 1390 +++++++++++++++++
> .../BoardBdsHookLib/BoardBdsHookLib.inf | 95 ++
> .../Library/BoardBdsHookLib/BoardBootOption.c | 598 +++++++
> .../Library/BoardBdsHookLib/BoardMemoryTest.c | 83 +
> 6 files changed, 2477 insertions(+)
> create mode 100644 Platform/Intel/BoardModulePkg/Include/Library/BoardBdsHookLib.h
> create mode 100644 Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook.h
> create mode 100644 Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
> create mode 100644 Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
> create mode 100644 Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBootOption.c
> create mode 100644 Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardMemoryTest.c
>
> diff --git a/Platform/Intel/BoardModulePkg/Include/Library/BoardBdsHookLib.h b/Platform/Intel/BoardModulePkg/Include/Library/BoardBdsHookLib.h
> new file mode 100644
> index 0000000000..ba351b7bf4
> --- /dev/null
> +++ b/Platform/Intel/BoardModulePkg/Include/Library/BoardBdsHookLib.h
> @@ -0,0 +1,100 @@
> +/** @file
> +Header file for BDS Hook Library
> +
> +Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef _BDS_HOOK_LIB_H_
> +#define _BDS_HOOK_LIB_H_
Please make the macros match the file name: _BOARD_BDS_HOOK_LIB_H_
> +
> +#include <Library/UefiLib.h>
> +
> +
> +/**
> + This is the callback function for Bds Ready To Boot event.
> +
> + @param Event Pointer to this event
> + @param Context Event hanlder private data
> +
> + @retval None.
> +**/
> +VOID
> +EFIAPI
> +BdsReadyToBootCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + );
> +
> +
> +/**
> + This is the callback function for Smm Ready To Lock event.
> +
> + @param[in] Event The Event this notify function registered to.
> + @param[in] Context Pointer to the context data registered to the Event.
> +**/
> +VOID
> +EFIAPI
> +BdsSmmReadyToLockCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + );
> +
> +
> +/**
> + This is the callback function for PCI ENUMERATION COMPLETE.
> +
> + @param[in] Event The Event this notify function registered to.
> + @param[in] Context Pointer to the context data registered to the Event.
> +**/
> +VOID
> +EFIAPI
> +BdsPciEnumCompleteCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + );
> +
> +
> +/**
> + Before console after trusted console event callback
> +
> + @param[in] Event The Event this notify function registered to.
> + @param[in] Context Pointer to the context data registered to the Event.
> +**/
> +VOID
> +EFIAPI
> +BdsBeforeConsoleAfterTrustedConsoleCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + );
> +
> +
> +/**
> + Before console before end of DXE event callback
> +
> + @param[in] Event The Event this notify function registered to.
> + @param[in] Context Pointer to the context data registered to the Event.
> +**/
> +VOID
> +EFIAPI
> +BdsBeforeConsoleBeforeEndOfDxeGuidCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + );
> +
> +
> +/**
> + After console ready before boot option event callback
> +
> + @param[in] Event The Event this notify function registered to.
> + @param[in] Context Pointer to the context data registered to the Event.
> +**/
> +VOID
> +EFIAPI
> +BdsAfterConsoleReadyBeforeBootOptionCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + );
> +
> +#endif
> diff --git a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook.h b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook.h
> new file mode 100644
> index 0000000000..748385499b
> --- /dev/null
> +++ b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook.h
> @@ -0,0 +1,211 @@
> +/** @file
> + Header file for BDS Hook Library
> +
> +Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef _BDS_HOOK_H_
> +#define _BDS_HOOK_H_
Please use the same macro name as the file name: _BOARD_BDS_HOOK_H_
> +
> +#include <PiDxe.h>
> +#include <Protocol/DevicePath.h>
> +#include <Protocol/SimpleNetwork.h>
> +#include <Protocol/PciRootBridgeIo.h>
> +#include <Protocol/LoadFile.h>
> +#include <Protocol/PciIo.h>
> +#include <Protocol/CpuIo2.h>
> +#include <Protocol/LoadedImage.h>
> +#include <Protocol/DiskInfo.h>
> +#include <Protocol/GraphicsOutput.h>
> +#include <Protocol/UgaDraw.h>
> +#include <Protocol/GenericMemoryTest.h>
> +#include <Protocol/DevicePathToText.h>
> +#include <Protocol/FirmwareVolume2.h>
> +#include <Protocol/SimpleFileSystem.h>
> +
> +#include <Guid/CapsuleVendor.h>
> +#include <Guid/MemoryTypeInformation.h>
> +#include <Guid/GlobalVariable.h>
> +#include <Guid/MemoryOverwriteControl.h>
> +#include <Guid/FileInfo.h>
> +#include <Library/DebugLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/UefiRuntimeServicesTableLib.h>
> +#include <Library/MemoryAllocationLib.h>
> +#include <Library/BaseLib.h>
> +#include <Library/PcdLib.h>
> +#include <Library/PlatformBootManagerLib.h>
> +#include <Library/DevicePathLib.h>
> +#include <Library/UefiLib.h>
> +#include <Library/HobLib.h>
> +#include <Library/DxeServicesLib.h>
> +#include <Library/DxeServicesTableLib.h>
> +#include <Library/PrintLib.h>
> +#include <Library/HiiLib.h>
> +#include <Library/CapsuleLib.h>
> +#include <Library/PerformanceLib.h>
> +
> +#include <IndustryStandard/Pci30.h>
> +#include <IndustryStandard/PciCodeId.h>
> +#include <Protocol/PciEnumerationComplete.h>
> +
> +///
> +/// ConnectType
> +///
> +#define CONSOLE_OUT 0x00000001
> +#define STD_ERROR 0x00000002
> +#define CONSOLE_IN 0x00000004
> +#define CONSOLE_ALL (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)
> +
> +extern EFI_GUID gUefiShellFileGuid;
> +extern EFI_BOOT_MODE gBootMode;
> +
> +#define gPciRootBridge \
> + { \
> + { \
> + ACPI_DEVICE_PATH, \
> + ACPI_DP, \
> + { \
> + (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \
> + (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \
> + }, \
> + }, \
> + EISA_PNP_ID (0x0A03), \
> + 0 \
> + }
> +
> +#define gEndEntire \
> + { \
> + END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { END_DEVICE_PATH_LENGTH, 0 } \
> + }
> +
> +typedef struct {
> + EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> + UINTN ConnectType;
> +} BDS_CONSOLE_CONNECT_ENTRY;
> +
> +//
> +// Platform Root Bridge
> +//
> +typedef struct {
> + ACPI_HID_DEVICE_PATH PciRootBridge;
> + EFI_DEVICE_PATH_PROTOCOL End;
> +} PLATFORM_ROOT_BRIDGE_DEVICE_PATH;
> +
> +//
> +// Below is the platform console device path
> +//
> +typedef struct {
> + ACPI_HID_DEVICE_PATH PciRootBridge;
> + PCI_DEVICE_PATH IsaBridge;
> + ACPI_HID_DEVICE_PATH Keyboard;
> + EFI_DEVICE_PATH_PROTOCOL End;
> +} PLATFORM_KEYBOARD_DEVICE_PATH;
> +
> +typedef struct {
> + ACPI_HID_DEVICE_PATH PciRootBridge;
> + PCI_DEVICE_PATH PciDevice;
> + EFI_DEVICE_PATH_PROTOCOL End;
> +} PLATFORM_ONBOARD_CONTROLLER_DEVICE_PATH;
> +
> +typedef struct {
> + ACPI_HID_DEVICE_PATH PciRootBridge;
> + PCI_DEVICE_PATH Pci0Device;
> + EFI_DEVICE_PATH_PROTOCOL End;
> +} PLATFORM_PEG_ROOT_CONTROLLER_DEVICE_PATH;
> +
> +typedef struct {
> + ACPI_HID_DEVICE_PATH PciRootBridge;
> + PCI_DEVICE_PATH PciBridge;
> + PCI_DEVICE_PATH PciDevice;
> + EFI_DEVICE_PATH_PROTOCOL End;
> +} PLATFORM_PCI_CONTROLLER_DEVICE_PATH;
> +
> +//
> +// Below is the boot option device path
> +//
> +
> +#define CLASS_HID 3
> +#define SUBCLASS_BOOT 1
> +#define PROTOCOL_KEYBOARD 1
> +
> +typedef struct {
> + USB_CLASS_DEVICE_PATH UsbClass;
> + EFI_DEVICE_PATH_PROTOCOL End;
> +} USB_CLASS_FORMAT_DEVICE_PATH;
> +
> +extern USB_CLASS_FORMAT_DEVICE_PATH gUsbClassKeyboardDevicePath;
> +
> +//
> +// Platform BDS Functions
> +//
> +
> +
> +/**
> + Perform the memory test base on the memory test intensive level,
> + and update the memory resource.
> +
> + @param Level The memory test intensive level.
> +
> + @retval EFI_STATUS Success test all the system memory and update
> + the memory resource
> +
> +**/
> +EFI_STATUS
> +MemoryTest (
> + IN EXTENDMEM_COVERAGE_LEVEL Level
> + );
> +
> +/**
> + Connect with predeined platform connect sequence,
> + the OEM/IBV can customize with their own connect sequence.
> +
> + @param[in] BootMode Boot mode of this boot.
> +**/
> +VOID
> +ConnectSequence (
> + IN EFI_BOOT_MODE BootMode
> + );
> +
> +
> +/**
> + Compares boot priorities of two boot options
> +
> + @param Left The left boot option
> + @param Right The right boot option
> +
> + @return The difference between the Left and Right
> + boot options
> + **/
> +INTN
> +EFIAPI
> +CompareBootOption (
> + CONST VOID *Left,
> + CONST VOID *Right
> + );
> +
> +/**
> + This function is called after all the boot options are enumerated and ordered properly.
> +**/
> +VOID
> +RegisterStaticHotkey (
> + VOID
> + );
> +
> +
> +/**
> + Registers/Unregisters boot option hotkey
> +
> + @param OptionNumber The boot option number for the key option.
> + @param Key The the key input
> + @param Add Flag to indicate to add or remove a key
> +**/
> +VOID
> +RegisterDefaultBootOption (
> + VOID
> + );
> +
> +#endif
> diff --git a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.c b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
> new file mode 100644
> index 0000000000..9d42a8c27f
> --- /dev/null
> +++ b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
> @@ -0,0 +1,1390 @@
> +/** @file
> + This library registers Bds callbacks. It is a default library
> + implementation instance of the BDS hook library
> +
> + Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Guid/EventGroup.h>
> +
> +#include <Library/IoLib.h>
> +#include <Library/PciLib.h>
> +#include <Library/UefiBootManagerLib.h>
> +#include <Library/Tcg2PhysicalPresenceLib.h>
> +
> +#include <Protocol/BlockIo.h>
> +#include <Protocol/UsbIo.h>
> +#include <Protocol/PciEnumerationComplete.h>
> +
> +#include "BoardBdsHook.h"
> +
> +GLOBAL_REMOVE_IF_UNREFERENCED EFI_BOOT_MODE gBootMode;
> +BOOLEAN gPPRequireUIConfirm;
> +extern UINTN mBootMenuOptionNumber;
> +
> +
> +GLOBAL_REMOVE_IF_UNREFERENCED USB_CLASS_FORMAT_DEVICE_PATH gUsbClassKeyboardDevicePath = {
> + {
> + {
> + MESSAGING_DEVICE_PATH,
> + MSG_USB_CLASS_DP,
> + {
> + (UINT8) (sizeof (USB_CLASS_DEVICE_PATH)),
> + (UINT8) ((sizeof (USB_CLASS_DEVICE_PATH)) >> 8)
> + }
> + },
> + 0xffff, // VendorId
> + 0xffff, // ProductId
> + CLASS_HID, // DeviceClass
> + SUBCLASS_BOOT, // DeviceSubClass
> + PROTOCOL_KEYBOARD // DeviceProtocol
> + },
> + gEndEntire
> +};
> +
> +
> +//
> +// BDS Platform Functions
> +//
> +BOOLEAN
> +IsMorBitSet (
> + VOID
> + )
> +{
> + UINTN MorControl;
> + EFI_STATUS Status;
> + UINTN DataSize;
> +
> + //
> + // Check if the MOR bit is set.
> + //
> + DataSize = sizeof (MorControl);
> + Status = gRT->GetVariable (
> + MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME,
> + &gEfiMemoryOverwriteControlDataGuid,
> + NULL,
> + &DataSize,
> + &MorControl
> + );
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_INFO, " gEfiMemoryOverwriteControlDataGuid doesn't exist!!***\n"));
> + MorControl = 0;
> + } else {
> + DEBUG ((DEBUG_INFO, " Get the gEfiMemoryOverwriteControlDataGuid = %x!!***\n", MorControl));
> + }
> +
> + return (BOOLEAN) (MorControl & 0x01);
> +}
> +
> +
> +/**
> + Prints device paths.
> + @param Name The device name.
> + @param DevicePath The device path to be printed
> +**/
> +VOID
> +EFIAPI
> +DumpDevicePath (
> + IN CHAR16 *Name,
> + IN EFI_DEVICE_PATH *DevicePath
> + )
> +{
> + CHAR16 *Str;
> + Str = ConvertDevicePathToText (DevicePath, TRUE, TRUE);
> + DEBUG ((DEBUG_INFO, "%s: %s\n", Name, Str));
> + if (Str != NULL) {
> + FreePool (Str);
> + }
> +}
> +
> +/**
> + Return whether the device is trusted console.
> +
> + @param Device The device to be tested.
> +
> + @retval TRUE The device can be trusted.
> + @retval FALSE The device cannot be trusted.
> +**/
> +BOOLEAN
> +IsTrustedConsole (
> + IN CONSOLE_TYPE ConsoleType,
> + IN EFI_DEVICE_PATH_PROTOCOL *Device
> + )
> +{
> + VOID *TrustedConsoleDevicepath;
> + EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
> + EFI_DEVICE_PATH_PROTOCOL *Instance;
> + UINTN Size;
> + EFI_DEVICE_PATH_PROTOCOL *ConsoleDevice;
> +
> + if (Device == NULL) {
> + return FALSE;
> + }
> +
> + ConsoleDevice = DuplicateDevicePath (Device);
> +
> + TrustedConsoleDevicepath = NULL;
> +
> + switch (ConsoleType) {
> + case ConIn:
> + TrustedConsoleDevicepath = PcdGetPtr (PcdTrustedConsoleInputDevicePath);
> + break;
> + case ConOut:
> + //
> + // Check GOP and remove last node
> + //
> + TempDevicePath = ConsoleDevice;
> + while (!IsDevicePathEndType (TempDevicePath)) {
> + if (DevicePathType (TempDevicePath) == ACPI_DEVICE_PATH &&
> + DevicePathSubType (TempDevicePath) == ACPI_ADR_DP) {
> + SetDevicePathEndNode (TempDevicePath);
> + break;
> + }
> + TempDevicePath = NextDevicePathNode (TempDevicePath);
> + }
> +
> + TrustedConsoleDevicepath = PcdGetPtr (PcdTrustedConsoleOutputDevicePath);
> + break;
> + default:
> + ASSERT (FALSE);
> + break;
> + }
> +
> + TempDevicePath = TrustedConsoleDevicepath;
> + do {
> + Instance = GetNextDevicePathInstance (&TempDevicePath, &Size);
> + if (Instance == NULL) {
> + break;
> + }
> +
> + if (CompareMem (ConsoleDevice, Instance, Size - END_DEVICE_PATH_LENGTH) == 0) {
> + FreePool (Instance);
> + FreePool (ConsoleDevice);
> + return TRUE;
> + }
> +
> + FreePool (Instance);
> + } while (TempDevicePath != NULL);
> +
> + FreePool (ConsoleDevice);
> +
> + return FALSE;
> +}
> +
> +
> +/**
> + Return whether the USB device path is in a short form.
> +
> + @param DevicePath The device path to be tested.
> +
> + @retval TRUE The device path is in short form.
> + @retval FALSE The device path is not in short form.
> +**/
> +BOOLEAN
> +IsUsbShortForm (
> + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
> + )
> +{
> + if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&
> + ((DevicePathSubType (DevicePath) == MSG_USB_CLASS_DP) ||
> + (DevicePathSubType (DevicePath) == MSG_USB_WWID_DP)) ) {
> + return TRUE;
> + }
> +
> + return FALSE;
> +}
> +
> +/**
> + Connect the USB short form device path.
> +
> + @param DevicePath USB short form device path
> +
> + @retval EFI_SUCCESS Successfully connected the USB device
> + @retval EFI_NOT_FOUND Cannot connect the USB device
> + @retval EFI_INVALID_PARAMETER The device path is invalid.
> +**/
> +EFI_STATUS
> +ConnectUsbShortFormDevicePath (
> + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
> + )
> +{
> + EFI_STATUS Status;
> + EFI_HANDLE *Handles;
> + UINTN HandleCount;
> + UINTN Index;
> + EFI_PCI_IO_PROTOCOL *PciIo;
> + UINT8 Class[3];
> + BOOLEAN AtLeastOneConnected;
> +
> + //
> + // Check the passed in parameters
> + //
> + if (DevicePath == NULL) {
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + if (!IsUsbShortForm (DevicePath)) {
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + //
> + // Find the usb host controller firstly, then connect with the remaining device path
> + //
> + AtLeastOneConnected = FALSE;
> + Status = gBS->LocateHandleBuffer (
> + ByProtocol,
> + &gEfiPciIoProtocolGuid,
> + NULL,
> + &HandleCount,
> + &Handles
> + );
> + for (Index = 0; Index < HandleCount; Index++) {
> + Status = gBS->HandleProtocol (
> + Handles[Index],
> + &gEfiPciIoProtocolGuid,
> + (VOID **) &PciIo
> + );
> + if (!EFI_ERROR (Status)) {
> + //
> + // Check whether the Pci device is the wanted usb host controller
> + //
> + Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0x09, 3, &Class);
> + if (!EFI_ERROR (Status) &&
> + ((PCI_CLASS_SERIAL == Class[2]) && (PCI_CLASS_SERIAL_USB == Class[1]))) {
> + Status = gBS->ConnectController (
> + Handles[Index],
> + NULL,
> + DevicePath,
> + FALSE
> + );
> + if (!EFI_ERROR(Status)) {
> + AtLeastOneConnected = TRUE;
> + }
> + }
> + }
> + }
> +
> + return AtLeastOneConnected ? EFI_SUCCESS : EFI_NOT_FOUND;
> +}
> +
> +
> +/**
> + Return whether the Handle is a vga handle.
> +
> + @param Handle The handle to be tested.
> +
> + @retval TRUE The handle is a vga handle.
> + @retval FALSE The handle is not a vga handle..
> +**/
> +BOOLEAN
> +IsVgaHandle (
> + IN EFI_HANDLE Handle
> + )
> +{
> + EFI_PCI_IO_PROTOCOL *PciIo;
> + PCI_TYPE00 Pci;
> + EFI_STATUS Status;
> +
> + Status = gBS->HandleProtocol (
> + Handle,
> + &gEfiPciIoProtocolGuid,
> + (VOID **)&PciIo
> + );
> + if (!EFI_ERROR (Status)) {
> + Status = PciIo->Pci.Read (
> + PciIo,
> + EfiPciIoWidthUint32,
> + 0,
> + sizeof (Pci) / sizeof (UINT32),
> + &Pci
> + );
> + if (!EFI_ERROR (Status)) {
> + if (IS_PCI_VGA (&Pci) || IS_PCI_OLD_VGA (&Pci)) {
> + return TRUE;
> + }
> + }
> + }
> + return FALSE;
> +}
> +
> +
> +/**
> + Return whether the device path points to a video controller.
> +
> + @param DevicePath The device path to be tested.
> +
> + @retval TRUE The device path points to a video controller.
> + @retval FALSE The device path does not point to a video controller.
> +**/
> +EFI_HANDLE
> +IsVideoController (
> + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
> + )
> +{
> + EFI_DEVICE_PATH_PROTOCOL *DupDevicePath;
> + EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
> + EFI_STATUS Status;
> + EFI_HANDLE DeviceHandle;
> +
> + DupDevicePath = DuplicateDevicePath (DevicePath);
> + ASSERT (DupDevicePath != NULL);
> + if (DupDevicePath == NULL) {
> + return NULL;
> + }
> +
> + TempDevicePath = DupDevicePath;
> + Status = gBS->LocateDevicePath (
> + &gEfiDevicePathProtocolGuid,
> + &TempDevicePath,
> + &DeviceHandle
> + );
> + FreePool (DupDevicePath);
> + if (EFI_ERROR (Status)) {
> + return NULL;
> + }
> +
> + if (IsVgaHandle (DeviceHandle)) {
> + return DeviceHandle;
> + } else {
> + return NULL;
> + }
> +}
> +
> +
> +/**
> + Return whether the device path is a GOP device path.
> +
> + @param DevicePath The device path to be tested.
> +
> + @retval TRUE The device path is a GOP device path.
> + @retval FALSE The device on the device path is not a GOP device path.
> +**/
> +BOOLEAN
> +IsGopDevicePath (
> + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
> + )
> +{
> + while (!IsDevicePathEndType (DevicePath)) {
> + if (DevicePathType (DevicePath) == ACPI_DEVICE_PATH &&
> + DevicePathSubType (DevicePath) == ACPI_ADR_DP) {
> + return TRUE;
> + }
> + DevicePath = NextDevicePathNode (DevicePath);
> + }
> + return FALSE;
> +}
> +
> +
> +/**
> + Remove all GOP device path instance from DevicePath and add the Gop to the DevicePath.
> +
> + @param DevicePath The device path to be removed
> + @param Gop The device path to be added.
> +
> + @retval Return The updated device path.
> +**/
> +EFI_DEVICE_PATH_PROTOCOL *
> +UpdateGopDevicePath (
> + EFI_DEVICE_PATH_PROTOCOL *DevicePath,
> + EFI_DEVICE_PATH_PROTOCOL *Gop
> + )
> +{
> + UINTN Size;
> + UINTN GopSize;
> + EFI_DEVICE_PATH_PROTOCOL *Temp;
> + EFI_DEVICE_PATH_PROTOCOL *Return;
> + EFI_DEVICE_PATH_PROTOCOL *Instance;
> + BOOLEAN Exist;
> +
> + Exist = FALSE;
> + Return = NULL;
> + GopSize = GetDevicePathSize (Gop);
> + do {
> + Instance = GetNextDevicePathInstance (&DevicePath, &Size);
> + if (Instance == NULL) {
> + break;
> + }
> + if (!IsGopDevicePath (Instance) ||
> + (Size == GopSize && CompareMem (Instance, Gop, GopSize) == 0)
> + ) {
> + if (Size == GopSize && CompareMem (Instance, Gop, GopSize) == 0) {
> + Exist = TRUE;
> + }
> + Temp = Return;
> + Return = AppendDevicePathInstance (Return, Instance);
> + if (Temp != NULL) {
> + FreePool (Temp);
> + }
> + }
> + FreePool (Instance);
> + } while (DevicePath != NULL);
> +
> + if (!Exist) {
> + Temp = Return;
> + Return = AppendDevicePathInstance (Return, Gop);
> + if (Temp != NULL) {
> + FreePool (Temp);
> + }
> + }
> + return Return;
> +}
> +
> +
> +/**
> + Get Graphics Controller Handle.
> +
> + @param NeedTrustedConsole The flag to determine if trusted console
> + or non trusted console should be returned
> +
> + @retval NULL Console not found
> + @retval PciHandles Successfully located
> +**/
> +EFI_HANDLE
> +EFIAPI
> +GetGraphicsController (
> + IN BOOLEAN NeedTrustedConsole
> + )
> +{
> + EFI_STATUS Status;
> + UINTN Index;
> + EFI_HANDLE *PciHandles;
> + UINTN PciHandlesSize;
> + EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> +
> + Status = gBS->LocateHandleBuffer (
> + ByProtocol,
> + &gEfiPciIoProtocolGuid,
> + NULL,
> + &PciHandlesSize,
> + &PciHandles
> + );
> + if (EFI_ERROR (Status)) {
> + return NULL;
> + }
> +
> + for (Index = 0; Index < PciHandlesSize; Index++) {
> + Status = gBS->HandleProtocol (
> + PciHandles[Index],
> + &gEfiDevicePathProtocolGuid,
> + (VOID **) &DevicePath
> + );
> + if (EFI_ERROR(Status)) {
> + continue;
> + }
> + if (!IsVgaHandle (PciHandles[Index])) {
> + continue;
> + }
> + if ((NeedTrustedConsole && IsTrustedConsole (ConOut, DevicePath)) ||
> + ((!NeedTrustedConsole) && (!IsTrustedConsole (ConOut, DevicePath)))) {
> + return PciHandles[Index];
> + }
> + }
> +
> + return NULL;
> +}
> +
> +
> +/**
> + Updates Graphic ConOut variable.
> +
> + @param NeedTrustedConsole The flag that determines if trusted console
> + or non trusted console should be returned
> +**/
> +VOID
> +UpdateGraphicConOut (
> + IN BOOLEAN NeedTrustedConsole
> + )
> +{
> + EFI_HANDLE GraphicsControllerHandle;
> + EFI_DEVICE_PATH_PROTOCOL *GopDevicePath;
> + EFI_DEVICE_PATH_PROTOCOL *ConOutDevicePath;
> + EFI_DEVICE_PATH_PROTOCOL *UpdatedConOutDevicePath;
> +
> + //
> + // Update ConOut variable
> + //
> + GraphicsControllerHandle = GetGraphicsController (NeedTrustedConsole);
> + if (GraphicsControllerHandle != NULL) {
> + //
> + // Connect the GOP driver
> + //
> + gBS->ConnectController (GraphicsControllerHandle, NULL, NULL, TRUE);
> +
> + //
> + // Get the GOP device path
> + // NOTE: We may get a device path that contains Controller node in it.
> + //
> + GopDevicePath = EfiBootManagerGetGopDevicePath (GraphicsControllerHandle);
> + if (GopDevicePath != NULL) {
> + GetEfiGlobalVariable2 (L"ConOut", (VOID **)&ConOutDevicePath, NULL);
> + UpdatedConOutDevicePath = UpdateGopDevicePath (ConOutDevicePath, GopDevicePath);
> + if (ConOutDevicePath != NULL) {
> + FreePool (ConOutDevicePath);
> + }
> + FreePool (GopDevicePath);
> + gRT->SetVariable (
> + L"ConOut",
> + &gEfiGlobalVariableGuid,
> + EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS,
> + GetDevicePathSize (UpdatedConOutDevicePath),
> + UpdatedConOutDevicePath
> + );
> + }
> + }
> +}
> +
> +
> +/**
> + The function connects the trusted consoles.
> +**/
> +VOID
> +ConnectTrustedConsole (
> + VOID
> + )
> +{
> + EFI_DEVICE_PATH_PROTOCOL *Consoles;
> + EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
> + EFI_DEVICE_PATH_PROTOCOL *Instance;
> + EFI_DEVICE_PATH_PROTOCOL *Next;
> + UINTN Size;
> + UINTN Index;
> + EFI_HANDLE Handle;
> + EFI_STATUS Status;
> + CHAR16 *ConsoleVar[] = {L"ConIn", L"ConOut"};
> + VOID *TrustedConsoleDevicepath;
> +
> + TrustedConsoleDevicepath = PcdGetPtr (PcdTrustedConsoleInputDevicePath);
> + DumpDevicePath (L"TrustedConsoleIn", TrustedConsoleDevicepath);
> + TrustedConsoleDevicepath = PcdGetPtr (PcdTrustedConsoleOutputDevicePath);
> + DumpDevicePath (L"TrustedConsoleOut", TrustedConsoleDevicepath);
> +
> + for (Index = 0; Index < sizeof (ConsoleVar) / sizeof (ConsoleVar[0]); Index++) {
> +
> + GetEfiGlobalVariable2 (ConsoleVar[Index], (VOID **)&Consoles, NULL);
> +
> + TempDevicePath = Consoles;
> + do {
> + Instance = GetNextDevicePathInstance (&TempDevicePath, &Size);
> + if (Instance == NULL) {
> + break;
> + }
> + if (IsTrustedConsole (Index, Instance)) {
> + if (IsUsbShortForm (Instance)) {
> + ConnectUsbShortFormDevicePath (Instance);
> + } else {
> + for (Next = Instance; !IsDevicePathEnd (Next); Next = NextDevicePathNode (Next)) {
> + if (DevicePathType (Next) == ACPI_DEVICE_PATH && DevicePathSubType (Next) == ACPI_ADR_DP) {
> + break;
> + } else if (DevicePathType (Next) == HARDWARE_DEVICE_PATH &&
> + DevicePathSubType (Next) == HW_CONTROLLER_DP &&
> + DevicePathType (NextDevicePathNode (Next)) == ACPI_DEVICE_PATH &&
> + DevicePathSubType (NextDevicePathNode (Next)) == ACPI_ADR_DP
> + ) {
> + break;
> + }
> + }
> + if (!IsDevicePathEnd (Next)) {
> + SetDevicePathEndNode (Next);
> + Status = EfiBootManagerConnectDevicePath (Instance, &Handle);
> + if (!EFI_ERROR (Status)) {
> + gBS->ConnectController (Handle, NULL, NULL, TRUE);
> + }
> + } else {
> + EfiBootManagerConnectDevicePath (Instance, NULL);
> + }
> + }
> + }
> + FreePool (Instance);
> + } while (TempDevicePath != NULL);
> +
> + if (Consoles != NULL) {
> + FreePool (Consoles);
> + }
> + }
> +}
> +
> +
> +/**
> + The function connects the trusted Storages.
> +**/
> +VOID
> +ConnectTrustedStorage (
> + VOID
> + )
> +{
> + VOID *TrustedStorageDevicepath;
> + EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
> + EFI_DEVICE_PATH_PROTOCOL *Instance;
> + UINTN Size;
> + EFI_DEVICE_PATH_PROTOCOL *TempStorageDevicePath;
> + EFI_STATUS Status;
> + EFI_HANDLE DeviceHandle;
> +
> + TrustedStorageDevicepath = PcdGetPtr (PcdTrustedStorageDevicePath);
> + DumpDevicePath (L"TrustedStorage", TrustedStorageDevicepath);
> +
> + TempDevicePath = TrustedStorageDevicepath;
> + do {
> + Instance = GetNextDevicePathInstance (&TempDevicePath, &Size);
> + if (Instance == NULL) {
> + break;
> + }
> +
> + EfiBootManagerConnectDevicePath (Instance, NULL);
> +
> + TempStorageDevicePath = Instance;
> +
> + Status = gBS->LocateDevicePath (
> + &gEfiDevicePathProtocolGuid,
> + &TempStorageDevicePath,
> + &DeviceHandle
> + );
> + if (!EFI_ERROR (Status)) {
> + gBS->ConnectController (DeviceHandle, NULL, NULL, FALSE);
> + }
> +
> + FreePool (Instance);
> + } while (TempDevicePath != NULL);
> +}
> +
> +
> +/**
> + Check if current BootCurrent variable is internal shell boot option.
> +
> + @retval TRUE BootCurrent is internal shell.
> + @retval FALSE BootCurrent is not internal shell.
> +**/
> +BOOLEAN
> +BootCurrentIsInternalShell (
> + VOID
> + )
> +{
> + UINTN VarSize;
> + UINT16 BootCurrent;
> + CHAR16 BootOptionName[16];
> + UINT8 *BootOption;
> + UINT8 *Ptr;
> + BOOLEAN Result;
> + EFI_STATUS Status;
> + EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
> + EFI_DEVICE_PATH_PROTOCOL *LastDeviceNode;
> + EFI_GUID *GuidPoint;
> +
> + BootOption = NULL;
> + Result = FALSE;
> +
> + //
> + // Get BootCurrent variable
> + //
> + VarSize = sizeof (UINT16);
> + Status = gRT->GetVariable (
> + L"BootCurrent",
> + &gEfiGlobalVariableGuid,
> + NULL,
> + &VarSize,
> + &BootCurrent
> + );
> + if (EFI_ERROR (Status)) {
> + return FALSE;
> + }
> +
> + //
> + // Create boot option Bootxxxx from BootCurrent
> + //
> + UnicodeSPrint (BootOptionName, sizeof(BootOptionName), L"Boot%04X", BootCurrent);
> +
> + GetEfiGlobalVariable2 (BootOptionName, (VOID **) &BootOption, &VarSize);
> + if (BootOption == NULL || VarSize == 0) {
> + return FALSE;
> + }
> +
> + Ptr = BootOption;
> + Ptr += sizeof (UINT32);
> + Ptr += sizeof (UINT16);
> + Ptr += StrSize ((CHAR16 *) Ptr);
> + TempDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) Ptr;
> + LastDeviceNode = TempDevicePath;
> + while (!IsDevicePathEnd (TempDevicePath)) {
> + LastDeviceNode = TempDevicePath;
> + TempDevicePath = NextDevicePathNode (TempDevicePath);
> + }
> + GuidPoint = EfiGetNameGuidFromFwVolDevicePathNode (
> + (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) LastDeviceNode
> + );
> + if ((GuidPoint != NULL) &&
> + ((CompareGuid (GuidPoint, &gUefiShellFileGuid)))) {
> + //
> + // if this option is internal shell, return TRUE
> + //
> + Result = TRUE;
> + }
> +
> + if (BootOption != NULL) {
> + FreePool (BootOption);
> + BootOption = NULL;
> + }
> +
> + return Result;
> +}
> +
> +/**
> + This function will change video resolution and text mode
> + for internl shell when internal shell is launched.
> +
> + @param None.
> +
> + @retval EFI_SUCCESS Mode is changed successfully.
> + @retval Others Mode failed to changed.
> +**/
> +EFI_STATUS
> +EFIAPI
> +ChangeModeForInternalShell (
> + VOID
> + )
> +{
> + EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
> + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;
> + UINTN SizeOfInfo;
> + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
> + UINT32 MaxGopMode;
> + UINT32 MaxTextMode;
> + UINT32 ModeNumber;
> + UINTN HandleCount;
> + EFI_HANDLE *HandleBuffer;
> + EFI_STATUS Status;
> + UINTN Index;
> + UINTN CurrentColumn;
> + UINTN CurrentRow;
> +
> + //
> + // Internal shell mode
> + //
> + UINT32 mShellModeColumn;
> + UINT32 mShellModeRow;
> + UINT32 mShellHorizontalResolution;
> + UINT32 mShellVerticalResolution;
> +
> +
> + //
> + // Get user defined text mode for internal shell only once.
> + //
> + mShellHorizontalResolution = PcdGet32 (PcdSetupVideoHorizontalResolution);
> + mShellVerticalResolution = PcdGet32 (PcdSetupVideoVerticalResolution);
> + mShellModeColumn = PcdGet32 (PcdSetupConOutColumn);
> + mShellModeRow = PcdGet32 (PcdSetupConOutRow);
> +
> +
> + Status = gBS->HandleProtocol (
> + gST->ConsoleOutHandle,
> + &gEfiGraphicsOutputProtocolGuid,
> + (VOID**)&GraphicsOutput
> + );
> + if (EFI_ERROR (Status)) {
> + GraphicsOutput = NULL;
> + }
> +
> + Status = gBS->HandleProtocol (
> + gST->ConsoleOutHandle,
> + &gEfiSimpleTextOutProtocolGuid,
> + (VOID**)&SimpleTextOut
> + );
> + if (EFI_ERROR (Status)) {
> + SimpleTextOut = NULL;
> + }
> +
> + if ((GraphicsOutput == NULL) || (SimpleTextOut == NULL)) {
> + return EFI_UNSUPPORTED;
> + }
> +
> + MaxGopMode = GraphicsOutput->Mode->MaxMode;
> + MaxTextMode = SimpleTextOut->Mode->MaxMode;
> +
> + //
> + // 1. If current video resolution is same with new video resolution,
> + // video resolution need not be changed.
> + // 1.1. If current text mode is same with new text mode, text mode need not be change.
> + // 1.2. If current text mode is different with new text mode, text mode need be change to new text mode.
> + // 2. If current video resolution is different with new video resolution, we need restart whole console drivers.
> + //
> + for (ModeNumber = 0; ModeNumber < MaxGopMode; ModeNumber++) {
> + Status = GraphicsOutput->QueryMode (
> + GraphicsOutput,
> + ModeNumber,
> + &SizeOfInfo,
> + &Info
> + );
> + if (!EFI_ERROR (Status)) {
> + if ((Info->HorizontalResolution == mShellHorizontalResolution) &&
> + (Info->VerticalResolution == mShellVerticalResolution)) {
> + if ((GraphicsOutput->Mode->Info->HorizontalResolution == mShellHorizontalResolution) &&
> + (GraphicsOutput->Mode->Info->VerticalResolution == mShellVerticalResolution)) {
> + //
> + // If current video resolution is same with new resolution,
> + // then check if current text mode is same with new text mode.
> + //
> + Status = SimpleTextOut->QueryMode (SimpleTextOut, SimpleTextOut->Mode->Mode, &CurrentColumn, &CurrentRow);
> + ASSERT_EFI_ERROR (Status);
> + if (CurrentColumn == mShellModeColumn && CurrentRow == mShellModeRow) {
> + //
> + // Current text mode is same with new text mode, text mode need not be change.
> + //
> + FreePool (Info);
> + return EFI_SUCCESS;
> + } else {
> + //
> + // Current text mode is different with new text mode, text mode need be change to new text mode.
> + //
> + for (Index = 0; Index < MaxTextMode; Index++) {
> + Status = SimpleTextOut->QueryMode (SimpleTextOut, Index, &CurrentColumn, &CurrentRow);
> + if (!EFI_ERROR(Status)) {
> + if ((CurrentColumn == mShellModeColumn) && (CurrentRow == mShellModeRow)) {
> + //
> + // New text mode is supported, set it.
> + //
> + Status = SimpleTextOut->SetMode (SimpleTextOut, Index);
> + ASSERT_EFI_ERROR (Status);
> + //
> + // Update text mode PCD.
> + //
> + Status = PcdSet32S (PcdConOutColumn, mShellModeColumn);
> + ASSERT_EFI_ERROR (Status);
> +
> + Status = PcdSet32S (PcdConOutRow, mShellModeRow);
> + ASSERT_EFI_ERROR (Status);
> +
> + FreePool (Info);
> + return EFI_SUCCESS;
> + }
> + }
> + }
> + if (Index == MaxTextMode) {
> + //
> + // If new text mode is not supported, return error.
> + //
> + FreePool (Info);
> + return EFI_UNSUPPORTED;
> + }
> + }
> + } else {
> + FreePool (Info);
> + //
> + // If current video resolution is not same with the new one, set new video resolution.
> + // In this case, the driver which produces simple text out need be restarted.
> + //
> + Status = GraphicsOutput->SetMode (GraphicsOutput, ModeNumber);
> + if (!EFI_ERROR (Status)) {
> + //
> + // Set PCD to restart GraphicsConsole and Consplitter to change video resolution
> + // and produce new text mode based on new resolution.
> + //
> + Status = PcdSet32S (PcdVideoHorizontalResolution, mShellHorizontalResolution);
> + ASSERT_EFI_ERROR (Status);
> +
> + Status = PcdSet32S (PcdVideoVerticalResolution, mShellVerticalResolution);
> + ASSERT_EFI_ERROR (Status);
> +
> + Status = PcdSet32S (PcdConOutColumn, mShellModeColumn);
> + ASSERT_EFI_ERROR (Status);
> +
> + Status = PcdSet32S (PcdConOutRow, mShellModeRow);
> + ASSERT_EFI_ERROR (Status);
> +
> + Status = gBS->LocateHandleBuffer (
> + ByProtocol,
> + &gEfiSimpleTextOutProtocolGuid,
> + NULL,
> + &HandleCount,
> + &HandleBuffer
> + );
> + if (!EFI_ERROR (Status)) {
> + for (Index = 0; Index < HandleCount; Index++) {
> + gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);
> + }
> + for (Index = 0; Index < HandleCount; Index++) {
> + gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
> + }
> + if (HandleBuffer != NULL) {
> + FreePool (HandleBuffer);
> + }
> + break;
> + }
> + }
> + }
> + }
> + FreePool (Info);
> + }
> + }
> +
> + if (ModeNumber == MaxGopMode) {
> + //
> + // If the new resolution is not supported, return error.
> + //
> + return EFI_UNSUPPORTED;
> + }
> +
> + return EFI_SUCCESS;
> +}
> +
> +
> +/**
> + The function connects the trusted consoles and then call the PP processing library interface.
> +**/
> +VOID
> +ProcessTcgPp (
> + VOID
> + )
> +{
> + gPPRequireUIConfirm |= Tcg2PhysicalPresenceLibNeedUserConfirm();
> +
> + if (gPPRequireUIConfirm) {
> + ConnectTrustedConsole ();
> + }
> +
> + Tcg2PhysicalPresenceLibProcessRequest (NULL);
> +}
> +
> +
> +/**
> + The function connects the trusted storage to perform TPerReset.
> +**/
> +VOID
> +ProcessTcgMor (
> + VOID
> + )
> +{
> + if (IsMorBitSet ()) {
> + ConnectTrustedConsole();
> + ConnectTrustedStorage();
> + }
> +}
> +
> +
> +/**
> + Update the ConIn variable with USB Keyboard device path,if its not already exists in ConIn
> +**/
> +VOID
> +EnumUsbKeyboard (
> + VOID
> + )
> +{
> + DEBUG ((DEBUG_INFO, "[EnumUsbKeyboard]\n"));
> + EfiBootManagerUpdateConsoleVariable (ConIn, (EFI_DEVICE_PATH_PROTOCOL *) &gUsbClassKeyboardDevicePath, NULL);
> + //
> + // Append Usb Keyboard short form DevicePath into "ConInDev"
> + //
> + EfiBootManagerUpdateConsoleVariable (ConInDev, (EFI_DEVICE_PATH_PROTOCOL *) &gUsbClassKeyboardDevicePath, NULL);
> +}
> +
> +
> +/**
> + Connect with predeined platform connect sequence,
> + the OEM/IBV can customize with their own connect sequence.
> +
> + @param[in] BootMode Boot mode of this boot.
> +**/
> +VOID
> +ConnectSequence (
> + IN EFI_BOOT_MODE BootMode
> + )
> +{
> + EfiBootManagerConnectAll ();
> +}
> +
> +
> +/**
> + The function is to consider the boot order which is not in our expectation.
> + In the case that we need to re-sort the boot option.
> +
> + @retval TRUE Need to sort Boot Option.
> + @retval FALSE Don't need to sort Boot Option.
> +**/
> +BOOLEAN
> +IsNeedSortBootOption (
> + VOID
> + )
> +{
> + EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
> + UINTN BootOptionCount;
> +
> + BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);
> +
> + //
> + // If setup is the first priority in boot option, we need to sort boot option.
> + //
> + if ((BootOptionCount > 1) &&
> + (((StrnCmp (BootOptions->Description, L"Enter Setup", StrLen (L"Enter Setup"))) == 0) ||
> + ((StrnCmp (BootOptions->Description, L"BootManagerMenuApp", StrLen (L"BootManagerMenuApp"))) == 0))) {
> + return TRUE;
> + }
> +
> + return FALSE;
> +}
> +
> +
> +/**
> + Connects Root Bridge
> + **/
> +VOID
> +ConnectRootBridge (
> + BOOLEAN Recursive
> + )
> +{
> + UINTN RootBridgeHandleCount;
> + EFI_HANDLE *RootBridgeHandleBuffer;
> + UINTN RootBridgeIndex;
> +
> + RootBridgeHandleCount = 0;
> + gBS->LocateHandleBuffer (
> + ByProtocol,
> + &gEfiPciRootBridgeIoProtocolGuid,
> + NULL,
> + &RootBridgeHandleCount,
> + &RootBridgeHandleBuffer
> + );
> + for (RootBridgeIndex = 0; RootBridgeIndex < RootBridgeHandleCount; RootBridgeIndex++) {
> + gBS->ConnectController (RootBridgeHandleBuffer[RootBridgeIndex], NULL, NULL, Recursive);
> + }
> +}
> +
> +VOID
> +AddConsoleVariable (
> + IN CONSOLE_TYPE ConsoleType,
> + IN EFI_DEVICE_PATH *ConsoleDevicePath
> + )
> +{
> + EFI_DEVICE_PATH *TempDevicePath;
> + EFI_DEVICE_PATH *Instance;
> + UINTN Size;
> + EFI_HANDLE GraphicsControllerHandle;
> + EFI_DEVICE_PATH *GopDevicePath;
> +
> + TempDevicePath = ConsoleDevicePath;
> + do {
> + Instance = GetNextDevicePathInstance (&TempDevicePath, &Size);
> + if (Instance == NULL) {
> + break;
> + }
> +
> + switch (ConsoleType) {
> + case ConIn:
> + if (IsUsbShortForm (Instance)) {
> + //
> + // Append Usb Keyboard short form DevicePath into "ConInDev"
> + //
> + EfiBootManagerUpdateConsoleVariable (ConInDev, Instance, NULL);
> + }
> + EfiBootManagerUpdateConsoleVariable (ConsoleType, Instance, NULL);
> + break;
> + case ConOut:
> + GraphicsControllerHandle = IsVideoController (Instance);
> + if (GraphicsControllerHandle == NULL) {
> + EfiBootManagerUpdateConsoleVariable (ConsoleType, Instance, NULL);
> + } else {
> + //
> + // Connect the GOP driver
> + //
> + gBS->ConnectController (GraphicsControllerHandle, NULL, NULL, TRUE);
> + //
> + // Get the GOP device path
> + // NOTE: We may get a device path that contains Controller node in it.
> + //
> + GopDevicePath = EfiBootManagerGetGopDevicePath (GraphicsControllerHandle);
> + if (GopDevicePath != NULL) {
> + EfiBootManagerUpdateConsoleVariable (ConsoleType, GopDevicePath, NULL);
> + }
> + }
> + break;
> + default:
> + ASSERT(FALSE);
> + break;
> + }
> +
> + FreePool (Instance);
> + } while (TempDevicePath != NULL);
> +}
> +
> +
> +/**
> + This is the callback function for PCI ENUMERATION COMPLETE.
> +
> + @param[in] Event The Event this notify function registered to.
> + @param[in] Context Pointer to the context data registered to the Event.
> +**/
> +VOID
> +EFIAPI
> +BdsPciEnumCompleteCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + )
> +{
> + EFI_STATUS Status;
> + VOID *ProtocolPointer;
> + EFI_DEVICE_PATH_PROTOCOL *VarConOut;
> + EFI_DEVICE_PATH_PROTOCOL *VarConIn;
> +
> + Status = EFI_SUCCESS;
> +
> + //
> + // Check if this is first time called by EfiCreateProtocolNotifyEvent() or not,
> + // if it is, we will skip it until real event is triggered
> + //
> + Status = gBS->LocateProtocol (&gEfiPciEnumerationCompleteProtocolGuid, NULL, (VOID **) &ProtocolPointer);
> + if (EFI_SUCCESS != Status) {
> + return;
> + }
> + //gBS->CloseEvent (Event);
> +
> +
> + DEBUG ((DEBUG_INFO, "Event BdsPciEnumCompleteCallback callback starts\n"));
> +
> + gBootMode = GetBootModeHob ();
> +
> + //
> + // Connect Root Bridge to make PCI BAR resource allocated and all PciIo created
> + //
> + ConnectRootBridge (FALSE);
> +
> + //
> + // Fill ConIn/ConOut in Full Configuration boot mode
> + //
> + DEBUG ((DEBUG_INFO, "PlatformBootManagerInit - %x\n", gBootMode));
> +
> +
> + if (gBootMode == BOOT_WITH_FULL_CONFIGURATION ||
> + gBootMode == BOOT_WITH_DEFAULT_SETTINGS ||
> + gBootMode == BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS ||
> + gBootMode == BOOT_IN_RECOVERY_MODE) {
> +
> + GetEfiGlobalVariable2 (L"ConOut", (VOID **)&VarConOut, NULL);
> + if (VarConOut != NULL) {
> + FreePool (VarConOut);
> + }
> +
> + GetEfiGlobalVariable2 (L"ConIn", (VOID **)&VarConIn, NULL);
> + if (VarConIn != NULL) {
> + FreePool (VarConIn);
> + }
> +
> + //
> + // Only fill ConIn/ConOut when ConIn/ConOut is empty because we may drop to Full Configuration boot mode in non-first boot
> + //
> + if (VarConOut == NULL || VarConIn == NULL) {
> + if (PcdGetSize (PcdTrustedConsoleOutputDevicePath) >= sizeof(EFI_DEVICE_PATH_PROTOCOL)) {
> + AddConsoleVariable (ConOut, PcdGetPtr (PcdTrustedConsoleOutputDevicePath));
> + }
> + if (PcdGetSize (PcdTrustedConsoleInputDevicePath) >= sizeof(EFI_DEVICE_PATH_PROTOCOL)) {
> + AddConsoleVariable (ConIn, PcdGetPtr (PcdTrustedConsoleInputDevicePath));
> + }
> + }
> + }
> +
> +}
> +
> +/**
> + This is the callback function for Smm Ready To Lock.
> +
> + @param[in] Event The Event this notify function registered to.
> + @param[in] Context Pointer to the context data registered to the Event.
> +**/
> +VOID
> +EFIAPI
> +BdsSmmReadyToLockCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + )
> +{
> + VOID *ProtocolPointer;
> + EFI_STATUS Status;
> + //
> + // Check if this is first time called by EfiCreateProtocolNotifyEvent() or not,
> + // if it is, we will skip it until real event is triggered
> + //
> + Status = gBS->LocateProtocol (&gEfiDxeSmmReadyToLockProtocolGuid, NULL, (VOID **) &ProtocolPointer);
> + if (EFI_SUCCESS != Status) {
> + return;
> + }
> +
> + DEBUG ((DEBUG_INFO, "Event gEfiDxeSmmReadyToLockProtocolGuid callback starts\n"));
> +
> + //
> + // Dispatch the deferred 3rd party images.
> + //
> + EfiBootManagerDispatchDeferredImages ();
> +
> + //
> + // For non-trusted console it must be handled here.
> + //
> + UpdateGraphicConOut (FALSE);
> +}
> +
> +/**
> + ReadyToBoot callback to set video and text mode for internal shell boot.
> + That will not connect USB controller while CSM and FastBoot are disabled, we need to connect them
> + before booting to Shell for showing USB devices in Shell.
> +
> + When FastBoot is enabled and Windows Console is the chosen Console behavior, input devices will not be connected
> + by default. Hence, when booting to EFI shell, connecting input consoles are required.
> +
> + @param Event Pointer to this event
> + @param Context Event hanlder private data
> +
> + @retval None.
> +**/
> +VOID
> +EFIAPI
> +BdsReadyToBootCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + )
> +{
> + DEBUG ((DEBUG_INFO, "BdsReadyToBootCallback\n"));
> +
> + if (BootCurrentIsInternalShell ()) {
> +
> + ChangeModeForInternalShell ();
> + EfiBootManagerConnectAllDefaultConsoles ();
> + gDS->Dispatch ();
> + }
> +}
> +
> +
> +/**
> + Before console after trusted console event callback
> +
> + @param[in] Event The Event this notify function registered to.
> + @param[in] Context Pointer to the context data registered to the Event.
> +**/
> +VOID
> +BdsBeforeConsoleAfterTrustedConsoleCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + )
> +{
> + DEBUG ((DEBUG_INFO, "Event gBdsEventBeforeConsoleBeforeEndOfDxeGuid callback starts\n"));
> +
> + //
> + // Enumerate USB keyboard
> + //
> + EnumUsbKeyboard ();
> +
> + //
> + // For trusted console it must be handled here.
> + //
> + UpdateGraphicConOut (TRUE);
> +
> + //
> + // Register Boot Options
> + //
> + RegisterDefaultBootOption ();
> +
> + //
> + // Register Static Hot keys
> + //
> + RegisterStaticHotkey ();
> +
> + //
> + // Process Physical Preo
> + //
> + PERF_START_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7010);
> + if (PcdGetBool (PcdTpm2Enable)) {
> + ProcessTcgPp ();
> + ProcessTcgMor ();
> + }
> + PERF_END_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7011);
> +
> + //
> + // Perform memory test
> + // We should make all UEFI memory and GCD information populated before ExitPmAuth.
> + // SMM may consume these information.
> + //
> + MemoryTest((EXTENDMEM_COVERAGE_LEVEL) PcdGet32 (PcdPlatformMemoryCheckLevel));
> +}
> +
> +
> +/**
> + Before console before end of DXE event callback
> +
> + @param[in] Event The Event this notify function registered to.
> + @param[in] Context Pointer to the context data registered to the Event.
> +**/
> +VOID
> +BdsBeforeConsoleBeforeEndOfDxeGuidCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + )
> +{
> + DEBUG ((DEBUG_INFO, "Event gBdsBeforeConsoleBeforeEndOfDxeGuid callback starts\n"));
> +
> +}
> +
> +
> +/**
> + After console ready before boot option event callback
> +
> + @param[in] Event The Event this notify function registered to.
> + @param[in] Context Pointer to the context data registered to the Event.
> +**/
> +VOID
> +BdsAfterConsoleReadyBeforeBootOptionCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + )
> +{
> + EFI_BOOT_MODE LocalBootMode;
> +
> + DEBUG ((DEBUG_INFO, "Event gBdsAfterConsoleReadyBeforeBootOptionEvent callback starts\n"));
> + //
> + // Get current Boot Mode
> + //
> + LocalBootMode = gBootMode;
> + DEBUG ((DEBUG_INFO, "Current local bootmode - %x\n", LocalBootMode));
> +
> + //
> + // Go the different platform policy with different boot mode
> + // Notes: this part code can be change with the table policy
> + //
> + switch (LocalBootMode) {
> + case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:
> + case BOOT_WITH_MINIMAL_CONFIGURATION:
> + case BOOT_ON_S4_RESUME:
> + //
> + // Perform some platform specific connect sequence
> + //
> + PERF_START_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7050);
> + ConnectSequence (LocalBootMode);
> + PERF_END_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7051);
> +
> + break;
> +
> + case BOOT_WITH_FULL_CONFIGURATION:
> + case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:
> + case BOOT_WITH_DEFAULT_SETTINGS:
> + default:
> + //
> + // Perform some platform specific connect sequence
> + //
> + ConnectSequence (LocalBootMode);
> +
> + //
> + // Only in Full Configuration boot mode we do the enumeration of boot device
> + //
> + //
> + // Dispatch all but Storage Oprom explicitly, because we assume Int13Thunk driver is there.
> + //
> +
> + //
> + // PXE boot option may appear after boot option enumeration
> + //
> + break;
> + }
> +
> + Print (L"Press F7 for BootMenu!\n");
> +
> + EfiBootManagerRefreshAllBootOption ();
> +
> + if (IsNeedSortBootOption()) {
> + EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot, CompareBootOption);
> + }
> +}
> diff --git a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
> new file mode 100644
> index 0000000000..69f3fcb552
> --- /dev/null
> +++ b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
> @@ -0,0 +1,95 @@
> +### @file
> +# Module Information file for the Bds Hook Library.
> +#
> +# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +###
> +
> +[Defines]
> + INF_VERSION = 0x00010017
> + BASE_NAME = BoardBdsHookLib
> + FILE_GUID = 649A7502-7301-4E3A-A99B-EA91AD6DD7A8
> + VERSION_STRING = 1.0
> + MODULE_TYPE = DXE_DRIVER
> + LIBRARY_CLASS = BoardBdsHookLib|DXE_DRIVER
> +
> +[LibraryClasses]
> + BaseLib
> + MemoryAllocationLib
> + UefiBootServicesTableLib
> + UefiRuntimeServicesTableLib
> + BaseMemoryLib
> + DebugLib
> + PcdLib
> + PrintLib
> + DevicePathLib
> + UefiLib
> + HobLib
> + DxeServicesLib
> + DxeServicesTableLib
> + HiiLib
> + UefiBootManagerLib
> + PerformanceLib
> + TimerLib
> + Tcg2PhysicalPresenceLib
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + SecurityPkg/SecurityPkg.dec
> + MinPlatformPkg/MinPlatformPkg.dec
> + BoardModulePkg/BoardModulePkg.dec
> +
> +[Pcd]
> + gMinPlatformPkgTokenSpaceGuid.PcdTpm2Enable ## CONSUMES
> + gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut ## PRODUCES
> + gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution ## PRODUCES
> + gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution ## PRODUCES
> + gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow ## PRODUCES
> + gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn ## PRODUCES
> + gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutColumn ## CONSUMES
> + gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutRow ## CONSUMES
> + gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution ## CONSUMES
> + gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution ## CONSUMES
> + gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand ## PRODUCES
> + gMinPlatformPkgTokenSpaceGuid.PcdPlatformMemoryCheckLevel ## CONSUMES
> + gMinPlatformPkgTokenSpaceGuid.PcdBootToShellOnly ## CONSUMES
> + gMinPlatformPkgTokenSpaceGuid.PcdTrustedConsoleInputDevicePath ## CONSUMES
> + gMinPlatformPkgTokenSpaceGuid.PcdTrustedConsoleOutputDevicePath ## CONSUMES
> + gMinPlatformPkgTokenSpaceGuid.PcdTrustedStorageDevicePath ## CONSUMES
> +
> +[Sources]
> + BoardBdsHook.h
> + BoardBdsHookLib.c
> + BoardMemoryTest.c
> + BoardBootOption.c
> +
> +[Protocols]
> + gEfiPciRootBridgeIoProtocolGuid ## CONSUMES
> + gEfiPciIoProtocolGuid ## CONSUMES
> + gEfiCpuIo2ProtocolGuid ## CONSUMES
> + gEfiDxeSmmReadyToLockProtocolGuid ## PRODUCES
> + gEfiGenericMemTestProtocolGuid ## CONSUMES
> + gEfiDiskInfoProtocolGuid ## CONSUMES
> + gEfiDevicePathToTextProtocolGuid ## CONSUMES
> + gEfiSimpleTextInputExProtocolGuid ## CONSUMES
> + gEfiFirmwareVolume2ProtocolGuid ## CONSUMES
> + gEfiFormBrowser2ProtocolGuid ## CONSUMES
> + gEfiGenericMemTestProtocolGuid ## CONSUMES
> + gEfiDxeSmmReadyToLockProtocolGuid
> +
> +[Guids]
> + gEfiGlobalVariableGuid ## PRODUCES
> + gEfiMemoryOverwriteControlDataGuid ## PRODUCES
> + gEfiEndOfDxeEventGroupGuid ## CONSUMES
> + gBdsEventBeforeConsoleAfterTrustedConsoleGuid
> + gBdsEventBeforeConsoleBeforeEndOfDxeGuid
> + gBdsEventAfterConsoleReadyBeforeBootOptionGuid
> +
> +[Depex.common.DXE_DRIVER]
> + gEfiVariableArchProtocolGuid
> +
> +[Depex]
> + TRUE
> diff --git a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBootOption.c b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBootOption.c
> new file mode 100644
> index 0000000000..87138bdd79
> --- /dev/null
> +++ b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBootOption.c
> @@ -0,0 +1,598 @@
> +/** @file
> + Driver for Platform Boot Options support.
> +
> +Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include "BoardBdsHook.h"
> +
> +BOOLEAN mContinueBoot = FALSE;
> +BOOLEAN mBootMenuBoot = FALSE;
> +BOOLEAN mPxeBoot = FALSE;
> +BOOLEAN mHotKeypressed = FALSE;
> +EFI_EVENT HotKeyEvent = NULL;
> +
> +UINTN mBootMenuOptionNumber;
> +
> +
> +/**
> + This function will create a SHELL BootOption to boot.
> +
> + @return Shell Device path for booting.
> +**/
> +EFI_DEVICE_PATH_PROTOCOL *
> +BdsCreateShellDevicePath (
> + VOID
> + )
> +{
> + UINTN FvHandleCount;
> + EFI_HANDLE *FvHandleBuffer;
> + UINTN Index;
> + EFI_STATUS Status;
> + EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
> + UINTN Size;
> + UINT32 AuthenticationStatus;
> + EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> + VOID *Buffer;
> +
> + DevicePath = NULL;
> + Status = EFI_SUCCESS;
> +
> + DEBUG ((DEBUG_INFO, "BdsCreateShellDevicePath\n"));
> + gBS->LocateHandleBuffer (
> + ByProtocol,
> + &gEfiFirmwareVolume2ProtocolGuid,
> + NULL,
> + &FvHandleCount,
> + &FvHandleBuffer
> + );
> +
> + for (Index = 0; Index < FvHandleCount; Index++) {
> + gBS->HandleProtocol (
> + FvHandleBuffer[Index],
> + &gEfiFirmwareVolume2ProtocolGuid,
> + (VOID **) &Fv
> + );
> +
> + Buffer = NULL;
> + Size = 0;
> + Status = Fv->ReadSection (
> + Fv,
> + &gUefiShellFileGuid,
> + EFI_SECTION_PE32,
> + 0,
> + &Buffer,
> + &Size,
> + &AuthenticationStatus
> + );
> + if (EFI_ERROR (Status)) {
> + //
> + // Skip if no shell file in the FV
> + //
> + continue;
> + } else {
> + //
> + // Found the shell
> + //
> + break;
> + }
> + }
> +
> + if (EFI_ERROR (Status)) {
> + //
> + // No shell present
> + //
> + if (FvHandleCount) {
> + FreePool (FvHandleBuffer);
> + }
> + return NULL;
> + }
> + //
> + // Build the shell boot option
> + //
> + DevicePath = DevicePathFromHandle (FvHandleBuffer[Index]);
> +
> + if (FvHandleCount) {
> + FreePool (FvHandleBuffer);
> + }
> +
> + return DevicePath;
> +}
> +
> +
> +EFI_STATUS
> +CreateFvBootOption (
> + EFI_GUID *FileGuid,
> + CHAR16 *Description,
> + EFI_BOOT_MANAGER_LOAD_OPTION *BootOption,
> + UINT32 Attributes,
> + UINT8 *OptionalData, OPTIONAL
> + UINT32 OptionalDataSize
> + )
> +{
> + EFI_STATUS Status;
> + EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> + EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
> + MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
> + EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
> + UINT32 AuthenticationStatus;
> + VOID *Buffer;
> + UINTN Size;
> +
> + if ((BootOption == NULL) || (FileGuid == NULL) || (Description == NULL)) {
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);
> +
> + if (!CompareGuid (&gUefiShellFileGuid, FileGuid)) {
> + Status = gBS->HandleProtocol (
> + gImageHandle,
> + &gEfiLoadedImageProtocolGuid,
> + (VOID **) &LoadedImage
> + );
> + if (!EFI_ERROR (Status)) {
> + Status = gBS->HandleProtocol (
> + LoadedImage->DeviceHandle,
> + &gEfiFirmwareVolume2ProtocolGuid,
> + (VOID **) &Fv
> + );
> + if (!EFI_ERROR (Status)) {
> + Buffer = NULL;
> + Size = 0;
> + Status = Fv->ReadSection (
> + Fv,
> + FileGuid,
> + EFI_SECTION_PE32,
> + 0,
> + &Buffer,
> + &Size,
> + &AuthenticationStatus
> + );
> + if (Buffer != NULL) {
> + FreePool (Buffer);
> + }
> + }
> + }
> + if (EFI_ERROR (Status)) {
> + return EFI_NOT_FOUND;
> + }
> +
> + DevicePath = AppendDevicePathNode (
> + DevicePathFromHandle (LoadedImage->DeviceHandle),
> + (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
> + );
> + } else {
> + DevicePath = AppendDevicePathNode (
> + BdsCreateShellDevicePath (),
> + (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
> + );
> + }
> +
> + Status = EfiBootManagerInitializeLoadOption (
> + BootOption,
> + LoadOptionNumberUnassigned,
> + LoadOptionTypeBoot,
> + Attributes,
> + Description,
> + DevicePath,
> + OptionalData,
> + OptionalDataSize
> + );
> + FreePool (DevicePath);
> + return Status;
> +}
> +
> +EFI_GUID mUiFile = {
> + 0x462CAA21, 0x7614, 0x4503, { 0x83, 0x6E, 0x8A, 0xB6, 0xF4, 0x66, 0x23, 0x31 }
> +};
> +EFI_GUID mBootMenuFile = {
> + 0xEEC25BDC, 0x67F2, 0x4D95, { 0xB1, 0xD5, 0xF8, 0x1B, 0x20, 0x39, 0xD1, 0x1D }
> +};
> +
> +
> +/**
> + Return the index of the load option in the load option array.
> +
> + The function consider two load options are equal when the
> + OptionType, Attributes, Description, FilePath and OptionalData are equal.
> +
> + @param Key Pointer to the load option to be found.
> + @param Array Pointer to the array of load options to be found.
> + @param Count Number of entries in the Array.
> +
> + @retval -1 Key wasn't found in the Array.
> + @retval 0 ~ Count-1 The index of the Key in the Array.
> +**/
> +INTN
> +PlatformFindLoadOption (
> + IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Key,
> + IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Array,
> + IN UINTN Count
> + )
> +{
> + UINTN Index;
> +
> + for (Index = 0; Index < Count; Index++) {
> + if ((Key->OptionType == Array[Index].OptionType) &&
> + (Key->Attributes == Array[Index].Attributes) &&
> + (StrCmp (Key->Description, Array[Index].Description) == 0) &&
> + (CompareMem (Key->FilePath, Array[Index].FilePath, GetDevicePathSize (Key->FilePath)) == 0) &&
> + (Key->OptionalDataSize == Array[Index].OptionalDataSize) &&
> + (CompareMem (Key->OptionalData, Array[Index].OptionalData, Key->OptionalDataSize) == 0)) {
> + return (INTN) Index;
> + }
> + }
> +
> + return -1;
> +}
> +
> +
> +/**
> + Registers a boot option
> +
> + @param FileGuid Boot file GUID
> + @param Description Boot option discription
> + @param Position Position of the new load option to put in the ****Order variable.
> + @param Attributes Boot option attributes
> + @param OptionalData Optional data of the boot option.
> + @param OptionalDataSize Size of the optional data of the boot option
> +
> + @return boot option number
> +**/
> +UINTN
> +RegisterFvBootOption (
> + EFI_GUID *FileGuid,
> + CHAR16 *Description,
> + UINTN Position,
> + UINT32 Attributes,
> + UINT8 *OptionalData, OPTIONAL
> + UINT32 OptionalDataSize
> + )
> +{
> + EFI_STATUS Status;
> + UINTN OptionIndex;
> + EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
> + EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
> + UINTN BootOptionCount;
> +
> + NewOption.OptionNumber = LoadOptionNumberUnassigned;
> + Status = CreateFvBootOption (FileGuid, Description, &NewOption, Attributes, OptionalData, OptionalDataSize);
> + if (!EFI_ERROR (Status)) {
> + BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);
> +
> + OptionIndex = PlatformFindLoadOption (&NewOption, BootOptions, BootOptionCount);
> +
> + if (OptionIndex == -1) {
> + Status = EfiBootManagerAddLoadOptionVariable (&NewOption, Position);
> + ASSERT_EFI_ERROR (Status);
> + } else {
> + NewOption.OptionNumber = BootOptions[OptionIndex].OptionNumber;
> + }
> + EfiBootManagerFreeLoadOption (&NewOption);
> + EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
> + }
> +
> + return NewOption.OptionNumber;
> +}
> +
> +
> +/**
> + Boot manager wait callback
> +
> + @param TimeoutRemain The remaingin timeout period
> +**/
> +VOID
> +EFIAPI
> +PlatformBootManagerWaitCallback (
> + UINT16 TimeoutRemain
> + )
> +{
> + EFI_STATUS Status;
> + EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TxtInEx;
> + EFI_KEY_DATA KeyData;
> + BOOLEAN PausePressed;
> +
> + //
> + // Pause on PAUSE key
> + //
> + Status = gBS->HandleProtocol (gST->ConsoleInHandle, &gEfiSimpleTextInputExProtocolGuid, (VOID **) &TxtInEx);
> + ASSERT_EFI_ERROR (Status);
> +
> + PausePressed = FALSE;
> +
> + while (TRUE) {
> + Status = TxtInEx->ReadKeyStrokeEx (TxtInEx, &KeyData);
> + if (EFI_ERROR (Status)) {
> + break;
> + }
> +
> + if (KeyData.Key.ScanCode == SCAN_PAUSE) {
> + PausePressed = TRUE;
> + break;
> + }
> + }
> +
> + //
> + // Loop until non-PAUSE key pressed
> + //
> + while (PausePressed) {
> + Status = TxtInEx->ReadKeyStrokeEx (TxtInEx, &KeyData);
> + if (!EFI_ERROR (Status)) {
> + DEBUG ((
> + DEBUG_INFO, "[PauseCallback] %x/%x %x/%x\n",
> + KeyData.Key.ScanCode, KeyData.Key.UnicodeChar,
> + KeyData.KeyState.KeyShiftState, KeyData.KeyState.KeyToggleState
> + ));
> + PausePressed = (BOOLEAN) (KeyData.Key.ScanCode == SCAN_PAUSE);
> + }
> + }
> +}
> +
> +
> +EFI_GUID gUefiShellFileGuid = { 0x7C04A583, 0x9E3E, 0x4f1c, { 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 } };
> +
> +#define INTERNAL_UEFI_SHELL_NAME L"Internal UEFI Shell 2.0"
> +#define UEFI_HARD_DRIVE_NAME L"UEFI Hard Drive"
> +
> +/**
> + Registers default boot option
> +**/
> +
> +VOID
> +RegisterDefaultBootOption (
> + VOID
> + )
> +{
> + UINT16 *ShellData;
> + UINT32 ShellDataSize;
> +
> + ShellData = NULL;
> + ShellDataSize = 0;
> + RegisterFvBootOption (&gUefiShellFileGuid, INTERNAL_UEFI_SHELL_NAME, (UINTN) -1, LOAD_OPTION_ACTIVE, (UINT8 *)ShellData, ShellDataSize);
> +
> + //
> + // Boot Menu
> + //
> + mBootMenuOptionNumber = RegisterFvBootOption (&mBootMenuFile, L"Boot Device List", (UINTN) -1, LOAD_OPTION_CATEGORY_APP | LOAD_OPTION_ACTIVE | LOAD_OPTION_HIDDEN, NULL, 0);
> +
> + if (mBootMenuOptionNumber == LoadOptionNumberUnassigned) {
> + DEBUG ((DEBUG_INFO, "BootMenuOptionNumber (%d) should not be same to LoadOptionNumberUnassigned(%d).\n", mBootMenuOptionNumber, LoadOptionNumberUnassigned));
> + }
> +#if 0
> + //
> + // Boot Manager Menu
> + //
> + EfiInitializeFwVolDevicepathNode (&FileNode, &mUiFile);
> +
> + gBS->HandleProtocol (
> + gImageHandle,
> + &gEfiLoadedImageProtocolGuid,
> + (VOID **) &LoadedImage
> + );
> + DevicePath = AppendDevicePathNode (DevicePathFromHandle (LoadedImage->DeviceHandle), (EFI_DEVICE_PATH_PROTOCOL *) &FileNode);
> +#endif
> +
> +}
> +
> +/**
> + Registers/Unregisters boot option hotkey
> +
> + @param OptionNumber The boot option number for the key option.
> + @param Key The the key input
> + @param Add Flag to indicate to add or remove a key
> +**/
> +VOID
> +RegisterBootOptionHotkey (
> + UINT16 OptionNumber,
> + EFI_INPUT_KEY *Key,
> + BOOLEAN Add
> + )
> +{
> + EFI_STATUS Status;
> +
> + if (!Add) {
> + //
> + // No enter hotkey when force to setup or there is no boot option
> + //
> + Status = EfiBootManagerDeleteKeyOptionVariable (NULL, 0, Key, NULL);
> + ASSERT (Status == EFI_SUCCESS || Status == EFI_NOT_FOUND);
> + } else {
> + //
> + // Register enter hotkey for the first boot option
> + //
> + Status = EfiBootManagerAddKeyOptionVariable (NULL, OptionNumber, 0, Key,NULL);
> + ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
> + }
> +}
> +
> +
> +/**
> + Detect key press callback
> +
> + @param The key data
> +
> + @retval EFI_SUCCESS
> +**/
> +EFI_STATUS
> +EFIAPI
> +DetectKeypressCallback (
> + IN EFI_KEY_DATA *KeyData
> +)
> +{
> + mHotKeypressed = TRUE;
> +
> + if (HotKeyEvent != NULL) {
> + gBS->SignalEvent(HotKeyEvent);
> + }
> +
> + return EFI_SUCCESS;
> +}
> +
> +/**
> + This function is called after all the boot options are enumerated and ordered properly.
> +**/
> +VOID
> +RegisterStaticHotkey (
> + VOID
> + )
> +{
> +
> + EFI_INPUT_KEY Enter;
> + EFI_KEY_DATA F2;
> + EFI_KEY_DATA F7;
> + BOOLEAN EnterSetup;
> + EFI_STATUS Status;
> + EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
> +
> + EnterSetup = FALSE;
> +
> + //
> + // [Enter]
> + //
> + mContinueBoot = !EnterSetup;
> + if (mContinueBoot) {
> + Enter.ScanCode = SCAN_NULL;
> + Enter.UnicodeChar = CHAR_CARRIAGE_RETURN;
> + EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL);
> + }
> +
> +
> + //
> + // [F2]/[F7]
> + //
> + F2.Key.ScanCode = SCAN_F2;
> + F2.Key.UnicodeChar = CHAR_NULL;
> + F2.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID;
> + F2.KeyState.KeyToggleState = 0;
> + Status = EfiBootManagerGetBootManagerMenu (&BootOption);
> + ASSERT_EFI_ERROR (Status);
> + RegisterBootOptionHotkey ((UINT16) BootOption.OptionNumber, &F2.Key, TRUE);
> + EfiBootManagerFreeLoadOption (&BootOption);
> +
> + F7.Key.ScanCode = SCAN_F7;
> + F7.Key.UnicodeChar = CHAR_NULL;
> + F7.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID;
> + F7.KeyState.KeyToggleState = 0;
> + mBootMenuBoot = !EnterSetup;
> + RegisterBootOptionHotkey ((UINT16) mBootMenuOptionNumber, &F7.Key, mBootMenuBoot);
> +
> +}
> +
> +
> +
> +/**
> + Returns the boot option type of a device
> +
> + @param DevicePath The path of device whose boot option type
> + to be returned
> + @retval -1 Device type not found
> + @retval > -1 Device type found
> +**/
> +UINT8
> +BootOptionType (
> + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
> + )
> +{
> + EFI_DEVICE_PATH_PROTOCOL *Node;
> + EFI_DEVICE_PATH_PROTOCOL *NextNode;
> +
> + for (Node = DevicePath; !IsDevicePathEndType (Node); Node = NextDevicePathNode (Node)) {
> + if (DevicePathType (Node) == MESSAGING_DEVICE_PATH) {
> + //
> + // Make sure the device path points to the driver device.
> + //
> + NextNode = NextDevicePathNode (Node);
> + if (DevicePathSubType(NextNode) == MSG_DEVICE_LOGICAL_UNIT_DP) {
> + //
> + // if the next node type is Device Logical Unit, which specify the Logical Unit Number (LUN),
> + // skip it
> + //
> + NextNode = NextDevicePathNode (NextNode);
> + }
> + if (IsDevicePathEndType (NextNode)) {
> + if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH)) {
> + return DevicePathSubType (Node);
> + } else {
> + return MSG_SATA_DP;
> + }
> + }
> + }
> + }
> +
> + return (UINT8) -1;
> +}
> +
> +/**
> + Returns the priority number.
> + OptionType EFI
> + ------------------------------------
> + PXE 2
> + DVD 4
> + USB 6
> + NVME 7
> + HDD 8
> + EFI Shell 9
> + Others 100
> +
> + @param BootOption
> +**/
> +UINTN
> +BootOptionPriority (
> + CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOption
> + )
> +{
> + //
> + // EFI boot options
> + //
> + switch (BootOptionType (BootOption->FilePath)) {
> + case MSG_MAC_ADDR_DP:
> + case MSG_VLAN_DP:
> + case MSG_IPv4_DP:
> + case MSG_IPv6_DP:
> + return 2;
> +
> + case MSG_SATA_DP:
> + case MSG_ATAPI_DP:
> + case MSG_UFS_DP:
> + case MSG_NVME_NAMESPACE_DP:
> + return 4;
> +
> + case MSG_USB_DP:
> + return 6;
> +
> + }
> + if (StrCmp (BootOption->Description, INTERNAL_UEFI_SHELL_NAME) == 0) {
> + if (PcdGetBool (PcdBootToShellOnly)) {
> + return 0;
> + }
> + return 9;
> + }
> + if (StrCmp (BootOption->Description, UEFI_HARD_DRIVE_NAME) == 0) {
> + return 8;
> + }
> + return 100;
> +}
> +
> +/**
> + Compares boot priorities of two boot options
> +
> + @param Left The left boot option
> + @param Right The right boot option
> +
> + @return The difference between the Left and Right
> + boot options
> + **/
> +INTN
> +EFIAPI
> +CompareBootOption (
> + CONST VOID *Left,
> + CONST VOID *Right
> + )
> +{
> + return BootOptionPriority ((EFI_BOOT_MANAGER_LOAD_OPTION *) Left) -
> + BootOptionPriority ((EFI_BOOT_MANAGER_LOAD_OPTION *) Right);
> +}
> +
> diff --git a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardMemoryTest.c b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardMemoryTest.c
> new file mode 100644
> index 0000000000..e3650721fe
> --- /dev/null
> +++ b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardMemoryTest.c
> @@ -0,0 +1,83 @@
> +/** @file
> + Perform the platform memory test
> +
> +Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include "BoardBdsHook.h"
> +#include <Protocol/GenericMemoryTest.h>
> +
> +/**
> + Perform the memory test base on the memory test intensive level,
> + and update the memory resource.
> +
> + @param Level The memory test intensive level.
> +
> + @retval EFI_STATUS Success test all the system memory and update
> + the memory resource
> +
> +**/
> +EFI_STATUS
> +MemoryTest (
> + IN EXTENDMEM_COVERAGE_LEVEL Level
> + )
> +{
> + EFI_STATUS Status;
> + BOOLEAN RequireSoftECCInit;
> + EFI_GENERIC_MEMORY_TEST_PROTOCOL *GenMemoryTest;
> + UINT64 TestedMemorySize;
> + UINT64 TotalMemorySize;
> + BOOLEAN ErrorOut;
> + BOOLEAN TestAbort;
> +
> + TestedMemorySize = 0;
> + TotalMemorySize = 0;
> + ErrorOut = FALSE;
> + TestAbort = FALSE;
> +
> + RequireSoftECCInit = FALSE;
> +
> + Status = gBS->LocateProtocol (
> + &gEfiGenericMemTestProtocolGuid,
> + NULL,
> + (VOID **) &GenMemoryTest
> + );
> + if (EFI_ERROR (Status)) {
> + return EFI_SUCCESS;
> + }
> +
> + Status = GenMemoryTest->MemoryTestInit (
> + GenMemoryTest,
> + Level,
> + &RequireSoftECCInit
> + );
> + if (Status == EFI_NO_MEDIA) {
> + //
> + // The PEI codes also have the relevant memory test code to check the memory,
> + // it can select to test some range of the memory or all of them. If PEI code
> + // checks all the memory, this BDS memory test will has no not-test memory to
> + // do the test, and then the status of EFI_NO_MEDIA will be returned by
> + // "MemoryTestInit". So it does not need to test memory again, just return.
> + //
> + return EFI_SUCCESS;
> + }
> +
> + do {
> + Status = GenMemoryTest->PerformMemoryTest (
> + GenMemoryTest,
> + &TestedMemorySize,
> + &TotalMemorySize,
> + &ErrorOut,
> + TestAbort
> + );
> + if (ErrorOut && (Status == EFI_DEVICE_ERROR)) {
> + ASSERT (0);
> + }
> + } while (Status != EFI_NOT_FOUND);
> +
> + Status = GenMemoryTest->Finished (GenMemoryTest);
> +
> + return EFI_SUCCESS;
> +}
> --
> 2.19.1.windows.1
>
Thanks,
Nate
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [edk2-platforms] [PATCH 02/11] BoardModulePkg: Add BDS Hook Library
2019-12-14 1:32 ` [edk2-platforms] [PATCH 02/11] BoardModulePkg: Add BDS Hook Library Agyeman, Prince
2019-12-18 1:19 ` Nate DeSimone
@ 2019-12-21 2:36 ` Kubacki, Michael A
1 sibling, 0 replies; 45+ messages in thread
From: Kubacki, Michael A @ 2019-12-21 2:36 UTC (permalink / raw)
To: Agyeman, Prince, devel@edk2.groups.io; +Cc: Chiu, Chasel, Desimone, Nathaniel L
Reviewed-by: Michael Kubacki <michael.a.kubacki@intel.com>
> -----Original Message-----
> From: Agyeman, Prince <prince.agyeman@intel.com>
> Sent: Friday, December 13, 2019 5:32 PM
> To: devel@edk2.groups.io
> Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Chiu, Chasel
> <chasel.chiu@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>
> Subject: [edk2-platforms] [PATCH 02/11] BoardModulePkg: Add BDS Hook
> Library
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
>
> Added a generic board BDS hook library that implements
> BDS hook points as defined in the Minimum platform specification.
>
> This library implements callbacks for the three MinPlatformPkg
> BDS event groups, namely
> gBdsEventBeforeConsoleAfterTrustedConsoleGuid,
> gBdsEventBeforeConsoleBeforeEndOfDxeGuid and
> gBdsEventAfterConsoleReadyBeforeBootOptionGuid.
>
> This Library also implements callbacks for pre-existing event groups:
> gEfiEndOfDxeEventGroupGuid, gEfiPciEnumerationCompleteProtocolGuid,
> gEfiDxeSmmReadyToLockProtocolGuid.
>
> These callbacks can be registered to their respective event groups,
> through other libraries or DXE drivers
>
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
>
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
> .../Include/Library/BoardBdsHookLib.h | 100 ++
> .../Library/BoardBdsHookLib/BoardBdsHook.h | 211 +++
> .../Library/BoardBdsHookLib/BoardBdsHookLib.c | 1390
> +++++++++++++++++
> .../BoardBdsHookLib/BoardBdsHookLib.inf | 95 ++
> .../Library/BoardBdsHookLib/BoardBootOption.c | 598 +++++++
> .../Library/BoardBdsHookLib/BoardMemoryTest.c | 83 +
> 6 files changed, 2477 insertions(+)
> create mode 100644
> Platform/Intel/BoardModulePkg/Include/Library/BoardBdsHookLib.h
> create mode 100644
> Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook.h
> create mode 100644
> Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLi
> b.c
> create mode 100644
> Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLi
> b.inf
> create mode 100644
> Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBootOptio
> n.c
> create mode 100644
> Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardMemoryTe
> st.c
>
> diff --git
> a/Platform/Intel/BoardModulePkg/Include/Library/BoardBdsHookLib.h
> b/Platform/Intel/BoardModulePkg/Include/Library/BoardBdsHookLib.h
> new file mode 100644
> index 0000000000..ba351b7bf4
> --- /dev/null
> +++ b/Platform/Intel/BoardModulePkg/Include/Library/BoardBdsHookLib.h
> @@ -0,0 +1,100 @@
> +/** @file
> +Header file for BDS Hook Library
> +
> +Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef _BDS_HOOK_LIB_H_
> +#define _BDS_HOOK_LIB_H_
> +
> +#include <Library/UefiLib.h>
> +
> +
> +/**
> + This is the callback function for Bds Ready To Boot event.
> +
> + @param Event Pointer to this event
> + @param Context Event hanlder private data
> +
> + @retval None.
> +**/
> +VOID
> +EFIAPI
> +BdsReadyToBootCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + );
> +
> +
> +/**
> + This is the callback function for Smm Ready To Lock event.
> +
> + @param[in] Event The Event this notify function registered to.
> + @param[in] Context Pointer to the context data registered to the Event.
> +**/
> +VOID
> +EFIAPI
> +BdsSmmReadyToLockCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + );
> +
> +
> +/**
> + This is the callback function for PCI ENUMERATION COMPLETE.
> +
> + @param[in] Event The Event this notify function registered to.
> + @param[in] Context Pointer to the context data registered to the Event.
> +**/
> +VOID
> +EFIAPI
> +BdsPciEnumCompleteCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + );
> +
> +
> +/**
> + Before console after trusted console event callback
> +
> + @param[in] Event The Event this notify function registered to.
> + @param[in] Context Pointer to the context data registered to the Event.
> +**/
> +VOID
> +EFIAPI
> +BdsBeforeConsoleAfterTrustedConsoleCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + );
> +
> +
> +/**
> + Before console before end of DXE event callback
> +
> + @param[in] Event The Event this notify function registered to.
> + @param[in] Context Pointer to the context data registered to the Event.
> +**/
> +VOID
> +EFIAPI
> +BdsBeforeConsoleBeforeEndOfDxeGuidCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + );
> +
> +
> +/**
> + After console ready before boot option event callback
> +
> + @param[in] Event The Event this notify function registered to.
> + @param[in] Context Pointer to the context data registered to the Event.
> +**/
> +VOID
> +EFIAPI
> +BdsAfterConsoleReadyBeforeBootOptionCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + );
> +
> +#endif
> diff --git
> a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook
> .h
> b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook
> .h
> new file mode 100644
> index 0000000000..748385499b
> --- /dev/null
> +++
> b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook
> .h
> @@ -0,0 +1,211 @@
> +/** @file
> + Header file for BDS Hook Library
> +
> +Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef _BDS_HOOK_H_
> +#define _BDS_HOOK_H_
> +
> +#include <PiDxe.h>
> +#include <Protocol/DevicePath.h>
> +#include <Protocol/SimpleNetwork.h>
> +#include <Protocol/PciRootBridgeIo.h>
> +#include <Protocol/LoadFile.h>
> +#include <Protocol/PciIo.h>
> +#include <Protocol/CpuIo2.h>
> +#include <Protocol/LoadedImage.h>
> +#include <Protocol/DiskInfo.h>
> +#include <Protocol/GraphicsOutput.h>
> +#include <Protocol/UgaDraw.h>
> +#include <Protocol/GenericMemoryTest.h>
> +#include <Protocol/DevicePathToText.h>
> +#include <Protocol/FirmwareVolume2.h>
> +#include <Protocol/SimpleFileSystem.h>
> +
> +#include <Guid/CapsuleVendor.h>
> +#include <Guid/MemoryTypeInformation.h>
> +#include <Guid/GlobalVariable.h>
> +#include <Guid/MemoryOverwriteControl.h>
> +#include <Guid/FileInfo.h>
> +#include <Library/DebugLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/UefiRuntimeServicesTableLib.h>
> +#include <Library/MemoryAllocationLib.h>
> +#include <Library/BaseLib.h>
> +#include <Library/PcdLib.h>
> +#include <Library/PlatformBootManagerLib.h>
> +#include <Library/DevicePathLib.h>
> +#include <Library/UefiLib.h>
> +#include <Library/HobLib.h>
> +#include <Library/DxeServicesLib.h>
> +#include <Library/DxeServicesTableLib.h>
> +#include <Library/PrintLib.h>
> +#include <Library/HiiLib.h>
> +#include <Library/CapsuleLib.h>
> +#include <Library/PerformanceLib.h>
> +
> +#include <IndustryStandard/Pci30.h>
> +#include <IndustryStandard/PciCodeId.h>
> +#include <Protocol/PciEnumerationComplete.h>
> +
> +///
> +/// ConnectType
> +///
> +#define CONSOLE_OUT 0x00000001
> +#define STD_ERROR 0x00000002
> +#define CONSOLE_IN 0x00000004
> +#define CONSOLE_ALL (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)
> +
> +extern EFI_GUID gUefiShellFileGuid;
> +extern EFI_BOOT_MODE gBootMode;
> +
> +#define gPciRootBridge \
> + { \
> + { \
> + ACPI_DEVICE_PATH, \
> + ACPI_DP, \
> + { \
> + (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \
> + (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \
> + }, \
> + }, \
> + EISA_PNP_ID (0x0A03), \
> + 0 \
> + }
> +
> +#define gEndEntire \
> + { \
> + END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, {
> END_DEVICE_PATH_LENGTH, 0 } \
> + }
> +
> +typedef struct {
> + EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> + UINTN ConnectType;
> +} BDS_CONSOLE_CONNECT_ENTRY;
> +
> +//
> +// Platform Root Bridge
> +//
> +typedef struct {
> + ACPI_HID_DEVICE_PATH PciRootBridge;
> + EFI_DEVICE_PATH_PROTOCOL End;
> +} PLATFORM_ROOT_BRIDGE_DEVICE_PATH;
> +
> +//
> +// Below is the platform console device path
> +//
> +typedef struct {
> + ACPI_HID_DEVICE_PATH PciRootBridge;
> + PCI_DEVICE_PATH IsaBridge;
> + ACPI_HID_DEVICE_PATH Keyboard;
> + EFI_DEVICE_PATH_PROTOCOL End;
> +} PLATFORM_KEYBOARD_DEVICE_PATH;
> +
> +typedef struct {
> + ACPI_HID_DEVICE_PATH PciRootBridge;
> + PCI_DEVICE_PATH PciDevice;
> + EFI_DEVICE_PATH_PROTOCOL End;
> +} PLATFORM_ONBOARD_CONTROLLER_DEVICE_PATH;
> +
> +typedef struct {
> + ACPI_HID_DEVICE_PATH PciRootBridge;
> + PCI_DEVICE_PATH Pci0Device;
> + EFI_DEVICE_PATH_PROTOCOL End;
> +} PLATFORM_PEG_ROOT_CONTROLLER_DEVICE_PATH;
> +
> +typedef struct {
> + ACPI_HID_DEVICE_PATH PciRootBridge;
> + PCI_DEVICE_PATH PciBridge;
> + PCI_DEVICE_PATH PciDevice;
> + EFI_DEVICE_PATH_PROTOCOL End;
> +} PLATFORM_PCI_CONTROLLER_DEVICE_PATH;
> +
> +//
> +// Below is the boot option device path
> +//
> +
> +#define CLASS_HID 3
> +#define SUBCLASS_BOOT 1
> +#define PROTOCOL_KEYBOARD 1
> +
> +typedef struct {
> + USB_CLASS_DEVICE_PATH UsbClass;
> + EFI_DEVICE_PATH_PROTOCOL End;
> +} USB_CLASS_FORMAT_DEVICE_PATH;
> +
> +extern USB_CLASS_FORMAT_DEVICE_PATH
> gUsbClassKeyboardDevicePath;
> +
> +//
> +// Platform BDS Functions
> +//
> +
> +
> +/**
> + Perform the memory test base on the memory test intensive level,
> + and update the memory resource.
> +
> + @param Level The memory test intensive level.
> +
> + @retval EFI_STATUS Success test all the system memory and update
> + the memory resource
> +
> +**/
> +EFI_STATUS
> +MemoryTest (
> + IN EXTENDMEM_COVERAGE_LEVEL Level
> + );
> +
> +/**
> + Connect with predeined platform connect sequence,
> + the OEM/IBV can customize with their own connect sequence.
> +
> + @param[in] BootMode Boot mode of this boot.
> +**/
> +VOID
> +ConnectSequence (
> + IN EFI_BOOT_MODE BootMode
> + );
> +
> +
> +/**
> + Compares boot priorities of two boot options
> +
> + @param Left The left boot option
> + @param Right The right boot option
> +
> + @return The difference between the Left and Right
> + boot options
> + **/
> +INTN
> +EFIAPI
> +CompareBootOption (
> + CONST VOID *Left,
> + CONST VOID *Right
> + );
> +
> +/**
> + This function is called after all the boot options are enumerated and
> ordered properly.
> +**/
> +VOID
> +RegisterStaticHotkey (
> + VOID
> + );
> +
> +
> +/**
> + Registers/Unregisters boot option hotkey
> +
> + @param OptionNumber The boot option number for the key option.
> + @param Key The the key input
> + @param Add Flag to indicate to add or remove a key
> +**/
> +VOID
> +RegisterDefaultBootOption (
> + VOID
> + );
> +
> +#endif
> diff --git
> a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook
> Lib.c
> b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook
> Lib.c
> new file mode 100644
> index 0000000000..9d42a8c27f
> --- /dev/null
> +++
> b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook
> Lib.c
> @@ -0,0 +1,1390 @@
> +/** @file
> + This library registers Bds callbacks. It is a default library
> + implementation instance of the BDS hook library
> +
> + Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Guid/EventGroup.h>
> +
> +#include <Library/IoLib.h>
> +#include <Library/PciLib.h>
> +#include <Library/UefiBootManagerLib.h>
> +#include <Library/Tcg2PhysicalPresenceLib.h>
> +
> +#include <Protocol/BlockIo.h>
> +#include <Protocol/UsbIo.h>
> +#include <Protocol/PciEnumerationComplete.h>
> +
> +#include "BoardBdsHook.h"
> +
> +GLOBAL_REMOVE_IF_UNREFERENCED EFI_BOOT_MODE gBootMode;
> +BOOLEAN gPPRequireUIConfirm;
> +extern UINTN mBootMenuOptionNumber;
> +
> +
> +GLOBAL_REMOVE_IF_UNREFERENCED
> USB_CLASS_FORMAT_DEVICE_PATH gUsbClassKeyboardDevicePath = {
> + {
> + {
> + MESSAGING_DEVICE_PATH,
> + MSG_USB_CLASS_DP,
> + {
> + (UINT8) (sizeof (USB_CLASS_DEVICE_PATH)),
> + (UINT8) ((sizeof (USB_CLASS_DEVICE_PATH)) >> 8)
> + }
> + },
> + 0xffff, // VendorId
> + 0xffff, // ProductId
> + CLASS_HID, // DeviceClass
> + SUBCLASS_BOOT, // DeviceSubClass
> + PROTOCOL_KEYBOARD // DeviceProtocol
> + },
> + gEndEntire
> +};
> +
> +
> +//
> +// BDS Platform Functions
> +//
> +BOOLEAN
> +IsMorBitSet (
> + VOID
> + )
> +{
> + UINTN MorControl;
> + EFI_STATUS Status;
> + UINTN DataSize;
> +
> + //
> + // Check if the MOR bit is set.
> + //
> + DataSize = sizeof (MorControl);
> + Status = gRT->GetVariable (
> + MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME,
> + &gEfiMemoryOverwriteControlDataGuid,
> + NULL,
> + &DataSize,
> + &MorControl
> + );
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_INFO, " gEfiMemoryOverwriteControlDataGuid doesn't
> exist!!***\n"));
> + MorControl = 0;
> + } else {
> + DEBUG ((DEBUG_INFO, " Get the gEfiMemoryOverwriteControlDataGuid
> = %x!!***\n", MorControl));
> + }
> +
> + return (BOOLEAN) (MorControl & 0x01);
> +}
> +
> +
> +/**
> + Prints device paths.
> + @param Name The device name.
> + @param DevicePath The device path to be printed
> +**/
> +VOID
> +EFIAPI
> +DumpDevicePath (
> + IN CHAR16 *Name,
> + IN EFI_DEVICE_PATH *DevicePath
> + )
> +{
> + CHAR16 *Str;
> + Str = ConvertDevicePathToText (DevicePath, TRUE, TRUE);
> + DEBUG ((DEBUG_INFO, "%s: %s\n", Name, Str));
> + if (Str != NULL) {
> + FreePool (Str);
> + }
> +}
> +
> +/**
> + Return whether the device is trusted console.
> +
> + @param Device The device to be tested.
> +
> + @retval TRUE The device can be trusted.
> + @retval FALSE The device cannot be trusted.
> +**/
> +BOOLEAN
> +IsTrustedConsole (
> + IN CONSOLE_TYPE ConsoleType,
> + IN EFI_DEVICE_PATH_PROTOCOL *Device
> + )
> +{
> + VOID *TrustedConsoleDevicepath;
> + EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
> + EFI_DEVICE_PATH_PROTOCOL *Instance;
> + UINTN Size;
> + EFI_DEVICE_PATH_PROTOCOL *ConsoleDevice;
> +
> + if (Device == NULL) {
> + return FALSE;
> + }
> +
> + ConsoleDevice = DuplicateDevicePath (Device);
> +
> + TrustedConsoleDevicepath = NULL;
> +
> + switch (ConsoleType) {
> + case ConIn:
> + TrustedConsoleDevicepath = PcdGetPtr
> (PcdTrustedConsoleInputDevicePath);
> + break;
> + case ConOut:
> + //
> + // Check GOP and remove last node
> + //
> + TempDevicePath = ConsoleDevice;
> + while (!IsDevicePathEndType (TempDevicePath)) {
> + if (DevicePathType (TempDevicePath) == ACPI_DEVICE_PATH &&
> + DevicePathSubType (TempDevicePath) == ACPI_ADR_DP) {
> + SetDevicePathEndNode (TempDevicePath);
> + break;
> + }
> + TempDevicePath = NextDevicePathNode (TempDevicePath);
> + }
> +
> + TrustedConsoleDevicepath = PcdGetPtr
> (PcdTrustedConsoleOutputDevicePath);
> + break;
> + default:
> + ASSERT (FALSE);
> + break;
> + }
> +
> + TempDevicePath = TrustedConsoleDevicepath;
> + do {
> + Instance = GetNextDevicePathInstance (&TempDevicePath, &Size);
> + if (Instance == NULL) {
> + break;
> + }
> +
> + if (CompareMem (ConsoleDevice, Instance, Size -
> END_DEVICE_PATH_LENGTH) == 0) {
> + FreePool (Instance);
> + FreePool (ConsoleDevice);
> + return TRUE;
> + }
> +
> + FreePool (Instance);
> + } while (TempDevicePath != NULL);
> +
> + FreePool (ConsoleDevice);
> +
> + return FALSE;
> +}
> +
> +
> +/**
> + Return whether the USB device path is in a short form.
> +
> + @param DevicePath The device path to be tested.
> +
> + @retval TRUE The device path is in short form.
> + @retval FALSE The device path is not in short form.
> +**/
> +BOOLEAN
> +IsUsbShortForm (
> + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
> + )
> +{
> + if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&
> + ((DevicePathSubType (DevicePath) == MSG_USB_CLASS_DP) ||
> + (DevicePathSubType (DevicePath) == MSG_USB_WWID_DP)) ) {
> + return TRUE;
> + }
> +
> + return FALSE;
> +}
> +
> +/**
> + Connect the USB short form device path.
> +
> + @param DevicePath USB short form device path
> +
> + @retval EFI_SUCCESS Successfully connected the USB device
> + @retval EFI_NOT_FOUND Cannot connect the USB device
> + @retval EFI_INVALID_PARAMETER The device path is invalid.
> +**/
> +EFI_STATUS
> +ConnectUsbShortFormDevicePath (
> + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
> + )
> +{
> + EFI_STATUS Status;
> + EFI_HANDLE *Handles;
> + UINTN HandleCount;
> + UINTN Index;
> + EFI_PCI_IO_PROTOCOL *PciIo;
> + UINT8 Class[3];
> + BOOLEAN AtLeastOneConnected;
> +
> + //
> + // Check the passed in parameters
> + //
> + if (DevicePath == NULL) {
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + if (!IsUsbShortForm (DevicePath)) {
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + //
> + // Find the usb host controller firstly, then connect with the remaining
> device path
> + //
> + AtLeastOneConnected = FALSE;
> + Status = gBS->LocateHandleBuffer (
> + ByProtocol,
> + &gEfiPciIoProtocolGuid,
> + NULL,
> + &HandleCount,
> + &Handles
> + );
> + for (Index = 0; Index < HandleCount; Index++) {
> + Status = gBS->HandleProtocol (
> + Handles[Index],
> + &gEfiPciIoProtocolGuid,
> + (VOID **) &PciIo
> + );
> + if (!EFI_ERROR (Status)) {
> + //
> + // Check whether the Pci device is the wanted usb host controller
> + //
> + Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0x09, 3, &Class);
> + if (!EFI_ERROR (Status) &&
> + ((PCI_CLASS_SERIAL == Class[2]) && (PCI_CLASS_SERIAL_USB ==
> Class[1]))) {
> + Status = gBS->ConnectController (
> + Handles[Index],
> + NULL,
> + DevicePath,
> + FALSE
> + );
> + if (!EFI_ERROR(Status)) {
> + AtLeastOneConnected = TRUE;
> + }
> + }
> + }
> + }
> +
> + return AtLeastOneConnected ? EFI_SUCCESS : EFI_NOT_FOUND;
> +}
> +
> +
> +/**
> + Return whether the Handle is a vga handle.
> +
> + @param Handle The handle to be tested.
> +
> + @retval TRUE The handle is a vga handle.
> + @retval FALSE The handle is not a vga handle..
> +**/
> +BOOLEAN
> +IsVgaHandle (
> + IN EFI_HANDLE Handle
> + )
> +{
> + EFI_PCI_IO_PROTOCOL *PciIo;
> + PCI_TYPE00 Pci;
> + EFI_STATUS Status;
> +
> + Status = gBS->HandleProtocol (
> + Handle,
> + &gEfiPciIoProtocolGuid,
> + (VOID **)&PciIo
> + );
> + if (!EFI_ERROR (Status)) {
> + Status = PciIo->Pci.Read (
> + PciIo,
> + EfiPciIoWidthUint32,
> + 0,
> + sizeof (Pci) / sizeof (UINT32),
> + &Pci
> + );
> + if (!EFI_ERROR (Status)) {
> + if (IS_PCI_VGA (&Pci) || IS_PCI_OLD_VGA (&Pci)) {
> + return TRUE;
> + }
> + }
> + }
> + return FALSE;
> +}
> +
> +
> +/**
> + Return whether the device path points to a video controller.
> +
> + @param DevicePath The device path to be tested.
> +
> + @retval TRUE The device path points to a video controller.
> + @retval FALSE The device path does not point to a video controller.
> +**/
> +EFI_HANDLE
> +IsVideoController (
> + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
> + )
> +{
> + EFI_DEVICE_PATH_PROTOCOL *DupDevicePath;
> + EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
> + EFI_STATUS Status;
> + EFI_HANDLE DeviceHandle;
> +
> + DupDevicePath = DuplicateDevicePath (DevicePath);
> + ASSERT (DupDevicePath != NULL);
> + if (DupDevicePath == NULL) {
> + return NULL;
> + }
> +
> + TempDevicePath = DupDevicePath;
> + Status = gBS->LocateDevicePath (
> + &gEfiDevicePathProtocolGuid,
> + &TempDevicePath,
> + &DeviceHandle
> + );
> + FreePool (DupDevicePath);
> + if (EFI_ERROR (Status)) {
> + return NULL;
> + }
> +
> + if (IsVgaHandle (DeviceHandle)) {
> + return DeviceHandle;
> + } else {
> + return NULL;
> + }
> +}
> +
> +
> +/**
> + Return whether the device path is a GOP device path.
> +
> + @param DevicePath The device path to be tested.
> +
> + @retval TRUE The device path is a GOP device path.
> + @retval FALSE The device on the device path is not a GOP device path.
> +**/
> +BOOLEAN
> +IsGopDevicePath (
> + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
> + )
> +{
> + while (!IsDevicePathEndType (DevicePath)) {
> + if (DevicePathType (DevicePath) == ACPI_DEVICE_PATH &&
> + DevicePathSubType (DevicePath) == ACPI_ADR_DP) {
> + return TRUE;
> + }
> + DevicePath = NextDevicePathNode (DevicePath);
> + }
> + return FALSE;
> +}
> +
> +
> +/**
> + Remove all GOP device path instance from DevicePath and add the Gop to
> the DevicePath.
> +
> + @param DevicePath The device path to be removed
> + @param Gop The device path to be added.
> +
> + @retval Return The updated device path.
> +**/
> +EFI_DEVICE_PATH_PROTOCOL *
> +UpdateGopDevicePath (
> + EFI_DEVICE_PATH_PROTOCOL *DevicePath,
> + EFI_DEVICE_PATH_PROTOCOL *Gop
> + )
> +{
> + UINTN Size;
> + UINTN GopSize;
> + EFI_DEVICE_PATH_PROTOCOL *Temp;
> + EFI_DEVICE_PATH_PROTOCOL *Return;
> + EFI_DEVICE_PATH_PROTOCOL *Instance;
> + BOOLEAN Exist;
> +
> + Exist = FALSE;
> + Return = NULL;
> + GopSize = GetDevicePathSize (Gop);
> + do {
> + Instance = GetNextDevicePathInstance (&DevicePath, &Size);
> + if (Instance == NULL) {
> + break;
> + }
> + if (!IsGopDevicePath (Instance) ||
> + (Size == GopSize && CompareMem (Instance, Gop, GopSize) == 0)
> + ) {
> + if (Size == GopSize && CompareMem (Instance, Gop, GopSize) == 0) {
> + Exist = TRUE;
> + }
> + Temp = Return;
> + Return = AppendDevicePathInstance (Return, Instance);
> + if (Temp != NULL) {
> + FreePool (Temp);
> + }
> + }
> + FreePool (Instance);
> + } while (DevicePath != NULL);
> +
> + if (!Exist) {
> + Temp = Return;
> + Return = AppendDevicePathInstance (Return, Gop);
> + if (Temp != NULL) {
> + FreePool (Temp);
> + }
> + }
> + return Return;
> +}
> +
> +
> +/**
> + Get Graphics Controller Handle.
> +
> + @param NeedTrustedConsole The flag to determine if trusted console
> + or non trusted console should be returned
> +
> + @retval NULL Console not found
> + @retval PciHandles Successfully located
> +**/
> +EFI_HANDLE
> +EFIAPI
> +GetGraphicsController (
> + IN BOOLEAN NeedTrustedConsole
> + )
> +{
> + EFI_STATUS Status;
> + UINTN Index;
> + EFI_HANDLE *PciHandles;
> + UINTN PciHandlesSize;
> + EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> +
> + Status = gBS->LocateHandleBuffer (
> + ByProtocol,
> + &gEfiPciIoProtocolGuid,
> + NULL,
> + &PciHandlesSize,
> + &PciHandles
> + );
> + if (EFI_ERROR (Status)) {
> + return NULL;
> + }
> +
> + for (Index = 0; Index < PciHandlesSize; Index++) {
> + Status = gBS->HandleProtocol (
> + PciHandles[Index],
> + &gEfiDevicePathProtocolGuid,
> + (VOID **) &DevicePath
> + );
> + if (EFI_ERROR(Status)) {
> + continue;
> + }
> + if (!IsVgaHandle (PciHandles[Index])) {
> + continue;
> + }
> + if ((NeedTrustedConsole && IsTrustedConsole (ConOut, DevicePath)) ||
> + ((!NeedTrustedConsole) && (!IsTrustedConsole (ConOut,
> DevicePath)))) {
> + return PciHandles[Index];
> + }
> + }
> +
> + return NULL;
> +}
> +
> +
> +/**
> + Updates Graphic ConOut variable.
> +
> + @param NeedTrustedConsole The flag that determines if trusted console
> + or non trusted console should be returned
> +**/
> +VOID
> +UpdateGraphicConOut (
> + IN BOOLEAN NeedTrustedConsole
> + )
> +{
> + EFI_HANDLE GraphicsControllerHandle;
> + EFI_DEVICE_PATH_PROTOCOL *GopDevicePath;
> + EFI_DEVICE_PATH_PROTOCOL *ConOutDevicePath;
> + EFI_DEVICE_PATH_PROTOCOL *UpdatedConOutDevicePath;
> +
> + //
> + // Update ConOut variable
> + //
> + GraphicsControllerHandle = GetGraphicsController (NeedTrustedConsole);
> + if (GraphicsControllerHandle != NULL) {
> + //
> + // Connect the GOP driver
> + //
> + gBS->ConnectController (GraphicsControllerHandle, NULL, NULL, TRUE);
> +
> + //
> + // Get the GOP device path
> + // NOTE: We may get a device path that contains Controller node in it.
> + //
> + GopDevicePath = EfiBootManagerGetGopDevicePath
> (GraphicsControllerHandle);
> + if (GopDevicePath != NULL) {
> + GetEfiGlobalVariable2 (L"ConOut", (VOID **)&ConOutDevicePath,
> NULL);
> + UpdatedConOutDevicePath = UpdateGopDevicePath
> (ConOutDevicePath, GopDevicePath);
> + if (ConOutDevicePath != NULL) {
> + FreePool (ConOutDevicePath);
> + }
> + FreePool (GopDevicePath);
> + gRT->SetVariable (
> + L"ConOut",
> + &gEfiGlobalVariableGuid,
> + EFI_VARIABLE_NON_VOLATILE |
> EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS,
> + GetDevicePathSize (UpdatedConOutDevicePath),
> + UpdatedConOutDevicePath
> + );
> + }
> + }
> +}
> +
> +
> +/**
> + The function connects the trusted consoles.
> +**/
> +VOID
> +ConnectTrustedConsole (
> + VOID
> + )
> +{
> + EFI_DEVICE_PATH_PROTOCOL *Consoles;
> + EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
> + EFI_DEVICE_PATH_PROTOCOL *Instance;
> + EFI_DEVICE_PATH_PROTOCOL *Next;
> + UINTN Size;
> + UINTN Index;
> + EFI_HANDLE Handle;
> + EFI_STATUS Status;
> + CHAR16 *ConsoleVar[] = {L"ConIn", L"ConOut"};
> + VOID *TrustedConsoleDevicepath;
> +
> + TrustedConsoleDevicepath = PcdGetPtr
> (PcdTrustedConsoleInputDevicePath);
> + DumpDevicePath (L"TrustedConsoleIn", TrustedConsoleDevicepath);
> + TrustedConsoleDevicepath = PcdGetPtr
> (PcdTrustedConsoleOutputDevicePath);
> + DumpDevicePath (L"TrustedConsoleOut", TrustedConsoleDevicepath);
> +
> + for (Index = 0; Index < sizeof (ConsoleVar) / sizeof (ConsoleVar[0]);
> Index++) {
> +
> + GetEfiGlobalVariable2 (ConsoleVar[Index], (VOID **)&Consoles, NULL);
> +
> + TempDevicePath = Consoles;
> + do {
> + Instance = GetNextDevicePathInstance (&TempDevicePath, &Size);
> + if (Instance == NULL) {
> + break;
> + }
> + if (IsTrustedConsole (Index, Instance)) {
> + if (IsUsbShortForm (Instance)) {
> + ConnectUsbShortFormDevicePath (Instance);
> + } else {
> + for (Next = Instance; !IsDevicePathEnd (Next); Next =
> NextDevicePathNode (Next)) {
> + if (DevicePathType (Next) == ACPI_DEVICE_PATH &&
> DevicePathSubType (Next) == ACPI_ADR_DP) {
> + break;
> + } else if (DevicePathType (Next) == HARDWARE_DEVICE_PATH &&
> + DevicePathSubType (Next) == HW_CONTROLLER_DP &&
> + DevicePathType (NextDevicePathNode (Next)) ==
> ACPI_DEVICE_PATH &&
> + DevicePathSubType (NextDevicePathNode (Next)) ==
> ACPI_ADR_DP
> + ) {
> + break;
> + }
> + }
> + if (!IsDevicePathEnd (Next)) {
> + SetDevicePathEndNode (Next);
> + Status = EfiBootManagerConnectDevicePath (Instance, &Handle);
> + if (!EFI_ERROR (Status)) {
> + gBS->ConnectController (Handle, NULL, NULL, TRUE);
> + }
> + } else {
> + EfiBootManagerConnectDevicePath (Instance, NULL);
> + }
> + }
> + }
> + FreePool (Instance);
> + } while (TempDevicePath != NULL);
> +
> + if (Consoles != NULL) {
> + FreePool (Consoles);
> + }
> + }
> +}
> +
> +
> +/**
> + The function connects the trusted Storages.
> +**/
> +VOID
> +ConnectTrustedStorage (
> + VOID
> + )
> +{
> + VOID *TrustedStorageDevicepath;
> + EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
> + EFI_DEVICE_PATH_PROTOCOL *Instance;
> + UINTN Size;
> + EFI_DEVICE_PATH_PROTOCOL *TempStorageDevicePath;
> + EFI_STATUS Status;
> + EFI_HANDLE DeviceHandle;
> +
> + TrustedStorageDevicepath = PcdGetPtr (PcdTrustedStorageDevicePath);
> + DumpDevicePath (L"TrustedStorage", TrustedStorageDevicepath);
> +
> + TempDevicePath = TrustedStorageDevicepath;
> + do {
> + Instance = GetNextDevicePathInstance (&TempDevicePath, &Size);
> + if (Instance == NULL) {
> + break;
> + }
> +
> + EfiBootManagerConnectDevicePath (Instance, NULL);
> +
> + TempStorageDevicePath = Instance;
> +
> + Status = gBS->LocateDevicePath (
> + &gEfiDevicePathProtocolGuid,
> + &TempStorageDevicePath,
> + &DeviceHandle
> + );
> + if (!EFI_ERROR (Status)) {
> + gBS->ConnectController (DeviceHandle, NULL, NULL, FALSE);
> + }
> +
> + FreePool (Instance);
> + } while (TempDevicePath != NULL);
> +}
> +
> +
> +/**
> + Check if current BootCurrent variable is internal shell boot option.
> +
> + @retval TRUE BootCurrent is internal shell.
> + @retval FALSE BootCurrent is not internal shell.
> +**/
> +BOOLEAN
> +BootCurrentIsInternalShell (
> + VOID
> + )
> +{
> + UINTN VarSize;
> + UINT16 BootCurrent;
> + CHAR16 BootOptionName[16];
> + UINT8 *BootOption;
> + UINT8 *Ptr;
> + BOOLEAN Result;
> + EFI_STATUS Status;
> + EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
> + EFI_DEVICE_PATH_PROTOCOL *LastDeviceNode;
> + EFI_GUID *GuidPoint;
> +
> + BootOption = NULL;
> + Result = FALSE;
> +
> + //
> + // Get BootCurrent variable
> + //
> + VarSize = sizeof (UINT16);
> + Status = gRT->GetVariable (
> + L"BootCurrent",
> + &gEfiGlobalVariableGuid,
> + NULL,
> + &VarSize,
> + &BootCurrent
> + );
> + if (EFI_ERROR (Status)) {
> + return FALSE;
> + }
> +
> + //
> + // Create boot option Bootxxxx from BootCurrent
> + //
> + UnicodeSPrint (BootOptionName, sizeof(BootOptionName), L"Boot%04X",
> BootCurrent);
> +
> + GetEfiGlobalVariable2 (BootOptionName, (VOID **) &BootOption,
> &VarSize);
> + if (BootOption == NULL || VarSize == 0) {
> + return FALSE;
> + }
> +
> + Ptr = BootOption;
> + Ptr += sizeof (UINT32);
> + Ptr += sizeof (UINT16);
> + Ptr += StrSize ((CHAR16 *) Ptr);
> + TempDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) Ptr;
> + LastDeviceNode = TempDevicePath;
> + while (!IsDevicePathEnd (TempDevicePath)) {
> + LastDeviceNode = TempDevicePath;
> + TempDevicePath = NextDevicePathNode (TempDevicePath);
> + }
> + GuidPoint = EfiGetNameGuidFromFwVolDevicePathNode (
> + (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) LastDeviceNode
> + );
> + if ((GuidPoint != NULL) &&
> + ((CompareGuid (GuidPoint, &gUefiShellFileGuid)))) {
> + //
> + // if this option is internal shell, return TRUE
> + //
> + Result = TRUE;
> + }
> +
> + if (BootOption != NULL) {
> + FreePool (BootOption);
> + BootOption = NULL;
> + }
> +
> + return Result;
> +}
> +
> +/**
> + This function will change video resolution and text mode
> + for internl shell when internal shell is launched.
> +
> + @param None.
> +
> + @retval EFI_SUCCESS Mode is changed successfully.
> + @retval Others Mode failed to changed.
> +**/
> +EFI_STATUS
> +EFIAPI
> +ChangeModeForInternalShell (
> + VOID
> + )
> +{
> + EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
> + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;
> + UINTN SizeOfInfo;
> + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
> + UINT32 MaxGopMode;
> + UINT32 MaxTextMode;
> + UINT32 ModeNumber;
> + UINTN HandleCount;
> + EFI_HANDLE *HandleBuffer;
> + EFI_STATUS Status;
> + UINTN Index;
> + UINTN CurrentColumn;
> + UINTN CurrentRow;
> +
> + //
> + // Internal shell mode
> + //
> + UINT32 mShellModeColumn;
> + UINT32 mShellModeRow;
> + UINT32 mShellHorizontalResolution;
> + UINT32 mShellVerticalResolution;
> +
> +
> + //
> + // Get user defined text mode for internal shell only once.
> + //
> + mShellHorizontalResolution = PcdGet32
> (PcdSetupVideoHorizontalResolution);
> + mShellVerticalResolution = PcdGet32 (PcdSetupVideoVerticalResolution);
> + mShellModeColumn = PcdGet32 (PcdSetupConOutColumn);
> + mShellModeRow = PcdGet32 (PcdSetupConOutRow);
> +
> +
> + Status = gBS->HandleProtocol (
> + gST->ConsoleOutHandle,
> + &gEfiGraphicsOutputProtocolGuid,
> + (VOID**)&GraphicsOutput
> + );
> + if (EFI_ERROR (Status)) {
> + GraphicsOutput = NULL;
> + }
> +
> + Status = gBS->HandleProtocol (
> + gST->ConsoleOutHandle,
> + &gEfiSimpleTextOutProtocolGuid,
> + (VOID**)&SimpleTextOut
> + );
> + if (EFI_ERROR (Status)) {
> + SimpleTextOut = NULL;
> + }
> +
> + if ((GraphicsOutput == NULL) || (SimpleTextOut == NULL)) {
> + return EFI_UNSUPPORTED;
> + }
> +
> + MaxGopMode = GraphicsOutput->Mode->MaxMode;
> + MaxTextMode = SimpleTextOut->Mode->MaxMode;
> +
> + //
> + // 1. If current video resolution is same with new video resolution,
> + // video resolution need not be changed.
> + // 1.1. If current text mode is same with new text mode, text mode need
> not be change.
> + // 1.2. If current text mode is different with new text mode, text mode
> need be change to new text mode.
> + // 2. If current video resolution is different with new video resolution, we
> need restart whole console drivers.
> + //
> + for (ModeNumber = 0; ModeNumber < MaxGopMode; ModeNumber++)
> {
> + Status = GraphicsOutput->QueryMode (
> + GraphicsOutput,
> + ModeNumber,
> + &SizeOfInfo,
> + &Info
> + );
> + if (!EFI_ERROR (Status)) {
> + if ((Info->HorizontalResolution == mShellHorizontalResolution) &&
> + (Info->VerticalResolution == mShellVerticalResolution)) {
> + if ((GraphicsOutput->Mode->Info->HorizontalResolution ==
> mShellHorizontalResolution) &&
> + (GraphicsOutput->Mode->Info->VerticalResolution ==
> mShellVerticalResolution)) {
> + //
> + // If current video resolution is same with new resolution,
> + // then check if current text mode is same with new text mode.
> + //
> + Status = SimpleTextOut->QueryMode (SimpleTextOut,
> SimpleTextOut->Mode->Mode, &CurrentColumn, &CurrentRow);
> + ASSERT_EFI_ERROR (Status);
> + if (CurrentColumn == mShellModeColumn && CurrentRow ==
> mShellModeRow) {
> + //
> + // Current text mode is same with new text mode, text mode need
> not be change.
> + //
> + FreePool (Info);
> + return EFI_SUCCESS;
> + } else {
> + //
> + // Current text mode is different with new text mode, text mode
> need be change to new text mode.
> + //
> + for (Index = 0; Index < MaxTextMode; Index++) {
> + Status = SimpleTextOut->QueryMode (SimpleTextOut, Index,
> &CurrentColumn, &CurrentRow);
> + if (!EFI_ERROR(Status)) {
> + if ((CurrentColumn == mShellModeColumn) && (CurrentRow ==
> mShellModeRow)) {
> + //
> + // New text mode is supported, set it.
> + //
> + Status = SimpleTextOut->SetMode (SimpleTextOut, Index);
> + ASSERT_EFI_ERROR (Status);
> + //
> + // Update text mode PCD.
> + //
> + Status = PcdSet32S (PcdConOutColumn, mShellModeColumn);
> + ASSERT_EFI_ERROR (Status);
> +
> + Status = PcdSet32S (PcdConOutRow, mShellModeRow);
> + ASSERT_EFI_ERROR (Status);
> +
> + FreePool (Info);
> + return EFI_SUCCESS;
> + }
> + }
> + }
> + if (Index == MaxTextMode) {
> + //
> + // If new text mode is not supported, return error.
> + //
> + FreePool (Info);
> + return EFI_UNSUPPORTED;
> + }
> + }
> + } else {
> + FreePool (Info);
> + //
> + // If current video resolution is not same with the new one, set new
> video resolution.
> + // In this case, the driver which produces simple text out need be
> restarted.
> + //
> + Status = GraphicsOutput->SetMode (GraphicsOutput, ModeNumber);
> + if (!EFI_ERROR (Status)) {
> + //
> + // Set PCD to restart GraphicsConsole and Consplitter to change video
> resolution
> + // and produce new text mode based on new resolution.
> + //
> + Status = PcdSet32S (PcdVideoHorizontalResolution,
> mShellHorizontalResolution);
> + ASSERT_EFI_ERROR (Status);
> +
> + Status = PcdSet32S (PcdVideoVerticalResolution,
> mShellVerticalResolution);
> + ASSERT_EFI_ERROR (Status);
> +
> + Status = PcdSet32S (PcdConOutColumn, mShellModeColumn);
> + ASSERT_EFI_ERROR (Status);
> +
> + Status = PcdSet32S (PcdConOutRow, mShellModeRow);
> + ASSERT_EFI_ERROR (Status);
> +
> + Status = gBS->LocateHandleBuffer (
> + ByProtocol,
> + &gEfiSimpleTextOutProtocolGuid,
> + NULL,
> + &HandleCount,
> + &HandleBuffer
> + );
> + if (!EFI_ERROR (Status)) {
> + for (Index = 0; Index < HandleCount; Index++) {
> + gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);
> + }
> + for (Index = 0; Index < HandleCount; Index++) {
> + gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
> + }
> + if (HandleBuffer != NULL) {
> + FreePool (HandleBuffer);
> + }
> + break;
> + }
> + }
> + }
> + }
> + FreePool (Info);
> + }
> + }
> +
> + if (ModeNumber == MaxGopMode) {
> + //
> + // If the new resolution is not supported, return error.
> + //
> + return EFI_UNSUPPORTED;
> + }
> +
> + return EFI_SUCCESS;
> +}
> +
> +
> +/**
> + The function connects the trusted consoles and then call the PP processing
> library interface.
> +**/
> +VOID
> +ProcessTcgPp (
> + VOID
> + )
> +{
> + gPPRequireUIConfirm |= Tcg2PhysicalPresenceLibNeedUserConfirm();
> +
> + if (gPPRequireUIConfirm) {
> + ConnectTrustedConsole ();
> + }
> +
> + Tcg2PhysicalPresenceLibProcessRequest (NULL);
> +}
> +
> +
> +/**
> + The function connects the trusted storage to perform TPerReset.
> +**/
> +VOID
> +ProcessTcgMor (
> + VOID
> + )
> +{
> + if (IsMorBitSet ()) {
> + ConnectTrustedConsole();
> + ConnectTrustedStorage();
> + }
> +}
> +
> +
> +/**
> + Update the ConIn variable with USB Keyboard device path,if its not already
> exists in ConIn
> +**/
> +VOID
> +EnumUsbKeyboard (
> + VOID
> + )
> +{
> + DEBUG ((DEBUG_INFO, "[EnumUsbKeyboard]\n"));
> + EfiBootManagerUpdateConsoleVariable (ConIn,
> (EFI_DEVICE_PATH_PROTOCOL *) &gUsbClassKeyboardDevicePath, NULL);
> + //
> + // Append Usb Keyboard short form DevicePath into "ConInDev"
> + //
> + EfiBootManagerUpdateConsoleVariable (ConInDev,
> (EFI_DEVICE_PATH_PROTOCOL *) &gUsbClassKeyboardDevicePath, NULL);
> +}
> +
> +
> +/**
> + Connect with predeined platform connect sequence,
> + the OEM/IBV can customize with their own connect sequence.
> +
> + @param[in] BootMode Boot mode of this boot.
> +**/
> +VOID
> +ConnectSequence (
> + IN EFI_BOOT_MODE BootMode
> + )
> +{
> + EfiBootManagerConnectAll ();
> +}
> +
> +
> +/**
> + The function is to consider the boot order which is not in our expectation.
> + In the case that we need to re-sort the boot option.
> +
> + @retval TRUE Need to sort Boot Option.
> + @retval FALSE Don't need to sort Boot Option.
> +**/
> +BOOLEAN
> +IsNeedSortBootOption (
> + VOID
> + )
> +{
> + EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
> + UINTN BootOptionCount;
> +
> + BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount,
> LoadOptionTypeBoot);
> +
> + //
> + // If setup is the first priority in boot option, we need to sort boot option.
> + //
> + if ((BootOptionCount > 1) &&
> + (((StrnCmp (BootOptions->Description, L"Enter Setup", StrLen (L"Enter
> Setup"))) == 0) ||
> + ((StrnCmp (BootOptions->Description, L"BootManagerMenuApp", StrLen
> (L"BootManagerMenuApp"))) == 0))) {
> + return TRUE;
> + }
> +
> + return FALSE;
> +}
> +
> +
> +/**
> + Connects Root Bridge
> + **/
> +VOID
> +ConnectRootBridge (
> + BOOLEAN Recursive
> + )
> +{
> + UINTN RootBridgeHandleCount;
> + EFI_HANDLE *RootBridgeHandleBuffer;
> + UINTN RootBridgeIndex;
> +
> + RootBridgeHandleCount = 0;
> + gBS->LocateHandleBuffer (
> + ByProtocol,
> + &gEfiPciRootBridgeIoProtocolGuid,
> + NULL,
> + &RootBridgeHandleCount,
> + &RootBridgeHandleBuffer
> + );
> + for (RootBridgeIndex = 0; RootBridgeIndex < RootBridgeHandleCount;
> RootBridgeIndex++) {
> + gBS->ConnectController (RootBridgeHandleBuffer[RootBridgeIndex],
> NULL, NULL, Recursive);
> + }
> +}
> +
> +VOID
> +AddConsoleVariable (
> + IN CONSOLE_TYPE ConsoleType,
> + IN EFI_DEVICE_PATH *ConsoleDevicePath
> + )
> +{
> + EFI_DEVICE_PATH *TempDevicePath;
> + EFI_DEVICE_PATH *Instance;
> + UINTN Size;
> + EFI_HANDLE GraphicsControllerHandle;
> + EFI_DEVICE_PATH *GopDevicePath;
> +
> + TempDevicePath = ConsoleDevicePath;
> + do {
> + Instance = GetNextDevicePathInstance (&TempDevicePath, &Size);
> + if (Instance == NULL) {
> + break;
> + }
> +
> + switch (ConsoleType) {
> + case ConIn:
> + if (IsUsbShortForm (Instance)) {
> + //
> + // Append Usb Keyboard short form DevicePath into "ConInDev"
> + //
> + EfiBootManagerUpdateConsoleVariable (ConInDev, Instance, NULL);
> + }
> + EfiBootManagerUpdateConsoleVariable (ConsoleType, Instance, NULL);
> + break;
> + case ConOut:
> + GraphicsControllerHandle = IsVideoController (Instance);
> + if (GraphicsControllerHandle == NULL) {
> + EfiBootManagerUpdateConsoleVariable (ConsoleType, Instance,
> NULL);
> + } else {
> + //
> + // Connect the GOP driver
> + //
> + gBS->ConnectController (GraphicsControllerHandle, NULL, NULL,
> TRUE);
> + //
> + // Get the GOP device path
> + // NOTE: We may get a device path that contains Controller node in it.
> + //
> + GopDevicePath = EfiBootManagerGetGopDevicePath
> (GraphicsControllerHandle);
> + if (GopDevicePath != NULL) {
> + EfiBootManagerUpdateConsoleVariable (ConsoleType,
> GopDevicePath, NULL);
> + }
> + }
> + break;
> + default:
> + ASSERT(FALSE);
> + break;
> + }
> +
> + FreePool (Instance);
> + } while (TempDevicePath != NULL);
> +}
> +
> +
> +/**
> + This is the callback function for PCI ENUMERATION COMPLETE.
> +
> + @param[in] Event The Event this notify function registered to.
> + @param[in] Context Pointer to the context data registered to the Event.
> +**/
> +VOID
> +EFIAPI
> +BdsPciEnumCompleteCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + )
> +{
> + EFI_STATUS Status;
> + VOID *ProtocolPointer;
> + EFI_DEVICE_PATH_PROTOCOL *VarConOut;
> + EFI_DEVICE_PATH_PROTOCOL *VarConIn;
> +
> + Status = EFI_SUCCESS;
> +
> + //
> + // Check if this is first time called by EfiCreateProtocolNotifyEvent() or not,
> + // if it is, we will skip it until real event is triggered
> + //
> + Status = gBS->LocateProtocol
> (&gEfiPciEnumerationCompleteProtocolGuid, NULL, (VOID **)
> &ProtocolPointer);
> + if (EFI_SUCCESS != Status) {
> + return;
> + }
> + //gBS->CloseEvent (Event);
> +
> +
> + DEBUG ((DEBUG_INFO, "Event BdsPciEnumCompleteCallback callback
> starts\n"));
> +
> + gBootMode = GetBootModeHob ();
> +
> + //
> + // Connect Root Bridge to make PCI BAR resource allocated and all PciIo
> created
> + //
> + ConnectRootBridge (FALSE);
> +
> + //
> + // Fill ConIn/ConOut in Full Configuration boot mode
> + //
> + DEBUG ((DEBUG_INFO, "PlatformBootManagerInit - %x\n", gBootMode));
> +
> +
> + if (gBootMode == BOOT_WITH_FULL_CONFIGURATION ||
> + gBootMode == BOOT_WITH_DEFAULT_SETTINGS ||
> + gBootMode ==
> BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS ||
> + gBootMode == BOOT_IN_RECOVERY_MODE) {
> +
> + GetEfiGlobalVariable2 (L"ConOut", (VOID **)&VarConOut, NULL);
> + if (VarConOut != NULL) {
> + FreePool (VarConOut);
> + }
> +
> + GetEfiGlobalVariable2 (L"ConIn", (VOID **)&VarConIn, NULL);
> + if (VarConIn != NULL) {
> + FreePool (VarConIn);
> + }
> +
> + //
> + // Only fill ConIn/ConOut when ConIn/ConOut is empty because we may
> drop to Full Configuration boot mode in non-first boot
> + //
> + if (VarConOut == NULL || VarConIn == NULL) {
> + if (PcdGetSize (PcdTrustedConsoleOutputDevicePath) >=
> sizeof(EFI_DEVICE_PATH_PROTOCOL)) {
> + AddConsoleVariable (ConOut, PcdGetPtr
> (PcdTrustedConsoleOutputDevicePath));
> + }
> + if (PcdGetSize (PcdTrustedConsoleInputDevicePath) >=
> sizeof(EFI_DEVICE_PATH_PROTOCOL)) {
> + AddConsoleVariable (ConIn, PcdGetPtr
> (PcdTrustedConsoleInputDevicePath));
> + }
> + }
> + }
> +
> +}
> +
> +/**
> + This is the callback function for Smm Ready To Lock.
> +
> + @param[in] Event The Event this notify function registered to.
> + @param[in] Context Pointer to the context data registered to the Event.
> +**/
> +VOID
> +EFIAPI
> +BdsSmmReadyToLockCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + )
> +{
> + VOID *ProtocolPointer;
> + EFI_STATUS Status;
> + //
> + // Check if this is first time called by EfiCreateProtocolNotifyEvent() or not,
> + // if it is, we will skip it until real event is triggered
> + //
> + Status = gBS->LocateProtocol (&gEfiDxeSmmReadyToLockProtocolGuid,
> NULL, (VOID **) &ProtocolPointer);
> + if (EFI_SUCCESS != Status) {
> + return;
> + }
> +
> + DEBUG ((DEBUG_INFO, "Event gEfiDxeSmmReadyToLockProtocolGuid
> callback starts\n"));
> +
> + //
> + // Dispatch the deferred 3rd party images.
> + //
> + EfiBootManagerDispatchDeferredImages ();
> +
> + //
> + // For non-trusted console it must be handled here.
> + //
> + UpdateGraphicConOut (FALSE);
> +}
> +
> +/**
> + ReadyToBoot callback to set video and text mode for internal shell boot.
> + That will not connect USB controller while CSM and FastBoot are disabled,
> we need to connect them
> + before booting to Shell for showing USB devices in Shell.
> +
> + When FastBoot is enabled and Windows Console is the chosen Console
> behavior, input devices will not be connected
> + by default. Hence, when booting to EFI shell, connecting input consoles are
> required.
> +
> + @param Event Pointer to this event
> + @param Context Event hanlder private data
> +
> + @retval None.
> +**/
> +VOID
> +EFIAPI
> +BdsReadyToBootCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + )
> +{
> + DEBUG ((DEBUG_INFO, "BdsReadyToBootCallback\n"));
> +
> + if (BootCurrentIsInternalShell ()) {
> +
> + ChangeModeForInternalShell ();
> + EfiBootManagerConnectAllDefaultConsoles ();
> + gDS->Dispatch ();
> + }
> +}
> +
> +
> +/**
> + Before console after trusted console event callback
> +
> + @param[in] Event The Event this notify function registered to.
> + @param[in] Context Pointer to the context data registered to the Event.
> +**/
> +VOID
> +BdsBeforeConsoleAfterTrustedConsoleCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + )
> +{
> + DEBUG ((DEBUG_INFO, "Event
> gBdsEventBeforeConsoleBeforeEndOfDxeGuid callback starts\n"));
> +
> + //
> + // Enumerate USB keyboard
> + //
> + EnumUsbKeyboard ();
> +
> + //
> + // For trusted console it must be handled here.
> + //
> + UpdateGraphicConOut (TRUE);
> +
> + //
> + // Register Boot Options
> + //
> + RegisterDefaultBootOption ();
> +
> + //
> + // Register Static Hot keys
> + //
> + RegisterStaticHotkey ();
> +
> + //
> + // Process Physical Preo
> + //
> + PERF_START_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7010);
> + if (PcdGetBool (PcdTpm2Enable)) {
> + ProcessTcgPp ();
> + ProcessTcgMor ();
> + }
> + PERF_END_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7011);
> +
> + //
> + // Perform memory test
> + // We should make all UEFI memory and GCD information populated
> before ExitPmAuth.
> + // SMM may consume these information.
> + //
> + MemoryTest((EXTENDMEM_COVERAGE_LEVEL) PcdGet32
> (PcdPlatformMemoryCheckLevel));
> +}
> +
> +
> +/**
> + Before console before end of DXE event callback
> +
> + @param[in] Event The Event this notify function registered to.
> + @param[in] Context Pointer to the context data registered to the Event.
> +**/
> +VOID
> +BdsBeforeConsoleBeforeEndOfDxeGuidCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + )
> +{
> + DEBUG ((DEBUG_INFO, "Event gBdsBeforeConsoleBeforeEndOfDxeGuid
> callback starts\n"));
> +
> +}
> +
> +
> +/**
> + After console ready before boot option event callback
> +
> + @param[in] Event The Event this notify function registered to.
> + @param[in] Context Pointer to the context data registered to the Event.
> +**/
> +VOID
> +BdsAfterConsoleReadyBeforeBootOptionCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + )
> +{
> + EFI_BOOT_MODE LocalBootMode;
> +
> + DEBUG ((DEBUG_INFO, "Event
> gBdsAfterConsoleReadyBeforeBootOptionEvent callback starts\n"));
> + //
> + // Get current Boot Mode
> + //
> + LocalBootMode = gBootMode;
> + DEBUG ((DEBUG_INFO, "Current local bootmode - %x\n",
> LocalBootMode));
> +
> + //
> + // Go the different platform policy with different boot mode
> + // Notes: this part code can be change with the table policy
> + //
> + switch (LocalBootMode) {
> + case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:
> + case BOOT_WITH_MINIMAL_CONFIGURATION:
> + case BOOT_ON_S4_RESUME:
> + //
> + // Perform some platform specific connect sequence
> + //
> + PERF_START_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7050);
> + ConnectSequence (LocalBootMode);
> + PERF_END_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7051);
> +
> + break;
> +
> + case BOOT_WITH_FULL_CONFIGURATION:
> + case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:
> + case BOOT_WITH_DEFAULT_SETTINGS:
> + default:
> + //
> + // Perform some platform specific connect sequence
> + //
> + ConnectSequence (LocalBootMode);
> +
> + //
> + // Only in Full Configuration boot mode we do the enumeration of boot
> device
> + //
> + //
> + // Dispatch all but Storage Oprom explicitly, because we assume
> Int13Thunk driver is there.
> + //
> +
> + //
> + // PXE boot option may appear after boot option enumeration
> + //
> + break;
> + }
> +
> + Print (L"Press F7 for BootMenu!\n");
> +
> + EfiBootManagerRefreshAllBootOption ();
> +
> + if (IsNeedSortBootOption()) {
> + EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot,
> CompareBootOption);
> + }
> +}
> diff --git
> a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook
> Lib.inf
> b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook
> Lib.inf
> new file mode 100644
> index 0000000000..69f3fcb552
> --- /dev/null
> +++
> b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook
> Lib.inf
> @@ -0,0 +1,95 @@
> +### @file
> +# Module Information file for the Bds Hook Library.
> +#
> +# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +###
> +
> +[Defines]
> + INF_VERSION = 0x00010017
> + BASE_NAME = BoardBdsHookLib
> + FILE_GUID = 649A7502-7301-4E3A-A99B-EA91AD6DD7A8
> + VERSION_STRING = 1.0
> + MODULE_TYPE = DXE_DRIVER
> + LIBRARY_CLASS = BoardBdsHookLib|DXE_DRIVER
> +
> +[LibraryClasses]
> + BaseLib
> + MemoryAllocationLib
> + UefiBootServicesTableLib
> + UefiRuntimeServicesTableLib
> + BaseMemoryLib
> + DebugLib
> + PcdLib
> + PrintLib
> + DevicePathLib
> + UefiLib
> + HobLib
> + DxeServicesLib
> + DxeServicesTableLib
> + HiiLib
> + UefiBootManagerLib
> + PerformanceLib
> + TimerLib
> + Tcg2PhysicalPresenceLib
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + SecurityPkg/SecurityPkg.dec
> + MinPlatformPkg/MinPlatformPkg.dec
> + BoardModulePkg/BoardModulePkg.dec
> +
> +[Pcd]
> + gMinPlatformPkgTokenSpaceGuid.PcdTpm2Enable ##
> CONSUMES
> + gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut ##
> PRODUCES
> + gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution ##
> PRODUCES
> + gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution ##
> PRODUCES
> + gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow ##
> PRODUCES
> + gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn ##
> PRODUCES
> + gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutColumn ##
> CONSUMES
> + gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutRow ##
> CONSUMES
> + gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution
> ## CONSUMES
> + gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution
> ## CONSUMES
> + gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand
> ## PRODUCES
> + gMinPlatformPkgTokenSpaceGuid.PcdPlatformMemoryCheckLevel ##
> CONSUMES
> + gMinPlatformPkgTokenSpaceGuid.PcdBootToShellOnly ##
> CONSUMES
> + gMinPlatformPkgTokenSpaceGuid.PcdTrustedConsoleInputDevicePath
> ## CONSUMES
> + gMinPlatformPkgTokenSpaceGuid.PcdTrustedConsoleOutputDevicePath
> ## CONSUMES
> + gMinPlatformPkgTokenSpaceGuid.PcdTrustedStorageDevicePath ##
> CONSUMES
> +
> +[Sources]
> + BoardBdsHook.h
> + BoardBdsHookLib.c
> + BoardMemoryTest.c
> + BoardBootOption.c
> +
> +[Protocols]
> + gEfiPciRootBridgeIoProtocolGuid ## CONSUMES
> + gEfiPciIoProtocolGuid ## CONSUMES
> + gEfiCpuIo2ProtocolGuid ## CONSUMES
> + gEfiDxeSmmReadyToLockProtocolGuid ## PRODUCES
> + gEfiGenericMemTestProtocolGuid ## CONSUMES
> + gEfiDiskInfoProtocolGuid ## CONSUMES
> + gEfiDevicePathToTextProtocolGuid ## CONSUMES
> + gEfiSimpleTextInputExProtocolGuid ## CONSUMES
> + gEfiFirmwareVolume2ProtocolGuid ## CONSUMES
> + gEfiFormBrowser2ProtocolGuid ## CONSUMES
> + gEfiGenericMemTestProtocolGuid ## CONSUMES
> + gEfiDxeSmmReadyToLockProtocolGuid
> +
> +[Guids]
> + gEfiGlobalVariableGuid ## PRODUCES
> + gEfiMemoryOverwriteControlDataGuid ## PRODUCES
> + gEfiEndOfDxeEventGroupGuid ## CONSUMES
> + gBdsEventBeforeConsoleAfterTrustedConsoleGuid
> + gBdsEventBeforeConsoleBeforeEndOfDxeGuid
> + gBdsEventAfterConsoleReadyBeforeBootOptionGuid
> +
> +[Depex.common.DXE_DRIVER]
> + gEfiVariableArchProtocolGuid
> +
> +[Depex]
> + TRUE
> diff --git
> a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBootOpti
> on.c
> b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBootOpti
> on.c
> new file mode 100644
> index 0000000000..87138bdd79
> --- /dev/null
> +++
> b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBootOpti
> on.c
> @@ -0,0 +1,598 @@
> +/** @file
> + Driver for Platform Boot Options support.
> +
> +Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include "BoardBdsHook.h"
> +
> +BOOLEAN mContinueBoot = FALSE;
> +BOOLEAN mBootMenuBoot = FALSE;
> +BOOLEAN mPxeBoot = FALSE;
> +BOOLEAN mHotKeypressed = FALSE;
> +EFI_EVENT HotKeyEvent = NULL;
> +
> +UINTN mBootMenuOptionNumber;
> +
> +
> +/**
> + This function will create a SHELL BootOption to boot.
> +
> + @return Shell Device path for booting.
> +**/
> +EFI_DEVICE_PATH_PROTOCOL *
> +BdsCreateShellDevicePath (
> + VOID
> + )
> +{
> + UINTN FvHandleCount;
> + EFI_HANDLE *FvHandleBuffer;
> + UINTN Index;
> + EFI_STATUS Status;
> + EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
> + UINTN Size;
> + UINT32 AuthenticationStatus;
> + EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> + VOID *Buffer;
> +
> + DevicePath = NULL;
> + Status = EFI_SUCCESS;
> +
> + DEBUG ((DEBUG_INFO, "BdsCreateShellDevicePath\n"));
> + gBS->LocateHandleBuffer (
> + ByProtocol,
> + &gEfiFirmwareVolume2ProtocolGuid,
> + NULL,
> + &FvHandleCount,
> + &FvHandleBuffer
> + );
> +
> + for (Index = 0; Index < FvHandleCount; Index++) {
> + gBS->HandleProtocol (
> + FvHandleBuffer[Index],
> + &gEfiFirmwareVolume2ProtocolGuid,
> + (VOID **) &Fv
> + );
> +
> + Buffer = NULL;
> + Size = 0;
> + Status = Fv->ReadSection (
> + Fv,
> + &gUefiShellFileGuid,
> + EFI_SECTION_PE32,
> + 0,
> + &Buffer,
> + &Size,
> + &AuthenticationStatus
> + );
> + if (EFI_ERROR (Status)) {
> + //
> + // Skip if no shell file in the FV
> + //
> + continue;
> + } else {
> + //
> + // Found the shell
> + //
> + break;
> + }
> + }
> +
> + if (EFI_ERROR (Status)) {
> + //
> + // No shell present
> + //
> + if (FvHandleCount) {
> + FreePool (FvHandleBuffer);
> + }
> + return NULL;
> + }
> + //
> + // Build the shell boot option
> + //
> + DevicePath = DevicePathFromHandle (FvHandleBuffer[Index]);
> +
> + if (FvHandleCount) {
> + FreePool (FvHandleBuffer);
> + }
> +
> + return DevicePath;
> +}
> +
> +
> +EFI_STATUS
> +CreateFvBootOption (
> + EFI_GUID *FileGuid,
> + CHAR16 *Description,
> + EFI_BOOT_MANAGER_LOAD_OPTION *BootOption,
> + UINT32 Attributes,
> + UINT8 *OptionalData, OPTIONAL
> + UINT32 OptionalDataSize
> + )
> +{
> + EFI_STATUS Status;
> + EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> + EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
> + MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
> + EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
> + UINT32 AuthenticationStatus;
> + VOID *Buffer;
> + UINTN Size;
> +
> + if ((BootOption == NULL) || (FileGuid == NULL) || (Description == NULL)) {
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);
> +
> + if (!CompareGuid (&gUefiShellFileGuid, FileGuid)) {
> + Status = gBS->HandleProtocol (
> + gImageHandle,
> + &gEfiLoadedImageProtocolGuid,
> + (VOID **) &LoadedImage
> + );
> + if (!EFI_ERROR (Status)) {
> + Status = gBS->HandleProtocol (
> + LoadedImage->DeviceHandle,
> + &gEfiFirmwareVolume2ProtocolGuid,
> + (VOID **) &Fv
> + );
> + if (!EFI_ERROR (Status)) {
> + Buffer = NULL;
> + Size = 0;
> + Status = Fv->ReadSection (
> + Fv,
> + FileGuid,
> + EFI_SECTION_PE32,
> + 0,
> + &Buffer,
> + &Size,
> + &AuthenticationStatus
> + );
> + if (Buffer != NULL) {
> + FreePool (Buffer);
> + }
> + }
> + }
> + if (EFI_ERROR (Status)) {
> + return EFI_NOT_FOUND;
> + }
> +
> + DevicePath = AppendDevicePathNode (
> + DevicePathFromHandle (LoadedImage->DeviceHandle),
> + (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
> + );
> + } else {
> + DevicePath = AppendDevicePathNode (
> + BdsCreateShellDevicePath (),
> + (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
> + );
> + }
> +
> + Status = EfiBootManagerInitializeLoadOption (
> + BootOption,
> + LoadOptionNumberUnassigned,
> + LoadOptionTypeBoot,
> + Attributes,
> + Description,
> + DevicePath,
> + OptionalData,
> + OptionalDataSize
> + );
> + FreePool (DevicePath);
> + return Status;
> +}
> +
> +EFI_GUID mUiFile = {
> + 0x462CAA21, 0x7614, 0x4503, { 0x83, 0x6E, 0x8A, 0xB6, 0xF4, 0x66, 0x23,
> 0x31 }
> +};
> +EFI_GUID mBootMenuFile = {
> + 0xEEC25BDC, 0x67F2, 0x4D95, { 0xB1, 0xD5, 0xF8, 0x1B, 0x20, 0x39, 0xD1,
> 0x1D }
> +};
> +
> +
> +/**
> + Return the index of the load option in the load option array.
> +
> + The function consider two load options are equal when the
> + OptionType, Attributes, Description, FilePath and OptionalData are equal.
> +
> + @param Key Pointer to the load option to be found.
> + @param Array Pointer to the array of load options to be found.
> + @param Count Number of entries in the Array.
> +
> + @retval -1 Key wasn't found in the Array.
> + @retval 0 ~ Count-1 The index of the Key in the Array.
> +**/
> +INTN
> +PlatformFindLoadOption (
> + IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Key,
> + IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Array,
> + IN UINTN Count
> + )
> +{
> + UINTN Index;
> +
> + for (Index = 0; Index < Count; Index++) {
> + if ((Key->OptionType == Array[Index].OptionType) &&
> + (Key->Attributes == Array[Index].Attributes) &&
> + (StrCmp (Key->Description, Array[Index].Description) == 0) &&
> + (CompareMem (Key->FilePath, Array[Index].FilePath,
> GetDevicePathSize (Key->FilePath)) == 0) &&
> + (Key->OptionalDataSize == Array[Index].OptionalDataSize) &&
> + (CompareMem (Key->OptionalData, Array[Index].OptionalData, Key-
> >OptionalDataSize) == 0)) {
> + return (INTN) Index;
> + }
> + }
> +
> + return -1;
> +}
> +
> +
> +/**
> + Registers a boot option
> +
> + @param FileGuid Boot file GUID
> + @param Description Boot option discription
> + @param Position Position of the new load option to put in the
> ****Order variable.
> + @param Attributes Boot option attributes
> + @param OptionalData Optional data of the boot option.
> + @param OptionalDataSize Size of the optional data of the boot option
> +
> + @return boot option number
> +**/
> +UINTN
> +RegisterFvBootOption (
> + EFI_GUID *FileGuid,
> + CHAR16 *Description,
> + UINTN Position,
> + UINT32 Attributes,
> + UINT8 *OptionalData, OPTIONAL
> + UINT32 OptionalDataSize
> + )
> +{
> + EFI_STATUS Status;
> + UINTN OptionIndex;
> + EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
> + EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
> + UINTN BootOptionCount;
> +
> + NewOption.OptionNumber = LoadOptionNumberUnassigned;
> + Status = CreateFvBootOption (FileGuid, Description, &NewOption,
> Attributes, OptionalData, OptionalDataSize);
> + if (!EFI_ERROR (Status)) {
> + BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount,
> LoadOptionTypeBoot);
> +
> + OptionIndex = PlatformFindLoadOption (&NewOption, BootOptions,
> BootOptionCount);
> +
> + if (OptionIndex == -1) {
> + Status = EfiBootManagerAddLoadOptionVariable (&NewOption,
> Position);
> + ASSERT_EFI_ERROR (Status);
> + } else {
> + NewOption.OptionNumber =
> BootOptions[OptionIndex].OptionNumber;
> + }
> + EfiBootManagerFreeLoadOption (&NewOption);
> + EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
> + }
> +
> + return NewOption.OptionNumber;
> +}
> +
> +
> +/**
> + Boot manager wait callback
> +
> + @param TimeoutRemain The remaingin timeout period
> +**/
> +VOID
> +EFIAPI
> +PlatformBootManagerWaitCallback (
> + UINT16 TimeoutRemain
> + )
> +{
> + EFI_STATUS Status;
> + EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TxtInEx;
> + EFI_KEY_DATA KeyData;
> + BOOLEAN PausePressed;
> +
> + //
> + // Pause on PAUSE key
> + //
> + Status = gBS->HandleProtocol (gST->ConsoleInHandle,
> &gEfiSimpleTextInputExProtocolGuid, (VOID **) &TxtInEx);
> + ASSERT_EFI_ERROR (Status);
> +
> + PausePressed = FALSE;
> +
> + while (TRUE) {
> + Status = TxtInEx->ReadKeyStrokeEx (TxtInEx, &KeyData);
> + if (EFI_ERROR (Status)) {
> + break;
> + }
> +
> + if (KeyData.Key.ScanCode == SCAN_PAUSE) {
> + PausePressed = TRUE;
> + break;
> + }
> + }
> +
> + //
> + // Loop until non-PAUSE key pressed
> + //
> + while (PausePressed) {
> + Status = TxtInEx->ReadKeyStrokeEx (TxtInEx, &KeyData);
> + if (!EFI_ERROR (Status)) {
> + DEBUG ((
> + DEBUG_INFO, "[PauseCallback] %x/%x %x/%x\n",
> + KeyData.Key.ScanCode, KeyData.Key.UnicodeChar,
> + KeyData.KeyState.KeyShiftState, KeyData.KeyState.KeyToggleState
> + ));
> + PausePressed = (BOOLEAN) (KeyData.Key.ScanCode == SCAN_PAUSE);
> + }
> + }
> +}
> +
> +
> +EFI_GUID gUefiShellFileGuid = { 0x7C04A583, 0x9E3E, 0x4f1c, { 0xAD, 0x65,
> 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 } };
> +
> +#define INTERNAL_UEFI_SHELL_NAME L"Internal UEFI Shell 2.0"
> +#define UEFI_HARD_DRIVE_NAME L"UEFI Hard Drive"
> +
> +/**
> + Registers default boot option
> +**/
> +
> +VOID
> +RegisterDefaultBootOption (
> + VOID
> + )
> +{
> + UINT16 *ShellData;
> + UINT32 ShellDataSize;
> +
> + ShellData = NULL;
> + ShellDataSize = 0;
> + RegisterFvBootOption (&gUefiShellFileGuid,
> INTERNAL_UEFI_SHELL_NAME, (UINTN) -1, LOAD_OPTION_ACTIVE, (UINT8
> *)ShellData, ShellDataSize);
> +
> + //
> + // Boot Menu
> + //
> + mBootMenuOptionNumber = RegisterFvBootOption (&mBootMenuFile,
> L"Boot Device List", (UINTN) -1, LOAD_OPTION_CATEGORY_APP |
> LOAD_OPTION_ACTIVE | LOAD_OPTION_HIDDEN, NULL, 0);
> +
> + if (mBootMenuOptionNumber == LoadOptionNumberUnassigned) {
> + DEBUG ((DEBUG_INFO, "BootMenuOptionNumber (%d) should not be
> same to LoadOptionNumberUnassigned(%d).\n",
> mBootMenuOptionNumber, LoadOptionNumberUnassigned));
> + }
> +#if 0
> + //
> + // Boot Manager Menu
> + //
> + EfiInitializeFwVolDevicepathNode (&FileNode, &mUiFile);
> +
> + gBS->HandleProtocol (
> + gImageHandle,
> + &gEfiLoadedImageProtocolGuid,
> + (VOID **) &LoadedImage
> + );
> + DevicePath = AppendDevicePathNode (DevicePathFromHandle
> (LoadedImage->DeviceHandle), (EFI_DEVICE_PATH_PROTOCOL *)
> &FileNode);
> +#endif
> +
> +}
> +
> +/**
> + Registers/Unregisters boot option hotkey
> +
> + @param OptionNumber The boot option number for the key option.
> + @param Key The the key input
> + @param Add Flag to indicate to add or remove a key
> +**/
> +VOID
> +RegisterBootOptionHotkey (
> + UINT16 OptionNumber,
> + EFI_INPUT_KEY *Key,
> + BOOLEAN Add
> + )
> +{
> + EFI_STATUS Status;
> +
> + if (!Add) {
> + //
> + // No enter hotkey when force to setup or there is no boot option
> + //
> + Status = EfiBootManagerDeleteKeyOptionVariable (NULL, 0, Key, NULL);
> + ASSERT (Status == EFI_SUCCESS || Status == EFI_NOT_FOUND);
> + } else {
> + //
> + // Register enter hotkey for the first boot option
> + //
> + Status = EfiBootManagerAddKeyOptionVariable (NULL, OptionNumber, 0,
> Key,NULL);
> + ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
> + }
> +}
> +
> +
> +/**
> + Detect key press callback
> +
> + @param The key data
> +
> + @retval EFI_SUCCESS
> +**/
> +EFI_STATUS
> +EFIAPI
> +DetectKeypressCallback (
> + IN EFI_KEY_DATA *KeyData
> +)
> +{
> + mHotKeypressed = TRUE;
> +
> + if (HotKeyEvent != NULL) {
> + gBS->SignalEvent(HotKeyEvent);
> + }
> +
> + return EFI_SUCCESS;
> +}
> +
> +/**
> + This function is called after all the boot options are enumerated and
> ordered properly.
> +**/
> +VOID
> +RegisterStaticHotkey (
> + VOID
> + )
> +{
> +
> + EFI_INPUT_KEY Enter;
> + EFI_KEY_DATA F2;
> + EFI_KEY_DATA F7;
> + BOOLEAN EnterSetup;
> + EFI_STATUS Status;
> + EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
> +
> + EnterSetup = FALSE;
> +
> + //
> + // [Enter]
> + //
> + mContinueBoot = !EnterSetup;
> + if (mContinueBoot) {
> + Enter.ScanCode = SCAN_NULL;
> + Enter.UnicodeChar = CHAR_CARRIAGE_RETURN;
> + EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL);
> + }
> +
> +
> + //
> + // [F2]/[F7]
> + //
> + F2.Key.ScanCode = SCAN_F2;
> + F2.Key.UnicodeChar = CHAR_NULL;
> + F2.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID;
> + F2.KeyState.KeyToggleState = 0;
> + Status = EfiBootManagerGetBootManagerMenu (&BootOption);
> + ASSERT_EFI_ERROR (Status);
> + RegisterBootOptionHotkey ((UINT16) BootOption.OptionNumber,
> &F2.Key, TRUE);
> + EfiBootManagerFreeLoadOption (&BootOption);
> +
> + F7.Key.ScanCode = SCAN_F7;
> + F7.Key.UnicodeChar = CHAR_NULL;
> + F7.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID;
> + F7.KeyState.KeyToggleState = 0;
> + mBootMenuBoot = !EnterSetup;
> + RegisterBootOptionHotkey ((UINT16) mBootMenuOptionNumber,
> &F7.Key, mBootMenuBoot);
> +
> +}
> +
> +
> +
> +/**
> + Returns the boot option type of a device
> +
> + @param DevicePath The path of device whose boot option type
> + to be returned
> + @retval -1 Device type not found
> + @retval > -1 Device type found
> +**/
> +UINT8
> +BootOptionType (
> + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
> + )
> +{
> + EFI_DEVICE_PATH_PROTOCOL *Node;
> + EFI_DEVICE_PATH_PROTOCOL *NextNode;
> +
> + for (Node = DevicePath; !IsDevicePathEndType (Node); Node =
> NextDevicePathNode (Node)) {
> + if (DevicePathType (Node) == MESSAGING_DEVICE_PATH) {
> + //
> + // Make sure the device path points to the driver device.
> + //
> + NextNode = NextDevicePathNode (Node);
> + if (DevicePathSubType(NextNode) ==
> MSG_DEVICE_LOGICAL_UNIT_DP) {
> + //
> + // if the next node type is Device Logical Unit, which specify the Logical
> Unit Number (LUN),
> + // skip it
> + //
> + NextNode = NextDevicePathNode (NextNode);
> + }
> + if (IsDevicePathEndType (NextNode)) {
> + if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH)) {
> + return DevicePathSubType (Node);
> + } else {
> + return MSG_SATA_DP;
> + }
> + }
> + }
> + }
> +
> + return (UINT8) -1;
> +}
> +
> +/**
> + Returns the priority number.
> + OptionType EFI
> + ------------------------------------
> + PXE 2
> + DVD 4
> + USB 6
> + NVME 7
> + HDD 8
> + EFI Shell 9
> + Others 100
> +
> + @param BootOption
> +**/
> +UINTN
> +BootOptionPriority (
> + CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOption
> + )
> +{
> + //
> + // EFI boot options
> + //
> + switch (BootOptionType (BootOption->FilePath)) {
> + case MSG_MAC_ADDR_DP:
> + case MSG_VLAN_DP:
> + case MSG_IPv4_DP:
> + case MSG_IPv6_DP:
> + return 2;
> +
> + case MSG_SATA_DP:
> + case MSG_ATAPI_DP:
> + case MSG_UFS_DP:
> + case MSG_NVME_NAMESPACE_DP:
> + return 4;
> +
> + case MSG_USB_DP:
> + return 6;
> +
> + }
> + if (StrCmp (BootOption->Description, INTERNAL_UEFI_SHELL_NAME) ==
> 0) {
> + if (PcdGetBool (PcdBootToShellOnly)) {
> + return 0;
> + }
> + return 9;
> + }
> + if (StrCmp (BootOption->Description, UEFI_HARD_DRIVE_NAME) == 0) {
> + return 8;
> + }
> + return 100;
> +}
> +
> +/**
> + Compares boot priorities of two boot options
> +
> + @param Left The left boot option
> + @param Right The right boot option
> +
> + @return The difference between the Left and Right
> + boot options
> + **/
> +INTN
> +EFIAPI
> +CompareBootOption (
> + CONST VOID *Left,
> + CONST VOID *Right
> + )
> +{
> + return BootOptionPriority ((EFI_BOOT_MANAGER_LOAD_OPTION *) Left)
> -
> + BootOptionPriority ((EFI_BOOT_MANAGER_LOAD_OPTION *) Right);
> +}
> +
> diff --git
> a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardMemory
> Test.c
> b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardMemory
> Test.c
> new file mode 100644
> index 0000000000..e3650721fe
> --- /dev/null
> +++
> b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardMemory
> Test.c
> @@ -0,0 +1,83 @@
> +/** @file
> + Perform the platform memory test
> +
> +Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include "BoardBdsHook.h"
> +#include <Protocol/GenericMemoryTest.h>
> +
> +/**
> + Perform the memory test base on the memory test intensive level,
> + and update the memory resource.
> +
> + @param Level The memory test intensive level.
> +
> + @retval EFI_STATUS Success test all the system memory and update
> + the memory resource
> +
> +**/
> +EFI_STATUS
> +MemoryTest (
> + IN EXTENDMEM_COVERAGE_LEVEL Level
> + )
> +{
> + EFI_STATUS Status;
> + BOOLEAN RequireSoftECCInit;
> + EFI_GENERIC_MEMORY_TEST_PROTOCOL *GenMemoryTest;
> + UINT64 TestedMemorySize;
> + UINT64 TotalMemorySize;
> + BOOLEAN ErrorOut;
> + BOOLEAN TestAbort;
> +
> + TestedMemorySize = 0;
> + TotalMemorySize = 0;
> + ErrorOut = FALSE;
> + TestAbort = FALSE;
> +
> + RequireSoftECCInit = FALSE;
> +
> + Status = gBS->LocateProtocol (
> + &gEfiGenericMemTestProtocolGuid,
> + NULL,
> + (VOID **) &GenMemoryTest
> + );
> + if (EFI_ERROR (Status)) {
> + return EFI_SUCCESS;
> + }
> +
> + Status = GenMemoryTest->MemoryTestInit (
> + GenMemoryTest,
> + Level,
> + &RequireSoftECCInit
> + );
> + if (Status == EFI_NO_MEDIA) {
> + //
> + // The PEI codes also have the relevant memory test code to check the
> memory,
> + // it can select to test some range of the memory or all of them. If PEI
> code
> + // checks all the memory, this BDS memory test will has no not-test
> memory to
> + // do the test, and then the status of EFI_NO_MEDIA will be returned by
> + // "MemoryTestInit". So it does not need to test memory again, just
> return.
> + //
> + return EFI_SUCCESS;
> + }
> +
> + do {
> + Status = GenMemoryTest->PerformMemoryTest (
> + GenMemoryTest,
> + &TestedMemorySize,
> + &TotalMemorySize,
> + &ErrorOut,
> + TestAbort
> + );
> + if (ErrorOut && (Status == EFI_DEVICE_ERROR)) {
> + ASSERT (0);
> + }
> + } while (Status != EFI_NOT_FOUND);
> +
> + Status = GenMemoryTest->Finished (GenMemoryTest);
> +
> + return EFI_SUCCESS;
> +}
> --
> 2.19.1.windows.1
^ permalink raw reply [flat|nested] 45+ messages in thread
* [edk2-platforms] [PATCH 03/11] BoardModulePkg: Add BDS Hook DXE Driver
2019-12-14 1:32 [edk2-platforms] [PATCH 00/11] Add BDS Hook Points Agyeman, Prince
2019-12-14 1:32 ` [edk2-platforms] [PATCH 01/11] MinPlatformPkg: Add BDS Hook Point Guids Agyeman, Prince
2019-12-14 1:32 ` [edk2-platforms] [PATCH 02/11] BoardModulePkg: Add BDS Hook Library Agyeman, Prince
@ 2019-12-14 1:32 ` Agyeman, Prince
2019-12-18 1:32 ` Nate DeSimone
2019-12-21 2:36 ` Kubacki, Michael A
2019-12-14 1:32 ` [edk2-platforms] [PATCH 04/11] MinPlatformPkg: Add BDS Board Boot Manager library Agyeman, Prince
` (8 subsequent siblings)
11 siblings, 2 replies; 45+ messages in thread
From: Agyeman, Prince @ 2019-12-14 1:32 UTC (permalink / raw)
To: devel; +Cc: Michael Kubacki, Chasel Chiu, Nate DeSimone
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
This is a sample/generic DXE driver that registers
all the BDS hook points or callbacks as defined in
BoardBdsHookLib.
Cc: Michael Kubacki <michael.a.kubacki@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
---
.../BoardBdsHookDxe/BoardBdsHookDxe.c | 121 ++++++++++++++++++
.../BoardBdsHookDxe/BoardBdsHookDxe.inf | 46 +++++++
2 files changed, 167 insertions(+)
create mode 100644 Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.c
create mode 100644 Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
diff --git a/Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.c b/Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.c
new file mode 100644
index 0000000000..88eb7d70e9
--- /dev/null
+++ b/Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.c
@@ -0,0 +1,121 @@
+/** @file
+ Bds Hook Point callbacks DXE driver
+
+ Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/UefiDriverEntryPoint.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
+#include <Library/BoardBdsHookLib.h>
+
+#include <Protocol/PciEnumerationComplete.h>
+
+/**
+ Initialize DXE Platform.
+
+ @param[in] ImageHandle Image handle of this driver.
+ @param[in] SystemTable Global system service table.
+
+ @retval EFI_SUCCESS Initialization complete.
+ @exception EFI_UNSUPPORTED The chipset is unsupported by this driver.
+ @retval EFI_OUT_OF_RESOURCES Do not have enough resources to initialize the driver.
+ @retval EFI_DEVICE_ERROR Device error, driver exits abnormally.
+**/
+EFI_STATUS
+EFIAPI
+BdsHookDxeEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_EVENT BeforeConsoleAfterTrustedConsoleEvent;
+ EFI_EVENT BeforeConsoleBeforeEndOfDxeEvent;
+ EFI_EVENT AfterConsoleReadyBeforeBootOptionEvent;
+ EFI_EVENT ReadyToBootEvent;
+ EFI_EVENT PciEnumCompleteEvent;
+ EFI_EVENT SmmReadyToLockEvent;
+ EFI_STATUS Status;
+ VOID *Registration;
+
+ DEBUG ((DEBUG_INFO, "%a starts\n", __FUNCTION__ ));
+
+ //
+ // Create event to set proper video resolution and text mode for internal shell.
+ //
+ Status = EfiCreateEventReadyToBootEx (
+ TPL_CALLBACK,
+ BdsReadyToBootCallback,
+ NULL,
+ &ReadyToBootEvent
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Create PCI Enumeration Completed callback for BDS
+ //
+ PciEnumCompleteEvent = EfiCreateProtocolNotifyEvent (
+ &gEfiPciEnumerationCompleteProtocolGuid,
+ TPL_CALLBACK,
+ BdsPciEnumCompleteCallback,
+ NULL,
+ &Registration
+ );
+ ASSERT (PciEnumCompleteEvent != NULL);
+
+ //
+ // Create PCI Enumeration Completed callback for BDS
+ //
+ SmmReadyToLockEvent = EfiCreateProtocolNotifyEvent (
+ &gEfiDxeSmmReadyToLockProtocolGuid,
+ TPL_CALLBACK,
+ BdsSmmReadyToLockCallback,
+ NULL,
+ &Registration
+ );
+ ASSERT (SmmReadyToLockEvent != NULL);
+
+ //
+ // Create BeforeConsoleAfterTrustedConsole event callback
+ //
+ Status = gBS->CreateEventEx (
+ EVT_NOTIFY_SIGNAL,
+ TPL_CALLBACK,
+ BdsBeforeConsoleAfterTrustedConsoleCallback,
+ NULL,
+ &gBdsEventBeforeConsoleAfterTrustedConsoleGuid,
+ &BeforeConsoleAfterTrustedConsoleEvent
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Create BeforeConsoleBeforeEndOfDxeGuid event callback
+ //
+ Status = gBS->CreateEventEx (
+ EVT_NOTIFY_SIGNAL,
+ TPL_CALLBACK,
+ BdsBeforeConsoleBeforeEndOfDxeGuidCallback,
+ NULL,
+ &gBdsEventBeforeConsoleBeforeEndOfDxeGuid,
+ &BeforeConsoleBeforeEndOfDxeEvent
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Create AfterConsoleReadyBeforeBootOption event callback
+ //
+ Status = gBS->CreateEventEx (
+ EVT_NOTIFY_SIGNAL,
+ TPL_CALLBACK,
+ BdsAfterConsoleReadyBeforeBootOptionCallback,
+ NULL,
+ &gBdsEventAfterConsoleReadyBeforeBootOptionGuid,
+ &AfterConsoleReadyBeforeBootOptionEvent
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ return Status;
+}
diff --git a/Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf b/Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
new file mode 100644
index 0000000000..e3871d6dd4
--- /dev/null
+++ b/Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
@@ -0,0 +1,46 @@
+### @file
+# Module Information file for the Bds Hook DXE driver.
+#
+# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+###
+
+[Defines]
+ INF_VERSION = 0x00010017
+ BASE_NAME = BoardBdsHookDxe
+ FILE_GUID = EEA6491C-0DC5-48AB-B99D-CE77D14D43F2
+ VERSION_STRING = 1.0
+ MODULE_TYPE = DXE_DRIVER
+ ENTRY_POINT = BdsHookDxeEntryPoint
+
+[LibraryClasses]
+ BaseLib
+ UefiBootServicesTableLib
+ UefiDriverEntryPoint
+ DebugLib
+ UefiLib
+ BoardBdsHookLib
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ SecurityPkg/SecurityPkg.dec
+ MinPlatformPkg/MinPlatformPkg.dec
+ BoardModulePkg/BoardModulePkg.dec
+
+[Sources]
+ BoardBdsHookDxe.c
+
+[Protocols]
+ gEfiPciEnumerationCompleteProtocolGuid
+ gEfiDxeSmmReadyToLockProtocolGuid
+
+[Guids]
+ gBdsEventBeforeConsoleAfterTrustedConsoleGuid
+ gBdsEventBeforeConsoleBeforeEndOfDxeGuid
+ gBdsEventAfterConsoleReadyBeforeBootOptionGuid
+
+[Depex]
+ TRUE
--
2.19.1.windows.1
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Re: [edk2-platforms] [PATCH 03/11] BoardModulePkg: Add BDS Hook DXE Driver
2019-12-14 1:32 ` [edk2-platforms] [PATCH 03/11] BoardModulePkg: Add BDS Hook DXE Driver Agyeman, Prince
@ 2019-12-18 1:32 ` Nate DeSimone
2019-12-21 2:36 ` Kubacki, Michael A
1 sibling, 0 replies; 45+ messages in thread
From: Nate DeSimone @ 2019-12-18 1:32 UTC (permalink / raw)
To: Agyeman, Prince; +Cc: devel@edk2.groups.io, Kubacki, Michael A, Chiu, Chasel
Hi Prince,
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
Thanks,
Nate
On Sat, Dec 14, 2019 at 01:32:29AM +0000, Agyeman, Prince wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
>
> This is a sample/generic DXE driver that registers
> all the BDS hook points or callbacks as defined in
> BoardBdsHookLib.
>
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
>
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
> .../BoardBdsHookDxe/BoardBdsHookDxe.c | 121 ++++++++++++++++++
> .../BoardBdsHookDxe/BoardBdsHookDxe.inf | 46 +++++++
> 2 files changed, 167 insertions(+)
> create mode 100644 Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.c
> create mode 100644 Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
>
> diff --git a/Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.c b/Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.c
> new file mode 100644
> index 0000000000..88eb7d70e9
> --- /dev/null
> +++ b/Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.c
> @@ -0,0 +1,121 @@
> +/** @file
> + Bds Hook Point callbacks DXE driver
> +
> + Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Library/UefiDriverEntryPoint.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/UefiLib.h>
> +#include <Library/BoardBdsHookLib.h>
> +
> +#include <Protocol/PciEnumerationComplete.h>
> +
> +/**
> + Initialize DXE Platform.
> +
> + @param[in] ImageHandle Image handle of this driver.
> + @param[in] SystemTable Global system service table.
> +
> + @retval EFI_SUCCESS Initialization complete.
> + @exception EFI_UNSUPPORTED The chipset is unsupported by this driver.
> + @retval EFI_OUT_OF_RESOURCES Do not have enough resources to initialize the driver.
> + @retval EFI_DEVICE_ERROR Device error, driver exits abnormally.
> +**/
> +EFI_STATUS
> +EFIAPI
> +BdsHookDxeEntryPoint (
> + IN EFI_HANDLE ImageHandle,
> + IN EFI_SYSTEM_TABLE *SystemTable
> + )
> +{
> + EFI_EVENT BeforeConsoleAfterTrustedConsoleEvent;
> + EFI_EVENT BeforeConsoleBeforeEndOfDxeEvent;
> + EFI_EVENT AfterConsoleReadyBeforeBootOptionEvent;
> + EFI_EVENT ReadyToBootEvent;
> + EFI_EVENT PciEnumCompleteEvent;
> + EFI_EVENT SmmReadyToLockEvent;
> + EFI_STATUS Status;
> + VOID *Registration;
> +
> + DEBUG ((DEBUG_INFO, "%a starts\n", __FUNCTION__ ));
> +
> + //
> + // Create event to set proper video resolution and text mode for internal shell.
> + //
> + Status = EfiCreateEventReadyToBootEx (
> + TPL_CALLBACK,
> + BdsReadyToBootCallback,
> + NULL,
> + &ReadyToBootEvent
> + );
> + ASSERT_EFI_ERROR (Status);
> +
> + //
> + // Create PCI Enumeration Completed callback for BDS
> + //
> + PciEnumCompleteEvent = EfiCreateProtocolNotifyEvent (
> + &gEfiPciEnumerationCompleteProtocolGuid,
> + TPL_CALLBACK,
> + BdsPciEnumCompleteCallback,
> + NULL,
> + &Registration
> + );
> + ASSERT (PciEnumCompleteEvent != NULL);
> +
> + //
> + // Create PCI Enumeration Completed callback for BDS
> + //
> + SmmReadyToLockEvent = EfiCreateProtocolNotifyEvent (
> + &gEfiDxeSmmReadyToLockProtocolGuid,
> + TPL_CALLBACK,
> + BdsSmmReadyToLockCallback,
> + NULL,
> + &Registration
> + );
> + ASSERT (SmmReadyToLockEvent != NULL);
> +
> + //
> + // Create BeforeConsoleAfterTrustedConsole event callback
> + //
> + Status = gBS->CreateEventEx (
> + EVT_NOTIFY_SIGNAL,
> + TPL_CALLBACK,
> + BdsBeforeConsoleAfterTrustedConsoleCallback,
> + NULL,
> + &gBdsEventBeforeConsoleAfterTrustedConsoleGuid,
> + &BeforeConsoleAfterTrustedConsoleEvent
> + );
> + ASSERT_EFI_ERROR (Status);
> +
> + //
> + // Create BeforeConsoleBeforeEndOfDxeGuid event callback
> + //
> + Status = gBS->CreateEventEx (
> + EVT_NOTIFY_SIGNAL,
> + TPL_CALLBACK,
> + BdsBeforeConsoleBeforeEndOfDxeGuidCallback,
> + NULL,
> + &gBdsEventBeforeConsoleBeforeEndOfDxeGuid,
> + &BeforeConsoleBeforeEndOfDxeEvent
> + );
> + ASSERT_EFI_ERROR (Status);
> +
> + //
> + // Create AfterConsoleReadyBeforeBootOption event callback
> + //
> + Status = gBS->CreateEventEx (
> + EVT_NOTIFY_SIGNAL,
> + TPL_CALLBACK,
> + BdsAfterConsoleReadyBeforeBootOptionCallback,
> + NULL,
> + &gBdsEventAfterConsoleReadyBeforeBootOptionGuid,
> + &AfterConsoleReadyBeforeBootOptionEvent
> + );
> + ASSERT_EFI_ERROR (Status);
> +
> + return Status;
> +}
> diff --git a/Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf b/Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
> new file mode 100644
> index 0000000000..e3871d6dd4
> --- /dev/null
> +++ b/Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
> @@ -0,0 +1,46 @@
> +### @file
> +# Module Information file for the Bds Hook DXE driver.
> +#
> +# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +###
> +
> +[Defines]
> + INF_VERSION = 0x00010017
> + BASE_NAME = BoardBdsHookDxe
> + FILE_GUID = EEA6491C-0DC5-48AB-B99D-CE77D14D43F2
> + VERSION_STRING = 1.0
> + MODULE_TYPE = DXE_DRIVER
> + ENTRY_POINT = BdsHookDxeEntryPoint
> +
> +[LibraryClasses]
> + BaseLib
> + UefiBootServicesTableLib
> + UefiDriverEntryPoint
> + DebugLib
> + UefiLib
> + BoardBdsHookLib
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + SecurityPkg/SecurityPkg.dec
> + MinPlatformPkg/MinPlatformPkg.dec
> + BoardModulePkg/BoardModulePkg.dec
> +
> +[Sources]
> + BoardBdsHookDxe.c
> +
> +[Protocols]
> + gEfiPciEnumerationCompleteProtocolGuid
> + gEfiDxeSmmReadyToLockProtocolGuid
> +
> +[Guids]
> + gBdsEventBeforeConsoleAfterTrustedConsoleGuid
> + gBdsEventBeforeConsoleBeforeEndOfDxeGuid
> + gBdsEventAfterConsoleReadyBeforeBootOptionGuid
> +
> +[Depex]
> + TRUE
> --
> 2.19.1.windows.1
>
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [edk2-platforms] [PATCH 03/11] BoardModulePkg: Add BDS Hook DXE Driver
2019-12-14 1:32 ` [edk2-platforms] [PATCH 03/11] BoardModulePkg: Add BDS Hook DXE Driver Agyeman, Prince
2019-12-18 1:32 ` Nate DeSimone
@ 2019-12-21 2:36 ` Kubacki, Michael A
1 sibling, 0 replies; 45+ messages in thread
From: Kubacki, Michael A @ 2019-12-21 2:36 UTC (permalink / raw)
To: Agyeman, Prince, devel@edk2.groups.io; +Cc: Chiu, Chasel, Desimone, Nathaniel L
Reviewed-by: Michael Kubacki <michael.a.kubacki@intel.com>
> -----Original Message-----
> From: Agyeman, Prince <prince.agyeman@intel.com>
> Sent: Friday, December 13, 2019 5:32 PM
> To: devel@edk2.groups.io
> Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Chiu, Chasel
> <chasel.chiu@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>
> Subject: [edk2-platforms] [PATCH 03/11] BoardModulePkg: Add BDS Hook
> DXE Driver
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
>
> This is a sample/generic DXE driver that registers all the BDS hook points or
> callbacks as defined in BoardBdsHookLib.
>
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
>
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
> .../BoardBdsHookDxe/BoardBdsHookDxe.c | 121 ++++++++++++++++++
> .../BoardBdsHookDxe/BoardBdsHookDxe.inf | 46 +++++++
> 2 files changed, 167 insertions(+)
> create mode 100644
> Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.c
> create mode 100644
> Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
>
> diff --git
> a/Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.c
> b/Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.c
> new file mode 100644
> index 0000000000..88eb7d70e9
> --- /dev/null
> +++
> b/Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.c
> @@ -0,0 +1,121 @@
> +/** @file
> + Bds Hook Point callbacks DXE driver
> +
> + Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Library/UefiDriverEntryPoint.h> #include
> +<Library/UefiBootServicesTableLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/UefiLib.h>
> +#include <Library/BoardBdsHookLib.h>
> +
> +#include <Protocol/PciEnumerationComplete.h>
> +
> +/**
> + Initialize DXE Platform.
> +
> + @param[in] ImageHandle Image handle of this driver.
> + @param[in] SystemTable Global system service table.
> +
> + @retval EFI_SUCCESS Initialization complete.
> + @exception EFI_UNSUPPORTED The chipset is unsupported by this
> driver.
> + @retval EFI_OUT_OF_RESOURCES Do not have enough resources to
> initialize the driver.
> + @retval EFI_DEVICE_ERROR Device error, driver exits abnormally.
> +**/
> +EFI_STATUS
> +EFIAPI
> +BdsHookDxeEntryPoint (
> + IN EFI_HANDLE ImageHandle,
> + IN EFI_SYSTEM_TABLE *SystemTable
> + )
> +{
> + EFI_EVENT BeforeConsoleAfterTrustedConsoleEvent;
> + EFI_EVENT BeforeConsoleBeforeEndOfDxeEvent;
> + EFI_EVENT AfterConsoleReadyBeforeBootOptionEvent;
> + EFI_EVENT ReadyToBootEvent;
> + EFI_EVENT PciEnumCompleteEvent;
> + EFI_EVENT SmmReadyToLockEvent;
> + EFI_STATUS Status;
> + VOID *Registration;
> +
> + DEBUG ((DEBUG_INFO, "%a starts\n", __FUNCTION__ ));
> +
> + //
> + // Create event to set proper video resolution and text mode for internal
> shell.
> + //
> + Status = EfiCreateEventReadyToBootEx (
> + TPL_CALLBACK,
> + BdsReadyToBootCallback,
> + NULL,
> + &ReadyToBootEvent
> + );
> + ASSERT_EFI_ERROR (Status);
> +
> + //
> + // Create PCI Enumeration Completed callback for BDS //
> + PciEnumCompleteEvent = EfiCreateProtocolNotifyEvent (
> + &gEfiPciEnumerationCompleteProtocolGuid,
> + TPL_CALLBACK,
> + BdsPciEnumCompleteCallback,
> + NULL,
> + &Registration
> + );
> + ASSERT (PciEnumCompleteEvent != NULL);
> +
> + //
> + // Create PCI Enumeration Completed callback for BDS //
> + SmmReadyToLockEvent = EfiCreateProtocolNotifyEvent (
> + &gEfiDxeSmmReadyToLockProtocolGuid,
> + TPL_CALLBACK,
> + BdsSmmReadyToLockCallback,
> + NULL,
> + &Registration
> + );
> + ASSERT (SmmReadyToLockEvent != NULL);
> +
> + //
> + // Create BeforeConsoleAfterTrustedConsole event callback // Status
> + = gBS->CreateEventEx (
> + EVT_NOTIFY_SIGNAL,
> + TPL_CALLBACK,
> + BdsBeforeConsoleAfterTrustedConsoleCallback,
> + NULL,
> + &gBdsEventBeforeConsoleAfterTrustedConsoleGuid,
> + &BeforeConsoleAfterTrustedConsoleEvent
> + );
> + ASSERT_EFI_ERROR (Status);
> +
> + //
> + // Create BeforeConsoleBeforeEndOfDxeGuid event callback // Status
> + = gBS->CreateEventEx (
> + EVT_NOTIFY_SIGNAL,
> + TPL_CALLBACK,
> + BdsBeforeConsoleBeforeEndOfDxeGuidCallback,
> + NULL,
> + &gBdsEventBeforeConsoleBeforeEndOfDxeGuid,
> + &BeforeConsoleBeforeEndOfDxeEvent
> + );
> + ASSERT_EFI_ERROR (Status);
> +
> + //
> + // Create AfterConsoleReadyBeforeBootOption event callback //
> + Status = gBS->CreateEventEx (
> + EVT_NOTIFY_SIGNAL,
> + TPL_CALLBACK,
> + BdsAfterConsoleReadyBeforeBootOptionCallback,
> + NULL,
> + &gBdsEventAfterConsoleReadyBeforeBootOptionGuid,
> + &AfterConsoleReadyBeforeBootOptionEvent
> + );
> + ASSERT_EFI_ERROR (Status);
> +
> + return Status;
> +}
> diff --git
> a/Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.in
> f
> b/Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.in
> f
> new file mode 100644
> index 0000000000..e3871d6dd4
> --- /dev/null
> +++
> b/Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.in
> f
> @@ -0,0 +1,46 @@
> +### @file
> +# Module Information file for the Bds Hook DXE driver.
> +#
> +# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> # #
> +SPDX-License-Identifier: BSD-2-Clause-Patent # ###
> +
> +[Defines]
> + INF_VERSION = 0x00010017
> + BASE_NAME = BoardBdsHookDxe
> + FILE_GUID = EEA6491C-0DC5-48AB-B99D-CE77D14D43F2
> + VERSION_STRING = 1.0
> + MODULE_TYPE = DXE_DRIVER
> + ENTRY_POINT = BdsHookDxeEntryPoint
> +
> +[LibraryClasses]
> + BaseLib
> + UefiBootServicesTableLib
> + UefiDriverEntryPoint
> + DebugLib
> + UefiLib
> + BoardBdsHookLib
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + SecurityPkg/SecurityPkg.dec
> + MinPlatformPkg/MinPlatformPkg.dec
> + BoardModulePkg/BoardModulePkg.dec
> +
> +[Sources]
> + BoardBdsHookDxe.c
> +
> +[Protocols]
> + gEfiPciEnumerationCompleteProtocolGuid
> + gEfiDxeSmmReadyToLockProtocolGuid
> +
> +[Guids]
> + gBdsEventBeforeConsoleAfterTrustedConsoleGuid
> + gBdsEventBeforeConsoleBeforeEndOfDxeGuid
> + gBdsEventAfterConsoleReadyBeforeBootOptionGuid
> +
> +[Depex]
> + TRUE
> --
> 2.19.1.windows.1
^ permalink raw reply [flat|nested] 45+ messages in thread
* [edk2-platforms] [PATCH 04/11] MinPlatformPkg: Add BDS Board Boot Manager library
2019-12-14 1:32 [edk2-platforms] [PATCH 00/11] Add BDS Hook Points Agyeman, Prince
` (2 preceding siblings ...)
2019-12-14 1:32 ` [edk2-platforms] [PATCH 03/11] BoardModulePkg: Add BDS Hook DXE Driver Agyeman, Prince
@ 2019-12-14 1:32 ` Agyeman, Prince
2019-12-17 4:24 ` Chiu, Chasel
` (2 more replies)
2019-12-14 1:32 ` [edk2-platforms] [PATCH 05/11] MinPlatformPkg: Add BDS Hook Points Agyeman, Prince
` (7 subsequent siblings)
11 siblings, 3 replies; 45+ messages in thread
From: Agyeman, Prince @ 2019-12-14 1:32 UTC (permalink / raw)
To: devel; +Cc: Michael Kubacki, Chasel Chiu, Nate DeSimone
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
As Minplatform's PlatformBootManager library instance implements
event signals (as specified in the minimum platform specification)
to trigger board actions, some of its functions namely
PlatformBootManagerWaitCallback and PlatformBootManagerUnableToBoot
will not have events signaled for boards to take action.
This library implements PlatformBootManagerWaitCallback
and PlatformBootManagerUnableToBoot which will be linked to Minplatform's
PlatformBootManager libary instance.
Added is an interface/header file that defines the board boot manager
library.
Also added is a NULL implementation of the board boot manager library
Cc: Michael Kubacki <michael.a.kubacki@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
---
.../BoardBootManagerLib.c | 38 ++++++++++++++++++
.../BoardBootManagerLibNull.inf | 31 +++++++++++++++
.../Include/Library/BoardBootManagerLib.h | 39 +++++++++++++++++++
3 files changed, 108 insertions(+)
create mode 100644 Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/BoardBootManagerLib.c
create mode 100644 Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/BoardBootManagerLibNull.inf
create mode 100644 Platform/Intel/MinPlatformPkg/Include/Library/BoardBootManagerLib.h
diff --git a/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/BoardBootManagerLib.c b/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/BoardBootManagerLib.c
new file mode 100644
index 0000000000..46fce8f59f
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/BoardBootManagerLib.c
@@ -0,0 +1,38 @@
+/** @file
+ This file include board specific boot manager callbacks
+
+ Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <Library/BoardBootManagerLib.h>
+
+/**
+ This function is called each second during the boot manager waits timeout.
+
+ @param TimeoutRemain The remaining timeout.
+**/
+VOID
+EFIAPI
+BoardBootManagerWaitCallback (
+ IN UINT16 TimeoutRemain
+ )
+{
+ return;
+}
+
+/**
+ The function is called when no boot option could be launched,
+ including platform recovery options and options pointing to applications
+ built into firmware volumes.
+
+**/
+VOID
+EFIAPI
+BoardBootManagerUnableToBoot (
+ VOID
+ )
+{
+ return;
+}
+
diff --git a/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/BoardBootManagerLibNull.inf b/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/BoardBootManagerLibNull.inf
new file mode 100644
index 0000000000..084207b111
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/BoardBootManagerLibNull.inf
@@ -0,0 +1,31 @@
+## @file
+# The module definition file for BoardBootManagerLib.
+#
+# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = BoardBootManagerLib
+ FILE_GUID = 7BA684A4-5B32-4F0C-B0FF-581F143E606C
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = BoardBootManagerLib|DXE_DRIVER
+
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 EBC
+#
+
+[Sources]
+ BoardBootManagerLib.c
+
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ MinPlatformPkg/MinPlatformPkg.dec
diff --git a/Platform/Intel/MinPlatformPkg/Include/Library/BoardBootManagerLib.h b/Platform/Intel/MinPlatformPkg/Include/Library/BoardBootManagerLib.h
new file mode 100644
index 0000000000..4240142073
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Include/Library/BoardBootManagerLib.h
@@ -0,0 +1,39 @@
+/** @file
+ Board Boot Manager library definition. A platform can implement
+ instances to support platform-specific behavior.
+
+ Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+
+#ifndef __BOARD_BOOT_MANAGER_LIB_H_
+#define __BOARD_BOOT_MANAGER_LIB_H_
+#include <Library/UefiBootManagerLib.h>
+
+
+/**
+ This function is called each second during boot manager waits the timeout.
+
+ @param TimeoutRemain The remaining timeout.
+**/
+VOID
+EFIAPI
+BoardBootManagerWaitCallback (
+ IN UINT16 TimeoutRemain
+ );
+
+/**
+ The function is called when no boot option could be launched,
+ including platform recovery options and options pointing to applications
+ built into firmware volumes.
+
+**/
+VOID
+EFIAPI
+BoardBootManagerUnableToBoot (
+ VOID
+ );
+
+#endif
--
2.19.1.windows.1
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Re: [edk2-platforms] [PATCH 04/11] MinPlatformPkg: Add BDS Board Boot Manager library
2019-12-14 1:32 ` [edk2-platforms] [PATCH 04/11] MinPlatformPkg: Add BDS Board Boot Manager library Agyeman, Prince
@ 2019-12-17 4:24 ` Chiu, Chasel
2019-12-18 1:33 ` Nate DeSimone
2019-12-21 2:36 ` Kubacki, Michael A
2 siblings, 0 replies; 45+ messages in thread
From: Chiu, Chasel @ 2019-12-17 4:24 UTC (permalink / raw)
To: Agyeman, Prince, devel@edk2.groups.io
Cc: Kubacki, Michael A, Desimone, Nathaniel L
Hi Prince,
BoardBootManagerLib.c is added as new file so it should have 2019 in copyright.
With that Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
> -----Original Message-----
> From: Agyeman, Prince <prince.agyeman@intel.com>
> Sent: Saturday, December 14, 2019 9:33 AM
> To: devel@edk2.groups.io
> Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Chiu, Chasel
> <chasel.chiu@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>
> Subject: [edk2-platforms] [PATCH 04/11] MinPlatformPkg: Add BDS Board
> Boot Manager library
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
>
> As Minplatform's PlatformBootManager library instance implements event
> signals (as specified in the minimum platform specification) to trigger board
> actions, some of its functions namely PlatformBootManagerWaitCallback
> and PlatformBootManagerUnableToBoot will not have events signaled for
> boards to take action.
>
> This library implements PlatformBootManagerWaitCallback and
> PlatformBootManagerUnableToBoot which will be linked to Minplatform's
> PlatformBootManager libary instance.
>
> Added is an interface/header file that defines the board boot manager
> library.
>
> Also added is a NULL implementation of the board boot manager library
>
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
>
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
> .../BoardBootManagerLib.c | 38
> ++++++++++++++++++
> .../BoardBootManagerLibNull.inf | 31 +++++++++++++++
> .../Include/Library/BoardBootManagerLib.h | 39
> +++++++++++++++++++
> 3 files changed, 108 insertions(+)
> create mode 100644
> Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/Boar
> dBootManagerLib.c
> create mode 100644
> Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/Boar
> dBootManagerLibNull.inf
> create mode 100644
> Platform/Intel/MinPlatformPkg/Include/Library/BoardBootManagerLib.h
>
> diff --git
> a/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/Bo
> ardBootManagerLib.c
> b/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/Bo
> ardBootManagerLib.c
> new file mode 100644
> index 0000000000..46fce8f59f
> --- /dev/null
> +++
> b/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/
> +++ BoardBootManagerLib.c
> @@ -0,0 +1,38 @@
> +/** @file
> + This file include board specific boot manager callbacks
> +
> + Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
> + SPDX-License-Identifier: BSD-2-Clause-Patent **/
> +
> +#include <Library/BoardBootManagerLib.h>
> +
> +/**
> + This function is called each second during the boot manager waits
> timeout.
> +
> + @param TimeoutRemain The remaining timeout.
> +**/
> +VOID
> +EFIAPI
> +BoardBootManagerWaitCallback (
> + IN UINT16 TimeoutRemain
> + )
> +{
> + return;
> +}
> +
> +/**
> + The function is called when no boot option could be launched,
> + including platform recovery options and options pointing to
> +applications
> + built into firmware volumes.
> +
> +**/
> +VOID
> +EFIAPI
> +BoardBootManagerUnableToBoot (
> + VOID
> + )
> +{
> + return;
> +}
> +
> diff --git
> a/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/Bo
> ardBootManagerLibNull.inf
> b/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/Bo
> ardBootManagerLibNull.inf
> new file mode 100644
> index 0000000000..084207b111
> --- /dev/null
> +++
> b/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/
> +++ BoardBootManagerLibNull.inf
> @@ -0,0 +1,31 @@
> +## @file
> +# The module definition file for BoardBootManagerLib.
> +#
> +# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> #
> +SPDX-License-Identifier: BSD-2-Clause-Patent # ##
> +
> +[Defines]
> + INF_VERSION = 0x00010005
> + BASE_NAME = BoardBootManagerLib
> + FILE_GUID =
> 7BA684A4-5B32-4F0C-B0FF-581F143E606C
> + MODULE_TYPE = DXE_DRIVER
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS =
> BoardBootManagerLib|DXE_DRIVER
> +
> +
> +#
> +# The following information is for reference only and not required by the
> build tools.
> +#
> +# VALID_ARCHITECTURES = IA32 X64 EBC
> +#
> +
> +[Sources]
> + BoardBootManagerLib.c
> +
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + MinPlatformPkg/MinPlatformPkg.dec
> diff --git
> a/Platform/Intel/MinPlatformPkg/Include/Library/BoardBootManagerLib.h
> b/Platform/Intel/MinPlatformPkg/Include/Library/BoardBootManagerLib.h
> new file mode 100644
> index 0000000000..4240142073
> --- /dev/null
> +++
> b/Platform/Intel/MinPlatformPkg/Include/Library/BoardBootManagerLib.
> +++ h
> @@ -0,0 +1,39 @@
> +/** @file
> + Board Boot Manager library definition. A platform can implement
> + instances to support platform-specific behavior.
> +
> + Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +
> +#ifndef __BOARD_BOOT_MANAGER_LIB_H_
> +#define __BOARD_BOOT_MANAGER_LIB_H_
> +#include <Library/UefiBootManagerLib.h>
> +
> +
> +/**
> + This function is called each second during boot manager waits the
> timeout.
> +
> + @param TimeoutRemain The remaining timeout.
> +**/
> +VOID
> +EFIAPI
> +BoardBootManagerWaitCallback (
> + IN UINT16 TimeoutRemain
> + );
> +
> +/**
> + The function is called when no boot option could be launched,
> + including platform recovery options and options pointing to
> +applications
> + built into firmware volumes.
> +
> +**/
> +VOID
> +EFIAPI
> +BoardBootManagerUnableToBoot (
> + VOID
> + );
> +
> +#endif
> --
> 2.19.1.windows.1
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [edk2-platforms] [PATCH 04/11] MinPlatformPkg: Add BDS Board Boot Manager library
2019-12-14 1:32 ` [edk2-platforms] [PATCH 04/11] MinPlatformPkg: Add BDS Board Boot Manager library Agyeman, Prince
2019-12-17 4:24 ` Chiu, Chasel
@ 2019-12-18 1:33 ` Nate DeSimone
2019-12-21 2:36 ` Kubacki, Michael A
2 siblings, 0 replies; 45+ messages in thread
From: Nate DeSimone @ 2019-12-18 1:33 UTC (permalink / raw)
To: Agyeman, Prince; +Cc: devel@edk2.groups.io, Kubacki, Michael A, Chiu, Chasel
Hi Prince,
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
Thanks,
Nate
On Sat, Dec 14, 2019 at 01:32:30AM +0000, Agyeman, Prince wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
>
> As Minplatform's PlatformBootManager library instance implements
> event signals (as specified in the minimum platform specification)
> to trigger board actions, some of its functions namely
> PlatformBootManagerWaitCallback and PlatformBootManagerUnableToBoot
> will not have events signaled for boards to take action.
>
> This library implements PlatformBootManagerWaitCallback
> and PlatformBootManagerUnableToBoot which will be linked to Minplatform's
> PlatformBootManager libary instance.
>
> Added is an interface/header file that defines the board boot manager
> library.
>
> Also added is a NULL implementation of the board boot manager library
>
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
>
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
> .../BoardBootManagerLib.c | 38 ++++++++++++++++++
> .../BoardBootManagerLibNull.inf | 31 +++++++++++++++
> .../Include/Library/BoardBootManagerLib.h | 39 +++++++++++++++++++
> 3 files changed, 108 insertions(+)
> create mode 100644 Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/BoardBootManagerLib.c
> create mode 100644 Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/BoardBootManagerLibNull.inf
> create mode 100644 Platform/Intel/MinPlatformPkg/Include/Library/BoardBootManagerLib.h
>
> diff --git a/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/BoardBootManagerLib.c b/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/BoardBootManagerLib.c
> new file mode 100644
> index 0000000000..46fce8f59f
> --- /dev/null
> +++ b/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/BoardBootManagerLib.c
> @@ -0,0 +1,38 @@
> +/** @file
> + This file include board specific boot manager callbacks
> +
> + Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +**/
> +
> +#include <Library/BoardBootManagerLib.h>
> +
> +/**
> + This function is called each second during the boot manager waits timeout.
> +
> + @param TimeoutRemain The remaining timeout.
> +**/
> +VOID
> +EFIAPI
> +BoardBootManagerWaitCallback (
> + IN UINT16 TimeoutRemain
> + )
> +{
> + return;
> +}
> +
> +/**
> + The function is called when no boot option could be launched,
> + including platform recovery options and options pointing to applications
> + built into firmware volumes.
> +
> +**/
> +VOID
> +EFIAPI
> +BoardBootManagerUnableToBoot (
> + VOID
> + )
> +{
> + return;
> +}
> +
> diff --git a/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/BoardBootManagerLibNull.inf b/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/BoardBootManagerLibNull.inf
> new file mode 100644
> index 0000000000..084207b111
> --- /dev/null
> +++ b/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/BoardBootManagerLibNull.inf
> @@ -0,0 +1,31 @@
> +## @file
> +# The module definition file for BoardBootManagerLib.
> +#
> +# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + INF_VERSION = 0x00010005
> + BASE_NAME = BoardBootManagerLib
> + FILE_GUID = 7BA684A4-5B32-4F0C-B0FF-581F143E606C
> + MODULE_TYPE = DXE_DRIVER
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = BoardBootManagerLib|DXE_DRIVER
> +
> +
> +#
> +# The following information is for reference only and not required by the build tools.
> +#
> +# VALID_ARCHITECTURES = IA32 X64 EBC
> +#
> +
> +[Sources]
> + BoardBootManagerLib.c
> +
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + MinPlatformPkg/MinPlatformPkg.dec
> diff --git a/Platform/Intel/MinPlatformPkg/Include/Library/BoardBootManagerLib.h b/Platform/Intel/MinPlatformPkg/Include/Library/BoardBootManagerLib.h
> new file mode 100644
> index 0000000000..4240142073
> --- /dev/null
> +++ b/Platform/Intel/MinPlatformPkg/Include/Library/BoardBootManagerLib.h
> @@ -0,0 +1,39 @@
> +/** @file
> + Board Boot Manager library definition. A platform can implement
> + instances to support platform-specific behavior.
> +
> + Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +
> +#ifndef __BOARD_BOOT_MANAGER_LIB_H_
> +#define __BOARD_BOOT_MANAGER_LIB_H_
> +#include <Library/UefiBootManagerLib.h>
> +
> +
> +/**
> + This function is called each second during boot manager waits the timeout.
> +
> + @param TimeoutRemain The remaining timeout.
> +**/
> +VOID
> +EFIAPI
> +BoardBootManagerWaitCallback (
> + IN UINT16 TimeoutRemain
> + );
> +
> +/**
> + The function is called when no boot option could be launched,
> + including platform recovery options and options pointing to applications
> + built into firmware volumes.
> +
> +**/
> +VOID
> +EFIAPI
> +BoardBootManagerUnableToBoot (
> + VOID
> + );
> +
> +#endif
> --
> 2.19.1.windows.1
>
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [edk2-platforms] [PATCH 04/11] MinPlatformPkg: Add BDS Board Boot Manager library
2019-12-14 1:32 ` [edk2-platforms] [PATCH 04/11] MinPlatformPkg: Add BDS Board Boot Manager library Agyeman, Prince
2019-12-17 4:24 ` Chiu, Chasel
2019-12-18 1:33 ` Nate DeSimone
@ 2019-12-21 2:36 ` Kubacki, Michael A
2 siblings, 0 replies; 45+ messages in thread
From: Kubacki, Michael A @ 2019-12-21 2:36 UTC (permalink / raw)
To: Agyeman, Prince, devel@edk2.groups.io; +Cc: Chiu, Chasel, Desimone, Nathaniel L
Since BoardBootManagerWaitCallback () is a new function, please add @param[in] for the TimeoutRemain parameter.
With that change - Reviewed-by: Michael Kubacki <michael.a.kubacki@intel.com>
> -----Original Message-----
> From: Agyeman, Prince <prince.agyeman@intel.com>
> Sent: Friday, December 13, 2019 5:33 PM
> To: devel@edk2.groups.io
> Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Chiu, Chasel
> <chasel.chiu@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>
> Subject: [edk2-platforms] [PATCH 04/11] MinPlatformPkg: Add BDS Board
> Boot Manager library
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
>
> As Minplatform's PlatformBootManager library instance implements event
> signals (as specified in the minimum platform specification) to trigger board
> actions, some of its functions namely PlatformBootManagerWaitCallback and
> PlatformBootManagerUnableToBoot will not have events signaled for boards
> to take action.
>
> This library implements PlatformBootManagerWaitCallback and
> PlatformBootManagerUnableToBoot which will be linked to Minplatform's
> PlatformBootManager libary instance.
>
> Added is an interface/header file that defines the board boot manager
> library.
>
> Also added is a NULL implementation of the board boot manager library
>
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
>
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
> .../BoardBootManagerLib.c | 38 ++++++++++++++++++
> .../BoardBootManagerLibNull.inf | 31 +++++++++++++++
> .../Include/Library/BoardBootManagerLib.h | 39 +++++++++++++++++++
> 3 files changed, 108 insertions(+)
> create mode 100644
> Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/Boar
> dBootManagerLib.c
> create mode 100644
> Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/Boar
> dBootManagerLibNull.inf
> create mode 100644
> Platform/Intel/MinPlatformPkg/Include/Library/BoardBootManagerLib.h
>
> diff --git
> a/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/Bo
> ardBootManagerLib.c
> b/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/Bo
> ardBootManagerLib.c
> new file mode 100644
> index 0000000000..46fce8f59f
> --- /dev/null
> +++
> b/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/
> +++ BoardBootManagerLib.c
> @@ -0,0 +1,38 @@
> +/** @file
> + This file include board specific boot manager callbacks
> +
> + Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
> + SPDX-License-Identifier: BSD-2-Clause-Patent **/
> +
> +#include <Library/BoardBootManagerLib.h>
> +
> +/**
> + This function is called each second during the boot manager waits timeout.
> +
> + @param TimeoutRemain The remaining timeout.
> +**/
> +VOID
> +EFIAPI
> +BoardBootManagerWaitCallback (
> + IN UINT16 TimeoutRemain
> + )
> +{
> + return;
> +}
> +
> +/**
> + The function is called when no boot option could be launched,
> + including platform recovery options and options pointing to
> +applications
> + built into firmware volumes.
> +
> +**/
> +VOID
> +EFIAPI
> +BoardBootManagerUnableToBoot (
> + VOID
> + )
> +{
> + return;
> +}
> +
> diff --git
> a/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/Bo
> ardBootManagerLibNull.inf
> b/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/Bo
> ardBootManagerLibNull.inf
> new file mode 100644
> index 0000000000..084207b111
> --- /dev/null
> +++
> b/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/
> +++ BoardBootManagerLibNull.inf
> @@ -0,0 +1,31 @@
> +## @file
> +# The module definition file for BoardBootManagerLib.
> +#
> +# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> #
> +SPDX-License-Identifier: BSD-2-Clause-Patent # ##
> +
> +[Defines]
> + INF_VERSION = 0x00010005
> + BASE_NAME = BoardBootManagerLib
> + FILE_GUID = 7BA684A4-5B32-4F0C-B0FF-581F143E606C
> + MODULE_TYPE = DXE_DRIVER
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = BoardBootManagerLib|DXE_DRIVER
> +
> +
> +#
> +# The following information is for reference only and not required by the
> build tools.
> +#
> +# VALID_ARCHITECTURES = IA32 X64 EBC
> +#
> +
> +[Sources]
> + BoardBootManagerLib.c
> +
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + MinPlatformPkg/MinPlatformPkg.dec
> diff --git
> a/Platform/Intel/MinPlatformPkg/Include/Library/BoardBootManagerLib.h
> b/Platform/Intel/MinPlatformPkg/Include/Library/BoardBootManagerLib.h
> new file mode 100644
> index 0000000000..4240142073
> --- /dev/null
> +++
> b/Platform/Intel/MinPlatformPkg/Include/Library/BoardBootManagerLib.
> +++ h
> @@ -0,0 +1,39 @@
> +/** @file
> + Board Boot Manager library definition. A platform can implement
> + instances to support platform-specific behavior.
> +
> + Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +
> +#ifndef __BOARD_BOOT_MANAGER_LIB_H_
> +#define __BOARD_BOOT_MANAGER_LIB_H_
> +#include <Library/UefiBootManagerLib.h>
> +
> +
> +/**
> + This function is called each second during boot manager waits the timeout.
> +
> + @param TimeoutRemain The remaining timeout.
> +**/
> +VOID
> +EFIAPI
> +BoardBootManagerWaitCallback (
> + IN UINT16 TimeoutRemain
> + );
> +
> +/**
> + The function is called when no boot option could be launched,
> + including platform recovery options and options pointing to
> +applications
> + built into firmware volumes.
> +
> +**/
> +VOID
> +EFIAPI
> +BoardBootManagerUnableToBoot (
> + VOID
> + );
> +
> +#endif
> --
> 2.19.1.windows.1
^ permalink raw reply [flat|nested] 45+ messages in thread
* [edk2-platforms] [PATCH 05/11] MinPlatformPkg: Add BDS Hook Points
2019-12-14 1:32 [edk2-platforms] [PATCH 00/11] Add BDS Hook Points Agyeman, Prince
` (3 preceding siblings ...)
2019-12-14 1:32 ` [edk2-platforms] [PATCH 04/11] MinPlatformPkg: Add BDS Board Boot Manager library Agyeman, Prince
@ 2019-12-14 1:32 ` Agyeman, Prince
2019-12-17 5:44 ` Chiu, Chasel
` (2 more replies)
2019-12-14 1:32 ` [edk2-platforms] [PATCH 06/11] BoardModulePkg: Add Generic BoardBootManagerLib Agyeman, Prince
` (6 subsequent siblings)
11 siblings, 3 replies; 45+ messages in thread
From: Agyeman, Prince @ 2019-12-14 1:32 UTC (permalink / raw)
To: devel; +Cc: Michael Kubacki, Chasel Chiu, Nate DeSimone
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
Added BDS hook points to the Minplatform boot manager library
as defined in the Minimum Platfrom specifcations.
Changes made:
* Added functions to signal three BDS event groups.
These event groups are BeforeConsoleAfterTrustedConsole,
BeforeConsoleBeforeEndOfDxe and AfterConsoleReadyBeforeBootOption.
* Removed BDS functionalities from the boot manager library.
These functionalities will be added to callbacks a module in BoardModule,
which will then register/hook to the BDS hook points
See https://edk2-docs.gitbooks.io/edk-ii-minimum-platform-specification,
under Appendix A.3 BDS Hook Points, for more details.
Cc: Michael Kubacki <michael.a.kubacki@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
---
.../DxePlatformBootManagerLib/BdsPlatform.c | 1262 ++---------------
.../DxePlatformBootManagerLib/BdsPlatform.h | 181 +--
.../DxePlatformBootManagerLib.inf | 51 +-
.../DxePlatformBootManagerLib/MemoryTest.c | 83 --
.../PlatformBootOption.c | 559 --------
5 files changed, 112 insertions(+), 2024 deletions(-)
delete mode 100644 Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/MemoryTest.c
delete mode 100644 Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/PlatformBootOption.c
diff --git a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c
index 491fb0f26f..31a9ef4a07 100644
--- a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c
+++ b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c
@@ -1,130 +1,14 @@
/** @file
This file include all platform action which can be customized by IBV/OEM.
-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include "BdsPlatform.h"
-#include <Guid/EventGroup.h>
-#include <Protocol/DxeSmmReadyToLock.h>
-#include <Protocol/FirmwareVolume2.h>
-#include <Protocol/PciRootBridgeIo.h>
-#include <Protocol/BlockIo.h>
-#include <Protocol/PciIo.h>
-#include <Library/IoLib.h>
-#include <Library/PciLib.h>
-#include <Guid/EventGroup.h>
-
-#include <Library/Tcg2PhysicalPresenceLib.h>
-
-#include <Library/HobLib.h>
-#include <Protocol/UsbIo.h>
-
-#include <Library/UefiBootManagerLib.h>
-
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_BOOT_MODE gBootMode;
-
-BOOLEAN gPPRequireUIConfirm;
-
-extern UINTN mBootMenuOptionNumber;
-
-GLOBAL_REMOVE_IF_UNREFERENCED USB_CLASS_FORMAT_DEVICE_PATH gUsbClassKeyboardDevicePath = {
- {
- {
- MESSAGING_DEVICE_PATH,
- MSG_USB_CLASS_DP,
- {
- (UINT8) (sizeof (USB_CLASS_DEVICE_PATH)),
- (UINT8) ((sizeof (USB_CLASS_DEVICE_PATH)) >> 8)
- }
- },
- 0xffff, // VendorId
- 0xffff, // ProductId
- CLASS_HID, // DeviceClass
- SUBCLASS_BOOT, // DeviceSubClass
- PROTOCOL_KEYBOARD // DeviceProtocol
- },
- gEndEntire
-};
-
-//
-// Internal shell mode
-//
-GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mShellModeColumn;
-GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mShellModeRow;
-GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mShellHorizontalResolution;
-GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mShellVerticalResolution;
-//
-// BDS Platform Functions
-//
-
-BOOLEAN
-IsMorBitSet (
- VOID
- )
-{
- UINTN MorControl;
- EFI_STATUS Status;
- UINTN DataSize;
-
- //
- // Check if the MOR bit is set.
- //
- DataSize = sizeof (MorControl);
- Status = gRT->GetVariable (
- MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME,
- &gEfiMemoryOverwriteControlDataGuid,
- NULL,
- &DataSize,
- &MorControl
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_INFO, " PlatformBootMangerLib: gEfiMemoryOverwriteControlDataGuid doesn't exist!!***\n"));
- MorControl = 0;
- } else {
- DEBUG ((DEBUG_INFO, " PlatformBootMangerLib: Get the gEfiMemoryOverwriteControlDataGuid = %x!!***\n", MorControl));
- }
-
- return (BOOLEAN) (MorControl & 0x01);
-}
-
-VOID
-DumpDevicePath (
- IN CHAR16 *Name,
- IN EFI_DEVICE_PATH *DevicePath
- )
-{
- CHAR16 *Str;
-
- Str = ConvertDevicePathToText(DevicePath, TRUE, TRUE);
- DEBUG ((DEBUG_INFO, "%s: %s\n", Name, Str));
- if (Str != NULL) {
- FreePool (Str);
- }
-}
-
-/**
- An empty function to pass error checking of CreateEventEx ().
-
- This empty function ensures that EVT_NOTIFY_SIGNAL_ALL is error
- checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0.
-
- @param Event Event whose notification function is being invoked.
- @param Context The pointer to the notification function's context,
- which is implementation-dependent.
-**/
-VOID
-EFIAPI
-InternalBdsEmptyCallbackFuntion (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- return;
-}
+extern UINTN mBootMenuOptionNumber;
VOID
ExitPmAuth (
@@ -145,7 +29,7 @@ ExitPmAuth (
Status = gBS->CreateEventEx (
EVT_NOTIFY_SIGNAL,
TPL_CALLBACK,
- InternalBdsEmptyCallbackFuntion,
+ EfiEventEmptyFunction,
NULL,
&gEfiEndOfDxeEventGroupGuid,
&EndOfDxeEvent
@@ -172,918 +56,134 @@ ExitPmAuth (
DEBUG((DEBUG_INFO,"ExitPmAuth ()- End\n"));
}
-VOID
-ConnectRootBridge (
- BOOLEAN Recursive
- )
-{
- UINTN RootBridgeHandleCount;
- EFI_HANDLE *RootBridgeHandleBuffer;
- UINTN RootBridgeIndex;
-
- RootBridgeHandleCount = 0;
- gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiPciRootBridgeIoProtocolGuid,
- NULL,
- &RootBridgeHandleCount,
- &RootBridgeHandleBuffer
- );
- for (RootBridgeIndex = 0; RootBridgeIndex < RootBridgeHandleCount; RootBridgeIndex++) {
- gBS->ConnectController (RootBridgeHandleBuffer[RootBridgeIndex], NULL, NULL, Recursive);
- }
-}
-
/**
- Return whether the device is trusted console.
-
- @param Device The device to be tested.
-
- @retval TRUE The device can be trusted.
- @retval FALSE The device cannot be trusted.
-**/
-BOOLEAN
-IsTrustedConsole (
- IN CONSOLE_TYPE ConsoleType,
- IN EFI_DEVICE_PATH_PROTOCOL *Device
- )
-{
- VOID *TrustedConsoleDevicepath;
- EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
- EFI_DEVICE_PATH_PROTOCOL *Instance;
- UINTN Size;
- EFI_DEVICE_PATH_PROTOCOL *ConsoleDevice;
-
- if (Device == NULL) {
- return FALSE;
- }
-
- ConsoleDevice = DuplicateDevicePath(Device);
-
- TrustedConsoleDevicepath = NULL;
-
- switch (ConsoleType) {
- case ConIn:
- TrustedConsoleDevicepath = PcdGetPtr (PcdTrustedConsoleInputDevicePath);
- break;
- case ConOut:
- //
- // Check GOP and remove last node
- //
- TempDevicePath = ConsoleDevice;
- while (!IsDevicePathEndType (TempDevicePath)) {
- if (DevicePathType (TempDevicePath) == ACPI_DEVICE_PATH &&
- DevicePathSubType (TempDevicePath) == ACPI_ADR_DP) {
- SetDevicePathEndNode (TempDevicePath);
- break;
- }
- TempDevicePath = NextDevicePathNode (TempDevicePath);
- }
-
- TrustedConsoleDevicepath = PcdGetPtr (PcdTrustedConsoleOutputDevicePath);
- break;
- default:
- ASSERT(FALSE);
- break;
- }
-
- TempDevicePath = TrustedConsoleDevicepath;
- do {
- Instance = GetNextDevicePathInstance (&TempDevicePath, &Size);
- if (Instance == NULL) {
- break;
- }
-
- if (CompareMem (ConsoleDevice, Instance, Size - END_DEVICE_PATH_LENGTH) == 0) {
- FreePool (Instance);
- FreePool (ConsoleDevice);
- return TRUE;
- }
-
- FreePool (Instance);
- } while (TempDevicePath != NULL);
-
- FreePool (ConsoleDevice);
+ Creates an EFI event in the BDS Event Group.
- return FALSE;
-}
-
-BOOLEAN
-IsUsbShortForm (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&
- ((DevicePathSubType (DevicePath) == MSG_USB_CLASS_DP) || (DevicePathSubType (DevicePath) == MSG_USB_WWID_DP)) ) {
- return TRUE;
- }
+ @param NotifyTpl The task priority level of the event.
+ @param gEfiEventGuid The GUID of the event group to signal.
+ @param BdsConsoleEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
- return FALSE;
-}
-
-/**
- Connect the USB short form device path.
+ @retval EFI_SUCCESS Event was created.
+ @retval Other Event was not created.
- @param DevicePath USB short form device path
-
- @retval EFI_SUCCESS Successfully connected the USB device
- @retval EFI_NOT_FOUND Cannot connect the USB device
- @retval EFI_INVALID_PARAMETER The device path is invalid.
**/
EFI_STATUS
-ConnectUsbShortFormDevicePath (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+EFIAPI
+CreateBdsEvent (
+ IN EFI_TPL NotifyTpl,
+ IN EFI_GUID *gEfiEventGuid,
+ OUT EFI_EVENT *BdsConsoleEvent
)
{
- EFI_STATUS Status;
- EFI_HANDLE *Handles;
- UINTN HandleCount;
- UINTN Index;
- EFI_PCI_IO_PROTOCOL *PciIo;
- UINT8 Class[3];
- BOOLEAN AtLeastOneConnected;
+ EFI_STATUS Status;
- //
- // Check the passed in parameters
- //
- if (DevicePath == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (!IsUsbShortForm (DevicePath)) {
- return EFI_INVALID_PARAMETER;
- }
+ ASSERT (BdsConsoleEvent != NULL);
- //
- // Find the usb host controller firstly, then connect with the remaining device path
- //
- AtLeastOneConnected = FALSE;
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiPciIoProtocolGuid,
+ Status = gBS->CreateEventEx (
+ EVT_NOTIFY_SIGNAL,
+ NotifyTpl,
+ EfiEventEmptyFunction,
NULL,
- &HandleCount,
- &Handles
- );
- for (Index = 0; Index < HandleCount; Index++) {
- Status = gBS->HandleProtocol (
- Handles[Index],
- &gEfiPciIoProtocolGuid,
- (VOID **) &PciIo
- );
- if (!EFI_ERROR (Status)) {
- //
- // Check whether the Pci device is the wanted usb host controller
- //
- Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0x09, 3, &Class);
- if (!EFI_ERROR (Status) &&
- ((PCI_CLASS_SERIAL == Class[2]) && (PCI_CLASS_SERIAL_USB == Class[1]))
- ) {
- Status = gBS->ConnectController (
- Handles[Index],
- NULL,
- DevicePath,
- FALSE
- );
- if (!EFI_ERROR(Status)) {
- AtLeastOneConnected = TRUE;
- }
- }
- }
- }
-
- return AtLeastOneConnected ? EFI_SUCCESS : EFI_NOT_FOUND;
-}
-
-/**
- Update the ConIn variable with USB Keyboard device path,if its not already exists in ConIn
-**/
-VOID
-EnumUsbKeyboard (
- VOID
- )
-{
- DEBUG ((DEBUG_INFO, "[EnumUsbKeyboard]\n"));
- EfiBootManagerUpdateConsoleVariable (ConIn, (EFI_DEVICE_PATH_PROTOCOL *) &gUsbClassKeyboardDevicePath, NULL);
-
- //
- // Append Usb Keyboard short form DevicePath into "ConInDev"
- //
- EfiBootManagerUpdateConsoleVariable (ConInDev, (EFI_DEVICE_PATH_PROTOCOL *) &gUsbClassKeyboardDevicePath, NULL);
-}
-
-BOOLEAN
-IsVgaHandle (
- IN EFI_HANDLE Handle
- )
-{
- EFI_PCI_IO_PROTOCOL *PciIo;
- PCI_TYPE00 Pci;
- EFI_STATUS Status;
-
- Status = gBS->HandleProtocol (
- Handle,
- &gEfiPciIoProtocolGuid,
- (VOID **)&PciIo
- );
- if (!EFI_ERROR (Status)) {
- Status = PciIo->Pci.Read (
- PciIo,
- EfiPciIoWidthUint32,
- 0,
- sizeof (Pci) / sizeof (UINT32),
- &Pci
- );
- if (!EFI_ERROR (Status)) {
- if (IS_PCI_VGA (&Pci) || IS_PCI_OLD_VGA (&Pci)) {
- return TRUE;
- }
- }
- }
- return FALSE;
-}
-
-EFI_HANDLE
-IsVideoController (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- EFI_DEVICE_PATH_PROTOCOL *DupDevicePath;
- EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
- EFI_STATUS Status;
- EFI_HANDLE DeviceHandle;
-
- DupDevicePath = DuplicateDevicePath (DevicePath);
- ASSERT (DupDevicePath != NULL);
- if (DupDevicePath == NULL) {
- return NULL;
- }
-
- TempDevicePath = DupDevicePath;
- Status = gBS->LocateDevicePath (
- &gEfiDevicePathProtocolGuid,
- &TempDevicePath,
- &DeviceHandle
+ gEfiEventGuid,
+ BdsConsoleEvent
);
- FreePool (DupDevicePath);
- if (EFI_ERROR (Status)) {
- return NULL;
- }
-
- if (IsVgaHandle (DeviceHandle)) {
- return DeviceHandle;
- } else {
- return NULL;
- }
-}
-
-BOOLEAN
-IsGopDevicePath (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- while (!IsDevicePathEndType (DevicePath)) {
- if (DevicePathType (DevicePath) == ACPI_DEVICE_PATH &&
- DevicePathSubType (DevicePath) == ACPI_ADR_DP) {
- return TRUE;
- }
- DevicePath = NextDevicePathNode (DevicePath);
- }
- return FALSE;
-}
-
-/**
- Remove all GOP device path instance from DevicePath and add the Gop to the DevicePath.
-**/
-EFI_DEVICE_PATH_PROTOCOL *
-UpdateGopDevicePath (
- EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- EFI_DEVICE_PATH_PROTOCOL *Gop
- )
-{
- UINTN Size;
- UINTN GopSize;
- EFI_DEVICE_PATH_PROTOCOL *Temp;
- EFI_DEVICE_PATH_PROTOCOL *Return;
- EFI_DEVICE_PATH_PROTOCOL *Instance;
- BOOLEAN Exist;
-
- Exist = FALSE;
- Return = NULL;
- GopSize = GetDevicePathSize (Gop);
- do {
- Instance = GetNextDevicePathInstance (&DevicePath, &Size);
- if (Instance == NULL) {
- break;
- }
- if (!IsGopDevicePath (Instance) ||
- (Size == GopSize && CompareMem (Instance, Gop, GopSize) == 0)
- ) {
- if (Size == GopSize && CompareMem (Instance, Gop, GopSize) == 0) {
- Exist = TRUE;
- }
- Temp = Return;
- Return = AppendDevicePathInstance (Return, Instance);
- if (Temp != NULL) {
- FreePool (Temp);
- }
- }
- FreePool (Instance);
- } while (DevicePath != NULL);
- if (!Exist) {
- Temp = Return;
- Return = AppendDevicePathInstance (Return, Gop);
- if (Temp != NULL) {
- FreePool (Temp);
- }
- }
- return Return;
+ return Status;
}
/**
- Get Graphics Controller Handle.
-
- @retval GraphicsController Successfully located
- @retval NULL Failed to locate
-**/
-EFI_HANDLE
-EFIAPI
-GetGraphicsController (
- IN BOOLEAN NeedTrustedConsole
- )
-{
- EFI_STATUS Status;
- UINTN Index;
- EFI_HANDLE *PciHandles;
- UINTN PciHandlesSize;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
-
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiPciIoProtocolGuid,
- NULL,
- &PciHandlesSize,
- &PciHandles
- );
- if (EFI_ERROR (Status)) {
- return NULL;
- }
-
- for (Index = 0; Index < PciHandlesSize; Index++) {
- Status = gBS->HandleProtocol (
- PciHandles[Index],
- &gEfiDevicePathProtocolGuid,
- (VOID **) &DevicePath
- );
- if (EFI_ERROR(Status)) {
- continue;
- }
- if (!IsVgaHandle (PciHandles[Index])) {
- continue;
- }
- if ((NeedTrustedConsole && IsTrustedConsole (ConOut, DevicePath)) ||
- ((!NeedTrustedConsole) && (!IsTrustedConsole (ConOut, DevicePath)))) {
- return PciHandles[Index];
- }
- }
-
- return NULL;
-}
-
-VOID
-UpdateGraphicConOut (
- IN BOOLEAN NeedTrustedConsole
- )
-{
- EFI_HANDLE GraphicsControllerHandle;
- EFI_DEVICE_PATH_PROTOCOL *GopDevicePath;
- EFI_DEVICE_PATH_PROTOCOL *ConOutDevicePath;
- EFI_DEVICE_PATH_PROTOCOL *UpdatedConOutDevicePath;
+ Create, Signal, and Close the Bds Event Before Console After
+ Trusted Console event using CreateBdsEvent().
- //
- // Update ConOut variable
- //
- GraphicsControllerHandle = GetGraphicsController (NeedTrustedConsole);
- if (GraphicsControllerHandle != NULL) {
- //
- // Connect the GOP driver
- //
- gBS->ConnectController (GraphicsControllerHandle, NULL, NULL, TRUE);
-
- //
- // Get the GOP device path
- // NOTE: We may get a device path that contains Controller node in it.
- //
- GopDevicePath = EfiBootManagerGetGopDevicePath (GraphicsControllerHandle);
- if (GopDevicePath != NULL) {
- GetEfiGlobalVariable2 (L"ConOut", (VOID **)&ConOutDevicePath, NULL);
- UpdatedConOutDevicePath = UpdateGopDevicePath (ConOutDevicePath, GopDevicePath);
- if (ConOutDevicePath != NULL) {
- FreePool (ConOutDevicePath);
- }
- FreePool (GopDevicePath);
- gRT->SetVariable (
- L"ConOut",
- &gEfiGlobalVariableGuid,
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS,
- GetDevicePathSize (UpdatedConOutDevicePath),
- UpdatedConOutDevicePath
- );
- }
- }
-}
-
-VOID
-AddConsoleVariable (
- IN CONSOLE_TYPE ConsoleType,
- IN EFI_DEVICE_PATH *ConsoleDevicePath
- )
-{
- EFI_DEVICE_PATH *TempDevicePath;
- EFI_DEVICE_PATH *Instance;
- UINTN Size;
- EFI_HANDLE GraphicsControllerHandle;
- EFI_DEVICE_PATH *GopDevicePath;
-
- TempDevicePath = ConsoleDevicePath;
- do {
- Instance = GetNextDevicePathInstance (&TempDevicePath, &Size);
- if (Instance == NULL) {
- break;
- }
-
- switch (ConsoleType) {
- case ConIn:
- if (IsUsbShortForm (Instance)) {
- //
- // Append Usb Keyboard short form DevicePath into "ConInDev"
- //
- EfiBootManagerUpdateConsoleVariable (ConInDev, Instance, NULL);
- }
- EfiBootManagerUpdateConsoleVariable (ConsoleType, Instance, NULL);
- break;
- case ConOut:
- GraphicsControllerHandle = IsVideoController (Instance);
- if (GraphicsControllerHandle == NULL) {
- EfiBootManagerUpdateConsoleVariable (ConsoleType, Instance, NULL);
- } else {
- //
- // Connect the GOP driver
- //
- gBS->ConnectController (GraphicsControllerHandle, NULL, NULL, TRUE);
- //
- // Get the GOP device path
- // NOTE: We may get a device path that contains Controller node in it.
- //
- GopDevicePath = EfiBootManagerGetGopDevicePath (GraphicsControllerHandle);
- if (GopDevicePath != NULL) {
- EfiBootManagerUpdateConsoleVariable (ConsoleType, GopDevicePath, NULL);
- }
- }
- break;
- default:
- ASSERT(FALSE);
- break;
- }
-
- FreePool (Instance);
- } while (TempDevicePath != NULL);
-}
-
-/**
- The function connects the trusted consoles.
**/
VOID
-ConnectTrustedConsole (
+EFIAPI
+BdsSignalEventBeforeConsoleAfterTrustedConsole (
VOID
)
{
- EFI_DEVICE_PATH_PROTOCOL *Consoles;
- EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
- EFI_DEVICE_PATH_PROTOCOL *Instance;
- EFI_DEVICE_PATH_PROTOCOL *Next;
- UINTN Size;
- UINTN Index;
- EFI_HANDLE Handle;
- EFI_STATUS Status;
- CHAR16 *ConsoleVar[] = {L"ConIn", L"ConOut"};
- VOID *TrustedConsoleDevicepath;
+ EFI_STATUS Status;
+ EFI_EVENT BdsConsoleEvent;
- TrustedConsoleDevicepath = PcdGetPtr (PcdTrustedConsoleInputDevicePath);
- DumpDevicePath (L"TrustedConsoleIn", TrustedConsoleDevicepath);
- TrustedConsoleDevicepath = PcdGetPtr (PcdTrustedConsoleOutputDevicePath);
- DumpDevicePath (L"TrustedConsoleOut", TrustedConsoleDevicepath);
+ DEBUG ((DEBUG_INFO, "%a \n", __FUNCTION__));
- for (Index = 0; Index < sizeof (ConsoleVar) / sizeof (ConsoleVar[0]); Index++) {
-
- GetEfiGlobalVariable2 (ConsoleVar[Index], (VOID **)&Consoles, NULL);
+ Status = CreateBdsEvent (
+ TPL_CALLBACK,
+ &gBdsEventBeforeConsoleAfterTrustedConsoleGuid,
+ &BdsConsoleEvent
+ );
- TempDevicePath = Consoles;
- do {
- Instance = GetNextDevicePathInstance (&TempDevicePath, &Size);
- if (Instance == NULL) {
- break;
- }
- if (IsTrustedConsole (Index, Instance)) {
- if (IsUsbShortForm (Instance)) {
- ConnectUsbShortFormDevicePath (Instance);
- } else {
- for (Next = Instance; !IsDevicePathEnd (Next); Next = NextDevicePathNode (Next)) {
- if (DevicePathType (Next) == ACPI_DEVICE_PATH && DevicePathSubType (Next) == ACPI_ADR_DP) {
- break;
- } else if (DevicePathType (Next) == HARDWARE_DEVICE_PATH &&
- DevicePathSubType (Next) == HW_CONTROLLER_DP &&
- DevicePathType (NextDevicePathNode (Next)) == ACPI_DEVICE_PATH &&
- DevicePathSubType (NextDevicePathNode (Next)) == ACPI_ADR_DP
- ) {
- break;
- }
- }
- if (!IsDevicePathEnd (Next)) {
- SetDevicePathEndNode (Next);
- Status = EfiBootManagerConnectDevicePath (Instance, &Handle);
- if (!EFI_ERROR (Status)) {
- gBS->ConnectController (Handle, NULL, NULL, TRUE);
- }
- } else {
- EfiBootManagerConnectDevicePath (Instance, NULL);
- }
- }
- }
- FreePool (Instance);
- } while (TempDevicePath != NULL);
+ ASSERT_EFI_ERROR (Status);
- if (Consoles != NULL) {
- FreePool (Consoles);
- }
+ if (!EFI_ERROR (Status)) {
+ gBS->SignalEvent (BdsConsoleEvent);
+ gBS->CloseEvent (BdsConsoleEvent);
+ DEBUG ((DEBUG_INFO,"All EventBeforeConsoleAfterTrustedConsole callbacks have returned successfully\n"));
}
}
-/**
- The function connects the trusted Storages.
-**/
-VOID
-ConnectTrustedStorage (
- VOID
- )
-{
- VOID *TrustedStorageDevicepath;
- EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
- EFI_DEVICE_PATH_PROTOCOL *Instance;
- UINTN Size;
- EFI_DEVICE_PATH_PROTOCOL *TempStorageDevicePath;
- EFI_STATUS Status;
- EFI_HANDLE DeviceHandle;
-
- TrustedStorageDevicepath = PcdGetPtr (PcdTrustedStorageDevicePath);
- DumpDevicePath (L"TrustedStorage", TrustedStorageDevicepath);
-
- TempDevicePath = TrustedStorageDevicepath;
- do {
- Instance = GetNextDevicePathInstance (&TempDevicePath, &Size);
- if (Instance == NULL) {
- break;
- }
-
- EfiBootManagerConnectDevicePath (Instance, NULL);
-
- TempStorageDevicePath = Instance;
-
- Status = gBS->LocateDevicePath (
- &gEfiDevicePathProtocolGuid,
- &TempStorageDevicePath,
- &DeviceHandle
- );
- if (!EFI_ERROR (Status)) {
- gBS->ConnectController (DeviceHandle, NULL, NULL, FALSE);
- }
-
- FreePool (Instance);
- } while (TempDevicePath != NULL);
-}
-
-/**
- The function connects the trusted consoles and then call the PP processing library interface.
-**/
-VOID
-ProcessTcgPp (
- VOID
- )
-{
- gPPRequireUIConfirm |= Tcg2PhysicalPresenceLibNeedUserConfirm();
-
- if (gPPRequireUIConfirm) {
- ConnectTrustedConsole ();
- }
-
- Tcg2PhysicalPresenceLibProcessRequest (NULL);
-}
/**
- The function connects the trusted storage to perform TPerReset.
+ Create, Signal, and Close the Bds Before Console Before End Of Dxe
+ event using CreateBdsEvent().
**/
VOID
-ProcessTcgMor (
- VOID
- )
-{
- if (IsMorBitSet ()) {
- ConnectTrustedConsole();
- ConnectTrustedStorage();
- }
-}
-
-/**
- Check if current BootCurrent variable is internal shell boot option.
-
- @retval TRUE BootCurrent is internal shell.
- @retval FALSE BootCurrent is not internal shell.
-**/
-BOOLEAN
-BootCurrentIsInternalShell (
+EFIAPI
+BdsSignalEventBeforeConsoleBeforeEndOfDxe (
VOID
)
{
- UINTN VarSize;
- UINT16 BootCurrent;
- CHAR16 BootOptionName[16];
- UINT8 *BootOption;
- UINT8 *Ptr;
- BOOLEAN Result;
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
- EFI_DEVICE_PATH_PROTOCOL *LastDeviceNode;
- EFI_GUID *GuidPoint;
-
- BootOption = NULL;
- Result = FALSE;
-
- //
- // Get BootCurrent variable
- //
- VarSize = sizeof (UINT16);
- Status = gRT->GetVariable (
- L"BootCurrent",
- &gEfiGlobalVariableGuid,
- NULL,
- &VarSize,
- &BootCurrent
- );
- if (EFI_ERROR (Status)) {
- return FALSE;
- }
+ EFI_STATUS Status;
+ EFI_EVENT BdsConsoleEvent;
- //
- // Create boot option Bootxxxx from BootCurrent
- //
- UnicodeSPrint (BootOptionName, sizeof(BootOptionName), L"Boot%04X", BootCurrent);
+ DEBUG ((DEBUG_INFO, "%a \n", __FUNCTION__));
- GetEfiGlobalVariable2 (BootOptionName, (VOID **) &BootOption, &VarSize);
- if (BootOption == NULL || VarSize == 0) {
- return FALSE;
- }
+ Status = CreateBdsEvent (
+ TPL_CALLBACK,
+ &gBdsEventBeforeConsoleBeforeEndOfDxeGuid,
+ &BdsConsoleEvent
+ );
- Ptr = BootOption;
- Ptr += sizeof (UINT32);
- Ptr += sizeof (UINT16);
- Ptr += StrSize ((CHAR16 *) Ptr);
- TempDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) Ptr;
- LastDeviceNode = TempDevicePath;
- while (!IsDevicePathEnd (TempDevicePath)) {
- LastDeviceNode = TempDevicePath;
- TempDevicePath = NextDevicePathNode (TempDevicePath);
- }
- GuidPoint = EfiGetNameGuidFromFwVolDevicePathNode (
- (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) LastDeviceNode
- );
- if ((GuidPoint != NULL) &&
- ((CompareGuid (GuidPoint, &gUefiShellFileGuid)))
- ) {
- //
- // if this option is internal shell, return TRUE
- //
- Result = TRUE;
- }
+ ASSERT_EFI_ERROR (Status);
- if (BootOption != NULL) {
- FreePool (BootOption);
- BootOption = NULL;
+ if (!EFI_ERROR (Status)) {
+ gBS->SignalEvent (BdsConsoleEvent);
+ gBS->CloseEvent (BdsConsoleEvent);
+ DEBUG ((DEBUG_INFO,"All BeforeConsoleBeforeEndOfDxe callbacks have returned successfully\n"));
}
-
- return Result;
}
/**
- This function will change video resolution and text mode
- for internl shell when internal shell is launched.
-
- @param None.
-
- @retval EFI_SUCCESS Mode is changed successfully.
- @retval Others Mode failed to changed.
+ Create, Signal, and Close the Bds After Console Ready Before Boot Option
+ using CreateBdsEvent().
**/
-EFI_STATUS
+VOID
EFIAPI
-ChangeModeForInternalShell (
+BdsSignalEventAfterConsoleReadyBeforeBootOption (
VOID
)
{
- EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
- EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;
- UINTN SizeOfInfo;
- EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
- UINT32 MaxGopMode;
- UINT32 MaxTextMode;
- UINT32 ModeNumber;
- UINTN HandleCount;
- EFI_HANDLE *HandleBuffer;
- EFI_STATUS Status;
- UINTN Index;
- UINTN CurrentColumn;
- UINTN CurrentRow;
-
- Status = gBS->HandleProtocol (
- gST->ConsoleOutHandle,
- &gEfiGraphicsOutputProtocolGuid,
- (VOID**)&GraphicsOutput
- );
- if (EFI_ERROR (Status)) {
- GraphicsOutput = NULL;
- }
-
- Status = gBS->HandleProtocol (
- gST->ConsoleOutHandle,
- &gEfiSimpleTextOutProtocolGuid,
- (VOID**)&SimpleTextOut
- );
- if (EFI_ERROR (Status)) {
- SimpleTextOut = NULL;
- }
+ EFI_STATUS Status;
+ EFI_EVENT BdsConsoleEvent;
- if ((GraphicsOutput == NULL) || (SimpleTextOut == NULL)) {
- return EFI_UNSUPPORTED;
- }
-
- MaxGopMode = GraphicsOutput->Mode->MaxMode;
- MaxTextMode = SimpleTextOut->Mode->MaxMode;
-
- //
- // 1. If current video resolution is same with new video resolution,
- // video resolution need not be changed.
- // 1.1. If current text mode is same with new text mode, text mode need not be change.
- // 1.2. If current text mode is different with new text mode, text mode need be change to new text mode.
- // 2. If current video resolution is different with new video resolution, we need restart whole console drivers.
- //
- for (ModeNumber = 0; ModeNumber < MaxGopMode; ModeNumber++) {
- Status = GraphicsOutput->QueryMode (
- GraphicsOutput,
- ModeNumber,
- &SizeOfInfo,
- &Info
- );
- if (!EFI_ERROR (Status)) {
- if ((Info->HorizontalResolution == mShellHorizontalResolution) &&
- (Info->VerticalResolution == mShellVerticalResolution)) {
- if ((GraphicsOutput->Mode->Info->HorizontalResolution == mShellHorizontalResolution) &&
- (GraphicsOutput->Mode->Info->VerticalResolution == mShellVerticalResolution)) {
- //
- // If current video resolution is same with new resolution,
- // then check if current text mode is same with new text mode.
- //
- Status = SimpleTextOut->QueryMode (SimpleTextOut, SimpleTextOut->Mode->Mode, &CurrentColumn, &CurrentRow);
- ASSERT_EFI_ERROR (Status);
- if (CurrentColumn == mShellModeColumn && CurrentRow == mShellModeRow) {
- //
- // Current text mode is same with new text mode, text mode need not be change.
- //
- FreePool (Info);
- return EFI_SUCCESS;
- } else {
- //
- // Current text mode is different with new text mode, text mode need be change to new text mode.
- //
- for (Index = 0; Index < MaxTextMode; Index++) {
- Status = SimpleTextOut->QueryMode (SimpleTextOut, Index, &CurrentColumn, &CurrentRow);
- if (!EFI_ERROR(Status)) {
- if ((CurrentColumn == mShellModeColumn) && (CurrentRow == mShellModeRow)) {
- //
- // New text mode is supported, set it.
- //
- Status = SimpleTextOut->SetMode (SimpleTextOut, Index);
- ASSERT_EFI_ERROR (Status);
- //
- // Update text mode PCD.
- //
- Status = PcdSet32S (PcdConOutColumn, mShellModeColumn);
- ASSERT_EFI_ERROR (Status);
+ DEBUG ((DEBUG_INFO, "%a \n", __FUNCTION__));
- Status = PcdSet32S (PcdConOutRow, mShellModeRow);
- ASSERT_EFI_ERROR (Status);
-
- FreePool (Info);
- return EFI_SUCCESS;
- }
- }
- }
- if (Index == MaxTextMode) {
- //
- // If new text mode is not supported, return error.
- //
- FreePool (Info);
- return EFI_UNSUPPORTED;
- }
- }
- } else {
- FreePool (Info);
- //
- // If current video resolution is not same with the new one, set new video resolution.
- // In this case, the driver which produces simple text out need be restarted.
- //
- Status = GraphicsOutput->SetMode (GraphicsOutput, ModeNumber);
- if (!EFI_ERROR (Status)) {
- //
- // Set PCD to restart GraphicsConsole and Consplitter to change video resolution
- // and produce new text mode based on new resolution.
- //
- Status = PcdSet32S (PcdVideoHorizontalResolution, mShellHorizontalResolution);
- ASSERT_EFI_ERROR (Status);
-
- Status = PcdSet32S (PcdVideoVerticalResolution, mShellVerticalResolution);
- ASSERT_EFI_ERROR (Status);
-
- Status = PcdSet32S (PcdConOutColumn, mShellModeColumn);
- ASSERT_EFI_ERROR (Status);
-
- Status = PcdSet32S (PcdConOutRow, mShellModeRow);
- ASSERT_EFI_ERROR (Status);
+ Status = CreateBdsEvent (
+ TPL_CALLBACK,
+ &gBdsEventAfterConsoleReadyBeforeBootOptionGuid,
+ &BdsConsoleEvent
+ );
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiSimpleTextOutProtocolGuid,
- NULL,
- &HandleCount,
- &HandleBuffer
- );
- if (!EFI_ERROR (Status)) {
- for (Index = 0; Index < HandleCount; Index++) {
- gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);
- }
- for (Index = 0; Index < HandleCount; Index++) {
- gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
- }
- if (HandleBuffer != NULL) {
- FreePool (HandleBuffer);
- }
- break;
- }
- }
- }
- }
- FreePool (Info);
- }
- }
+ ASSERT_EFI_ERROR (Status);
- if (ModeNumber == MaxGopMode) {
- //
- // If the new resolution is not supported, return error.
- //
- return EFI_UNSUPPORTED;
+ if (!EFI_ERROR (Status)) {
+ gBS->SignalEvent (BdsConsoleEvent);
+ gBS->CloseEvent (BdsConsoleEvent);
+ DEBUG ((DEBUG_INFO,"All AfterConsoleReadyBeforeBootOption callbacks have returned successfully\n"));
}
-
- return EFI_SUCCESS;
}
-/**
- ReadyToBoot callback to set video and text mode for internal shell boot.
- That will not connect USB controller while CSM and FastBoot are disabled, we need to connect them
- before booting to Shell for showing USB devices in Shell.
-
- When FastBoot is enabled and Windows Console is the chosen Console behavior, input devices will not be connected
- by default. Hence, when booting to EFI shell, connecting input consoles are required.
-
- @param Event Pointer to this event
- @param Context Event hanlder private data
-
- @retval None.
-**/
-VOID
-EFIAPI
-OnReadyToBootCallBack (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- DEBUG ((EFI_D_INFO, "OnReadyToBootCallBack\n"));
-
- if (BootCurrentIsInternalShell ()) {
-
- ChangeModeForInternalShell ();
- EfiBootManagerConnectAllDefaultConsoles();
- gDS->Dispatch ();
- }
-}
/**
Platform Bds init. Incude the platform firmware vendor, revision
@@ -1095,149 +195,37 @@ PlatformBootManagerBeforeConsole (
VOID
)
{
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *VarConOut;
- EFI_DEVICE_PATH_PROTOCOL *VarConIn;
- EFI_EVENT Event;
DEBUG ((EFI_D_INFO, "PlatformBootManagerBeforeConsole\n"));
- Status = EFI_SUCCESS;
-
- //
- // Get user defined text mode for internal shell only once.
- //
- mShellHorizontalResolution = PcdGet32 (PcdSetupVideoHorizontalResolution);
- mShellVerticalResolution = PcdGet32 (PcdSetupVideoVerticalResolution);
- mShellModeColumn = PcdGet32 (PcdSetupConOutColumn);
- mShellModeRow = PcdGet32 (PcdSetupConOutRow);
-
- //
- // Create event to set proper video resolution and text mode for internal shell.
- //
- Status = EfiCreateEventReadyToBootEx (
- TPL_CALLBACK,
- OnReadyToBootCallBack,
- NULL,
- &Event
- );
- ASSERT_EFI_ERROR (Status);
-
- //
- // Connect Root Bridge to make PCI BAR resource allocated and all PciIo created
- //
- ConnectRootBridge (FALSE);
-
//
- // Fill ConIn/ConOut in Full Configuration boot mode
+ // Trusted console can be added in a PciEnumComplete callback
//
- DEBUG ((DEBUG_INFO, "PlatformBootManagerInit - %x\n", gBootMode));
-
- if (gBootMode == BOOT_WITH_FULL_CONFIGURATION ||
- gBootMode == BOOT_WITH_DEFAULT_SETTINGS ||
- gBootMode == BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS ||
- gBootMode == BOOT_IN_RECOVERY_MODE) {
-
- GetEfiGlobalVariable2 (L"ConOut", (VOID **)&VarConOut, NULL); if (VarConOut != NULL) { FreePool (VarConOut); }
- GetEfiGlobalVariable2 (L"ConIn", (VOID **)&VarConIn, NULL); if (VarConIn != NULL) { FreePool (VarConIn); }
-
- //
- // Only fill ConIn/ConOut when ConIn/ConOut is empty because we may drop to Full Configuration boot mode in non-first boot
- //
- if (VarConOut == NULL || VarConIn == NULL) {
- if (PcdGetSize (PcdTrustedConsoleOutputDevicePath) >= sizeof(EFI_DEVICE_PATH_PROTOCOL)) {
- AddConsoleVariable (ConOut, PcdGetPtr (PcdTrustedConsoleOutputDevicePath));
- }
- if (PcdGetSize (PcdTrustedConsoleInputDevicePath) >= sizeof(EFI_DEVICE_PATH_PROTOCOL)) {
- AddConsoleVariable (ConIn, PcdGetPtr (PcdTrustedConsoleInputDevicePath));
- }
- }
- }
- EnumUsbKeyboard ();
//
- // For trusted console it must be handled here.
+ // Signal Before Console, after Trusted console Event
//
- UpdateGraphicConOut (TRUE);
+ BdsSignalEventBeforeConsoleAfterTrustedConsole ();
//
- // Dynamically register hot key: F2/F7/Enter
+ // Signal Before Console, before End of Dxe
//
- RegisterDefaultBootOption ();
- RegisterStaticHotkey ();
-
- PERF_START_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7010);
- if (PcdGetBool (PcdTpm2Enable)) {
- ProcessTcgPp ();
- ProcessTcgMor ();
- }
- PERF_END_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7011);
+ BdsSignalEventBeforeConsoleBeforeEndOfDxe ();
//
- // We should make all UEFI memory and GCD information populated before ExitPmAuth.
- // SMM may consume these information.
+ // Signal End Of Dxe Event
//
- MemoryTest((EXTENDMEM_COVERAGE_LEVEL) PcdGet32 (PcdPlatformMemoryCheckLevel));
-
PERF_START_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7020);
ExitPmAuth ();
PERF_END_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7021);
//
- // Dispatch the deferred 3rd party images.
- //
- EfiBootManagerDispatchDeferredImages ();
-
- //
- // For non-trusted console it must be handled here.
+ // Deferred 3rd party images can be dispatched in
+ // an SmmReadyToLock callback
//
- UpdateGraphicConOut (FALSE);
}
-/**
- Connect with predeined platform connect sequence,
- the OEM/IBV can customize with their own connect sequence.
-
- @param[in] BootMode Boot mode of this boot.
-**/
-VOID
-ConnectSequence (
- IN EFI_BOOT_MODE BootMode
- )
-{
- EfiBootManagerConnectAll ();
-}
-
-/**
- The function is to consider the boot order which is not in our expectation.
- In the case that we need to re-sort the boot option.
-
- @retval TRUE Need to sort Boot Option.
- @retval FALSE Don't need to sort Boot Option.
-**/
-BOOLEAN
-IsNeedSortBootOption (
- VOID
- )
-{
- EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
- UINTN BootOptionCount;
-
- BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);
-
- //
- // If setup is the first priority in boot option, we need to sort boot option.
- //
- if ((BootOptionCount > 1) &&
- (((StrnCmp (BootOptions->Description, L"Enter Setup", StrLen (L"Enter Setup"))) == 0) ||
- ((StrnCmp (BootOptions->Description, L"BootManagerMenuApp", StrLen (L"BootManagerMenuApp"))) == 0))) {
- return TRUE;
- }
-
- return FALSE;
-}
-
/**
The function will excute with as the platform policy, current policy
is driven by boot mode. IBV/OEM can customize this code for their specific
@@ -1254,65 +242,9 @@ PlatformBootManagerAfterConsole (
VOID
)
{
- EFI_BOOT_MODE LocalBootMode;
-
DEBUG ((EFI_D_INFO, "PlatformBootManagerAfterConsole\n"));
- //
- // Get current Boot Mode
- //
- LocalBootMode = gBootMode;
- DEBUG ((DEBUG_INFO, "Current local bootmode - %x\n", LocalBootMode));
-
- //
- // Go the different platform policy with different boot mode
- // Notes: this part code can be change with the table policy
- //
- switch (LocalBootMode) {
-
- case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:
- case BOOT_WITH_MINIMAL_CONFIGURATION:
- case BOOT_ON_S4_RESUME:
- //
- // Perform some platform specific connect sequence
- //
- PERF_START_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7050);
- ConnectSequence (LocalBootMode);
- PERF_END_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7051);
-
- break;
-
- case BOOT_WITH_FULL_CONFIGURATION:
- case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:
- case BOOT_WITH_DEFAULT_SETTINGS:
- default:
- //
- // Perform some platform specific connect sequence
- //
- ConnectSequence (LocalBootMode);
-
- //
- // Only in Full Configuration boot mode we do the enumeration of boot device
- //
- //
- // Dispatch all but Storage Oprom explicitly, because we assume Int13Thunk driver is there.
- //
- EfiBootManagerRefreshAllBootOption ();
-
- if (IsNeedSortBootOption()) {
- EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot, CompareBootOption);
- }
- //
- // PXE boot option may appear after boot option enumeration
- //
-
- break;
- }
-
- Print (L"Press F7 for BootMenu!\n");
-
- EfiBootManagerRefreshAllBootOption ();
- EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot, CompareBootOption);
+ BdsSignalEventAfterConsoleReadyBeforeBootOption ();
}
/**
@@ -1328,19 +260,19 @@ PlatformBootManagerUnableToBoot (
VOID
)
{
- EFI_STATUS Status;
- EFI_BOOT_MANAGER_LOAD_OPTION BootDeviceList;
- CHAR16 OptionName[sizeof ("Boot####")];
+ BoardBootManagerUnableToBoot ();
+}
- if (mBootMenuOptionNumber == LoadOptionNumberUnassigned) {
- return;
- }
- UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", mBootMenuOptionNumber);
- Status = EfiBootManagerVariableToLoadOption (OptionName, &BootDeviceList);
- if (EFI_ERROR (Status)) {
- return;
- }
- for (;;) {
- EfiBootManagerBoot (&BootDeviceList);
- }
+/**
+ This function is called each second during the boot manager waits the timeout.
+
+ @param TimeoutRemain The remaining timeout.
+**/
+VOID
+EFIAPI
+PlatformBootManagerWaitCallback (
+ UINT16 TimeoutRemain
+ )
+{
+ BoardBootManagerWaitCallback (TimeoutRemain);
}
diff --git a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.h b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.h
index 360a00d7d7..031676cdc3 100644
--- a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.h
+++ b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.h
@@ -1,7 +1,7 @@
/** @file
Header file for BDS Platform specific code
-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -9,176 +9,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _BDS_PLATFORM_H
#define _BDS_PLATFORM_H
-#include <PiDxe.h>
-#include <Protocol/DevicePath.h>
-#include <Protocol/SimpleNetwork.h>
-#include <Protocol/PciRootBridgeIo.h>
-#include <Protocol/LoadFile.h>
-#include <Protocol/PciIo.h>
-#include <Protocol/CpuIo2.h>
-#include <Protocol/LoadedImage.h>
-#include <Protocol/DiskInfo.h>
-#include <Protocol/GraphicsOutput.h>
-#include <Protocol/UgaDraw.h>
-#include <Protocol/GenericMemoryTest.h>
-#include <Protocol/DevicePathToText.h>
-#include <Protocol/FirmwareVolume2.h>
-#include <Protocol/SimpleFileSystem.h>
-
-#include <Guid/CapsuleVendor.h>
-#include <Guid/MemoryTypeInformation.h>
-#include <Guid/GlobalVariable.h>
-#include <Guid/MemoryOverwriteControl.h>
-#include <Guid/FileInfo.h>
-#include <Library/DebugLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/BaseLib.h>
-#include <Library/PcdLib.h>
-#include <Library/PlatformBootManagerLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/UefiLib.h>
-#include <Library/HobLib.h>
-#include <Library/DxeServicesLib.h>
-#include <Library/DxeServicesTableLib.h>
-#include <Library/PrintLib.h>
-#include <Library/HiiLib.h>
-#include <Library/CapsuleLib.h>
-#include <Library/PerformanceLib.h>
-
-#include <IndustryStandard/Pci30.h>
-#include <IndustryStandard/PciCodeId.h>
-
-///
-/// ConnectType
-///
-#define CONSOLE_OUT 0x00000001
-#define STD_ERROR 0x00000002
-#define CONSOLE_IN 0x00000004
-#define CONSOLE_ALL (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)
-
-extern EFI_GUID gUefiShellFileGuid;
-extern EFI_BOOT_MODE gBootMode;
-
-#define gPciRootBridge \
- { \
- { \
- ACPI_DEVICE_PATH, \
- ACPI_DP, \
- { \
- (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \
- (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \
- }, \
- }, \
- EISA_PNP_ID (0x0A03), \
- 0 \
- }
-
-#define gEndEntire \
- { \
- END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { END_DEVICE_PATH_LENGTH, 0 } \
- }
-
-typedef struct {
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- UINTN ConnectType;
-} BDS_CONSOLE_CONNECT_ENTRY;
-
-//
-// Platform Root Bridge
-//
-typedef struct {
- ACPI_HID_DEVICE_PATH PciRootBridge;
- EFI_DEVICE_PATH_PROTOCOL End;
-} PLATFORM_ROOT_BRIDGE_DEVICE_PATH;
-
-//
-// Below is the platform console device path
-//
-typedef struct {
- ACPI_HID_DEVICE_PATH PciRootBridge;
- PCI_DEVICE_PATH IsaBridge;
- ACPI_HID_DEVICE_PATH Keyboard;
- EFI_DEVICE_PATH_PROTOCOL End;
-} PLATFORM_KEYBOARD_DEVICE_PATH;
-
-typedef struct {
- ACPI_HID_DEVICE_PATH PciRootBridge;
- PCI_DEVICE_PATH PciDevice;
- EFI_DEVICE_PATH_PROTOCOL End;
-} PLATFORM_ONBOARD_CONTROLLER_DEVICE_PATH;
-
-typedef struct {
- ACPI_HID_DEVICE_PATH PciRootBridge;
- PCI_DEVICE_PATH Pci0Device;
- EFI_DEVICE_PATH_PROTOCOL End;
-} PLATFORM_PEG_ROOT_CONTROLLER_DEVICE_PATH;
-
-typedef struct {
- ACPI_HID_DEVICE_PATH PciRootBridge;
- PCI_DEVICE_PATH PciBridge;
- PCI_DEVICE_PATH PciDevice;
- EFI_DEVICE_PATH_PROTOCOL End;
-} PLATFORM_PCI_CONTROLLER_DEVICE_PATH;
-
-//
-// Below is the boot option device path
-//
-
-#define CLASS_HID 3
-#define SUBCLASS_BOOT 1
-#define PROTOCOL_KEYBOARD 1
-
-typedef struct {
- USB_CLASS_DEVICE_PATH UsbClass;
- EFI_DEVICE_PATH_PROTOCOL End;
-} USB_CLASS_FORMAT_DEVICE_PATH;
-
-extern USB_CLASS_FORMAT_DEVICE_PATH gUsbClassKeyboardDevicePath;
-
-//
-// Platform BDS Functions
-//
-
-
-/**
- Perform the memory test base on the memory test intensive level,
- and update the memory resource.
-
- @param Level The memory test intensive level.
-
- @retval EFI_STATUS Success test all the system memory and update
- the memory resource
-
-**/
-EFI_STATUS
-MemoryTest (
- IN EXTENDMEM_COVERAGE_LEVEL Level
- );
-
-VOID
-ConnectSequence (
- IN EFI_BOOT_MODE BootMode
- );
-
-
-INTN
-EFIAPI
-CompareBootOption (
- CONST VOID *Left,
- CONST VOID *Right
- );
-
-
-VOID
-RegisterStaticHotkey (
- VOID
- );
-VOID
-RegisterDefaultBootOption (
- VOID
- );
+ #include <Library/DebugLib.h>
+ #include <Library/UefiBootServicesTableLib.h>
+ #include <Library/PlatformBootManagerLib.h>
+ #include <Library/UefiLib.h>
+ #include <Library/HobLib.h>
+ #include <Library/PrintLib.h>
+ #include <Library/PerformanceLib.h>
+ #include <Library/BoardBootManagerLib.h>
#endif
diff --git a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLib.inf b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLib.inf
index 388ffd808b..4f7299f1df 100644
--- a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLib.inf
+++ b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLib.inf
@@ -23,23 +23,13 @@
[LibraryClasses]
BaseLib
- MemoryAllocationLib
UefiBootServicesTableLib
- UefiRuntimeServicesTableLib
- BaseMemoryLib
DebugLib
- PcdLib
- PrintLib
- DevicePathLib
UefiLib
HobLib
- DxeServicesLib
- DxeServicesTableLib
- HiiLib
UefiBootManagerLib
PerformanceLib
- TimerLib
- Tcg2PhysicalPresenceLib
+ BoardBootManagerLib
[Packages]
MdePkg/MdePkg.dec
@@ -47,47 +37,18 @@
SecurityPkg/SecurityPkg.dec
MinPlatformPkg/MinPlatformPkg.dec
-[Pcd]
- gMinPlatformPkgTokenSpaceGuid.PcdTpm2Enable ## CONSUMES
- gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut ## PRODUCES
- gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution ## PRODUCES
- gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution ## PRODUCES
- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow ## PRODUCES
- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn ## PRODUCES
- gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutColumn ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutRow ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand ## PRODUCES
- gMinPlatformPkgTokenSpaceGuid.PcdPlatformMemoryCheckLevel ## CONSUMES
- gMinPlatformPkgTokenSpaceGuid.PcdBootToShellOnly ## CONSUMES
- gMinPlatformPkgTokenSpaceGuid.PcdTrustedConsoleInputDevicePath ## CONSUMES
- gMinPlatformPkgTokenSpaceGuid.PcdTrustedConsoleOutputDevicePath ## CONSUMES
- gMinPlatformPkgTokenSpaceGuid.PcdTrustedStorageDevicePath ## CONSUMES
-
[Sources]
BdsPlatform.c
BdsPlatform.h
- PlatformBootOption.c
- MemoryTest.c
[Protocols]
- gEfiPciRootBridgeIoProtocolGuid ## CONSUMES
- gEfiPciIoProtocolGuid ## CONSUMES
- gEfiCpuIo2ProtocolGuid ## CONSUMES
- gEfiDxeSmmReadyToLockProtocolGuid ## PRODUCES
- gEfiGenericMemTestProtocolGuid ## CONSUMES
- gEfiDiskInfoProtocolGuid ## CONSUMES
- gEfiDevicePathToTextProtocolGuid ## CONSUMES
- gEfiSimpleTextInputExProtocolGuid ## CONSUMES
- gEfiFirmwareVolume2ProtocolGuid ## CONSUMES
- gEfiFormBrowser2ProtocolGuid ## CONSUMES
- gEfiGenericMemTestProtocolGuid ## CONSUMES
+ gEfiDxeSmmReadyToLockProtocolGuid ## PRODUCES
[Guids]
- gEfiGlobalVariableGuid ## PRODUCES
- gEfiMemoryOverwriteControlDataGuid ## PRODUCES
- gEfiEndOfDxeEventGroupGuid ## CONSUMES
+ gEfiEndOfDxeEventGroupGuid ## CONSUMES
+ gBdsEventBeforeConsoleAfterTrustedConsoleGuid
+ gBdsEventBeforeConsoleBeforeEndOfDxeGuid
+ gBdsEventAfterConsoleReadyBeforeBootOptionGuid
[Depex.common.DXE_DRIVER]
gEfiVariableArchProtocolGuid
diff --git a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/MemoryTest.c b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/MemoryTest.c
deleted file mode 100644
index 654845349a..0000000000
--- a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/MemoryTest.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/** @file
- Perform the platform memory test
-
-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
-SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#include "BdsPlatform.h"
-#include <Protocol/GenericMemoryTest.h>
-
-/**
- Perform the memory test base on the memory test intensive level,
- and update the memory resource.
-
- @param Level The memory test intensive level.
-
- @retval EFI_STATUS Success test all the system memory and update
- the memory resource
-
-**/
-EFI_STATUS
-MemoryTest (
- IN EXTENDMEM_COVERAGE_LEVEL Level
- )
-{
- EFI_STATUS Status;
- BOOLEAN RequireSoftECCInit;
- EFI_GENERIC_MEMORY_TEST_PROTOCOL *GenMemoryTest;
- UINT64 TestedMemorySize;
- UINT64 TotalMemorySize;
- BOOLEAN ErrorOut;
- BOOLEAN TestAbort;
-
- TestedMemorySize = 0;
- TotalMemorySize = 0;
- ErrorOut = FALSE;
- TestAbort = FALSE;
-
- RequireSoftECCInit = FALSE;
-
- Status = gBS->LocateProtocol (
- &gEfiGenericMemTestProtocolGuid,
- NULL,
- (VOID **) &GenMemoryTest
- );
- if (EFI_ERROR (Status)) {
- return EFI_SUCCESS;
- }
-
- Status = GenMemoryTest->MemoryTestInit (
- GenMemoryTest,
- Level,
- &RequireSoftECCInit
- );
- if (Status == EFI_NO_MEDIA) {
- //
- // The PEI codes also have the relevant memory test code to check the memory,
- // it can select to test some range of the memory or all of them. If PEI code
- // checks all the memory, this BDS memory test will has no not-test memory to
- // do the test, and then the status of EFI_NO_MEDIA will be returned by
- // "MemoryTestInit". So it does not need to test memory again, just return.
- //
- return EFI_SUCCESS;
- }
-
- do {
- Status = GenMemoryTest->PerformMemoryTest (
- GenMemoryTest,
- &TestedMemorySize,
- &TotalMemorySize,
- &ErrorOut,
- TestAbort
- );
- if (ErrorOut && (Status == EFI_DEVICE_ERROR)) {
- ASSERT (0);
- }
- } while (Status != EFI_NOT_FOUND);
-
- Status = GenMemoryTest->Finished (GenMemoryTest);
-
- return EFI_SUCCESS;
-}
diff --git a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/PlatformBootOption.c b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/PlatformBootOption.c
deleted file mode 100644
index 84aa097d58..0000000000
--- a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/PlatformBootOption.c
+++ /dev/null
@@ -1,559 +0,0 @@
-/** @file
- Driver for Platform Boot Options support.
-
-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
-SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#include "BdsPlatform.h"
-
-#include <Library/PcdLib.h>
-
-BOOLEAN mContinueBoot = FALSE;
-BOOLEAN mBootMenuBoot = FALSE;
-BOOLEAN mPxeBoot = FALSE;
-BOOLEAN mHotKeypressed = FALSE;
-EFI_EVENT HotKeyEvent = NULL;
-
-UINTN mBootMenuOptionNumber;
-
-EFI_DEVICE_PATH_PROTOCOL *
-BdsCreateShellDevicePath (
- VOID
- )
-/*++
-
-Routine Description:
-
- This function will create a SHELL BootOption to boot.
-
-Arguments:
-
- None.
-
-Returns:
-
- Shell Device path for booting.
-
---*/
-{
- UINTN FvHandleCount;
- EFI_HANDLE *FvHandleBuffer;
- UINTN Index;
- EFI_STATUS Status;
- EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
- UINTN Size;
- UINT32 AuthenticationStatus;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- VOID *Buffer;
-
- DevicePath = NULL;
- Status = EFI_SUCCESS;
-
- DEBUG ((DEBUG_INFO, "BdsCreateShellDevicePath\n"));
- gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiFirmwareVolume2ProtocolGuid,
- NULL,
- &FvHandleCount,
- &FvHandleBuffer
- );
-
- for (Index = 0; Index < FvHandleCount; Index++) {
- gBS->HandleProtocol (
- FvHandleBuffer[Index],
- &gEfiFirmwareVolume2ProtocolGuid,
- (VOID **) &Fv
- );
-
- Buffer = NULL;
- Size = 0;
- Status = Fv->ReadSection (
- Fv,
- &gUefiShellFileGuid,
- EFI_SECTION_PE32,
- 0,
- &Buffer,
- &Size,
- &AuthenticationStatus
- );
- if (EFI_ERROR (Status)) {
- //
- // Skip if no shell file in the FV
- //
- continue;
- } else {
- //
- // Found the shell
- //
- break;
- }
- }
-
- if (EFI_ERROR (Status)) {
- //
- // No shell present
- //
- if (FvHandleCount) {
- FreePool (FvHandleBuffer);
- }
- return NULL;
- }
- //
- // Build the shell boot option
- //
- DevicePath = DevicePathFromHandle (FvHandleBuffer[Index]);
-
- if (FvHandleCount) {
- FreePool (FvHandleBuffer);
- }
-
- return DevicePath;
-}
-
-
-EFI_STATUS
-CreateFvBootOption (
- EFI_GUID *FileGuid,
- CHAR16 *Description,
- EFI_BOOT_MANAGER_LOAD_OPTION *BootOption,
- UINT32 Attributes,
- UINT8 *OptionalData, OPTIONAL
- UINT32 OptionalDataSize
- )
-{
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
- MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
- EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
- UINT32 AuthenticationStatus;
- VOID *Buffer;
- UINTN Size;
-
- if ((BootOption == NULL) || (FileGuid == NULL) || (Description == NULL)) {
- return EFI_INVALID_PARAMETER;
- }
-
- EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);
-
- if (!CompareGuid (&gUefiShellFileGuid, FileGuid)) {
- Status = gBS->HandleProtocol (
- gImageHandle,
- &gEfiLoadedImageProtocolGuid,
- (VOID **) &LoadedImage
- );
- if (!EFI_ERROR (Status)) {
- Status = gBS->HandleProtocol (
- LoadedImage->DeviceHandle,
- &gEfiFirmwareVolume2ProtocolGuid,
- (VOID **) &Fv
- );
- if (!EFI_ERROR (Status)) {
- Buffer = NULL;
- Size = 0;
- Status = Fv->ReadSection (
- Fv,
- FileGuid,
- EFI_SECTION_PE32,
- 0,
- &Buffer,
- &Size,
- &AuthenticationStatus
- );
- if (Buffer != NULL) {
- FreePool (Buffer);
- }
- }
- }
- if (EFI_ERROR (Status)) {
- return EFI_NOT_FOUND;
- }
-
- DevicePath = AppendDevicePathNode (
- DevicePathFromHandle (LoadedImage->DeviceHandle),
- (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
- );
- } else {
- DevicePath = AppendDevicePathNode (
- BdsCreateShellDevicePath (),
- (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
- );
- }
-
- Status = EfiBootManagerInitializeLoadOption (
- BootOption,
- LoadOptionNumberUnassigned,
- LoadOptionTypeBoot,
- Attributes,
- Description,
- DevicePath,
- OptionalData,
- OptionalDataSize
- );
- FreePool (DevicePath);
- return Status;
-}
-
-EFI_GUID mUiFile = {
- 0x462CAA21, 0x7614, 0x4503, { 0x83, 0x6E, 0x8A, 0xB6, 0xF4, 0x66, 0x23, 0x31 }
-};
-EFI_GUID mBootMenuFile = {
- 0xEEC25BDC, 0x67F2, 0x4D95, { 0xB1, 0xD5, 0xF8, 0x1B, 0x20, 0x39, 0xD1, 0x1D }
-};
-
-
-/**
- Return the index of the load option in the load option array.
-
- The function consider two load options are equal when the
- OptionType, Attributes, Description, FilePath and OptionalData are equal.
-
- @param Key Pointer to the load option to be found.
- @param Array Pointer to the array of load options to be found.
- @param Count Number of entries in the Array.
-
- @retval -1 Key wasn't found in the Array.
- @retval 0 ~ Count-1 The index of the Key in the Array.
-**/
-INTN
-PlatformFindLoadOption (
- IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Key,
- IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Array,
- IN UINTN Count
- )
-{
- UINTN Index;
-
- for (Index = 0; Index < Count; Index++) {
- if ((Key->OptionType == Array[Index].OptionType) &&
- (Key->Attributes == Array[Index].Attributes) &&
- (StrCmp (Key->Description, Array[Index].Description) == 0) &&
- (CompareMem (Key->FilePath, Array[Index].FilePath, GetDevicePathSize (Key->FilePath)) == 0) &&
- (Key->OptionalDataSize == Array[Index].OptionalDataSize) &&
- (CompareMem (Key->OptionalData, Array[Index].OptionalData, Key->OptionalDataSize) == 0)) {
- return (INTN) Index;
- }
- }
-
- return -1;
-}
-
-UINTN
-RegisterFvBootOption (
- EFI_GUID *FileGuid,
- CHAR16 *Description,
- UINTN Position,
- UINT32 Attributes,
- UINT8 *OptionalData, OPTIONAL
- UINT32 OptionalDataSize
- )
-{
- EFI_STATUS Status;
- UINTN OptionIndex;
- EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
- EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
- UINTN BootOptionCount;
-
- NewOption.OptionNumber = LoadOptionNumberUnassigned;
- Status = CreateFvBootOption (FileGuid, Description, &NewOption, Attributes, OptionalData, OptionalDataSize);
- if (!EFI_ERROR (Status)) {
- BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);
-
- OptionIndex = PlatformFindLoadOption (&NewOption, BootOptions, BootOptionCount);
-
- if (OptionIndex == -1) {
- Status = EfiBootManagerAddLoadOptionVariable (&NewOption, Position);
- ASSERT_EFI_ERROR (Status);
- } else {
- NewOption.OptionNumber = BootOptions[OptionIndex].OptionNumber;
- }
- EfiBootManagerFreeLoadOption (&NewOption);
- EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
- }
-
- return NewOption.OptionNumber;
-}
-
-
-
-VOID
-EFIAPI
-PlatformBootManagerWaitCallback (
- UINT16 TimeoutRemain
- )
-{
- EFI_STATUS Status;
- EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TxtInEx;
- EFI_KEY_DATA KeyData;
- BOOLEAN PausePressed;
-
- //
- // Pause on PAUSE key
- //
- Status = gBS->HandleProtocol (gST->ConsoleInHandle, &gEfiSimpleTextInputExProtocolGuid, (VOID **) &TxtInEx);
- ASSERT_EFI_ERROR (Status);
-
- PausePressed = FALSE;
-
- while (TRUE) {
- Status = TxtInEx->ReadKeyStrokeEx (TxtInEx, &KeyData);
- if (EFI_ERROR (Status)) {
- break;
- }
-
- if (KeyData.Key.ScanCode == SCAN_PAUSE) {
- PausePressed = TRUE;
- break;
- }
- }
-
- //
- // Loop until non-PAUSE key pressed
- //
- while (PausePressed) {
- Status = TxtInEx->ReadKeyStrokeEx (TxtInEx, &KeyData);
- if (!EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_INFO, "[PauseCallback] %x/%x %x/%x\n",
- KeyData.Key.ScanCode, KeyData.Key.UnicodeChar,
- KeyData.KeyState.KeyShiftState, KeyData.KeyState.KeyToggleState
- ));
- PausePressed = (BOOLEAN) (KeyData.Key.ScanCode == SCAN_PAUSE);
- }
- }
-}
-
-
-EFI_GUID gUefiShellFileGuid = { 0x7C04A583, 0x9E3E, 0x4f1c, { 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 } };
-
-#define INTERNAL_UEFI_SHELL_NAME L"Internal UEFI Shell 2.0"
-#define UEFI_HARD_DRIVE_NAME L"UEFI Hard Drive"
-
-VOID
-RegisterDefaultBootOption (
- VOID
- )
-{
-#if 0
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
- MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
-#endif
- UINT16 *ShellData;
- UINT32 ShellDataSize;
-
- ShellData = NULL;
- ShellDataSize = 0;
- RegisterFvBootOption (&gUefiShellFileGuid, INTERNAL_UEFI_SHELL_NAME, (UINTN) -1, LOAD_OPTION_ACTIVE, (UINT8 *)ShellData, ShellDataSize);
-
- //
- // Boot Menu
- //
- mBootMenuOptionNumber = RegisterFvBootOption (&mBootMenuFile, L"Boot Device List", (UINTN) -1, LOAD_OPTION_CATEGORY_APP | LOAD_OPTION_ACTIVE | LOAD_OPTION_HIDDEN, NULL, 0);
-
- if (mBootMenuOptionNumber == LoadOptionNumberUnassigned) {
- DEBUG ((DEBUG_INFO, "BootMenuOptionNumber (%d) should not be same to LoadOptionNumberUnassigned(%d).\n", mBootMenuOptionNumber, LoadOptionNumberUnassigned));
- }
-#if 0
- //
- // Boot Manager Menu
- //
- EfiInitializeFwVolDevicepathNode (&FileNode, &mUiFile);
-
- gBS->HandleProtocol (
- gImageHandle,
- &gEfiLoadedImageProtocolGuid,
- (VOID **) &LoadedImage
- );
- DevicePath = AppendDevicePathNode (DevicePathFromHandle (LoadedImage->DeviceHandle), (EFI_DEVICE_PATH_PROTOCOL *) &FileNode);
-#endif
-
-}
-
-VOID
-RegisterBootOptionHotkey (
- UINT16 OptionNumber,
- EFI_INPUT_KEY *Key,
- BOOLEAN Add
- )
-{
- EFI_STATUS Status;
-
- if (!Add) {
- //
- // No enter hotkey when force to setup or there is no boot option
- //
- Status = EfiBootManagerDeleteKeyOptionVariable (NULL, 0, Key, NULL);
- ASSERT (Status == EFI_SUCCESS || Status == EFI_NOT_FOUND);
- } else {
- //
- // Register enter hotkey for the first boot option
- //
- Status = EfiBootManagerAddKeyOptionVariable (NULL, OptionNumber, 0, Key,NULL);
- ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
- }
-}
-
-EFI_STATUS
-EFIAPI
-DetectKeypressCallback (
- IN EFI_KEY_DATA *KeyData
-)
-{
- mHotKeypressed = TRUE;
-
- if (HotKeyEvent != NULL) {
- gBS->SignalEvent(HotKeyEvent);
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- This function is called after all the boot options are enumerated and ordered properly.
-**/
-VOID
-RegisterStaticHotkey (
- VOID
- )
-{
-
- EFI_INPUT_KEY Enter;
- EFI_KEY_DATA F2;
- EFI_KEY_DATA F7;
- BOOLEAN EnterSetup;
- EFI_STATUS Status;
- EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
-
- EnterSetup = FALSE;
-
- //
- // [Enter]
- //
- mContinueBoot = !EnterSetup;
- if (mContinueBoot) {
- Enter.ScanCode = SCAN_NULL;
- Enter.UnicodeChar = CHAR_CARRIAGE_RETURN;
- EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL);
- }
-
-
- //
- // [F2]/[F7]
- //
- F2.Key.ScanCode = SCAN_F2;
- F2.Key.UnicodeChar = CHAR_NULL;
- F2.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID;
- F2.KeyState.KeyToggleState = 0;
- Status = EfiBootManagerGetBootManagerMenu (&BootOption);
- ASSERT_EFI_ERROR (Status);
- RegisterBootOptionHotkey ((UINT16) BootOption.OptionNumber, &F2.Key, TRUE);
- EfiBootManagerFreeLoadOption (&BootOption);
-
- F7.Key.ScanCode = SCAN_F7;
- F7.Key.UnicodeChar = CHAR_NULL;
- F7.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID;
- F7.KeyState.KeyToggleState = 0;
- mBootMenuBoot = !EnterSetup;
- RegisterBootOptionHotkey ((UINT16) mBootMenuOptionNumber, &F7.Key, mBootMenuBoot);
-
-}
-
-UINT8
-BootOptionType (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- EFI_DEVICE_PATH_PROTOCOL *Node;
- EFI_DEVICE_PATH_PROTOCOL *NextNode;
-
- for (Node = DevicePath; !IsDevicePathEndType (Node); Node = NextDevicePathNode (Node)) {
- if (DevicePathType (Node) == MESSAGING_DEVICE_PATH) {
- //
- // Make sure the device path points to the driver device.
- //
- NextNode = NextDevicePathNode (Node);
- if (DevicePathSubType(NextNode) == MSG_DEVICE_LOGICAL_UNIT_DP) {
- //
- // if the next node type is Device Logical Unit, which specify the Logical Unit Number (LUN),
- // skip it
- //
- NextNode = NextDevicePathNode (NextNode);
- }
- if (IsDevicePathEndType (NextNode)) {
- if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH)) {
- return DevicePathSubType (Node);
- } else {
- return MSG_SATA_DP;
- }
- }
- }
- }
-
- return (UINT8) -1;
-}
-
-/**
- Returns the priority number.
- OptionType EFI
- ------------------------------------
- PXE 2
- DVD 4
- USB 6
- NVME 7
- HDD 8
- EFI Shell 9
- Others 100
-
- @param BootOption
-**/
-UINTN
-BootOptionPriority (
- CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOption
- )
-{
- //
- // EFI boot options
- //
- switch (BootOptionType (BootOption->FilePath)) {
- case MSG_MAC_ADDR_DP:
- case MSG_VLAN_DP:
- case MSG_IPv4_DP:
- case MSG_IPv6_DP:
- return 2;
-
- case MSG_SATA_DP:
- case MSG_ATAPI_DP:
- case MSG_UFS_DP:
- case MSG_NVME_NAMESPACE_DP:
- return 4;
-
- case MSG_USB_DP:
- return 6;
-
- }
- if (StrCmp (BootOption->Description, INTERNAL_UEFI_SHELL_NAME) == 0) {
- if (PcdGetBool (PcdBootToShellOnly)) {
- return 0;
- }
- return 9;
- }
- if (StrCmp (BootOption->Description, UEFI_HARD_DRIVE_NAME) == 0) {
- return 8;
- }
- return 100;
-}
-
-INTN
-EFIAPI
-CompareBootOption (
- CONST VOID *Left,
- CONST VOID *Right
- )
-{
- return BootOptionPriority ((EFI_BOOT_MANAGER_LOAD_OPTION *) Left) -
- BootOptionPriority ((EFI_BOOT_MANAGER_LOAD_OPTION *) Right);
-}
-
--
2.19.1.windows.1
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Re: [edk2-platforms] [PATCH 05/11] MinPlatformPkg: Add BDS Hook Points
2019-12-14 1:32 ` [edk2-platforms] [PATCH 05/11] MinPlatformPkg: Add BDS Hook Points Agyeman, Prince
@ 2019-12-17 5:44 ` Chiu, Chasel
2019-12-18 1:33 ` Nate DeSimone
2019-12-21 2:36 ` Kubacki, Michael A
2 siblings, 0 replies; 45+ messages in thread
From: Chiu, Chasel @ 2019-12-17 5:44 UTC (permalink / raw)
To: Agyeman, Prince, devel@edk2.groups.io
Cc: Kubacki, Michael A, Desimone, Nathaniel L
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
> -----Original Message-----
> From: Agyeman, Prince <prince.agyeman@intel.com>
> Sent: Saturday, December 14, 2019 9:33 AM
> To: devel@edk2.groups.io
> Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Chiu, Chasel
> <chasel.chiu@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>
> Subject: [edk2-platforms] [PATCH 05/11] MinPlatformPkg: Add BDS Hook
> Points
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
>
> Added BDS hook points to the Minplatform boot manager library
> as defined in the Minimum Platfrom specifcations.
>
> Changes made:
>
> * Added functions to signal three BDS event groups.
> These event groups are BeforeConsoleAfterTrustedConsole,
> BeforeConsoleBeforeEndOfDxe and AfterConsoleReadyBeforeBootOption.
>
> * Removed BDS functionalities from the boot manager library.
> These functionalities will be added to callbacks a module in BoardModule,
> which will then register/hook to the BDS hook points
>
> See https://edk2-docs.gitbooks.io/edk-ii-minimum-platform-specification,
> under Appendix A.3 BDS Hook Points, for more details.
>
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
>
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
> .../DxePlatformBootManagerLib/BdsPlatform.c | 1262 ++---------------
> .../DxePlatformBootManagerLib/BdsPlatform.h | 181 +--
> .../DxePlatformBootManagerLib.inf | 51 +-
> .../DxePlatformBootManagerLib/MemoryTest.c | 83 --
> .../PlatformBootOption.c | 559 --------
> 5 files changed, 112 insertions(+), 2024 deletions(-)
> delete mode 100644
> Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/Me
> moryTest.c
> delete mode 100644
> Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/Pla
> tformBootOption.c
>
> diff --git
> a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/
> BdsPlatform.c
> b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/
> BdsPlatform.c
> index 491fb0f26f..31a9ef4a07 100644
> ---
> a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/
> BdsPlatform.c
> +++
> b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/
> BdsPlatform.c
> @@ -1,130 +1,14 @@
> /** @file
> This file include all platform action which can be customized by IBV/OEM.
>
> -Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
> **/
>
> #include "BdsPlatform.h"
> -#include <Guid/EventGroup.h>
> -#include <Protocol/DxeSmmReadyToLock.h>
> -#include <Protocol/FirmwareVolume2.h>
> -#include <Protocol/PciRootBridgeIo.h>
>
> -#include <Protocol/BlockIo.h>
> -#include <Protocol/PciIo.h>
> -#include <Library/IoLib.h>
> -#include <Library/PciLib.h>
> -#include <Guid/EventGroup.h>
> -
> -#include <Library/Tcg2PhysicalPresenceLib.h>
> -
> -#include <Library/HobLib.h>
> -#include <Protocol/UsbIo.h>
> -
> -#include <Library/UefiBootManagerLib.h>
> -
> -GLOBAL_REMOVE_IF_UNREFERENCED EFI_BOOT_MODE
> gBootMode;
> -
> -BOOLEAN gPPRequireUIConfirm;
> -
> -extern UINTN
> mBootMenuOptionNumber;
> -
> -GLOBAL_REMOVE_IF_UNREFERENCED USB_CLASS_FORMAT_DEVICE_PATH
> gUsbClassKeyboardDevicePath = {
> - {
> - {
> - MESSAGING_DEVICE_PATH,
> - MSG_USB_CLASS_DP,
> - {
> - (UINT8) (sizeof (USB_CLASS_DEVICE_PATH)),
> - (UINT8) ((sizeof (USB_CLASS_DEVICE_PATH)) >> 8)
> - }
> - },
> - 0xffff, // VendorId
> - 0xffff, // ProductId
> - CLASS_HID, // DeviceClass
> - SUBCLASS_BOOT, // DeviceSubClass
> - PROTOCOL_KEYBOARD // DeviceProtocol
> - },
> - gEndEntire
> -};
> -
> -//
> -// Internal shell mode
> -//
> -GLOBAL_REMOVE_IF_UNREFERENCED UINT32
> mShellModeColumn;
> -GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mShellModeRow;
> -GLOBAL_REMOVE_IF_UNREFERENCED UINT32
> mShellHorizontalResolution;
> -GLOBAL_REMOVE_IF_UNREFERENCED UINT32
> mShellVerticalResolution;
> -//
> -// BDS Platform Functions
> -//
> -
> -BOOLEAN
> -IsMorBitSet (
> - VOID
> - )
> -{
> - UINTN MorControl;
> - EFI_STATUS Status;
> - UINTN DataSize;
> -
> - //
> - // Check if the MOR bit is set.
> - //
> - DataSize = sizeof (MorControl);
> - Status = gRT->GetVariable (
> - MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME,
> - &gEfiMemoryOverwriteControlDataGuid,
> - NULL,
> - &DataSize,
> - &MorControl
> - );
> - if (EFI_ERROR (Status)) {
> - DEBUG ((DEBUG_INFO, " PlatformBootMangerLib:
> gEfiMemoryOverwriteControlDataGuid doesn't exist!!***\n"));
> - MorControl = 0;
> - } else {
> - DEBUG ((DEBUG_INFO, " PlatformBootMangerLib: Get the
> gEfiMemoryOverwriteControlDataGuid = %x!!***\n", MorControl));
> - }
> -
> - return (BOOLEAN) (MorControl & 0x01);
> -}
> -
> -VOID
> -DumpDevicePath (
> - IN CHAR16 *Name,
> - IN EFI_DEVICE_PATH *DevicePath
> - )
> -{
> - CHAR16 *Str;
> -
> - Str = ConvertDevicePathToText(DevicePath, TRUE, TRUE);
> - DEBUG ((DEBUG_INFO, "%s: %s\n", Name, Str));
> - if (Str != NULL) {
> - FreePool (Str);
> - }
> -}
> -
> -/**
> - An empty function to pass error checking of CreateEventEx ().
> -
> - This empty function ensures that EVT_NOTIFY_SIGNAL_ALL is error
> - checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0.
> -
> - @param Event Event whose notification function is
> being invoked.
> - @param Context The pointer to the notification
> function's context,
> - which is implementation-dependent.
> -**/
> -VOID
> -EFIAPI
> -InternalBdsEmptyCallbackFuntion (
> - IN EFI_EVENT Event,
> - IN VOID *Context
> - )
> -{
> - return;
> -}
> +extern UINTN
> mBootMenuOptionNumber;
>
> VOID
> ExitPmAuth (
> @@ -145,7 +29,7 @@ ExitPmAuth (
> Status = gBS->CreateEventEx (
> EVT_NOTIFY_SIGNAL,
> TPL_CALLBACK,
> - InternalBdsEmptyCallbackFuntion,
> + EfiEventEmptyFunction,
> NULL,
> &gEfiEndOfDxeEventGroupGuid,
> &EndOfDxeEvent
> @@ -172,918 +56,134 @@ ExitPmAuth (
> DEBUG((DEBUG_INFO,"ExitPmAuth ()- End\n"));
> }
>
> -VOID
> -ConnectRootBridge (
> - BOOLEAN Recursive
> - )
> -{
> - UINTN RootBridgeHandleCount;
> - EFI_HANDLE *RootBridgeHandleBuffer;
> - UINTN RootBridgeIndex;
> -
> - RootBridgeHandleCount = 0;
> - gBS->LocateHandleBuffer (
> - ByProtocol,
> - &gEfiPciRootBridgeIoProtocolGuid,
> - NULL,
> - &RootBridgeHandleCount,
> - &RootBridgeHandleBuffer
> - );
> - for (RootBridgeIndex = 0; RootBridgeIndex < RootBridgeHandleCount;
> RootBridgeIndex++) {
> - gBS->ConnectController (RootBridgeHandleBuffer[RootBridgeIndex],
> NULL, NULL, Recursive);
> - }
> -}
> -
>
> /**
> - Return whether the device is trusted console.
> -
> - @param Device The device to be tested.
> -
> - @retval TRUE The device can be trusted.
> - @retval FALSE The device cannot be trusted.
> -**/
> -BOOLEAN
> -IsTrustedConsole (
> - IN CONSOLE_TYPE ConsoleType,
> - IN EFI_DEVICE_PATH_PROTOCOL *Device
> - )
> -{
> - VOID *TrustedConsoleDevicepath;
> - EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
> - EFI_DEVICE_PATH_PROTOCOL *Instance;
> - UINTN Size;
> - EFI_DEVICE_PATH_PROTOCOL *ConsoleDevice;
> -
> - if (Device == NULL) {
> - return FALSE;
> - }
> -
> - ConsoleDevice = DuplicateDevicePath(Device);
> -
> - TrustedConsoleDevicepath = NULL;
> -
> - switch (ConsoleType) {
> - case ConIn:
> - TrustedConsoleDevicepath = PcdGetPtr
> (PcdTrustedConsoleInputDevicePath);
> - break;
> - case ConOut:
> - //
> - // Check GOP and remove last node
> - //
> - TempDevicePath = ConsoleDevice;
> - while (!IsDevicePathEndType (TempDevicePath)) {
> - if (DevicePathType (TempDevicePath) == ACPI_DEVICE_PATH &&
> - DevicePathSubType (TempDevicePath) == ACPI_ADR_DP) {
> - SetDevicePathEndNode (TempDevicePath);
> - break;
> - }
> - TempDevicePath = NextDevicePathNode (TempDevicePath);
> - }
> -
> - TrustedConsoleDevicepath = PcdGetPtr
> (PcdTrustedConsoleOutputDevicePath);
> - break;
> - default:
> - ASSERT(FALSE);
> - break;
> - }
> -
> - TempDevicePath = TrustedConsoleDevicepath;
> - do {
> - Instance = GetNextDevicePathInstance (&TempDevicePath, &Size);
> - if (Instance == NULL) {
> - break;
> - }
> -
> - if (CompareMem (ConsoleDevice, Instance, Size -
> END_DEVICE_PATH_LENGTH) == 0) {
> - FreePool (Instance);
> - FreePool (ConsoleDevice);
> - return TRUE;
> - }
> -
> - FreePool (Instance);
> - } while (TempDevicePath != NULL);
> -
> - FreePool (ConsoleDevice);
> + Creates an EFI event in the BDS Event Group.
>
> - return FALSE;
> -}
> -
> -BOOLEAN
> -IsUsbShortForm (
> - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
> - )
> -{
> - if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&
> - ((DevicePathSubType (DevicePath) == MSG_USB_CLASS_DP) ||
> (DevicePathSubType (DevicePath) == MSG_USB_WWID_DP)) ) {
> - return TRUE;
> - }
> + @param NotifyTpl The task priority level of the event.
> + @param gEfiEventGuid The GUID of the event group to signal.
> + @param BdsConsoleEvent Returns the EFI event returned from
> gBS->CreateEvent(Ex).
>
> - return FALSE;
> -}
> -
> -/**
> - Connect the USB short form device path.
> + @retval EFI_SUCCESS Event was created.
> + @retval Other Event was not created.
>
> - @param DevicePath USB short form device path
> -
> - @retval EFI_SUCCESS Successfully connected the USB device
> - @retval EFI_NOT_FOUND Cannot connect the USB device
> - @retval EFI_INVALID_PARAMETER The device path is invalid.
> **/
> EFI_STATUS
> -ConnectUsbShortFormDevicePath (
> - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
> +EFIAPI
> +CreateBdsEvent (
> + IN EFI_TPL NotifyTpl,
> + IN EFI_GUID *gEfiEventGuid,
> + OUT EFI_EVENT *BdsConsoleEvent
> )
> {
> - EFI_STATUS Status;
> - EFI_HANDLE *Handles;
> - UINTN HandleCount;
> - UINTN Index;
> - EFI_PCI_IO_PROTOCOL *PciIo;
> - UINT8 Class[3];
> - BOOLEAN AtLeastOneConnected;
> + EFI_STATUS Status;
>
> - //
> - // Check the passed in parameters
> - //
> - if (DevicePath == NULL) {
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - if (!IsUsbShortForm (DevicePath)) {
> - return EFI_INVALID_PARAMETER;
> - }
> + ASSERT (BdsConsoleEvent != NULL);
>
> - //
> - // Find the usb host controller firstly, then connect with the remaining
> device path
> - //
> - AtLeastOneConnected = FALSE;
> - Status = gBS->LocateHandleBuffer (
> - ByProtocol,
> - &gEfiPciIoProtocolGuid,
> + Status = gBS->CreateEventEx (
> + EVT_NOTIFY_SIGNAL,
> + NotifyTpl,
> + EfiEventEmptyFunction,
> NULL,
> - &HandleCount,
> - &Handles
> - );
> - for (Index = 0; Index < HandleCount; Index++) {
> - Status = gBS->HandleProtocol (
> - Handles[Index],
> - &gEfiPciIoProtocolGuid,
> - (VOID **) &PciIo
> - );
> - if (!EFI_ERROR (Status)) {
> - //
> - // Check whether the Pci device is the wanted usb host controller
> - //
> - Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0x09, 3, &Class);
> - if (!EFI_ERROR (Status) &&
> - ((PCI_CLASS_SERIAL == Class[2]) && (PCI_CLASS_SERIAL_USB ==
> Class[1]))
> - ) {
> - Status = gBS->ConnectController (
> - Handles[Index],
> - NULL,
> - DevicePath,
> - FALSE
> - );
> - if (!EFI_ERROR(Status)) {
> - AtLeastOneConnected = TRUE;
> - }
> - }
> - }
> - }
> -
> - return AtLeastOneConnected ? EFI_SUCCESS : EFI_NOT_FOUND;
> -}
> -
> -/**
> - Update the ConIn variable with USB Keyboard device path,if its not
> already exists in ConIn
> -**/
> -VOID
> -EnumUsbKeyboard (
> - VOID
> - )
> -{
> - DEBUG ((DEBUG_INFO, "[EnumUsbKeyboard]\n"));
> - EfiBootManagerUpdateConsoleVariable (ConIn,
> (EFI_DEVICE_PATH_PROTOCOL *) &gUsbClassKeyboardDevicePath, NULL);
> -
> - //
> - // Append Usb Keyboard short form DevicePath into "ConInDev"
> - //
> - EfiBootManagerUpdateConsoleVariable (ConInDev,
> (EFI_DEVICE_PATH_PROTOCOL *) &gUsbClassKeyboardDevicePath, NULL);
> -}
> -
> -BOOLEAN
> -IsVgaHandle (
> - IN EFI_HANDLE Handle
> - )
> -{
> - EFI_PCI_IO_PROTOCOL *PciIo;
> - PCI_TYPE00 Pci;
> - EFI_STATUS Status;
> -
> - Status = gBS->HandleProtocol (
> - Handle,
> - &gEfiPciIoProtocolGuid,
> - (VOID **)&PciIo
> - );
> - if (!EFI_ERROR (Status)) {
> - Status = PciIo->Pci.Read (
> - PciIo,
> - EfiPciIoWidthUint32,
> - 0,
> - sizeof (Pci) / sizeof (UINT32),
> - &Pci
> - );
> - if (!EFI_ERROR (Status)) {
> - if (IS_PCI_VGA (&Pci) || IS_PCI_OLD_VGA (&Pci)) {
> - return TRUE;
> - }
> - }
> - }
> - return FALSE;
> -}
> -
> -EFI_HANDLE
> -IsVideoController (
> - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
> - )
> -{
> - EFI_DEVICE_PATH_PROTOCOL *DupDevicePath;
> - EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
> - EFI_STATUS Status;
> - EFI_HANDLE DeviceHandle;
> -
> - DupDevicePath = DuplicateDevicePath (DevicePath);
> - ASSERT (DupDevicePath != NULL);
> - if (DupDevicePath == NULL) {
> - return NULL;
> - }
> -
> - TempDevicePath = DupDevicePath;
> - Status = gBS->LocateDevicePath (
> - &gEfiDevicePathProtocolGuid,
> - &TempDevicePath,
> - &DeviceHandle
> + gEfiEventGuid,
> + BdsConsoleEvent
> );
> - FreePool (DupDevicePath);
> - if (EFI_ERROR (Status)) {
> - return NULL;
> - }
> -
> - if (IsVgaHandle (DeviceHandle)) {
> - return DeviceHandle;
> - } else {
> - return NULL;
> - }
> -}
> -
> -BOOLEAN
> -IsGopDevicePath (
> - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
> - )
> -{
> - while (!IsDevicePathEndType (DevicePath)) {
> - if (DevicePathType (DevicePath) == ACPI_DEVICE_PATH &&
> - DevicePathSubType (DevicePath) == ACPI_ADR_DP) {
> - return TRUE;
> - }
> - DevicePath = NextDevicePathNode (DevicePath);
> - }
> - return FALSE;
> -}
> -
> -/**
> - Remove all GOP device path instance from DevicePath and add the Gop
> to the DevicePath.
> -**/
> -EFI_DEVICE_PATH_PROTOCOL *
> -UpdateGopDevicePath (
> - EFI_DEVICE_PATH_PROTOCOL *DevicePath,
> - EFI_DEVICE_PATH_PROTOCOL *Gop
> - )
> -{
> - UINTN Size;
> - UINTN GopSize;
> - EFI_DEVICE_PATH_PROTOCOL *Temp;
> - EFI_DEVICE_PATH_PROTOCOL *Return;
> - EFI_DEVICE_PATH_PROTOCOL *Instance;
> - BOOLEAN Exist;
> -
> - Exist = FALSE;
> - Return = NULL;
> - GopSize = GetDevicePathSize (Gop);
> - do {
> - Instance = GetNextDevicePathInstance (&DevicePath, &Size);
> - if (Instance == NULL) {
> - break;
> - }
> - if (!IsGopDevicePath (Instance) ||
> - (Size == GopSize && CompareMem (Instance, Gop, GopSize) == 0)
> - ) {
> - if (Size == GopSize && CompareMem (Instance, Gop, GopSize) == 0) {
> - Exist = TRUE;
> - }
> - Temp = Return;
> - Return = AppendDevicePathInstance (Return, Instance);
> - if (Temp != NULL) {
> - FreePool (Temp);
> - }
> - }
> - FreePool (Instance);
> - } while (DevicePath != NULL);
>
> - if (!Exist) {
> - Temp = Return;
> - Return = AppendDevicePathInstance (Return, Gop);
> - if (Temp != NULL) {
> - FreePool (Temp);
> - }
> - }
> - return Return;
> + return Status;
> }
>
> /**
> - Get Graphics Controller Handle.
> -
> - @retval GraphicsController Successfully located
> - @retval NULL Failed to locate
> -**/
> -EFI_HANDLE
> -EFIAPI
> -GetGraphicsController (
> - IN BOOLEAN NeedTrustedConsole
> - )
> -{
> - EFI_STATUS Status;
> - UINTN Index;
> - EFI_HANDLE *PciHandles;
> - UINTN PciHandlesSize;
> - EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> -
> - Status = gBS->LocateHandleBuffer (
> - ByProtocol,
> - &gEfiPciIoProtocolGuid,
> - NULL,
> - &PciHandlesSize,
> - &PciHandles
> - );
> - if (EFI_ERROR (Status)) {
> - return NULL;
> - }
> -
> - for (Index = 0; Index < PciHandlesSize; Index++) {
> - Status = gBS->HandleProtocol (
> - PciHandles[Index],
> - &gEfiDevicePathProtocolGuid,
> - (VOID **) &DevicePath
> - );
> - if (EFI_ERROR(Status)) {
> - continue;
> - }
> - if (!IsVgaHandle (PciHandles[Index])) {
> - continue;
> - }
> - if ((NeedTrustedConsole && IsTrustedConsole (ConOut, DevicePath)) ||
> - ((!NeedTrustedConsole) && (!IsTrustedConsole (ConOut,
> DevicePath)))) {
> - return PciHandles[Index];
> - }
> - }
> -
> - return NULL;
> -}
> -
> -VOID
> -UpdateGraphicConOut (
> - IN BOOLEAN NeedTrustedConsole
> - )
> -{
> - EFI_HANDLE GraphicsControllerHandle;
> - EFI_DEVICE_PATH_PROTOCOL *GopDevicePath;
> - EFI_DEVICE_PATH_PROTOCOL *ConOutDevicePath;
> - EFI_DEVICE_PATH_PROTOCOL *UpdatedConOutDevicePath;
> + Create, Signal, and Close the Bds Event Before Console After
> + Trusted Console event using CreateBdsEvent().
>
> - //
> - // Update ConOut variable
> - //
> - GraphicsControllerHandle = GetGraphicsController
> (NeedTrustedConsole);
> - if (GraphicsControllerHandle != NULL) {
> - //
> - // Connect the GOP driver
> - //
> - gBS->ConnectController (GraphicsControllerHandle, NULL, NULL,
> TRUE);
> -
> - //
> - // Get the GOP device path
> - // NOTE: We may get a device path that contains Controller node in it.
> - //
> - GopDevicePath = EfiBootManagerGetGopDevicePath
> (GraphicsControllerHandle);
> - if (GopDevicePath != NULL) {
> - GetEfiGlobalVariable2 (L"ConOut", (VOID **)&ConOutDevicePath,
> NULL);
> - UpdatedConOutDevicePath = UpdateGopDevicePath
> (ConOutDevicePath, GopDevicePath);
> - if (ConOutDevicePath != NULL) {
> - FreePool (ConOutDevicePath);
> - }
> - FreePool (GopDevicePath);
> - gRT->SetVariable (
> - L"ConOut",
> - &gEfiGlobalVariableGuid,
> - EFI_VARIABLE_NON_VOLATILE |
> EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS,
> - GetDevicePathSize (UpdatedConOutDevicePath),
> - UpdatedConOutDevicePath
> - );
> - }
> - }
> -}
> -
> -VOID
> -AddConsoleVariable (
> - IN CONSOLE_TYPE ConsoleType,
> - IN EFI_DEVICE_PATH *ConsoleDevicePath
> - )
> -{
> - EFI_DEVICE_PATH *TempDevicePath;
> - EFI_DEVICE_PATH *Instance;
> - UINTN Size;
> - EFI_HANDLE GraphicsControllerHandle;
> - EFI_DEVICE_PATH *GopDevicePath;
> -
> - TempDevicePath = ConsoleDevicePath;
> - do {
> - Instance = GetNextDevicePathInstance (&TempDevicePath, &Size);
> - if (Instance == NULL) {
> - break;
> - }
> -
> - switch (ConsoleType) {
> - case ConIn:
> - if (IsUsbShortForm (Instance)) {
> - //
> - // Append Usb Keyboard short form DevicePath into "ConInDev"
> - //
> - EfiBootManagerUpdateConsoleVariable (ConInDev, Instance,
> NULL);
> - }
> - EfiBootManagerUpdateConsoleVariable (ConsoleType, Instance,
> NULL);
> - break;
> - case ConOut:
> - GraphicsControllerHandle = IsVideoController (Instance);
> - if (GraphicsControllerHandle == NULL) {
> - EfiBootManagerUpdateConsoleVariable (ConsoleType, Instance,
> NULL);
> - } else {
> - //
> - // Connect the GOP driver
> - //
> - gBS->ConnectController (GraphicsControllerHandle, NULL, NULL,
> TRUE);
> - //
> - // Get the GOP device path
> - // NOTE: We may get a device path that contains Controller node
> in it.
> - //
> - GopDevicePath = EfiBootManagerGetGopDevicePath
> (GraphicsControllerHandle);
> - if (GopDevicePath != NULL) {
> - EfiBootManagerUpdateConsoleVariable (ConsoleType,
> GopDevicePath, NULL);
> - }
> - }
> - break;
> - default:
> - ASSERT(FALSE);
> - break;
> - }
> -
> - FreePool (Instance);
> - } while (TempDevicePath != NULL);
> -}
> -
> -/**
> - The function connects the trusted consoles.
> **/
> VOID
> -ConnectTrustedConsole (
> +EFIAPI
> +BdsSignalEventBeforeConsoleAfterTrustedConsole (
> VOID
> )
> {
> - EFI_DEVICE_PATH_PROTOCOL *Consoles;
> - EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
> - EFI_DEVICE_PATH_PROTOCOL *Instance;
> - EFI_DEVICE_PATH_PROTOCOL *Next;
> - UINTN Size;
> - UINTN Index;
> - EFI_HANDLE Handle;
> - EFI_STATUS Status;
> - CHAR16 *ConsoleVar[] = {L"ConIn",
> L"ConOut"};
> - VOID *TrustedConsoleDevicepath;
> + EFI_STATUS Status;
> + EFI_EVENT BdsConsoleEvent;
>
> - TrustedConsoleDevicepath = PcdGetPtr
> (PcdTrustedConsoleInputDevicePath);
> - DumpDevicePath (L"TrustedConsoleIn", TrustedConsoleDevicepath);
> - TrustedConsoleDevicepath = PcdGetPtr
> (PcdTrustedConsoleOutputDevicePath);
> - DumpDevicePath (L"TrustedConsoleOut", TrustedConsoleDevicepath);
> + DEBUG ((DEBUG_INFO, "%a \n", __FUNCTION__));
>
> - for (Index = 0; Index < sizeof (ConsoleVar) / sizeof (ConsoleVar[0]);
> Index++) {
> -
> - GetEfiGlobalVariable2 (ConsoleVar[Index], (VOID **)&Consoles, NULL);
> + Status = CreateBdsEvent (
> + TPL_CALLBACK,
> + &gBdsEventBeforeConsoleAfterTrustedConsoleGuid,
> + &BdsConsoleEvent
> + );
>
> - TempDevicePath = Consoles;
> - do {
> - Instance = GetNextDevicePathInstance (&TempDevicePath, &Size);
> - if (Instance == NULL) {
> - break;
> - }
> - if (IsTrustedConsole (Index, Instance)) {
> - if (IsUsbShortForm (Instance)) {
> - ConnectUsbShortFormDevicePath (Instance);
> - } else {
> - for (Next = Instance; !IsDevicePathEnd (Next); Next =
> NextDevicePathNode (Next)) {
> - if (DevicePathType (Next) == ACPI_DEVICE_PATH &&
> DevicePathSubType (Next) == ACPI_ADR_DP) {
> - break;
> - } else if (DevicePathType (Next) == HARDWARE_DEVICE_PATH
> &&
> - DevicePathSubType (Next) ==
> HW_CONTROLLER_DP &&
> - DevicePathType (NextDevicePathNode (Next)) ==
> ACPI_DEVICE_PATH &&
> - DevicePathSubType (NextDevicePathNode (Next))
> == ACPI_ADR_DP
> - ) {
> - break;
> - }
> - }
> - if (!IsDevicePathEnd (Next)) {
> - SetDevicePathEndNode (Next);
> - Status = EfiBootManagerConnectDevicePath (Instance,
> &Handle);
> - if (!EFI_ERROR (Status)) {
> - gBS->ConnectController (Handle, NULL, NULL, TRUE);
> - }
> - } else {
> - EfiBootManagerConnectDevicePath (Instance, NULL);
> - }
> - }
> - }
> - FreePool (Instance);
> - } while (TempDevicePath != NULL);
> + ASSERT_EFI_ERROR (Status);
>
> - if (Consoles != NULL) {
> - FreePool (Consoles);
> - }
> + if (!EFI_ERROR (Status)) {
> + gBS->SignalEvent (BdsConsoleEvent);
> + gBS->CloseEvent (BdsConsoleEvent);
> + DEBUG ((DEBUG_INFO,"All EventBeforeConsoleAfterTrustedConsole
> callbacks have returned successfully\n"));
> }
> }
>
> -/**
> - The function connects the trusted Storages.
> -**/
> -VOID
> -ConnectTrustedStorage (
> - VOID
> - )
> -{
> - VOID *TrustedStorageDevicepath;
> - EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
> - EFI_DEVICE_PATH_PROTOCOL *Instance;
> - UINTN Size;
> - EFI_DEVICE_PATH_PROTOCOL *TempStorageDevicePath;
> - EFI_STATUS Status;
> - EFI_HANDLE DeviceHandle;
> -
> - TrustedStorageDevicepath = PcdGetPtr (PcdTrustedStorageDevicePath);
> - DumpDevicePath (L"TrustedStorage", TrustedStorageDevicepath);
> -
> - TempDevicePath = TrustedStorageDevicepath;
> - do {
> - Instance = GetNextDevicePathInstance (&TempDevicePath, &Size);
> - if (Instance == NULL) {
> - break;
> - }
> -
> - EfiBootManagerConnectDevicePath (Instance, NULL);
> -
> - TempStorageDevicePath = Instance;
> -
> - Status = gBS->LocateDevicePath (
> - &gEfiDevicePathProtocolGuid,
> - &TempStorageDevicePath,
> - &DeviceHandle
> - );
> - if (!EFI_ERROR (Status)) {
> - gBS->ConnectController (DeviceHandle, NULL, NULL, FALSE);
> - }
> -
> - FreePool (Instance);
> - } while (TempDevicePath != NULL);
> -}
> -
> -/**
> - The function connects the trusted consoles and then call the PP
> processing library interface.
> -**/
> -VOID
> -ProcessTcgPp (
> - VOID
> - )
> -{
> - gPPRequireUIConfirm |= Tcg2PhysicalPresenceLibNeedUserConfirm();
> -
> - if (gPPRequireUIConfirm) {
> - ConnectTrustedConsole ();
> - }
> -
> - Tcg2PhysicalPresenceLibProcessRequest (NULL);
> -}
>
> /**
> - The function connects the trusted storage to perform TPerReset.
> + Create, Signal, and Close the Bds Before Console Before End Of Dxe
> + event using CreateBdsEvent().
> **/
> VOID
> -ProcessTcgMor (
> - VOID
> - )
> -{
> - if (IsMorBitSet ()) {
> - ConnectTrustedConsole();
> - ConnectTrustedStorage();
> - }
> -}
> -
> -/**
> - Check if current BootCurrent variable is internal shell boot option.
> -
> - @retval TRUE BootCurrent is internal shell.
> - @retval FALSE BootCurrent is not internal shell.
> -**/
> -BOOLEAN
> -BootCurrentIsInternalShell (
> +EFIAPI
> +BdsSignalEventBeforeConsoleBeforeEndOfDxe (
> VOID
> )
> {
> - UINTN VarSize;
> - UINT16 BootCurrent;
> - CHAR16 BootOptionName[16];
> - UINT8 *BootOption;
> - UINT8 *Ptr;
> - BOOLEAN Result;
> - EFI_STATUS Status;
> - EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
> - EFI_DEVICE_PATH_PROTOCOL *LastDeviceNode;
> - EFI_GUID *GuidPoint;
> -
> - BootOption = NULL;
> - Result = FALSE;
> -
> - //
> - // Get BootCurrent variable
> - //
> - VarSize = sizeof (UINT16);
> - Status = gRT->GetVariable (
> - L"BootCurrent",
> - &gEfiGlobalVariableGuid,
> - NULL,
> - &VarSize,
> - &BootCurrent
> - );
> - if (EFI_ERROR (Status)) {
> - return FALSE;
> - }
> + EFI_STATUS Status;
> + EFI_EVENT BdsConsoleEvent;
>
> - //
> - // Create boot option Bootxxxx from BootCurrent
> - //
> - UnicodeSPrint (BootOptionName, sizeof(BootOptionName), L"Boot%04X",
> BootCurrent);
> + DEBUG ((DEBUG_INFO, "%a \n", __FUNCTION__));
>
> - GetEfiGlobalVariable2 (BootOptionName, (VOID **) &BootOption,
> &VarSize);
> - if (BootOption == NULL || VarSize == 0) {
> - return FALSE;
> - }
> + Status = CreateBdsEvent (
> + TPL_CALLBACK,
> + &gBdsEventBeforeConsoleBeforeEndOfDxeGuid,
> + &BdsConsoleEvent
> + );
>
> - Ptr = BootOption;
> - Ptr += sizeof (UINT32);
> - Ptr += sizeof (UINT16);
> - Ptr += StrSize ((CHAR16 *) Ptr);
> - TempDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) Ptr;
> - LastDeviceNode = TempDevicePath;
> - while (!IsDevicePathEnd (TempDevicePath)) {
> - LastDeviceNode = TempDevicePath;
> - TempDevicePath = NextDevicePathNode (TempDevicePath);
> - }
> - GuidPoint = EfiGetNameGuidFromFwVolDevicePathNode (
> - (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)
> LastDeviceNode
> - );
> - if ((GuidPoint != NULL) &&
> - ((CompareGuid (GuidPoint, &gUefiShellFileGuid)))
> - ) {
> - //
> - // if this option is internal shell, return TRUE
> - //
> - Result = TRUE;
> - }
> + ASSERT_EFI_ERROR (Status);
>
> - if (BootOption != NULL) {
> - FreePool (BootOption);
> - BootOption = NULL;
> + if (!EFI_ERROR (Status)) {
> + gBS->SignalEvent (BdsConsoleEvent);
> + gBS->CloseEvent (BdsConsoleEvent);
> + DEBUG ((DEBUG_INFO,"All BeforeConsoleBeforeEndOfDxe callbacks
> have returned successfully\n"));
> }
> -
> - return Result;
> }
>
> /**
> - This function will change video resolution and text mode
> - for internl shell when internal shell is launched.
> -
> - @param None.
> -
> - @retval EFI_SUCCESS Mode is changed successfully.
> - @retval Others Mode failed to changed.
> + Create, Signal, and Close the Bds After Console Ready Before Boot
> Option
> + using CreateBdsEvent().
> **/
> -EFI_STATUS
> +VOID
> EFIAPI
> -ChangeModeForInternalShell (
> +BdsSignalEventAfterConsoleReadyBeforeBootOption (
> VOID
> )
> {
> - EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
> - EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;
> - UINTN SizeOfInfo;
> - EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
> - UINT32 MaxGopMode;
> - UINT32 MaxTextMode;
> - UINT32 ModeNumber;
> - UINTN HandleCount;
> - EFI_HANDLE *HandleBuffer;
> - EFI_STATUS Status;
> - UINTN Index;
> - UINTN CurrentColumn;
> - UINTN CurrentRow;
> -
> - Status = gBS->HandleProtocol (
> - gST->ConsoleOutHandle,
> - &gEfiGraphicsOutputProtocolGuid,
> - (VOID**)&GraphicsOutput
> - );
> - if (EFI_ERROR (Status)) {
> - GraphicsOutput = NULL;
> - }
> -
> - Status = gBS->HandleProtocol (
> - gST->ConsoleOutHandle,
> - &gEfiSimpleTextOutProtocolGuid,
> - (VOID**)&SimpleTextOut
> - );
> - if (EFI_ERROR (Status)) {
> - SimpleTextOut = NULL;
> - }
> + EFI_STATUS Status;
> + EFI_EVENT BdsConsoleEvent;
>
> - if ((GraphicsOutput == NULL) || (SimpleTextOut == NULL)) {
> - return EFI_UNSUPPORTED;
> - }
> -
> - MaxGopMode = GraphicsOutput->Mode->MaxMode;
> - MaxTextMode = SimpleTextOut->Mode->MaxMode;
> -
> - //
> - // 1. If current video resolution is same with new video resolution,
> - // video resolution need not be changed.
> - // 1.1. If current text mode is same with new text mode, text mode
> need not be change.
> - // 1.2. If current text mode is different with new text mode, text
> mode need be change to new text mode.
> - // 2. If current video resolution is different with new video resolution, we
> need restart whole console drivers.
> - //
> - for (ModeNumber = 0; ModeNumber < MaxGopMode; ModeNumber++) {
> - Status = GraphicsOutput->QueryMode (
> - GraphicsOutput,
> - ModeNumber,
> - &SizeOfInfo,
> - &Info
> - );
> - if (!EFI_ERROR (Status)) {
> - if ((Info->HorizontalResolution == mShellHorizontalResolution) &&
> - (Info->VerticalResolution == mShellVerticalResolution)) {
> - if ((GraphicsOutput->Mode->Info->HorizontalResolution ==
> mShellHorizontalResolution) &&
> - (GraphicsOutput->Mode->Info->VerticalResolution ==
> mShellVerticalResolution)) {
> - //
> - // If current video resolution is same with new resolution,
> - // then check if current text mode is same with new text mode.
> - //
> - Status = SimpleTextOut->QueryMode (SimpleTextOut,
> SimpleTextOut->Mode->Mode, &CurrentColumn, &CurrentRow);
> - ASSERT_EFI_ERROR (Status);
> - if (CurrentColumn == mShellModeColumn && CurrentRow ==
> mShellModeRow) {
> - //
> - // Current text mode is same with new text mode, text mode
> need not be change.
> - //
> - FreePool (Info);
> - return EFI_SUCCESS;
> - } else {
> - //
> - // Current text mode is different with new text mode, text
> mode need be change to new text mode.
> - //
> - for (Index = 0; Index < MaxTextMode; Index++) {
> - Status = SimpleTextOut->QueryMode (SimpleTextOut, Index,
> &CurrentColumn, &CurrentRow);
> - if (!EFI_ERROR(Status)) {
> - if ((CurrentColumn == mShellModeColumn) &&
> (CurrentRow == mShellModeRow)) {
> - //
> - // New text mode is supported, set it.
> - //
> - Status = SimpleTextOut->SetMode (SimpleTextOut,
> Index);
> - ASSERT_EFI_ERROR (Status);
> - //
> - // Update text mode PCD.
> - //
> - Status = PcdSet32S (PcdConOutColumn,
> mShellModeColumn);
> - ASSERT_EFI_ERROR (Status);
> + DEBUG ((DEBUG_INFO, "%a \n", __FUNCTION__));
>
> - Status = PcdSet32S (PcdConOutRow, mShellModeRow);
> - ASSERT_EFI_ERROR (Status);
> -
> - FreePool (Info);
> - return EFI_SUCCESS;
> - }
> - }
> - }
> - if (Index == MaxTextMode) {
> - //
> - // If new text mode is not supported, return error.
> - //
> - FreePool (Info);
> - return EFI_UNSUPPORTED;
> - }
> - }
> - } else {
> - FreePool (Info);
> - //
> - // If current video resolution is not same with the new one, set
> new video resolution.
> - // In this case, the driver which produces simple text out need
> be restarted.
> - //
> - Status = GraphicsOutput->SetMode (GraphicsOutput,
> ModeNumber);
> - if (!EFI_ERROR (Status)) {
> - //
> - // Set PCD to restart GraphicsConsole and Consplitter to
> change video resolution
> - // and produce new text mode based on new resolution.
> - //
> - Status = PcdSet32S (PcdVideoHorizontalResolution,
> mShellHorizontalResolution);
> - ASSERT_EFI_ERROR (Status);
> -
> - Status = PcdSet32S (PcdVideoVerticalResolution,
> mShellVerticalResolution);
> - ASSERT_EFI_ERROR (Status);
> -
> - Status = PcdSet32S (PcdConOutColumn, mShellModeColumn);
> - ASSERT_EFI_ERROR (Status);
> -
> - Status = PcdSet32S (PcdConOutRow, mShellModeRow);
> - ASSERT_EFI_ERROR (Status);
> + Status = CreateBdsEvent (
> + TPL_CALLBACK,
> + &gBdsEventAfterConsoleReadyBeforeBootOptionGuid,
> + &BdsConsoleEvent
> + );
>
> - Status = gBS->LocateHandleBuffer (
> - ByProtocol,
> - &gEfiSimpleTextOutProtocolGuid,
> - NULL,
> - &HandleCount,
> - &HandleBuffer
> - );
> - if (!EFI_ERROR (Status)) {
> - for (Index = 0; Index < HandleCount; Index++) {
> - gBS->DisconnectController (HandleBuffer[Index], NULL,
> NULL);
> - }
> - for (Index = 0; Index < HandleCount; Index++) {
> - gBS->ConnectController (HandleBuffer[Index], NULL,
> NULL, TRUE);
> - }
> - if (HandleBuffer != NULL) {
> - FreePool (HandleBuffer);
> - }
> - break;
> - }
> - }
> - }
> - }
> - FreePool (Info);
> - }
> - }
> + ASSERT_EFI_ERROR (Status);
>
> - if (ModeNumber == MaxGopMode) {
> - //
> - // If the new resolution is not supported, return error.
> - //
> - return EFI_UNSUPPORTED;
> + if (!EFI_ERROR (Status)) {
> + gBS->SignalEvent (BdsConsoleEvent);
> + gBS->CloseEvent (BdsConsoleEvent);
> + DEBUG ((DEBUG_INFO,"All AfterConsoleReadyBeforeBootOption
> callbacks have returned successfully\n"));
> }
> -
> - return EFI_SUCCESS;
> }
>
> -/**
> - ReadyToBoot callback to set video and text mode for internal shell boot.
> - That will not connect USB controller while CSM and FastBoot are
> disabled, we need to connect them
> - before booting to Shell for showing USB devices in Shell.
> -
> - When FastBoot is enabled and Windows Console is the chosen Console
> behavior, input devices will not be connected
> - by default. Hence, when booting to EFI shell, connecting input consoles
> are required.
> -
> - @param Event Pointer to this event
> - @param Context Event hanlder private data
> -
> - @retval None.
> -**/
> -VOID
> -EFIAPI
> -OnReadyToBootCallBack (
> - IN EFI_EVENT Event,
> - IN VOID *Context
> - )
> -{
> - DEBUG ((EFI_D_INFO, "OnReadyToBootCallBack\n"));
> -
> - if (BootCurrentIsInternalShell ()) {
> -
> - ChangeModeForInternalShell ();
> - EfiBootManagerConnectAllDefaultConsoles();
> - gDS->Dispatch ();
> - }
> -}
>
> /**
> Platform Bds init. Incude the platform firmware vendor, revision
> @@ -1095,149 +195,37 @@ PlatformBootManagerBeforeConsole (
> VOID
> )
> {
> - EFI_STATUS Status;
> - EFI_DEVICE_PATH_PROTOCOL *VarConOut;
> - EFI_DEVICE_PATH_PROTOCOL *VarConIn;
> - EFI_EVENT Event;
>
> DEBUG ((EFI_D_INFO, "PlatformBootManagerBeforeConsole\n"));
>
> - Status = EFI_SUCCESS;
> -
> - //
> - // Get user defined text mode for internal shell only once.
> - //
> - mShellHorizontalResolution = PcdGet32
> (PcdSetupVideoHorizontalResolution);
> - mShellVerticalResolution = PcdGet32
> (PcdSetupVideoVerticalResolution);
> - mShellModeColumn = PcdGet32 (PcdSetupConOutColumn);
> - mShellModeRow = PcdGet32 (PcdSetupConOutRow);
> -
> - //
> - // Create event to set proper video resolution and text mode for internal
> shell.
> - //
> - Status = EfiCreateEventReadyToBootEx (
> - TPL_CALLBACK,
> - OnReadyToBootCallBack,
> - NULL,
> - &Event
> - );
> - ASSERT_EFI_ERROR (Status);
> -
> - //
> - // Connect Root Bridge to make PCI BAR resource allocated and all PciIo
> created
> - //
> - ConnectRootBridge (FALSE);
> -
> //
> - // Fill ConIn/ConOut in Full Configuration boot mode
> + // Trusted console can be added in a PciEnumComplete callback
> //
> - DEBUG ((DEBUG_INFO, "PlatformBootManagerInit - %x\n", gBootMode));
> -
> - if (gBootMode == BOOT_WITH_FULL_CONFIGURATION ||
> - gBootMode == BOOT_WITH_DEFAULT_SETTINGS ||
> - gBootMode ==
> BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS ||
> - gBootMode == BOOT_IN_RECOVERY_MODE) {
> -
> - GetEfiGlobalVariable2 (L"ConOut", (VOID **)&VarConOut, NULL); if
> (VarConOut != NULL) { FreePool (VarConOut); }
> - GetEfiGlobalVariable2 (L"ConIn", (VOID **)&VarConIn, NULL); if
> (VarConIn != NULL) { FreePool (VarConIn); }
> -
> - //
> - // Only fill ConIn/ConOut when ConIn/ConOut is empty because we
> may drop to Full Configuration boot mode in non-first boot
> - //
> - if (VarConOut == NULL || VarConIn == NULL) {
> - if (PcdGetSize (PcdTrustedConsoleOutputDevicePath) >=
> sizeof(EFI_DEVICE_PATH_PROTOCOL)) {
> - AddConsoleVariable (ConOut, PcdGetPtr
> (PcdTrustedConsoleOutputDevicePath));
> - }
> - if (PcdGetSize (PcdTrustedConsoleInputDevicePath) >=
> sizeof(EFI_DEVICE_PATH_PROTOCOL)) {
> - AddConsoleVariable (ConIn, PcdGetPtr
> (PcdTrustedConsoleInputDevicePath));
> - }
> - }
> - }
>
> - EnumUsbKeyboard ();
> //
> - // For trusted console it must be handled here.
> + // Signal Before Console, after Trusted console Event
> //
> - UpdateGraphicConOut (TRUE);
> + BdsSignalEventBeforeConsoleAfterTrustedConsole ();
>
> //
> - // Dynamically register hot key: F2/F7/Enter
> + // Signal Before Console, before End of Dxe
> //
> - RegisterDefaultBootOption ();
> - RegisterStaticHotkey ();
> -
> - PERF_START_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7010);
> - if (PcdGetBool (PcdTpm2Enable)) {
> - ProcessTcgPp ();
> - ProcessTcgMor ();
> - }
> - PERF_END_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7011);
> + BdsSignalEventBeforeConsoleBeforeEndOfDxe ();
>
> //
> - // We should make all UEFI memory and GCD information populated
> before ExitPmAuth.
> - // SMM may consume these information.
> + // Signal End Of Dxe Event
> //
> - MemoryTest((EXTENDMEM_COVERAGE_LEVEL) PcdGet32
> (PcdPlatformMemoryCheckLevel));
> -
> PERF_START_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7020);
> ExitPmAuth ();
> PERF_END_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7021);
>
> //
> - // Dispatch the deferred 3rd party images.
> - //
> - EfiBootManagerDispatchDeferredImages ();
> -
> - //
> - // For non-trusted console it must be handled here.
> + // Deferred 3rd party images can be dispatched in
> + // an SmmReadyToLock callback
> //
> - UpdateGraphicConOut (FALSE);
> }
>
>
> -/**
> - Connect with predeined platform connect sequence,
> - the OEM/IBV can customize with their own connect sequence.
> -
> - @param[in] BootMode Boot mode of this boot.
> -**/
> -VOID
> -ConnectSequence (
> - IN EFI_BOOT_MODE BootMode
> - )
> -{
> - EfiBootManagerConnectAll ();
> -}
> -
> -/**
> - The function is to consider the boot order which is not in our
> expectation.
> - In the case that we need to re-sort the boot option.
> -
> - @retval TRUE Need to sort Boot Option.
> - @retval FALSE Don't need to sort Boot Option.
> -**/
> -BOOLEAN
> -IsNeedSortBootOption (
> - VOID
> - )
> -{
> - EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
> - UINTN BootOptionCount;
> -
> - BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount,
> LoadOptionTypeBoot);
> -
> - //
> - // If setup is the first priority in boot option, we need to sort boot
> option.
> - //
> - if ((BootOptionCount > 1) &&
> - (((StrnCmp (BootOptions->Description, L"Enter Setup", StrLen
> (L"Enter Setup"))) == 0) ||
> - ((StrnCmp (BootOptions->Description, L"BootManagerMenuApp",
> StrLen (L"BootManagerMenuApp"))) == 0))) {
> - return TRUE;
> - }
> -
> - return FALSE;
> -}
> -
> /**
> The function will excute with as the platform policy, current policy
> is driven by boot mode. IBV/OEM can customize this code for their
> specific
> @@ -1254,65 +242,9 @@ PlatformBootManagerAfterConsole (
> VOID
> )
> {
> - EFI_BOOT_MODE LocalBootMode;
> -
> DEBUG ((EFI_D_INFO, "PlatformBootManagerAfterConsole\n"));
>
> - //
> - // Get current Boot Mode
> - //
> - LocalBootMode = gBootMode;
> - DEBUG ((DEBUG_INFO, "Current local bootmode - %x\n",
> LocalBootMode));
> -
> - //
> - // Go the different platform policy with different boot mode
> - // Notes: this part code can be change with the table policy
> - //
> - switch (LocalBootMode) {
> -
> - case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:
> - case BOOT_WITH_MINIMAL_CONFIGURATION:
> - case BOOT_ON_S4_RESUME:
> - //
> - // Perform some platform specific connect sequence
> - //
> - PERF_START_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7050);
> - ConnectSequence (LocalBootMode);
> - PERF_END_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7051);
> -
> - break;
> -
> - case BOOT_WITH_FULL_CONFIGURATION:
> - case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:
> - case BOOT_WITH_DEFAULT_SETTINGS:
> - default:
> - //
> - // Perform some platform specific connect sequence
> - //
> - ConnectSequence (LocalBootMode);
> -
> - //
> - // Only in Full Configuration boot mode we do the enumeration of
> boot device
> - //
> - //
> - // Dispatch all but Storage Oprom explicitly, because we assume
> Int13Thunk driver is there.
> - //
> - EfiBootManagerRefreshAllBootOption ();
> -
> - if (IsNeedSortBootOption()) {
> - EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot,
> CompareBootOption);
> - }
> - //
> - // PXE boot option may appear after boot option enumeration
> - //
> -
> - break;
> - }
> -
> - Print (L"Press F7 for BootMenu!\n");
> -
> - EfiBootManagerRefreshAllBootOption ();
> - EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot,
> CompareBootOption);
> + BdsSignalEventAfterConsoleReadyBeforeBootOption ();
> }
>
> /**
> @@ -1328,19 +260,19 @@ PlatformBootManagerUnableToBoot (
> VOID
> )
> {
> - EFI_STATUS Status;
> - EFI_BOOT_MANAGER_LOAD_OPTION BootDeviceList;
> - CHAR16 OptionName[sizeof ("Boot####")];
> + BoardBootManagerUnableToBoot ();
> +}
>
> - if (mBootMenuOptionNumber == LoadOptionNumberUnassigned) {
> - return;
> - }
> - UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x",
> mBootMenuOptionNumber);
> - Status = EfiBootManagerVariableToLoadOption (OptionName,
> &BootDeviceList);
> - if (EFI_ERROR (Status)) {
> - return;
> - }
> - for (;;) {
> - EfiBootManagerBoot (&BootDeviceList);
> - }
> +/**
> + This function is called each second during the boot manager waits the
> timeout.
> +
> + @param TimeoutRemain The remaining timeout.
> +**/
> +VOID
> +EFIAPI
> +PlatformBootManagerWaitCallback (
> + UINT16 TimeoutRemain
> + )
> +{
> + BoardBootManagerWaitCallback (TimeoutRemain);
> }
> diff --git
> a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/
> BdsPlatform.h
> b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/
> BdsPlatform.h
> index 360a00d7d7..031676cdc3 100644
> ---
> a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/
> BdsPlatform.h
> +++
> b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/
> BdsPlatform.h
> @@ -1,7 +1,7 @@
> /** @file
> Header file for BDS Platform specific code
>
> -Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
> **/
> @@ -9,176 +9,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> #ifndef _BDS_PLATFORM_H
> #define _BDS_PLATFORM_H
>
> -#include <PiDxe.h>
> -#include <Protocol/DevicePath.h>
> -#include <Protocol/SimpleNetwork.h>
> -#include <Protocol/PciRootBridgeIo.h>
> -#include <Protocol/LoadFile.h>
> -#include <Protocol/PciIo.h>
> -#include <Protocol/CpuIo2.h>
> -#include <Protocol/LoadedImage.h>
> -#include <Protocol/DiskInfo.h>
> -#include <Protocol/GraphicsOutput.h>
> -#include <Protocol/UgaDraw.h>
> -#include <Protocol/GenericMemoryTest.h>
> -#include <Protocol/DevicePathToText.h>
> -#include <Protocol/FirmwareVolume2.h>
> -#include <Protocol/SimpleFileSystem.h>
> -
> -#include <Guid/CapsuleVendor.h>
> -#include <Guid/MemoryTypeInformation.h>
> -#include <Guid/GlobalVariable.h>
> -#include <Guid/MemoryOverwriteControl.h>
> -#include <Guid/FileInfo.h>
> -#include <Library/DebugLib.h>
> -#include <Library/BaseMemoryLib.h>
> -#include <Library/UefiBootServicesTableLib.h>
> -#include <Library/UefiRuntimeServicesTableLib.h>
> -#include <Library/MemoryAllocationLib.h>
> -#include <Library/BaseLib.h>
> -#include <Library/PcdLib.h>
> -#include <Library/PlatformBootManagerLib.h>
> -#include <Library/DevicePathLib.h>
> -#include <Library/UefiLib.h>
> -#include <Library/HobLib.h>
> -#include <Library/DxeServicesLib.h>
> -#include <Library/DxeServicesTableLib.h>
> -#include <Library/PrintLib.h>
> -#include <Library/HiiLib.h>
> -#include <Library/CapsuleLib.h>
> -#include <Library/PerformanceLib.h>
> -
> -#include <IndustryStandard/Pci30.h>
> -#include <IndustryStandard/PciCodeId.h>
> -
> -///
> -/// ConnectType
> -///
> -#define CONSOLE_OUT 0x00000001
> -#define STD_ERROR 0x00000002
> -#define CONSOLE_IN 0x00000004
> -#define CONSOLE_ALL (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)
> -
> -extern EFI_GUID gUefiShellFileGuid;
> -extern EFI_BOOT_MODE gBootMode;
> -
> -#define gPciRootBridge \
> - { \
> - { \
> - ACPI_DEVICE_PATH, \
> - ACPI_DP, \
> - { \
> - (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \
> - (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \
> - }, \
> - }, \
> - EISA_PNP_ID (0x0A03), \
> - 0 \
> - }
> -
> -#define gEndEntire \
> - { \
> - END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE,
> { END_DEVICE_PATH_LENGTH, 0 } \
> - }
> -
> -typedef struct {
> - EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> - UINTN ConnectType;
> -} BDS_CONSOLE_CONNECT_ENTRY;
> -
> -//
> -// Platform Root Bridge
> -//
> -typedef struct {
> - ACPI_HID_DEVICE_PATH PciRootBridge;
> - EFI_DEVICE_PATH_PROTOCOL End;
> -} PLATFORM_ROOT_BRIDGE_DEVICE_PATH;
> -
> -//
> -// Below is the platform console device path
> -//
> -typedef struct {
> - ACPI_HID_DEVICE_PATH PciRootBridge;
> - PCI_DEVICE_PATH IsaBridge;
> - ACPI_HID_DEVICE_PATH Keyboard;
> - EFI_DEVICE_PATH_PROTOCOL End;
> -} PLATFORM_KEYBOARD_DEVICE_PATH;
> -
> -typedef struct {
> - ACPI_HID_DEVICE_PATH PciRootBridge;
> - PCI_DEVICE_PATH PciDevice;
> - EFI_DEVICE_PATH_PROTOCOL End;
> -} PLATFORM_ONBOARD_CONTROLLER_DEVICE_PATH;
> -
> -typedef struct {
> - ACPI_HID_DEVICE_PATH PciRootBridge;
> - PCI_DEVICE_PATH Pci0Device;
> - EFI_DEVICE_PATH_PROTOCOL End;
> -} PLATFORM_PEG_ROOT_CONTROLLER_DEVICE_PATH;
> -
> -typedef struct {
> - ACPI_HID_DEVICE_PATH PciRootBridge;
> - PCI_DEVICE_PATH PciBridge;
> - PCI_DEVICE_PATH PciDevice;
> - EFI_DEVICE_PATH_PROTOCOL End;
> -} PLATFORM_PCI_CONTROLLER_DEVICE_PATH;
> -
> -//
> -// Below is the boot option device path
> -//
> -
> -#define CLASS_HID 3
> -#define SUBCLASS_BOOT 1
> -#define PROTOCOL_KEYBOARD 1
> -
> -typedef struct {
> - USB_CLASS_DEVICE_PATH UsbClass;
> - EFI_DEVICE_PATH_PROTOCOL End;
> -} USB_CLASS_FORMAT_DEVICE_PATH;
> -
> -extern USB_CLASS_FORMAT_DEVICE_PATH
> gUsbClassKeyboardDevicePath;
> -
> -//
> -// Platform BDS Functions
> -//
> -
> -
> -/**
> - Perform the memory test base on the memory test intensive level,
> - and update the memory resource.
> -
> - @param Level The memory test intensive level.
> -
> - @retval EFI_STATUS Success test all the system memory and update
> - the memory resource
> -
> -**/
> -EFI_STATUS
> -MemoryTest (
> - IN EXTENDMEM_COVERAGE_LEVEL Level
> - );
> -
> -VOID
> -ConnectSequence (
> - IN EFI_BOOT_MODE BootMode
> - );
> -
> -
> -INTN
> -EFIAPI
> -CompareBootOption (
> - CONST VOID *Left,
> - CONST VOID *Right
> - );
> -
> -
> -VOID
> -RegisterStaticHotkey (
> - VOID
> - );
> -VOID
> -RegisterDefaultBootOption (
> - VOID
> - );
> + #include <Library/DebugLib.h>
> + #include <Library/UefiBootServicesTableLib.h>
> + #include <Library/PlatformBootManagerLib.h>
> + #include <Library/UefiLib.h>
> + #include <Library/HobLib.h>
> + #include <Library/PrintLib.h>
> + #include <Library/PerformanceLib.h>
> + #include <Library/BoardBootManagerLib.h>
>
> #endif
> diff --git
> a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/
> DxePlatformBootManagerLib.inf
> b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/
> DxePlatformBootManagerLib.inf
> index 388ffd808b..4f7299f1df 100644
> ---
> a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/
> DxePlatformBootManagerLib.inf
> +++
> b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/
> DxePlatformBootManagerLib.inf
> @@ -23,23 +23,13 @@
>
> [LibraryClasses]
> BaseLib
> - MemoryAllocationLib
> UefiBootServicesTableLib
> - UefiRuntimeServicesTableLib
> - BaseMemoryLib
> DebugLib
> - PcdLib
> - PrintLib
> - DevicePathLib
> UefiLib
> HobLib
> - DxeServicesLib
> - DxeServicesTableLib
> - HiiLib
> UefiBootManagerLib
> PerformanceLib
> - TimerLib
> - Tcg2PhysicalPresenceLib
> + BoardBootManagerLib
>
> [Packages]
> MdePkg/MdePkg.dec
> @@ -47,47 +37,18 @@
> SecurityPkg/SecurityPkg.dec
> MinPlatformPkg/MinPlatformPkg.dec
>
> -[Pcd]
> - gMinPlatformPkgTokenSpaceGuid.PcdTpm2Enable
> ## CONSUMES
> - gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
> ## PRODUCES
> - gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution
> ## PRODUCES
> - gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution
> ## PRODUCES
> - gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow
> ## PRODUCES
> - gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn
> ## PRODUCES
> - gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutColumn
> ## CONSUMES
> - gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutRow
> ## CONSUMES
> - gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution
> ## CONSUMES
> - gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution
> ## CONSUMES
> - gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand
> ## PRODUCES
> - gMinPlatformPkgTokenSpaceGuid.PcdPlatformMemoryCheckLevel
> ## CONSUMES
> - gMinPlatformPkgTokenSpaceGuid.PcdBootToShellOnly
> ## CONSUMES
> - gMinPlatformPkgTokenSpaceGuid.PcdTrustedConsoleInputDevicePath
> ## CONSUMES
> - gMinPlatformPkgTokenSpaceGuid.PcdTrustedConsoleOutputDevicePath
> ## CONSUMES
> - gMinPlatformPkgTokenSpaceGuid.PcdTrustedStorageDevicePath
> ## CONSUMES
> -
> [Sources]
> BdsPlatform.c
> BdsPlatform.h
> - PlatformBootOption.c
> - MemoryTest.c
>
> [Protocols]
> - gEfiPciRootBridgeIoProtocolGuid ## CONSUMES
> - gEfiPciIoProtocolGuid ## CONSUMES
> - gEfiCpuIo2ProtocolGuid ## CONSUMES
> - gEfiDxeSmmReadyToLockProtocolGuid ## PRODUCES
> - gEfiGenericMemTestProtocolGuid ## CONSUMES
> - gEfiDiskInfoProtocolGuid ## CONSUMES
> - gEfiDevicePathToTextProtocolGuid ## CONSUMES
> - gEfiSimpleTextInputExProtocolGuid ## CONSUMES
> - gEfiFirmwareVolume2ProtocolGuid ## CONSUMES
> - gEfiFormBrowser2ProtocolGuid ## CONSUMES
> - gEfiGenericMemTestProtocolGuid ## CONSUMES
> + gEfiDxeSmmReadyToLockProtocolGuid ## PRODUCES
>
> [Guids]
> - gEfiGlobalVariableGuid ## PRODUCES
> - gEfiMemoryOverwriteControlDataGuid ## PRODUCES
> - gEfiEndOfDxeEventGroupGuid ## CONSUMES
> + gEfiEndOfDxeEventGroupGuid ## CONSUMES
> + gBdsEventBeforeConsoleAfterTrustedConsoleGuid
> + gBdsEventBeforeConsoleBeforeEndOfDxeGuid
> + gBdsEventAfterConsoleReadyBeforeBootOptionGuid
>
> [Depex.common.DXE_DRIVER]
> gEfiVariableArchProtocolGuid
> diff --git
> a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/
> MemoryTest.c
> b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/
> MemoryTest.c
> deleted file mode 100644
> index 654845349a..0000000000
> ---
> a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/
> MemoryTest.c
> +++ /dev/null
> @@ -1,83 +0,0 @@
> -/** @file
> - Perform the platform memory test
> -
> -Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
> -SPDX-License-Identifier: BSD-2-Clause-Patent
> -
> -**/
> -
> -#include "BdsPlatform.h"
> -#include <Protocol/GenericMemoryTest.h>
> -
> -/**
> - Perform the memory test base on the memory test intensive level,
> - and update the memory resource.
> -
> - @param Level The memory test intensive level.
> -
> - @retval EFI_STATUS Success test all the system memory and update
> - the memory resource
> -
> -**/
> -EFI_STATUS
> -MemoryTest (
> - IN EXTENDMEM_COVERAGE_LEVEL Level
> - )
> -{
> - EFI_STATUS Status;
> - BOOLEAN RequireSoftECCInit;
> - EFI_GENERIC_MEMORY_TEST_PROTOCOL *GenMemoryTest;
> - UINT64 TestedMemorySize;
> - UINT64 TotalMemorySize;
> - BOOLEAN ErrorOut;
> - BOOLEAN TestAbort;
> -
> - TestedMemorySize = 0;
> - TotalMemorySize = 0;
> - ErrorOut = FALSE;
> - TestAbort = FALSE;
> -
> - RequireSoftECCInit = FALSE;
> -
> - Status = gBS->LocateProtocol (
> - &gEfiGenericMemTestProtocolGuid,
> - NULL,
> - (VOID **) &GenMemoryTest
> - );
> - if (EFI_ERROR (Status)) {
> - return EFI_SUCCESS;
> - }
> -
> - Status = GenMemoryTest->MemoryTestInit (
> - GenMemoryTest,
> - Level,
> - &RequireSoftECCInit
> - );
> - if (Status == EFI_NO_MEDIA) {
> - //
> - // The PEI codes also have the relevant memory test code to check the
> memory,
> - // it can select to test some range of the memory or all of them. If PEI
> code
> - // checks all the memory, this BDS memory test will has no not-test
> memory to
> - // do the test, and then the status of EFI_NO_MEDIA will be returned
> by
> - // "MemoryTestInit". So it does not need to test memory again, just
> return.
> - //
> - return EFI_SUCCESS;
> - }
> -
> - do {
> - Status = GenMemoryTest->PerformMemoryTest (
> - GenMemoryTest,
> - &TestedMemorySize,
> - &TotalMemorySize,
> - &ErrorOut,
> - TestAbort
> - );
> - if (ErrorOut && (Status == EFI_DEVICE_ERROR)) {
> - ASSERT (0);
> - }
> - } while (Status != EFI_NOT_FOUND);
> -
> - Status = GenMemoryTest->Finished (GenMemoryTest);
> -
> - return EFI_SUCCESS;
> -}
> diff --git
> a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/
> PlatformBootOption.c
> b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/
> PlatformBootOption.c
> deleted file mode 100644
> index 84aa097d58..0000000000
> ---
> a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/
> PlatformBootOption.c
> +++ /dev/null
> @@ -1,559 +0,0 @@
> -/** @file
> - Driver for Platform Boot Options support.
> -
> -Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
> -SPDX-License-Identifier: BSD-2-Clause-Patent
> -
> -**/
> -
> -#include "BdsPlatform.h"
> -
> -#include <Library/PcdLib.h>
> -
> -BOOLEAN mContinueBoot = FALSE;
> -BOOLEAN mBootMenuBoot = FALSE;
> -BOOLEAN mPxeBoot = FALSE;
> -BOOLEAN mHotKeypressed = FALSE;
> -EFI_EVENT HotKeyEvent = NULL;
> -
> -UINTN mBootMenuOptionNumber;
> -
> -EFI_DEVICE_PATH_PROTOCOL *
> -BdsCreateShellDevicePath (
> - VOID
> - )
> -/*++
> -
> -Routine Description:
> -
> - This function will create a SHELL BootOption to boot.
> -
> -Arguments:
> -
> - None.
> -
> -Returns:
> -
> - Shell Device path for booting.
> -
> ---*/
> -{
> - UINTN FvHandleCount;
> - EFI_HANDLE *FvHandleBuffer;
> - UINTN Index;
> - EFI_STATUS Status;
> - EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
> - UINTN Size;
> - UINT32 AuthenticationStatus;
> - EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> - VOID *Buffer;
> -
> - DevicePath = NULL;
> - Status = EFI_SUCCESS;
> -
> - DEBUG ((DEBUG_INFO, "BdsCreateShellDevicePath\n"));
> - gBS->LocateHandleBuffer (
> - ByProtocol,
> - &gEfiFirmwareVolume2ProtocolGuid,
> - NULL,
> - &FvHandleCount,
> - &FvHandleBuffer
> - );
> -
> - for (Index = 0; Index < FvHandleCount; Index++) {
> - gBS->HandleProtocol (
> - FvHandleBuffer[Index],
> - &gEfiFirmwareVolume2ProtocolGuid,
> - (VOID **) &Fv
> - );
> -
> - Buffer = NULL;
> - Size = 0;
> - Status = Fv->ReadSection (
> - Fv,
> - &gUefiShellFileGuid,
> - EFI_SECTION_PE32,
> - 0,
> - &Buffer,
> - &Size,
> - &AuthenticationStatus
> - );
> - if (EFI_ERROR (Status)) {
> - //
> - // Skip if no shell file in the FV
> - //
> - continue;
> - } else {
> - //
> - // Found the shell
> - //
> - break;
> - }
> - }
> -
> - if (EFI_ERROR (Status)) {
> - //
> - // No shell present
> - //
> - if (FvHandleCount) {
> - FreePool (FvHandleBuffer);
> - }
> - return NULL;
> - }
> - //
> - // Build the shell boot option
> - //
> - DevicePath = DevicePathFromHandle (FvHandleBuffer[Index]);
> -
> - if (FvHandleCount) {
> - FreePool (FvHandleBuffer);
> - }
> -
> - return DevicePath;
> -}
> -
> -
> -EFI_STATUS
> -CreateFvBootOption (
> - EFI_GUID *FileGuid,
> - CHAR16 *Description,
> - EFI_BOOT_MANAGER_LOAD_OPTION *BootOption,
> - UINT32 Attributes,
> - UINT8 *OptionalData, OPTIONAL
> - UINT32 OptionalDataSize
> - )
> -{
> - EFI_STATUS Status;
> - EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> - EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
> - MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
> - EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
> - UINT32 AuthenticationStatus;
> - VOID *Buffer;
> - UINTN Size;
> -
> - if ((BootOption == NULL) || (FileGuid == NULL) || (Description == NULL)) {
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);
> -
> - if (!CompareGuid (&gUefiShellFileGuid, FileGuid)) {
> - Status = gBS->HandleProtocol (
> - gImageHandle,
> - &gEfiLoadedImageProtocolGuid,
> - (VOID **) &LoadedImage
> - );
> - if (!EFI_ERROR (Status)) {
> - Status = gBS->HandleProtocol (
> - LoadedImage->DeviceHandle,
> - &gEfiFirmwareVolume2ProtocolGuid,
> - (VOID **) &Fv
> - );
> - if (!EFI_ERROR (Status)) {
> - Buffer = NULL;
> - Size = 0;
> - Status = Fv->ReadSection (
> - Fv,
> - FileGuid,
> - EFI_SECTION_PE32,
> - 0,
> - &Buffer,
> - &Size,
> - &AuthenticationStatus
> - );
> - if (Buffer != NULL) {
> - FreePool (Buffer);
> - }
> - }
> - }
> - if (EFI_ERROR (Status)) {
> - return EFI_NOT_FOUND;
> - }
> -
> - DevicePath = AppendDevicePathNode (
> - DevicePathFromHandle
> (LoadedImage->DeviceHandle),
> - (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
> - );
> - } else {
> - DevicePath = AppendDevicePathNode (
> - BdsCreateShellDevicePath (),
> - (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
> - );
> - }
> -
> - Status = EfiBootManagerInitializeLoadOption (
> - BootOption,
> - LoadOptionNumberUnassigned,
> - LoadOptionTypeBoot,
> - Attributes,
> - Description,
> - DevicePath,
> - OptionalData,
> - OptionalDataSize
> - );
> - FreePool (DevicePath);
> - return Status;
> -}
> -
> -EFI_GUID mUiFile = {
> - 0x462CAA21, 0x7614, 0x4503, { 0x83, 0x6E, 0x8A, 0xB6, 0xF4, 0x66, 0x23,
> 0x31 }
> -};
> -EFI_GUID mBootMenuFile = {
> - 0xEEC25BDC, 0x67F2, 0x4D95, { 0xB1, 0xD5, 0xF8, 0x1B, 0x20, 0x39, 0xD1,
> 0x1D }
> -};
> -
> -
> -/**
> - Return the index of the load option in the load option array.
> -
> - The function consider two load options are equal when the
> - OptionType, Attributes, Description, FilePath and OptionalData are equal.
> -
> - @param Key Pointer to the load option to be found.
> - @param Array Pointer to the array of load options to be found.
> - @param Count Number of entries in the Array.
> -
> - @retval -1 Key wasn't found in the Array.
> - @retval 0 ~ Count-1 The index of the Key in the Array.
> -**/
> -INTN
> -PlatformFindLoadOption (
> - IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Key,
> - IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Array,
> - IN UINTN Count
> - )
> -{
> - UINTN Index;
> -
> - for (Index = 0; Index < Count; Index++) {
> - if ((Key->OptionType == Array[Index].OptionType) &&
> - (Key->Attributes == Array[Index].Attributes) &&
> - (StrCmp (Key->Description, Array[Index].Description) == 0) &&
> - (CompareMem (Key->FilePath, Array[Index].FilePath,
> GetDevicePathSize (Key->FilePath)) == 0) &&
> - (Key->OptionalDataSize == Array[Index].OptionalDataSize) &&
> - (CompareMem (Key->OptionalData, Array[Index].OptionalData,
> Key->OptionalDataSize) == 0)) {
> - return (INTN) Index;
> - }
> - }
> -
> - return -1;
> -}
> -
> -UINTN
> -RegisterFvBootOption (
> - EFI_GUID *FileGuid,
> - CHAR16 *Description,
> - UINTN Position,
> - UINT32 Attributes,
> - UINT8 *OptionalData, OPTIONAL
> - UINT32 OptionalDataSize
> - )
> -{
> - EFI_STATUS Status;
> - UINTN OptionIndex;
> - EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
> - EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
> - UINTN BootOptionCount;
> -
> - NewOption.OptionNumber = LoadOptionNumberUnassigned;
> - Status = CreateFvBootOption (FileGuid, Description, &NewOption,
> Attributes, OptionalData, OptionalDataSize);
> - if (!EFI_ERROR (Status)) {
> - BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount,
> LoadOptionTypeBoot);
> -
> - OptionIndex = PlatformFindLoadOption (&NewOption, BootOptions,
> BootOptionCount);
> -
> - if (OptionIndex == -1) {
> - Status = EfiBootManagerAddLoadOptionVariable (&NewOption,
> Position);
> - ASSERT_EFI_ERROR (Status);
> - } else {
> - NewOption.OptionNumber =
> BootOptions[OptionIndex].OptionNumber;
> - }
> - EfiBootManagerFreeLoadOption (&NewOption);
> - EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
> - }
> -
> - return NewOption.OptionNumber;
> -}
> -
> -
> -
> -VOID
> -EFIAPI
> -PlatformBootManagerWaitCallback (
> - UINT16 TimeoutRemain
> - )
> -{
> - EFI_STATUS Status;
> - EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TxtInEx;
> - EFI_KEY_DATA KeyData;
> - BOOLEAN PausePressed;
> -
> - //
> - // Pause on PAUSE key
> - //
> - Status = gBS->HandleProtocol (gST->ConsoleInHandle,
> &gEfiSimpleTextInputExProtocolGuid, (VOID **) &TxtInEx);
> - ASSERT_EFI_ERROR (Status);
> -
> - PausePressed = FALSE;
> -
> - while (TRUE) {
> - Status = TxtInEx->ReadKeyStrokeEx (TxtInEx, &KeyData);
> - if (EFI_ERROR (Status)) {
> - break;
> - }
> -
> - if (KeyData.Key.ScanCode == SCAN_PAUSE) {
> - PausePressed = TRUE;
> - break;
> - }
> - }
> -
> - //
> - // Loop until non-PAUSE key pressed
> - //
> - while (PausePressed) {
> - Status = TxtInEx->ReadKeyStrokeEx (TxtInEx, &KeyData);
> - if (!EFI_ERROR (Status)) {
> - DEBUG ((
> - DEBUG_INFO, "[PauseCallback] %x/%x %x/%x\n",
> - KeyData.Key.ScanCode, KeyData.Key.UnicodeChar,
> - KeyData.KeyState.KeyShiftState, KeyData.KeyState.KeyToggleState
> - ));
> - PausePressed = (BOOLEAN) (KeyData.Key.ScanCode == SCAN_PAUSE);
> - }
> - }
> -}
> -
> -
> -EFI_GUID gUefiShellFileGuid = { 0x7C04A583, 0x9E3E, 0x4f1c, { 0xAD, 0x65,
> 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 } };
> -
> -#define INTERNAL_UEFI_SHELL_NAME L"Internal UEFI Shell 2.0"
> -#define UEFI_HARD_DRIVE_NAME L"UEFI Hard Drive"
> -
> -VOID
> -RegisterDefaultBootOption (
> - VOID
> - )
> -{
> -#if 0
> - EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> - EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
> - MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
> -#endif
> - UINT16 *ShellData;
> - UINT32 ShellDataSize;
> -
> - ShellData = NULL;
> - ShellDataSize = 0;
> - RegisterFvBootOption (&gUefiShellFileGuid,
> INTERNAL_UEFI_SHELL_NAME, (UINTN) -1, LOAD_OPTION_ACTIVE, (UINT8
> *)ShellData, ShellDataSize);
> -
> - //
> - // Boot Menu
> - //
> - mBootMenuOptionNumber = RegisterFvBootOption (&mBootMenuFile,
> L"Boot Device List", (UINTN) -1, LOAD_OPTION_CATEGORY_APP |
> LOAD_OPTION_ACTIVE | LOAD_OPTION_HIDDEN, NULL, 0);
> -
> - if (mBootMenuOptionNumber == LoadOptionNumberUnassigned) {
> - DEBUG ((DEBUG_INFO, "BootMenuOptionNumber (%d) should not be
> same to LoadOptionNumberUnassigned(%d).\n", mBootMenuOptionNumber,
> LoadOptionNumberUnassigned));
> - }
> -#if 0
> - //
> - // Boot Manager Menu
> - //
> - EfiInitializeFwVolDevicepathNode (&FileNode, &mUiFile);
> -
> - gBS->HandleProtocol (
> - gImageHandle,
> - &gEfiLoadedImageProtocolGuid,
> - (VOID **) &LoadedImage
> - );
> - DevicePath = AppendDevicePathNode (DevicePathFromHandle
> (LoadedImage->DeviceHandle), (EFI_DEVICE_PATH_PROTOCOL *) &FileNode);
> -#endif
> -
> -}
> -
> -VOID
> -RegisterBootOptionHotkey (
> - UINT16 OptionNumber,
> - EFI_INPUT_KEY *Key,
> - BOOLEAN Add
> - )
> -{
> - EFI_STATUS Status;
> -
> - if (!Add) {
> - //
> - // No enter hotkey when force to setup or there is no boot option
> - //
> - Status = EfiBootManagerDeleteKeyOptionVariable (NULL, 0, Key, NULL);
> - ASSERT (Status == EFI_SUCCESS || Status == EFI_NOT_FOUND);
> - } else {
> - //
> - // Register enter hotkey for the first boot option
> - //
> - Status = EfiBootManagerAddKeyOptionVariable (NULL, OptionNumber,
> 0, Key,NULL);
> - ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
> - }
> -}
> -
> -EFI_STATUS
> -EFIAPI
> -DetectKeypressCallback (
> - IN EFI_KEY_DATA *KeyData
> -)
> -{
> - mHotKeypressed = TRUE;
> -
> - if (HotKeyEvent != NULL) {
> - gBS->SignalEvent(HotKeyEvent);
> - }
> -
> - return EFI_SUCCESS;
> -}
> -
> -/**
> - This function is called after all the boot options are enumerated and
> ordered properly.
> -**/
> -VOID
> -RegisterStaticHotkey (
> - VOID
> - )
> -{
> -
> - EFI_INPUT_KEY Enter;
> - EFI_KEY_DATA F2;
> - EFI_KEY_DATA F7;
> - BOOLEAN EnterSetup;
> - EFI_STATUS Status;
> - EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
> -
> - EnterSetup = FALSE;
> -
> - //
> - // [Enter]
> - //
> - mContinueBoot = !EnterSetup;
> - if (mContinueBoot) {
> - Enter.ScanCode = SCAN_NULL;
> - Enter.UnicodeChar = CHAR_CARRIAGE_RETURN;
> - EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL);
> - }
> -
> -
> - //
> - // [F2]/[F7]
> - //
> - F2.Key.ScanCode = SCAN_F2;
> - F2.Key.UnicodeChar = CHAR_NULL;
> - F2.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID;
> - F2.KeyState.KeyToggleState = 0;
> - Status = EfiBootManagerGetBootManagerMenu (&BootOption);
> - ASSERT_EFI_ERROR (Status);
> - RegisterBootOptionHotkey ((UINT16) BootOption.OptionNumber, &F2.Key,
> TRUE);
> - EfiBootManagerFreeLoadOption (&BootOption);
> -
> - F7.Key.ScanCode = SCAN_F7;
> - F7.Key.UnicodeChar = CHAR_NULL;
> - F7.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID;
> - F7.KeyState.KeyToggleState = 0;
> - mBootMenuBoot = !EnterSetup;
> - RegisterBootOptionHotkey ((UINT16) mBootMenuOptionNumber, &F7.Key,
> mBootMenuBoot);
> -
> -}
> -
> -UINT8
> -BootOptionType (
> - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
> - )
> -{
> - EFI_DEVICE_PATH_PROTOCOL *Node;
> - EFI_DEVICE_PATH_PROTOCOL *NextNode;
> -
> - for (Node = DevicePath; !IsDevicePathEndType (Node); Node =
> NextDevicePathNode (Node)) {
> - if (DevicePathType (Node) == MESSAGING_DEVICE_PATH) {
> - //
> - // Make sure the device path points to the driver device.
> - //
> - NextNode = NextDevicePathNode (Node);
> - if (DevicePathSubType(NextNode) ==
> MSG_DEVICE_LOGICAL_UNIT_DP) {
> - //
> - // if the next node type is Device Logical Unit, which specify the
> Logical Unit Number (LUN),
> - // skip it
> - //
> - NextNode = NextDevicePathNode (NextNode);
> - }
> - if (IsDevicePathEndType (NextNode)) {
> - if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH)) {
> - return DevicePathSubType (Node);
> - } else {
> - return MSG_SATA_DP;
> - }
> - }
> - }
> - }
> -
> - return (UINT8) -1;
> -}
> -
> -/**
> - Returns the priority number.
> - OptionType EFI
> - ------------------------------------
> - PXE 2
> - DVD 4
> - USB 6
> - NVME 7
> - HDD 8
> - EFI Shell 9
> - Others 100
> -
> - @param BootOption
> -**/
> -UINTN
> -BootOptionPriority (
> - CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOption
> - )
> -{
> - //
> - // EFI boot options
> - //
> - switch (BootOptionType (BootOption->FilePath)) {
> - case MSG_MAC_ADDR_DP:
> - case MSG_VLAN_DP:
> - case MSG_IPv4_DP:
> - case MSG_IPv6_DP:
> - return 2;
> -
> - case MSG_SATA_DP:
> - case MSG_ATAPI_DP:
> - case MSG_UFS_DP:
> - case MSG_NVME_NAMESPACE_DP:
> - return 4;
> -
> - case MSG_USB_DP:
> - return 6;
> -
> - }
> - if (StrCmp (BootOption->Description, INTERNAL_UEFI_SHELL_NAME) ==
> 0) {
> - if (PcdGetBool (PcdBootToShellOnly)) {
> - return 0;
> - }
> - return 9;
> - }
> - if (StrCmp (BootOption->Description, UEFI_HARD_DRIVE_NAME) == 0) {
> - return 8;
> - }
> - return 100;
> -}
> -
> -INTN
> -EFIAPI
> -CompareBootOption (
> - CONST VOID *Left,
> - CONST VOID *Right
> - )
> -{
> - return BootOptionPriority ((EFI_BOOT_MANAGER_LOAD_OPTION *) Left) -
> - BootOptionPriority ((EFI_BOOT_MANAGER_LOAD_OPTION *)
> Right);
> -}
> -
> --
> 2.19.1.windows.1
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [edk2-platforms] [PATCH 05/11] MinPlatformPkg: Add BDS Hook Points
2019-12-14 1:32 ` [edk2-platforms] [PATCH 05/11] MinPlatformPkg: Add BDS Hook Points Agyeman, Prince
2019-12-17 5:44 ` Chiu, Chasel
@ 2019-12-18 1:33 ` Nate DeSimone
2019-12-21 2:36 ` Kubacki, Michael A
2 siblings, 0 replies; 45+ messages in thread
From: Nate DeSimone @ 2019-12-18 1:33 UTC (permalink / raw)
To: Agyeman, Prince; +Cc: devel@edk2.groups.io, Kubacki, Michael A, Chiu, Chasel
Hi Prince,
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
Thanks,
Nate
On Sat, Dec 14, 2019 at 01:32:31AM +0000, Agyeman, Prince wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
>
> Added BDS hook points to the Minplatform boot manager library
> as defined in the Minimum Platfrom specifcations.
>
> Changes made:
>
> * Added functions to signal three BDS event groups.
> These event groups are BeforeConsoleAfterTrustedConsole,
> BeforeConsoleBeforeEndOfDxe and AfterConsoleReadyBeforeBootOption.
>
> * Removed BDS functionalities from the boot manager library.
> These functionalities will be added to callbacks a module in BoardModule,
> which will then register/hook to the BDS hook points
>
> See https://edk2-docs.gitbooks.io/edk-ii-minimum-platform-specification,
> under Appendix A.3 BDS Hook Points, for more details.
>
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
>
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
> .../DxePlatformBootManagerLib/BdsPlatform.c | 1262 ++---------------
> .../DxePlatformBootManagerLib/BdsPlatform.h | 181 +--
> .../DxePlatformBootManagerLib.inf | 51 +-
> .../DxePlatformBootManagerLib/MemoryTest.c | 83 --
> .../PlatformBootOption.c | 559 --------
> 5 files changed, 112 insertions(+), 2024 deletions(-)
> delete mode 100644 Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/MemoryTest.c
> delete mode 100644 Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/PlatformBootOption.c
>
> diff --git a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c
> index 491fb0f26f..31a9ef4a07 100644
> --- a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c
> +++ b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c
> @@ -1,130 +1,14 @@
> /** @file
> This file include all platform action which can be customized by IBV/OEM.
>
> -Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
> **/
>
> #include "BdsPlatform.h"
> -#include <Guid/EventGroup.h>
> -#include <Protocol/DxeSmmReadyToLock.h>
> -#include <Protocol/FirmwareVolume2.h>
> -#include <Protocol/PciRootBridgeIo.h>
>
> -#include <Protocol/BlockIo.h>
> -#include <Protocol/PciIo.h>
> -#include <Library/IoLib.h>
> -#include <Library/PciLib.h>
> -#include <Guid/EventGroup.h>
> -
> -#include <Library/Tcg2PhysicalPresenceLib.h>
> -
> -#include <Library/HobLib.h>
> -#include <Protocol/UsbIo.h>
> -
> -#include <Library/UefiBootManagerLib.h>
> -
> -GLOBAL_REMOVE_IF_UNREFERENCED EFI_BOOT_MODE gBootMode;
> -
> -BOOLEAN gPPRequireUIConfirm;
> -
> -extern UINTN mBootMenuOptionNumber;
> -
> -GLOBAL_REMOVE_IF_UNREFERENCED USB_CLASS_FORMAT_DEVICE_PATH gUsbClassKeyboardDevicePath = {
> - {
> - {
> - MESSAGING_DEVICE_PATH,
> - MSG_USB_CLASS_DP,
> - {
> - (UINT8) (sizeof (USB_CLASS_DEVICE_PATH)),
> - (UINT8) ((sizeof (USB_CLASS_DEVICE_PATH)) >> 8)
> - }
> - },
> - 0xffff, // VendorId
> - 0xffff, // ProductId
> - CLASS_HID, // DeviceClass
> - SUBCLASS_BOOT, // DeviceSubClass
> - PROTOCOL_KEYBOARD // DeviceProtocol
> - },
> - gEndEntire
> -};
> -
> -//
> -// Internal shell mode
> -//
> -GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mShellModeColumn;
> -GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mShellModeRow;
> -GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mShellHorizontalResolution;
> -GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mShellVerticalResolution;
> -//
> -// BDS Platform Functions
> -//
> -
> -BOOLEAN
> -IsMorBitSet (
> - VOID
> - )
> -{
> - UINTN MorControl;
> - EFI_STATUS Status;
> - UINTN DataSize;
> -
> - //
> - // Check if the MOR bit is set.
> - //
> - DataSize = sizeof (MorControl);
> - Status = gRT->GetVariable (
> - MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME,
> - &gEfiMemoryOverwriteControlDataGuid,
> - NULL,
> - &DataSize,
> - &MorControl
> - );
> - if (EFI_ERROR (Status)) {
> - DEBUG ((DEBUG_INFO, " PlatformBootMangerLib: gEfiMemoryOverwriteControlDataGuid doesn't exist!!***\n"));
> - MorControl = 0;
> - } else {
> - DEBUG ((DEBUG_INFO, " PlatformBootMangerLib: Get the gEfiMemoryOverwriteControlDataGuid = %x!!***\n", MorControl));
> - }
> -
> - return (BOOLEAN) (MorControl & 0x01);
> -}
> -
> -VOID
> -DumpDevicePath (
> - IN CHAR16 *Name,
> - IN EFI_DEVICE_PATH *DevicePath
> - )
> -{
> - CHAR16 *Str;
> -
> - Str = ConvertDevicePathToText(DevicePath, TRUE, TRUE);
> - DEBUG ((DEBUG_INFO, "%s: %s\n", Name, Str));
> - if (Str != NULL) {
> - FreePool (Str);
> - }
> -}
> -
> -/**
> - An empty function to pass error checking of CreateEventEx ().
> -
> - This empty function ensures that EVT_NOTIFY_SIGNAL_ALL is error
> - checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0.
> -
> - @param Event Event whose notification function is being invoked.
> - @param Context The pointer to the notification function's context,
> - which is implementation-dependent.
> -**/
> -VOID
> -EFIAPI
> -InternalBdsEmptyCallbackFuntion (
> - IN EFI_EVENT Event,
> - IN VOID *Context
> - )
> -{
> - return;
> -}
> +extern UINTN mBootMenuOptionNumber;
>
> VOID
> ExitPmAuth (
> @@ -145,7 +29,7 @@ ExitPmAuth (
> Status = gBS->CreateEventEx (
> EVT_NOTIFY_SIGNAL,
> TPL_CALLBACK,
> - InternalBdsEmptyCallbackFuntion,
> + EfiEventEmptyFunction,
> NULL,
> &gEfiEndOfDxeEventGroupGuid,
> &EndOfDxeEvent
> @@ -172,918 +56,134 @@ ExitPmAuth (
> DEBUG((DEBUG_INFO,"ExitPmAuth ()- End\n"));
> }
>
> -VOID
> -ConnectRootBridge (
> - BOOLEAN Recursive
> - )
> -{
> - UINTN RootBridgeHandleCount;
> - EFI_HANDLE *RootBridgeHandleBuffer;
> - UINTN RootBridgeIndex;
> -
> - RootBridgeHandleCount = 0;
> - gBS->LocateHandleBuffer (
> - ByProtocol,
> - &gEfiPciRootBridgeIoProtocolGuid,
> - NULL,
> - &RootBridgeHandleCount,
> - &RootBridgeHandleBuffer
> - );
> - for (RootBridgeIndex = 0; RootBridgeIndex < RootBridgeHandleCount; RootBridgeIndex++) {
> - gBS->ConnectController (RootBridgeHandleBuffer[RootBridgeIndex], NULL, NULL, Recursive);
> - }
> -}
> -
>
> /**
> - Return whether the device is trusted console.
> -
> - @param Device The device to be tested.
> -
> - @retval TRUE The device can be trusted.
> - @retval FALSE The device cannot be trusted.
> -**/
> -BOOLEAN
> -IsTrustedConsole (
> - IN CONSOLE_TYPE ConsoleType,
> - IN EFI_DEVICE_PATH_PROTOCOL *Device
> - )
> -{
> - VOID *TrustedConsoleDevicepath;
> - EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
> - EFI_DEVICE_PATH_PROTOCOL *Instance;
> - UINTN Size;
> - EFI_DEVICE_PATH_PROTOCOL *ConsoleDevice;
> -
> - if (Device == NULL) {
> - return FALSE;
> - }
> -
> - ConsoleDevice = DuplicateDevicePath(Device);
> -
> - TrustedConsoleDevicepath = NULL;
> -
> - switch (ConsoleType) {
> - case ConIn:
> - TrustedConsoleDevicepath = PcdGetPtr (PcdTrustedConsoleInputDevicePath);
> - break;
> - case ConOut:
> - //
> - // Check GOP and remove last node
> - //
> - TempDevicePath = ConsoleDevice;
> - while (!IsDevicePathEndType (TempDevicePath)) {
> - if (DevicePathType (TempDevicePath) == ACPI_DEVICE_PATH &&
> - DevicePathSubType (TempDevicePath) == ACPI_ADR_DP) {
> - SetDevicePathEndNode (TempDevicePath);
> - break;
> - }
> - TempDevicePath = NextDevicePathNode (TempDevicePath);
> - }
> -
> - TrustedConsoleDevicepath = PcdGetPtr (PcdTrustedConsoleOutputDevicePath);
> - break;
> - default:
> - ASSERT(FALSE);
> - break;
> - }
> -
> - TempDevicePath = TrustedConsoleDevicepath;
> - do {
> - Instance = GetNextDevicePathInstance (&TempDevicePath, &Size);
> - if (Instance == NULL) {
> - break;
> - }
> -
> - if (CompareMem (ConsoleDevice, Instance, Size - END_DEVICE_PATH_LENGTH) == 0) {
> - FreePool (Instance);
> - FreePool (ConsoleDevice);
> - return TRUE;
> - }
> -
> - FreePool (Instance);
> - } while (TempDevicePath != NULL);
> -
> - FreePool (ConsoleDevice);
> + Creates an EFI event in the BDS Event Group.
>
> - return FALSE;
> -}
> -
> -BOOLEAN
> -IsUsbShortForm (
> - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
> - )
> -{
> - if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&
> - ((DevicePathSubType (DevicePath) == MSG_USB_CLASS_DP) || (DevicePathSubType (DevicePath) == MSG_USB_WWID_DP)) ) {
> - return TRUE;
> - }
> + @param NotifyTpl The task priority level of the event.
> + @param gEfiEventGuid The GUID of the event group to signal.
> + @param BdsConsoleEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
>
> - return FALSE;
> -}
> -
> -/**
> - Connect the USB short form device path.
> + @retval EFI_SUCCESS Event was created.
> + @retval Other Event was not created.
>
> - @param DevicePath USB short form device path
> -
> - @retval EFI_SUCCESS Successfully connected the USB device
> - @retval EFI_NOT_FOUND Cannot connect the USB device
> - @retval EFI_INVALID_PARAMETER The device path is invalid.
> **/
> EFI_STATUS
> -ConnectUsbShortFormDevicePath (
> - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
> +EFIAPI
> +CreateBdsEvent (
> + IN EFI_TPL NotifyTpl,
> + IN EFI_GUID *gEfiEventGuid,
> + OUT EFI_EVENT *BdsConsoleEvent
> )
> {
> - EFI_STATUS Status;
> - EFI_HANDLE *Handles;
> - UINTN HandleCount;
> - UINTN Index;
> - EFI_PCI_IO_PROTOCOL *PciIo;
> - UINT8 Class[3];
> - BOOLEAN AtLeastOneConnected;
> + EFI_STATUS Status;
>
> - //
> - // Check the passed in parameters
> - //
> - if (DevicePath == NULL) {
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - if (!IsUsbShortForm (DevicePath)) {
> - return EFI_INVALID_PARAMETER;
> - }
> + ASSERT (BdsConsoleEvent != NULL);
>
> - //
> - // Find the usb host controller firstly, then connect with the remaining device path
> - //
> - AtLeastOneConnected = FALSE;
> - Status = gBS->LocateHandleBuffer (
> - ByProtocol,
> - &gEfiPciIoProtocolGuid,
> + Status = gBS->CreateEventEx (
> + EVT_NOTIFY_SIGNAL,
> + NotifyTpl,
> + EfiEventEmptyFunction,
> NULL,
> - &HandleCount,
> - &Handles
> - );
> - for (Index = 0; Index < HandleCount; Index++) {
> - Status = gBS->HandleProtocol (
> - Handles[Index],
> - &gEfiPciIoProtocolGuid,
> - (VOID **) &PciIo
> - );
> - if (!EFI_ERROR (Status)) {
> - //
> - // Check whether the Pci device is the wanted usb host controller
> - //
> - Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0x09, 3, &Class);
> - if (!EFI_ERROR (Status) &&
> - ((PCI_CLASS_SERIAL == Class[2]) && (PCI_CLASS_SERIAL_USB == Class[1]))
> - ) {
> - Status = gBS->ConnectController (
> - Handles[Index],
> - NULL,
> - DevicePath,
> - FALSE
> - );
> - if (!EFI_ERROR(Status)) {
> - AtLeastOneConnected = TRUE;
> - }
> - }
> - }
> - }
> -
> - return AtLeastOneConnected ? EFI_SUCCESS : EFI_NOT_FOUND;
> -}
> -
> -/**
> - Update the ConIn variable with USB Keyboard device path,if its not already exists in ConIn
> -**/
> -VOID
> -EnumUsbKeyboard (
> - VOID
> - )
> -{
> - DEBUG ((DEBUG_INFO, "[EnumUsbKeyboard]\n"));
> - EfiBootManagerUpdateConsoleVariable (ConIn, (EFI_DEVICE_PATH_PROTOCOL *) &gUsbClassKeyboardDevicePath, NULL);
> -
> - //
> - // Append Usb Keyboard short form DevicePath into "ConInDev"
> - //
> - EfiBootManagerUpdateConsoleVariable (ConInDev, (EFI_DEVICE_PATH_PROTOCOL *) &gUsbClassKeyboardDevicePath, NULL);
> -}
> -
> -BOOLEAN
> -IsVgaHandle (
> - IN EFI_HANDLE Handle
> - )
> -{
> - EFI_PCI_IO_PROTOCOL *PciIo;
> - PCI_TYPE00 Pci;
> - EFI_STATUS Status;
> -
> - Status = gBS->HandleProtocol (
> - Handle,
> - &gEfiPciIoProtocolGuid,
> - (VOID **)&PciIo
> - );
> - if (!EFI_ERROR (Status)) {
> - Status = PciIo->Pci.Read (
> - PciIo,
> - EfiPciIoWidthUint32,
> - 0,
> - sizeof (Pci) / sizeof (UINT32),
> - &Pci
> - );
> - if (!EFI_ERROR (Status)) {
> - if (IS_PCI_VGA (&Pci) || IS_PCI_OLD_VGA (&Pci)) {
> - return TRUE;
> - }
> - }
> - }
> - return FALSE;
> -}
> -
> -EFI_HANDLE
> -IsVideoController (
> - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
> - )
> -{
> - EFI_DEVICE_PATH_PROTOCOL *DupDevicePath;
> - EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
> - EFI_STATUS Status;
> - EFI_HANDLE DeviceHandle;
> -
> - DupDevicePath = DuplicateDevicePath (DevicePath);
> - ASSERT (DupDevicePath != NULL);
> - if (DupDevicePath == NULL) {
> - return NULL;
> - }
> -
> - TempDevicePath = DupDevicePath;
> - Status = gBS->LocateDevicePath (
> - &gEfiDevicePathProtocolGuid,
> - &TempDevicePath,
> - &DeviceHandle
> + gEfiEventGuid,
> + BdsConsoleEvent
> );
> - FreePool (DupDevicePath);
> - if (EFI_ERROR (Status)) {
> - return NULL;
> - }
> -
> - if (IsVgaHandle (DeviceHandle)) {
> - return DeviceHandle;
> - } else {
> - return NULL;
> - }
> -}
> -
> -BOOLEAN
> -IsGopDevicePath (
> - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
> - )
> -{
> - while (!IsDevicePathEndType (DevicePath)) {
> - if (DevicePathType (DevicePath) == ACPI_DEVICE_PATH &&
> - DevicePathSubType (DevicePath) == ACPI_ADR_DP) {
> - return TRUE;
> - }
> - DevicePath = NextDevicePathNode (DevicePath);
> - }
> - return FALSE;
> -}
> -
> -/**
> - Remove all GOP device path instance from DevicePath and add the Gop to the DevicePath.
> -**/
> -EFI_DEVICE_PATH_PROTOCOL *
> -UpdateGopDevicePath (
> - EFI_DEVICE_PATH_PROTOCOL *DevicePath,
> - EFI_DEVICE_PATH_PROTOCOL *Gop
> - )
> -{
> - UINTN Size;
> - UINTN GopSize;
> - EFI_DEVICE_PATH_PROTOCOL *Temp;
> - EFI_DEVICE_PATH_PROTOCOL *Return;
> - EFI_DEVICE_PATH_PROTOCOL *Instance;
> - BOOLEAN Exist;
> -
> - Exist = FALSE;
> - Return = NULL;
> - GopSize = GetDevicePathSize (Gop);
> - do {
> - Instance = GetNextDevicePathInstance (&DevicePath, &Size);
> - if (Instance == NULL) {
> - break;
> - }
> - if (!IsGopDevicePath (Instance) ||
> - (Size == GopSize && CompareMem (Instance, Gop, GopSize) == 0)
> - ) {
> - if (Size == GopSize && CompareMem (Instance, Gop, GopSize) == 0) {
> - Exist = TRUE;
> - }
> - Temp = Return;
> - Return = AppendDevicePathInstance (Return, Instance);
> - if (Temp != NULL) {
> - FreePool (Temp);
> - }
> - }
> - FreePool (Instance);
> - } while (DevicePath != NULL);
>
> - if (!Exist) {
> - Temp = Return;
> - Return = AppendDevicePathInstance (Return, Gop);
> - if (Temp != NULL) {
> - FreePool (Temp);
> - }
> - }
> - return Return;
> + return Status;
> }
>
> /**
> - Get Graphics Controller Handle.
> -
> - @retval GraphicsController Successfully located
> - @retval NULL Failed to locate
> -**/
> -EFI_HANDLE
> -EFIAPI
> -GetGraphicsController (
> - IN BOOLEAN NeedTrustedConsole
> - )
> -{
> - EFI_STATUS Status;
> - UINTN Index;
> - EFI_HANDLE *PciHandles;
> - UINTN PciHandlesSize;
> - EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> -
> - Status = gBS->LocateHandleBuffer (
> - ByProtocol,
> - &gEfiPciIoProtocolGuid,
> - NULL,
> - &PciHandlesSize,
> - &PciHandles
> - );
> - if (EFI_ERROR (Status)) {
> - return NULL;
> - }
> -
> - for (Index = 0; Index < PciHandlesSize; Index++) {
> - Status = gBS->HandleProtocol (
> - PciHandles[Index],
> - &gEfiDevicePathProtocolGuid,
> - (VOID **) &DevicePath
> - );
> - if (EFI_ERROR(Status)) {
> - continue;
> - }
> - if (!IsVgaHandle (PciHandles[Index])) {
> - continue;
> - }
> - if ((NeedTrustedConsole && IsTrustedConsole (ConOut, DevicePath)) ||
> - ((!NeedTrustedConsole) && (!IsTrustedConsole (ConOut, DevicePath)))) {
> - return PciHandles[Index];
> - }
> - }
> -
> - return NULL;
> -}
> -
> -VOID
> -UpdateGraphicConOut (
> - IN BOOLEAN NeedTrustedConsole
> - )
> -{
> - EFI_HANDLE GraphicsControllerHandle;
> - EFI_DEVICE_PATH_PROTOCOL *GopDevicePath;
> - EFI_DEVICE_PATH_PROTOCOL *ConOutDevicePath;
> - EFI_DEVICE_PATH_PROTOCOL *UpdatedConOutDevicePath;
> + Create, Signal, and Close the Bds Event Before Console After
> + Trusted Console event using CreateBdsEvent().
>
> - //
> - // Update ConOut variable
> - //
> - GraphicsControllerHandle = GetGraphicsController (NeedTrustedConsole);
> - if (GraphicsControllerHandle != NULL) {
> - //
> - // Connect the GOP driver
> - //
> - gBS->ConnectController (GraphicsControllerHandle, NULL, NULL, TRUE);
> -
> - //
> - // Get the GOP device path
> - // NOTE: We may get a device path that contains Controller node in it.
> - //
> - GopDevicePath = EfiBootManagerGetGopDevicePath (GraphicsControllerHandle);
> - if (GopDevicePath != NULL) {
> - GetEfiGlobalVariable2 (L"ConOut", (VOID **)&ConOutDevicePath, NULL);
> - UpdatedConOutDevicePath = UpdateGopDevicePath (ConOutDevicePath, GopDevicePath);
> - if (ConOutDevicePath != NULL) {
> - FreePool (ConOutDevicePath);
> - }
> - FreePool (GopDevicePath);
> - gRT->SetVariable (
> - L"ConOut",
> - &gEfiGlobalVariableGuid,
> - EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS,
> - GetDevicePathSize (UpdatedConOutDevicePath),
> - UpdatedConOutDevicePath
> - );
> - }
> - }
> -}
> -
> -VOID
> -AddConsoleVariable (
> - IN CONSOLE_TYPE ConsoleType,
> - IN EFI_DEVICE_PATH *ConsoleDevicePath
> - )
> -{
> - EFI_DEVICE_PATH *TempDevicePath;
> - EFI_DEVICE_PATH *Instance;
> - UINTN Size;
> - EFI_HANDLE GraphicsControllerHandle;
> - EFI_DEVICE_PATH *GopDevicePath;
> -
> - TempDevicePath = ConsoleDevicePath;
> - do {
> - Instance = GetNextDevicePathInstance (&TempDevicePath, &Size);
> - if (Instance == NULL) {
> - break;
> - }
> -
> - switch (ConsoleType) {
> - case ConIn:
> - if (IsUsbShortForm (Instance)) {
> - //
> - // Append Usb Keyboard short form DevicePath into "ConInDev"
> - //
> - EfiBootManagerUpdateConsoleVariable (ConInDev, Instance, NULL);
> - }
> - EfiBootManagerUpdateConsoleVariable (ConsoleType, Instance, NULL);
> - break;
> - case ConOut:
> - GraphicsControllerHandle = IsVideoController (Instance);
> - if (GraphicsControllerHandle == NULL) {
> - EfiBootManagerUpdateConsoleVariable (ConsoleType, Instance, NULL);
> - } else {
> - //
> - // Connect the GOP driver
> - //
> - gBS->ConnectController (GraphicsControllerHandle, NULL, NULL, TRUE);
> - //
> - // Get the GOP device path
> - // NOTE: We may get a device path that contains Controller node in it.
> - //
> - GopDevicePath = EfiBootManagerGetGopDevicePath (GraphicsControllerHandle);
> - if (GopDevicePath != NULL) {
> - EfiBootManagerUpdateConsoleVariable (ConsoleType, GopDevicePath, NULL);
> - }
> - }
> - break;
> - default:
> - ASSERT(FALSE);
> - break;
> - }
> -
> - FreePool (Instance);
> - } while (TempDevicePath != NULL);
> -}
> -
> -/**
> - The function connects the trusted consoles.
> **/
> VOID
> -ConnectTrustedConsole (
> +EFIAPI
> +BdsSignalEventBeforeConsoleAfterTrustedConsole (
> VOID
> )
> {
> - EFI_DEVICE_PATH_PROTOCOL *Consoles;
> - EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
> - EFI_DEVICE_PATH_PROTOCOL *Instance;
> - EFI_DEVICE_PATH_PROTOCOL *Next;
> - UINTN Size;
> - UINTN Index;
> - EFI_HANDLE Handle;
> - EFI_STATUS Status;
> - CHAR16 *ConsoleVar[] = {L"ConIn", L"ConOut"};
> - VOID *TrustedConsoleDevicepath;
> + EFI_STATUS Status;
> + EFI_EVENT BdsConsoleEvent;
>
> - TrustedConsoleDevicepath = PcdGetPtr (PcdTrustedConsoleInputDevicePath);
> - DumpDevicePath (L"TrustedConsoleIn", TrustedConsoleDevicepath);
> - TrustedConsoleDevicepath = PcdGetPtr (PcdTrustedConsoleOutputDevicePath);
> - DumpDevicePath (L"TrustedConsoleOut", TrustedConsoleDevicepath);
> + DEBUG ((DEBUG_INFO, "%a \n", __FUNCTION__));
>
> - for (Index = 0; Index < sizeof (ConsoleVar) / sizeof (ConsoleVar[0]); Index++) {
> -
> - GetEfiGlobalVariable2 (ConsoleVar[Index], (VOID **)&Consoles, NULL);
> + Status = CreateBdsEvent (
> + TPL_CALLBACK,
> + &gBdsEventBeforeConsoleAfterTrustedConsoleGuid,
> + &BdsConsoleEvent
> + );
>
> - TempDevicePath = Consoles;
> - do {
> - Instance = GetNextDevicePathInstance (&TempDevicePath, &Size);
> - if (Instance == NULL) {
> - break;
> - }
> - if (IsTrustedConsole (Index, Instance)) {
> - if (IsUsbShortForm (Instance)) {
> - ConnectUsbShortFormDevicePath (Instance);
> - } else {
> - for (Next = Instance; !IsDevicePathEnd (Next); Next = NextDevicePathNode (Next)) {
> - if (DevicePathType (Next) == ACPI_DEVICE_PATH && DevicePathSubType (Next) == ACPI_ADR_DP) {
> - break;
> - } else if (DevicePathType (Next) == HARDWARE_DEVICE_PATH &&
> - DevicePathSubType (Next) == HW_CONTROLLER_DP &&
> - DevicePathType (NextDevicePathNode (Next)) == ACPI_DEVICE_PATH &&
> - DevicePathSubType (NextDevicePathNode (Next)) == ACPI_ADR_DP
> - ) {
> - break;
> - }
> - }
> - if (!IsDevicePathEnd (Next)) {
> - SetDevicePathEndNode (Next);
> - Status = EfiBootManagerConnectDevicePath (Instance, &Handle);
> - if (!EFI_ERROR (Status)) {
> - gBS->ConnectController (Handle, NULL, NULL, TRUE);
> - }
> - } else {
> - EfiBootManagerConnectDevicePath (Instance, NULL);
> - }
> - }
> - }
> - FreePool (Instance);
> - } while (TempDevicePath != NULL);
> + ASSERT_EFI_ERROR (Status);
>
> - if (Consoles != NULL) {
> - FreePool (Consoles);
> - }
> + if (!EFI_ERROR (Status)) {
> + gBS->SignalEvent (BdsConsoleEvent);
> + gBS->CloseEvent (BdsConsoleEvent);
> + DEBUG ((DEBUG_INFO,"All EventBeforeConsoleAfterTrustedConsole callbacks have returned successfully\n"));
> }
> }
>
> -/**
> - The function connects the trusted Storages.
> -**/
> -VOID
> -ConnectTrustedStorage (
> - VOID
> - )
> -{
> - VOID *TrustedStorageDevicepath;
> - EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
> - EFI_DEVICE_PATH_PROTOCOL *Instance;
> - UINTN Size;
> - EFI_DEVICE_PATH_PROTOCOL *TempStorageDevicePath;
> - EFI_STATUS Status;
> - EFI_HANDLE DeviceHandle;
> -
> - TrustedStorageDevicepath = PcdGetPtr (PcdTrustedStorageDevicePath);
> - DumpDevicePath (L"TrustedStorage", TrustedStorageDevicepath);
> -
> - TempDevicePath = TrustedStorageDevicepath;
> - do {
> - Instance = GetNextDevicePathInstance (&TempDevicePath, &Size);
> - if (Instance == NULL) {
> - break;
> - }
> -
> - EfiBootManagerConnectDevicePath (Instance, NULL);
> -
> - TempStorageDevicePath = Instance;
> -
> - Status = gBS->LocateDevicePath (
> - &gEfiDevicePathProtocolGuid,
> - &TempStorageDevicePath,
> - &DeviceHandle
> - );
> - if (!EFI_ERROR (Status)) {
> - gBS->ConnectController (DeviceHandle, NULL, NULL, FALSE);
> - }
> -
> - FreePool (Instance);
> - } while (TempDevicePath != NULL);
> -}
> -
> -/**
> - The function connects the trusted consoles and then call the PP processing library interface.
> -**/
> -VOID
> -ProcessTcgPp (
> - VOID
> - )
> -{
> - gPPRequireUIConfirm |= Tcg2PhysicalPresenceLibNeedUserConfirm();
> -
> - if (gPPRequireUIConfirm) {
> - ConnectTrustedConsole ();
> - }
> -
> - Tcg2PhysicalPresenceLibProcessRequest (NULL);
> -}
>
> /**
> - The function connects the trusted storage to perform TPerReset.
> + Create, Signal, and Close the Bds Before Console Before End Of Dxe
> + event using CreateBdsEvent().
> **/
> VOID
> -ProcessTcgMor (
> - VOID
> - )
> -{
> - if (IsMorBitSet ()) {
> - ConnectTrustedConsole();
> - ConnectTrustedStorage();
> - }
> -}
> -
> -/**
> - Check if current BootCurrent variable is internal shell boot option.
> -
> - @retval TRUE BootCurrent is internal shell.
> - @retval FALSE BootCurrent is not internal shell.
> -**/
> -BOOLEAN
> -BootCurrentIsInternalShell (
> +EFIAPI
> +BdsSignalEventBeforeConsoleBeforeEndOfDxe (
> VOID
> )
> {
> - UINTN VarSize;
> - UINT16 BootCurrent;
> - CHAR16 BootOptionName[16];
> - UINT8 *BootOption;
> - UINT8 *Ptr;
> - BOOLEAN Result;
> - EFI_STATUS Status;
> - EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
> - EFI_DEVICE_PATH_PROTOCOL *LastDeviceNode;
> - EFI_GUID *GuidPoint;
> -
> - BootOption = NULL;
> - Result = FALSE;
> -
> - //
> - // Get BootCurrent variable
> - //
> - VarSize = sizeof (UINT16);
> - Status = gRT->GetVariable (
> - L"BootCurrent",
> - &gEfiGlobalVariableGuid,
> - NULL,
> - &VarSize,
> - &BootCurrent
> - );
> - if (EFI_ERROR (Status)) {
> - return FALSE;
> - }
> + EFI_STATUS Status;
> + EFI_EVENT BdsConsoleEvent;
>
> - //
> - // Create boot option Bootxxxx from BootCurrent
> - //
> - UnicodeSPrint (BootOptionName, sizeof(BootOptionName), L"Boot%04X", BootCurrent);
> + DEBUG ((DEBUG_INFO, "%a \n", __FUNCTION__));
>
> - GetEfiGlobalVariable2 (BootOptionName, (VOID **) &BootOption, &VarSize);
> - if (BootOption == NULL || VarSize == 0) {
> - return FALSE;
> - }
> + Status = CreateBdsEvent (
> + TPL_CALLBACK,
> + &gBdsEventBeforeConsoleBeforeEndOfDxeGuid,
> + &BdsConsoleEvent
> + );
>
> - Ptr = BootOption;
> - Ptr += sizeof (UINT32);
> - Ptr += sizeof (UINT16);
> - Ptr += StrSize ((CHAR16 *) Ptr);
> - TempDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) Ptr;
> - LastDeviceNode = TempDevicePath;
> - while (!IsDevicePathEnd (TempDevicePath)) {
> - LastDeviceNode = TempDevicePath;
> - TempDevicePath = NextDevicePathNode (TempDevicePath);
> - }
> - GuidPoint = EfiGetNameGuidFromFwVolDevicePathNode (
> - (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) LastDeviceNode
> - );
> - if ((GuidPoint != NULL) &&
> - ((CompareGuid (GuidPoint, &gUefiShellFileGuid)))
> - ) {
> - //
> - // if this option is internal shell, return TRUE
> - //
> - Result = TRUE;
> - }
> + ASSERT_EFI_ERROR (Status);
>
> - if (BootOption != NULL) {
> - FreePool (BootOption);
> - BootOption = NULL;
> + if (!EFI_ERROR (Status)) {
> + gBS->SignalEvent (BdsConsoleEvent);
> + gBS->CloseEvent (BdsConsoleEvent);
> + DEBUG ((DEBUG_INFO,"All BeforeConsoleBeforeEndOfDxe callbacks have returned successfully\n"));
> }
> -
> - return Result;
> }
>
> /**
> - This function will change video resolution and text mode
> - for internl shell when internal shell is launched.
> -
> - @param None.
> -
> - @retval EFI_SUCCESS Mode is changed successfully.
> - @retval Others Mode failed to changed.
> + Create, Signal, and Close the Bds After Console Ready Before Boot Option
> + using CreateBdsEvent().
> **/
> -EFI_STATUS
> +VOID
> EFIAPI
> -ChangeModeForInternalShell (
> +BdsSignalEventAfterConsoleReadyBeforeBootOption (
> VOID
> )
> {
> - EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
> - EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;
> - UINTN SizeOfInfo;
> - EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
> - UINT32 MaxGopMode;
> - UINT32 MaxTextMode;
> - UINT32 ModeNumber;
> - UINTN HandleCount;
> - EFI_HANDLE *HandleBuffer;
> - EFI_STATUS Status;
> - UINTN Index;
> - UINTN CurrentColumn;
> - UINTN CurrentRow;
> -
> - Status = gBS->HandleProtocol (
> - gST->ConsoleOutHandle,
> - &gEfiGraphicsOutputProtocolGuid,
> - (VOID**)&GraphicsOutput
> - );
> - if (EFI_ERROR (Status)) {
> - GraphicsOutput = NULL;
> - }
> -
> - Status = gBS->HandleProtocol (
> - gST->ConsoleOutHandle,
> - &gEfiSimpleTextOutProtocolGuid,
> - (VOID**)&SimpleTextOut
> - );
> - if (EFI_ERROR (Status)) {
> - SimpleTextOut = NULL;
> - }
> + EFI_STATUS Status;
> + EFI_EVENT BdsConsoleEvent;
>
> - if ((GraphicsOutput == NULL) || (SimpleTextOut == NULL)) {
> - return EFI_UNSUPPORTED;
> - }
> -
> - MaxGopMode = GraphicsOutput->Mode->MaxMode;
> - MaxTextMode = SimpleTextOut->Mode->MaxMode;
> -
> - //
> - // 1. If current video resolution is same with new video resolution,
> - // video resolution need not be changed.
> - // 1.1. If current text mode is same with new text mode, text mode need not be change.
> - // 1.2. If current text mode is different with new text mode, text mode need be change to new text mode.
> - // 2. If current video resolution is different with new video resolution, we need restart whole console drivers.
> - //
> - for (ModeNumber = 0; ModeNumber < MaxGopMode; ModeNumber++) {
> - Status = GraphicsOutput->QueryMode (
> - GraphicsOutput,
> - ModeNumber,
> - &SizeOfInfo,
> - &Info
> - );
> - if (!EFI_ERROR (Status)) {
> - if ((Info->HorizontalResolution == mShellHorizontalResolution) &&
> - (Info->VerticalResolution == mShellVerticalResolution)) {
> - if ((GraphicsOutput->Mode->Info->HorizontalResolution == mShellHorizontalResolution) &&
> - (GraphicsOutput->Mode->Info->VerticalResolution == mShellVerticalResolution)) {
> - //
> - // If current video resolution is same with new resolution,
> - // then check if current text mode is same with new text mode.
> - //
> - Status = SimpleTextOut->QueryMode (SimpleTextOut, SimpleTextOut->Mode->Mode, &CurrentColumn, &CurrentRow);
> - ASSERT_EFI_ERROR (Status);
> - if (CurrentColumn == mShellModeColumn && CurrentRow == mShellModeRow) {
> - //
> - // Current text mode is same with new text mode, text mode need not be change.
> - //
> - FreePool (Info);
> - return EFI_SUCCESS;
> - } else {
> - //
> - // Current text mode is different with new text mode, text mode need be change to new text mode.
> - //
> - for (Index = 0; Index < MaxTextMode; Index++) {
> - Status = SimpleTextOut->QueryMode (SimpleTextOut, Index, &CurrentColumn, &CurrentRow);
> - if (!EFI_ERROR(Status)) {
> - if ((CurrentColumn == mShellModeColumn) && (CurrentRow == mShellModeRow)) {
> - //
> - // New text mode is supported, set it.
> - //
> - Status = SimpleTextOut->SetMode (SimpleTextOut, Index);
> - ASSERT_EFI_ERROR (Status);
> - //
> - // Update text mode PCD.
> - //
> - Status = PcdSet32S (PcdConOutColumn, mShellModeColumn);
> - ASSERT_EFI_ERROR (Status);
> + DEBUG ((DEBUG_INFO, "%a \n", __FUNCTION__));
>
> - Status = PcdSet32S (PcdConOutRow, mShellModeRow);
> - ASSERT_EFI_ERROR (Status);
> -
> - FreePool (Info);
> - return EFI_SUCCESS;
> - }
> - }
> - }
> - if (Index == MaxTextMode) {
> - //
> - // If new text mode is not supported, return error.
> - //
> - FreePool (Info);
> - return EFI_UNSUPPORTED;
> - }
> - }
> - } else {
> - FreePool (Info);
> - //
> - // If current video resolution is not same with the new one, set new video resolution.
> - // In this case, the driver which produces simple text out need be restarted.
> - //
> - Status = GraphicsOutput->SetMode (GraphicsOutput, ModeNumber);
> - if (!EFI_ERROR (Status)) {
> - //
> - // Set PCD to restart GraphicsConsole and Consplitter to change video resolution
> - // and produce new text mode based on new resolution.
> - //
> - Status = PcdSet32S (PcdVideoHorizontalResolution, mShellHorizontalResolution);
> - ASSERT_EFI_ERROR (Status);
> -
> - Status = PcdSet32S (PcdVideoVerticalResolution, mShellVerticalResolution);
> - ASSERT_EFI_ERROR (Status);
> -
> - Status = PcdSet32S (PcdConOutColumn, mShellModeColumn);
> - ASSERT_EFI_ERROR (Status);
> -
> - Status = PcdSet32S (PcdConOutRow, mShellModeRow);
> - ASSERT_EFI_ERROR (Status);
> + Status = CreateBdsEvent (
> + TPL_CALLBACK,
> + &gBdsEventAfterConsoleReadyBeforeBootOptionGuid,
> + &BdsConsoleEvent
> + );
>
> - Status = gBS->LocateHandleBuffer (
> - ByProtocol,
> - &gEfiSimpleTextOutProtocolGuid,
> - NULL,
> - &HandleCount,
> - &HandleBuffer
> - );
> - if (!EFI_ERROR (Status)) {
> - for (Index = 0; Index < HandleCount; Index++) {
> - gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);
> - }
> - for (Index = 0; Index < HandleCount; Index++) {
> - gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
> - }
> - if (HandleBuffer != NULL) {
> - FreePool (HandleBuffer);
> - }
> - break;
> - }
> - }
> - }
> - }
> - FreePool (Info);
> - }
> - }
> + ASSERT_EFI_ERROR (Status);
>
> - if (ModeNumber == MaxGopMode) {
> - //
> - // If the new resolution is not supported, return error.
> - //
> - return EFI_UNSUPPORTED;
> + if (!EFI_ERROR (Status)) {
> + gBS->SignalEvent (BdsConsoleEvent);
> + gBS->CloseEvent (BdsConsoleEvent);
> + DEBUG ((DEBUG_INFO,"All AfterConsoleReadyBeforeBootOption callbacks have returned successfully\n"));
> }
> -
> - return EFI_SUCCESS;
> }
>
> -/**
> - ReadyToBoot callback to set video and text mode for internal shell boot.
> - That will not connect USB controller while CSM and FastBoot are disabled, we need to connect them
> - before booting to Shell for showing USB devices in Shell.
> -
> - When FastBoot is enabled and Windows Console is the chosen Console behavior, input devices will not be connected
> - by default. Hence, when booting to EFI shell, connecting input consoles are required.
> -
> - @param Event Pointer to this event
> - @param Context Event hanlder private data
> -
> - @retval None.
> -**/
> -VOID
> -EFIAPI
> -OnReadyToBootCallBack (
> - IN EFI_EVENT Event,
> - IN VOID *Context
> - )
> -{
> - DEBUG ((EFI_D_INFO, "OnReadyToBootCallBack\n"));
> -
> - if (BootCurrentIsInternalShell ()) {
> -
> - ChangeModeForInternalShell ();
> - EfiBootManagerConnectAllDefaultConsoles();
> - gDS->Dispatch ();
> - }
> -}
>
> /**
> Platform Bds init. Incude the platform firmware vendor, revision
> @@ -1095,149 +195,37 @@ PlatformBootManagerBeforeConsole (
> VOID
> )
> {
> - EFI_STATUS Status;
> - EFI_DEVICE_PATH_PROTOCOL *VarConOut;
> - EFI_DEVICE_PATH_PROTOCOL *VarConIn;
> - EFI_EVENT Event;
>
> DEBUG ((EFI_D_INFO, "PlatformBootManagerBeforeConsole\n"));
>
> - Status = EFI_SUCCESS;
> -
> - //
> - // Get user defined text mode for internal shell only once.
> - //
> - mShellHorizontalResolution = PcdGet32 (PcdSetupVideoHorizontalResolution);
> - mShellVerticalResolution = PcdGet32 (PcdSetupVideoVerticalResolution);
> - mShellModeColumn = PcdGet32 (PcdSetupConOutColumn);
> - mShellModeRow = PcdGet32 (PcdSetupConOutRow);
> -
> - //
> - // Create event to set proper video resolution and text mode for internal shell.
> - //
> - Status = EfiCreateEventReadyToBootEx (
> - TPL_CALLBACK,
> - OnReadyToBootCallBack,
> - NULL,
> - &Event
> - );
> - ASSERT_EFI_ERROR (Status);
> -
> - //
> - // Connect Root Bridge to make PCI BAR resource allocated and all PciIo created
> - //
> - ConnectRootBridge (FALSE);
> -
> //
> - // Fill ConIn/ConOut in Full Configuration boot mode
> + // Trusted console can be added in a PciEnumComplete callback
> //
> - DEBUG ((DEBUG_INFO, "PlatformBootManagerInit - %x\n", gBootMode));
> -
> - if (gBootMode == BOOT_WITH_FULL_CONFIGURATION ||
> - gBootMode == BOOT_WITH_DEFAULT_SETTINGS ||
> - gBootMode == BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS ||
> - gBootMode == BOOT_IN_RECOVERY_MODE) {
> -
> - GetEfiGlobalVariable2 (L"ConOut", (VOID **)&VarConOut, NULL); if (VarConOut != NULL) { FreePool (VarConOut); }
> - GetEfiGlobalVariable2 (L"ConIn", (VOID **)&VarConIn, NULL); if (VarConIn != NULL) { FreePool (VarConIn); }
> -
> - //
> - // Only fill ConIn/ConOut when ConIn/ConOut is empty because we may drop to Full Configuration boot mode in non-first boot
> - //
> - if (VarConOut == NULL || VarConIn == NULL) {
> - if (PcdGetSize (PcdTrustedConsoleOutputDevicePath) >= sizeof(EFI_DEVICE_PATH_PROTOCOL)) {
> - AddConsoleVariable (ConOut, PcdGetPtr (PcdTrustedConsoleOutputDevicePath));
> - }
> - if (PcdGetSize (PcdTrustedConsoleInputDevicePath) >= sizeof(EFI_DEVICE_PATH_PROTOCOL)) {
> - AddConsoleVariable (ConIn, PcdGetPtr (PcdTrustedConsoleInputDevicePath));
> - }
> - }
> - }
>
> - EnumUsbKeyboard ();
> //
> - // For trusted console it must be handled here.
> + // Signal Before Console, after Trusted console Event
> //
> - UpdateGraphicConOut (TRUE);
> + BdsSignalEventBeforeConsoleAfterTrustedConsole ();
>
> //
> - // Dynamically register hot key: F2/F7/Enter
> + // Signal Before Console, before End of Dxe
> //
> - RegisterDefaultBootOption ();
> - RegisterStaticHotkey ();
> -
> - PERF_START_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7010);
> - if (PcdGetBool (PcdTpm2Enable)) {
> - ProcessTcgPp ();
> - ProcessTcgMor ();
> - }
> - PERF_END_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7011);
> + BdsSignalEventBeforeConsoleBeforeEndOfDxe ();
>
> //
> - // We should make all UEFI memory and GCD information populated before ExitPmAuth.
> - // SMM may consume these information.
> + // Signal End Of Dxe Event
> //
> - MemoryTest((EXTENDMEM_COVERAGE_LEVEL) PcdGet32 (PcdPlatformMemoryCheckLevel));
> -
> PERF_START_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7020);
> ExitPmAuth ();
> PERF_END_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7021);
>
> //
> - // Dispatch the deferred 3rd party images.
> - //
> - EfiBootManagerDispatchDeferredImages ();
> -
> - //
> - // For non-trusted console it must be handled here.
> + // Deferred 3rd party images can be dispatched in
> + // an SmmReadyToLock callback
> //
> - UpdateGraphicConOut (FALSE);
> }
>
>
> -/**
> - Connect with predeined platform connect sequence,
> - the OEM/IBV can customize with their own connect sequence.
> -
> - @param[in] BootMode Boot mode of this boot.
> -**/
> -VOID
> -ConnectSequence (
> - IN EFI_BOOT_MODE BootMode
> - )
> -{
> - EfiBootManagerConnectAll ();
> -}
> -
> -/**
> - The function is to consider the boot order which is not in our expectation.
> - In the case that we need to re-sort the boot option.
> -
> - @retval TRUE Need to sort Boot Option.
> - @retval FALSE Don't need to sort Boot Option.
> -**/
> -BOOLEAN
> -IsNeedSortBootOption (
> - VOID
> - )
> -{
> - EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
> - UINTN BootOptionCount;
> -
> - BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);
> -
> - //
> - // If setup is the first priority in boot option, we need to sort boot option.
> - //
> - if ((BootOptionCount > 1) &&
> - (((StrnCmp (BootOptions->Description, L"Enter Setup", StrLen (L"Enter Setup"))) == 0) ||
> - ((StrnCmp (BootOptions->Description, L"BootManagerMenuApp", StrLen (L"BootManagerMenuApp"))) == 0))) {
> - return TRUE;
> - }
> -
> - return FALSE;
> -}
> -
> /**
> The function will excute with as the platform policy, current policy
> is driven by boot mode. IBV/OEM can customize this code for their specific
> @@ -1254,65 +242,9 @@ PlatformBootManagerAfterConsole (
> VOID
> )
> {
> - EFI_BOOT_MODE LocalBootMode;
> -
> DEBUG ((EFI_D_INFO, "PlatformBootManagerAfterConsole\n"));
>
> - //
> - // Get current Boot Mode
> - //
> - LocalBootMode = gBootMode;
> - DEBUG ((DEBUG_INFO, "Current local bootmode - %x\n", LocalBootMode));
> -
> - //
> - // Go the different platform policy with different boot mode
> - // Notes: this part code can be change with the table policy
> - //
> - switch (LocalBootMode) {
> -
> - case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:
> - case BOOT_WITH_MINIMAL_CONFIGURATION:
> - case BOOT_ON_S4_RESUME:
> - //
> - // Perform some platform specific connect sequence
> - //
> - PERF_START_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7050);
> - ConnectSequence (LocalBootMode);
> - PERF_END_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7051);
> -
> - break;
> -
> - case BOOT_WITH_FULL_CONFIGURATION:
> - case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:
> - case BOOT_WITH_DEFAULT_SETTINGS:
> - default:
> - //
> - // Perform some platform specific connect sequence
> - //
> - ConnectSequence (LocalBootMode);
> -
> - //
> - // Only in Full Configuration boot mode we do the enumeration of boot device
> - //
> - //
> - // Dispatch all but Storage Oprom explicitly, because we assume Int13Thunk driver is there.
> - //
> - EfiBootManagerRefreshAllBootOption ();
> -
> - if (IsNeedSortBootOption()) {
> - EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot, CompareBootOption);
> - }
> - //
> - // PXE boot option may appear after boot option enumeration
> - //
> -
> - break;
> - }
> -
> - Print (L"Press F7 for BootMenu!\n");
> -
> - EfiBootManagerRefreshAllBootOption ();
> - EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot, CompareBootOption);
> + BdsSignalEventAfterConsoleReadyBeforeBootOption ();
> }
>
> /**
> @@ -1328,19 +260,19 @@ PlatformBootManagerUnableToBoot (
> VOID
> )
> {
> - EFI_STATUS Status;
> - EFI_BOOT_MANAGER_LOAD_OPTION BootDeviceList;
> - CHAR16 OptionName[sizeof ("Boot####")];
> + BoardBootManagerUnableToBoot ();
> +}
>
> - if (mBootMenuOptionNumber == LoadOptionNumberUnassigned) {
> - return;
> - }
> - UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", mBootMenuOptionNumber);
> - Status = EfiBootManagerVariableToLoadOption (OptionName, &BootDeviceList);
> - if (EFI_ERROR (Status)) {
> - return;
> - }
> - for (;;) {
> - EfiBootManagerBoot (&BootDeviceList);
> - }
> +/**
> + This function is called each second during the boot manager waits the timeout.
> +
> + @param TimeoutRemain The remaining timeout.
> +**/
> +VOID
> +EFIAPI
> +PlatformBootManagerWaitCallback (
> + UINT16 TimeoutRemain
> + )
> +{
> + BoardBootManagerWaitCallback (TimeoutRemain);
> }
> diff --git a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.h b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.h
> index 360a00d7d7..031676cdc3 100644
> --- a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.h
> +++ b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.h
> @@ -1,7 +1,7 @@
> /** @file
> Header file for BDS Platform specific code
>
> -Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
> **/
> @@ -9,176 +9,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> #ifndef _BDS_PLATFORM_H
> #define _BDS_PLATFORM_H
>
> -#include <PiDxe.h>
> -#include <Protocol/DevicePath.h>
> -#include <Protocol/SimpleNetwork.h>
> -#include <Protocol/PciRootBridgeIo.h>
> -#include <Protocol/LoadFile.h>
> -#include <Protocol/PciIo.h>
> -#include <Protocol/CpuIo2.h>
> -#include <Protocol/LoadedImage.h>
> -#include <Protocol/DiskInfo.h>
> -#include <Protocol/GraphicsOutput.h>
> -#include <Protocol/UgaDraw.h>
> -#include <Protocol/GenericMemoryTest.h>
> -#include <Protocol/DevicePathToText.h>
> -#include <Protocol/FirmwareVolume2.h>
> -#include <Protocol/SimpleFileSystem.h>
> -
> -#include <Guid/CapsuleVendor.h>
> -#include <Guid/MemoryTypeInformation.h>
> -#include <Guid/GlobalVariable.h>
> -#include <Guid/MemoryOverwriteControl.h>
> -#include <Guid/FileInfo.h>
> -#include <Library/DebugLib.h>
> -#include <Library/BaseMemoryLib.h>
> -#include <Library/UefiBootServicesTableLib.h>
> -#include <Library/UefiRuntimeServicesTableLib.h>
> -#include <Library/MemoryAllocationLib.h>
> -#include <Library/BaseLib.h>
> -#include <Library/PcdLib.h>
> -#include <Library/PlatformBootManagerLib.h>
> -#include <Library/DevicePathLib.h>
> -#include <Library/UefiLib.h>
> -#include <Library/HobLib.h>
> -#include <Library/DxeServicesLib.h>
> -#include <Library/DxeServicesTableLib.h>
> -#include <Library/PrintLib.h>
> -#include <Library/HiiLib.h>
> -#include <Library/CapsuleLib.h>
> -#include <Library/PerformanceLib.h>
> -
> -#include <IndustryStandard/Pci30.h>
> -#include <IndustryStandard/PciCodeId.h>
> -
> -///
> -/// ConnectType
> -///
> -#define CONSOLE_OUT 0x00000001
> -#define STD_ERROR 0x00000002
> -#define CONSOLE_IN 0x00000004
> -#define CONSOLE_ALL (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)
> -
> -extern EFI_GUID gUefiShellFileGuid;
> -extern EFI_BOOT_MODE gBootMode;
> -
> -#define gPciRootBridge \
> - { \
> - { \
> - ACPI_DEVICE_PATH, \
> - ACPI_DP, \
> - { \
> - (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \
> - (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \
> - }, \
> - }, \
> - EISA_PNP_ID (0x0A03), \
> - 0 \
> - }
> -
> -#define gEndEntire \
> - { \
> - END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { END_DEVICE_PATH_LENGTH, 0 } \
> - }
> -
> -typedef struct {
> - EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> - UINTN ConnectType;
> -} BDS_CONSOLE_CONNECT_ENTRY;
> -
> -//
> -// Platform Root Bridge
> -//
> -typedef struct {
> - ACPI_HID_DEVICE_PATH PciRootBridge;
> - EFI_DEVICE_PATH_PROTOCOL End;
> -} PLATFORM_ROOT_BRIDGE_DEVICE_PATH;
> -
> -//
> -// Below is the platform console device path
> -//
> -typedef struct {
> - ACPI_HID_DEVICE_PATH PciRootBridge;
> - PCI_DEVICE_PATH IsaBridge;
> - ACPI_HID_DEVICE_PATH Keyboard;
> - EFI_DEVICE_PATH_PROTOCOL End;
> -} PLATFORM_KEYBOARD_DEVICE_PATH;
> -
> -typedef struct {
> - ACPI_HID_DEVICE_PATH PciRootBridge;
> - PCI_DEVICE_PATH PciDevice;
> - EFI_DEVICE_PATH_PROTOCOL End;
> -} PLATFORM_ONBOARD_CONTROLLER_DEVICE_PATH;
> -
> -typedef struct {
> - ACPI_HID_DEVICE_PATH PciRootBridge;
> - PCI_DEVICE_PATH Pci0Device;
> - EFI_DEVICE_PATH_PROTOCOL End;
> -} PLATFORM_PEG_ROOT_CONTROLLER_DEVICE_PATH;
> -
> -typedef struct {
> - ACPI_HID_DEVICE_PATH PciRootBridge;
> - PCI_DEVICE_PATH PciBridge;
> - PCI_DEVICE_PATH PciDevice;
> - EFI_DEVICE_PATH_PROTOCOL End;
> -} PLATFORM_PCI_CONTROLLER_DEVICE_PATH;
> -
> -//
> -// Below is the boot option device path
> -//
> -
> -#define CLASS_HID 3
> -#define SUBCLASS_BOOT 1
> -#define PROTOCOL_KEYBOARD 1
> -
> -typedef struct {
> - USB_CLASS_DEVICE_PATH UsbClass;
> - EFI_DEVICE_PATH_PROTOCOL End;
> -} USB_CLASS_FORMAT_DEVICE_PATH;
> -
> -extern USB_CLASS_FORMAT_DEVICE_PATH gUsbClassKeyboardDevicePath;
> -
> -//
> -// Platform BDS Functions
> -//
> -
> -
> -/**
> - Perform the memory test base on the memory test intensive level,
> - and update the memory resource.
> -
> - @param Level The memory test intensive level.
> -
> - @retval EFI_STATUS Success test all the system memory and update
> - the memory resource
> -
> -**/
> -EFI_STATUS
> -MemoryTest (
> - IN EXTENDMEM_COVERAGE_LEVEL Level
> - );
> -
> -VOID
> -ConnectSequence (
> - IN EFI_BOOT_MODE BootMode
> - );
> -
> -
> -INTN
> -EFIAPI
> -CompareBootOption (
> - CONST VOID *Left,
> - CONST VOID *Right
> - );
> -
> -
> -VOID
> -RegisterStaticHotkey (
> - VOID
> - );
> -VOID
> -RegisterDefaultBootOption (
> - VOID
> - );
> + #include <Library/DebugLib.h>
> + #include <Library/UefiBootServicesTableLib.h>
> + #include <Library/PlatformBootManagerLib.h>
> + #include <Library/UefiLib.h>
> + #include <Library/HobLib.h>
> + #include <Library/PrintLib.h>
> + #include <Library/PerformanceLib.h>
> + #include <Library/BoardBootManagerLib.h>
>
> #endif
> diff --git a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLib.inf b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLib.inf
> index 388ffd808b..4f7299f1df 100644
> --- a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLib.inf
> +++ b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLib.inf
> @@ -23,23 +23,13 @@
>
> [LibraryClasses]
> BaseLib
> - MemoryAllocationLib
> UefiBootServicesTableLib
> - UefiRuntimeServicesTableLib
> - BaseMemoryLib
> DebugLib
> - PcdLib
> - PrintLib
> - DevicePathLib
> UefiLib
> HobLib
> - DxeServicesLib
> - DxeServicesTableLib
> - HiiLib
> UefiBootManagerLib
> PerformanceLib
> - TimerLib
> - Tcg2PhysicalPresenceLib
> + BoardBootManagerLib
>
> [Packages]
> MdePkg/MdePkg.dec
> @@ -47,47 +37,18 @@
> SecurityPkg/SecurityPkg.dec
> MinPlatformPkg/MinPlatformPkg.dec
>
> -[Pcd]
> - gMinPlatformPkgTokenSpaceGuid.PcdTpm2Enable ## CONSUMES
> - gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut ## PRODUCES
> - gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution ## PRODUCES
> - gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution ## PRODUCES
> - gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow ## PRODUCES
> - gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn ## PRODUCES
> - gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutColumn ## CONSUMES
> - gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutRow ## CONSUMES
> - gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution ## CONSUMES
> - gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution ## CONSUMES
> - gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand ## PRODUCES
> - gMinPlatformPkgTokenSpaceGuid.PcdPlatformMemoryCheckLevel ## CONSUMES
> - gMinPlatformPkgTokenSpaceGuid.PcdBootToShellOnly ## CONSUMES
> - gMinPlatformPkgTokenSpaceGuid.PcdTrustedConsoleInputDevicePath ## CONSUMES
> - gMinPlatformPkgTokenSpaceGuid.PcdTrustedConsoleOutputDevicePath ## CONSUMES
> - gMinPlatformPkgTokenSpaceGuid.PcdTrustedStorageDevicePath ## CONSUMES
> -
> [Sources]
> BdsPlatform.c
> BdsPlatform.h
> - PlatformBootOption.c
> - MemoryTest.c
>
> [Protocols]
> - gEfiPciRootBridgeIoProtocolGuid ## CONSUMES
> - gEfiPciIoProtocolGuid ## CONSUMES
> - gEfiCpuIo2ProtocolGuid ## CONSUMES
> - gEfiDxeSmmReadyToLockProtocolGuid ## PRODUCES
> - gEfiGenericMemTestProtocolGuid ## CONSUMES
> - gEfiDiskInfoProtocolGuid ## CONSUMES
> - gEfiDevicePathToTextProtocolGuid ## CONSUMES
> - gEfiSimpleTextInputExProtocolGuid ## CONSUMES
> - gEfiFirmwareVolume2ProtocolGuid ## CONSUMES
> - gEfiFormBrowser2ProtocolGuid ## CONSUMES
> - gEfiGenericMemTestProtocolGuid ## CONSUMES
> + gEfiDxeSmmReadyToLockProtocolGuid ## PRODUCES
>
> [Guids]
> - gEfiGlobalVariableGuid ## PRODUCES
> - gEfiMemoryOverwriteControlDataGuid ## PRODUCES
> - gEfiEndOfDxeEventGroupGuid ## CONSUMES
> + gEfiEndOfDxeEventGroupGuid ## CONSUMES
> + gBdsEventBeforeConsoleAfterTrustedConsoleGuid
> + gBdsEventBeforeConsoleBeforeEndOfDxeGuid
> + gBdsEventAfterConsoleReadyBeforeBootOptionGuid
>
> [Depex.common.DXE_DRIVER]
> gEfiVariableArchProtocolGuid
> diff --git a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/MemoryTest.c b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/MemoryTest.c
> deleted file mode 100644
> index 654845349a..0000000000
> --- a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/MemoryTest.c
> +++ /dev/null
> @@ -1,83 +0,0 @@
> -/** @file
> - Perform the platform memory test
> -
> -Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
> -SPDX-License-Identifier: BSD-2-Clause-Patent
> -
> -**/
> -
> -#include "BdsPlatform.h"
> -#include <Protocol/GenericMemoryTest.h>
> -
> -/**
> - Perform the memory test base on the memory test intensive level,
> - and update the memory resource.
> -
> - @param Level The memory test intensive level.
> -
> - @retval EFI_STATUS Success test all the system memory and update
> - the memory resource
> -
> -**/
> -EFI_STATUS
> -MemoryTest (
> - IN EXTENDMEM_COVERAGE_LEVEL Level
> - )
> -{
> - EFI_STATUS Status;
> - BOOLEAN RequireSoftECCInit;
> - EFI_GENERIC_MEMORY_TEST_PROTOCOL *GenMemoryTest;
> - UINT64 TestedMemorySize;
> - UINT64 TotalMemorySize;
> - BOOLEAN ErrorOut;
> - BOOLEAN TestAbort;
> -
> - TestedMemorySize = 0;
> - TotalMemorySize = 0;
> - ErrorOut = FALSE;
> - TestAbort = FALSE;
> -
> - RequireSoftECCInit = FALSE;
> -
> - Status = gBS->LocateProtocol (
> - &gEfiGenericMemTestProtocolGuid,
> - NULL,
> - (VOID **) &GenMemoryTest
> - );
> - if (EFI_ERROR (Status)) {
> - return EFI_SUCCESS;
> - }
> -
> - Status = GenMemoryTest->MemoryTestInit (
> - GenMemoryTest,
> - Level,
> - &RequireSoftECCInit
> - );
> - if (Status == EFI_NO_MEDIA) {
> - //
> - // The PEI codes also have the relevant memory test code to check the memory,
> - // it can select to test some range of the memory or all of them. If PEI code
> - // checks all the memory, this BDS memory test will has no not-test memory to
> - // do the test, and then the status of EFI_NO_MEDIA will be returned by
> - // "MemoryTestInit". So it does not need to test memory again, just return.
> - //
> - return EFI_SUCCESS;
> - }
> -
> - do {
> - Status = GenMemoryTest->PerformMemoryTest (
> - GenMemoryTest,
> - &TestedMemorySize,
> - &TotalMemorySize,
> - &ErrorOut,
> - TestAbort
> - );
> - if (ErrorOut && (Status == EFI_DEVICE_ERROR)) {
> - ASSERT (0);
> - }
> - } while (Status != EFI_NOT_FOUND);
> -
> - Status = GenMemoryTest->Finished (GenMemoryTest);
> -
> - return EFI_SUCCESS;
> -}
> diff --git a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/PlatformBootOption.c b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/PlatformBootOption.c
> deleted file mode 100644
> index 84aa097d58..0000000000
> --- a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/PlatformBootOption.c
> +++ /dev/null
> @@ -1,559 +0,0 @@
> -/** @file
> - Driver for Platform Boot Options support.
> -
> -Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
> -SPDX-License-Identifier: BSD-2-Clause-Patent
> -
> -**/
> -
> -#include "BdsPlatform.h"
> -
> -#include <Library/PcdLib.h>
> -
> -BOOLEAN mContinueBoot = FALSE;
> -BOOLEAN mBootMenuBoot = FALSE;
> -BOOLEAN mPxeBoot = FALSE;
> -BOOLEAN mHotKeypressed = FALSE;
> -EFI_EVENT HotKeyEvent = NULL;
> -
> -UINTN mBootMenuOptionNumber;
> -
> -EFI_DEVICE_PATH_PROTOCOL *
> -BdsCreateShellDevicePath (
> - VOID
> - )
> -/*++
> -
> -Routine Description:
> -
> - This function will create a SHELL BootOption to boot.
> -
> -Arguments:
> -
> - None.
> -
> -Returns:
> -
> - Shell Device path for booting.
> -
> ---*/
> -{
> - UINTN FvHandleCount;
> - EFI_HANDLE *FvHandleBuffer;
> - UINTN Index;
> - EFI_STATUS Status;
> - EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
> - UINTN Size;
> - UINT32 AuthenticationStatus;
> - EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> - VOID *Buffer;
> -
> - DevicePath = NULL;
> - Status = EFI_SUCCESS;
> -
> - DEBUG ((DEBUG_INFO, "BdsCreateShellDevicePath\n"));
> - gBS->LocateHandleBuffer (
> - ByProtocol,
> - &gEfiFirmwareVolume2ProtocolGuid,
> - NULL,
> - &FvHandleCount,
> - &FvHandleBuffer
> - );
> -
> - for (Index = 0; Index < FvHandleCount; Index++) {
> - gBS->HandleProtocol (
> - FvHandleBuffer[Index],
> - &gEfiFirmwareVolume2ProtocolGuid,
> - (VOID **) &Fv
> - );
> -
> - Buffer = NULL;
> - Size = 0;
> - Status = Fv->ReadSection (
> - Fv,
> - &gUefiShellFileGuid,
> - EFI_SECTION_PE32,
> - 0,
> - &Buffer,
> - &Size,
> - &AuthenticationStatus
> - );
> - if (EFI_ERROR (Status)) {
> - //
> - // Skip if no shell file in the FV
> - //
> - continue;
> - } else {
> - //
> - // Found the shell
> - //
> - break;
> - }
> - }
> -
> - if (EFI_ERROR (Status)) {
> - //
> - // No shell present
> - //
> - if (FvHandleCount) {
> - FreePool (FvHandleBuffer);
> - }
> - return NULL;
> - }
> - //
> - // Build the shell boot option
> - //
> - DevicePath = DevicePathFromHandle (FvHandleBuffer[Index]);
> -
> - if (FvHandleCount) {
> - FreePool (FvHandleBuffer);
> - }
> -
> - return DevicePath;
> -}
> -
> -
> -EFI_STATUS
> -CreateFvBootOption (
> - EFI_GUID *FileGuid,
> - CHAR16 *Description,
> - EFI_BOOT_MANAGER_LOAD_OPTION *BootOption,
> - UINT32 Attributes,
> - UINT8 *OptionalData, OPTIONAL
> - UINT32 OptionalDataSize
> - )
> -{
> - EFI_STATUS Status;
> - EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> - EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
> - MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
> - EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
> - UINT32 AuthenticationStatus;
> - VOID *Buffer;
> - UINTN Size;
> -
> - if ((BootOption == NULL) || (FileGuid == NULL) || (Description == NULL)) {
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);
> -
> - if (!CompareGuid (&gUefiShellFileGuid, FileGuid)) {
> - Status = gBS->HandleProtocol (
> - gImageHandle,
> - &gEfiLoadedImageProtocolGuid,
> - (VOID **) &LoadedImage
> - );
> - if (!EFI_ERROR (Status)) {
> - Status = gBS->HandleProtocol (
> - LoadedImage->DeviceHandle,
> - &gEfiFirmwareVolume2ProtocolGuid,
> - (VOID **) &Fv
> - );
> - if (!EFI_ERROR (Status)) {
> - Buffer = NULL;
> - Size = 0;
> - Status = Fv->ReadSection (
> - Fv,
> - FileGuid,
> - EFI_SECTION_PE32,
> - 0,
> - &Buffer,
> - &Size,
> - &AuthenticationStatus
> - );
> - if (Buffer != NULL) {
> - FreePool (Buffer);
> - }
> - }
> - }
> - if (EFI_ERROR (Status)) {
> - return EFI_NOT_FOUND;
> - }
> -
> - DevicePath = AppendDevicePathNode (
> - DevicePathFromHandle (LoadedImage->DeviceHandle),
> - (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
> - );
> - } else {
> - DevicePath = AppendDevicePathNode (
> - BdsCreateShellDevicePath (),
> - (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
> - );
> - }
> -
> - Status = EfiBootManagerInitializeLoadOption (
> - BootOption,
> - LoadOptionNumberUnassigned,
> - LoadOptionTypeBoot,
> - Attributes,
> - Description,
> - DevicePath,
> - OptionalData,
> - OptionalDataSize
> - );
> - FreePool (DevicePath);
> - return Status;
> -}
> -
> -EFI_GUID mUiFile = {
> - 0x462CAA21, 0x7614, 0x4503, { 0x83, 0x6E, 0x8A, 0xB6, 0xF4, 0x66, 0x23, 0x31 }
> -};
> -EFI_GUID mBootMenuFile = {
> - 0xEEC25BDC, 0x67F2, 0x4D95, { 0xB1, 0xD5, 0xF8, 0x1B, 0x20, 0x39, 0xD1, 0x1D }
> -};
> -
> -
> -/**
> - Return the index of the load option in the load option array.
> -
> - The function consider two load options are equal when the
> - OptionType, Attributes, Description, FilePath and OptionalData are equal.
> -
> - @param Key Pointer to the load option to be found.
> - @param Array Pointer to the array of load options to be found.
> - @param Count Number of entries in the Array.
> -
> - @retval -1 Key wasn't found in the Array.
> - @retval 0 ~ Count-1 The index of the Key in the Array.
> -**/
> -INTN
> -PlatformFindLoadOption (
> - IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Key,
> - IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Array,
> - IN UINTN Count
> - )
> -{
> - UINTN Index;
> -
> - for (Index = 0; Index < Count; Index++) {
> - if ((Key->OptionType == Array[Index].OptionType) &&
> - (Key->Attributes == Array[Index].Attributes) &&
> - (StrCmp (Key->Description, Array[Index].Description) == 0) &&
> - (CompareMem (Key->FilePath, Array[Index].FilePath, GetDevicePathSize (Key->FilePath)) == 0) &&
> - (Key->OptionalDataSize == Array[Index].OptionalDataSize) &&
> - (CompareMem (Key->OptionalData, Array[Index].OptionalData, Key->OptionalDataSize) == 0)) {
> - return (INTN) Index;
> - }
> - }
> -
> - return -1;
> -}
> -
> -UINTN
> -RegisterFvBootOption (
> - EFI_GUID *FileGuid,
> - CHAR16 *Description,
> - UINTN Position,
> - UINT32 Attributes,
> - UINT8 *OptionalData, OPTIONAL
> - UINT32 OptionalDataSize
> - )
> -{
> - EFI_STATUS Status;
> - UINTN OptionIndex;
> - EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
> - EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
> - UINTN BootOptionCount;
> -
> - NewOption.OptionNumber = LoadOptionNumberUnassigned;
> - Status = CreateFvBootOption (FileGuid, Description, &NewOption, Attributes, OptionalData, OptionalDataSize);
> - if (!EFI_ERROR (Status)) {
> - BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);
> -
> - OptionIndex = PlatformFindLoadOption (&NewOption, BootOptions, BootOptionCount);
> -
> - if (OptionIndex == -1) {
> - Status = EfiBootManagerAddLoadOptionVariable (&NewOption, Position);
> - ASSERT_EFI_ERROR (Status);
> - } else {
> - NewOption.OptionNumber = BootOptions[OptionIndex].OptionNumber;
> - }
> - EfiBootManagerFreeLoadOption (&NewOption);
> - EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
> - }
> -
> - return NewOption.OptionNumber;
> -}
> -
> -
> -
> -VOID
> -EFIAPI
> -PlatformBootManagerWaitCallback (
> - UINT16 TimeoutRemain
> - )
> -{
> - EFI_STATUS Status;
> - EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TxtInEx;
> - EFI_KEY_DATA KeyData;
> - BOOLEAN PausePressed;
> -
> - //
> - // Pause on PAUSE key
> - //
> - Status = gBS->HandleProtocol (gST->ConsoleInHandle, &gEfiSimpleTextInputExProtocolGuid, (VOID **) &TxtInEx);
> - ASSERT_EFI_ERROR (Status);
> -
> - PausePressed = FALSE;
> -
> - while (TRUE) {
> - Status = TxtInEx->ReadKeyStrokeEx (TxtInEx, &KeyData);
> - if (EFI_ERROR (Status)) {
> - break;
> - }
> -
> - if (KeyData.Key.ScanCode == SCAN_PAUSE) {
> - PausePressed = TRUE;
> - break;
> - }
> - }
> -
> - //
> - // Loop until non-PAUSE key pressed
> - //
> - while (PausePressed) {
> - Status = TxtInEx->ReadKeyStrokeEx (TxtInEx, &KeyData);
> - if (!EFI_ERROR (Status)) {
> - DEBUG ((
> - DEBUG_INFO, "[PauseCallback] %x/%x %x/%x\n",
> - KeyData.Key.ScanCode, KeyData.Key.UnicodeChar,
> - KeyData.KeyState.KeyShiftState, KeyData.KeyState.KeyToggleState
> - ));
> - PausePressed = (BOOLEAN) (KeyData.Key.ScanCode == SCAN_PAUSE);
> - }
> - }
> -}
> -
> -
> -EFI_GUID gUefiShellFileGuid = { 0x7C04A583, 0x9E3E, 0x4f1c, { 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 } };
> -
> -#define INTERNAL_UEFI_SHELL_NAME L"Internal UEFI Shell 2.0"
> -#define UEFI_HARD_DRIVE_NAME L"UEFI Hard Drive"
> -
> -VOID
> -RegisterDefaultBootOption (
> - VOID
> - )
> -{
> -#if 0
> - EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> - EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
> - MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
> -#endif
> - UINT16 *ShellData;
> - UINT32 ShellDataSize;
> -
> - ShellData = NULL;
> - ShellDataSize = 0;
> - RegisterFvBootOption (&gUefiShellFileGuid, INTERNAL_UEFI_SHELL_NAME, (UINTN) -1, LOAD_OPTION_ACTIVE, (UINT8 *)ShellData, ShellDataSize);
> -
> - //
> - // Boot Menu
> - //
> - mBootMenuOptionNumber = RegisterFvBootOption (&mBootMenuFile, L"Boot Device List", (UINTN) -1, LOAD_OPTION_CATEGORY_APP | LOAD_OPTION_ACTIVE | LOAD_OPTION_HIDDEN, NULL, 0);
> -
> - if (mBootMenuOptionNumber == LoadOptionNumberUnassigned) {
> - DEBUG ((DEBUG_INFO, "BootMenuOptionNumber (%d) should not be same to LoadOptionNumberUnassigned(%d).\n", mBootMenuOptionNumber, LoadOptionNumberUnassigned));
> - }
> -#if 0
> - //
> - // Boot Manager Menu
> - //
> - EfiInitializeFwVolDevicepathNode (&FileNode, &mUiFile);
> -
> - gBS->HandleProtocol (
> - gImageHandle,
> - &gEfiLoadedImageProtocolGuid,
> - (VOID **) &LoadedImage
> - );
> - DevicePath = AppendDevicePathNode (DevicePathFromHandle (LoadedImage->DeviceHandle), (EFI_DEVICE_PATH_PROTOCOL *) &FileNode);
> -#endif
> -
> -}
> -
> -VOID
> -RegisterBootOptionHotkey (
> - UINT16 OptionNumber,
> - EFI_INPUT_KEY *Key,
> - BOOLEAN Add
> - )
> -{
> - EFI_STATUS Status;
> -
> - if (!Add) {
> - //
> - // No enter hotkey when force to setup or there is no boot option
> - //
> - Status = EfiBootManagerDeleteKeyOptionVariable (NULL, 0, Key, NULL);
> - ASSERT (Status == EFI_SUCCESS || Status == EFI_NOT_FOUND);
> - } else {
> - //
> - // Register enter hotkey for the first boot option
> - //
> - Status = EfiBootManagerAddKeyOptionVariable (NULL, OptionNumber, 0, Key,NULL);
> - ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
> - }
> -}
> -
> -EFI_STATUS
> -EFIAPI
> -DetectKeypressCallback (
> - IN EFI_KEY_DATA *KeyData
> -)
> -{
> - mHotKeypressed = TRUE;
> -
> - if (HotKeyEvent != NULL) {
> - gBS->SignalEvent(HotKeyEvent);
> - }
> -
> - return EFI_SUCCESS;
> -}
> -
> -/**
> - This function is called after all the boot options are enumerated and ordered properly.
> -**/
> -VOID
> -RegisterStaticHotkey (
> - VOID
> - )
> -{
> -
> - EFI_INPUT_KEY Enter;
> - EFI_KEY_DATA F2;
> - EFI_KEY_DATA F7;
> - BOOLEAN EnterSetup;
> - EFI_STATUS Status;
> - EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
> -
> - EnterSetup = FALSE;
> -
> - //
> - // [Enter]
> - //
> - mContinueBoot = !EnterSetup;
> - if (mContinueBoot) {
> - Enter.ScanCode = SCAN_NULL;
> - Enter.UnicodeChar = CHAR_CARRIAGE_RETURN;
> - EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL);
> - }
> -
> -
> - //
> - // [F2]/[F7]
> - //
> - F2.Key.ScanCode = SCAN_F2;
> - F2.Key.UnicodeChar = CHAR_NULL;
> - F2.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID;
> - F2.KeyState.KeyToggleState = 0;
> - Status = EfiBootManagerGetBootManagerMenu (&BootOption);
> - ASSERT_EFI_ERROR (Status);
> - RegisterBootOptionHotkey ((UINT16) BootOption.OptionNumber, &F2.Key, TRUE);
> - EfiBootManagerFreeLoadOption (&BootOption);
> -
> - F7.Key.ScanCode = SCAN_F7;
> - F7.Key.UnicodeChar = CHAR_NULL;
> - F7.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID;
> - F7.KeyState.KeyToggleState = 0;
> - mBootMenuBoot = !EnterSetup;
> - RegisterBootOptionHotkey ((UINT16) mBootMenuOptionNumber, &F7.Key, mBootMenuBoot);
> -
> -}
> -
> -UINT8
> -BootOptionType (
> - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
> - )
> -{
> - EFI_DEVICE_PATH_PROTOCOL *Node;
> - EFI_DEVICE_PATH_PROTOCOL *NextNode;
> -
> - for (Node = DevicePath; !IsDevicePathEndType (Node); Node = NextDevicePathNode (Node)) {
> - if (DevicePathType (Node) == MESSAGING_DEVICE_PATH) {
> - //
> - // Make sure the device path points to the driver device.
> - //
> - NextNode = NextDevicePathNode (Node);
> - if (DevicePathSubType(NextNode) == MSG_DEVICE_LOGICAL_UNIT_DP) {
> - //
> - // if the next node type is Device Logical Unit, which specify the Logical Unit Number (LUN),
> - // skip it
> - //
> - NextNode = NextDevicePathNode (NextNode);
> - }
> - if (IsDevicePathEndType (NextNode)) {
> - if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH)) {
> - return DevicePathSubType (Node);
> - } else {
> - return MSG_SATA_DP;
> - }
> - }
> - }
> - }
> -
> - return (UINT8) -1;
> -}
> -
> -/**
> - Returns the priority number.
> - OptionType EFI
> - ------------------------------------
> - PXE 2
> - DVD 4
> - USB 6
> - NVME 7
> - HDD 8
> - EFI Shell 9
> - Others 100
> -
> - @param BootOption
> -**/
> -UINTN
> -BootOptionPriority (
> - CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOption
> - )
> -{
> - //
> - // EFI boot options
> - //
> - switch (BootOptionType (BootOption->FilePath)) {
> - case MSG_MAC_ADDR_DP:
> - case MSG_VLAN_DP:
> - case MSG_IPv4_DP:
> - case MSG_IPv6_DP:
> - return 2;
> -
> - case MSG_SATA_DP:
> - case MSG_ATAPI_DP:
> - case MSG_UFS_DP:
> - case MSG_NVME_NAMESPACE_DP:
> - return 4;
> -
> - case MSG_USB_DP:
> - return 6;
> -
> - }
> - if (StrCmp (BootOption->Description, INTERNAL_UEFI_SHELL_NAME) == 0) {
> - if (PcdGetBool (PcdBootToShellOnly)) {
> - return 0;
> - }
> - return 9;
> - }
> - if (StrCmp (BootOption->Description, UEFI_HARD_DRIVE_NAME) == 0) {
> - return 8;
> - }
> - return 100;
> -}
> -
> -INTN
> -EFIAPI
> -CompareBootOption (
> - CONST VOID *Left,
> - CONST VOID *Right
> - )
> -{
> - return BootOptionPriority ((EFI_BOOT_MANAGER_LOAD_OPTION *) Left) -
> - BootOptionPriority ((EFI_BOOT_MANAGER_LOAD_OPTION *) Right);
> -}
> -
> --
> 2.19.1.windows.1
>
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [edk2-platforms] [PATCH 05/11] MinPlatformPkg: Add BDS Hook Points
2019-12-14 1:32 ` [edk2-platforms] [PATCH 05/11] MinPlatformPkg: Add BDS Hook Points Agyeman, Prince
2019-12-17 5:44 ` Chiu, Chasel
2019-12-18 1:33 ` Nate DeSimone
@ 2019-12-21 2:36 ` Kubacki, Michael A
2 siblings, 0 replies; 45+ messages in thread
From: Kubacki, Michael A @ 2019-12-21 2:36 UTC (permalink / raw)
To: Agyeman, Prince, devel@edk2.groups.io; +Cc: Chiu, Chasel, Desimone, Nathaniel L
Reviewed-by: Michael Kubacki <michael.a.kubacki@intel.com>
> -----Original Message-----
> From: Agyeman, Prince <prince.agyeman@intel.com>
> Sent: Friday, December 13, 2019 5:33 PM
> To: devel@edk2.groups.io
> Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Chiu, Chasel
> <chasel.chiu@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>
> Subject: [edk2-platforms] [PATCH 05/11] MinPlatformPkg: Add BDS Hook
> Points
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
>
> Added BDS hook points to the Minplatform boot manager library
> as defined in the Minimum Platfrom specifcations.
>
> Changes made:
>
> * Added functions to signal three BDS event groups.
> These event groups are BeforeConsoleAfterTrustedConsole,
> BeforeConsoleBeforeEndOfDxe and AfterConsoleReadyBeforeBootOption.
>
> * Removed BDS functionalities from the boot manager library.
> These functionalities will be added to callbacks a module in BoardModule,
> which will then register/hook to the BDS hook points
>
> See https://edk2-docs.gitbooks.io/edk-ii-minimum-platform-specification,
> under Appendix A.3 BDS Hook Points, for more details.
>
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
>
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
> .../DxePlatformBootManagerLib/BdsPlatform.c | 1262 ++---------------
> .../DxePlatformBootManagerLib/BdsPlatform.h | 181 +--
> .../DxePlatformBootManagerLib.inf | 51 +-
> .../DxePlatformBootManagerLib/MemoryTest.c | 83 --
> .../PlatformBootOption.c | 559 --------
> 5 files changed, 112 insertions(+), 2024 deletions(-)
> delete mode 100644
> Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/M
> emoryTest.c
> delete mode 100644
> Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/Pl
> atformBootOption.c
>
> diff --git
> a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/
> BdsPlatform.c
> b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib
> /BdsPlatform.c
> index 491fb0f26f..31a9ef4a07 100644
> ---
> a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/
> BdsPlatform.c
> +++
> b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib
> /BdsPlatform.c
> @@ -1,130 +1,14 @@
> /** @file
> This file include all platform action which can be customized by IBV/OEM.
>
> -Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
> **/
>
> #include "BdsPlatform.h"
> -#include <Guid/EventGroup.h>
> -#include <Protocol/DxeSmmReadyToLock.h>
> -#include <Protocol/FirmwareVolume2.h>
> -#include <Protocol/PciRootBridgeIo.h>
>
> -#include <Protocol/BlockIo.h>
> -#include <Protocol/PciIo.h>
> -#include <Library/IoLib.h>
> -#include <Library/PciLib.h>
> -#include <Guid/EventGroup.h>
> -
> -#include <Library/Tcg2PhysicalPresenceLib.h>
> -
> -#include <Library/HobLib.h>
> -#include <Protocol/UsbIo.h>
> -
> -#include <Library/UefiBootManagerLib.h>
> -
> -GLOBAL_REMOVE_IF_UNREFERENCED EFI_BOOT_MODE
> gBootMode;
> -
> -BOOLEAN gPPRequireUIConfirm;
> -
> -extern UINTN mBootMenuOptionNumber;
> -
> -GLOBAL_REMOVE_IF_UNREFERENCED USB_CLASS_FORMAT_DEVICE_PATH
> gUsbClassKeyboardDevicePath = {
> - {
> - {
> - MESSAGING_DEVICE_PATH,
> - MSG_USB_CLASS_DP,
> - {
> - (UINT8) (sizeof (USB_CLASS_DEVICE_PATH)),
> - (UINT8) ((sizeof (USB_CLASS_DEVICE_PATH)) >> 8)
> - }
> - },
> - 0xffff, // VendorId
> - 0xffff, // ProductId
> - CLASS_HID, // DeviceClass
> - SUBCLASS_BOOT, // DeviceSubClass
> - PROTOCOL_KEYBOARD // DeviceProtocol
> - },
> - gEndEntire
> -};
> -
> -//
> -// Internal shell mode
> -//
> -GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mShellModeColumn;
> -GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mShellModeRow;
> -GLOBAL_REMOVE_IF_UNREFERENCED UINT32
> mShellHorizontalResolution;
> -GLOBAL_REMOVE_IF_UNREFERENCED UINT32
> mShellVerticalResolution;
> -//
> -// BDS Platform Functions
> -//
> -
> -BOOLEAN
> -IsMorBitSet (
> - VOID
> - )
> -{
> - UINTN MorControl;
> - EFI_STATUS Status;
> - UINTN DataSize;
> -
> - //
> - // Check if the MOR bit is set.
> - //
> - DataSize = sizeof (MorControl);
> - Status = gRT->GetVariable (
> - MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME,
> - &gEfiMemoryOverwriteControlDataGuid,
> - NULL,
> - &DataSize,
> - &MorControl
> - );
> - if (EFI_ERROR (Status)) {
> - DEBUG ((DEBUG_INFO, " PlatformBootMangerLib:
> gEfiMemoryOverwriteControlDataGuid doesn't exist!!***\n"));
> - MorControl = 0;
> - } else {
> - DEBUG ((DEBUG_INFO, " PlatformBootMangerLib: Get the
> gEfiMemoryOverwriteControlDataGuid = %x!!***\n", MorControl));
> - }
> -
> - return (BOOLEAN) (MorControl & 0x01);
> -}
> -
> -VOID
> -DumpDevicePath (
> - IN CHAR16 *Name,
> - IN EFI_DEVICE_PATH *DevicePath
> - )
> -{
> - CHAR16 *Str;
> -
> - Str = ConvertDevicePathToText(DevicePath, TRUE, TRUE);
> - DEBUG ((DEBUG_INFO, "%s: %s\n", Name, Str));
> - if (Str != NULL) {
> - FreePool (Str);
> - }
> -}
> -
> -/**
> - An empty function to pass error checking of CreateEventEx ().
> -
> - This empty function ensures that EVT_NOTIFY_SIGNAL_ALL is error
> - checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0.
> -
> - @param Event Event whose notification function is being invoked.
> - @param Context The pointer to the notification function's context,
> - which is implementation-dependent.
> -**/
> -VOID
> -EFIAPI
> -InternalBdsEmptyCallbackFuntion (
> - IN EFI_EVENT Event,
> - IN VOID *Context
> - )
> -{
> - return;
> -}
> +extern UINTN mBootMenuOptionNumber;
>
> VOID
> ExitPmAuth (
> @@ -145,7 +29,7 @@ ExitPmAuth (
> Status = gBS->CreateEventEx (
> EVT_NOTIFY_SIGNAL,
> TPL_CALLBACK,
> - InternalBdsEmptyCallbackFuntion,
> + EfiEventEmptyFunction,
> NULL,
> &gEfiEndOfDxeEventGroupGuid,
> &EndOfDxeEvent
> @@ -172,918 +56,134 @@ ExitPmAuth (
> DEBUG((DEBUG_INFO,"ExitPmAuth ()- End\n"));
> }
>
> -VOID
> -ConnectRootBridge (
> - BOOLEAN Recursive
> - )
> -{
> - UINTN RootBridgeHandleCount;
> - EFI_HANDLE *RootBridgeHandleBuffer;
> - UINTN RootBridgeIndex;
> -
> - RootBridgeHandleCount = 0;
> - gBS->LocateHandleBuffer (
> - ByProtocol,
> - &gEfiPciRootBridgeIoProtocolGuid,
> - NULL,
> - &RootBridgeHandleCount,
> - &RootBridgeHandleBuffer
> - );
> - for (RootBridgeIndex = 0; RootBridgeIndex < RootBridgeHandleCount;
> RootBridgeIndex++) {
> - gBS->ConnectController (RootBridgeHandleBuffer[RootBridgeIndex],
> NULL, NULL, Recursive);
> - }
> -}
> -
>
> /**
> - Return whether the device is trusted console.
> -
> - @param Device The device to be tested.
> -
> - @retval TRUE The device can be trusted.
> - @retval FALSE The device cannot be trusted.
> -**/
> -BOOLEAN
> -IsTrustedConsole (
> - IN CONSOLE_TYPE ConsoleType,
> - IN EFI_DEVICE_PATH_PROTOCOL *Device
> - )
> -{
> - VOID *TrustedConsoleDevicepath;
> - EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
> - EFI_DEVICE_PATH_PROTOCOL *Instance;
> - UINTN Size;
> - EFI_DEVICE_PATH_PROTOCOL *ConsoleDevice;
> -
> - if (Device == NULL) {
> - return FALSE;
> - }
> -
> - ConsoleDevice = DuplicateDevicePath(Device);
> -
> - TrustedConsoleDevicepath = NULL;
> -
> - switch (ConsoleType) {
> - case ConIn:
> - TrustedConsoleDevicepath = PcdGetPtr
> (PcdTrustedConsoleInputDevicePath);
> - break;
> - case ConOut:
> - //
> - // Check GOP and remove last node
> - //
> - TempDevicePath = ConsoleDevice;
> - while (!IsDevicePathEndType (TempDevicePath)) {
> - if (DevicePathType (TempDevicePath) == ACPI_DEVICE_PATH &&
> - DevicePathSubType (TempDevicePath) == ACPI_ADR_DP) {
> - SetDevicePathEndNode (TempDevicePath);
> - break;
> - }
> - TempDevicePath = NextDevicePathNode (TempDevicePath);
> - }
> -
> - TrustedConsoleDevicepath = PcdGetPtr
> (PcdTrustedConsoleOutputDevicePath);
> - break;
> - default:
> - ASSERT(FALSE);
> - break;
> - }
> -
> - TempDevicePath = TrustedConsoleDevicepath;
> - do {
> - Instance = GetNextDevicePathInstance (&TempDevicePath, &Size);
> - if (Instance == NULL) {
> - break;
> - }
> -
> - if (CompareMem (ConsoleDevice, Instance, Size -
> END_DEVICE_PATH_LENGTH) == 0) {
> - FreePool (Instance);
> - FreePool (ConsoleDevice);
> - return TRUE;
> - }
> -
> - FreePool (Instance);
> - } while (TempDevicePath != NULL);
> -
> - FreePool (ConsoleDevice);
> + Creates an EFI event in the BDS Event Group.
>
> - return FALSE;
> -}
> -
> -BOOLEAN
> -IsUsbShortForm (
> - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
> - )
> -{
> - if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&
> - ((DevicePathSubType (DevicePath) == MSG_USB_CLASS_DP) ||
> (DevicePathSubType (DevicePath) == MSG_USB_WWID_DP)) ) {
> - return TRUE;
> - }
> + @param NotifyTpl The task priority level of the event.
> + @param gEfiEventGuid The GUID of the event group to signal.
> + @param BdsConsoleEvent Returns the EFI event returned from gBS-
> >CreateEvent(Ex).
>
> - return FALSE;
> -}
> -
> -/**
> - Connect the USB short form device path.
> + @retval EFI_SUCCESS Event was created.
> + @retval Other Event was not created.
>
> - @param DevicePath USB short form device path
> -
> - @retval EFI_SUCCESS Successfully connected the USB device
> - @retval EFI_NOT_FOUND Cannot connect the USB device
> - @retval EFI_INVALID_PARAMETER The device path is invalid.
> **/
> EFI_STATUS
> -ConnectUsbShortFormDevicePath (
> - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
> +EFIAPI
> +CreateBdsEvent (
> + IN EFI_TPL NotifyTpl,
> + IN EFI_GUID *gEfiEventGuid,
> + OUT EFI_EVENT *BdsConsoleEvent
> )
> {
> - EFI_STATUS Status;
> - EFI_HANDLE *Handles;
> - UINTN HandleCount;
> - UINTN Index;
> - EFI_PCI_IO_PROTOCOL *PciIo;
> - UINT8 Class[3];
> - BOOLEAN AtLeastOneConnected;
> + EFI_STATUS Status;
>
> - //
> - // Check the passed in parameters
> - //
> - if (DevicePath == NULL) {
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - if (!IsUsbShortForm (DevicePath)) {
> - return EFI_INVALID_PARAMETER;
> - }
> + ASSERT (BdsConsoleEvent != NULL);
>
> - //
> - // Find the usb host controller firstly, then connect with the remaining
> device path
> - //
> - AtLeastOneConnected = FALSE;
> - Status = gBS->LocateHandleBuffer (
> - ByProtocol,
> - &gEfiPciIoProtocolGuid,
> + Status = gBS->CreateEventEx (
> + EVT_NOTIFY_SIGNAL,
> + NotifyTpl,
> + EfiEventEmptyFunction,
> NULL,
> - &HandleCount,
> - &Handles
> - );
> - for (Index = 0; Index < HandleCount; Index++) {
> - Status = gBS->HandleProtocol (
> - Handles[Index],
> - &gEfiPciIoProtocolGuid,
> - (VOID **) &PciIo
> - );
> - if (!EFI_ERROR (Status)) {
> - //
> - // Check whether the Pci device is the wanted usb host controller
> - //
> - Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0x09, 3, &Class);
> - if (!EFI_ERROR (Status) &&
> - ((PCI_CLASS_SERIAL == Class[2]) && (PCI_CLASS_SERIAL_USB ==
> Class[1]))
> - ) {
> - Status = gBS->ConnectController (
> - Handles[Index],
> - NULL,
> - DevicePath,
> - FALSE
> - );
> - if (!EFI_ERROR(Status)) {
> - AtLeastOneConnected = TRUE;
> - }
> - }
> - }
> - }
> -
> - return AtLeastOneConnected ? EFI_SUCCESS : EFI_NOT_FOUND;
> -}
> -
> -/**
> - Update the ConIn variable with USB Keyboard device path,if its not already
> exists in ConIn
> -**/
> -VOID
> -EnumUsbKeyboard (
> - VOID
> - )
> -{
> - DEBUG ((DEBUG_INFO, "[EnumUsbKeyboard]\n"));
> - EfiBootManagerUpdateConsoleVariable (ConIn,
> (EFI_DEVICE_PATH_PROTOCOL *) &gUsbClassKeyboardDevicePath, NULL);
> -
> - //
> - // Append Usb Keyboard short form DevicePath into "ConInDev"
> - //
> - EfiBootManagerUpdateConsoleVariable (ConInDev,
> (EFI_DEVICE_PATH_PROTOCOL *) &gUsbClassKeyboardDevicePath, NULL);
> -}
> -
> -BOOLEAN
> -IsVgaHandle (
> - IN EFI_HANDLE Handle
> - )
> -{
> - EFI_PCI_IO_PROTOCOL *PciIo;
> - PCI_TYPE00 Pci;
> - EFI_STATUS Status;
> -
> - Status = gBS->HandleProtocol (
> - Handle,
> - &gEfiPciIoProtocolGuid,
> - (VOID **)&PciIo
> - );
> - if (!EFI_ERROR (Status)) {
> - Status = PciIo->Pci.Read (
> - PciIo,
> - EfiPciIoWidthUint32,
> - 0,
> - sizeof (Pci) / sizeof (UINT32),
> - &Pci
> - );
> - if (!EFI_ERROR (Status)) {
> - if (IS_PCI_VGA (&Pci) || IS_PCI_OLD_VGA (&Pci)) {
> - return TRUE;
> - }
> - }
> - }
> - return FALSE;
> -}
> -
> -EFI_HANDLE
> -IsVideoController (
> - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
> - )
> -{
> - EFI_DEVICE_PATH_PROTOCOL *DupDevicePath;
> - EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
> - EFI_STATUS Status;
> - EFI_HANDLE DeviceHandle;
> -
> - DupDevicePath = DuplicateDevicePath (DevicePath);
> - ASSERT (DupDevicePath != NULL);
> - if (DupDevicePath == NULL) {
> - return NULL;
> - }
> -
> - TempDevicePath = DupDevicePath;
> - Status = gBS->LocateDevicePath (
> - &gEfiDevicePathProtocolGuid,
> - &TempDevicePath,
> - &DeviceHandle
> + gEfiEventGuid,
> + BdsConsoleEvent
> );
> - FreePool (DupDevicePath);
> - if (EFI_ERROR (Status)) {
> - return NULL;
> - }
> -
> - if (IsVgaHandle (DeviceHandle)) {
> - return DeviceHandle;
> - } else {
> - return NULL;
> - }
> -}
> -
> -BOOLEAN
> -IsGopDevicePath (
> - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
> - )
> -{
> - while (!IsDevicePathEndType (DevicePath)) {
> - if (DevicePathType (DevicePath) == ACPI_DEVICE_PATH &&
> - DevicePathSubType (DevicePath) == ACPI_ADR_DP) {
> - return TRUE;
> - }
> - DevicePath = NextDevicePathNode (DevicePath);
> - }
> - return FALSE;
> -}
> -
> -/**
> - Remove all GOP device path instance from DevicePath and add the Gop to
> the DevicePath.
> -**/
> -EFI_DEVICE_PATH_PROTOCOL *
> -UpdateGopDevicePath (
> - EFI_DEVICE_PATH_PROTOCOL *DevicePath,
> - EFI_DEVICE_PATH_PROTOCOL *Gop
> - )
> -{
> - UINTN Size;
> - UINTN GopSize;
> - EFI_DEVICE_PATH_PROTOCOL *Temp;
> - EFI_DEVICE_PATH_PROTOCOL *Return;
> - EFI_DEVICE_PATH_PROTOCOL *Instance;
> - BOOLEAN Exist;
> -
> - Exist = FALSE;
> - Return = NULL;
> - GopSize = GetDevicePathSize (Gop);
> - do {
> - Instance = GetNextDevicePathInstance (&DevicePath, &Size);
> - if (Instance == NULL) {
> - break;
> - }
> - if (!IsGopDevicePath (Instance) ||
> - (Size == GopSize && CompareMem (Instance, Gop, GopSize) == 0)
> - ) {
> - if (Size == GopSize && CompareMem (Instance, Gop, GopSize) == 0) {
> - Exist = TRUE;
> - }
> - Temp = Return;
> - Return = AppendDevicePathInstance (Return, Instance);
> - if (Temp != NULL) {
> - FreePool (Temp);
> - }
> - }
> - FreePool (Instance);
> - } while (DevicePath != NULL);
>
> - if (!Exist) {
> - Temp = Return;
> - Return = AppendDevicePathInstance (Return, Gop);
> - if (Temp != NULL) {
> - FreePool (Temp);
> - }
> - }
> - return Return;
> + return Status;
> }
>
> /**
> - Get Graphics Controller Handle.
> -
> - @retval GraphicsController Successfully located
> - @retval NULL Failed to locate
> -**/
> -EFI_HANDLE
> -EFIAPI
> -GetGraphicsController (
> - IN BOOLEAN NeedTrustedConsole
> - )
> -{
> - EFI_STATUS Status;
> - UINTN Index;
> - EFI_HANDLE *PciHandles;
> - UINTN PciHandlesSize;
> - EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> -
> - Status = gBS->LocateHandleBuffer (
> - ByProtocol,
> - &gEfiPciIoProtocolGuid,
> - NULL,
> - &PciHandlesSize,
> - &PciHandles
> - );
> - if (EFI_ERROR (Status)) {
> - return NULL;
> - }
> -
> - for (Index = 0; Index < PciHandlesSize; Index++) {
> - Status = gBS->HandleProtocol (
> - PciHandles[Index],
> - &gEfiDevicePathProtocolGuid,
> - (VOID **) &DevicePath
> - );
> - if (EFI_ERROR(Status)) {
> - continue;
> - }
> - if (!IsVgaHandle (PciHandles[Index])) {
> - continue;
> - }
> - if ((NeedTrustedConsole && IsTrustedConsole (ConOut, DevicePath)) ||
> - ((!NeedTrustedConsole) && (!IsTrustedConsole (ConOut,
> DevicePath)))) {
> - return PciHandles[Index];
> - }
> - }
> -
> - return NULL;
> -}
> -
> -VOID
> -UpdateGraphicConOut (
> - IN BOOLEAN NeedTrustedConsole
> - )
> -{
> - EFI_HANDLE GraphicsControllerHandle;
> - EFI_DEVICE_PATH_PROTOCOL *GopDevicePath;
> - EFI_DEVICE_PATH_PROTOCOL *ConOutDevicePath;
> - EFI_DEVICE_PATH_PROTOCOL *UpdatedConOutDevicePath;
> + Create, Signal, and Close the Bds Event Before Console After
> + Trusted Console event using CreateBdsEvent().
>
> - //
> - // Update ConOut variable
> - //
> - GraphicsControllerHandle = GetGraphicsController (NeedTrustedConsole);
> - if (GraphicsControllerHandle != NULL) {
> - //
> - // Connect the GOP driver
> - //
> - gBS->ConnectController (GraphicsControllerHandle, NULL, NULL, TRUE);
> -
> - //
> - // Get the GOP device path
> - // NOTE: We may get a device path that contains Controller node in it.
> - //
> - GopDevicePath = EfiBootManagerGetGopDevicePath
> (GraphicsControllerHandle);
> - if (GopDevicePath != NULL) {
> - GetEfiGlobalVariable2 (L"ConOut", (VOID **)&ConOutDevicePath,
> NULL);
> - UpdatedConOutDevicePath = UpdateGopDevicePath
> (ConOutDevicePath, GopDevicePath);
> - if (ConOutDevicePath != NULL) {
> - FreePool (ConOutDevicePath);
> - }
> - FreePool (GopDevicePath);
> - gRT->SetVariable (
> - L"ConOut",
> - &gEfiGlobalVariableGuid,
> - EFI_VARIABLE_NON_VOLATILE |
> EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS,
> - GetDevicePathSize (UpdatedConOutDevicePath),
> - UpdatedConOutDevicePath
> - );
> - }
> - }
> -}
> -
> -VOID
> -AddConsoleVariable (
> - IN CONSOLE_TYPE ConsoleType,
> - IN EFI_DEVICE_PATH *ConsoleDevicePath
> - )
> -{
> - EFI_DEVICE_PATH *TempDevicePath;
> - EFI_DEVICE_PATH *Instance;
> - UINTN Size;
> - EFI_HANDLE GraphicsControllerHandle;
> - EFI_DEVICE_PATH *GopDevicePath;
> -
> - TempDevicePath = ConsoleDevicePath;
> - do {
> - Instance = GetNextDevicePathInstance (&TempDevicePath, &Size);
> - if (Instance == NULL) {
> - break;
> - }
> -
> - switch (ConsoleType) {
> - case ConIn:
> - if (IsUsbShortForm (Instance)) {
> - //
> - // Append Usb Keyboard short form DevicePath into "ConInDev"
> - //
> - EfiBootManagerUpdateConsoleVariable (ConInDev, Instance, NULL);
> - }
> - EfiBootManagerUpdateConsoleVariable (ConsoleType, Instance, NULL);
> - break;
> - case ConOut:
> - GraphicsControllerHandle = IsVideoController (Instance);
> - if (GraphicsControllerHandle == NULL) {
> - EfiBootManagerUpdateConsoleVariable (ConsoleType, Instance, NULL);
> - } else {
> - //
> - // Connect the GOP driver
> - //
> - gBS->ConnectController (GraphicsControllerHandle, NULL, NULL, TRUE);
> - //
> - // Get the GOP device path
> - // NOTE: We may get a device path that contains Controller node in it.
> - //
> - GopDevicePath = EfiBootManagerGetGopDevicePath
> (GraphicsControllerHandle);
> - if (GopDevicePath != NULL) {
> - EfiBootManagerUpdateConsoleVariable (ConsoleType,
> GopDevicePath, NULL);
> - }
> - }
> - break;
> - default:
> - ASSERT(FALSE);
> - break;
> - }
> -
> - FreePool (Instance);
> - } while (TempDevicePath != NULL);
> -}
> -
> -/**
> - The function connects the trusted consoles.
> **/
> VOID
> -ConnectTrustedConsole (
> +EFIAPI
> +BdsSignalEventBeforeConsoleAfterTrustedConsole (
> VOID
> )
> {
> - EFI_DEVICE_PATH_PROTOCOL *Consoles;
> - EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
> - EFI_DEVICE_PATH_PROTOCOL *Instance;
> - EFI_DEVICE_PATH_PROTOCOL *Next;
> - UINTN Size;
> - UINTN Index;
> - EFI_HANDLE Handle;
> - EFI_STATUS Status;
> - CHAR16 *ConsoleVar[] = {L"ConIn", L"ConOut"};
> - VOID *TrustedConsoleDevicepath;
> + EFI_STATUS Status;
> + EFI_EVENT BdsConsoleEvent;
>
> - TrustedConsoleDevicepath = PcdGetPtr
> (PcdTrustedConsoleInputDevicePath);
> - DumpDevicePath (L"TrustedConsoleIn", TrustedConsoleDevicepath);
> - TrustedConsoleDevicepath = PcdGetPtr
> (PcdTrustedConsoleOutputDevicePath);
> - DumpDevicePath (L"TrustedConsoleOut", TrustedConsoleDevicepath);
> + DEBUG ((DEBUG_INFO, "%a \n", __FUNCTION__));
>
> - for (Index = 0; Index < sizeof (ConsoleVar) / sizeof (ConsoleVar[0]);
> Index++) {
> -
> - GetEfiGlobalVariable2 (ConsoleVar[Index], (VOID **)&Consoles, NULL);
> + Status = CreateBdsEvent (
> + TPL_CALLBACK,
> + &gBdsEventBeforeConsoleAfterTrustedConsoleGuid,
> + &BdsConsoleEvent
> + );
>
> - TempDevicePath = Consoles;
> - do {
> - Instance = GetNextDevicePathInstance (&TempDevicePath, &Size);
> - if (Instance == NULL) {
> - break;
> - }
> - if (IsTrustedConsole (Index, Instance)) {
> - if (IsUsbShortForm (Instance)) {
> - ConnectUsbShortFormDevicePath (Instance);
> - } else {
> - for (Next = Instance; !IsDevicePathEnd (Next); Next =
> NextDevicePathNode (Next)) {
> - if (DevicePathType (Next) == ACPI_DEVICE_PATH &&
> DevicePathSubType (Next) == ACPI_ADR_DP) {
> - break;
> - } else if (DevicePathType (Next) == HARDWARE_DEVICE_PATH &&
> - DevicePathSubType (Next) == HW_CONTROLLER_DP &&
> - DevicePathType (NextDevicePathNode (Next)) ==
> ACPI_DEVICE_PATH &&
> - DevicePathSubType (NextDevicePathNode (Next)) ==
> ACPI_ADR_DP
> - ) {
> - break;
> - }
> - }
> - if (!IsDevicePathEnd (Next)) {
> - SetDevicePathEndNode (Next);
> - Status = EfiBootManagerConnectDevicePath (Instance, &Handle);
> - if (!EFI_ERROR (Status)) {
> - gBS->ConnectController (Handle, NULL, NULL, TRUE);
> - }
> - } else {
> - EfiBootManagerConnectDevicePath (Instance, NULL);
> - }
> - }
> - }
> - FreePool (Instance);
> - } while (TempDevicePath != NULL);
> + ASSERT_EFI_ERROR (Status);
>
> - if (Consoles != NULL) {
> - FreePool (Consoles);
> - }
> + if (!EFI_ERROR (Status)) {
> + gBS->SignalEvent (BdsConsoleEvent);
> + gBS->CloseEvent (BdsConsoleEvent);
> + DEBUG ((DEBUG_INFO,"All EventBeforeConsoleAfterTrustedConsole
> callbacks have returned successfully\n"));
> }
> }
>
> -/**
> - The function connects the trusted Storages.
> -**/
> -VOID
> -ConnectTrustedStorage (
> - VOID
> - )
> -{
> - VOID *TrustedStorageDevicepath;
> - EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
> - EFI_DEVICE_PATH_PROTOCOL *Instance;
> - UINTN Size;
> - EFI_DEVICE_PATH_PROTOCOL *TempStorageDevicePath;
> - EFI_STATUS Status;
> - EFI_HANDLE DeviceHandle;
> -
> - TrustedStorageDevicepath = PcdGetPtr (PcdTrustedStorageDevicePath);
> - DumpDevicePath (L"TrustedStorage", TrustedStorageDevicepath);
> -
> - TempDevicePath = TrustedStorageDevicepath;
> - do {
> - Instance = GetNextDevicePathInstance (&TempDevicePath, &Size);
> - if (Instance == NULL) {
> - break;
> - }
> -
> - EfiBootManagerConnectDevicePath (Instance, NULL);
> -
> - TempStorageDevicePath = Instance;
> -
> - Status = gBS->LocateDevicePath (
> - &gEfiDevicePathProtocolGuid,
> - &TempStorageDevicePath,
> - &DeviceHandle
> - );
> - if (!EFI_ERROR (Status)) {
> - gBS->ConnectController (DeviceHandle, NULL, NULL, FALSE);
> - }
> -
> - FreePool (Instance);
> - } while (TempDevicePath != NULL);
> -}
> -
> -/**
> - The function connects the trusted consoles and then call the PP processing
> library interface.
> -**/
> -VOID
> -ProcessTcgPp (
> - VOID
> - )
> -{
> - gPPRequireUIConfirm |= Tcg2PhysicalPresenceLibNeedUserConfirm();
> -
> - if (gPPRequireUIConfirm) {
> - ConnectTrustedConsole ();
> - }
> -
> - Tcg2PhysicalPresenceLibProcessRequest (NULL);
> -}
>
> /**
> - The function connects the trusted storage to perform TPerReset.
> + Create, Signal, and Close the Bds Before Console Before End Of Dxe
> + event using CreateBdsEvent().
> **/
> VOID
> -ProcessTcgMor (
> - VOID
> - )
> -{
> - if (IsMorBitSet ()) {
> - ConnectTrustedConsole();
> - ConnectTrustedStorage();
> - }
> -}
> -
> -/**
> - Check if current BootCurrent variable is internal shell boot option.
> -
> - @retval TRUE BootCurrent is internal shell.
> - @retval FALSE BootCurrent is not internal shell.
> -**/
> -BOOLEAN
> -BootCurrentIsInternalShell (
> +EFIAPI
> +BdsSignalEventBeforeConsoleBeforeEndOfDxe (
> VOID
> )
> {
> - UINTN VarSize;
> - UINT16 BootCurrent;
> - CHAR16 BootOptionName[16];
> - UINT8 *BootOption;
> - UINT8 *Ptr;
> - BOOLEAN Result;
> - EFI_STATUS Status;
> - EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
> - EFI_DEVICE_PATH_PROTOCOL *LastDeviceNode;
> - EFI_GUID *GuidPoint;
> -
> - BootOption = NULL;
> - Result = FALSE;
> -
> - //
> - // Get BootCurrent variable
> - //
> - VarSize = sizeof (UINT16);
> - Status = gRT->GetVariable (
> - L"BootCurrent",
> - &gEfiGlobalVariableGuid,
> - NULL,
> - &VarSize,
> - &BootCurrent
> - );
> - if (EFI_ERROR (Status)) {
> - return FALSE;
> - }
> + EFI_STATUS Status;
> + EFI_EVENT BdsConsoleEvent;
>
> - //
> - // Create boot option Bootxxxx from BootCurrent
> - //
> - UnicodeSPrint (BootOptionName, sizeof(BootOptionName), L"Boot%04X",
> BootCurrent);
> + DEBUG ((DEBUG_INFO, "%a \n", __FUNCTION__));
>
> - GetEfiGlobalVariable2 (BootOptionName, (VOID **) &BootOption,
> &VarSize);
> - if (BootOption == NULL || VarSize == 0) {
> - return FALSE;
> - }
> + Status = CreateBdsEvent (
> + TPL_CALLBACK,
> + &gBdsEventBeforeConsoleBeforeEndOfDxeGuid,
> + &BdsConsoleEvent
> + );
>
> - Ptr = BootOption;
> - Ptr += sizeof (UINT32);
> - Ptr += sizeof (UINT16);
> - Ptr += StrSize ((CHAR16 *) Ptr);
> - TempDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) Ptr;
> - LastDeviceNode = TempDevicePath;
> - while (!IsDevicePathEnd (TempDevicePath)) {
> - LastDeviceNode = TempDevicePath;
> - TempDevicePath = NextDevicePathNode (TempDevicePath);
> - }
> - GuidPoint = EfiGetNameGuidFromFwVolDevicePathNode (
> - (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) LastDeviceNode
> - );
> - if ((GuidPoint != NULL) &&
> - ((CompareGuid (GuidPoint, &gUefiShellFileGuid)))
> - ) {
> - //
> - // if this option is internal shell, return TRUE
> - //
> - Result = TRUE;
> - }
> + ASSERT_EFI_ERROR (Status);
>
> - if (BootOption != NULL) {
> - FreePool (BootOption);
> - BootOption = NULL;
> + if (!EFI_ERROR (Status)) {
> + gBS->SignalEvent (BdsConsoleEvent);
> + gBS->CloseEvent (BdsConsoleEvent);
> + DEBUG ((DEBUG_INFO,"All BeforeConsoleBeforeEndOfDxe callbacks
> have returned successfully\n"));
> }
> -
> - return Result;
> }
>
> /**
> - This function will change video resolution and text mode
> - for internl shell when internal shell is launched.
> -
> - @param None.
> -
> - @retval EFI_SUCCESS Mode is changed successfully.
> - @retval Others Mode failed to changed.
> + Create, Signal, and Close the Bds After Console Ready Before Boot Option
> + using CreateBdsEvent().
> **/
> -EFI_STATUS
> +VOID
> EFIAPI
> -ChangeModeForInternalShell (
> +BdsSignalEventAfterConsoleReadyBeforeBootOption (
> VOID
> )
> {
> - EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
> - EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;
> - UINTN SizeOfInfo;
> - EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
> - UINT32 MaxGopMode;
> - UINT32 MaxTextMode;
> - UINT32 ModeNumber;
> - UINTN HandleCount;
> - EFI_HANDLE *HandleBuffer;
> - EFI_STATUS Status;
> - UINTN Index;
> - UINTN CurrentColumn;
> - UINTN CurrentRow;
> -
> - Status = gBS->HandleProtocol (
> - gST->ConsoleOutHandle,
> - &gEfiGraphicsOutputProtocolGuid,
> - (VOID**)&GraphicsOutput
> - );
> - if (EFI_ERROR (Status)) {
> - GraphicsOutput = NULL;
> - }
> -
> - Status = gBS->HandleProtocol (
> - gST->ConsoleOutHandle,
> - &gEfiSimpleTextOutProtocolGuid,
> - (VOID**)&SimpleTextOut
> - );
> - if (EFI_ERROR (Status)) {
> - SimpleTextOut = NULL;
> - }
> + EFI_STATUS Status;
> + EFI_EVENT BdsConsoleEvent;
>
> - if ((GraphicsOutput == NULL) || (SimpleTextOut == NULL)) {
> - return EFI_UNSUPPORTED;
> - }
> -
> - MaxGopMode = GraphicsOutput->Mode->MaxMode;
> - MaxTextMode = SimpleTextOut->Mode->MaxMode;
> -
> - //
> - // 1. If current video resolution is same with new video resolution,
> - // video resolution need not be changed.
> - // 1.1. If current text mode is same with new text mode, text mode need
> not be change.
> - // 1.2. If current text mode is different with new text mode, text mode
> need be change to new text mode.
> - // 2. If current video resolution is different with new video resolution, we
> need restart whole console drivers.
> - //
> - for (ModeNumber = 0; ModeNumber < MaxGopMode; ModeNumber++) {
> - Status = GraphicsOutput->QueryMode (
> - GraphicsOutput,
> - ModeNumber,
> - &SizeOfInfo,
> - &Info
> - );
> - if (!EFI_ERROR (Status)) {
> - if ((Info->HorizontalResolution == mShellHorizontalResolution) &&
> - (Info->VerticalResolution == mShellVerticalResolution)) {
> - if ((GraphicsOutput->Mode->Info->HorizontalResolution ==
> mShellHorizontalResolution) &&
> - (GraphicsOutput->Mode->Info->VerticalResolution ==
> mShellVerticalResolution)) {
> - //
> - // If current video resolution is same with new resolution,
> - // then check if current text mode is same with new text mode.
> - //
> - Status = SimpleTextOut->QueryMode (SimpleTextOut, SimpleTextOut-
> >Mode->Mode, &CurrentColumn, &CurrentRow);
> - ASSERT_EFI_ERROR (Status);
> - if (CurrentColumn == mShellModeColumn && CurrentRow ==
> mShellModeRow) {
> - //
> - // Current text mode is same with new text mode, text mode need
> not be change.
> - //
> - FreePool (Info);
> - return EFI_SUCCESS;
> - } else {
> - //
> - // Current text mode is different with new text mode, text mode
> need be change to new text mode.
> - //
> - for (Index = 0; Index < MaxTextMode; Index++) {
> - Status = SimpleTextOut->QueryMode (SimpleTextOut, Index,
> &CurrentColumn, &CurrentRow);
> - if (!EFI_ERROR(Status)) {
> - if ((CurrentColumn == mShellModeColumn) && (CurrentRow ==
> mShellModeRow)) {
> - //
> - // New text mode is supported, set it.
> - //
> - Status = SimpleTextOut->SetMode (SimpleTextOut, Index);
> - ASSERT_EFI_ERROR (Status);
> - //
> - // Update text mode PCD.
> - //
> - Status = PcdSet32S (PcdConOutColumn, mShellModeColumn);
> - ASSERT_EFI_ERROR (Status);
> + DEBUG ((DEBUG_INFO, "%a \n", __FUNCTION__));
>
> - Status = PcdSet32S (PcdConOutRow, mShellModeRow);
> - ASSERT_EFI_ERROR (Status);
> -
> - FreePool (Info);
> - return EFI_SUCCESS;
> - }
> - }
> - }
> - if (Index == MaxTextMode) {
> - //
> - // If new text mode is not supported, return error.
> - //
> - FreePool (Info);
> - return EFI_UNSUPPORTED;
> - }
> - }
> - } else {
> - FreePool (Info);
> - //
> - // If current video resolution is not same with the new one, set new
> video resolution.
> - // In this case, the driver which produces simple text out need be
> restarted.
> - //
> - Status = GraphicsOutput->SetMode (GraphicsOutput, ModeNumber);
> - if (!EFI_ERROR (Status)) {
> - //
> - // Set PCD to restart GraphicsConsole and Consplitter to change video
> resolution
> - // and produce new text mode based on new resolution.
> - //
> - Status = PcdSet32S (PcdVideoHorizontalResolution,
> mShellHorizontalResolution);
> - ASSERT_EFI_ERROR (Status);
> -
> - Status = PcdSet32S (PcdVideoVerticalResolution,
> mShellVerticalResolution);
> - ASSERT_EFI_ERROR (Status);
> -
> - Status = PcdSet32S (PcdConOutColumn, mShellModeColumn);
> - ASSERT_EFI_ERROR (Status);
> -
> - Status = PcdSet32S (PcdConOutRow, mShellModeRow);
> - ASSERT_EFI_ERROR (Status);
> + Status = CreateBdsEvent (
> + TPL_CALLBACK,
> + &gBdsEventAfterConsoleReadyBeforeBootOptionGuid,
> + &BdsConsoleEvent
> + );
>
> - Status = gBS->LocateHandleBuffer (
> - ByProtocol,
> - &gEfiSimpleTextOutProtocolGuid,
> - NULL,
> - &HandleCount,
> - &HandleBuffer
> - );
> - if (!EFI_ERROR (Status)) {
> - for (Index = 0; Index < HandleCount; Index++) {
> - gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);
> - }
> - for (Index = 0; Index < HandleCount; Index++) {
> - gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
> - }
> - if (HandleBuffer != NULL) {
> - FreePool (HandleBuffer);
> - }
> - break;
> - }
> - }
> - }
> - }
> - FreePool (Info);
> - }
> - }
> + ASSERT_EFI_ERROR (Status);
>
> - if (ModeNumber == MaxGopMode) {
> - //
> - // If the new resolution is not supported, return error.
> - //
> - return EFI_UNSUPPORTED;
> + if (!EFI_ERROR (Status)) {
> + gBS->SignalEvent (BdsConsoleEvent);
> + gBS->CloseEvent (BdsConsoleEvent);
> + DEBUG ((DEBUG_INFO,"All AfterConsoleReadyBeforeBootOption
> callbacks have returned successfully\n"));
> }
> -
> - return EFI_SUCCESS;
> }
>
> -/**
> - ReadyToBoot callback to set video and text mode for internal shell boot.
> - That will not connect USB controller while CSM and FastBoot are disabled,
> we need to connect them
> - before booting to Shell for showing USB devices in Shell.
> -
> - When FastBoot is enabled and Windows Console is the chosen Console
> behavior, input devices will not be connected
> - by default. Hence, when booting to EFI shell, connecting input consoles are
> required.
> -
> - @param Event Pointer to this event
> - @param Context Event hanlder private data
> -
> - @retval None.
> -**/
> -VOID
> -EFIAPI
> -OnReadyToBootCallBack (
> - IN EFI_EVENT Event,
> - IN VOID *Context
> - )
> -{
> - DEBUG ((EFI_D_INFO, "OnReadyToBootCallBack\n"));
> -
> - if (BootCurrentIsInternalShell ()) {
> -
> - ChangeModeForInternalShell ();
> - EfiBootManagerConnectAllDefaultConsoles();
> - gDS->Dispatch ();
> - }
> -}
>
> /**
> Platform Bds init. Incude the platform firmware vendor, revision
> @@ -1095,149 +195,37 @@ PlatformBootManagerBeforeConsole (
> VOID
> )
> {
> - EFI_STATUS Status;
> - EFI_DEVICE_PATH_PROTOCOL *VarConOut;
> - EFI_DEVICE_PATH_PROTOCOL *VarConIn;
> - EFI_EVENT Event;
>
> DEBUG ((EFI_D_INFO, "PlatformBootManagerBeforeConsole\n"));
>
> - Status = EFI_SUCCESS;
> -
> - //
> - // Get user defined text mode for internal shell only once.
> - //
> - mShellHorizontalResolution = PcdGet32
> (PcdSetupVideoHorizontalResolution);
> - mShellVerticalResolution = PcdGet32 (PcdSetupVideoVerticalResolution);
> - mShellModeColumn = PcdGet32 (PcdSetupConOutColumn);
> - mShellModeRow = PcdGet32 (PcdSetupConOutRow);
> -
> - //
> - // Create event to set proper video resolution and text mode for internal
> shell.
> - //
> - Status = EfiCreateEventReadyToBootEx (
> - TPL_CALLBACK,
> - OnReadyToBootCallBack,
> - NULL,
> - &Event
> - );
> - ASSERT_EFI_ERROR (Status);
> -
> - //
> - // Connect Root Bridge to make PCI BAR resource allocated and all PciIo
> created
> - //
> - ConnectRootBridge (FALSE);
> -
> //
> - // Fill ConIn/ConOut in Full Configuration boot mode
> + // Trusted console can be added in a PciEnumComplete callback
> //
> - DEBUG ((DEBUG_INFO, "PlatformBootManagerInit - %x\n", gBootMode));
> -
> - if (gBootMode == BOOT_WITH_FULL_CONFIGURATION ||
> - gBootMode == BOOT_WITH_DEFAULT_SETTINGS ||
> - gBootMode ==
> BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS ||
> - gBootMode == BOOT_IN_RECOVERY_MODE) {
> -
> - GetEfiGlobalVariable2 (L"ConOut", (VOID **)&VarConOut, NULL); if
> (VarConOut != NULL) { FreePool (VarConOut); }
> - GetEfiGlobalVariable2 (L"ConIn", (VOID **)&VarConIn, NULL); if
> (VarConIn != NULL) { FreePool (VarConIn); }
> -
> - //
> - // Only fill ConIn/ConOut when ConIn/ConOut is empty because we may
> drop to Full Configuration boot mode in non-first boot
> - //
> - if (VarConOut == NULL || VarConIn == NULL) {
> - if (PcdGetSize (PcdTrustedConsoleOutputDevicePath) >=
> sizeof(EFI_DEVICE_PATH_PROTOCOL)) {
> - AddConsoleVariable (ConOut, PcdGetPtr
> (PcdTrustedConsoleOutputDevicePath));
> - }
> - if (PcdGetSize (PcdTrustedConsoleInputDevicePath) >=
> sizeof(EFI_DEVICE_PATH_PROTOCOL)) {
> - AddConsoleVariable (ConIn, PcdGetPtr
> (PcdTrustedConsoleInputDevicePath));
> - }
> - }
> - }
>
> - EnumUsbKeyboard ();
> //
> - // For trusted console it must be handled here.
> + // Signal Before Console, after Trusted console Event
> //
> - UpdateGraphicConOut (TRUE);
> + BdsSignalEventBeforeConsoleAfterTrustedConsole ();
>
> //
> - // Dynamically register hot key: F2/F7/Enter
> + // Signal Before Console, before End of Dxe
> //
> - RegisterDefaultBootOption ();
> - RegisterStaticHotkey ();
> -
> - PERF_START_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7010);
> - if (PcdGetBool (PcdTpm2Enable)) {
> - ProcessTcgPp ();
> - ProcessTcgMor ();
> - }
> - PERF_END_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7011);
> + BdsSignalEventBeforeConsoleBeforeEndOfDxe ();
>
> //
> - // We should make all UEFI memory and GCD information populated
> before ExitPmAuth.
> - // SMM may consume these information.
> + // Signal End Of Dxe Event
> //
> - MemoryTest((EXTENDMEM_COVERAGE_LEVEL) PcdGet32
> (PcdPlatformMemoryCheckLevel));
> -
> PERF_START_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7020);
> ExitPmAuth ();
> PERF_END_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7021);
>
> //
> - // Dispatch the deferred 3rd party images.
> - //
> - EfiBootManagerDispatchDeferredImages ();
> -
> - //
> - // For non-trusted console it must be handled here.
> + // Deferred 3rd party images can be dispatched in
> + // an SmmReadyToLock callback
> //
> - UpdateGraphicConOut (FALSE);
> }
>
>
> -/**
> - Connect with predeined platform connect sequence,
> - the OEM/IBV can customize with their own connect sequence.
> -
> - @param[in] BootMode Boot mode of this boot.
> -**/
> -VOID
> -ConnectSequence (
> - IN EFI_BOOT_MODE BootMode
> - )
> -{
> - EfiBootManagerConnectAll ();
> -}
> -
> -/**
> - The function is to consider the boot order which is not in our expectation.
> - In the case that we need to re-sort the boot option.
> -
> - @retval TRUE Need to sort Boot Option.
> - @retval FALSE Don't need to sort Boot Option.
> -**/
> -BOOLEAN
> -IsNeedSortBootOption (
> - VOID
> - )
> -{
> - EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
> - UINTN BootOptionCount;
> -
> - BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount,
> LoadOptionTypeBoot);
> -
> - //
> - // If setup is the first priority in boot option, we need to sort boot option.
> - //
> - if ((BootOptionCount > 1) &&
> - (((StrnCmp (BootOptions->Description, L"Enter Setup", StrLen (L"Enter
> Setup"))) == 0) ||
> - ((StrnCmp (BootOptions->Description, L"BootManagerMenuApp",
> StrLen (L"BootManagerMenuApp"))) == 0))) {
> - return TRUE;
> - }
> -
> - return FALSE;
> -}
> -
> /**
> The function will excute with as the platform policy, current policy
> is driven by boot mode. IBV/OEM can customize this code for their specific
> @@ -1254,65 +242,9 @@ PlatformBootManagerAfterConsole (
> VOID
> )
> {
> - EFI_BOOT_MODE LocalBootMode;
> -
> DEBUG ((EFI_D_INFO, "PlatformBootManagerAfterConsole\n"));
>
> - //
> - // Get current Boot Mode
> - //
> - LocalBootMode = gBootMode;
> - DEBUG ((DEBUG_INFO, "Current local bootmode - %x\n",
> LocalBootMode));
> -
> - //
> - // Go the different platform policy with different boot mode
> - // Notes: this part code can be change with the table policy
> - //
> - switch (LocalBootMode) {
> -
> - case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:
> - case BOOT_WITH_MINIMAL_CONFIGURATION:
> - case BOOT_ON_S4_RESUME:
> - //
> - // Perform some platform specific connect sequence
> - //
> - PERF_START_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7050);
> - ConnectSequence (LocalBootMode);
> - PERF_END_EX(NULL,"EventRec", NULL, AsmReadTsc(), 0x7051);
> -
> - break;
> -
> - case BOOT_WITH_FULL_CONFIGURATION:
> - case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:
> - case BOOT_WITH_DEFAULT_SETTINGS:
> - default:
> - //
> - // Perform some platform specific connect sequence
> - //
> - ConnectSequence (LocalBootMode);
> -
> - //
> - // Only in Full Configuration boot mode we do the enumeration of boot
> device
> - //
> - //
> - // Dispatch all but Storage Oprom explicitly, because we assume
> Int13Thunk driver is there.
> - //
> - EfiBootManagerRefreshAllBootOption ();
> -
> - if (IsNeedSortBootOption()) {
> - EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot,
> CompareBootOption);
> - }
> - //
> - // PXE boot option may appear after boot option enumeration
> - //
> -
> - break;
> - }
> -
> - Print (L"Press F7 for BootMenu!\n");
> -
> - EfiBootManagerRefreshAllBootOption ();
> - EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot,
> CompareBootOption);
> + BdsSignalEventAfterConsoleReadyBeforeBootOption ();
> }
>
> /**
> @@ -1328,19 +260,19 @@ PlatformBootManagerUnableToBoot (
> VOID
> )
> {
> - EFI_STATUS Status;
> - EFI_BOOT_MANAGER_LOAD_OPTION BootDeviceList;
> - CHAR16 OptionName[sizeof ("Boot####")];
> + BoardBootManagerUnableToBoot ();
> +}
>
> - if (mBootMenuOptionNumber == LoadOptionNumberUnassigned) {
> - return;
> - }
> - UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x",
> mBootMenuOptionNumber);
> - Status = EfiBootManagerVariableToLoadOption (OptionName,
> &BootDeviceList);
> - if (EFI_ERROR (Status)) {
> - return;
> - }
> - for (;;) {
> - EfiBootManagerBoot (&BootDeviceList);
> - }
> +/**
> + This function is called each second during the boot manager waits the
> timeout.
> +
> + @param TimeoutRemain The remaining timeout.
> +**/
> +VOID
> +EFIAPI
> +PlatformBootManagerWaitCallback (
> + UINT16 TimeoutRemain
> + )
> +{
> + BoardBootManagerWaitCallback (TimeoutRemain);
> }
> diff --git
> a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/
> BdsPlatform.h
> b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib
> /BdsPlatform.h
> index 360a00d7d7..031676cdc3 100644
> ---
> a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/
> BdsPlatform.h
> +++
> b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib
> /BdsPlatform.h
> @@ -1,7 +1,7 @@
> /** @file
> Header file for BDS Platform specific code
>
> -Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
> **/
> @@ -9,176 +9,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> #ifndef _BDS_PLATFORM_H
> #define _BDS_PLATFORM_H
>
> -#include <PiDxe.h>
> -#include <Protocol/DevicePath.h>
> -#include <Protocol/SimpleNetwork.h>
> -#include <Protocol/PciRootBridgeIo.h>
> -#include <Protocol/LoadFile.h>
> -#include <Protocol/PciIo.h>
> -#include <Protocol/CpuIo2.h>
> -#include <Protocol/LoadedImage.h>
> -#include <Protocol/DiskInfo.h>
> -#include <Protocol/GraphicsOutput.h>
> -#include <Protocol/UgaDraw.h>
> -#include <Protocol/GenericMemoryTest.h>
> -#include <Protocol/DevicePathToText.h>
> -#include <Protocol/FirmwareVolume2.h>
> -#include <Protocol/SimpleFileSystem.h>
> -
> -#include <Guid/CapsuleVendor.h>
> -#include <Guid/MemoryTypeInformation.h>
> -#include <Guid/GlobalVariable.h>
> -#include <Guid/MemoryOverwriteControl.h>
> -#include <Guid/FileInfo.h>
> -#include <Library/DebugLib.h>
> -#include <Library/BaseMemoryLib.h>
> -#include <Library/UefiBootServicesTableLib.h>
> -#include <Library/UefiRuntimeServicesTableLib.h>
> -#include <Library/MemoryAllocationLib.h>
> -#include <Library/BaseLib.h>
> -#include <Library/PcdLib.h>
> -#include <Library/PlatformBootManagerLib.h>
> -#include <Library/DevicePathLib.h>
> -#include <Library/UefiLib.h>
> -#include <Library/HobLib.h>
> -#include <Library/DxeServicesLib.h>
> -#include <Library/DxeServicesTableLib.h>
> -#include <Library/PrintLib.h>
> -#include <Library/HiiLib.h>
> -#include <Library/CapsuleLib.h>
> -#include <Library/PerformanceLib.h>
> -
> -#include <IndustryStandard/Pci30.h>
> -#include <IndustryStandard/PciCodeId.h>
> -
> -///
> -/// ConnectType
> -///
> -#define CONSOLE_OUT 0x00000001
> -#define STD_ERROR 0x00000002
> -#define CONSOLE_IN 0x00000004
> -#define CONSOLE_ALL (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)
> -
> -extern EFI_GUID gUefiShellFileGuid;
> -extern EFI_BOOT_MODE gBootMode;
> -
> -#define gPciRootBridge \
> - { \
> - { \
> - ACPI_DEVICE_PATH, \
> - ACPI_DP, \
> - { \
> - (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \
> - (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \
> - }, \
> - }, \
> - EISA_PNP_ID (0x0A03), \
> - 0 \
> - }
> -
> -#define gEndEntire \
> - { \
> - END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, {
> END_DEVICE_PATH_LENGTH, 0 } \
> - }
> -
> -typedef struct {
> - EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> - UINTN ConnectType;
> -} BDS_CONSOLE_CONNECT_ENTRY;
> -
> -//
> -// Platform Root Bridge
> -//
> -typedef struct {
> - ACPI_HID_DEVICE_PATH PciRootBridge;
> - EFI_DEVICE_PATH_PROTOCOL End;
> -} PLATFORM_ROOT_BRIDGE_DEVICE_PATH;
> -
> -//
> -// Below is the platform console device path
> -//
> -typedef struct {
> - ACPI_HID_DEVICE_PATH PciRootBridge;
> - PCI_DEVICE_PATH IsaBridge;
> - ACPI_HID_DEVICE_PATH Keyboard;
> - EFI_DEVICE_PATH_PROTOCOL End;
> -} PLATFORM_KEYBOARD_DEVICE_PATH;
> -
> -typedef struct {
> - ACPI_HID_DEVICE_PATH PciRootBridge;
> - PCI_DEVICE_PATH PciDevice;
> - EFI_DEVICE_PATH_PROTOCOL End;
> -} PLATFORM_ONBOARD_CONTROLLER_DEVICE_PATH;
> -
> -typedef struct {
> - ACPI_HID_DEVICE_PATH PciRootBridge;
> - PCI_DEVICE_PATH Pci0Device;
> - EFI_DEVICE_PATH_PROTOCOL End;
> -} PLATFORM_PEG_ROOT_CONTROLLER_DEVICE_PATH;
> -
> -typedef struct {
> - ACPI_HID_DEVICE_PATH PciRootBridge;
> - PCI_DEVICE_PATH PciBridge;
> - PCI_DEVICE_PATH PciDevice;
> - EFI_DEVICE_PATH_PROTOCOL End;
> -} PLATFORM_PCI_CONTROLLER_DEVICE_PATH;
> -
> -//
> -// Below is the boot option device path
> -//
> -
> -#define CLASS_HID 3
> -#define SUBCLASS_BOOT 1
> -#define PROTOCOL_KEYBOARD 1
> -
> -typedef struct {
> - USB_CLASS_DEVICE_PATH UsbClass;
> - EFI_DEVICE_PATH_PROTOCOL End;
> -} USB_CLASS_FORMAT_DEVICE_PATH;
> -
> -extern USB_CLASS_FORMAT_DEVICE_PATH
> gUsbClassKeyboardDevicePath;
> -
> -//
> -// Platform BDS Functions
> -//
> -
> -
> -/**
> - Perform the memory test base on the memory test intensive level,
> - and update the memory resource.
> -
> - @param Level The memory test intensive level.
> -
> - @retval EFI_STATUS Success test all the system memory and update
> - the memory resource
> -
> -**/
> -EFI_STATUS
> -MemoryTest (
> - IN EXTENDMEM_COVERAGE_LEVEL Level
> - );
> -
> -VOID
> -ConnectSequence (
> - IN EFI_BOOT_MODE BootMode
> - );
> -
> -
> -INTN
> -EFIAPI
> -CompareBootOption (
> - CONST VOID *Left,
> - CONST VOID *Right
> - );
> -
> -
> -VOID
> -RegisterStaticHotkey (
> - VOID
> - );
> -VOID
> -RegisterDefaultBootOption (
> - VOID
> - );
> + #include <Library/DebugLib.h>
> + #include <Library/UefiBootServicesTableLib.h>
> + #include <Library/PlatformBootManagerLib.h>
> + #include <Library/UefiLib.h>
> + #include <Library/HobLib.h>
> + #include <Library/PrintLib.h>
> + #include <Library/PerformanceLib.h>
> + #include <Library/BoardBootManagerLib.h>
>
> #endif
> diff --git
> a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/
> DxePlatformBootManagerLib.inf
> b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib
> /DxePlatformBootManagerLib.inf
> index 388ffd808b..4f7299f1df 100644
> ---
> a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/
> DxePlatformBootManagerLib.inf
> +++
> b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib
> /DxePlatformBootManagerLib.inf
> @@ -23,23 +23,13 @@
>
> [LibraryClasses]
> BaseLib
> - MemoryAllocationLib
> UefiBootServicesTableLib
> - UefiRuntimeServicesTableLib
> - BaseMemoryLib
> DebugLib
> - PcdLib
> - PrintLib
> - DevicePathLib
> UefiLib
> HobLib
> - DxeServicesLib
> - DxeServicesTableLib
> - HiiLib
> UefiBootManagerLib
> PerformanceLib
> - TimerLib
> - Tcg2PhysicalPresenceLib
> + BoardBootManagerLib
>
> [Packages]
> MdePkg/MdePkg.dec
> @@ -47,47 +37,18 @@
> SecurityPkg/SecurityPkg.dec
> MinPlatformPkg/MinPlatformPkg.dec
>
> -[Pcd]
> - gMinPlatformPkgTokenSpaceGuid.PcdTpm2Enable ##
> CONSUMES
> - gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut ##
> PRODUCES
> - gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution ##
> PRODUCES
> - gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution ##
> PRODUCES
> - gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow ##
> PRODUCES
> - gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn ##
> PRODUCES
> - gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutColumn ##
> CONSUMES
> - gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutRow ##
> CONSUMES
> - gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution
> ## CONSUMES
> - gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution
> ## CONSUMES
> - gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand ##
> PRODUCES
> - gMinPlatformPkgTokenSpaceGuid.PcdPlatformMemoryCheckLevel ##
> CONSUMES
> - gMinPlatformPkgTokenSpaceGuid.PcdBootToShellOnly ##
> CONSUMES
> - gMinPlatformPkgTokenSpaceGuid.PcdTrustedConsoleInputDevicePath ##
> CONSUMES
> - gMinPlatformPkgTokenSpaceGuid.PcdTrustedConsoleOutputDevicePath
> ## CONSUMES
> - gMinPlatformPkgTokenSpaceGuid.PcdTrustedStorageDevicePath ##
> CONSUMES
> -
> [Sources]
> BdsPlatform.c
> BdsPlatform.h
> - PlatformBootOption.c
> - MemoryTest.c
>
> [Protocols]
> - gEfiPciRootBridgeIoProtocolGuid ## CONSUMES
> - gEfiPciIoProtocolGuid ## CONSUMES
> - gEfiCpuIo2ProtocolGuid ## CONSUMES
> - gEfiDxeSmmReadyToLockProtocolGuid ## PRODUCES
> - gEfiGenericMemTestProtocolGuid ## CONSUMES
> - gEfiDiskInfoProtocolGuid ## CONSUMES
> - gEfiDevicePathToTextProtocolGuid ## CONSUMES
> - gEfiSimpleTextInputExProtocolGuid ## CONSUMES
> - gEfiFirmwareVolume2ProtocolGuid ## CONSUMES
> - gEfiFormBrowser2ProtocolGuid ## CONSUMES
> - gEfiGenericMemTestProtocolGuid ## CONSUMES
> + gEfiDxeSmmReadyToLockProtocolGuid ## PRODUCES
>
> [Guids]
> - gEfiGlobalVariableGuid ## PRODUCES
> - gEfiMemoryOverwriteControlDataGuid ## PRODUCES
> - gEfiEndOfDxeEventGroupGuid ## CONSUMES
> + gEfiEndOfDxeEventGroupGuid ## CONSUMES
> + gBdsEventBeforeConsoleAfterTrustedConsoleGuid
> + gBdsEventBeforeConsoleBeforeEndOfDxeGuid
> + gBdsEventAfterConsoleReadyBeforeBootOptionGuid
>
> [Depex.common.DXE_DRIVER]
> gEfiVariableArchProtocolGuid
> diff --git
> a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/
> MemoryTest.c
> b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib
> /MemoryTest.c
> deleted file mode 100644
> index 654845349a..0000000000
> ---
> a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/
> MemoryTest.c
> +++ /dev/null
> @@ -1,83 +0,0 @@
> -/** @file
> - Perform the platform memory test
> -
> -Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
> -SPDX-License-Identifier: BSD-2-Clause-Patent
> -
> -**/
> -
> -#include "BdsPlatform.h"
> -#include <Protocol/GenericMemoryTest.h>
> -
> -/**
> - Perform the memory test base on the memory test intensive level,
> - and update the memory resource.
> -
> - @param Level The memory test intensive level.
> -
> - @retval EFI_STATUS Success test all the system memory and update
> - the memory resource
> -
> -**/
> -EFI_STATUS
> -MemoryTest (
> - IN EXTENDMEM_COVERAGE_LEVEL Level
> - )
> -{
> - EFI_STATUS Status;
> - BOOLEAN RequireSoftECCInit;
> - EFI_GENERIC_MEMORY_TEST_PROTOCOL *GenMemoryTest;
> - UINT64 TestedMemorySize;
> - UINT64 TotalMemorySize;
> - BOOLEAN ErrorOut;
> - BOOLEAN TestAbort;
> -
> - TestedMemorySize = 0;
> - TotalMemorySize = 0;
> - ErrorOut = FALSE;
> - TestAbort = FALSE;
> -
> - RequireSoftECCInit = FALSE;
> -
> - Status = gBS->LocateProtocol (
> - &gEfiGenericMemTestProtocolGuid,
> - NULL,
> - (VOID **) &GenMemoryTest
> - );
> - if (EFI_ERROR (Status)) {
> - return EFI_SUCCESS;
> - }
> -
> - Status = GenMemoryTest->MemoryTestInit (
> - GenMemoryTest,
> - Level,
> - &RequireSoftECCInit
> - );
> - if (Status == EFI_NO_MEDIA) {
> - //
> - // The PEI codes also have the relevant memory test code to check the
> memory,
> - // it can select to test some range of the memory or all of them. If PEI
> code
> - // checks all the memory, this BDS memory test will has no not-test
> memory to
> - // do the test, and then the status of EFI_NO_MEDIA will be returned by
> - // "MemoryTestInit". So it does not need to test memory again, just
> return.
> - //
> - return EFI_SUCCESS;
> - }
> -
> - do {
> - Status = GenMemoryTest->PerformMemoryTest (
> - GenMemoryTest,
> - &TestedMemorySize,
> - &TotalMemorySize,
> - &ErrorOut,
> - TestAbort
> - );
> - if (ErrorOut && (Status == EFI_DEVICE_ERROR)) {
> - ASSERT (0);
> - }
> - } while (Status != EFI_NOT_FOUND);
> -
> - Status = GenMemoryTest->Finished (GenMemoryTest);
> -
> - return EFI_SUCCESS;
> -}
> diff --git
> a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/
> PlatformBootOption.c
> b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib
> /PlatformBootOption.c
> deleted file mode 100644
> index 84aa097d58..0000000000
> ---
> a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/
> PlatformBootOption.c
> +++ /dev/null
> @@ -1,559 +0,0 @@
> -/** @file
> - Driver for Platform Boot Options support.
> -
> -Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
> -SPDX-License-Identifier: BSD-2-Clause-Patent
> -
> -**/
> -
> -#include "BdsPlatform.h"
> -
> -#include <Library/PcdLib.h>
> -
> -BOOLEAN mContinueBoot = FALSE;
> -BOOLEAN mBootMenuBoot = FALSE;
> -BOOLEAN mPxeBoot = FALSE;
> -BOOLEAN mHotKeypressed = FALSE;
> -EFI_EVENT HotKeyEvent = NULL;
> -
> -UINTN mBootMenuOptionNumber;
> -
> -EFI_DEVICE_PATH_PROTOCOL *
> -BdsCreateShellDevicePath (
> - VOID
> - )
> -/*++
> -
> -Routine Description:
> -
> - This function will create a SHELL BootOption to boot.
> -
> -Arguments:
> -
> - None.
> -
> -Returns:
> -
> - Shell Device path for booting.
> -
> ---*/
> -{
> - UINTN FvHandleCount;
> - EFI_HANDLE *FvHandleBuffer;
> - UINTN Index;
> - EFI_STATUS Status;
> - EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
> - UINTN Size;
> - UINT32 AuthenticationStatus;
> - EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> - VOID *Buffer;
> -
> - DevicePath = NULL;
> - Status = EFI_SUCCESS;
> -
> - DEBUG ((DEBUG_INFO, "BdsCreateShellDevicePath\n"));
> - gBS->LocateHandleBuffer (
> - ByProtocol,
> - &gEfiFirmwareVolume2ProtocolGuid,
> - NULL,
> - &FvHandleCount,
> - &FvHandleBuffer
> - );
> -
> - for (Index = 0; Index < FvHandleCount; Index++) {
> - gBS->HandleProtocol (
> - FvHandleBuffer[Index],
> - &gEfiFirmwareVolume2ProtocolGuid,
> - (VOID **) &Fv
> - );
> -
> - Buffer = NULL;
> - Size = 0;
> - Status = Fv->ReadSection (
> - Fv,
> - &gUefiShellFileGuid,
> - EFI_SECTION_PE32,
> - 0,
> - &Buffer,
> - &Size,
> - &AuthenticationStatus
> - );
> - if (EFI_ERROR (Status)) {
> - //
> - // Skip if no shell file in the FV
> - //
> - continue;
> - } else {
> - //
> - // Found the shell
> - //
> - break;
> - }
> - }
> -
> - if (EFI_ERROR (Status)) {
> - //
> - // No shell present
> - //
> - if (FvHandleCount) {
> - FreePool (FvHandleBuffer);
> - }
> - return NULL;
> - }
> - //
> - // Build the shell boot option
> - //
> - DevicePath = DevicePathFromHandle (FvHandleBuffer[Index]);
> -
> - if (FvHandleCount) {
> - FreePool (FvHandleBuffer);
> - }
> -
> - return DevicePath;
> -}
> -
> -
> -EFI_STATUS
> -CreateFvBootOption (
> - EFI_GUID *FileGuid,
> - CHAR16 *Description,
> - EFI_BOOT_MANAGER_LOAD_OPTION *BootOption,
> - UINT32 Attributes,
> - UINT8 *OptionalData, OPTIONAL
> - UINT32 OptionalDataSize
> - )
> -{
> - EFI_STATUS Status;
> - EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> - EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
> - MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
> - EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
> - UINT32 AuthenticationStatus;
> - VOID *Buffer;
> - UINTN Size;
> -
> - if ((BootOption == NULL) || (FileGuid == NULL) || (Description == NULL)) {
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);
> -
> - if (!CompareGuid (&gUefiShellFileGuid, FileGuid)) {
> - Status = gBS->HandleProtocol (
> - gImageHandle,
> - &gEfiLoadedImageProtocolGuid,
> - (VOID **) &LoadedImage
> - );
> - if (!EFI_ERROR (Status)) {
> - Status = gBS->HandleProtocol (
> - LoadedImage->DeviceHandle,
> - &gEfiFirmwareVolume2ProtocolGuid,
> - (VOID **) &Fv
> - );
> - if (!EFI_ERROR (Status)) {
> - Buffer = NULL;
> - Size = 0;
> - Status = Fv->ReadSection (
> - Fv,
> - FileGuid,
> - EFI_SECTION_PE32,
> - 0,
> - &Buffer,
> - &Size,
> - &AuthenticationStatus
> - );
> - if (Buffer != NULL) {
> - FreePool (Buffer);
> - }
> - }
> - }
> - if (EFI_ERROR (Status)) {
> - return EFI_NOT_FOUND;
> - }
> -
> - DevicePath = AppendDevicePathNode (
> - DevicePathFromHandle (LoadedImage->DeviceHandle),
> - (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
> - );
> - } else {
> - DevicePath = AppendDevicePathNode (
> - BdsCreateShellDevicePath (),
> - (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
> - );
> - }
> -
> - Status = EfiBootManagerInitializeLoadOption (
> - BootOption,
> - LoadOptionNumberUnassigned,
> - LoadOptionTypeBoot,
> - Attributes,
> - Description,
> - DevicePath,
> - OptionalData,
> - OptionalDataSize
> - );
> - FreePool (DevicePath);
> - return Status;
> -}
> -
> -EFI_GUID mUiFile = {
> - 0x462CAA21, 0x7614, 0x4503, { 0x83, 0x6E, 0x8A, 0xB6, 0xF4, 0x66, 0x23,
> 0x31 }
> -};
> -EFI_GUID mBootMenuFile = {
> - 0xEEC25BDC, 0x67F2, 0x4D95, { 0xB1, 0xD5, 0xF8, 0x1B, 0x20, 0x39, 0xD1,
> 0x1D }
> -};
> -
> -
> -/**
> - Return the index of the load option in the load option array.
> -
> - The function consider two load options are equal when the
> - OptionType, Attributes, Description, FilePath and OptionalData are equal.
> -
> - @param Key Pointer to the load option to be found.
> - @param Array Pointer to the array of load options to be found.
> - @param Count Number of entries in the Array.
> -
> - @retval -1 Key wasn't found in the Array.
> - @retval 0 ~ Count-1 The index of the Key in the Array.
> -**/
> -INTN
> -PlatformFindLoadOption (
> - IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Key,
> - IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Array,
> - IN UINTN Count
> - )
> -{
> - UINTN Index;
> -
> - for (Index = 0; Index < Count; Index++) {
> - if ((Key->OptionType == Array[Index].OptionType) &&
> - (Key->Attributes == Array[Index].Attributes) &&
> - (StrCmp (Key->Description, Array[Index].Description) == 0) &&
> - (CompareMem (Key->FilePath, Array[Index].FilePath,
> GetDevicePathSize (Key->FilePath)) == 0) &&
> - (Key->OptionalDataSize == Array[Index].OptionalDataSize) &&
> - (CompareMem (Key->OptionalData, Array[Index].OptionalData, Key-
> >OptionalDataSize) == 0)) {
> - return (INTN) Index;
> - }
> - }
> -
> - return -1;
> -}
> -
> -UINTN
> -RegisterFvBootOption (
> - EFI_GUID *FileGuid,
> - CHAR16 *Description,
> - UINTN Position,
> - UINT32 Attributes,
> - UINT8 *OptionalData, OPTIONAL
> - UINT32 OptionalDataSize
> - )
> -{
> - EFI_STATUS Status;
> - UINTN OptionIndex;
> - EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
> - EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
> - UINTN BootOptionCount;
> -
> - NewOption.OptionNumber = LoadOptionNumberUnassigned;
> - Status = CreateFvBootOption (FileGuid, Description, &NewOption,
> Attributes, OptionalData, OptionalDataSize);
> - if (!EFI_ERROR (Status)) {
> - BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount,
> LoadOptionTypeBoot);
> -
> - OptionIndex = PlatformFindLoadOption (&NewOption, BootOptions,
> BootOptionCount);
> -
> - if (OptionIndex == -1) {
> - Status = EfiBootManagerAddLoadOptionVariable (&NewOption,
> Position);
> - ASSERT_EFI_ERROR (Status);
> - } else {
> - NewOption.OptionNumber = BootOptions[OptionIndex].OptionNumber;
> - }
> - EfiBootManagerFreeLoadOption (&NewOption);
> - EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
> - }
> -
> - return NewOption.OptionNumber;
> -}
> -
> -
> -
> -VOID
> -EFIAPI
> -PlatformBootManagerWaitCallback (
> - UINT16 TimeoutRemain
> - )
> -{
> - EFI_STATUS Status;
> - EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TxtInEx;
> - EFI_KEY_DATA KeyData;
> - BOOLEAN PausePressed;
> -
> - //
> - // Pause on PAUSE key
> - //
> - Status = gBS->HandleProtocol (gST->ConsoleInHandle,
> &gEfiSimpleTextInputExProtocolGuid, (VOID **) &TxtInEx);
> - ASSERT_EFI_ERROR (Status);
> -
> - PausePressed = FALSE;
> -
> - while (TRUE) {
> - Status = TxtInEx->ReadKeyStrokeEx (TxtInEx, &KeyData);
> - if (EFI_ERROR (Status)) {
> - break;
> - }
> -
> - if (KeyData.Key.ScanCode == SCAN_PAUSE) {
> - PausePressed = TRUE;
> - break;
> - }
> - }
> -
> - //
> - // Loop until non-PAUSE key pressed
> - //
> - while (PausePressed) {
> - Status = TxtInEx->ReadKeyStrokeEx (TxtInEx, &KeyData);
> - if (!EFI_ERROR (Status)) {
> - DEBUG ((
> - DEBUG_INFO, "[PauseCallback] %x/%x %x/%x\n",
> - KeyData.Key.ScanCode, KeyData.Key.UnicodeChar,
> - KeyData.KeyState.KeyShiftState, KeyData.KeyState.KeyToggleState
> - ));
> - PausePressed = (BOOLEAN) (KeyData.Key.ScanCode == SCAN_PAUSE);
> - }
> - }
> -}
> -
> -
> -EFI_GUID gUefiShellFileGuid = { 0x7C04A583, 0x9E3E, 0x4f1c, { 0xAD, 0x65,
> 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 } };
> -
> -#define INTERNAL_UEFI_SHELL_NAME L"Internal UEFI Shell 2.0"
> -#define UEFI_HARD_DRIVE_NAME L"UEFI Hard Drive"
> -
> -VOID
> -RegisterDefaultBootOption (
> - VOID
> - )
> -{
> -#if 0
> - EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> - EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
> - MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
> -#endif
> - UINT16 *ShellData;
> - UINT32 ShellDataSize;
> -
> - ShellData = NULL;
> - ShellDataSize = 0;
> - RegisterFvBootOption (&gUefiShellFileGuid,
> INTERNAL_UEFI_SHELL_NAME, (UINTN) -1, LOAD_OPTION_ACTIVE, (UINT8
> *)ShellData, ShellDataSize);
> -
> - //
> - // Boot Menu
> - //
> - mBootMenuOptionNumber = RegisterFvBootOption (&mBootMenuFile,
> L"Boot Device List", (UINTN) -1, LOAD_OPTION_CATEGORY_APP |
> LOAD_OPTION_ACTIVE | LOAD_OPTION_HIDDEN, NULL, 0);
> -
> - if (mBootMenuOptionNumber == LoadOptionNumberUnassigned) {
> - DEBUG ((DEBUG_INFO, "BootMenuOptionNumber (%d) should not be
> same to LoadOptionNumberUnassigned(%d).\n",
> mBootMenuOptionNumber, LoadOptionNumberUnassigned));
> - }
> -#if 0
> - //
> - // Boot Manager Menu
> - //
> - EfiInitializeFwVolDevicepathNode (&FileNode, &mUiFile);
> -
> - gBS->HandleProtocol (
> - gImageHandle,
> - &gEfiLoadedImageProtocolGuid,
> - (VOID **) &LoadedImage
> - );
> - DevicePath = AppendDevicePathNode (DevicePathFromHandle
> (LoadedImage->DeviceHandle), (EFI_DEVICE_PATH_PROTOCOL *)
> &FileNode);
> -#endif
> -
> -}
> -
> -VOID
> -RegisterBootOptionHotkey (
> - UINT16 OptionNumber,
> - EFI_INPUT_KEY *Key,
> - BOOLEAN Add
> - )
> -{
> - EFI_STATUS Status;
> -
> - if (!Add) {
> - //
> - // No enter hotkey when force to setup or there is no boot option
> - //
> - Status = EfiBootManagerDeleteKeyOptionVariable (NULL, 0, Key, NULL);
> - ASSERT (Status == EFI_SUCCESS || Status == EFI_NOT_FOUND);
> - } else {
> - //
> - // Register enter hotkey for the first boot option
> - //
> - Status = EfiBootManagerAddKeyOptionVariable (NULL, OptionNumber, 0,
> Key,NULL);
> - ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
> - }
> -}
> -
> -EFI_STATUS
> -EFIAPI
> -DetectKeypressCallback (
> - IN EFI_KEY_DATA *KeyData
> -)
> -{
> - mHotKeypressed = TRUE;
> -
> - if (HotKeyEvent != NULL) {
> - gBS->SignalEvent(HotKeyEvent);
> - }
> -
> - return EFI_SUCCESS;
> -}
> -
> -/**
> - This function is called after all the boot options are enumerated and
> ordered properly.
> -**/
> -VOID
> -RegisterStaticHotkey (
> - VOID
> - )
> -{
> -
> - EFI_INPUT_KEY Enter;
> - EFI_KEY_DATA F2;
> - EFI_KEY_DATA F7;
> - BOOLEAN EnterSetup;
> - EFI_STATUS Status;
> - EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
> -
> - EnterSetup = FALSE;
> -
> - //
> - // [Enter]
> - //
> - mContinueBoot = !EnterSetup;
> - if (mContinueBoot) {
> - Enter.ScanCode = SCAN_NULL;
> - Enter.UnicodeChar = CHAR_CARRIAGE_RETURN;
> - EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL);
> - }
> -
> -
> - //
> - // [F2]/[F7]
> - //
> - F2.Key.ScanCode = SCAN_F2;
> - F2.Key.UnicodeChar = CHAR_NULL;
> - F2.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID;
> - F2.KeyState.KeyToggleState = 0;
> - Status = EfiBootManagerGetBootManagerMenu (&BootOption);
> - ASSERT_EFI_ERROR (Status);
> - RegisterBootOptionHotkey ((UINT16) BootOption.OptionNumber,
> &F2.Key, TRUE);
> - EfiBootManagerFreeLoadOption (&BootOption);
> -
> - F7.Key.ScanCode = SCAN_F7;
> - F7.Key.UnicodeChar = CHAR_NULL;
> - F7.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID;
> - F7.KeyState.KeyToggleState = 0;
> - mBootMenuBoot = !EnterSetup;
> - RegisterBootOptionHotkey ((UINT16) mBootMenuOptionNumber,
> &F7.Key, mBootMenuBoot);
> -
> -}
> -
> -UINT8
> -BootOptionType (
> - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
> - )
> -{
> - EFI_DEVICE_PATH_PROTOCOL *Node;
> - EFI_DEVICE_PATH_PROTOCOL *NextNode;
> -
> - for (Node = DevicePath; !IsDevicePathEndType (Node); Node =
> NextDevicePathNode (Node)) {
> - if (DevicePathType (Node) == MESSAGING_DEVICE_PATH) {
> - //
> - // Make sure the device path points to the driver device.
> - //
> - NextNode = NextDevicePathNode (Node);
> - if (DevicePathSubType(NextNode) == MSG_DEVICE_LOGICAL_UNIT_DP)
> {
> - //
> - // if the next node type is Device Logical Unit, which specify the Logical
> Unit Number (LUN),
> - // skip it
> - //
> - NextNode = NextDevicePathNode (NextNode);
> - }
> - if (IsDevicePathEndType (NextNode)) {
> - if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH)) {
> - return DevicePathSubType (Node);
> - } else {
> - return MSG_SATA_DP;
> - }
> - }
> - }
> - }
> -
> - return (UINT8) -1;
> -}
> -
> -/**
> - Returns the priority number.
> - OptionType EFI
> - ------------------------------------
> - PXE 2
> - DVD 4
> - USB 6
> - NVME 7
> - HDD 8
> - EFI Shell 9
> - Others 100
> -
> - @param BootOption
> -**/
> -UINTN
> -BootOptionPriority (
> - CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOption
> - )
> -{
> - //
> - // EFI boot options
> - //
> - switch (BootOptionType (BootOption->FilePath)) {
> - case MSG_MAC_ADDR_DP:
> - case MSG_VLAN_DP:
> - case MSG_IPv4_DP:
> - case MSG_IPv6_DP:
> - return 2;
> -
> - case MSG_SATA_DP:
> - case MSG_ATAPI_DP:
> - case MSG_UFS_DP:
> - case MSG_NVME_NAMESPACE_DP:
> - return 4;
> -
> - case MSG_USB_DP:
> - return 6;
> -
> - }
> - if (StrCmp (BootOption->Description, INTERNAL_UEFI_SHELL_NAME) ==
> 0) {
> - if (PcdGetBool (PcdBootToShellOnly)) {
> - return 0;
> - }
> - return 9;
> - }
> - if (StrCmp (BootOption->Description, UEFI_HARD_DRIVE_NAME) == 0) {
> - return 8;
> - }
> - return 100;
> -}
> -
> -INTN
> -EFIAPI
> -CompareBootOption (
> - CONST VOID *Left,
> - CONST VOID *Right
> - )
> -{
> - return BootOptionPriority ((EFI_BOOT_MANAGER_LOAD_OPTION *) Left)
> -
> - BootOptionPriority ((EFI_BOOT_MANAGER_LOAD_OPTION *) Right);
> -}
> -
> --
> 2.19.1.windows.1
^ permalink raw reply [flat|nested] 45+ messages in thread
* [edk2-platforms] [PATCH 06/11] BoardModulePkg: Add Generic BoardBootManagerLib
2019-12-14 1:32 [edk2-platforms] [PATCH 00/11] Add BDS Hook Points Agyeman, Prince
` (4 preceding siblings ...)
2019-12-14 1:32 ` [edk2-platforms] [PATCH 05/11] MinPlatformPkg: Add BDS Hook Points Agyeman, Prince
@ 2019-12-14 1:32 ` Agyeman, Prince
2019-12-18 1:34 ` Nate DeSimone
2019-12-21 2:36 ` Kubacki, Michael A
2019-12-14 1:32 ` [edk2-platforms] [PATCH 07/11] KabylakeOpenBoardPkg: Add BDS Hook Dxe Driver Agyeman, Prince
` (5 subsequent siblings)
11 siblings, 2 replies; 45+ messages in thread
From: Agyeman, Prince @ 2019-12-14 1:32 UTC (permalink / raw)
To: devel; +Cc: Michael Kubacki, Chasel Chiu, Nate DeSimone
This library implements a generic PlatformBootManagerWaitCallback
and PlatformBootManagerUnableToBoot which will be linked Minplatform's
PlatformBootManager library instance.
Cc: Michael Kubacki <michael.a.kubacki@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
---
.../BoardBootManagerLib/BoardBootManager.c | 103 ++++++++++++++++++
.../BoardBootManagerLib.inf | 39 +++++++
.../BoardBootManagerLib.c | 2 +-
3 files changed, 143 insertions(+), 1 deletion(-)
create mode 100644 Platform/Intel/BoardModulePkg/Library/BoardBootManagerLib/BoardBootManager.c
create mode 100644 Platform/Intel/BoardModulePkg/Library/BoardBootManagerLib/BoardBootManagerLib.inf
diff --git a/Platform/Intel/BoardModulePkg/Library/BoardBootManagerLib/BoardBootManager.c b/Platform/Intel/BoardModulePkg/Library/BoardBootManagerLib/BoardBootManager.c
new file mode 100644
index 0000000000..f6628d4125
--- /dev/null
+++ b/Platform/Intel/BoardModulePkg/Library/BoardBootManagerLib/BoardBootManager.c
@@ -0,0 +1,103 @@
+/** @file
+ This file include board specific boot manager callbacks
+
+ Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+
+#include <Library/DebugLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/PlatformBootManagerLib.h>
+#include <Library/UefiLib.h>
+#include <Library/HobLib.h>
+#include <Library/PrintLib.h>
+#include <Library/PerformanceLib.h>
+#include <Library/BoardBootManagerLib.h>
+
+
+BOOLEAN mHotKeypressed = FALSE;
+EFI_EVENT HotKeyEvent = NULL;
+UINTN mBootMenuOptionNumber;
+
+/**
+ This function is called each second during the boot manager waits timeout.
+
+ @param TimeoutRemain The remaining timeout.
+**/
+VOID
+EFIAPI
+BoardBootManagerWaitCallback (
+ UINT16 TimeoutRemain
+ )
+{
+ EFI_STATUS Status;
+ EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TxtInEx;
+ EFI_KEY_DATA KeyData;
+ BOOLEAN PausePressed;
+
+ //
+ // Pause on PAUSE key
+ //
+ Status = gBS->HandleProtocol (gST->ConsoleInHandle, &gEfiSimpleTextInputExProtocolGuid, (VOID **) &TxtInEx);
+ ASSERT_EFI_ERROR (Status);
+
+ PausePressed = FALSE;
+
+ while (TRUE) {
+ Status = TxtInEx->ReadKeyStrokeEx (TxtInEx, &KeyData);
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+
+ if (KeyData.Key.ScanCode == SCAN_PAUSE) {
+ PausePressed = TRUE;
+ break;
+ }
+ }
+
+ //
+ // Loop until non-PAUSE key pressed
+ //
+ while (PausePressed) {
+ Status = TxtInEx->ReadKeyStrokeEx (TxtInEx, &KeyData);
+ if (!EFI_ERROR (Status)) {
+ DEBUG ((
+ DEBUG_INFO, "[PauseCallback] %x/%x %x/%x\n",
+ KeyData.Key.ScanCode, KeyData.Key.UnicodeChar,
+ KeyData.KeyState.KeyShiftState, KeyData.KeyState.KeyToggleState
+ ));
+ PausePressed = (BOOLEAN) (KeyData.Key.ScanCode == SCAN_PAUSE);
+ }
+ }
+}
+
+/**
+ The function is called when no boot option could be launched,
+ including platform recovery options and options pointing to applications
+ built into firmware volumes.
+
+ If this function returns, BDS attempts to enter an infinite loop.
+**/
+VOID
+EFIAPI
+BoardBootManagerUnableToBoot (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_BOOT_MANAGER_LOAD_OPTION BootDeviceList;
+ CHAR16 OptionName[sizeof ("Boot####")];
+
+ if (mBootMenuOptionNumber == LoadOptionNumberUnassigned) {
+ return;
+ }
+ UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", mBootMenuOptionNumber);
+ Status = EfiBootManagerVariableToLoadOption (OptionName, &BootDeviceList);
+ if (EFI_ERROR (Status)) {
+ return;
+ }
+ for (;;) {
+ EfiBootManagerBoot (&BootDeviceList);
+ }
+}
diff --git a/Platform/Intel/BoardModulePkg/Library/BoardBootManagerLib/BoardBootManagerLib.inf b/Platform/Intel/BoardModulePkg/Library/BoardBootManagerLib/BoardBootManagerLib.inf
new file mode 100644
index 0000000000..38ff52ca81
--- /dev/null
+++ b/Platform/Intel/BoardModulePkg/Library/BoardBootManagerLib/BoardBootManagerLib.inf
@@ -0,0 +1,39 @@
+## @file
+# The module definition file for BoardBootManagerLib.
+#
+# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = BoardBootManagerLib
+ FILE_GUID = E7512AE0-6CB1-47ED-B6FF-94A97A86BABB
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = BoardBootManagerLib|DXE_DRIVER
+
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 EBC
+#
+
+[Sources]
+ BoardBootManager.c
+
+[LibraryClasses]
+ BaseLib
+ UefiBootServicesTableLib
+ DebugLib
+ UefiLib
+ HobLib
+ UefiBootManagerLib
+ TimerLib
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ MinPlatformPkg/MinPlatformPkg.dec
diff --git a/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/BoardBootManagerLib.c b/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/BoardBootManagerLib.c
index 46fce8f59f..6bc518f02c 100644
--- a/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/BoardBootManagerLib.c
+++ b/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/BoardBootManagerLib.c
@@ -1,7 +1,7 @@
/** @file
This file include board specific boot manager callbacks
- Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
--
2.19.1.windows.1
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Re: [edk2-platforms] [PATCH 06/11] BoardModulePkg: Add Generic BoardBootManagerLib
2019-12-14 1:32 ` [edk2-platforms] [PATCH 06/11] BoardModulePkg: Add Generic BoardBootManagerLib Agyeman, Prince
@ 2019-12-18 1:34 ` Nate DeSimone
2019-12-21 2:36 ` Kubacki, Michael A
1 sibling, 0 replies; 45+ messages in thread
From: Nate DeSimone @ 2019-12-18 1:34 UTC (permalink / raw)
To: Agyeman, Prince; +Cc: devel@edk2.groups.io, Kubacki, Michael A, Chiu, Chasel
Hi Prince,
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
Thanks,
Nate
On Sat, Dec 14, 2019 at 01:32:32AM +0000, Agyeman, Prince wrote:
> This library implements a generic PlatformBootManagerWaitCallback
> and PlatformBootManagerUnableToBoot which will be linked Minplatform's
> PlatformBootManager library instance.
>
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
>
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
> .../BoardBootManagerLib/BoardBootManager.c | 103 ++++++++++++++++++
> .../BoardBootManagerLib.inf | 39 +++++++
> .../BoardBootManagerLib.c | 2 +-
> 3 files changed, 143 insertions(+), 1 deletion(-)
> create mode 100644 Platform/Intel/BoardModulePkg/Library/BoardBootManagerLib/BoardBootManager.c
> create mode 100644 Platform/Intel/BoardModulePkg/Library/BoardBootManagerLib/BoardBootManagerLib.inf
>
> diff --git a/Platform/Intel/BoardModulePkg/Library/BoardBootManagerLib/BoardBootManager.c b/Platform/Intel/BoardModulePkg/Library/BoardBootManagerLib/BoardBootManager.c
> new file mode 100644
> index 0000000000..f6628d4125
> --- /dev/null
> +++ b/Platform/Intel/BoardModulePkg/Library/BoardBootManagerLib/BoardBootManager.c
> @@ -0,0 +1,103 @@
> +/** @file
> + This file include board specific boot manager callbacks
> +
> + Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +**/
> +
> +
> +#include <Library/DebugLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/PlatformBootManagerLib.h>
> +#include <Library/UefiLib.h>
> +#include <Library/HobLib.h>
> +#include <Library/PrintLib.h>
> +#include <Library/PerformanceLib.h>
> +#include <Library/BoardBootManagerLib.h>
> +
> +
> +BOOLEAN mHotKeypressed = FALSE;
> +EFI_EVENT HotKeyEvent = NULL;
> +UINTN mBootMenuOptionNumber;
> +
> +/**
> + This function is called each second during the boot manager waits timeout.
> +
> + @param TimeoutRemain The remaining timeout.
> +**/
> +VOID
> +EFIAPI
> +BoardBootManagerWaitCallback (
> + UINT16 TimeoutRemain
> + )
> +{
> + EFI_STATUS Status;
> + EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TxtInEx;
> + EFI_KEY_DATA KeyData;
> + BOOLEAN PausePressed;
> +
> + //
> + // Pause on PAUSE key
> + //
> + Status = gBS->HandleProtocol (gST->ConsoleInHandle, &gEfiSimpleTextInputExProtocolGuid, (VOID **) &TxtInEx);
> + ASSERT_EFI_ERROR (Status);
> +
> + PausePressed = FALSE;
> +
> + while (TRUE) {
> + Status = TxtInEx->ReadKeyStrokeEx (TxtInEx, &KeyData);
> + if (EFI_ERROR (Status)) {
> + break;
> + }
> +
> + if (KeyData.Key.ScanCode == SCAN_PAUSE) {
> + PausePressed = TRUE;
> + break;
> + }
> + }
> +
> + //
> + // Loop until non-PAUSE key pressed
> + //
> + while (PausePressed) {
> + Status = TxtInEx->ReadKeyStrokeEx (TxtInEx, &KeyData);
> + if (!EFI_ERROR (Status)) {
> + DEBUG ((
> + DEBUG_INFO, "[PauseCallback] %x/%x %x/%x\n",
> + KeyData.Key.ScanCode, KeyData.Key.UnicodeChar,
> + KeyData.KeyState.KeyShiftState, KeyData.KeyState.KeyToggleState
> + ));
> + PausePressed = (BOOLEAN) (KeyData.Key.ScanCode == SCAN_PAUSE);
> + }
> + }
> +}
> +
> +/**
> + The function is called when no boot option could be launched,
> + including platform recovery options and options pointing to applications
> + built into firmware volumes.
> +
> + If this function returns, BDS attempts to enter an infinite loop.
> +**/
> +VOID
> +EFIAPI
> +BoardBootManagerUnableToBoot (
> + VOID
> + )
> +{
> + EFI_STATUS Status;
> + EFI_BOOT_MANAGER_LOAD_OPTION BootDeviceList;
> + CHAR16 OptionName[sizeof ("Boot####")];
> +
> + if (mBootMenuOptionNumber == LoadOptionNumberUnassigned) {
> + return;
> + }
> + UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", mBootMenuOptionNumber);
> + Status = EfiBootManagerVariableToLoadOption (OptionName, &BootDeviceList);
> + if (EFI_ERROR (Status)) {
> + return;
> + }
> + for (;;) {
> + EfiBootManagerBoot (&BootDeviceList);
> + }
> +}
> diff --git a/Platform/Intel/BoardModulePkg/Library/BoardBootManagerLib/BoardBootManagerLib.inf b/Platform/Intel/BoardModulePkg/Library/BoardBootManagerLib/BoardBootManagerLib.inf
> new file mode 100644
> index 0000000000..38ff52ca81
> --- /dev/null
> +++ b/Platform/Intel/BoardModulePkg/Library/BoardBootManagerLib/BoardBootManagerLib.inf
> @@ -0,0 +1,39 @@
> +## @file
> +# The module definition file for BoardBootManagerLib.
> +#
> +# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + INF_VERSION = 0x00010005
> + BASE_NAME = BoardBootManagerLib
> + FILE_GUID = E7512AE0-6CB1-47ED-B6FF-94A97A86BABB
> + MODULE_TYPE = DXE_DRIVER
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = BoardBootManagerLib|DXE_DRIVER
> +
> +
> +#
> +# The following information is for reference only and not required by the build tools.
> +#
> +# VALID_ARCHITECTURES = IA32 X64 EBC
> +#
> +
> +[Sources]
> + BoardBootManager.c
> +
> +[LibraryClasses]
> + BaseLib
> + UefiBootServicesTableLib
> + DebugLib
> + UefiLib
> + HobLib
> + UefiBootManagerLib
> + TimerLib
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + MinPlatformPkg/MinPlatformPkg.dec
> diff --git a/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/BoardBootManagerLib.c b/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/BoardBootManagerLib.c
> index 46fce8f59f..6bc518f02c 100644
> --- a/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/BoardBootManagerLib.c
> +++ b/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/BoardBootManagerLib.c
> @@ -1,7 +1,7 @@
> /** @file
> This file include board specific boot manager callbacks
>
> - Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> SPDX-License-Identifier: BSD-2-Clause-Patent
> **/
>
> --
> 2.19.1.windows.1
>
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [edk2-platforms] [PATCH 06/11] BoardModulePkg: Add Generic BoardBootManagerLib
2019-12-14 1:32 ` [edk2-platforms] [PATCH 06/11] BoardModulePkg: Add Generic BoardBootManagerLib Agyeman, Prince
2019-12-18 1:34 ` Nate DeSimone
@ 2019-12-21 2:36 ` Kubacki, Michael A
1 sibling, 0 replies; 45+ messages in thread
From: Kubacki, Michael A @ 2019-12-21 2:36 UTC (permalink / raw)
To: Agyeman, Prince, devel@edk2.groups.io; +Cc: Chiu, Chasel, Desimone, Nathaniel L
Reviewed-by: Michael Kubacki <michael.a.kubacki@intel.com>
> -----Original Message-----
> From: Agyeman, Prince <prince.agyeman@intel.com>
> Sent: Friday, December 13, 2019 5:33 PM
> To: devel@edk2.groups.io
> Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Chiu, Chasel
> <chasel.chiu@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>
> Subject: [edk2-platforms] [PATCH 06/11] BoardModulePkg: Add Generic
> BoardBootManagerLib
>
> This library implements a generic PlatformBootManagerWaitCallback and
> PlatformBootManagerUnableToBoot which will be linked Minplatform's
> PlatformBootManager library instance.
>
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
>
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
> .../BoardBootManagerLib/BoardBootManager.c | 103
> ++++++++++++++++++
> .../BoardBootManagerLib.inf | 39 +++++++
> .../BoardBootManagerLib.c | 2 +-
> 3 files changed, 143 insertions(+), 1 deletion(-) create mode 100644
> Platform/Intel/BoardModulePkg/Library/BoardBootManagerLib/BoardBoot
> Manager.c
> create mode 100644
> Platform/Intel/BoardModulePkg/Library/BoardBootManagerLib/BoardBoot
> ManagerLib.inf
>
> diff --git
> a/Platform/Intel/BoardModulePkg/Library/BoardBootManagerLib/BoardBoo
> tManager.c
> b/Platform/Intel/BoardModulePkg/Library/BoardBootManagerLib/BoardBoo
> tManager.c
> new file mode 100644
> index 0000000000..f6628d4125
> --- /dev/null
> +++
> b/Platform/Intel/BoardModulePkg/Library/BoardBootManagerLib/BoardBoo
> +++ tManager.c
> @@ -0,0 +1,103 @@
> +/** @file
> + This file include board specific boot manager callbacks
> +
> + Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> + SPDX-License-Identifier: BSD-2-Clause-Patent **/
> +
> +
> +#include <Library/DebugLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/PlatformBootManagerLib.h>
> +#include <Library/UefiLib.h>
> +#include <Library/HobLib.h>
> +#include <Library/PrintLib.h>
> +#include <Library/PerformanceLib.h>
> +#include <Library/BoardBootManagerLib.h>
> +
> +
> +BOOLEAN mHotKeypressed = FALSE;
> +EFI_EVENT HotKeyEvent = NULL;
> +UINTN mBootMenuOptionNumber;
> +
> +/**
> + This function is called each second during the boot manager waits timeout.
> +
> + @param TimeoutRemain The remaining timeout.
> +**/
> +VOID
> +EFIAPI
> +BoardBootManagerWaitCallback (
> + UINT16 TimeoutRemain
> + )
> +{
> + EFI_STATUS Status;
> + EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TxtInEx;
> + EFI_KEY_DATA KeyData;
> + BOOLEAN PausePressed;
> +
> + //
> + // Pause on PAUSE key
> + //
> + Status = gBS->HandleProtocol (gST->ConsoleInHandle,
> + &gEfiSimpleTextInputExProtocolGuid, (VOID **) &TxtInEx);
> + ASSERT_EFI_ERROR (Status);
> +
> + PausePressed = FALSE;
> +
> + while (TRUE) {
> + Status = TxtInEx->ReadKeyStrokeEx (TxtInEx, &KeyData);
> + if (EFI_ERROR (Status)) {
> + break;
> + }
> +
> + if (KeyData.Key.ScanCode == SCAN_PAUSE) {
> + PausePressed = TRUE;
> + break;
> + }
> + }
> +
> + //
> + // Loop until non-PAUSE key pressed
> + //
> + while (PausePressed) {
> + Status = TxtInEx->ReadKeyStrokeEx (TxtInEx, &KeyData);
> + if (!EFI_ERROR (Status)) {
> + DEBUG ((
> + DEBUG_INFO, "[PauseCallback] %x/%x %x/%x\n",
> + KeyData.Key.ScanCode, KeyData.Key.UnicodeChar,
> + KeyData.KeyState.KeyShiftState, KeyData.KeyState.KeyToggleState
> + ));
> + PausePressed = (BOOLEAN) (KeyData.Key.ScanCode == SCAN_PAUSE);
> + }
> + }
> +}
> +
> +/**
> + The function is called when no boot option could be launched,
> + including platform recovery options and options pointing to
> +applications
> + built into firmware volumes.
> +
> + If this function returns, BDS attempts to enter an infinite loop.
> +**/
> +VOID
> +EFIAPI
> +BoardBootManagerUnableToBoot (
> + VOID
> + )
> +{
> + EFI_STATUS Status;
> + EFI_BOOT_MANAGER_LOAD_OPTION BootDeviceList;
> + CHAR16 OptionName[sizeof ("Boot####")];
> +
> + if (mBootMenuOptionNumber == LoadOptionNumberUnassigned) {
> + return;
> + }
> + UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x",
> +mBootMenuOptionNumber);
> + Status = EfiBootManagerVariableToLoadOption (OptionName,
> +&BootDeviceList);
> + if (EFI_ERROR (Status)) {
> + return;
> + }
> + for (;;) {
> + EfiBootManagerBoot (&BootDeviceList);
> + }
> +}
> diff --git
> a/Platform/Intel/BoardModulePkg/Library/BoardBootManagerLib/BoardBoo
> tManagerLib.inf
> b/Platform/Intel/BoardModulePkg/Library/BoardBootManagerLib/BoardBoo
> tManagerLib.inf
> new file mode 100644
> index 0000000000..38ff52ca81
> --- /dev/null
> +++
> b/Platform/Intel/BoardModulePkg/Library/BoardBootManagerLib/BoardBoo
> +++ tManagerLib.inf
> @@ -0,0 +1,39 @@
> +## @file
> +# The module definition file for BoardBootManagerLib.
> +#
> +# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> #
> +SPDX-License-Identifier: BSD-2-Clause-Patent # ##
> +
> +[Defines]
> + INF_VERSION = 0x00010005
> + BASE_NAME = BoardBootManagerLib
> + FILE_GUID = E7512AE0-6CB1-47ED-B6FF-94A97A86BABB
> + MODULE_TYPE = DXE_DRIVER
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = BoardBootManagerLib|DXE_DRIVER
> +
> +
> +#
> +# The following information is for reference only and not required by the
> build tools.
> +#
> +# VALID_ARCHITECTURES = IA32 X64 EBC
> +#
> +
> +[Sources]
> + BoardBootManager.c
> +
> +[LibraryClasses]
> + BaseLib
> + UefiBootServicesTableLib
> + DebugLib
> + UefiLib
> + HobLib
> + UefiBootManagerLib
> + TimerLib
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + MinPlatformPkg/MinPlatformPkg.dec
> diff --git
> a/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/Bo
> ardBootManagerLib.c
> b/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/Bo
> ardBootManagerLib.c
> index 46fce8f59f..6bc518f02c 100644
> ---
> a/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/Bo
> ardBootManagerLib.c
> +++
> b/Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/
> +++ BoardBootManagerLib.c
> @@ -1,7 +1,7 @@
> /** @file
> This file include board specific boot manager callbacks
>
> - Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> SPDX-License-Identifier: BSD-2-Clause-Patent **/
>
> --
> 2.19.1.windows.1
^ permalink raw reply [flat|nested] 45+ messages in thread
* [edk2-platforms] [PATCH 07/11] KabylakeOpenBoardPkg: Add BDS Hook Dxe Driver
2019-12-14 1:32 [edk2-platforms] [PATCH 00/11] Add BDS Hook Points Agyeman, Prince
` (5 preceding siblings ...)
2019-12-14 1:32 ` [edk2-platforms] [PATCH 06/11] BoardModulePkg: Add Generic BoardBootManagerLib Agyeman, Prince
@ 2019-12-14 1:32 ` Agyeman, Prince
2019-12-17 5:44 ` Chiu, Chasel
` (2 more replies)
2019-12-14 1:32 ` [edk2-platforms] [PATCH 08/11] WhiskeylakeOpenBoardPkg: " Agyeman, Prince
` (4 subsequent siblings)
11 siblings, 3 replies; 45+ messages in thread
From: Agyeman, Prince @ 2019-12-14 1:32 UTC (permalink / raw)
To: devel; +Cc: Michael Kubacki, Chasel Chiu, Nate DeSimone
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
Added a DXE driver that registers the minimum platform
BDS hook points for the GalagoPro3 and KabylakeRvp3 boards.
These hooks are triggered on the BDS hook events
What was done:
* Included an instance of BoardBdsHookLib and BoardBootManagerLib
from BoardModulePkg
* Included BdsHookDxe to register the callbacks implemented
in BoardBdsHookLib
Cc: Michael Kubacki <michael.a.kubacki@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
---
.../Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc | 7 +++++++
.../Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf | 1 +
.../KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc | 6 ++++++
.../KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.fdf | 1 +
4 files changed, 15 insertions(+)
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
index a39547f41f..bf63d53bef 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
@@ -201,6 +201,12 @@
TestPointCheckLib|$(PLATFORM_PACKAGE)/Test/Library/TestPointCheckLib/DxeTestPointCheckLib.inf
!endif
+ #######################################
+ # Board Package
+ #######################################
+ BoardBdsHookLib|BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
+ BoardBootManagerLib|BoardModulePkg/Library/BoardBootManagerLib/BoardBootManagerLib.inf
+
#######################################
# Board-specific
#######################################
@@ -425,3 +431,4 @@
}
!endif
BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
+ BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf
index da94ed0cd1..196f04c68d 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf
@@ -341,6 +341,7 @@ INF MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDxe.inf
INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
INF BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
INF MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf
+INF BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
INF ShellPkg/Application/Shell/Shell.inf
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc
index 50be2bb624..044688ba4e 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc
@@ -241,6 +241,11 @@
!if $(TARGET) == DEBUG
TestPointCheckLib|$(PLATFORM_PACKAGE)/Test/Library/TestPointCheckLib/DxeTestPointCheckLib.inf
!endif
+ #######################################
+ # Board Package
+ #######################################
+ BoardBdsHookLib|BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
+ BoardBootManagerLib|BoardModulePkg/Library/BoardBootManagerLib/BoardBootManagerLib.inf
#######################################
# Board-specific
@@ -505,3 +510,4 @@
}
!endif
BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
+ BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.fdf b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.fdf
index fc1c6a9c25..f2cfff1c7b 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.fdf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.fdf
@@ -343,6 +343,7 @@ INF MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
INF MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDxe.inf
INF BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
INF MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf
+INF BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
INF ShellPkg/Application/Shell/Shell.inf
--
2.19.1.windows.1
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Re: [edk2-platforms] [PATCH 07/11] KabylakeOpenBoardPkg: Add BDS Hook Dxe Driver
2019-12-14 1:32 ` [edk2-platforms] [PATCH 07/11] KabylakeOpenBoardPkg: Add BDS Hook Dxe Driver Agyeman, Prince
@ 2019-12-17 5:44 ` Chiu, Chasel
2019-12-18 1:35 ` Nate DeSimone
2019-12-21 2:36 ` Kubacki, Michael A
2 siblings, 0 replies; 45+ messages in thread
From: Chiu, Chasel @ 2019-12-17 5:44 UTC (permalink / raw)
To: Agyeman, Prince, devel@edk2.groups.io
Cc: Kubacki, Michael A, Desimone, Nathaniel L
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
> -----Original Message-----
> From: Agyeman, Prince <prince.agyeman@intel.com>
> Sent: Saturday, December 14, 2019 9:33 AM
> To: devel@edk2.groups.io
> Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Chiu, Chasel
> <chasel.chiu@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>
> Subject: [edk2-platforms] [PATCH 07/11] KabylakeOpenBoardPkg: Add BDS
> Hook Dxe Driver
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
>
> Added a DXE driver that registers the minimum platform BDS hook points for
> the GalagoPro3 and KabylakeRvp3 boards.
> These hooks are triggered on the BDS hook events
>
> What was done:
>
> * Included an instance of BoardBdsHookLib and BoardBootManagerLib from
> BoardModulePkg
>
> * Included BdsHookDxe to register the callbacks implemented in
> BoardBdsHookLib
>
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
>
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
> .../Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc | 7
> +++++++ .../Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf |
> 1 +
> .../KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc | 6
> ++++++
> .../KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.fdf | 1 +
> 4 files changed, 15 insertions(+)
>
> diff --git
> a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
> b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
> index a39547f41f..bf63d53bef 100644
> --- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
> +++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
> @@ -201,6 +201,12 @@
>
> TestPointCheckLib|$(PLATFORM_PACKAGE)/Test/Library/TestPointCheckLib/D
> xeTestPointCheckLib.inf
> !endif
>
> + #######################################
> + # Board Package
> + #######################################
> +
> +
> BoardBdsHookLib|BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHo
> okLib
> + .inf
> +
> BoardBootManagerLib|BoardModulePkg/Library/BoardBootManagerLib/Bo
> ardBo
> + otManagerLib.inf
> +
> #######################################
> # Board-specific
> #######################################
> @@ -425,3 +431,4 @@
> }
> !endif
> BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> + BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
> diff --git
> a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf
> b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf
> index da94ed0cd1..196f04c68d 100644
> --- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf
> +++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf
> @@ -341,6 +341,7 @@ INF
> MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDxe.
> inf
> INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
> INF BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> INF MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf
> +INF BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
>
> INF ShellPkg/Application/Shell/Shell.inf
>
> diff --git
> a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc
> b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc
> index 50be2bb624..044688ba4e 100644
> ---
> a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc
> +++
> b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc
> @@ -241,6 +241,11 @@
> !if $(TARGET) == DEBUG
>
> TestPointCheckLib|$(PLATFORM_PACKAGE)/Test/Library/TestPointCheckLib/D
> xeTestPointCheckLib.inf
> !endif
> + #######################################
> + # Board Package
> + #######################################
> +
> +
> BoardBdsHookLib|BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHo
> okLib
> + .inf
> +
> BoardBootManagerLib|BoardModulePkg/Library/BoardBootManagerLib/Bo
> ardBo
> + otManagerLib.inf
>
> #######################################
> # Board-specific
> @@ -505,3 +510,4 @@
> }
> !endif
> BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> + BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
> diff --git
> a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.fdf
> b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.fdf
> index fc1c6a9c25..f2cfff1c7b 100644
> --- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.fdf
> +++
> b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.fdf
> @@ -343,6 +343,7 @@ INF
> MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
> INF
> MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDxe.
> inf
> INF BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> INF MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf
> +INF BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
>
> INF ShellPkg/Application/Shell/Shell.inf
>
> --
> 2.19.1.windows.1
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [edk2-platforms] [PATCH 07/11] KabylakeOpenBoardPkg: Add BDS Hook Dxe Driver
2019-12-14 1:32 ` [edk2-platforms] [PATCH 07/11] KabylakeOpenBoardPkg: Add BDS Hook Dxe Driver Agyeman, Prince
2019-12-17 5:44 ` Chiu, Chasel
@ 2019-12-18 1:35 ` Nate DeSimone
2019-12-21 2:36 ` Kubacki, Michael A
2 siblings, 0 replies; 45+ messages in thread
From: Nate DeSimone @ 2019-12-18 1:35 UTC (permalink / raw)
To: Agyeman, Prince; +Cc: devel@edk2.groups.io, Kubacki, Michael A, Chiu, Chasel
Hi Prince,
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
Thanks,
Nate
On Sat, Dec 14, 2019 at 01:32:33AM +0000, Agyeman, Prince wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
>
> Added a DXE driver that registers the minimum platform
> BDS hook points for the GalagoPro3 and KabylakeRvp3 boards.
> These hooks are triggered on the BDS hook events
>
> What was done:
>
> * Included an instance of BoardBdsHookLib and BoardBootManagerLib
> from BoardModulePkg
>
> * Included BdsHookDxe to register the callbacks implemented
> in BoardBdsHookLib
>
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
>
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
> .../Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc | 7 +++++++
> .../Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf | 1 +
> .../KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc | 6 ++++++
> .../KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.fdf | 1 +
> 4 files changed, 15 insertions(+)
>
> diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
> index a39547f41f..bf63d53bef 100644
> --- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
> +++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
> @@ -201,6 +201,12 @@
> TestPointCheckLib|$(PLATFORM_PACKAGE)/Test/Library/TestPointCheckLib/DxeTestPointCheckLib.inf
> !endif
>
> + #######################################
> + # Board Package
> + #######################################
> + BoardBdsHookLib|BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
> + BoardBootManagerLib|BoardModulePkg/Library/BoardBootManagerLib/BoardBootManagerLib.inf
> +
> #######################################
> # Board-specific
> #######################################
> @@ -425,3 +431,4 @@
> }
> !endif
> BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> + BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
> diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf
> index da94ed0cd1..196f04c68d 100644
> --- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf
> +++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf
> @@ -341,6 +341,7 @@ INF MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDxe.inf
> INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
> INF BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> INF MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf
> +INF BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
>
> INF ShellPkg/Application/Shell/Shell.inf
>
> diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc
> index 50be2bb624..044688ba4e 100644
> --- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc
> +++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc
> @@ -241,6 +241,11 @@
> !if $(TARGET) == DEBUG
> TestPointCheckLib|$(PLATFORM_PACKAGE)/Test/Library/TestPointCheckLib/DxeTestPointCheckLib.inf
> !endif
> + #######################################
> + # Board Package
> + #######################################
> + BoardBdsHookLib|BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
> + BoardBootManagerLib|BoardModulePkg/Library/BoardBootManagerLib/BoardBootManagerLib.inf
>
> #######################################
> # Board-specific
> @@ -505,3 +510,4 @@
> }
> !endif
> BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> + BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
> diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.fdf b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.fdf
> index fc1c6a9c25..f2cfff1c7b 100644
> --- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.fdf
> +++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.fdf
> @@ -343,6 +343,7 @@ INF MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
> INF MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDxe.inf
> INF BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> INF MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf
> +INF BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
>
> INF ShellPkg/Application/Shell/Shell.inf
>
> --
> 2.19.1.windows.1
>
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [edk2-platforms] [PATCH 07/11] KabylakeOpenBoardPkg: Add BDS Hook Dxe Driver
2019-12-14 1:32 ` [edk2-platforms] [PATCH 07/11] KabylakeOpenBoardPkg: Add BDS Hook Dxe Driver Agyeman, Prince
2019-12-17 5:44 ` Chiu, Chasel
2019-12-18 1:35 ` Nate DeSimone
@ 2019-12-21 2:36 ` Kubacki, Michael A
2 siblings, 0 replies; 45+ messages in thread
From: Kubacki, Michael A @ 2019-12-21 2:36 UTC (permalink / raw)
To: Agyeman, Prince, devel@edk2.groups.io; +Cc: Chiu, Chasel, Desimone, Nathaniel L
Reviewed-by: Michael Kubacki <michael.a.kubacki@intel.com>
> -----Original Message-----
> From: Agyeman, Prince <prince.agyeman@intel.com>
> Sent: Friday, December 13, 2019 5:33 PM
> To: devel@edk2.groups.io
> Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Chiu, Chasel
> <chasel.chiu@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>
> Subject: [edk2-platforms] [PATCH 07/11] KabylakeOpenBoardPkg: Add BDS
> Hook Dxe Driver
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
>
> Added a DXE driver that registers the minimum platform BDS hook points for
> the GalagoPro3 and KabylakeRvp3 boards.
> These hooks are triggered on the BDS hook events
>
> What was done:
>
> * Included an instance of BoardBdsHookLib and BoardBootManagerLib from
> BoardModulePkg
>
> * Included BdsHookDxe to register the callbacks implemented in
> BoardBdsHookLib
>
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
>
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
> .../Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc | 7
> +++++++ .../Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf |
> 1 +
> .../KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc | 6 ++++++
> .../KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.fdf | 1 +
> 4 files changed, 15 insertions(+)
>
> diff --git
> a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
> b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
> index a39547f41f..bf63d53bef 100644
> --- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
> +++
> b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
> @@ -201,6 +201,12 @@
>
> TestPointCheckLib|$(PLATFORM_PACKAGE)/Test/Library/TestPointCheckLib
> /DxeTestPointCheckLib.inf
> !endif
>
> + #######################################
> + # Board Package
> + #######################################
> +
> +
> BoardBdsHookLib|BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHoo
> kLib
> + .inf
> +
> BoardBootManagerLib|BoardModulePkg/Library/BoardBootManagerLib/Boa
> rdBo
> + otManagerLib.inf
> +
> #######################################
> # Board-specific
> #######################################
> @@ -425,3 +431,4 @@
> }
> !endif
> BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> + BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
> diff --git
> a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf
> b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf
> index da94ed0cd1..196f04c68d 100644
> --- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf
> +++
> b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf
> @@ -341,6 +341,7 @@ INF
> MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDx
> e.inf
> INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
> INF BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> INF MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf
> +INF BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
>
> INF ShellPkg/Application/Shell/Shell.inf
>
> diff --git
> a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc
> b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc
> index 50be2bb624..044688ba4e 100644
> ---
> a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc
> +++
> b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc
> @@ -241,6 +241,11 @@
> !if $(TARGET) == DEBUG
>
> TestPointCheckLib|$(PLATFORM_PACKAGE)/Test/Library/TestPointCheckLib
> /DxeTestPointCheckLib.inf
> !endif
> + #######################################
> + # Board Package
> + #######################################
> +
> +
> BoardBdsHookLib|BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHoo
> kLib
> + .inf
> +
> BoardBootManagerLib|BoardModulePkg/Library/BoardBootManagerLib/Boa
> rdBo
> + otManagerLib.inf
>
> #######################################
> # Board-specific
> @@ -505,3 +510,4 @@
> }
> !endif
> BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> + BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
> diff --git
> a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.fdf
> b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.fdf
> index fc1c6a9c25..f2cfff1c7b 100644
> ---
> a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.fdf
> +++
> b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.fdf
> @@ -343,6 +343,7 @@ INF
> MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
> INF
> MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDx
> e.inf
> INF BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> INF MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf
> +INF BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
>
> INF ShellPkg/Application/Shell/Shell.inf
>
> --
> 2.19.1.windows.1
^ permalink raw reply [flat|nested] 45+ messages in thread
* [edk2-platforms] [PATCH 08/11] WhiskeylakeOpenBoardPkg: Add BDS Hook Dxe Driver
2019-12-14 1:32 [edk2-platforms] [PATCH 00/11] Add BDS Hook Points Agyeman, Prince
` (6 preceding siblings ...)
2019-12-14 1:32 ` [edk2-platforms] [PATCH 07/11] KabylakeOpenBoardPkg: Add BDS Hook Dxe Driver Agyeman, Prince
@ 2019-12-14 1:32 ` Agyeman, Prince
2019-12-17 5:45 ` Chiu, Chasel
` (2 more replies)
2019-12-14 1:32 ` [edk2-platforms] [PATCH 09/11] SimicsOpenBoardPkg: Add Bds Hook Library Agyeman, Prince
` (3 subsequent siblings)
11 siblings, 3 replies; 45+ messages in thread
From: Agyeman, Prince @ 2019-12-14 1:32 UTC (permalink / raw)
To: devel; +Cc: Michael Kubacki, Chasel Chiu, Nate DeSimone
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
Added a DXE driver that registers the minimum platform
BDS hook points, to WhiskeylakeURvp board.
These hooks are triggered on the BDS hook events
What was done:
* Included an instance of BdsHookLib and BoardBootManagerLib
from BoardModulePkg
* Included BdsHookDxe to register the callbacks implemented
in BdsHookLib
Cc: Michael Kubacki <michael.a.kubacki@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
---
.../WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.dsc | 4 ++++
.../WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.fdf | 1 +
2 files changed, 5 insertions(+)
diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.dsc b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.dsc
index 47e156be08..1a9e608bd6 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.dsc
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.dsc
@@ -224,6 +224,8 @@
#######################################
DxePolicyUpdateLib|$(PLATFORM_BOARD_PACKAGE)/Policy/Library/DxePolicyUpdateLib/DxePolicyUpdateLib.inf
DxeTbtPolicyLib|$(PLATFORM_BOARD_PACKAGE)/Features/Tbt/Library/DxeTbtPolicyLib/DxeTbtPolicyLib.inf
+ BoardBdsHookLib|BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
+ BoardBootManagerLib|BoardModulePkg/Library/BoardBootManagerLib/BoardBootManagerLib.inf
#######################################
# Board-specific
@@ -452,3 +454,5 @@
$(PLATFORM_BOARD_PACKAGE)/Acpi/BoardAcpiDxe/BoardAcpiDxe.inf
!endif
BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
+ BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
+
diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.fdf b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.fdf
index f39b41b186..ad32268a82 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.fdf
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.fdf
@@ -346,6 +346,7 @@ INF MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDxe.inf
INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
INF BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
INF MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf
+INF BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
INF ShellPkg/Application/Shell/Shell.inf
--
2.19.1.windows.1
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Re: [edk2-platforms] [PATCH 08/11] WhiskeylakeOpenBoardPkg: Add BDS Hook Dxe Driver
2019-12-14 1:32 ` [edk2-platforms] [PATCH 08/11] WhiskeylakeOpenBoardPkg: " Agyeman, Prince
@ 2019-12-17 5:45 ` Chiu, Chasel
2019-12-18 1:35 ` Nate DeSimone
2019-12-21 2:36 ` Kubacki, Michael A
2 siblings, 0 replies; 45+ messages in thread
From: Chiu, Chasel @ 2019-12-17 5:45 UTC (permalink / raw)
To: Agyeman, Prince, devel@edk2.groups.io
Cc: Kubacki, Michael A, Desimone, Nathaniel L
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
> -----Original Message-----
> From: Agyeman, Prince <prince.agyeman@intel.com>
> Sent: Saturday, December 14, 2019 9:33 AM
> To: devel@edk2.groups.io
> Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Chiu, Chasel
> <chasel.chiu@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>
> Subject: [edk2-platforms] [PATCH 08/11] WhiskeylakeOpenBoardPkg: Add BDS
> Hook Dxe Driver
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
>
> Added a DXE driver that registers the minimum platform BDS hook points, to
> WhiskeylakeURvp board.
> These hooks are triggered on the BDS hook events
>
> What was done:
>
> * Included an instance of BdsHookLib and BoardBootManagerLib from
> BoardModulePkg
>
> * Included BdsHookDxe to register the callbacks implemented in BdsHookLib
>
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
>
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
> .../WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.dsc | 4
> ++++ .../WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.fdf
> | 1 +
> 2 files changed, 5 insertions(+)
>
> diff --git
> a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardP
> kg.dsc
> b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardP
> kg.dsc
> index 47e156be08..1a9e608bd6 100644
> ---
> a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardP
> kg.dsc
> +++
> b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardP
> k
> +++ g.dsc
> @@ -224,6 +224,8 @@
> #######################################
>
> DxePolicyUpdateLib|$(PLATFORM_BOARD_PACKAGE)/Policy/Library/DxePolic
> yUpdateLib/DxePolicyUpdateLib.inf
>
> DxeTbtPolicyLib|$(PLATFORM_BOARD_PACKAGE)/Features/Tbt/Library/DxeTb
> tPolicyLib/DxeTbtPolicyLib.inf
> +
> +
> BoardBdsHookLib|BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHo
> okLib
> + .inf
> +
> BoardBootManagerLib|BoardModulePkg/Library/BoardBootManagerLib/Bo
> ardBo
> + otManagerLib.inf
>
> #######################################
> # Board-specific
> @@ -452,3 +454,5 @@
> $(PLATFORM_BOARD_PACKAGE)/Acpi/BoardAcpiDxe/BoardAcpiDxe.inf
> !endif
> BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> + BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
> +
> diff --git
> a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardP
> kg.fdf
> b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardP
> kg.fdf
> index f39b41b186..ad32268a82 100644
> ---
> a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardP
> kg.fdf
> +++
> b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardP
> k
> +++ g.fdf
> @@ -346,6 +346,7 @@ INF
> MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDxe.
> inf
> INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
> INF BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> INF MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf
> +INF BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
>
> INF ShellPkg/Application/Shell/Shell.inf
>
> --
> 2.19.1.windows.1
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [edk2-platforms] [PATCH 08/11] WhiskeylakeOpenBoardPkg: Add BDS Hook Dxe Driver
2019-12-14 1:32 ` [edk2-platforms] [PATCH 08/11] WhiskeylakeOpenBoardPkg: " Agyeman, Prince
2019-12-17 5:45 ` Chiu, Chasel
@ 2019-12-18 1:35 ` Nate DeSimone
2019-12-21 2:36 ` Kubacki, Michael A
2 siblings, 0 replies; 45+ messages in thread
From: Nate DeSimone @ 2019-12-18 1:35 UTC (permalink / raw)
To: Agyeman, Prince; +Cc: devel@edk2.groups.io, Kubacki, Michael A, Chiu, Chasel
Hi Prince,
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
Thanks,
Nate
On Sat, Dec 14, 2019 at 01:32:34AM +0000, Agyeman, Prince wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
>
> Added a DXE driver that registers the minimum platform
> BDS hook points, to WhiskeylakeURvp board.
> These hooks are triggered on the BDS hook events
>
> What was done:
>
> * Included an instance of BdsHookLib and BoardBootManagerLib
> from BoardModulePkg
>
> * Included BdsHookDxe to register the callbacks implemented
> in BdsHookLib
>
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
>
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
> .../WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.dsc | 4 ++++
> .../WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.fdf | 1 +
> 2 files changed, 5 insertions(+)
>
> diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.dsc b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.dsc
> index 47e156be08..1a9e608bd6 100644
> --- a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.dsc
> +++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.dsc
> @@ -224,6 +224,8 @@
> #######################################
> DxePolicyUpdateLib|$(PLATFORM_BOARD_PACKAGE)/Policy/Library/DxePolicyUpdateLib/DxePolicyUpdateLib.inf
> DxeTbtPolicyLib|$(PLATFORM_BOARD_PACKAGE)/Features/Tbt/Library/DxeTbtPolicyLib/DxeTbtPolicyLib.inf
> + BoardBdsHookLib|BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
> + BoardBootManagerLib|BoardModulePkg/Library/BoardBootManagerLib/BoardBootManagerLib.inf
>
> #######################################
> # Board-specific
> @@ -452,3 +454,5 @@
> $(PLATFORM_BOARD_PACKAGE)/Acpi/BoardAcpiDxe/BoardAcpiDxe.inf
> !endif
> BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> + BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
> +
> diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.fdf b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.fdf
> index f39b41b186..ad32268a82 100644
> --- a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.fdf
> +++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.fdf
> @@ -346,6 +346,7 @@ INF MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDxe.inf
> INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
> INF BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> INF MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf
> +INF BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
>
> INF ShellPkg/Application/Shell/Shell.inf
>
> --
> 2.19.1.windows.1
>
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [edk2-platforms] [PATCH 08/11] WhiskeylakeOpenBoardPkg: Add BDS Hook Dxe Driver
2019-12-14 1:32 ` [edk2-platforms] [PATCH 08/11] WhiskeylakeOpenBoardPkg: " Agyeman, Prince
2019-12-17 5:45 ` Chiu, Chasel
2019-12-18 1:35 ` Nate DeSimone
@ 2019-12-21 2:36 ` Kubacki, Michael A
2 siblings, 0 replies; 45+ messages in thread
From: Kubacki, Michael A @ 2019-12-21 2:36 UTC (permalink / raw)
To: Agyeman, Prince, devel@edk2.groups.io; +Cc: Chiu, Chasel, Desimone, Nathaniel L
Reviewed-by: Michael Kubacki <michael.a.kubacki@intel.com>
> -----Original Message-----
> From: Agyeman, Prince <prince.agyeman@intel.com>
> Sent: Friday, December 13, 2019 5:33 PM
> To: devel@edk2.groups.io
> Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Chiu, Chasel
> <chasel.chiu@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>
> Subject: [edk2-platforms] [PATCH 08/11] WhiskeylakeOpenBoardPkg: Add
> BDS Hook Dxe Driver
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
>
> Added a DXE driver that registers the minimum platform BDS hook points, to
> WhiskeylakeURvp board.
> These hooks are triggered on the BDS hook events
>
> What was done:
>
> * Included an instance of BdsHookLib and BoardBootManagerLib from
> BoardModulePkg
>
> * Included BdsHookDxe to register the callbacks implemented in BdsHookLib
>
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
>
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
> .../WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.dsc | 4
> ++++ .../WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.fdf
> | 1 +
> 2 files changed, 5 insertions(+)
>
> diff --git
> a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoard
> Pkg.dsc
> b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoard
> Pkg.dsc
> index 47e156be08..1a9e608bd6 100644
> ---
> a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoard
> Pkg.dsc
> +++
> b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoard
> Pk
> +++ g.dsc
> @@ -224,6 +224,8 @@
> #######################################
>
> DxePolicyUpdateLib|$(PLATFORM_BOARD_PACKAGE)/Policy/Library/DxePol
> icyUpdateLib/DxePolicyUpdateLib.inf
>
> DxeTbtPolicyLib|$(PLATFORM_BOARD_PACKAGE)/Features/Tbt/Library/Dxe
> TbtPolicyLib/DxeTbtPolicyLib.inf
> +
> +
> BoardBdsHookLib|BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHoo
> kLib
> + .inf
> +
> BoardBootManagerLib|BoardModulePkg/Library/BoardBootManagerLib/Boa
> rdBo
> + otManagerLib.inf
>
> #######################################
> # Board-specific
> @@ -452,3 +454,5 @@
> $(PLATFORM_BOARD_PACKAGE)/Acpi/BoardAcpiDxe/BoardAcpiDxe.inf
> !endif
> BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> + BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
> +
> diff --git
> a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoard
> Pkg.fdf
> b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoard
> Pkg.fdf
> index f39b41b186..ad32268a82 100644
> ---
> a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoard
> Pkg.fdf
> +++
> b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoard
> Pk
> +++ g.fdf
> @@ -346,6 +346,7 @@ INF
> MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDx
> e.inf
> INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
> INF BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> INF MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf
> +INF BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
>
> INF ShellPkg/Application/Shell/Shell.inf
>
> --
> 2.19.1.windows.1
^ permalink raw reply [flat|nested] 45+ messages in thread
* [edk2-platforms] [PATCH 09/11] SimicsOpenBoardPkg: Add Bds Hook Library
2019-12-14 1:32 [edk2-platforms] [PATCH 00/11] Add BDS Hook Points Agyeman, Prince
` (7 preceding siblings ...)
2019-12-14 1:32 ` [edk2-platforms] [PATCH 08/11] WhiskeylakeOpenBoardPkg: " Agyeman, Prince
@ 2019-12-14 1:32 ` Agyeman, Prince
2019-12-18 1:29 ` Nate DeSimone
2019-12-21 2:37 ` Kubacki, Michael A
2019-12-14 1:32 ` [edk2-platforms] [PATCH 10/11] SimicsOpenBoardPkg: Add BDS Board Boot Manager library Agyeman, Prince
` (2 subsequent siblings)
11 siblings, 2 replies; 45+ messages in thread
From: Agyeman, Prince @ 2019-12-14 1:32 UTC (permalink / raw)
To: devel; +Cc: Nate DeSimone, Michael Kubacki
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
Added Board BDS Hook library that implements simics specific
Bds hook points or callbacks.
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Michael Kubacki <michael.a.kubacki@intel.com>
Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
---
.../Library/BoardBdsHookLib/BoardBdsHook.h | 173 ++
.../Library/BoardBdsHookLib/BoardBdsHookLib.c | 1630 +++++++++++++++++
.../BoardBdsHookLib/BoardBdsHookLib.inf | 81 +
3 files changed, 1884 insertions(+)
create mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHook.h
create mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
create mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHook.h b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHook.h
new file mode 100644
index 0000000000..fda41b1c97
--- /dev/null
+++ b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHook.h
@@ -0,0 +1,173 @@
+/** @file
+ Header file for the board board specific BDS hook library.
+
+ Copyright (c) 2019 Intel Corporation. All rights reserved. <BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef _PLATFORM_SPECIFIC_BDS_PLATFORM_H_
+#define _PLATFORM_SPECIFIC_BDS_PLATFORM_H_
+
+
+#include <PiDxe.h>
+
+#include <IndustryStandard/Pci.h>
+#include <IndustryStandard/Acpi.h>
+#include <IndustryStandard/SmBios.h>
+#include <IndustryStandard/PeImage.h>
+
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/BaseLib.h>
+#include <Library/PcdLib.h>
+#include <Library/PciLib.h>
+#include <Library/UefiBootManagerLib.h>
+#include <Library/BootLogoLib.h>
+#include <Library/HobLib.h>
+#include <Library/UefiLib.h>
+#include <Library/DxeServicesTableLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/IoLib.h>
+#include <Library/NvVarsFileLib.h>
+#include <Library/BoardBdsHookLib.h>
+
+#include <Protocol/Decompress.h>
+#include <Protocol/PciIo.h>
+#include <Protocol/FirmwareVolume2.h>
+#include <Protocol/SimpleFileSystem.h>
+#include <Protocol/PciRootBridgeIo.h>
+#include <Protocol/S3SaveState.h>
+#include <Protocol/DxeSmmReadyToLock.h>
+#include <Protocol/LoadedImage.h>
+
+#include <Guid/Acpi.h>
+#include <Guid/SmBios.h>
+#include <Guid/Mps.h>
+#include <Guid/HobList.h>
+#include <Guid/GlobalVariable.h>
+#include <Guid/EventGroup.h>
+
+#include <SimicsPlatforms.h>
+
+extern EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[];
+extern ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode;
+extern ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode;
+extern UART_DEVICE_PATH gUartDeviceNode;
+extern VENDOR_DEVICE_PATH gTerminalTypeDeviceNode;
+
+#define PCI_DEVICE_PATH_NODE(Func, Dev) \
+ { \
+ { \
+ HARDWARE_DEVICE_PATH, \
+ HW_PCI_DP, \
+ { \
+ (UINT8) (sizeof (PCI_DEVICE_PATH)), \
+ (UINT8) ((sizeof (PCI_DEVICE_PATH)) >> 8) \
+ } \
+ }, \
+ (Func), \
+ (Dev) \
+ }
+
+#define PNPID_DEVICE_PATH_NODE(PnpId) \
+ { \
+ { \
+ ACPI_DEVICE_PATH, \
+ ACPI_DP, \
+ { \
+ (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \
+ (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \
+ }, \
+ }, \
+ EISA_PNP_ID((PnpId)), \
+ 0 \
+ }
+
+#define gPciIsaBridge \
+ PCI_DEVICE_PATH_NODE(0, 0x1f)
+
+#define gP2PBridge \
+ PCI_DEVICE_PATH_NODE(0, 0x1e)
+
+#define gPnpPs2Keyboard \
+ PNPID_DEVICE_PATH_NODE(0x0303)
+
+#define gPnp16550ComPort \
+ PNPID_DEVICE_PATH_NODE(0x0501)
+
+#define gUart \
+ { \
+ { \
+ MESSAGING_DEVICE_PATH, \
+ MSG_UART_DP, \
+ { \
+ (UINT8) (sizeof (UART_DEVICE_PATH)), \
+ (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8) \
+ } \
+ }, \
+ 0, \
+ 115200, \
+ 8, \
+ 1, \
+ 1 \
+ }
+
+#define gPcAnsiTerminal \
+ { \
+ { \
+ MESSAGING_DEVICE_PATH, \
+ MSG_VENDOR_DP, \
+ { \
+ (UINT8) (sizeof (VENDOR_DEVICE_PATH)), \
+ (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) \
+ } \
+ }, \
+ DEVICE_PATH_MESSAGING_PC_ANSI \
+ }
+
+#define PCI_CLASS_SCC 0x07
+#define PCI_SUBCLASS_SERIAL 0x00
+#define PCI_IF_16550 0x02
+#define IS_PCI_16550SERIAL(_p) IS_CLASS3 (_p, PCI_CLASS_SCC, PCI_SUBCLASS_SERIAL, PCI_IF_16550)
+#define IS_PCI_ISA_PDECODE(_p) IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA_PDECODE, 0)
+
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ UINTN ConnectType;
+} PLATFORM_CONSOLE_CONNECT_ENTRY;
+
+#define CONSOLE_OUT BIT0
+#define CONSOLE_IN BIT1
+#define STD_ERROR BIT2
+extern PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[];
+
+//
+// Platform BDS Functions
+//
+
+VOID
+PlatformInitializeConsole (
+ IN PLATFORM_CONSOLE_CONNECT_ENTRY *PlatformConsole
+ );
+
+/**
+ Use SystemTable ConOut to stop video based Simple Text Out consoles from going
+ to the video device. Put up LogoFile on every video device that is a console.
+
+ @param[in] LogoFile The file name of logo to display on the center of the screen.
+
+ @retval EFI_SUCCESS ConsoleControl has been flipped to graphics and logo displayed.
+ @retval EFI_UNSUPPORTED Logo not found.
+
+**/
+EFI_STATUS
+EFIAPI
+EnableBootLogo(
+ IN EFI_GUID *LogoFile
+);
+
+#endif // _PLATFORM_SPECIFIC_BDS_PLATFORM_H_
diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.c b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
new file mode 100644
index 0000000000..1058dbf3cf
--- /dev/null
+++ b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
@@ -0,0 +1,1630 @@
+/** @file
+ Board BDS hook Library. Implements board specific BDS hook library
+
+ Copyright (c) 2019 Intel Corporation. All rights reserved. <BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include "BoardBdsHook.h"
+#include <Guid/RootBridgesConnectedEventGroup.h>
+#include <Protocol/FirmwareVolume2.h>
+
+#define LEGACY_8259_MASK_REGISTER_MASTER 0x21
+#define LEGACY_8259_MASK_REGISTER_SLAVE 0xA1
+#define LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_MASTER 0x4D0
+#define LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_SLAVE 0x4D1
+
+//
+// Predefined platform connect sequence
+//
+EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[] = { NULL };
+
+
+ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode = gPnpPs2Keyboard;
+ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode = gPnp16550ComPort;
+UART_DEVICE_PATH gUartDeviceNode = gUart;
+VENDOR_DEVICE_PATH gTerminalTypeDeviceNode = gPcAnsiTerminal;
+
+//
+// Global data
+//
+
+VOID *mEfiDevPathNotifyReg;
+EFI_EVENT mEfiDevPathEvent;
+VOID *mEmuVariableEventReg;
+EFI_EVENT mEmuVariableEvent;
+BOOLEAN mDetectVgaOnly;
+UINT16 mHostBridgeDevId;
+
+//
+// Table of host IRQs matching PCI IRQs A-D
+// (for configuring PCI Interrupt Line register)
+//
+CONST UINT8 PciHostIrqs[] = {
+ 0x0a, 0x0a, 0x0b, 0x0b
+};
+
+//
+// Type definitions
+//
+typedef
+EFI_STATUS
+(EFIAPI *PROTOCOL_INSTANCE_CALLBACK)(
+ IN EFI_HANDLE Handle,
+ IN VOID *Instance,
+ IN VOID *Context
+ );
+
+/**
+ @param[in] Handle - Handle of PCI device instance
+ @param[in] PciIo - PCI IO protocol instance
+ @param[in] Pci - PCI Header register block
+**/
+typedef
+EFI_STATUS
+(EFIAPI *VISIT_PCI_INSTANCE_CALLBACK)(
+ IN EFI_HANDLE Handle,
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN PCI_TYPE00 *Pci
+ );
+
+
+//
+// Function prototypes
+//
+
+EFI_STATUS
+VisitAllInstancesOfProtocol (
+ IN EFI_GUID *Id,
+ IN PROTOCOL_INSTANCE_CALLBACK CallBackFunction,
+ IN VOID *Context
+ );
+
+EFI_STATUS
+VisitAllPciInstancesOfProtocol (
+ IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction
+ );
+
+VOID
+InstallDevicePathCallback (
+ VOID
+ );
+
+EFI_STATUS
+EFIAPI
+ConnectRootBridge (
+ IN EFI_HANDLE RootBridgeHandle,
+ IN VOID *Instance,
+ IN VOID *Context
+ );
+
+
+VOID
+PlatformRegisterFvBootOption (
+ EFI_GUID *FileGuid,
+ CHAR16 *Description,
+ UINT32 Attributes
+ )
+{
+ EFI_STATUS Status;
+ INTN OptionIndex;
+ EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
+ EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
+ UINTN BootOptionCount;
+ MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+
+ Status = gBS->HandleProtocol (
+ gImageHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID **) &LoadedImage
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);
+ DevicePath = DevicePathFromHandle (LoadedImage->DeviceHandle);
+ ASSERT (DevicePath != NULL);
+ DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
+ );
+ ASSERT (DevicePath != NULL);
+
+ Status = EfiBootManagerInitializeLoadOption (
+ &NewOption,
+ LoadOptionNumberUnassigned,
+ LoadOptionTypeBoot,
+ Attributes,
+ Description,
+ DevicePath,
+ NULL,
+ 0
+ );
+ ASSERT_EFI_ERROR (Status);
+ FreePool (DevicePath);
+
+ BootOptions = EfiBootManagerGetLoadOptions (
+ &BootOptionCount, LoadOptionTypeBoot
+ );
+
+ OptionIndex = EfiBootManagerFindLoadOption (
+ &NewOption, BootOptions, BootOptionCount
+ );
+
+ if (OptionIndex == -1) {
+ Status = EfiBootManagerAddLoadOptionVariable (&NewOption, MAX_UINTN);
+ ASSERT_EFI_ERROR (Status);
+ }
+ EfiBootManagerFreeLoadOption (&NewOption);
+ EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
+}
+
+/**
+ Remove all MemoryMapped(...)/FvFile(...) and Fv(...)/FvFile(...) boot options
+ whose device paths do not resolve exactly to an FvFile in the system.
+
+ This removes any boot options that point to binaries built into the firmware
+ and have become stale due to any of the following:
+ - DXEFV's base address or size changed (historical),
+ - DXEFV's FvNameGuid changed,
+ - the FILE_GUID of the pointed-to binary changed,
+ - the referenced binary is no longer built into the firmware.
+
+ EfiBootManagerFindLoadOption() used in PlatformRegisterFvBootOption() only
+ avoids exact duplicates.
+**/
+VOID
+RemoveStaleFvFileOptions (
+ VOID
+ )
+{
+ EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
+ UINTN BootOptionCount;
+ UINTN Index;
+
+ BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount,
+ LoadOptionTypeBoot);
+
+ for (Index = 0; Index < BootOptionCount; ++Index) {
+ EFI_DEVICE_PATH_PROTOCOL *Node1, *Node2, *SearchNode;
+ EFI_STATUS Status;
+ EFI_HANDLE FvHandle;
+
+ //
+ // If the device path starts with neither MemoryMapped(...) nor Fv(...),
+ // then keep the boot option.
+ //
+ Node1 = BootOptions[Index].FilePath;
+ if (!(DevicePathType (Node1) == HARDWARE_DEVICE_PATH &&
+ DevicePathSubType (Node1) == HW_MEMMAP_DP) &&
+ !(DevicePathType (Node1) == MEDIA_DEVICE_PATH &&
+ DevicePathSubType (Node1) == MEDIA_PIWG_FW_VOL_DP)) {
+ continue;
+ }
+
+ //
+ // If the second device path node is not FvFile(...), then keep the boot
+ // option.
+ //
+ Node2 = NextDevicePathNode (Node1);
+ if (DevicePathType (Node2) != MEDIA_DEVICE_PATH ||
+ DevicePathSubType (Node2) != MEDIA_PIWG_FW_FILE_DP) {
+ continue;
+ }
+
+ //
+ // Locate the Firmware Volume2 protocol instance that is denoted by the
+ // boot option. If this lookup fails (i.e., the boot option references a
+ // firmware volume that doesn't exist), then we'll proceed to delete the
+ // boot option.
+ //
+ SearchNode = Node1;
+ Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid,
+ &SearchNode, &FvHandle);
+
+ if (!EFI_ERROR (Status)) {
+ //
+ // The firmware volume was found; now let's see if it contains the FvFile
+ // identified by GUID.
+ //
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *FvProtocol;
+ MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFileNode;
+ UINTN BufferSize;
+ EFI_FV_FILETYPE FoundType;
+ EFI_FV_FILE_ATTRIBUTES FileAttributes;
+ UINT32 AuthenticationStatus;
+
+ Status = gBS->HandleProtocol (FvHandle, &gEfiFirmwareVolume2ProtocolGuid,
+ (VOID **)&FvProtocol);
+ ASSERT_EFI_ERROR (Status);
+
+ FvFileNode = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)Node2;
+ //
+ // Buffer==NULL means we request metadata only: BufferSize, FoundType,
+ // FileAttributes.
+ //
+ Status = FvProtocol->ReadFile (
+ FvProtocol,
+ &FvFileNode->FvFileName, // NameGuid
+ NULL, // Buffer
+ &BufferSize,
+ &FoundType,
+ &FileAttributes,
+ &AuthenticationStatus
+ );
+ if (!EFI_ERROR (Status)) {
+ //
+ // The FvFile was found. Keep the boot option.
+ //
+ continue;
+ }
+ }
+
+ //
+ // Delete the boot option.
+ //
+ Status = EfiBootManagerDeleteLoadOptionVariable (
+ BootOptions[Index].OptionNumber, LoadOptionTypeBoot);
+ DEBUG_CODE (
+ CHAR16 *DevicePathString;
+
+ DevicePathString = ConvertDevicePathToText(BootOptions[Index].FilePath,
+ FALSE, FALSE);
+ DEBUG ((
+ EFI_ERROR (Status) ? EFI_D_WARN : DEBUG_VERBOSE,
+ "%a: removing stale Boot#%04x %s: %r\n",
+ __FUNCTION__,
+ (UINT32)BootOptions[Index].OptionNumber,
+ DevicePathString == NULL ? L"<unavailable>" : DevicePathString,
+ Status
+ ));
+ if (DevicePathString != NULL) {
+ FreePool (DevicePathString);
+ }
+ );
+ }
+
+ EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
+}
+
+VOID
+PlatformRegisterOptionsAndKeys (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_INPUT_KEY Enter;
+ EFI_INPUT_KEY F2;
+ EFI_INPUT_KEY Esc;
+ EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
+
+ //
+ // Register ENTER as CONTINUE key
+ //
+ Enter.ScanCode = SCAN_NULL;
+ Enter.UnicodeChar = CHAR_CARRIAGE_RETURN;
+ Status = EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL);
+ ASSERT_EFI_ERROR (Status);
+ DEBUG ((DEBUG_INFO, "PlatformRegisterOptionsAndKeys\n"));
+ if (EFI_ERROR(Status)){
+ return;
+ }
+ //
+ // Map F2 to Boot Manager Menu
+ //
+ F2.ScanCode = SCAN_F2;
+ F2.UnicodeChar = CHAR_NULL;
+ Esc.ScanCode = SCAN_ESC;
+ Esc.UnicodeChar = CHAR_NULL;
+ Status = EfiBootManagerGetBootManagerMenu (&BootOption);
+ ASSERT_EFI_ERROR (Status);
+ Status = EfiBootManagerAddKeyOptionVariable (
+ NULL, (UINT16) BootOption.OptionNumber, 0, &F2, NULL
+ );
+ ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
+ Status = EfiBootManagerAddKeyOptionVariable (
+ NULL, (UINT16) BootOption.OptionNumber, 0, &Esc, NULL
+ );
+ ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
+}
+
+
+/**
+ Add IsaKeyboard to ConIn; add IsaSerial to ConOut, ConIn, ErrOut.
+
+ @param[in] DeviceHandle Handle of the LPC Bridge device.
+
+ @retval EFI_SUCCESS Console devices on the LPC bridge have been added to
+ ConOut, ConIn, and ErrOut.
+
+ @return Error codes, due to EFI_DEVICE_PATH_PROTOCOL missing
+ from DeviceHandle.
+**/
+EFI_STATUS
+EFIAPI
+ConnectRootBridge (
+ IN EFI_HANDLE RootBridgeHandle,
+ IN VOID *Instance,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status;
+
+ //
+ // Make the PCI bus driver connect the root bridge, non-recursively. This
+ // will produce a number of child handles with PciIo on them.
+ //
+ Status = gBS->ConnectController (
+ RootBridgeHandle, // ControllerHandle
+ NULL, // DriverImageHandle
+ NULL, // RemainingDevicePath -- produce all
+ // children
+ FALSE // Recursive
+ );
+ return Status;
+}
+
+
+/**
+ Add IsaKeyboard to ConIn; add IsaSerial to ConOut, ConIn, ErrOut.
+
+ @param[in] DeviceHandle Handle of the LPC Bridge device.
+
+ @retval EFI_SUCCESS Console devices on the LPC bridge have been added to
+ ConOut, ConIn, and ErrOut.
+
+ @return Error codes, due to EFI_DEVICE_PATH_PROTOCOL missing
+ from DeviceHandle.
+**/
+EFI_STATUS
+PrepareLpcBridgeDevicePath (
+ IN EFI_HANDLE DeviceHandle
+ )
+{
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
+ CHAR16 *DevPathStr;
+
+ DevicePath = NULL;
+ Status = gBS->HandleProtocol (
+ DeviceHandle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID*)&DevicePath
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ TempDevicePath = DevicePath;
+
+ //
+ // Register Keyboard
+ //
+ DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnpPs2KeyboardDeviceNode);
+
+ EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);
+
+ //
+ // Register COM1
+ //
+ DevicePath = TempDevicePath;
+ gPnp16550ComPortDeviceNode.UID = 0;
+
+ DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);
+ DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);
+ DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);
+
+ //
+ // Print Device Path
+ //
+ DevPathStr = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
+ if (DevPathStr != NULL) {
+ DEBUG((
+ DEBUG_INFO,
+ "BdsPlatform.c+%d: COM%d DevPath: %s\n",
+ __LINE__,
+ gPnp16550ComPortDeviceNode.UID + 1,
+ DevPathStr
+ ));
+ FreePool(DevPathStr);
+ }
+
+ EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
+ EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);
+ EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);
+
+ //
+ // Register COM2
+ //
+ DevicePath = TempDevicePath;
+ gPnp16550ComPortDeviceNode.UID = 1;
+
+ DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);
+ DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);
+ DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);
+
+ //
+ // Print Device Path
+ //
+ DevPathStr = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
+ if (DevPathStr != NULL) {
+ DEBUG((
+ DEBUG_INFO,
+ "BdsPlatform.c+%d: COM%d DevPath: %s\n",
+ __LINE__,
+ gPnp16550ComPortDeviceNode.UID + 1,
+ DevPathStr
+ ));
+ FreePool(DevPathStr);
+ }
+
+ EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
+ EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);
+ EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+GetGopDevicePath (
+ IN EFI_DEVICE_PATH_PROTOCOL *PciDevicePath,
+ OUT EFI_DEVICE_PATH_PROTOCOL **GopDevicePath
+ )
+{
+ UINTN Index;
+ EFI_STATUS Status;
+ EFI_HANDLE PciDeviceHandle;
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *TempPciDevicePath;
+ UINTN GopHandleCount;
+ EFI_HANDLE *GopHandleBuffer;
+
+ if (PciDevicePath == NULL || GopDevicePath == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Initialize the GopDevicePath to be PciDevicePath
+ //
+ *GopDevicePath = PciDevicePath;
+ TempPciDevicePath = PciDevicePath;
+
+ Status = gBS->LocateDevicePath (
+ &gEfiDevicePathProtocolGuid,
+ &TempPciDevicePath,
+ &PciDeviceHandle
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Try to connect this handle, so that GOP driver could start on this
+ // device and create child handles with GraphicsOutput Protocol installed
+ // on them, then we get device paths of these child handles and select
+ // them as possible console device.
+ //
+ gBS->ConnectController (PciDeviceHandle, NULL, NULL, FALSE);
+
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiGraphicsOutputProtocolGuid,
+ NULL,
+ &GopHandleCount,
+ &GopHandleBuffer
+ );
+ if (!EFI_ERROR (Status)) {
+ //
+ // Add all the child handles as possible Console Device
+ //
+ for (Index = 0; Index < GopHandleCount; Index++) {
+ Status = gBS->HandleProtocol (GopHandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID*)&TempDevicePath);
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+ if (CompareMem (
+ PciDevicePath,
+ TempDevicePath,
+ GetDevicePathSize (PciDevicePath) - END_DEVICE_PATH_LENGTH
+ ) == 0) {
+ //
+ // In current implementation, we only enable one of the child handles
+ // as console device, i.e. sotre one of the child handle's device
+ // path to variable "ConOut"
+ // In future, we could select all child handles to be console device
+ //
+
+ *GopDevicePath = TempDevicePath;
+
+ //
+ // Delete the PCI device's path that added by
+ // GetPlugInPciVgaDevicePath(). Add the integrity GOP device path.
+ //
+ EfiBootManagerUpdateConsoleVariable (ConOutDev, NULL, PciDevicePath);
+ EfiBootManagerUpdateConsoleVariable (ConOutDev, TempDevicePath, NULL);
+ }
+ }
+ gBS->FreePool (GopHandleBuffer);
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Add PCI display to ConOut.
+
+ @param[in] DeviceHandle Handle of the PCI display device.
+
+ @retval EFI_SUCCESS The PCI display device has been added to ConOut.
+
+ @return Error codes, due to EFI_DEVICE_PATH_PROTOCOL missing
+ from DeviceHandle.
+**/
+EFI_STATUS
+PreparePciDisplayDevicePath (
+ IN EFI_HANDLE DeviceHandle
+ )
+{
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *GopDevicePath;
+
+ DevicePath = NULL;
+ GopDevicePath = NULL;
+ Status = gBS->HandleProtocol (
+ DeviceHandle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID*)&DevicePath
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ GetGopDevicePath (DevicePath, &GopDevicePath);
+ DevicePath = GopDevicePath;
+
+ EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Add PCI Serial to ConOut, ConIn, ErrOut.
+
+ @param[in] DeviceHandle Handle of the PCI serial device.
+
+ @retval EFI_SUCCESS The PCI serial device has been added to ConOut, ConIn,
+ ErrOut.
+
+ @return Error codes, due to EFI_DEVICE_PATH_PROTOCOL missing
+ from DeviceHandle.
+**/
+EFI_STATUS
+PreparePciSerialDevicePath (
+ IN EFI_HANDLE DeviceHandle
+ )
+{
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+
+ DevicePath = NULL;
+ Status = gBS->HandleProtocol (
+ DeviceHandle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID*)&DevicePath
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);
+ DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);
+
+ EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
+ EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);
+ EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+VisitAllInstancesOfProtocol (
+ IN EFI_GUID *Id,
+ IN PROTOCOL_INSTANCE_CALLBACK CallBackFunction,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status;
+ UINTN HandleCount;
+ EFI_HANDLE *HandleBuffer;
+ UINTN Index;
+ VOID *Instance;
+
+ //
+ // Start to check all the PciIo to find all possible device
+ //
+ HandleCount = 0;
+ HandleBuffer = NULL;
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ Id,
+ NULL,
+ &HandleCount,
+ &HandleBuffer
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ for (Index = 0; Index < HandleCount; Index++) {
+ Status = gBS->HandleProtocol (HandleBuffer[Index], Id, &Instance);
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+
+ Status = (*CallBackFunction) (
+ HandleBuffer[Index],
+ Instance,
+ Context
+ );
+ }
+
+ gBS->FreePool (HandleBuffer);
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+EFIAPI
+VisitingAPciInstance (
+ IN EFI_HANDLE Handle,
+ IN VOID *Instance,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ PCI_TYPE00 Pci;
+
+ PciIo = (EFI_PCI_IO_PROTOCOL*) Instance;
+
+ //
+ // Check for all PCI device
+ //
+ Status = PciIo->Pci.Read (
+ PciIo,
+ EfiPciIoWidthUint32,
+ 0,
+ sizeof (Pci) / sizeof (UINT32),
+ &Pci
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ return (*(VISIT_PCI_INSTANCE_CALLBACK)(UINTN) Context) (
+ Handle,
+ PciIo,
+ &Pci
+ );
+
+}
+
+
+
+EFI_STATUS
+VisitAllPciInstances (
+ IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction
+ )
+{
+ return VisitAllInstancesOfProtocol (
+ &gEfiPciIoProtocolGuid,
+ VisitingAPciInstance,
+ (VOID*)(UINTN) CallBackFunction
+ );
+}
+
+
+/**
+ Do platform specific PCI Device check and add them to
+ ConOut, ConIn, ErrOut.
+
+ @param[in] Handle - Handle of PCI device instance
+ @param[in] PciIo - PCI IO protocol instance
+ @param[in] Pci - PCI Header register block
+
+ @retval EFI_SUCCESS - PCI Device check and Console variable update
+ successfully.
+ @retval EFI_STATUS - PCI Device check or Console variable update fail.
+
+**/
+EFI_STATUS
+EFIAPI
+DetectAndPreparePlatformPciDevicePath (
+ IN EFI_HANDLE Handle,
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN PCI_TYPE00 *Pci
+ )
+{
+ EFI_STATUS Status;
+
+ Status = PciIo->Attributes (
+ PciIo,
+ EfiPciIoAttributeOperationEnable,
+ EFI_PCI_DEVICE_ENABLE,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ if (!mDetectVgaOnly) {
+ //
+ // Here we decide whether it is LPC Bridge
+ //
+ if ((IS_PCI_LPC (Pci)) ||
+ ((IS_PCI_ISA_PDECODE (Pci)) &&
+ (Pci->Hdr.VendorId == 0x8086) &&
+ (Pci->Hdr.DeviceId == 0x7000)
+ )
+ ) {
+ //
+ // Add IsaKeyboard to ConIn,
+ // add IsaSerial to ConOut, ConIn, ErrOut
+ //
+ DEBUG ((DEBUG_INFO, "Found LPC Bridge device\n"));
+ PrepareLpcBridgeDevicePath (Handle);
+ return EFI_SUCCESS;
+ }
+ //
+ // Here we decide which Serial device to enable in PCI bus
+ //
+ if (IS_PCI_16550SERIAL (Pci)) {
+ //
+ // Add them to ConOut, ConIn, ErrOut.
+ //
+ DEBUG ((DEBUG_INFO, "Found PCI 16550 SERIAL device\n"));
+ PreparePciSerialDevicePath (Handle);
+ return EFI_SUCCESS;
+ }
+ }
+
+ //
+ // Here we decide which display device to enable in PCI bus
+ //
+ if (IS_PCI_DISPLAY (Pci)) {
+ //
+ // Add them to ConOut.
+ //
+ DEBUG ((DEBUG_INFO, "Found PCI display device\n"));
+ PreparePciDisplayDevicePath (Handle);
+ return EFI_SUCCESS;
+ }
+
+ return Status;
+}
+
+
+/**
+ Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut
+
+ @param[in] DetectVgaOnly - Only detect VGA device if it's TRUE.
+
+ @retval EFI_SUCCESS - PCI Device check and Console variable update successfully.
+ @retval EFI_STATUS - PCI Device check or Console variable update fail.
+
+**/
+EFI_STATUS
+DetectAndPreparePlatformPciDevicePaths (
+ BOOLEAN DetectVgaOnly
+ )
+{
+ mDetectVgaOnly = DetectVgaOnly;
+ return VisitAllPciInstances (DetectAndPreparePlatformPciDevicePath);
+}
+
+/**
+ Connect the predefined platform default console device.
+
+ Always try to find and enable PCI display devices.
+
+ @param[in] PlatformConsole Predefined platform default console device array.
+**/
+VOID
+PlatformInitializeConsole (
+ IN PLATFORM_CONSOLE_CONNECT_ENTRY *PlatformConsole
+ )
+{
+ UINTN Index;
+ EFI_DEVICE_PATH_PROTOCOL *VarConout;
+ EFI_DEVICE_PATH_PROTOCOL *VarConin;
+
+ //
+ // Connect RootBridge
+ //
+ GetEfiGlobalVariable2 (EFI_CON_OUT_VARIABLE_NAME, (VOID **) &VarConout, NULL);
+ GetEfiGlobalVariable2 (EFI_CON_IN_VARIABLE_NAME, (VOID **) &VarConin, NULL);
+
+ if (VarConout == NULL || VarConin == NULL) {
+ //
+ // Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut
+ //
+ DetectAndPreparePlatformPciDevicePaths (FALSE);
+ DetectAndPreparePlatformPciDevicePaths(TRUE);
+ //
+ // Have chance to connect the platform default console,
+ // the platform default console is the minimue device group
+ // the platform should support
+ //
+ for (Index = 0; PlatformConsole[Index].DevicePath != NULL; ++Index) {
+ //
+ // Update the console variable with the connect type
+ //
+ if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {
+ EfiBootManagerUpdateConsoleVariable (ConIn, PlatformConsole[Index].DevicePath, NULL);
+ }
+ if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {
+ EfiBootManagerUpdateConsoleVariable (ConOut, PlatformConsole[Index].DevicePath, NULL);
+ }
+ if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {
+ EfiBootManagerUpdateConsoleVariable (ErrOut, PlatformConsole[Index].DevicePath, NULL);
+ }
+ }
+ } else {
+ //
+ // Only detect VGA device and add them to ConOut
+ //
+ DetectAndPreparePlatformPciDevicePaths (TRUE);
+ }
+}
+
+
+/**
+ Configure PCI Interrupt Line register for applicable devices
+ Ported from SeaBIOS, src/fw/pciinit.c, *_pci_slot_get_irq()
+
+ @param[in] Handle - Handle of PCI device instance
+ @param[in] PciIo - PCI IO protocol instance
+ @param[in] PciHdr - PCI Header register block
+
+ @retval EFI_SUCCESS - PCI Interrupt Line register configured successfully.
+
+**/
+EFI_STATUS
+EFIAPI
+SetPciIntLine (
+ IN EFI_HANDLE Handle,
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN PCI_TYPE00 *PciHdr
+ )
+{
+ EFI_DEVICE_PATH_PROTOCOL *DevPathNode;
+ EFI_DEVICE_PATH_PROTOCOL *DevPath;
+ UINTN RootSlot;
+ UINTN Idx;
+ UINT8 IrqLine;
+ EFI_STATUS Status;
+ UINT32 RootBusNumber;
+
+ Status = EFI_SUCCESS;
+
+ if (PciHdr->Device.InterruptPin != 0) {
+
+ DevPathNode = DevicePathFromHandle (Handle);
+ ASSERT (DevPathNode != NULL);
+ DevPath = DevPathNode;
+
+ RootBusNumber = 0;
+ if (DevicePathType (DevPathNode) == ACPI_DEVICE_PATH &&
+ DevicePathSubType (DevPathNode) == ACPI_DP &&
+ ((ACPI_HID_DEVICE_PATH *)DevPathNode)->HID == EISA_PNP_ID(0x0A03)) {
+ RootBusNumber = ((ACPI_HID_DEVICE_PATH *)DevPathNode)->UID;
+ }
+
+ //
+ // Compute index into PciHostIrqs[] table by walking
+ // the device path and adding up all device numbers
+ //
+ Status = EFI_NOT_FOUND;
+ RootSlot = 0;
+ Idx = PciHdr->Device.InterruptPin - 1;
+ while (!IsDevicePathEnd (DevPathNode)) {
+ if (DevicePathType (DevPathNode) == HARDWARE_DEVICE_PATH &&
+ DevicePathSubType (DevPathNode) == HW_PCI_DP) {
+
+ Idx += ((PCI_DEVICE_PATH *)DevPathNode)->Device;
+
+ //
+ // Unlike SeaBIOS, which starts climbing from the leaf device
+ // up toward the root, we traverse the device path starting at
+ // the root moving toward the leaf node.
+ // The slot number of the top-level parent bridge is needed
+ // with more than 24 slots on the root bus.
+ //
+ if (Status != EFI_SUCCESS) {
+ Status = EFI_SUCCESS;
+ RootSlot = ((PCI_DEVICE_PATH *)DevPathNode)->Device;
+ }
+ }
+
+ DevPathNode = NextDevicePathNode (DevPathNode);
+ }
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ if (RootBusNumber == 0 && RootSlot == 0) {
+ return Status; //bugbug: workaround; need SIMICS change B0/D0/F0 PCI_IntPin reg(0x3D) = 0X0
+// DEBUG((
+// DEBUG_ERROR,
+// "%a: PCI host bridge (00:00.0) should have no interrupts!\n",
+// __FUNCTION__
+// ));
+// ASSERT (FALSE);
+ }
+
+ //
+ // Final PciHostIrqs[] index calculation depends on the platform
+ // and should match SeaBIOS src/fw/pciinit.c *_pci_slot_get_irq()
+ //
+ switch (mHostBridgeDevId) {
+ case INTEL_82441_DEVICE_ID:
+ Idx -= 1;
+ break;
+ case INTEL_ICH10_DEVICE_ID:
+ //
+ // SeaBIOS contains the following comment:
+ // "Slots 0-24 rotate slot:pin mapping similar to piix above, but
+ // with a different starting index.
+ //
+ // Slots 25-31 all use LNKA mapping (or LNKE, but A:D = E:H)"
+ //
+ if (RootSlot > 24) {
+ //
+ // in this case, subtract back out RootSlot from Idx
+ // (SeaBIOS never adds it to begin with, but that would make our
+ // device path traversal loop above too awkward)
+ //
+ Idx -= RootSlot;
+ }
+ break;
+ default:
+ ASSERT (FALSE); // should never get here
+ }
+ Idx %= ARRAY_SIZE (PciHostIrqs);
+ IrqLine = PciHostIrqs[Idx];
+
+ DEBUG_CODE_BEGIN ();
+ {
+ CHAR16 *DevPathString;
+ STATIC CHAR16 Fallback[] = L"<failed to convert>";
+ UINTN Segment, Bus, Device, Function;
+
+ DevPathString = ConvertDevicePathToText (DevPath, FALSE, FALSE);
+ if (DevPathString == NULL) {
+ DevPathString = Fallback;
+ }
+ Status = PciIo->GetLocation (PciIo, &Segment, &Bus, &Device, &Function);
+ ASSERT_EFI_ERROR (Status);
+
+ DEBUG ((DEBUG_VERBOSE, "%a: [%02x:%02x.%x] %s -> 0x%02x\n", __FUNCTION__,
+ (UINT32)Bus, (UINT32)Device, (UINT32)Function, DevPathString,
+ IrqLine));
+
+ if (DevPathString != Fallback) {
+ FreePool (DevPathString);
+ }
+ }
+ DEBUG_CODE_END ();
+
+ //
+ // Set PCI Interrupt Line register for this device to PciHostIrqs[Idx]
+ //
+ Status = PciIo->Pci.Write (
+ PciIo,
+ EfiPciIoWidthUint8,
+ PCI_INT_LINE_OFFSET,
+ 1,
+ &IrqLine
+ );
+ }
+
+ return Status;
+}
+
+/**
+Write to mask and edge/level triggered registers of master and slave 8259 PICs.
+
+@param[in] Mask low byte for master PIC mask register,
+high byte for slave PIC mask register.
+@param[in] EdgeLevel low byte for master PIC edge/level triggered register,
+high byte for slave PIC edge/level triggered register.
+
+**/
+VOID
+Interrupt8259WriteMask(
+ IN UINT16 Mask,
+ IN UINT16 EdgeLevel
+)
+{
+ IoWrite8(LEGACY_8259_MASK_REGISTER_MASTER, (UINT8)Mask);
+ IoWrite8(LEGACY_8259_MASK_REGISTER_SLAVE, (UINT8)(Mask >> 8));
+ IoWrite8(LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_MASTER, (UINT8)EdgeLevel);
+ IoWrite8(LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_SLAVE, (UINT8)(EdgeLevel >> 8));
+}
+
+VOID
+PciAcpiInitialization (
+ VOID
+ )
+{
+ UINTN Pmba;
+
+ //
+ // Query Host Bridge DID to determine platform type
+ //
+ mHostBridgeDevId = PcdGet16 (PcdSimicsX58HostBridgePciDevId);
+ switch (mHostBridgeDevId) {
+ case INTEL_82441_DEVICE_ID:
+ Pmba = POWER_MGMT_REGISTER_PIIX4 (PIIX4_PMBA);
+ //
+ // 00:01.0 ISA Bridge (PIIX4) LNK routing targets
+ //
+ PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x60), 0x0b); // A
+ PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x61), 0x0b); // B
+ PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x62), 0x0a); // C
+ PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x63), 0x0a); // D
+ break;
+ case INTEL_ICH10_DEVICE_ID:
+ Pmba = POWER_MGMT_REGISTER_ICH10 (ICH10_PMBASE);
+ //
+ // 00:1f.0 LPC Bridge LNK routing targets
+ //
+ PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x60), 0x0a); // A
+ PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x61), 0x0a); // B
+ PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x62), 0x0b); // C
+ PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x63), 0x0b); // D
+ PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x68), 0x0a); // E
+ PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x69), 0x0a); // F
+ PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x6a), 0x0b); // G
+ PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x6b), 0x0b); // H
+ break;
+ default:
+ DEBUG ((DEBUG_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n",
+ __FUNCTION__, mHostBridgeDevId));
+ ASSERT (FALSE);
+ return;
+ }
+
+ //
+ // Initialize PCI_INTERRUPT_LINE for applicable present PCI devices
+ //
+ VisitAllPciInstances (SetPciIntLine);
+
+ //
+ // Set ACPI SCI_EN bit in PMCNTRL
+ //
+ IoOr16 ((PciRead32 (Pmba) & ~BIT0) + 4, BIT0);
+ //
+ // Set all 8259 interrupts to edge triggered and disabled
+ //
+ Interrupt8259WriteMask(0xFFFF, 0x0000);
+}
+
+EFI_STATUS
+EFIAPI
+ConnectRecursivelyIfPciMassStorage (
+ IN EFI_HANDLE Handle,
+ IN EFI_PCI_IO_PROTOCOL *Instance,
+ IN PCI_TYPE00 *PciHeader
+ )
+{
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ CHAR16 *DevPathStr;
+
+ //
+ // Recognize PCI Mass Storage
+ //
+ if (IS_CLASS1 (PciHeader, PCI_CLASS_MASS_STORAGE)) {
+ DevicePath = NULL;
+ Status = gBS->HandleProtocol (
+ Handle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID*)&DevicePath
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Print Device Path
+ //
+ DevPathStr = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
+ if (DevPathStr != NULL) {
+ DEBUG(( DEBUG_INFO, "Found Mass Storage device: %s\n", DevPathStr));
+ FreePool(DevPathStr);
+ }
+
+ Status = gBS->ConnectController (Handle, NULL, NULL, TRUE);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+/**
+ This notification function is invoked when the
+ EMU Variable FVB has been changed.
+
+ @param Event The event that occurred
+ @param Context For EFI compatibility. Not used.
+
+**/
+VOID
+EFIAPI
+EmuVariablesUpdatedCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ DEBUG ((DEBUG_INFO, "%a called\n", __FUNCTION__));
+ UpdateNvVarsOnFileSystem ();
+}
+
+
+EFI_STATUS
+EFIAPI
+VisitingFileSystemInstance (
+ IN EFI_HANDLE Handle,
+ IN VOID *Instance,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status;
+ STATIC BOOLEAN ConnectedToFileSystem = FALSE;
+
+ if (ConnectedToFileSystem) {
+ return EFI_ALREADY_STARTED;
+ }
+
+ Status = ConnectNvVarsToFileSystem (Handle);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ ConnectedToFileSystem = TRUE;
+ mEmuVariableEvent =
+ EfiCreateProtocolNotifyEvent (
+ &gEfiDevicePathProtocolGuid,
+ TPL_CALLBACK,
+ EmuVariablesUpdatedCallback,
+ NULL,
+ &mEmuVariableEventReg
+ );
+ PcdSet64 (PcdEmuVariableEvent, (UINT64)(UINTN) mEmuVariableEvent);
+
+ return EFI_SUCCESS;
+}
+
+
+VOID
+PlatformBdsRestoreNvVarsFromHardDisk (
+ )
+{
+ VisitAllPciInstances (ConnectRecursivelyIfPciMassStorage);
+ VisitAllInstancesOfProtocol (
+ &gEfiSimpleFileSystemProtocolGuid,
+ VisitingFileSystemInstance,
+ NULL
+ );
+}
+
+/**
+ Connect with predefined platform connect sequence.
+
+ The OEM/IBV can customize with their own connect sequence.
+**/
+VOID
+PlatformBdsConnectSequence (
+ VOID
+ )
+{
+ UINTN Index;
+
+ DEBUG ((DEBUG_INFO, "%a called\n", __FUNCTION__));
+
+ Index = 0;
+
+ //
+ // Here we can get the customized platform connect sequence
+ // Notes: we can connect with new variable which record the
+ // last time boots connect device path sequence
+ //
+ while (gPlatformConnectSequence[Index] != NULL) {
+ //
+ // Build the platform boot option
+ //
+ EfiBootManagerConnectDevicePath (gPlatformConnectSequence[Index], NULL);
+ Index++;
+ }
+
+ //
+ // Just use the simple policy to connect all devices
+ //
+ DEBUG ((DEBUG_INFO, "EfiBootManagerConnectAll\n"));
+ EfiBootManagerConnectAll ();
+
+ PciAcpiInitialization ();
+}
+
+/**
+ Do the platform specific action after the console is ready
+
+ Possible things that can be done in PlatformBootManagerAfterConsole:
+
+ > Console post action:
+ > Dynamically switch output mode from 100x31 to 80x25 for certain senarino
+ > Signal console ready platform customized event
+ > Run diagnostics like memory testing
+ > Connect certain devices
+ > Dispatch aditional option roms
+ > Special boot: e.g.: USB boot, enter UI
+**/
+// VOID
+// EFIAPI
+// PlatformBootManagerAfterConsole (
+// VOID
+// )
+// {
+
+// }
+
+/**
+ This notification function is invoked when an instance of the
+ EFI_DEVICE_PATH_PROTOCOL is produced.
+
+ @param Event The event that occurred
+ @param Context For EFI compatibility. Not used.
+
+**/
+VOID
+EFIAPI
+NotifyDevPath (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_HANDLE Handle;
+ EFI_STATUS Status;
+ UINTN BufferSize;
+ EFI_DEVICE_PATH_PROTOCOL *DevPathNode;
+ ATAPI_DEVICE_PATH *Atapi;
+
+ //
+ // Examine all new handles
+ //
+ for (;;) {
+ //
+ // Get the next handle
+ //
+ BufferSize = sizeof (Handle);
+ Status = gBS->LocateHandle (
+ ByRegisterNotify,
+ NULL,
+ mEfiDevPathNotifyReg,
+ &BufferSize,
+ &Handle
+ );
+
+ //
+ // If not found, we're done
+ //
+ if (EFI_NOT_FOUND == Status) {
+ break;
+ }
+
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+
+ //
+ // Get the DevicePath protocol on that handle
+ //
+ Status = gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID **)&DevPathNode);
+ ASSERT_EFI_ERROR (Status);
+
+ while (!IsDevicePathEnd (DevPathNode)) {
+ //
+ // Find the handler to dump this device path node
+ //
+ if (
+ (DevicePathType(DevPathNode) == MESSAGING_DEVICE_PATH) &&
+ (DevicePathSubType(DevPathNode) == MSG_ATAPI_DP)
+ ) {
+ Atapi = (ATAPI_DEVICE_PATH*) DevPathNode;
+ PciOr16 (
+ PCI_LIB_ADDRESS (
+ 0,
+ 1,
+ 1,
+ (Atapi->PrimarySecondary == 1) ? 0x42: 0x40
+ ),
+ BIT15
+ );
+ }
+
+ //
+ // Next device path node
+ //
+ DevPathNode = NextDevicePathNode (DevPathNode);
+ }
+ }
+
+ return;
+}
+
+
+VOID
+InstallDevicePathCallback (
+ VOID
+ )
+{
+ DEBUG ((DEBUG_INFO, "Registered NotifyDevPath Event\n"));
+ mEfiDevPathEvent = EfiCreateProtocolNotifyEvent (
+ &gEfiDevicePathProtocolGuid,
+ TPL_CALLBACK,
+ NotifyDevPath,
+ NULL,
+ &mEfiDevPathNotifyReg
+ );
+}
+
+
+
+/**
+ ReadyToBoot callback to set video and text mode for internal shell boot.
+ That will not connect USB controller while CSM and FastBoot are disabled, we need to connect them
+ before booting to Shell for showing USB devices in Shell.
+
+ When FastBoot is enabled and Windows Console is the chosen Console behavior, input devices will not be connected
+ by default. Hence, when booting to EFI shell, connecting input consoles are required.
+
+ @param Event Pointer to this event
+ @param Context Event hanlder private data
+
+ @retval None.
+**/
+VOID
+EFIAPI
+BdsReadyToBootCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ DEBUG ((DEBUG_INFO, "%a called\n", __FUNCTION__));
+}
+
+
+/**
+ This is the callback function for PCI ENUMERATION COMPLETE.
+
+ @param[in] Event The Event this notify function registered to.
+ @param[in] Context Pointer to the context data registered to the Event.
+**/
+VOID
+EFIAPI
+BdsSmmReadyToLockCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+
+ VOID *ProtocolPointer;
+ EFI_STATUS Status;
+
+ //
+ // Check if this is first time called by EfiCreateProtocolNotifyEvent() or not,
+ // if it is, we will skip it until real event is triggered
+ //
+ Status = gBS->LocateProtocol (&gEfiDxeSmmReadyToLockProtocolGuid, NULL, (VOID **) &ProtocolPointer);
+ if (EFI_SUCCESS != Status) {
+ return;
+ }
+
+ DEBUG ((DEBUG_INFO, "%a called\n", __FUNCTION__));
+
+ //
+ // Dispatch the deferred 3rd party images.
+ //
+ EfiBootManagerDispatchDeferredImages ();
+
+ //
+ // For non-trusted console it must be handled here.
+ //
+ //UpdateGraphicConOut (FALSE);
+}
+
+
+/**
+ This is the callback function for PCI ENUMERATION COMPLETE.
+
+ @param[in] Event The Event this notify function registered to.
+ @param[in] Context Pointer to the context data registered to the Event.
+**/
+VOID
+EFIAPI
+BdsPciEnumCompleteCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ VOID *ProtocolPointer;
+ EFI_STATUS Status;
+ PLATFORM_CONSOLE_CONNECT_ENTRY PlatformConsole[3];
+ UINTN PlatformConsoleCount;
+ UINTN MaxCount;
+ //
+ // Check if this is first time called by EfiCreateProtocolNotifyEvent() or not,
+ // if it is, we will skip it until real event is triggered
+ //
+ Status = gBS->LocateProtocol (&gEfiPciEnumerationCompleteProtocolGuid, NULL, (VOID **) &ProtocolPointer);
+ if (EFI_SUCCESS != Status) {
+ return;
+ }
+
+ PlatformConsoleCount = 0;
+ MaxCount = ARRAY_SIZE(PlatformConsole);
+
+ if (PcdGetSize (PcdTrustedConsoleOutputDevicePath) >= sizeof(EFI_DEVICE_PATH_PROTOCOL)) {
+ PlatformConsole[PlatformConsoleCount].ConnectType = ConOut;
+ PlatformConsole[PlatformConsoleCount].DevicePath = PcdGetPtr (PcdTrustedConsoleOutputDevicePath);
+ PlatformConsoleCount++;
+ }
+ if (PcdGetSize (PcdTrustedConsoleInputDevicePath) >= sizeof(EFI_DEVICE_PATH_PROTOCOL) &&
+ PlatformConsoleCount < MaxCount) {
+ PlatformConsole[PlatformConsoleCount].ConnectType = ConIn;
+ PlatformConsole[PlatformConsoleCount].DevicePath = PcdGetPtr (PcdTrustedConsoleInputDevicePath);
+ PlatformConsoleCount++;
+ }
+
+ if (PlatformConsoleCount < MaxCount){
+ PlatformConsole[PlatformConsoleCount].ConnectType = 0;
+ PlatformConsole[PlatformConsoleCount].DevicePath = NULL;
+ }else{
+ PlatformConsole[MaxCount - 1].ConnectType = 0;
+ PlatformConsole[MaxCount - 1].DevicePath = NULL;
+ }
+
+ DEBUG ((DEBUG_INFO, "%a called\n", __FUNCTION__));
+
+ PlatformInitializeConsole (PlatformConsole);
+}
+
+
+/**
+ Before console after trusted console event callback
+
+ @param[in] Event The Event this notify function registered to.
+ @param[in] Context Pointer to the context data registered to the Event.
+**/
+VOID
+EFIAPI
+BdsBeforeConsoleAfterTrustedConsoleCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_BOOT_MANAGER_LOAD_OPTION *NvBootOptions;
+ UINTN NvBootOptionCount;
+ UINTN Index;
+ EFI_STATUS Status;
+
+ DEBUG ((DEBUG_INFO, "%a called\n", __FUNCTION__));
+
+ NvBootOptions = EfiBootManagerGetLoadOptions (&NvBootOptionCount, LoadOptionTypeBoot);
+ for (Index = 0; Index < NvBootOptionCount; Index++) {
+ Status = EfiBootManagerDeleteLoadOptionVariable (NvBootOptions[Index].OptionNumber, LoadOptionTypeBoot);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: removing Boot#%04x %r\n",
+ __FUNCTION__,
+ (UINT32) NvBootOptions[Index].OptionNumber,
+ Status
+ ));
+ }
+ }
+
+ InstallDevicePathCallback ();
+
+ VisitAllInstancesOfProtocol (&gEfiPciRootBridgeIoProtocolGuid, ConnectRootBridge, NULL);
+ //
+ // Enable LPC
+ //
+ PciOr16 (POWER_MGMT_REGISTER_ICH10(0x04), BIT0 | BIT1 | BIT2);
+
+ PlatformRegisterOptionsAndKeys ();
+}
+
+
+/**
+ Before console before end of DXE event callback
+
+ @param[in] Event The Event this notify function registered to.
+ @param[in] Context Pointer to the context data registered to the Event.
+**/
+VOID
+EFIAPI
+BdsBeforeConsoleBeforeEndOfDxeGuidCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+){
+ DEBUG ((DEBUG_INFO, "%a called\n", __FUNCTION__));
+}
+
+/**
+ After console ready before boot option event callback
+
+ @param[in] Event The Event this notify function registered to.
+ @param[in] Context Pointer to the context data registered to the Event.
+**/
+VOID
+EFIAPI
+BdsAfterConsoleReadyBeforeBootOptionCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_BOOT_MODE BootMode;
+
+ DEBUG ((DEBUG_INFO, "%a called\n", __FUNCTION__));
+
+ if (PcdGetBool (PcdOvmfFlashVariablesEnable)) {
+ DEBUG ((DEBUG_INFO, "PlatformBdsPolicyBehavior: not restoring NvVars "
+ "from disk since flash variables appear to be supported.\n"));
+ } else {
+ //
+ // Try to restore variables from the hard disk early so
+ // they can be used for the other BDS connect operations.
+ //
+ PlatformBdsRestoreNvVarsFromHardDisk ();
+ }
+
+ //
+ // Get current Boot Mode
+ //
+ BootMode = GetBootModeHob ();
+ DEBUG ((DEBUG_ERROR, "Boot Mode:%x\n", BootMode));
+
+ //
+ // Go the different platform policy with different boot mode
+ // Notes: this part code can be change with the table policy
+ //
+ ASSERT (BootMode == BOOT_WITH_FULL_CONFIGURATION);
+
+ //
+ // Perform some platform specific connect sequence
+ //
+ PlatformBdsConnectSequence ();
+
+ //
+ // Logo show
+ //
+ EnableBootLogo(PcdGetPtr(PcdLogoFile));
+
+ EfiBootManagerRefreshAllBootOption ();
+
+ //
+ // Register UEFI Shell
+ //
+ PlatformRegisterFvBootOption (
+ PcdGetPtr (PcdShellFile), L"EFI Internal Shell", LOAD_OPTION_ACTIVE
+ );
+
+ RemoveStaleFvFileOptions ();
+}
diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
new file mode 100644
index 0000000000..a77edf2699
--- /dev/null
+++ b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
@@ -0,0 +1,81 @@
+## @file
+# Board BDS hook Library definition file.
+#
+# Copyright (c) 2019 Intel Corporation. All rights reserved. <BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = BoardBdsHookLib
+ FILE_GUID = 285AB0B8-D0D2-4D83-BF20-F85ED040383E
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = BoardBdsHookLib|DXE_DRIVER
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 EBC
+#
+
+[Sources]
+ BoardBdsHookLib.c
+ BoardBdsHook.h
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ MinPlatformPkg/MinPlatformPkg.dec
+ BoardModulePkg/BoardModulePkg.dec
+ SimicsOpenBoardPkg/OpenBoardPkg.dec
+ OvmfPkg/OvmfPkg.dec
+ SimicsIch10Pkg/Ich10Pkg.dec
+
+[LibraryClasses]
+ BaseLib
+ MemoryAllocationLib
+ UefiBootServicesTableLib
+ BaseMemoryLib
+ DebugLib
+ PcdLib
+ UefiBootManagerLib
+ BootLogoLib
+ DevicePathLib
+ PciLib
+ NvVarsFileLib
+ DxeLoadLinuxLib
+ UefiLib
+ LogoLib
+
+[Pcd]
+ gSimicsOpenBoardPkgTokenSpaceGuid.PcdEmuVariableEvent
+ gSimicsOpenBoardPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable
+ gSimicsOpenBoardPkgTokenSpaceGuid.PcdSimicsX58HostBridgePciDevId
+ gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
+ gSimicsOpenBoardPkgTokenSpaceGuid.PcdShellFile
+ gSimicsOpenBoardPkgTokenSpaceGuid.PcdLogoFile
+ gMinPlatformPkgTokenSpaceGuid.PcdTrustedConsoleInputDevicePath ## CONSUMES
+ gMinPlatformPkgTokenSpaceGuid.PcdTrustedConsoleOutputDevicePath ## CONSUMES
+ gMinPlatformPkgTokenSpaceGuid.PcdTrustedStorageDevicePath ## CONSUMES
+
+[Pcd.IA32, Pcd.X64]
+ gEfiMdePkgTokenSpaceGuid.PcdFSBClock
+
+[Protocols]
+ gEfiDecompressProtocolGuid
+ gEfiPciRootBridgeIoProtocolGuid
+ gEfiS3SaveStateProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
+ gEfiDxeSmmReadyToLockProtocolGuid # PROTOCOL SOMETIMES_PRODUCED
+ gEfiLoadedImageProtocolGuid # PROTOCOL SOMETIMES_PRODUCED
+ gEfiFirmwareVolume2ProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
+ gEfiPciEnumerationCompleteProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
+
+
+[Guids]
+ gEfiEndOfDxeEventGroupGuid
+
+[Depex]
+ TRUE
--
2.19.1.windows.1
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Re: [edk2-platforms] [PATCH 09/11] SimicsOpenBoardPkg: Add Bds Hook Library
2019-12-14 1:32 ` [edk2-platforms] [PATCH 09/11] SimicsOpenBoardPkg: Add Bds Hook Library Agyeman, Prince
@ 2019-12-18 1:29 ` Nate DeSimone
2019-12-21 2:37 ` Kubacki, Michael A
1 sibling, 0 replies; 45+ messages in thread
From: Nate DeSimone @ 2019-12-18 1:29 UTC (permalink / raw)
To: Agyeman, Prince; +Cc: devel@edk2.groups.io, Kubacki, Michael A
Hi Prince,
Feedback inline.
On Sat, Dec 14, 2019 at 01:32:35AM +0000, Agyeman, Prince wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
>
> Added Board BDS Hook library that implements simics specific
> Bds hook points or callbacks.
>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
>
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
> .../Library/BoardBdsHookLib/BoardBdsHook.h | 173 ++
> .../Library/BoardBdsHookLib/BoardBdsHookLib.c | 1630 +++++++++++++++++
> .../BoardBdsHookLib/BoardBdsHookLib.inf | 81 +
> 3 files changed, 1884 insertions(+)
> create mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHook.h
> create mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
> create mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
>
> diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHook.h b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHook.h
> new file mode 100644
> index 0000000000..fda41b1c97
> --- /dev/null
> +++ b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHook.h
> @@ -0,0 +1,173 @@
> +/** @file
> + Header file for the board board specific BDS hook library.
> +
> + Copyright (c) 2019 Intel Corporation. All rights reserved. <BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +**/
> +
> +#ifndef _PLATFORM_SPECIFIC_BDS_PLATFORM_H_
> +#define _PLATFORM_SPECIFIC_BDS_PLATFORM_H_
Please make the macros match the file name: _BOARD_BDS_HOOK_H_
> +
> +
> +#include <PiDxe.h>
> +
> +#include <IndustryStandard/Pci.h>
> +#include <IndustryStandard/Acpi.h>
> +#include <IndustryStandard/SmBios.h>
> +#include <IndustryStandard/PeImage.h>
> +
> +#include <Library/DebugLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/UefiRuntimeServicesTableLib.h>
> +#include <Library/MemoryAllocationLib.h>
> +#include <Library/BaseLib.h>
> +#include <Library/PcdLib.h>
> +#include <Library/PciLib.h>
> +#include <Library/UefiBootManagerLib.h>
> +#include <Library/BootLogoLib.h>
> +#include <Library/HobLib.h>
> +#include <Library/UefiLib.h>
> +#include <Library/DxeServicesTableLib.h>
> +#include <Library/DevicePathLib.h>
> +#include <Library/IoLib.h>
> +#include <Library/NvVarsFileLib.h>
> +#include <Library/BoardBdsHookLib.h>
> +
> +#include <Protocol/Decompress.h>
> +#include <Protocol/PciIo.h>
> +#include <Protocol/FirmwareVolume2.h>
> +#include <Protocol/SimpleFileSystem.h>
> +#include <Protocol/PciRootBridgeIo.h>
> +#include <Protocol/S3SaveState.h>
> +#include <Protocol/DxeSmmReadyToLock.h>
> +#include <Protocol/LoadedImage.h>
> +
> +#include <Guid/Acpi.h>
> +#include <Guid/SmBios.h>
> +#include <Guid/Mps.h>
> +#include <Guid/HobList.h>
> +#include <Guid/GlobalVariable.h>
> +#include <Guid/EventGroup.h>
> +
> +#include <SimicsPlatforms.h>
> +
> +extern EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[];
> +extern ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode;
> +extern ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode;
> +extern UART_DEVICE_PATH gUartDeviceNode;
> +extern VENDOR_DEVICE_PATH gTerminalTypeDeviceNode;
> +
> +#define PCI_DEVICE_PATH_NODE(Func, Dev) \
> + { \
> + { \
> + HARDWARE_DEVICE_PATH, \
> + HW_PCI_DP, \
> + { \
> + (UINT8) (sizeof (PCI_DEVICE_PATH)), \
> + (UINT8) ((sizeof (PCI_DEVICE_PATH)) >> 8) \
> + } \
> + }, \
> + (Func), \
> + (Dev) \
> + }
> +
> +#define PNPID_DEVICE_PATH_NODE(PnpId) \
> + { \
> + { \
> + ACPI_DEVICE_PATH, \
> + ACPI_DP, \
> + { \
> + (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \
> + (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \
> + }, \
> + }, \
> + EISA_PNP_ID((PnpId)), \
> + 0 \
> + }
> +
> +#define gPciIsaBridge \
> + PCI_DEVICE_PATH_NODE(0, 0x1f)
> +
> +#define gP2PBridge \
> + PCI_DEVICE_PATH_NODE(0, 0x1e)
> +
> +#define gPnpPs2Keyboard \
> + PNPID_DEVICE_PATH_NODE(0x0303)
> +
> +#define gPnp16550ComPort \
> + PNPID_DEVICE_PATH_NODE(0x0501)
> +
> +#define gUart \
> + { \
> + { \
> + MESSAGING_DEVICE_PATH, \
> + MSG_UART_DP, \
> + { \
> + (UINT8) (sizeof (UART_DEVICE_PATH)), \
> + (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8) \
> + } \
> + }, \
> + 0, \
> + 115200, \
> + 8, \
> + 1, \
> + 1 \
> + }
> +
> +#define gPcAnsiTerminal \
> + { \
> + { \
> + MESSAGING_DEVICE_PATH, \
> + MSG_VENDOR_DP, \
> + { \
> + (UINT8) (sizeof (VENDOR_DEVICE_PATH)), \
> + (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) \
> + } \
> + }, \
> + DEVICE_PATH_MESSAGING_PC_ANSI \
> + }
> +
> +#define PCI_CLASS_SCC 0x07
> +#define PCI_SUBCLASS_SERIAL 0x00
> +#define PCI_IF_16550 0x02
> +#define IS_PCI_16550SERIAL(_p) IS_CLASS3 (_p, PCI_CLASS_SCC, PCI_SUBCLASS_SERIAL, PCI_IF_16550)
> +#define IS_PCI_ISA_PDECODE(_p) IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA_PDECODE, 0)
> +
> +typedef struct {
> + EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> + UINTN ConnectType;
> +} PLATFORM_CONSOLE_CONNECT_ENTRY;
> +
> +#define CONSOLE_OUT BIT0
> +#define CONSOLE_IN BIT1
> +#define STD_ERROR BIT2
> +extern PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[];
> +
> +//
> +// Platform BDS Functions
> +//
> +
> +VOID
> +PlatformInitializeConsole (
> + IN PLATFORM_CONSOLE_CONNECT_ENTRY *PlatformConsole
> + );
> +
> +/**
> + Use SystemTable ConOut to stop video based Simple Text Out consoles from going
> + to the video device. Put up LogoFile on every video device that is a console.
> +
> + @param[in] LogoFile The file name of logo to display on the center of the screen.
> +
> + @retval EFI_SUCCESS ConsoleControl has been flipped to graphics and logo displayed.
> + @retval EFI_UNSUPPORTED Logo not found.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +EnableBootLogo(
> + IN EFI_GUID *LogoFile
> +);
> +
> +#endif // _PLATFORM_SPECIFIC_BDS_PLATFORM_H_
> diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.c b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
> new file mode 100644
> index 0000000000..1058dbf3cf
> --- /dev/null
> +++ b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
> @@ -0,0 +1,1630 @@
> +/** @file
> + Board BDS hook Library. Implements board specific BDS hook library
> +
> + Copyright (c) 2019 Intel Corporation. All rights reserved. <BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +**/
> +
> +#include "BoardBdsHook.h"
> +#include <Guid/RootBridgesConnectedEventGroup.h>
> +#include <Protocol/FirmwareVolume2.h>
> +
> +#define LEGACY_8259_MASK_REGISTER_MASTER 0x21
> +#define LEGACY_8259_MASK_REGISTER_SLAVE 0xA1
> +#define LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_MASTER 0x4D0
> +#define LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_SLAVE 0x4D1
> +
> +//
> +// Predefined platform connect sequence
> +//
> +EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[] = { NULL };
> +
> +
> +ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode = gPnpPs2Keyboard;
> +ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode = gPnp16550ComPort;
> +UART_DEVICE_PATH gUartDeviceNode = gUart;
> +VENDOR_DEVICE_PATH gTerminalTypeDeviceNode = gPcAnsiTerminal;
> +
> +//
> +// Global data
> +//
> +
> +VOID *mEfiDevPathNotifyReg;
> +EFI_EVENT mEfiDevPathEvent;
> +VOID *mEmuVariableEventReg;
> +EFI_EVENT mEmuVariableEvent;
> +BOOLEAN mDetectVgaOnly;
> +UINT16 mHostBridgeDevId;
> +
> +//
> +// Table of host IRQs matching PCI IRQs A-D
> +// (for configuring PCI Interrupt Line register)
> +//
> +CONST UINT8 PciHostIrqs[] = {
> + 0x0a, 0x0a, 0x0b, 0x0b
> +};
> +
> +//
> +// Type definitions
> +//
> +typedef
> +EFI_STATUS
> +(EFIAPI *PROTOCOL_INSTANCE_CALLBACK)(
> + IN EFI_HANDLE Handle,
> + IN VOID *Instance,
> + IN VOID *Context
> + );
> +
> +/**
> + @param[in] Handle - Handle of PCI device instance
> + @param[in] PciIo - PCI IO protocol instance
> + @param[in] Pci - PCI Header register block
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *VISIT_PCI_INSTANCE_CALLBACK)(
> + IN EFI_HANDLE Handle,
> + IN EFI_PCI_IO_PROTOCOL *PciIo,
> + IN PCI_TYPE00 *Pci
> + );
> +
> +
> +//
> +// Function prototypes
> +//
> +
> +EFI_STATUS
> +VisitAllInstancesOfProtocol (
> + IN EFI_GUID *Id,
> + IN PROTOCOL_INSTANCE_CALLBACK CallBackFunction,
> + IN VOID *Context
> + );
> +
> +EFI_STATUS
> +VisitAllPciInstancesOfProtocol (
> + IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction
> + );
> +
> +VOID
> +InstallDevicePathCallback (
> + VOID
> + );
> +
> +EFI_STATUS
> +EFIAPI
> +ConnectRootBridge (
> + IN EFI_HANDLE RootBridgeHandle,
> + IN VOID *Instance,
> + IN VOID *Context
> + );
> +
> +
> +VOID
> +PlatformRegisterFvBootOption (
> + EFI_GUID *FileGuid,
> + CHAR16 *Description,
> + UINT32 Attributes
> + )
> +{
> + EFI_STATUS Status;
> + INTN OptionIndex;
> + EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
> + EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
> + UINTN BootOptionCount;
> + MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
> + EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
> + EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> +
> + Status = gBS->HandleProtocol (
> + gImageHandle,
> + &gEfiLoadedImageProtocolGuid,
> + (VOID **) &LoadedImage
> + );
> + ASSERT_EFI_ERROR (Status);
> +
> + EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);
> + DevicePath = DevicePathFromHandle (LoadedImage->DeviceHandle);
> + ASSERT (DevicePath != NULL);
> + DevicePath = AppendDevicePathNode (
> + DevicePath,
> + (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
> + );
> + ASSERT (DevicePath != NULL);
> +
> + Status = EfiBootManagerInitializeLoadOption (
> + &NewOption,
> + LoadOptionNumberUnassigned,
> + LoadOptionTypeBoot,
> + Attributes,
> + Description,
> + DevicePath,
> + NULL,
> + 0
> + );
> + ASSERT_EFI_ERROR (Status);
> + FreePool (DevicePath);
> +
> + BootOptions = EfiBootManagerGetLoadOptions (
> + &BootOptionCount, LoadOptionTypeBoot
> + );
> +
> + OptionIndex = EfiBootManagerFindLoadOption (
> + &NewOption, BootOptions, BootOptionCount
> + );
> +
> + if (OptionIndex == -1) {
> + Status = EfiBootManagerAddLoadOptionVariable (&NewOption, MAX_UINTN);
> + ASSERT_EFI_ERROR (Status);
> + }
> + EfiBootManagerFreeLoadOption (&NewOption);
> + EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
> +}
> +
> +/**
> + Remove all MemoryMapped(...)/FvFile(...) and Fv(...)/FvFile(...) boot options
> + whose device paths do not resolve exactly to an FvFile in the system.
> +
> + This removes any boot options that point to binaries built into the firmware
> + and have become stale due to any of the following:
> + - DXEFV's base address or size changed (historical),
> + - DXEFV's FvNameGuid changed,
> + - the FILE_GUID of the pointed-to binary changed,
> + - the referenced binary is no longer built into the firmware.
> +
> + EfiBootManagerFindLoadOption() used in PlatformRegisterFvBootOption() only
> + avoids exact duplicates.
> +**/
> +VOID
> +RemoveStaleFvFileOptions (
> + VOID
> + )
> +{
> + EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
> + UINTN BootOptionCount;
> + UINTN Index;
> +
> + BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount,
> + LoadOptionTypeBoot);
> +
> + for (Index = 0; Index < BootOptionCount; ++Index) {
> + EFI_DEVICE_PATH_PROTOCOL *Node1, *Node2, *SearchNode;
> + EFI_STATUS Status;
> + EFI_HANDLE FvHandle;
> +
> + //
> + // If the device path starts with neither MemoryMapped(...) nor Fv(...),
> + // then keep the boot option.
> + //
> + Node1 = BootOptions[Index].FilePath;
> + if (!(DevicePathType (Node1) == HARDWARE_DEVICE_PATH &&
> + DevicePathSubType (Node1) == HW_MEMMAP_DP) &&
> + !(DevicePathType (Node1) == MEDIA_DEVICE_PATH &&
> + DevicePathSubType (Node1) == MEDIA_PIWG_FW_VOL_DP)) {
> + continue;
> + }
> +
> + //
> + // If the second device path node is not FvFile(...), then keep the boot
> + // option.
> + //
> + Node2 = NextDevicePathNode (Node1);
> + if (DevicePathType (Node2) != MEDIA_DEVICE_PATH ||
> + DevicePathSubType (Node2) != MEDIA_PIWG_FW_FILE_DP) {
> + continue;
> + }
> +
> + //
> + // Locate the Firmware Volume2 protocol instance that is denoted by the
> + // boot option. If this lookup fails (i.e., the boot option references a
> + // firmware volume that doesn't exist), then we'll proceed to delete the
> + // boot option.
> + //
> + SearchNode = Node1;
> + Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid,
> + &SearchNode, &FvHandle);
> +
> + if (!EFI_ERROR (Status)) {
> + //
> + // The firmware volume was found; now let's see if it contains the FvFile
> + // identified by GUID.
> + //
> + EFI_FIRMWARE_VOLUME2_PROTOCOL *FvProtocol;
> + MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFileNode;
> + UINTN BufferSize;
> + EFI_FV_FILETYPE FoundType;
> + EFI_FV_FILE_ATTRIBUTES FileAttributes;
> + UINT32 AuthenticationStatus;
> +
> + Status = gBS->HandleProtocol (FvHandle, &gEfiFirmwareVolume2ProtocolGuid,
> + (VOID **)&FvProtocol);
> + ASSERT_EFI_ERROR (Status);
> +
> + FvFileNode = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)Node2;
> + //
> + // Buffer==NULL means we request metadata only: BufferSize, FoundType,
> + // FileAttributes.
> + //
> + Status = FvProtocol->ReadFile (
> + FvProtocol,
> + &FvFileNode->FvFileName, // NameGuid
> + NULL, // Buffer
> + &BufferSize,
> + &FoundType,
> + &FileAttributes,
> + &AuthenticationStatus
> + );
> + if (!EFI_ERROR (Status)) {
> + //
> + // The FvFile was found. Keep the boot option.
> + //
> + continue;
> + }
> + }
> +
> + //
> + // Delete the boot option.
> + //
> + Status = EfiBootManagerDeleteLoadOptionVariable (
> + BootOptions[Index].OptionNumber, LoadOptionTypeBoot);
> + DEBUG_CODE (
> + CHAR16 *DevicePathString;
> +
> + DevicePathString = ConvertDevicePathToText(BootOptions[Index].FilePath,
> + FALSE, FALSE);
> + DEBUG ((
> + EFI_ERROR (Status) ? EFI_D_WARN : DEBUG_VERBOSE,
> + "%a: removing stale Boot#%04x %s: %r\n",
> + __FUNCTION__,
> + (UINT32)BootOptions[Index].OptionNumber,
> + DevicePathString == NULL ? L"<unavailable>" : DevicePathString,
> + Status
> + ));
> + if (DevicePathString != NULL) {
> + FreePool (DevicePathString);
> + }
> + );
> + }
> +
> + EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
> +}
> +
> +VOID
> +PlatformRegisterOptionsAndKeys (
> + VOID
> + )
> +{
> + EFI_STATUS Status;
> + EFI_INPUT_KEY Enter;
> + EFI_INPUT_KEY F2;
> + EFI_INPUT_KEY Esc;
> + EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
> +
> + //
> + // Register ENTER as CONTINUE key
> + //
> + Enter.ScanCode = SCAN_NULL;
> + Enter.UnicodeChar = CHAR_CARRIAGE_RETURN;
> + Status = EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL);
> + ASSERT_EFI_ERROR (Status);
> + DEBUG ((DEBUG_INFO, "PlatformRegisterOptionsAndKeys\n"));
> + if (EFI_ERROR(Status)){
> + return;
> + }
> + //
> + // Map F2 to Boot Manager Menu
> + //
> + F2.ScanCode = SCAN_F2;
> + F2.UnicodeChar = CHAR_NULL;
> + Esc.ScanCode = SCAN_ESC;
> + Esc.UnicodeChar = CHAR_NULL;
> + Status = EfiBootManagerGetBootManagerMenu (&BootOption);
> + ASSERT_EFI_ERROR (Status);
> + Status = EfiBootManagerAddKeyOptionVariable (
> + NULL, (UINT16) BootOption.OptionNumber, 0, &F2, NULL
> + );
> + ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
> + Status = EfiBootManagerAddKeyOptionVariable (
> + NULL, (UINT16) BootOption.OptionNumber, 0, &Esc, NULL
> + );
> + ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
> +}
> +
> +
> +/**
> + Add IsaKeyboard to ConIn; add IsaSerial to ConOut, ConIn, ErrOut.
> +
> + @param[in] DeviceHandle Handle of the LPC Bridge device.
> +
> + @retval EFI_SUCCESS Console devices on the LPC bridge have been added to
> + ConOut, ConIn, and ErrOut.
> +
> + @return Error codes, due to EFI_DEVICE_PATH_PROTOCOL missing
> + from DeviceHandle.
> +**/
> +EFI_STATUS
> +EFIAPI
> +ConnectRootBridge (
> + IN EFI_HANDLE RootBridgeHandle,
> + IN VOID *Instance,
> + IN VOID *Context
> + )
> +{
> + EFI_STATUS Status;
> +
> + //
> + // Make the PCI bus driver connect the root bridge, non-recursively. This
> + // will produce a number of child handles with PciIo on them.
> + //
> + Status = gBS->ConnectController (
> + RootBridgeHandle, // ControllerHandle
> + NULL, // DriverImageHandle
> + NULL, // RemainingDevicePath -- produce all
> + // children
> + FALSE // Recursive
> + );
> + return Status;
> +}
> +
> +
> +/**
> + Add IsaKeyboard to ConIn; add IsaSerial to ConOut, ConIn, ErrOut.
> +
> + @param[in] DeviceHandle Handle of the LPC Bridge device.
> +
> + @retval EFI_SUCCESS Console devices on the LPC bridge have been added to
> + ConOut, ConIn, and ErrOut.
> +
> + @return Error codes, due to EFI_DEVICE_PATH_PROTOCOL missing
> + from DeviceHandle.
> +**/
> +EFI_STATUS
> +PrepareLpcBridgeDevicePath (
> + IN EFI_HANDLE DeviceHandle
> + )
> +{
> + EFI_STATUS Status;
> + EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> + EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
> + CHAR16 *DevPathStr;
> +
> + DevicePath = NULL;
> + Status = gBS->HandleProtocol (
> + DeviceHandle,
> + &gEfiDevicePathProtocolGuid,
> + (VOID*)&DevicePath
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> + TempDevicePath = DevicePath;
> +
> + //
> + // Register Keyboard
> + //
> + DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnpPs2KeyboardDeviceNode);
> +
> + EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);
> +
> + //
> + // Register COM1
> + //
> + DevicePath = TempDevicePath;
> + gPnp16550ComPortDeviceNode.UID = 0;
> +
> + DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);
> + DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);
> + DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);
> +
> + //
> + // Print Device Path
> + //
> + DevPathStr = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
> + if (DevPathStr != NULL) {
> + DEBUG((
> + DEBUG_INFO,
> + "BdsPlatform.c+%d: COM%d DevPath: %s\n",
> + __LINE__,
> + gPnp16550ComPortDeviceNode.UID + 1,
> + DevPathStr
> + ));
> + FreePool(DevPathStr);
> + }
> +
> + EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
> + EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);
> + EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);
> +
> + //
> + // Register COM2
> + //
> + DevicePath = TempDevicePath;
> + gPnp16550ComPortDeviceNode.UID = 1;
> +
> + DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);
> + DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);
> + DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);
> +
> + //
> + // Print Device Path
> + //
> + DevPathStr = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
> + if (DevPathStr != NULL) {
> + DEBUG((
> + DEBUG_INFO,
> + "BdsPlatform.c+%d: COM%d DevPath: %s\n",
> + __LINE__,
> + gPnp16550ComPortDeviceNode.UID + 1,
> + DevPathStr
> + ));
> + FreePool(DevPathStr);
> + }
> +
> + EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
> + EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);
> + EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);
> +
> + return EFI_SUCCESS;
> +}
> +
> +EFI_STATUS
> +GetGopDevicePath (
> + IN EFI_DEVICE_PATH_PROTOCOL *PciDevicePath,
> + OUT EFI_DEVICE_PATH_PROTOCOL **GopDevicePath
> + )
> +{
> + UINTN Index;
> + EFI_STATUS Status;
> + EFI_HANDLE PciDeviceHandle;
> + EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
> + EFI_DEVICE_PATH_PROTOCOL *TempPciDevicePath;
> + UINTN GopHandleCount;
> + EFI_HANDLE *GopHandleBuffer;
> +
> + if (PciDevicePath == NULL || GopDevicePath == NULL) {
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + //
> + // Initialize the GopDevicePath to be PciDevicePath
> + //
> + *GopDevicePath = PciDevicePath;
> + TempPciDevicePath = PciDevicePath;
> +
> + Status = gBS->LocateDevicePath (
> + &gEfiDevicePathProtocolGuid,
> + &TempPciDevicePath,
> + &PciDeviceHandle
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + //
> + // Try to connect this handle, so that GOP driver could start on this
> + // device and create child handles with GraphicsOutput Protocol installed
> + // on them, then we get device paths of these child handles and select
> + // them as possible console device.
> + //
> + gBS->ConnectController (PciDeviceHandle, NULL, NULL, FALSE);
> +
> + Status = gBS->LocateHandleBuffer (
> + ByProtocol,
> + &gEfiGraphicsOutputProtocolGuid,
> + NULL,
> + &GopHandleCount,
> + &GopHandleBuffer
> + );
> + if (!EFI_ERROR (Status)) {
> + //
> + // Add all the child handles as possible Console Device
> + //
> + for (Index = 0; Index < GopHandleCount; Index++) {
> + Status = gBS->HandleProtocol (GopHandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID*)&TempDevicePath);
> + if (EFI_ERROR (Status)) {
> + continue;
> + }
> + if (CompareMem (
> + PciDevicePath,
> + TempDevicePath,
> + GetDevicePathSize (PciDevicePath) - END_DEVICE_PATH_LENGTH
> + ) == 0) {
> + //
> + // In current implementation, we only enable one of the child handles
> + // as console device, i.e. sotre one of the child handle's device
> + // path to variable "ConOut"
> + // In future, we could select all child handles to be console device
> + //
> +
> + *GopDevicePath = TempDevicePath;
> +
> + //
> + // Delete the PCI device's path that added by
> + // GetPlugInPciVgaDevicePath(). Add the integrity GOP device path.
> + //
> + EfiBootManagerUpdateConsoleVariable (ConOutDev, NULL, PciDevicePath);
> + EfiBootManagerUpdateConsoleVariable (ConOutDev, TempDevicePath, NULL);
> + }
> + }
> + gBS->FreePool (GopHandleBuffer);
> + }
> +
> + return EFI_SUCCESS;
> +}
> +
> +/**
> + Add PCI display to ConOut.
> +
> + @param[in] DeviceHandle Handle of the PCI display device.
> +
> + @retval EFI_SUCCESS The PCI display device has been added to ConOut.
> +
> + @return Error codes, due to EFI_DEVICE_PATH_PROTOCOL missing
> + from DeviceHandle.
> +**/
> +EFI_STATUS
> +PreparePciDisplayDevicePath (
> + IN EFI_HANDLE DeviceHandle
> + )
> +{
> + EFI_STATUS Status;
> + EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> + EFI_DEVICE_PATH_PROTOCOL *GopDevicePath;
> +
> + DevicePath = NULL;
> + GopDevicePath = NULL;
> + Status = gBS->HandleProtocol (
> + DeviceHandle,
> + &gEfiDevicePathProtocolGuid,
> + (VOID*)&DevicePath
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + GetGopDevicePath (DevicePath, &GopDevicePath);
> + DevicePath = GopDevicePath;
> +
> + EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
> +
> + return EFI_SUCCESS;
> +}
> +
> +/**
> + Add PCI Serial to ConOut, ConIn, ErrOut.
> +
> + @param[in] DeviceHandle Handle of the PCI serial device.
> +
> + @retval EFI_SUCCESS The PCI serial device has been added to ConOut, ConIn,
> + ErrOut.
> +
> + @return Error codes, due to EFI_DEVICE_PATH_PROTOCOL missing
> + from DeviceHandle.
> +**/
> +EFI_STATUS
> +PreparePciSerialDevicePath (
> + IN EFI_HANDLE DeviceHandle
> + )
> +{
> + EFI_STATUS Status;
> + EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> +
> + DevicePath = NULL;
> + Status = gBS->HandleProtocol (
> + DeviceHandle,
> + &gEfiDevicePathProtocolGuid,
> + (VOID*)&DevicePath
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);
> + DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);
> +
> + EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
> + EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);
> + EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);
> +
> + return EFI_SUCCESS;
> +}
> +
> +EFI_STATUS
> +VisitAllInstancesOfProtocol (
> + IN EFI_GUID *Id,
> + IN PROTOCOL_INSTANCE_CALLBACK CallBackFunction,
> + IN VOID *Context
> + )
> +{
> + EFI_STATUS Status;
> + UINTN HandleCount;
> + EFI_HANDLE *HandleBuffer;
> + UINTN Index;
> + VOID *Instance;
> +
> + //
> + // Start to check all the PciIo to find all possible device
> + //
> + HandleCount = 0;
> + HandleBuffer = NULL;
> + Status = gBS->LocateHandleBuffer (
> + ByProtocol,
> + Id,
> + NULL,
> + &HandleCount,
> + &HandleBuffer
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + for (Index = 0; Index < HandleCount; Index++) {
> + Status = gBS->HandleProtocol (HandleBuffer[Index], Id, &Instance);
> + if (EFI_ERROR (Status)) {
> + continue;
> + }
> +
> + Status = (*CallBackFunction) (
> + HandleBuffer[Index],
> + Instance,
> + Context
> + );
> + }
> +
> + gBS->FreePool (HandleBuffer);
> +
> + return EFI_SUCCESS;
> +}
> +
> +
> +EFI_STATUS
> +EFIAPI
> +VisitingAPciInstance (
> + IN EFI_HANDLE Handle,
> + IN VOID *Instance,
> + IN VOID *Context
> + )
> +{
> + EFI_STATUS Status;
> + EFI_PCI_IO_PROTOCOL *PciIo;
> + PCI_TYPE00 Pci;
> +
> + PciIo = (EFI_PCI_IO_PROTOCOL*) Instance;
> +
> + //
> + // Check for all PCI device
> + //
> + Status = PciIo->Pci.Read (
> + PciIo,
> + EfiPciIoWidthUint32,
> + 0,
> + sizeof (Pci) / sizeof (UINT32),
> + &Pci
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + return (*(VISIT_PCI_INSTANCE_CALLBACK)(UINTN) Context) (
> + Handle,
> + PciIo,
> + &Pci
> + );
> +
> +}
> +
> +
> +
> +EFI_STATUS
> +VisitAllPciInstances (
> + IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction
> + )
> +{
> + return VisitAllInstancesOfProtocol (
> + &gEfiPciIoProtocolGuid,
> + VisitingAPciInstance,
> + (VOID*)(UINTN) CallBackFunction
> + );
> +}
> +
> +
> +/**
> + Do platform specific PCI Device check and add them to
> + ConOut, ConIn, ErrOut.
> +
> + @param[in] Handle - Handle of PCI device instance
> + @param[in] PciIo - PCI IO protocol instance
> + @param[in] Pci - PCI Header register block
> +
> + @retval EFI_SUCCESS - PCI Device check and Console variable update
> + successfully.
> + @retval EFI_STATUS - PCI Device check or Console variable update fail.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +DetectAndPreparePlatformPciDevicePath (
> + IN EFI_HANDLE Handle,
> + IN EFI_PCI_IO_PROTOCOL *PciIo,
> + IN PCI_TYPE00 *Pci
> + )
> +{
> + EFI_STATUS Status;
> +
> + Status = PciIo->Attributes (
> + PciIo,
> + EfiPciIoAttributeOperationEnable,
> + EFI_PCI_DEVICE_ENABLE,
> + NULL
> + );
> + ASSERT_EFI_ERROR (Status);
> +
> + if (!mDetectVgaOnly) {
> + //
> + // Here we decide whether it is LPC Bridge
> + //
> + if ((IS_PCI_LPC (Pci)) ||
> + ((IS_PCI_ISA_PDECODE (Pci)) &&
> + (Pci->Hdr.VendorId == 0x8086) &&
> + (Pci->Hdr.DeviceId == 0x7000)
> + )
> + ) {
> + //
> + // Add IsaKeyboard to ConIn,
> + // add IsaSerial to ConOut, ConIn, ErrOut
> + //
> + DEBUG ((DEBUG_INFO, "Found LPC Bridge device\n"));
> + PrepareLpcBridgeDevicePath (Handle);
> + return EFI_SUCCESS;
> + }
> + //
> + // Here we decide which Serial device to enable in PCI bus
> + //
> + if (IS_PCI_16550SERIAL (Pci)) {
> + //
> + // Add them to ConOut, ConIn, ErrOut.
> + //
> + DEBUG ((DEBUG_INFO, "Found PCI 16550 SERIAL device\n"));
> + PreparePciSerialDevicePath (Handle);
> + return EFI_SUCCESS;
> + }
> + }
> +
> + //
> + // Here we decide which display device to enable in PCI bus
> + //
> + if (IS_PCI_DISPLAY (Pci)) {
> + //
> + // Add them to ConOut.
> + //
> + DEBUG ((DEBUG_INFO, "Found PCI display device\n"));
> + PreparePciDisplayDevicePath (Handle);
> + return EFI_SUCCESS;
> + }
> +
> + return Status;
> +}
> +
> +
> +/**
> + Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut
> +
> + @param[in] DetectVgaOnly - Only detect VGA device if it's TRUE.
> +
> + @retval EFI_SUCCESS - PCI Device check and Console variable update successfully.
> + @retval EFI_STATUS - PCI Device check or Console variable update fail.
> +
> +**/
> +EFI_STATUS
> +DetectAndPreparePlatformPciDevicePaths (
> + BOOLEAN DetectVgaOnly
> + )
> +{
> + mDetectVgaOnly = DetectVgaOnly;
> + return VisitAllPciInstances (DetectAndPreparePlatformPciDevicePath);
> +}
> +
> +/**
> + Connect the predefined platform default console device.
> +
> + Always try to find and enable PCI display devices.
> +
> + @param[in] PlatformConsole Predefined platform default console device array.
> +**/
> +VOID
> +PlatformInitializeConsole (
> + IN PLATFORM_CONSOLE_CONNECT_ENTRY *PlatformConsole
> + )
> +{
> + UINTN Index;
> + EFI_DEVICE_PATH_PROTOCOL *VarConout;
> + EFI_DEVICE_PATH_PROTOCOL *VarConin;
> +
> + //
> + // Connect RootBridge
> + //
> + GetEfiGlobalVariable2 (EFI_CON_OUT_VARIABLE_NAME, (VOID **) &VarConout, NULL);
> + GetEfiGlobalVariable2 (EFI_CON_IN_VARIABLE_NAME, (VOID **) &VarConin, NULL);
> +
> + if (VarConout == NULL || VarConin == NULL) {
> + //
> + // Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut
> + //
> + DetectAndPreparePlatformPciDevicePaths (FALSE);
> + DetectAndPreparePlatformPciDevicePaths(TRUE);
> + //
> + // Have chance to connect the platform default console,
> + // the platform default console is the minimue device group
> + // the platform should support
> + //
> + for (Index = 0; PlatformConsole[Index].DevicePath != NULL; ++Index) {
> + //
> + // Update the console variable with the connect type
> + //
> + if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {
> + EfiBootManagerUpdateConsoleVariable (ConIn, PlatformConsole[Index].DevicePath, NULL);
> + }
> + if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {
> + EfiBootManagerUpdateConsoleVariable (ConOut, PlatformConsole[Index].DevicePath, NULL);
> + }
> + if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {
> + EfiBootManagerUpdateConsoleVariable (ErrOut, PlatformConsole[Index].DevicePath, NULL);
> + }
> + }
> + } else {
> + //
> + // Only detect VGA device and add them to ConOut
> + //
> + DetectAndPreparePlatformPciDevicePaths (TRUE);
> + }
> +}
> +
> +
> +/**
> + Configure PCI Interrupt Line register for applicable devices
> + Ported from SeaBIOS, src/fw/pciinit.c, *_pci_slot_get_irq()
> +
> + @param[in] Handle - Handle of PCI device instance
> + @param[in] PciIo - PCI IO protocol instance
> + @param[in] PciHdr - PCI Header register block
> +
> + @retval EFI_SUCCESS - PCI Interrupt Line register configured successfully.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +SetPciIntLine (
> + IN EFI_HANDLE Handle,
> + IN EFI_PCI_IO_PROTOCOL *PciIo,
> + IN PCI_TYPE00 *PciHdr
> + )
> +{
> + EFI_DEVICE_PATH_PROTOCOL *DevPathNode;
> + EFI_DEVICE_PATH_PROTOCOL *DevPath;
> + UINTN RootSlot;
> + UINTN Idx;
> + UINT8 IrqLine;
> + EFI_STATUS Status;
> + UINT32 RootBusNumber;
> +
> + Status = EFI_SUCCESS;
> +
> + if (PciHdr->Device.InterruptPin != 0) {
> +
> + DevPathNode = DevicePathFromHandle (Handle);
> + ASSERT (DevPathNode != NULL);
> + DevPath = DevPathNode;
> +
> + RootBusNumber = 0;
> + if (DevicePathType (DevPathNode) == ACPI_DEVICE_PATH &&
> + DevicePathSubType (DevPathNode) == ACPI_DP &&
> + ((ACPI_HID_DEVICE_PATH *)DevPathNode)->HID == EISA_PNP_ID(0x0A03)) {
> + RootBusNumber = ((ACPI_HID_DEVICE_PATH *)DevPathNode)->UID;
> + }
> +
> + //
> + // Compute index into PciHostIrqs[] table by walking
> + // the device path and adding up all device numbers
> + //
> + Status = EFI_NOT_FOUND;
> + RootSlot = 0;
> + Idx = PciHdr->Device.InterruptPin - 1;
> + while (!IsDevicePathEnd (DevPathNode)) {
> + if (DevicePathType (DevPathNode) == HARDWARE_DEVICE_PATH &&
> + DevicePathSubType (DevPathNode) == HW_PCI_DP) {
> +
> + Idx += ((PCI_DEVICE_PATH *)DevPathNode)->Device;
> +
> + //
> + // Unlike SeaBIOS, which starts climbing from the leaf device
> + // up toward the root, we traverse the device path starting at
> + // the root moving toward the leaf node.
> + // The slot number of the top-level parent bridge is needed
> + // with more than 24 slots on the root bus.
> + //
> + if (Status != EFI_SUCCESS) {
> + Status = EFI_SUCCESS;
> + RootSlot = ((PCI_DEVICE_PATH *)DevPathNode)->Device;
> + }
> + }
> +
> + DevPathNode = NextDevicePathNode (DevPathNode);
> + }
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> + if (RootBusNumber == 0 && RootSlot == 0) {
> + return Status; //bugbug: workaround; need SIMICS change B0/D0/F0 PCI_IntPin reg(0x3D) = 0X0
> +// DEBUG((
> +// DEBUG_ERROR,
> +// "%a: PCI host bridge (00:00.0) should have no interrupts!\n",
> +// __FUNCTION__
> +// ));
> +// ASSERT (FALSE);
> + }
> +
> + //
> + // Final PciHostIrqs[] index calculation depends on the platform
> + // and should match SeaBIOS src/fw/pciinit.c *_pci_slot_get_irq()
> + //
> + switch (mHostBridgeDevId) {
> + case INTEL_82441_DEVICE_ID:
> + Idx -= 1;
> + break;
> + case INTEL_ICH10_DEVICE_ID:
> + //
> + // SeaBIOS contains the following comment:
> + // "Slots 0-24 rotate slot:pin mapping similar to piix above, but
> + // with a different starting index.
> + //
> + // Slots 25-31 all use LNKA mapping (or LNKE, but A:D = E:H)"
> + //
> + if (RootSlot > 24) {
> + //
> + // in this case, subtract back out RootSlot from Idx
> + // (SeaBIOS never adds it to begin with, but that would make our
> + // device path traversal loop above too awkward)
> + //
> + Idx -= RootSlot;
> + }
> + break;
> + default:
> + ASSERT (FALSE); // should never get here
> + }
> + Idx %= ARRAY_SIZE (PciHostIrqs);
> + IrqLine = PciHostIrqs[Idx];
> +
> + DEBUG_CODE_BEGIN ();
> + {
> + CHAR16 *DevPathString;
> + STATIC CHAR16 Fallback[] = L"<failed to convert>";
> + UINTN Segment, Bus, Device, Function;
> +
> + DevPathString = ConvertDevicePathToText (DevPath, FALSE, FALSE);
> + if (DevPathString == NULL) {
> + DevPathString = Fallback;
> + }
> + Status = PciIo->GetLocation (PciIo, &Segment, &Bus, &Device, &Function);
> + ASSERT_EFI_ERROR (Status);
> +
> + DEBUG ((DEBUG_VERBOSE, "%a: [%02x:%02x.%x] %s -> 0x%02x\n", __FUNCTION__,
> + (UINT32)Bus, (UINT32)Device, (UINT32)Function, DevPathString,
> + IrqLine));
> +
> + if (DevPathString != Fallback) {
> + FreePool (DevPathString);
> + }
> + }
> + DEBUG_CODE_END ();
> +
> + //
> + // Set PCI Interrupt Line register for this device to PciHostIrqs[Idx]
> + //
> + Status = PciIo->Pci.Write (
> + PciIo,
> + EfiPciIoWidthUint8,
> + PCI_INT_LINE_OFFSET,
> + 1,
> + &IrqLine
> + );
> + }
> +
> + return Status;
> +}
> +
> +/**
> +Write to mask and edge/level triggered registers of master and slave 8259 PICs.
> +
> +@param[in] Mask low byte for master PIC mask register,
> +high byte for slave PIC mask register.
> +@param[in] EdgeLevel low byte for master PIC edge/level triggered register,
> +high byte for slave PIC edge/level triggered register.
> +
> +**/
> +VOID
> +Interrupt8259WriteMask(
> + IN UINT16 Mask,
> + IN UINT16 EdgeLevel
> +)
> +{
> + IoWrite8(LEGACY_8259_MASK_REGISTER_MASTER, (UINT8)Mask);
> + IoWrite8(LEGACY_8259_MASK_REGISTER_SLAVE, (UINT8)(Mask >> 8));
> + IoWrite8(LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_MASTER, (UINT8)EdgeLevel);
> + IoWrite8(LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_SLAVE, (UINT8)(EdgeLevel >> 8));
> +}
> +
> +VOID
> +PciAcpiInitialization (
> + VOID
> + )
> +{
> + UINTN Pmba;
> +
> + //
> + // Query Host Bridge DID to determine platform type
> + //
> + mHostBridgeDevId = PcdGet16 (PcdSimicsX58HostBridgePciDevId);
> + switch (mHostBridgeDevId) {
> + case INTEL_82441_DEVICE_ID:
> + Pmba = POWER_MGMT_REGISTER_PIIX4 (PIIX4_PMBA);
> + //
> + // 00:01.0 ISA Bridge (PIIX4) LNK routing targets
> + //
> + PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x60), 0x0b); // A
> + PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x61), 0x0b); // B
> + PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x62), 0x0a); // C
> + PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x63), 0x0a); // D
> + break;
> + case INTEL_ICH10_DEVICE_ID:
> + Pmba = POWER_MGMT_REGISTER_ICH10 (ICH10_PMBASE);
> + //
> + // 00:1f.0 LPC Bridge LNK routing targets
> + //
> + PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x60), 0x0a); // A
> + PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x61), 0x0a); // B
> + PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x62), 0x0b); // C
> + PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x63), 0x0b); // D
> + PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x68), 0x0a); // E
> + PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x69), 0x0a); // F
> + PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x6a), 0x0b); // G
> + PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x6b), 0x0b); // H
> + break;
> + default:
> + DEBUG ((DEBUG_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n",
> + __FUNCTION__, mHostBridgeDevId));
> + ASSERT (FALSE);
> + return;
> + }
> +
> + //
> + // Initialize PCI_INTERRUPT_LINE for applicable present PCI devices
> + //
> + VisitAllPciInstances (SetPciIntLine);
> +
> + //
> + // Set ACPI SCI_EN bit in PMCNTRL
> + //
> + IoOr16 ((PciRead32 (Pmba) & ~BIT0) + 4, BIT0);
> + //
> + // Set all 8259 interrupts to edge triggered and disabled
> + //
> + Interrupt8259WriteMask(0xFFFF, 0x0000);
> +}
> +
> +EFI_STATUS
> +EFIAPI
> +ConnectRecursivelyIfPciMassStorage (
> + IN EFI_HANDLE Handle,
> + IN EFI_PCI_IO_PROTOCOL *Instance,
> + IN PCI_TYPE00 *PciHeader
> + )
> +{
> + EFI_STATUS Status;
> + EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> + CHAR16 *DevPathStr;
> +
> + //
> + // Recognize PCI Mass Storage
> + //
> + if (IS_CLASS1 (PciHeader, PCI_CLASS_MASS_STORAGE)) {
> + DevicePath = NULL;
> + Status = gBS->HandleProtocol (
> + Handle,
> + &gEfiDevicePathProtocolGuid,
> + (VOID*)&DevicePath
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + //
> + // Print Device Path
> + //
> + DevPathStr = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
> + if (DevPathStr != NULL) {
> + DEBUG(( DEBUG_INFO, "Found Mass Storage device: %s\n", DevPathStr));
> + FreePool(DevPathStr);
> + }
> +
> + Status = gBS->ConnectController (Handle, NULL, NULL, TRUE);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + }
> +
> + return EFI_SUCCESS;
> +}
> +
> +
> +/**
> + This notification function is invoked when the
> + EMU Variable FVB has been changed.
> +
> + @param Event The event that occurred
> + @param Context For EFI compatibility. Not used.
> +
> +**/
> +VOID
> +EFIAPI
> +EmuVariablesUpdatedCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + )
> +{
> + DEBUG ((DEBUG_INFO, "%a called\n", __FUNCTION__));
> + UpdateNvVarsOnFileSystem ();
> +}
> +
> +
> +EFI_STATUS
> +EFIAPI
> +VisitingFileSystemInstance (
> + IN EFI_HANDLE Handle,
> + IN VOID *Instance,
> + IN VOID *Context
> + )
> +{
> + EFI_STATUS Status;
> + STATIC BOOLEAN ConnectedToFileSystem = FALSE;
> +
> + if (ConnectedToFileSystem) {
> + return EFI_ALREADY_STARTED;
> + }
> +
> + Status = ConnectNvVarsToFileSystem (Handle);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + ConnectedToFileSystem = TRUE;
> + mEmuVariableEvent =
> + EfiCreateProtocolNotifyEvent (
> + &gEfiDevicePathProtocolGuid,
> + TPL_CALLBACK,
> + EmuVariablesUpdatedCallback,
> + NULL,
> + &mEmuVariableEventReg
> + );
> + PcdSet64 (PcdEmuVariableEvent, (UINT64)(UINTN) mEmuVariableEvent);
> +
> + return EFI_SUCCESS;
> +}
> +
> +
> +VOID
> +PlatformBdsRestoreNvVarsFromHardDisk (
> + )
> +{
> + VisitAllPciInstances (ConnectRecursivelyIfPciMassStorage);
> + VisitAllInstancesOfProtocol (
> + &gEfiSimpleFileSystemProtocolGuid,
> + VisitingFileSystemInstance,
> + NULL
> + );
> +}
> +
> +/**
> + Connect with predefined platform connect sequence.
> +
> + The OEM/IBV can customize with their own connect sequence.
> +**/
> +VOID
> +PlatformBdsConnectSequence (
> + VOID
> + )
> +{
> + UINTN Index;
> +
> + DEBUG ((DEBUG_INFO, "%a called\n", __FUNCTION__));
> +
> + Index = 0;
> +
> + //
> + // Here we can get the customized platform connect sequence
> + // Notes: we can connect with new variable which record the
> + // last time boots connect device path sequence
> + //
> + while (gPlatformConnectSequence[Index] != NULL) {
> + //
> + // Build the platform boot option
> + //
> + EfiBootManagerConnectDevicePath (gPlatformConnectSequence[Index], NULL);
> + Index++;
> + }
> +
> + //
> + // Just use the simple policy to connect all devices
> + //
> + DEBUG ((DEBUG_INFO, "EfiBootManagerConnectAll\n"));
> + EfiBootManagerConnectAll ();
> +
> + PciAcpiInitialization ();
> +}
> +
> +/**
> + Do the platform specific action after the console is ready
> +
> + Possible things that can be done in PlatformBootManagerAfterConsole:
> +
> + > Console post action:
> + > Dynamically switch output mode from 100x31 to 80x25 for certain senarino
> + > Signal console ready platform customized event
> + > Run diagnostics like memory testing
> + > Connect certain devices
> + > Dispatch aditional option roms
> + > Special boot: e.g.: USB boot, enter UI
> +**/
> +// VOID
> +// EFIAPI
> +// PlatformBootManagerAfterConsole (
> +// VOID
> +// )
> +// {
> +
> +// }
> +
> +/**
> + This notification function is invoked when an instance of the
> + EFI_DEVICE_PATH_PROTOCOL is produced.
> +
> + @param Event The event that occurred
> + @param Context For EFI compatibility. Not used.
> +
> +**/
> +VOID
> +EFIAPI
> +NotifyDevPath (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + )
> +{
> + EFI_HANDLE Handle;
> + EFI_STATUS Status;
> + UINTN BufferSize;
> + EFI_DEVICE_PATH_PROTOCOL *DevPathNode;
> + ATAPI_DEVICE_PATH *Atapi;
> +
> + //
> + // Examine all new handles
> + //
> + for (;;) {
> + //
> + // Get the next handle
> + //
> + BufferSize = sizeof (Handle);
> + Status = gBS->LocateHandle (
> + ByRegisterNotify,
> + NULL,
> + mEfiDevPathNotifyReg,
> + &BufferSize,
> + &Handle
> + );
> +
> + //
> + // If not found, we're done
> + //
> + if (EFI_NOT_FOUND == Status) {
> + break;
> + }
> +
> + if (EFI_ERROR (Status)) {
> + continue;
> + }
> +
> + //
> + // Get the DevicePath protocol on that handle
> + //
> + Status = gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID **)&DevPathNode);
> + ASSERT_EFI_ERROR (Status);
> +
> + while (!IsDevicePathEnd (DevPathNode)) {
> + //
> + // Find the handler to dump this device path node
> + //
> + if (
> + (DevicePathType(DevPathNode) == MESSAGING_DEVICE_PATH) &&
> + (DevicePathSubType(DevPathNode) == MSG_ATAPI_DP)
> + ) {
> + Atapi = (ATAPI_DEVICE_PATH*) DevPathNode;
> + PciOr16 (
> + PCI_LIB_ADDRESS (
> + 0,
> + 1,
> + 1,
> + (Atapi->PrimarySecondary == 1) ? 0x42: 0x40
> + ),
> + BIT15
> + );
> + }
> +
> + //
> + // Next device path node
> + //
> + DevPathNode = NextDevicePathNode (DevPathNode);
> + }
> + }
> +
> + return;
> +}
> +
> +
> +VOID
> +InstallDevicePathCallback (
> + VOID
> + )
> +{
> + DEBUG ((DEBUG_INFO, "Registered NotifyDevPath Event\n"));
> + mEfiDevPathEvent = EfiCreateProtocolNotifyEvent (
> + &gEfiDevicePathProtocolGuid,
> + TPL_CALLBACK,
> + NotifyDevPath,
> + NULL,
> + &mEfiDevPathNotifyReg
> + );
> +}
> +
> +
> +
> +/**
> + ReadyToBoot callback to set video and text mode for internal shell boot.
> + That will not connect USB controller while CSM and FastBoot are disabled, we need to connect them
> + before booting to Shell for showing USB devices in Shell.
> +
> + When FastBoot is enabled and Windows Console is the chosen Console behavior, input devices will not be connected
> + by default. Hence, when booting to EFI shell, connecting input consoles are required.
> +
> + @param Event Pointer to this event
> + @param Context Event hanlder private data
> +
> + @retval None.
> +**/
> +VOID
> +EFIAPI
> +BdsReadyToBootCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + )
> +{
> + DEBUG ((DEBUG_INFO, "%a called\n", __FUNCTION__));
> +}
> +
> +
> +/**
> + This is the callback function for PCI ENUMERATION COMPLETE.
> +
> + @param[in] Event The Event this notify function registered to.
> + @param[in] Context Pointer to the context data registered to the Event.
> +**/
> +VOID
> +EFIAPI
> +BdsSmmReadyToLockCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + )
> +{
> +
> + VOID *ProtocolPointer;
> + EFI_STATUS Status;
> +
> + //
> + // Check if this is first time called by EfiCreateProtocolNotifyEvent() or not,
> + // if it is, we will skip it until real event is triggered
> + //
> + Status = gBS->LocateProtocol (&gEfiDxeSmmReadyToLockProtocolGuid, NULL, (VOID **) &ProtocolPointer);
> + if (EFI_SUCCESS != Status) {
> + return;
> + }
> +
> + DEBUG ((DEBUG_INFO, "%a called\n", __FUNCTION__));
> +
> + //
> + // Dispatch the deferred 3rd party images.
> + //
> + EfiBootManagerDispatchDeferredImages ();
> +
> + //
> + // For non-trusted console it must be handled here.
> + //
> + //UpdateGraphicConOut (FALSE);
> +}
> +
> +
> +/**
> + This is the callback function for PCI ENUMERATION COMPLETE.
> +
> + @param[in] Event The Event this notify function registered to.
> + @param[in] Context Pointer to the context data registered to the Event.
> +**/
> +VOID
> +EFIAPI
> +BdsPciEnumCompleteCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + )
> +{
> + VOID *ProtocolPointer;
> + EFI_STATUS Status;
> + PLATFORM_CONSOLE_CONNECT_ENTRY PlatformConsole[3];
> + UINTN PlatformConsoleCount;
> + UINTN MaxCount;
> + //
> + // Check if this is first time called by EfiCreateProtocolNotifyEvent() or not,
> + // if it is, we will skip it until real event is triggered
> + //
> + Status = gBS->LocateProtocol (&gEfiPciEnumerationCompleteProtocolGuid, NULL, (VOID **) &ProtocolPointer);
> + if (EFI_SUCCESS != Status) {
> + return;
> + }
> +
> + PlatformConsoleCount = 0;
> + MaxCount = ARRAY_SIZE(PlatformConsole);
> +
> + if (PcdGetSize (PcdTrustedConsoleOutputDevicePath) >= sizeof(EFI_DEVICE_PATH_PROTOCOL)) {
> + PlatformConsole[PlatformConsoleCount].ConnectType = ConOut;
> + PlatformConsole[PlatformConsoleCount].DevicePath = PcdGetPtr (PcdTrustedConsoleOutputDevicePath);
> + PlatformConsoleCount++;
> + }
> + if (PcdGetSize (PcdTrustedConsoleInputDevicePath) >= sizeof(EFI_DEVICE_PATH_PROTOCOL) &&
> + PlatformConsoleCount < MaxCount) {
> + PlatformConsole[PlatformConsoleCount].ConnectType = ConIn;
> + PlatformConsole[PlatformConsoleCount].DevicePath = PcdGetPtr (PcdTrustedConsoleInputDevicePath);
> + PlatformConsoleCount++;
> + }
> +
> + if (PlatformConsoleCount < MaxCount){
> + PlatformConsole[PlatformConsoleCount].ConnectType = 0;
> + PlatformConsole[PlatformConsoleCount].DevicePath = NULL;
> + }else{
> + PlatformConsole[MaxCount - 1].ConnectType = 0;
> + PlatformConsole[MaxCount - 1].DevicePath = NULL;
> + }
> +
> + DEBUG ((DEBUG_INFO, "%a called\n", __FUNCTION__));
> +
> + PlatformInitializeConsole (PlatformConsole);
> +}
> +
> +
> +/**
> + Before console after trusted console event callback
> +
> + @param[in] Event The Event this notify function registered to.
> + @param[in] Context Pointer to the context data registered to the Event.
> +**/
> +VOID
> +EFIAPI
> +BdsBeforeConsoleAfterTrustedConsoleCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + )
> +{
> + EFI_BOOT_MANAGER_LOAD_OPTION *NvBootOptions;
> + UINTN NvBootOptionCount;
> + UINTN Index;
> + EFI_STATUS Status;
> +
> + DEBUG ((DEBUG_INFO, "%a called\n", __FUNCTION__));
> +
> + NvBootOptions = EfiBootManagerGetLoadOptions (&NvBootOptionCount, LoadOptionTypeBoot);
> + for (Index = 0; Index < NvBootOptionCount; Index++) {
> + Status = EfiBootManagerDeleteLoadOptionVariable (NvBootOptions[Index].OptionNumber, LoadOptionTypeBoot);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((
> + DEBUG_ERROR,
> + "%a: removing Boot#%04x %r\n",
> + __FUNCTION__,
> + (UINT32) NvBootOptions[Index].OptionNumber,
> + Status
> + ));
> + }
> + }
> +
> + InstallDevicePathCallback ();
> +
> + VisitAllInstancesOfProtocol (&gEfiPciRootBridgeIoProtocolGuid, ConnectRootBridge, NULL);
> + //
> + // Enable LPC
> + //
> + PciOr16 (POWER_MGMT_REGISTER_ICH10(0x04), BIT0 | BIT1 | BIT2);
> +
> + PlatformRegisterOptionsAndKeys ();
> +}
> +
> +
> +/**
> + Before console before end of DXE event callback
> +
> + @param[in] Event The Event this notify function registered to.
> + @param[in] Context Pointer to the context data registered to the Event.
> +**/
> +VOID
> +EFIAPI
> +BdsBeforeConsoleBeforeEndOfDxeGuidCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> +){
> + DEBUG ((DEBUG_INFO, "%a called\n", __FUNCTION__));
> +}
> +
> +/**
> + After console ready before boot option event callback
> +
> + @param[in] Event The Event this notify function registered to.
> + @param[in] Context Pointer to the context data registered to the Event.
> +**/
> +VOID
> +EFIAPI
> +BdsAfterConsoleReadyBeforeBootOptionCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + )
> +{
> + EFI_BOOT_MODE BootMode;
> +
> + DEBUG ((DEBUG_INFO, "%a called\n", __FUNCTION__));
> +
> + if (PcdGetBool (PcdOvmfFlashVariablesEnable)) {
> + DEBUG ((DEBUG_INFO, "PlatformBdsPolicyBehavior: not restoring NvVars "
> + "from disk since flash variables appear to be supported.\n"));
> + } else {
> + //
> + // Try to restore variables from the hard disk early so
> + // they can be used for the other BDS connect operations.
> + //
> + PlatformBdsRestoreNvVarsFromHardDisk ();
> + }
> +
> + //
> + // Get current Boot Mode
> + //
> + BootMode = GetBootModeHob ();
> + DEBUG ((DEBUG_ERROR, "Boot Mode:%x\n", BootMode));
> +
> + //
> + // Go the different platform policy with different boot mode
> + // Notes: this part code can be change with the table policy
> + //
> + ASSERT (BootMode == BOOT_WITH_FULL_CONFIGURATION);
> +
> + //
> + // Perform some platform specific connect sequence
> + //
> + PlatformBdsConnectSequence ();
> +
> + //
> + // Logo show
> + //
> + EnableBootLogo(PcdGetPtr(PcdLogoFile));
> +
> + EfiBootManagerRefreshAllBootOption ();
> +
> + //
> + // Register UEFI Shell
> + //
> + PlatformRegisterFvBootOption (
> + PcdGetPtr (PcdShellFile), L"EFI Internal Shell", LOAD_OPTION_ACTIVE
> + );
> +
> + RemoveStaleFvFileOptions ();
> +}
> diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
> new file mode 100644
> index 0000000000..a77edf2699
> --- /dev/null
> +++ b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
> @@ -0,0 +1,81 @@
> +## @file
> +# Board BDS hook Library definition file.
> +#
> +# Copyright (c) 2019 Intel Corporation. All rights reserved. <BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + INF_VERSION = 0x00010005
> + BASE_NAME = BoardBdsHookLib
> + FILE_GUID = 285AB0B8-D0D2-4D83-BF20-F85ED040383E
> + MODULE_TYPE = DXE_DRIVER
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = BoardBdsHookLib|DXE_DRIVER
> +
> +#
> +# The following information is for reference only and not required by the build tools.
> +#
> +# VALID_ARCHITECTURES = IA32 X64 EBC
> +#
> +
> +[Sources]
> + BoardBdsHookLib.c
> + BoardBdsHook.h
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + MinPlatformPkg/MinPlatformPkg.dec
> + BoardModulePkg/BoardModulePkg.dec
> + SimicsOpenBoardPkg/OpenBoardPkg.dec
> + OvmfPkg/OvmfPkg.dec
> + SimicsIch10Pkg/Ich10Pkg.dec
> +
> +[LibraryClasses]
> + BaseLib
> + MemoryAllocationLib
> + UefiBootServicesTableLib
> + BaseMemoryLib
> + DebugLib
> + PcdLib
> + UefiBootManagerLib
> + BootLogoLib
> + DevicePathLib
> + PciLib
> + NvVarsFileLib
> + DxeLoadLinuxLib
> + UefiLib
> + LogoLib
> +
> +[Pcd]
> + gSimicsOpenBoardPkgTokenSpaceGuid.PcdEmuVariableEvent
> + gSimicsOpenBoardPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable
> + gSimicsOpenBoardPkgTokenSpaceGuid.PcdSimicsX58HostBridgePciDevId
> + gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
> + gSimicsOpenBoardPkgTokenSpaceGuid.PcdShellFile
> + gSimicsOpenBoardPkgTokenSpaceGuid.PcdLogoFile
> + gMinPlatformPkgTokenSpaceGuid.PcdTrustedConsoleInputDevicePath ## CONSUMES
> + gMinPlatformPkgTokenSpaceGuid.PcdTrustedConsoleOutputDevicePath ## CONSUMES
> + gMinPlatformPkgTokenSpaceGuid.PcdTrustedStorageDevicePath ## CONSUMES
> +
> +[Pcd.IA32, Pcd.X64]
> + gEfiMdePkgTokenSpaceGuid.PcdFSBClock
> +
> +[Protocols]
> + gEfiDecompressProtocolGuid
> + gEfiPciRootBridgeIoProtocolGuid
> + gEfiS3SaveStateProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
> + gEfiDxeSmmReadyToLockProtocolGuid # PROTOCOL SOMETIMES_PRODUCED
> + gEfiLoadedImageProtocolGuid # PROTOCOL SOMETIMES_PRODUCED
> + gEfiFirmwareVolume2ProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
> + gEfiPciEnumerationCompleteProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
> +
> +
> +[Guids]
> + gEfiEndOfDxeEventGroupGuid
> +
> +[Depex]
> + TRUE
> --
> 2.19.1.windows.1
>
Thanks,
Nate
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [edk2-platforms] [PATCH 09/11] SimicsOpenBoardPkg: Add Bds Hook Library
2019-12-14 1:32 ` [edk2-platforms] [PATCH 09/11] SimicsOpenBoardPkg: Add Bds Hook Library Agyeman, Prince
2019-12-18 1:29 ` Nate DeSimone
@ 2019-12-21 2:37 ` Kubacki, Michael A
1 sibling, 0 replies; 45+ messages in thread
From: Kubacki, Michael A @ 2019-12-21 2:37 UTC (permalink / raw)
To: Agyeman, Prince, devel@edk2.groups.io; +Cc: Desimone, Nathaniel L
Reviewed-by: Michael Kubacki <michael.a.kubacki@intel.com>
> -----Original Message-----
> From: Agyeman, Prince <prince.agyeman@intel.com>
> Sent: Friday, December 13, 2019 5:33 PM
> To: devel@edk2.groups.io
> Cc: Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Kubacki,
> Michael A <michael.a.kubacki@intel.com>
> Subject: [edk2-platforms] [PATCH 09/11] SimicsOpenBoardPkg: Add Bds
> Hook Library
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
>
> Added Board BDS Hook library that implements simics specific
> Bds hook points or callbacks.
>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
>
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
> .../Library/BoardBdsHookLib/BoardBdsHook.h | 173 ++
> .../Library/BoardBdsHookLib/BoardBdsHookLib.c | 1630
> +++++++++++++++++
> .../BoardBdsHookLib/BoardBdsHookLib.inf | 81 +
> 3 files changed, 1884 insertions(+)
> create mode 100644
> Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHo
> ok.h
> create mode 100644
> Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHo
> okLib.c
> create mode 100644
> Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHo
> okLib.inf
>
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsH
> ook.h
> b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsH
> ook.h
> new file mode 100644
> index 0000000000..fda41b1c97
> --- /dev/null
> +++
> b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsH
> ook.h
> @@ -0,0 +1,173 @@
> +/** @file
> + Header file for the board board specific BDS hook library.
> +
> + Copyright (c) 2019 Intel Corporation. All rights reserved. <BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +**/
> +
> +#ifndef _PLATFORM_SPECIFIC_BDS_PLATFORM_H_
> +#define _PLATFORM_SPECIFIC_BDS_PLATFORM_H_
> +
> +
> +#include <PiDxe.h>
> +
> +#include <IndustryStandard/Pci.h>
> +#include <IndustryStandard/Acpi.h>
> +#include <IndustryStandard/SmBios.h>
> +#include <IndustryStandard/PeImage.h>
> +
> +#include <Library/DebugLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/UefiRuntimeServicesTableLib.h>
> +#include <Library/MemoryAllocationLib.h>
> +#include <Library/BaseLib.h>
> +#include <Library/PcdLib.h>
> +#include <Library/PciLib.h>
> +#include <Library/UefiBootManagerLib.h>
> +#include <Library/BootLogoLib.h>
> +#include <Library/HobLib.h>
> +#include <Library/UefiLib.h>
> +#include <Library/DxeServicesTableLib.h>
> +#include <Library/DevicePathLib.h>
> +#include <Library/IoLib.h>
> +#include <Library/NvVarsFileLib.h>
> +#include <Library/BoardBdsHookLib.h>
> +
> +#include <Protocol/Decompress.h>
> +#include <Protocol/PciIo.h>
> +#include <Protocol/FirmwareVolume2.h>
> +#include <Protocol/SimpleFileSystem.h>
> +#include <Protocol/PciRootBridgeIo.h>
> +#include <Protocol/S3SaveState.h>
> +#include <Protocol/DxeSmmReadyToLock.h>
> +#include <Protocol/LoadedImage.h>
> +
> +#include <Guid/Acpi.h>
> +#include <Guid/SmBios.h>
> +#include <Guid/Mps.h>
> +#include <Guid/HobList.h>
> +#include <Guid/GlobalVariable.h>
> +#include <Guid/EventGroup.h>
> +
> +#include <SimicsPlatforms.h>
> +
> +extern EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[];
> +extern ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode;
> +extern ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode;
> +extern UART_DEVICE_PATH gUartDeviceNode;
> +extern VENDOR_DEVICE_PATH gTerminalTypeDeviceNode;
> +
> +#define PCI_DEVICE_PATH_NODE(Func, Dev) \
> + { \
> + { \
> + HARDWARE_DEVICE_PATH, \
> + HW_PCI_DP, \
> + { \
> + (UINT8) (sizeof (PCI_DEVICE_PATH)), \
> + (UINT8) ((sizeof (PCI_DEVICE_PATH)) >> 8) \
> + } \
> + }, \
> + (Func), \
> + (Dev) \
> + }
> +
> +#define PNPID_DEVICE_PATH_NODE(PnpId) \
> + { \
> + { \
> + ACPI_DEVICE_PATH, \
> + ACPI_DP, \
> + { \
> + (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \
> + (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \
> + }, \
> + }, \
> + EISA_PNP_ID((PnpId)), \
> + 0 \
> + }
> +
> +#define gPciIsaBridge \
> + PCI_DEVICE_PATH_NODE(0, 0x1f)
> +
> +#define gP2PBridge \
> + PCI_DEVICE_PATH_NODE(0, 0x1e)
> +
> +#define gPnpPs2Keyboard \
> + PNPID_DEVICE_PATH_NODE(0x0303)
> +
> +#define gPnp16550ComPort \
> + PNPID_DEVICE_PATH_NODE(0x0501)
> +
> +#define gUart \
> + { \
> + { \
> + MESSAGING_DEVICE_PATH, \
> + MSG_UART_DP, \
> + { \
> + (UINT8) (sizeof (UART_DEVICE_PATH)), \
> + (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8) \
> + } \
> + }, \
> + 0, \
> + 115200, \
> + 8, \
> + 1, \
> + 1 \
> + }
> +
> +#define gPcAnsiTerminal \
> + { \
> + { \
> + MESSAGING_DEVICE_PATH, \
> + MSG_VENDOR_DP, \
> + { \
> + (UINT8) (sizeof (VENDOR_DEVICE_PATH)), \
> + (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) \
> + } \
> + }, \
> + DEVICE_PATH_MESSAGING_PC_ANSI \
> + }
> +
> +#define PCI_CLASS_SCC 0x07
> +#define PCI_SUBCLASS_SERIAL 0x00
> +#define PCI_IF_16550 0x02
> +#define IS_PCI_16550SERIAL(_p) IS_CLASS3 (_p, PCI_CLASS_SCC,
> PCI_SUBCLASS_SERIAL, PCI_IF_16550)
> +#define IS_PCI_ISA_PDECODE(_p) IS_CLASS3 (_p, PCI_CLASS_BRIDGE,
> PCI_CLASS_BRIDGE_ISA_PDECODE, 0)
> +
> +typedef struct {
> + EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> + UINTN ConnectType;
> +} PLATFORM_CONSOLE_CONNECT_ENTRY;
> +
> +#define CONSOLE_OUT BIT0
> +#define CONSOLE_IN BIT1
> +#define STD_ERROR BIT2
> +extern PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[];
> +
> +//
> +// Platform BDS Functions
> +//
> +
> +VOID
> +PlatformInitializeConsole (
> + IN PLATFORM_CONSOLE_CONNECT_ENTRY *PlatformConsole
> + );
> +
> +/**
> + Use SystemTable ConOut to stop video based Simple Text Out consoles
> from going
> + to the video device. Put up LogoFile on every video device that is a
> console.
> +
> + @param[in] LogoFile The file name of logo to display on the center of the
> screen.
> +
> + @retval EFI_SUCCESS ConsoleControl has been flipped to graphics and
> logo displayed.
> + @retval EFI_UNSUPPORTED Logo not found.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +EnableBootLogo(
> + IN EFI_GUID *LogoFile
> +);
> +
> +#endif // _PLATFORM_SPECIFIC_BDS_PLATFORM_H_
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsH
> ookLib.c
> b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsH
> ookLib.c
> new file mode 100644
> index 0000000000..1058dbf3cf
> --- /dev/null
> +++
> b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsH
> ookLib.c
> @@ -0,0 +1,1630 @@
> +/** @file
> + Board BDS hook Library. Implements board specific BDS hook library
> +
> + Copyright (c) 2019 Intel Corporation. All rights reserved. <BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +**/
> +
> +#include "BoardBdsHook.h"
> +#include <Guid/RootBridgesConnectedEventGroup.h>
> +#include <Protocol/FirmwareVolume2.h>
> +
> +#define LEGACY_8259_MASK_REGISTER_MASTER 0x21
> +#define LEGACY_8259_MASK_REGISTER_SLAVE 0xA1
> +#define LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_MASTER
> 0x4D0
> +#define LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_SLAVE 0x4D1
> +
> +//
> +// Predefined platform connect sequence
> +//
> +EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[] = { NULL };
> +
> +
> +ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode =
> gPnpPs2Keyboard;
> +ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode =
> gPnp16550ComPort;
> +UART_DEVICE_PATH gUartDeviceNode = gUart;
> +VENDOR_DEVICE_PATH gTerminalTypeDeviceNode =
> gPcAnsiTerminal;
> +
> +//
> +// Global data
> +//
> +
> +VOID *mEfiDevPathNotifyReg;
> +EFI_EVENT mEfiDevPathEvent;
> +VOID *mEmuVariableEventReg;
> +EFI_EVENT mEmuVariableEvent;
> +BOOLEAN mDetectVgaOnly;
> +UINT16 mHostBridgeDevId;
> +
> +//
> +// Table of host IRQs matching PCI IRQs A-D
> +// (for configuring PCI Interrupt Line register)
> +//
> +CONST UINT8 PciHostIrqs[] = {
> + 0x0a, 0x0a, 0x0b, 0x0b
> +};
> +
> +//
> +// Type definitions
> +//
> +typedef
> +EFI_STATUS
> +(EFIAPI *PROTOCOL_INSTANCE_CALLBACK)(
> + IN EFI_HANDLE Handle,
> + IN VOID *Instance,
> + IN VOID *Context
> + );
> +
> +/**
> + @param[in] Handle - Handle of PCI device instance
> + @param[in] PciIo - PCI IO protocol instance
> + @param[in] Pci - PCI Header register block
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *VISIT_PCI_INSTANCE_CALLBACK)(
> + IN EFI_HANDLE Handle,
> + IN EFI_PCI_IO_PROTOCOL *PciIo,
> + IN PCI_TYPE00 *Pci
> + );
> +
> +
> +//
> +// Function prototypes
> +//
> +
> +EFI_STATUS
> +VisitAllInstancesOfProtocol (
> + IN EFI_GUID *Id,
> + IN PROTOCOL_INSTANCE_CALLBACK CallBackFunction,
> + IN VOID *Context
> + );
> +
> +EFI_STATUS
> +VisitAllPciInstancesOfProtocol (
> + IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction
> + );
> +
> +VOID
> +InstallDevicePathCallback (
> + VOID
> + );
> +
> +EFI_STATUS
> +EFIAPI
> +ConnectRootBridge (
> + IN EFI_HANDLE RootBridgeHandle,
> + IN VOID *Instance,
> + IN VOID *Context
> + );
> +
> +
> +VOID
> +PlatformRegisterFvBootOption (
> + EFI_GUID *FileGuid,
> + CHAR16 *Description,
> + UINT32 Attributes
> + )
> +{
> + EFI_STATUS Status;
> + INTN OptionIndex;
> + EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
> + EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
> + UINTN BootOptionCount;
> + MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
> + EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
> + EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> +
> + Status = gBS->HandleProtocol (
> + gImageHandle,
> + &gEfiLoadedImageProtocolGuid,
> + (VOID **) &LoadedImage
> + );
> + ASSERT_EFI_ERROR (Status);
> +
> + EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);
> + DevicePath = DevicePathFromHandle (LoadedImage->DeviceHandle);
> + ASSERT (DevicePath != NULL);
> + DevicePath = AppendDevicePathNode (
> + DevicePath,
> + (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
> + );
> + ASSERT (DevicePath != NULL);
> +
> + Status = EfiBootManagerInitializeLoadOption (
> + &NewOption,
> + LoadOptionNumberUnassigned,
> + LoadOptionTypeBoot,
> + Attributes,
> + Description,
> + DevicePath,
> + NULL,
> + 0
> + );
> + ASSERT_EFI_ERROR (Status);
> + FreePool (DevicePath);
> +
> + BootOptions = EfiBootManagerGetLoadOptions (
> + &BootOptionCount, LoadOptionTypeBoot
> + );
> +
> + OptionIndex = EfiBootManagerFindLoadOption (
> + &NewOption, BootOptions, BootOptionCount
> + );
> +
> + if (OptionIndex == -1) {
> + Status = EfiBootManagerAddLoadOptionVariable (&NewOption,
> MAX_UINTN);
> + ASSERT_EFI_ERROR (Status);
> + }
> + EfiBootManagerFreeLoadOption (&NewOption);
> + EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
> +}
> +
> +/**
> + Remove all MemoryMapped(...)/FvFile(...) and Fv(...)/FvFile(...) boot
> options
> + whose device paths do not resolve exactly to an FvFile in the system.
> +
> + This removes any boot options that point to binaries built into the
> firmware
> + and have become stale due to any of the following:
> + - DXEFV's base address or size changed (historical),
> + - DXEFV's FvNameGuid changed,
> + - the FILE_GUID of the pointed-to binary changed,
> + - the referenced binary is no longer built into the firmware.
> +
> + EfiBootManagerFindLoadOption() used in PlatformRegisterFvBootOption()
> only
> + avoids exact duplicates.
> +**/
> +VOID
> +RemoveStaleFvFileOptions (
> + VOID
> + )
> +{
> + EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
> + UINTN BootOptionCount;
> + UINTN Index;
> +
> + BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount,
> + LoadOptionTypeBoot);
> +
> + for (Index = 0; Index < BootOptionCount; ++Index) {
> + EFI_DEVICE_PATH_PROTOCOL *Node1, *Node2, *SearchNode;
> + EFI_STATUS Status;
> + EFI_HANDLE FvHandle;
> +
> + //
> + // If the device path starts with neither MemoryMapped(...) nor Fv(...),
> + // then keep the boot option.
> + //
> + Node1 = BootOptions[Index].FilePath;
> + if (!(DevicePathType (Node1) == HARDWARE_DEVICE_PATH &&
> + DevicePathSubType (Node1) == HW_MEMMAP_DP) &&
> + !(DevicePathType (Node1) == MEDIA_DEVICE_PATH &&
> + DevicePathSubType (Node1) == MEDIA_PIWG_FW_VOL_DP)) {
> + continue;
> + }
> +
> + //
> + // If the second device path node is not FvFile(...), then keep the boot
> + // option.
> + //
> + Node2 = NextDevicePathNode (Node1);
> + if (DevicePathType (Node2) != MEDIA_DEVICE_PATH ||
> + DevicePathSubType (Node2) != MEDIA_PIWG_FW_FILE_DP) {
> + continue;
> + }
> +
> + //
> + // Locate the Firmware Volume2 protocol instance that is denoted by the
> + // boot option. If this lookup fails (i.e., the boot option references a
> + // firmware volume that doesn't exist), then we'll proceed to delete the
> + // boot option.
> + //
> + SearchNode = Node1;
> + Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid,
> + &SearchNode, &FvHandle);
> +
> + if (!EFI_ERROR (Status)) {
> + //
> + // The firmware volume was found; now let's see if it contains the FvFile
> + // identified by GUID.
> + //
> + EFI_FIRMWARE_VOLUME2_PROTOCOL *FvProtocol;
> + MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFileNode;
> + UINTN BufferSize;
> + EFI_FV_FILETYPE FoundType;
> + EFI_FV_FILE_ATTRIBUTES FileAttributes;
> + UINT32 AuthenticationStatus;
> +
> + Status = gBS->HandleProtocol (FvHandle,
> &gEfiFirmwareVolume2ProtocolGuid,
> + (VOID **)&FvProtocol);
> + ASSERT_EFI_ERROR (Status);
> +
> + FvFileNode = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)Node2;
> + //
> + // Buffer==NULL means we request metadata only: BufferSize,
> FoundType,
> + // FileAttributes.
> + //
> + Status = FvProtocol->ReadFile (
> + FvProtocol,
> + &FvFileNode->FvFileName, // NameGuid
> + NULL, // Buffer
> + &BufferSize,
> + &FoundType,
> + &FileAttributes,
> + &AuthenticationStatus
> + );
> + if (!EFI_ERROR (Status)) {
> + //
> + // The FvFile was found. Keep the boot option.
> + //
> + continue;
> + }
> + }
> +
> + //
> + // Delete the boot option.
> + //
> + Status = EfiBootManagerDeleteLoadOptionVariable (
> + BootOptions[Index].OptionNumber, LoadOptionTypeBoot);
> + DEBUG_CODE (
> + CHAR16 *DevicePathString;
> +
> + DevicePathString =
> ConvertDevicePathToText(BootOptions[Index].FilePath,
> + FALSE, FALSE);
> + DEBUG ((
> + EFI_ERROR (Status) ? EFI_D_WARN : DEBUG_VERBOSE,
> + "%a: removing stale Boot#%04x %s: %r\n",
> + __FUNCTION__,
> + (UINT32)BootOptions[Index].OptionNumber,
> + DevicePathString == NULL ? L"<unavailable>" : DevicePathString,
> + Status
> + ));
> + if (DevicePathString != NULL) {
> + FreePool (DevicePathString);
> + }
> + );
> + }
> +
> + EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
> +}
> +
> +VOID
> +PlatformRegisterOptionsAndKeys (
> + VOID
> + )
> +{
> + EFI_STATUS Status;
> + EFI_INPUT_KEY Enter;
> + EFI_INPUT_KEY F2;
> + EFI_INPUT_KEY Esc;
> + EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
> +
> + //
> + // Register ENTER as CONTINUE key
> + //
> + Enter.ScanCode = SCAN_NULL;
> + Enter.UnicodeChar = CHAR_CARRIAGE_RETURN;
> + Status = EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL);
> + ASSERT_EFI_ERROR (Status);
> + DEBUG ((DEBUG_INFO, "PlatformRegisterOptionsAndKeys\n"));
> + if (EFI_ERROR(Status)){
> + return;
> + }
> + //
> + // Map F2 to Boot Manager Menu
> + //
> + F2.ScanCode = SCAN_F2;
> + F2.UnicodeChar = CHAR_NULL;
> + Esc.ScanCode = SCAN_ESC;
> + Esc.UnicodeChar = CHAR_NULL;
> + Status = EfiBootManagerGetBootManagerMenu (&BootOption);
> + ASSERT_EFI_ERROR (Status);
> + Status = EfiBootManagerAddKeyOptionVariable (
> + NULL, (UINT16) BootOption.OptionNumber, 0, &F2, NULL
> + );
> + ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
> + Status = EfiBootManagerAddKeyOptionVariable (
> + NULL, (UINT16) BootOption.OptionNumber, 0, &Esc, NULL
> + );
> + ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
> +}
> +
> +
> +/**
> + Add IsaKeyboard to ConIn; add IsaSerial to ConOut, ConIn, ErrOut.
> +
> + @param[in] DeviceHandle Handle of the LPC Bridge device.
> +
> + @retval EFI_SUCCESS Console devices on the LPC bridge have been added
> to
> + ConOut, ConIn, and ErrOut.
> +
> + @return Error codes, due to EFI_DEVICE_PATH_PROTOCOL missing
> + from DeviceHandle.
> +**/
> +EFI_STATUS
> +EFIAPI
> +ConnectRootBridge (
> + IN EFI_HANDLE RootBridgeHandle,
> + IN VOID *Instance,
> + IN VOID *Context
> + )
> +{
> + EFI_STATUS Status;
> +
> + //
> + // Make the PCI bus driver connect the root bridge, non-recursively. This
> + // will produce a number of child handles with PciIo on them.
> + //
> + Status = gBS->ConnectController (
> + RootBridgeHandle, // ControllerHandle
> + NULL, // DriverImageHandle
> + NULL, // RemainingDevicePath -- produce all
> + // children
> + FALSE // Recursive
> + );
> + return Status;
> +}
> +
> +
> +/**
> + Add IsaKeyboard to ConIn; add IsaSerial to ConOut, ConIn, ErrOut.
> +
> + @param[in] DeviceHandle Handle of the LPC Bridge device.
> +
> + @retval EFI_SUCCESS Console devices on the LPC bridge have been added
> to
> + ConOut, ConIn, and ErrOut.
> +
> + @return Error codes, due to EFI_DEVICE_PATH_PROTOCOL missing
> + from DeviceHandle.
> +**/
> +EFI_STATUS
> +PrepareLpcBridgeDevicePath (
> + IN EFI_HANDLE DeviceHandle
> + )
> +{
> + EFI_STATUS Status;
> + EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> + EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
> + CHAR16 *DevPathStr;
> +
> + DevicePath = NULL;
> + Status = gBS->HandleProtocol (
> + DeviceHandle,
> + &gEfiDevicePathProtocolGuid,
> + (VOID*)&DevicePath
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> + TempDevicePath = DevicePath;
> +
> + //
> + // Register Keyboard
> + //
> + DevicePath = AppendDevicePathNode (DevicePath,
> (EFI_DEVICE_PATH_PROTOCOL *)&gPnpPs2KeyboardDeviceNode);
> +
> + EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);
> +
> + //
> + // Register COM1
> + //
> + DevicePath = TempDevicePath;
> + gPnp16550ComPortDeviceNode.UID = 0;
> +
> + DevicePath = AppendDevicePathNode (DevicePath,
> (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);
> + DevicePath = AppendDevicePathNode (DevicePath,
> (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);
> + DevicePath = AppendDevicePathNode (DevicePath,
> (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);
> +
> + //
> + // Print Device Path
> + //
> + DevPathStr = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
> + if (DevPathStr != NULL) {
> + DEBUG((
> + DEBUG_INFO,
> + "BdsPlatform.c+%d: COM%d DevPath: %s\n",
> + __LINE__,
> + gPnp16550ComPortDeviceNode.UID + 1,
> + DevPathStr
> + ));
> + FreePool(DevPathStr);
> + }
> +
> + EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
> + EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);
> + EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);
> +
> + //
> + // Register COM2
> + //
> + DevicePath = TempDevicePath;
> + gPnp16550ComPortDeviceNode.UID = 1;
> +
> + DevicePath = AppendDevicePathNode (DevicePath,
> (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);
> + DevicePath = AppendDevicePathNode (DevicePath,
> (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);
> + DevicePath = AppendDevicePathNode (DevicePath,
> (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);
> +
> + //
> + // Print Device Path
> + //
> + DevPathStr = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
> + if (DevPathStr != NULL) {
> + DEBUG((
> + DEBUG_INFO,
> + "BdsPlatform.c+%d: COM%d DevPath: %s\n",
> + __LINE__,
> + gPnp16550ComPortDeviceNode.UID + 1,
> + DevPathStr
> + ));
> + FreePool(DevPathStr);
> + }
> +
> + EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
> + EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);
> + EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);
> +
> + return EFI_SUCCESS;
> +}
> +
> +EFI_STATUS
> +GetGopDevicePath (
> + IN EFI_DEVICE_PATH_PROTOCOL *PciDevicePath,
> + OUT EFI_DEVICE_PATH_PROTOCOL **GopDevicePath
> + )
> +{
> + UINTN Index;
> + EFI_STATUS Status;
> + EFI_HANDLE PciDeviceHandle;
> + EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
> + EFI_DEVICE_PATH_PROTOCOL *TempPciDevicePath;
> + UINTN GopHandleCount;
> + EFI_HANDLE *GopHandleBuffer;
> +
> + if (PciDevicePath == NULL || GopDevicePath == NULL) {
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + //
> + // Initialize the GopDevicePath to be PciDevicePath
> + //
> + *GopDevicePath = PciDevicePath;
> + TempPciDevicePath = PciDevicePath;
> +
> + Status = gBS->LocateDevicePath (
> + &gEfiDevicePathProtocolGuid,
> + &TempPciDevicePath,
> + &PciDeviceHandle
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + //
> + // Try to connect this handle, so that GOP driver could start on this
> + // device and create child handles with GraphicsOutput Protocol installed
> + // on them, then we get device paths of these child handles and select
> + // them as possible console device.
> + //
> + gBS->ConnectController (PciDeviceHandle, NULL, NULL, FALSE);
> +
> + Status = gBS->LocateHandleBuffer (
> + ByProtocol,
> + &gEfiGraphicsOutputProtocolGuid,
> + NULL,
> + &GopHandleCount,
> + &GopHandleBuffer
> + );
> + if (!EFI_ERROR (Status)) {
> + //
> + // Add all the child handles as possible Console Device
> + //
> + for (Index = 0; Index < GopHandleCount; Index++) {
> + Status = gBS->HandleProtocol (GopHandleBuffer[Index],
> &gEfiDevicePathProtocolGuid, (VOID*)&TempDevicePath);
> + if (EFI_ERROR (Status)) {
> + continue;
> + }
> + if (CompareMem (
> + PciDevicePath,
> + TempDevicePath,
> + GetDevicePathSize (PciDevicePath) - END_DEVICE_PATH_LENGTH
> + ) == 0) {
> + //
> + // In current implementation, we only enable one of the child handles
> + // as console device, i.e. sotre one of the child handle's device
> + // path to variable "ConOut"
> + // In future, we could select all child handles to be console device
> + //
> +
> + *GopDevicePath = TempDevicePath;
> +
> + //
> + // Delete the PCI device's path that added by
> + // GetPlugInPciVgaDevicePath(). Add the integrity GOP device path.
> + //
> + EfiBootManagerUpdateConsoleVariable (ConOutDev, NULL,
> PciDevicePath);
> + EfiBootManagerUpdateConsoleVariable (ConOutDev, TempDevicePath,
> NULL);
> + }
> + }
> + gBS->FreePool (GopHandleBuffer);
> + }
> +
> + return EFI_SUCCESS;
> +}
> +
> +/**
> + Add PCI display to ConOut.
> +
> + @param[in] DeviceHandle Handle of the PCI display device.
> +
> + @retval EFI_SUCCESS The PCI display device has been added to ConOut.
> +
> + @return Error codes, due to EFI_DEVICE_PATH_PROTOCOL missing
> + from DeviceHandle.
> +**/
> +EFI_STATUS
> +PreparePciDisplayDevicePath (
> + IN EFI_HANDLE DeviceHandle
> + )
> +{
> + EFI_STATUS Status;
> + EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> + EFI_DEVICE_PATH_PROTOCOL *GopDevicePath;
> +
> + DevicePath = NULL;
> + GopDevicePath = NULL;
> + Status = gBS->HandleProtocol (
> + DeviceHandle,
> + &gEfiDevicePathProtocolGuid,
> + (VOID*)&DevicePath
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + GetGopDevicePath (DevicePath, &GopDevicePath);
> + DevicePath = GopDevicePath;
> +
> + EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
> +
> + return EFI_SUCCESS;
> +}
> +
> +/**
> + Add PCI Serial to ConOut, ConIn, ErrOut.
> +
> + @param[in] DeviceHandle Handle of the PCI serial device.
> +
> + @retval EFI_SUCCESS The PCI serial device has been added to ConOut,
> ConIn,
> + ErrOut.
> +
> + @return Error codes, due to EFI_DEVICE_PATH_PROTOCOL missing
> + from DeviceHandle.
> +**/
> +EFI_STATUS
> +PreparePciSerialDevicePath (
> + IN EFI_HANDLE DeviceHandle
> + )
> +{
> + EFI_STATUS Status;
> + EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> +
> + DevicePath = NULL;
> + Status = gBS->HandleProtocol (
> + DeviceHandle,
> + &gEfiDevicePathProtocolGuid,
> + (VOID*)&DevicePath
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + DevicePath = AppendDevicePathNode (DevicePath,
> (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);
> + DevicePath = AppendDevicePathNode (DevicePath,
> (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);
> +
> + EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
> + EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);
> + EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);
> +
> + return EFI_SUCCESS;
> +}
> +
> +EFI_STATUS
> +VisitAllInstancesOfProtocol (
> + IN EFI_GUID *Id,
> + IN PROTOCOL_INSTANCE_CALLBACK CallBackFunction,
> + IN VOID *Context
> + )
> +{
> + EFI_STATUS Status;
> + UINTN HandleCount;
> + EFI_HANDLE *HandleBuffer;
> + UINTN Index;
> + VOID *Instance;
> +
> + //
> + // Start to check all the PciIo to find all possible device
> + //
> + HandleCount = 0;
> + HandleBuffer = NULL;
> + Status = gBS->LocateHandleBuffer (
> + ByProtocol,
> + Id,
> + NULL,
> + &HandleCount,
> + &HandleBuffer
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + for (Index = 0; Index < HandleCount; Index++) {
> + Status = gBS->HandleProtocol (HandleBuffer[Index], Id, &Instance);
> + if (EFI_ERROR (Status)) {
> + continue;
> + }
> +
> + Status = (*CallBackFunction) (
> + HandleBuffer[Index],
> + Instance,
> + Context
> + );
> + }
> +
> + gBS->FreePool (HandleBuffer);
> +
> + return EFI_SUCCESS;
> +}
> +
> +
> +EFI_STATUS
> +EFIAPI
> +VisitingAPciInstance (
> + IN EFI_HANDLE Handle,
> + IN VOID *Instance,
> + IN VOID *Context
> + )
> +{
> + EFI_STATUS Status;
> + EFI_PCI_IO_PROTOCOL *PciIo;
> + PCI_TYPE00 Pci;
> +
> + PciIo = (EFI_PCI_IO_PROTOCOL*) Instance;
> +
> + //
> + // Check for all PCI device
> + //
> + Status = PciIo->Pci.Read (
> + PciIo,
> + EfiPciIoWidthUint32,
> + 0,
> + sizeof (Pci) / sizeof (UINT32),
> + &Pci
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + return (*(VISIT_PCI_INSTANCE_CALLBACK)(UINTN) Context) (
> + Handle,
> + PciIo,
> + &Pci
> + );
> +
> +}
> +
> +
> +
> +EFI_STATUS
> +VisitAllPciInstances (
> + IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction
> + )
> +{
> + return VisitAllInstancesOfProtocol (
> + &gEfiPciIoProtocolGuid,
> + VisitingAPciInstance,
> + (VOID*)(UINTN) CallBackFunction
> + );
> +}
> +
> +
> +/**
> + Do platform specific PCI Device check and add them to
> + ConOut, ConIn, ErrOut.
> +
> + @param[in] Handle - Handle of PCI device instance
> + @param[in] PciIo - PCI IO protocol instance
> + @param[in] Pci - PCI Header register block
> +
> + @retval EFI_SUCCESS - PCI Device check and Console variable update
> + successfully.
> + @retval EFI_STATUS - PCI Device check or Console variable update fail.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +DetectAndPreparePlatformPciDevicePath (
> + IN EFI_HANDLE Handle,
> + IN EFI_PCI_IO_PROTOCOL *PciIo,
> + IN PCI_TYPE00 *Pci
> + )
> +{
> + EFI_STATUS Status;
> +
> + Status = PciIo->Attributes (
> + PciIo,
> + EfiPciIoAttributeOperationEnable,
> + EFI_PCI_DEVICE_ENABLE,
> + NULL
> + );
> + ASSERT_EFI_ERROR (Status);
> +
> + if (!mDetectVgaOnly) {
> + //
> + // Here we decide whether it is LPC Bridge
> + //
> + if ((IS_PCI_LPC (Pci)) ||
> + ((IS_PCI_ISA_PDECODE (Pci)) &&
> + (Pci->Hdr.VendorId == 0x8086) &&
> + (Pci->Hdr.DeviceId == 0x7000)
> + )
> + ) {
> + //
> + // Add IsaKeyboard to ConIn,
> + // add IsaSerial to ConOut, ConIn, ErrOut
> + //
> + DEBUG ((DEBUG_INFO, "Found LPC Bridge device\n"));
> + PrepareLpcBridgeDevicePath (Handle);
> + return EFI_SUCCESS;
> + }
> + //
> + // Here we decide which Serial device to enable in PCI bus
> + //
> + if (IS_PCI_16550SERIAL (Pci)) {
> + //
> + // Add them to ConOut, ConIn, ErrOut.
> + //
> + DEBUG ((DEBUG_INFO, "Found PCI 16550 SERIAL device\n"));
> + PreparePciSerialDevicePath (Handle);
> + return EFI_SUCCESS;
> + }
> + }
> +
> + //
> + // Here we decide which display device to enable in PCI bus
> + //
> + if (IS_PCI_DISPLAY (Pci)) {
> + //
> + // Add them to ConOut.
> + //
> + DEBUG ((DEBUG_INFO, "Found PCI display device\n"));
> + PreparePciDisplayDevicePath (Handle);
> + return EFI_SUCCESS;
> + }
> +
> + return Status;
> +}
> +
> +
> +/**
> + Do platform specific PCI Device check and add them to ConOut, ConIn,
> ErrOut
> +
> + @param[in] DetectVgaOnly - Only detect VGA device if it's TRUE.
> +
> + @retval EFI_SUCCESS - PCI Device check and Console variable update
> successfully.
> + @retval EFI_STATUS - PCI Device check or Console variable update fail.
> +
> +**/
> +EFI_STATUS
> +DetectAndPreparePlatformPciDevicePaths (
> + BOOLEAN DetectVgaOnly
> + )
> +{
> + mDetectVgaOnly = DetectVgaOnly;
> + return VisitAllPciInstances (DetectAndPreparePlatformPciDevicePath);
> +}
> +
> +/**
> + Connect the predefined platform default console device.
> +
> + Always try to find and enable PCI display devices.
> +
> + @param[in] PlatformConsole Predefined platform default console device
> array.
> +**/
> +VOID
> +PlatformInitializeConsole (
> + IN PLATFORM_CONSOLE_CONNECT_ENTRY *PlatformConsole
> + )
> +{
> + UINTN Index;
> + EFI_DEVICE_PATH_PROTOCOL *VarConout;
> + EFI_DEVICE_PATH_PROTOCOL *VarConin;
> +
> + //
> + // Connect RootBridge
> + //
> + GetEfiGlobalVariable2 (EFI_CON_OUT_VARIABLE_NAME, (VOID **)
> &VarConout, NULL);
> + GetEfiGlobalVariable2 (EFI_CON_IN_VARIABLE_NAME, (VOID **)
> &VarConin, NULL);
> +
> + if (VarConout == NULL || VarConin == NULL) {
> + //
> + // Do platform specific PCI Device check and add them to ConOut, ConIn,
> ErrOut
> + //
> + DetectAndPreparePlatformPciDevicePaths (FALSE);
> + DetectAndPreparePlatformPciDevicePaths(TRUE);
> + //
> + // Have chance to connect the platform default console,
> + // the platform default console is the minimue device group
> + // the platform should support
> + //
> + for (Index = 0; PlatformConsole[Index].DevicePath != NULL; ++Index) {
> + //
> + // Update the console variable with the connect type
> + //
> + if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) ==
> CONSOLE_IN) {
> + EfiBootManagerUpdateConsoleVariable (ConIn,
> PlatformConsole[Index].DevicePath, NULL);
> + }
> + if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) ==
> CONSOLE_OUT) {
> + EfiBootManagerUpdateConsoleVariable (ConOut,
> PlatformConsole[Index].DevicePath, NULL);
> + }
> + if ((PlatformConsole[Index].ConnectType & STD_ERROR) ==
> STD_ERROR) {
> + EfiBootManagerUpdateConsoleVariable (ErrOut,
> PlatformConsole[Index].DevicePath, NULL);
> + }
> + }
> + } else {
> + //
> + // Only detect VGA device and add them to ConOut
> + //
> + DetectAndPreparePlatformPciDevicePaths (TRUE);
> + }
> +}
> +
> +
> +/**
> + Configure PCI Interrupt Line register for applicable devices
> + Ported from SeaBIOS, src/fw/pciinit.c, *_pci_slot_get_irq()
> +
> + @param[in] Handle - Handle of PCI device instance
> + @param[in] PciIo - PCI IO protocol instance
> + @param[in] PciHdr - PCI Header register block
> +
> + @retval EFI_SUCCESS - PCI Interrupt Line register configured successfully.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +SetPciIntLine (
> + IN EFI_HANDLE Handle,
> + IN EFI_PCI_IO_PROTOCOL *PciIo,
> + IN PCI_TYPE00 *PciHdr
> + )
> +{
> + EFI_DEVICE_PATH_PROTOCOL *DevPathNode;
> + EFI_DEVICE_PATH_PROTOCOL *DevPath;
> + UINTN RootSlot;
> + UINTN Idx;
> + UINT8 IrqLine;
> + EFI_STATUS Status;
> + UINT32 RootBusNumber;
> +
> + Status = EFI_SUCCESS;
> +
> + if (PciHdr->Device.InterruptPin != 0) {
> +
> + DevPathNode = DevicePathFromHandle (Handle);
> + ASSERT (DevPathNode != NULL);
> + DevPath = DevPathNode;
> +
> + RootBusNumber = 0;
> + if (DevicePathType (DevPathNode) == ACPI_DEVICE_PATH &&
> + DevicePathSubType (DevPathNode) == ACPI_DP &&
> + ((ACPI_HID_DEVICE_PATH *)DevPathNode)->HID ==
> EISA_PNP_ID(0x0A03)) {
> + RootBusNumber = ((ACPI_HID_DEVICE_PATH *)DevPathNode)->UID;
> + }
> +
> + //
> + // Compute index into PciHostIrqs[] table by walking
> + // the device path and adding up all device numbers
> + //
> + Status = EFI_NOT_FOUND;
> + RootSlot = 0;
> + Idx = PciHdr->Device.InterruptPin - 1;
> + while (!IsDevicePathEnd (DevPathNode)) {
> + if (DevicePathType (DevPathNode) == HARDWARE_DEVICE_PATH &&
> + DevicePathSubType (DevPathNode) == HW_PCI_DP) {
> +
> + Idx += ((PCI_DEVICE_PATH *)DevPathNode)->Device;
> +
> + //
> + // Unlike SeaBIOS, which starts climbing from the leaf device
> + // up toward the root, we traverse the device path starting at
> + // the root moving toward the leaf node.
> + // The slot number of the top-level parent bridge is needed
> + // with more than 24 slots on the root bus.
> + //
> + if (Status != EFI_SUCCESS) {
> + Status = EFI_SUCCESS;
> + RootSlot = ((PCI_DEVICE_PATH *)DevPathNode)->Device;
> + }
> + }
> +
> + DevPathNode = NextDevicePathNode (DevPathNode);
> + }
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> + if (RootBusNumber == 0 && RootSlot == 0) {
> + return Status; //bugbug: workaround; need SIMICS change B0/D0/F0
> PCI_IntPin reg(0x3D) = 0X0
> +// DEBUG((
> +// DEBUG_ERROR,
> +// "%a: PCI host bridge (00:00.0) should have no interrupts!\n",
> +// __FUNCTION__
> +// ));
> +// ASSERT (FALSE);
> + }
> +
> + //
> + // Final PciHostIrqs[] index calculation depends on the platform
> + // and should match SeaBIOS src/fw/pciinit.c *_pci_slot_get_irq()
> + //
> + switch (mHostBridgeDevId) {
> + case INTEL_82441_DEVICE_ID:
> + Idx -= 1;
> + break;
> + case INTEL_ICH10_DEVICE_ID:
> + //
> + // SeaBIOS contains the following comment:
> + // "Slots 0-24 rotate slot:pin mapping similar to piix above, but
> + // with a different starting index.
> + //
> + // Slots 25-31 all use LNKA mapping (or LNKE, but A:D = E:H)"
> + //
> + if (RootSlot > 24) {
> + //
> + // in this case, subtract back out RootSlot from Idx
> + // (SeaBIOS never adds it to begin with, but that would make our
> + // device path traversal loop above too awkward)
> + //
> + Idx -= RootSlot;
> + }
> + break;
> + default:
> + ASSERT (FALSE); // should never get here
> + }
> + Idx %= ARRAY_SIZE (PciHostIrqs);
> + IrqLine = PciHostIrqs[Idx];
> +
> + DEBUG_CODE_BEGIN ();
> + {
> + CHAR16 *DevPathString;
> + STATIC CHAR16 Fallback[] = L"<failed to convert>";
> + UINTN Segment, Bus, Device, Function;
> +
> + DevPathString = ConvertDevicePathToText (DevPath, FALSE, FALSE);
> + if (DevPathString == NULL) {
> + DevPathString = Fallback;
> + }
> + Status = PciIo->GetLocation (PciIo, &Segment, &Bus, &Device,
> &Function);
> + ASSERT_EFI_ERROR (Status);
> +
> + DEBUG ((DEBUG_VERBOSE, "%a: [%02x:%02x.%x] %s -> 0x%02x\n",
> __FUNCTION__,
> + (UINT32)Bus, (UINT32)Device, (UINT32)Function, DevPathString,
> + IrqLine));
> +
> + if (DevPathString != Fallback) {
> + FreePool (DevPathString);
> + }
> + }
> + DEBUG_CODE_END ();
> +
> + //
> + // Set PCI Interrupt Line register for this device to PciHostIrqs[Idx]
> + //
> + Status = PciIo->Pci.Write (
> + PciIo,
> + EfiPciIoWidthUint8,
> + PCI_INT_LINE_OFFSET,
> + 1,
> + &IrqLine
> + );
> + }
> +
> + return Status;
> +}
> +
> +/**
> +Write to mask and edge/level triggered registers of master and slave 8259
> PICs.
> +
> +@param[in] Mask low byte for master PIC mask register,
> +high byte for slave PIC mask register.
> +@param[in] EdgeLevel low byte for master PIC edge/level triggered
> register,
> +high byte for slave PIC edge/level triggered register.
> +
> +**/
> +VOID
> +Interrupt8259WriteMask(
> + IN UINT16 Mask,
> + IN UINT16 EdgeLevel
> +)
> +{
> + IoWrite8(LEGACY_8259_MASK_REGISTER_MASTER, (UINT8)Mask);
> + IoWrite8(LEGACY_8259_MASK_REGISTER_SLAVE, (UINT8)(Mask >> 8));
> + IoWrite8(LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_MASTER,
> (UINT8)EdgeLevel);
> + IoWrite8(LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_SLAVE,
> (UINT8)(EdgeLevel >> 8));
> +}
> +
> +VOID
> +PciAcpiInitialization (
> + VOID
> + )
> +{
> + UINTN Pmba;
> +
> + //
> + // Query Host Bridge DID to determine platform type
> + //
> + mHostBridgeDevId = PcdGet16 (PcdSimicsX58HostBridgePciDevId);
> + switch (mHostBridgeDevId) {
> + case INTEL_82441_DEVICE_ID:
> + Pmba = POWER_MGMT_REGISTER_PIIX4 (PIIX4_PMBA);
> + //
> + // 00:01.0 ISA Bridge (PIIX4) LNK routing targets
> + //
> + PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x60), 0x0b); // A
> + PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x61), 0x0b); // B
> + PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x62), 0x0a); // C
> + PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x63), 0x0a); // D
> + break;
> + case INTEL_ICH10_DEVICE_ID:
> + Pmba = POWER_MGMT_REGISTER_ICH10 (ICH10_PMBASE);
> + //
> + // 00:1f.0 LPC Bridge LNK routing targets
> + //
> + PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x60), 0x0a); // A
> + PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x61), 0x0a); // B
> + PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x62), 0x0b); // C
> + PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x63), 0x0b); // D
> + PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x68), 0x0a); // E
> + PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x69), 0x0a); // F
> + PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x6a), 0x0b); // G
> + PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x6b), 0x0b); // H
> + break;
> + default:
> + DEBUG ((DEBUG_ERROR, "%a: Unknown Host Bridge Device ID:
> 0x%04x\n",
> + __FUNCTION__, mHostBridgeDevId));
> + ASSERT (FALSE);
> + return;
> + }
> +
> + //
> + // Initialize PCI_INTERRUPT_LINE for applicable present PCI devices
> + //
> + VisitAllPciInstances (SetPciIntLine);
> +
> + //
> + // Set ACPI SCI_EN bit in PMCNTRL
> + //
> + IoOr16 ((PciRead32 (Pmba) & ~BIT0) + 4, BIT0);
> + //
> + // Set all 8259 interrupts to edge triggered and disabled
> + //
> + Interrupt8259WriteMask(0xFFFF, 0x0000);
> +}
> +
> +EFI_STATUS
> +EFIAPI
> +ConnectRecursivelyIfPciMassStorage (
> + IN EFI_HANDLE Handle,
> + IN EFI_PCI_IO_PROTOCOL *Instance,
> + IN PCI_TYPE00 *PciHeader
> + )
> +{
> + EFI_STATUS Status;
> + EFI_DEVICE_PATH_PROTOCOL *DevicePath;
> + CHAR16 *DevPathStr;
> +
> + //
> + // Recognize PCI Mass Storage
> + //
> + if (IS_CLASS1 (PciHeader, PCI_CLASS_MASS_STORAGE)) {
> + DevicePath = NULL;
> + Status = gBS->HandleProtocol (
> + Handle,
> + &gEfiDevicePathProtocolGuid,
> + (VOID*)&DevicePath
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + //
> + // Print Device Path
> + //
> + DevPathStr = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
> + if (DevPathStr != NULL) {
> + DEBUG(( DEBUG_INFO, "Found Mass Storage device: %s\n",
> DevPathStr));
> + FreePool(DevPathStr);
> + }
> +
> + Status = gBS->ConnectController (Handle, NULL, NULL, TRUE);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + }
> +
> + return EFI_SUCCESS;
> +}
> +
> +
> +/**
> + This notification function is invoked when the
> + EMU Variable FVB has been changed.
> +
> + @param Event The event that occurred
> + @param Context For EFI compatibility. Not used.
> +
> +**/
> +VOID
> +EFIAPI
> +EmuVariablesUpdatedCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + )
> +{
> + DEBUG ((DEBUG_INFO, "%a called\n", __FUNCTION__));
> + UpdateNvVarsOnFileSystem ();
> +}
> +
> +
> +EFI_STATUS
> +EFIAPI
> +VisitingFileSystemInstance (
> + IN EFI_HANDLE Handle,
> + IN VOID *Instance,
> + IN VOID *Context
> + )
> +{
> + EFI_STATUS Status;
> + STATIC BOOLEAN ConnectedToFileSystem = FALSE;
> +
> + if (ConnectedToFileSystem) {
> + return EFI_ALREADY_STARTED;
> + }
> +
> + Status = ConnectNvVarsToFileSystem (Handle);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + ConnectedToFileSystem = TRUE;
> + mEmuVariableEvent =
> + EfiCreateProtocolNotifyEvent (
> + &gEfiDevicePathProtocolGuid,
> + TPL_CALLBACK,
> + EmuVariablesUpdatedCallback,
> + NULL,
> + &mEmuVariableEventReg
> + );
> + PcdSet64 (PcdEmuVariableEvent, (UINT64)(UINTN) mEmuVariableEvent);
> +
> + return EFI_SUCCESS;
> +}
> +
> +
> +VOID
> +PlatformBdsRestoreNvVarsFromHardDisk (
> + )
> +{
> + VisitAllPciInstances (ConnectRecursivelyIfPciMassStorage);
> + VisitAllInstancesOfProtocol (
> + &gEfiSimpleFileSystemProtocolGuid,
> + VisitingFileSystemInstance,
> + NULL
> + );
> +}
> +
> +/**
> + Connect with predefined platform connect sequence.
> +
> + The OEM/IBV can customize with their own connect sequence.
> +**/
> +VOID
> +PlatformBdsConnectSequence (
> + VOID
> + )
> +{
> + UINTN Index;
> +
> + DEBUG ((DEBUG_INFO, "%a called\n", __FUNCTION__));
> +
> + Index = 0;
> +
> + //
> + // Here we can get the customized platform connect sequence
> + // Notes: we can connect with new variable which record the
> + // last time boots connect device path sequence
> + //
> + while (gPlatformConnectSequence[Index] != NULL) {
> + //
> + // Build the platform boot option
> + //
> + EfiBootManagerConnectDevicePath (gPlatformConnectSequence[Index],
> NULL);
> + Index++;
> + }
> +
> + //
> + // Just use the simple policy to connect all devices
> + //
> + DEBUG ((DEBUG_INFO, "EfiBootManagerConnectAll\n"));
> + EfiBootManagerConnectAll ();
> +
> + PciAcpiInitialization ();
> +}
> +
> +/**
> + Do the platform specific action after the console is ready
> +
> + Possible things that can be done in PlatformBootManagerAfterConsole:
> +
> + > Console post action:
> + > Dynamically switch output mode from 100x31 to 80x25 for certain
> senarino
> + > Signal console ready platform customized event
> + > Run diagnostics like memory testing
> + > Connect certain devices
> + > Dispatch aditional option roms
> + > Special boot: e.g.: USB boot, enter UI
> +**/
> +// VOID
> +// EFIAPI
> +// PlatformBootManagerAfterConsole (
> +// VOID
> +// )
> +// {
> +
> +// }
> +
> +/**
> + This notification function is invoked when an instance of the
> + EFI_DEVICE_PATH_PROTOCOL is produced.
> +
> + @param Event The event that occurred
> + @param Context For EFI compatibility. Not used.
> +
> +**/
> +VOID
> +EFIAPI
> +NotifyDevPath (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + )
> +{
> + EFI_HANDLE Handle;
> + EFI_STATUS Status;
> + UINTN BufferSize;
> + EFI_DEVICE_PATH_PROTOCOL *DevPathNode;
> + ATAPI_DEVICE_PATH *Atapi;
> +
> + //
> + // Examine all new handles
> + //
> + for (;;) {
> + //
> + // Get the next handle
> + //
> + BufferSize = sizeof (Handle);
> + Status = gBS->LocateHandle (
> + ByRegisterNotify,
> + NULL,
> + mEfiDevPathNotifyReg,
> + &BufferSize,
> + &Handle
> + );
> +
> + //
> + // If not found, we're done
> + //
> + if (EFI_NOT_FOUND == Status) {
> + break;
> + }
> +
> + if (EFI_ERROR (Status)) {
> + continue;
> + }
> +
> + //
> + // Get the DevicePath protocol on that handle
> + //
> + Status = gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid,
> (VOID **)&DevPathNode);
> + ASSERT_EFI_ERROR (Status);
> +
> + while (!IsDevicePathEnd (DevPathNode)) {
> + //
> + // Find the handler to dump this device path node
> + //
> + if (
> + (DevicePathType(DevPathNode) == MESSAGING_DEVICE_PATH) &&
> + (DevicePathSubType(DevPathNode) == MSG_ATAPI_DP)
> + ) {
> + Atapi = (ATAPI_DEVICE_PATH*) DevPathNode;
> + PciOr16 (
> + PCI_LIB_ADDRESS (
> + 0,
> + 1,
> + 1,
> + (Atapi->PrimarySecondary == 1) ? 0x42: 0x40
> + ),
> + BIT15
> + );
> + }
> +
> + //
> + // Next device path node
> + //
> + DevPathNode = NextDevicePathNode (DevPathNode);
> + }
> + }
> +
> + return;
> +}
> +
> +
> +VOID
> +InstallDevicePathCallback (
> + VOID
> + )
> +{
> + DEBUG ((DEBUG_INFO, "Registered NotifyDevPath Event\n"));
> + mEfiDevPathEvent = EfiCreateProtocolNotifyEvent (
> + &gEfiDevicePathProtocolGuid,
> + TPL_CALLBACK,
> + NotifyDevPath,
> + NULL,
> + &mEfiDevPathNotifyReg
> + );
> +}
> +
> +
> +
> +/**
> + ReadyToBoot callback to set video and text mode for internal shell boot.
> + That will not connect USB controller while CSM and FastBoot are disabled,
> we need to connect them
> + before booting to Shell for showing USB devices in Shell.
> +
> + When FastBoot is enabled and Windows Console is the chosen Console
> behavior, input devices will not be connected
> + by default. Hence, when booting to EFI shell, connecting input consoles are
> required.
> +
> + @param Event Pointer to this event
> + @param Context Event hanlder private data
> +
> + @retval None.
> +**/
> +VOID
> +EFIAPI
> +BdsReadyToBootCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + )
> +{
> + DEBUG ((DEBUG_INFO, "%a called\n", __FUNCTION__));
> +}
> +
> +
> +/**
> + This is the callback function for PCI ENUMERATION COMPLETE.
> +
> + @param[in] Event The Event this notify function registered to.
> + @param[in] Context Pointer to the context data registered to the Event.
> +**/
> +VOID
> +EFIAPI
> +BdsSmmReadyToLockCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + )
> +{
> +
> + VOID *ProtocolPointer;
> + EFI_STATUS Status;
> +
> + //
> + // Check if this is first time called by EfiCreateProtocolNotifyEvent() or not,
> + // if it is, we will skip it until real event is triggered
> + //
> + Status = gBS->LocateProtocol (&gEfiDxeSmmReadyToLockProtocolGuid,
> NULL, (VOID **) &ProtocolPointer);
> + if (EFI_SUCCESS != Status) {
> + return;
> + }
> +
> + DEBUG ((DEBUG_INFO, "%a called\n", __FUNCTION__));
> +
> + //
> + // Dispatch the deferred 3rd party images.
> + //
> + EfiBootManagerDispatchDeferredImages ();
> +
> + //
> + // For non-trusted console it must be handled here.
> + //
> + //UpdateGraphicConOut (FALSE);
> +}
> +
> +
> +/**
> + This is the callback function for PCI ENUMERATION COMPLETE.
> +
> + @param[in] Event The Event this notify function registered to.
> + @param[in] Context Pointer to the context data registered to the Event.
> +**/
> +VOID
> +EFIAPI
> +BdsPciEnumCompleteCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + )
> +{
> + VOID *ProtocolPointer;
> + EFI_STATUS Status;
> + PLATFORM_CONSOLE_CONNECT_ENTRY PlatformConsole[3];
> + UINTN PlatformConsoleCount;
> + UINTN MaxCount;
> + //
> + // Check if this is first time called by EfiCreateProtocolNotifyEvent() or not,
> + // if it is, we will skip it until real event is triggered
> + //
> + Status = gBS->LocateProtocol
> (&gEfiPciEnumerationCompleteProtocolGuid, NULL, (VOID **)
> &ProtocolPointer);
> + if (EFI_SUCCESS != Status) {
> + return;
> + }
> +
> + PlatformConsoleCount = 0;
> + MaxCount = ARRAY_SIZE(PlatformConsole);
> +
> + if (PcdGetSize (PcdTrustedConsoleOutputDevicePath) >=
> sizeof(EFI_DEVICE_PATH_PROTOCOL)) {
> + PlatformConsole[PlatformConsoleCount].ConnectType = ConOut;
> + PlatformConsole[PlatformConsoleCount].DevicePath = PcdGetPtr
> (PcdTrustedConsoleOutputDevicePath);
> + PlatformConsoleCount++;
> + }
> + if (PcdGetSize (PcdTrustedConsoleInputDevicePath) >=
> sizeof(EFI_DEVICE_PATH_PROTOCOL) &&
> + PlatformConsoleCount < MaxCount) {
> + PlatformConsole[PlatformConsoleCount].ConnectType = ConIn;
> + PlatformConsole[PlatformConsoleCount].DevicePath = PcdGetPtr
> (PcdTrustedConsoleInputDevicePath);
> + PlatformConsoleCount++;
> + }
> +
> + if (PlatformConsoleCount < MaxCount){
> + PlatformConsole[PlatformConsoleCount].ConnectType = 0;
> + PlatformConsole[PlatformConsoleCount].DevicePath = NULL;
> + }else{
> + PlatformConsole[MaxCount - 1].ConnectType = 0;
> + PlatformConsole[MaxCount - 1].DevicePath = NULL;
> + }
> +
> + DEBUG ((DEBUG_INFO, "%a called\n", __FUNCTION__));
> +
> + PlatformInitializeConsole (PlatformConsole);
> +}
> +
> +
> +/**
> + Before console after trusted console event callback
> +
> + @param[in] Event The Event this notify function registered to.
> + @param[in] Context Pointer to the context data registered to the Event.
> +**/
> +VOID
> +EFIAPI
> +BdsBeforeConsoleAfterTrustedConsoleCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + )
> +{
> + EFI_BOOT_MANAGER_LOAD_OPTION *NvBootOptions;
> + UINTN NvBootOptionCount;
> + UINTN Index;
> + EFI_STATUS Status;
> +
> + DEBUG ((DEBUG_INFO, "%a called\n", __FUNCTION__));
> +
> + NvBootOptions = EfiBootManagerGetLoadOptions (&NvBootOptionCount,
> LoadOptionTypeBoot);
> + for (Index = 0; Index < NvBootOptionCount; Index++) {
> + Status = EfiBootManagerDeleteLoadOptionVariable
> (NvBootOptions[Index].OptionNumber, LoadOptionTypeBoot);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((
> + DEBUG_ERROR,
> + "%a: removing Boot#%04x %r\n",
> + __FUNCTION__,
> + (UINT32) NvBootOptions[Index].OptionNumber,
> + Status
> + ));
> + }
> + }
> +
> + InstallDevicePathCallback ();
> +
> + VisitAllInstancesOfProtocol (&gEfiPciRootBridgeIoProtocolGuid,
> ConnectRootBridge, NULL);
> + //
> + // Enable LPC
> + //
> + PciOr16 (POWER_MGMT_REGISTER_ICH10(0x04), BIT0 | BIT1 | BIT2);
> +
> + PlatformRegisterOptionsAndKeys ();
> +}
> +
> +
> +/**
> + Before console before end of DXE event callback
> +
> + @param[in] Event The Event this notify function registered to.
> + @param[in] Context Pointer to the context data registered to the Event.
> +**/
> +VOID
> +EFIAPI
> +BdsBeforeConsoleBeforeEndOfDxeGuidCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> +){
> + DEBUG ((DEBUG_INFO, "%a called\n", __FUNCTION__));
> +}
> +
> +/**
> + After console ready before boot option event callback
> +
> + @param[in] Event The Event this notify function registered to.
> + @param[in] Context Pointer to the context data registered to the Event.
> +**/
> +VOID
> +EFIAPI
> +BdsAfterConsoleReadyBeforeBootOptionCallback (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + )
> +{
> + EFI_BOOT_MODE BootMode;
> +
> + DEBUG ((DEBUG_INFO, "%a called\n", __FUNCTION__));
> +
> + if (PcdGetBool (PcdOvmfFlashVariablesEnable)) {
> + DEBUG ((DEBUG_INFO, "PlatformBdsPolicyBehavior: not restoring NvVars
> "
> + "from disk since flash variables appear to be supported.\n"));
> + } else {
> + //
> + // Try to restore variables from the hard disk early so
> + // they can be used for the other BDS connect operations.
> + //
> + PlatformBdsRestoreNvVarsFromHardDisk ();
> + }
> +
> + //
> + // Get current Boot Mode
> + //
> + BootMode = GetBootModeHob ();
> + DEBUG ((DEBUG_ERROR, "Boot Mode:%x\n", BootMode));
> +
> + //
> + // Go the different platform policy with different boot mode
> + // Notes: this part code can be change with the table policy
> + //
> + ASSERT (BootMode == BOOT_WITH_FULL_CONFIGURATION);
> +
> + //
> + // Perform some platform specific connect sequence
> + //
> + PlatformBdsConnectSequence ();
> +
> + //
> + // Logo show
> + //
> + EnableBootLogo(PcdGetPtr(PcdLogoFile));
> +
> + EfiBootManagerRefreshAllBootOption ();
> +
> + //
> + // Register UEFI Shell
> + //
> + PlatformRegisterFvBootOption (
> + PcdGetPtr (PcdShellFile), L"EFI Internal Shell", LOAD_OPTION_ACTIVE
> + );
> +
> + RemoveStaleFvFileOptions ();
> +}
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsH
> ookLib.inf
> b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsH
> ookLib.inf
> new file mode 100644
> index 0000000000..a77edf2699
> --- /dev/null
> +++
> b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsH
> ookLib.inf
> @@ -0,0 +1,81 @@
> +## @file
> +# Board BDS hook Library definition file.
> +#
> +# Copyright (c) 2019 Intel Corporation. All rights reserved. <BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + INF_VERSION = 0x00010005
> + BASE_NAME = BoardBdsHookLib
> + FILE_GUID = 285AB0B8-D0D2-4D83-BF20-F85ED040383E
> + MODULE_TYPE = DXE_DRIVER
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = BoardBdsHookLib|DXE_DRIVER
> +
> +#
> +# The following information is for reference only and not required by the
> build tools.
> +#
> +# VALID_ARCHITECTURES = IA32 X64 EBC
> +#
> +
> +[Sources]
> + BoardBdsHookLib.c
> + BoardBdsHook.h
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + MinPlatformPkg/MinPlatformPkg.dec
> + BoardModulePkg/BoardModulePkg.dec
> + SimicsOpenBoardPkg/OpenBoardPkg.dec
> + OvmfPkg/OvmfPkg.dec
> + SimicsIch10Pkg/Ich10Pkg.dec
> +
> +[LibraryClasses]
> + BaseLib
> + MemoryAllocationLib
> + UefiBootServicesTableLib
> + BaseMemoryLib
> + DebugLib
> + PcdLib
> + UefiBootManagerLib
> + BootLogoLib
> + DevicePathLib
> + PciLib
> + NvVarsFileLib
> + DxeLoadLinuxLib
> + UefiLib
> + LogoLib
> +
> +[Pcd]
> + gSimicsOpenBoardPkgTokenSpaceGuid.PcdEmuVariableEvent
> + gSimicsOpenBoardPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable
> + gSimicsOpenBoardPkgTokenSpaceGuid.PcdSimicsX58HostBridgePciDevId
> + gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
> + gSimicsOpenBoardPkgTokenSpaceGuid.PcdShellFile
> + gSimicsOpenBoardPkgTokenSpaceGuid.PcdLogoFile
> + gMinPlatformPkgTokenSpaceGuid.PcdTrustedConsoleInputDevicePath ##
> CONSUMES
> + gMinPlatformPkgTokenSpaceGuid.PcdTrustedConsoleOutputDevicePath
> ## CONSUMES
> + gMinPlatformPkgTokenSpaceGuid.PcdTrustedStorageDevicePath ##
> CONSUMES
> +
> +[Pcd.IA32, Pcd.X64]
> + gEfiMdePkgTokenSpaceGuid.PcdFSBClock
> +
> +[Protocols]
> + gEfiDecompressProtocolGuid
> + gEfiPciRootBridgeIoProtocolGuid
> + gEfiS3SaveStateProtocolGuid # PROTOCOL
> SOMETIMES_CONSUMED
> + gEfiDxeSmmReadyToLockProtocolGuid # PROTOCOL
> SOMETIMES_PRODUCED
> + gEfiLoadedImageProtocolGuid # PROTOCOL
> SOMETIMES_PRODUCED
> + gEfiFirmwareVolume2ProtocolGuid # PROTOCOL
> SOMETIMES_CONSUMED
> + gEfiPciEnumerationCompleteProtocolGuid # PROTOCOL
> SOMETIMES_CONSUMED
> +
> +
> +[Guids]
> + gEfiEndOfDxeEventGroupGuid
> +
> +[Depex]
> + TRUE
> --
> 2.19.1.windows.1
^ permalink raw reply [flat|nested] 45+ messages in thread
* [edk2-platforms] [PATCH 10/11] SimicsOpenBoardPkg: Add BDS Board Boot Manager library
2019-12-14 1:32 [edk2-platforms] [PATCH 00/11] Add BDS Hook Points Agyeman, Prince
` (8 preceding siblings ...)
2019-12-14 1:32 ` [edk2-platforms] [PATCH 09/11] SimicsOpenBoardPkg: Add Bds Hook Library Agyeman, Prince
@ 2019-12-14 1:32 ` Agyeman, Prince
2019-12-18 1:35 ` Nate DeSimone
2019-12-21 2:37 ` Kubacki, Michael A
2019-12-14 1:32 ` [edk2-platforms] [PATCH 11/11] SimicsOpenBoardPkg: Add Bds Hook Points Agyeman, Prince
2020-04-21 20:37 ` [edk2-devel] [edk2-platforms] [PATCH 00/11] Add BDS " Nate DeSimone
11 siblings, 2 replies; 45+ messages in thread
From: Agyeman, Prince @ 2019-12-14 1:32 UTC (permalink / raw)
To: devel; +Cc: Nate DeSimone, Michael Kubacki
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
This library implements PlatformBootManagerWaitCallback
and PlatformBootManagerUnableToBoot which can be linked Minplatform's
PlatformBootManager libary instance.
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Michael Kubacki <michael.a.kubacki@intel.com>
Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
---
.../BoardBootManagerLib/BoardBootManager.c | 67 +++++++++++++++++++
.../BoardBootManagerLib.inf | 45 +++++++++++++
2 files changed, 112 insertions(+)
create mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/BoardBootManagerLib/BoardBootManager.c
create mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/BoardBootManagerLib/BoardBootManagerLib.inf
diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBootManagerLib/BoardBootManager.c b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBootManagerLib/BoardBootManager.c
new file mode 100644
index 0000000000..58035f2766
--- /dev/null
+++ b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBootManagerLib/BoardBootManager.c
@@ -0,0 +1,67 @@
+/** @file
+ The Board Boot Manager Library implements BoardBootManagerWaitCallback
+ and BoardBootManagerUnableToBoot callback, which is linked to the
+ Platform Boot Manager Library
+
+ Copyright (c) 2019 Intel Corporation. All rights reserved. <BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <Library/DebugLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/PlatformBootManagerLib.h>
+#include <Library/UefiLib.h>
+#include <Library/HobLib.h>
+#include <Library/PcdLib.h>
+#include <Library/PrintLib.h>
+#include <Library/PerformanceLib.h>
+#include <Library/BootLogoLib.h>
+#include <Library/BoardBootManagerLib.h>
+
+/**
+ This function is called each second during the boot manager waits the
+ timeout.
+
+ @param TimeoutRemain The remaining timeout.
+**/
+VOID
+EFIAPI
+BoardBootManagerWaitCallback (
+ UINT16 TimeoutRemain
+ )
+{
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White;
+ UINT16 Timeout;
+
+ Timeout = PcdGet16 (PcdPlatformBootTimeOut);
+
+ Black.Raw = 0x00000000;
+ White.Raw = 0x00FFFFFF;
+
+ BootLogoUpdateProgress (
+ White.Pixel,
+ Black.Pixel,
+ L"Start boot option",
+ White.Pixel,
+ (Timeout - TimeoutRemain) * 100 / Timeout,
+ 0
+ );
+}
+
+/**
+ The function is called when no boot option could be launched,
+ including platform recovery options and options pointing to applications
+ built into firmware volumes.
+
+ If this function returns, BDS attempts to enter an infinite loop.
+**/
+VOID
+EFIAPI
+BoardBootManagerUnableToBoot (
+ VOID
+ )
+{
+
+}
diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBootManagerLib/BoardBootManagerLib.inf b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBootManagerLib/BoardBootManagerLib.inf
new file mode 100644
index 0000000000..20778981bc
--- /dev/null
+++ b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBootManagerLib/BoardBootManagerLib.inf
@@ -0,0 +1,45 @@
+## @file
+# Definition file for the Board Boot Manager Library.
+#
+# Copyright (c) 2019 Intel Corporation. All rights reserved. <BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = BoardBootManagerLib
+ FILE_GUID = EBBB176A-3883-4BA4-A74D-1510D0C35B37
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = BoardBootManagerLib|DXE_DRIVER
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 EBC
+#
+
+[Sources]
+ BoardBootManager.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ MinPlatformPkg/MinPlatformPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ UefiBootServicesTableLib
+ DebugLib
+ UefiLib
+ HobLib
+ UefiBootManagerLib
+ TimerLib
+ BoardBootManagerLib
+ BootLogoLib
+ PcdLib
+
+[Pcd]
+ gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
--
2.19.1.windows.1
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Re: [edk2-platforms] [PATCH 10/11] SimicsOpenBoardPkg: Add BDS Board Boot Manager library
2019-12-14 1:32 ` [edk2-platforms] [PATCH 10/11] SimicsOpenBoardPkg: Add BDS Board Boot Manager library Agyeman, Prince
@ 2019-12-18 1:35 ` Nate DeSimone
2019-12-21 2:37 ` Kubacki, Michael A
1 sibling, 0 replies; 45+ messages in thread
From: Nate DeSimone @ 2019-12-18 1:35 UTC (permalink / raw)
To: Agyeman, Prince; +Cc: devel@edk2.groups.io, Kubacki, Michael A
Hi Prince,
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
Thanks,
Nate
On Sat, Dec 14, 2019 at 01:32:36AM +0000, Agyeman, Prince wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
>
> This library implements PlatformBootManagerWaitCallback
> and PlatformBootManagerUnableToBoot which can be linked Minplatform's
> PlatformBootManager libary instance.
>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
>
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
> .../BoardBootManagerLib/BoardBootManager.c | 67 +++++++++++++++++++
> .../BoardBootManagerLib.inf | 45 +++++++++++++
> 2 files changed, 112 insertions(+)
> create mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/BoardBootManagerLib/BoardBootManager.c
> create mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/BoardBootManagerLib/BoardBootManagerLib.inf
>
> diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBootManagerLib/BoardBootManager.c b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBootManagerLib/BoardBootManager.c
> new file mode 100644
> index 0000000000..58035f2766
> --- /dev/null
> +++ b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBootManagerLib/BoardBootManager.c
> @@ -0,0 +1,67 @@
> +/** @file
> + The Board Boot Manager Library implements BoardBootManagerWaitCallback
> + and BoardBootManagerUnableToBoot callback, which is linked to the
> + Platform Boot Manager Library
> +
> + Copyright (c) 2019 Intel Corporation. All rights reserved. <BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +**/
> +
> +#include <Library/DebugLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/PlatformBootManagerLib.h>
> +#include <Library/UefiLib.h>
> +#include <Library/HobLib.h>
> +#include <Library/PcdLib.h>
> +#include <Library/PrintLib.h>
> +#include <Library/PerformanceLib.h>
> +#include <Library/BootLogoLib.h>
> +#include <Library/BoardBootManagerLib.h>
> +
> +/**
> + This function is called each second during the boot manager waits the
> + timeout.
> +
> + @param TimeoutRemain The remaining timeout.
> +**/
> +VOID
> +EFIAPI
> +BoardBootManagerWaitCallback (
> + UINT16 TimeoutRemain
> + )
> +{
> + EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black;
> + EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White;
> + UINT16 Timeout;
> +
> + Timeout = PcdGet16 (PcdPlatformBootTimeOut);
> +
> + Black.Raw = 0x00000000;
> + White.Raw = 0x00FFFFFF;
> +
> + BootLogoUpdateProgress (
> + White.Pixel,
> + Black.Pixel,
> + L"Start boot option",
> + White.Pixel,
> + (Timeout - TimeoutRemain) * 100 / Timeout,
> + 0
> + );
> +}
> +
> +/**
> + The function is called when no boot option could be launched,
> + including platform recovery options and options pointing to applications
> + built into firmware volumes.
> +
> + If this function returns, BDS attempts to enter an infinite loop.
> +**/
> +VOID
> +EFIAPI
> +BoardBootManagerUnableToBoot (
> + VOID
> + )
> +{
> +
> +}
> diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBootManagerLib/BoardBootManagerLib.inf b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBootManagerLib/BoardBootManagerLib.inf
> new file mode 100644
> index 0000000000..20778981bc
> --- /dev/null
> +++ b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBootManagerLib/BoardBootManagerLib.inf
> @@ -0,0 +1,45 @@
> +## @file
> +# Definition file for the Board Boot Manager Library.
> +#
> +# Copyright (c) 2019 Intel Corporation. All rights reserved. <BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + INF_VERSION = 0x00010005
> + BASE_NAME = BoardBootManagerLib
> + FILE_GUID = EBBB176A-3883-4BA4-A74D-1510D0C35B37
> + MODULE_TYPE = DXE_DRIVER
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = BoardBootManagerLib|DXE_DRIVER
> +
> +#
> +# The following information is for reference only and not required by the build tools.
> +#
> +# VALID_ARCHITECTURES = IA32 X64 EBC
> +#
> +
> +[Sources]
> + BoardBootManager.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + MinPlatformPkg/MinPlatformPkg.dec
> +
> +[LibraryClasses]
> + BaseLib
> + UefiBootServicesTableLib
> + DebugLib
> + UefiLib
> + HobLib
> + UefiBootManagerLib
> + TimerLib
> + BoardBootManagerLib
> + BootLogoLib
> + PcdLib
> +
> +[Pcd]
> + gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
> --
> 2.19.1.windows.1
>
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [edk2-platforms] [PATCH 10/11] SimicsOpenBoardPkg: Add BDS Board Boot Manager library
2019-12-14 1:32 ` [edk2-platforms] [PATCH 10/11] SimicsOpenBoardPkg: Add BDS Board Boot Manager library Agyeman, Prince
2019-12-18 1:35 ` Nate DeSimone
@ 2019-12-21 2:37 ` Kubacki, Michael A
1 sibling, 0 replies; 45+ messages in thread
From: Kubacki, Michael A @ 2019-12-21 2:37 UTC (permalink / raw)
To: Agyeman, Prince, devel@edk2.groups.io; +Cc: Desimone, Nathaniel L
Reviewed-by: Michael Kubacki <michael.a.kubacki@intel.com>
> -----Original Message-----
> From: Agyeman, Prince <prince.agyeman@intel.com>
> Sent: Friday, December 13, 2019 5:33 PM
> To: devel@edk2.groups.io
> Cc: Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Kubacki,
> Michael A <michael.a.kubacki@intel.com>
> Subject: [edk2-platforms] [PATCH 10/11] SimicsOpenBoardPkg: Add BDS
> Board Boot Manager library
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
>
> This library implements PlatformBootManagerWaitCallback and
> PlatformBootManagerUnableToBoot which can be linked Minplatform's
> PlatformBootManager libary instance.
>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
>
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
> .../BoardBootManagerLib/BoardBootManager.c | 67
> +++++++++++++++++++
> .../BoardBootManagerLib.inf | 45 +++++++++++++
> 2 files changed, 112 insertions(+)
> create mode 100644
> Platform/Intel/SimicsOpenBoardPkg/Library/BoardBootManagerLib/BoardBo
> otManager.c
> create mode 100644
> Platform/Intel/SimicsOpenBoardPkg/Library/BoardBootManagerLib/BoardBo
> otManagerLib.inf
>
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBootManagerLib/Board
> BootManager.c
> b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBootManagerLib/Board
> BootManager.c
> new file mode 100644
> index 0000000000..58035f2766
> --- /dev/null
> +++
> b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBootManagerLib/Boar
> +++ dBootManager.c
> @@ -0,0 +1,67 @@
> +/** @file
> + The Board Boot Manager Library implements
> +BoardBootManagerWaitCallback
> + and BoardBootManagerUnableToBoot callback, which is linked to the
> + Platform Boot Manager Library
> +
> + Copyright (c) 2019 Intel Corporation. All rights reserved. <BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent **/
> +
> +#include <Library/DebugLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/PlatformBootManagerLib.h>
> +#include <Library/UefiLib.h>
> +#include <Library/HobLib.h>
> +#include <Library/PcdLib.h>
> +#include <Library/PrintLib.h>
> +#include <Library/PerformanceLib.h>
> +#include <Library/BootLogoLib.h>
> +#include <Library/BoardBootManagerLib.h>
> +
> +/**
> + This function is called each second during the boot manager waits the
> + timeout.
> +
> + @param TimeoutRemain The remaining timeout.
> +**/
> +VOID
> +EFIAPI
> +BoardBootManagerWaitCallback (
> + UINT16 TimeoutRemain
> + )
> +{
> + EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black;
> + EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White;
> + UINT16 Timeout;
> +
> + Timeout = PcdGet16 (PcdPlatformBootTimeOut);
> +
> + Black.Raw = 0x00000000;
> + White.Raw = 0x00FFFFFF;
> +
> + BootLogoUpdateProgress (
> + White.Pixel,
> + Black.Pixel,
> + L"Start boot option",
> + White.Pixel,
> + (Timeout - TimeoutRemain) * 100 / Timeout,
> + 0
> + );
> +}
> +
> +/**
> + The function is called when no boot option could be launched,
> + including platform recovery options and options pointing to
> +applications
> + built into firmware volumes.
> +
> + If this function returns, BDS attempts to enter an infinite loop.
> +**/
> +VOID
> +EFIAPI
> +BoardBootManagerUnableToBoot (
> + VOID
> + )
> +{
> +
> +}
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBootManagerLib/Board
> BootManagerLib.inf
> b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBootManagerLib/Board
> BootManagerLib.inf
> new file mode 100644
> index 0000000000..20778981bc
> --- /dev/null
> +++
> b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBootManagerLib/Boar
> +++ dBootManagerLib.inf
> @@ -0,0 +1,45 @@
> +## @file
> +# Definition file for the Board Boot Manager Library.
> +#
> +# Copyright (c) 2019 Intel Corporation. All rights reserved. <BR> # #
> +SPDX-License-Identifier: BSD-2-Clause-Patent # ##
> +
> +[Defines]
> + INF_VERSION = 0x00010005
> + BASE_NAME = BoardBootManagerLib
> + FILE_GUID = EBBB176A-3883-4BA4-A74D-1510D0C35B37
> + MODULE_TYPE = DXE_DRIVER
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = BoardBootManagerLib|DXE_DRIVER
> +
> +#
> +# The following information is for reference only and not required by the
> build tools.
> +#
> +# VALID_ARCHITECTURES = IA32 X64 EBC
> +#
> +
> +[Sources]
> + BoardBootManager.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + MinPlatformPkg/MinPlatformPkg.dec
> +
> +[LibraryClasses]
> + BaseLib
> + UefiBootServicesTableLib
> + DebugLib
> + UefiLib
> + HobLib
> + UefiBootManagerLib
> + TimerLib
> + BoardBootManagerLib
> + BootLogoLib
> + PcdLib
> +
> +[Pcd]
> + gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
> --
> 2.19.1.windows.1
^ permalink raw reply [flat|nested] 45+ messages in thread
* [edk2-platforms] [PATCH 11/11] SimicsOpenBoardPkg: Add Bds Hook Points
2019-12-14 1:32 [edk2-platforms] [PATCH 00/11] Add BDS Hook Points Agyeman, Prince
` (9 preceding siblings ...)
2019-12-14 1:32 ` [edk2-platforms] [PATCH 10/11] SimicsOpenBoardPkg: Add BDS Board Boot Manager library Agyeman, Prince
@ 2019-12-14 1:32 ` Agyeman, Prince
2019-12-18 1:36 ` Nate DeSimone
2019-12-21 2:37 ` Kubacki, Michael A
2020-04-21 20:37 ` [edk2-devel] [edk2-platforms] [PATCH 00/11] Add BDS " Nate DeSimone
11 siblings, 2 replies; 45+ messages in thread
From: Agyeman, Prince @ 2019-12-14 1:32 UTC (permalink / raw)
To: devel; +Cc: Michael Kubacki, Chasel Chiu, Nate DeSimone
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
Added a DXE driver that registers the minimum platform
BDS hook points, to BoardX58Ich10 board.
These hooks are triggered on the BDS hook events
What was done:
* Included a board specific instance of BoardBdsHookLib
and BoardBootManagerLib
* Included Minplatforms PlatformBootManagerLib instance.
This Library instance signals the Bds event groups
* Included BoardBdsHookDxe to register the callbacks implemented
in BoardBdsHookLib
Cc: Michael Kubacki <michael.a.kubacki@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
---
.../SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc | 10 +++++++++-
.../SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf | 1 +
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
index 7576648d57..350a75a313 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
+++ b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
@@ -146,10 +146,17 @@
SetCacheMtrrLib|$(PLATFORM_PACKAGE)/Library/SetCacheMtrrLib/SetCacheMtrrLib.inf
[LibraryClasses.common.DXE_DRIVER]
+
+ #####################################
+ # Platform Package
+ #####################################
+ PlatformBootManagerLib|$(PLATFORM_PACKAGE)/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLib.inf
+
#######################################
# Board Package
#######################################
- PlatformBootManagerLib|$(BOARD_PKG)/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
+ BoardBdsHookLib|$(BOARD_PKG)/Library/BoardBdsHookLib/BoardBdsHookLib.inf
+ BoardBootManagerLib|$(BOARD_PKG)/Library/BoardBootManagerLib/BoardBootManagerLib.inf
[LibraryClasses.common.DXE_SMM_DRIVER]
#######################################
@@ -294,3 +301,4 @@
$(BOARD_PKG)/SimicsVideoDxe/SimicsVideoDxe.inf
$(BOARD_PKG)/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
+ BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
diff --git a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
index e0a1daddee..99bf607775 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
+++ b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
@@ -213,6 +213,7 @@ INF MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
INF MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceSmm.inf
INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
INF BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
+INF BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
INF MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf
--
2.19.1.windows.1
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Re: [edk2-platforms] [PATCH 11/11] SimicsOpenBoardPkg: Add Bds Hook Points
2019-12-14 1:32 ` [edk2-platforms] [PATCH 11/11] SimicsOpenBoardPkg: Add Bds Hook Points Agyeman, Prince
@ 2019-12-18 1:36 ` Nate DeSimone
2019-12-21 2:37 ` Kubacki, Michael A
1 sibling, 0 replies; 45+ messages in thread
From: Nate DeSimone @ 2019-12-18 1:36 UTC (permalink / raw)
To: Agyeman, Prince; +Cc: devel@edk2.groups.io, Kubacki, Michael A, Chiu, Chasel
Hi Prince,
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
Thanks,
Nate
On Sat, Dec 14, 2019 at 01:32:37AM +0000, Agyeman, Prince wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
>
> Added a DXE driver that registers the minimum platform
> BDS hook points, to BoardX58Ich10 board.
> These hooks are triggered on the BDS hook events
>
> What was done:
>
> * Included a board specific instance of BoardBdsHookLib
> and BoardBootManagerLib
>
> * Included Minplatforms PlatformBootManagerLib instance.
> This Library instance signals the Bds event groups
>
> * Included BoardBdsHookDxe to register the callbacks implemented
> in BoardBdsHookLib
>
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
>
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
> .../SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc | 10 +++++++++-
> .../SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf | 1 +
> 2 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
> index 7576648d57..350a75a313 100644
> --- a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
> +++ b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
> @@ -146,10 +146,17 @@
> SetCacheMtrrLib|$(PLATFORM_PACKAGE)/Library/SetCacheMtrrLib/SetCacheMtrrLib.inf
>
> [LibraryClasses.common.DXE_DRIVER]
> +
> + #####################################
> + # Platform Package
> + #####################################
> + PlatformBootManagerLib|$(PLATFORM_PACKAGE)/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLib.inf
> +
> #######################################
> # Board Package
> #######################################
> - PlatformBootManagerLib|$(BOARD_PKG)/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
> + BoardBdsHookLib|$(BOARD_PKG)/Library/BoardBdsHookLib/BoardBdsHookLib.inf
> + BoardBootManagerLib|$(BOARD_PKG)/Library/BoardBootManagerLib/BoardBootManagerLib.inf
>
> [LibraryClasses.common.DXE_SMM_DRIVER]
> #######################################
> @@ -294,3 +301,4 @@
> $(BOARD_PKG)/SimicsVideoDxe/SimicsVideoDxe.inf
> $(BOARD_PKG)/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
> BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> + BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
> diff --git a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
> index e0a1daddee..99bf607775 100644
> --- a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
> +++ b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
> @@ -213,6 +213,7 @@ INF MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
> INF MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceSmm.inf
> INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
> INF BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> +INF BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
>
> INF MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf
>
> --
> 2.19.1.windows.1
>
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [edk2-platforms] [PATCH 11/11] SimicsOpenBoardPkg: Add Bds Hook Points
2019-12-14 1:32 ` [edk2-platforms] [PATCH 11/11] SimicsOpenBoardPkg: Add Bds Hook Points Agyeman, Prince
2019-12-18 1:36 ` Nate DeSimone
@ 2019-12-21 2:37 ` Kubacki, Michael A
1 sibling, 0 replies; 45+ messages in thread
From: Kubacki, Michael A @ 2019-12-21 2:37 UTC (permalink / raw)
To: Agyeman, Prince, devel@edk2.groups.io; +Cc: Chiu, Chasel, Desimone, Nathaniel L
Reviewed-by: Michael Kubacki <michael.a.kubacki@intel.com>
> -----Original Message-----
> From: Agyeman, Prince <prince.agyeman@intel.com>
> Sent: Friday, December 13, 2019 5:33 PM
> To: devel@edk2.groups.io
> Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Chiu, Chasel
> <chasel.chiu@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>
> Subject: [edk2-platforms] [PATCH 11/11] SimicsOpenBoardPkg: Add Bds
> Hook Points
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
>
> Added a DXE driver that registers the minimum platform BDS hook points, to
> BoardX58Ich10 board.
> These hooks are triggered on the BDS hook events
>
> What was done:
>
> * Included a board specific instance of BoardBdsHookLib and
> BoardBootManagerLib
>
> * Included Minplatforms PlatformBootManagerLib instance.
> This Library instance signals the Bds event groups
>
> * Included BoardBdsHookDxe to register the callbacks implemented in
> BoardBdsHookLib
>
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
>
> Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
> ---
> .../SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc | 10
> +++++++++- .../SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf |
> 1 +
> 2 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
> b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
> index 7576648d57..350a75a313 100644
> ---
> a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
> +++
> b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
> @@ -146,10 +146,17 @@
>
> SetCacheMtrrLib|$(PLATFORM_PACKAGE)/Library/SetCacheMtrrLib/SetCac
> heMtrrLib.inf
>
> [LibraryClasses.common.DXE_DRIVER]
> +
> + #####################################
> + # Platform Package
> + #####################################
> +
> +
> PlatformBootManagerLib|$(PLATFORM_PACKAGE)/Bds/Library/DxePlatfor
> mBoot
> + ManagerLib/DxePlatformBootManagerLib.inf
> +
> #######################################
> # Board Package
> #######################################
> -
> PlatformBootManagerLib|$(BOARD_PKG)/Library/PlatformBootManagerLib/
> PlatformBootManagerLib.inf
> +
> +
> BoardBdsHookLib|$(BOARD_PKG)/Library/BoardBdsHookLib/BoardBdsHook
> Lib.i
> + nf
> +
> BoardBootManagerLib|$(BOARD_PKG)/Library/BoardBootManagerLib/Boar
> dBoot
> + ManagerLib.inf
>
> [LibraryClasses.common.DXE_SMM_DRIVER]
> #######################################
> @@ -294,3 +301,4 @@
> $(BOARD_PKG)/SimicsVideoDxe/SimicsVideoDxe.inf
> $(BOARD_PKG)/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
> BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> + BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
> b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
> index e0a1daddee..99bf607775 100644
> --- a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
> +++
> b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
> @@ -213,6 +213,7 @@ INF
> MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
> INF MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceSmm.inf
> INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
> INF BoardModulePkg/LegacySioDxe/LegacySioDxe.inf
> +INF BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
>
> INF MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf
>
> --
> 2.19.1.windows.1
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [edk2-devel] [edk2-platforms] [PATCH 00/11] Add BDS Hook Points
2019-12-14 1:32 [edk2-platforms] [PATCH 00/11] Add BDS Hook Points Agyeman, Prince
` (10 preceding siblings ...)
2019-12-14 1:32 ` [edk2-platforms] [PATCH 11/11] SimicsOpenBoardPkg: Add Bds Hook Points Agyeman, Prince
@ 2020-04-21 20:37 ` Nate DeSimone
2020-04-22 10:31 ` Leif Lindholm
11 siblings, 1 reply; 45+ messages in thread
From: Nate DeSimone @ 2020-04-21 20:37 UTC (permalink / raw)
To: devel@edk2.groups.io, Agyeman, Prince
This patch series has gotten very old and the review comments were minor and cosmetic. Since this is a good new feature, I have made the cosmetic fixes and pushed the patch series as 765cbda6~..5a60c2de.
Thanks,
Nate
-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Agyeman, Prince
Sent: Friday, December 13, 2019 5:32 PM
To: devel@edk2.groups.io
Subject: [edk2-devel] [edk2-platforms] [PATCH 00/11] Add BDS Hook Points
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
This patch series implements BDS hook points as defined in the EDK II Minimum Platform Specification. For details, see https://edk2-docs.gitbooks.io/edk-ii-minimum-platform-specification/appendix_a_full_maps/a3_bds_hook_points.html
What was done:
* MinplatformPkg: Three BDS event group PCDs were added
- gBdsEventBeforeConsoleAfterTrustedConsoleGuid
- gBdsEventBeforeConsoleBeforeEndOfDxeGuid
- gBdsEventAfterConsoleReadyBeforeBootOptionGuid
* DxePlatformBootManager: MinplatformPkg's DxePlatformBootManager library instance was modified to signal the three newly added BDS events groups
* BoardBdsHookLib: BDS event callback library was added.
This library implements the callbacks for the three Bds event groups as well as callbacks for already existing gEfiEndOfDxeEventGroupGuid, gEfiPciEnumerationCompleteProtocolGuid and gEfiDxeSmmReadyToLockProtocolGuid event groups
- A default implementation of the board BDS hook library
was added to BoardModulePkg
- A SimicOpenBoardPkg specific implementation of the Board BDS
hook library was also added
* BoardBdsHookDxe: A generic DXE driver that registers the callbacks implemented in the Board BDS hook library was added
* BoardBootManagerLib: A board boot manager library was added.
This library implements PlatformBootManagerWaitCallback and PlatformBootManagerUnableToBoot needed by Minplatform's PlatformBootManager libary instance.
- A null instance of this library was added to MinplatformPkg
- A default instance of this library was added to BoardModulePkg
- A SimicOpenBoardPkg instance was implemented
* Support for the BDS Hook points were added to all the Minplatform boards
Prince Agyeman (11):
MinPlatformPkg: Add BDS Hook Point Guids
BoardModulePkg: Add BDS Hook Library
BoardModulePkg: Add BDS Hook DXE Driver
MinPlatformPkg: Add BDS Board Boot Manager library
MinPlatformPkg: Add BDS Hook Points
BoardModulePkg: Add Generic BoardBootManagerLib
KabylakeOpenBoardPkg: Add BDS Hook Dxe Driver
WhiskeylakeOpenBoardPkg: Add BDS Hook Dxe Driver
SimicsOpenBoardPkg: Add Bds Hook Library
SimicsOpenBoardPkg: Add BDS Board Boot Manager library
SimicsOpenBoardPkg: Add Bds Hook Points
.../BoardBdsHookDxe/BoardBdsHookDxe.c | 121 ++
.../BoardBdsHookDxe/BoardBdsHookDxe.inf | 46 +
.../Include/Library/BoardBdsHookLib.h | 100 +
.../Library/BoardBdsHookLib/BoardBdsHook.h | 211 +++
.../Library/BoardBdsHookLib/BoardBdsHookLib.c | 1390 ++++++++++++++
.../BoardBdsHookLib/BoardBdsHookLib.inf | 95 +
.../BoardBdsHookLib/BoardBootOption.c} | 87 +-
.../BoardBdsHookLib/BoardMemoryTest.c} | 4 +-
.../BoardBootManagerLib/BoardBootManager.c | 103 ++
.../BoardBootManagerLib.inf | 39 +
.../GalagoPro3/OpenBoardPkg.dsc | 7 +
.../GalagoPro3/OpenBoardPkg.fdf | 1 +
.../KabylakeRvp3/OpenBoardPkg.dsc | 6 +
.../KabylakeRvp3/OpenBoardPkg.fdf | 1 +
.../BoardBootManagerLib.c | 38 +
.../BoardBootManagerLibNull.inf | 31 +
.../DxePlatformBootManagerLib/BdsPlatform.c | 1262 +------------
.../DxePlatformBootManagerLib/BdsPlatform.h | 181 +-
.../DxePlatformBootManagerLib.inf | 51 +-
.../Include/Library/BoardBootManagerLib.h | 39 +
.../Intel/MinPlatformPkg/MinPlatformPkg.dec | 5 +
.../BoardX58Ich10/OpenBoardPkg.dsc | 10 +-
.../BoardX58Ich10/OpenBoardPkg.fdf | 1 +
.../Library/BoardBdsHookLib/BoardBdsHook.h | 173 ++
.../Library/BoardBdsHookLib/BoardBdsHookLib.c | 1630 +++++++++++++++++
.../BoardBdsHookLib/BoardBdsHookLib.inf | 81 +
.../BoardBootManagerLib/BoardBootManager.c | 67 +
.../BoardBootManagerLib.inf | 45 +
.../WhiskeylakeURvp/OpenBoardPkg.dsc | 4 +
.../WhiskeylakeURvp/OpenBoardPkg.fdf | 1 +
30 files changed, 4421 insertions(+), 1409 deletions(-) create mode 100644 Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.c
create mode 100644 Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
create mode 100644 Platform/Intel/BoardModulePkg/Include/Library/BoardBdsHookLib.h
create mode 100644 Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook.h
create mode 100644 Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
create mode 100644 Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
rename Platform/Intel/{MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/PlatformBootOption.c => BoardModulePkg/Library/BoardBdsHookLib/BoardBootOption.c} (87%) rename Platform/Intel/{MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/MemoryTest.c => BoardModulePkg/Library/BoardBdsHookLib/BoardMemoryTest.c} (93%) create mode 100644 Platform/Intel/BoardModulePkg/Library/BoardBootManagerLib/BoardBootManager.c
create mode 100644 Platform/Intel/BoardModulePkg/Library/BoardBootManagerLib/BoardBootManagerLib.inf
create mode 100644 Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/BoardBootManagerLib.c
create mode 100644 Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/BoardBootManagerLibNull.inf
create mode 100644 Platform/Intel/MinPlatformPkg/Include/Library/BoardBootManagerLib.h
create mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHook.h
create mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
create mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
create mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/BoardBootManagerLib/BoardBootManager.c
create mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/BoardBootManagerLib/BoardBootManagerLib.inf
--
2.19.1.windows.1
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [edk2-devel] [edk2-platforms] [PATCH 00/11] Add BDS Hook Points
2020-04-21 20:37 ` [edk2-devel] [edk2-platforms] [PATCH 00/11] Add BDS " Nate DeSimone
@ 2020-04-22 10:31 ` Leif Lindholm
2020-04-22 22:13 ` Nate DeSimone
0 siblings, 1 reply; 45+ messages in thread
From: Leif Lindholm @ 2020-04-22 10:31 UTC (permalink / raw)
To: devel, nathaniel.l.desimone; +Cc: Agyeman, Prince
Hi Nate,
On Tue, Apr 21, 2020 at 20:37:39 +0000, Nate DeSimone wrote:
> This patch series has gotten very old and the review comments were
> minor and cosmetic. Since this is a good new feature, I have made
> the cosmetic fixes and pushed the patch series as
> 765cbda6~..5a60c2de.
Could you make sure the BZ gets updated/closed as well?
Regards,
Leif
>
> Thanks,
> Nate
>
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Agyeman, Prince
> Sent: Friday, December 13, 2019 5:32 PM
> To: devel@edk2.groups.io
> Subject: [edk2-devel] [edk2-platforms] [PATCH 00/11] Add BDS Hook Points
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
>
> This patch series implements BDS hook points as defined in the EDK II Minimum Platform Specification. For details, see https://edk2-docs.gitbooks.io/edk-ii-minimum-platform-specification/appendix_a_full_maps/a3_bds_hook_points.html
>
> What was done:
>
> * MinplatformPkg: Three BDS event group PCDs were added
> - gBdsEventBeforeConsoleAfterTrustedConsoleGuid
> - gBdsEventBeforeConsoleBeforeEndOfDxeGuid
> - gBdsEventAfterConsoleReadyBeforeBootOptionGuid
>
> * DxePlatformBootManager: MinplatformPkg's DxePlatformBootManager library instance was modified to signal the three newly added BDS events groups
>
> * BoardBdsHookLib: BDS event callback library was added.
> This library implements the callbacks for the three Bds event groups as well as callbacks for already existing gEfiEndOfDxeEventGroupGuid, gEfiPciEnumerationCompleteProtocolGuid and gEfiDxeSmmReadyToLockProtocolGuid event groups
> - A default implementation of the board BDS hook library
> was added to BoardModulePkg
> - A SimicOpenBoardPkg specific implementation of the Board BDS
> hook library was also added
>
> * BoardBdsHookDxe: A generic DXE driver that registers the callbacks implemented in the Board BDS hook library was added
>
> * BoardBootManagerLib: A board boot manager library was added.
> This library implements PlatformBootManagerWaitCallback and PlatformBootManagerUnableToBoot needed by Minplatform's PlatformBootManager libary instance.
> - A null instance of this library was added to MinplatformPkg
> - A default instance of this library was added to BoardModulePkg
> - A SimicOpenBoardPkg instance was implemented
>
> * Support for the BDS Hook points were added to all the Minplatform boards
>
> Prince Agyeman (11):
> MinPlatformPkg: Add BDS Hook Point Guids
> BoardModulePkg: Add BDS Hook Library
> BoardModulePkg: Add BDS Hook DXE Driver
> MinPlatformPkg: Add BDS Board Boot Manager library
> MinPlatformPkg: Add BDS Hook Points
> BoardModulePkg: Add Generic BoardBootManagerLib
> KabylakeOpenBoardPkg: Add BDS Hook Dxe Driver
> WhiskeylakeOpenBoardPkg: Add BDS Hook Dxe Driver
> SimicsOpenBoardPkg: Add Bds Hook Library
> SimicsOpenBoardPkg: Add BDS Board Boot Manager library
> SimicsOpenBoardPkg: Add Bds Hook Points
>
> .../BoardBdsHookDxe/BoardBdsHookDxe.c | 121 ++
> .../BoardBdsHookDxe/BoardBdsHookDxe.inf | 46 +
> .../Include/Library/BoardBdsHookLib.h | 100 +
> .../Library/BoardBdsHookLib/BoardBdsHook.h | 211 +++
> .../Library/BoardBdsHookLib/BoardBdsHookLib.c | 1390 ++++++++++++++
> .../BoardBdsHookLib/BoardBdsHookLib.inf | 95 +
> .../BoardBdsHookLib/BoardBootOption.c} | 87 +-
> .../BoardBdsHookLib/BoardMemoryTest.c} | 4 +-
> .../BoardBootManagerLib/BoardBootManager.c | 103 ++
> .../BoardBootManagerLib.inf | 39 +
> .../GalagoPro3/OpenBoardPkg.dsc | 7 +
> .../GalagoPro3/OpenBoardPkg.fdf | 1 +
> .../KabylakeRvp3/OpenBoardPkg.dsc | 6 +
> .../KabylakeRvp3/OpenBoardPkg.fdf | 1 +
> .../BoardBootManagerLib.c | 38 +
> .../BoardBootManagerLibNull.inf | 31 +
> .../DxePlatformBootManagerLib/BdsPlatform.c | 1262 +------------
> .../DxePlatformBootManagerLib/BdsPlatform.h | 181 +-
> .../DxePlatformBootManagerLib.inf | 51 +-
> .../Include/Library/BoardBootManagerLib.h | 39 +
> .../Intel/MinPlatformPkg/MinPlatformPkg.dec | 5 +
> .../BoardX58Ich10/OpenBoardPkg.dsc | 10 +-
> .../BoardX58Ich10/OpenBoardPkg.fdf | 1 +
> .../Library/BoardBdsHookLib/BoardBdsHook.h | 173 ++
> .../Library/BoardBdsHookLib/BoardBdsHookLib.c | 1630 +++++++++++++++++
> .../BoardBdsHookLib/BoardBdsHookLib.inf | 81 +
> .../BoardBootManagerLib/BoardBootManager.c | 67 +
> .../BoardBootManagerLib.inf | 45 +
> .../WhiskeylakeURvp/OpenBoardPkg.dsc | 4 +
> .../WhiskeylakeURvp/OpenBoardPkg.fdf | 1 +
> 30 files changed, 4421 insertions(+), 1409 deletions(-) create mode 100644 Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.c
> create mode 100644 Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
> create mode 100644 Platform/Intel/BoardModulePkg/Include/Library/BoardBdsHookLib.h
> create mode 100644 Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook.h
> create mode 100644 Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
> create mode 100644 Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
> rename Platform/Intel/{MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/PlatformBootOption.c => BoardModulePkg/Library/BoardBdsHookLib/BoardBootOption.c} (87%) rename Platform/Intel/{MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/MemoryTest.c => BoardModulePkg/Library/BoardBdsHookLib/BoardMemoryTest.c} (93%) create mode 100644 Platform/Intel/BoardModulePkg/Library/BoardBootManagerLib/BoardBootManager.c
> create mode 100644 Platform/Intel/BoardModulePkg/Library/BoardBootManagerLib/BoardBootManagerLib.inf
> create mode 100644 Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/BoardBootManagerLib.c
> create mode 100644 Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/BoardBootManagerLibNull.inf
> create mode 100644 Platform/Intel/MinPlatformPkg/Include/Library/BoardBootManagerLib.h
> create mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHook.h
> create mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
> create mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
> create mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/BoardBootManagerLib/BoardBootManager.c
> create mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/BoardBootManagerLib/BoardBootManagerLib.inf
>
> --
> 2.19.1.windows.1
>
>
>
>
>
>
>
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [edk2-devel] [edk2-platforms] [PATCH 00/11] Add BDS Hook Points
2020-04-22 10:31 ` Leif Lindholm
@ 2020-04-22 22:13 ` Nate DeSimone
0 siblings, 0 replies; 45+ messages in thread
From: Nate DeSimone @ 2020-04-22 22:13 UTC (permalink / raw)
To: Leif Lindholm, devel@edk2.groups.io; +Cc: Agyeman, Prince
Hi Leif,
Definitely. I held back on closing it for my follow-up patch series to be reviewed and committed as well:
https://edk2.groups.io/g/devel/message/57762
Thanks,
Nate
On 4/22/20, 3:32 AM, "Leif Lindholm" <leif@nuviainc.com> wrote:
Hi Nate,
On Tue, Apr 21, 2020 at 20:37:39 +0000, Nate DeSimone wrote:
> This patch series has gotten very old and the review comments were
> minor and cosmetic. Since this is a good new feature, I have made
> the cosmetic fixes and pushed the patch series as
> 765cbda6~..5a60c2de.
Could you make sure the BZ gets updated/closed as well?
Regards,
Leif
>
> Thanks,
> Nate
>
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Agyeman, Prince
> Sent: Friday, December 13, 2019 5:32 PM
> To: devel@edk2.groups.io
> Subject: [edk2-devel] [edk2-platforms] [PATCH 00/11] Add BDS Hook Points
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
>
> This patch series implements BDS hook points as defined in the EDK II Minimum Platform Specification. For details, see https://edk2-docs.gitbooks.io/edk-ii-minimum-platform-specification/appendix_a_full_maps/a3_bds_hook_points.html
>
> What was done:
>
> * MinplatformPkg: Three BDS event group PCDs were added
> - gBdsEventBeforeConsoleAfterTrustedConsoleGuid
> - gBdsEventBeforeConsoleBeforeEndOfDxeGuid
> - gBdsEventAfterConsoleReadyBeforeBootOptionGuid
>
> * DxePlatformBootManager: MinplatformPkg's DxePlatformBootManager library instance was modified to signal the three newly added BDS events groups
>
> * BoardBdsHookLib: BDS event callback library was added.
> This library implements the callbacks for the three Bds event groups as well as callbacks for already existing gEfiEndOfDxeEventGroupGuid, gEfiPciEnumerationCompleteProtocolGuid and gEfiDxeSmmReadyToLockProtocolGuid event groups
> - A default implementation of the board BDS hook library
> was added to BoardModulePkg
> - A SimicOpenBoardPkg specific implementation of the Board BDS
> hook library was also added
>
> * BoardBdsHookDxe: A generic DXE driver that registers the callbacks implemented in the Board BDS hook library was added
>
> * BoardBootManagerLib: A board boot manager library was added.
> This library implements PlatformBootManagerWaitCallback and PlatformBootManagerUnableToBoot needed by Minplatform's PlatformBootManager libary instance.
> - A null instance of this library was added to MinplatformPkg
> - A default instance of this library was added to BoardModulePkg
> - A SimicOpenBoardPkg instance was implemented
>
> * Support for the BDS Hook points were added to all the Minplatform boards
>
> Prince Agyeman (11):
> MinPlatformPkg: Add BDS Hook Point Guids
> BoardModulePkg: Add BDS Hook Library
> BoardModulePkg: Add BDS Hook DXE Driver
> MinPlatformPkg: Add BDS Board Boot Manager library
> MinPlatformPkg: Add BDS Hook Points
> BoardModulePkg: Add Generic BoardBootManagerLib
> KabylakeOpenBoardPkg: Add BDS Hook Dxe Driver
> WhiskeylakeOpenBoardPkg: Add BDS Hook Dxe Driver
> SimicsOpenBoardPkg: Add Bds Hook Library
> SimicsOpenBoardPkg: Add BDS Board Boot Manager library
> SimicsOpenBoardPkg: Add Bds Hook Points
>
> .../BoardBdsHookDxe/BoardBdsHookDxe.c | 121 ++
> .../BoardBdsHookDxe/BoardBdsHookDxe.inf | 46 +
> .../Include/Library/BoardBdsHookLib.h | 100 +
> .../Library/BoardBdsHookLib/BoardBdsHook.h | 211 +++
> .../Library/BoardBdsHookLib/BoardBdsHookLib.c | 1390 ++++++++++++++
> .../BoardBdsHookLib/BoardBdsHookLib.inf | 95 +
> .../BoardBdsHookLib/BoardBootOption.c} | 87 +-
> .../BoardBdsHookLib/BoardMemoryTest.c} | 4 +-
> .../BoardBootManagerLib/BoardBootManager.c | 103 ++
> .../BoardBootManagerLib.inf | 39 +
> .../GalagoPro3/OpenBoardPkg.dsc | 7 +
> .../GalagoPro3/OpenBoardPkg.fdf | 1 +
> .../KabylakeRvp3/OpenBoardPkg.dsc | 6 +
> .../KabylakeRvp3/OpenBoardPkg.fdf | 1 +
> .../BoardBootManagerLib.c | 38 +
> .../BoardBootManagerLibNull.inf | 31 +
> .../DxePlatformBootManagerLib/BdsPlatform.c | 1262 +------------
> .../DxePlatformBootManagerLib/BdsPlatform.h | 181 +-
> .../DxePlatformBootManagerLib.inf | 51 +-
> .../Include/Library/BoardBootManagerLib.h | 39 +
> .../Intel/MinPlatformPkg/MinPlatformPkg.dec | 5 +
> .../BoardX58Ich10/OpenBoardPkg.dsc | 10 +-
> .../BoardX58Ich10/OpenBoardPkg.fdf | 1 +
> .../Library/BoardBdsHookLib/BoardBdsHook.h | 173 ++
> .../Library/BoardBdsHookLib/BoardBdsHookLib.c | 1630 +++++++++++++++++
> .../BoardBdsHookLib/BoardBdsHookLib.inf | 81 +
> .../BoardBootManagerLib/BoardBootManager.c | 67 +
> .../BoardBootManagerLib.inf | 45 +
> .../WhiskeylakeURvp/OpenBoardPkg.dsc | 4 +
> .../WhiskeylakeURvp/OpenBoardPkg.fdf | 1 +
> 30 files changed, 4421 insertions(+), 1409 deletions(-) create mode 100644 Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.c
> create mode 100644 Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf
> create mode 100644 Platform/Intel/BoardModulePkg/Include/Library/BoardBdsHookLib.h
> create mode 100644 Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook.h
> create mode 100644 Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
> create mode 100644 Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
> rename Platform/Intel/{MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/PlatformBootOption.c => BoardModulePkg/Library/BoardBdsHookLib/BoardBootOption.c} (87%) rename Platform/Intel/{MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/MemoryTest.c => BoardModulePkg/Library/BoardBdsHookLib/BoardMemoryTest.c} (93%) create mode 100644 Platform/Intel/BoardModulePkg/Library/BoardBootManagerLib/BoardBootManager.c
> create mode 100644 Platform/Intel/BoardModulePkg/Library/BoardBootManagerLib/BoardBootManagerLib.inf
> create mode 100644 Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/BoardBootManagerLib.c
> create mode 100644 Platform/Intel/MinPlatformPkg/Bds/Library/BoardBootManagerLibNull/BoardBootManagerLibNull.inf
> create mode 100644 Platform/Intel/MinPlatformPkg/Include/Library/BoardBootManagerLib.h
> create mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHook.h
> create mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
> create mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
> create mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/BoardBootManagerLib/BoardBootManager.c
> create mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/BoardBootManagerLib/BoardBootManagerLib.inf
>
> --
> 2.19.1.windows.1
>
>
>
>
>
>
>
^ permalink raw reply [flat|nested] 45+ messages in thread