diff --git a/.gitmodules b/.gitmodules index 596468684f..d37feb96aa 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,7 +6,14 @@ url = https://github.com/ucb-bar/berkeley-softfloat-3.git [submodule "UnitTestFrameworkPkg/Library/CmockaLib/cmocka"] path = UnitTestFrameworkPkg/Library/CmockaLib/cmocka - url = https://git.cryptomilk.org/projects/cmocka.git + url = https://github.com/tianocore/edk2-cmocka.git [submodule "DasharoModulePkg"] - path = DasharoModulePkg - url = https://github.com/Dasharo/DasharoModulePkg.git + path = DasharoModulePkg + url = https://github.com/Dasharo/DasharoModulePkg.git +[submodule "MdeModulePkg/Library/BrotliCustomDecompressLib/brotli"] + path = MdeModulePkg/Library/BrotliCustomDecompressLib/brotli + url = https://github.com/google/brotli +[submodule "BaseTools/Source/C/BrotliCompress/brotli"] + path = BaseTools/Source/C/BrotliCompress/brotli + url = https://github.com/google/brotli + ignore = untracked diff --git a/BaseTools/Source/C/BrotliCompress/brotli b/BaseTools/Source/C/BrotliCompress/brotli new file mode 160000 index 0000000000..f4153a09f8 --- /dev/null +++ b/BaseTools/Source/C/BrotliCompress/brotli @@ -0,0 +1 @@ +Subproject commit f4153a09f87cbb9c826d8fc12c74642bb2d879ea diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h index 40e4373e57..f547f2d505 100644 --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h @@ -24,6 +24,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include #include #include @@ -49,7 +50,7 @@ extern EDKII_SD_MMC_OVERRIDE *mOverride; // // Generic time out value, 1 microsecond as unit. // -#define SD_MMC_HC_GENERIC_TIMEOUT 1 * 1000 * 1000 +#define SD_MMC_HC_GENERIC_TIMEOUT (PcdGet32 (PcdSdMmcGenericTimeoutValue)) // // SD/MMC async transfer timer interval, set by experience. diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.inf b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.inf index 453ecde7fd..e502443ddd 100644 --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.inf +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.inf @@ -56,6 +56,7 @@ BaseLib UefiDriverEntryPoint DebugLib + PcdLib [Protocols] gEdkiiSdMmcOverrideProtocolGuid ## SOMETIMES_CONSUMES @@ -68,3 +69,6 @@ [UserExtensions.TianoCore."ExtraFiles"] SdMmcPciHcDxeExtra.uni + +[Pcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdSdMmcGenericTimeoutValue ## CONSUMES diff --git a/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli b/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli new file mode 160000 index 0000000000..f4153a09f8 --- /dev/null +++ b/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli @@ -0,0 +1 @@ +Subproject commit f4153a09f87cbb9c826d8fc12c74642bb2d879ea diff --git a/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli/decode.h b/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli/decode.h deleted file mode 100644 index 2cd17250d9..0000000000 --- a/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli/decode.h +++ /dev/null @@ -1,344 +0,0 @@ -/* Copyright 2013 Google Inc. All Rights Reserved. - - Distributed under MIT license. - See file LICENSE for detail or copy at https://opensource.org/licenses/MIT -*/ - -/** - * @file - * API for Brotli decompression. - */ - -#ifndef BROTLI_DEC_DECODE_H_ -#define BROTLI_DEC_DECODE_H_ - -#include -#include - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -/** - * Opaque structure that holds decoder state. - * - * Allocated and initialized with ::BrotliDecoderCreateInstance. - * Cleaned up and deallocated with ::BrotliDecoderDestroyInstance. - */ -typedef struct BrotliDecoderStateStruct BrotliDecoderState; - -/** - * Result type for ::BrotliDecoderDecompress and - * ::BrotliDecoderDecompressStream functions. - */ -typedef enum { - /** Decoding error, e.g. corrupted input or memory allocation problem. */ - BROTLI_DECODER_RESULT_ERROR = 0, - /** Decoding successfully completed. */ - BROTLI_DECODER_RESULT_SUCCESS = 1, - /** Partially done; should be called again with more input. */ - BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT = 2, - /** Partially done; should be called again with more output. */ - BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT = 3 -} BrotliDecoderResult; - -/** - * Template that evaluates items of ::BrotliDecoderErrorCode. - * - * Example: @code {.cpp} - * // Log Brotli error code. - * switch (brotliDecoderErrorCode) { - * #define CASE_(PREFIX, NAME, CODE) \ - * case BROTLI_DECODER ## PREFIX ## NAME: \ - * LOG(INFO) << "error code:" << #NAME; \ - * break; - * #define NEWLINE_ - * BROTLI_DECODER_ERROR_CODES_LIST(CASE_, NEWLINE_) - * #undef CASE_ - * #undef NEWLINE_ - * default: LOG(FATAL) << "unknown brotli error code"; - * } - * @endcode - */ -#define BROTLI_DECODER_ERROR_CODES_LIST(BROTLI_ERROR_CODE, SEPARATOR) \ - BROTLI_ERROR_CODE(_, NO_ERROR, 0) SEPARATOR \ - /* Same as BrotliDecoderResult values */ \ - BROTLI_ERROR_CODE(_, SUCCESS, 1) SEPARATOR \ - BROTLI_ERROR_CODE(_, NEEDS_MORE_INPUT, 2) SEPARATOR \ - BROTLI_ERROR_CODE(_, NEEDS_MORE_OUTPUT, 3) SEPARATOR \ - \ - /* Errors caused by invalid input */ \ - BROTLI_ERROR_CODE(_ERROR_FORMAT_, EXUBERANT_NIBBLE, -1) SEPARATOR \ - BROTLI_ERROR_CODE(_ERROR_FORMAT_, RESERVED, -2) SEPARATOR \ - BROTLI_ERROR_CODE(_ERROR_FORMAT_, EXUBERANT_META_NIBBLE, -3) SEPARATOR \ - BROTLI_ERROR_CODE(_ERROR_FORMAT_, SIMPLE_HUFFMAN_ALPHABET, -4) SEPARATOR \ - BROTLI_ERROR_CODE(_ERROR_FORMAT_, SIMPLE_HUFFMAN_SAME, -5) SEPARATOR \ - BROTLI_ERROR_CODE(_ERROR_FORMAT_, CL_SPACE, -6) SEPARATOR \ - BROTLI_ERROR_CODE(_ERROR_FORMAT_, HUFFMAN_SPACE, -7) SEPARATOR \ - BROTLI_ERROR_CODE(_ERROR_FORMAT_, CONTEXT_MAP_REPEAT, -8) SEPARATOR \ - BROTLI_ERROR_CODE(_ERROR_FORMAT_, BLOCK_LENGTH_1, -9) SEPARATOR \ - BROTLI_ERROR_CODE(_ERROR_FORMAT_, BLOCK_LENGTH_2, -10) SEPARATOR \ - BROTLI_ERROR_CODE(_ERROR_FORMAT_, TRANSFORM, -11) SEPARATOR \ - BROTLI_ERROR_CODE(_ERROR_FORMAT_, DICTIONARY, -12) SEPARATOR \ - BROTLI_ERROR_CODE(_ERROR_FORMAT_, WINDOW_BITS, -13) SEPARATOR \ - BROTLI_ERROR_CODE(_ERROR_FORMAT_, PADDING_1, -14) SEPARATOR \ - BROTLI_ERROR_CODE(_ERROR_FORMAT_, PADDING_2, -15) SEPARATOR \ - BROTLI_ERROR_CODE(_ERROR_FORMAT_, DISTANCE, -16) SEPARATOR \ - \ - /* -17..-18 codes are reserved */ \ - \ - BROTLI_ERROR_CODE(_ERROR_, DICTIONARY_NOT_SET, -19) SEPARATOR \ - BROTLI_ERROR_CODE(_ERROR_, INVALID_ARGUMENTS, -20) SEPARATOR \ - \ - /* Memory allocation problems */ \ - BROTLI_ERROR_CODE(_ERROR_ALLOC_, CONTEXT_MODES, -21) SEPARATOR \ - /* Literal, insert and distance trees together */ \ - BROTLI_ERROR_CODE(_ERROR_ALLOC_, TREE_GROUPS, -22) SEPARATOR \ - /* -23..-24 codes are reserved for distinct tree groups */ \ - BROTLI_ERROR_CODE(_ERROR_ALLOC_, CONTEXT_MAP, -25) SEPARATOR \ - BROTLI_ERROR_CODE(_ERROR_ALLOC_, RING_BUFFER_1, -26) SEPARATOR \ - BROTLI_ERROR_CODE(_ERROR_ALLOC_, RING_BUFFER_2, -27) SEPARATOR \ - /* -28..-29 codes are reserved for dynamic ring-buffer allocation */ \ - BROTLI_ERROR_CODE(_ERROR_ALLOC_, BLOCK_TYPE_TREES, -30) SEPARATOR \ - \ - /* "Impossible" states */ \ - BROTLI_ERROR_CODE(_ERROR_, UNREACHABLE, -31) - -/** - * Error code for detailed logging / production debugging. - * - * See ::BrotliDecoderGetErrorCode and ::BROTLI_LAST_ERROR_CODE. - */ -typedef enum { -#define BROTLI_COMMA_ , -#define BROTLI_ERROR_CODE_ENUM_ITEM_(PREFIX, NAME, CODE) \ - BROTLI_DECODER ## PREFIX ## NAME = CODE - BROTLI_DECODER_ERROR_CODES_LIST(BROTLI_ERROR_CODE_ENUM_ITEM_, BROTLI_COMMA_) -} BrotliDecoderErrorCode; -#undef BROTLI_ERROR_CODE_ENUM_ITEM_ -#undef BROTLI_COMMA_ - -/** - * The value of the last error code, negative integer. - * - * All other error code values are in the range from ::BROTLI_LAST_ERROR_CODE - * to @c -1. There are also 4 other possible non-error codes @c 0 .. @c 3 in - * ::BrotliDecoderErrorCode enumeration. - */ -#define BROTLI_LAST_ERROR_CODE BROTLI_DECODER_ERROR_UNREACHABLE - -/** Options to be used with ::BrotliDecoderSetParameter. */ -typedef enum BrotliDecoderParameter { - /** - * Disable "canny" ring buffer allocation strategy. - * - * Ring buffer is allocated according to window size, despite the real size of - * the content. - */ - BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION = 0, - /** - * Flag that determines if "Large Window Brotli" is used. - */ - BROTLI_DECODER_PARAM_LARGE_WINDOW = 1 -} BrotliDecoderParameter; - -/** - * Sets the specified parameter to the given decoder instance. - * - * @param state decoder instance - * @param param parameter to set - * @param value new parameter value - * @returns ::BROTLI_FALSE if parameter is unrecognized, or value is invalid - * @returns ::BROTLI_TRUE if value is accepted - */ -BROTLI_DEC_API BROTLI_BOOL BrotliDecoderSetParameter( - BrotliDecoderState* state, BrotliDecoderParameter param, uint32_t value); - -/** - * Creates an instance of ::BrotliDecoderState and initializes it. - * - * The instance can be used once for decoding and should then be destroyed with - * ::BrotliDecoderDestroyInstance, it cannot be reused for a new decoding - * session. - * - * @p alloc_func and @p free_func @b MUST be both zero or both non-zero. In the - * case they are both zero, default memory allocators are used. @p opaque is - * passed to @p alloc_func and @p free_func when they are called. @p free_func - * has to return without doing anything when asked to free a NULL pointer. - * - * @param alloc_func custom memory allocation function - * @param free_func custom memory free function - * @param opaque custom memory manager handle - * @returns @c 0 if instance can not be allocated or initialized - * @returns pointer to initialized ::BrotliDecoderState otherwise - */ -BROTLI_DEC_API BrotliDecoderState* BrotliDecoderCreateInstance( - brotli_alloc_func alloc_func, brotli_free_func free_func, void* opaque); - -/** - * Deinitializes and frees ::BrotliDecoderState instance. - * - * @param state decoder instance to be cleaned up and deallocated - */ -BROTLI_DEC_API void BrotliDecoderDestroyInstance(BrotliDecoderState* state); - -/** - * Performs one-shot memory-to-memory decompression. - * - * Decompresses the data in @p encoded_buffer into @p decoded_buffer, and sets - * @p *decoded_size to the decompressed length. - * - * @param encoded_size size of @p encoded_buffer - * @param encoded_buffer compressed data buffer with at least @p encoded_size - * addressable bytes - * @param[in, out] decoded_size @b in: size of @p decoded_buffer; \n - * @b out: length of decompressed data written to - * @p decoded_buffer - * @param decoded_buffer decompressed data destination buffer - * @returns ::BROTLI_DECODER_RESULT_ERROR if input is corrupted, memory - * allocation failed, or @p decoded_buffer is not large enough; - * @returns ::BROTLI_DECODER_RESULT_SUCCESS otherwise - */ -BROTLI_DEC_API BrotliDecoderResult BrotliDecoderDecompress( - size_t encoded_size, - const uint8_t encoded_buffer[BROTLI_ARRAY_PARAM(encoded_size)], - size_t* decoded_size, - uint8_t decoded_buffer[BROTLI_ARRAY_PARAM(*decoded_size)]); - -/** - * Decompresses the input stream to the output stream. - * - * The values @p *available_in and @p *available_out must specify the number of - * bytes addressable at @p *next_in and @p *next_out respectively. - * When @p *available_out is @c 0, @p next_out is allowed to be @c NULL. - * - * After each call, @p *available_in will be decremented by the amount of input - * bytes consumed, and the @p *next_in pointer will be incremented by that - * amount. Similarly, @p *available_out will be decremented by the amount of - * output bytes written, and the @p *next_out pointer will be incremented by - * that amount. - * - * @p total_out, if it is not a null-pointer, will be set to the number - * of bytes decompressed since the last @p state initialization. - * - * @note Input is never overconsumed, so @p next_in and @p available_in could be - * passed to the next consumer after decoding is complete. - * - * @param state decoder instance - * @param[in, out] available_in @b in: amount of available input; \n - * @b out: amount of unused input - * @param[in, out] next_in pointer to the next compressed byte - * @param[in, out] available_out @b in: length of output buffer; \n - * @b out: remaining size of output buffer - * @param[in, out] next_out output buffer cursor; - * can be @c NULL if @p available_out is @c 0 - * @param[out] total_out number of bytes decompressed so far; can be @c NULL - * @returns ::BROTLI_DECODER_RESULT_ERROR if input is corrupted, memory - * allocation failed, arguments were invalid, etc.; - * use ::BrotliDecoderGetErrorCode to get detailed error code - * @returns ::BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT decoding is blocked until - * more input data is provided - * @returns ::BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT decoding is blocked until - * more output space is provided - * @returns ::BROTLI_DECODER_RESULT_SUCCESS decoding is finished, no more - * input might be consumed and no more output will be produced - */ -BROTLI_DEC_API BrotliDecoderResult BrotliDecoderDecompressStream( - BrotliDecoderState* state, size_t* available_in, const uint8_t** next_in, - size_t* available_out, uint8_t** next_out, size_t* total_out); - -/** - * Checks if decoder has more output. - * - * @param state decoder instance - * @returns ::BROTLI_TRUE, if decoder has some unconsumed output - * @returns ::BROTLI_FALSE otherwise - */ -BROTLI_DEC_API BROTLI_BOOL BrotliDecoderHasMoreOutput( - const BrotliDecoderState* state); - -/** - * Acquires pointer to internal output buffer. - * - * This method is used to make language bindings easier and more efficient: - * -# push data to ::BrotliDecoderDecompressStream, - * until ::BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT is reported - * -# use ::BrotliDecoderTakeOutput to peek bytes and copy to language-specific - * entity - * - * Also this could be useful if there is an output stream that is able to - * consume all the provided data (e.g. when data is saved to file system). - * - * @attention After every call to ::BrotliDecoderTakeOutput @p *size bytes of - * output are considered consumed for all consecutive calls to the - * instance methods; returned pointer becomes invalidated as well. - * - * @note Decoder output is not guaranteed to be contiguous. This means that - * after the size-unrestricted call to ::BrotliDecoderTakeOutput, - * immediate next call to ::BrotliDecoderTakeOutput may return more data. - * - * @param state decoder instance - * @param[in, out] size @b in: number of bytes caller is ready to take, @c 0 if - * any amount could be handled; \n - * @b out: amount of data pointed by returned pointer and - * considered consumed; \n - * out value is never greater than in value, unless it is @c 0 - * @returns pointer to output data - */ -BROTLI_DEC_API const uint8_t* BrotliDecoderTakeOutput( - BrotliDecoderState* state, size_t* size); - -/** - * Checks if instance has already consumed input. - * - * Instance that returns ::BROTLI_FALSE is considered "fresh" and could be - * reused. - * - * @param state decoder instance - * @returns ::BROTLI_TRUE if decoder has already used some input bytes - * @returns ::BROTLI_FALSE otherwise - */ -BROTLI_DEC_API BROTLI_BOOL BrotliDecoderIsUsed(const BrotliDecoderState* state); - -/** - * Checks if decoder instance reached the final state. - * - * @param state decoder instance - * @returns ::BROTLI_TRUE if decoder is in a state where it reached the end of - * the input and produced all of the output - * @returns ::BROTLI_FALSE otherwise - */ -BROTLI_DEC_API BROTLI_BOOL BrotliDecoderIsFinished( - const BrotliDecoderState* state); - -/** - * Acquires a detailed error code. - * - * Should be used only after ::BrotliDecoderDecompressStream returns - * ::BROTLI_DECODER_RESULT_ERROR. - * - * See also ::BrotliDecoderErrorString - * - * @param state decoder instance - * @returns last saved error code - */ -BROTLI_DEC_API BrotliDecoderErrorCode BrotliDecoderGetErrorCode( - const BrotliDecoderState* state); - -/** - * Converts error code to a c-string. - */ -BROTLI_DEC_API const char* BrotliDecoderErrorString(BrotliDecoderErrorCode c); - -/** - * Gets a decoder library version. - * - * Look at BROTLI_VERSION for more information. - */ -BROTLI_DEC_API uint32_t BrotliDecoderVersion(void); - -#if defined(__cplusplus) || defined(c_plusplus) -} /* extern "C" */ -#endif - -#endif /* BROTLI_DEC_DECODE_H_ */ diff --git a/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli/port.h b/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli/port.h deleted file mode 100644 index 6e439987b5..0000000000 --- a/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli/port.h +++ /dev/null @@ -1,274 +0,0 @@ -/* Copyright 2016 Google Inc. All Rights Reserved. - - Distributed under MIT license. - See file LICENSE for detail or copy at https://opensource.org/licenses/MIT -*/ - -/* Macros for compiler / platform specific API declarations. */ - -#ifndef BROTLI_COMMON_PORT_H_ -#define BROTLI_COMMON_PORT_H_ - -/* The following macros were borrowed from https://github.com/nemequ/hedley - * with permission of original author - Evan Nemerson */ - -/* >>> >>> >>> hedley macros */ - -#define BROTLI_MAKE_VERSION(major, minor, revision) \ - (((major) * 1000000) + ((minor) * 1000) + (revision)) - -#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__) -#define BROTLI_GNUC_VERSION \ - BROTLI_MAKE_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) -#elif defined(__GNUC__) -#define BROTLI_GNUC_VERSION BROTLI_MAKE_VERSION(__GNUC__, __GNUC_MINOR__, 0) -#endif - -#if defined(BROTLI_GNUC_VERSION) -#define BROTLI_GNUC_VERSION_CHECK(major, minor, patch) \ - (BROTLI_GNUC_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch)) -#else -#define BROTLI_GNUC_VERSION_CHECK(major, minor, patch) (0) -#endif - -#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) -#define BROTLI_MSVC_VERSION \ - BROTLI_MAKE_VERSION((_MSC_FULL_VER / 10000000), \ - (_MSC_FULL_VER % 10000000) / 100000, \ - (_MSC_FULL_VER % 100000) / 100) -#elif defined(_MSC_FULL_VER) -#define BROTLI_MSVC_VERSION \ - BROTLI_MAKE_VERSION((_MSC_FULL_VER / 1000000), \ - (_MSC_FULL_VER % 1000000) / 10000, \ - (_MSC_FULL_VER % 10000) / 10) -#elif defined(_MSC_VER) -#define BROTLI_MSVC_VERSION \ - BROTLI_MAKE_VERSION(_MSC_VER / 100, _MSC_VER % 100, 0) -#endif - -#if !defined(_MSC_VER) -#define BROTLI_MSVC_VERSION_CHECK(major, minor, patch) (0) -#elif defined(_MSC_VER) && (_MSC_VER >= 1400) -#define BROTLI_MSVC_VERSION_CHECK(major, minor, patch) \ - (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch))) -#elif defined(_MSC_VER) && (_MSC_VER >= 1200) -#define BROTLI_MSVC_VERSION_CHECK(major, minor, patch) \ - (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch))) -#else -#define BROTLI_MSVC_VERSION_CHECK(major, minor, patch) \ - (_MSC_VER >= ((major * 100) + (minor))) -#endif - -#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) -#define BROTLI_INTEL_VERSION \ - BROTLI_MAKE_VERSION(__INTEL_COMPILER / 100, \ - __INTEL_COMPILER % 100, \ - __INTEL_COMPILER_UPDATE) -#elif defined(__INTEL_COMPILER) -#define BROTLI_INTEL_VERSION \ - BROTLI_MAKE_VERSION(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0) -#endif - -#if defined(BROTLI_INTEL_VERSION) -#define BROTLI_INTEL_VERSION_CHECK(major, minor, patch) \ - (BROTLI_INTEL_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch)) -#else -#define BROTLI_INTEL_VERSION_CHECK(major, minor, patch) (0) -#endif - -#if defined(__PGI) && \ - defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__) -#define BROTLI_PGI_VERSION \ - BROTLI_MAKE_VERSION(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__) -#endif - -#if defined(BROTLI_PGI_VERSION) -#define BROTLI_PGI_VERSION_CHECK(major, minor, patch) \ - (BROTLI_PGI_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch)) -#else -#define BROTLI_PGI_VERSION_CHECK(major, minor, patch) (0) -#endif - -#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000) -#define BROTLI_SUNPRO_VERSION \ - BROTLI_MAKE_VERSION( \ - (((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), \ - (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), \ - (__SUNPRO_C & 0xf) * 10) -#elif defined(__SUNPRO_C) -#define BROTLI_SUNPRO_VERSION \ - BROTLI_MAKE_VERSION((__SUNPRO_C >> 8) & 0xf, \ - (__SUNPRO_C >> 4) & 0xf, \ - (__SUNPRO_C) & 0xf) -#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000) -#define BROTLI_SUNPRO_VERSION \ - BROTLI_MAKE_VERSION( \ - (((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), \ - (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), \ - (__SUNPRO_CC & 0xf) * 10) -#elif defined(__SUNPRO_CC) -#define BROTLI_SUNPRO_VERSION \ - BROTLI_MAKE_VERSION((__SUNPRO_CC >> 8) & 0xf, \ - (__SUNPRO_CC >> 4) & 0xf, \ - (__SUNPRO_CC) & 0xf) -#endif - -#if defined(BROTLI_SUNPRO_VERSION) -#define BROTLI_SUNPRO_VERSION_CHECK(major, minor, patch) \ - (BROTLI_SUNPRO_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch)) -#else -#define BROTLI_SUNPRO_VERSION_CHECK(major, minor, patch) (0) -#endif - -#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION) -#define BROTLI_ARM_VERSION \ - BROTLI_MAKE_VERSION((__ARMCOMPILER_VERSION / 1000000), \ - (__ARMCOMPILER_VERSION % 1000000) / 10000, \ - (__ARMCOMPILER_VERSION % 10000) / 100) -#elif defined(__CC_ARM) && defined(__ARMCC_VERSION) -#define BROTLI_ARM_VERSION \ - BROTLI_MAKE_VERSION((__ARMCC_VERSION / 1000000), \ - (__ARMCC_VERSION % 1000000) / 10000, \ - (__ARMCC_VERSION % 10000) / 100) -#endif - -#if defined(BROTLI_ARM_VERSION) -#define BROTLI_ARM_VERSION_CHECK(major, minor, patch) \ - (BROTLI_ARM_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch)) -#else -#define BROTLI_ARM_VERSION_CHECK(major, minor, patch) (0) -#endif - -#if defined(__ibmxl__) -#define BROTLI_IBM_VERSION \ - BROTLI_MAKE_VERSION(__ibmxl_version__, \ - __ibmxl_release__, \ - __ibmxl_modification__) -#elif defined(__xlC__) && defined(__xlC_ver__) -#define BROTLI_IBM_VERSION \ - BROTLI_MAKE_VERSION(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff) -#elif defined(__xlC__) -#define BROTLI_IBM_VERSION BROTLI_MAKE_VERSION(__xlC__ >> 8, __xlC__ & 0xff, 0) -#endif - -#if defined(BROTLI_IBM_VERSION) -#define BROTLI_IBM_VERSION_CHECK(major, minor, patch) \ - (BROTLI_IBM_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch)) -#else -#define BROTLI_IBM_VERSION_CHECK(major, minor, patch) (0) -#endif - -#if defined(__TI_COMPILER_VERSION__) -#define BROTLI_TI_VERSION \ - BROTLI_MAKE_VERSION((__TI_COMPILER_VERSION__ / 1000000), \ - (__TI_COMPILER_VERSION__ % 1000000) / 1000, \ - (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(BROTLI_TI_VERSION) -#define BROTLI_TI_VERSION_CHECK(major, minor, patch) \ - (BROTLI_TI_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch)) -#else -#define BROTLI_TI_VERSION_CHECK(major, minor, patch) (0) -#endif - -#if defined(__IAR_SYSTEMS_ICC__) -#if __VER__ > 1000 -#define BROTLI_IAR_VERSION \ - BROTLI_MAKE_VERSION((__VER__ / 1000000), \ - (__VER__ / 1000) % 1000, \ - (__VER__ % 1000)) -#else -#define BROTLI_IAR_VERSION BROTLI_MAKE_VERSION(VER / 100, __VER__ % 100, 0) -#endif -#endif - -#if defined(BROTLI_IAR_VERSION) -#define BROTLI_IAR_VERSION_CHECK(major, minor, patch) \ - (BROTLI_IAR_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch)) -#else -#define BROTLI_IAR_VERSION_CHECK(major, minor, patch) (0) -#endif - -#if defined(__TINYC__) -#define BROTLI_TINYC_VERSION \ - BROTLI_MAKE_VERSION(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100) -#endif - -#if defined(BROTLI_TINYC_VERSION) -#define BROTLI_TINYC_VERSION_CHECK(major, minor, patch) \ - (BROTLI_TINYC_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch)) -#else -#define BROTLI_TINYC_VERSION_CHECK(major, minor, patch) (0) -#endif - -#if defined(__has_attribute) -#define BROTLI_GNUC_HAS_ATTRIBUTE(attribute, major, minor, patch) \ - __has_attribute(attribute) -#else -#define BROTLI_GNUC_HAS_ATTRIBUTE(attribute, major, minor, patch) \ - BROTLI_GNUC_VERSION_CHECK(major, minor, patch) -#endif - -#if defined(__has_builtin) -#define BROTLI_GNUC_HAS_BUILTIN(builtin, major, minor, patch) \ - __has_builtin(builtin) -#else -#define BROTLI_GNUC_HAS_BUILTIN(builtin, major, minor, patch) \ - BROTLI_GNUC_VERSION_CHECK(major, minor, patch) -#endif - -#if defined(_WIN32) || defined(__CYGWIN__) -#define BROTLI_PUBLIC -#elif BROTLI_GNUC_VERSION_CHECK(3, 3, 0) || \ - BROTLI_TI_VERSION_CHECK(8, 0, 0) || \ - BROTLI_INTEL_VERSION_CHECK(16, 0, 0) || \ - BROTLI_ARM_VERSION_CHECK(4, 1, 0) || \ - BROTLI_IBM_VERSION_CHECK(13, 1, 0) || \ - BROTLI_SUNPRO_VERSION_CHECK(5, 11, 0) || \ - (BROTLI_TI_VERSION_CHECK(7, 3, 0) && \ - defined(__TI_GNU_ATTRIBUTE_SUPPORT__) && defined(__TI_EABI__)) -#define BROTLI_PUBLIC __attribute__ ((visibility ("default"))) -#else -#define BROTLI_PUBLIC -#endif - -#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ - !defined(__STDC_NO_VLA__) && !defined(__cplusplus) && \ - !defined(__PGI) && !defined(__PGIC__) && !defined(__TINYC__) -#define BROTLI_ARRAY_PARAM(name) (name) -#else -#define BROTLI_ARRAY_PARAM(name) -#endif - -/* <<< <<< <<< end of hedley macros. */ - -#if defined(BROTLI_SHARED_COMPILATION) -#if defined(_WIN32) -#if defined(BROTLICOMMON_SHARED_COMPILATION) -#define BROTLI_COMMON_API __declspec(dllexport) -#else -#define BROTLI_COMMON_API __declspec(dllimport) -#endif /* BROTLICOMMON_SHARED_COMPILATION */ -#if defined(BROTLIDEC_SHARED_COMPILATION) -#define BROTLI_DEC_API __declspec(dllexport) -#else -#define BROTLI_DEC_API __declspec(dllimport) -#endif /* BROTLIDEC_SHARED_COMPILATION */ -#if defined(BROTLIENC_SHARED_COMPILATION) -#define BROTLI_ENC_API __declspec(dllexport) -#else -#define BROTLI_ENC_API __declspec(dllimport) -#endif /* BROTLIENC_SHARED_COMPILATION */ -#else /* _WIN32 */ -#define BROTLI_COMMON_API BROTLI_PUBLIC -#define BROTLI_DEC_API BROTLI_PUBLIC -#define BROTLI_ENC_API BROTLI_PUBLIC -#endif /* _WIN32 */ -#else /* BROTLI_SHARED_COMPILATION */ -#define BROTLI_COMMON_API -#define BROTLI_DEC_API -#define BROTLI_ENC_API -#endif - -#endif /* BROTLI_COMMON_PORT_H_ */ diff --git a/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli/types.h b/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli/types.h deleted file mode 100644 index 35c9569642..0000000000 --- a/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli/types.h +++ /dev/null @@ -1,92 +0,0 @@ -/* Copyright 2013 Google Inc. All Rights Reserved. - - Distributed under MIT license. - See file LICENSE for detail or copy at https://opensource.org/licenses/MIT -*/ - -/** - * @file - * Common types used in decoder and encoder API. - */ - -#ifndef BROTLI_COMMON_TYPES_H_ -#define BROTLI_COMMON_TYPES_H_ - -//#include /* for size_t */ -typedef UINTN size_t; - -#if defined(_MSC_VER) && (_MSC_VER < 1600) -typedef __int8 int8_t; -typedef unsigned __int8 uint8_t; -typedef __int16 int16_t; -typedef unsigned __int16 uint16_t; -typedef __int32 int32_t; -typedef unsigned __int32 uint32_t; -typedef unsigned __int64 uint64_t; -typedef __int64 int64_t; -#else -//#include -typedef INT8 int8_t; -typedef INT16 int16_t; -typedef INT32 int32_t; -typedef INT64 int64_t; -typedef UINT8 uint8_t; -typedef UINT16 uint16_t; -typedef UINT32 uint32_t; -typedef UINT64 uint64_t; -#endif /* defined(_MSC_VER) && (_MSC_VER < 1600) */ - -/** - * A portable @c bool replacement. - * - * ::BROTLI_BOOL is a "documentation" type: actually it is @c int, but in API it - * denotes a type, whose only values are ::BROTLI_TRUE and ::BROTLI_FALSE. - * - * ::BROTLI_BOOL values passed to Brotli should either be ::BROTLI_TRUE or - * ::BROTLI_FALSE, or be a result of ::TO_BROTLI_BOOL macros. - * - * ::BROTLI_BOOL values returned by Brotli should not be tested for equality - * with @c true, @c false, ::BROTLI_TRUE, ::BROTLI_FALSE, but rather should be - * evaluated, for example: @code{.cpp} - * if (SomeBrotliFunction(encoder, BROTLI_TRUE) && - * !OtherBrotliFunction(decoder, BROTLI_FALSE)) { - * bool x = !!YetAnotherBrotliFunction(encoder, TO_BROLTI_BOOL(2 * 2 == 4)); - * DoSomething(x); - * } - * @endcode - */ -#define BROTLI_BOOL int -/** Portable @c true replacement. */ -#define BROTLI_TRUE 1 -/** Portable @c false replacement. */ -#define BROTLI_FALSE 0 -/** @c bool to ::BROTLI_BOOL conversion macros. */ -#define TO_BROTLI_BOOL(X) (!!(X) ? BROTLI_TRUE : BROTLI_FALSE) - -#define BROTLI_MAKE_UINT64_T(high, low) ((((uint64_t)(high)) << 32) | low) - -#define BROTLI_UINT32_MAX (~((uint32_t)0)) -#define BROTLI_SIZE_MAX (~((size_t)0)) - -/** - * Allocating function pointer type. - * - * @param opaque custom memory manager handle provided by client - * @param size requested memory region size; can not be @c 0 - * @returns @c 0 in the case of failure - * @returns a valid pointer to a memory region of at least @p size bytes - * long otherwise - */ -typedef void* (*brotli_alloc_func)(void* opaque, size_t size); - -/** - * Deallocating function pointer type. - * - * This function @b SHOULD do nothing if @p address is @c 0. - * - * @param opaque custom memory manager handle provided by client - * @param address memory region pointer returned by ::brotli_alloc_func, or @c 0 - */ -typedef void (*brotli_free_func)(void* opaque, void* address); - -#endif /* BROTLI_COMMON_TYPES_H_ */ diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 2cad6c3640..88f9c5bdb2 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -1531,6 +1531,16 @@ # @Prompt Enable Capsule On Disk support. gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleOnDiskSupport|FALSE|BOOLEAN|0x0000002d + ## Maximum permitted encapsulation levels of sections in a firmware volume, + # in the DXE phase. Minimum value is 1. Sections nested more deeply are + # rejected. + # @Prompt Maximum permitted FwVol section nesting depth (exclusive). + gEfiMdeModulePkgTokenSpaceGuid.PcdFwVolDxeMaxEncapsulationDepth|0x10|UINT32|0x00000030 + + ## Indicates the default timeout value for SD/MMC Host Controller operations in microseconds. + # @Prompt SD/MMC Host Controller Operations Timeout (us). + gEfiMdeModulePkgTokenSpaceGuid.PcdSdMmcGenericTimeoutValue|1000000|UINT32|0x00000031 + [PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx] ## This PCD defines the Console output row. The default value is 25 according to UEFI spec. # This PCD could be set to 0 then console output would be at max column and max row. diff --git a/MdeModulePkg/MdeModulePkg.uni b/MdeModulePkg/MdeModulePkg.uni index 2c856ed073..77e8944f75 100644 --- a/MdeModulePkg/MdeModulePkg.uni +++ b/MdeModulePkg/MdeModulePkg.uni @@ -1175,7 +1175,11 @@ " TRUE - Capsule In Ram is supported.
" " FALSE - Capsule In Ram is not supported." -#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdCodRelocationDevPath_PROMPT #language en-US "Capsule On Disk relacation device path." +#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdSdMmcGenericTimeoutValue_PROMPT #language en-US "SD/MMC Host Controller Operations Timeout (us)." + +#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdSdMmcGenericTimeoutValue_HELP #language en-US "Indicates the default timeout value for SD/MMC Host Controller operations in microseconds." + +#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdCodRelocationDevPath_PROMPT #language en-US "Capsule On Disk relocation device path." #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdCodRelocationDevPath_HELP #language en-US "Full device path of plaform specific device to store Capsule On Disk temp relocation file.
" "If this PCD is set, Capsule On Disk temp relocation file will be stored in the device specified by this PCD, instead of the EFI System Partition that stores capsule image file." diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c index dfa848022b..d0e7ae3d34 100644 --- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c +++ b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c @@ -2763,6 +2763,10 @@ IsMtrrSupported ( CPUID_VERSION_INFO_EDX Edx; MSR_IA32_MTRRCAP_REGISTER MtrrCap; + if (PcdGetBool(PcdCpuDisableMtrrProgramming)) { + return FALSE; + } + // // Check CPUID(1).EDX[12] for MTRR capability // diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.inf b/UefiCpuPkg/Library/MtrrLib/MtrrLib.inf index 4c9ea2def3..611fdc7047 100644 --- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.inf +++ b/UefiCpuPkg/Library/MtrrLib/MtrrLib.inf @@ -37,4 +37,4 @@ [Pcd] gUefiCpuPkgTokenSpaceGuid.PcdCpuNumberOfReservedVariableMtrrs ## SOMETIMES_CONSUMES - + gUefiCpuPkgTokenSpaceGuid.PcdCpuDisableMtrrProgramming ## CONSUMES diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec index 762badf5d2..662dba08e8 100644 --- a/UefiCpuPkg/UefiCpuPkg.dec +++ b/UefiCpuPkg/UefiCpuPkg.dec @@ -197,6 +197,10 @@ # @Prompt SMM Code Access Check. gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmCodeAccessCheckEnable|TRUE|BOOLEAN|0x60000013 + ## Disables MTRR programming in case it's already programmed by FSB. + # @Prompt Disable MTRR programming. + gUefiCpuPkgTokenSpaceGuid.PcdCpuDisableMtrrProgramming|FALSE|BOOLEAN|0x00000017 + ## Specifies the number of variable MTRRs reserved for OS use. The default number of # MTRRs reserved for OS use is 2. # @Prompt Number of reserved variable MTRRs. diff --git a/UefiCpuPkg/UefiCpuPkg.uni b/UefiCpuPkg/UefiCpuPkg.uni index 1780dfdc12..02e5c1ab69 100644 --- a/UefiCpuPkg/UefiCpuPkg.uni +++ b/UefiCpuPkg/UefiCpuPkg.uni @@ -140,9 +140,13 @@ #string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuHotPlugDataAddress_HELP #language en-US "Contains the pointer to a CPU Hot Plug Data structure if CPU hot-plug is supported." -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuNumberOfReservedVariableMtrrs_PROMPT #language en-US "Number of reserved variable MTRRs" +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuDisableMtrrProgramming_PROMPT #language en-US "Number of reserved variable MTRRs" -#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuNumberOfReservedVariableMtrrs_HELP #language en-US "Specifies the number of variable MTRRs reserved for OS use." +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuDisableMtrrProgramming_HELP #language en-US "Specifies the number of variable MTRRs reserved for OS use." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuNumberOfReservedVariableMtrrs_PROMPT #language en-US "Disable MTRR programming." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuNumberOfReservedVariableMtrrs_HELP #language en-US "Disables MTRR programming in case it's already programmed by FSB." #string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuApLoopMode_PROMPT #language en-US "The AP wait loop state" diff --git a/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.c b/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.c new file mode 100644 index 0000000000..f3e9785c70 --- /dev/null +++ b/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.c @@ -0,0 +1,174 @@ +/*++ + +Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved + + + SPDX-License-Identifier: BSD-2-Clause-Patent + + + + +--*/ + +/** @file +**/ + +#include +#include +#include +#include "PlatformGopPolicy.h" + +#include +#include + +PLATFORM_GOP_POLICY_PROTOCOL mPlatformGOPPolicy; + +// +// Function implementations +// + +/** + The function will execute with as the platform policy, and gives + the Platform Lid Status. IBV/OEM can customize this code for their specific + policy action. + + @param CurrentLidStatus Gives the current LID Status + + @retval EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +GetPlatformLidStatus ( + OUT LID_STATUS *CurrentLidStatus +) +{ + *CurrentLidStatus = LidOpen; + + return EFI_SUCCESS; +} + +/** + The function will execute and gives the Video Bios Table Size and Address. + + @param VbtAddress Gives the Physical Address of Video BIOS Table + + @param VbtSize Gives the Size of Video BIOS Table + + @retval EFI_STATUS. + +**/ + +EFI_STATUS +EFIAPI +GetVbtData ( + OUT EFI_PHYSICAL_ADDRESS *VbtAddress, + OUT UINT32 *VbtSize +) +{ + EFI_STATUS Status; + UINTN FvProtocolCount; + EFI_HANDLE *FvHandles; + EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv; + UINTN Index; + UINT32 AuthenticationStatus; + + UINT8 *Buffer; + UINTN VbtBufferSize; + + Buffer = 0; + FvHandles = NULL; + + if (VbtAddress == NULL || VbtSize == NULL){ + return EFI_INVALID_PARAMETER; + } + Status = gBS->LocateHandleBuffer ( + ByProtocol, + &gEfiFirmwareVolume2ProtocolGuid, + NULL, + &FvProtocolCount, + &FvHandles + ); + + if (!EFI_ERROR (Status)) { + for (Index = 0; Index < FvProtocolCount; Index++) { + Status = gBS->HandleProtocol ( + FvHandles[Index], + &gEfiFirmwareVolume2ProtocolGuid, + (VOID **) &Fv + ); + VbtBufferSize = 0; + Status = Fv->ReadSection ( + Fv, + &gBmpImageGuid, + EFI_SECTION_RAW, + 0, + (void **)&Buffer, + &VbtBufferSize, + &AuthenticationStatus + ); + + if (!EFI_ERROR (Status)) { + *VbtAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Buffer; + *VbtSize = (UINT32)VbtBufferSize; + Status = EFI_SUCCESS; + break; + } + } + } else { + Status = EFI_NOT_FOUND; + } + + if (FvHandles != NULL) { + gBS->FreePool (FvHandles); + FvHandles = NULL; + } + + return Status; +} + +/** + Entry point for the Platform GOP Policy Driver. + + @param ImageHandle Image handle of this driver. + @param SystemTable Global system service table. + + @retval EFI_SUCCESS Initialization complete. + @retval EFI_OUT_OF_RESOURCES Do not have enough resources to initialize the driver. + +**/ + +EFI_STATUS +EFIAPI +PlatformGOPPolicyEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) + +{ + EFI_STATUS Status = EFI_SUCCESS; + + gBS = SystemTable->BootServices; + + gBS->SetMem ( + &mPlatformGOPPolicy, + sizeof (PLATFORM_GOP_POLICY_PROTOCOL), + 0 + ); + + mPlatformGOPPolicy.Revision = PLATFORM_GOP_POLICY_PROTOCOL_REVISION_01; + mPlatformGOPPolicy.GetPlatformLidStatus = GetPlatformLidStatus; + mPlatformGOPPolicy.GetVbtData = GetVbtData; + + // + // Install protocol to allow access to this Policy. + // + Status = gBS->InstallMultipleProtocolInterfaces ( + &ImageHandle, + &gPlatformGOPPolicyGuid, + &mPlatformGOPPolicy, + NULL + ); + + return Status; +} diff --git a/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.h b/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.h new file mode 100644 index 0000000000..9205afbd8f --- /dev/null +++ b/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.h @@ -0,0 +1,70 @@ +/*++ + +Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved + + + SPDX-License-Identifier: BSD-2-Clause-Patent + + + + +--*/ + +/** @file +**/ + +#ifndef _PLATFORM_GOP_POLICY_PROTOCOL_H_ +#define _PLATFORM_GOP_POLICY_PROTOCOL_H_ + +#define EFI_PLATFORM_GOP_POLICY_PROTOCOL_GUID \ + { 0xec2e931b, 0x3281, 0x48a5, 0x81, 0x7, 0xdf, 0x8a, 0x8b, 0xed, 0x3c, 0x5d } + +#define EFI_BMP_IMAGE_GUID \ + { 0x878AC2CC, 0x5343, 0x46F2, 0xB5, 0x63, 0x51, 0xF8, 0x9D, 0xAF, 0x56, 0xBA } + +#define PLATFORM_GOP_POLICY_PROTOCOL_REVISION_01 0x01 +#define PLATFORM_GOP_POLICY_PROTOCOL_REVISION_02 x0222 + +#pragma pack(1) + +typedef enum { + LidClosed, + LidOpen, + LidStatusMax +} LID_STATUS; + +typedef enum { + Docked, + UnDocked, + DockStatusMax +} DOCK_STATUS; + +typedef +EFI_STATUS +(EFIAPI *GET_PLATFORM_LID_STATUS) ( + OUT LID_STATUS *CurrentLidStatus +); + +typedef +EFI_STATUS +(EFIAPI *GET_VBT_DATA) ( + OUT EFI_PHYSICAL_ADDRESS *VbtAddress, + OUT UINT32 *VbtSize +); + +#pragma pack() + +typedef struct _PLATFORM_GOP_POLICY_PROTOCOL { + UINT32 Revision; + GET_PLATFORM_LID_STATUS GetPlatformLidStatus; + GET_VBT_DATA GetVbtData; +} PLATFORM_GOP_POLICY_PROTOCOL; + +// +// Extern the GUID for protocol users. +// +extern EFI_GUID gPlatformGOPPolicyGuid; + +extern EFI_GUID gBmpImageGuid; + +#endif diff --git a/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf b/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf new file mode 100644 index 0000000000..a8c1d32ca8 --- /dev/null +++ b/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf @@ -0,0 +1,44 @@ +# +# +# Copyright (c) 1999 - 2019, Intel Corporation. All rights reserved +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = PlatformGOPPolicy + FILE_GUID = 9737D7CA-D869-45e5-A5EF-75D9438688DE + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = PlatformGOPPolicyEntryPoint + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = X64 +# + +[Sources.common] + PlatformGopPolicy.c + +[Packages] + MdePkg/MdePkg.dec + UefiPayloadPkg/UefiPayloadPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + UefiDriverEntryPoint + UefiRuntimeServicesTableLib + +[Guids] + gBmpImageGuid + +[Protocols] + gEfiFirmwareVolume2ProtocolGuid + gPlatformGOPPolicyGuid + +[Depex] + gEfiVariableArchProtocolGuid diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c new file mode 100644 index 0000000000..bff8a37fa9 --- /dev/null +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c @@ -0,0 +1,498 @@ +/** @file + + Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include "UefiPayloadEntry.h" + +STATIC UINT32 mTopOfLowerUsableDram = 0; + +EFI_MEMORY_TYPE_INFORMATION mDefaultMemoryTypeInformation[] = { + { EfiACPIReclaimMemory, FixedPcdGet32 (PcdMemoryTypeEfiACPIReclaimMemory) }, + { EfiACPIMemoryNVS, FixedPcdGet32 (PcdMemoryTypeEfiACPIMemoryNVS) }, + { EfiReservedMemoryType, FixedPcdGet32 (PcdMemoryTypeEfiReservedMemoryType) }, + { EfiRuntimeServicesData, FixedPcdGet32 (PcdMemoryTypeEfiRuntimeServicesData) }, + { EfiRuntimeServicesCode, FixedPcdGet32 (PcdMemoryTypeEfiRuntimeServicesCode) }, + { EfiMaxMemoryType, 0 } +}; + +/** + Function to reserve memory below 4GB for EDKII Modules. + + This causes the DXE to dispatch everything under 4GB and allows Operating + System's that require EFI_LOADED_IMAGE to be under 4GB to start. + e.g. Xen hypervisor used in Qubes. +**/ +VOID +ForceModulesBelow4G ( + VOID + ) +{ + DEBUG ((DEBUG_INFO, "Building hob to restrict memory resorces to below 4G.\n")); + + // + // Create Memory Type Information HOB + // + BuildGuidDataHob ( + &gEfiMemoryTypeInformationGuid, + mDefaultMemoryTypeInformation, + sizeof (mDefaultMemoryTypeInformation) + ); +} + +/** + Callback function to build resource descriptor HOB + + This function build a HOB based on the memory map entry info. + It creates only EFI_RESOURCE_MEMORY_MAPPED_IO and EFI_RESOURCE_MEMORY_RESERVED + resources. + + @param MemoryMapEntry Memory map entry info got from bootloader. + @param Params A pointer to ACPI_BOARD_INFO. + + @retval EFI_SUCCESS Successfully build a HOB. + @retval EFI_INVALID_PARAMETER Invalid parameter provided. +**/ +EFI_STATUS +MemInfoCallbackMmio ( + IN MEMORY_MAP_ENTRY *MemoryMapEntry, + IN VOID *Params + ) +{ + EFI_PHYSICAL_ADDRESS Base; + EFI_RESOURCE_TYPE Type; + UINT64 Size; + EFI_RESOURCE_ATTRIBUTE_TYPE Attribue; + ACPI_BOARD_INFO *AcpiBoardInfo; + + AcpiBoardInfo = (ACPI_BOARD_INFO *)Params; + if (AcpiBoardInfo == NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // Skip types already handled in MemInfoCallback + // + if ((MemoryMapEntry->Type == E820_RAM) || (MemoryMapEntry->Type == E820_ACPI)) { + return EFI_SUCCESS; + } + + if (MemoryMapEntry->Base == AcpiBoardInfo->PcieBaseAddress) { + // + // MMCONF is always MMIO + // + Type = EFI_RESOURCE_MEMORY_MAPPED_IO; + } else if (MemoryMapEntry->Base < mTopOfLowerUsableDram) { + // + // It's in DRAM and thus must be reserved + // + Type = EFI_RESOURCE_MEMORY_RESERVED; + } else if ((MemoryMapEntry->Base < 0x100000000ULL) && (MemoryMapEntry->Base >= mTopOfLowerUsableDram)) { + // + // It's not in DRAM, must be MMIO + // + Type = EFI_RESOURCE_MEMORY_MAPPED_IO; + } else { + Type = EFI_RESOURCE_MEMORY_RESERVED; + } + + Base = MemoryMapEntry->Base; + Size = MemoryMapEntry->Size; + + Attribue = EFI_RESOURCE_ATTRIBUTE_PRESENT | + EFI_RESOURCE_ATTRIBUTE_INITIALIZED | + EFI_RESOURCE_ATTRIBUTE_TESTED | + EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE | + EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE | + EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE | + EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE; + + BuildResourceDescriptorHob (Type, Attribue, (EFI_PHYSICAL_ADDRESS)Base, Size); + DEBUG ((DEBUG_INFO, "buildhob: base = 0x%lx, size = 0x%lx, type = 0x%x\n", Base, Size, Type)); + + if ((MemoryMapEntry->Type == E820_UNUSABLE) || + (MemoryMapEntry->Type == E820_DISABLED)) + { + BuildMemoryAllocationHob (Base, Size, EfiUnusableMemory); + } else if (MemoryMapEntry->Type == E820_PMEM) { + BuildMemoryAllocationHob (Base, Size, EfiPersistentMemory); + } + + return EFI_SUCCESS; +} + +/** + Callback function to find TOLUD (Top of Lower Usable DRAM) + + Estimate where TOLUD (Top of Lower Usable DRAM) resides. The exact position + would require platform specific code. + + @param MemoryMapEntry Memory map entry info got from bootloader. + @param Params Not used for now. + + @retval EFI_SUCCESS Successfully updated mTopOfLowerUsableDram. +**/ +EFI_STATUS +FindToludCallback ( + IN MEMORY_MAP_ENTRY *MemoryMapEntry, + IN VOID *Params + ) +{ + // + // This code assumes that the memory map on this x86 machine below 4GiB is continous + // until TOLUD. In addition it assumes that the bootloader provided memory tables have + // no "holes" and thus the first memory range not covered by e820 marks the end of + // usable DRAM. In addition it's assumed that every reserved memory region touching + // usable RAM is also covering DRAM, everything else that is marked reserved thus must be + // MMIO not detectable by bootloader/OS + // + + // + // Skip memory types not RAM or reserved + // + if ((MemoryMapEntry->Type == E820_UNUSABLE) || (MemoryMapEntry->Type == E820_DISABLED) || + (MemoryMapEntry->Type == E820_PMEM)) + { + return EFI_SUCCESS; + } + + // + // Skip resources above 4GiB + // + if ((MemoryMapEntry->Base + MemoryMapEntry->Size) > 0x100000000ULL) { + return EFI_SUCCESS; + } + + if ((MemoryMapEntry->Type == E820_RAM) || (MemoryMapEntry->Type == E820_ACPI) || + (MemoryMapEntry->Type == E820_NVS)) + { + // + // It's usable DRAM. Update TOLUD. + // + if (mTopOfLowerUsableDram < (MemoryMapEntry->Base + MemoryMapEntry->Size)) { + mTopOfLowerUsableDram = (UINT32)(MemoryMapEntry->Base + MemoryMapEntry->Size); + } + } else { + // + // It might be 'reserved DRAM' or 'MMIO'. + // + // If it touches usable DRAM at Base assume it's DRAM as well, + // as it could be bootloader installed tables, TSEG, GTT, ... + // + if (mTopOfLowerUsableDram == MemoryMapEntry->Base) { + mTopOfLowerUsableDram = (UINT32)(MemoryMapEntry->Base + MemoryMapEntry->Size); + } + } + + return EFI_SUCCESS; +} + +/** + Callback function to build resource descriptor HOB + + This function build a HOB based on the memory map entry info. + Only add EFI_RESOURCE_SYSTEM_MEMORY. + + @param MemoryMapEntry Memory map entry info got from bootloader. + @param Params Not used for now. + + @retval RETURN_SUCCESS Successfully build a HOB. +**/ +EFI_STATUS +MemInfoCallback ( + IN MEMORY_MAP_ENTRY *MemoryMapEntry, + IN VOID *Params + ) +{ + EFI_PHYSICAL_ADDRESS Base; + EFI_RESOURCE_TYPE Type; + UINT64 Size; + EFI_RESOURCE_ATTRIBUTE_TYPE Attribue; + + // + // Skip everything not known to be usable DRAM. + // It will be added later. + // + if ((MemoryMapEntry->Type != E820_RAM) && (MemoryMapEntry->Type != E820_ACPI) && + (MemoryMapEntry->Type != E820_NVS)) + { + return RETURN_SUCCESS; + } + + Type = EFI_RESOURCE_SYSTEM_MEMORY; + Base = MemoryMapEntry->Base; + Size = MemoryMapEntry->Size; + + Attribue = EFI_RESOURCE_ATTRIBUTE_PRESENT | + EFI_RESOURCE_ATTRIBUTE_INITIALIZED | + EFI_RESOURCE_ATTRIBUTE_TESTED | + EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE | + EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE | + EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE | + EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE; + + BuildResourceDescriptorHob (Type, Attribue, (EFI_PHYSICAL_ADDRESS)Base, Size); + DEBUG ((DEBUG_INFO, "buildhob: base = 0x%lx, size = 0x%lx, type = 0x%x\n", Base, Size, Type)); + + if (MemoryMapEntry->Type == E820_ACPI) { + BuildMemoryAllocationHob (Base, Size, EfiACPIReclaimMemory); + } else if (MemoryMapEntry->Type == E820_NVS) { + BuildMemoryAllocationHob (Base, Size, EfiACPIMemoryNVS); + } + + return RETURN_SUCCESS; +} + +/** + It will build HOBs based on information from bootloaders. + + @retval EFI_SUCCESS If it completed successfully. + @retval Others If it failed to build required HOBs. +**/ +EFI_STATUS +BuildHobFromBl ( + VOID + ) +{ + EFI_STATUS Status; + ACPI_BOARD_INFO *AcpiBoardInfo; + EFI_PEI_GRAPHICS_INFO_HOB GfxInfo; + EFI_PEI_GRAPHICS_INFO_HOB *NewGfxInfo; + EFI_PEI_GRAPHICS_DEVICE_INFO_HOB GfxDeviceInfo; + EFI_PEI_GRAPHICS_DEVICE_INFO_HOB *NewGfxDeviceInfo; + UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SmBiosTableHob; + UNIVERSAL_PAYLOAD_ACPI_TABLE *AcpiTableHob; + + // + // First find TOLUD + // + DEBUG ((DEBUG_INFO, "Guessing Top of Lower Usable DRAM:\n")); + Status = ParseMemoryInfo (FindToludCallback, NULL); + if (EFI_ERROR (Status)) { + return Status; + } + + DEBUG ((DEBUG_INFO, "Assuming TOLUD = 0x%x\n", mTopOfLowerUsableDram)); + + // + // Parse memory info and build memory HOBs for Usable RAM + // + DEBUG ((DEBUG_INFO, "Building ResourceDescriptorHobs for usable memory:\n")); + Status = ParseMemoryInfo (MemInfoCallback, NULL); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Create guid hob for frame buffer information + // + Status = ParseGfxInfo (&GfxInfo); + if (!EFI_ERROR (Status)) { + NewGfxInfo = BuildGuidHob (&gEfiGraphicsInfoHobGuid, sizeof (GfxInfo)); + ASSERT (NewGfxInfo != NULL); + CopyMem (NewGfxInfo, &GfxInfo, sizeof (GfxInfo)); + DEBUG ((DEBUG_INFO, "Created graphics info hob\n")); + } + + Status = ParseGfxDeviceInfo (&GfxDeviceInfo); + if (!EFI_ERROR (Status)) { + NewGfxDeviceInfo = BuildGuidHob (&gEfiGraphicsDeviceInfoHobGuid, sizeof (GfxDeviceInfo)); + ASSERT (NewGfxDeviceInfo != NULL); + CopyMem (NewGfxDeviceInfo, &GfxDeviceInfo, sizeof (GfxDeviceInfo)); + DEBUG ((DEBUG_INFO, "Created graphics device info hob\n")); + } + + // + // Creat SmBios table Hob + // + SmBiosTableHob = BuildGuidHob (&gUniversalPayloadSmbiosTableGuid, sizeof (UNIVERSAL_PAYLOAD_SMBIOS_TABLE)); + ASSERT (SmBiosTableHob != NULL); + SmBiosTableHob->Header.Revision = UNIVERSAL_PAYLOAD_SMBIOS_TABLE_REVISION; + SmBiosTableHob->Header.Length = sizeof (UNIVERSAL_PAYLOAD_SMBIOS_TABLE); + DEBUG ((DEBUG_INFO, "Create smbios table gUniversalPayloadSmbiosTableGuid guid hob\n")); + Status = ParseSmbiosTable (SmBiosTableHob); + if (!EFI_ERROR (Status)) { + DEBUG ((DEBUG_INFO, "Detected Smbios Table at 0x%lx\n", SmBiosTableHob->SmBiosEntryPoint)); + } + + // + // Creat ACPI table Hob + // + AcpiTableHob = BuildGuidHob (&gUniversalPayloadAcpiTableGuid, sizeof (UNIVERSAL_PAYLOAD_ACPI_TABLE)); + ASSERT (AcpiTableHob != NULL); + AcpiTableHob->Header.Revision = UNIVERSAL_PAYLOAD_ACPI_TABLE_REVISION; + AcpiTableHob->Header.Length = sizeof (UNIVERSAL_PAYLOAD_ACPI_TABLE); + DEBUG ((DEBUG_INFO, "Create ACPI table gUniversalPayloadAcpiTableGuid guid hob\n")); + Status = ParseAcpiTableInfo (AcpiTableHob); + if (!EFI_ERROR (Status)) { + DEBUG ((DEBUG_INFO, "Detected ACPI Table at 0x%lx\n", AcpiTableHob->Rsdp)); + } + + // + // Create guid hob for acpi board information + // + AcpiBoardInfo = BuildHobFromAcpi (AcpiTableHob->Rsdp); + ASSERT (AcpiBoardInfo != NULL); + + // + // Parse memory info and build memory HOBs for reserved DRAM and MMIO + // + DEBUG ((DEBUG_INFO, "Building ResourceDescriptorHobs for reserved memory:\n")); + Status = ParseMemoryInfo (MemInfoCallbackMmio, AcpiBoardInfo); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Parse the misc info provided by bootloader + // + Status = ParseMiscInfo (); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "Error when parsing misc info, Status = %r\n", Status)); + } + + // + // Parse platform specific information. + // + Status = ParsePlatformInfo (); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Error when parsing platform info, Status = %r\n", Status)); + return Status; + } + + return EFI_SUCCESS; +} + +/** + This function will build some generic HOBs that doesn't depend on information from bootloaders. + +**/ +VOID +BuildGenericHob ( + VOID + ) +{ + UINT32 RegEax; + UINT8 PhysicalAddressBits; + EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute; + + // The UEFI payload FV + BuildMemoryAllocationHob (PcdGet32 (PcdPayloadFdMemBase), PcdGet32 (PcdPayloadFdMemSize), EfiBootServicesData); + + // + // Build CPU memory space and IO space hob + // + AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); + if (RegEax >= 0x80000008) { + AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL); + PhysicalAddressBits = (UINT8)RegEax; + } else { + PhysicalAddressBits = 36; + } + + BuildCpuHob (PhysicalAddressBits, 16); + + // + // Report Local APIC range, cause sbl HOB to be NULL, comment now + // + ResourceAttribute = ( + EFI_RESOURCE_ATTRIBUTE_PRESENT | + EFI_RESOURCE_ATTRIBUTE_INITIALIZED | + EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE | + EFI_RESOURCE_ATTRIBUTE_TESTED + ); + BuildResourceDescriptorHob (EFI_RESOURCE_MEMORY_MAPPED_IO, ResourceAttribute, 0xFEC80000, SIZE_512KB); + BuildMemoryAllocationHob (0xFEC80000, SIZE_512KB, EfiMemoryMappedIO); +} + +/** + Entry point to the C language phase of UEFI payload. + + @param[in] BootloaderParameter The starting address of bootloader parameter block. + + @retval It will not return if SUCCESS, and return error when passing bootloader parameter. +**/ +EFI_STATUS +EFIAPI +_ModuleEntryPoint ( + IN UINTN BootloaderParameter + ) +{ + EFI_STATUS Status; + PHYSICAL_ADDRESS DxeCoreEntryPoint; + UINTN MemBase; + UINTN HobMemBase; + UINTN HobMemTop; + EFI_PEI_HOB_POINTERS Hob; + SERIAL_PORT_INFO SerialPortInfo; + UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *UniversalSerialPort; + + Status = PcdSet64S (PcdBootloaderParameter, BootloaderParameter); + ASSERT_EFI_ERROR (Status); + + // Initialize floating point operating environment to be compliant with UEFI spec. + InitializeFloatingPointUnits (); + + // HOB region is used for HOB and memory allocation for this module + MemBase = PcdGet32 (PcdPayloadFdMemBase); + HobMemBase = ALIGN_VALUE (MemBase + PcdGet32 (PcdPayloadFdMemSize), SIZE_1MB); + HobMemTop = HobMemBase + FixedPcdGet32 (PcdSystemMemoryUefiRegionSize); + + HobConstructor ((VOID *)MemBase, (VOID *)HobMemTop, (VOID *)HobMemBase, (VOID *)HobMemTop); + + // + // Build serial port info + // + Status = ParseSerialInfo (&SerialPortInfo); + if (!EFI_ERROR (Status)) { + UniversalSerialPort = BuildGuidHob (&gUniversalPayloadSerialPortInfoGuid, sizeof (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO)); + ASSERT (UniversalSerialPort != NULL); + UniversalSerialPort->Header.Revision = UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO_REVISION; + UniversalSerialPort->Header.Length = sizeof (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO); + UniversalSerialPort->UseMmio = (SerialPortInfo.Type == 1) ? FALSE : TRUE; + UniversalSerialPort->RegisterBase = SerialPortInfo.BaseAddr; + UniversalSerialPort->BaudRate = SerialPortInfo.Baud; + UniversalSerialPort->RegisterStride = (UINT8)SerialPortInfo.RegWidth; + } + + // The library constructors might depend on serial port, so call it after serial port hob + ProcessLibraryConstructorList (); + DEBUG ((DEBUG_INFO, "sizeof(UINTN) = 0x%x\n", sizeof (UINTN))); + + // Build HOB based on information from Bootloader + Status = BuildHobFromBl (); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "BuildHobFromBl Status = %r\n", Status)); + return Status; + } + + // Build other HOBs required by DXE + BuildGenericHob (); + + // Create a HOB to make resources for EDKII modules below 4G + if (!FixedPcdGetBool (PcdDispatchModuleAbove4GMemory)) { + ForceModulesBelow4G (); + } + + // Load the DXE Core + Status = LoadDxeCore (&DxeCoreEntryPoint); + ASSERT_EFI_ERROR (Status); + + DEBUG ((DEBUG_INFO, "DxeCoreEntryPoint = 0x%lx\n", DxeCoreEntryPoint)); + + // + // Mask off all legacy 8259 interrupt sources + // + IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0xFF); + IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0xFF); + + Hob.HandoffInformationTable = (EFI_HOB_HANDOFF_INFO_TABLE *)GetFirstHob (EFI_HOB_TYPE_HANDOFF); + HandOffToDxeCore (DxeCoreEntryPoint, Hob); + + // Should not get here + CpuDeadLoop (); + return EFI_SUCCESS; +} diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf new file mode 100644 index 0000000000..dfbe2b1cc8 --- /dev/null +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf @@ -0,0 +1,100 @@ +## @file +# This is the first module for UEFI payload. +# +# Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
+# Copyright (c) 2017, AMD Incorporated. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = PayloadEntry + FILE_GUID = 2119BBD7-9432-4f47-B5E2-5C4EA31B6BDC + MODULE_TYPE = SEC + VERSION_STRING = 1.0 + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources] + UefiPayloadEntry.c + LoadDxeCore.c + MemoryAllocation.c + AcpiTable.c + +[Sources.Ia32] + X64/VirtualMemory.h + X64/VirtualMemory.c + Ia32/DxeLoadFunc.c + Ia32/IdtVectorAsm.nasm + +[Sources.X64] + X64/VirtualMemory.h + X64/VirtualMemory.c + X64/DxeLoadFunc.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + UefiPayloadPkg/UefiPayloadPkg.dec + +[LibraryClasses] + BaseMemoryLib + DebugLib + BaseLib + SerialPortLib + IoLib + BlParseLib + HobLib + PeCoffLib + PlatformSupportLib + UefiCpuLib + +[Guids] + gEfiMemoryTypeInformationGuid + gEfiFirmwareFileSystem2Guid + gEfiGraphicsInfoHobGuid + gEfiGraphicsDeviceInfoHobGuid + gUefiAcpiBoardInfoGuid + gUniversalPayloadSmbiosTableGuid + gUniversalPayloadAcpiTableGuid + gUniversalPayloadSerialPortInfoGuid + +[FeaturePcd.IA32] + gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode ## CONSUMES + +[FeaturePcd.X64] + gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplBuildPageTables ## CONSUMES + + +[Pcd.IA32,Pcd.X64] + gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable ## SOMETIMES_CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbBase ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbSize ## CONSUMES + + gUefiPayloadPkgTokenSpaceGuid.PcdPayloadFdMemBase + gUefiPayloadPkgTokenSpaceGuid.PcdPayloadFdMemSize + gUefiPayloadPkgTokenSpaceGuid.PcdBootloaderParameter + gUefiPayloadPkgTokenSpaceGuid.PcdSystemMemoryUefiRegionSize + gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS + gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory + gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType + gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData + gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode + + gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack ## SOMETIMES_CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy ## SOMETIMES_CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy ## SOMETIMES_CONSUMES + + gUefiPayloadPkgTokenSpaceGuid.PcdDispatchModuleAbove4GMemory + diff --git a/UefiPayloadPkg/UefiPayloadPkg.dec b/UefiPayloadPkg/UefiPayloadPkg.dec index 0cc6ff62f1..27461a420c 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dec +++ b/UefiPayloadPkg/UefiPayloadPkg.dec @@ -90,5 +90,14 @@ gPcAtChipsetPkgTokenSpaceGuid.PcdInitialValueRtcRegisterB|0x02|UINT8|0x00000002 ## Specifies the scan code of the key to enter boot menu gUefiPayloadPkgTokenSpaceGuid.PcdBootMenuKey|0x0016|UINT16|0x00000007 + ## Specifies the scan code of the key to enter boot menu gUefiPayloadPkgTokenSpaceGuid.PcdSetupMenuKey|0x0017|UINT16|0x00000008 + +# Above 4G Memory +gUefiPayloadPkgTokenSpaceGuid.PcdDispatchModuleAbove4GMemory|TRUE|BOOLEAN|0x00000019 + +## FFS filename to find the default variable initial data file. +# @Prompt FFS Name of variable initial data file + gUefiPayloadPkgTokenSpaceGuid.PcdNvsDataFile |{ 0x1a, 0xf1, 0xb1, 0xae, 0x42, 0xcc, 0xcf, 0x4e, 0xac, 0x60, 0xdb, 0xab, 0xf6, 0xca, 0x69, 0xe6 }|VOID*|0x00000025 + diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayloadPkg.dsc index a871fb1217..9e0d04b11e 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dsc +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc @@ -25,6 +25,13 @@ FLASH_DEFINITION = UefiPayloadPkg/UefiPayloadPkg.fdf DEFINE SOURCE_DEBUG_ENABLE = FALSE + DEFINE PS2_KEYBOARD_ENABLE = TRUE + DEFINE RAM_DISK_ENABLE = FALSE + DEFINE SIO_BUS_ENABLE = FALSE + DEFINE UNIVERSAL_PAYLOAD = FALSE + DEFINE SECURITY_STUB_ENABLE = TRUE + DEFINE SMM_SUPPORT = FALSE + DEFINE ABOVE_4G_MEMORY = TRUE # # SBL: UEFI payload for Slim Bootloader @@ -124,6 +131,13 @@ # DEFINE NETWORK_IPXE = FALSE + # Dfine the maximum size of the capsule image without a reset flag that the platform can support. + DEFINE MAX_SIZE_NON_POPULATE_CAPSULE = 0xa00000 + + # Define RTC related register. + DEFINE RTC_INDEX_REGISTER = 0x70 + DEFINE RTC_TARGET_REGISTER = 0x71 + [BuildOptions] *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES !if $(USE_CBMEM_FOR_CONSOLE) == FALSE @@ -419,6 +433,51 @@ !if $(SOURCE_DEBUG_ENABLE) gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugLoadImageMethod|0x2 !endif + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackSize|0x4000 + gEfiMdeModulePkgTokenSpaceGuid.PcdEdkiiFpdtStringRecordEnableOnly| TRUE +!if $(PERFORMANCE_MEASUREMENT_ENABLE) + gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask | 0x1 +!endif + gEfiMdeModulePkgTokenSpaceGuid.PcdSdMmcGenericTimeoutValue|$(SD_MMC_TIMEOUT) + + gUefiPayloadPkgTokenSpaceGuid.PcdDispatchModuleAbove4GMemory|$(ABOVE_4G_MEMORY) + + gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|1800000 + +!if $(CRYPTO_PROTOCOL_SUPPORT) == TRUE + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha256.Family | PCD_CRYPTO_SERVICE_ENABLE_FAMILY + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Md5.Family | PCD_CRYPTO_SERVICE_ENABLE_FAMILY + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Pkcs.Family | PCD_CRYPTO_SERVICE_ENABLE_FAMILY + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Dh.Family | PCD_CRYPTO_SERVICE_ENABLE_FAMILY + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Random.Family | PCD_CRYPTO_SERVICE_ENABLE_FAMILY + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Rsa.Family | PCD_CRYPTO_SERVICE_ENABLE_FAMILY + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha1.Family | PCD_CRYPTO_SERVICE_ENABLE_FAMILY + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha256.Family | PCD_CRYPTO_SERVICE_ENABLE_FAMILY + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha384.Family | PCD_CRYPTO_SERVICE_ENABLE_FAMILY + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha512.Family | PCD_CRYPTO_SERVICE_ENABLE_FAMILY + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.X509.Family | PCD_CRYPTO_SERVICE_ENABLE_FAMILY + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Tdes.Family | PCD_CRYPTO_SERVICE_ENABLE_FAMILY + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Aes.Services.GetContextSize | TRUE + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Aes.Services.Init | TRUE + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Aes.Services.CbcEncrypt | TRUE + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Aes.Services.CbcDecrypt | TRUE + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Arc4.Family | PCD_CRYPTO_SERVICE_ENABLE_FAMILY + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sm3.Family | PCD_CRYPTO_SERVICE_ENABLE_FAMILY + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Hkdf.Family | PCD_CRYPTO_SERVICE_ENABLE_FAMILY + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Tls.Family | PCD_CRYPTO_SERVICE_ENABLE_FAMILY + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.TlsSet.Family | PCD_CRYPTO_SERVICE_ENABLE_FAMILY + gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.TlsGet.Family | PCD_CRYPTO_SERVICE_ENABLE_FAMILY +!endif + + # Disable MTRR programming + gUefiCpuPkgTokenSpaceGuid.PcdCpuDisableMtrrProgramming|TRUE + +[PcdsPatchableInModule.X64] + gPcAtChipsetPkgTokenSpaceGuid.PcdRtcIndexRegister|$(RTC_INDEX_REGISTER) + gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister|$(RTC_TARGET_REGISTER) +!if $(NETWORK_DRIVER_ENABLE) == TRUE + gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections|TRUE +!endif [PcdsPatchableInModule.common] gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x7 @@ -436,7 +495,7 @@ gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x03 !endif !endif - + gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizeNonPopulateCapsule|$(MAX_SIZE_NON_POPULATE_CAPSULE) # # Network Pcds # @@ -722,8 +781,17 @@ !if $(SERIAL_TERMINAL) == TRUE MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf !endif + +!if $(USE_PLATFORM_GOP) == TRUE + UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf +!else UefiPayloadPkg/GraphicsOutputDxe/GraphicsOutputDxe.inf UefiPayloadPkg/PciPlatformDxe/PciPlatformDxe.inf +!endif + +!if $(PERFORMANCE_MEASUREMENT_ENABLE) + MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.inf +!endif # # SMMSTORE diff --git a/UefiPayloadPkg/UefiPayloadPkg.fdf b/UefiPayloadPkg/UefiPayloadPkg.fdf index 91cd850dde..332a78c629 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.fdf +++ b/UefiPayloadPkg/UefiPayloadPkg.fdf @@ -175,8 +175,26 @@ INF MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf !if $(SERIAL_TERMINAL) == TRUE INF MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf !endif + +!if $(USE_PLATFORM_GOP) == TRUE +!if "X64" in $(ARCH) +INF UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf +!endif +FILE DRIVER = FF0C8745-3270-4439-B74F-3E45F8C77064 { + SECTION DXE_DEPEX_EXP = {gPlatformGOPPolicyGuid} + SECTION PE32 = UefiPayloadPkg/IntelGopDriver.efi + SECTION UI = "IntelGopDriver" +} + +FILE FREEFORM = 878AC2CC-5343-46F2-B563-51F89DAF56BA { + SECTION RAW = UefiPayloadPkg/vbt.bin + SECTION UI = "IntelGopVbt" +} +!else INF UefiPayloadPkg/GraphicsOutputDxe/GraphicsOutputDxe.inf INF UefiPayloadPkg/PciPlatformDxe/PciPlatformDxe.inf +!endif + # # SCSI/ATA/IDE/DISK Support