提交 ce1c67b6 编写于 作者: V vit9696

Build: Include DuetPkg as OpenDuetPkg

上级 f76030f7
......@@ -37,3 +37,7 @@ prelinkedkernel.unpack
*.pyc
Debug/QemuRun
Doxy
Legacy/BinDrivers/X64
Legacy/BinDrivers/IA32
Legacy/BootLoader/bin
Legacy/BootSector/bin
......@@ -25,7 +25,8 @@ matrix:
script:
- HOMEBREW_NO_INSTALL_CLEANUP=1 HOMEBREW_NO_AUTO_UPDATE=1 brew install openssl mingw-w64
- "./macbuild.tool"
- "./build_oc.tool"
- "./build_duet.tool"
deploy:
provider: releases
......@@ -59,7 +60,8 @@ matrix:
- if [ "$sum" != "$expsum" ]; then echo "Invalid checksum $sum" ; exit 1 ; fi
- tar -xf "${file}${suf}" || exit 1
- export PATH="$(pwd)/${file}/bin:$PATH"
- "./macbuild.tool"
- "./build_oc.tool"
- "./build_duet.tool"
- os: linux
name: "Build Linux CLANG38"
......@@ -77,7 +79,8 @@ matrix:
- sudo apt-get remove -y llvm-3.8 libllvm3.8 # Move LLVM 3.8 out of the way.
- export PATH="/usr/lib/llvm-8/bin:$PATH" # Default compiler (7.0 or 3.8) has no LTO plugin.
- export TOOLCHAINS=CLANG38
- "./macbuild.tool"
- "./build_oc.tool"
- "./build_duet.tool"
# Currently this is too ugly, but maybe we can use that in the future.
- sudo apt-get install -y doxygen texlive texlive-latex-extra
- abort() { tail -200 log.txt ; exit 1 ; }
......@@ -107,6 +110,6 @@ matrix:
name: "acidanthera/OpenCorePkg"
description: "OpenCorePkg"
notification_email: $NOTIFICATION_EMAIL
build_command_prepend: "./macbuild.tool --skip-build --skip-package && cd UDK ; src=$(curl -Lfs https://raw.githubusercontent.com/acidanthera/Lilu/master/Lilu/Scripts/covstrap.sh) && eval \"$src\" || exit 1"
build_command: "../macbuild.tool --skip-tests --skip-package RELEASE"
build_command_prepend: "./build_oc.tool --skip-build --skip-package && cd UDK ; src=$(curl -Lfs https://raw.githubusercontent.com/acidanthera/Lilu/master/Lilu/Scripts/covstrap.sh) && eval \"$src\" || exit 1"
build_command: "../build_oc.tool --skip-tests --skip-package RELEASE"
branch_pattern: master
......@@ -557,9 +557,9 @@ cross-platform and open-source alternative
utilised.
For BIOS booting a third-party UEFI environment provider will have to
be used. \texttt{DuetPkg} is one of the known UEFI environment providers
be used. \texttt{OpenDuetPkg} is one of the known UEFI environment providers
for legacy systems. To run OpenCore on such a legacy system you can install
\texttt{DuetPkg} with a dedicated tool BootInstall (bundled with OpenCore).
\texttt{OpenDuetPkg} with a dedicated tool BootInstall (bundled with OpenCore).
For upgrade purposes refer to \texttt{Differences.pdf} document, providing
the information about the changes affecting the configuration compared
......@@ -591,7 +591,6 @@ command sequence may look as follows:
\begin{lstlisting}[caption=Compilation Commands, label=compile, style=ocbash]
git clone https://github.com/acidanthera/audk UDK
cd UDK
git clone https://github.com/acidanthera/DuetPkg
git clone https://github.com/acidanthera/OpenCorePkg
source edksetup.sh
make -C BaseTools
......@@ -610,11 +609,12 @@ Add \texttt{.clang\_complete} file with similar content to your UDK root:
-I/UefiPackages/MdeModulePkg
-I/UefiPackages/MdeModulePkg/Include
-I/UefiPackages/MdeModulePkg/Include/X64
-I/UefiPackages/DuetPkg/Include
-I/UefiPackages/AppleSupportPkg/Include
-I/UefiPackages/OpenCorePkg/Include/AMI
-I/UefiPackages/OpenCorePkg/Include/Acidanthera
-I/UefiPackages/OpenCorePkg/Include/Apple
-I/UefiPackages/OpenCorePkg/Include/Apple/X64
-I/UefiPackages/OpenCorePkg/Include/Duet
-I/UefiPackages/OpenCorePkg/Include/Generic
-I/UefiPackages/OpenCorePkg/Include/Intel
-I/UefiPackages/OpenCorePkg/Include/Microsoft
......@@ -2217,7 +2217,7 @@ The boot process is as follows:
\end{itemize}
\emph{Note 1}: This process is meant to work reliably only when \texttt{RequestBootVarRouting}
option is enabled or the firmware does not control UEFI boot options (\texttt{DuetPkg} or
option is enabled or the firmware does not control UEFI boot options (\texttt{OpenDuetPkg} or
custom BDS). Without \texttt{BootProtect} it also is possible that other operating systems
overwrite OpenCore, make sure to enable it if you plan to use them.
......@@ -4163,7 +4163,7 @@ even cause permanent firmware damage. Some of the known drivers are listed below
on top of a custom USB keyboard driver implementation. This is an alternative to
builtin \texttt{KeySupport}, which may work better or worse depending on the firmware. \\
\href{https://github.com/acidanthera/audk}{\texttt{Ps2KeyboardDxe}}\textbf{*}
& PS/2 keyboard driver from \texttt{MdeModulePkg}. DuetPkg and some firmwares
& PS/2 keyboard driver from \texttt{MdeModulePkg}. \texttt{OpenDuetPkg} and some firmwares
may not include this driver, but it is necessary for PS/2 keyboard to work.
Note, unlike \texttt{OpenUsbKbDxe} this driver has no \texttt{AppleKeyMapAggregator}
support and thus requires \texttt{KeySupport} to be enabled. \\
......
/** @file
Copyright (c) 2004 - 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:
EfiFlashMap.h
Abstract:
Defines for the EFI Flash Map functionality
**/
#ifndef _EFI_FLASHMAP_H_
#define _EFI_FLASHMAP_H_
//
// Definition for flash map GUIDed HOBs
//
typedef UINT32 EFI_FLASH_AREA_ATTRIBUTES;
#define EFI_FLASH_AREA_FV 0x0001
#define EFI_FLASH_AREA_SUBFV 0x0002
#define EFI_FLASH_AREA_MEMMAPPED_FV 0x0004
#define EFI_FLASH_AREA_REQUIRED 0x0008
#define EFI_FLASH_AREA_CORRUPT 0x0010
typedef UINT8 EFI_FLASH_AREA_TYPE;
#define EFI_FLASH_AREA_RECOVERY_BIOS 0x0 // Recovery code
#define EFI_FLASH_AREA_MAIN_BIOS 0x1 // Regular BIOS code
#define EFI_FLASH_AREA_PAL_B 0x2 // PAL-B
#define EFI_FLASH_AREA_RESERVED_03 0x3 // Reserved for backwards compatibility
#define EFI_FLASH_AREA_RESERVED_04 0x4 // Reserved for backwards compatibility
#define EFI_FLASH_AREA_DMI_FRU 0x5 // DMI FRU information
#define EFI_FLASH_AREA_OEM_BINARY 0x6 // OEM Binary Code/data
#define EFI_FLASH_AREA_RESERVED_07 0x7 // Reserved for backwards compatibility
#define EFI_FLASH_AREA_RESERVED_08 0x8 // Reserved for backwards compatibility
#define EFI_FLASH_AREA_RESERVED_09 0x9 // Reserved for backwards compatibility
#define EFI_FLASH_AREA_RESERVED_0A 0x0a // Reserved for backwards compatibility
#define EFI_FLASH_AREA_EFI_VARIABLES 0x0b // EFI variables
#define EFI_FLASH_AREA_MCA_LOG 0x0c // MCA error log
#define EFI_FLASH_AREA_SMBIOS_LOG 0x0d // SMBIOS error log
#define EFI_FLASH_AREA_FTW_BACKUP 0x0e // A backup block during FTW operations
#define EFI_FLASH_AREA_FTW_STATE 0x0f // State information during FTW operations
#define EFI_FLASH_AREA_UNUSED 0x0fd // Not used
#define EFI_FLASH_AREA_GUID_DEFINED 0x0fe // Usage defined by a GUID
#pragma pack(1)
//
// An individual sub-area Entry.
// A single flash area may consist of more than one sub-area.
//
/**
typedef struct {
EFI_FLASH_AREA_ATTRIBUTES Attributes;
UINT32 Reserved;
EFI_PHYSICAL_ADDRESS Base;
EFI_PHYSICAL_ADDRESS Length;
EFI_GUID FileSystem;
} EFI_FLASH_SUBAREA_ENTRY;
typedef struct {
UINT8 Reserved[3];
EFI_FLASH_AREA_TYPE AreaType;
EFI_GUID AreaTypeGuid;
UINT32 NumEntries;
EFI_FLASH_SUBAREA_ENTRY Entries[1];
} EFI_FLASH_MAP_ENTRY_DATA;
typedef struct {
UINT8 Reserved[3];
EFI_FLASH_AREA_TYPE AreaType;
EFI_GUID AreaTypeGuid;
UINT32 NumberOfEntries;
EFI_FLASH_SUBAREA_ENTRY Entries[1];
//
// Extended Hob data.
//
// VolumeId and FilePath indicating a unique file.
//
UINT32 VolumeId;
CHAR16 FilePath[256];
UINT32 ActuralSize;
UINT32 Offset;
} EFI_FLASH_MAP_FS_ENTRY_DATA;
typedef struct {
EFI_HOB_GENERIC_HEADER Header;
EFI_GUID Name;
UINT8 Reserved[3];
EFI_FLASH_AREA_TYPE AreaType;
EFI_GUID AreaTypeGuid;
UINT32 NumEntries;
EFI_FLASH_SUBAREA_ENTRY Entries[1];
} EFI_HOB_FLASH_MAP_ENTRY_TYPE;
//
// Internal definitions
//
typedef struct {
UINT8 Reserved[3];
EFI_FLASH_AREA_TYPE AreaType;
EFI_GUID AreaTypeGuid;
UINT32 NumberOfEntries;
EFI_FLASH_SUBAREA_ENTRY SubAreaData;
} EFI_FLASH_AREA_HOB_DATA;
typedef struct {
UINTN Base;
UINTN Length;
EFI_FLASH_AREA_ATTRIBUTES Attributes;
EFI_FLASH_AREA_TYPE AreaType;
UINT8 Reserved[3];
EFI_GUID AreaTypeGuid;
} EFI_FLASH_AREA_DATA;
**/
typedef struct {
EFI_FLASH_AREA_ATTRIBUTES Attributes;
UINT32 Reserved;
EFI_PHYSICAL_ADDRESS Base;
EFI_PHYSICAL_ADDRESS Length;
EFI_GUID FileSystem;
} EFI_FLASH_SUBAREA_ENTRY;
typedef struct {
UINT8 Reserved[3];
EFI_FLASH_AREA_TYPE AreaType;
EFI_GUID AreaTypeGuid;
UINT32 NumberOfEntries;
EFI_FLASH_SUBAREA_ENTRY Entries[1];
//
// Extended Hob data.
//
// VolumeId and FilePath indicating a unique file.
//
UINT32 VolumeId;
CHAR16 FilePath[258];
UINT32 ActuralSize;
UINT32 Offset;
} EFI_FLASH_MAP_FS_ENTRY_DATA;
#pragma pack()
#endif // #ifndef _EFI_FLASHMAP_H_
/*++
Copyright (c) 2004, 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:
EfiImageFormat.h
Abstract:
This file defines the data structures that are architecturally defined for file
images loaded via the FirmwareVolume protocol. The Firmware Volume specification
is the basis for these definitions.
--*/
#ifndef _EFI_IMAGE_FORMAT_H_
#define _EFI_IMAGE_FORMAT_H_
//
// pack all data structures since this is actually a binary format and we cannot
// allow internal padding in the data structures because of some compilerism..
//
#pragma pack(1)
//
// ////////////////////////////////////////////////////////////////////////////
//
// Architectural file types
//
typedef UINT8 EFI_FV_FILETYPE;
#define EFI_FV_FILETYPE_ALL 0x00
#define EFI_FV_FILETYPE_RAW 0x01
#define EFI_FV_FILETYPE_FREEFORM 0x02
#define EFI_FV_FILETYPE_SECURITY_CORE 0x03
#define EFI_FV_FILETYPE_PEI_CORE 0x04
#define EFI_FV_FILETYPE_DXE_CORE 0x05
#define EFI_FV_FILETYPE_PEIM 0x06
#define EFI_FV_FILETYPE_DRIVER 0x07
#define EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER 0x08
#define EFI_FV_FILETYPE_APPLICATION 0x09
//
// File type 0x0A is reserved and should not be used
//
#define EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE 0x0B
//
// ////////////////////////////////////////////////////////////////////////////
//
// Section types
//
typedef UINT8 EFI_SECTION_TYPE;
//
// ************************************************************
// The section type EFI_SECTION_ALL is a psuedo type. It is
// used as a wildcard when retrieving sections. The section
// type EFI_SECTION_ALL matches all section types.
// ************************************************************
//
#define EFI_SECTION_ALL 0x00
//
// ************************************************************
// Encapsulation section Type values
// ************************************************************
//
#define EFI_SECTION_COMPRESSION 0x01
#define EFI_SECTION_GUID_DEFINED 0x02
//
// ************************************************************
// Leaf section Type values
// ************************************************************
//
#define EFI_SECTION_FIRST_LEAF_SECTION_TYPE 0x10
#define EFI_SECTION_PE32 0x10
#define EFI_SECTION_PIC 0x11
#define EFI_SECTION_TE 0x12
#define EFI_SECTION_DXE_DEPEX 0x13
#define EFI_SECTION_VERSION 0x14
#define EFI_SECTION_USER_INTERFACE 0x15
#define EFI_SECTION_COMPATIBILITY16 0x16
#define EFI_SECTION_FIRMWARE_VOLUME_IMAGE 0x17
#define EFI_SECTION_FREEFORM_SUBTYPE_GUID 0x18
#define EFI_SECTION_RAW 0x19
#define EFI_SECTION_PEI_DEPEX 0x1B
#define EFI_SECTION_LAST_LEAF_SECTION_TYPE 0x1B
#define EFI_SECTION_LAST_SECTION_TYPE 0x1B
//
// ////////////////////////////////////////////////////////////////////////////
//
// Common section header
//
typedef struct {
UINT8 Size[3];
UINT8 Type;
} EFI_COMMON_SECTION_HEADER;
#define SECTION_SIZE(SectionHeaderPtr) \
((UINT32) (*((UINT32 *) ((EFI_COMMON_SECTION_HEADER *) SectionHeaderPtr)->Size) & 0x00ffffff))
//
// ////////////////////////////////////////////////////////////////////////////
//
// Compression section
//
//
// CompressionType values
//
#define EFI_NOT_COMPRESSED 0x00
#define EFI_STANDARD_COMPRESSION 0x01
#define EFI_CUSTOMIZED_COMPRESSION 0x02
typedef struct {
EFI_COMMON_SECTION_HEADER CommonHeader;
UINT32 UncompressedLength;
UINT8 CompressionType;
} EFI_COMPRESSION_SECTION;
//
// ////////////////////////////////////////////////////////////////////////////
//
// GUID defined section
//
typedef struct {
EFI_COMMON_SECTION_HEADER CommonHeader;
EFI_GUID SectionDefinitionGuid;
UINT16 DataOffset;
UINT16 Attributes;
} EFI_GUID_DEFINED_SECTION;
//
// Bit values for Attributes
//
#define EFI_GUIDED_SECTION_PROCESSING_REQUIRED 0x01
#define EFI_GUIDED_SECTION_AUTH_STATUS_VALID 0x02
//
// Bit values for AuthenticationStatus
//
#define EFI_AGGREGATE_AUTH_STATUS_PLATFORM_OVERRIDE 0x000001
#define EFI_AGGREGATE_AUTH_STATUS_IMAGE_SIGNED 0x000002
#define EFI_AGGREGATE_AUTH_STATUS_NOT_TESTED 0x000004
#define EFI_AGGREGATE_AUTH_STATUS_TEST_FAILED 0x000008
#define EFI_AGGREGATE_AUTH_STATUS_ALL 0x00000f
#define EFI_LOCAL_AUTH_STATUS_PLATFORM_OVERRIDE 0x010000
#define EFI_LOCAL_AUTH_STATUS_IMAGE_SIGNED 0x020000
#define EFI_LOCAL_AUTH_STATUS_NOT_TESTED 0x040000
#define EFI_LOCAL_AUTH_STATUS_TEST_FAILED 0x080000
#define EFI_LOCAL_AUTH_STATUS_ALL 0x0f0000
//
// ////////////////////////////////////////////////////////////////////////////
//
// PE32+ section
//
typedef struct {
EFI_COMMON_SECTION_HEADER CommonHeader;
} EFI_PE32_SECTION;
//
// ////////////////////////////////////////////////////////////////////////////
//
// PIC section
//
typedef struct {
EFI_COMMON_SECTION_HEADER CommonHeader;
} EFI_PIC_SECTION;
//
// ////////////////////////////////////////////////////////////////////////////
//
// PEIM header section
//
typedef struct {
EFI_COMMON_SECTION_HEADER CommonHeader;
} EFI_PEIM_HEADER_SECTION;
//
// ////////////////////////////////////////////////////////////////////////////
//
// DEPEX section
//
typedef struct {
EFI_COMMON_SECTION_HEADER CommonHeader;
} EFI_DEPEX_SECTION;
//
// ////////////////////////////////////////////////////////////////////////////
//
// Version section
//
typedef struct {
EFI_COMMON_SECTION_HEADER CommonHeader;
UINT16 BuildNumber;
INT16 VersionString[1];
} EFI_VERSION_SECTION;
//
// ////////////////////////////////////////////////////////////////////////////
//
// User interface section
//
typedef struct {
EFI_COMMON_SECTION_HEADER CommonHeader;
INT16 FileNameString[1];
} EFI_USER_INTERFACE_SECTION;
//
// ////////////////////////////////////////////////////////////////////////////
//
// Code16 section
//
typedef struct {
EFI_COMMON_SECTION_HEADER CommonHeader;
} EFI_CODE16_SECTION;
//
// ////////////////////////////////////////////////////////////////////////////
//
// Firmware Volume Image section
//
typedef struct {
EFI_COMMON_SECTION_HEADER CommonHeader;
} EFI_FIRMWARE_VOLUME_IMAGE_SECTION;
//
// ////////////////////////////////////////////////////////////////////////////
//
// Freeform subtype GUID section
//
typedef struct {
EFI_COMMON_SECTION_HEADER CommonHeader;
EFI_GUID SubTypeGuid;
} EFI_FREEFORM_SUBTYPE_GUID_SECTION;
//
// ////////////////////////////////////////////////////////////////////////////
//
// Raw section
//
typedef struct {
EFI_COMMON_SECTION_HEADER CommonHeader;
} EFI_RAW_SECTION;
//
// undo the pragma from the beginning...
//
#pragma pack()
typedef union {
EFI_COMMON_SECTION_HEADER *CommonHeader;
EFI_COMPRESSION_SECTION *CompressionSection;
EFI_GUID_DEFINED_SECTION *GuidDefinedSection;
EFI_PE32_SECTION *Pe32Section;
EFI_PIC_SECTION *PicSection;
EFI_PEIM_HEADER_SECTION *PeimHeaderSection;
EFI_DEPEX_SECTION *DependencySection;
EFI_VERSION_SECTION *VersionSection;
EFI_USER_INTERFACE_SECTION *UISection;
EFI_CODE16_SECTION *Code16Section;
EFI_FIRMWARE_VOLUME_IMAGE_SECTION *FVImageSection;
EFI_FREEFORM_SUBTYPE_GUID_SECTION *FreeformSubtypeSection;
EFI_RAW_SECTION *RawSection;
} EFI_FILE_SECTION_POINTER;
//
// EFI_FV_ATTRIBUTES bit definitions
//
typedef UINT64 EFI_FV_ATTRIBUTES;
typedef UINT32 EFI_FV_FILE_ATTRIBUTES;
typedef UINT32 EFI_FV_WRITE_POLICY;
typedef struct {
EFI_GUID *NameGuid;
EFI_FV_FILETYPE Type;
EFI_FV_FILE_ATTRIBUTES FileAttributes;
VOID *Buffer;
UINT32 BufferSize;
} EFI_FV_WRITE_FILE_DATA;
#endif
/** @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:
EfiLdrHandoff.h
Abstract:
Revision History:
**/
#ifndef _EFILDR_HANDOFF_H_
#define _EFILDR_HANDOFF_H_
#include <Base.h>
#include <Uefi.h>
#define EFILDR_BASE_SEGMENT 0x2000
#define EFILDR_LOAD_ADDRESS (EFILDR_BASE_SEGMENT << 4)
#define EFILDR_HEADER_ADDRESS (EFILDR_LOAD_ADDRESS+0x2000)
#define EFILDR_CB_VA 0x00
typedef struct _EFILDRHANDOFF {
UINTN MemDescCount;
EFI_MEMORY_DESCRIPTOR *MemDesc;
VOID *BfvBase;
UINTN BfvSize;
VOID *DxeIplImageBase;
UINTN DxeIplImageSize;
VOID *DxeCoreImageBase;
UINTN DxeCoreImageSize;
VOID *DxeCoreEntryPoint;
} EFILDRHANDOFF;
typedef struct {
UINT32 CheckSum;
UINT32 Offset;
UINT32 Length;
UINT8 FileName[52];
} EFILDR_IMAGE;
typedef struct {
UINT32 Signature;
UINT32 HeaderCheckSum;
UINT32 FileLength;
UINT32 NumberOfImages;
} EFILDR_HEADER;
#endif
/** @file
Copyright (c) 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:
FlashLayout.h
Abstract:
Platform specific flash layout
**/
#ifndef _EFI_FLASH_LAYOUT
#define _EFI_FLASH_LAYOUT
#include <EfiFlashMap.h>
//
// Firmware Volume Information for DUET
//
#define FV_BLOCK_SIZE 0x10000
#define FV_BLOCK_MASK 0x0FFFF
#define EFI_RUNTIME_UPDATABLE_FV_HEADER_LENGTH (sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY))
#define NV_STORAGE_SIZE 0x4000
#define NV_STORAGE_FVB_SIZE ((NV_STORAGE_SIZE + EFI_RUNTIME_UPDATABLE_FV_HEADER_LENGTH + FV_BLOCK_MASK) & ~FV_BLOCK_MASK)
#define NV_STORAGE_FVB_BLOCK_NUM (NV_STORAGE_FVB_SIZE / FV_BLOCK_SIZE)
#define NV_FTW_WORKING_SIZE 0x2000
#define NV_FTW_SPARE_SIZE 0x10000
#define NV_FTW_FVB_SIZE ((NV_FTW_WORKING_SIZE + NV_FTW_SPARE_SIZE + EFI_RUNTIME_UPDATABLE_FV_HEADER_LENGTH + FV_BLOCK_MASK) & ~FV_BLOCK_MASK)
#define NV_FTW_FVB_BLOCK_NUM (NV_FTW_FVB_SIZE / FV_BLOCK_SIZE)
#define NV_STORAGE_FILE_PATH L".\\Efivar.bin"
#define BOOT1_BASE ((UINTN) 0xE000U)
#define BOOT1_MAGIC 0xAA55
typedef struct {
UINT8 LoaderCode[496];
UINT8 Signature[14];
UINT16 Magic;
} BOOT1_LOADER;
#endif // _EFI_FLASH_LAYOUT
/** @file
Copyright (c) 2006 - 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:
AcpiDescription.h
Abstract:
GUIDs used for ACPI Description
**/
#ifndef _EFI_ACPI_DESCRIPTION_H_
#define _EFI_ACPI_DESCRIPTION_H_
#include <IndustryStandard/Acpi.h>
#define EFI_ACPI_DESCRIPTION_GUID \
{ \
0x3c699197, 0x93c, 0x4c69, {0xb0, 0x6b, 0x12, 0x8a, 0xe3, 0x48, 0x1d, 0xc9} \
}
//
// Following structure defines ACPI Description information.
// This information is platform specific, may be consumed by DXE generic driver.
//
#pragma pack(1)
typedef struct _EFI_ACPI_DESCRIPTION {
//
// For Timer
//
EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE PM_TMR_BLK;
UINT8 PM_TMR_LEN;
UINT8 TMR_VAL_EXT;
//
// For RTC
//
UINT8 DAY_ALRM;
UINT8 MON_ALRM;
UINT8 CENTURY;
//
// For Reset
//
EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE RESET_REG;
UINT8 RESET_VALUE;
//
// For Shutdown
//
EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE PM1a_EVT_BLK;
EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE PM1b_EVT_BLK;
EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE PM1a_CNT_BLK;
EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE PM1b_CNT_BLK;
EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE PM2_CNT_BLK;
UINT8 PM1_EVT_LEN;
UINT8 PM1_CNT_LEN;
UINT8 PM2_CNT_LEN;
UINT8 SLP_TYPa;
UINT8 SLP_TYPb;
//
// For sleep
//
UINT8 SLP1_TYPa;
UINT8 SLP1_TYPb;
UINT8 SLP2_TYPa;
UINT8 SLP2_TYPb;
UINT8 SLP3_TYPa;
UINT8 SLP3_TYPb;
UINT8 SLP4_TYPa;
UINT8 SLP4_TYPb;
//
// GPE
//
EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE GPE0_BLK;
EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE GPE1_BLK;
UINT8 GPE0_BLK_LEN;
UINT8 GPE1_BLK_LEN;
UINT8 GPE1_BASE;
//
// IAPC Boot Arch
//
UINT16 IAPC_BOOT_ARCH;
//
// Flags
//
UINT32 Flags;
} EFI_ACPI_DESCRIPTION;
#pragma pack()
extern EFI_GUID gEfiAcpiDescriptionGuid;
#endif
/** @file
Guid is EDKII DxeCore moudle GUID.
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 __DXE_CORE_FILE_NAME__
#define __DXE_CORE_FILE_NAME__
#define DXE_CORE_FILE_NAME_GUID \
{ 0xD6A2CB7F, 0x6A18, 0x4e2f, {0xB4, 0x3B, 0x99, 0x20, 0xA7, 0x33, 0x70, 0x0A }}
extern EFI_GUID gDxeCoreFileNameGuid;
#endif
/** @file
Copyright (c) 2004, 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:
FlashMapHob.h
Abstract:
GUID used for Flash Map HOB entries in the HOB list.
**/
#ifndef _FLASH_MAP_HOB_GUID_H_
#define _FLASH_MAP_HOB_GUID_H_
//
// Definitions for Flash Map
//
#define EFI_FLASH_MAP_HOB_GUID \
{ 0xb091e7d2, 0x5a0, 0x4198, {0x94, 0xf0, 0x74, 0xb7, 0xb8, 0xc5, 0x54, 0x59} }
extern EFI_GUID gEfiFlashMapHobGuid;
#endif // _FLASH_MAP_HOB_GUID_H_
/** @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
/** @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
/** @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
Duet BDS library.
Copyright (c) 2004 - 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 that 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 _DUET_BDS_LIB_H_
#define _DUET_BDS_LIB_H_
///
/// ConnectType
///
#define CONSOLE_OUT 0x00000001
#define STD_ERROR 0x00000002
#define CONSOLE_IN 0x00000004
#define CONSOLE_ALL (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)
typedef struct {
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
UINTN ConnectType;
} BDS_CONSOLE_CONNECT_ENTRY;
/**
This function reads the EFI variable (VendorGuid/Name) and returns a dynamically allocated
buffer and the size of the buffer. If it fails, return NULL.
@param Name The string part of the EFI variable name.
@param VendorGuid The GUID part of the EFI variable name.
@param VariableSize Returns the size of the EFI variable that was read.
@return Dynamically allocated memory that contains a copy
of the EFI variable. The caller is responsible for
freeing the buffer.
@retval NULL The variable was not read.
**/
VOID *
EFIAPI
BdsLibGetVariableAndSize (
IN CHAR16 *Name,
IN EFI_GUID *VendorGuid,
OUT UINTN *VariableSize
);
//
// Bds connect and disconnect driver lib funcions
//
/**
This function connects all system drivers with the corresponding controllers.
**/
VOID
EFIAPI
BdsLibConnectAllDriversToAllControllers (
VOID
);
/**
This function connects all system drivers to controllers.
**/
VOID
EFIAPI
BdsLibConnectAll (
VOID
);
/**
This function creates all handles associated with the given device
path node. If the handle associated with one device path node cannot
be created, then it tries to execute the dispatch to load the missing drivers.
@param DevicePathToConnect The device path to be connected. Can be
a multi-instance device path.
@retval EFI_SUCCESS All handles associates with every device path node
were created.
@retval EFI_OUT_OF_RESOURCES Not enough resources to create new handles.
@retval EFI_NOT_FOUND At least one handle could not be created.
**/
EFI_STATUS
EFIAPI
BdsLibConnectDevicePath (
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect
);
/**
This function will connect all current system handles recursively.
gBS->ConnectController() service is invoked for each handle exist in system handler buffer.
If the handle is bus type handler, all childrens also will be connected recursively by gBS->ConnectController().
@retval EFI_SUCCESS All handles and child handles have been
connected.
@retval EFI_STATUS Return the status of gBS->LocateHandleBuffer().
**/
EFI_STATUS
EFIAPI
BdsLibConnectAllEfi (
VOID
);
/**
This function will disconnect all current system handles.
gBS->DisconnectController() is invoked for each handle exists in system handle buffer.
If handle is a bus type handle, all childrens also are disconnected recursively by gBS->DisconnectController().
@retval EFI_SUCCESS All handles have been disconnected.
@retval EFI_STATUS Error status returned by of gBS->LocateHandleBuffer().
**/
EFI_STATUS
EFIAPI
BdsLibDisconnectAllEfi (
VOID
);
//
// Bds console related lib functions
//
/**
This function will search every simpletxt device in the current system,
and make every simpletxt device a potential console device.
**/
VOID
EFIAPI
BdsLibConnectAllConsoles (
VOID
);
/**
This function will connect console device based on the console
device variable ConIn, ConOut and ErrOut.
@retval EFI_SUCCESS At least one of the ConIn and ConOut devices have
been connected.
@retval EFI_STATUS Return the status of BdsLibConnectConsoleVariable ().
**/
EFI_STATUS
EFIAPI
BdsLibConnectAllDefaultConsoles (
VOID
);
/**
This function updates the console variable based on ConVarName. It can
add or remove one specific console device path from the variable
@param ConVarName The console-related variable name: ConIn, ConOut,
ErrOut.
@param CustomizedConDevicePath The console device path to be added to
the console variable ConVarName. Cannot be multi-instance.
@param ExclusiveDevicePath The console device path to be removed
from the console variable ConVarName. Cannot be multi-instance.
@retval EFI_UNSUPPORTED The added device path is the same as a removed one.
@retval EFI_SUCCESS Successfully added or removed the device path from the
console variable.
**/
EFI_STATUS
EFIAPI
BdsLibUpdateConsoleVariable (
IN CHAR16 *ConVarName,
IN EFI_DEVICE_PATH_PROTOCOL *CustomizedConDevicePath,
IN EFI_DEVICE_PATH_PROTOCOL *ExclusiveDevicePath
);
/**
Connect the console device base on the variable ConVarName. If
ConVarName is a multi-instance device path, and at least one
instance connects successfully, then this function
will return success.
If the handle associate with one device path node can not
be created successfully, then still give chance to do the dispatch,
which load the missing drivers if possible.
@param ConVarName The console related variable name: ConIn, ConOut,
ErrOut.
@retval EFI_NOT_FOUND No console devices were connected successfully
@retval EFI_SUCCESS Connected at least one instance of the console
device path based on the variable ConVarName.
**/
EFI_STATUS
EFIAPI
BdsLibConnectConsoleVariable (
IN CHAR16 *ConVarName
);
//
// Bds device path related lib functions
//
/**
Delete the instance in Multi that overlaps with Single.
@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 removes the device path instances in Multi that overlap
Single, and returns the resulting device path. If there is no
remaining device path as a result, this function will return NULL.
**/
EFI_DEVICE_PATH_PROTOCOL *
EFIAPI
BdsLibDelPartMatchInstance (
IN EFI_DEVICE_PATH_PROTOCOL *Multi,
IN EFI_DEVICE_PATH_PROTOCOL *Single
);
/**
This 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 a
Multi device path.
@retval FALSE The Single device path is not contained within a
Multi device path.
**/
BOOLEAN
EFIAPI
BdsLibMatchDevicePaths (
IN EFI_DEVICE_PATH_PROTOCOL *Multi,
IN EFI_DEVICE_PATH_PROTOCOL *Single
);
/**
Connect the specific USB device that matches the RemainingDevicePath,
and whose bus is determined by Host Controller (Uhci or Ehci).
@param HostControllerPI Uhci (0x00) or Ehci (0x20) or Both uhci and ehci
(0xFF).
@param RemainingDevicePath A short-form device path that starts with the first
element being a USB WWID or a USB Class device
path.
@retval EFI_SUCCESS The specific Usb device is connected successfully.
@retval EFI_INVALID_PARAMETER Invalid HostControllerPi (not 0x00, 0x20 or 0xFF)
or RemainingDevicePath is not the USB class device path.
@retval EFI_NOT_FOUND The device specified by device path is not found.
**/
EFI_STATUS
EFIAPI
BdsLibConnectUsbDevByShortFormDP (
IN UINT8 HostControllerPI,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
);
/**
Platform Bds initialization. Includes the platform firmware vendor, revision
and so crc check.
**/
VOID
EFIAPI
PlatformBdsInit (
VOID
);
/**
The function will execute with as the platform policy, current policy
is driven by boot mode. IBV/OEM can customize this code for their specific
policy action.
**/
VOID
EFIAPI
PlatformBdsPolicyBehavior (
VOID
);
#endif
/** @file
The VGA Mini Port Protocol used to set the text display mode of a VGA controller.
Copyright (c) 2006 - 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 that 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 __VGA_MINI_PORT_H_
#define __VGA_MINI_PORT_H_
///
/// Global ID for the EFI_VGA_MINI_PORT_PROTOCOL.
///
#define EFI_VGA_MINI_PORT_PROTOCOL_GUID \
{ \
0xc7735a2f, 0x88f5, 0x4882, {0xae, 0x63, 0xfa, 0xac, 0x8c, 0x8b, 0x86, 0xb3 } \
}
///
/// Forward declaration for the EFI_VGA_MINI_PORT_PROTOCOL.
///
typedef struct _EFI_VGA_MINI_PORT_PROTOCOL EFI_VGA_MINI_PORT_PROTOCOL;
/**
Sets the text display mode of a VGA controller.
Sets the text display mode of the VGA controller to the mode specified by
ModeNumber. A ModeNumber of 0 is a request for an 80x25 text mode. A
ModeNumber of 1 is a request for an 80x50 text mode. If ModeNumber is greater
than MaxModeNumber, then EFI_UNSUPPORTED is returned. If the VGA controller
is not functioning properly, then EFI_DEVICE_ERROR is returned. If the VGA
controller is sucessfully set to the mode number specified by ModeNumber, then
EFI_SUCCESS is returned.
@param[in] This A pointer to the EFI_VGA_MINI_PORT_PROTOCOL instance.
@param[in] ModeNumber The requested mode number. 0 for 80x25. 1 for 80x5.
@retval EFI_SUCCESS The mode number was set.
@retval EFI_UNSUPPORTED The mode number specified by ModeNumber is not supported.
@retval EFI_DEVICE_ERROR The device is not functioning properly.
**/
typedef
EFI_STATUS
(EFIAPI *EFI_VGA_MINI_PORT_SET_MODE)(
IN EFI_VGA_MINI_PORT_PROTOCOL *This,
IN UINTN ModeNumber
);
struct _EFI_VGA_MINI_PORT_PROTOCOL {
EFI_VGA_MINI_PORT_SET_MODE SetMode;
///
/// MMIO base address of the VGA text mode framebuffer. Typically set to 0xB8000.
///
UINT64 VgaMemoryOffset;
///
/// I/O Port address for the VGA CRTC address register. Typically set to 0x3D4.
///
UINT64 CrtcAddressRegisterOffset;
///
/// I/O Port address for the VGA CRTC data register. Typically set to 0x3D5.
///
UINT64 CrtcDataRegisterOffset;
///
/// PCI Controller MMIO BAR index of the VGA text mode frame buffer. Typically
/// set to EFI_PCI_IO_PASS_THROUGH_BAR
///
UINT8 VgaMemoryBar;
///
/// PCI Controller I/O BAR index of the VGA CRTC address register. Typically
/// set to EFI_PCI_IO_PASS_THROUGH_BAR
///
UINT8 CrtcAddressRegisterBar;
///
/// PCI Controller I/O BAR index of the VGA CRTC data register. Typically set
/// to EFI_PCI_IO_PASS_THROUGH_BAR
///
UINT8 CrtcDataRegisterBar;
///
/// The maximum number of text modes that this VGA controller supports.
///
UINT8 MaxMode;
};
extern EFI_GUID gEfiVgaMiniPortProtocolGuid;
#endif
## @file
#
# HFS+ Filesystem Driver
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = HfsPlus
FILE_GUID = 6839D927-3CAC-4CF9-B05A-400A623B327E
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
#
[Binaries.Ia32]
PE32|IA32/HfsPlusLegacy.efi|*
[Binaries.X64]
PE32|X64/HfsPlusLegacy.efi|*
## @file
#
# OpenCore USB Keyboard Driver
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = OpenUsbKbDxe
FILE_GUID = B4B18806-349E-4305-A7F3-2BD23C8FC1B2
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
#
[Binaries.Ia32]
PE32|IA32/OpenUsbKbDxe.efi|*
[Binaries.X64]
PE32|X64/OpenUsbKbDxe.efi|*
BinDrivers
==========
Put binary drivers here and enable them in DuetPkg.fdf.
DESTDIR ?= bin
BOOTSECTORS = boot0 boot1f32
MKDIR ?= mkdir
BOOTSECTOR_SRCS = $(addsuffix .nasm, $(BOOTSECTORS))
BOOTSECTOR_BINS = $(addprefix $(DESTDIR)/, $(BOOTSECTORS))
ifdef NASM_PREFIX
NASM=$(NASM_PREFIX)nasm
else
NASM=nasm
endif
all: $(BOOTSECTOR_BINS)
$(BOOTSECTOR_BINS): $(BOOTSECTOR_SRCS)
@$(MKDIR) -p bin
@echo "[NASM] $(@F).nasm -> $@"
@"$(NASM)" $(@F).nasm -f bin -o $@
clean:
rm -f $(BOOTSECTOR_BINS) *~
此差异已折叠。
; Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
;
; @APPLE_LICENSE_HEADER_START@
;
; Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
; Reserved. This file contains Original Code and/or Modifications of
; Original Code as defined in and that are subject to the Apple Public
; Source License Version 2.0 (the "License"). You may not use this file
; except in compliance with the License. Please obtain a copy of the
; License at http://www.apple.com/publicsource and read it before using
; this file.
;
; The Original Code and all software distributed under the License are
; distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
; EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
; INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
; FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
; License for the specific language governing rights and limitations
; under the License.
;
; @APPLE_LICENSE_HEADER_END@
;
; Partition Boot Loader: boot1f32
;
; This program is designed to reside in sector 0 of a FAT32 partition.
; It expects that the MBR has left the drive number in DL
; and a pointer to the partition entry in SI.
;
; This version requires a BIOS with EBIOS (LBA) support.
;
; This code is written for the NASM assembler.
; nasm boot1f32.s -o boot1f32
;
; dd if=origbs of=newbs skip=3 seek=3 bs=1 count=87 conv=notrunc
;
;
; This version of boot1f32 tries to find a stage2 boot file in the root folder.
;
; Written by mackerintel on 2009-01-26
;
;
; Set to 1 to enable obscure debug messages.
;
DEBUG EQU 0
;
; Set to 1 to enable verbose mode.
;
VERBOSE EQU 0
;
; Various constants.
;
NULL EQU 0
CR EQU 0x0D
LF EQU 0x0A
maxSectorCount EQU 64 ; maximum sector count for readSectors
kSectorBytes EQU 512 ; sector size in bytes
kBootSignature EQU 0xAA55 ; boot sector signature
kBoot1StackAddress EQU 0xFFF0 ; boot1 stack pointer
kBoot1LoadAddr EQU 0xE000 ; boot1 load address
kBoot2Sectors EQU (480 * 1024 - 512) / kSectorBytes ; max size of 'boot' file in sectors
kBoot2Segment EQU 0x2000 ; boot2 load segment
kBoot2Address EQU kSectorBytes ; boot2 load address
FATBUF EQU 0x7000 ; Just place for one sectors
DIRBUFSEG EQU 0x1000 ; Cluster sizes >64KB aren't supported
;
; Format of fdisk partition entry.
;
; The symbol 'part_size' is automatically defined as an `EQU'
; giving the size of the structure.
;
struc part
.bootid resb 1 ; bootable or not
.head resb 1 ; starting head, sector, cylinder
.sect resb 1 ;
.cyl resb 1 ;
.type resb 1 ; partition type
.endhead resb 1 ; ending head, sector, cylinder
.endsect resb 1 ;
.endcyl resb 1 ;
.lba resd 1 ; starting lba
.sectors resd 1 ; size in sectors
endstruc
struc direntry
.nameext resb 11
.attr resb 1
.nused1 resb 8
.highclus resw 1
.nused2 resb 4
.lowclus resw 1
.size resd 1
endstruc
;
; Macros.
;
%macro jmpabs 1
push WORD %1
ret
%endmacro
%macro DebugCharMacro 1
pushad
mov al, %1
call print_char
call getc
popad
%endmacro
%macro PrintCharMacro 1
pushad
mov al, %1
call print_char
popad
%endmacro
%macro PutCharMacro 1
call print_char
%endmacro
%macro PrintHexMacro 1
call print_hex
%endmacro
%macro PrintString 1
mov si, %1
call print_string
%endmacro
%macro LogString 1
mov di, %1
call log_string
%endmacro
%if DEBUG
%define DebugChar(x) DebugCharMacro x
%define PrintChar(x) PrintCharMacro x
%define PutChar(x) PutCharMacro
%define PrintHex(x) PrintHexMacro x
%else
%define DebugChar(x)
%define PrintChar(x)
%define PutChar(x)
%define PrintHex(x)
%endif
;--------------------------------------------------------------------------
; Start of text segment.
SEGMENT .text
ORG kBoot1LoadAddr
jmp start
times 3-($-$$) nop
gOEMName times 8 db 0 ;OEMNAME
gBPS dw 0
gSPC db 0
gReservedSectors dw 0
gNumFats db 0
gCrap1 times 11 db 0
gPartLBA dd 0
gPartSize dd 0
gSectPerFat dd 0
gCrap2 times 4 db 0
gRootCluster dd 0
gCrap3 times 16 db 0
gBIOSDriveNumber db 0
gExtInfo times 25 db 0
gFileName db "BOOT " ; Used as a magic string in boot0
;--------------------------------------------------------------------------
; Boot code is loaded at 0:E000h.
;
start:
;
; set up the stack to grow down from kBoot1StackSegment:kBoot1StackAddress.
; Interrupts should be off while the stack is being manipulated.
;
cli ; interrupts off
xor eax, eax ; zero ax
mov ss, ax ; ss <- 0
mov sp, kBoot1StackAddress ; sp <- top of stack
sti ; reenable interrupts
mov ds, ax ; ds <- 0
mov es, ax ; es <- 0
;
; Initializing global variables.
;
mov ax, word [gReservedSectors]
add eax, [si + part.lba]
mov [gPartLBA], eax ; save the current FAT LBA offset
mov [gBIOSDriveNumber], dl ; save BIOS drive number
xor eax,eax
mov al, [gNumFats]
mul dword [gSectPerFat]
mov [gSectPerFat], eax
;--------------------------------------------------------------------------
; Find stage2 boot file in a FAT32 Volume's root folder.
;
findRootBoot:
%if VERBOSE
LogString(init_str)
%endif
mov eax, [gRootCluster]
nextdirclus:
mov edx, DIRBUFSEG<<4
call readCluster
jc error
xor si, si
mov bl, [gSPC]
shl bx, 9
add bx, si
nextdirent:
mov di, gFileName
push ds
push DIRBUFSEG
pop ds
mov cl, [si]
test cl, cl
jz dserror
mov cx, 11
repe cmpsb
jz direntfound
falsealert:
pop ds
add cl, 21
add si, cx
cmp si, bx
jz nextdirclus
jmp nextdirent
direntfound:
lodsb
test al, 0x18
jnz falsealert
push WORD [si + direntry.highclus - 12]
push WORD [si + direntry.lowclus - 12]
pop eax
pop ds
mov edx, (kBoot2Segment << 4) + kBoot2Address
cont_read:
push edx
call readCluster
pop edx
pushf
xor ebx,ebx
mov bl, [gSPC]
shl ebx, 9
add edx, ebx
popf
jnc cont_read
boot2:
%if DEBUG
DebugChar ('!')
%endif
mov dl, [gBIOSDriveNumber] ; load BIOS drive number
jmp kBoot2Segment:kBoot2Address
dserror:
pop ds
error:
%if VERBOSE
LogString(error_str)
%endif
hang:
hlt
jmp hang
; readCluster - Reads cluster EAX to (EDX), updates EAX to next cluster
readCluster:
cmp eax, 0x0ffffff8
jb do_read
stc
ret
do_read:
push eax
xor ecx,ecx
dec eax
dec eax
mov cl, [gSPC]
push edx
mul ecx
pop edx
add eax, [gSectPerFat]
mov ecx, eax
xor ah,ah
mov al, [gSPC]
call readSectors
jc clusend
pop ecx
push cx
shr ecx, 7
xor ax, ax
inc ax
mov edx, FATBUF
call readSectors
jc clusend
pop si
and si, 0x7f
shl si, 2
mov eax, [FATBUF + si]
and eax, 0x0fffffff
clc
ret
clusend:
pop eax
ret
;--------------------------------------------------------------------------
; readSectors - Reads more than 127 sectors using LBA addressing.
;
; Arguments:
; AX = number of 512-byte sectors to read (valid from 1-1280).
; EDX = pointer to where the sectors should be stored.
; ECX = sector offset in partition
;
; Returns:
; CF = 0 success
; 1 error
;
readSectors:
pushad
mov bx, ax
.loop:
xor eax, eax ; EAX = 0
mov al, bl ; assume we reached the last block.
cmp bx, maxSectorCount ; check if we really reached the last block
jb .readBlock ; yes, BX < MaxSectorCount
mov al, maxSectorCount ; no, read MaxSectorCount
.readBlock:
call readLBA
sub bx, ax ; decrease remaning sectors with the read amount
jz .exit ; exit if no more sectors left to be loaded
add ecx, eax ; adjust LBA sector offset
shl ax, 9 ; convert sectors to bytes
add edx, eax ; adjust target memory location
jmp .loop ; read remaining sectors
.exit:
popad
ret
;--------------------------------------------------------------------------
; readLBA - Read sectors from a partition using LBA addressing.
;
; Arguments:
; AL = number of 512-byte sectors to read (valid from 1-127).
; EDX = pointer to where the sectors should be stored.
; ECX = sector offset in partition
; [bios_drive_number] = drive number (0x80 + unit number)
;
; Returns:
; CF = 0 success
; 1 error
;
readLBA:
pushad ; save all registers
push es ; save ES
mov bp, sp ; save current SP
;
; Convert EDX to segment:offset model and set ES:BX
;
; Some BIOSes do not like offset to be negative while reading
; from hard drives. This usually leads to "boot1: error" when trying
; to boot from hard drive, while booting normally from USB flash.
; The routines, responsible for this are apparently different.
; Thus we split linear address slightly differently for these
; capricious BIOSes to make sure offset is always positive.
;
mov bx, dx ; save offset to BX
and bh, 0x0f ; keep low 12 bits
shr edx, 4 ; adjust linear address to segment base
xor dl, dl ; mask low 8 bits
mov es, dx ; save segment to ES
;
; Create the Disk Address Packet structure for the
; INT13/F42 (Extended Read Sectors) on the stack.
;
; push DWORD 0 ; offset 12, upper 32-bit LBA
push ds ; For sake of saving memory,
push ds ; push DS register, which is 0.
add ecx, [gPartLBA] ; offset 8, lower 32-bit LBA
push ecx
push es ; offset 6, memory segment
push bx ; offset 4, memory offset
xor ah, ah ; offset 3, must be 0
push ax ; offset 2, number of sectors
push WORD 16 ; offset 0-1, packet size
;
; INT13 Func 42 - Extended Read Sectors
;
; Arguments:
; AH = 0x42
; [bios_drive_number] = drive number (0x80 + unit number)
; DS:SI = pointer to Disk Address Packet
;
; Returns:
; AH = return status (sucess is 0)
; carry = 0 success
; 1 error
;
; Packet offset 2 indicates the number of sectors read
; successfully.
;
mov dl, [gBIOSDriveNumber] ; load BIOS drive number
mov si, sp
mov ah, 0x42
int 0x13
jc error
;
; Issue a disk reset on error.
; Should this be changed to Func 0xD to skip the diskette controller
; reset?
;
; xor ax, ax ; Func 0
; int 0x13 ; INT 13
; stc ; set carry to indicate error
.exit:
mov sp, bp ; restore SP
pop es ; restore ES
popad
ret
%if VERBOSE
;--------------------------------------------------------------------------
; Write a string with 'boot1: ' prefix to the console.
;
; Arguments:
; ES:DI pointer to a NULL terminated string.
;
; Clobber list:
; DI
;
log_string:
pushad
push di
mov si, log_title_str
call print_string
pop si
call print_string
popad
ret
;-------------------------------------------------------------------------
; Write a string to the console.
;
; Arguments:
; DS:SI pointer to a NULL terminated string.
;
; Clobber list:
; AX, BX, SI
;
print_string:
mov bx, 1 ; BH=0, BL=1 (blue)
.loop:
lodsb ; load a byte from DS:SI into AL
cmp al, 0 ; Is it a NULL?
je .exit ; yes, all done
mov ah, 0xE ; INT10 Func 0xE
int 0x10 ; display byte in tty mode
jmp .loop
.exit:
ret
%endif ; VERBOSE
%if DEBUG
;--------------------------------------------------------------------------
; Write the 4-byte value to the console in hex.
;
; Arguments:
; EAX = Value to be displayed in hex.
;
print_hex:
pushad
mov cx, WORD 4
bswap eax
.loop:
push ax
ror al, 4
call print_nibble ; display upper nibble
pop ax
call print_nibble ; display lower nibble
ror eax, 8
loop .loop
popad
ret
print_nibble:
and al, 0x0f
add al, '0'
cmp al, '9'
jna .print_ascii
add al, 'A' - '9' - 1
.print_ascii:
call print_char
ret
;--------------------------------------------------------------------------
; getc - wait for a key press
;
getc:
pushad
mov ah, 0
int 0x16
popad
ret
;--------------------------------------------------------------------------
; Write a ASCII character to the console.
;
; Arguments:
; AL = ASCII character.
;
print_char:
pushad
mov bx, 1 ; BH=0, BL=1 (blue)
mov ah, 0x0e ; bios INT 10, Function 0xE
int 0x10 ; display byte in tty mode
popad
ret
%endif ; DEBUG
;--------------------------------------------------------------------------
; Static data.
;
%if VERBOSE
log_title_str db CR, LF, 'b1f: ', NULL
init_str db 'init', NULL
error_str db 'error', NULL
%endif
;--------------------------------------------------------------------------
; Pad the rest of the 512 byte sized sector with zeroes. The last
; two bytes is the mandatory boot sector signature.
;
; If the booter code becomes too large, then nasm will complain
; that the 'times' argument is negative.
pad_table_and_sig:
times 496-($-$$) db 0
; We will put volume magic identifier here
times 14 db 0
dw kBootSignature
ABSOLUTE kBoot1LoadAddr + kSectorBytes
; END
/*++ @file
Reset Architectural Protocol implementation.
Copyright (c) 2006 - 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.
--*/
#include <PiDxe.h>
#include <Protocol/Reset.h>
#include <Guid/AcpiDescription.h>
#include <Library/BaseLib.h>
#include <Library/IoLib.h>
#include <Library/PciLib.h>
#include <Library/HobLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/UefiBootServicesTableLib.h>
///
/// Handle for the Reset Architectural Protocol
///
EFI_HANDLE mResetHandle = NULL;
///
/// Copy of ACPI Description HOB in runtime memory
///
EFI_ACPI_DESCRIPTION mAcpiDescription;
/**
Reset the system.
@param[in] ResetType Warm or cold
@param[in] ResetStatus Possible cause of reset
@param[in] DataSize Size of ResetData in bytes
@param[in] ResetData Optional Unicode string
**/
VOID
EFIAPI
EfiAcpiResetSystem (
IN EFI_RESET_TYPE ResetType,
IN EFI_STATUS ResetStatus,
IN UINTN DataSize,
IN VOID *ResetData OPTIONAL
)
{
UINT8 Dev;
UINT8 Func;
UINT8 Register;
switch (ResetType) {
case EfiResetShutdown:
//
// 1. Write SLP_TYPa
//
if ((mAcpiDescription.PM1a_CNT_BLK.Address != 0) && (mAcpiDescription.SLP_TYPa != 0)) {
switch (mAcpiDescription.PM1a_CNT_BLK.AddressSpaceId) {
case EFI_ACPI_3_0_SYSTEM_IO:
IoAndThenOr16 ((UINTN)mAcpiDescription.PM1a_CNT_BLK.Address, 0xc3ff, (UINT16)(0x2000 | (mAcpiDescription.SLP_TYPa << 10)));
break;
case EFI_ACPI_3_0_SYSTEM_MEMORY:
MmioAndThenOr16 ((UINTN)mAcpiDescription.PM1a_CNT_BLK.Address, 0xc3ff, (UINT16)(0x2000 | (mAcpiDescription.SLP_TYPa << 10)));
break;
}
}
//
// 2. Write SLP_TYPb
//
if ((mAcpiDescription.PM1b_CNT_BLK.Address != 0) && (mAcpiDescription.SLP_TYPb != 0)) {
switch (mAcpiDescription.PM1b_CNT_BLK.AddressSpaceId) {
case EFI_ACPI_3_0_SYSTEM_IO:
IoAndThenOr16 ((UINTN)mAcpiDescription.PM1b_CNT_BLK.Address, 0xc3ff, (UINT16)(0x2000 | (mAcpiDescription.SLP_TYPb << 10)));
break;
case EFI_ACPI_3_0_SYSTEM_MEMORY:
MmioAndThenOr16 ((UINTN)mAcpiDescription.PM1b_CNT_BLK.Address, 0xc3ff, (UINT16)(0x2000 | (mAcpiDescription.SLP_TYPb << 10)));
break;
}
}
//
// If Shutdown fails, then let fall through to reset
//
case EfiResetWarm:
case EfiResetCold:
if ((mAcpiDescription.RESET_REG.Address != 0) &&
((mAcpiDescription.RESET_REG.AddressSpaceId == EFI_ACPI_3_0_SYSTEM_IO) ||
(mAcpiDescription.RESET_REG.AddressSpaceId == EFI_ACPI_3_0_SYSTEM_MEMORY) ||
(mAcpiDescription.RESET_REG.AddressSpaceId == EFI_ACPI_3_0_PCI_CONFIGURATION_SPACE))) {
//
// Use ACPI System Reset
//
switch (mAcpiDescription.RESET_REG.AddressSpaceId) {
case EFI_ACPI_3_0_SYSTEM_IO:
//
// Send reset request through I/O port register
//
IoWrite8 ((UINTN)mAcpiDescription.RESET_REG.Address, mAcpiDescription.RESET_VALUE);
//
// Halt
//
CpuDeadLoop ();
case EFI_ACPI_3_0_SYSTEM_MEMORY:
//
// Send reset request through MMIO register
//
MmioWrite8 ((UINTN)mAcpiDescription.RESET_REG.Address, mAcpiDescription.RESET_VALUE);
//
// Halt
//
CpuDeadLoop ();
case EFI_ACPI_3_0_PCI_CONFIGURATION_SPACE:
//
// Send reset request through PCI register
//
Register = (UINT8)mAcpiDescription.RESET_REG.Address;
Func = (UINT8) (RShiftU64 (mAcpiDescription.RESET_REG.Address, 16) & 0x7);
Dev = (UINT8) (RShiftU64 (mAcpiDescription.RESET_REG.Address, 32) & 0x1F);
PciWrite8 (PCI_LIB_ADDRESS (0, Dev, Func, Register), mAcpiDescription.RESET_VALUE);
//
// Halt
//
CpuDeadLoop ();
}
}
//
// If system comes here, means ACPI reset is not supported, so do Legacy System Reset, assume 8042 available
//
IoWrite8 (0x64, 0xfe);
CpuDeadLoop ();
default:
break;
}
//
// Given we should have reset getting here would be bad
//
ASSERT (FALSE);
CpuDeadLoop();
}
/**
Initialize the state information for the Reset Architectural Protocol.
@param[in] ImageHandle Image handle of the loaded driver
@param[in] SystemTable Pointer to the System Table
@retval EFI_SUCCESS Thread can be successfully created
@retval EFI_UNSUPPORTED Cannot find the info to reset system
**/
EFI_STATUS
EFIAPI
InitializeReset (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_HOB_GUID_TYPE *HobAcpiDescription;
//
// Make sure the Reset Architectural Protocol is not already installed in the system
//
ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiResetArchProtocolGuid);
//
// Get ACPI Description HOB
//
HobAcpiDescription = GetFirstGuidHob (&gEfiAcpiDescriptionGuid);
if (HobAcpiDescription == NULL) {
return EFI_UNSUPPORTED;
}
//
// Copy it to Runtime Memory
//
ASSERT (sizeof (EFI_ACPI_DESCRIPTION) == GET_GUID_HOB_DATA_SIZE (HobAcpiDescription));
CopyMem (&mAcpiDescription, GET_GUID_HOB_DATA (HobAcpiDescription), sizeof (EFI_ACPI_DESCRIPTION));
DEBUG ((DEBUG_INFO, "ACPI Reset Base - %lx\n", mAcpiDescription.RESET_REG.Address));
DEBUG ((DEBUG_INFO, "ACPI Reset Value - %02x\n", (UINTN)mAcpiDescription.RESET_VALUE));
DEBUG ((DEBUG_INFO, "IAPC support - %x\n", (UINTN)(mAcpiDescription.IAPC_BOOT_ARCH)));
//
// Hook the runtime service table
//
SystemTable->RuntimeServices->ResetSystem = EfiAcpiResetSystem;
//
// Install the Reset Architectural Protocol onto a new handle
//
Status = gBS->InstallMultipleProtocolInterfaces (
&mResetHandle,
&gEfiResetArchProtocolGuid, NULL,
NULL
);
ASSERT_EFI_ERROR (Status);
return Status;
}
## @file
# Component description file for AcpiResetDxe module.
#
# Copyright (c) 2006 - 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.
#
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = AcpiReset
FILE_GUID = 928EF6D4-72BC-4686-B57B-1EEB6ABD4F93
MODULE_TYPE = DXE_RUNTIME_DRIVER
VERSION_STRING = 1.0
ENTRY_POINT = InitializeReset
[Packages]
MdePkg/MdePkg.dec
OpenCorePkg/OpenDuetPkg.dec
[LibraryClasses]
DebugLib
UefiBootServicesTableLib
UefiDriverEntryPoint
IoLib
PciLib
HobLib
BaseLib
BaseMemoryLib
[Sources]
Reset.c
[Protocols]
gEfiResetArchProtocolGuid
[Guids]
gEfiAcpiDescriptionGuid
[Depex]
TRUE
/** @file
Head file for BDS Architectural Protocol implementation
Copyright (c) 2004 - 2014, 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 _BDS_MODULE_H_
#define _BDS_MODULE_H_
#include <Protocol/Bds.h>
/**
Install Boot Device Selection Protocol
@param ImageHandle The image handle.
@param SystemTable The system table.
@retval EFI_SUCEESS BDS has finished initializing.
Return the dispatcher and recall BDS.Entry
@retval Other Return status from AllocatePool() or gBS->InstallProtocolInterface
**/
EFI_STATUS
EFIAPI
BdsInitialize (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
/**
Service routine for BdsInstance->Entry(). Devices are connected, the
consoles are initialized, and the boot options are tried.
@param This Protocol Instance structure.
**/
VOID
EFIAPI
BdsEntry (
IN EFI_BDS_ARCH_PROTOCOL *This
);
#endif
## @file
#
# BDSDxe module is core driver for BDS phase.
# When DxeCore dispatching all DXE driver, this module will produce architecture protocol
# gEfiBdsArchProtocolGuid. After DxeCore finish dispatching, DxeCore will invoke Entry
# interface of protocol gEfiBdsArchProtocolGuid, then BDS phase is entered.
#
# Generally, this module take reposiblity to connect all necessary devices for platform boot,
# these boot device path are hold in PlatformBdsLib library instance produced by platform.
# For legacy boot, BDS will transfer control to legacy BIOS after legacy boot device is select.
# For EFI boot, BDS will load boot loader file EFI\BOOT\BOOTIA32.EFI, EFI\BOOT\BOOTX64.EFI,
# EFI\BOOT\BOOTIA64.EFI file from selected boot device and transfer control to boot loader.
#
# BDSDxe also maintain the UI for "Boot Manager, Boot Maintaince Manager, Device Manager" which
# is used for user to configure boot option or maintain hardware device.
#
# Copyright (c) 2008 - 2014, 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 = BdsDxe
MODULE_UNI_FILE = BdsDxe.uni
FILE_GUID = FC5C7020-1A48-4198-9BE2-EAD5ABC8CF2F
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
ENTRY_POINT = BdsInitialize
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]
Bds.h
BdsEntry.c
[Packages]
OpenCorePkg/OpenDuetPkg.dec
OpenCorePkg/OpenCorePkg.dec
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
OvmfPkg/OvmfPkg.dec
[LibraryClasses]
BaseLib
BaseMemoryLib
DebugLib
DevicePathLib
DuetBdsLib
MemoryAllocationLib
PcdLib
PrintLib
UefiBootServicesTableLib
UefiDriverEntryPoint
UefiLib
UefiRuntimeServicesTableLib
[Guids]
gEfiEndOfDxeEventGroupGuid
[Protocols]
gEfiSimpleFileSystemProtocolGuid ## PROTOCOL CONSUMES
gEfiCpuArchProtocolGuid
gEdkiiVariableLockProtocolGuid ## PROTOCOL CONSUMES
gEfiBdsArchProtocolGuid ## PROTOCOL PRODUCES
gEfiCapsuleArchProtocolGuid ## PROTOCOL PRODUCES
gEfiBlockIoProtocolGuid
[Pcd]
gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLangCodes ## CONSUMES
gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLang ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareRevision ## CONSUMES
[Depex]
TRUE
// /** @file
// BDSDxe module is core driver for BDS phase.
//
// When DxeCore dispatching all DXE driver, this module will produce architecture protocol
// gEfiBdsArchProtocolGuid. After DxeCore finish dispatching, DxeCore will invoke Entry
// interface of protocol gEfiBdsArchProtocolGuid, then BDS phase is entered.
//
// Generally, this module take reposiblity to connect all necessary devices for platform boot,
// these boot device path are hold in PlatformBdsLib library instance produced by platform.
// For legacy boot, BDS will transfer control to legacy BIOS after legacy boot device is select.
// For EFI boot, BDS will load boot loader file EFI\BOOT\BOOTIA32.EFI, EFI\BOOT\BOOTX64.EFI,
// EFI\BOOT\BOOTIA64.EFI file from selected boot device and transfer control to boot loader.
//
// BDSDxe also maintain the UI for "Boot Manager, Boot Maintaince Manager, Device Manager" which
// is used for user to configure boot option or maintain hardware device.
//
// Copyright (c) 2008 - 2014, 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.
//
// **/
#string STR_MODULE_ABSTRACT #language en-US "BDSDxe module is core driver for BDS phase"
#string STR_MODULE_DESCRIPTION #language en-US "When DxeCore dispatching all DXE driver, this module will produce architecture protocol gEfiBdsArchProtocolGuid. After DxeCore finishes dispatching, DxeCore will invoke the Entry interface of protocol gEfiBdsArchProtocolGuid. Then BDS phase is entered. Generally, this module takes reposiblity to connect all necessary devices for platform boot. These boot device paths are held in PlatformBdsLib a library instance produced by the platform. For legacy boot, BDS will transfer control to legacy BIOS after legacy boot device is selected. For EFI boot, BDS will load boot loader file EFI\BOOT\BOOTIA32.EFI, EFI\BOOT\BOOTX64.EFI, EFI\BOOT\BOOTIA64.EFI files from selected boot devices, and transfers control to the boot loader. BDSDxe also maintains the UI for \"Boot Manager, Boot Maintaince Manager, Device Manager\", which is used by the user to configure boot options or to maintain hardware devices."
/** @file
This module produce main entry for BDS phase - BdsEntry.
When this module was dispatched by DxeCore, gEfiBdsArchProtocolGuid will be installed
which contains interface of BdsEntry.
After DxeCore finish DXE phase, gEfiBdsArchProtocolGuid->BdsEntry will be invoked
to enter BDS phase.
Copyright (c) 2004 - 2014, 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 "Bds.h"
#include <Guid/GlobalVariable.h>
#include <Guid/EventGroup.h>
#include <FlashLayout.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/DevicePathLib.h>
#include <Library/DuetBdsLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PcdLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Protocol/Capsule.h>
#include <Protocol/BlockIo.h>
#include <Protocol/VariableLock.h>
///
/// BDS arch protocol instance initial value.
///
EFI_HANDLE gBdsHandle = NULL;
EFI_BDS_ARCH_PROTOCOL gBds = {
BdsEntry
};
///
/// The read-only variables defined in UEFI Spec.
///
CHAR16 *mReadOnlyVariables[] = {
L"PlatformLangCodes",
L"LangCodes",
L"BootOptionSupport",
L"HwErrRecSupport",
L"OsIndicationsSupported"
};
/**
Install Boot Device Selection Protocol
@param ImageHandle The image handle.
@param SystemTable The system table.
@retval EFI_SUCEESS BDS has finished initializing.
Return the dispatcher and recall BDS.Entry
@retval Other Return status from AllocatePool() or gBS->InstallProtocolInterface
**/
EFI_STATUS
EFIAPI
BdsInitialize (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
VOID *ReturnUnsupported;
#ifdef MDE_CPU_X64
STATIC UINT8 mReturnUnsupported[] = {0x48, 0xB8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC3};
#else
STATIC UINT8 mReturnUnsupported[] = {0xB8, 0x03, 0x00, 0x00, 0x80, 0xC3};
#endif
//
// Provide dummy functions
//
Status = gBS->AllocatePool (EfiRuntimeServicesCode, sizeof (mReturnUnsupported), (VOID **) &ReturnUnsupported);
ASSERT_EFI_ERROR (Status);
CopyMem (ReturnUnsupported, mReturnUnsupported, sizeof (mReturnUnsupported));
gRT->UpdateCapsule = (EFI_UPDATE_CAPSULE) ReturnUnsupported;
gRT->QueryCapsuleCapabilities = (EFI_QUERY_CAPSULE_CAPABILITIES) ReturnUnsupported;
//
// Install protocol interface
//
Status = gBS->InstallMultipleProtocolInterfaces (
&gBdsHandle,
&gEfiBdsArchProtocolGuid, &gBds,
&gEfiCapsuleArchProtocolGuid, NULL,
NULL
);
ASSERT_EFI_ERROR (Status);
return Status;
}
STATIC
EFI_STATUS
BdsCheckSignature (
IN EFI_HANDLE Handle
)
{
EFI_STATUS Status;
volatile BOOT1_LOADER *SelfSignature;
BOOT1_LOADER *DiskSignature;
UINTN DiskSignatureSize;
EFI_BLOCK_IO_PROTOCOL *BlockIo;
UINTN Index;
UINT8 NonZero;
SelfSignature = (volatile BOOT1_LOADER *) (BOOT1_BASE);
if (SelfSignature->Magic != BOOT1_MAGIC) {
return EFI_UNSUPPORTED;
}
Status = gBS->HandleProtocol (
Handle,
&gEfiBlockIoProtocolGuid,
(VOID **) &BlockIo
);
if (EFI_ERROR (Status)) {
return Status;
}
DiskSignatureSize = ALIGN_VALUE (
MAX (sizeof (*DiskSignature), BlockIo->Media->BlockSize),
BlockIo->Media->BlockSize
);
DiskSignature = AllocatePool (DiskSignatureSize);
if (DiskSignature == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Status = BlockIo->ReadBlocks (
BlockIo,
BlockIo->Media->MediaId,
0,
DiskSignatureSize,
DiskSignature
);
if (!EFI_ERROR (Status) && DiskSignature->Magic == SelfSignature->Magic) {
NonZero = 0;
for (Index = 0; Index < sizeof (SelfSignature->Signature); ++Index) {
if (SelfSignature->Signature[Index] != DiskSignature->Signature[Index]) {
Status = EFI_NOT_FOUND;
break;
}
NonZero |= SelfSignature->Signature[Index];
}
if (NonZero == 0) {
Status = EFI_NOT_FOUND;
}
} else {
Status = EFI_UNSUPPORTED;
}
FreePool (DiskSignature);
return Status;
}
/**
This function attempts to boot for the boot order specified
by platform policy.
**/
STATIC
VOID
BdsBootDeviceSelect (
IN BOOLEAN RequireValidDisk
)
{
EFI_STATUS Status;
UINTN Index;
EFI_HANDLE *FileSystemHandles;
UINTN NumberFileSystemHandles;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
EFI_HANDLE ImageHandle;
//
// Signal the EVT_SIGNAL_READY_TO_BOOT event
//
EfiSignalEventReadyToBoot ();
//
// If there is simple file protocol which does not consume block Io protocol, create a boot option for it here.
//
Status = gBS->LocateHandleBuffer (
ByProtocol,
&gEfiSimpleFileSystemProtocolGuid,
NULL,
&NumberFileSystemHandles,
&FileSystemHandles
);
if (EFI_ERROR (Status)) {
return;
}
for (Index = 0; Index < NumberFileSystemHandles; Index++) {
//
// Check matching volume DuetPkg was booted from.
//
if (RequireValidDisk) {
Status = BdsCheckSignature (FileSystemHandles[Index]);
if (EFI_ERROR (Status)) {
continue;
}
}
//
// Do the removable Media thing. \EFI\BOOT\boot{machinename}.EFI
// machinename is ia32, ia64, x64, ...
//
DevicePath = FileDevicePath (
FileSystemHandles[Index],
L"\\EFI\\OC\\OpenCore.efi"
);
if (DevicePath == NULL) {
continue;
}
ImageHandle = NULL;
Status = gBS->LoadImage (
TRUE,
gImageHandle,
DevicePath,
NULL,
0,
&ImageHandle
);
if (!EFI_ERROR (Status)) {
gBS->StartImage (
ImageHandle,
0,
NULL
);
}
FreePool (DevicePath);
}
if (NumberFileSystemHandles != 0) {
FreePool (FileSystemHandles);
}
}
/**
Validate input console variable data.
If found the device path is not a valid device path, remove the variable.
@param VariableName Input console variable name.
**/
STATIC
VOID
BdsFormalizeConsoleVariable (
IN CHAR16 *VariableName
)
{
EFI_STATUS Status;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
UINTN VariableSize;
DevicePath = BdsLibGetVariableAndSize (
VariableName,
&gEfiGlobalVariableGuid,
&VariableSize
);
if ((DevicePath != NULL) && !IsDevicePathValid (DevicePath, VariableSize)) {
Status = gRT->SetVariable (
VariableName,
&gEfiGlobalVariableGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
0,
NULL
);
ASSERT_EFI_ERROR (Status);
}
}
/**
Formalize Bds global variables.
1. For ConIn/ConOut/ConErr, if found the device path is not a valid device path, remove the variable.
2. For OsIndicationsSupported, Create a BS/RT/UINT64 variable to report caps
3. Delete OsIndications variable if it is not NV/BS/RT UINT64
Item 3 is used to solve case when OS corrupts OsIndications. Here simply delete this NV variable.
**/
STATIC
VOID
BdsFormalizeEfiGlobalVariable (
VOID
)
{
UINT64 OsIndicationSupport;
//
// Validate Console variable.
//
BdsFormalizeConsoleVariable (L"ConIn");
BdsFormalizeConsoleVariable (L"ConOut");
BdsFormalizeConsoleVariable (L"ErrOut");
//
// OS indicater support variable
//
OsIndicationSupport = EFI_OS_INDICATIONS_BOOT_TO_FW_UI \
| EFI_OS_INDICATIONS_FMP_CAPSULE_SUPPORTED;
gRT->SetVariable (
L"OsIndicationsSupported",
&gEfiGlobalVariableGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
sizeof(UINT64),
&OsIndicationSupport
);
}
/**
Set language related EFI Variables.
**/
STATIC
VOID
InitializeLanguage (
VOID
)
{
CHAR8 *PlatformLangCodes;
CHAR8 *PlatformLang;
PlatformLangCodes = (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes);
PlatformLang = (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLang);
gRT->SetVariable (
L"PlatformLangCodes",
&gEfiGlobalVariableGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
AsciiStrSize (PlatformLangCodes),
PlatformLangCodes
);
gRT->SetVariable (
L"PlatformLang",
&gEfiGlobalVariableGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
AsciiStrSize (PlatformLang),
PlatformLang
);
}
/**
Service routine for BdsInstance->Entry(). Devices are connected, the
consoles are initialized, and the boot options are tried.
@param This Protocol Instance structure.
**/
VOID
EFIAPI
BdsEntry (
IN EFI_BDS_ARCH_PROTOCOL *This
)
{
CHAR16 *FirmwareVendor;
EFI_STATUS Status;
UINT16 BootTimeOut;
UINTN Index;
EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock;
//
// Fill in FirmwareVendor and FirmwareRevision from PCDs
//
FirmwareVendor = (CHAR16 *) PcdGetPtr (PcdFirmwareVendor);
gST->FirmwareVendor = AllocateRuntimeCopyPool (StrSize (FirmwareVendor), FirmwareVendor);
ASSERT (gST->FirmwareVendor != NULL);
gST->FirmwareRevision = PcdGet32 (PcdFirmwareRevision);
//
// Fixup Table CRC after we updated Firmware Vendor and Revision
//
gST->Hdr.CRC32 = 0;
gBS->CalculateCrc32 (gST, sizeof (EFI_SYSTEM_TABLE), &gST->Hdr.CRC32);
//
// Validate Variable.
// TODO: Explore.
//
BdsFormalizeEfiGlobalVariable ();
//
// Mark the read-only variables if the Variable Lock protocol exists
//
Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **) &VariableLock);
DEBUG ((EFI_D_INFO, "[BdsDxe] Locate Variable Lock protocol - %r\n", Status));
if (!EFI_ERROR (Status)) {
for (Index = 0; Index < sizeof (mReadOnlyVariables) / sizeof (mReadOnlyVariables[0]); Index++) {
Status = VariableLock->RequestToLock (VariableLock, mReadOnlyVariables[Index], &gEfiGlobalVariableGuid);
ASSERT_EFI_ERROR (Status);
}
}
//
// Initialize L"Timeout" EFI global variable.
//
BootTimeOut = 0;
gRT->SetVariable (
L"Timeout",
&gEfiGlobalVariableGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
sizeof (UINT16),
&BootTimeOut
);
//
// Platform specific code
// Initialize the platform specific string and language
//
InitializeLanguage ();
//
// Do the platform init, can be customized by OEM/IBV
//
PlatformBdsInit ();
//
// Signal EndOfDxe
//
EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);
//
// Setup some platform policy here
//
PlatformBdsPolicyBehavior ();
//
// BDS select the boot device to load OS
//
BdsBootDeviceSelect (TRUE);
//
// Try to boot any volume
//
gST->ConOut->OutputString (gST->ConOut, L"BOOT MISMATCH!\r\n");
gBS->Stall (3000000);
BdsBootDeviceSelect (FALSE);
//
// Abort with error.
//
gST->ConOut->OutputString (gST->ConOut, L"BOOT FAIL!\r\n");
gBS->Stall (3000000);
CpuDeadLoop ();
//
// Only assert here since this is the right behavior, we should never
// return back to DxeCore.
//
ASSERT (FALSE);
}
此差异已折叠。
/** @file
Copyright (c) 2006 - 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.
**/
#ifndef _BIOS_GRAPHICS_OUTPUT_H
#define _BIOS_GRAPHICS_OUTPUT_H
#include <Uefi.h>
//
// Driver Consumed Protocol Prototypes
//
#include <Guid/GlobalVariable.h>
#include <Protocol/DevicePath.h>
#include <Protocol/PciIo.h>
#include <Protocol/DriverBinding.h>
#include <Protocol/ComponentName.h>
#include <Protocol/ComponentName2.h>
#include <Protocol/UgaDraw.h>
#include <Protocol/VgaMiniPort.h>
#include <Protocol/Legacy8259.h>
#include <Protocol/EdidActive.h>
#include <Protocol/EdidDiscovered.h>
#include <Protocol/EdidOverride.h>
#include <Protocol/DevicePath.h>
#include <Library/UefiLib.h>
#include <Library/DebugLib.h>
#include <Library/PrintLib.h>
#include <Library/BaseLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/DevicePathLib.h>
#include <IndustryStandard/Pci.h>
#include "VesaBiosExtensions.h"
//
// ** CHANGE **
// Legacy region base is now 0x0C0000 instead of 0x100000.
//
#define LEGACY_REGION_BASE 0x0C0000
//
// Packed format support: The number of bits reserved for each of the colors and the actual
// position of RGB in the frame buffer is specified in the VBE Mode information
//
typedef struct {
UINT8 Position; // Position of the color
UINT8 Mask; // The number of bits expressed as a mask
} BIOS_VIDEO_COLOR_PLACEMENT;
//
// BIOS Graphics Output Graphical Mode Data
//
typedef struct {
UINT16 VbeModeNumber;
UINT16 BytesPerScanLine;
VOID *LinearFrameBuffer;
UINTN FrameBufferSize;
UINT32 HorizontalResolution;
UINT32 VerticalResolution;
UINT32 ColorDepth;
UINT32 RefreshRate;
UINT32 BitsPerPixel;
BIOS_VIDEO_COLOR_PLACEMENT Red;
BIOS_VIDEO_COLOR_PLACEMENT Green;
BIOS_VIDEO_COLOR_PLACEMENT Blue;
BIOS_VIDEO_COLOR_PLACEMENT Reserved;
EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
EFI_PIXEL_BITMASK PixelBitMask;
} BIOS_VIDEO_MODE_DATA;
//
// BIOS video child handle private data Structure
//
#define BIOS_VIDEO_DEV_SIGNATURE SIGNATURE_32 ('B', 'V', 'M', 'p')
typedef struct {
UINTN Signature;
EFI_HANDLE Handle;
//
// Consumed Protocols inherited from parent controller.
//
EFI_PCI_IO_PROTOCOL *PciIo;
EFI_LEGACY_8259_PROTOCOL *Legacy8259;
THUNK_CONTEXT *ThunkContext;
//
// Produced Protocols
//
EFI_GRAPHICS_OUTPUT_PROTOCOL GraphicsOutput;
EFI_EDID_DISCOVERED_PROTOCOL EdidDiscovered;
EFI_EDID_ACTIVE_PROTOCOL EdidActive;
EFI_VGA_MINI_PORT_PROTOCOL VgaMiniPort;
//
// General fields
//
BOOLEAN VgaCompatible;
BOOLEAN ProduceGraphicsOutput;
//
// Graphics Output Protocol related fields
//
BOOLEAN HardwareNeedsStarting;
UINTN CurrentMode;
UINTN MaxMode;
BIOS_VIDEO_MODE_DATA *ModeData;
UINT8 *LineBuffer;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *VbeFrameBuffer;
UINT8 *VgaFrameBuffer;
//
// VESA Bios Extensions related fields
//
UINTN NumberOfPagesBelow1MB; // Number of 4KB pages in PagesBelow1MB
EFI_PHYSICAL_ADDRESS PagesBelow1MB; // Buffer for all VBE Information Blocks
VESA_BIOS_EXTENSIONS_INFORMATION_BLOCK *VbeInformationBlock; // 0x200 bytes. Must be allocated below 1MB
VESA_BIOS_EXTENSIONS_MODE_INFORMATION_BLOCK *VbeModeInformationBlock; // 0x100 bytes. Must be allocated below 1MB
VESA_BIOS_EXTENSIONS_EDID_DATA_BLOCK *VbeEdidDataBlock; // 0x80 bytes. Must be allocated below 1MB
VESA_BIOS_EXTENSIONS_CRTC_INFORMATION_BLOCK *VbeCrtcInformationBlock; // 59 bytes. Must be allocated below 1MB
UINTN VbeSaveRestorePages; // Number of 4KB pages in VbeSaveRestoreBuffer
EFI_PHYSICAL_ADDRESS VbeSaveRestoreBuffer; // Must be allocated below 1MB
//
// Status code
//
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
EFI_EVENT ExitBootServicesEvent;
} BIOS_VIDEO_DEV;
#define BIOS_VIDEO_DEV_FROM_PCI_IO_THIS(a) CR (a, BIOS_VIDEO_DEV, PciIo, BIOS_VIDEO_DEV_SIGNATURE)
#define BIOS_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS(a) CR (a, BIOS_VIDEO_DEV, GraphicsOutput, BIOS_VIDEO_DEV_SIGNATURE)
#define BIOS_VIDEO_DEV_FROM_VGA_MINI_PORT_THIS(a) CR (a, BIOS_VIDEO_DEV, VgaMiniPort, BIOS_VIDEO_DEV_SIGNATURE)
#define GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER 0xffff
#define EFI_SEGMENT(_Adr) (UINT16) ((UINT16) (((UINTN) (_Adr)) >> 4) & 0xf000)
#define EFI_OFFSET(_Adr) (UINT16) (((UINT16) ((UINTN) (_Adr))) & 0xffff)
//
// Global Variables
//
extern EFI_DRIVER_BINDING_PROTOCOL gBiosVideoDriverBinding;
extern EFI_COMPONENT_NAME_PROTOCOL gBiosVideoComponentName;
extern EFI_COMPONENT_NAME2_PROTOCOL gBiosVideoComponentName2;
//
// Driver Binding Protocol functions
//
/**
Test to see if Bios Video could be supported on the Controller.
@param This Pointer to driver binding protocol
@param Controller Controller handle to connect
@param RemainingDevicePath A pointer to the remaining portion of a device path
@retval EFI_SUCCESS This driver supports this device.
@retval other This driver does not support this device.
**/
EFI_STATUS
EFIAPI
BiosVideoDriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
);
/**
Install Graphics Output Protocol onto VGA device handles
@param This Pointer to driver binding protocol
@param Controller Controller handle to connect
@param RemainingDevicePath A pointer to the remaining portion of a device path
@return EFI_STATUS
**/
EFI_STATUS
EFIAPI
BiosVideoDriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
);
/**
Stop this driver on Controller
@param This Protocol instance pointer.
@param Controller Handle of device to stop driver on
@param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
children is zero stop the entire bus driver.
@param ChildHandleBuffer List of Child Handles to Stop.
@retval EFI_SUCCESS This driver is removed Controller.
@retval other This driver was not removed from this device.
**/
EFI_STATUS
EFIAPI
BiosVideoDriverBindingStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer
);
//
// Private worker functions
//
/**
Check for VBE device.
@param BiosVideoPrivate - Pointer to BIOS_VIDEO_DEV structure
@retval EFI_SUCCESS VBE device found
**/
EFI_STATUS
EFIAPI
BiosVideoCheckForVbe (
IN OUT BIOS_VIDEO_DEV *BiosVideoPrivate
);
/**
Check for VGA device.
@param BiosVideoPrivate - Pointer to BIOS_VIDEO_DEV structure
@retval EFI_SUCCESS Standard VGA device found
**/
EFI_STATUS
EFIAPI
BiosVideoCheckForVga (
IN OUT BIOS_VIDEO_DEV *BiosVideoPrivate
);
/**
Collect the resource from destroyed bios video device.
@param BiosVideoPrivate Video child device private data structure
**/
VOID
BiosVideoDeviceReleaseResource (
BIOS_VIDEO_DEV *BiosVideoChildPrivate
)
;
//
// BIOS Graphics Output Protocol functions
//
/**
Graphics Output protocol interface to get video mode
@param This - Protocol instance pointer.
@param ModeNumber - The mode number to return information on.
@param SizeOfInfo - A pointer to the size, in bytes, of the Info buffer.
@param Info - Caller allocated buffer that returns information about ModeNumber.
@return EFI_SUCCESS - Mode information returned.
EFI_DEVICE_ERROR - A hardware error occurred trying to retrieve the video mode.
EFI_NOT_STARTED - Video display is not initialized. Call SetMode ()
EFI_INVALID_PARAMETER - One of the input args was NULL.
**/
EFI_STATUS
EFIAPI
BiosVideoGraphicsOutputQueryMode (
IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
IN UINT32 ModeNumber,
OUT UINTN *SizeOfInfo,
OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info
);
/**
Graphics Output protocol interface to set video mode
@param This - Protocol instance pointer.
@param ModeNumber - The mode number to be set.
@return EFI_SUCCESS - Graphics mode was changed.
EFI_DEVICE_ERROR - The device had an error and could not complete the request.
EFI_UNSUPPORTED - ModeNumber is not supported by this device.
**/
EFI_STATUS
EFIAPI
BiosVideoGraphicsOutputSetMode (
IN EFI_GRAPHICS_OUTPUT_PROTOCOL * This,
IN UINT32 ModeNumber
);
/**
Graphics Output protocol instance to block transfer for VBE device
@param This - Pointer to Graphics Output protocol instance
@param BltBuffer - The data to transfer to screen
@param BltOperation - The operation to perform
@param SourceX - The X coordinate of the source for BltOperation
@param SourceY - The Y coordinate of the source for BltOperation
@param DestinationX - The X coordinate of the destination for BltOperation
@param DestinationY - The Y coordinate of the destination for BltOperation
@param Width - The width of a rectangle in the blt rectangle in pixels
@param Height - The height of a rectangle in the blt rectangle in pixels
@param Delta - Not used for EfiBltVideoFill and EfiBltVideoToVideo operation.
If a Delta of 0 is used, the entire BltBuffer will be operated on.
If a subrectangle of the BltBuffer is used, then Delta represents
the number of bytes in a row of the BltBuffer.
@return EFI_INVALID_PARAMETER - Invalid parameter passed in
EFI_SUCCESS - Blt operation success
**/
EFI_STATUS
EFIAPI
BiosVideoGraphicsOutputVbeBlt (
IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL
IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,
IN UINTN SourceX,
IN UINTN SourceY,
IN UINTN DestinationX,
IN UINTN DestinationY,
IN UINTN Width,
IN UINTN Height,
IN UINTN Delta
);
/**
Grahpics Output protocol instance to block transfer for VGA device
@param This Pointer to Grahpics Output protocol instance
@param BltBuffer The data to transfer to screen
@param BltOperation The operation to perform
@param SourceX The X coordinate of the source for BltOperation
@param SourceY The Y coordinate of the source for BltOperation
@param DestinationX The X coordinate of the destination for BltOperation
@param DestinationY The Y coordinate of the destination for BltOperation
@param Width The width of a rectangle in the blt rectangle in pixels
@param Height The height of a rectangle in the blt rectangle in pixels
@param Delta Not used for EfiBltVideoFill and EfiBltVideoToVideo operation.
If a Delta of 0 is used, the entire BltBuffer will be operated on.
If a subrectangle of the BltBuffer is used, then Delta represents
the number of bytes in a row of the BltBuffer.
@retval EFI_INVALID_PARAMETER Invalid parameter passed in
@retval EFI_SUCCESS Blt operation success
**/
EFI_STATUS
EFIAPI
BiosVideoGraphicsOutputVgaBlt (
IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL
IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,
IN UINTN SourceX,
IN UINTN SourceY,
IN UINTN DestinationX,
IN UINTN DestinationY,
IN UINTN Width,
IN UINTN Height,
IN UINTN Delta
);
//
// BIOS VGA Mini Port Protocol functions
//
/**
VgaMiniPort protocol interface to set mode.
@param This Pointer to VgaMiniPort protocol instance
@param ModeNumber The index of the mode
@retval EFI_UNSUPPORTED The requested mode is not supported
@retval EFI_SUCCESS The requested mode is set successfully
**/
EFI_STATUS
EFIAPI
BiosVideoVgaMiniPortSetMode (
IN EFI_VGA_MINI_PORT_PROTOCOL *This,
IN UINTN ModeNumber
);
/**
Judge whether this device is VGA device.
@param PciIo Parent PciIo protocol instance pointer
@retval TRUE Is vga device
@retval FALSE Is no vga device
**/
BOOLEAN
BiosVideoIsVga (
IN EFI_PCI_IO_PROTOCOL *PciIo
)
;
//
// Standard VGA Definitions
//
#define VGA_HORIZONTAL_RESOLUTION 640
#define VGA_VERTICAL_RESOLUTION 480
#define VGA_NUMBER_OF_BIT_PLANES 4
#define VGA_PIXELS_PER_BYTE 8
#define VGA_BYTES_PER_SCAN_LINE (VGA_HORIZONTAL_RESOLUTION / VGA_PIXELS_PER_BYTE)
#define VGA_BYTES_PER_BIT_PLANE (VGA_VERTICAL_RESOLUTION * VGA_BYTES_PER_SCAN_LINE)
#define VGA_GRAPHICS_CONTROLLER_ADDRESS_REGISTER 0x3ce
#define VGA_GRAPHICS_CONTROLLER_DATA_REGISTER 0x3cf
#define VGA_GRAPHICS_CONTROLLER_SET_RESET_REGISTER 0x00
#define VGA_GRAPHICS_CONTROLLER_ENABLE_SET_RESET_REGISTER 0x01
#define VGA_GRAPHICS_CONTROLLER_COLOR_COMPARE_REGISTER 0x02
#define VGA_GRAPHICS_CONTROLLER_DATA_ROTATE_REGISTER 0x03
#define VGA_GRAPHICS_CONTROLLER_FUNCTION_REPLACE 0x00
#define VGA_GRAPHICS_CONTROLLER_FUNCTION_AND 0x08
#define VGA_GRAPHICS_CONTROLLER_FUNCTION_OR 0x10
#define VGA_GRAPHICS_CONTROLLER_FUNCTION_XOR 0x18
#define VGA_GRAPHICS_CONTROLLER_READ_MAP_SELECT_REGISTER 0x04
#define VGA_GRAPHICS_CONTROLLER_MODE_REGISTER 0x05
#define VGA_GRAPHICS_CONTROLLER_READ_MODE_0 0x00
#define VGA_GRAPHICS_CONTROLLER_READ_MODE_1 0x08
#define VGA_GRAPHICS_CONTROLLER_WRITE_MODE_0 0x00
#define VGA_GRAPHICS_CONTROLLER_WRITE_MODE_1 0x01
#define VGA_GRAPHICS_CONTROLLER_WRITE_MODE_2 0x02
#define VGA_GRAPHICS_CONTROLLER_WRITE_MODE_3 0x03
#define VGA_GRAPHICS_CONTROLLER_MISCELLANEOUS_REGISTER 0x06
#define VGA_GRAPHICS_CONTROLLER_COLOR_DONT_CARE_REGISTER 0x07
#define VGA_GRAPHICS_CONTROLLER_BIT_MASK_REGISTER 0x08
/**
Initialize legacy environment for BIOS INI caller.
@param ThunkContext the instance pointer of THUNK_CONTEXT
**/
VOID
InitializeBiosIntCaller (
THUNK_CONTEXT *ThunkContext
);
/**
Initialize interrupt redirection code and entries, because
IDT Vectors 0x68-0x6f must be redirected to IDT Vectors 0x08-0x0f.
Or the interrupt will lost when we do thunk.
NOTE: We do not reset 8259 vector base, because it will cause pending
interrupt lost.
@param Legacy8259 Instance pointer for EFI_LEGACY_8259_PROTOCOL.
**/
VOID
InitializeInterruptRedirection (
IN EFI_LEGACY_8259_PROTOCOL *Legacy8259
);
/**
Thunk to 16-bit real mode and execute a software interrupt with a vector
of BiosInt. Regs will contain the 16-bit register context on entry and
exit.
@param This Protocol instance pointer.
@param BiosInt Processor interrupt vector to invoke
@param Reg Register contexted passed into (and returned) from thunk to 16-bit mode
@retval TRUE Thunk completed, and there were no BIOS errors in the target code.
See Regs for status.
@retval FALSE There was a BIOS erro in the target code.
**/
BOOLEAN
EFIAPI
LegacyBiosInt86 (
IN BIOS_VIDEO_DEV *BiosDev,
IN UINT8 BiosInt,
IN IA32_REGISTER_SET *Regs
);
#endif
## @file
# This module provides EFI_GRAPHIC_OUT_PROTOCOL based on functions of video
# on legacy BIOS.
#
# Copyright (c) 2006 - 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.
#
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = BiosVideo
FILE_GUID = 29CF55F8-B675-4f5d-8F2F-B87A3ECFD063
MODULE_TYPE = UEFI_DRIVER
VERSION_STRING = 1.0
ENTRY_POINT = BiosVideoDriverEntryPoint
[Packages]
MdePkg/MdePkg.dec
OpenCorePkg/OpenDuetPkg.dec
OvmfPkg/OvmfPkg.dec
[LibraryClasses]
UefiLib
DebugLib
PrintLib
UefiBootServicesTableLib
UefiRuntimeServicesTableLib
BaseMemoryLib
MemoryAllocationLib
UefiDriverEntryPoint
DevicePathLib
[Sources]
BiosVideo.h
BiosVideo.c
ComponentName.c
VesaBiosExtensions.h
LegacyBiosThunk.c
[Protocols]
gEfiPciIoProtocolGuid
gEfiVgaMiniPortProtocolGuid
gEfiLegacy8259ProtocolGuid
gEfiEdidDiscoveredProtocolGuid
gEfiEdidActiveProtocolGuid
[Guids]
gEfiGlobalVariableGuid
/*++
Copyright (c) 2006 - 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 "BiosVideo.h"
EFI_STATUS
EFIAPI
BiosVideoComponentNameGetDriverName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
OUT CHAR16 **DriverName
);
EFI_STATUS
EFIAPI
BiosVideoComponentNameGetControllerName (
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 gBiosVideoComponentName = {
BiosVideoComponentNameGetDriverName,
BiosVideoComponentNameGetControllerName,
"eng"
};
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gBiosVideoComponentName2 = {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) BiosVideoComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) BiosVideoComponentNameGetControllerName,
"en"
};
static EFI_UNICODE_STRING_TABLE mBiosVideoDriverNameTable[] = {
{
"eng;en",
L"BIOS[INT10] Video Driver"
},
{
NULL,
NULL
}
};
EFI_STATUS
EFIAPI
BiosVideoComponentNameGetDriverName (
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,
mBiosVideoDriverNameTable,
DriverName,
(BOOLEAN)(This == &gBiosVideoComponentName)
);
}
EFI_STATUS
EFIAPI
BiosVideoComponentNameGetControllerName (
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;
}
/** @file
Provide legacy thunk interface for accessing Bios Video Rom.
Copyright (c) 2006 - 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.
**/
#include "BiosVideo.h"
#define EFI_CPU_EFLAGS_IF 0x200
/**
Initialize legacy environment for BIOS INI caller.
@param ThunkContext the instance pointer of THUNK_CONTEXT
**/
VOID
InitializeBiosIntCaller (
THUNK_CONTEXT *ThunkContext
)
{
EFI_STATUS Status;
UINT32 RealModeBufferSize;
UINT32 ExtraStackSize;
EFI_PHYSICAL_ADDRESS LegacyRegionBase;
UINT32 LegacyRegionSize;
//
// Get LegacyRegion
//
AsmGetThunk16Properties (&RealModeBufferSize, &ExtraStackSize);
LegacyRegionSize = (((RealModeBufferSize + ExtraStackSize) / EFI_PAGE_SIZE) + 1) * EFI_PAGE_SIZE;
LegacyRegionBase = LEGACY_REGION_BASE;
Status = gBS->AllocatePages (
AllocateMaxAddress,
EfiACPIMemoryNVS,
EFI_SIZE_TO_PAGES(LegacyRegionSize),
&LegacyRegionBase
);
ASSERT_EFI_ERROR (Status);
ThunkContext->RealModeBuffer = (VOID*)(UINTN)LegacyRegionBase;
ThunkContext->RealModeBufferSize = LegacyRegionSize;
ThunkContext->ThunkAttributes = THUNK_ATTRIBUTE_BIG_REAL_MODE|THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15;
AsmPrepareThunk16(ThunkContext);
}
/**
Initialize interrupt redirection code and entries, because
IDT Vectors 0x68-0x6f must be redirected to IDT Vectors 0x08-0x0f.
Or the interrupt will lost when we do thunk.
NOTE: We do not reset 8259 vector base, because it will cause pending
interrupt lost.
@param Legacy8259 Instance pointer for EFI_LEGACY_8259_PROTOCOL.
**/
VOID
InitializeInterruptRedirection (
IN EFI_LEGACY_8259_PROTOCOL *Legacy8259
)
{
EFI_STATUS Status;
EFI_PHYSICAL_ADDRESS LegacyRegionBase;
UINTN LegacyRegionLength;
volatile UINT32 *IdtArray;
UINTN Index;
UINT8 ProtectedModeBaseVector;
STATIC CONST UINT32 InterruptRedirectionCode[] = {
0x90CF08CD, // INT8; IRET; NOP
0x90CF09CD, // INT9; IRET; NOP
0x90CF0ACD, // INTA; IRET; NOP
0x90CF0BCD, // INTB; IRET; NOP
0x90CF0CCD, // INTC; IRET; NOP
0x90CF0DCD, // INTD; IRET; NOP
0x90CF0ECD, // INTE; IRET; NOP
0x90CF0FCD // INTF; IRET; NOP
};
//
// Get LegacyRegion
//
LegacyRegionLength = sizeof(InterruptRedirectionCode);
LegacyRegionBase = LEGACY_REGION_BASE;
Status = gBS->AllocatePages (
AllocateMaxAddress,
EfiACPIMemoryNVS,
EFI_SIZE_TO_PAGES(LegacyRegionLength),
&LegacyRegionBase
);
ASSERT_EFI_ERROR (Status);
//
// Copy code to legacy region
//
CopyMem ((VOID *)(UINTN)LegacyRegionBase, InterruptRedirectionCode, sizeof (InterruptRedirectionCode));
//
// Get VectorBase, it should be 0x68
//
Status = Legacy8259->GetVector (Legacy8259, Efi8259Irq0, &ProtectedModeBaseVector);
ASSERT_EFI_ERROR (Status);
//
// Patch IVT 0x68 ~ 0x6f
//
IdtArray = (UINT32 *) 0;
for (Index = 0; Index < 8; Index++) {
IdtArray[ProtectedModeBaseVector + Index] = ((EFI_SEGMENT (LegacyRegionBase + Index * 4)) << 16) | (EFI_OFFSET (LegacyRegionBase + Index * 4));
}
return ;
}
/**
Thunk to 16-bit real mode and execute a software interrupt with a vector
of BiosInt. Regs will contain the 16-bit register context on entry and
exit.
@param This Protocol instance pointer.
@param BiosInt Processor interrupt vector to invoke
@param Reg Register contexted passed into (and returned) from thunk to 16-bit mode
@retval TRUE Thunk completed, and there were no BIOS errors in the target code.
See Regs for status.
@retval FALSE There was a BIOS erro in the target code.
**/
BOOLEAN
EFIAPI
LegacyBiosInt86 (
IN BIOS_VIDEO_DEV *BiosDev,
IN UINT8 BiosInt,
IN IA32_REGISTER_SET *Regs
)
{
UINTN Status;
IA32_REGISTER_SET ThunkRegSet;
BOOLEAN Ret;
UINT16 *Stack16;
BOOLEAN Enabled;
ZeroMem (&ThunkRegSet, sizeof (ThunkRegSet));
ThunkRegSet.E.EFLAGS.Bits.Reserved_0 = 1;
ThunkRegSet.E.EFLAGS.Bits.Reserved_1 = 0;
ThunkRegSet.E.EFLAGS.Bits.Reserved_2 = 0;
ThunkRegSet.E.EFLAGS.Bits.Reserved_3 = 0;
ThunkRegSet.E.EFLAGS.Bits.IOPL = 3;
ThunkRegSet.E.EFLAGS.Bits.NT = 0;
ThunkRegSet.E.EFLAGS.Bits.IF = 1;
ThunkRegSet.E.EFLAGS.Bits.TF = 0;
ThunkRegSet.E.EFLAGS.Bits.CF = 0;
ThunkRegSet.E.EDI = Regs->E.EDI;
ThunkRegSet.E.ESI = Regs->E.ESI;
ThunkRegSet.E.EBP = Regs->E.EBP;
ThunkRegSet.E.EBX = Regs->E.EBX;
ThunkRegSet.E.EDX = Regs->E.EDX;
ThunkRegSet.E.ECX = Regs->E.ECX;
ThunkRegSet.E.EAX = Regs->E.EAX;
ThunkRegSet.E.DS = Regs->E.DS;
ThunkRegSet.E.ES = Regs->E.ES;
//
// The call to Legacy16 is a critical section to EFI
//
Enabled = SaveAndDisableInterrupts();
//
// Set Legacy16 state. 0x08, 0x70 is legacy 8259 vector bases.
//
Status = BiosDev->Legacy8259->SetMode (BiosDev->Legacy8259, Efi8259LegacyMode, NULL, NULL);
ASSERT_EFI_ERROR (Status);
Stack16 = (UINT16 *)((UINT8 *) BiosDev->ThunkContext->RealModeBuffer + BiosDev->ThunkContext->RealModeBufferSize - sizeof (UINT16));
ThunkRegSet.E.SS = (UINT16) (((UINTN) Stack16 >> 16) << 12);
ThunkRegSet.E.ESP = (UINT16) (UINTN) Stack16;
ThunkRegSet.E.Eip = (UINT16)((volatile UINT32 *)NULL)[BiosInt];
ThunkRegSet.E.CS = (UINT16)(((volatile UINT32 *)NULL)[BiosInt] >> 16);
BiosDev->ThunkContext->RealModeState = &ThunkRegSet;
AsmThunk16 (BiosDev->ThunkContext);
//
// Restore protected mode interrupt state
//
Status = BiosDev->Legacy8259->SetMode (BiosDev->Legacy8259, Efi8259ProtectedMode, NULL, NULL);
ASSERT_EFI_ERROR (Status);
//
// End critical section
//
SetInterruptState (Enabled);
Regs->E.EDI = ThunkRegSet.E.EDI;
Regs->E.ESI = ThunkRegSet.E.ESI;
Regs->E.EBP = ThunkRegSet.E.EBP;
Regs->E.EBX = ThunkRegSet.E.EBX;
Regs->E.EDX = ThunkRegSet.E.EDX;
Regs->E.ECX = ThunkRegSet.E.ECX;
Regs->E.EAX = ThunkRegSet.E.EAX;
Regs->E.SS = ThunkRegSet.E.SS;
Regs->E.CS = ThunkRegSet.E.CS;
Regs->E.DS = ThunkRegSet.E.DS;
Regs->E.ES = ThunkRegSet.E.ES;
CopyMem (&(Regs->E.EFLAGS), &(ThunkRegSet.E.EFLAGS), sizeof (UINT32));
Ret = (BOOLEAN) (Regs->E.EFLAGS.Bits.CF == 1);
return Ret;
}
此差异已折叠。
此差异已折叠。
/*++
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
CpuDxe.h
Abstract:
--*/
#ifndef _CPU_DXE_H
#define _CPU_DXE_H
#include <Protocol/Cpu.h>
#include <Protocol/Legacy8259.h>
#include <Protocol/LegacyBios.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/PrintLib.h>
#include <Library/UefiBootServicesTableLib.h>
#define CPU_EXCEPTION_DEBUG_OUTPUT 0
#define CPU_EXCEPTION_VGA_SWITCH 1
#define INTERRUPT_VECTOR_NUMBER 0x100
//
// Function declarations
//
EFI_STATUS
EFIAPI
InitializeCpu (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
EFI_STATUS
EFIAPI
CpuFlushCpuDataCache (
IN EFI_CPU_ARCH_PROTOCOL *This,
IN EFI_PHYSICAL_ADDRESS Start,
IN UINT64 Length,
IN EFI_CPU_FLUSH_TYPE FlushType
);
EFI_STATUS
EFIAPI
CpuEnableInterrupt (
IN EFI_CPU_ARCH_PROTOCOL *This
);
EFI_STATUS
EFIAPI
CpuDisableInterrupt (
IN EFI_CPU_ARCH_PROTOCOL *This
);
EFI_STATUS
EFIAPI
CpuGetInterruptState (
IN EFI_CPU_ARCH_PROTOCOL *This,
OUT BOOLEAN *State
);
EFI_STATUS
EFIAPI
CpuInit (
IN EFI_CPU_ARCH_PROTOCOL *This,
IN EFI_CPU_INIT_TYPE InitType
);
EFI_STATUS
EFIAPI
CpuRegisterInterruptHandler (
IN EFI_CPU_ARCH_PROTOCOL *This,
IN EFI_EXCEPTION_TYPE InterruptType,
IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
);
EFI_STATUS
EFIAPI
CpuGetTimerValue (
IN EFI_CPU_ARCH_PROTOCOL *This,
IN UINT32 TimerIndex,
OUT UINT64 *TimerValue,
OUT UINT64 *TimerPeriod OPTIONAL
);
EFI_STATUS
EFIAPI
CpuSetMemoryAttributes(
IN EFI_CPU_ARCH_PROTOCOL *This,
IN EFI_PHYSICAL_ADDRESS BaseAddress,
IN UINT64 Length,
IN UINT64 Attributes
);
VOID
EFIAPI
InstallInterruptHandler (
UINTN Vector,
VOID (EFIAPI *Handler)(VOID)
);
VOID
EFIAPI
SystemExceptionHandler (
VOID
);
VOID
EFIAPI
SystemTimerHandler (
VOID
);
VOID
EFIAPI
InitDescriptor (
VOID
);
BOOLEAN
EFIAPI
LegacyBiosInt86 (
IN UINT8 BiosInt,
IN EFI_IA32_REGISTER_SET *Regs
);
#endif
## @file
#
# Copyright (c) 2006 - 2010, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
# CpuDxe.inf
#
# Abstract:
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = CpuDxe
FILE_GUID = 10527025-78B2-4D3E-A9DF-41E75C220F5A
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
ENTRY_POINT = InitializeCpu
[Packages]
OpenCorePkg/OpenDuetPkg.dec
MdePkg/MdePkg.dec
OvmfPkg/OvmfPkg.dec
[LibraryClasses]
UefiDriverEntryPoint
PrintLib
UefiBootServicesTableLib
BaseMemoryLib
[Sources.IA32]
Ia32/CpuInterrupt.nasm
[Sources.X64]
X64/CpuInterrupt.nasm
[Sources]
CpuDxe.c
CpuDxe.h
[Protocols]
gEfiCpuArchProtocolGuid
gEfiLegacy8259ProtocolGuid
[Depex]
gEfiLegacy8259ProtocolGuid
此差异已折叠。
此差异已折叠。
此差异已折叠。
/** @file
Internal header file for DxeIpl module.
Copyright (c) 2006 - 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 _DUET_DXEIPL_H_
#define _DUET_DXEIPL_H_
#include <EfiLdrHandoff.h>
#include <EfiFlashMap.h>
#include <Guid/MemoryTypeInformation.h>
#include <Guid/PciExpressBaseAddress.h>
#include <Guid/AcpiDescription.h>
#include <Guid/MemoryAllocationHob.h>
#include <Guid/Acpi.h>
#include <Guid/SmBios.h>
#include <Guid/Mps.h>
#include <Guid/FlashMapHob.h>
#include <Guid/SystemNvDataGuid.h>
#include <Guid/VariableFormat.h>
#include <Guid/StatusCodeDataTypeDebug.h>
#include <Guid/DxeCoreFileName.h>
#include <Guid/LdrMemoryDescriptor.h>
#include <Protocol/Decompress.h>
#include <Protocol/StatusCode.h>
#include <Protocol/FirmwareVolumeBlock.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/ReportStatusCodeLib.h>
#include <Library/PrintLib.h>
#include <Library/IoLib.h>
#define EFI_FVB_READ_DISABLED_CAP 0x00000001
#define EFI_FVB_READ_ENABLED_CAP 0x00000002
#define EFI_FVB_READ_STATUS 0x00000004
#define EFI_FVB_WRITE_DISABLED_CAP 0x00000008
#define EFI_FVB_WRITE_ENABLED_CAP 0x00000010
#define EFI_FVB_WRITE_STATUS 0x00000020
#define EFI_FVB_STICKY_WRITE 0x00000200
#define EFI_FVB_MEMORY_MAPPED 0x00000400
#define EFI_FVB_ERASE_POLARITY 0x00000800
#endif // _DUET_DXEIPL_H_
## @file
#
# Copyright (c) 2006 - 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.
#
# Module Name:
# DxeIpl.inf
#
# Abstract:
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = DxeIpl
FILE_GUID = 2119BBD7-9432-4f47-B5E2-5C4EA31B6BDC
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
[Packages]
MdePkg/MdePkg.dec
OpenCorePkg/OpenDuetPkg.dec
MdeModulePkg/MdeModulePkg.dec
[LibraryClasses]
BaseLib
BaseMemoryLib
PrintLib
ReportStatusCodeLib
IoLib
[Guids]
gEfiVariableGuid
gDxeCoreFileNameGuid
gLdrMemoryDescriptorGuid
[Sources]
DxeIpl.h
DxeInit.c
LegacyTable.c
LegacyTable.h
HobGeneration.c
HobGeneration.h
[Sources.x64]
X64/EnterDxeCore.c
X64/Paging.c
X64/VirtualMemory.h
[Sources.Ia32]
Ia32/EnterDxeCore.c
Ia32/Paging.c
Ia32/VirtualMemory.h
[Depex]
TRUE
此差异已折叠。
此差异已折叠。
/** @file
IA32 specific code to enter DxeCore
Copyright (c) 2006 - 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.
**/
#include "DxeIpl.h"
VOID
EnterDxeMain (
IN VOID *StackTop,
IN VOID *DxeCoreEntryPoint,
IN VOID *Hob,
IN VOID *PageTable
)
{
SwitchStack (
(SWITCH_STACK_ENTRY_POINT)(UINTN)DxeCoreEntryPoint,
Hob,
NULL,
StackTop
);
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
/** @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:
LegacyTable.h
Abstract:
Revision History:
**/
#ifndef _DXELDR_LEGACY_TABLE_H_
#define _DXELDR_LEGACY_TABLE_H_
#include "HobGeneration.h"
VOID
PrepareHobLegacyTable (
IN HOB_TEMPLATE *Hob
);
#endif
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册