Compare commits

...

86 Commits

Author SHA1 Message Date
f40dc199c2 Merge pull request #6 from system76/boot-uefi-only
Skip volumes that do not have an EFI volume
2020-01-27 15:47:07 -07:00
3f54e8f57a Skip volumes that do not have an EFI volume 2020-01-27 15:32:04 -07:00
55849a4a46 IntelFrameworkModulePkg/BdsDxe: Ensure forms have unique IDs 2020-01-24 19:13:51 -07:00
74f2015276 Expand HD paths when checking for invalid options 2020-01-24 19:13:51 -07:00
6dff36c9b2 Add PlatformBdsPreBoot to allow hooks immediately before booting an option 2020-01-24 18:50:48 -07:00
814c0fa862 Load firmware-smmstore driver 2020-01-24 18:50:48 -07:00
a05aa4aff0 Also ignore keysizes of 0 2020-01-24 18:50:48 -07:00
30c84e8277 Update numbering 2020-01-24 18:50:48 -07:00
2ba9869baa Prioritize Udf and ElTorito partition types over Mbr to fix ISO boots 2020-01-24 18:50:48 -07:00
826b9d30cf Add firmware version to front page 2020-01-24 18:50:48 -07:00
b0e7e3919f Add SPACE for recovery message 2020-01-24 18:50:48 -07:00
976842130a Revise key handling in boot phase
Add escape key handler as early as possible, and set timeout immediately
upon displaying splash.
2020-01-24 18:50:48 -07:00
52d5d1b2c5 Improve error output when boot option fails to load 2020-01-24 18:50:48 -07:00
7050fc3a26 Make it possible to delete SMMSTORE variable by appending it with size 0 2020-01-24 18:50:48 -07:00
0eca9e3c1a Replace Front Page with computer name 2020-01-24 18:43:52 -07:00
19304f2144 Edit strings 2020-01-24 18:43:52 -07:00
b062ed0c86 Make Change Boot Order the primary boot maintenance manager page 2020-01-24 18:32:19 -07:00
d9cf95c6a2 Remove cruft from boot options 2020-01-24 18:10:15 -07:00
75a5161506 Ignore DEBUG interrupt (happens on gaze14) 2020-01-24 18:10:09 -07:00
d193b18023 Increase size of buffer for DMI information 2020-01-24 18:10:04 -07:00
061df3962f Update serial port to use 2020-01-24 18:09:54 -07:00
f6e7c15556 Add Intel GOP driver 2020-01-24 18:09:45 -07:00
95fb70f34d Update logo 2020-01-24 18:09:37 -07:00
900debdeec Add System76 Setup menu 2020-01-24 18:09:31 -07:00
33006e4f4e Order NVMe devices first 2020-01-24 18:09:23 -07:00
b8fbf69c16 Frontpage: add entries for some more KBL Chromebooks
Add entries for ATLAS, BARD, EKKO, EVE, NAUTILUS, NOCTURNE,
RAMMUS, SONA, SYNDRA

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2019-12-01 10:43:24 -06:00
ba13872223 Frontpage: fix max size used for GetDeviceNameFromProduct()
Fixes some device name strings not being copied due to
exceeding max size (but not size of buffer passed in)

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2019-11-25 00:27:53 -06:00
eb1e7a0284 MdeModulePkg/NvmExpressDxe: Simplify NvmExpress name
Signed-off-by: Jeremy Soller <jeremy@system76.com>
2019-11-25 00:27:53 -06:00
eba6c7c6ce BdsBoot: use better device descriptions
Query boot devices and obtain make/model info if
available. Prefix description with device type
for better identification.

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2019-11-25 00:27:53 -06:00
a5f556c37b GenericBdsLib: add BmBootDescription from UefiBootManagerLib
Copy BmBootDescription from MdeModulePkg/UefiBootManagerLib,
removing appending of serial # since it makes descriptions
unweildy.

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2019-11-25 00:27:53 -06:00
e9023ae655 IntelFrameworkModulePkg: rework Frontpage layout
- center device name; left-justify other info
- remove Language and Device Manager options
- rename 'Continue' to 'Default Boot'

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2019-11-25 00:27:53 -06:00
cdd43b2533 IntelFrameworkModulePkg: rename/rework Boot Maintenance Manager
With Boot Manager now renamed, rename BMM as well.
Also clean up and simplify menu to eliminate unused/non-
functional items.

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2019-11-25 00:27:53 -06:00
d1a6917813 IntelFrameworkModulePkg: rename Boot Manager to Boot Menu
'Boot Menu' is much more intuitive for users

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2019-11-25 00:27:53 -06:00
81e096bda1 Boot Maintenance Mrg: add missing 'save changes' option 2019-11-25 00:27:53 -06:00
42f99de779 MdeModulePkg: fix UninstallMultipleProtocolInterfaces() calls
Unlike the InstallMultipleProtocolInterfaces() boot service, which takes
an (EFI_HANDLE*) as first parameter, the
UninstallMultipleProtocolInterfaces() boot service takes an EFI_HANDLE as
first parameter.

These are actual bugs. They must have remained hidden until now because
they are on error paths. Fix the UninstallMultipleProtocolInterfaces()
calls.

Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
2019-11-25 00:27:53 -06:00
a03327088a MdeModulePkg/UsbBusDxe: Return error when the device is not present
Until now, during the USB device enumeration when its PortState
USB_PORT_STAT_CONNECTION bit was not set, the stack was not informed
that the device is not present. Fix that by returning appropriate
error code.

Signed-off-by: Marcin Wojtas <mw@semihalf.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
2019-11-25 00:27:53 -06:00
4ba839c5c8 MdeModulePkg/XhciPei: Fix Aligned Page Allocation
Add support for allocating aligned pages at an alignment higher
than 4K. The new function allocated memory taking into account
the padding required and then frees up unused pages before mapping
it.

Signed-off-by: Ashish Singhal <ashishsingha@nvidia.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
2019-11-25 00:27:53 -06:00
6bd9d60b41 MdeModulePkg/XhciDxe: Fix Aligned Page Allocation
While allocating pages aligned at an alignment higher than
4K, allocate memory taking into consideration the padding
required for that alignment. The calls to free pages takes
care of this already.

Signed-off-by: Ashish Singhal <ashishsingha@nvidia.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
2019-11-25 00:27:53 -06:00
964f80253a Revert "UsbMassBoot: treat all USB drives as removable"
This reverts commit de4592d59e16f91b1cf480478572533be6cc5f1b.
2019-11-25 00:27:53 -06:00
47794944e6 IntelFrameworkModulePkg/Universal/BdsDxe: Fix assertion
Fix an assertion that prevented the boot menu to show up when the coreboot
string is very long.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2019-11-22 14:08:20 -06:00
8f008298cc Frontpage: add entry for AMD Chromebooks (grunt)
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2019-06-23 18:18:19 -05:00
783f22ecc3 Frontpage: add entries for NAMI variants and SORAKA
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2019-06-23 18:18:19 -05:00
81a93fb3a9 UefiCpuPkg/CpuCommonFeaturesLib: Aesni.c uses BIT0 and BIT1 reversedly
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1621

According to Intel SDM as below, the BIT0 should be treated as
lock bit, and BIT1 should be treated as disable(1)/enable(0) bit.

"11b: AES instructions are not available until next
RESET.
Otherwise, AES instructions are available.
If the configuration is not 01b, AES
instructions can be mis-configured if a privileged agent
unintentionally writes 11b"

Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Chandana Kumar <chandana.c.kumar@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
2019-06-23 18:18:19 -05:00
30dc65997f AddBGRT: match BGRT with boot logo postition
Don't hard-code the logo size, and use the Microsoft-recommended logo position.

Signed-off-by: James Ye <jye836@gmail.com>
2019-05-13 11:54:26 +10:00
93f8c4a6d5 BdsConsole: use recommended boot logo position
Microsoft user experience specifications recommend the boot logo is drawn 38.2%
from the top of the screen. This is also where operating systems like Fedora
expect the logo to be drawn.

Signed-off-by: James Ye <jye836@gmail.com>
2019-05-13 11:40:56 +10:00
51be9d0425 BdsConsole: fix up boot logo positioning
No reason to hardcode the image size into the
positon calculations. Keep shift to upper 2/3
of screen.

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2019-02-21 20:21:18 -06:00
31a4e13c19 BmpSupportLib: fix BMP validation
BMP files by tools other than MS paint can have a
variable number of padding bytes, which results in
the DataSize being less than (ImageSize - HeaderSize).
Fix the check to be less stringent.

Test: use BMP created by/saved by Photoshop

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2019-02-21 20:19:21 -06:00
9d32ca34d2 MemoryTest: remove unused variable StrTotalMemory
fixes compiler warning->error

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2019-02-21 20:19:21 -06:00
0f9b597012 Logo: use slightly larger logo
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2019-02-20 17:29:26 -06:00
19e12d66fe BdsPlatform: increase timeout to 2s
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2019-02-20 17:29:26 -06:00
9332332724 MemoryTest: replace test result with boot menu prompt
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2019-02-20 17:29:26 -06:00
239e19e391 BdsBoot: add boot menu text for eMMC/SD, NVMe devices
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2019-02-20 17:29:26 -06:00
c8a3cdb675 CorebootModulePkg: remove unused/deprecated SATA driver
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2019-02-20 17:29:26 -06:00
40147bbf14 CorebootPayloadPkg: switch to MdeModulePkg SATA driver
CorebootModulePkg version is buggy and unmaintained, switching
to MdeModulePkg version fixes channel count / drive detection
issue on some KBL Chromeboxes

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2019-02-20 17:29:26 -06:00
cf2bde63a1 Revert "MdeModulePkg/SdMmcPciHcDxe: Execute card detect only for RemovableSlot"
This reverts commit 4cd9d7fc6f.

card detect causes hangs on many devices with a directly-attached SD card reader
2019-02-20 17:29:26 -06:00
f6f2ff4904 WIP: hook into emuvariable to sync data with coreboot smm store
changed: buffer size from 64k to 256k

Change-Id: I7f443b9f36612f79787e1b4b1075176a91107686
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2019-02-20 17:29:26 -06:00
a26aad44d1 Frontpage: add device name for Lars, Cave, Fizz, others
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2019-02-20 17:29:26 -06:00
3596140a69 CorebootPayloadPkg: Add SafeIntLib and BmpSupportLib to DSC files
Commit 2460ec2a8f added the new libraries
to DuetPkg to fix building. Do the same for CorebootPayloadPkg.

Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Prince Agyeman <prince.agyeman@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Alex James <theracermaster@gmail.com>
2019-02-20 17:29:26 -06:00
9b7ce3b9a1 Frontpage: use SMBIOS data directly for non-Google devices
Since board names match the device, just print manufacturer
and device name without translation.

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2019-02-20 17:29:25 -06:00
147c02d66e Disable Page Table Protection.
Effectively disables the PT protection created by: 2ac1730bf2, 147fd35c3e, and 41b4600c30.

This fixes macOS boot issues.
2019-02-20 17:29:25 -06:00
768fe7365f EmmcDevice: fix detection on some models
From stepan:
"This enables eMMC booting when starting edk2
from depthcharge. Previously the driver would
bail out with an error while setting the eMMC
frequency, because depthcharge has already set
up the controller."

Also fixed detection on google/lars w/Core-i5
with upstream coreboot + Tianocore payload
2019-02-20 17:29:25 -06:00
0f6978e314 CbSupportPei: prevent lower coreboot table from being overwritten
Exclude the bottom 4kb from being included in System Memory HoB

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2019-02-20 17:29:25 -06:00
0a8abc3c4d FSDrivers: update drivers from rEFInd 0.11.2 2019-02-20 17:29:25 -06:00
54b26ae48f CorebootPayloadPkg: add NVMe support 2019-02-14 15:44:32 -06:00
9d72e4b922 MdeModulePkg/GraphicsConsole: don't draw cursor at 0,0
Prevents cursor from flashing on screen when
changing modes or clearing the screen.

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2019-02-14 15:44:32 -06:00
7f094cdf45 Frontpage: gut unnecessary mode changes
minimize flicker between splash screen and BGRT
2019-02-14 15:44:32 -06:00
b0f8ea3c9c BdsPlatform: cleanup and use coreboot logo
- remove 'start boot option' text
- use boot logo splash for 1s, align to BGRT
- rework frontpage usage
2019-02-14 15:44:20 -06:00
731869826b MemoryTest: Remove upper left display, status bar
Since the memory test is essentially instantanous,
remove unnecessry duplication of memory count and
static status bar for cleaner display with coreboot logo
2019-02-14 15:41:27 -06:00
a49a99ef5e Use coreboot logo for CorebootPayloadPkg 2019-02-14 15:41:27 -06:00
d06545cd3d IntelFrameworkModulePkg: add BGRT table
Add support for adding a BGRT table for Windows 8/8.1/10 bootlogo.
2019-02-14 15:41:27 -06:00
575764deeb UsbMassBoot: treat all USB drives as removable 2019-02-14 15:41:27 -06:00
ed1cf61e3e Frontpage: Use a larger SimpleText console mode 2019-02-14 15:41:27 -06:00
091f5d689f CorebootPayloadPkg: Add DataHubDxe for OS X 2019-02-14 15:41:27 -06:00
d944c24078 Frontpage: remove leading spaces from CPU string 2019-02-14 15:41:27 -06:00
bdd22050f6 Frontpage: get SMBIOS Data from table directly
rather than getting it from the EFI SMBIOS protocol
2019-02-14 15:41:27 -06:00
0286bfae44 Frontpage: add device names, FW info to setup screen
Signed-off-by: Matt Devo <matt.devillier@gmail.com>
2019-02-14 15:41:27 -06:00
735fae0452 CorebootPayloadPkg: Use additional FS Drivers 2019-02-14 15:41:27 -06:00
8de2a8523d Add NTFS/ext4 filesystem drivers 2019-02-14 15:41:27 -06:00
e4fc0fbacb CorebootPayloadPkg: Remove OHCI and UHCI drivers 2019-02-14 15:41:26 -06:00
fceee0d621 CorebootPayloadPkg: Add PS/2 keyboard drivers. 2019-02-14 15:41:26 -06:00
d67d692ee2 CorebootModulePkg: Don't mask off legacy 8259 sources.
With the legacy sources masked, closing laptop lid results
in hard shutdown vs graceful transition to S3/suspend
(per coolstar)
2019-02-14 15:41:26 -06:00
927fc0e4b5 CorebootBdsLib: Call End of DXE event to allow booting 3rd party efi binaries. 2019-02-14 15:41:26 -06:00
04515ff368 CorebootPayloadPkg: Use BDS stage from DUET 2019-02-14 15:41:26 -06:00
439e7d2556 Frontpage: Set/Use native display resolution
set the mSetupH/V resolution based on GraphicsOutput mode,
not SimpleTextOut mode
2019-02-14 15:41:26 -06:00
0554ac9dd0 MdeModulePkg/GraphicsConsole: Don't re-set video output mode
Fixes display resolution issues with booting OS X
2019-02-14 15:41:26 -06:00
0a679652e8 PCI: copy/use Duet's PciNoEnumeration
Tianocore's PCI enumeration goes into an infinite loop, and
isn't necessary since coreboot has already handled it.
Copy and use DuetPkg's PciNoEnumeration package (which has
since been removed).

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2019-02-14 15:34:48 -06:00
96 changed files with 18169 additions and 2479 deletions

View File

@ -261,8 +261,9 @@ CbPeiEntryPoint (
EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE | EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE
), ),
(EFI_PHYSICAL_ADDRESS)(0), // Lower 640KB, except for first 4KB where the lower coreboot pointer ("LBIO") resides
(UINT64)(0xA0000) (EFI_PHYSICAL_ADDRESS)(0 + 0x1000),
(UINT64)(0xA0000 - 0x1000)
); );
@ -435,12 +436,6 @@ CbPeiEntryPoint (
return Status; return Status;
} }
//
// Mask off all legacy 8259 interrupt sources
//
IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0xFF);
IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0xFF);
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -33,8 +33,17 @@
gUefiCorebootModulePkgTokenSpaceGuid = {0xe6ff49a0, 0x15df, 0x48fd, {0x9a, 0xcf, 0xd7, 0xdc, 0x27, 0x1b, 0x39, 0xd5}} gUefiCorebootModulePkgTokenSpaceGuid = {0xe6ff49a0, 0x15df, 0x48fd, {0x9a, 0xcf, 0xd7, 0xdc, 0x27, 0x1b, 0x39, 0xd5}}
gUefiSystemTableInfoGuid = {0x16c8a6d0, 0xfe8a, 0x4082, {0xa2, 0x8, 0xcf, 0x89, 0xc4, 0x29, 0x4, 0x33}} gUefiSystemTableInfoGuid = {0x16c8a6d0, 0xfe8a, 0x4082, {0xa2, 0x8, 0xcf, 0x89, 0xc4, 0x29, 0x4, 0x33}}
gUefiFrameBufferInfoGuid = {0xdc2cd8bd, 0x402c, 0x4dc4, {0x9b, 0xe0, 0xc, 0x43, 0x2b, 0x7, 0xfa, 0x34}} gUefiFrameBufferInfoGuid = {0xdc2cd8bd, 0x402c, 0x4dc4, {0x9b, 0xe0, 0xc, 0x43, 0x2b, 0x7, 0xfa, 0x34}}
gEfiPciExpressBaseAddressGuid = {0x3677d529, 0x326f, 0x4603, {0xa9, 0x26, 0xea, 0xac, 0xe0, 0x1d, 0xcb, 0xb0 }}
gUefiAcpiBoardInfoGuid = {0xad3d31b, 0xb3d8, 0x4506, {0xae, 0x71, 0x2e, 0xf1, 0x10, 0x6, 0xd9, 0xf}} gUefiAcpiBoardInfoGuid = {0xad3d31b, 0xb3d8, 0x4506, {0xae, 0x71, 0x2e, 0xf1, 0x10, 0x6, 0xd9, 0xf}}
## Include/Guid/PciOptionRomTable.h
gEfiPciOptionRomTableGuid = { 0x7462660F, 0x1CBD, 0x48DA, { 0xAD, 0x11, 0x91, 0x71, 0x79, 0x13, 0x83, 0x1C }}
## Include/Guid/LdrMemoryDescriptor.h
gLdrMemoryDescriptorGuid = { 0x7701d7e5, 0x7d1d, 0x4432, { 0xa4, 0x68, 0x67, 0x3d, 0xab, 0x8a, 0xde, 0x60 }}
gBmpImageGuid = { 0x878AC2CC, 0x5343, 0x46F2, { 0xB5, 0x63, 0x51, 0xF8, 0x9D, 0xAF, 0x56, 0xBA } }
[Ppis] [Ppis]

View File

@ -0,0 +1,33 @@
/** @file
Guid is for GUIDED HOB of LDR memory descriptor.
Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef __LDR_MEMORY_DESCRIPTOR__
#define __LDR_MEMORY_DESCRIPTOR__
#define LDR_MEMORY_DESCRIPTOR_GUID \
{ 0x7701d7e5, 0x7d1d, 0x4432, {0xa4, 0x68, 0x67, 0x3d, 0xab, 0x8a, 0xde, 0x60}}
#pragma pack(1)
typedef struct {
EFI_HOB_GUID_TYPE Hob;
UINTN MemDescCount;
EFI_MEMORY_DESCRIPTOR *MemDesc;
} MEMORY_DESC_HOB;
#pragma pack()
extern EFI_GUID gLdrMemoryDescriptorGuid;
#endif

View File

@ -0,0 +1,46 @@
/** @file
Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
PciExpressBaseAddress.h
Abstract:
GUIDs used for PciExpress Base Address
**/
#ifndef _EFI_PCI_EXPRESS_BASE_ADDRESS_H_
#define _EFI_PCI_EXPRESS_BASE_ADDRESS_H_
#define EFI_PCI_EXPRESS_BASE_ADDRESS_GUID \
{ \
0x3677d529, 0x326f, 0x4603, {0xa9, 0x26, 0xea, 0xac, 0xe0, 0x1d, 0xcb, 0xb0} \
}
//
// Following structure defines PCI Express Base Address information.
// This information is platform specific, and built into hob in PEI phase.
// It can be consumed by PEI PCI driver and DXE PCI driver.
//
#pragma pack(1)
typedef struct _EFI_PCI_EXPRESS_BASE_ADDRESS_INFORMATION {
UINT32 HostBridgeNumber;
UINT32 RootBridgeNumber;
UINT64 PciExpressBaseAddress;
} EFI_PCI_EXPRESS_BASE_ADDRESS_INFORMATION;
#pragma pack()
extern EFI_GUID gEfiPciExpressBaseAddressGuid;
#endif

View File

@ -0,0 +1,41 @@
/** @file
GUID and data structure used to describe the list of PCI Option ROMs present in a system.
Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef __PCI_OPTION_ROM_TABLE_GUID_H_
#define __PCI_OPTION_ROM_TABLE_GUID_H_
#define EFI_PCI_OPTION_ROM_TABLE_GUID \
{ 0x7462660f, 0x1cbd, 0x48da, {0xad, 0x11, 0x91, 0x71, 0x79, 0x13, 0x83, 0x1c } }
extern EFI_GUID gEfiPciOptionRomTableGuid;
typedef struct {
EFI_PHYSICAL_ADDRESS RomAddress;
EFI_MEMORY_TYPE MemoryType;
UINT32 RomLength;
UINT32 Seg;
UINT8 Bus;
UINT8 Dev;
UINT8 Func;
BOOLEAN ExecutedLegacyBiosImage;
BOOLEAN DontLoadEfiRom;
} EFI_PCI_OPTION_ROM_DESCRIPTOR;
typedef struct {
UINT64 PciOptionRomCount;
EFI_PCI_OPTION_ROM_DESCRIPTOR *PciOptionRomDescriptors;
} EFI_PCI_OPTION_ROM_TABLE;
#endif // __PCI_OPTION_ROM_TABLE_GUID_H_

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,288 @@
/*++
Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
BdsPlatform.h
Abstract:
Head file for BDS Platform specific code
--*/
#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/LegacyBiosMpTable.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/BaseLib.h>
#include <Library/PcdLib.h>
#include <Library/GenericBdsLib.h>
#include <Library/PlatformBdsLib.h>
#include <Library/HobLib.h>
#include <Library/UefiLib.h>
#include <Library/DxeServicesTableLib.h>
#include <Library/DevicePathLib.h>
#include <Protocol/PciIo.h>
#include <Guid/Acpi.h>
#include <Guid/SmBios.h>
#include <Guid/Mps.h>
#include <Guid/HobList.h>
#include <Guid/PciExpressBaseAddress.h>
#include <Guid/GlobalVariable.h>
#include <Guid/LdrMemoryDescriptor.h>
extern BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[];
extern EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[];
extern EFI_DEVICE_PATH_PROTOCOL *gPlatformDriverOption[];
extern EFI_DEVICE_PATH_PROTOCOL *gPlatformRootBridges[];
extern ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode;
extern ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode;
extern UART_DEVICE_PATH gUartDeviceNode;
extern VENDOR_DEVICE_PATH gTerminalTypeDeviceNode;
//
//
//
#define VarConsoleInpDev L"ConInDev"
#define VarConsoleInp L"ConIn"
#define VarConsoleOutDev L"ConOutDev"
#define VarConsoleOut L"ConOut"
#define VarErrorOutDev L"ErrOutDev"
#define VarErrorOut L"ErrOut"
#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 gPciRootBridge \
PNPID_DEVICE_PATH_NODE(0x0A03)
#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 gEndEntire \
{ \
END_DEVICE_PATH_TYPE, \
END_ENTIRE_DEVICE_PATH_SUBTYPE, \
{ \
END_DEVICE_PATH_LENGTH, \
0 \
} \
}
#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 EFI_SYSTEM_TABLE_MAX_ADDRESS 0xFFFFFFFF
#define SYS_TABLE_PAD(ptr) (((~ptr) +1) & 0x07 )
//
// Platform Root Bridge
//
typedef struct {
ACPI_HID_DEVICE_PATH PciRootBridge;
EFI_DEVICE_PATH_PROTOCOL End;
} PLATFORM_ROOT_BRIDGE_DEVICE_PATH;
typedef struct {
ACPI_HID_DEVICE_PATH PciRootBridge;
PCI_DEVICE_PATH IsaBridge;
ACPI_HID_DEVICE_PATH Keyboard;
EFI_DEVICE_PATH_PROTOCOL End;
} PLATFORM_DUMMY_ISA_KEYBOARD_DEVICE_PATH;
typedef struct {
ACPI_HID_DEVICE_PATH PciRootBridge;
PCI_DEVICE_PATH IsaBridge;
ACPI_HID_DEVICE_PATH IsaSerial;
UART_DEVICE_PATH Uart;
VENDOR_DEVICE_PATH TerminalType;
EFI_DEVICE_PATH_PROTOCOL End;
} PLATFORM_DUMMY_ISA_SERIAL_DEVICE_PATH;
typedef struct {
ACPI_HID_DEVICE_PATH PciRootBridge;
PCI_DEVICE_PATH VgaDevice;
EFI_DEVICE_PATH_PROTOCOL End;
} PLATFORM_DUMMY_PCI_VGA_DEVICE_PATH;
typedef struct {
ACPI_HID_DEVICE_PATH PciRootBridge;
PCI_DEVICE_PATH PciBridge;
PCI_DEVICE_PATH SerialDevice;
UART_DEVICE_PATH Uart;
VENDOR_DEVICE_PATH TerminalType;
EFI_DEVICE_PATH_PROTOCOL End;
} PLATFORM_DUMMY_PCI_SERIAL_DEVICE_PATH;
//
// the short form device path for Usb keyboard
//
#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 PLATFORM_ROOT_BRIDGE_DEVICE_PATH gPlatformRootBridge0;
//
// Platform BDS Functions
//
VOID
PlatformBdsGetDriverOption (
IN LIST_ENTRY *BdsDriverLists
);
EFI_STATUS
BdsMemoryTest (
EXTENDMEM_COVERAGE_LEVEL Level
);
EFI_STATUS
PlatformBdsShowProgress (
EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleForeground,
EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleBackground,
CHAR16 *Title,
EFI_GRAPHICS_OUTPUT_BLT_PIXEL ProgressColor,
UINTN Progress,
UINTN PreviousValue
);
VOID
PlatformBdsConnectSequence (
VOID
);
EFI_STATUS
ProcessCapsules (
EFI_BOOT_MODE BootMode
);
EFI_STATUS
PlatformBdsConnectConsole (
IN BDS_CONSOLE_CONNECT_ENTRY *PlatformConsole
);
EFI_STATUS
PlatformBdsNoConsoleAction (
VOID
);
EFI_STATUS
ConvertMpsTable (
IN OUT VOID **Table
);
EFI_STATUS
ConvertSmbiosTable (
IN OUT VOID **Table
);
EFI_STATUS
ConvertAcpiTable (
IN UINTN TableLen,
IN OUT VOID **Table
);
EFI_STATUS
ConvertSystemTable (
IN EFI_GUID *TableGuid,
IN OUT VOID **Table
);
VOID
PlatformBdsEnterFrontPage (
IN UINT16 TimeoutDefault,
IN BOOLEAN ConnectAllHappened
);
#endif // _PLATFORM_SPECIFIC_BDS_PLATFORM_H_

View File

@ -0,0 +1,66 @@
## @file
#
# Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# PlatformBds.inf
#
# Abstract:
#
# Component description file for Bds module.
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = CorebootBds
FILE_GUID = A6F691AC-31C8-4444-854C-E2C1A6950F92
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
LIBRARY_CLASS = PlatformBdsLib|DXE_DRIVER
[Sources]
BdsPlatform.c
PlatformData.c
BdsPlatform.h
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
CorebootModulePkg/CorebootModulePkg.dec
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
[LibraryClasses]
BaseLib
MemoryAllocationLib
UefiBootServicesTableLib
BaseMemoryLib
DebugLib
PcdLib
GenericBdsLib
HobLib
UefiLib
DevicePathLib
[Guids]
gEfiGlobalVariableGuid
gEfiPciExpressBaseAddressGuid
gEfiAcpi20TableGuid
gEfiMpsTableGuid
gEfiSmbiosTableGuid
gEfiAcpiTableGuid
gLdrMemoryDescriptorGuid
gEfiEndOfDxeEventGroupGuid
[Pcd]
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile

View File

@ -0,0 +1,161 @@
/*++
Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
PlatformData.c
Abstract:
Defined the platform specific device path which will be used by
platform Bbd to perform the platform policy connect.
--*/
#include "BdsPlatform.h"
//
// Predefined platform default time out value
//
UINT16 gPlatformBootTimeOutDefault = 3;
ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode = gPnpPs2Keyboard;
ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode = gPnp16550ComPort;
UART_DEVICE_PATH gUartDeviceNode = gUart;
VENDOR_DEVICE_PATH gTerminalTypeDeviceNode = gPcAnsiTerminal;
//
// Predefined platform root bridge
//
PLATFORM_ROOT_BRIDGE_DEVICE_PATH gPlatformRootBridge0 = {
gPciRootBridge,
gEndEntire
};
EFI_DEVICE_PATH_PROTOCOL *gPlatformRootBridges[] = {
(EFI_DEVICE_PATH_PROTOCOL *) &gPlatformRootBridge0,
NULL
};
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
},
{
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
END_DEVICE_PATH_LENGTH,
0
}
}
};
/*
//
// Platform specific Dummy ISA keyboard device path
//
PLATFORM_DUMMY_ISA_KEYBOARD_DEVICE_PATH gDummyIsaKeyboardDevicePath = {
gPciRootBridge,
gPciIsaBridge,
gPnpPs2Keyboard,
gEndEntire
};
//
// Platform specific Dummy ISA serial device path
//
PLATFORM_DUMMY_ISA_SERIAL_DEVICE_PATH gDummyIsaSerialDevicePath = {
gPciRootBridge,
gPciIsaBridge,
gPnp16550ComPort,
gUart,
gPcAnsiTerminal,
gEndEntire
};
//
// Platform specific Dummy PCI VGA device path
//
PLATFORM_DUMMY_PCI_VGA_DEVICE_PATH gDummyPciVgaDevicePath = {
gPciRootBridge,
PCI_DEVICE_PATH_NODE(0, 0x2),
gEndEntire
};
//
// Platform specific Dummy PCI serial device path
//
PLATFORM_DUMMY_PCI_SERIAL_DEVICE_PATH gDummyPciSerialDevicePath = {
gPciRootBridge,
gP2PBridge,
PCI_DEVICE_PATH_NODE(0, 0x0),
gUart,
gPcAnsiTerminal,
gEndEntire
};
*/
//
// Predefined platform default console device path
//
BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = {
//
// need update dynamically
//
// {
// (EFI_DEVICE_PATH_PROTOCOL *) &gDummyIsaSerialDevicePath,
// (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)
// },
// {
// (EFI_DEVICE_PATH_PROTOCOL *) &gDummyIsaKeyboardDevicePath,
// (CONSOLE_IN | STD_ERROR)
// },
// {
// (EFI_DEVICE_PATH_PROTOCOL *) &gDummyPciVgaDevicePath,
// CONSOLE_OUT
// },
// {
// (EFI_DEVICE_PATH_PROTOCOL *) &gDummyPciSerialDevicePath,
// (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)
// },
{
(EFI_DEVICE_PATH_PROTOCOL*) &gUsbClassKeyboardDevicePath,
CONSOLE_IN
},
{
NULL,
0
}
};
//
// Predefined platform specific driver option
//
EFI_DEVICE_PATH_PROTOCOL *gPlatformDriverOption[] = { NULL };
//
// Predefined platform connect sequence
//
EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[] = { NULL };

View File

@ -0,0 +1,161 @@
/*++
Copyright (c) 2005 - 2007, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
ComponentName.c
Abstract:
--*/
#include "PciBus.h"
//
// EFI Component Name Functions
//
EFI_STATUS
EFIAPI
PciBusComponentNameGetDriverName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
OUT CHAR16 **DriverName
);
EFI_STATUS
EFIAPI
PciBusComponentNameGetControllerName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
);
//
// EFI Component Name Protocol
//
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gPciBusComponentName = {
PciBusComponentNameGetDriverName,
PciBusComponentNameGetControllerName,
"eng"
};
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPciBusComponentName2 = {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) PciBusComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) PciBusComponentNameGetControllerName,
"en"
};
EFI_UNICODE_STRING_TABLE mPciBusDriverNameTable[] = {
{ "eng;en", L"PCI Bus Driver" },
{ NULL, NULL }
};
EFI_STATUS
EFIAPI
PciBusComponentNameGetDriverName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
OUT CHAR16 **DriverName
)
/*++
Routine Description:
Retrieves a Unicode string that is the user readable name of the EFI Driver.
Arguments:
This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
Language - A pointer to a three character ISO 639-2 language identifier.
This is the language of the driver name that that the caller
is requesting, and it must match one of the languages specified
in SupportedLanguages. The number of languages supported by a
driver is up to the driver writer.
DriverName - A pointer to the Unicode string to return. This Unicode string
is the name of the driver specified by This in the language
specified by Language.
Returns:
EFI_SUCCESS - The Unicode string for the Driver specified by This
and the language specified by Language was returned
in DriverName.
EFI_INVALID_PARAMETER - Language is NULL.
EFI_INVALID_PARAMETER - DriverName is NULL.
EFI_UNSUPPORTED - The driver specified by This does not support the
language specified by Language.
--*/
{
return LookupUnicodeString2 (
Language,
This->SupportedLanguages,
mPciBusDriverNameTable,
DriverName,
(BOOLEAN)(This == &gPciBusComponentName)
);
}
EFI_STATUS
EFIAPI
PciBusComponentNameGetControllerName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
)
/*++
Routine Description:
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by an EFI Driver.
Arguments:
This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
ControllerHandle - The handle of a controller that the driver specified by
This is managing. This handle specifies the controller
whose name is to be returned.
ChildHandle - The handle of the child controller to retrieve the name
of. This is an optional parameter that may be NULL. It
will be NULL for device drivers. It will also be NULL
for a bus drivers that wish to retrieve the name of the
bus controller. It will not be NULL for a bus driver
that wishes to retrieve the name of a child controller.
Language - A pointer to a three character ISO 639-2 language
identifier. This is the language of the controller name
that that the caller is requesting, and it must match one
of the languages specified in SupportedLanguages. The
number of languages supported by a driver is up to the
driver writer.
ControllerName - A pointer to the Unicode string to return. This Unicode
string is the name of the controller specified by
ControllerHandle and ChildHandle in the language specified
by Language from the point of view of the driver specified
by This.
Returns:
EFI_SUCCESS - The Unicode string for the user readable name in the
language specified by Language for the driver
specified by This was returned in DriverName.
EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
EFI_INVALID_PARAMETER - Language is NULL.
EFI_INVALID_PARAMETER - ControllerName is NULL.
EFI_UNSUPPORTED - The driver specified by This is not currently managing
the controller specified by ControllerHandle and
ChildHandle.
EFI_UNSUPPORTED - The driver specified by This does not support the
language specified by Language.
--*/
{
return EFI_UNSUPPORTED;
}

View File

@ -0,0 +1,346 @@
/*++
Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
PciBus.c
Abstract:
PCI Bus Driver
Revision History
--*/
#include "PciBus.h"
//
// PCI Bus Support Function Prototypes
//
EFI_STATUS
EFIAPI
PciBusEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
EFI_STATUS
EFIAPI
PciBusDriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
);
EFI_STATUS
EFIAPI
PciBusDriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
);
EFI_STATUS
EFIAPI
PciBusDriverBindingStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer
);
//
// PCI Bus Driver Global Variables
//
EFI_DRIVER_BINDING_PROTOCOL gPciBusDriverBinding = {
PciBusDriverBindingSupported,
PciBusDriverBindingStart,
PciBusDriverBindingStop,
0xa,
NULL,
NULL
};
BOOLEAN gFullEnumeration;
UINT64 gAllOne = 0xFFFFFFFFFFFFFFFFULL;
UINT64 gAllZero = 0;
//
// PCI Bus Driver Support Functions
//
EFI_STATUS
EFIAPI
PciBusEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
/*++
Routine Description:
Initialize the global variables
publish the driver binding protocol
Arguments:
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
Returns:
EFI_SUCCESS
EFI_DEVICE_ERROR
--*/
{
EFI_STATUS Status;
//
// Initialize the EFI Driver Library
//
Status = EfiLibInstallDriverBindingComponentName2 (
ImageHandle,
SystemTable,
&gPciBusDriverBinding,
ImageHandle,
&gPciBusComponentName,
&gPciBusComponentName2
);
ASSERT_EFI_ERROR (Status);
InitializePciDevicePool ();
gFullEnumeration = TRUE;
return Status;
}
EFI_STATUS
EFIAPI
PciBusDriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
/*++
Routine Description:
Check to see if pci bus driver supports the given controller
Arguments:
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
Returns:
EFI_SUCCESS
--*/
{
EFI_STATUS Status;
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;
EFI_DEV_PATH_PTR Node;
if (RemainingDevicePath != NULL) {
Node.DevPath = RemainingDevicePath;
if (Node.DevPath->Type != HARDWARE_DEVICE_PATH ||
Node.DevPath->SubType != HW_PCI_DP ||
DevicePathNodeLength(Node.DevPath) != sizeof(PCI_DEVICE_PATH)) {
return EFI_UNSUPPORTED;
}
}
//
// Open the IO Abstraction(s) needed to perform the supported test
//
Status = gBS->OpenProtocol (
Controller,
&gEfiDevicePathProtocolGuid,
(VOID **) &ParentDevicePath,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (Status == EFI_ALREADY_STARTED) {
return EFI_SUCCESS;
}
if (EFI_ERROR (Status)) {
return Status;
}
gBS->CloseProtocol (
Controller,
&gEfiDevicePathProtocolGuid,
This->DriverBindingHandle,
Controller
);
Status = gBS->OpenProtocol (
Controller,
&gEfiPciRootBridgeIoProtocolGuid,
(VOID **) &PciRootBridgeIo,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (Status == EFI_ALREADY_STARTED) {
return EFI_SUCCESS;
}
if (EFI_ERROR (Status)) {
return Status;
}
gBS->CloseProtocol (
Controller,
&gEfiPciRootBridgeIoProtocolGuid,
This->DriverBindingHandle,
Controller
);
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
PciBusDriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
/*++
Routine Description:
Start to management the controller passed in
Arguments:
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
Returns:
--*/
{
EFI_STATUS Status;
//
// Enumerate the entire host bridge
// After enumeration, a database that records all the device information will be created
//
//
Status = PciEnumerator (Controller);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Enable PCI device specified by remaining device path. BDS or other driver can call the
// start more than once.
//
StartPciDevices (Controller, RemainingDevicePath);
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
PciBusDriverBindingStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer
)
/*++
Routine Description:
Stop one or more children created at start of pci bus driver
if all the the children get closed, close the protocol
Arguments:
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer
Returns:
--*/
{
EFI_STATUS Status;
UINTN Index;
BOOLEAN AllChildrenStopped;
if (NumberOfChildren == 0) {
//
// Close the bus driver
//
gBS->CloseProtocol (
Controller,
&gEfiDevicePathProtocolGuid,
This->DriverBindingHandle,
Controller
);
gBS->CloseProtocol (
Controller,
&gEfiPciRootBridgeIoProtocolGuid,
This->DriverBindingHandle,
Controller
);
DestroyRootBridgeByHandle (
Controller
);
return EFI_SUCCESS;
}
//
// Stop all the children
//
AllChildrenStopped = TRUE;
for (Index = 0; Index < NumberOfChildren; Index++) {
//
// De register all the pci device
//
Status = DeRegisterPciDevice (Controller, ChildHandleBuffer[Index]);
if (EFI_ERROR (Status)) {
AllChildrenStopped = FALSE;
}
}
if (!AllChildrenStopped) {
return EFI_DEVICE_ERROR;
}
return EFI_SUCCESS;
}

View File

@ -0,0 +1,225 @@
/*++
Copyright (c) 2005 - 2007, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
PciBus.h
Abstract:
PCI Bus Driver
Revision History
--*/
#ifndef _EFI_PCI_BUS_H
#define _EFI_PCI_BUS_H
#include <PiDxe.h>
#include <Protocol/PciIo.h>
#include <Protocol/PciRootBridgeIo.h>
#include <Protocol/DevicePath.h>
#include <Protocol/Decompress.h>
#include <Protocol/UgaIo.h>
#include <Protocol/LoadedImage.h>
#include <Protocol/BusSpecificDriverOverride.h>
#include <Guid/PciOptionRomTable.h>
#include <IndustryStandard/Pci.h>
#include <IndustryStandard/Acpi.h>
#include <IndustryStandard/PeImage.h>
#include <Library/DebugLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/BaseLib.h>
#include <Library/UefiLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/ReportStatusCodeLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/DevicePathLib.h>
#include <Library/PcdLib.h>
#include <Library/PeCoffLib.h>
//
// Driver Produced Protocol Prototypes
//
#define VGABASE1 0x3B0
#define VGALIMIT1 0x3BB
#define VGABASE2 0x3C0
#define VGALIMIT2 0x3DF
#define ISABASE 0x100
#define ISALIMIT 0x3FF
typedef enum {
PciBarTypeUnknown = 0,
PciBarTypeIo16,
PciBarTypeIo32,
PciBarTypeMem32,
PciBarTypePMem32,
PciBarTypeMem64,
PciBarTypePMem64,
PciBarTypeIo,
PciBarTypeMem,
PciBarTypeMaxType
} PCI_BAR_TYPE;
typedef struct {
UINT64 BaseAddress;
UINT64 Length;
UINT64 Alignment;
PCI_BAR_TYPE BarType;
BOOLEAN Prefetchable;
UINT8 MemType;
UINT8 Offset;
} PCI_BAR;
#define PCI_IO_DEVICE_SIGNATURE SIGNATURE_32 ('p','c','i','o')
#define EFI_BRIDGE_IO32_DECODE_SUPPORTED 0x0001
#define EFI_BRIDGE_PMEM32_DECODE_SUPPORTED 0x0002
#define EFI_BRIDGE_PMEM64_DECODE_SUPPORTED 0x0004
#define EFI_BRIDGE_IO16_DECODE_SUPPORTED 0x0008
#define EFI_BRIDGE_PMEM_MEM_COMBINE_SUPPORTED 0x0010
#define EFI_BRIDGE_MEM64_DECODE_SUPPORTED 0x0020
#define EFI_BRIDGE_MEM32_DECODE_SUPPORTED 0x0040
typedef struct _PCI_IO_DEVICE {
UINT32 Signature;
EFI_HANDLE Handle;
EFI_PCI_IO_PROTOCOL PciIo;
LIST_ENTRY Link;
EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL PciDriverOverride;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;
//
// PCI configuration space header type
//
PCI_TYPE00 Pci;
//
// Bus number, Device number, Function number
//
UINT8 BusNumber;
UINT8 DeviceNumber;
UINT8 FunctionNumber;
//
// BAR for this PCI Device
//
PCI_BAR PciBar[PCI_MAX_BAR];
//
// The bridge device this pci device is subject to
//
struct _PCI_IO_DEVICE *Parent;
//
// A linked list for children Pci Device if it is bridge device
//
LIST_ENTRY ChildList;
//
// TRUE if the PCI bus driver creates the handle for this PCI device
//
BOOLEAN Registered;
//
// TRUE if the PCI bus driver successfully allocates the resource required by
// this PCI device
//
BOOLEAN Allocated;
//
// The attribute this PCI device currently set
//
UINT64 Attributes;
//
// The attributes this PCI device actually supports
//
UINT64 Supports;
//
// The resource decode the bridge supports
//
UINT32 Decodes;
//
// The OptionRom Size
//
UINT64 RomSize;
//
// TRUE if there is any EFI driver in the OptionRom
//
BOOLEAN BusOverride;
//
// A list tracking reserved resource on a bridge device
//
LIST_ENTRY ReservedResourceList;
//
// A list tracking image handle of platform specific overriding driver
//
LIST_ENTRY OptionRomDriverList;
BOOLEAN IsPciExp;
} PCI_IO_DEVICE;
#define PCI_IO_DEVICE_FROM_PCI_IO_THIS(a) \
CR (a, PCI_IO_DEVICE, PciIo, PCI_IO_DEVICE_SIGNATURE)
#define PCI_IO_DEVICE_FROM_PCI_DRIVER_OVERRIDE_THIS(a) \
CR (a, PCI_IO_DEVICE, PciDriverOverride, PCI_IO_DEVICE_SIGNATURE)
#define PCI_IO_DEVICE_FROM_LINK(a) \
CR (a, PCI_IO_DEVICE, Link, PCI_IO_DEVICE_SIGNATURE)
//
// Global Variables
//
extern EFI_COMPONENT_NAME_PROTOCOL gPciBusComponentName;
extern EFI_COMPONENT_NAME2_PROTOCOL gPciBusComponentName2;
extern EFI_DRIVER_BINDING_PROTOCOL gPciBusDriverBinding;
extern BOOLEAN gFullEnumeration;
extern UINT64 gAllOne;
extern UINT64 gAllZero;
#include "PciIo.h"
#include "PciCommand.h"
#include "PciDeviceSupport.h"
#include "PciEnumerator.h"
#include "PciEnumeratorSupport.h"
#include "PciDriverOverride.h"
#include "PciRomTable.h"
#include "PciOptionRomSupport.h"
#include "PciPowerManagement.h"
#define IS_ISA_BRIDGE(_p) IS_CLASS2 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA)
#define IS_INTEL_ISA_BRIDGE(_p) (IS_CLASS2 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA_PDECODE) && ((_p)->Hdr.VendorId == 0x8086) && ((_p)->Hdr.DeviceId == 0x7110))
#define IS_PCI_GFX(_p) IS_CLASS2 (_p, PCI_CLASS_DISPLAY, PCI_CLASS_DISPLAY_OTHER)
#endif

View File

@ -0,0 +1,72 @@
## @file
#
# Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# Abstract:
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = PciBusNoEnumerationDxe
FILE_GUID = 35C0C168-2607-4e51-BB53-448E3ED1A87F
MODULE_TYPE = UEFI_DRIVER
VERSION_STRING = 1.0
ENTRY_POINT = PciBusEntryPoint
[Packages]
MdePkg/MdePkg.dec
CorebootModulePkg/CorebootModulePkg.dec
[LibraryClasses]
DebugLib
BaseLib
UefiLib
UefiBootServicesTableLib
UefiDriverEntryPoint
BaseMemoryLib
ReportStatusCodeLib
DevicePathLib
PeCoffLib
[Sources]
PciBus.h
PciIo.h
PciCommand.h
PciDeviceSupport.h
PciEnumerator.h
PciEnumeratorSupport.h
PciOptionRomSupport.h
PciRomTable.h
PciPowerManagement.h
PciPowerManagement.c
PciRomTable.c
PciDriverOverride.h
PciDriverOverride.c
PciOptionRomSupport.c
PciEnumerator.c
PciEnumeratorSupport.c
PciCommand.c
ComponentName.c
PciDeviceSupport.c
PciBus.c
PciIo.c
[Protocols]
gEfiPciRootBridgeIoProtocolGuid
gEfiPciIoProtocolGuid
gEfiDevicePathProtocolGuid
gEfiBusSpecificDriverOverrideProtocolGuid
gEfiDecompressProtocolGuid
[Guids]
gEfiPciOptionRomTableGuid

View File

@ -0,0 +1,453 @@
/*++
Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
PciCommand.c
Abstract:
PCI Bus Driver
Revision History
--*/
#include "PciBus.h"
EFI_STATUS
PciReadCommandRegister (
IN PCI_IO_DEVICE *PciIoDevice,
OUT UINT16 *Command
)
/*++
Routine Description:
Arguments:
Returns:
None
--*/
{
EFI_PCI_IO_PROTOCOL *PciIo;
*Command = 0;
PciIo = &PciIoDevice->PciIo;
return PciIo->Pci.Read (
PciIo,
EfiPciIoWidthUint16,
PCI_COMMAND_OFFSET,
1,
Command
);
}
EFI_STATUS
PciSetCommandRegister (
IN PCI_IO_DEVICE *PciIoDevice,
IN UINT16 Command
)
/*++
Routine Description:
Arguments:
Returns:
None
--*/
{
UINT16 Temp;
EFI_PCI_IO_PROTOCOL *PciIo;
Temp = Command;
PciIo = &PciIoDevice->PciIo;
return PciIo->Pci.Write (
PciIo,
EfiPciIoWidthUint16,
PCI_COMMAND_OFFSET,
1,
&Temp
);
}
EFI_STATUS
PciEnableCommandRegister (
IN PCI_IO_DEVICE *PciIoDevice,
IN UINT16 Command
)
/*++
Routine Description:
Arguments:
Returns:
None
--*/
{
UINT16 OldCommand;
EFI_PCI_IO_PROTOCOL *PciIo;
OldCommand = 0;
PciIo = &PciIoDevice->PciIo;
PciIo->Pci.Read (
PciIo,
EfiPciIoWidthUint16,
PCI_COMMAND_OFFSET,
1,
&OldCommand
);
OldCommand = (UINT16) (OldCommand | Command);
return PciIo->Pci.Write (
PciIo,
EfiPciIoWidthUint16,
PCI_COMMAND_OFFSET,
1,
&OldCommand
);
}
EFI_STATUS
PciDisableCommandRegister (
IN PCI_IO_DEVICE *PciIoDevice,
IN UINT16 Command
)
/*++
Routine Description:
Arguments:
Returns:
None
--*/
{
UINT16 OldCommand;
EFI_PCI_IO_PROTOCOL *PciIo;
OldCommand = 0;
PciIo = &PciIoDevice->PciIo;
PciIo->Pci.Read (
PciIo,
EfiPciIoWidthUint16,
PCI_COMMAND_OFFSET,
1,
&OldCommand
);
OldCommand = (UINT16) (OldCommand & ~(Command));
return PciIo->Pci.Write (
PciIo,
EfiPciIoWidthUint16,
PCI_COMMAND_OFFSET,
1,
&OldCommand
);
}
EFI_STATUS
PciSetBridgeControlRegister (
IN PCI_IO_DEVICE *PciIoDevice,
IN UINT16 Command
)
/*++
Routine Description:
Arguments:
Returns:
None
--*/
{
UINT16 Temp;
EFI_PCI_IO_PROTOCOL *PciIo;
Temp = Command;
PciIo = &PciIoDevice->PciIo;
return PciIo->Pci.Write (
PciIo,
EfiPciIoWidthUint16,
PCI_BRIDGE_CONTROL_REGISTER_OFFSET,
1,
&Temp
);
}
EFI_STATUS
PciEnableBridgeControlRegister (
IN PCI_IO_DEVICE *PciIoDevice,
IN UINT16 Command
)
/*++
Routine Description:
Arguments:
Returns:
None
--*/
{
UINT16 OldCommand;
EFI_PCI_IO_PROTOCOL *PciIo;
OldCommand = 0;
PciIo = &PciIoDevice->PciIo;
PciIo->Pci.Read (
PciIo,
EfiPciIoWidthUint16,
PCI_BRIDGE_CONTROL_REGISTER_OFFSET,
1,
&OldCommand
);
OldCommand = (UINT16) (OldCommand | Command);
return PciIo->Pci.Write (
PciIo,
EfiPciIoWidthUint16,
PCI_BRIDGE_CONTROL_REGISTER_OFFSET,
1,
&OldCommand
);
}
EFI_STATUS
PciDisableBridgeControlRegister (
IN PCI_IO_DEVICE *PciIoDevice,
IN UINT16 Command
)
/*++
Routine Description:
Arguments:
Returns:
None
--*/
{
UINT16 OldCommand;
EFI_PCI_IO_PROTOCOL *PciIo;
OldCommand = 0;
PciIo = &PciIoDevice->PciIo;
PciIo->Pci.Read (
PciIo,
EfiPciIoWidthUint16,
PCI_BRIDGE_CONTROL_REGISTER_OFFSET,
1,
&OldCommand
);
OldCommand = (UINT16) (OldCommand & ~(Command));
return PciIo->Pci.Write (
PciIo,
EfiPciIoWidthUint16,
PCI_BRIDGE_CONTROL_REGISTER_OFFSET,
1,
&OldCommand
);
}
EFI_STATUS
PciReadBridgeControlRegister (
IN PCI_IO_DEVICE *PciIoDevice,
OUT UINT16 *Command
)
/*++
Routine Description:
Arguments:
Returns:
None
--*/
{
EFI_PCI_IO_PROTOCOL *PciIo;
*Command = 0;
PciIo = &PciIoDevice->PciIo;
return PciIo->Pci.Read (
PciIo,
EfiPciIoWidthUint16,
PCI_BRIDGE_CONTROL_REGISTER_OFFSET,
1,
Command
);
}
BOOLEAN
PciCapabilitySupport (
IN PCI_IO_DEVICE *PciIoDevice
)
/*++
Routine Description:
Arguments:
Returns:
None
--*/
// TODO: PciIoDevice - add argument and description to function comment
{
if (PciIoDevice->Pci.Hdr.Status & EFI_PCI_STATUS_CAPABILITY) {
return TRUE;
}
return FALSE;
}
EFI_STATUS
LocateCapabilityRegBlock (
IN PCI_IO_DEVICE *PciIoDevice,
IN UINT8 CapId,
IN OUT UINT8 *Offset,
OUT UINT8 *NextRegBlock OPTIONAL
)
/*++
Routine Description:
Locate Capability register.
Arguments:
PciIoDevice - A pointer to the PCI_IO_DEVICE.
CapId - The capability ID.
Offset - A pointer to the offset.
As input: the default offset;
As output: the offset of the found block.
NextRegBlock - An optional pointer to return the value of next block.
Returns:
EFI_UNSUPPORTED - The Pci Io device is not supported.
EFI_NOT_FOUND - The Pci Io device cannot be found.
EFI_SUCCESS - The Pci Io device is successfully located.
--*/
{
UINT8 CapabilityPtr;
UINT16 CapabilityEntry;
UINT8 CapabilityID;
//
// To check the capability of this device supports
//
if (!PciCapabilitySupport (PciIoDevice)) {
return EFI_UNSUPPORTED;
}
if (*Offset != 0) {
CapabilityPtr = *Offset;
} else {
CapabilityPtr = 0;
if (IS_CARDBUS_BRIDGE (&PciIoDevice->Pci)) {
PciIoDevice->PciIo.Pci.Read (
&PciIoDevice->PciIo,
EfiPciIoWidthUint8,
EFI_PCI_CARDBUS_BRIDGE_CAPABILITY_PTR,
1,
&CapabilityPtr
);
} else {
PciIoDevice->PciIo.Pci.Read (
&PciIoDevice->PciIo,
EfiPciIoWidthUint8,
PCI_CAPBILITY_POINTER_OFFSET,
1,
&CapabilityPtr
);
}
}
while ((CapabilityPtr >= 0x40) && ((CapabilityPtr & 0x03) == 0x00)) {
PciIoDevice->PciIo.Pci.Read (
&PciIoDevice->PciIo,
EfiPciIoWidthUint16,
CapabilityPtr,
1,
&CapabilityEntry
);
CapabilityID = (UINT8) CapabilityEntry;
if (CapabilityID == CapId) {
*Offset = CapabilityPtr;
if (NextRegBlock != NULL) {
*NextRegBlock = (UINT8) (CapabilityEntry >> 8);
}
return EFI_SUCCESS;
}
CapabilityPtr = (UINT8) (CapabilityEntry >> 8);
}
return EFI_NOT_FOUND;
}

View File

@ -0,0 +1,167 @@
/*++
Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
PciCommand.h
Abstract:
PCI Bus Driver
Revision History
--*/
#ifndef _EFI_PCI_COMMAND_H
#define _EFI_PCI_COMMAND_H
#include "PciBus.h"
//
// The PCI Command register bits owned by PCI Bus driver.
//
// They should be cleared at the beginning. The other registers
// are owned by chipset, we should not touch them.
//
#define EFI_PCI_COMMAND_BITS_OWNED ( \
EFI_PCI_COMMAND_IO_SPACE | \
EFI_PCI_COMMAND_MEMORY_SPACE | \
EFI_PCI_COMMAND_BUS_MASTER | \
EFI_PCI_COMMAND_MEMORY_WRITE_AND_INVALIDATE | \
EFI_PCI_COMMAND_VGA_PALETTE_SNOOP | \
EFI_PCI_COMMAND_FAST_BACK_TO_BACK \
)
//
// The PCI Bridge Control register bits owned by PCI Bus driver.
//
// They should be cleared at the beginning. The other registers
// are owned by chipset, we should not touch them.
//
#define EFI_PCI_BRIDGE_CONTROL_BITS_OWNED ( \
EFI_PCI_BRIDGE_CONTROL_ISA | \
EFI_PCI_BRIDGE_CONTROL_VGA | \
EFI_PCI_BRIDGE_CONTROL_VGA_16 | \
EFI_PCI_BRIDGE_CONTROL_FAST_BACK_TO_BACK \
)
//
// The PCCard Bridge Control register bits owned by PCI Bus driver.
//
// They should be cleared at the beginning. The other registers
// are owned by chipset, we should not touch them.
//
#define EFI_PCCARD_BRIDGE_CONTROL_BITS_OWNED ( \
EFI_PCI_BRIDGE_CONTROL_ISA | \
EFI_PCI_BRIDGE_CONTROL_VGA | \
EFI_PCI_BRIDGE_CONTROL_FAST_BACK_TO_BACK \
)
EFI_STATUS
PciReadCommandRegister (
IN PCI_IO_DEVICE *PciIoDevice,
OUT UINT16 *Command
);
EFI_STATUS
PciSetCommandRegister (
IN PCI_IO_DEVICE *PciIoDevice,
IN UINT16 Command
);
EFI_STATUS
PciEnableCommandRegister (
IN PCI_IO_DEVICE *PciIoDevice,
IN UINT16 Command
);
EFI_STATUS
PciDisableCommandRegister (
IN PCI_IO_DEVICE *PciIoDevice,
IN UINT16 Command
);
EFI_STATUS
PciDisableBridgeControlRegister (
IN PCI_IO_DEVICE *PciIoDevice,
IN UINT16 Command
);
EFI_STATUS
PciEnableBridgeControlRegister (
IN PCI_IO_DEVICE *PciIoDevice,
IN UINT16 Command
);
EFI_STATUS
PciReadBridgeControlRegister (
IN PCI_IO_DEVICE *PciIoDevice,
OUT UINT16 *Command
);
BOOLEAN
PciCapabilitySupport (
IN PCI_IO_DEVICE *PciIoDevice
)
/*++
Routine Description:
TODO: Add function description
Arguments:
PciIoDevice - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
LocateCapabilityRegBlock (
IN PCI_IO_DEVICE *PciIoDevice,
IN UINT8 CapId,
IN OUT UINT8 *Offset,
OUT UINT8 *NextRegBlock OPTIONAL
)
/*++
Routine Description:
Locate Capability register.
Arguments:
PciIoDevice - A pointer to the PCI_IO_DEVICE.
CapId - The capability ID.
Offset - A pointer to the offset.
As input: the default offset;
As output: the offset of the found block.
NextRegBlock - An optional pointer to return the value of next block.
Returns:
EFI_UNSUPPORTED - The Pci Io device is not supported.
EFI_NOT_FOUND - The Pci Io device cannot be found.
EFI_SUCCESS - The Pci Io device is successfully located.
--*/
;
#endif

View File

@ -0,0 +1,973 @@
/*++
Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
PciDeviceSupport.c
Abstract:
This file provides routine to support Pci device node manipulation
Revision History
--*/
#include "PciBus.h"
//
// This device structure is serviced as a header.
// Its Next field points to the first root bridge device node
//
LIST_ENTRY gPciDevicePool;
EFI_STATUS
InitializePciDevicePool (
VOID
)
/*++
Routine Description:
Initialize the gPciDevicePool
Arguments:
Returns:
None
--*/
{
InitializeListHead (&gPciDevicePool);
return EFI_SUCCESS;
}
EFI_STATUS
InsertRootBridge (
IN PCI_IO_DEVICE *RootBridge
)
/*++
Routine Description:
Insert a root bridge into PCI device pool
Arguments:
RootBridge - A pointer to the PCI_IO_DEVICE.
Returns:
None
--*/
{
InsertTailList (&gPciDevicePool, &(RootBridge->Link));
return EFI_SUCCESS;
}
EFI_STATUS
InsertPciDevice (
PCI_IO_DEVICE *Bridge,
PCI_IO_DEVICE *PciDeviceNode
)
/*++
Routine Description:
This function is used to insert a PCI device node under
a bridge
Arguments:
Bridge - A pointer to the PCI_IO_DEVICE.
PciDeviceNode - A pointer to the PCI_IO_DEVICE.
Returns:
None
--*/
{
InsertTailList (&Bridge->ChildList, &(PciDeviceNode->Link));
PciDeviceNode->Parent = Bridge;
return EFI_SUCCESS;
}
EFI_STATUS
DestroyRootBridge (
IN PCI_IO_DEVICE *RootBridge
)
/*++
Routine Description:
Arguments:
RootBridge - A pointer to the PCI_IO_DEVICE.
Returns:
None
--*/
{
DestroyPciDeviceTree (RootBridge);
gBS->FreePool (RootBridge);
return EFI_SUCCESS;
}
EFI_STATUS
DestroyPciDeviceTree (
IN PCI_IO_DEVICE *Bridge
)
/*++
Routine Description:
Destroy all the pci device node under the bridge.
Bridge itself is not included.
Arguments:
Bridge - A pointer to the PCI_IO_DEVICE.
Returns:
None
--*/
{
LIST_ENTRY *CurrentLink;
PCI_IO_DEVICE *Temp;
while (!IsListEmpty (&Bridge->ChildList)) {
CurrentLink = Bridge->ChildList.ForwardLink;
//
// Remove this node from the linked list
//
RemoveEntryList (CurrentLink);
Temp = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
if (IS_PCI_BRIDGE (&(Temp->Pci))) {
DestroyPciDeviceTree (Temp);
}
gBS->FreePool (Temp);
}
return EFI_SUCCESS;
}
EFI_STATUS
DestroyRootBridgeByHandle (
EFI_HANDLE Controller
)
/*++
Routine Description:
Destroy all device nodes under the root bridge
specified by Controller.
The root bridge itself is also included.
Arguments:
Controller - An efi handle.
Returns:
None
--*/
{
LIST_ENTRY *CurrentLink;
PCI_IO_DEVICE *Temp;
CurrentLink = gPciDevicePool.ForwardLink;
while (CurrentLink && CurrentLink != &gPciDevicePool) {
Temp = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
if (Temp->Handle == Controller) {
RemoveEntryList (CurrentLink);
DestroyPciDeviceTree (Temp);
gBS->FreePool(Temp);
return EFI_SUCCESS;
}
CurrentLink = CurrentLink->ForwardLink;
}
return EFI_NOT_FOUND;
}
EFI_STATUS
RegisterPciDevice (
IN EFI_HANDLE Controller,
IN PCI_IO_DEVICE *PciIoDevice,
OUT EFI_HANDLE *Handle OPTIONAL
)
/*++
Routine Description:
This function registers the PCI IO device. It creates a handle for this PCI IO device
(if the handle does not exist), attaches appropriate protocols onto the handle, does
necessary initialization, and sets up parent/child relationship with its bus controller.
Arguments:
Controller - An EFI handle for the PCI bus controller.
PciIoDevice - A PCI_IO_DEVICE pointer to the PCI IO device to be registered.
Handle - A pointer to hold the EFI handle for the PCI IO device.
Returns:
EFI_SUCCESS - The PCI device is successfully registered.
Others - An error occurred when registering the PCI device.
--*/
{
EFI_STATUS Status;
UINT8 PciExpressCapRegOffset;
//
// Install the pciio protocol, device path protocol and
// Bus Specific Driver Override Protocol
//
if (PciIoDevice->BusOverride) {
Status = gBS->InstallMultipleProtocolInterfaces (
&PciIoDevice->Handle,
&gEfiDevicePathProtocolGuid,
PciIoDevice->DevicePath,
&gEfiPciIoProtocolGuid,
&PciIoDevice->PciIo,
&gEfiBusSpecificDriverOverrideProtocolGuid,
&PciIoDevice->PciDriverOverride,
NULL
);
} else {
Status = gBS->InstallMultipleProtocolInterfaces (
&PciIoDevice->Handle,
&gEfiDevicePathProtocolGuid,
PciIoDevice->DevicePath,
&gEfiPciIoProtocolGuid,
&PciIoDevice->PciIo,
NULL
);
}
if (EFI_ERROR (Status)) {
return Status;
} else {
Status = gBS->OpenProtocol (
Controller,
&gEfiPciRootBridgeIoProtocolGuid,
(VOID **)&(PciIoDevice->PciRootBridgeIo),
gPciBusDriverBinding.DriverBindingHandle,
PciIoDevice->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
);
if (EFI_ERROR (Status)) {
return Status;
}
}
if (Handle != NULL) {
*Handle = PciIoDevice->Handle;
}
//
// Detect if PCI Express Device
//
PciExpressCapRegOffset = 0;
Status = LocateCapabilityRegBlock (
PciIoDevice,
EFI_PCI_CAPABILITY_ID_PCIEXP,
&PciExpressCapRegOffset,
NULL
);
if (!EFI_ERROR (Status)) {
PciIoDevice->IsPciExp = TRUE;
DEBUG ((EFI_D_ERROR, "PciExp - %x (B-%x, D-%x, F-%x)\n", PciIoDevice->IsPciExp, PciIoDevice->BusNumber, PciIoDevice->DeviceNumber, PciIoDevice->FunctionNumber));
}
//
// Indicate the pci device is registered
//
PciIoDevice->Registered = TRUE;
return EFI_SUCCESS;
}
EFI_STATUS
DeRegisterPciDevice (
IN EFI_HANDLE Controller,
IN EFI_HANDLE Handle
)
/*++
Routine Description:
This function is used to de-register the PCI device from the EFI,
That includes un-installing PciIo protocol from the specified PCI
device handle.
Arguments:
Controller - An efi handle.
Handle - An efi handle.
Returns:
None
--*/
{
EFI_PCI_IO_PROTOCOL *PciIo;
EFI_STATUS Status;
PCI_IO_DEVICE *PciIoDevice;
PCI_IO_DEVICE *Node;
LIST_ENTRY *CurrentLink;
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;
Status = gBS->OpenProtocol (
Handle,
&gEfiPciIoProtocolGuid,
(VOID **) &PciIo,
gPciBusDriverBinding.DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (!EFI_ERROR (Status)) {
PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (PciIo);
//
// If it is already de-registered
//
if (!PciIoDevice->Registered) {
return EFI_SUCCESS;
}
//
// If it is PPB, first de-register its children
//
if (IS_PCI_BRIDGE (&(PciIoDevice->Pci))) {
CurrentLink = PciIoDevice->ChildList.ForwardLink;
while (CurrentLink && CurrentLink != &PciIoDevice->ChildList) {
Node = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
Status = DeRegisterPciDevice (Controller, Node->Handle);
if (EFI_ERROR (Status)) {
return Status;
}
CurrentLink = CurrentLink->ForwardLink;
}
}
//
// First disconnect this device
//
// PciIoDevice->PciIo.Attributes(&(PciIoDevice->PciIo),
// EfiPciIoAttributeOperationDisable,
// EFI_PCI_DEVICE_ENABLE,
// NULL
// );
//
// Close the child handle
//
Status = gBS->CloseProtocol (
Controller,
&gEfiPciRootBridgeIoProtocolGuid,
gPciBusDriverBinding.DriverBindingHandle,
Handle
);
//
// Un-install the device path protocol and pci io protocol
//
if (PciIoDevice->BusOverride) {
Status = gBS->UninstallMultipleProtocolInterfaces (
Handle,
&gEfiDevicePathProtocolGuid,
PciIoDevice->DevicePath,
&gEfiPciIoProtocolGuid,
&PciIoDevice->PciIo,
&gEfiBusSpecificDriverOverrideProtocolGuid,
&PciIoDevice->PciDriverOverride,
NULL
);
} else {
Status = gBS->UninstallMultipleProtocolInterfaces (
Handle,
&gEfiDevicePathProtocolGuid,
PciIoDevice->DevicePath,
&gEfiPciIoProtocolGuid,
&PciIoDevice->PciIo,
NULL
);
}
if (EFI_ERROR (Status)) {
gBS->OpenProtocol (
Controller,
&gEfiPciRootBridgeIoProtocolGuid,
(VOID **) &PciRootBridgeIo,
gPciBusDriverBinding.DriverBindingHandle,
Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
);
return Status;
}
//
// The Device Driver should disable this device after disconnect
// so the Pci Bus driver will not touch this device any more.
// Restore the register field to the original value
//
PciIoDevice->Registered = FALSE;
PciIoDevice->Handle = NULL;
} else {
//
// Handle may be closed before
//
return EFI_SUCCESS;
}
return EFI_SUCCESS;
}
EFI_STATUS
EnableBridgeAttributes (
IN PCI_IO_DEVICE *PciIoDevice
)
{
PCI_TYPE01 PciData;
//
// NOTE: We should not set EFI_PCI_DEVICE_ENABLE for a bridge
// directly, because some legacy BIOS will NOT assign
// IO or Memory resource for a bridge who has no child
// device. So we add check IO or Memory here.
//
PciIoDevice->PciIo.Pci.Read (
&PciIoDevice->PciIo,
EfiPciIoWidthUint8,
0,
sizeof (PciData),
&PciData
);
if ((((PciData.Bridge.IoBase & 0xF) == 0) &&
(PciData.Bridge.IoBase != 0 || PciData.Bridge.IoLimit != 0)) ||
(((PciData.Bridge.IoBase & 0xF) == 1) &&
((PciData.Bridge.IoBase & 0xF0) != 0 || (PciData.Bridge.IoLimit & 0xF0) != 0 || PciData.Bridge.IoBaseUpper16 != 0 || PciData.Bridge.IoLimitUpper16 != 0))) {
PciIoDevice->PciIo.Attributes(
&(PciIoDevice->PciIo),
EfiPciIoAttributeOperationEnable,
(EFI_PCI_IO_ATTRIBUTE_IO | EFI_PCI_IO_ATTRIBUTE_BUS_MASTER),
NULL
);
}
if ((PciData.Bridge.MemoryBase & 0xFFF0) != 0 || (PciData.Bridge.MemoryLimit & 0xFFF0) != 0) {
PciIoDevice->PciIo.Attributes(
&(PciIoDevice->PciIo),
EfiPciIoAttributeOperationEnable,
(EFI_PCI_IO_ATTRIBUTE_MEMORY | EFI_PCI_IO_ATTRIBUTE_BUS_MASTER),
NULL
);
}
if ((((PciData.Bridge.PrefetchableMemoryBase & 0xF) == 0) &&
(PciData.Bridge.PrefetchableMemoryBase != 0 || PciData.Bridge.PrefetchableMemoryLimit != 0)) ||
(((PciData.Bridge.PrefetchableMemoryBase & 0xF) == 1) &&
((PciData.Bridge.PrefetchableMemoryBase & 0xFFF0) != 0 || (PciData.Bridge.PrefetchableMemoryLimit & 0xFFF0) != 0 || PciData.Bridge.PrefetchableBaseUpper32 != 0 || PciData.Bridge.PrefetchableLimitUpper32 != 0))) {
PciIoDevice->PciIo.Attributes(
&(PciIoDevice->PciIo),
EfiPciIoAttributeOperationEnable,
(EFI_PCI_IO_ATTRIBUTE_MEMORY | EFI_PCI_IO_ATTRIBUTE_BUS_MASTER),
NULL
);
}
return EFI_SUCCESS;
}
EFI_STATUS
StartPciDevicesOnBridge (
IN EFI_HANDLE Controller,
IN PCI_IO_DEVICE *RootBridge,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
/*++
Routine Description:
Start to manage the PCI device on specified the root bridge or PCI-PCI Bridge
Arguments:
Controller - An efi handle.
RootBridge - A pointer to the PCI_IO_DEVICE.
RemainingDevicePath - A pointer to the EFI_DEVICE_PATH_PROTOCOL.
NumberOfChildren - Children number.
ChildHandleBuffer - A pointer to the child handle buffer.
Returns:
None
--*/
{
PCI_IO_DEVICE *Temp;
PCI_IO_DEVICE *PciIoDevice;
EFI_DEV_PATH_PTR Node;
EFI_DEVICE_PATH_PROTOCOL *CurrentDevicePath;
EFI_STATUS Status;
LIST_ENTRY *CurrentLink;
CurrentLink = RootBridge->ChildList.ForwardLink;
while (CurrentLink && CurrentLink != &RootBridge->ChildList) {
Temp = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
if (RemainingDevicePath != NULL) {
Node.DevPath = RemainingDevicePath;
if (Node.Pci->Device != Temp->DeviceNumber ||
Node.Pci->Function != Temp->FunctionNumber) {
CurrentLink = CurrentLink->ForwardLink;
continue;
}
//
// Check if the device has been assigned with required resource
//
if (!Temp->Allocated) {
return EFI_NOT_READY;
}
//
// Check if the current node has been registered before
// If it is not, register it
//
if (!Temp->Registered) {
PciIoDevice = Temp;
Status = RegisterPciDevice (
Controller,
PciIoDevice,
NULL
);
}
//
// Get the next device path
//
CurrentDevicePath = NextDevicePathNode (RemainingDevicePath);
if (IsDevicePathEnd (CurrentDevicePath)) {
return EFI_SUCCESS;
}
//
// If it is a PPB
//
if (IS_PCI_BRIDGE (&(Temp->Pci))) {
Status = StartPciDevicesOnBridge (
Controller,
Temp,
CurrentDevicePath
);
EnableBridgeAttributes (Temp);
return Status;
} else {
//
// Currently, the PCI bus driver only support PCI-PCI bridge
//
return EFI_UNSUPPORTED;
}
} else {
//
// If remaining device path is NULL,
// try to enable all the pci devices under this bridge
//
if (!Temp->Registered && Temp->Allocated) {
PciIoDevice = Temp;
Status = RegisterPciDevice (
Controller,
PciIoDevice,
NULL
);
}
if (IS_PCI_BRIDGE (&(Temp->Pci))) {
Status = StartPciDevicesOnBridge (
Controller,
Temp,
RemainingDevicePath
);
EnableBridgeAttributes (Temp);
}
CurrentLink = CurrentLink->ForwardLink;
continue;
}
}
return EFI_NOT_FOUND;
}
EFI_STATUS
StartPciDevices (
IN EFI_HANDLE Controller,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
/*++
Routine Description:
Start to manage the PCI device according to RemainingDevicePath
If RemainingDevicePath == NULL, the PCI bus driver will start
to manage all the PCI devices it found previously
Arguments:
Controller - An efi handle.
RemainingDevicePath - A pointer to the EFI_DEVICE_PATH_PROTOCOL.
Returns:
None
--*/
{
EFI_DEV_PATH_PTR Node;
PCI_IO_DEVICE *RootBridge;
LIST_ENTRY *CurrentLink;
if (RemainingDevicePath != NULL) {
//
// Check if the RemainingDevicePath is valid
//
Node.DevPath = RemainingDevicePath;
if (Node.DevPath->Type != HARDWARE_DEVICE_PATH ||
Node.DevPath->SubType != HW_PCI_DP ||
DevicePathNodeLength (Node.DevPath) != sizeof (PCI_DEVICE_PATH)
) {
return EFI_UNSUPPORTED;
}
}
CurrentLink = gPciDevicePool.ForwardLink;
while (CurrentLink && CurrentLink != &gPciDevicePool) {
RootBridge = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
//
// Locate the right root bridge to start
//
if (RootBridge->Handle == Controller) {
StartPciDevicesOnBridge (
Controller,
RootBridge,
RemainingDevicePath
);
}
CurrentLink = CurrentLink->ForwardLink;
}
return EFI_SUCCESS;
}
PCI_IO_DEVICE *
CreateRootBridge (
IN EFI_HANDLE RootBridgeHandle
)
/*++
Routine Description:
Arguments:
RootBridgeHandle - An efi handle.
Returns:
None
--*/
{
EFI_STATUS Status;
PCI_IO_DEVICE *Dev;
Dev = NULL;
Status = gBS->AllocatePool (
EfiBootServicesData,
sizeof (PCI_IO_DEVICE),
(VOID **) &Dev
);
if (EFI_ERROR (Status)) {
return NULL;
}
ZeroMem (Dev, sizeof (PCI_IO_DEVICE));
Dev->Signature = PCI_IO_DEVICE_SIGNATURE;
Dev->Handle = RootBridgeHandle;
InitializeListHead (&Dev->ChildList);
return Dev;
}
PCI_IO_DEVICE *
GetRootBridgeByHandle (
EFI_HANDLE RootBridgeHandle
)
/*++
Routine Description:
Arguments:
RootBridgeHandle - An efi handle.
Returns:
None
--*/
{
PCI_IO_DEVICE *RootBridgeDev;
LIST_ENTRY *CurrentLink;
CurrentLink = gPciDevicePool.ForwardLink;
while (CurrentLink && CurrentLink != &gPciDevicePool) {
RootBridgeDev = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
if (RootBridgeDev->Handle == RootBridgeHandle) {
return RootBridgeDev;
}
CurrentLink = CurrentLink->ForwardLink;
}
return NULL;
}
BOOLEAN
RootBridgeExisted (
IN EFI_HANDLE RootBridgeHandle
)
/*++
Routine Description:
This function searches if RootBridgeHandle has already existed
in current device pool.
If so, it means the given root bridge has been already enumerated.
Arguments:
RootBridgeHandle - An efi handle.
Returns:
None
--*/
{
PCI_IO_DEVICE *Bridge;
Bridge = GetRootBridgeByHandle (RootBridgeHandle);
if (Bridge != NULL) {
return TRUE;
}
return FALSE;
}
BOOLEAN
PciDeviceExisted (
IN PCI_IO_DEVICE *Bridge,
IN PCI_IO_DEVICE *PciIoDevice
)
/*++
Routine Description:
Arguments:
Bridge - A pointer to the PCI_IO_DEVICE.
PciIoDevice - A pointer to the PCI_IO_DEVICE.
Returns:
None
--*/
{
PCI_IO_DEVICE *Temp;
LIST_ENTRY *CurrentLink;
CurrentLink = Bridge->ChildList.ForwardLink;
while (CurrentLink && CurrentLink != &Bridge->ChildList) {
Temp = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
if (Temp == PciIoDevice) {
return TRUE;
}
if (!IsListEmpty (&Temp->ChildList)) {
if (PciDeviceExisted (Temp, PciIoDevice)) {
return TRUE;
}
}
CurrentLink = CurrentLink->ForwardLink;
}
return FALSE;
}
PCI_IO_DEVICE *
ActiveVGADeviceOnTheSameSegment (
IN PCI_IO_DEVICE *VgaDevice
)
/*++
Routine Description:
Arguments:
VgaDevice - A pointer to the PCI_IO_DEVICE.
Returns:
None
--*/
{
LIST_ENTRY *CurrentLink;
PCI_IO_DEVICE *Temp;
CurrentLink = gPciDevicePool.ForwardLink;
while (CurrentLink && CurrentLink != &gPciDevicePool) {
Temp = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
if (Temp->PciRootBridgeIo->SegmentNumber == VgaDevice->PciRootBridgeIo->SegmentNumber) {
Temp = ActiveVGADeviceOnTheRootBridge (Temp);
if (Temp != NULL) {
return Temp;
}
}
CurrentLink = CurrentLink->ForwardLink;
}
return NULL;
}
PCI_IO_DEVICE *
ActiveVGADeviceOnTheRootBridge (
IN PCI_IO_DEVICE *RootBridge
)
/*++
Routine Description:
Arguments:
RootBridge - A pointer to the PCI_IO_DEVICE.
Returns:
None
--*/
{
LIST_ENTRY *CurrentLink;
PCI_IO_DEVICE *Temp;
CurrentLink = RootBridge->ChildList.ForwardLink;
while (CurrentLink && CurrentLink != &RootBridge->ChildList) {
Temp = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
if (IS_PCI_VGA(&Temp->Pci) &&
(Temp->Attributes &
(EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY |
EFI_PCI_IO_ATTRIBUTE_VGA_IO |
EFI_PCI_IO_ATTRIBUTE_VGA_IO_16))) {
return Temp;
}
if (IS_PCI_BRIDGE (&Temp->Pci)) {
Temp = ActiveVGADeviceOnTheRootBridge (Temp);
if (Temp != NULL) {
return Temp;
}
}
CurrentLink = CurrentLink->ForwardLink;
}
return NULL;
}

View File

@ -0,0 +1,324 @@
/*++
Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
PciDeviceSupport.h
Abstract:
Revision History
--*/
#ifndef _EFI_PCI_DEVICE_SUPPORT_H
#define _EFI_PCI_DEVICE_SUPPORT_H
EFI_STATUS
InitializePciDevicePool (
VOID
)
/*++
Routine Description:
TODO: Add function description
Arguments:
None
Returns:
TODO: add return values
--*/
;
EFI_STATUS
InsertPciDevice (
PCI_IO_DEVICE *Bridge,
PCI_IO_DEVICE *PciDeviceNode
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Bridge - TODO: add argument description
PciDeviceNode - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
DestroyPciDeviceTree (
IN PCI_IO_DEVICE *Bridge
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Bridge - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
DestroyRootBridgeByHandle (
EFI_HANDLE Controller
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Controller - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
RegisterPciDevice (
IN EFI_HANDLE Controller,
IN PCI_IO_DEVICE *PciIoDevice,
OUT EFI_HANDLE *Handle OPTIONAL
)
/*++
Routine Description:
This function registers the PCI IO device. It creates a handle for this PCI IO device
(if the handle does not exist), attaches appropriate protocols onto the handle, does
necessary initialization, and sets up parent/child relationship with its bus controller.
Arguments:
Controller - An EFI handle for the PCI bus controller.
PciIoDevice - A PCI_IO_DEVICE pointer to the PCI IO device to be registered.
Handle - A pointer to hold the EFI handle for the PCI IO device.
Returns:
EFI_SUCCESS - The PCI device is successfully registered.
Others - An error occurred when registering the PCI device.
--*/
;
EFI_STATUS
DeRegisterPciDevice (
IN EFI_HANDLE Controller,
IN EFI_HANDLE Handle
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Controller - TODO: add argument description
Handle - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
StartPciDevices (
IN EFI_HANDLE Controller,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Controller - TODO: add argument description
RemainingDevicePath - TODO: add argument description
Returns:
TODO: add return values
--*/
;
PCI_IO_DEVICE *
CreateRootBridge (
IN EFI_HANDLE RootBridgeHandle
)
/*++
Routine Description:
TODO: Add function description
Arguments:
RootBridgeHandle - TODO: add argument description
Returns:
TODO: add return values
--*/
;
PCI_IO_DEVICE *
GetRootBridgeByHandle (
EFI_HANDLE RootBridgeHandle
)
/*++
Routine Description:
TODO: Add function description
Arguments:
RootBridgeHandle - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
InsertRootBridge (
PCI_IO_DEVICE *RootBridge
);
EFI_STATUS
DestroyRootBridge (
IN PCI_IO_DEVICE *RootBridge
);
BOOLEAN
RootBridgeExisted (
IN EFI_HANDLE RootBridgeHandle
)
/*++
Routine Description:
TODO: Add function description
Arguments:
RootBridgeHandle - TODO: add argument description
Returns:
TODO: add return values
--*/
;
BOOLEAN
PciDeviceExisted (
IN PCI_IO_DEVICE *Bridge,
IN PCI_IO_DEVICE *PciIoDevice
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Bridge - TODO: add argument description
PciIoDevice - TODO: add argument description
Returns:
TODO: add return values
--*/
;
PCI_IO_DEVICE *
ActiveVGADeviceOnTheSameSegment (
IN PCI_IO_DEVICE *VgaDevice
)
/*++
Routine Description:
TODO: Add function description
Arguments:
VgaDevice - TODO: add argument description
Returns:
TODO: add return values
--*/
;
PCI_IO_DEVICE *
ActiveVGADeviceOnTheRootBridge (
IN PCI_IO_DEVICE *RootBridge
)
/*++
Routine Description:
TODO: Add function description
Arguments:
RootBridge - TODO: add argument description
Returns:
TODO: add return values
--*/
;
#endif

View File

@ -0,0 +1,176 @@
/*++
Copyright (c) 2005 - 2007, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
PciDriverOverride.c
Abstract:
PCI Bus Driver
Revision History
--*/
#include "PciBus.h"
EFI_STATUS
EFIAPI
GetDriver(
IN EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL *This,
IN OUT EFI_HANDLE *DriverImageHandle
);
EFI_STATUS
InitializePciDriverOverrideInstance (
PCI_IO_DEVICE *PciIoDevice
)
/*++
Routine Description:
Initializes a PCI Driver Override Instance
Arguments:
Returns:
None
--*/
{
PciIoDevice->PciDriverOverride.GetDriver = GetDriver;
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
GetDriver (
IN EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL *This,
IN OUT EFI_HANDLE *DriverImageHandle
)
/*++
Routine Description:
Get a overriding driver image
Arguments:
Returns:
None
--*/
{
PCI_IO_DEVICE *PciIoDevice;
LIST_ENTRY *CurrentLink;
PCI_DRIVER_OVERRIDE_LIST *Node;
PciIoDevice = PCI_IO_DEVICE_FROM_PCI_DRIVER_OVERRIDE_THIS (This);
CurrentLink = PciIoDevice->OptionRomDriverList.ForwardLink;
while (CurrentLink && CurrentLink != &PciIoDevice->OptionRomDriverList) {
Node = DRIVER_OVERRIDE_FROM_LINK (CurrentLink);
if (*DriverImageHandle == NULL) {
*DriverImageHandle = Node->DriverImageHandle;
return EFI_SUCCESS;
}
if (*DriverImageHandle == Node->DriverImageHandle) {
if (CurrentLink->ForwardLink == &PciIoDevice->OptionRomDriverList ||
CurrentLink->ForwardLink == NULL) {
return EFI_NOT_FOUND;
}
//
// Get next node
//
Node = DRIVER_OVERRIDE_FROM_LINK (CurrentLink->ForwardLink);
*DriverImageHandle = Node->DriverImageHandle;
return EFI_SUCCESS;
}
CurrentLink = CurrentLink->ForwardLink;
}
return EFI_INVALID_PARAMETER;
}
EFI_STATUS
AddDriver (
IN PCI_IO_DEVICE *PciIoDevice,
IN EFI_HANDLE DriverImageHandle
)
/*++
Routine Description:
Add a overriding driver image
Arguments:
Returns:
None
--*/
{
EFI_STATUS Status;
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
PCI_DRIVER_OVERRIDE_LIST *Node;
Status = gBS->HandleProtocol (DriverImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &LoadedImage);
if (EFI_ERROR (Status)) {
return Status;
}
Node = AllocatePool (sizeof (PCI_DRIVER_OVERRIDE_LIST));
if (Node == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Node->Signature = DRIVER_OVERRIDE_SIGNATURE;
Node->DriverImageHandle = DriverImageHandle;
InsertTailList (&PciIoDevice->OptionRomDriverList, &(Node->Link));
PciIoDevice->BusOverride = TRUE;
ImageContext.Handle = LoadedImage->ImageBase;
ImageContext.ImageRead = PeCoffLoaderImageReadFromMemory;
//
// Get information about the image
//
Status = PeCoffLoaderGetImageInfo (&ImageContext);
if (EFI_ERROR (Status)) {
return EFI_SUCCESS;
}
if (ImageContext.Machine != EFI_IMAGE_MACHINE_EBC) {
return EFI_SUCCESS;
}
return EFI_SUCCESS;
}

View File

@ -0,0 +1,110 @@
/*++
Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
PciDriverOverride.h
Abstract:
Revision History
--*/
#ifndef _EFI_PCI_DRIVER_OVERRRIDE_H
#define _EFI_PCI_DRIVER_OVERRRIDE_H
#include "PciBus.h"
#define DRIVER_OVERRIDE_SIGNATURE SIGNATURE_32 ('d', 'r', 'o', 'v')
typedef struct {
UINT32 Signature;
LIST_ENTRY Link;
EFI_HANDLE DriverImageHandle;
} PCI_DRIVER_OVERRIDE_LIST;
#define DRIVER_OVERRIDE_FROM_LINK(a) \
CR (a, PCI_DRIVER_OVERRIDE_LIST, Link, DRIVER_OVERRIDE_SIGNATURE)
EFI_STATUS
InitializePciDriverOverrideInstance (
PCI_IO_DEVICE *PciIoDevice
)
/*++
Routine Description:
TODO: Add function description
Arguments:
PciIoDevice - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
AddDriver (
IN PCI_IO_DEVICE *PciIoDevice,
IN EFI_HANDLE DriverImageHandle
)
/*++
Routine Description:
TODO: Add function description
Arguments:
PciIoDevice - TODO: add argument description
DriverImageHandle - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
EFIAPI
GetDriver (
IN EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL *This,
IN OUT EFI_HANDLE *DriverImageHandle
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
DriverImageHandle - TODO: add argument description
Returns:
TODO: add return values
--*/
;
#endif

View File

@ -0,0 +1,57 @@
/*++
Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
PciEnumerator.c
Abstract:
PCI Bus Driver
Revision History
--*/
#include "PciBus.h"
EFI_STATUS
PciEnumerator (
IN EFI_HANDLE Controller
)
/*++
Routine Description:
This routine is used to enumerate entire pci bus system
in a given platform
Arguments:
Returns:
None
--*/
{
//
// This PCI bus driver depends on the legacy BIOS
// to do the resource allocation
//
gFullEnumeration = FALSE;
return PciEnumeratorLight (Controller) ;
}

View File

@ -0,0 +1,47 @@
/*++
Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
PciEnumerator.h
Abstract:
PCI Bus Driver
Revision History
--*/
#ifndef _EFI_PCI_ENUMERATOR_H
#define _EFI_PCI_ENUMERATOR_H
EFI_STATUS
PciEnumerator (
IN EFI_HANDLE Controller
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Controller - TODO: add argument description
Returns:
TODO: add return values
--*/
;
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,108 @@
/*++
Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
PciEnumeratorSupport.h
Abstract:
PCI Bus Driver
Revision History
--*/
#ifndef _EFI_PCI_ENUMERATOR_SUPPORT_H
#define _EFI_PCI_ENUMERATOR_SUPPORT_H
#include "PciBus.h"
EFI_STATUS
PciPciDeviceInfoCollector (
IN PCI_IO_DEVICE *Bridge,
UINT8 StartBusNumber
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Bridge - TODO: add argument description
StartBusNumber - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
PciDevicePresent(
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo,
PCI_TYPE00 *Pci,
UINT8 Bus,
UINT8 Device,
UINT8 Func
);
EFI_STATUS
PciEnumeratorLight (
IN EFI_HANDLE Controller
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Controller - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
PciGetBusRange (
IN EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR **Descriptors,
OUT UINT16 *MinBus,
OUT UINT16 *MaxBus,
OUT UINT16 *BusRange
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Descriptors - TODO: add argument description
MinBus - TODO: add argument description
MaxBus - TODO: add argument description
BusRange - TODO: add argument description
Returns:
TODO: add return values
--*/
;
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,48 @@
/*++
Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
PciIo.h
Abstract:
PCI Bus Driver
Revision History
--*/
#ifndef _EFI_PCI_IO_PROTOCOL_H
#define _EFI_PCI_IO_PROTOCOL_H
EFI_STATUS
InitializePciIoInstance (
PCI_IO_DEVICE *PciIoDevice
)
/*++
Routine Description:
TODO: Add function description
Arguments:
PciIoDevice - TODO: add argument description
Returns:
TODO: add return values
--*/
;
#endif

View File

@ -0,0 +1,557 @@
/*++
Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
PciOptionRomSupport.c
Abstract:
PCI Bus Driver
Revision History
--*/
#include "PciBus.h"
EFI_STATUS
RomDecode (
IN PCI_IO_DEVICE *PciDevice,
IN UINT8 RomBarIndex,
IN UINT32 RomBar,
IN BOOLEAN Enable
);
EFI_STATUS
GetOpRomInfo (
IN PCI_IO_DEVICE *PciIoDevice
)
/*++
Routine Description:
Arguments:
Returns:
--*/
{
UINT8 RomBarIndex;
UINT32 AllOnes;
UINT64 Address;
EFI_STATUS Status;
UINT8 Bus;
UINT8 Device;
UINT8 Function;
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;
Bus = PciIoDevice->BusNumber;
Device = PciIoDevice->DeviceNumber;
Function = PciIoDevice->FunctionNumber;
PciRootBridgeIo = PciIoDevice->PciRootBridgeIo;
//
// offset is 0x30 if is not ppb
//
//
// 0x30
//
RomBarIndex = PCI_EXPANSION_ROM_BASE;
if (IS_PCI_BRIDGE (&PciIoDevice->Pci)) {
//
// if is ppb
//
//
// 0x38
//
RomBarIndex = PCI_BRIDGE_ROMBAR;
}
//
// the bit0 is 0 to prevent the enabling of the Rom address decoder
//
AllOnes = 0xfffffffe;
Address = EFI_PCI_ADDRESS (Bus, Device, Function, RomBarIndex);
Status = PciRootBridgeIo->Pci.Write (
PciRootBridgeIo,
EfiPciWidthUint32,
Address,
1,
&AllOnes
);
if (EFI_ERROR (Status)) {
return Status;
}
//
// read back
//
Status = PciRootBridgeIo->Pci.Read (
PciRootBridgeIo,
EfiPciWidthUint32,
Address,
1,
&AllOnes
);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Bits [1, 10] are reserved
//
AllOnes &= 0xFFFFF800;
if ((AllOnes == 0) || (AllOnes == 0xFFFFF800)) {
return EFI_NOT_FOUND;
}
DEBUG ((EFI_D_ERROR, "PCIBUS: GetOpRomInfo: OPROM detected!\n"));
DEBUG ((EFI_D_ERROR, "PCIBUS: GetOpRomInfo: B-%x, D-%x, F-%x\n", (UINTN)Bus, (UINTN)Device, (UINTN)Function));
PciIoDevice->RomSize = (UINT64) ((~AllOnes) + 1);
return EFI_SUCCESS;
}
EFI_STATUS
LoadOpRomImage (
IN PCI_IO_DEVICE *PciDevice,
IN UINT64 ReservedMemoryBase
)
/*++
Routine Description:
Load option rom image for specified PCI device
Arguments:
Returns:
--*/
{
UINT8 RomBarIndex;
UINT8 Indicator;
UINT16 OffsetPcir;
UINT32 RomBarOffset;
UINT32 RomBar;
EFI_STATUS retStatus;
BOOLEAN FirstCheck;
UINT8 *Image;
PCI_EXPANSION_ROM_HEADER *RomHeader;
PCI_DATA_STRUCTURE *RomPcir;
UINT64 RomSize;
UINT64 RomImageSize;
UINT32 LegacyImageLength;
UINT8 *RomInMemory;
UINT8 CodeType;
RomSize = PciDevice->RomSize;
Indicator = 0;
RomImageSize = 0;
RomInMemory = NULL;
CodeType = 0xFF;
//
// Get the RomBarIndex
//
//
// 0x30
//
RomBarIndex = PCI_EXPANSION_ROM_BASE;
if (IS_PCI_BRIDGE (&(PciDevice->Pci))) {
//
// if is ppb
//
//
// 0x38
//
RomBarIndex = PCI_BRIDGE_ROMBAR;
}
//
// Allocate memory for Rom header and PCIR
//
RomHeader = AllocatePool (sizeof (PCI_EXPANSION_ROM_HEADER));
if (RomHeader == NULL) {
return EFI_OUT_OF_RESOURCES;
}
RomPcir = AllocatePool (sizeof (PCI_DATA_STRUCTURE));
if (RomPcir == NULL) {
gBS->FreePool (RomHeader);
return EFI_OUT_OF_RESOURCES;
}
RomBar = (UINT32)ReservedMemoryBase;
//
// Enable RomBar
//
RomDecode (PciDevice, RomBarIndex, RomBar, TRUE);
RomBarOffset = RomBar;
retStatus = EFI_NOT_FOUND;
FirstCheck = TRUE;
LegacyImageLength = 0;
do {
PciDevice->PciRootBridgeIo->Mem.Read (
PciDevice->PciRootBridgeIo,
EfiPciWidthUint8,
RomBarOffset,
sizeof (PCI_EXPANSION_ROM_HEADER),
(UINT8 *) RomHeader
);
if (RomHeader->Signature != PCI_EXPANSION_ROM_HEADER_SIGNATURE) {
RomBarOffset = RomBarOffset + 512;
if (FirstCheck) {
break;
} else {
RomImageSize = RomImageSize + 512;
continue;
}
}
FirstCheck = FALSE;
OffsetPcir = RomHeader->PcirOffset;
//
// If the pointer to the PCI Data Structure is invalid, no further images can be located.
// The PCI Data Structure must be DWORD aligned.
//
if (OffsetPcir == 0 ||
(OffsetPcir & 3) != 0 ||
RomImageSize + OffsetPcir + sizeof (PCI_DATA_STRUCTURE) > RomSize) {
break;
}
PciDevice->PciRootBridgeIo->Mem.Read (
PciDevice->PciRootBridgeIo,
EfiPciWidthUint8,
RomBarOffset + OffsetPcir,
sizeof (PCI_DATA_STRUCTURE),
(UINT8 *) RomPcir
);
//
// If a valid signature is not present in the PCI Data Structure, no further images can be located.
//
if (RomPcir->Signature != PCI_DATA_STRUCTURE_SIGNATURE) {
break;
}
if (RomImageSize + RomPcir->ImageLength * 512 > RomSize) {
break;
}
if (RomPcir->CodeType == PCI_CODE_TYPE_PCAT_IMAGE) {
CodeType = PCI_CODE_TYPE_PCAT_IMAGE;
LegacyImageLength = ((UINT32)((EFI_LEGACY_EXPANSION_ROM_HEADER *)RomHeader)->Size512) * 512;
}
Indicator = RomPcir->Indicator;
RomImageSize = RomImageSize + RomPcir->ImageLength * 512;
RomBarOffset = RomBarOffset + RomPcir->ImageLength * 512;
} while (((Indicator & 0x80) == 0x00) && ((RomBarOffset - RomBar) < RomSize));
//
// Some Legacy Cards do not report the correct ImageLength so used the maximum
// of the legacy length and the PCIR Image Length
//
if (CodeType == PCI_CODE_TYPE_PCAT_IMAGE) {
RomImageSize = MAX (RomImageSize, LegacyImageLength);
}
if (RomImageSize > 0) {
retStatus = EFI_SUCCESS;
Image = AllocatePool ((UINT32) RomImageSize);
if (Image == NULL) {
RomDecode (PciDevice, RomBarIndex, RomBar, FALSE);
gBS->FreePool (RomHeader);
gBS->FreePool (RomPcir);
return EFI_OUT_OF_RESOURCES;
}
//
// Copy Rom image into memory
//
PciDevice->PciRootBridgeIo->Mem.Read (
PciDevice->PciRootBridgeIo,
EfiPciWidthUint8,
RomBar,
(UINT32) RomImageSize,
Image
);
RomInMemory = Image;
}
RomDecode (PciDevice, RomBarIndex, RomBar, FALSE);
PciDevice->PciIo.RomSize = RomImageSize;
PciDevice->PciIo.RomImage = RomInMemory;
//
// Free allocated memory
//
gBS->FreePool (RomHeader);
gBS->FreePool (RomPcir);
return retStatus;
}
EFI_STATUS
RomDecode (
IN PCI_IO_DEVICE *PciDevice,
IN UINT8 RomBarIndex,
IN UINT32 RomBar,
IN BOOLEAN Enable
)
/*++
Routine Description:
Arguments:
Returns:
--*/
{
UINT16 CommandValue;
UINT32 Value32;
UINT64 Address;
//EFI_STATUS Status;
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;
PciRootBridgeIo = PciDevice->PciRootBridgeIo;
if (Enable) {
Address = EFI_PCI_ADDRESS (PciDevice->BusNumber, PciDevice->DeviceNumber, PciDevice->FunctionNumber, RomBarIndex);
//
// set the Rom base address: now is hardcode
//
PciRootBridgeIo->Pci.Write(
PciRootBridgeIo,
EfiPciWidthUint32,
Address,
1,
&RomBar);
//
// enable its decoder
//
Value32 = RomBar | 0x1;
PciRootBridgeIo->Pci.Write(
PciRootBridgeIo,
EfiPciWidthUint32,
Address,
1,
&Value32);
//
//setting the memory space bit in the function's command register
//
Address = EFI_PCI_ADDRESS (PciDevice->BusNumber, PciDevice->DeviceNumber, PciDevice->FunctionNumber, 0x04);
PciRootBridgeIo->Pci.Read(
PciRootBridgeIo,
EfiPciWidthUint16,
Address,
1,
&CommandValue);
CommandValue = (UINT16)(CommandValue | 0x0002); //0x0003
PciRootBridgeIo->Pci.Write(
PciRootBridgeIo,
EfiPciWidthUint16,
Address,
1,
&CommandValue);
} else {
//
// disable rom decode
//
Address = EFI_PCI_ADDRESS (PciDevice->BusNumber, PciDevice->DeviceNumber, PciDevice->FunctionNumber, RomBarIndex);
Value32 = 0xfffffffe;
PciRootBridgeIo->Pci.Write(
PciRootBridgeIo,
EfiPciWidthUint32,
Address,
1,
&Value32);
}
return EFI_SUCCESS;
}
EFI_STATUS
ProcessOpRomImage (
PCI_IO_DEVICE *PciDevice
)
/*++
Routine Description:
Process the oprom image.
Arguments:
PciDevice A pointer to a pci device.
Returns:
EFI Status.
--*/
{
UINT8 Indicator;
UINT32 ImageSize;
UINT16 ImageOffset;
VOID *RomBar;
UINT8 *RomBarOffset;
EFI_HANDLE ImageHandle;
EFI_STATUS Status;
EFI_STATUS retStatus;
BOOLEAN SkipImage;
UINT32 DestinationSize;
UINT32 ScratchSize;
UINT8 *Scratch;
VOID *ImageBuffer;
VOID *DecompressedImageBuffer;
UINT32 ImageLength;
EFI_DECOMPRESS_PROTOCOL *Decompress;
EFI_PCI_EXPANSION_ROM_HEADER *EfiRomHeader;
PCI_DATA_STRUCTURE *Pcir;
UINT32 InitializationSize;
Indicator = 0;
//
// Get the Address of the Rom image
//
RomBar = PciDevice->PciIo.RomImage;
RomBarOffset = (UINT8 *) RomBar;
retStatus = EFI_NOT_FOUND;
if (RomBarOffset == NULL) {
return retStatus;
}
ASSERT (((EFI_PCI_EXPANSION_ROM_HEADER *) RomBarOffset)->Signature == PCI_EXPANSION_ROM_HEADER_SIGNATURE);
do {
EfiRomHeader = (EFI_PCI_EXPANSION_ROM_HEADER *) RomBarOffset;
if (EfiRomHeader->Signature != PCI_EXPANSION_ROM_HEADER_SIGNATURE) {
RomBarOffset = RomBarOffset + 512;
continue;
}
Pcir = (PCI_DATA_STRUCTURE *) (RomBarOffset + EfiRomHeader->PcirOffset);
ASSERT (Pcir->Signature == PCI_DATA_STRUCTURE_SIGNATURE);
ImageSize = (UINT32) (Pcir->ImageLength * 512);
Indicator = Pcir->Indicator;
if ((Pcir->CodeType == PCI_CODE_TYPE_EFI_IMAGE) &&
(EfiRomHeader->EfiSignature == EFI_PCI_EXPANSION_ROM_HEADER_EFISIGNATURE) &&
((EfiRomHeader->EfiSubsystem == EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER) ||
(EfiRomHeader->EfiSubsystem == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER))) {
ImageOffset = EfiRomHeader->EfiImageHeaderOffset;
InitializationSize = EfiRomHeader->InitializationSize * 512;
if (InitializationSize <= ImageSize && ImageOffset < InitializationSize) {
ImageBuffer = (VOID *) (RomBarOffset + ImageOffset);
ImageLength = InitializationSize - (UINT32)ImageOffset;
DecompressedImageBuffer = NULL;
//
// decompress here if needed
//
SkipImage = FALSE;
if (EfiRomHeader->CompressionType > EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED) {
SkipImage = TRUE;
}
if (EfiRomHeader->CompressionType == EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED) {
Status = gBS->LocateProtocol (&gEfiDecompressProtocolGuid, NULL, (VOID **) &Decompress);
if (EFI_ERROR (Status)) {
SkipImage = TRUE;
} else {
SkipImage = TRUE;
Status = Decompress->GetInfo (
Decompress,
ImageBuffer,
ImageLength,
&DestinationSize,
&ScratchSize
);
if (!EFI_ERROR (Status)) {
DecompressedImageBuffer = NULL;
DecompressedImageBuffer = AllocatePool (DestinationSize);
if (DecompressedImageBuffer != NULL) {
Scratch = AllocatePool (ScratchSize);
if (Scratch != NULL) {
Status = Decompress->Decompress (
Decompress,
ImageBuffer,
ImageLength,
DecompressedImageBuffer,
DestinationSize,
Scratch,
ScratchSize
);
if (!EFI_ERROR (Status)) {
ImageBuffer = DecompressedImageBuffer;
ImageLength = DestinationSize;
SkipImage = FALSE;
}
gBS->FreePool (Scratch);
}
}
}
}
}
if (!SkipImage) {
//
// load image and start image
//
Status = gBS->LoadImage (
FALSE,
gPciBusDriverBinding.DriverBindingHandle,
NULL,
ImageBuffer,
ImageLength,
&ImageHandle
);
if (!EFI_ERROR (Status)) {
Status = gBS->StartImage (ImageHandle, NULL, NULL);
if (!EFI_ERROR (Status)) {
AddDriver (PciDevice, ImageHandle);
retStatus = EFI_SUCCESS;
}
}
}
RomBarOffset = RomBarOffset + ImageSize;
} else {
RomBarOffset = RomBarOffset + ImageSize;
}
} else {
RomBarOffset = RomBarOffset + ImageSize;
}
} while (((Indicator & 0x80) == 0x00) && ((UINTN) (RomBarOffset - (UINT8 *) RomBar) < PciDevice->RomSize));
return retStatus;
}

View File

@ -0,0 +1,92 @@
/*++
Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
PciOptionRomSupport.h
Abstract:
PCI Bus Driver
Revision History
--*/
#ifndef _EFI_PCI_OP_ROM_SUPPORT_H
#define _EFI_PCI_OP_ROM_SUPPORT_H
EFI_STATUS
GetOpRomInfo (
IN PCI_IO_DEVICE *PciIoDevice
)
/*++
Routine Description:
TODO: Add function description
Arguments:
PciIoDevice - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
LoadOpRomImage (
IN PCI_IO_DEVICE *PciDevice,
IN UINT64 ReservedMemoryBase
)
/*++
Routine Description:
TODO: Add function description
Arguments:
PciDevice - TODO: add argument description
RomBase - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
ProcessOpRomImage (
PCI_IO_DEVICE *PciDevice
)
/*++
Routine Description:
TODO: Add function description
Arguments:
PciDevice - TODO: add argument description
Returns:
TODO: add return values
--*/
;
#endif

View File

@ -0,0 +1,100 @@
/*++
Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
PciPowerManagement.c
Abstract:
PCI Bus Driver
Revision History
--*/
#include "PciBus.h"
EFI_STATUS
EFIAPI
ResetPowerManagementFeature (
IN PCI_IO_DEVICE *PciIoDevice
)
/*++
Routine Description:
This function is intended to turn off PWE assertion and
put the device to D0 state if the device supports
PCI Power Management.
Arguments:
Returns:
None
--*/
{
EFI_STATUS Status;
UINT8 PowerManagementRegBlock;
UINT16 PowerManagementCSR;
PowerManagementRegBlock = 0;
Status = LocateCapabilityRegBlock (
PciIoDevice,
EFI_PCI_CAPABILITY_ID_PMI,
&PowerManagementRegBlock,
NULL
);
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
//
// Turn off the PWE assertion and put the device into D0 State
//
//
// Read PMCSR
//
Status = PciIoDevice->PciIo.Pci.Read (
&PciIoDevice->PciIo,
EfiPciIoWidthUint16,
PowerManagementRegBlock + 4,
1,
&PowerManagementCSR
);
if (!EFI_ERROR (Status)) {
//
// Clear PME_Status bit
//
PowerManagementCSR |= BIT15;
//
// Clear PME_En bit. PowerState = D0.
//
PowerManagementCSR &= ~(BIT8 | BIT1 | BIT0);
//
// Write PMCSR
//
Status = PciIoDevice->PciIo.Pci.Write (
&PciIoDevice->PciIo,
EfiPciIoWidthUint16,
PowerManagementRegBlock + 4,
1,
&PowerManagementCSR
);
}
return Status;
}

View File

@ -0,0 +1,49 @@
/*++
Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
PciPowerManagement.h
Abstract:
PCI Bus Driver
Revision History
--*/
#ifndef _EFI_PCI_POWER_MANAGEMENT_H
#define _EFI_PCI_POWER_MANAGEMENT_H
EFI_STATUS
EFIAPI
ResetPowerManagementFeature (
IN PCI_IO_DEVICE *PciIoDevice
)
/*++
Routine Description:
TODO: Add function description
Arguments:
PciIoDevice - TODO: add argument description
Returns:
TODO: add return values
--*/
;
#endif

View File

@ -0,0 +1,393 @@
/*++
Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
PciRomTable.c
Abstract:
Option Rom Support for PCI Bus Driver
Revision History
--*/
#include "PciBus.h"
typedef struct {
EFI_HANDLE ImageHandle;
UINTN Seg;
UINT8 Bus;
UINT8 Dev;
UINT8 Func;
} EFI_PCI_ROM_IMAGE_MAPPING;
UINTN mNumberOfPciRomImages = 0;
UINTN mMaxNumberOfPciRomImages = 0;
EFI_PCI_ROM_IMAGE_MAPPING *mRomImageTable = NULL;
CHAR16 mHexDigit[17] = L"0123456789ABCDEF";
VOID
PciRomAddImageMapping (
IN EFI_HANDLE ImageHandle,
IN UINTN Seg,
IN UINT8 Bus,
IN UINT8 Dev,
IN UINT8 Func
)
{
EFI_PCI_ROM_IMAGE_MAPPING *TempMapping;
if (mNumberOfPciRomImages >= mMaxNumberOfPciRomImages) {
mMaxNumberOfPciRomImages += 0x20;
TempMapping = NULL;
TempMapping = AllocatePool (mMaxNumberOfPciRomImages * sizeof (EFI_PCI_ROM_IMAGE_MAPPING));
if (TempMapping == NULL) {
return ;
}
CopyMem (TempMapping, mRomImageTable, mNumberOfPciRomImages * sizeof (EFI_PCI_ROM_IMAGE_MAPPING));
if (mRomImageTable != NULL) {
gBS->FreePool (mRomImageTable);
}
mRomImageTable = TempMapping;
}
mRomImageTable[mNumberOfPciRomImages].ImageHandle = ImageHandle;
mRomImageTable[mNumberOfPciRomImages].Seg = Seg;
mRomImageTable[mNumberOfPciRomImages].Bus = Bus;
mRomImageTable[mNumberOfPciRomImages].Dev = Dev;
mRomImageTable[mNumberOfPciRomImages].Func = Func;
mNumberOfPciRomImages++;
}
VOID
HexToString (
CHAR16 *String,
UINTN Value,
UINTN Digits
)
{
for (; Digits > 0; Digits--, String++) {
*String = mHexDigit[((Value >> (4*(Digits-1))) & 0x0f)];
}
}
EFI_STATUS
PciRomLoadEfiDriversFromRomImage (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_PCI_OPTION_ROM_DESCRIPTOR *PciOptionRomDescriptor
)
/*++
Routine Description:
Command entry point.
Arguments:
ImageHandle The image handle.
SystemTable The system table.
Returns:
EFI_SUCCESS - The command completed successfully
EFI_INVALID_PARAMETER - Command usage error
EFI_UNSUPPORTED - Protocols unsupported
EFI_OUT_OF_RESOURCES - Out of memory
Other value - Unknown error
--*/
{
VOID *RomBar;
UINTN RomSize;
CHAR16 *FileName;
EFI_PCI_EXPANSION_ROM_HEADER *EfiRomHeader;
PCI_DATA_STRUCTURE *Pcir;
UINTN ImageIndex;
UINTN RomBarOffset;
UINT32 ImageSize;
UINT16 ImageOffset;
EFI_HANDLE ImageHandle;
EFI_STATUS Status;
EFI_STATUS retStatus;
EFI_DEVICE_PATH_PROTOCOL *FilePath;
BOOLEAN SkipImage;
UINT32 DestinationSize;
UINT32 ScratchSize;
UINT8 *Scratch;
VOID *ImageBuffer;
VOID *DecompressedImageBuffer;
UINT32 ImageLength;
EFI_DECOMPRESS_PROTOCOL *Decompress;
UINT32 InitializationSize;
RomBar = (VOID *) (UINTN) PciOptionRomDescriptor->RomAddress;
RomSize = (UINTN) PciOptionRomDescriptor->RomLength;
FileName = L"PciRom Seg=00000000 Bus=00 Dev=00 Func=00 Image=0000";
HexToString (&FileName[11], PciOptionRomDescriptor->Seg, 8);
HexToString (&FileName[24], PciOptionRomDescriptor->Bus, 2);
HexToString (&FileName[31], PciOptionRomDescriptor->Dev, 2);
HexToString (&FileName[39], PciOptionRomDescriptor->Func, 2);
ImageIndex = 0;
retStatus = EFI_NOT_FOUND;
RomBarOffset = (UINTN) RomBar;
do {
EfiRomHeader = (EFI_PCI_EXPANSION_ROM_HEADER *) (UINTN) RomBarOffset;
if (EfiRomHeader->Signature != PCI_EXPANSION_ROM_HEADER_SIGNATURE) {
return retStatus;
}
//
// If the pointer to the PCI Data Structure is invalid, no further images can be located.
// The PCI Data Structure must be DWORD aligned.
//
if (EfiRomHeader->PcirOffset == 0 ||
(EfiRomHeader->PcirOffset & 3) != 0 ||
RomBarOffset - (UINTN)RomBar + EfiRomHeader->PcirOffset + sizeof (PCI_DATA_STRUCTURE) > RomSize) {
break;
}
Pcir = (PCI_DATA_STRUCTURE *) (UINTN) (RomBarOffset + EfiRomHeader->PcirOffset);
//
// If a valid signature is not present in the PCI Data Structure, no further images can be located.
//
if (Pcir->Signature != PCI_DATA_STRUCTURE_SIGNATURE) {
break;
}
ImageSize = Pcir->ImageLength * 512;
if (RomBarOffset - (UINTN)RomBar + ImageSize > RomSize) {
break;
}
if ((Pcir->CodeType == PCI_CODE_TYPE_EFI_IMAGE) &&
(EfiRomHeader->EfiSignature == EFI_PCI_EXPANSION_ROM_HEADER_EFISIGNATURE) &&
((EfiRomHeader->EfiSubsystem == EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER) ||
(EfiRomHeader->EfiSubsystem == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER))) {
ImageOffset = EfiRomHeader->EfiImageHeaderOffset;
InitializationSize = EfiRomHeader->InitializationSize * 512;
if (InitializationSize <= ImageSize && ImageOffset < InitializationSize) {
ImageBuffer = (VOID *) (UINTN) (RomBarOffset + ImageOffset);
ImageLength = InitializationSize - ImageOffset;
DecompressedImageBuffer = NULL;
//
// decompress here if needed
//
SkipImage = FALSE;
if (EfiRomHeader->CompressionType > EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED) {
SkipImage = TRUE;
}
if (EfiRomHeader->CompressionType == EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED) {
Status = gBS->LocateProtocol (&gEfiDecompressProtocolGuid, NULL, (VOID **) &Decompress);
if (EFI_ERROR (Status)) {
SkipImage = TRUE;
} else {
SkipImage = TRUE;
Status = Decompress->GetInfo (
Decompress,
ImageBuffer,
ImageLength,
&DestinationSize,
&ScratchSize
);
if (!EFI_ERROR (Status)) {
DecompressedImageBuffer = NULL;
DecompressedImageBuffer = AllocatePool (DestinationSize);
if (DecompressedImageBuffer != NULL) {
Scratch = AllocatePool (ScratchSize);
if (Scratch != NULL) {
Status = Decompress->Decompress (
Decompress,
ImageBuffer,
ImageLength,
DecompressedImageBuffer,
DestinationSize,
Scratch,
ScratchSize
);
if (!EFI_ERROR (Status)) {
ImageBuffer = DecompressedImageBuffer;
ImageLength = DestinationSize;
SkipImage = FALSE;
}
gBS->FreePool (Scratch);
}
}
}
}
}
if (!SkipImage) {
//
// load image and start image
//
HexToString (&FileName[48], ImageIndex, 4);
FilePath = FileDevicePath (NULL, FileName);
Status = gBS->LoadImage (
FALSE,
This->ImageHandle,
FilePath,
ImageBuffer,
ImageLength,
&ImageHandle
);
if (!EFI_ERROR (Status)) {
Status = gBS->StartImage (ImageHandle, NULL, NULL);
if (!EFI_ERROR (Status)) {
PciRomAddImageMapping (
ImageHandle,
PciOptionRomDescriptor->Seg,
PciOptionRomDescriptor->Bus,
PciOptionRomDescriptor->Dev,
PciOptionRomDescriptor->Func
);
retStatus = Status;
}
}
if (FilePath != NULL) {
gBS->FreePool (FilePath);
}
}
if (DecompressedImageBuffer != NULL) {
gBS->FreePool (DecompressedImageBuffer);
}
}
}
RomBarOffset = RomBarOffset + ImageSize;
ImageIndex++;
} while (((Pcir->Indicator & 0x80) == 0x00) && ((RomBarOffset - (UINTN) RomBar) < RomSize));
return retStatus;
}
EFI_STATUS
PciRomLoadEfiDriversFromOptionRomTable (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo
)
/*++
Routine Description:
Arguments:
Returns:
--*/
{
EFI_STATUS Status;
EFI_PCI_OPTION_ROM_TABLE *PciOptionRomTable;
EFI_PCI_OPTION_ROM_DESCRIPTOR *PciOptionRomDescriptor;
UINTN Index;
EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptors;
UINT16 MinBus;
UINT16 MaxBus;
Status = EfiGetSystemConfigurationTable (&gEfiPciOptionRomTableGuid, (VOID **) &PciOptionRomTable);
if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND;
}
Status = EFI_NOT_FOUND;
for (Index = 0; Index < PciOptionRomTable->PciOptionRomCount; Index++) {
PciOptionRomDescriptor = &PciOptionRomTable->PciOptionRomDescriptors[Index];
if (!PciOptionRomDescriptor->DontLoadEfiRom) {
if (PciOptionRomDescriptor->Seg == PciRootBridgeIo->SegmentNumber) {
Status = PciRootBridgeIo->Configuration (PciRootBridgeIo, (VOID **) &Descriptors);
if (EFI_ERROR (Status)) {
return Status;
}
PciGetBusRange (&Descriptors, &MinBus, &MaxBus, NULL);
if ((MinBus <= PciOptionRomDescriptor->Bus) && (PciOptionRomDescriptor->Bus <= MaxBus)) {
Status = PciRomLoadEfiDriversFromRomImage (This, PciOptionRomDescriptor);
PciOptionRomDescriptor->DontLoadEfiRom |= 2;
}
}
}
}
return Status;
}
EFI_STATUS
PciRomGetRomResourceFromPciOptionRomTable (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo,
PCI_IO_DEVICE *PciIoDevice
)
/*++
Routine Description:
Arguments:
Returns:
--*/
{
EFI_STATUS Status;
EFI_PCI_OPTION_ROM_TABLE *PciOptionRomTable;
EFI_PCI_OPTION_ROM_DESCRIPTOR *PciOptionRomDescriptor;
UINTN Index;
Status = EfiGetSystemConfigurationTable (&gEfiPciOptionRomTableGuid, (VOID **) &PciOptionRomTable);
if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND;
}
for (Index = 0; Index < PciOptionRomTable->PciOptionRomCount; Index++) {
PciOptionRomDescriptor = &PciOptionRomTable->PciOptionRomDescriptors[Index];
if (PciOptionRomDescriptor->Seg == PciRootBridgeIo->SegmentNumber &&
PciOptionRomDescriptor->Bus == PciIoDevice->BusNumber &&
PciOptionRomDescriptor->Dev == PciIoDevice->DeviceNumber &&
PciOptionRomDescriptor->Func == PciIoDevice->FunctionNumber ) {
PciIoDevice->PciIo.RomImage = (VOID *) (UINTN) PciOptionRomDescriptor->RomAddress;
PciIoDevice->PciIo.RomSize = (UINTN) PciOptionRomDescriptor->RomLength;
}
}
for (Index = 0; Index < mNumberOfPciRomImages; Index++) {
if (mRomImageTable[Index].Seg == PciRootBridgeIo->SegmentNumber &&
mRomImageTable[Index].Bus == PciIoDevice->BusNumber &&
mRomImageTable[Index].Dev == PciIoDevice->DeviceNumber &&
mRomImageTable[Index].Func == PciIoDevice->FunctionNumber ) {
AddDriver (PciIoDevice, mRomImageTable[Index].ImageHandle);
}
}
return EFI_SUCCESS;
}

View File

@ -0,0 +1,58 @@
/*++
Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
PciRomTable.h
Abstract:
Option Rom Support for PCI Bus Driver
Revision History
--*/
#ifndef _EFI_PCI_ROM_TABLE_H
#define _EFI_PCI_ROM_TABLE_H
EFI_STATUS
PciRomLoadEfiDriversFromOptionRomTable (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo
);
EFI_STATUS
PciRomGetRomResourceFromPciOptionRomTable (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo,
PCI_IO_DEVICE *PciIoDevice
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
PciRootBridgeIo - TODO: add argument description
PciIoDevice - TODO: add argument description
Returns:
TODO: add return values
--*/
;
#endif

View File

@ -0,0 +1,845 @@
/*++
Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
DeviceIo.c
Abstract:
EFI PC-AT PCI Device IO driver
--*/
#include "PcatPciRootBridge.h"
#include "DeviceIo.h"
EFI_STATUS
DeviceIoConstructor (
IN EFI_HANDLE Handle,
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo,
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
IN UINT16 PrimaryBus,
IN UINT16 SubordinateBus
)
/*++
Routine Description:
Initialize and install a Device IO protocol on a empty device path handle.
Arguments:
Handle - Handle of PCI RootBridge IO instance
PciRootBridgeIo - PCI RootBridge IO instance
DevicePath - Device Path of PCI RootBridge IO instance
PrimaryBus - Primary Bus
SubordinateBus - Subordinate Bus
Returns:
EFI_SUCCESS - This driver is added to ControllerHandle.
EFI_ALREADY_STARTED - This driver is already running on ControllerHandle.
Others - This driver does not support this device.
--*/
{
EFI_STATUS Status;
DEVICE_IO_PRIVATE_DATA *Private;
//
// Initialize the Device IO device instance.
//
Private = AllocateZeroPool (sizeof (DEVICE_IO_PRIVATE_DATA));
if (Private == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Private->Signature = DEVICE_IO_PRIVATE_DATA_SIGNATURE;
Private->Handle = Handle;
Private->PciRootBridgeIo = PciRootBridgeIo;
Private->DevicePath = DevicePath;
Private->PrimaryBus = PrimaryBus;
Private->SubordinateBus = SubordinateBus;
Private->DeviceIo.Mem.Read = DeviceIoMemRead;
Private->DeviceIo.Mem.Write = DeviceIoMemWrite;
Private->DeviceIo.Io.Read = DeviceIoIoRead;
Private->DeviceIo.Io.Write = DeviceIoIoWrite;
Private->DeviceIo.Pci.Read = DeviceIoPciRead;
Private->DeviceIo.Pci.Write = DeviceIoPciWrite;
Private->DeviceIo.PciDevicePath = DeviceIoPciDevicePath;
Private->DeviceIo.Map = DeviceIoMap;
Private->DeviceIo.Unmap = DeviceIoUnmap;
Private->DeviceIo.AllocateBuffer = DeviceIoAllocateBuffer;
Private->DeviceIo.Flush = DeviceIoFlush;
Private->DeviceIo.FreeBuffer = DeviceIoFreeBuffer;
//
// Install protocol interfaces for the Device IO device.
//
Status = gBS->InstallMultipleProtocolInterfaces (
&Private->Handle,
&gEfiDeviceIoProtocolGuid,
&Private->DeviceIo,
NULL
);
ASSERT_EFI_ERROR (Status);
return Status;
}
EFI_STATUS
EFIAPI
DeviceIoMemRead (
IN EFI_DEVICE_IO_PROTOCOL *This,
IN EFI_IO_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN OUT VOID *Buffer
)
/*++
Routine Description:
Perform reading memory mapped I/O space of device.
Arguments:
This - A pointer to EFI_DEVICE_IO protocol instance.
Width - Width of I/O operations.
Address - The base address of I/O operations.
Count - The number of I/O operations to perform.
Bytes moves is Width size * Count, starting at Address.
Buffer - The destination buffer to store results.
Returns:
EFI_SUCCESS - The data was read from the device.
EFI_INVALID_PARAMETER - Width is invalid.
EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.
--*/
{
EFI_STATUS Status;
DEVICE_IO_PRIVATE_DATA *Private;
Private = DEVICE_IO_PRIVATE_DATA_FROM_THIS (This);
if (Width > MMIO_COPY_UINT64) {
return EFI_INVALID_PARAMETER;
}
if (Width >= MMIO_COPY_UINT8) {
Width = (EFI_IO_WIDTH) (Width - MMIO_COPY_UINT8);
Status = Private->PciRootBridgeIo->CopyMem (
Private->PciRootBridgeIo,
(EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width,
(UINT64)(UINTN) Buffer,
Address,
Count
);
} else {
Status = Private->PciRootBridgeIo->Mem.Read (
Private->PciRootBridgeIo,
(EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width,
Address,
Count,
Buffer
);
}
return Status;
}
EFI_STATUS
EFIAPI
DeviceIoMemWrite (
IN EFI_DEVICE_IO_PROTOCOL *This,
IN EFI_IO_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN OUT VOID *Buffer
)
/*++
Routine Description:
Perform writing memory mapped I/O space of device.
Arguments:
This - A pointer to EFI_DEVICE_IO protocol instance.
Width - Width of I/O operations.
Address - The base address of I/O operations.
Count - The number of I/O operations to perform.
Bytes moves is Width size * Count, starting at Address.
Buffer - The source buffer of data to be written.
Returns:
EFI_SUCCESS - The data was written to the device.
EFI_INVALID_PARAMETER - Width is invalid.
EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.
--*/
{
EFI_STATUS Status;
DEVICE_IO_PRIVATE_DATA *Private;
Private = DEVICE_IO_PRIVATE_DATA_FROM_THIS (This);
if (Width > MMIO_COPY_UINT64) {
return EFI_INVALID_PARAMETER;
}
if (Width >= MMIO_COPY_UINT8) {
Width = (EFI_IO_WIDTH) (Width - MMIO_COPY_UINT8);
Status = Private->PciRootBridgeIo->CopyMem (
Private->PciRootBridgeIo,
(EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width,
Address,
(UINT64)(UINTN) Buffer,
Count
);
} else {
Status = Private->PciRootBridgeIo->Mem.Write (
Private->PciRootBridgeIo,
(EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width,
Address,
Count,
Buffer
);
}
return Status;
}
EFI_STATUS
EFIAPI
DeviceIoIoRead (
IN EFI_DEVICE_IO_PROTOCOL *This,
IN EFI_IO_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN OUT VOID *Buffer
)
/*++
Routine Description:
Perform reading I/O space of device.
Arguments:
This - A pointer to EFI_DEVICE_IO protocol instance.
Width - Width of I/O operations.
Address - The base address of I/O operations.
Count - The number of I/O operations to perform.
Bytes moves is Width size * Count, starting at Address.
Buffer - The destination buffer to store results.
Returns:
EFI_SUCCESS - The data was read from the device.
EFI_INVALID_PARAMETER - Width is invalid.
EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.
--*/
{
EFI_STATUS Status;
DEVICE_IO_PRIVATE_DATA *Private;
Private = DEVICE_IO_PRIVATE_DATA_FROM_THIS (This);
if (Width >= MMIO_COPY_UINT8) {
return EFI_INVALID_PARAMETER;
}
Status = Private->PciRootBridgeIo->Io.Read (
Private->PciRootBridgeIo,
(EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width,
Address,
Count,
Buffer
);
return Status;
}
EFI_STATUS
EFIAPI
DeviceIoIoWrite (
IN EFI_DEVICE_IO_PROTOCOL *This,
IN EFI_IO_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN OUT VOID *Buffer
)
/*++
Routine Description:
Perform writing I/O space of device.
Arguments:
This - A pointer to EFI_DEVICE_IO protocol instance.
Width - Width of I/O operations.
Address - The base address of I/O operations.
Count - The number of I/O operations to perform.
Bytes moves is Width size * Count, starting at Address.
Buffer - The source buffer of data to be written.
Returns:
EFI_SUCCESS - The data was written to the device.
EFI_INVALID_PARAMETER - Width is invalid.
EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.
--*/
{
EFI_STATUS Status;
DEVICE_IO_PRIVATE_DATA *Private;
Private = DEVICE_IO_PRIVATE_DATA_FROM_THIS (This);
if (Width >= MMIO_COPY_UINT8) {
return EFI_INVALID_PARAMETER;
}
Status = Private->PciRootBridgeIo->Io.Write (
Private->PciRootBridgeIo,
(EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width,
Address,
Count,
Buffer
);
return Status;
}
EFI_STATUS
EFIAPI
DeviceIoPciRead (
IN EFI_DEVICE_IO_PROTOCOL *This,
IN EFI_IO_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN OUT VOID *Buffer
)
/*++
Routine Description:
Perform reading PCI configuration space of device
Arguments:
This - A pointer to EFI_DEVICE_IO protocol instance.
Width - Width of I/O operations.
Address - The base address of I/O operations.
Count - The number of I/O operations to perform.
Bytes moves is Width size * Count, starting at Address.
Buffer - The destination buffer to store results.
Returns:
EFI_SUCCESS - The data was read from the device.
EFI_INVALID_PARAMETER - Width is invalid.
EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.
--*/
{
EFI_STATUS Status;
DEVICE_IO_PRIVATE_DATA *Private;
Private = DEVICE_IO_PRIVATE_DATA_FROM_THIS (This);
if ((UINT32)Width >= MMIO_COPY_UINT8) {
return EFI_INVALID_PARAMETER;
}
Status = Private->PciRootBridgeIo->Pci.Read (
Private->PciRootBridgeIo,
(EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width,
Address,
Count,
Buffer
);
return Status;
}
EFI_STATUS
EFIAPI
DeviceIoPciWrite (
IN EFI_DEVICE_IO_PROTOCOL *This,
IN EFI_IO_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN OUT VOID *Buffer
)
/*++
Routine Description:
Perform writing PCI configuration space of device.
Arguments:
This - A pointer to EFI_DEVICE_IO protocol instance.
Width - Width of I/O operations.
Address - The base address of I/O operations.
Count - The number of I/O operations to perform.
Bytes moves is Width size * Count, starting at Address.
Buffer - The source buffer of data to be written.
Returns:
EFI_SUCCESS - The data was written to the device.
EFI_INVALID_PARAMETER - Width is invalid.
EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.
--*/
{
EFI_STATUS Status;
DEVICE_IO_PRIVATE_DATA *Private;
Private = DEVICE_IO_PRIVATE_DATA_FROM_THIS (This);
if ((UINT32)Width >= MMIO_COPY_UINT8) {
return EFI_INVALID_PARAMETER;
}
Status = Private->PciRootBridgeIo->Pci.Write (
Private->PciRootBridgeIo,
(EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width,
Address,
Count,
Buffer
);
return Status;
}
EFI_DEVICE_PATH_PROTOCOL *
AppendPciDevicePath (
IN DEVICE_IO_PRIVATE_DATA *Private,
IN UINT8 Bus,
IN UINT8 Device,
IN UINT8 Function,
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
IN OUT UINT16 *BridgePrimaryBus,
IN OUT UINT16 *BridgeSubordinateBus
)
/*++
Routine Description:
Append a PCI device path node to another device path.
Arguments:
Private - A pointer to DEVICE_IO_PRIVATE_DATA instance.
Bus - PCI bus number of the device.
Device - PCI device number of the device.
Function - PCI function number of the device.
DevicePath - Original device path which will be appended a PCI device path node.
BridgePrimaryBus - Primary bus number of the bridge.
BridgeSubordinateBus - Subordinate bus number of the bridge.
Returns:
Pointer to the appended PCI device path.
--*/
{
UINT16 ThisBus;
UINT8 ThisDevice;
UINT8 ThisFunc;
UINT64 Address;
PCI_TYPE01 PciBridge;
PCI_TYPE01 *PciPtr;
EFI_DEVICE_PATH_PROTOCOL *ReturnDevicePath;
PCI_DEVICE_PATH PciNode;
PciPtr = &PciBridge;
for (ThisBus = *BridgePrimaryBus; ThisBus <= *BridgeSubordinateBus; ThisBus++) {
for (ThisDevice = 0; ThisDevice <= PCI_MAX_DEVICE; ThisDevice++) {
for (ThisFunc = 0; ThisFunc <= PCI_MAX_FUNC; ThisFunc++) {
Address = EFI_PCI_ADDRESS (ThisBus, ThisDevice, ThisFunc, 0);
ZeroMem (PciPtr, sizeof (PCI_TYPE01));
Private->DeviceIo.Pci.Read (
&Private->DeviceIo,
IO_UINT32,
Address,
1,
&(PciPtr->Hdr.VendorId)
);
if ((PciPtr->Hdr.VendorId == 0xffff) && (ThisFunc == 0)) {
break;
}
if (PciPtr->Hdr.VendorId == 0xffff) {
continue;
}
Private->DeviceIo.Pci.Read (
&Private->DeviceIo,
IO_UINT32,
Address,
sizeof (PCI_TYPE01) / sizeof (UINT32),
PciPtr
);
if (IS_PCI_BRIDGE (PciPtr)) {
if (Bus >= PciPtr->Bridge.SecondaryBus && Bus <= PciPtr->Bridge.SubordinateBus) {
PciNode.Header.Type = HARDWARE_DEVICE_PATH;
PciNode.Header.SubType = HW_PCI_DP;
SetDevicePathNodeLength (&PciNode.Header, sizeof (PciNode));
PciNode.Device = ThisDevice;
PciNode.Function = ThisFunc;
ReturnDevicePath = AppendDevicePathNode (DevicePath, &PciNode.Header);
*BridgePrimaryBus = PciPtr->Bridge.SecondaryBus;
*BridgeSubordinateBus = PciPtr->Bridge.SubordinateBus;
return ReturnDevicePath;
}
}
if ((ThisFunc == 0) && ((PciPtr->Hdr.HeaderType & HEADER_TYPE_MULTI_FUNCTION) == 0x0)) {
//
// Skip sub functions, this is not a multi function device
//
break;
}
}
}
}
ZeroMem (&PciNode, sizeof (PciNode));
PciNode.Header.Type = HARDWARE_DEVICE_PATH;
PciNode.Header.SubType = HW_PCI_DP;
SetDevicePathNodeLength (&PciNode.Header, sizeof (PciNode));
PciNode.Device = Device;
PciNode.Function = Function;
ReturnDevicePath = AppendDevicePathNode (DevicePath, &PciNode.Header);
*BridgePrimaryBus = 0xffff;
*BridgeSubordinateBus = 0xffff;
return ReturnDevicePath;
}
EFI_STATUS
EFIAPI
DeviceIoPciDevicePath (
IN EFI_DEVICE_IO_PROTOCOL *This,
IN UINT64 Address,
IN OUT EFI_DEVICE_PATH_PROTOCOL **PciDevicePath
)
/*++
Routine Description:
Provides an EFI Device Path for a PCI device with the given PCI configuration space address.
Arguments:
This - A pointer to the EFI_DEVICE_IO_INTERFACE instance.
Address - The PCI configuration space address of the device whose Device Path
is going to be returned.
PciDevicePath - A pointer to the pointer for the EFI Device Path for PciAddress.
Memory for the Device Path is allocated from the pool.
Returns:
EFI_SUCCESS - The PciDevicePath returns a pointer to a valid EFI Device Path.
EFI_UNSUPPORTED - The PciAddress does not map to a valid EFI Device Path.
EFI_OUT_OF_RESOURCES - The request could not be completed due to a lack of resources.
--*/
{
DEVICE_IO_PRIVATE_DATA *Private;
UINT16 PrimaryBus;
UINT16 SubordinateBus;
UINT8 Bus;
UINT8 Device;
UINT8 Func;
Private = DEVICE_IO_PRIVATE_DATA_FROM_THIS (This);
Bus = (UINT8) (((UINT32) Address >> 24) & 0xff);
Device = (UINT8) (((UINT32) Address >> 16) & 0xff);
Func = (UINT8) (((UINT32) Address >> 8) & 0xff);
if (Bus < Private->PrimaryBus || Bus > Private->SubordinateBus) {
return EFI_UNSUPPORTED;
}
*PciDevicePath = Private->DevicePath;
PrimaryBus = Private->PrimaryBus;
SubordinateBus = Private->SubordinateBus;
do {
*PciDevicePath = AppendPciDevicePath (
Private,
Bus,
Device,
Func,
*PciDevicePath,
&PrimaryBus,
&SubordinateBus
);
if (*PciDevicePath == NULL) {
return EFI_OUT_OF_RESOURCES;
}
} while (PrimaryBus != 0xffff);
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
DeviceIoMap (
IN EFI_DEVICE_IO_PROTOCOL *This,
IN EFI_IO_OPERATION_TYPE Operation,
IN EFI_PHYSICAL_ADDRESS *HostAddress,
IN OUT UINTN *NumberOfBytes,
OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
OUT VOID **Mapping
)
/*++
Routine Description:
Provides the device-specific addresses needed to access system memory.
Arguments:
This - A pointer to the EFI_DEVICE_IO_INTERFACE instance.
Operation - Indicates if the bus master is going to read or write to system memory.
HostAddress - The system memory address to map to the device.
NumberOfBytes - On input the number of bytes to map. On output the number of bytes
that were mapped.
DeviceAddress - The resulting map address for the bus master device to use to access the
hosts HostAddress.
Mapping - A resulting value to pass to Unmap().
Returns:
EFI_SUCCESS - The range was mapped for the returned NumberOfBytes.
EFI_INVALID_PARAMETER - The Operation or HostAddress is undefined.
EFI_UNSUPPORTED - The HostAddress cannot be mapped as a common buffer.
EFI_DEVICE_ERROR - The system hardware could not map the requested address.
EFI_OUT_OF_RESOURCES - The request could not be completed due to a lack of resources.
--*/
{
EFI_STATUS Status;
DEVICE_IO_PRIVATE_DATA *Private;
Private = DEVICE_IO_PRIVATE_DATA_FROM_THIS (This);
if ((UINT32)Operation > EfiBusMasterCommonBuffer) {
return EFI_INVALID_PARAMETER;
}
if (((UINTN) (*HostAddress) != (*HostAddress)) && Operation == EfiBusMasterCommonBuffer) {
return EFI_UNSUPPORTED;
}
Status = Private->PciRootBridgeIo->Map (
Private->PciRootBridgeIo,
(EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION) Operation,
(VOID *) (UINTN) (*HostAddress),
NumberOfBytes,
DeviceAddress,
Mapping
);
return Status;
}
EFI_STATUS
EFIAPI
DeviceIoUnmap (
IN EFI_DEVICE_IO_PROTOCOL *This,
IN VOID *Mapping
)
/*++
Routine Description:
Completes the Map() operation and releases any corresponding resources.
Arguments:
This - A pointer to the EFI_DEVICE_IO_INTERFACE instance.
Mapping - The mapping value returned from Map().
Returns:
EFI_SUCCESS - The range was unmapped.
EFI_DEVICE_ERROR - The data was not committed to the target system memory.
--*/
{
EFI_STATUS Status;
DEVICE_IO_PRIVATE_DATA *Private;
Private = DEVICE_IO_PRIVATE_DATA_FROM_THIS (This);
Status = Private->PciRootBridgeIo->Unmap (
Private->PciRootBridgeIo,
Mapping
);
return Status;
}
EFI_STATUS
EFIAPI
DeviceIoAllocateBuffer (
IN EFI_DEVICE_IO_PROTOCOL *This,
IN EFI_ALLOCATE_TYPE Type,
IN EFI_MEMORY_TYPE MemoryType,
IN UINTN Pages,
IN OUT EFI_PHYSICAL_ADDRESS *PhysicalAddress
)
/*++
Routine Description:
Allocates pages that are suitable for an EFIBusMasterCommonBuffer mapping.
Arguments:
This - A pointer to the EFI_DEVICE_IO_INTERFACE instance.
Type - The type allocation to perform.
MemoryType - The type of memory to allocate, EfiBootServicesData or
EfiRuntimeServicesData.
Pages - The number of pages to allocate.
PhysicalAddress - A pointer to store the base address of the allocated range.
Returns:
EFI_SUCCESS - The requested memory pages were allocated.
EFI_OUT_OF_RESOURCES - The memory pages could not be allocated.
EFI_INVALID_PARAMETER - The requested memory type is invalid.
EFI_UNSUPPORTED - The requested PhysicalAddress is not supported on
this platform.
--*/
{
EFI_STATUS Status;
EFI_PHYSICAL_ADDRESS HostAddress;
HostAddress = *PhysicalAddress;
if ((MemoryType != EfiBootServicesData) && (MemoryType != EfiRuntimeServicesData)) {
return EFI_INVALID_PARAMETER;
}
if ((UINT32)Type >= MaxAllocateType) {
return EFI_INVALID_PARAMETER;
}
if ((Type == AllocateAddress) && (HostAddress + EFI_PAGES_TO_SIZE (Pages) - 1 > MAX_COMMON_BUFFER)) {
return EFI_UNSUPPORTED;
}
if ((AllocateAnyPages == Type) || (AllocateMaxAddress == Type && HostAddress > MAX_COMMON_BUFFER)) {
Type = AllocateMaxAddress;
HostAddress = MAX_COMMON_BUFFER;
}
Status = gBS->AllocatePages (
Type,
MemoryType,
Pages,
&HostAddress
);
if (EFI_ERROR (Status)) {
return Status;
}
*PhysicalAddress = HostAddress;
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
DeviceIoFlush (
IN EFI_DEVICE_IO_PROTOCOL *This
)
/*++
Routine Description:
Flushes any posted write data to the device.
Arguments:
This - A pointer to the EFI_DEVICE_IO_INTERFACE instance.
Returns:
EFI_SUCCESS - The buffers were flushed.
EFI_DEVICE_ERROR - The buffers were not flushed due to a hardware error.
--*/
{
EFI_STATUS Status;
DEVICE_IO_PRIVATE_DATA *Private;
Private = DEVICE_IO_PRIVATE_DATA_FROM_THIS (This);
Status = Private->PciRootBridgeIo->Flush (Private->PciRootBridgeIo);
return Status;
}
EFI_STATUS
EFIAPI
DeviceIoFreeBuffer (
IN EFI_DEVICE_IO_PROTOCOL *This,
IN UINTN Pages,
IN EFI_PHYSICAL_ADDRESS HostAddress
)
/*++
Routine Description:
Frees pages that were allocated with AllocateBuffer().
Arguments:
This - A pointer to the EFI_DEVICE_IO_INTERFACE instance.
Pages - The number of pages to free.
HostAddress - The base address of the range to free.
Returns:
EFI_SUCCESS - The requested memory pages were freed.
EFI_NOT_FOUND - The requested memory pages were not allocated with
AllocateBuffer().
EFI_INVALID_PARAMETER - HostAddress is not page aligned or Pages is invalid.
--*/
{
if (((HostAddress & EFI_PAGE_MASK) != 0) || (Pages <= 0)) {
return EFI_INVALID_PARAMETER;
}
return gBS->FreePages (HostAddress, Pages);
}

View File

@ -0,0 +1,449 @@
/*++
Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
DeviceIo.h
Abstract:
Private Data definition for Device IO driver
--*/
#ifndef _DEVICE_IO_H
#define _DEVICE_IO_H
#define DEVICE_IO_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('d', 'e', 'v', 'I')
#define MAX_COMMON_BUFFER 0x00000000FFFFFFFF
typedef struct {
UINTN Signature;
EFI_HANDLE Handle;
EFI_DEVICE_IO_PROTOCOL DeviceIo;
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
UINT16 PrimaryBus;
UINT16 SubordinateBus;
} DEVICE_IO_PRIVATE_DATA;
#define DEVICE_IO_PRIVATE_DATA_FROM_THIS(a) CR (a, DEVICE_IO_PRIVATE_DATA, DeviceIo, DEVICE_IO_PRIVATE_DATA_SIGNATURE)
EFI_STATUS
DeviceIoConstructor (
IN EFI_HANDLE Handle,
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo,
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
IN UINT16 PrimaryBus,
IN UINT16 SubordinateBus
)
/*++
Routine Description:
Initialize and install a Device IO protocol on a empty device path handle.
Arguments:
Handle - Handle of PCI RootBridge IO instance
PciRootBridgeIo - PCI RootBridge IO instance
DevicePath - Device Path of PCI RootBridge IO instance
PrimaryBus - Primary Bus
SubordinateBus - Subordinate Bus
Returns:
EFI_SUCCESS - This driver is added to ControllerHandle.
EFI_ALREADY_STARTED - This driver is already running on ControllerHandle.
Others - This driver does not support this device.
--*/
;
EFI_STATUS
EFIAPI
DeviceIoMemRead (
IN EFI_DEVICE_IO_PROTOCOL *This,
IN EFI_IO_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN OUT VOID *Buffer
)
/*++
Routine Description:
Perform reading memory mapped I/O space of device.
Arguments:
This - A pointer to EFI_DEVICE_IO protocol instance.
Width - Width of I/O operations.
Address - The base address of I/O operations.
Count - The number of I/O operations to perform.
Bytes moves is Width size * Count, starting at Address.
Buffer - The destination buffer to store results.
Returns:
EFI_SUCCESS - The data was read from the device.
EFI_INVALID_PARAMETER - Width is invalid.
EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.
--*/
;
EFI_STATUS
EFIAPI
DeviceIoMemWrite (
IN EFI_DEVICE_IO_PROTOCOL *This,
IN EFI_IO_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN OUT VOID *Buffer
)
/*++
Routine Description:
Perform writing memory mapped I/O space of device.
Arguments:
This - A pointer to EFI_DEVICE_IO protocol instance.
Width - Width of I/O operations.
Address - The base address of I/O operations.
Count - The number of I/O operations to perform.
Bytes moves is Width size * Count, starting at Address.
Buffer - The source buffer of data to be written.
Returns:
EFI_SUCCESS - The data was written to the device.
EFI_INVALID_PARAMETER - Width is invalid.
EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.
--*/
;
EFI_STATUS
EFIAPI
DeviceIoIoRead (
IN EFI_DEVICE_IO_PROTOCOL *This,
IN EFI_IO_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN OUT VOID *Buffer
)
/*++
Routine Description:
Perform reading I/O space of device.
Arguments:
This - A pointer to EFI_DEVICE_IO protocol instance.
Width - Width of I/O operations.
Address - The base address of I/O operations.
Count - The number of I/O operations to perform.
Bytes moves is Width size * Count, starting at Address.
Buffer - The destination buffer to store results.
Returns:
EFI_SUCCESS - The data was read from the device.
EFI_INVALID_PARAMETER - Width is invalid.
EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.
--*/
;
EFI_STATUS
EFIAPI
DeviceIoIoWrite (
IN EFI_DEVICE_IO_PROTOCOL *This,
IN EFI_IO_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN OUT VOID *Buffer
)
/*++
Routine Description:
Perform writing I/O space of device.
Arguments:
This - A pointer to EFI_DEVICE_IO protocol instance.
Width - Width of I/O operations.
Address - The base address of I/O operations.
Count - The number of I/O operations to perform.
Bytes moves is Width size * Count, starting at Address.
Buffer - The source buffer of data to be written.
Returns:
EFI_SUCCESS - The data was written to the device.
EFI_INVALID_PARAMETER - Width is invalid.
EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.
--*/
;
EFI_STATUS
EFIAPI
DeviceIoPciRead (
IN EFI_DEVICE_IO_PROTOCOL *This,
IN EFI_IO_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN OUT VOID *Buffer
)
/*++
Routine Description:
Perform reading PCI configuration space of device
Arguments:
This - A pointer to EFI_DEVICE_IO protocol instance.
Width - Width of I/O operations.
Address - The base address of I/O operations.
Count - The number of I/O operations to perform.
Bytes moves is Width size * Count, starting at Address.
Buffer - The destination buffer to store results.
Returns:
EFI_SUCCESS - The data was read from the device.
EFI_INVALID_PARAMETER - Width is invalid.
EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.
--*/
;
EFI_STATUS
EFIAPI
DeviceIoPciWrite (
IN EFI_DEVICE_IO_PROTOCOL *This,
IN EFI_IO_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN OUT VOID *Buffer
)
/*++
Routine Description:
Perform writing PCI configuration space of device.
Arguments:
This - A pointer to EFI_DEVICE_IO protocol instance.
Width - Width of I/O operations.
Address - The base address of I/O operations.
Count - The number of I/O operations to perform.
Bytes moves is Width size * Count, starting at Address.
Buffer - The source buffer of data to be written.
Returns:
EFI_SUCCESS - The data was written to the device.
EFI_INVALID_PARAMETER - Width is invalid.
EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.
--*/
;
EFI_STATUS
EFIAPI
DeviceIoPciDevicePath (
IN EFI_DEVICE_IO_PROTOCOL *This,
IN UINT64 Address,
IN OUT EFI_DEVICE_PATH_PROTOCOL **PciDevicePath
)
/*++
Routine Description:
Append a PCI device path node to another device path.
Arguments:
This - A pointer to EFI_DEVICE_IO_PROTOCOL.
Address - PCI bus,device, function.
PciDevicePath - PCI device path.
Returns:
Pointer to the appended PCI device path.
--*/
;
EFI_STATUS
EFIAPI
DeviceIoMap (
IN EFI_DEVICE_IO_PROTOCOL *This,
IN EFI_IO_OPERATION_TYPE Operation,
IN EFI_PHYSICAL_ADDRESS *HostAddress,
IN OUT UINTN *NumberOfBytes,
OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
OUT VOID **Mapping
)
/*++
Routine Description:
Provides the device-specific addresses needed to access system memory.
Arguments:
This - A pointer to the EFI_DEVICE_IO_INTERFACE instance.
Operation - Indicates if the bus master is going to read or write to system memory.
HostAddress - The system memory address to map to the device.
NumberOfBytes - On input the number of bytes to map. On output the number of bytes
that were mapped.
DeviceAddress - The resulting map address for the bus master device to use to access the
hosts HostAddress.
Mapping - A resulting value to pass to Unmap().
Returns:
EFI_SUCCESS - The range was mapped for the returned NumberOfBytes.
EFI_INVALID_PARAMETER - The Operation or HostAddress is undefined.
EFI_UNSUPPORTED - The HostAddress cannot be mapped as a common buffer.
EFI_DEVICE_ERROR - The system hardware could not map the requested address.
EFI_OUT_OF_RESOURCES - The request could not be completed due to a lack of resources.
--*/
;
EFI_STATUS
EFIAPI
DeviceIoUnmap (
IN EFI_DEVICE_IO_PROTOCOL *This,
IN VOID *Mapping
)
/*++
Routine Description:
Completes the Map() operation and releases any corresponding resources.
Arguments:
This - A pointer to the EFI_DEVICE_IO_INTERFACE instance.
Mapping - The mapping value returned from Map().
Returns:
EFI_SUCCESS - The range was unmapped.
EFI_DEVICE_ERROR - The data was not committed to the target system memory.
--*/
;
EFI_STATUS
EFIAPI
DeviceIoAllocateBuffer (
IN EFI_DEVICE_IO_PROTOCOL *This,
IN EFI_ALLOCATE_TYPE Type,
IN EFI_MEMORY_TYPE MemoryType,
IN UINTN Pages,
IN OUT EFI_PHYSICAL_ADDRESS *HostAddress
)
/*++
Routine Description:
Allocates pages that are suitable for an EFIBusMasterCommonBuffer mapping.
Arguments:
This - A pointer to the EFI_DEVICE_IO_INTERFACE instance.
Type - The type allocation to perform.
MemoryType - The type of memory to allocate, EfiBootServicesData or
EfiRuntimeServicesData.
Pages - The number of pages to allocate.
HostAddress - A pointer to store the base address of the allocated range.
Returns:
EFI_SUCCESS - The requested memory pages were allocated.
EFI_OUT_OF_RESOURCES - The memory pages could not be allocated.
EFI_INVALID_PARAMETER - The requested memory type is invalid.
EFI_UNSUPPORTED - The requested PhysicalAddress is not supported on
this platform.
--*/
;
EFI_STATUS
EFIAPI
DeviceIoFlush (
IN EFI_DEVICE_IO_PROTOCOL *This
)
/*++
Routine Description:
Flushes any posted write data to the device.
Arguments:
This - A pointer to the EFI_DEVICE_IO_INTERFACE instance.
Returns:
EFI_SUCCESS - The buffers were flushed.
EFI_DEVICE_ERROR - The buffers were not flushed due to a hardware error.
--*/
;
EFI_STATUS
EFIAPI
DeviceIoFreeBuffer (
IN EFI_DEVICE_IO_PROTOCOL *This,
IN UINTN Pages,
IN EFI_PHYSICAL_ADDRESS HostAddress
)
/*++
Routine Description:
Frees pages that were allocated with AllocateBuffer().
Arguments:
This - A pointer to the EFI_DEVICE_IO_INTERFACE instance.
Pages - The number of pages to free.
HostAddress - The base address of the range to free.
Returns:
EFI_SUCCESS - The requested memory pages were freed.
EFI_NOT_FOUND - The requested memory pages were not allocated with
AllocateBuffer().
EFI_INVALID_PARAMETER - HostAddress is not page aligned or Pages is invalid.
--*/
;
#endif

View File

@ -0,0 +1,738 @@
/*++
Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
PcatPciRootBridgeIo.c
Abstract:
EFI PC AT PCI Root Bridge Io Protocol
Revision History
--*/
#include "PcatPciRootBridge.h"
BOOLEAN mPciOptionRomTableInstalled = FALSE;
EFI_PCI_OPTION_ROM_TABLE mPciOptionRomTable = {0, NULL};
EFI_STATUS
EFIAPI
PcatRootBridgeIoIoRead (
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
IN UINT64 UserAddress,
IN UINTN Count,
IN OUT VOID *UserBuffer
)
{
return gCpuIo->Io.Read (
gCpuIo,
(EFI_CPU_IO_PROTOCOL_WIDTH) Width,
UserAddress,
Count,
UserBuffer
);
}
EFI_STATUS
EFIAPI
PcatRootBridgeIoIoWrite (
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
IN UINT64 UserAddress,
IN UINTN Count,
IN OUT VOID *UserBuffer
)
{
return gCpuIo->Io.Write (
gCpuIo,
(EFI_CPU_IO_PROTOCOL_WIDTH) Width,
UserAddress,
Count,
UserBuffer
);
}
EFI_STATUS
PcatRootBridgeIoGetIoPortMapping (
OUT EFI_PHYSICAL_ADDRESS *IoPortMapping,
OUT EFI_PHYSICAL_ADDRESS *MemoryPortMapping
)
/*++
Get the IO Port Mapping. For IA-32 it is always 0.
--*/
{
*IoPortMapping = 0;
*MemoryPortMapping = 0;
return EFI_SUCCESS;
}
EFI_STATUS
PcatRootBridgeIoPciRW (
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
IN BOOLEAN Write,
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
IN UINT64 UserAddress,
IN UINTN Count,
IN OUT VOID *UserBuffer
)
{
PCI_CONFIG_ACCESS_CF8 Pci;
PCI_CONFIG_ACCESS_CF8 PciAligned;
UINT32 InStride;
UINT32 OutStride;
UINTN PciData;
UINTN PciDataStride;
PCAT_PCI_ROOT_BRIDGE_INSTANCE *PrivateData;
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS PciAddress;
UINT64 PciExpressRegAddr;
BOOLEAN UsePciExpressAccess;
if ((UINT32)Width >= EfiPciWidthMaximum) {
return EFI_INVALID_PARAMETER;
}
if ((Width & 0x03) >= EfiPciWidthUint64) {
return EFI_INVALID_PARAMETER;
}
PrivateData = DRIVER_INSTANCE_FROM_PCI_ROOT_BRIDGE_IO_THIS(This);
InStride = 1 << (Width & 0x03);
OutStride = InStride;
if (Width >= EfiPciWidthFifoUint8 && Width <= EfiPciWidthFifoUint64) {
InStride = 0;
}
if (Width >= EfiPciWidthFillUint8 && Width <= EfiPciWidthFillUint64) {
OutStride = 0;
}
UsePciExpressAccess = FALSE;
CopyMem (&PciAddress, &UserAddress, sizeof(UINT64));
if (PciAddress.ExtendedRegister > 0xFF) {
//
// Check PciExpressBaseAddress
//
if ((PrivateData->PciExpressBaseAddress == 0) ||
(PrivateData->PciExpressBaseAddress >= MAX_ADDRESS)) {
return EFI_UNSUPPORTED;
} else {
UsePciExpressAccess = TRUE;
}
} else {
if (PciAddress.ExtendedRegister != 0) {
Pci.Bits.Reg = PciAddress.ExtendedRegister & 0xFF;
} else {
Pci.Bits.Reg = PciAddress.Register;
}
//
// Note: We can also use PciExpress access here, if wanted.
//
}
if (!UsePciExpressAccess) {
Pci.Bits.Func = PciAddress.Function;
Pci.Bits.Dev = PciAddress.Device;
Pci.Bits.Bus = PciAddress.Bus;
Pci.Bits.Reserved = 0;
Pci.Bits.Enable = 1;
//
// PCI Config access are all 32-bit alligned, but by accessing the
// CONFIG_DATA_REGISTER (0xcfc) with different widths more cycle types
// are possible on PCI.
//
// To read a byte of PCI config space you load 0xcf8 and
// read 0xcfc, 0xcfd, 0xcfe, 0xcff
//
PciDataStride = Pci.Bits.Reg & 0x03;
while (Count) {
PciAligned = Pci;
PciAligned.Bits.Reg &= 0xfc;
PciData = (UINTN)PrivateData->PciData + PciDataStride;
EfiAcquireLock(&PrivateData->PciLock);
This->Io.Write (This, EfiPciWidthUint32, PrivateData->PciAddress, 1, &PciAligned);
if (Write) {
This->Io.Write (This, Width, PciData, 1, UserBuffer);
} else {
This->Io.Read (This, Width, PciData, 1, UserBuffer);
}
EfiReleaseLock(&PrivateData->PciLock);
UserBuffer = ((UINT8 *)UserBuffer) + OutStride;
PciDataStride = (PciDataStride + InStride) % 4;
Pci.Bits.Reg += InStride;
Count -= 1;
}
} else {
//
// Access PCI-Express space by using memory mapped method.
//
PciExpressRegAddr = (PrivateData->PciExpressBaseAddress) |
(PciAddress.Bus << 20) |
(PciAddress.Device << 15) |
(PciAddress.Function << 12);
if (PciAddress.ExtendedRegister != 0) {
PciExpressRegAddr += PciAddress.ExtendedRegister;
} else {
PciExpressRegAddr += PciAddress.Register;
}
while (Count) {
if (Write) {
This->Mem.Write (This, Width, (UINTN) PciExpressRegAddr, 1, UserBuffer);
} else {
This->Mem.Read (This, Width, (UINTN) PciExpressRegAddr, 1, UserBuffer);
}
UserBuffer = ((UINT8 *) UserBuffer) + OutStride;
PciExpressRegAddr += InStride;
Count -= 1;
}
}
return EFI_SUCCESS;
}
VOID
ScanPciBus(
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev,
UINT16 MinBus,
UINT16 MaxBus,
UINT16 MinDevice,
UINT16 MaxDevice,
UINT16 MinFunc,
UINT16 MaxFunc,
EFI_PCI_BUS_SCAN_CALLBACK Callback,
VOID *Context
)
{
UINT16 Bus;
UINT16 Device;
UINT16 Func;
UINT64 Address;
PCI_TYPE00 PciHeader;
//
// Loop through all busses
//
for (Bus = MinBus; Bus <= MaxBus; Bus++) {
//
// Loop 32 devices per bus
//
for (Device = MinDevice; Device <= MaxDevice; Device++) {
//
// Loop through 8 functions per device
//
for (Func = MinFunc; Func <= MaxFunc; Func++) {
//
// Compute the EFI Address required to access the PCI Configuration Header of this PCI Device
//
Address = EFI_PCI_ADDRESS (Bus, Device, Func, 0);
//
// Read the VendorID from this PCI Device's Confioguration Header
//
IoDev->Pci.Read (IoDev, EfiPciWidthUint16, Address, 1, &PciHeader.Hdr.VendorId);
//
// If VendorId = 0xffff, there does not exist a device at this
// location. For each device, if there is any function on it,
// there must be 1 function at Function 0. So if Func = 0, there
// will be no more functions in the same device, so we can break
// loop to deal with the next device.
//
if (PciHeader.Hdr.VendorId == 0xffff && Func == 0) {
break;
}
if (PciHeader.Hdr.VendorId != 0xffff) {
//
// Read the HeaderType to determine if this is a multi-function device
//
IoDev->Pci.Read (IoDev, EfiPciWidthUint8, Address + 0x0e, 1, &PciHeader.Hdr.HeaderType);
//
// Call the callback function for the device that was found
//
Callback(
IoDev,
MinBus, MaxBus,
MinDevice, MaxDevice,
MinFunc, MaxFunc,
Bus,
Device,
Func,
Context
);
//
// If this is not a multi-function device, we can leave the loop
// to deal with the next device.
//
if ((PciHeader.Hdr.HeaderType & HEADER_TYPE_MULTI_FUNCTION) == 0x00 && Func == 0) {
break;
}
}
}
}
}
}
VOID
CheckForRom (
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev,
UINT16 MinBus,
UINT16 MaxBus,
UINT16 MinDevice,
UINT16 MaxDevice,
UINT16 MinFunc,
UINT16 MaxFunc,
UINT16 Bus,
UINT16 Device,
UINT16 Func,
IN VOID *VoidContext
)
{
EFI_STATUS Status;
PCAT_PCI_ROOT_BRIDGE_SCAN_FOR_ROM_CONTEXT *Context;
UINT64 Address;
PCI_TYPE00 PciHeader;
PCI_TYPE01 *PciBridgeHeader;
UINT32 Register;
UINT32 RomBar;
UINT32 RomBarSize;
EFI_PHYSICAL_ADDRESS RomBuffer;
UINT32 MaxRomSize;
EFI_PCI_EXPANSION_ROM_HEADER EfiRomHeader;
PCI_DATA_STRUCTURE Pcir;
EFI_PCI_OPTION_ROM_DESCRIPTOR *TempPciOptionRomDescriptors;
BOOLEAN LastImage;
Context = (PCAT_PCI_ROOT_BRIDGE_SCAN_FOR_ROM_CONTEXT *)VoidContext;
Address = EFI_PCI_ADDRESS (Bus, Device, Func, 0);
//
// Save the contents of the PCI Configuration Header
//
IoDev->Pci.Read (IoDev, EfiPciWidthUint32, Address, sizeof(PciHeader)/sizeof(UINT32), &PciHeader);
if (IS_PCI_BRIDGE(&PciHeader)) {
PciBridgeHeader = (PCI_TYPE01 *)(&PciHeader);
//
// See if the PCI-PCI Bridge has its secondary interface enabled.
//
if (PciBridgeHeader->Bridge.SubordinateBus >= PciBridgeHeader->Bridge.SecondaryBus) {
//
// Disable the Prefetchable Memory Window
//
Register = 0x00000000;
IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address + 0x26, 1, &Register);
IoDev->Pci.Write (IoDev, EfiPciWidthUint32, Address + 0x2c, 1, &Register);
Register = 0xffffffff;
IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address + 0x24, 1, &Register);
IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address + 0x28, 1, &Register);
//
// Program Memory Window to the PCI Root Bridge Memory Window
//
IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address + 0x20, 4, &Context->PpbMemoryWindow);
//
// Enable the Memory decode for the PCI-PCI Bridge
//
IoDev->Pci.Read (IoDev, EfiPciWidthUint16, Address + 4, 1, &Register);
Register |= 0x02;
IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address + 4, 1, &Register);
//
// Recurse on the Secondary Bus Number
//
ScanPciBus(
IoDev,
PciBridgeHeader->Bridge.SecondaryBus, PciBridgeHeader->Bridge.SecondaryBus,
0, PCI_MAX_DEVICE,
0, PCI_MAX_FUNC,
CheckForRom, Context
);
}
} else {
//
// Check if an Option ROM Register is present and save the Option ROM Window Register
//
RomBar = 0xffffffff;
IoDev->Pci.Write (IoDev, EfiPciWidthUint32, Address + 0x30, 1, &RomBar);
IoDev->Pci.Read (IoDev, EfiPciWidthUint32, Address + 0x30, 1, &RomBar);
RomBarSize = (~(RomBar & 0xfffff800)) + 1;
//
// Make sure the size of the ROM is between 0 and 16 MB
//
if (RomBarSize > 0 && RomBarSize <= 0x01000000) {
//
// Program Option ROM Window Register to the PCI Root Bridge Window and Enable the Option ROM Window
//
RomBar = (Context->PpbMemoryWindow & 0xffff) << 16;
RomBar = ((RomBar - 1) & (~(RomBarSize - 1))) + RomBarSize;
if (RomBar < (Context->PpbMemoryWindow & 0xffff0000)) {
MaxRomSize = (Context->PpbMemoryWindow & 0xffff0000) - RomBar;
RomBar = RomBar + 1;
IoDev->Pci.Write (IoDev, EfiPciWidthUint32, Address + 0x30, 1, &RomBar);
IoDev->Pci.Read (IoDev, EfiPciWidthUint32, Address + 0x30, 1, &RomBar);
RomBar = RomBar - 1;
//
// Enable the Memory decode for the PCI Device
//
IoDev->Pci.Read (IoDev, EfiPciWidthUint16, Address + 4, 1, &Register);
Register |= 0x02;
IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address + 4, 1, &Register);
//
// Follow the chain of images to determine the size of the Option ROM present
// Keep going until the last image is found by looking at the Indicator field
// or the size of an image is 0, or the size of all the images is bigger than the
// size of the window programmed into the PPB.
//
RomBarSize = 0;
do {
LastImage = TRUE;
ZeroMem (&EfiRomHeader, sizeof(EfiRomHeader));
IoDev->Mem.Read (
IoDev,
EfiPciWidthUint8,
RomBar + RomBarSize,
sizeof(EfiRomHeader),
&EfiRomHeader
);
Pcir.ImageLength = 0;
if (EfiRomHeader.Signature == PCI_EXPANSION_ROM_HEADER_SIGNATURE &&
EfiRomHeader.PcirOffset != 0 &&
(EfiRomHeader.PcirOffset & 3) == 0 &&
RomBarSize + EfiRomHeader.PcirOffset + sizeof (PCI_DATA_STRUCTURE) <= MaxRomSize) {
ZeroMem (&Pcir, sizeof(Pcir));
IoDev->Mem.Read (
IoDev,
EfiPciWidthUint8,
RomBar + RomBarSize + EfiRomHeader.PcirOffset,
sizeof(Pcir),
&Pcir
);
if (Pcir.Signature != PCI_DATA_STRUCTURE_SIGNATURE) {
break;
}
if (RomBarSize + Pcir.ImageLength * 512 > MaxRomSize) {
break;
}
if ((Pcir.Indicator & 0x80) == 0x00) {
LastImage = FALSE;
}
RomBarSize += Pcir.ImageLength * 512;
}
} while (!LastImage && RomBarSize < MaxRomSize && Pcir.ImageLength !=0);
if (RomBarSize > 0) {
//
// Allocate a memory buffer for the Option ROM contents.
//
Status = gBS->AllocatePages(
AllocateAnyPages,
EfiBootServicesData,
EFI_SIZE_TO_PAGES(RomBarSize),
&RomBuffer
);
if (!EFI_ERROR (Status)) {
//
// Copy the contents of the Option ROM to the memory buffer
//
IoDev->Mem.Read (IoDev, EfiPciWidthUint32, RomBar, RomBarSize / sizeof(UINT32), (VOID *)(UINTN)RomBuffer);
Status = gBS->AllocatePool(
EfiBootServicesData,
((UINT32)mPciOptionRomTable.PciOptionRomCount + 1) * sizeof(EFI_PCI_OPTION_ROM_DESCRIPTOR),
(VOID*)&TempPciOptionRomDescriptors
);
if (mPciOptionRomTable.PciOptionRomCount > 0) {
CopyMem(
TempPciOptionRomDescriptors,
mPciOptionRomTable.PciOptionRomDescriptors,
(UINT32)mPciOptionRomTable.PciOptionRomCount * sizeof(EFI_PCI_OPTION_ROM_DESCRIPTOR)
);
gBS->FreePool(mPciOptionRomTable.PciOptionRomDescriptors);
}
mPciOptionRomTable.PciOptionRomDescriptors = TempPciOptionRomDescriptors;
TempPciOptionRomDescriptors = &(mPciOptionRomTable.PciOptionRomDescriptors[(UINT32)mPciOptionRomTable.PciOptionRomCount]);
TempPciOptionRomDescriptors->RomAddress = RomBuffer;
TempPciOptionRomDescriptors->MemoryType = EfiBootServicesData;
TempPciOptionRomDescriptors->RomLength = RomBarSize;
TempPciOptionRomDescriptors->Seg = (UINT32)IoDev->SegmentNumber;
TempPciOptionRomDescriptors->Bus = (UINT8)Bus;
TempPciOptionRomDescriptors->Dev = (UINT8)Device;
TempPciOptionRomDescriptors->Func = (UINT8)Func;
TempPciOptionRomDescriptors->ExecutedLegacyBiosImage = TRUE;
TempPciOptionRomDescriptors->DontLoadEfiRom = FALSE;
mPciOptionRomTable.PciOptionRomCount++;
}
}
//
// Disable the Memory decode for the PCI-PCI Bridge
//
IoDev->Pci.Read (IoDev, EfiPciWidthUint16, Address + 4, 1, &Register);
Register &= (~0x02);
IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address + 4, 1, &Register);
}
}
}
//
// Restore the PCI Configuration Header
//
IoDev->Pci.Write (IoDev, EfiPciWidthUint32, Address, sizeof(PciHeader)/sizeof(UINT32), &PciHeader);
}
VOID
SaveCommandRegister (
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev,
UINT16 MinBus,
UINT16 MaxBus,
UINT16 MinDevice,
UINT16 MaxDevice,
UINT16 MinFunc,
UINT16 MaxFunc,
UINT16 Bus,
UINT16 Device,
UINT16 Func,
IN VOID *VoidContext
)
{
PCAT_PCI_ROOT_BRIDGE_SCAN_FOR_ROM_CONTEXT *Context;
UINT64 Address;
UINTN Index;
UINT16 Command;
Context = (PCAT_PCI_ROOT_BRIDGE_SCAN_FOR_ROM_CONTEXT *)VoidContext;
Address = EFI_PCI_ADDRESS (Bus, Device, Func, 4);
Index = (Bus - MinBus) * (PCI_MAX_DEVICE+1) * (PCI_MAX_FUNC+1) + Device * (PCI_MAX_FUNC+1) + Func;
IoDev->Pci.Read (IoDev, EfiPciWidthUint16, Address, 1, &Context->CommandRegisterBuffer[Index]);
//
// Clear the memory enable bit
//
Command = (UINT16) (Context->CommandRegisterBuffer[Index] & (~0x02));
IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address, 1, &Command);
}
VOID
RestoreCommandRegister (
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev,
UINT16 MinBus,
UINT16 MaxBus,
UINT16 MinDevice,
UINT16 MaxDevice,
UINT16 MinFunc,
UINT16 MaxFunc,
UINT16 Bus,
UINT16 Device,
UINT16 Func,
IN VOID *VoidContext
)
{
PCAT_PCI_ROOT_BRIDGE_SCAN_FOR_ROM_CONTEXT *Context;
UINT64 Address;
UINTN Index;
Context = (PCAT_PCI_ROOT_BRIDGE_SCAN_FOR_ROM_CONTEXT *)VoidContext;
Address = EFI_PCI_ADDRESS (Bus, Device, Func, 4);
Index = (Bus - MinBus) * (PCI_MAX_DEVICE+1) * (PCI_MAX_FUNC+1) + Device * (PCI_MAX_FUNC+1) + Func;
IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address, 1, &Context->CommandRegisterBuffer[Index]);
}
EFI_STATUS
ScanPciRootBridgeForRoms(
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev
)
{
EFI_STATUS Status;
EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptors;
UINT16 MinBus;
UINT16 MaxBus;
UINT64 RootWindowBase;
UINT64 RootWindowLimit;
PCAT_PCI_ROOT_BRIDGE_SCAN_FOR_ROM_CONTEXT Context;
if (mPciOptionRomTableInstalled == FALSE) {
gBS->InstallConfigurationTable(&gEfiPciOptionRomTableGuid, &mPciOptionRomTable);
mPciOptionRomTableInstalled = TRUE;
}
Status = IoDev->Configuration(IoDev, (VOID **)&Descriptors);
if (EFI_ERROR (Status) || Descriptors == NULL) {
return EFI_NOT_FOUND;
}
MinBus = 0xffff;
MaxBus = 0xffff;
RootWindowBase = 0;
RootWindowLimit = 0;
while (Descriptors->Desc != ACPI_END_TAG_DESCRIPTOR) {
//
// Find bus range
//
if (Descriptors->ResType == ACPI_ADDRESS_SPACE_TYPE_BUS) {
MinBus = (UINT16)Descriptors->AddrRangeMin;
MaxBus = (UINT16)Descriptors->AddrRangeMax;
}
//
// Find memory descriptors that are not prefetchable
//
if (Descriptors->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM && Descriptors->SpecificFlag == 0) {
//
// Find Memory Descriptors that are less than 4GB, so the PPB Memory Window can be used for downstream devices
//
if (Descriptors->AddrRangeMax < 0x100000000ULL) {
//
// Find the largest Non-Prefetchable Memory Descriptor that is less than 4GB
//
if ((Descriptors->AddrRangeMax - Descriptors->AddrRangeMin) > (RootWindowLimit - RootWindowBase)) {
RootWindowBase = Descriptors->AddrRangeMin;
RootWindowLimit = Descriptors->AddrRangeMax;
}
}
}
Descriptors ++;
}
//
// Make sure a bus range was found
//
if (MinBus == 0xffff || MaxBus == 0xffff) {
return EFI_NOT_FOUND;
}
//
// Make sure a non-prefetchable memory region was found
//
if (RootWindowBase == 0 && RootWindowLimit == 0) {
return EFI_NOT_FOUND;
}
//
// Round the Base and Limit values to 1 MB boudaries
//
RootWindowBase = ((RootWindowBase - 1) & 0xfff00000) + 0x00100000;
RootWindowLimit = ((RootWindowLimit + 1) & 0xfff00000) - 1;
//
// Make sure that the size of the rounded window is greater than zero
//
if (RootWindowLimit <= RootWindowBase) {
return EFI_NOT_FOUND;
}
//
// Allocate buffer to save the Command register from all the PCI devices
//
Context.CommandRegisterBuffer = NULL;
Status = gBS->AllocatePool(
EfiBootServicesData,
sizeof(UINT16) * (MaxBus - MinBus + 1) * (PCI_MAX_DEVICE+1) * (PCI_MAX_FUNC+1),
(VOID **)&Context.CommandRegisterBuffer
);
if (EFI_ERROR (Status)) {
return Status;
}
Context.PpbMemoryWindow = (((UINT32)RootWindowBase) >> 16) | ((UINT32)RootWindowLimit & 0xffff0000);
//
// Save the Command register from all the PCI devices, and disable the I/O, Mem, and BusMaster bits
//
ScanPciBus(
IoDev,
MinBus, MaxBus,
0, PCI_MAX_DEVICE,
0, PCI_MAX_FUNC,
SaveCommandRegister, &Context
);
//
// Recursively scan all the busses for PCI Option ROMs
//
ScanPciBus(
IoDev,
MinBus, MinBus,
0, PCI_MAX_DEVICE,
0, PCI_MAX_FUNC,
CheckForRom, &Context
);
//
// Restore the Command register in all the PCI devices
//
ScanPciBus(
IoDev,
MinBus, MaxBus,
0, PCI_MAX_DEVICE,
0, PCI_MAX_FUNC,
RestoreCommandRegister, &Context
);
//
// Free the buffer used to save all the Command register values
//
gBS->FreePool(Context.CommandRegisterBuffer);
return EFI_SUCCESS;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,244 @@
/*++
Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
PcatPciRootBridge.h
Abstract:
The driver for the host to pci bridge (root bridge).
--*/
#ifndef _PCAT_PCI_ROOT_BRIDGE_H_
#define _PCAT_PCI_ROOT_BRIDGE_H_
#include <PiDxe.h>
#include <Protocol/PciRootBridgeIo.h>
#include <Protocol/DeviceIo.h>
#include <Protocol/CpuIo2.h>
#include <Library/UefiLib.h>
#include <Library/BaseLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DevicePathLib.h>
#include <Library/HobLib.h>
#include <Guid/PciOptionRomTable.h>
#include <Guid/HobList.h>
#include <Guid/PciExpressBaseAddress.h>
#include <IndustryStandard/Acpi.h>
#include <IndustryStandard/Pci.h>
#define PCI_MAX_SEGMENT 0
//
// Driver Instance Data Prototypes
//
#define PCAT_PCI_ROOT_BRIDGE_SIGNATURE SIGNATURE_32('p', 'c', 'r', 'b')
typedef struct {
UINT32 Signature;
EFI_HANDLE Handle;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL Io;
EFI_CPU_IO2_PROTOCOL *CpuIo;
UINT32 RootBridgeNumber;
UINT32 PrimaryBus;
UINT32 SubordinateBus;
UINT64 MemBase; // Offsets host to bus memory addr.
UINT64 MemLimit; // Max allowable memory access
UINT64 IoBase; // Offsets host to bus io addr.
UINT64 IoLimit; // Max allowable io access
UINT64 PciAddress;
UINT64 PciData;
UINT64 PhysicalMemoryBase;
UINT64 PhysicalIoBase;
EFI_LOCK PciLock;
UINT64 Attributes;
UINT64 Mem32Base;
UINT64 Mem32Limit;
UINT64 Pmem32Base;
UINT64 Pmem32Limit;
UINT64 Mem64Base;
UINT64 Mem64Limit;
UINT64 Pmem64Base;
UINT64 Pmem64Limit;
UINT64 PciExpressBaseAddress;
EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Configuration;
LIST_ENTRY MapInfo;
} PCAT_PCI_ROOT_BRIDGE_INSTANCE;
//
// Driver Instance Data Macros
//
#define DRIVER_INSTANCE_FROM_PCI_ROOT_BRIDGE_IO_THIS(a) \
CR(a, PCAT_PCI_ROOT_BRIDGE_INSTANCE, Io, PCAT_PCI_ROOT_BRIDGE_SIGNATURE)
//
// Private data types
//
typedef union {
UINT8 volatile *buf;
UINT8 volatile *ui8;
UINT16 volatile *ui16;
UINT32 volatile *ui32;
UINT64 volatile *ui64;
UINTN volatile ui;
} PTR;
typedef struct {
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION Operation;
UINTN NumberOfBytes;
UINTN NumberOfPages;
EFI_PHYSICAL_ADDRESS HostAddress;
EFI_PHYSICAL_ADDRESS MappedHostAddress;
} MAP_INFO;
typedef struct {
LIST_ENTRY Link;
MAP_INFO * Map;
} MAP_INFO_INSTANCE;
typedef
VOID
(*EFI_PCI_BUS_SCAN_CALLBACK) (
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev,
UINT16 MinBus,
UINT16 MaxBus,
UINT16 MinDevice,
UINT16 MaxDevice,
UINT16 MinFunc,
UINT16 MaxFunc,
UINT16 Bus,
UINT16 Device,
UINT16 Func,
IN VOID *Context
);
typedef struct {
UINT16 *CommandRegisterBuffer;
UINT32 PpbMemoryWindow;
} PCAT_PCI_ROOT_BRIDGE_SCAN_FOR_ROM_CONTEXT;
typedef struct {
UINT8 Register;
UINT8 Function;
UINT8 Device;
UINT8 Bus;
UINT8 Reserved[4];
} DEFIO_PCI_ADDR;
//
// Driver Protocol Constructor Prototypes
//
EFI_STATUS
ConstructConfiguration(
IN OUT PCAT_PCI_ROOT_BRIDGE_INSTANCE *PrivateData
);
EFI_STATUS
PcatPciRootBridgeParseBars (
IN PCAT_PCI_ROOT_BRIDGE_INSTANCE *PrivateData,
IN UINT16 Command,
IN UINTN Bus,
IN UINTN Device,
IN UINTN Function
);
EFI_STATUS
ScanPciRootBridgeForRoms(
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev
);
EFI_STATUS
PcatRootBridgeDevicePathConstructor (
IN EFI_DEVICE_PATH_PROTOCOL **Protocol,
IN UINTN RootBridgeNumber,
IN BOOLEAN IsPciExpress
);
EFI_STATUS
PcatRootBridgeIoConstructor (
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *Protocol,
IN UINTN SegmentNumber
);
EFI_STATUS
PcatRootBridgeIoGetIoPortMapping (
OUT EFI_PHYSICAL_ADDRESS *IoPortMapping,
OUT EFI_PHYSICAL_ADDRESS *MemoryPortMapping
);
EFI_STATUS
PcatRootBridgeIoPciRW (
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
IN BOOLEAN Write,
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
IN UINT64 UserAddress,
IN UINTN Count,
IN OUT VOID *UserBuffer
);
UINT64
GetPciExpressBaseAddressForRootBridge (
IN UINTN HostBridgeNumber,
IN UINTN RootBridgeNumber
);
EFI_STATUS
EFIAPI
PcatRootBridgeIoIoRead (
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
IN UINT64 UserAddress,
IN UINTN Count,
IN OUT VOID *UserBuffer
);
EFI_STATUS
EFIAPI
PcatRootBridgeIoIoWrite (
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
IN UINT64 UserAddress,
IN UINTN Count,
IN OUT VOID *UserBuffer
);
//
// Driver entry point prototype
//
EFI_STATUS
EFIAPI
InitializePcatPciRootBridge (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
extern EFI_CPU_IO2_PROTOCOL *gCpuIo;
#endif

View File

@ -0,0 +1,93 @@
/*++
Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
PcatPciRootBridgeDevicePath.c
Abstract:
EFI PCAT PCI Root Bridge Device Path Protocol
Revision History
--*/
#include "PcatPciRootBridge.h"
//
// Static device path declarations for this driver.
//
typedef struct {
ACPI_HID_DEVICE_PATH AcpiDevicePath;
EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
} EFI_PCI_ROOT_BRIDGE_DEVICE_PATH;
EFI_PCI_ROOT_BRIDGE_DEVICE_PATH mEfiPciRootBridgeDevicePath = {
{
{
ACPI_DEVICE_PATH,
ACPI_DP,
{
(UINT8) (sizeof(ACPI_HID_DEVICE_PATH)),
(UINT8) ((sizeof(ACPI_HID_DEVICE_PATH)) >> 8),
}
},
EISA_PNP_ID(0x0A03),
0
},
{
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
END_DEVICE_PATH_LENGTH,
0
}
}
};
EFI_STATUS
PcatRootBridgeDevicePathConstructor (
IN EFI_DEVICE_PATH_PROTOCOL **Protocol,
IN UINTN RootBridgeNumber,
IN BOOLEAN IsPciExpress
)
/*++
Routine Description:
Construct the device path protocol
Arguments:
Protocol - protocol to initialize
Returns:
None
--*/
{
ACPI_HID_DEVICE_PATH *AcpiDevicePath;
*Protocol = DuplicateDevicePath((EFI_DEVICE_PATH_PROTOCOL *)(&mEfiPciRootBridgeDevicePath));
AcpiDevicePath = (ACPI_HID_DEVICE_PATH *)(*Protocol);
AcpiDevicePath->UID = (UINT32)RootBridgeNumber;
if (IsPciExpress) {
AcpiDevicePath->HID = EISA_PNP_ID(0x0A08);
}
return EFI_SUCCESS;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,66 @@
## @file
#
# Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# Abstract:
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = PcatPciRootBridge
FILE_GUID = 0F7EC77A-1EE1-400f-A99D-7CBD1FEB181E
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
ENTRY_POINT = InitializePcatPciRootBridge
[Packages]
MdePkg/MdePkg.dec
CorebootModulePkg/CorebootModulePkg.dec
[LibraryClasses]
UefiDriverEntryPoint
UefiLib
MemoryAllocationLib
UefiBootServicesTableLib
DebugLib
BaseMemoryLib
DevicePathLib
HobLib
[Sources]
PcatPciRootBridge.h
PcatPciRootBridge.c
PcatPciRootBridgeDevicePath.c
PcatPciRootBridgeIo.c
DeviceIo.h
DeviceIo.c
[Sources.ia32]
Ia32/PcatIo.c
[Sources.x64]
X64/PcatIo.c
[Protocols]
gEfiPciRootBridgeIoProtocolGuid
gEfiDeviceIoProtocolGuid
gEfiCpuIo2ProtocolGuid
[Guids]
gEfiPciOptionRomTableGuid
gEfiPciExpressBaseAddressGuid
[Depex]
gEfiCpuIo2ProtocolGuid

View File

@ -0,0 +1,738 @@
/*++
Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
PcatPciRootBridgeIo.c
Abstract:
EFI PC AT PCI Root Bridge Io Protocol
Revision History
--*/
#include "PcatPciRootBridge.h"
BOOLEAN mPciOptionRomTableInstalled = FALSE;
EFI_PCI_OPTION_ROM_TABLE mPciOptionRomTable = {0, NULL};
EFI_STATUS
EFIAPI
PcatRootBridgeIoIoRead (
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
IN UINT64 UserAddress,
IN UINTN Count,
IN OUT VOID *UserBuffer
)
{
return gCpuIo->Io.Read (
gCpuIo,
(EFI_CPU_IO_PROTOCOL_WIDTH) Width,
UserAddress,
Count,
UserBuffer
);
}
EFI_STATUS
EFIAPI
PcatRootBridgeIoIoWrite (
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
IN UINT64 UserAddress,
IN UINTN Count,
IN OUT VOID *UserBuffer
)
{
return gCpuIo->Io.Write (
gCpuIo,
(EFI_CPU_IO_PROTOCOL_WIDTH) Width,
UserAddress,
Count,
UserBuffer
);
}
EFI_STATUS
PcatRootBridgeIoGetIoPortMapping (
OUT EFI_PHYSICAL_ADDRESS *IoPortMapping,
OUT EFI_PHYSICAL_ADDRESS *MemoryPortMapping
)
/*++
Get the IO Port Mapping. For IA-32 it is always 0.
--*/
{
*IoPortMapping = 0;
*MemoryPortMapping = 0;
return EFI_SUCCESS;
}
EFI_STATUS
PcatRootBridgeIoPciRW (
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
IN BOOLEAN Write,
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
IN UINT64 UserAddress,
IN UINTN Count,
IN OUT VOID *UserBuffer
)
{
PCI_CONFIG_ACCESS_CF8 Pci;
PCI_CONFIG_ACCESS_CF8 PciAligned;
UINT32 InStride;
UINT32 OutStride;
UINTN PciData;
UINTN PciDataStride;
PCAT_PCI_ROOT_BRIDGE_INSTANCE *PrivateData;
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS PciAddress;
UINT64 PciExpressRegAddr;
BOOLEAN UsePciExpressAccess;
if ((UINT32)Width >= EfiPciWidthMaximum) {
return EFI_INVALID_PARAMETER;
}
if ((Width & 0x03) >= EfiPciWidthUint64) {
return EFI_INVALID_PARAMETER;
}
PrivateData = DRIVER_INSTANCE_FROM_PCI_ROOT_BRIDGE_IO_THIS(This);
InStride = 1 << (Width & 0x03);
OutStride = InStride;
if (Width >= EfiPciWidthFifoUint8 && Width <= EfiPciWidthFifoUint64) {
InStride = 0;
}
if (Width >= EfiPciWidthFillUint8 && Width <= EfiPciWidthFillUint64) {
OutStride = 0;
}
UsePciExpressAccess = FALSE;
CopyMem (&PciAddress, &UserAddress, sizeof(UINT64));
if (PciAddress.ExtendedRegister > 0xFF) {
//
// Check PciExpressBaseAddress
//
if ((PrivateData->PciExpressBaseAddress == 0) ||
(PrivateData->PciExpressBaseAddress >= MAX_ADDRESS)) {
return EFI_UNSUPPORTED;
} else {
UsePciExpressAccess = TRUE;
}
} else {
if (PciAddress.ExtendedRegister != 0) {
Pci.Bits.Reg = PciAddress.ExtendedRegister & 0xFF;
} else {
Pci.Bits.Reg = PciAddress.Register;
}
//
// Note: We can also use PciExpress access here, if wanted.
//
}
if (!UsePciExpressAccess) {
Pci.Bits.Func = PciAddress.Function;
Pci.Bits.Dev = PciAddress.Device;
Pci.Bits.Bus = PciAddress.Bus;
Pci.Bits.Reserved = 0;
Pci.Bits.Enable = 1;
//
// PCI Config access are all 32-bit alligned, but by accessing the
// CONFIG_DATA_REGISTER (0xcfc) with different widths more cycle types
// are possible on PCI.
//
// To read a byte of PCI config space you load 0xcf8 and
// read 0xcfc, 0xcfd, 0xcfe, 0xcff
//
PciDataStride = Pci.Bits.Reg & 0x03;
while (Count) {
PciAligned = Pci;
PciAligned.Bits.Reg &= 0xfc;
PciData = (UINTN)PrivateData->PciData + PciDataStride;
EfiAcquireLock(&PrivateData->PciLock);
This->Io.Write (This, EfiPciWidthUint32, PrivateData->PciAddress, 1, &PciAligned);
if (Write) {
This->Io.Write (This, Width, PciData, 1, UserBuffer);
} else {
This->Io.Read (This, Width, PciData, 1, UserBuffer);
}
EfiReleaseLock(&PrivateData->PciLock);
UserBuffer = ((UINT8 *)UserBuffer) + OutStride;
PciDataStride = (PciDataStride + InStride) % 4;
Pci.Bits.Reg += InStride;
Count -= 1;
}
} else {
//
// Access PCI-Express space by using memory mapped method.
//
PciExpressRegAddr = (PrivateData->PciExpressBaseAddress) |
(PciAddress.Bus << 20) |
(PciAddress.Device << 15) |
(PciAddress.Function << 12);
if (PciAddress.ExtendedRegister != 0) {
PciExpressRegAddr += PciAddress.ExtendedRegister;
} else {
PciExpressRegAddr += PciAddress.Register;
}
while (Count) {
if (Write) {
This->Mem.Write (This, Width, (UINTN) PciExpressRegAddr, 1, UserBuffer);
} else {
This->Mem.Read (This, Width, (UINTN) PciExpressRegAddr, 1, UserBuffer);
}
UserBuffer = ((UINT8 *) UserBuffer) + OutStride;
PciExpressRegAddr += InStride;
Count -= 1;
}
}
return EFI_SUCCESS;
}
VOID
ScanPciBus(
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev,
UINT16 MinBus,
UINT16 MaxBus,
UINT16 MinDevice,
UINT16 MaxDevice,
UINT16 MinFunc,
UINT16 MaxFunc,
EFI_PCI_BUS_SCAN_CALLBACK Callback,
VOID *Context
)
{
UINT16 Bus;
UINT16 Device;
UINT16 Func;
UINT64 Address;
PCI_TYPE00 PciHeader;
//
// Loop through all busses
//
for (Bus = MinBus; Bus <= MaxBus; Bus++) {
//
// Loop 32 devices per bus
//
for (Device = MinDevice; Device <= MaxDevice; Device++) {
//
// Loop through 8 functions per device
//
for (Func = MinFunc; Func <= MaxFunc; Func++) {
//
// Compute the EFI Address required to access the PCI Configuration Header of this PCI Device
//
Address = EFI_PCI_ADDRESS (Bus, Device, Func, 0);
//
// Read the VendorID from this PCI Device's Confioguration Header
//
IoDev->Pci.Read (IoDev, EfiPciWidthUint16, Address, 1, &PciHeader.Hdr.VendorId);
//
// If VendorId = 0xffff, there does not exist a device at this
// location. For each device, if there is any function on it,
// there must be 1 function at Function 0. So if Func = 0, there
// will be no more functions in the same device, so we can break
// loop to deal with the next device.
//
if (PciHeader.Hdr.VendorId == 0xffff && Func == 0) {
break;
}
if (PciHeader.Hdr.VendorId != 0xffff) {
//
// Read the HeaderType to determine if this is a multi-function device
//
IoDev->Pci.Read (IoDev, EfiPciWidthUint8, Address + 0x0e, 1, &PciHeader.Hdr.HeaderType);
//
// Call the callback function for the device that was found
//
Callback(
IoDev,
MinBus, MaxBus,
MinDevice, MaxDevice,
MinFunc, MaxFunc,
Bus,
Device,
Func,
Context
);
//
// If this is not a multi-function device, we can leave the loop
// to deal with the next device.
//
if ((PciHeader.Hdr.HeaderType & HEADER_TYPE_MULTI_FUNCTION) == 0x00 && Func == 0) {
break;
}
}
}
}
}
}
VOID
CheckForRom (
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev,
UINT16 MinBus,
UINT16 MaxBus,
UINT16 MinDevice,
UINT16 MaxDevice,
UINT16 MinFunc,
UINT16 MaxFunc,
UINT16 Bus,
UINT16 Device,
UINT16 Func,
IN VOID *VoidContext
)
{
EFI_STATUS Status;
PCAT_PCI_ROOT_BRIDGE_SCAN_FOR_ROM_CONTEXT *Context;
UINT64 Address;
PCI_TYPE00 PciHeader;
PCI_TYPE01 *PciBridgeHeader;
UINT32 Register;
UINT32 RomBar;
UINT32 RomBarSize;
EFI_PHYSICAL_ADDRESS RomBuffer;
UINT32 MaxRomSize;
EFI_PCI_EXPANSION_ROM_HEADER EfiRomHeader;
PCI_DATA_STRUCTURE Pcir;
EFI_PCI_OPTION_ROM_DESCRIPTOR *TempPciOptionRomDescriptors;
BOOLEAN LastImage;
Context = (PCAT_PCI_ROOT_BRIDGE_SCAN_FOR_ROM_CONTEXT *)VoidContext;
Address = EFI_PCI_ADDRESS (Bus, Device, Func, 0);
//
// Save the contents of the PCI Configuration Header
//
IoDev->Pci.Read (IoDev, EfiPciWidthUint32, Address, sizeof(PciHeader)/sizeof(UINT32), &PciHeader);
if (IS_PCI_BRIDGE(&PciHeader)) {
PciBridgeHeader = (PCI_TYPE01 *)(&PciHeader);
//
// See if the PCI-PCI Bridge has its secondary interface enabled.
//
if (PciBridgeHeader->Bridge.SubordinateBus >= PciBridgeHeader->Bridge.SecondaryBus) {
//
// Disable the Prefetchable Memory Window
//
Register = 0x00000000;
IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address + 0x26, 1, &Register);
IoDev->Pci.Write (IoDev, EfiPciWidthUint32, Address + 0x2c, 1, &Register);
Register = 0xffffffff;
IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address + 0x24, 1, &Register);
IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address + 0x28, 1, &Register);
//
// Program Memory Window to the PCI Root Bridge Memory Window
//
IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address + 0x20, 4, &Context->PpbMemoryWindow);
//
// Enable the Memory decode for the PCI-PCI Bridge
//
IoDev->Pci.Read (IoDev, EfiPciWidthUint16, Address + 4, 1, &Register);
Register |= 0x02;
IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address + 4, 1, &Register);
//
// Recurse on the Secondary Bus Number
//
ScanPciBus(
IoDev,
PciBridgeHeader->Bridge.SecondaryBus, PciBridgeHeader->Bridge.SecondaryBus,
0, PCI_MAX_DEVICE,
0, PCI_MAX_FUNC,
CheckForRom, Context
);
}
} else {
//
// Check if an Option ROM Register is present and save the Option ROM Window Register
//
RomBar = 0xffffffff;
IoDev->Pci.Write (IoDev, EfiPciWidthUint32, Address + 0x30, 1, &RomBar);
IoDev->Pci.Read (IoDev, EfiPciWidthUint32, Address + 0x30, 1, &RomBar);
RomBarSize = (~(RomBar & 0xfffff800)) + 1;
//
// Make sure the size of the ROM is between 0 and 16 MB
//
if (RomBarSize > 0 && RomBarSize <= 0x01000000) {
//
// Program Option ROM Window Register to the PCI Root Bridge Window and Enable the Option ROM Window
//
RomBar = (Context->PpbMemoryWindow & 0xffff) << 16;
RomBar = ((RomBar - 1) & (~(RomBarSize - 1))) + RomBarSize;
if (RomBar < (Context->PpbMemoryWindow & 0xffff0000)) {
MaxRomSize = (Context->PpbMemoryWindow & 0xffff0000) - RomBar;
RomBar = RomBar + 1;
IoDev->Pci.Write (IoDev, EfiPciWidthUint32, Address + 0x30, 1, &RomBar);
IoDev->Pci.Read (IoDev, EfiPciWidthUint32, Address + 0x30, 1, &RomBar);
RomBar = RomBar - 1;
//
// Enable the Memory decode for the PCI Device
//
IoDev->Pci.Read (IoDev, EfiPciWidthUint16, Address + 4, 1, &Register);
Register |= 0x02;
IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address + 4, 1, &Register);
//
// Follow the chain of images to determine the size of the Option ROM present
// Keep going until the last image is found by looking at the Indicator field
// or the size of an image is 0, or the size of all the images is bigger than the
// size of the window programmed into the PPB.
//
RomBarSize = 0;
do {
LastImage = TRUE;
ZeroMem (&EfiRomHeader, sizeof(EfiRomHeader));
IoDev->Mem.Read (
IoDev,
EfiPciWidthUint8,
RomBar + RomBarSize,
sizeof(EfiRomHeader),
&EfiRomHeader
);
Pcir.ImageLength = 0;
if (EfiRomHeader.Signature == PCI_EXPANSION_ROM_HEADER_SIGNATURE &&
EfiRomHeader.PcirOffset != 0 &&
(EfiRomHeader.PcirOffset & 3) == 0 &&
RomBarSize + EfiRomHeader.PcirOffset + sizeof (PCI_DATA_STRUCTURE) <= MaxRomSize) {
ZeroMem (&Pcir, sizeof(Pcir));
IoDev->Mem.Read (
IoDev,
EfiPciWidthUint8,
RomBar + RomBarSize + EfiRomHeader.PcirOffset,
sizeof(Pcir),
&Pcir
);
if (Pcir.Signature != PCI_DATA_STRUCTURE_SIGNATURE) {
break;
}
if (RomBarSize + Pcir.ImageLength * 512 > MaxRomSize) {
break;
}
if ((Pcir.Indicator & 0x80) == 0x00) {
LastImage = FALSE;
}
RomBarSize += Pcir.ImageLength * 512;
}
} while (!LastImage && RomBarSize < MaxRomSize && Pcir.ImageLength !=0);
if (RomBarSize > 0) {
//
// Allocate a memory buffer for the Option ROM contents.
//
Status = gBS->AllocatePages(
AllocateAnyPages,
EfiBootServicesData,
EFI_SIZE_TO_PAGES(RomBarSize),
&RomBuffer
);
if (!EFI_ERROR (Status)) {
//
// Copy the contents of the Option ROM to the memory buffer
//
IoDev->Mem.Read (IoDev, EfiPciWidthUint32, RomBar, RomBarSize / sizeof(UINT32), (VOID *)(UINTN)RomBuffer);
Status = gBS->AllocatePool(
EfiBootServicesData,
((UINT32)mPciOptionRomTable.PciOptionRomCount + 1) * sizeof(EFI_PCI_OPTION_ROM_DESCRIPTOR),
(VOID **) &TempPciOptionRomDescriptors
);
if (mPciOptionRomTable.PciOptionRomCount > 0) {
CopyMem(
TempPciOptionRomDescriptors,
mPciOptionRomTable.PciOptionRomDescriptors,
(UINT32)mPciOptionRomTable.PciOptionRomCount * sizeof(EFI_PCI_OPTION_ROM_DESCRIPTOR)
);
gBS->FreePool(mPciOptionRomTable.PciOptionRomDescriptors);
}
mPciOptionRomTable.PciOptionRomDescriptors = TempPciOptionRomDescriptors;
TempPciOptionRomDescriptors = &(mPciOptionRomTable.PciOptionRomDescriptors[(UINT32)mPciOptionRomTable.PciOptionRomCount]);
TempPciOptionRomDescriptors->RomAddress = RomBuffer;
TempPciOptionRomDescriptors->MemoryType = EfiBootServicesData;
TempPciOptionRomDescriptors->RomLength = RomBarSize;
TempPciOptionRomDescriptors->Seg = (UINT32)IoDev->SegmentNumber;
TempPciOptionRomDescriptors->Bus = (UINT8)Bus;
TempPciOptionRomDescriptors->Dev = (UINT8)Device;
TempPciOptionRomDescriptors->Func = (UINT8)Func;
TempPciOptionRomDescriptors->ExecutedLegacyBiosImage = TRUE;
TempPciOptionRomDescriptors->DontLoadEfiRom = FALSE;
mPciOptionRomTable.PciOptionRomCount++;
}
}
//
// Disable the Memory decode for the PCI-PCI Bridge
//
IoDev->Pci.Read (IoDev, EfiPciWidthUint16, Address + 4, 1, &Register);
Register &= (~0x02);
IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address + 4, 1, &Register);
}
}
}
//
// Restore the PCI Configuration Header
//
IoDev->Pci.Write (IoDev, EfiPciWidthUint32, Address, sizeof(PciHeader)/sizeof(UINT32), &PciHeader);
}
VOID
SaveCommandRegister (
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev,
UINT16 MinBus,
UINT16 MaxBus,
UINT16 MinDevice,
UINT16 MaxDevice,
UINT16 MinFunc,
UINT16 MaxFunc,
UINT16 Bus,
UINT16 Device,
UINT16 Func,
IN VOID *VoidContext
)
{
PCAT_PCI_ROOT_BRIDGE_SCAN_FOR_ROM_CONTEXT *Context;
UINT64 Address;
UINTN Index;
UINT16 Command;
Context = (PCAT_PCI_ROOT_BRIDGE_SCAN_FOR_ROM_CONTEXT *)VoidContext;
Address = EFI_PCI_ADDRESS (Bus, Device, Func, 4);
Index = (Bus - MinBus) * (PCI_MAX_DEVICE+1) * (PCI_MAX_FUNC+1) + Device * (PCI_MAX_FUNC+1) + Func;
IoDev->Pci.Read (IoDev, EfiPciWidthUint16, Address, 1, &Context->CommandRegisterBuffer[Index]);
//
// Clear the memory enable bit
//
Command = (UINT16) (Context->CommandRegisterBuffer[Index] & (~0x02));
IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address, 1, &Command);
}
VOID
RestoreCommandRegister (
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev,
UINT16 MinBus,
UINT16 MaxBus,
UINT16 MinDevice,
UINT16 MaxDevice,
UINT16 MinFunc,
UINT16 MaxFunc,
UINT16 Bus,
UINT16 Device,
UINT16 Func,
IN VOID *VoidContext
)
{
PCAT_PCI_ROOT_BRIDGE_SCAN_FOR_ROM_CONTEXT *Context;
UINT64 Address;
UINTN Index;
Context = (PCAT_PCI_ROOT_BRIDGE_SCAN_FOR_ROM_CONTEXT *)VoidContext;
Address = EFI_PCI_ADDRESS (Bus, Device, Func, 4);
Index = (Bus - MinBus) * (PCI_MAX_DEVICE+1) * (PCI_MAX_FUNC+1) + Device * (PCI_MAX_FUNC+1) + Func;
IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address, 1, &Context->CommandRegisterBuffer[Index]);
}
EFI_STATUS
ScanPciRootBridgeForRoms(
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev
)
{
EFI_STATUS Status;
EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptors;
UINT16 MinBus;
UINT16 MaxBus;
UINT64 RootWindowBase;
UINT64 RootWindowLimit;
PCAT_PCI_ROOT_BRIDGE_SCAN_FOR_ROM_CONTEXT Context;
if (mPciOptionRomTableInstalled == FALSE) {
gBS->InstallConfigurationTable(&gEfiPciOptionRomTableGuid, &mPciOptionRomTable);
mPciOptionRomTableInstalled = TRUE;
}
Status = IoDev->Configuration(IoDev, (VOID **) &Descriptors);
if (EFI_ERROR (Status) || Descriptors == NULL) {
return EFI_NOT_FOUND;
}
MinBus = 0xffff;
MaxBus = 0xffff;
RootWindowBase = 0;
RootWindowLimit = 0;
while (Descriptors->Desc != ACPI_END_TAG_DESCRIPTOR) {
//
// Find bus range
//
if (Descriptors->ResType == ACPI_ADDRESS_SPACE_TYPE_BUS) {
MinBus = (UINT16)Descriptors->AddrRangeMin;
MaxBus = (UINT16)Descriptors->AddrRangeMax;
}
//
// Find memory descriptors that are not prefetchable
//
if (Descriptors->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM && Descriptors->SpecificFlag == 0) {
//
// Find Memory Descriptors that are less than 4GB, so the PPB Memory Window can be used for downstream devices
//
if (Descriptors->AddrRangeMax < 0x100000000ULL) {
//
// Find the largest Non-Prefetchable Memory Descriptor that is less than 4GB
//
if ((Descriptors->AddrRangeMax - Descriptors->AddrRangeMin) > (RootWindowLimit - RootWindowBase)) {
RootWindowBase = Descriptors->AddrRangeMin;
RootWindowLimit = Descriptors->AddrRangeMax;
}
}
}
Descriptors ++;
}
//
// Make sure a bus range was found
//
if (MinBus == 0xffff || MaxBus == 0xffff) {
return EFI_NOT_FOUND;
}
//
// Make sure a non-prefetchable memory region was found
//
if (RootWindowBase == 0 && RootWindowLimit == 0) {
return EFI_NOT_FOUND;
}
//
// Round the Base and Limit values to 1 MB boudaries
//
RootWindowBase = ((RootWindowBase - 1) & 0xfff00000) + 0x00100000;
RootWindowLimit = ((RootWindowLimit + 1) & 0xfff00000) - 1;
//
// Make sure that the size of the rounded window is greater than zero
//
if (RootWindowLimit <= RootWindowBase) {
return EFI_NOT_FOUND;
}
//
// Allocate buffer to save the Command register from all the PCI devices
//
Context.CommandRegisterBuffer = NULL;
Status = gBS->AllocatePool(
EfiBootServicesData,
sizeof(UINT16) * (MaxBus - MinBus + 1) * (PCI_MAX_DEVICE+1) * (PCI_MAX_FUNC+1),
(VOID **) &Context.CommandRegisterBuffer
);
if (EFI_ERROR (Status)) {
return Status;
}
Context.PpbMemoryWindow = (((UINT32)RootWindowBase) >> 16) | ((UINT32)RootWindowLimit & 0xffff0000);
//
// Save the Command register from all the PCI devices, and disable the I/O, Mem, and BusMaster bits
//
ScanPciBus(
IoDev,
MinBus, MaxBus,
0, PCI_MAX_DEVICE,
0, PCI_MAX_FUNC,
SaveCommandRegister, &Context
);
//
// Recursively scan all the busses for PCI Option ROMs
//
ScanPciBus(
IoDev,
MinBus, MinBus,
0, PCI_MAX_DEVICE,
0, PCI_MAX_FUNC,
CheckForRom, &Context
);
//
// Restore the Command register in all the PCI devices
//
ScanPciBus(
IoDev,
MinBus, MaxBus,
0, PCI_MAX_DEVICE,
0, PCI_MAX_FUNC,
RestoreCommandRegister, &Context
);
//
// Free the buffer used to save all the Command register values
//
gBS->FreePool(Context.CommandRegisterBuffer);
return EFI_SUCCESS;
}

View File

@ -1,176 +0,0 @@
/** @file
UEFI Component Name(2) protocol implementation for Sata Controller driver.
Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "SataController.h"
//
/// EFI Component Name Protocol
///
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gSataControllerComponentName = {
SataControllerComponentNameGetDriverName,
SataControllerComponentNameGetControllerName,
"eng"
};
//
/// EFI Component Name 2 Protocol
///
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gSataControllerComponentName2 = {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) SataControllerComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) SataControllerComponentNameGetControllerName,
"en"
};
//
/// Driver Name Strings
///
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mSataControllerDriverNameTable[] = {
{
"eng;en",
(CHAR16 *)L"Sata Controller Init Driver"
},
{
NULL,
NULL
}
};
///
/// Controller Name Strings
///
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mSataControllerControllerNameTable[] = {
{
"eng;en",
(CHAR16 *)L"Sata Controller"
},
{
NULL,
NULL
}
};
/**
Retrieves a Unicode string that is the user readable name of the UEFI Driver.
@param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
@param Language A pointer to a three character ISO 639-2 language identifier.
This is the language of the driver name that that the caller
is requesting, and it must match one of the languages specified
in SupportedLanguages. The number of languages supported by a
driver is up to the driver writer.
@param DriverName A pointer to the Unicode string to return. This Unicode string
is the name of the driver specified by This in the language
specified by Language.
@retval EFI_SUCCESS The Unicode string for the Driver specified by This
and the language specified by Language was returned
in DriverName.
@retval EFI_INVALID_PARAMETER Language is NULL.
@retval EFI_INVALID_PARAMETER DriverName is NULL.
@retval EFI_UNSUPPORTED The driver specified by This does not support the
language specified by Language.
**/
EFI_STATUS
EFIAPI
SataControllerComponentNameGetDriverName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
OUT CHAR16 **DriverName
)
{
return LookupUnicodeString2 (
Language,
This->SupportedLanguages,
mSataControllerDriverNameTable,
DriverName,
(BOOLEAN)(This == &gSataControllerComponentName)
);
}
/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by an UEFI Driver.
@param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
@param ControllerHandle The handle of a controller that the driver specified by
This is managing. This handle specifies the controller
whose name is to be returned.
@param ChildHandle OPTIONAL The handle of the child controller to retrieve the name
of. This is an optional parameter that may be NULL. It
will be NULL for device drivers. It will also be NULL
for a bus drivers that wish to retrieve the name of the
bus controller. It will not be NULL for a bus driver
that wishes to retrieve the name of a child controller.
@param Language A pointer to a three character ISO 639-2 language
identifier. This is the language of the controller name
that that the caller is requesting, and it must match one
of the languages specified in SupportedLanguages. The
number of languages supported by a driver is up to the
driver writer.
@param ControllerName A pointer to the Unicode string to return. This Unicode
string is the name of the controller specified by
ControllerHandle and ChildHandle in the language
specified by Language from the point of view of the
driver specified by This.
@retval EFI_SUCCESS The Unicode string for the user readable name in the
language specified by Language for the driver
specified by This was returned in DriverName.
@retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
EFI_HANDLE.
@retval EFI_INVALID_PARAMETER Language is NULL.
@retval EFI_INVALID_PARAMETER ControllerName is NULL.
@retval EFI_UNSUPPORTED The driver specified by This is not currently
managing the controller specified by
ControllerHandle and ChildHandle.
@retval EFI_UNSUPPORTED The driver specified by This does not support the
language specified by Language.
**/
EFI_STATUS
EFIAPI
SataControllerComponentNameGetControllerName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
)
{
EFI_STATUS Status;
//
// Make sure this driver is currently managing ControllHandle
//
Status = EfiTestManagedDevice (
ControllerHandle,
gSataControllerDriverBinding.DriverBindingHandle,
&gEfiPciIoProtocolGuid
);
if (EFI_ERROR (Status)) {
return Status;
}
if (ChildHandle != NULL) {
return EFI_UNSUPPORTED;
}
return LookupUnicodeString2 (
Language,
This->SupportedLanguages,
mSataControllerControllerNameTable,
ControllerName,
(BOOLEAN)(This == &gSataControllerComponentName)
);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,542 +0,0 @@
/** @file
Header file for Sata Controller driver.
Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef _SATA_CONTROLLER_H_
#define _SATA_CONTROLLER_H_
#include <Uefi.h>
#include <Protocol/ComponentName.h>
#include <Protocol/DriverBinding.h>
#include <Protocol/PciIo.h>
#include <Protocol/IdeControllerInit.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/DebugLib.h>
#include <Library/UefiLib.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <IndustryStandard/Pci.h>
//
// Global Variables definitions
//
extern EFI_DRIVER_BINDING_PROTOCOL gSataControllerDriverBinding;
extern EFI_COMPONENT_NAME_PROTOCOL gSataControllerComponentName;
extern EFI_COMPONENT_NAME2_PROTOCOL gSataControllerComponentName2;
#define AHCI_BAR_INDEX 0x05
#define R_AHCI_CAP 0x0
#define B_AHCI_CAP_NPS (BIT4 | BIT3 | BIT2 | BIT1 | BIT0) // Number of Ports
#define B_AHCI_CAP_SPM BIT17 // Supports Port Multiplier
///
/// AHCI each channel can have up to 1 device
///
#define AHCI_MAX_DEVICES 0x01
///
/// AHCI each channel can have 15 devices in the presence of a multiplier
///
#define AHCI_MULTI_MAX_DEVICES 0x0F
///
/// IDE supports 2 channel max
///
#define IDE_MAX_CHANNEL 0x02
///
/// IDE supports 2 devices max
///
#define IDE_MAX_DEVICES 0x02
#define SATA_ENUMER_ALL FALSE
//
// Sata Controller driver private data structure
//
#define SATA_CONTROLLER_SIGNATURE SIGNATURE_32('S','A','T','A')
typedef struct _EFI_SATA_CONTROLLER_PRIVATE_DATA {
//
// Standard signature used to identify Sata Controller private data
//
UINT32 Signature;
//
// Protocol instance of IDE_CONTROLLER_INIT produced by this driver
//
EFI_IDE_CONTROLLER_INIT_PROTOCOL IdeInit;
//
// Copy of protocol pointers used by this driver
//
EFI_PCI_IO_PROTOCOL *PciIo;
//
// The number of devices that are supported by this channel
//
UINT8 DeviceCount;
//
// The highest disqulified mode for each attached device,
// From ATA/ATAPI spec, if a mode is not supported,
// the modes higher than it is also not supported
//
EFI_ATA_COLLECTIVE_MODE *DisqualifiedModes;
//
// A copy of EFI_IDENTIFY_DATA data for each attached SATA device and its flag
//
EFI_IDENTIFY_DATA *IdentifyData;
BOOLEAN *IdentifyValid;
} EFI_SATA_CONTROLLER_PRIVATE_DATA;
#define SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS(a) CR(a, EFI_SATA_CONTROLLER_PRIVATE_DATA, IdeInit, SATA_CONTROLLER_SIGNATURE)
//
// Driver binding functions declaration
//
/**
Supported function of Driver Binding protocol for this driver.
Test to see if this driver supports ControllerHandle.
@param This Protocol instance pointer.
@param Controller Handle of device to test.
@param RemainingDevicePath A pointer to the device path. Should be ignored by
device driver.
@retval EFI_SUCCESS This driver supports this device.
@retval EFI_ALREADY_STARTED This driver is already running on this device.
@retval other This driver does not support this device.
**/
EFI_STATUS
EFIAPI
SataControllerSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
;
/**
This routine is called right after the .Supported() called and
Start this driver on ControllerHandle.
@param This Protocol instance pointer.
@param Controller Handle of device to bind driver to.
@param RemainingDevicePath A pointer to the device path. Should be ignored by
device driver.
@retval EFI_SUCCESS This driver is added to this device.
@retval EFI_ALREADY_STARTED This driver is already running on this device.
@retval other Some error occurs when binding this driver to this device.
**/
EFI_STATUS
EFIAPI
SataControllerStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
;
/**
Stop this driver on ControllerHandle.
@param This Protocol instance pointer.
@param Controller Handle of device to stop driver on.
@param NumberOfChildren Not used.
@param ChildHandleBuffer Not used.
@retval EFI_SUCCESS This driver is removed from this device.
@retval other Some error occurs when removing this driver from this device.
**/
EFI_STATUS
EFIAPI
SataControllerStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer
)
;
//
// IDE controller init functions declaration
//
/**
Returns the information about the specified IDE channel.
This function can be used to obtain information about a particular IDE channel.
The driver entity uses this information during the enumeration process.
If Enabled is set to FALSE, the driver entity will not scan the channel. Note
that it will not prevent an operating system driver from scanning the channel.
For most of today's controllers, MaxDevices will either be 1 or 2. For SATA
controllers, this value will always be 1. SATA configurations can contain SATA
port multipliers. SATA port multipliers behave like SATA bridges and can support
up to 16 devices on the other side. If a SATA port out of the IDE controller
is connected to a port multiplier, MaxDevices will be set to the number of SATA
devices that the port multiplier supports. Because today's port multipliers
support up to fifteen SATA devices, this number can be as large as fifteen. The IDE
bus driver is required to scan for the presence of port multipliers behind an SATA
controller and enumerate up to MaxDevices number of devices behind the port
multiplier.
In this context, the devices behind a port multiplier constitute a channel.
@param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
@param[in] Channel Zero-based channel number.
@param[out] Enabled TRUE if this channel is enabled. Disabled channels
are not scanned to see if any devices are present.
@param[out] MaxDevices The maximum number of IDE devices that the bus driver
can expect on this channel. For the ATA/ATAPI
specification, version 6, this number will either be
one or two. For Serial ATA (SATA) configurations with a
port multiplier, this number can be as large as fifteen.
@retval EFI_SUCCESS Information was returned without any errors.
@retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).
**/
EFI_STATUS
EFIAPI
IdeInitGetChannelInfo (
IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
IN UINT8 Channel,
OUT BOOLEAN *Enabled,
OUT UINT8 *MaxDevices
)
;
/**
The notifications from the driver entity that it is about to enter a certain
phase of the IDE channel enumeration process.
This function can be used to notify the IDE controller driver to perform
specific actions, including any chipset-specific initialization, so that the
chipset is ready to enter the next phase. Seven notification points are defined
at this time.
More synchronization points may be added as required in the future.
@param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
@param[in] Phase The phase during enumeration.
@param[in] Channel Zero-based channel number.
@retval EFI_SUCCESS The notification was accepted without any errors.
@retval EFI_UNSUPPORTED Phase is not supported.
@retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).
@retval EFI_NOT_READY This phase cannot be entered at this time; for
example, an attempt was made to enter a Phase
without having entered one or more previous
Phase.
**/
EFI_STATUS
EFIAPI
IdeInitNotifyPhase (
IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
IN EFI_IDE_CONTROLLER_ENUM_PHASE Phase,
IN UINT8 Channel
)
;
/**
Submits the device information to the IDE controller driver.
This function is used by the driver entity to pass detailed information about
a particular device to the IDE controller driver. The driver entity obtains
this information by issuing an ATA or ATAPI IDENTIFY_DEVICE command. IdentifyData
is the pointer to the response data buffer. The IdentifyData buffer is owned
by the driver entity, and the IDE controller driver must make a local copy
of the entire buffer or parts of the buffer as needed. The original IdentifyData
buffer pointer may not be valid when
- EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() or
- EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode() is called at a later point.
The IDE controller driver may consult various fields of EFI_IDENTIFY_DATA to
compute the optimum mode for the device. These fields are not limited to the
timing information. For example, an implementation of the IDE controller driver
may examine the vendor and type/mode field to match known bad drives.
The driver entity may submit drive information in any order, as long as it
submits information for all the devices belonging to the enumeration group
before EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() is called for any device
in that enumeration group. If a device is absent, EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData()
should be called with IdentifyData set to NULL. The IDE controller driver may
not have any other mechanism to know whether a device is present or not. Therefore,
setting IdentifyData to NULL does not constitute an error condition.
EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData() can be called only once for a
given (Channel, Device) pair.
@param[in] This A pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
@param[in] Channel Zero-based channel number.
@param[in] Device Zero-based device number on the Channel.
@param[in] IdentifyData The device's response to the ATA IDENTIFY_DEVICE command.
@retval EFI_SUCCESS The information was accepted without any errors.
@retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).
@retval EFI_INVALID_PARAMETER Device is invalid.
**/
EFI_STATUS
EFIAPI
IdeInitSubmitData (
IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
IN UINT8 Channel,
IN UINT8 Device,
IN EFI_IDENTIFY_DATA *IdentifyData
)
;
/**
Disqualifies specific modes for an IDE device.
This function allows the driver entity or other drivers (such as platform
drivers) to reject certain timing modes and request the IDE controller driver
to recalculate modes. This function allows the driver entity and the IDE
controller driver to negotiate the timings on a per-device basis. This function
is useful in the case of drives that lie about their capabilities. An example
is when the IDE device fails to accept the timing modes that are calculated
by the IDE controller driver based on the response to the Identify Drive command.
If the driver entity does not want to limit the ATA timing modes and leave that
decision to the IDE controller driver, it can either not call this function for
the given device or call this function and set the Valid flag to FALSE for all
modes that are listed in EFI_ATA_COLLECTIVE_MODE.
The driver entity may disqualify modes for a device in any order and any number
of times.
This function can be called multiple times to invalidate multiple modes of the
same type (e.g., Programmed Input/Output [PIO] modes 3 and 4). See the ATA/ATAPI
specification for more information on PIO modes.
For Serial ATA (SATA) controllers, this member function can be used to disqualify
a higher transfer rate mode on a given channel. For example, a platform driver
may inform the IDE controller driver to not use second-generation (Gen2) speeds
for a certain SATA drive.
@param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
@param[in] Channel The zero-based channel number.
@param[in] Device The zero-based device number on the Channel.
@param[in] BadModes The modes that the device does not support and that
should be disqualified.
@retval EFI_SUCCESS The modes were accepted without any errors.
@retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).
@retval EFI_INVALID_PARAMETER Device is invalid.
@retval EFI_INVALID_PARAMETER IdentifyData is NULL.
**/
EFI_STATUS
EFIAPI
IdeInitDisqualifyMode (
IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
IN UINT8 Channel,
IN UINT8 Device,
IN EFI_ATA_COLLECTIVE_MODE *BadModes
)
;
/**
Returns the information about the optimum modes for the specified IDE device.
This function is used by the driver entity to obtain the optimum ATA modes for
a specific device. The IDE controller driver takes into account the following
while calculating the mode:
- The IdentifyData inputs to EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData()
- The BadModes inputs to EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode()
The driver entity is required to call EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData()
for all the devices that belong to an enumeration group before calling
EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() for any device in the same group.
The IDE controller driver will use controller- and possibly platform-specific
algorithms to arrive at SupportedModes. The IDE controller may base its
decision on user preferences and other considerations as well. This function
may be called multiple times because the driver entity may renegotiate the mode
with the IDE controller driver using EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode().
The driver entity may collect timing information for various devices in any
order. The driver entity is responsible for making sure that all the dependencies
are satisfied. For example, the SupportedModes information for device A that
was previously returned may become stale after a call to
EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode() for device B.
The buffer SupportedModes is allocated by the callee because the caller does
not necessarily know the size of the buffer. The type EFI_ATA_COLLECTIVE_MODE
is defined in a way that allows for future extensibility and can be of variable
length. This memory pool should be deallocated by the caller when it is no
longer necessary.
The IDE controller driver for a Serial ATA (SATA) controller can use this
member function to force a lower speed (first-generation [Gen1] speeds on a
second-generation [Gen2]-capable hardware). The IDE controller driver can
also allow the driver entity to stay with the speed that has been negotiated
by the physical layer.
@param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
@param[in] Channel A zero-based channel number.
@param[in] Device A zero-based device number on the Channel.
@param[out] SupportedModes The optimum modes for the device.
@retval EFI_SUCCESS SupportedModes was returned.
@retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).
@retval EFI_INVALID_PARAMETER Device is invalid.
@retval EFI_INVALID_PARAMETER SupportedModes is NULL.
@retval EFI_NOT_READY Modes cannot be calculated due to a lack of
data. This error may happen if
EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData()
and EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyData()
were not called for at least one drive in the
same enumeration group.
**/
EFI_STATUS
EFIAPI
IdeInitCalculateMode (
IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
IN UINT8 Channel,
IN UINT8 Device,
OUT EFI_ATA_COLLECTIVE_MODE **SupportedModes
)
;
/**
Commands the IDE controller driver to program the IDE controller hardware
so that the specified device can operate at the specified mode.
This function is used by the driver entity to instruct the IDE controller
driver to program the IDE controller hardware to the specified modes. This
function can be called only once for a particular device. For a Serial ATA
(SATA) Advanced Host Controller Interface (AHCI) controller, no controller-
specific programming may be required.
@param[in] This Pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
@param[in] Channel Zero-based channel number.
@param[in] Device Zero-based device number on the Channel.
@param[in] Modes The modes to set.
@retval EFI_SUCCESS The command was accepted without any errors.
@retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).
@retval EFI_INVALID_PARAMETER Device is invalid.
@retval EFI_NOT_READY Modes cannot be set at this time due to lack of data.
@retval EFI_DEVICE_ERROR Modes cannot be set due to hardware failure.
The driver entity should not use this device.
**/
EFI_STATUS
EFIAPI
IdeInitSetTiming (
IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
IN UINT8 Channel,
IN UINT8 Device,
IN EFI_ATA_COLLECTIVE_MODE *Modes
)
;
//
// Forward reference declaration
//
/**
Retrieves a Unicode string that is the user readable name of the UEFI Driver.
@param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
@param Language A pointer to a three character ISO 639-2 language identifier.
This is the language of the driver name that that the caller
is requesting, and it must match one of the languages specified
in SupportedLanguages. The number of languages supported by a
driver is up to the driver writer.
@param DriverName A pointer to the Unicode string to return. This Unicode string
is the name of the driver specified by This in the language
specified by Language.
@retval EFI_SUCCESS The Unicode string for the Driver specified by This
and the language specified by Language was returned
in DriverName.
@retval EFI_INVALID_PARAMETER Language is NULL.
@retval EFI_INVALID_PARAMETER DriverName is NULL.
@retval EFI_UNSUPPORTED The driver specified by This does not support the
language specified by Language.
**/
EFI_STATUS
EFIAPI
SataControllerComponentNameGetDriverName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
OUT CHAR16 **DriverName
)
;
/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by an UEFI Driver.
@param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
@param ControllerHandle The handle of a controller that the driver specified by
This is managing. This handle specifies the controller
whose name is to be returned.
@param OPTIONAL ChildHandle The handle of the child controller to retrieve the name
of. This is an optional parameter that may be NULL. It
will be NULL for device drivers. It will also be NULL
for a bus drivers that wish to retrieve the name of the
bus controller. It will not be NULL for a bus driver
that wishes to retrieve the name of a child controller.
@param Language A pointer to a three character ISO 639-2 language
identifier. This is the language of the controller name
that that the caller is requesting, and it must match one
of the languages specified in SupportedLanguages. The
number of languages supported by a driver is up to the
driver writer.
@param ControllerName A pointer to the Unicode string to return. This Unicode
string is the name of the controller specified by
ControllerHandle and ChildHandle in the language
specified by Language from the point of view of the
driver specified by This.
@retval EFI_SUCCESS The Unicode string for the user readable name in the
language specified by Language for the driver
specified by This was returned in DriverName.
@retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
EFI_HANDLE.
@retval EFI_INVALID_PARAMETER Language is NULL.
@retval EFI_INVALID_PARAMETER ControllerName is NULL.
@retval EFI_UNSUPPORTED The driver specified by This is not currently
managing the controller specified by
ControllerHandle and ChildHandle.
@retval EFI_UNSUPPORTED The driver specified by This does not support the
language specified by Language.
**/
EFI_STATUS
EFIAPI
SataControllerComponentNameGetControllerName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
)
;
#endif

View File

@ -1,49 +0,0 @@
## @file
#
# Component description file for the Sata Controller driver.
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = SataController
FILE_GUID = 8F4CD826-A5A0-4e93-9522-CFB0AB72926C
MODULE_TYPE = UEFI_DRIVER
VERSION_STRING = 1.0
ENTRY_POINT = InitializeSataControllerDriver
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 EBC
#
[Sources]
ComponentName.c
SataController.c
SataController.h
[Packages]
MdePkg/MdePkg.dec
[LibraryClasses]
UefiDriverEntryPoint
DebugLib
UefiLib
BaseLib
BaseMemoryLib
MemoryAllocationLib
UefiBootServicesTableLib
[Protocols]
gEfiPciIoProtocolGuid
gEfiIdeControllerInitProtocolGuid

View File

@ -95,8 +95,9 @@ INF MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntime
INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
INF UefiCpuPkg/CpuDxe/CpuDxe.inf INF UefiCpuPkg/CpuDxe/CpuDxe.inf
INF MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
INF MdeModulePkg/Application/UiApp/UiApp.inf INF IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf
!if $(USE_HPET_TIMER) == TRUE !if $(USE_HPET_TIMER) == TRUE
INF PcAtChipsetPkg/HpetTimerDxe/HpetTimerDxe.inf INF PcAtChipsetPkg/HpetTimerDxe/HpetTimerDxe.inf
!else !else
@ -109,6 +110,12 @@ INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
INF PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf INF PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
!ifdef $(FIRMWARE_OPEN_FIRMWARE_SMMSTORE)
!if $(ARCH) == IA32
!else
INF RuleOverride=BINARY USE = X64 $(FIRMWARE_OPEN_FIRMWARE_SMMSTORE)
!endif
!endif
INF MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf INF MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
INF UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf INF UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
@ -118,19 +125,28 @@ INF PcAtChipsetPkg/8259InterruptControllerDxe/8259.inf
INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
INF MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf INF MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
!ifdef $(FIRMWARE_OPEN_FIRMWARE_SETUP)
!if $(ARCH) == IA32
!else
INF RuleOverride=BINARY USE = X64 $(FIRMWARE_OPEN_FIRMWARE_SETUP)
!endif
!endif
INF CorebootModulePkg/CbSupportDxe/CbSupportDxe.inf INF CorebootModulePkg/CbSupportDxe/CbSupportDxe.inf
INF MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf INF MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
# #
# PCI Support # PCI Support
# #
INF MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf INF CorebootModulePkg/PciRootBridgeNoEnumerationDxe/PciRootBridgeNoEnumeration.inf
INF MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf INF CorebootModulePkg/PciBusNoEnumerationDxe/PciBusNoEnumeration.inf
# #
# ISA Support # ISA Support
# #
INF MdeModulePkg/Universal/SerialDxe/SerialDxe.inf INF MdeModulePkg/Universal/SerialDxe/SerialDxe.inf
INF PcAtChipsetPkg/IsaAcpiDxe/IsaAcpi.inf
INF IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxe.inf
INF IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf
# #
# Console Support # Console Support
@ -140,20 +156,30 @@ INF MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
INF MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf INF MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
INF MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf INF MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
# DataHubDxe
INF IntelFrameworkModulePkg/Universal/DataHubDxe/DataHubDxe.inf
# #
# SCSI/ATA/IDE/DISK Support # SCSI/ATA/IDE/DISK Support
# #
INF MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf INF MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
INF CorebootModulePkg/SataControllerDxe/SataControllerDxe.inf
INF MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf INF MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
INF MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf INF MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
INF MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
INF MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf INF MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
INF MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf INF MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
INF FatPkg/EnhancedFatDxe/Fat.inf INF FatPkg/EnhancedFatDxe/Fat.inf
!if $(ARCH) == IA32
!else
INF RuleOverride=BINARY USE = X64 FSDrivers/ntfs.inf
INF RuleOverride=BINARY USE = X64 FSDrivers/ext4.inf
!endif
# #
# SD/eMMC Support # SD/eMMC Support
# #
@ -164,18 +190,12 @@ INF MdeModulePkg/Bus/Sd/SdDxe/SdDxe.inf
# #
# Usb Support # Usb Support
# #
INF MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf
INF MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf INF MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf
INF MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf INF MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
INF MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf INF MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
INF MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf INF MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf
INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
#
# OHCI Support
#
INF QuarkSocPkg/QuarkSouthCluster/Usb/Ohci/Dxe/OhciDxe.inf
# #
# Shell # Shell
# #
@ -202,13 +222,29 @@ INF RuleOverride = BINARY USE = X64 ShellBinPkg/UefiShell/UefiShell.inf
!endif !endif
FILE FREEFORM = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile) { FILE FREEFORM = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile) {
SECTION RAW = MdeModulePkg/Logo/Logo.bmp SECTION RAW = CorebootPayloadPkg/Logo/Logo.bmp
} }
!ifdef $(FIRMWARE_OPEN_GOP_POLICY)
# Add PlatformGopPolicy implementation
!if $(ARCH) == IA32
!else
INF RuleOverride=BINARY USE = X64 $(FIRMWARE_OPEN_GOP_POLICY)
!endif
!endif
!ifdef $(FIRMWARE_OPEN_GOP)
# Use IntelGopDriver binary
!if $(ARCH) == IA32
!else
INF RuleOverride=BINARY USE = X64 $(FIRMWARE_OPEN_GOP)
!endif
!else
# #
# Framebuffer Gop # Framebuffer Gop
# #
INF CorebootPayloadPkg/FbGop/FbGop.inf INF CorebootPayloadPkg/FbGop/FbGop.inf
!endif
################################################################################ ################################################################################
# #

View File

@ -165,6 +165,9 @@
UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf
BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf
SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
@ -183,7 +186,7 @@
ResetSystemLib|CorebootPayloadPkg/Library/ResetSystemLib/ResetSystemLib.inf ResetSystemLib|CorebootPayloadPkg/Library/ResetSystemLib/ResetSystemLib.inf
SerialPortLib|CorebootModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf SerialPortLib|CorebootModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf
PlatformHookLib|CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib.inf PlatformHookLib|CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib.inf
PlatformBootManagerLib|CorebootPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf PlatformBdsLib|CorebootModulePkg/Library/CorebootBdsLib/PlatformBds.inf
IoApicLib|PcAtChipsetPkg/Library/BaseIoApicLib/BaseIoApicLib.inf IoApicLib|PcAtChipsetPkg/Library/BaseIoApicLib/BaseIoApicLib.inf
CbPlatformSupportLib|CorebootModulePkg/Library/CbPlatformSupportLibNull/CbPlatformSupportLibNull.inf CbPlatformSupportLib|CorebootModulePkg/Library/CbPlatformSupportLibNull/CbPlatformSupportLibNull.inf
@ -300,7 +303,7 @@
# The following parameters are set by Library/PlatformHookLib # The following parameters are set by Library/PlatformHookLib
# #
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio|FALSE gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x3f8 gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x3e8
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialBaudRate|$(BAUD_RATE) gEfiMdeModulePkgTokenSpaceGuid.PcdSerialBaudRate|$(BAUD_RATE)
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride|1 gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride|1
@ -398,13 +401,12 @@
# #
MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
UefiCpuPkg/CpuDxe/CpuDxe.inf UefiCpuPkg/CpuDxe/CpuDxe.inf
MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
MdeModulePkg/Application/UiApp/UiApp.inf { IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf {
<LibraryClasses> <LibraryClasses>
NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
NULL|MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf
NULL|MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf
} }
!if $(USE_HPET_TIMER) == TRUE !if $(USE_HPET_TIMER) == TRUE
PcAtChipsetPkg/HpetTimerDxe/HpetTimerDxe.inf PcAtChipsetPkg/HpetTimerDxe/HpetTimerDxe.inf
!else !else
@ -452,11 +454,8 @@
# #
# PCI Support # PCI Support
# #
MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf CorebootModulePkg/PciRootBridgeNoEnumerationDxe/PciRootBridgeNoEnumeration.inf
MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf { CorebootModulePkg/PciBusNoEnumerationDxe/PciBusNoEnumeration.inf
<LibraryClasses>
PciHostBridgeLib|CorebootPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
}
# #
# SCSI/ATA/IDE/DISK Support # SCSI/ATA/IDE/DISK Support
@ -465,9 +464,10 @@
MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
FatPkg/EnhancedFatDxe/Fat.inf FatPkg/EnhancedFatDxe/Fat.inf
CorebootModulePkg/SataControllerDxe/SataControllerDxe.inf
MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
@ -481,22 +481,24 @@
# #
# Usb Support # Usb Support
# #
MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf
MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf
MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf
MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
#
# OHCI support
#
QuarkSocPkg/QuarkSouthCluster/Usb/Ohci/Dxe/OhciDxe.inf
# #
# ISA Support # ISA Support
# #
MdeModulePkg/Universal/SerialDxe/SerialDxe.inf MdeModulePkg/Universal/SerialDxe/SerialDxe.inf
PcAtChipsetPkg/IsaAcpiDxe/IsaAcpi.inf
IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxe.inf
IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf
#
# DataHubDxe
#
IntelFrameworkModulePkg/Universal/DataHubDxe/DataHubDxe.inf
# #
# Console Support # Console Support

View File

@ -165,6 +165,9 @@
UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf
BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf
SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
@ -183,7 +186,7 @@
ResetSystemLib|CorebootPayloadPkg/Library/ResetSystemLib/ResetSystemLib.inf ResetSystemLib|CorebootPayloadPkg/Library/ResetSystemLib/ResetSystemLib.inf
SerialPortLib|CorebootModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf SerialPortLib|CorebootModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf
PlatformHookLib|CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib.inf PlatformHookLib|CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib.inf
PlatformBootManagerLib|CorebootPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf PlatformBdsLib|CorebootModulePkg/Library/CorebootBdsLib/PlatformBds.inf
IoApicLib|PcAtChipsetPkg/Library/BaseIoApicLib/BaseIoApicLib.inf IoApicLib|PcAtChipsetPkg/Library/BaseIoApicLib/BaseIoApicLib.inf
CbPlatformSupportLib|CorebootModulePkg/Library/CbPlatformSupportLibNull/CbPlatformSupportLibNull.inf CbPlatformSupportLib|CorebootModulePkg/Library/CbPlatformSupportLibNull/CbPlatformSupportLibNull.inf
@ -301,7 +304,7 @@
# The following parameters are set by Library/PlatformHookLib # The following parameters are set by Library/PlatformHookLib
# #
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio|FALSE gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x3f8 gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x3e8
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialBaudRate|$(BAUD_RATE) gEfiMdeModulePkgTokenSpaceGuid.PcdSerialBaudRate|$(BAUD_RATE)
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride|1 gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride|1
@ -399,13 +402,12 @@
# #
MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
UefiCpuPkg/CpuDxe/CpuDxe.inf UefiCpuPkg/CpuDxe/CpuDxe.inf
MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
MdeModulePkg/Application/UiApp/UiApp.inf { IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf {
<LibraryClasses> <LibraryClasses>
NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
NULL|MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf
NULL|MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf
} }
!if $(USE_HPET_TIMER) == TRUE !if $(USE_HPET_TIMER) == TRUE
PcAtChipsetPkg/HpetTimerDxe/HpetTimerDxe.inf PcAtChipsetPkg/HpetTimerDxe/HpetTimerDxe.inf
!else !else
@ -453,11 +455,8 @@
# #
# PCI Support # PCI Support
# #
MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf CorebootModulePkg/PciRootBridgeNoEnumerationDxe/PciRootBridgeNoEnumeration.inf
MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf { CorebootModulePkg/PciBusNoEnumerationDxe/PciBusNoEnumeration.inf
<LibraryClasses>
PciHostBridgeLib|CorebootPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
}
# #
# SCSI/ATA/IDE/DISK Support # SCSI/ATA/IDE/DISK Support
@ -466,9 +465,10 @@
MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
FatPkg/EnhancedFatDxe/Fat.inf FatPkg/EnhancedFatDxe/Fat.inf
CorebootModulePkg/SataControllerDxe/SataControllerDxe.inf
MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
@ -482,22 +482,24 @@
# #
# Usb Support # Usb Support
# #
MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf
MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf
MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf
MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
#
# OHCI support
#
QuarkSocPkg/QuarkSouthCluster/Usb/Ohci/Dxe/OhciDxe.inf
# #
# ISA Support # ISA Support
# #
MdeModulePkg/Universal/SerialDxe/SerialDxe.inf MdeModulePkg/Universal/SerialDxe/SerialDxe.inf
PcAtChipsetPkg/IsaAcpiDxe/IsaAcpi.inf
IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxe.inf
IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf
#
# DataHubDxe
#
IntelFrameworkModulePkg/Universal/DataHubDxe/DataHubDxe.inf
# #
# Console Support # Console Support

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 KiB

BIN
FSDrivers/X64/ext4.efi Normal file

Binary file not shown.

BIN
FSDrivers/X64/ntfs.efi Normal file

Binary file not shown.

22
FSDrivers/ext4.inf Normal file
View File

@ -0,0 +1,22 @@
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = ext4
FILE_GUID = 9d380387-a15a-4053-ae19-ff3495b6d0d5
MODULE_TYPE = UEFI_DRIVER
VERSION_STRING = 1.0
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
VALID_ARCHITECTURES = X64
[Binaries.X64]
PE32|X64/ext4.efi|*

22
FSDrivers/ntfs.inf Normal file
View File

@ -0,0 +1,22 @@
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = ntfs
FILE_GUID = 2282efd0-678b-4753-8d06-200d5940285d
MODULE_TYPE = UEFI_DRIVER
VERSION_STRING = 1.0
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
VALID_ARCHITECTURES = X64
[Binaries.X64]
PE32|X64/ntfs.efi|*

View File

@ -821,6 +821,9 @@ SetupResetReminder (
#define BDS_EFI_MESSAGE_USB_DEVICE_BOOT 0x0305 // Type 03; Sub-Type 05 #define BDS_EFI_MESSAGE_USB_DEVICE_BOOT 0x0305 // Type 03; Sub-Type 05
#define BDS_EFI_MESSAGE_SATA_BOOT 0x0312 // Type 03; Sub-Type 18 #define BDS_EFI_MESSAGE_SATA_BOOT 0x0312 // Type 03; Sub-Type 18
#define BDS_EFI_MESSAGE_MAC_BOOT 0x030b // Type 03; Sub-Type 11 #define BDS_EFI_MESSAGE_MAC_BOOT 0x030b // Type 03; Sub-Type 11
#define BDS_EFI_MESSAGE_SD_BOOT 0x030c // Type 03; Sub-Type 12
#define BDS_EFI_MESSAGE_EMMC_BOOT 0x030d // Type 03; Sub-Type 13
#define BDS_EFI_MESSAGE_NVME_BOOT 0x030e // Type 03; Sub-Type 14
#define BDS_EFI_MESSAGE_MISC_BOOT 0x03FF #define BDS_EFI_MESSAGE_MISC_BOOT 0x03FF
/// ///

View File

@ -91,6 +91,12 @@ PlatformBdsPolicyBehavior (
IN BASEM_MEMORY_TEST BaseMemoryTest IN BASEM_MEMORY_TEST BaseMemoryTest
); );
VOID
EFIAPI
PlatformBdsPreBoot (
IN BDS_COMMON_OPTION *Option
);
/** /**
Hook point for a user-provided function, for after a boot attempt fails. Hook point for a user-provided function, for after a boot attempt fails.

View File

@ -14,6 +14,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "InternalBdsLib.h" #include "InternalBdsLib.h"
#include "String.h" #include "String.h"
#include "InternalBm.h"
BOOLEAN mEnumBootDevice = FALSE; BOOLEAN mEnumBootDevice = FALSE;
EFI_HII_HANDLE gBdsLibStringPackHandle = NULL; EFI_HII_HANDLE gBdsLibStringPackHandle = NULL;
@ -2963,6 +2964,7 @@ BdsDeleteAllInvalidEfiBootOption (
UINTN Index2; UINTN Index2;
UINT16 BootOption[BOOT_OPTION_MAX_CHAR]; UINT16 BootOption[BOOT_OPTION_MAX_CHAR];
EFI_DEVICE_PATH_PROTOCOL *OptionDevicePath; EFI_DEVICE_PATH_PROTOCOL *OptionDevicePath;
EFI_DEVICE_PATH_PROTOCOL *WorkingDevicePath;
UINT8 *TempPtr; UINT8 *TempPtr;
CHAR16 *Description; CHAR16 *Description;
BOOLEAN Corrupted; BOOLEAN Corrupted;
@ -3017,6 +3019,24 @@ BdsDeleteAllInvalidEfiBootOption (
Index++; Index++;
continue; continue;
} }
//
// If it's Device Path that starts with a hard drive path, append it with the front part to compose a
// full device path
//
WorkingDevicePath = NULL;
if ((DevicePathType (OptionDevicePath) == MEDIA_DEVICE_PATH) &&
(DevicePathSubType (OptionDevicePath) == MEDIA_HARDDRIVE_DP)) {
WorkingDevicePath = BdsExpandPartitionPartialDevicePathToFull (
(HARDDRIVE_DEVICE_PATH *)OptionDevicePath
);
if (WorkingDevicePath != NULL) {
OptionDevicePath = WorkingDevicePath;
} else {
// Ensure unexpandable HD paths are removed
Corrupted = TRUE;
}
}
} }
if (Corrupted || !BdsLibIsValidEFIBootOptDevicePathExt (OptionDevicePath, FALSE, Description)) { if (Corrupted || !BdsLibIsValidEFIBootOptDevicePathExt (OptionDevicePath, FALSE, Description)) {
@ -3128,14 +3148,17 @@ BdsLibEnumerateAllBootOption (
UINT16 HarddriveNumber; UINT16 HarddriveNumber;
UINT16 CdromNumber; UINT16 CdromNumber;
UINT16 UsbNumber; UINT16 UsbNumber;
UINT16 SdNumber;
UINT16 MiscNumber; UINT16 MiscNumber;
UINT16 ScsiNumber; UINT16 ScsiNumber;
UINT16 NvmeNumber;
UINT16 NonBlockNumber; UINT16 NonBlockNumber;
UINTN NumberBlockIoHandles; UINTN NumberBlockIoHandles;
EFI_HANDLE *BlockIoHandles; EFI_HANDLE *BlockIoHandles;
EFI_BLOCK_IO_PROTOCOL *BlkIo; EFI_BLOCK_IO_PROTOCOL *BlkIo;
BOOLEAN Removable[2]; BOOLEAN Removable[2];
UINTN RemovableIndex; UINTN RemovableIndex;
UINTN DPTIndex;
UINTN Index; UINTN Index;
UINTN NumOfLoadFileHandles; UINTN NumOfLoadFileHandles;
EFI_HANDLE *LoadFileHandles; EFI_HANDLE *LoadFileHandles;
@ -3148,7 +3171,7 @@ BdsLibEnumerateAllBootOption (
EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv; EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
EFI_DEVICE_PATH_PROTOCOL *DevicePath; EFI_DEVICE_PATH_PROTOCOL *DevicePath;
UINTN DevicePathType; UINTN DevicePathType;
CHAR16 Buffer[40]; CHAR16 Buffer[80];
EFI_HANDLE *FileSystemHandles; EFI_HANDLE *FileSystemHandles;
UINTN NumberFileSystemHandles; UINTN NumberFileSystemHandles;
BOOLEAN NeedDelete; BOOLEAN NeedDelete;
@ -3162,8 +3185,10 @@ BdsLibEnumerateAllBootOption (
HarddriveNumber = 0; HarddriveNumber = 0;
CdromNumber = 0; CdromNumber = 0;
UsbNumber = 0; UsbNumber = 0;
SdNumber = 0;
MiscNumber = 0; MiscNumber = 0;
ScsiNumber = 0; ScsiNumber = 0;
NvmeNumber = 0;
PlatLang = NULL; PlatLang = NULL;
LastLang = NULL; LastLang = NULL;
ZeroMem (Buffer, sizeof (Buffer)); ZeroMem (Buffer, sizeof (Buffer));
@ -3229,6 +3254,7 @@ BdsLibEnumerateAllBootOption (
); );
for (RemovableIndex = 0; RemovableIndex < 2; RemovableIndex++) { for (RemovableIndex = 0; RemovableIndex < 2; RemovableIndex++) {
for (DPTIndex = 0; DPTIndex < 2; DPTIndex++) {
for (Index = 0; Index < NumberBlockIoHandles; Index++) { for (Index = 0; Index < NumberBlockIoHandles; Index++) {
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
BlockIoHandles[Index], BlockIoHandles[Index],
@ -3251,10 +3277,33 @@ BdsLibEnumerateAllBootOption (
DevicePath = DevicePathFromHandle (BlockIoHandles[Index]); DevicePath = DevicePathFromHandle (BlockIoHandles[Index]);
DevicePathType = BdsGetBootTypeFromDevicePath (DevicePath); DevicePathType = BdsGetBootTypeFromDevicePath (DevicePath);
//
// Skip devices that do not have an EFI volume
//
if (BdsLibGetBootableHandle (DevicePath) == NULL) {
continue;
}
// Do NVMe devices first, all others second
if (DPTIndex == 0) {
if (DevicePathType != BDS_EFI_MESSAGE_NVME_BOOT) {
continue;
}
} else if (DevicePathType == BDS_EFI_MESSAGE_NVME_BOOT) {
continue;
}
//
// get description for current block handle
//
CHAR16 * DevName = BmGetBootDescription(BlockIoHandles[Index]);
switch (DevicePathType) { switch (DevicePathType) {
case BDS_EFI_ACPI_FLOPPY_BOOT: case BDS_EFI_ACPI_FLOPPY_BOOT:
if (FloppyNumber != 0) { if (DevName != NULL) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_FLOPPY)), FloppyNumber); UnicodeSPrint (Buffer, sizeof (Buffer), L"Floppy: %s", DevName);
} else if (FloppyNumber != 0) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_FLOPPY)), FloppyNumber + 1);
} else { } else {
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_FLOPPY))); UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_FLOPPY)));
} }
@ -3268,15 +3317,23 @@ BdsLibEnumerateAllBootOption (
case BDS_EFI_MESSAGE_ATAPI_BOOT: case BDS_EFI_MESSAGE_ATAPI_BOOT:
case BDS_EFI_MESSAGE_SATA_BOOT: case BDS_EFI_MESSAGE_SATA_BOOT:
if (BlkIo->Media->RemovableMedia) { if (BlkIo->Media->RemovableMedia) {
if (CdromNumber != 0) { if (DevName != NULL) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_CD_DVD)), CdromNumber); UnicodeSPrint (Buffer, sizeof (Buffer), L"CD/DVD: %s", DevName);
} else if (CdromNumber != 0) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_CD_DVD)), CdromNumber + 1);
} else { } else {
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_CD_DVD))); UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_CD_DVD)));
} }
CdromNumber++; CdromNumber++;
} else { } else {
if (HarddriveNumber != 0) { if (DevName != NULL) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_HARDDRIVE)), HarddriveNumber); if (DevicePathType == BDS_EFI_MESSAGE_ATAPI_BOOT) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"IDE: %s", DevName);
} else {
UnicodeSPrint (Buffer, sizeof (Buffer), L"SATA: %s", DevName);
}
} else if (HarddriveNumber != 0) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_HARDDRIVE)), HarddriveNumber + 1);
} else { } else {
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_HARDDRIVE))); UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_HARDDRIVE)));
} }
@ -3287,8 +3344,10 @@ BdsLibEnumerateAllBootOption (
break; break;
case BDS_EFI_MESSAGE_USB_DEVICE_BOOT: case BDS_EFI_MESSAGE_USB_DEVICE_BOOT:
if (UsbNumber != 0) { if (DevName != NULL) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_USB)), UsbNumber); UnicodeSPrint (Buffer, sizeof (Buffer), L"USB: %s", DevName);
} else if (UsbNumber != 0) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_USB)), UsbNumber + 1);
} else { } else {
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_USB))); UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_USB)));
} }
@ -3297,8 +3356,10 @@ BdsLibEnumerateAllBootOption (
break; break;
case BDS_EFI_MESSAGE_SCSI_BOOT: case BDS_EFI_MESSAGE_SCSI_BOOT:
if (ScsiNumber != 0) { if (DevName != NULL) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_SCSI)), ScsiNumber); UnicodeSPrint (Buffer, sizeof (Buffer), L"SCSI: %s", DevName);
} else if (ScsiNumber != 0) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_SCSI)), ScsiNumber + 1);
} else { } else {
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_SCSI))); UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_SCSI)));
} }
@ -3306,18 +3367,53 @@ BdsLibEnumerateAllBootOption (
ScsiNumber++; ScsiNumber++;
break; break;
case BDS_EFI_MESSAGE_MISC_BOOT: case BDS_EFI_MESSAGE_EMMC_BOOT:
default: if (DevName != NULL) {
if (MiscNumber != 0) { UnicodeSPrint (Buffer, sizeof (Buffer), L"eMMC: %s", DevName);
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_MISC)), MiscNumber); } else if (MiscNumber != 0) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"EFI eMMC Device %d", MiscNumber + 1);
} else { } else {
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_MISC))); UnicodeSPrint (Buffer, sizeof (Buffer), L"EFI eMMC Device");
} }
BdsLibBuildOptionFromHandle (BlockIoHandles[Index], BdsBootOptionList, Buffer); BdsLibBuildOptionFromHandle (BlockIoHandles[Index], BdsBootOptionList, Buffer);
MiscNumber++; MiscNumber++;
break; break;
case BDS_EFI_MESSAGE_SD_BOOT:
if (DevName != NULL) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"SD: %s", DevName);
} else if (SdNumber != 0) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"EFI SD Device %d", SdNumber + 1);
} else {
UnicodeSPrint (Buffer, sizeof (Buffer), L"EFI SD Device");
}
BdsLibBuildOptionFromHandle (BlockIoHandles[Index], BdsBootOptionList, Buffer);
SdNumber++;
break;
case BDS_EFI_MESSAGE_NVME_BOOT:
if (DevName != NULL) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"NVMe: %s", DevName);
} else if (NvmeNumber != 0) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"EFI NVMe Device %d", NvmeNumber + 1);
} else {
UnicodeSPrint (Buffer, sizeof (Buffer), L"EFI NVMe Device");
}
BdsLibBuildOptionFromHandle (BlockIoHandles[Index], BdsBootOptionList, Buffer);
NvmeNumber++;
break;
case BDS_EFI_MESSAGE_MISC_BOOT:
default:
if (MiscNumber == 0) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"eMMC: Internal Drive");
BdsLibBuildOptionFromHandle (BlockIoHandles[Index], BdsBootOptionList, Buffer);
}
MiscNumber++;
break;
} }
} }
}
} }
if (NumberBlockIoHandles != 0) { if (NumberBlockIoHandles != 0) {
@ -3373,7 +3469,7 @@ BdsLibEnumerateAllBootOption (
BdsLibDeleteOptionFromHandle (FileSystemHandles[Index]); BdsLibDeleteOptionFromHandle (FileSystemHandles[Index]);
} else { } else {
if (NonBlockNumber != 0) { if (NonBlockNumber != 0) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_NON_BLOCK)), NonBlockNumber); UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_NON_BLOCK)), NonBlockNumber + 1);
} else { } else {
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_NON_BLOCK))); UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_NON_BLOCK)));
} }
@ -3960,8 +4056,20 @@ BdsGetBootTypeFromDevicePath (
BootType = BDS_EFI_MESSAGE_MAC_BOOT; BootType = BDS_EFI_MESSAGE_MAC_BOOT;
break; break;
case MSG_EMMC_DP:
BootType = BDS_EFI_MESSAGE_EMMC_BOOT;
break;
case MSG_SD_DP:
BootType = BDS_EFI_MESSAGE_SD_BOOT;
break;
case MSG_NVME_NAMESPACE_DP:
BootType = BDS_EFI_MESSAGE_NVME_BOOT;
break;
default: default:
BootType = BDS_EFI_MESSAGE_MISC_BOOT; BootType = DevicePathSubType (TempDevicePath);
break; break;
} }
return BootType; return BootType;

View File

@ -862,7 +862,7 @@ EnableQuietBoot (
case EfiBadgingDisplayAttributeCenter: case EfiBadgingDisplayAttributeCenter:
DestX = (SizeOfX - Width) / 2; DestX = (SizeOfX - Width) / 2;
DestY = (SizeOfY - Height) / 2; DestY = ((SizeOfY * 382) / 1000) - Height / 2;
break; break;
case EfiBadgingDisplayAttributeCustomized: case EfiBadgingDisplayAttributeCustomized:

View File

@ -0,0 +1,870 @@
/** @file
Library functions which relate with boot option description.
Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "InternalBm.h"
#define VENDOR_IDENTIFICATION_OFFSET 3
#define VENDOR_IDENTIFICATION_LENGTH 8
#define PRODUCT_IDENTIFICATION_OFFSET 11
#define PRODUCT_IDENTIFICATION_LENGTH 16
CONST UINT16 mBmUsbLangId = 0x0409; // English
CHAR16 mBmUefiPrefix[] = L"";
LIST_ENTRY mPlatformBootDescriptionHandlers = INITIALIZE_LIST_HEAD_VARIABLE (mPlatformBootDescriptionHandlers);
/**
For a bootable Device path, return its boot type.
@param DevicePath The bootable device Path to check
@retval AcpiFloppyBoot If given device path contains ACPI_DEVICE_PATH type device path node
which HID is floppy device.
@retval MessageAtapiBoot If given device path contains MESSAGING_DEVICE_PATH type device path node
and its last device path node's subtype is MSG_ATAPI_DP.
@retval MessageSataBoot If given device path contains MESSAGING_DEVICE_PATH type device path node
and its last device path node's subtype is MSG_SATA_DP.
@retval MessageScsiBoot If given device path contains MESSAGING_DEVICE_PATH type device path node
and its last device path node's subtype is MSG_SCSI_DP.
@retval MessageUsbBoot If given device path contains MESSAGING_DEVICE_PATH type device path node
and its last device path node's subtype is MSG_USB_DP.
@retval BmMiscBoot If tiven device path doesn't match the above condition.
**/
BM_BOOT_TYPE
BmDevicePathType (
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
EFI_DEVICE_PATH_PROTOCOL *Node;
EFI_DEVICE_PATH_PROTOCOL *NextNode;
ASSERT (DevicePath != NULL);
for (Node = DevicePath; !IsDevicePathEndType (Node); Node = NextDevicePathNode (Node)) {
switch (DevicePathType (Node)) {
case ACPI_DEVICE_PATH:
if (EISA_ID_TO_NUM (((ACPI_HID_DEVICE_PATH *) Node)->HID) == 0x0604) {
return BmAcpiFloppyBoot;
}
break;
case HARDWARE_DEVICE_PATH:
if (DevicePathSubType (Node) == HW_CONTROLLER_DP) {
return BmHardwareDeviceBoot;
}
break;
case MESSAGING_DEVICE_PATH:
//
// Skip LUN device node
//
NextNode = Node;
do {
NextNode = NextDevicePathNode (NextNode);
} while (
(DevicePathType (NextNode) == MESSAGING_DEVICE_PATH) &&
(DevicePathSubType(NextNode) == MSG_DEVICE_LOGICAL_UNIT_DP)
);
//
// If the device path not only point to driver device, it is not a messaging device path,
//
if (!IsDevicePathEndType (NextNode)) {
continue;
}
switch (DevicePathSubType (Node)) {
case MSG_ATAPI_DP:
return BmMessageAtapiBoot;
break;
case MSG_SATA_DP:
return BmMessageSataBoot;
break;
case MSG_USB_DP:
return BmMessageUsbBoot;
break;
case MSG_SCSI_DP:
return BmMessageScsiBoot;
break;
}
}
}
return BmMiscBoot;
}
/**
Eliminate the extra spaces in the Str to one space.
@param Str Input string info.
**/
VOID
BmEliminateExtraSpaces (
IN CHAR16 *Str
)
{
UINTN Index;
UINTN ActualIndex;
for (Index = 0, ActualIndex = 0; Str[Index] != L'\0'; Index++) {
if ((Str[Index] != L' ') || ((ActualIndex > 0) && (Str[ActualIndex - 1] != L' '))) {
Str[ActualIndex++] = Str[Index];
}
}
Str[ActualIndex] = L'\0';
}
/**
Try to get the controller's ATA/ATAPI description.
@param Handle Controller handle.
@return The description string.
**/
CHAR16 *
BmGetDescriptionFromDiskInfo (
IN EFI_HANDLE Handle
)
{
UINTN Index;
EFI_STATUS Status;
EFI_DISK_INFO_PROTOCOL *DiskInfo;
UINT32 BufferSize;
EFI_ATAPI_IDENTIFY_DATA IdentifyData;
EFI_SCSI_INQUIRY_DATA InquiryData;
CHAR16 *Description;
UINTN Length;
CONST UINTN ModelNameLength = 40;
CHAR8 *StrPtr;
UINT8 Temp;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
Description = NULL;
Status = gBS->HandleProtocol (
Handle,
&gEfiDiskInfoProtocolGuid,
(VOID **) &DiskInfo
);
if (EFI_ERROR (Status)) {
return NULL;
}
if (CompareGuid (&DiskInfo->Interface, &gEfiDiskInfoAhciInterfaceGuid) ||
CompareGuid (&DiskInfo->Interface, &gEfiDiskInfoIdeInterfaceGuid)) {
BufferSize = sizeof (EFI_ATAPI_IDENTIFY_DATA);
Status = DiskInfo->Identify (
DiskInfo,
&IdentifyData,
&BufferSize
);
if (!EFI_ERROR (Status)) {
Description = AllocateZeroPool ((ModelNameLength + 1) * sizeof (CHAR16));
ASSERT (Description != NULL);
for (Index = 0; Index + 1 < ModelNameLength; Index += 2) {
Description[Index] = (CHAR16) IdentifyData.ModelName[Index + 1];
Description[Index + 1] = (CHAR16) IdentifyData.ModelName[Index];
}
Length = Index;
Description[Length++] = L'\0';
ASSERT (Length == ModelNameLength + 1);
BmEliminateExtraSpaces (Description);
}
} else if (CompareGuid (&DiskInfo->Interface, &gEfiDiskInfoScsiInterfaceGuid)) {
BufferSize = sizeof (EFI_SCSI_INQUIRY_DATA);
Status = DiskInfo->Inquiry (
DiskInfo,
&InquiryData,
&BufferSize
);
if (!EFI_ERROR (Status)) {
Description = AllocateZeroPool ((VENDOR_IDENTIFICATION_LENGTH + PRODUCT_IDENTIFICATION_LENGTH + 2) * sizeof (CHAR16));
ASSERT (Description != NULL);
//
// Per SCSI spec, EFI_SCSI_INQUIRY_DATA.Reserved_5_95[3 - 10] save the Verdor identification
// EFI_SCSI_INQUIRY_DATA.Reserved_5_95[11 - 26] save the product identification,
// Here combine the vendor identification and product identification to the description.
//
StrPtr = (CHAR8 *) (&InquiryData.Reserved_5_95[VENDOR_IDENTIFICATION_OFFSET]);
Temp = StrPtr[VENDOR_IDENTIFICATION_LENGTH];
StrPtr[VENDOR_IDENTIFICATION_LENGTH] = '\0';
AsciiStrToUnicodeStrS (StrPtr, Description, VENDOR_IDENTIFICATION_LENGTH + 1);
StrPtr[VENDOR_IDENTIFICATION_LENGTH] = Temp;
//
// Add one space at the middle of vendor information and product information.
//
Description[VENDOR_IDENTIFICATION_LENGTH] = L' ';
StrPtr = (CHAR8 *) (&InquiryData.Reserved_5_95[PRODUCT_IDENTIFICATION_OFFSET]);
StrPtr[PRODUCT_IDENTIFICATION_LENGTH] = '\0';
AsciiStrToUnicodeStrS (StrPtr, Description + VENDOR_IDENTIFICATION_LENGTH + 1, PRODUCT_IDENTIFICATION_LENGTH + 1);
BmEliminateExtraSpaces (Description);
}
} else if (CompareGuid (&DiskInfo->Interface, &gEfiDiskInfoSdMmcInterfaceGuid)) {
DevicePath = DevicePathFromHandle (Handle);
if (DevicePath == NULL) {
return NULL;
}
while (!IsDevicePathEnd (DevicePath) && (DevicePathType (DevicePath) != MESSAGING_DEVICE_PATH)) {
DevicePath = NextDevicePathNode (DevicePath);
}
if (IsDevicePathEnd (DevicePath)) {
return NULL;
}
if (DevicePathSubType (DevicePath) == MSG_SD_DP) {
Description = L"SD Device";
} else if (DevicePathSubType (DevicePath) == MSG_EMMC_DP) {
Description = L"eMMC Device";
} else {
return NULL;
}
Description = AllocateCopyPool (StrSize (Description), Description);
}
return Description;
}
/**
Try to get the controller's USB description.
@param Handle Controller handle.
@return The description string.
**/
CHAR16 *
BmGetUsbDescription (
IN EFI_HANDLE Handle
)
{
EFI_STATUS Status;
EFI_USB_IO_PROTOCOL *UsbIo;
CHAR16 NullChar;
CHAR16 *Manufacturer;
CHAR16 *Product;
CHAR16 *SerialNumber;
CHAR16 *Description;
EFI_USB_DEVICE_DESCRIPTOR DevDesc;
UINTN DescMaxSize;
Status = gBS->HandleProtocol (
Handle,
&gEfiUsbIoProtocolGuid,
(VOID **) &UsbIo
);
if (EFI_ERROR (Status)) {
return NULL;
}
NullChar = L'\0';
Status = UsbIo->UsbGetDeviceDescriptor (UsbIo, &DevDesc);
if (EFI_ERROR (Status)) {
return NULL;
}
Status = UsbIo->UsbGetStringDescriptor (
UsbIo,
mBmUsbLangId,
DevDesc.StrManufacturer,
&Manufacturer
);
if (EFI_ERROR (Status)) {
Manufacturer = &NullChar;
}
Status = UsbIo->UsbGetStringDescriptor (
UsbIo,
mBmUsbLangId,
DevDesc.StrProduct,
&Product
);
if (EFI_ERROR (Status)) {
Product = &NullChar;
}
Status = UsbIo->UsbGetStringDescriptor (
UsbIo,
mBmUsbLangId,
DevDesc.StrSerialNumber,
&SerialNumber
);
if (EFI_ERROR (Status)) {
SerialNumber = &NullChar;
}
if ((Manufacturer == &NullChar) &&
(Product == &NullChar) &&
(SerialNumber == &NullChar)
) {
return NULL;
}
DescMaxSize = StrSize (Manufacturer) + StrSize (Product);
Description = AllocateZeroPool (DescMaxSize);
ASSERT (Description != NULL);
StrCatS (Description, DescMaxSize/sizeof(CHAR16), Manufacturer);
StrCatS (Description, DescMaxSize/sizeof(CHAR16), L" ");
StrCatS (Description, DescMaxSize/sizeof(CHAR16), Product);
if (Manufacturer != &NullChar) {
FreePool (Manufacturer);
}
if (Product != &NullChar) {
FreePool (Product);
}
if (SerialNumber != &NullChar) {
FreePool (SerialNumber);
}
BmEliminateExtraSpaces (Description);
return Description;
}
/**
Return the description for network boot device.
@param Handle Controller handle.
@return The description string.
**/
CHAR16 *
BmGetNetworkDescription (
IN EFI_HANDLE Handle
)
{
EFI_STATUS Status;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
MAC_ADDR_DEVICE_PATH *Mac;
VLAN_DEVICE_PATH *Vlan;
EFI_DEVICE_PATH_PROTOCOL *Ip;
EFI_DEVICE_PATH_PROTOCOL *Uri;
CHAR16 *Description;
UINTN DescriptionSize;
Status = gBS->OpenProtocol (
Handle,
&gEfiLoadFileProtocolGuid,
NULL,
gImageHandle,
Handle,
EFI_OPEN_PROTOCOL_TEST_PROTOCOL
);
if (EFI_ERROR (Status)) {
return NULL;
}
Status = gBS->OpenProtocol (
Handle,
&gEfiDevicePathProtocolGuid,
(VOID **) &DevicePath,
gImageHandle,
Handle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status) || (DevicePath == NULL)) {
return NULL;
}
//
// The PXE device path is like:
// ....../Mac(...)[/Vlan(...)][/Wi-Fi(...)]
// ....../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv4(...)
// ....../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv6(...)
//
// The HTTP device path is like:
// ....../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv4(...)[/Dns(...)]/Uri(...)
// ....../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv6(...)[/Dns(...)]/Uri(...)
//
while (!IsDevicePathEnd (DevicePath) &&
((DevicePathType (DevicePath) != MESSAGING_DEVICE_PATH) ||
(DevicePathSubType (DevicePath) != MSG_MAC_ADDR_DP))
) {
DevicePath = NextDevicePathNode (DevicePath);
}
if (IsDevicePathEnd (DevicePath)) {
return NULL;
}
Mac = (MAC_ADDR_DEVICE_PATH *) DevicePath;
DevicePath = NextDevicePathNode (DevicePath);
//
// Locate the optional Vlan node
//
if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&
(DevicePathSubType (DevicePath) == MSG_VLAN_DP)
) {
Vlan = (VLAN_DEVICE_PATH *) DevicePath;
DevicePath = NextDevicePathNode (DevicePath);
} else {
Vlan = NULL;
}
//
// Skip the optional Wi-Fi node
//
if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&
(DevicePathSubType (DevicePath) == MSG_WIFI_DP)
) {
DevicePath = NextDevicePathNode (DevicePath);
}
//
// Locate the IP node
//
if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&
((DevicePathSubType (DevicePath) == MSG_IPv4_DP) ||
(DevicePathSubType (DevicePath) == MSG_IPv6_DP))
) {
Ip = DevicePath;
DevicePath = NextDevicePathNode (DevicePath);
} else {
Ip = NULL;
}
//
// Skip the optional DNS node
//
if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&
(DevicePathSubType (DevicePath) == MSG_DNS_DP)
) {
DevicePath = NextDevicePathNode (DevicePath);
}
//
// Locate the URI node
//
if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&
(DevicePathSubType (DevicePath) == MSG_URI_DP)
) {
Uri = DevicePath;
DevicePath = NextDevicePathNode (DevicePath);
} else {
Uri = NULL;
}
//
// Build description like below:
// "PXEv6 (MAC:112233445566 VLAN1)"
// "HTTPv4 (MAC:112233445566)"
//
DescriptionSize = sizeof (L"HTTPv6 (MAC:112233445566 VLAN65535)");
Description = AllocatePool (DescriptionSize);
ASSERT (Description != NULL);
UnicodeSPrint (
Description, DescriptionSize,
(Vlan == NULL) ?
L"%sv%d (MAC:%02x%02x%02x%02x%02x%02x)" :
L"%sv%d (MAC:%02x%02x%02x%02x%02x%02x VLAN%d)",
(Uri == NULL) ? L"PXE" : L"HTTP",
((Ip == NULL) || (DevicePathSubType (Ip) == MSG_IPv4_DP)) ? 4 : 6,
Mac->MacAddress.Addr[0], Mac->MacAddress.Addr[1], Mac->MacAddress.Addr[2],
Mac->MacAddress.Addr[3], Mac->MacAddress.Addr[4], Mac->MacAddress.Addr[5],
(Vlan == NULL) ? 0 : Vlan->VlanId
);
return Description;
}
/**
Return the boot description for LoadFile
@param Handle Controller handle.
@return The description string.
**/
CHAR16 *
BmGetLoadFileDescription (
IN EFI_HANDLE Handle
)
{
EFI_STATUS Status;
EFI_DEVICE_PATH_PROTOCOL *FilePath;
EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;
CHAR16 *Description;
EFI_LOAD_FILE_PROTOCOL *LoadFile;
Status = gBS->HandleProtocol (Handle, &gEfiLoadFileProtocolGuid, (VOID **)&LoadFile);
if (EFI_ERROR (Status)) {
return NULL;
}
//
// Get the file name
//
Description = NULL;
Status = gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID **)&FilePath);
if (!EFI_ERROR (Status)) {
DevicePathNode = FilePath;
while (!IsDevicePathEnd (DevicePathNode)) {
if (DevicePathNode->Type == MEDIA_DEVICE_PATH && DevicePathNode->SubType == MEDIA_FILEPATH_DP) {
Description = (CHAR16 *)(DevicePathNode + 1);
break;
}
DevicePathNode = NextDevicePathNode (DevicePathNode);
}
}
if (Description != NULL) {
return AllocateCopyPool (StrSize (Description), Description);
}
return NULL;
}
/**
Return the boot description for NVME boot device.
@param Handle Controller handle.
@return The description string.
**/
CHAR16 *
BmGetNvmeDescription (
IN EFI_HANDLE Handle
)
{
EFI_STATUS Status;
EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *NvmePassthru;
EFI_DEV_PATH_PTR DevicePath;
EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET CommandPacket;
EFI_NVM_EXPRESS_COMMAND Command;
EFI_NVM_EXPRESS_COMPLETION Completion;
NVME_ADMIN_CONTROLLER_DATA ControllerData;
CHAR16 *Description;
CHAR16 *Char;
UINTN Index;
Status = gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID **) &DevicePath.DevPath);
if (EFI_ERROR (Status)) {
return NULL;
}
Status = gBS->LocateDevicePath (&gEfiNvmExpressPassThruProtocolGuid, &DevicePath.DevPath, &Handle);
if (EFI_ERROR (Status) ||
(DevicePathType (DevicePath.DevPath) != MESSAGING_DEVICE_PATH) ||
(DevicePathSubType (DevicePath.DevPath) != MSG_NVME_NAMESPACE_DP)) {
//
// Do not return description when the Handle is not a child of NVME controller.
//
return NULL;
}
//
// Send ADMIN_IDENTIFY command to NVME controller to get the model and serial number.
//
Status = gBS->HandleProtocol (Handle, &gEfiNvmExpressPassThruProtocolGuid, (VOID **) &NvmePassthru);
ASSERT_EFI_ERROR (Status);
ZeroMem (&CommandPacket, sizeof(EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
ZeroMem (&Command, sizeof(EFI_NVM_EXPRESS_COMMAND));
ZeroMem (&Completion, sizeof(EFI_NVM_EXPRESS_COMPLETION));
Command.Cdw0.Opcode = NVME_ADMIN_IDENTIFY_CMD;
//
// According to Nvm Express 1.1 spec Figure 38, When not used, the field shall be cleared to 0h.
// For the Identify command, the Namespace Identifier is only used for the Namespace data structure.
//
Command.Nsid = 0;
CommandPacket.NvmeCmd = &Command;
CommandPacket.NvmeCompletion = &Completion;
CommandPacket.TransferBuffer = &ControllerData;
CommandPacket.TransferLength = sizeof (ControllerData);
CommandPacket.CommandTimeout = EFI_TIMER_PERIOD_SECONDS (5);
CommandPacket.QueueType = NVME_ADMIN_QUEUE;
//
// Set bit 0 (Cns bit) to 1 to identify a controller
//
Command.Cdw10 = 1;
Command.Flags = CDW10_VALID;
Status = NvmePassthru->PassThru (
NvmePassthru,
0,
&CommandPacket,
NULL
);
if (EFI_ERROR (Status)) {
return NULL;
}
Description = AllocateZeroPool (
(ARRAY_SIZE (ControllerData.Mn) + 1
+ ARRAY_SIZE (ControllerData.Sn) + 1
+ MAXIMUM_VALUE_CHARACTERS + 1
) * sizeof (CHAR16));
if (Description != NULL) {
Char = Description;
for (Index = 0; Index < ARRAY_SIZE (ControllerData.Mn); Index++) {
*(Char++) = (CHAR16) ControllerData.Mn[Index];
}
*(Char++) = L' ';
for (Index = 0; Index < ARRAY_SIZE (ControllerData.Sn); Index++) {
*(Char++) = (CHAR16) ControllerData.Sn[Index];
}
*(Char++) = L' ';
UnicodeValueToStringS (
Char, sizeof (CHAR16) * (MAXIMUM_VALUE_CHARACTERS + 1),
0, DevicePath.NvmeNamespace->NamespaceId, 0
);
BmEliminateExtraSpaces (Description);
}
return Description;
}
/**
Return the boot description for the controller based on the type.
@param Handle Controller handle.
@return The description string.
**/
CHAR16 *
BmGetMiscDescription (
IN EFI_HANDLE Handle
)
{
EFI_STATUS Status;
CHAR16 *Description;
EFI_BLOCK_IO_PROTOCOL *BlockIo;
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs;
switch (BmDevicePathType (DevicePathFromHandle (Handle))) {
case BmAcpiFloppyBoot:
Description = L"Floppy";
break;
case BmMessageAtapiBoot:
case BmMessageSataBoot:
Status = gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **) &BlockIo);
ASSERT_EFI_ERROR (Status);
//
// Assume a removable SATA device should be the DVD/CD device
//
Description = BlockIo->Media->RemovableMedia ? L"DVD/CDROM" : L"Hard Drive";
break;
case BmMessageUsbBoot:
Description = L"USB Device";
break;
case BmMessageScsiBoot:
Description = L"SCSI Device";
break;
case BmHardwareDeviceBoot:
Status = gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **) &BlockIo);
if (!EFI_ERROR (Status)) {
Description = BlockIo->Media->RemovableMedia ? L"Removable Disk" : L"Hard Drive";
} else {
Description = L"Misc Device";
}
break;
default:
Status = gBS->HandleProtocol (Handle, &gEfiSimpleFileSystemProtocolGuid, (VOID **) &Fs);
if (!EFI_ERROR (Status)) {
Description = L"Non-Block Boot Device";
} else {
Description = L"Misc Device";
}
break;
}
return AllocateCopyPool (StrSize (Description), Description);
}
/**
Register the platform provided boot description handler.
@param Handler The platform provided boot description handler
@retval EFI_SUCCESS The handler was registered successfully.
@retval EFI_ALREADY_STARTED The handler was already registered.
@retval EFI_OUT_OF_RESOURCES There is not enough resource to perform the registration.
**/
EFI_STATUS
EFIAPI
EfiBootManagerRegisterBootDescriptionHandler (
IN EFI_BOOT_MANAGER_BOOT_DESCRIPTION_HANDLER Handler
)
{
LIST_ENTRY *Link;
BM_BOOT_DESCRIPTION_ENTRY *Entry;
for ( Link = GetFirstNode (&mPlatformBootDescriptionHandlers)
; !IsNull (&mPlatformBootDescriptionHandlers, Link)
; Link = GetNextNode (&mPlatformBootDescriptionHandlers, Link)
) {
Entry = CR (Link, BM_BOOT_DESCRIPTION_ENTRY, Link, BM_BOOT_DESCRIPTION_ENTRY_SIGNATURE);
if (Entry->Handler == Handler) {
return EFI_ALREADY_STARTED;
}
}
Entry = AllocatePool (sizeof (BM_BOOT_DESCRIPTION_ENTRY));
if (Entry == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Entry->Signature = BM_BOOT_DESCRIPTION_ENTRY_SIGNATURE;
Entry->Handler = Handler;
InsertTailList (&mPlatformBootDescriptionHandlers, &Entry->Link);
return EFI_SUCCESS;
}
BM_GET_BOOT_DESCRIPTION mBmBootDescriptionHandlers[] = {
BmGetUsbDescription,
BmGetDescriptionFromDiskInfo,
BmGetNetworkDescription,
BmGetLoadFileDescription,
BmGetNvmeDescription,
BmGetMiscDescription
};
/**
Return the boot description for the controller.
@param Handle Controller handle.
@return The description string.
**/
CHAR16 *
BmGetBootDescription (
IN EFI_HANDLE Handle
)
{
LIST_ENTRY *Link;
BM_BOOT_DESCRIPTION_ENTRY *Entry;
CHAR16 *Description;
CHAR16 *DefaultDescription;
CHAR16 *Temp;
UINTN Index;
//
// Firstly get the default boot description
//
DefaultDescription = NULL;
for (Index = 0; Index < ARRAY_SIZE (mBmBootDescriptionHandlers); Index++) {
DefaultDescription = mBmBootDescriptionHandlers[Index] (Handle);
if (DefaultDescription != NULL) {
//
// Avoid description confusion between UEFI & Legacy boot option by adding "UEFI " prefix
// ONLY for core provided boot description handler.
//
Temp = AllocatePool (StrSize (DefaultDescription) + sizeof (mBmUefiPrefix));
ASSERT (Temp != NULL);
StrCpyS (Temp, (StrSize (DefaultDescription) + sizeof (mBmUefiPrefix)) / sizeof (CHAR16), mBmUefiPrefix);
StrCatS (Temp, (StrSize (DefaultDescription) + sizeof (mBmUefiPrefix)) / sizeof (CHAR16), DefaultDescription);
FreePool (DefaultDescription);
DefaultDescription = Temp;
break;
}
}
ASSERT (DefaultDescription != NULL);
//
// Secondly query platform for the better boot description
//
for ( Link = GetFirstNode (&mPlatformBootDescriptionHandlers)
; !IsNull (&mPlatformBootDescriptionHandlers, Link)
; Link = GetNextNode (&mPlatformBootDescriptionHandlers, Link)
) {
Entry = CR (Link, BM_BOOT_DESCRIPTION_ENTRY, Link, BM_BOOT_DESCRIPTION_ENTRY_SIGNATURE);
Description = Entry->Handler (Handle, DefaultDescription);
if (Description != NULL) {
FreePool (DefaultDescription);
return Description;
}
}
return DefaultDescription;
}
/**
Enumerate all boot option descriptions and append " 2"/" 3"/... to make
unique description.
@param BootOptions Array of boot options.
@param BootOptionCount Count of boot options.
**/
VOID
BmMakeBootOptionDescriptionUnique (
EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions,
UINTN BootOptionCount
)
{
UINTN Base;
UINTN Index;
UINTN DescriptionSize;
UINTN MaxSuffixSize;
BOOLEAN *Visited;
UINTN MatchCount;
if (BootOptionCount == 0) {
return;
}
//
// Calculate the maximum buffer size for the number suffix.
// The initial sizeof (CHAR16) is for the blank space before the number.
//
MaxSuffixSize = sizeof (CHAR16);
for (Index = BootOptionCount; Index != 0; Index = Index / 10) {
MaxSuffixSize += sizeof (CHAR16);
}
Visited = AllocateZeroPool (sizeof (BOOLEAN) * BootOptionCount);
ASSERT (Visited != NULL);
for (Base = 0; Base < BootOptionCount; Base++) {
if (!Visited[Base]) {
MatchCount = 1;
Visited[Base] = TRUE;
DescriptionSize = StrSize (BootOptions[Base].Description);
for (Index = Base + 1; Index < BootOptionCount; Index++) {
if (!Visited[Index] && StrCmp (BootOptions[Base].Description, BootOptions[Index].Description) == 0) {
Visited[Index] = TRUE;
MatchCount++;
FreePool (BootOptions[Index].Description);
BootOptions[Index].Description = AllocatePool (DescriptionSize + MaxSuffixSize);
UnicodeSPrint (
BootOptions[Index].Description, DescriptionSize + MaxSuffixSize,
L"%s %d",
BootOptions[Base].Description, MatchCount
);
}
}
}
}
FreePool (Visited);
}

View File

@ -39,7 +39,9 @@
BdsMisc.c BdsMisc.c
BdsConsole.c BdsConsole.c
BdsBoot.c BdsBoot.c
BmBootDescription.c
InternalBdsLib.h InternalBdsLib.h
InternalBm.h
String.h String.h
String.c String.c
GenericBdsStrings.uni GenericBdsStrings.uni
@ -103,6 +105,10 @@
## SOMETIMES_CONSUMES ## Variable:L"LegacyDevOrder" ## SOMETIMES_CONSUMES ## Variable:L"LegacyDevOrder"
gEfiLegacyDevOrderVariableGuid gEfiLegacyDevOrderVariableGuid
gEdkiiStatusCodeDataTypeVariableGuid ## SOMETIMES_CONSUMES ## GUID gEdkiiStatusCodeDataTypeVariableGuid ## SOMETIMES_CONSUMES ## GUID
gEfiDiskInfoAhciInterfaceGuid ## SOMETIMES_CONSUMES ## GUID
gEfiDiskInfoIdeInterfaceGuid ## SOMETIMES_CONSUMES ## GUID
gEfiDiskInfoScsiInterfaceGuid ## SOMETIMES_CONSUMES ## GUID
gEfiDiskInfoSdMmcInterfaceGuid ## SOMETIMES_CONSUMES ## GUID
[Protocols] [Protocols]
gEfiSimpleFileSystemProtocolGuid ## SOMETIMES_CONSUMES gEfiSimpleFileSystemProtocolGuid ## SOMETIMES_CONSUMES
@ -125,6 +131,8 @@
gEfiUserManagerProtocolGuid ## SOMETIMES_CONSUMES gEfiUserManagerProtocolGuid ## SOMETIMES_CONSUMES
gEfiUsbIoProtocolGuid ## SOMETIMES_CONSUMES gEfiUsbIoProtocolGuid ## SOMETIMES_CONSUMES
gEfiBootLogoProtocolGuid ## SOMETIMES_CONSUMES gEfiBootLogoProtocolGuid ## SOMETIMES_CONSUMES
gEfiNvmExpressPassThruProtocolGuid ## SOMETIMES_CONSUMES
gEfiDiskInfoProtocolGuid ## SOMETIMES_CONSUMES
[FeaturePcd] [FeaturePcd]
gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport ## CONSUMES gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport ## CONSUMES

View File

@ -0,0 +1,471 @@
/** @file
BDS library definition, include the file and data structure
Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef _INTERNAL_BM_H_
#define _INTERNAL_BM_H_
#include <PiDxe.h>
#include <IndustryStandard/Pci.h>
#include <IndustryStandard/PeImage.h>
#include <IndustryStandard/Atapi.h>
#include <IndustryStandard/Scsi.h>
#include <IndustryStandard/Nvme.h>
#include <Protocol/PciRootBridgeIo.h>
#include <Protocol/BlockIo.h>
#include <Protocol/LoadedImage.h>
#include <Protocol/SimpleFileSystem.h>
#include <Protocol/LoadFile.h>
#include <Protocol/DevicePath.h>
#include <Protocol/SimpleTextIn.h>
#include <Protocol/SimpleTextInEx.h>
#include <Protocol/SimpleTextOut.h>
#include <Protocol/SimpleNetwork.h>
#include <Protocol/FirmwareVolume2.h>
#include <Protocol/PciIo.h>
#include <Protocol/GraphicsOutput.h>
#include <Protocol/UsbIo.h>
#include <Protocol/DiskInfo.h>
#include <Protocol/NvmExpressPassthru.h>
#include <Protocol/IdeControllerInit.h>
#include <Protocol/BootLogo.h>
#include <Protocol/DriverHealth.h>
#include <Protocol/FormBrowser2.h>
#include <Protocol/VariableLock.h>
#include <Protocol/RamDisk.h>
#include <Protocol/DeferredImageLoad.h>
#include <Guid/MemoryTypeInformation.h>
#include <Guid/FileInfo.h>
#include <Guid/GlobalVariable.h>
#include <Guid/StatusCodeDataTypeVariable.h>
#include <Library/PrintLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/DxeServicesTableLib.h>
#include <Library/HobLib.h>
#include <Library/BaseLib.h>
#include <Library/DevicePathLib.h>
#include <Library/PerformanceLib.h>
#include <Library/PcdLib.h>
#include <Library/PeCoffGetEntryPointLib.h>
#include <Library/UefiBootManagerLib.h>
#include <Library/DxeServicesLib.h>
#include <Library/ReportStatusCodeLib.h>
#include <Library/CapsuleLib.h>
#include <Library/PerformanceLib.h>
#include <Library/HiiLib.h>
#if !defined (EFI_REMOVABLE_MEDIA_FILE_NAME)
#if defined (MDE_CPU_EBC)
//
// Uefi specification only defines the default boot file name for IA32, X64
// and IPF processor, so need define boot file name for EBC architecture here.
//
#define EFI_REMOVABLE_MEDIA_FILE_NAME L"\\EFI\\BOOT\\BOOTEBC.EFI"
#else
#error "Can not determine the default boot file name for unknown processor type!"
#endif
#endif
typedef enum {
BmAcpiFloppyBoot,
BmHardwareDeviceBoot,
BmMessageAtapiBoot,
BmMessageSataBoot,
BmMessageUsbBoot,
BmMessageScsiBoot,
BmMiscBoot
} BM_BOOT_TYPE;
typedef
CHAR16 *
(* BM_GET_BOOT_DESCRIPTION) (
IN EFI_HANDLE Handle
);
//
// PlatformRecovery#### is the load option with the longest name
//
#define BM_OPTION_NAME_LEN sizeof ("PlatformRecovery####")
extern CHAR16 *mBmLoadOptionName[];
//
// Maximum number of reconnect retry to repair controller; it is to limit the
// number of recursive call of BmRepairAllControllers.
//
#define MAX_RECONNECT_REPAIR 10
/**
Visitor function to be called by BmForEachVariable for each variable
in variable storage.
@param Name Variable name.
@param Guid Variable GUID.
@param Context The same context passed to BmForEachVariable.
**/
typedef
VOID
(*BM_VARIABLE_VISITOR) (
CHAR16 *Name,
EFI_GUID *Guid,
VOID *Context
);
/**
Call Visitor function for each variable in variable storage.
@param Visitor Visitor function.
@param Context The context passed to Visitor function.
**/
VOID
BmForEachVariable (
BM_VARIABLE_VISITOR Visitor,
VOID *Context
);
#define BM_BOOT_DESCRIPTION_ENTRY_SIGNATURE SIGNATURE_32 ('b', 'm', 'd', 'h')
typedef struct {
UINT32 Signature;
LIST_ENTRY Link;
EFI_BOOT_MANAGER_BOOT_DESCRIPTION_HANDLER Handler;
} BM_BOOT_DESCRIPTION_ENTRY;
/**
Repair all the controllers according to the Driver Health status queried.
@param ReconnectRepairCount To record the number of recursive call of
this function itself.
**/
VOID
BmRepairAllControllers (
UINTN ReconnectRepairCount
);
#define BM_HOTKEY_SIGNATURE SIGNATURE_32 ('b', 'm', 'h', 'k')
typedef struct {
UINT32 Signature;
LIST_ENTRY Link;
BOOLEAN IsContinue;
UINT16 BootOption;
UINT8 CodeCount;
UINT8 WaitingKey;
EFI_KEY_DATA KeyData[3];
} BM_HOTKEY;
#define BM_HOTKEY_FROM_LINK(a) CR (a, BM_HOTKEY, Link, BM_HOTKEY_SIGNATURE)
/**
Get the Option Number that wasn't used.
@param LoadOptionType Load option type.
@param FreeOptionNumber To receive the minimal free option number.
@retval EFI_SUCCESS The option number is found
@retval EFI_OUT_OF_RESOURCES There is no free option number that can be used.
@retval EFI_INVALID_PARAMETER FreeOptionNumber is NULL
**/
EFI_STATUS
BmGetFreeOptionNumber (
IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE LoadOptionType,
OUT UINT16 *FreeOptionNumber
);
/**
This routine adjust the memory information for different memory type and
save them into the variables for next boot. It resets the system when
memory information is updated and the current boot option belongs to
boot category instead of application category. It doesn't count the
reserved memory occupied by RAM Disk.
@param Boot TRUE if current boot option belongs to boot
category instead of application category.
**/
VOID
BmSetMemoryTypeInformationVariable (
IN BOOLEAN Boot
);
/**
Check whether there is a instance in BlockIoDevicePath, which contain multi device path
instances, has the same partition node with HardDriveDevicePath device path
@param BlockIoDevicePath Multi device path instances which need to check
@param HardDriveDevicePath A device path which starts with a hard drive media
device path.
@retval TRUE There is a matched device path instance.
@retval FALSE There is no matched device path instance.
**/
BOOLEAN
BmMatchPartitionDevicePathNode (
IN EFI_DEVICE_PATH_PROTOCOL *BlockIoDevicePath,
IN HARDDRIVE_DEVICE_PATH *HardDriveDevicePath
);
/**
Connect the specific Usb device which match the short form device path.
@param DevicePath A short-form device path that starts with the first
element being a USB WWID or a USB Class device
path
@return EFI_INVALID_PARAMETER DevicePath is NULL pointer.
DevicePath is not a USB device path.
@return EFI_SUCCESS Success to connect USB device
@return EFI_NOT_FOUND Fail to find handle for USB controller to connect.
**/
EFI_STATUS
BmConnectUsbShortFormDevicePath (
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
);
/**
Stop the hotkey processing.
@param Event Event pointer related to hotkey service.
@param Context Context pass to this function.
**/
VOID
EFIAPI
BmStopHotkeyService (
IN EFI_EVENT Event,
IN VOID *Context
);
/**
Set the variable and report the error through status code upon failure.
@param VariableName A Null-terminated string that is the name of the vendor's variable.
Each VariableName is unique for each VendorGuid. VariableName must
contain 1 or more characters. If VariableName is an empty string,
then EFI_INVALID_PARAMETER is returned.
@param VendorGuid A unique identifier for the vendor.
@param Attributes Attributes bitmask to set for the variable.
@param DataSize The size in bytes of the Data buffer. Unless the EFI_VARIABLE_APPEND_WRITE,
or EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS attribute is set, a size of zero
causes the variable to be deleted. When the EFI_VARIABLE_APPEND_WRITE attribute is
set, then a SetVariable() call with a DataSize of zero will not cause any change to
the variable value (the timestamp associated with the variable may be updated however
even if no new data value is provided,see the description of the
EFI_VARIABLE_AUTHENTICATION_2 descriptor below. In this case the DataSize will not
be zero since the EFI_VARIABLE_AUTHENTICATION_2 descriptor will be populated).
@param Data The contents for the variable.
@retval EFI_SUCCESS The firmware has successfully stored the variable and its data as
defined by the Attributes.
@retval EFI_INVALID_PARAMETER An invalid combination of attribute bits, name, and GUID was supplied, or the
DataSize exceeds the maximum allowed.
@retval EFI_INVALID_PARAMETER VariableName is an empty string.
@retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
@retval EFI_DEVICE_ERROR The variable could not be retrieved due to a hardware error.
@retval EFI_WRITE_PROTECTED The variable in question is read-only.
@retval EFI_WRITE_PROTECTED The variable in question cannot be deleted.
@retval EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACESS
being set, but the AuthInfo does NOT pass the validation check carried out by the firmware.
@retval EFI_NOT_FOUND The variable trying to be updated or deleted was not found.
**/
EFI_STATUS
BmSetVariableAndReportStatusCodeOnError (
IN CHAR16 *VariableName,
IN EFI_GUID *VendorGuid,
IN UINT32 Attributes,
IN UINTN DataSize,
IN VOID *Data
);
/**
Function compares a device path data structure to that of all the nodes of a
second device path instance.
@param Multi A pointer to a multi-instance device path data
structure.
@param Single A pointer to a single-instance device path data
structure.
@retval TRUE If the Single device path is contained within Multi device path.
@retval FALSE The Single device path is not match within Multi device path.
**/
BOOLEAN
BmMatchDevicePaths (
IN EFI_DEVICE_PATH_PROTOCOL *Multi,
IN EFI_DEVICE_PATH_PROTOCOL *Single
);
/**
Delete the instance in Multi which matches partly with Single instance
@param Multi A pointer to a multi-instance device path data
structure.
@param Single A pointer to a single-instance device path data
structure.
@return This function will remove the device path instances in Multi which partly
match with the Single, and return the result device path. If there is no
remaining device path as a result, this function will return NULL.
**/
EFI_DEVICE_PATH_PROTOCOL *
BmDelPartMatchInstance (
IN EFI_DEVICE_PATH_PROTOCOL *Multi,
IN EFI_DEVICE_PATH_PROTOCOL *Single
);
/**
Print the device path info.
@param DevicePath The device path need to print.
**/
VOID
BmPrintDp (
EFI_DEVICE_PATH_PROTOCOL *DevicePath
);
/**
Convert a single character to number.
It assumes the input Char is in the scope of L'0' ~ L'9' and L'A' ~ L'F'
@param Char The input char which need to convert to int.
@return The converted 8-bit number or (UINTN) -1 if conversion failed.
**/
UINTN
BmCharToUint (
IN CHAR16 Char
);
/**
Return the boot description for the controller.
@param Handle Controller handle.
@return The description string.
**/
CHAR16 *
BmGetBootDescription (
IN EFI_HANDLE Handle
);
/**
Enumerate all boot option descriptions and append " 2"/" 3"/... to make
unique description.
@param BootOptions Array of boot options.
@param BootOptionCount Count of boot options.
**/
VOID
BmMakeBootOptionDescriptionUnique (
EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions,
UINTN BootOptionCount
);
/**
Get the file buffer from the specified Load File instance.
@param LoadFileHandle The specified Load File instance.
@param FilePath The file path which will pass to LoadFile().
@return The full device path pointing to the load option buffer.
**/
EFI_DEVICE_PATH_PROTOCOL *
BmExpandLoadFile (
IN EFI_HANDLE LoadFileHandle,
IN EFI_DEVICE_PATH_PROTOCOL *FilePath
);
/**
Return the RAM Disk device path created by LoadFile.
@param FilePath The source file path.
@return Callee-to-free RAM Disk device path
**/
EFI_DEVICE_PATH_PROTOCOL *
BmGetRamDiskDevicePath (
IN EFI_DEVICE_PATH_PROTOCOL *FilePath
);
/**
Destroy the RAM Disk.
The destroy operation includes to call RamDisk.Unregister to
unregister the RAM DISK from RAM DISK driver, free the memory
allocated for the RAM Disk.
@param RamDiskDevicePath RAM Disk device path.
**/
VOID
BmDestroyRamDisk (
IN EFI_DEVICE_PATH_PROTOCOL *RamDiskDevicePath
);
/**
Get the next possible full path pointing to the load option.
@param FilePath The device path pointing to a load option.
It could be a short-form device path.
@param FullPath The full path returned by the routine in last call.
Set to NULL in first call.
@return The next possible full path pointing to the load option.
Caller is responsible to free the memory.
**/
EFI_DEVICE_PATH_PROTOCOL *
BmGetNextLoadOptionDevicePath (
IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
IN EFI_DEVICE_PATH_PROTOCOL *FullPath
);
/**
Return the next matched load option buffer.
The routine keeps calling BmGetNextLoadOptionDevicePath() until a valid
load option is read.
@param Type The load option type.
It's used to check whether the load option is valid.
When it's LoadOptionTypeMax, the routine only guarantees
the load option is a valid PE image but doesn't guarantee
the PE's subsystem type is valid.
@param FilePath The device path pointing to a load option.
It could be a short-form device path.
@param FullPath Return the next full device path of the load option after
short-form device path expanding.
Caller is responsible to free it.
NULL to return the first matched full device path.
@param FileSize Return the load option size.
@return The load option buffer. Caller is responsible to free the memory.
**/
VOID *
BmGetNextLoadOptionBuffer (
IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE Type,
IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
OUT EFI_DEVICE_PATH_PROTOCOL **FullPath,
OUT UINTN *FileSize
);
#endif // _INTERNAL_BM_H_

View File

@ -0,0 +1,276 @@
#include "Bds.h"
#include "FrontPage.h"
#include <IndustryStandard/Acpi.h>
#include <IndustryStandard/Bmp.h>
#include <Protocol/FirmwareVolume2.h>
#include <Protocol/SimpleFileSystem.h>
/** RSDP (Root System Description Pointer) */
typedef struct {
CHAR8 signature[8];
UINT8 checksum;
CHAR8 oem_id[6];
UINT8 revision;
UINT32 rsdt_address;
UINT32 length;
UINT64 xsdt_address;
UINT8 extended_checksum;
UINT8 reserved[3];
} ACPI_20_RSDP;
/** SDT (System Description Table) entry header */
typedef struct {
CHAR8 signature[4];
UINT32 length;
UINT8 revision;
UINT8 checksum;
CHAR8 oem_id[6];
CHAR8 oem_table_id[8];
UINT32 oem_revision;
UINT32 asl_compiler_id;
UINT32 asl_compiler_revision;
} ACPI_SDT_HEADER;
/** BGRT structure */
typedef struct {
ACPI_SDT_HEADER header;
UINT16 version;
UINT8 status;
UINT8 image_type;
UINT64 image_address;
UINT32 image_offset_x;
UINT32 image_offset_y;
} ACPI_BGRT;
EFI_STATUS
EFIAPI
LoadBmp(
OUT EFI_PHYSICAL_ADDRESS *BmpAddress,
OUT UINT32 *BmpSize
)
{
EFI_STATUS Status;
UINTN FvProtocolCount;
EFI_HANDLE *FvHandles;
EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
UINTN Index;
UINT32 AuthenticationStatus;
UINT8 *Buffer;
UINTN BmpBufferSize;
Buffer = 0;
FvHandles = NULL;
Status = gBS->LocateHandleBuffer (
ByProtocol,
&gEfiFirmwareVolume2ProtocolGuid,
NULL,
&FvProtocolCount,
&FvHandles
);
if (!EFI_ERROR (Status)) {
for (Index = 0; Index < FvProtocolCount; Index++) {
Status = gBS->HandleProtocol (
FvHandles[Index],
&gEfiFirmwareVolume2ProtocolGuid,
(VOID **) &Fv
);
BmpBufferSize = 0;
Status = Fv->ReadSection (
Fv,
(EFI_GUID *)PcdGetPtr(PcdLogoFile),
EFI_SECTION_RAW,
0,
(void **)&Buffer,
&BmpBufferSize,
&AuthenticationStatus
);
if (!EFI_ERROR (Status)) {
*BmpAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Buffer;
*BmpSize = (UINT32)BmpBufferSize;
Status = EFI_SUCCESS;
break;
}
}
} else {
Status = EFI_NOT_FOUND;
}
if (FvHandles != NULL) {
gBS->FreePool (FvHandles);
FvHandles = NULL;
}
return Status;
}
UINT8 SumBytes(const UINT8* arr, UINTN size) {
UINT8 sum = 0;
UINTN i;
for (i = 0; i < size; ++i) {
sum += arr[i];
}
return sum;
}
int VerifyAcpiRsdp2Checksums(const void* data) {
const UINT8* arr = data;
UINTN size = *(const UINT32*)&arr[20];
return SumBytes(arr, 20) == 0 && SumBytes(arr, size) == 0;
}
void SetAcpiRsdp2Checksums(void* data) {
UINT8* arr = data;
UINTN size = *(const UINT32*)&arr[20];
arr[9] = 0;
arr[32] = 0;
arr[9] = -SumBytes(arr, 20);
arr[32] = -SumBytes(arr, size);
}
int VerifyAcpiSdtChecksum(const void* data) {
const UINT8* arr = data;
UINTN size = *(const UINT32*)&arr[4];
return SumBytes(arr, size) == 0;
}
void SetAcpiSdtChecksum(void* data) {
UINT8* arr = data;
UINTN size = *(const UINT32*)&arr[4];
arr[9] = 0;
arr[9] = -SumBytes(arr, size);
}
const CHAR16* TmpStr(CHAR8 *src, int length) {
static CHAR16 arr[4][16];
static int j;
CHAR16* dest = arr[j = (j+1) % 4];
int i;
for (i = 0; i < length && i < 16-1 && src[i]; ++i) {
dest[i] = src[i];
}
dest[i] = 0;
return dest;
}
static UINT32 min(UINT32 first, UINT32 second){
if (first < second)
return first;
return second;
}
ACPI_SDT_HEADER* CreateXsdt(ACPI_SDT_HEADER* xsdt0, UINTN entries) {
ACPI_SDT_HEADER* xsdt = 0;
UINT32 xsdt_len = (UINT32)(sizeof(ACPI_SDT_HEADER) + entries * sizeof(UINT64));
gBS->AllocatePool(EfiACPIReclaimMemory, xsdt_len, (void**)&xsdt);
if (!xsdt) {
DEBUG ((EFI_D_INFO, "HackBGRT: Failed to allocate memory for XSDT.\n"));
return 0;
}
ZeroMem(xsdt, xsdt_len);
CopyMem(xsdt, xsdt0, min(xsdt0->length, xsdt_len));
xsdt->length = xsdt_len;
SetAcpiSdtChecksum(xsdt);
return xsdt;
}
static ACPI_BGRT* HandleAcpiTables(ACPI_BGRT* bgrt) {
int i;
for (i = 0; i < gST->NumberOfTableEntries; i++) {
EFI_GUID* vendor_guid = &gST->ConfigurationTable[i].VendorGuid;
ACPI_20_RSDP *rsdp;
ACPI_SDT_HEADER *xsdt;
UINT64 *entry_arr;
UINT32 entry_arr_length;
if (!CompareGuid(vendor_guid, &gEfiAcpiTableGuid) && !CompareGuid(vendor_guid, &gEfiAcpi20TableGuid)) {
continue;
}
rsdp = (ACPI_20_RSDP *) gST->ConfigurationTable[i].VendorTable;
if (CompareMem(rsdp->signature, "RSD PTR ", 8) != 0 || rsdp->revision < 2 || !VerifyAcpiRsdp2Checksums(rsdp)) {
continue;
}
DEBUG ((EFI_D_INFO, "RSDP: revision = %d, OEM ID = %s\n", rsdp->revision, TmpStr(rsdp->oem_id, 6)));
xsdt = (ACPI_SDT_HEADER *) (UINTN) rsdp->xsdt_address;
if (!xsdt || CompareMem(xsdt->signature, "XSDT", 4) != 0 || !VerifyAcpiSdtChecksum(xsdt)) {
DEBUG ((EFI_D_INFO, "* XSDT: missing or invalid\n"));
continue;
}
entry_arr = (UINT64*)&xsdt[1];
entry_arr_length = (xsdt->length - sizeof(*xsdt)) / sizeof(UINT64);
DEBUG ((EFI_D_INFO, "* XSDT: OEM ID = %s, entry count = %d\n", TmpStr(xsdt->oem_id, 6), entry_arr_length));
if (bgrt) {
DEBUG ((EFI_D_INFO, " - Adding missing BGRT.\n"));
xsdt = CreateXsdt(xsdt, entry_arr_length + 1);
entry_arr = (UINT64*)&xsdt[1];
entry_arr[entry_arr_length++] = (UINTN) bgrt;
rsdp->xsdt_address = (UINTN) xsdt;
SetAcpiRsdp2Checksums(rsdp);
}
SetAcpiSdtChecksum(xsdt);
}
return bgrt;
}
void AddBGRT(){
EFI_STATUS status;
ACPI_BGRT *bgrt;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
EFI_PHYSICAL_ADDRESS BmpAddress;
UINT32 BmpSize;
BMP_IMAGE_HEADER *BmpHeader;
const char data[0x38] =
"BGRT" "\x38\x00\x00\x00" "\x00" "\xd6" "INTEL " " EDK2"
"\x20\x17\x00\x00" "PTL " "\x02\x00\x00\x00"
"\x01\x00" "\x00" "\x00";
BmpAddress = 0;
DEBUG ((EFI_D_INFO, "HackBGRT Start\n"));
status = gBS->HandleProtocol (
gST->ConsoleOutHandle,
&gEfiGraphicsOutputProtocolGuid,
(VOID**)&GraphicsOutput
);
// Replace missing = allocate new.
gBS->AllocatePool(EfiACPIReclaimMemory, sizeof(*bgrt), (void**)&bgrt);
if (!bgrt) {
DEBUG ((EFI_D_INFO, "HackBGRT MEM ERR\n"));
return;
}
DEBUG ((EFI_D_INFO, "HackBGRT Load Bmp\n"));
status = LoadBmp(&BmpAddress, &BmpSize);
if (EFI_ERROR(status)){
DEBUG ((EFI_D_INFO, "HackBGRT BMP Load ERR\n"));
return;
}
DEBUG ((EFI_D_INFO, "HackBGRT Set Table; BMP Size: %d\n", BmpSize));
// Clear the BGRT.
CopyMem(bgrt, data, sizeof(data));
if (GraphicsOutput != NULL && GraphicsOutput->Mode != NULL && GraphicsOutput->Mode->Info != NULL)
{
BmpHeader = (BMP_IMAGE_HEADER *)BmpAddress;
bgrt->image_address = (UINTN)BmpAddress;
bgrt->image_offset_x = (GraphicsOutput->Mode->Info->HorizontalResolution - BmpHeader->PixelWidth) / 2;
bgrt->image_offset_y = ((GraphicsOutput->Mode->Info->VerticalResolution * 382) / 1000) -
(BmpHeader->PixelHeight / 2);
DEBUG ((EFI_D_INFO, "HackBGRT Set checksum\n"));
SetAcpiSdtChecksum(bgrt);
DEBUG ((EFI_D_INFO, "HackBGRT Add Table\n"));
HandleAcpiTables(bgrt);
} else {
DEBUG ((EFI_D_INFO, "HackBGRT no display connected, skip adding table\n"));
}
}

View File

@ -84,7 +84,7 @@
FrontPageStrings.uni FrontPageStrings.uni
FrontPage.c FrontPage.c
BdsEntry.c BdsEntry.c
AddBGRT.c
[Packages] [Packages]
MdePkg/MdePkg.dec MdePkg/MdePkg.dec
@ -136,6 +136,8 @@
## SOMETIMES_CONSUMES ## Variable:L"ConOutDev" # The device path of console out device ## SOMETIMES_CONSUMES ## Variable:L"ConOutDev" # The device path of console out device
## SOMETIMES_CONSUMES ## Variable:L"ErrOutDev" # The device path of error out device ## SOMETIMES_CONSUMES ## Variable:L"ErrOutDev" # The device path of error out device
## SOMETIMES_PRODUCES ## Variable:L"BootNext" # The number of next boot option ## SOMETIMES_PRODUCES ## Variable:L"BootNext" # The number of next boot option
gEfiAcpiTableGuid
gEfiAcpi20TableGuid
gEfiGlobalVariableGuid gEfiGlobalVariableGuid
gEfiFileSystemVolumeLabelInfoIdGuid ## SOMETIMES_CONSUMES ## UNDEFINED # Indicate the information type is volume gEfiFileSystemVolumeLabelInfoIdGuid ## SOMETIMES_CONSUMES ## UNDEFINED # Indicate the information type is volume
gEfiFileInfoGuid ## SOMETIMES_CONSUMES ## UNDEFINED # Indicate the information type is file gEfiFileInfoGuid ## SOMETIMES_CONSUMES ## UNDEFINED # Indicate the information type is file
@ -215,6 +217,7 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdErrorCodeSetVariable ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdErrorCodeSetVariable ## CONSUMES
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile
[Depex] [Depex]
TRUE TRUE

View File

@ -105,6 +105,8 @@ BdsBootDeviceSelect (
BOOLEAN BootNextExist; BOOLEAN BootNextExist;
LIST_ENTRY *LinkBootNext; LIST_ENTRY *LinkBootNext;
EFI_EVENT ConnectConInEvent; EFI_EVENT ConnectConInEvent;
UINTN Index;
EFI_INPUT_KEY Key;
// //
// Got the latest boot option // Got the latest boot option
@ -261,6 +263,8 @@ BdsBootDeviceSelect (
// //
BdsSetConsoleMode (FALSE); BdsSetConsoleMode (FALSE);
PlatformBdsPreBoot (BootOption);
// //
// All the driver options should have been processed since // All the driver options should have been processed since
// now boot will be performed. // now boot will be performed.
@ -273,6 +277,16 @@ BdsBootDeviceSelect (
BootOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_FAILED)); BootOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_FAILED));
PlatformBdsBootFail (BootOption, Status, ExitData, ExitDataSize); PlatformBdsBootFail (BootOption, Status, ExitData, ExitDataSize);
// Wait for key
gST->ConOut->OutputString (
gST->ConOut,
GetStringById (STRING_TOKEN (STR_ANY_KEY_CONTINUE))
);
Status = gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &Index);
ASSERT_EFI_ERROR (Status);
ASSERT (Index == 0);
while (!EFI_ERROR (gST->ConIn->ReadKeyStroke (gST->ConIn, &Key))) {}
// //
// Check the next boot option // Check the next boot option
// //

View File

@ -26,30 +26,36 @@ formset
name = BmmData, name = BmmData,
guid = BOOT_MAINT_FORMSET_GUID; guid = BOOT_MAINT_FORMSET_GUID;
form formid = FORM_BOOT_CHG_ID,
title = STRING_TOKEN(STR_FORM_BOOT_CHG_TITLE);
label FORM_BOOT_CHG_ID;
label LABEL_END;
endform;
form formid = FORM_MAIN_ID, form formid = FORM_MAIN_ID,
title = STRING_TOKEN(STR_FORM_MAIN_TITLE); title = STRING_TOKEN(STR_FORM_MAIN_TITLE);
goto FORM_BOOT_SETUP_ID, goto FORM_BOOT_CHG_ID,
prompt = STRING_TOKEN(STR_FORM_BOOT_SETUP_TITLE), prompt = STRING_TOKEN(STR_FORM_BOOT_CHG_TITLE),
help = STRING_TOKEN(STR_FORM_BOOT_SETUP_HELP), help = STRING_TOKEN(STR_FORM_BOOT_IMMEDIATE_HELP),
flags = INTERACTIVE, flags = INTERACTIVE,
key = FORM_BOOT_SETUP_ID; key = FORM_BOOT_CHG_ID;
subtitle text = STRING_TOKEN(STR_NULL_STRING); subtitle text = STRING_TOKEN(STR_NULL_STRING);
goto FORM_DRIVER_SETUP_ID, goto FORM_BOOT_ADD_ID,
prompt = STRING_TOKEN(STR_FORM_DRIVER_SETUP_TITLE), prompt = STRING_TOKEN(STR_FORM_BOOT_ADD_TITLE),
help = STRING_TOKEN(STR_FORM_DRIVER_SETUP_HELP), help = STRING_TOKEN(STR_FORM_BOOT_ADD_HELP),
flags = INTERACTIVE, flags = INTERACTIVE,
key = FORM_DRIVER_SETUP_ID; key = FORM_BOOT_ADD_ID;
subtitle text = STRING_TOKEN(STR_NULL_STRING); goto FORM_BOOT_DEL_ID,
prompt = STRING_TOKEN(STR_FORM_BOOT_DEL_TITLE),
goto FORM_CON_MAIN_ID, help = STRING_TOKEN(STR_FORM_BOOT_IMMEDIATE_HELP),
prompt = STRING_TOKEN(STR_FORM_CON_MAIN_TITLE), flags = INTERACTIVE,
help = STRING_TOKEN(STR_FORM_CON_MAIN_HELP), key = FORM_BOOT_DEL_ID;
flags = INTERACTIVE,
key = FORM_CON_MAIN_ID;
subtitle text = STRING_TOKEN(STR_NULL_STRING); subtitle text = STRING_TOKEN(STR_NULL_STRING);
@ -61,22 +67,6 @@ formset
subtitle text = STRING_TOKEN(STR_NULL_STRING); subtitle text = STRING_TOKEN(STR_NULL_STRING);
// label FORM_MAIN_ID;
goto FORM_BOOT_NEXT_ID,
prompt = STRING_TOKEN(STR_FORM_BOOT_NEXT_TITLE),
help = STRING_TOKEN(STR_FORM_BOOT_NEXT_HELP),
flags = INTERACTIVE,
key = FORM_BOOT_NEXT_ID;
goto FORM_TIME_OUT_ID,
prompt = STRING_TOKEN(STR_FORM_TIME_OUT_TITLE),
help = STRING_TOKEN(STR_FORM_TIME_OUT_HELP),
flags = INTERACTIVE,
key = FORM_TIME_OUT_ID;
subtitle text = STRING_TOKEN(STR_NULL_STRING);
text text
help = STRING_TOKEN(STR_RESET), help = STRING_TOKEN(STR_RESET),
text = STRING_TOKEN(STR_RESET), text = STRING_TOKEN(STR_RESET),
@ -85,72 +75,6 @@ formset
endform; endform;
form formid = FORM_BOOT_SETUP_ID,
title = STRING_TOKEN(STR_FORM_BOOT_SETUP_TITLE);
goto FORM_MAIN_ID,
prompt = STRING_TOKEN(STR_FORM_GOTO_MAIN),
help = STRING_TOKEN(STR_FORM_GOTO_MAIN);
//flags = INTERACTIVE,
//key = FORM_MAIN_ID;
goto FORM_BOOT_ADD_ID,
prompt = STRING_TOKEN(STR_FORM_BOOT_ADD_TITLE),
help = STRING_TOKEN(STR_FORM_BOOT_ADD_HELP),
flags = INTERACTIVE,
key = FORM_BOOT_ADD_ID;
goto FORM_BOOT_DEL_ID,
prompt = STRING_TOKEN(STR_FORM_BOOT_DEL_TITLE),
help = STRING_TOKEN(STR_FORM_BOOT_IMMEDIATE_HELP),
flags = INTERACTIVE,
key = FORM_BOOT_DEL_ID;
goto FORM_BOOT_CHG_ID,
prompt = STRING_TOKEN(STR_FORM_BOOT_CHG_TITLE),
help = STRING_TOKEN(STR_FORM_BOOT_IMMEDIATE_HELP),
flags = INTERACTIVE,
key = FORM_BOOT_CHG_ID;
subtitle text = STRING_TOKEN(STR_NULL_STRING);
//
// We will add "Select Legacy Boot Floppy Drive" and "Select Legacy Boot Hard Drive"
// here dynamically
//
label FORM_BOOT_LEGACY_DEVICE_ID;
label LABEL_END;
endform;
form formid = FORM_DRIVER_SETUP_ID,
title = STRING_TOKEN(STR_FORM_DRIVER_SETUP_TITLE);
goto FORM_MAIN_ID,
prompt = STRING_TOKEN(STR_FORM_GOTO_MAIN),
help = STRING_TOKEN(STR_FORM_GOTO_MAIN);
//help = STRING_TOKEN(STR_FORM_GOTO_MAIN),
//flags = INTERACTIVE,
//key = FORM_MAIN_ID;
goto FORM_DRV_ADD_ID,
prompt = STRING_TOKEN(STR_FORM_DRV_ADD_TITLE),
help = STRING_TOKEN(STR_FORM_DRV_ADD_HELP),
flags = INTERACTIVE,
key = FORM_DRV_ADD_ID;
goto FORM_DRV_DEL_ID,
prompt = STRING_TOKEN(STR_FORM_DRV_DEL_TITLE),
help = STRING_TOKEN(STR_FORM_NEXT_BOOT_HELP),
flags = INTERACTIVE,
key = FORM_DRV_DEL_ID;
goto FORM_DRV_CHG_ID,
prompt = STRING_TOKEN(STR_FORM_DRV_CHG_TITLE),
help = STRING_TOKEN(STR_FORM_NEXT_BOOT_HELP),
flags = INTERACTIVE,
key = FORM_DRV_CHG_ID;
endform;
form formid = FORM_BOOT_DEL_ID, form formid = FORM_BOOT_DEL_ID,
title = STRING_TOKEN(STR_FORM_BOOT_DEL_TITLE); title = STRING_TOKEN(STR_FORM_BOOT_DEL_TITLE);
@ -158,45 +82,6 @@ formset
label LABEL_END; label LABEL_END;
endform; endform;
form formid = FORM_BOOT_CHG_ID,
title = STRING_TOKEN(STR_FORM_BOOT_CHG_TITLE);
label FORM_BOOT_CHG_ID;
label LABEL_END;
endform;
form formid = FORM_BOOT_NEXT_ID,
title = STRING_TOKEN(STR_FORM_BOOT_NEXT_TITLE);
label FORM_BOOT_NEXT_ID;
label LABEL_END;
endform;
form formid = FORM_TIME_OUT_ID,
title = STRING_TOKEN(STR_FORM_TIME_OUT_TITLE);
label FORM_TIME_OUT_ID;
label LABEL_END;
endform;
form formid = FORM_DRV_ADD_ID,
title = STRING_TOKEN(STR_FORM_DRV_ADD_TITLE);
goto FORM_MAIN_ID,
prompt = STRING_TOKEN(STR_FORM_GOTO_MAIN),
help = STRING_TOKEN(STR_FORM_GOTO_MAIN);
//flags = INTERACTIVE,
//key = FORM_MAIN_ID;
goto FORM_DRV_ADD_FILE_ID,
prompt = STRING_TOKEN(STR_FORM_DRV_ADD_FILE_TITLE),
help = STRING_TOKEN(STR_FORM_DRV_ADD_FILE_TITLE),
flags = INTERACTIVE,
key = FORM_DRV_ADD_FILE_ID;
endform;
form formid = FORM_DRV_DEL_ID, form formid = FORM_DRV_DEL_ID,
title = STRING_TOKEN(STR_FORM_DRV_DEL_TITLE); title = STRING_TOKEN(STR_FORM_DRV_DEL_TITLE);
@ -205,74 +90,8 @@ formset
endform; endform;
form formid = FORM_DRV_CHG_ID,
title = STRING_TOKEN(STR_FORM_DRV_CHG_TITLE);
label FORM_DRV_CHG_ID;
label LABEL_END;
endform;
form formid = FORM_CON_MAIN_ID,
title = STRING_TOKEN(STR_FORM_CON_MAIN_TITLE);
goto FORM_MAIN_ID,
prompt = STRING_TOKEN(STR_FORM_GOTO_MAIN),
help = STRING_TOKEN(STR_FORM_GOTO_MAIN);
//flags = INTERACTIVE,
//key = FORM_MAIN_ID;
goto FORM_CON_IN_ID,
prompt = STRING_TOKEN(STR_FORM_CON_IN_TITLE),
help = STRING_TOKEN(STR_FORM_CON_IN_HELP),
flags = INTERACTIVE,
key = FORM_CON_IN_ID;
goto FORM_CON_OUT_ID,
prompt = STRING_TOKEN(STR_FORM_CON_OUT_TITLE),
help = STRING_TOKEN(STR_FORM_CON_OUT_HELP),
flags = INTERACTIVE,
key = FORM_CON_OUT_ID;
goto FORM_CON_ERR_ID,
prompt = STRING_TOKEN(STR_FORM_STD_ERR_TITLE),
help = STRING_TOKEN(STR_FORM_STD_ERR_HELP),
flags = INTERACTIVE,
key = FORM_CON_ERR_ID;
goto FORM_CON_MODE_ID,
prompt = STRING_TOKEN(STR_FORM_MODE_TITLE),
help = STRING_TOKEN(STR_FORM_MODE_HELP),
flags = INTERACTIVE,
key = FORM_CON_MODE_ID;
goto FORM_CON_COM_ID,
prompt = STRING_TOKEN(STR_FORM_COM_TITLE),
help = STRING_TOKEN(STR_FORM_COM_HELP),
flags = INTERACTIVE,
key = FORM_CON_COM_ID;
endform;
form formid = FORM_CON_MODE_ID,
title = STRING_TOKEN(STR_FORM_MODE_TITLE);
label FORM_CON_MODE_ID;
label LABEL_END;
endform;
form formid = FORM_CON_COM_ID,
title = STRING_TOKEN(STR_FORM_COM_TITLE);
label FORM_CON_COM_ID;
label LABEL_END;
endform;
form formid = FORM_CON_COM_SETUP_ID,
title = STRING_TOKEN(STR_CON_COM_SETUP);
label FORM_CON_COM_SETUP_ID;
label LABEL_END;
endform;
form formid = FORM_FILE_SEEK_ID, form formid = FORM_FILE_SEEK_ID,
title = STRING_TOKEN(STR_FORM_BOOT_ADD_TITLE); title = STRING_TOKEN(STR_FORM_BOOT_ADD_TITLE);
@ -288,28 +107,7 @@ formset
label LABEL_END; label LABEL_END;
endform; endform;
form formid = FORM_DRV_ADD_HANDLE_ID,
title = STRING_TOKEN(STR_FORM_DRV_ADD_HANDLE_TITLE);
label FORM_DRV_ADD_HANDLE_ID;
label LABEL_END;
endform;
form formid = FORM_DRV_ADD_HANDLE_DESC_ID,
title = STRING_TOKEN(STR_FORM_DRV_ADD_DESC_TITLE);
label FORM_DRV_ADD_HANDLE_DESC_ID;
label LABEL_END;
endform;
form formid = FORM_CON_IN_ID,
title = STRING_TOKEN(STR_FORM_CON_IN_TITLE);
label FORM_CON_IN_ID;
label LABEL_END;
endform;
form formid = FORM_CON_OUT_ID, form formid = FORM_CON_OUT_ID,
title = STRING_TOKEN(STR_FORM_CON_OUT_TITLE); title = STRING_TOKEN(STR_FORM_CON_OUT_TITLE);

View File

@ -22,8 +22,8 @@
#language fr-FR " " #language fr-FR " "
#string STR_NONE #language en-US "NONE" #string STR_NONE #language en-US "NONE"
#language fr-FR "NONE" #language fr-FR "NONE"
#string STR_FORM_MAIN_TITLE #language en-US "Boot Maintenance Manager" #string STR_FORM_MAIN_TITLE #language en-US "Boot Manager"
#language fr-FR "Boot Maintenance Manager" #language fr-FR "Boot Manager"
#string STR_FORM_BOOT_SETUP_TITLE #language en-US "Boot Options" #string STR_FORM_BOOT_SETUP_TITLE #language en-US "Boot Options"
#language fr-FR "Boot Options" #language fr-FR "Boot Options"
#string STR_FORM_BOOT_SETUP_HELP #language en-US "Modify system boot options" #string STR_FORM_BOOT_SETUP_HELP #language en-US "Modify system boot options"
@ -232,7 +232,7 @@
#language fr-FR "Boot system from a file or device" #language fr-FR "Boot system from a file or device"
#string STR_OPTIONAL_DATA #language en-US "Input Optional Data" #string STR_OPTIONAL_DATA #language en-US "Input Optional Data"
#language fr-FR "Input Optional Data" #language fr-FR "Input Optional Data"
#string STR_CHANGE_ORDER #language en-US "Change the order" #string STR_CHANGE_ORDER #language en-US "Change Boot Order"
#language fr-FR "Change the order" #language fr-FR "Change the order"
#string STR_BOOT_LEGACY #language en-US "Boot Legacy System" #string STR_BOOT_LEGACY #language en-US "Boot Legacy System"
#language fr-FR "Boot Legacy System" #language fr-FR "Boot Legacy System"

View File

@ -1483,7 +1483,8 @@ FormSetDispatcher (
EFI_BROWSER_ACTION_REQUEST ActionRequest; EFI_BROWSER_ACTION_REQUEST ActionRequest;
while (TRUE) { while (TRUE) {
UpdatePageId (CallbackData, FORM_MAIN_ID); UpdatePageId (CallbackData, FORM_BOOT_CHG_ID);
UpdatePageBody (FORM_BOOT_CHG_ID, CallbackData);
ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE; ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;
Status = gFormBrowser2->SendForm ( Status = gFormBrowser2->SendForm (

View File

@ -548,6 +548,7 @@ UpdateOrderPage (
EFI_QUESTION_ID QuestionId; EFI_QUESTION_ID QuestionId;
UINT16 VarOffset; UINT16 VarOffset;
CallbackData->BmmAskSaveOrNot = TRUE;
UpdatePageStart (CallbackData); UpdatePageStart (CallbackData);

View File

@ -203,6 +203,7 @@ CallBootManager (
CHAR16 *ExitData; CHAR16 *ExitData;
UINTN ExitDataSize; UINTN ExitDataSize;
EFI_STRING_ID Token; EFI_STRING_ID Token;
UINTN Index;
EFI_INPUT_KEY Key; EFI_INPUT_KEY Key;
CHAR16 *HelpString; CHAR16 *HelpString;
UINTN HelpSize; UINTN HelpSize;
@ -379,6 +380,8 @@ CallBootManager (
// //
BdsSetConsoleMode (FALSE); BdsSetConsoleMode (FALSE);
PlatformBdsPreBoot (gOption);
// //
// parse the selected option // parse the selected option
// //
@ -390,10 +393,15 @@ CallBootManager (
} else { } else {
gOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_FAILED)); gOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_FAILED));
PlatformBdsBootFail (gOption, Status, ExitData, ExitDataSize); PlatformBdsBootFail (gOption, Status, ExitData, ExitDataSize);
// Wait for key
gST->ConOut->OutputString ( gST->ConOut->OutputString (
gST->ConOut, gST->ConOut,
GetStringById (STRING_TOKEN (STR_ANY_KEY_CONTINUE)) GetStringById (STRING_TOKEN (STR_ANY_KEY_CONTINUE))
); );
gST->ConIn->ReadKeyStroke (gST->ConIn, &Key); Status = gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &Index);
ASSERT_EFI_ERROR (Status);
ASSERT (Index == 0);
while (!EFI_ERROR (gST->ConIn->ReadKeyStroke (gST->ConIn, &Key))) {}
} }
} }

View File

@ -18,7 +18,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "Bds.h" #include "Bds.h"
#include "FrontPage.h" #include "FrontPage.h"
#define BOOT_MANAGER_FORM_ID 0x1000 #define BOOT_MANAGER_FORM_ID 0x1030
#define LABEL_BOOT_OPTION 0x00 #define LABEL_BOOT_OPTION 0x00
#define LABEL_BOOT_OPTION_END 0x01 #define LABEL_BOOT_OPTION_END 0x01

View File

@ -18,15 +18,15 @@
#langdef en-US "English" #langdef en-US "English"
#langdef fr-FR "Français" #langdef fr-FR "Français"
#string STR_BM_BANNER #language en-US "Boot Manager" #string STR_BM_BANNER #language en-US "One Time Boot"
#language fr-FR "Boot Manager" #language fr-FR "Boot Menu"
#string STR_HELP_FOOTER #language en-US "↑ and ↓ to change option, ENTER to select an option, ESC to exit" #string STR_HELP_FOOTER #language en-US "↑ and ↓ to change option, ENTER to select an option, ESC to exit"
#language fr-FR "↑ pour ↓ changer l'option, ENTRER choisir une option, ESC pour sortir" #language fr-FR "↑ pour ↓ changer l'option, ENTRER choisir une option, ESC pour sortir"
#string STR_AND #language en-US " and " #string STR_AND #language en-US " and "
#language fr-FR " et " #language fr-FR " et "
#string STR_BOOT_OPTION_BANNER #language en-US "Boot Option Menu" #string STR_BOOT_OPTION_BANNER #language en-US "Select a Boot Device"
#language fr-FR "le Menu d'Option de Botte" #language fr-FR "le Menu d'Option de Botte"
#string STR_ANY_KEY_CONTINUE #language en-US "Press any key to continue..." #string STR_ANY_KEY_CONTINUE #language en-US "Press any key to continue...\n"
#language fr-FR "Appuie n'importe quelle pour continuer..." #language fr-FR "Appuie n'importe quelle pour continuer..."
#string STR_LAST_STRING #language en-US "" #string STR_LAST_STRING #language en-US ""
#language fr-FR "" #language fr-FR ""

View File

@ -15,7 +15,7 @@
#include <Guid/BdsHii.h> #include <Guid/BdsHii.h>
#define BOOT_MANAGER_FORM_ID 0x1000 #define BOOT_MANAGER_FORM_ID 0x1030
#define LABEL_BOOT_OPTION 0x00 #define LABEL_BOOT_OPTION 0x00
#define LABEL_BOOT_OPTION_END 0x01 #define LABEL_BOOT_OPTION_END 0x01
@ -32,9 +32,9 @@ formset
form formid = BOOT_MANAGER_FORM_ID, form formid = BOOT_MANAGER_FORM_ID,
title = STRING_TOKEN(STR_BM_BANNER); title = STRING_TOKEN(STR_BM_BANNER);
subtitle text = STRING_TOKEN(STR_LAST_STRING); // subtitle text = STRING_TOKEN(STR_LAST_STRING);
subtitle text = STRING_TOKEN(STR_BOOT_OPTION_BANNER); // subtitle text = STRING_TOKEN(STR_BOOT_OPTION_BANNER);
subtitle text = STRING_TOKEN(STR_LAST_STRING); // subtitle text = STRING_TOKEN(STR_LAST_STRING);
// //
// This is where we will dynamically add choices for the Boot Manager // This is where we will dynamically add choices for the Boot Manager
@ -42,8 +42,6 @@ formset
label LABEL_BOOT_OPTION; label LABEL_BOOT_OPTION;
label LABEL_BOOT_OPTION_END; label LABEL_BOOT_OPTION_END;
subtitle text = STRING_TOKEN(STR_LAST_STRING);
subtitle text = STRING_TOKEN(STR_HELP_FOOTER);
endform; endform;

View File

@ -74,6 +74,8 @@ HII_VENDOR_DEVICE_PATH mFrontPageHiiVendorDevicePath = {
} }
}; };
void AddBGRT();
/** /**
This function allows a caller to extract the current configuration for one This function allows a caller to extract the current configuration for one
or more named elements from the target driver. or more named elements from the target driver.
@ -688,6 +690,201 @@ GetOptionalStringByIndex (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
UINT16 SmbiosTableLength (SMBIOS_STRUCTURE_POINTER SmbiosTableN)
{
CHAR8 *AChar;
UINT16 Length;
AChar = (CHAR8 *)(SmbiosTableN.Raw + SmbiosTableN.Hdr->Length);
while ((*AChar != 0) || (*(AChar + 1) != 0)) {
AChar ++; //stop at 00 - first 0
}
Length = (UINT16)((UINTN)AChar - (UINTN)SmbiosTableN.Raw + 2); //length includes 00
return Length;
}
SMBIOS_STRUCTURE_POINTER GetSmbiosTableFromType (
SMBIOS_TABLE_ENTRY_POINT *SmbiosPoint, UINT8 SmbiosType, UINTN IndexTable)
{
SMBIOS_STRUCTURE_POINTER SmbiosTableN;
UINTN SmbiosTypeIndex;
SmbiosTypeIndex = 0;
SmbiosTableN.Raw = (UINT8 *)((UINTN)SmbiosPoint->TableAddress);
if (SmbiosTableN.Raw == NULL) {
return SmbiosTableN;
}
while ((SmbiosTypeIndex != IndexTable) || (SmbiosTableN.Hdr->Type != SmbiosType)) {
if (SmbiosTableN.Hdr->Type == SMBIOS_TYPE_END_OF_TABLE) {
SmbiosTableN.Raw = NULL;
return SmbiosTableN;
}
if (SmbiosTableN.Hdr->Type == SmbiosType) {
SmbiosTypeIndex++;
}
SmbiosTableN.Raw = (UINT8 *)(SmbiosTableN.Raw + SmbiosTableLength (SmbiosTableN));
}
return SmbiosTableN;
}
VOID
GetDeviceNameFromProduct (
IN CHAR16 *Product,
OUT CHAR16 **DeviceName
)
{
if (!StrCmp(Product, L"Akali")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Acer Chromebook 13");
} else if (!StrCmp(Product, L"Akali 360")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Acer Chromebook Spin 13");
} else if (!StrCmp(Product, L"Atlas")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Google Pixelbook Go 2019");
} else if (!StrCmp(Product, L"Auron")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Acer Chromebook C740/C910");
} else if (!StrCmp(Product, L"Auron_Paine")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Acer Chromebook 11 C740");
} else if (!StrCmp(Product, L"Auron_Yuna")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Acer Chromebook 15 C910");
} else if (!StrCmp(Product, L"Banjo")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Acer Chromebook 15 CB3-571");
} else if (!StrCmp(Product, L"Banon")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Acer Chromebook 15 CB5-532");
} else if (!StrCmp(Product, L"Bard")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Acer Chromebook 715");
} else if (!StrCmp(Product, L"Buddy")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Acer Chromebase 24");
} else if (!StrCmp(Product, L"Butterfly")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"HP Pavilion Chromebook 14");
} else if (!StrCmp(Product, L"Candy")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Dell Chromebook 11 3120");
} else if (!StrCmp(Product, L"Cave")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Asus Chromebook Flip C302");
} else if (!StrCmp(Product, L"Celes")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Samsung Chromebook 3");
} else if (!StrCmp(Product, L"Chell")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"HP Chromebook 13 G1");
} else if (!StrCmp(Product, L"Clapper")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Lenovo N20 Chromebook");
} else if (!StrCmp(Product, L"Cyan")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Acer Chromebook R11 / C738T");
} else if (!StrCmp(Product, L"Edgar")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Acer Chromebook 14");
} else if (!StrCmp(Product, L"Ekko")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Acer Chromebook 714");
} else if (!StrCmp(Product, L"Enguarde")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Lenovo N21 Chromebook");
} else if (!StrCmp(Product, L"Eve")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Google Pixelbook 2017");
} else if (!StrCmp(Product, L"Falco")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"HP Chromebook 14");
} else if (!StrCmp(Product, L"Gandof")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Toshiba Chromebook2 2015");
} else if (!StrCmp(Product, L"Glimmer")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Lenovo ThinkPad 11e");
} else if (!StrCmp(Product, L"Gnawty")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Acer Chromebook 11 CB3-111/131");
} else if (!StrCmp(Product, L"Grunt")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"AMD StonyRidge Chromebook");
} else if (!StrCmp(Product, L"Guado")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Asus Chromebox 2 / CN62");
} else if (!StrCmp(Product, L"Kefka")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Dell Chromebook 11 3180/3189");
} else if (!StrCmp(Product, L"Kench")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"HP Chromebox G2");
} else if (!StrCmp(Product, L"Kip")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"HP Chromebook 11 G3/G4");
} else if (!StrCmp(Product, L"Lars")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Acer Chromebook 14 for Work");
} else if (!StrCmp(Product, L"Leon")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Toshiba Chromebook");
} else if (!StrCmp(Product, L"Librem 13 v2")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Purism Librem 13 v2");
} else if (!StrCmp(Product, L"Lulu")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Dell Chromebook 13 7310");
} else if (!StrCmp(Product, L"Link")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Google Chromebook Pixel 2013");
} else if (!StrCmp(Product, L"Lumpy")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Samsung Chromebook Series 5 550");
} else if (!StrCmp(Product, L"Mccloud")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Acer Chromebox CXI");
} else if (!StrCmp(Product, L"Monroe")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"LG Chromebase");
} else if (!StrCmp(Product, L"Nautilus")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Samsung Chromebook Plus V2");
} else if (!StrCmp(Product, L"Ninja")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"AOpen Chromebox Commercial");
} else if (!StrCmp(Product, L"Nocturne")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Google Pixel Slate");
} else if (!StrCmp(Product, L"Orco")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Lenovo Ideapad 100s");
} else if (!StrCmp(Product, L"Pantheon")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Lenovo Yoga Chromebook C630");
} else if (!StrCmp(Product, L"Panther")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Asus Chromebox CN60");
} else if (!StrCmp(Product, L"Parrot")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Acer Chromebook C710");
} else if (!StrCmp(Product, L"Peppy")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Acer Chromebook C720");
} else if (!StrCmp(Product, L"Quawks")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Asus Chromebook C300");
} else if (!StrCmp(Product, L"Rammus")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Asus Chromebook C425/C433/C434");
} else if (!StrCmp(Product, L"Reks")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Lenovo N22 Chromebook");
} else if (!StrCmp(Product, L"Relm")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Acer Chromebook 11 N7");
} else if (!StrCmp(Product, L"Rikku")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Acer Chromebox CXI2");
} else if (!StrCmp(Product, L"Samus")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Google Chromebook Pixel 2015");
} else if (!StrCmp(Product, L"Sentry")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Lenovo ThinkPad 13 Chromebook");
} else if (!StrCmp(Product, L"Setzer")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"HP Chromebook 11 G5");
} else if (!StrCmp(Product, L"Sion")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Acer Chromebox CXI3");
} else if (!StrCmp(Product, L"Sona")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"HP Chromebook x360 14");
} else if (!StrCmp(Product, L"Soraka")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"HP Chromebook x2");
} else if (!StrCmp(Product, L"Squawks")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Asus Chromebook C200");
} else if (!StrCmp(Product, L"Stout")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Lenovo ThinkPad X131e Chromebook");
} else if (!StrCmp(Product, L"Stumpy")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Samsung Chromebox Series 3");
} else if (!StrCmp(Product, L"Sumo")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"AOpen Chromebase Commercial");
} else if (!StrCmp(Product, L"Swanky")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Toshiba Chromebook2 2014");
} else if (!StrCmp(Product, L"Syndra")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"HP Chromebook 15 G1");
} else if (!StrCmp(Product, L"Teemo")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Asus Chromebox 3 / CN65");
} else if (!StrCmp(Product, L"Terra")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Asus Chromebook C202SA/C300SA");
} else if (!StrCmp(Product, L"Tidus")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Lenovo ThinkCentre Chromebox");
} else if (!StrCmp(Product, L"Tricky")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Dell Chromebox 3010");
} else if (!StrCmp(Product, L"Ultima")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Lenovo ThinkPad 11e/Yoga Chromebook (G3)");
} else if (!StrCmp(Product, L"Vayne")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Dell Inspiron Chromebook 14");
} else if (!StrCmp(Product, L"Winky")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Samsung Chromebook 2");
} else if (!StrCmp(Product, L"Wizpig")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"White Box Braswell Chromebook");
} else if (!StrCmp(Product, L"Wolf")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Dell Chromebook 11 2013");
} else if (!StrCmp(Product, L"Wukong")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"CTL Chromebox CBX1");
} else if (!StrCmp(Product, L"Zako")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"HP Chromebox CB1");
}
//etc etc
}
/** /**
Update the banner information for the Front Page based on DataHub information. Update the banner information for the Front Page based on DataHub information.
@ -699,16 +896,15 @@ UpdateFrontPageStrings (
) )
{ {
UINT8 StrIndex; UINT8 StrIndex;
UINT8 Str2Index;
CHAR16 *NewString; CHAR16 *NewString;
CHAR16 *NewString2;
CHAR16 *NewString3;
EFI_STATUS Status; EFI_STATUS Status;
EFI_STRING_ID TokenToUpdate; EFI_STRING_ID TokenToUpdate;
EFI_SMBIOS_HANDLE SmbiosHandle; EFI_PHYSICAL_ADDRESS *Table;
EFI_SMBIOS_PROTOCOL *Smbios; SMBIOS_TABLE_ENTRY_POINT *EntryPoint;
SMBIOS_TABLE_TYPE0 *Type0Record; SMBIOS_STRUCTURE_POINTER SmbiosTable;
SMBIOS_TABLE_TYPE1 *Type1Record;
SMBIOS_TABLE_TYPE4 *Type4Record;
SMBIOS_TABLE_TYPE19 *Type19Record;
EFI_SMBIOS_TABLE_HEADER *Record;
UINT64 InstalledMemory; UINT64 InstalledMemory;
InstalledMemory = 0; InstalledMemory = 0;
@ -716,69 +912,97 @@ UpdateFrontPageStrings (
// //
// Update Front Page strings // Update Front Page strings
// //
Status = gBS->LocateProtocol ( Status = EfiGetSystemConfigurationTable (&gEfiSmbiosTableGuid, (VOID **) &Table);
&gEfiSmbiosProtocolGuid, if (EFI_ERROR (Status) || Table == NULL) {
NULL, } else {
(VOID **) &Smbios EntryPoint = (SMBIOS_TABLE_ENTRY_POINT*)Table;
);
if (!EFI_ERROR (Status)) {
SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);
while (!EFI_ERROR(Status)) {
if (Record->Type == SMBIOS_TYPE_BIOS_INFORMATION) {
Type0Record = (SMBIOS_TABLE_TYPE0 *) Record;
StrIndex = Type0Record->BiosVersion;
GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type0Record + Type0Record->Hdr.Length), StrIndex, &NewString);
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION);
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);
FreePool (NewString);
}
if (Record->Type == SMBIOS_TYPE_SYSTEM_INFORMATION) { SmbiosTable = GetSmbiosTableFromType (EntryPoint, EFI_SMBIOS_TYPE_BIOS_INFORMATION , 0);
Type1Record = (SMBIOS_TABLE_TYPE1 *) Record; if (SmbiosTable.Raw == NULL) {
StrIndex = Type1Record->ProductName; } else {
GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type1Record + Type1Record->Hdr.Length), StrIndex, &NewString); NewString3 = AllocateZeroPool (0xC0);
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL);
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);
FreePool (NewString);
}
if (Record->Type == SMBIOS_TYPE_PROCESSOR_INFORMATION) { StrIndex = SmbiosTable.Type0->BiosVersion;
Type4Record = (SMBIOS_TABLE_TYPE4 *) Record; Str2Index = SmbiosTable.Type0->BiosReleaseDate;
StrIndex = Type4Record->ProcessorVersion; GetOptionalStringByIndex ((CHAR8*)((UINT8*)SmbiosTable.Raw + SmbiosTable.Hdr->Length), StrIndex, &NewString);
GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type4Record + Type4Record->Hdr.Length), StrIndex, &NewString); GetOptionalStringByIndex ((CHAR8*)((UINT8*)SmbiosTable.Raw + SmbiosTable.Hdr->Length), Str2Index, &NewString2);
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL); StrCatS (NewString3, 0x80 / sizeof (CHAR16), L"Version: ");
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL); StrCatS (NewString3, 0x80 / sizeof (CHAR16), NewString);
FreePool (NewString); // StrCatS (NewString3, 0x80 / sizeof (CHAR16), L" ");
} // StrCatS (NewString3, 0x80 / sizeof (CHAR16), NewString2);
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION);
if (Record->Type == SMBIOS_TYPE_PROCESSOR_INFORMATION) { HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString3, NULL);
Type4Record = (SMBIOS_TABLE_TYPE4 *) Record; FreePool (NewString);
ConvertProcessorToString(Type4Record->CurrentSpeed, 6, &NewString);
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED);
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);
FreePool (NewString);
}
if ( Record->Type == SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS ) {
Type19Record = (SMBIOS_TABLE_TYPE19 *) Record;
if (Type19Record->StartingAddress != 0xFFFFFFFF ) {
InstalledMemory += RShiftU64(Type19Record->EndingAddress -
Type19Record->StartingAddress + 1, 10);
} else {
InstalledMemory += RShiftU64(Type19Record->ExtendedEndingAddress -
Type19Record->ExtendedStartingAddress + 1, 20);
}
}
Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);
} }
// now update the total installed RAM size SmbiosTable = GetSmbiosTableFromType (EntryPoint, SMBIOS_TYPE_SYSTEM_INFORMATION , 0);
ConvertMemorySizeToString ((UINT32)InstalledMemory, &NewString ); if (SmbiosTable.Raw == NULL) {
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE); } else {
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL); NewString3 = AllocateZeroPool (0x60);
FreePool (NewString);
StrIndex = SmbiosTable.Type1->ProductName;
Str2Index = SmbiosTable.Type1->Manufacturer;
GetOptionalStringByIndex ((CHAR8*)((UINT8*)SmbiosTable.Raw + SmbiosTable.Hdr->Length), StrIndex, &NewString);
GetOptionalStringByIndex ((CHAR8*)((UINT8*)SmbiosTable.Raw + SmbiosTable.Hdr->Length), Str2Index, &NewString2);
if (!StrCmp(NewString2, L"GOOGLE") || !StrCmp(NewString2, L"Google")) {
NewString2 = AllocateZeroPool (0x60);
GetDeviceNameFromProduct(NewString, &NewString2);
StrCatS (NewString3, 0x60 / sizeof (CHAR16), NewString2);
StrCatS (NewString3, 0x60 / sizeof (CHAR16), L" (");
StrCatS (NewString3, 0x60 / sizeof (CHAR16), NewString);
StrCatS (NewString3, 0x60 / sizeof (CHAR16), L")");
} else {
StrCatS (NewString3, 0x60 / sizeof (CHAR16), NewString2);
StrCatS (NewString3, 0x60 / sizeof (CHAR16), L" ");
StrCatS (NewString3, 0x60 / sizeof (CHAR16), NewString);
}
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_TITLE);
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString3, NULL);
FreePool (NewString);
NewString3 = AllocateZeroPool (0x60);
StrIndex = SmbiosTable.Type1->Version;
GetOptionalStringByIndex ((CHAR8*)((UINT8*)SmbiosTable.Raw + SmbiosTable.Hdr->Length), StrIndex, &NewString);
StrCatS (NewString3, 0x60 / sizeof (CHAR16), L"Model: ");
StrCatS (NewString3, 0x60 / sizeof (CHAR16), NewString);
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL);
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString3, NULL);
FreePool (NewString);
}
SmbiosTable = GetSmbiosTableFromType (EntryPoint, SMBIOS_TYPE_PROCESSOR_INFORMATION , 0);
if (SmbiosTable.Raw == NULL) {
} else {
NewString3 = AllocateZeroPool (0x60);
StrIndex = SmbiosTable.Type4->ProcessorVersion;
GetOptionalStringByIndex ((CHAR8*)((UINT8*)SmbiosTable.Raw + SmbiosTable.Hdr->Length), StrIndex, &NewString);
StrCatS (NewString3, 0x60 / sizeof (CHAR16), NewString);
while (NewString3[0] == 0x20) {
NewString3 = &NewString3[1];
}
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL);
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString3, NULL);
FreePool (NewString);
}
SmbiosTable = GetSmbiosTableFromType (EntryPoint, SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS , 0);
if (SmbiosTable.Raw == NULL) {
} else {
if (SmbiosTable.Type19->StartingAddress != 0xFFFFFFFF ) {
InstalledMemory += RShiftU64(SmbiosTable.Type19->EndingAddress -
SmbiosTable.Type19->StartingAddress + 1, 10);
} else {
InstalledMemory += RShiftU64(SmbiosTable.Type19->ExtendedEndingAddress -
SmbiosTable.Type19->ExtendedStartingAddress + 1, 20);
}
// now update the total installed RAM size
ConvertMemorySizeToString ((UINT32)InstalledMemory, &NewString );
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE);
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);
FreePool (NewString);
}
} }
return ; return ;
@ -968,7 +1192,6 @@ PlatformBdsEnterFrontPage (
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_STATUS StatusHotkey;
EFI_BOOT_LOGO_PROTOCOL *BootLogo; EFI_BOOT_LOGO_PROTOCOL *BootLogo;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut; EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;
@ -1018,9 +1241,14 @@ PlatformBdsEnterFrontPage (
// //
mBootHorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution; mBootHorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution;
mBootVerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution; mBootVerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution;
mSetupHorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution;
mSetupVerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution;
} }
if (SimpleTextOut != NULL) { if (SimpleTextOut != NULL) {
SimpleTextOut->SetMode (SimpleTextOut, 2);
Status = SimpleTextOut->QueryMode ( Status = SimpleTextOut->QueryMode (
SimpleTextOut, SimpleTextOut,
SimpleTextOut->Mode->Mode, SimpleTextOut->Mode->Mode,
@ -1029,19 +1257,15 @@ PlatformBdsEnterFrontPage (
); );
mBootTextModeColumn = (UINT32)BootTextColumn; mBootTextModeColumn = (UINT32)BootTextColumn;
mBootTextModeRow = (UINT32)BootTextRow; mBootTextModeRow = (UINT32)BootTextRow;
}
// mSetupTextModeColumn = mBootTextModeColumn;
// Get user defined text mode for setup. mSetupTextModeRow = mBootTextModeRow;
// }
mSetupHorizontalResolution = PcdGet32 (PcdSetupVideoHorizontalResolution);
mSetupVerticalResolution = PcdGet32 (PcdSetupVideoVerticalResolution);
mSetupTextModeColumn = PcdGet32 (PcdSetupConOutColumn);
mSetupTextModeRow = PcdGet32 (PcdSetupConOutRow);
mModeInitialized = TRUE; mModeInitialized = TRUE;
} }
AddBGRT();
// //
// goto FrontPage directly when EFI_OS_INDICATIONS_BOOT_TO_FW_UI is set // goto FrontPage directly when EFI_OS_INDICATIONS_BOOT_TO_FW_UI is set
@ -1083,34 +1307,11 @@ PlatformBdsEnterFrontPage (
gST->ConIn->ReadKeyStroke(gST->ConIn, &Key); gST->ConIn->ReadKeyStroke(gST->ConIn, &Key);
} }
//
// Ensure screen is clear when switch Console from Graphics mode to Text mode
//
gST->ConOut->EnableCursor (gST->ConOut, TRUE);
gST->ConOut->ClearScreen (gST->ConOut);
} else { } else {
HotkeyBoot (); if (TimeoutDefault == 0) {
if (TimeoutDefault != 0xffff) { goto Exit;
Status = ShowProgress (TimeoutDefault);
StatusHotkey = HotkeyBoot ();
if (!FeaturePcdGet(PcdBootlogoOnlyEnable) || !EFI_ERROR(Status) || !EFI_ERROR(StatusHotkey)){
//
// Ensure screen is clear when switch Console from Graphics mode to Text mode
// Skip it in normal boot
//
gST->ConOut->EnableCursor (gST->ConOut, TRUE);
gST->ConOut->ClearScreen (gST->ConOut);
}
if (EFI_ERROR (Status)) {
//
// Timeout or user press enter to continue
//
goto Exit;
}
} }
} }

View File

@ -44,21 +44,21 @@
#language fr-FR "ACME® EFI BIOS Version 13.5 Release 1039.92" #language fr-FR "ACME® EFI BIOS Version 13.5 Release 1039.92"
#string STR_FRONT_PAGE_BANNER_3_LEFT #language en-US "Serial Number: 1Z123456789MARMAR (Need SMBIOS entries)" #string STR_FRONT_PAGE_BANNER_3_LEFT #language en-US "Serial Number: 1Z123456789MARMAR (Need SMBIOS entries)"
#language fr-FR "Numéro de série: 1Z123456789MARMAR (Les entrées de SMBIOS de besoin)" #language fr-FR "Numéro de série: 1Z123456789MARMAR (Les entrées de SMBIOS de besoin)"
#string STR_CONTINUE_PROMPT #language en-US "Continue" #string STR_CONTINUE_PROMPT #language en-US "Boot Default"
#language fr-FR "Continuer" #language fr-FR "Default Boot"
#string STR_CONTINUE_HELP #language en-US "This selection will direct the system to continue to booting process" #string STR_CONTINUE_HELP #language en-US "Boot the default entry"
#language fr-FR "Cette sélection dirigera le système pour continuer au charger de procédé" #language fr-FR "Cette sélection dirigera le système pour continuer au charger de procédé"
#string STR_LANGUAGE_SELECT #language en-US "Select Language" #string STR_LANGUAGE_SELECT #language en-US "Select Language"
#language fr-FR "Choisir la Langue" #language fr-FR "Choisir la Langue"
#string STR_LANGUAGE_SELECT_HELP #language en-US "This is the option one adjusts to change the language for the current system" #string STR_LANGUAGE_SELECT_HELP #language en-US "This is the option one adjusts to change the language for the current system"
#language fr-FR "Ceci est l'option que celui ajuste changer la langue pour le système actuel" #language fr-FR "Ceci est l'option que celui ajuste changer la langue pour le système actuel"
#string STR_BOOT_MANAGER #language en-US "Boot Manager" #string STR_BOOT_MANAGER #language en-US "One Time Boot"
#language fr-FR "Charger le Directeur" #language fr-FR "Charger le Directeur"
#string STR_BOOT_MANAGER_HELP #language en-US "This selection will take you to the Boot Manager" #string STR_BOOT_MANAGER_HELP #language en-US "Boot an entry one time"
#language fr-FR "Cette sélection vous prendra au Directeur de Botte" #language fr-FR "Cette sélection vous prendra au Directeur de Botte"
#string STR_BOOT_MAINT_MANAGER #language en-US "Boot Maintenance Manager" #string STR_BOOT_MAINT_MANAGER #language en-US "Change Boot Order"
#language fr-FR "Directeur d'Entretien" #language fr-FR "Directeur d'Entretien"
#string STR_BOOT_MAINT_MANAGER_HELP #language en-US "This selection will take you to the Boot Maintenance Manager" #string STR_BOOT_MAINT_MANAGER_HELP #language en-US "Change the order of boot entries"
#language fr-FR "Cette sélection vous prendra au Directeur d'Entretien" #language fr-FR "Cette sélection vous prendra au Directeur d'Entretien"
#string STR_DEVICE_MANAGER #language en-US "Device Manager" #string STR_DEVICE_MANAGER #language en-US "Device Manager"
#language fr-FR "Directeur d'appareil" #language fr-FR "Directeur d'appareil"

View File

@ -45,61 +45,31 @@ formset
form formid = FRONT_PAGE_FORM_ID, form formid = FRONT_PAGE_FORM_ID,
title = STRING_TOKEN(STR_FRONT_PAGE_TITLE); title = STRING_TOKEN(STR_FRONT_PAGE_TITLE);
banner subtitle text = STRING_TOKEN(STR_FRONT_PAGE_COMPUTER_MODEL);
title = STRING_TOKEN(STR_FRONT_PAGE_COMPUTER_MODEL), subtitle text = STRING_TOKEN(STR_FRONT_PAGE_BIOS_VERSION);
line 1, subtitle text = STRING_TOKEN(STR_NULL_STRING);
align left;
banner //banner
title = STRING_TOKEN(STR_FRONT_PAGE_CPU_MODEL), // title = STRING_TOKEN(STR_FRONT_PAGE_COMPUTER_MODEL),
line 2, // line 1,
align left; // align center;
banner //banner
title = STRING_TOKEN(STR_FRONT_PAGE_CPU_SPEED), // title = STRING_TOKEN(STR_FRONT_PAGE_BIOS_VERSION),
line 2, // line 3,
align right; // align left;
banner //banner
title = STRING_TOKEN(STR_FRONT_PAGE_BIOS_VERSION), // title = STRING_TOKEN(STR_FRONT_PAGE_CPU_MODEL),
line 3, // line 4,
align left; // align left;
banner //banner
title = STRING_TOKEN(STR_FRONT_PAGE_MEMORY_SIZE), // title = STRING_TOKEN(STR_FRONT_PAGE_MEMORY_SIZE),
line 3, // line 5,
align right; // align left;
// banner
// title = STRING_TOKEN(STR_FRONT_PAGE_BANNER_0_LEFT),
// line 0,
// align left;
// banner
// title = STRING_TOKEN(STR_FRONT_PAGE_BANNER_0_RIGHT),
// line 0,
// align right;
// banner
// title = STRING_TOKEN(STR_FRONT_PAGE_BANNER_1_LEFT),
// line 1,
// align left;
// banner
// title = STRING_TOKEN(STR_FRONT_PAGE_BANNER_1_RIGHT),
// line 1,
// align right;
// banner
// title = STRING_TOKEN(STR_FRONT_PAGE_BANNER_2_LEFT),
// line 2,
// align left;
// banner
// title = STRING_TOKEN(STR_FRONT_PAGE_BANNER_3_LEFT),
// line 3,
// align left;
subtitle text = STRING_TOKEN(STR_NULL_STRING);
text text
help = STRING_TOKEN(STR_CONTINUE_HELP), help = STRING_TOKEN(STR_CONTINUE_HELP),
@ -107,12 +77,7 @@ formset
flags = INTERACTIVE, flags = INTERACTIVE,
key = FRONT_PAGE_KEY_CONTINUE; key = FRONT_PAGE_KEY_CONTINUE;
label LABEL_SELECT_LANGUAGE; //subtitle text = STRING_TOKEN(STR_NULL_STRING);
//
// This is where we will dynamically add a OneOf type op-code to select
// Languages from the currently available choices
//
label LABEL_END;
goto FRONT_PAGE_ITEM_THREE, goto FRONT_PAGE_ITEM_THREE,
prompt = STRING_TOKEN(STR_BOOT_MANAGER), prompt = STRING_TOKEN(STR_BOOT_MANAGER),
@ -120,11 +85,7 @@ formset
flags = INTERACTIVE, flags = INTERACTIVE,
key = FRONT_PAGE_KEY_BOOT_MANAGER; key = FRONT_PAGE_KEY_BOOT_MANAGER;
goto FRONT_PAGE_ITEM_FOUR, //subtitle text = STRING_TOKEN(STR_NULL_STRING);
prompt = STRING_TOKEN(STR_DEVICE_MANAGER),
help = STRING_TOKEN(STR_DEVICE_MANAGER_HELP),
flags = INTERACTIVE,
key = FRONT_PAGE_KEY_DEVICE_MANAGER;
goto FRONT_PAGE_ITEM_FIVE, goto FRONT_PAGE_ITEM_FIVE,
prompt = STRING_TOKEN(STR_BOOT_MAINT_MANAGER), prompt = STRING_TOKEN(STR_BOOT_MAINT_MANAGER),

View File

@ -77,6 +77,8 @@ HotkeyBoot (
EFI_STATUS Status; EFI_STATUS Status;
UINTN ExitDataSize; UINTN ExitDataSize;
CHAR16 *ExitData; CHAR16 *ExitData;
UINTN Index;
EFI_INPUT_KEY Key;
if (mHotkeyBootOption == NULL) { if (mHotkeyBootOption == NULL) {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
@ -89,6 +91,8 @@ HotkeyBoot (
// //
gST->ConOut->Reset (gST->ConOut, FALSE); gST->ConOut->Reset (gST->ConOut, FALSE);
PlatformBdsPreBoot (mHotkeyBootOption);
Status = BdsLibBootViaBootOption (mHotkeyBootOption, mHotkeyBootOption->DevicePath, &ExitDataSize, &ExitData); Status = BdsLibBootViaBootOption (mHotkeyBootOption, mHotkeyBootOption->DevicePath, &ExitDataSize, &ExitData);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -97,6 +101,16 @@ HotkeyBoot (
// //
mHotkeyBootOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_FAILED)); mHotkeyBootOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_FAILED));
PlatformBdsBootFail (mHotkeyBootOption, Status, ExitData, ExitDataSize); PlatformBdsBootFail (mHotkeyBootOption, Status, ExitData, ExitDataSize);
// Wait for key
gST->ConOut->OutputString (
gST->ConOut,
GetStringById (STRING_TOKEN (STR_ANY_KEY_CONTINUE))
);
Status = gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &Index);
ASSERT_EFI_ERROR (Status);
ASSERT (Index == 0);
while (!EFI_ERROR (gST->ConIn->ReadKeyStroke (gST->ConIn, &Key))) {}
} else { } else {
// //
// Call platform action to indicate the boot success // Call platform action to indicate the boot success

View File

@ -51,12 +51,8 @@ PlatformBdsShowProgress (
UINT32 ColorDepth; UINT32 ColorDepth;
UINT32 RefreshRate; UINT32 RefreshRate;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color; EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color;
UINTN BlockHeight;
UINTN BlockWidth;
UINTN BlockNum; UINTN BlockNum;
UINTN PosX;
UINTN PosY; UINTN PosY;
UINTN Index;
if (Progress > 100) { if (Progress > 100) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
@ -101,12 +97,8 @@ PlatformBdsShowProgress (
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
BlockWidth = SizeOfX / 100;
BlockHeight = SizeOfY / 50;
BlockNum = Progress; BlockNum = Progress;
PosX = 0;
PosY = SizeOfY * 48 / 50; PosY = SizeOfY * 48 / 50;
if (BlockNum == 0) { if (BlockNum == 0) {
@ -145,41 +137,6 @@ PlatformBdsShowProgress (
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
} }
//
// Show progress by drawing blocks
//
for (Index = PreviousValue; Index < BlockNum; Index++) {
PosX = Index * BlockWidth;
if (GraphicsOutput != NULL) {
Status = GraphicsOutput->Blt (
GraphicsOutput,
&ProgressColor,
EfiBltVideoFill,
0,
0,
PosX,
PosY,
BlockWidth - 1,
BlockHeight,
(BlockWidth) * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
);
} else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
Status = UgaDraw->Blt (
UgaDraw,
(EFI_UGA_PIXEL *) &ProgressColor,
EfiUgaVideoFill,
0,
0,
PosX,
PosY,
BlockWidth - 1,
BlockHeight,
(BlockWidth) * sizeof (EFI_UGA_PIXEL)
);
} else {
return EFI_UNSUPPORTED;
}
}
PrintXY ( PrintXY (
(SizeOfX - StrLen (Title) * EFI_GLYPH_WIDTH) / 2, (SizeOfX - StrLen (Title) * EFI_GLYPH_WIDTH) / 2,
@ -222,7 +179,6 @@ BdsMemoryTest (
BOOLEAN TestAbort; BOOLEAN TestAbort;
EFI_INPUT_KEY Key; EFI_INPUT_KEY Key;
CHAR16 StrPercent[80]; CHAR16 StrPercent[80];
CHAR16 *StrTotalMemory;
CHAR16 *Pos; CHAR16 *Pos;
CHAR16 *TmpStr; CHAR16 *TmpStr;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground; EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;
@ -242,8 +198,6 @@ BdsMemoryTest (
return ReturnStatus; return ReturnStatus;
} }
StrTotalMemory = Pos;
TestedMemorySize = 0; TestedMemorySize = 0;
TotalMemorySize = 0; TotalMemorySize = 0;
PreviousValue = 0; PreviousValue = 0;
@ -287,7 +241,6 @@ BdsMemoryTest (
TmpStr = GetStringById (STRING_TOKEN (STR_ESC_TO_SKIP_MEM_TEST)); TmpStr = GetStringById (STRING_TOKEN (STR_ESC_TO_SKIP_MEM_TEST));
if (TmpStr != NULL) { if (TmpStr != NULL) {
PrintXY (10, 10, NULL, NULL, TmpStr);
FreePool (TmpStr); FreePool (TmpStr);
} }
} else { } else {
@ -304,7 +257,6 @@ BdsMemoryTest (
if (ErrorOut && (Status == EFI_DEVICE_ERROR)) { if (ErrorOut && (Status == EFI_DEVICE_ERROR)) {
TmpStr = GetStringById (STRING_TOKEN (STR_SYSTEM_MEM_ERROR)); TmpStr = GetStringById (STRING_TOKEN (STR_SYSTEM_MEM_ERROR));
if (TmpStr != NULL) { if (TmpStr != NULL) {
PrintXY (10, 10, NULL, NULL, TmpStr);
FreePool (TmpStr); FreePool (TmpStr);
} }
@ -330,7 +282,6 @@ BdsMemoryTest (
TmpStr, TmpStr,
sizeof (StrPercent) / sizeof (CHAR16) - StrLen (StrPercent) - 1 sizeof (StrPercent) / sizeof (CHAR16) - StrLen (StrPercent) - 1
); );
PrintXY (10, 10, NULL, NULL, StrPercent);
FreePool (TmpStr); FreePool (TmpStr);
} }
@ -370,8 +321,6 @@ BdsMemoryTest (
); );
FreePool (TmpStr); FreePool (TmpStr);
} }
PrintXY (10, 10, NULL, NULL, L"100");
} }
Status = GenMemoryTest->Finished (GenMemoryTest); Status = GenMemoryTest->Finished (GenMemoryTest);
goto Done; goto Done;
@ -386,28 +335,11 @@ BdsMemoryTest (
Done: Done:
if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) { if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) {
UnicodeValueToStringS (StrTotalMemory, StrTotalMemorySize, COMMA_TYPE, TotalMemorySize, 0);
if (StrTotalMemory[0] == L',') {
StrTotalMemory++;
StrTotalMemorySize -= sizeof (CHAR16);
}
TmpStr = GetStringById (STRING_TOKEN (STR_MEM_TEST_COMPLETED));
if (TmpStr != NULL) {
StrnCatS (
StrTotalMemory,
StrTotalMemorySize / sizeof (CHAR16),
TmpStr,
StrTotalMemorySize / sizeof (CHAR16) - StrLen (StrTotalMemory) - 1
);
FreePool (TmpStr);
}
PrintXY (10, 10, NULL, NULL, StrTotalMemory);
PlatformBdsShowProgress ( PlatformBdsShowProgress (
Foreground, Foreground,
Background, Background,
StrTotalMemory, L"Press ESC for Boot Options/Settings, or SPACE for Pop!_OS Recovery",
Color, Color,
100, 100,
(UINTN) PreviousValue (UINTN) PreviousValue

View File

@ -726,7 +726,7 @@ Error:
if (I2cBusContext != NULL) { if (I2cBusContext != NULL) {
Status = gBS->UninstallMultipleProtocolInterfaces ( Status = gBS->UninstallMultipleProtocolInterfaces (
&Controller, Controller,
gEfiCallerIdGuid, gEfiCallerIdGuid,
I2cBusContext, I2cBusContext,
NULL NULL

View File

@ -250,7 +250,7 @@ EnumerateNvmeDevNamespace (
); );
if(EFI_ERROR(Status)) { if(EFI_ERROR(Status)) {
gBS->UninstallMultipleProtocolInterfaces ( gBS->UninstallMultipleProtocolInterfaces (
&Device->DeviceHandle, Device->DeviceHandle,
&gEfiDevicePathProtocolGuid, &gEfiDevicePathProtocolGuid,
Device->DevicePath, Device->DevicePath,
&gEfiBlockIoProtocolGuid, &gEfiBlockIoProtocolGuid,
@ -290,7 +290,7 @@ EnumerateNvmeDevNamespace (
Sn[20] = 0; Sn[20] = 0;
CopyMem (Mn, Private->ControllerData->Mn, sizeof (Private->ControllerData->Mn)); CopyMem (Mn, Private->ControllerData->Mn, sizeof (Private->ControllerData->Mn));
Mn[40] = 0; Mn[40] = 0;
UnicodeSPrintAsciiFormat (Device->ModelName, sizeof (Device->ModelName), "%a-%a-%x", Sn, Mn, NamespaceData->Eui64); UnicodeSPrintAsciiFormat (Device->ModelName, sizeof (Device->ModelName), "%a", Mn);
AddUnicodeString2 ( AddUnicodeString2 (
"eng", "eng",

View File

@ -319,7 +319,7 @@ RegisterPciDevice (
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
gBS->UninstallMultipleProtocolInterfaces ( gBS->UninstallMultipleProtocolInterfaces (
&PciIoDevice->Handle, PciIoDevice->Handle,
&gEfiDevicePathProtocolGuid, &gEfiDevicePathProtocolGuid,
PciIoDevice->DevicePath, PciIoDevice->DevicePath,
&gEfiPciIoProtocolGuid, &gEfiPciIoProtocolGuid,
@ -357,7 +357,7 @@ RegisterPciDevice (
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
gBS->UninstallMultipleProtocolInterfaces ( gBS->UninstallMultipleProtocolInterfaces (
&PciIoDevice->Handle, PciIoDevice->Handle,
&gEfiDevicePathProtocolGuid, &gEfiDevicePathProtocolGuid,
PciIoDevice->DevicePath, PciIoDevice->DevicePath,
&gEfiPciIoProtocolGuid, &gEfiPciIoProtocolGuid,
@ -366,7 +366,7 @@ RegisterPciDevice (
); );
if (HasEfiImage) { if (HasEfiImage) {
gBS->UninstallMultipleProtocolInterfaces ( gBS->UninstallMultipleProtocolInterfaces (
&PciIoDevice->Handle, PciIoDevice->Handle,
&gEfiLoadFile2ProtocolGuid, &gEfiLoadFile2ProtocolGuid,
&PciIoDevice->LoadFile2, &PciIoDevice->LoadFile2,
NULL NULL

View File

@ -671,7 +671,7 @@ CreateSerialDevice (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
gBS->UninstallMultipleProtocolInterfaces ( gBS->UninstallMultipleProtocolInterfaces (
&SerialDevice->Handle, SerialDevice->Handle,
&gEfiDevicePathProtocolGuid, SerialDevice->DevicePath, &gEfiDevicePathProtocolGuid, SerialDevice->DevicePath,
&gEfiSerialIoProtocolGuid, &SerialDevice->SerialIo, &gEfiSerialIoProtocolGuid, &SerialDevice->SerialIo,
NULL NULL

View File

@ -695,7 +695,6 @@ EmmcSwitchClockFreq (
Status = EmmcSendStatus (PassThru, Slot, Rca, &DevStatus); Status = EmmcSendStatus (PassThru, Slot, Rca, &DevStatus);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "EmmcSwitchClockFreq: Send status fails with %r\n", Status)); DEBUG ((DEBUG_ERROR, "EmmcSwitchClockFreq: Send status fails with %r\n", Status));
return Status;
} }
// //
// Check the switch operation is really successful or not. // Check the switch operation is really successful or not.
@ -1166,7 +1165,10 @@ EmmcIdentification (
Private->Slot[Slot].CardType = EmmcCardType; Private->Slot[Slot].CardType = EmmcCardType;
Status = EmmcSetBusMode (PciIo, PassThru, Slot, Rca); Status = EmmcSetBusMode (PciIo, PassThru, Slot, Rca);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "EmmcSetBusMode: fails with %r\n", Status));
}
return Status; return EFI_SUCCESS;
} }

View File

@ -672,18 +672,12 @@ SdMmcPciHcDriverBindingStart (
// //
// Check whether there is a SD/MMC card attached // Check whether there is a SD/MMC card attached
// //
if (Private->Slot[Slot].SlotType == RemovableSlot) { Status = SdMmcHcCardDetect (PciIo, Slot, &MediaPresent);
Status = SdMmcHcCardDetect (PciIo, Slot, &MediaPresent); if (EFI_ERROR (Status) && (Status != EFI_MEDIA_CHANGED)) {
if (EFI_ERROR (Status) && (Status != EFI_MEDIA_CHANGED)) { continue;
continue; } else if (!MediaPresent) {
} else if (!MediaPresent) { DEBUG ((DEBUG_INFO, "SdMmcHcCardDetect: No device attached in Slot[%d]!!!\n", Slot));
DEBUG (( continue;
DEBUG_INFO,
"SdMmcHcCardDetect: No device attached in Slot[%d]!!!\n",
Slot
));
continue;
}
} }
Status = SdMmcHcInitHost (Private, Slot); Status = SdMmcHcInitHost (Private, Slot);

View File

@ -662,7 +662,7 @@ UsbHcAllocateAlignedPages (
PciIo, PciIo,
AllocateAnyPages, AllocateAnyPages,
EfiBootServicesData, EfiBootServicesData,
Pages, RealPages,
&Memory, &Memory,
0 0
); );

View File

@ -231,6 +231,134 @@ IoMmuFreeBuffer (
return Status; return Status;
} }
/**
Allocates aligned pages that are suitable for an OperationBusMasterCommonBuffer or
OperationBusMasterCommonBuffer64 mapping.
@param Pages The number of pages to allocate.
@param Alignment The requested alignment of the allocation. Must be a power of two.
@param HostAddress A pointer to store the base system memory address of the
allocated range.
@param DeviceAddress The resulting map address for the bus master PCI controller to use to
access the hosts HostAddress.
@param Mapping A resulting value to pass to Unmap().
@retval EFI_SUCCESS The requested memory pages were allocated.
@retval EFI_UNSUPPORTED Attributes is unsupported. The only legal attribute bits are
MEMORY_WRITE_COMBINE and MEMORY_CACHED.
@retval EFI_INVALID_PARAMETER One or more parameters are invalid.
@retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
**/
EFI_STATUS
IoMmuAllocateAlignedBuffer (
IN UINTN Pages,
IN UINTN Alignment,
OUT VOID **HostAddress,
OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
OUT VOID **Mapping
)
{
EFI_STATUS Status;
VOID *Memory;
UINTN AlignedMemory;
UINTN AlignmentMask;
UINTN UnalignedPages;
UINTN RealPages;
UINTN NumberOfBytes;
EFI_PHYSICAL_ADDRESS HostPhyAddress;
*HostAddress = NULL;
*DeviceAddress = 0;
AlignmentMask = Alignment - 1;
//
// Calculate the total number of pages since alignment is larger than page size.
//
RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment);
//
// Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.
//
ASSERT (RealPages > Pages);
if (mIoMmu != NULL) {
Status = mIoMmu->AllocateBuffer (
mIoMmu,
EfiBootServicesData,
RealPages,
HostAddress,
0
);
if (EFI_ERROR (Status)) {
return EFI_OUT_OF_RESOURCES;
}
Memory = *HostAddress;
AlignedMemory = ((UINTN) Memory + AlignmentMask) & ~AlignmentMask;
UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN) Memory);
if (UnalignedPages > 0) {
//
// Free first unaligned page(s).
//
Status = mIoMmu->FreeBuffer (
mIoMmu,
UnalignedPages,
Memory);
if (EFI_ERROR (Status)) {
return Status;
}
}
Memory = (VOID *)(UINTN)(AlignedMemory + EFI_PAGES_TO_SIZE (Pages));
UnalignedPages = RealPages - Pages - UnalignedPages;
if (UnalignedPages > 0) {
//
// Free last unaligned page(s).
//
Status = mIoMmu->FreeBuffer (
mIoMmu,
UnalignedPages,
Memory);
if (EFI_ERROR (Status)) {
return Status;
}
}
*HostAddress = (VOID *) AlignedMemory;
NumberOfBytes = EFI_PAGES_TO_SIZE(Pages);
Status = mIoMmu->Map (
mIoMmu,
EdkiiIoMmuOperationBusMasterCommonBuffer,
*HostAddress,
&NumberOfBytes,
DeviceAddress,
Mapping
);
if (EFI_ERROR (Status)) {
return EFI_OUT_OF_RESOURCES;
}
Status = mIoMmu->SetAttribute (
mIoMmu,
*Mapping,
EDKII_IOMMU_ACCESS_READ | EDKII_IOMMU_ACCESS_WRITE
);
if (EFI_ERROR (Status)) {
return Status;
}
} else {
Status = PeiServicesAllocatePages (
EfiBootServicesData,
RealPages,
&HostPhyAddress
);
if (EFI_ERROR (Status)) {
return EFI_OUT_OF_RESOURCES;
}
*HostAddress = (VOID *)(((UINTN) HostPhyAddress + AlignmentMask) & ~AlignmentMask);
*DeviceAddress = ((UINTN) HostPhyAddress + AlignmentMask) & ~AlignmentMask;
*Mapping = NULL;
}
return Status;
}
/** /**
Initialize IOMMU. Initialize IOMMU.
**/ **/

View File

@ -569,11 +569,7 @@ UsbHcAllocateAlignedPages (
{ {
EFI_STATUS Status; EFI_STATUS Status;
VOID *Memory; VOID *Memory;
UINTN AlignedMemory;
UINTN AlignmentMask;
EFI_PHYSICAL_ADDRESS DeviceMemory; EFI_PHYSICAL_ADDRESS DeviceMemory;
UINTN AlignedDeviceMemory;
UINTN RealPages;
// //
// Alignment must be a power of two or zero. // Alignment must be a power of two or zero.
@ -589,18 +585,9 @@ UsbHcAllocateAlignedPages (
} }
if (Alignment > EFI_PAGE_SIZE) { if (Alignment > EFI_PAGE_SIZE) {
// Status = IoMmuAllocateAlignedBuffer (
// Calculate the total number of pages since alignment is larger than page size.
//
AlignmentMask = Alignment - 1;
RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment);
//
// Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.
//
ASSERT (RealPages > Pages);
Status = IoMmuAllocateBuffer (
Pages, Pages,
Alignment,
&Memory, &Memory,
&DeviceMemory, &DeviceMemory,
Mapping Mapping
@ -608,8 +595,6 @@ UsbHcAllocateAlignedPages (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
AlignedMemory = ((UINTN) Memory + AlignmentMask) & ~AlignmentMask;
AlignedDeviceMemory = ((UINTN) DeviceMemory + AlignmentMask) & ~AlignmentMask;
} else { } else {
// //
// Do not over-allocate pages in this case. // Do not over-allocate pages in this case.
@ -623,12 +608,10 @@ UsbHcAllocateAlignedPages (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
AlignedMemory = (UINTN) Memory;
AlignedDeviceMemory = (UINTN) DeviceMemory;
} }
*HostAddress = (VOID *) AlignedMemory; *HostAddress = Memory;
*DeviceAddress = (EFI_PHYSICAL_ADDRESS) AlignedDeviceMemory; *DeviceAddress = DeviceMemory;
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -349,4 +349,32 @@ IoMmuFreeBuffer (
IN VOID *Mapping IN VOID *Mapping
); );
/**
Allocates aligned pages that are suitable for an OperationBusMasterCommonBuffer or
OperationBusMasterCommonBuffer64 mapping.
@param Pages The number of pages to allocate.
@param Alignment The requested alignment of the allocation. Must be a power of two.
@param HostAddress A pointer to store the base system memory address of the
allocated range.
@param DeviceAddress The resulting map address for the bus master PCI controller to use to
access the hosts HostAddress.
@param Mapping A resulting value to pass to Unmap().
@retval EFI_SUCCESS The requested memory pages were allocated.
@retval EFI_UNSUPPORTED Attributes is unsupported. The only legal attribute bits are
MEMORY_WRITE_COMBINE and MEMORY_CACHED.
@retval EFI_INVALID_PARAMETER One or more parameters are invalid.
@retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
**/
EFI_STATUS
IoMmuAllocateAlignedBuffer (
IN UINTN Pages,
IN UINTN Alignment,
OUT VOID **HostAddress,
OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
OUT VOID **Mapping
);
#endif #endif

View File

@ -481,7 +481,7 @@ InstallProtocolOnPartition (
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
gBS->UninstallMultipleProtocolInterfaces ( gBS->UninstallMultipleProtocolInterfaces (
&Partition->Handle, Partition->Handle,
&gEfiDevicePathProtocolGuid, &gEfiDevicePathProtocolGuid,
Partition->DevicePath, Partition->DevicePath,
&gEfiBlockIoProtocolGuid, &gEfiBlockIoProtocolGuid,

View File

@ -165,7 +165,7 @@ UsbCreateInterface (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
gBS->UninstallMultipleProtocolInterfaces ( gBS->UninstallMultipleProtocolInterfaces (
&UsbIf->Handle, UsbIf->Handle,
&gEfiDevicePathProtocolGuid, &gEfiDevicePathProtocolGuid,
UsbIf->DevicePath, UsbIf->DevicePath,
&gEfiUsbIoProtocolGuid, &gEfiUsbIoProtocolGuid,
@ -725,6 +725,7 @@ UsbEnumerateNewDev (
if (!USB_BIT_IS_SET (PortState.PortStatus, USB_PORT_STAT_CONNECTION)) { if (!USB_BIT_IS_SET (PortState.PortStatus, USB_PORT_STAT_CONNECTION)) {
DEBUG ((EFI_D_ERROR, "UsbEnumerateNewDev: No device present at port %d\n", Port)); DEBUG ((EFI_D_ERROR, "UsbEnumerateNewDev: No device present at port %d\n", Port));
Status = EFI_NOT_FOUND;
goto ON_ERROR; goto ON_ERROR;
} else if (USB_BIT_IS_SET (PortState.PortStatus, USB_PORT_STAT_SUPER_SPEED)){ } else if (USB_BIT_IS_SET (PortState.PortStatus, USB_PORT_STAT_SUPER_SPEED)){
Child->Speed = EFI_USB_SPEED_SUPER; Child->Speed = EFI_USB_SPEED_SUPER;

View File

@ -581,7 +581,7 @@ UsbMassInitMultiLun (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "UsbMassInitMultiLun: OpenUsbIoProtocol By Child (%r)\n", Status)); DEBUG ((EFI_D_ERROR, "UsbMassInitMultiLun: OpenUsbIoProtocol By Child (%r)\n", Status));
gBS->UninstallMultipleProtocolInterfaces ( gBS->UninstallMultipleProtocolInterfaces (
&UsbMass->Controller, UsbMass->Controller,
&gEfiDevicePathProtocolGuid, &gEfiDevicePathProtocolGuid,
UsbMass->DevicePath, UsbMass->DevicePath,
&gEfiBlockIoProtocolGuid, &gEfiBlockIoProtocolGuid,

View File

@ -149,12 +149,6 @@ Create4GPageTablesIa32Pae (
); );
} }
//
// Protect the page table by marking the memory used for page table to be
// read-only.
//
EnablePageTableProtection ((UINTN)PageMap, FALSE);
return (UINTN) PageMap; return (UINTN) PageMap;
} }

View File

@ -805,11 +805,6 @@ CreateIdentityMappingPageTables (
); );
} }
//
// Protect the page table by marking the memory used for page table to be
// read-only.
//
EnablePageTableProtection ((UINTN)PageMap, TRUE);
// //
// Set IA32_EFER.NXE if necessary. // Set IA32_EFER.NXE if necessary.

View File

@ -230,7 +230,7 @@ TranslateBmpToGopBlt (
if ((BmpHeader->Size != BmpImageSize) || if ((BmpHeader->Size != BmpImageSize) ||
(BmpHeader->Size < BmpHeader->ImageOffset) || (BmpHeader->Size < BmpHeader->ImageOffset) ||
(BmpHeader->Size - BmpHeader->ImageOffset != DataSize)) { (BmpHeader->Size - BmpHeader->ImageOffset < DataSize)) {
DEBUG ((DEBUG_ERROR, "TranslateBmpToGopBlt: invalid BmpImage... \n")); DEBUG ((DEBUG_ERROR, "TranslateBmpToGopBlt: invalid BmpImage... \n"));
DEBUG ((DEBUG_ERROR, " BmpHeader->Size: 0x%x\n", BmpHeader->Size)); DEBUG ((DEBUG_ERROR, " BmpHeader->Size: 0x%x\n", BmpHeader->Size));

View File

@ -499,19 +499,6 @@ GraphicsConsoleControllerDriverStart (
} }
} }
} }
if (ModeNumber != Private->GraphicsOutput->Mode->Mode) {
//
// Current graphics mode is not set or is not set to the mode which we has found,
// set the new graphic mode.
//
Status = Private->GraphicsOutput->SetMode (Private->GraphicsOutput, ModeNumber);
if (EFI_ERROR (Status)) {
//
// The mode set operation failed
//
goto Error;
}
}
} else if (FeaturePcdGet (PcdUgaConsumeSupport)) { } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
// //
// At first try to set user-defined resolution // At first try to set user-defined resolution
@ -764,23 +751,6 @@ CheckModeSupported (
&Info &Info
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
if ((Info->HorizontalResolution == HorizontalResolution) &&
(Info->VerticalResolution == VerticalResolution)) {
if ((GraphicsOutput->Mode->Info->HorizontalResolution == HorizontalResolution) &&
(GraphicsOutput->Mode->Info->VerticalResolution == VerticalResolution)) {
//
// If video device has been set to this mode, we do not need to SetMode again
//
FreePool (Info);
break;
} else {
Status = GraphicsOutput->SetMode (GraphicsOutput, ModeNumber);
if (!EFI_ERROR (Status)) {
FreePool (Info);
break;
}
}
}
FreePool (Info); FreePool (Info);
} }
} }
@ -1906,7 +1876,8 @@ FlushCursor (
CurrentMode = This->Mode; CurrentMode = This->Mode;
if (!CurrentMode->CursorVisible) { if (!CurrentMode->CursorVisible ||
(CurrentMode->CursorColumn == 0 && CurrentMode->CursorRow == 0 )) {
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -44,8 +44,8 @@ EFI_DRIVER_BINDING_PROTOCOL gPartitionDriverBinding = {
// //
PARTITION_DETECT_ROUTINE mPartitionDetectRoutineTable[] = { PARTITION_DETECT_ROUTINE mPartitionDetectRoutineTable[] = {
PartitionInstallGptChildHandles, PartitionInstallGptChildHandles,
PartitionInstallMbrChildHandles,
PartitionInstallUdfChildHandles, PartitionInstallUdfChildHandles,
PartitionInstallMbrChildHandles,
NULL NULL
}; };

View File

@ -14,8 +14,53 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
#include <Library/UefiRuntimeServicesTableLib.h>
#include "Variable.h" #include "Variable.h"
EFI_EVENT mVirtualAddressChangeEvent2 = NULL;
int storeInitialized = 0;
VOID *rt_buffer;
UINTN rt_buffer_phys;
/*
* calls into SMM with the given cmd and subcmd in eax, and arg in ebx
*
* static inline because the resulting assembly is often smaller than
* the call sequence due to constant folding.
*/
static inline UINT32 call_smm(UINT8 cmd, UINT8 subcmd, UINT32 arg) {
UINT32 res = 0;
__asm__ __volatile__ (
"outb %b0, $0xb2"
: "=a" (res)
: "a" ((subcmd << 8) | cmd), "b" (arg)
: "memory");
return res;
}
#define SMMSTORE_APM_CNT 0xed
#define SMMSTORE_RET_SUCCESS 0
#define SMMSTORE_RET_FAILURE 1
#define SMMSTORE_RET_UNSUPPORTED 2
#define SMMSTORE_CMD_CLEAR 1
#define SMMSTORE_CMD_READ 2
#define SMMSTORE_CMD_APPEND 3
struct smmstore_params_read {
UINT32 buf;
UINT32 bufsize;
};
struct smmstore_params_append {
UINT32 key;
UINT32 keysize;
UINT32 val;
UINT32 valsize;
};
/// ///
/// Don't use module globals after the SetVirtualAddress map is signaled /// Don't use module globals after the SetVirtualAddress map is signaled
/// ///
@ -899,6 +944,7 @@ UpdateVariable (
UINTN VarSize; UINTN VarSize;
VARIABLE_GLOBAL *Global; VARIABLE_GLOBAL *Global;
UINTN NonVolatileVarableStoreSize; UINTN NonVolatileVarableStoreSize;
BOOLEAN Delete = FALSE;
Global = &mVariableModuleGlobal->VariableGlobal[Physical]; Global = &mVariableModuleGlobal->VariableGlobal[Physical];
@ -931,10 +977,8 @@ UpdateVariable (
// specified causes it to be deleted. // specified causes it to be deleted.
// //
if (DataSize == 0 || (Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == 0) { if (DataSize == 0 || (Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == 0) {
Variable->CurrPtr->State &= VAR_DELETED; DataSize = 0;
UpdateVariableInfo (VariableName, VendorGuid, Variable->Volatile, FALSE, FALSE, TRUE, FALSE); Delete = TRUE;
Status = EFI_SUCCESS;
goto Done;
} }
// //
@ -944,8 +988,12 @@ UpdateVariable (
if (Variable->CurrPtr->DataSize == DataSize && if (Variable->CurrPtr->DataSize == DataSize &&
CompareMem (Data, GetVariableDataPtr (Variable->CurrPtr), DataSize) == 0 CompareMem (Data, GetVariableDataPtr (Variable->CurrPtr), DataSize) == 0
) { ) {
Status = EFI_SUCCESS; if (Delete) {
goto Done; goto Update;
} else {
Status = EFI_SUCCESS;
goto Done;
}
} else if (Variable->CurrPtr->State == VAR_ADDED) { } else if (Variable->CurrPtr->State == VAR_ADDED) {
// //
// Mark the old variable as in delete transition // Mark the old variable as in delete transition
@ -987,6 +1035,10 @@ UpdateVariable (
VarDataOffset = VarNameOffset + VarNameSize + GET_PAD_SIZE (VarNameSize); VarDataOffset = VarNameOffset + VarNameSize + GET_PAD_SIZE (VarNameSize);
VarSize = VarDataOffset + DataSize + GET_PAD_SIZE (DataSize); VarSize = VarDataOffset + DataSize + GET_PAD_SIZE (DataSize);
if (Delete) {
goto Store;
}
if ((Attributes & EFI_VARIABLE_NON_VOLATILE) != 0) { if ((Attributes & EFI_VARIABLE_NON_VOLATILE) != 0) {
NonVolatileVarableStoreSize = ((VARIABLE_STORE_HEADER *)(UINTN)(Global->NonVolatileVariableBase))->Size; NonVolatileVarableStoreSize = ((VARIABLE_STORE_HEADER *)(UINTN)(Global->NonVolatileVariableBase))->Size;
if ((((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0) if ((((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0)
@ -1044,6 +1096,43 @@ UpdateVariable (
DataSize DataSize
); );
Store:
// If the store is initialized
// And we are storing or deleting a non volatile variable
// Send the new data to SMMSTORE
if (storeInitialized && (
(Attributes & EFI_VARIABLE_NON_VOLATILE) != 0 || (
Delete &&
(Variable->CurrPtr->Attributes & EFI_VARIABLE_NON_VOLATILE) != 0
)
)) {
/* TODO: add hook for logging nv changes here */
int keysize = sizeof (EFI_GUID) + VarNameSize;
int valsize = DataSize;
struct smmstore_params_append *data = rt_buffer;
void *keydata = rt_buffer + sizeof(*data);
void *valdata = keydata + keysize;
data->key = (UINT32)(UINTN)rt_buffer_phys + sizeof(*data);
data->keysize = keysize;
data->val = data->key + keysize;
data->valsize = valsize;
CopyMem (keydata, VendorGuid, sizeof (EFI_GUID));
CopyMem (keydata + sizeof (EFI_GUID), VariableName, VarNameSize);
CopyMem (valdata, Data, DataSize);
call_smm(SMMSTORE_APM_CNT, SMMSTORE_CMD_APPEND, (UINT32)rt_buffer_phys);
/* call into SMM through EFI_ISA_IO_PROTOCOL to write to 0xb2:
* set registers (how?)
* UINT8 Data = ...;
* IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUInt8, 0xb2, 1, &Data);
*/
}
Update:
// //
// Mark the old variable as deleted // Mark the old variable as deleted
// //
@ -1051,7 +1140,11 @@ UpdateVariable (
Variable->CurrPtr->State &= VAR_DELETED; Variable->CurrPtr->State &= VAR_DELETED;
} }
UpdateVariableInfo (VariableName, VendorGuid, Variable->Volatile, FALSE, TRUE, FALSE, FALSE); if (Delete) {
UpdateVariableInfo (VariableName, VendorGuid, Variable->Volatile, FALSE, FALSE, TRUE, FALSE);
} else {
UpdateVariableInfo (VariableName, VendorGuid, Variable->Volatile, FALSE, TRUE, FALSE, FALSE);
}
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
@ -1769,6 +1862,19 @@ InitializeVariableStore (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
VOID
EFIAPI
EmuVariableAddressChangeEvent (
IN EFI_EVENT Event,
IN VOID *Context
)
{
//
// Converts a pointer for runtime memory management to a new virtual address.
//
EfiConvertPointer (0x0, (VOID **) &rt_buffer);
}
/** /**
Initializes variable store area for non-volatile and volatile variable. Initializes variable store area for non-volatile and volatile variable.
@ -1816,5 +1922,77 @@ VariableCommonInitialize (
// //
Status = InitializeVariableStore (FALSE); Status = InitializeVariableStore (FALSE);
/* TODO: add hook for filling nv store from log here */
const int bufsize = 64 * 1024;
rt_buffer = AllocateRuntimePool (bufsize);
/* needed later for the 32bit 1:1 mapped SMM interface */
rt_buffer_phys = (UINTN)rt_buffer;
ASSERT(rt_buffer_phys <= 0x100000000 - bufsize);
Status = gBS->CreateEventEx (
EVT_NOTIFY_SIGNAL,
TPL_NOTIFY,
EmuVariableAddressChangeEvent,
NULL,
&gEfiEventVirtualAddressChangeGuid,
&mVirtualAddressChangeEvent2
);
ASSERT_EFI_ERROR (Status);
/* read store */
/* we're still phys mapped here, so no magic necessary */
UINT8 buf[0x40000];
ASSERT((UINTN)buf <= 0x100000000 - sizeof(buf));
struct smmstore_params_read read_cmd = {
.buf = (UINT32)(UINTN)&buf,
.bufsize = sizeof(buf),
};
ASSERT((UINTN)&read_cmd <= 0x100000000 - sizeof(read_cmd));
call_smm(SMMSTORE_APM_CNT, SMMSTORE_CMD_READ, (UINT32)(UINTN)&read_cmd);
DEBUG ((DEBUG_WARN, "Initialize buffer from 0x%x bytes of flash\n", read_cmd.bufsize));
int i = 0;
while (i < read_cmd.bufsize) {
// assume native endian
UINT32 keysz = ((UINT32 *)(buf + i))[0];
if (keysz == 0 || keysz == 0xffffffff)
break; // no more entries
UINTN valsz = ((UINT32 *)(buf + i))[1];
if (i + keysz + valsz + 1 > read_cmd.bufsize)
break;
// TODO: check if entry is properly terminated
DEBUG ((DEBUG_WARN, "Found variable: key size: 0x%x, val size: %x\n", keysz, valsz));
if (keysz > sizeof (EFI_GUID)) {
CHAR16 *varname = (CHAR16 *)(buf + i + 8 + sizeof (EFI_GUID));
EFI_GUID *guid = (EFI_GUID *)(buf + i + 8);
VOID *data = (VOID *)(buf + i + 8 + keysz);
DEBUG ((DEBUG_WARN, "Fetching variable: %s\n", varname));
DEBUG ((DEBUG_WARN, "buf: %p, buf+i: %p, guid: %p, varname: %p, data: %p\n", buf, buf + i, guid, varname, data));
VARIABLE_POINTER_TRACK Variable;
FindVariable (varname, guid, &Variable, (VARIABLE_GLOBAL *)mVariableModuleGlobal);
DEBUG ((DEBUG_WARN, "Updating variable: %s\n", varname));
UpdateVariable (
varname,
guid,
data,
valsz,
// all of these variables are nv
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
&Variable
);
}
DEBUG ((DEBUG_WARN, "Added variable: 0x%x, val size: %x\n", keysz, valsz));
// no UEFI variable since it's at most the GUID part, so skip
i += 8 + keysz + valsz + 1;
i = (i + 3) & ~3;
}
storeInitialized = 1;
return Status; return Status;
} }

View File

@ -1,7 +1,7 @@
/** @file /** @file
AESNI feature. AESNI feature.
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -123,7 +123,7 @@ AesniInitialize (
MSR_SANDY_BRIDGE_FEATURE_CONFIG, MSR_SANDY_BRIDGE_FEATURE_CONFIG,
MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER, MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER,
Bits.AESConfiguration, Bits.AESConfiguration,
BIT1 | ((State) ? 0 : BIT0) BIT0 | ((State) ? 0 : BIT1)
); );
} }
} }

View File

@ -117,7 +117,7 @@ CommonExceptionHandlerWorker (
// //
// Enter a dead loop if needn't to execute old IDT handler further // Enter a dead loop if needn't to execute old IDT handler further
// //
if (ReservedVectors[ExceptionType].Attribute != EFI_VECTOR_HANDOFF_HOOK_BEFORE) { if (ReservedVectors[ExceptionType].Attribute != EFI_VECTOR_HANDOFF_HOOK_BEFORE && ExceptionType != EXCEPT_IA32_DEBUG) {
CpuDeadLoop (); CpuDeadLoop ();
} }
} }
@ -299,4 +299,3 @@ RegisterCpuInterruptHandlerWorker (
ExternalInterruptHandler[InterruptType] = InterruptHandler; ExternalInterruptHandler[InterruptType] = InterruptHandler;
return EFI_SUCCESS; return EFI_SUCCESS;
} }