ExtendedIfrSupportLib|MdeModulePkg/Library/ExtendedIfrSupportLib/ExtendedIfrSupportLib.inf\r
GenericBdsLib|MdeModulePkg/Library/GenericBdsLib/GenericBdsLib.inf\r
PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf\r
- GraphicsLib|MdePkg/Library/GraphicsLib/GraphicsLib.inf\r
+ GraphicsLib|MdeModulePkg/Library/GraphicsLib/GraphicsLib.inf\r
ExtendedHiiLib|MdeModulePkg/Library/ExtendedHiiLib/ExtendedHiiLib.inf\r
CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf\r
DxePiLib|MdePkg/Library/DxePiLib/DxePiLib.inf\r
--- /dev/null
+#/** @file\r
+# FvbService Library for UEFI drivers\r
+#\r
+# This library instance provide sevice functions to access Firmware Volume Block protocol.\r
+# Copyright (c) 2006 - 2007, Intel Corporation\r
+#\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = EdkFvbServiceLib\r
+ FILE_GUID = bd4d540e-04b0-4b10-8fd5-4a7bb533cf67\r
+ MODULE_TYPE = DXE_RUNTIME_DRIVER\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = FvbServiceLib|DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION\r
+ EDK_RELEASE_VERSION = 0x00020000\r
+ EFI_SPECIFICATION_VERSION = 0x00020000\r
+\r
+ CONSTRUCTOR = FvbLibInitialize\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64\r
+#\r
+# VIRTUAL_ADDRESS_MAP_CALLBACK = FvbVirtualAddressChangeNotifyEvent\r
+#\r
+\r
+[Sources]\r
+ Fvb.h\r
+ Fvb.c\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ MdeModulePkg/MdeModulePkg.dec\r
+\r
+[LibraryClasses]\r
+ UefiBootServicesTableLib\r
+ UefiRuntimeLib\r
+ BaseMemoryLib\r
+ DebugLib\r
+ BaseLib\r
+ UefiLib\r
+\r
+[Protocols]\r
+ gEfiFirmwareVolumeBlockProtocolGuid # PROTOCOL_NOTIFY SOMETIMES_CONSUMED\r
+ gEfiFvbExtensionProtocolGuid # PROTOCOL ALWAYS_CONSUMED\r
+ gEfiFirmwareVolumeBlockProtocolGuid # PROTOCOL ALWAYS_CONSUMED\r
+\r
--- /dev/null
+/**@file\r
+\r
+ Firmware Volume Block Protocol Runtime Interface Abstraction\r
+ And FVB Extension protocol Runtime Interface Abstraction\r
+\r
+ mFvbEntry is an array of Handle Fvb pairs. The Fvb Lib Instance matches the\r
+ index in the mFvbEntry array. This should be the same sequence as the FVB's\r
+ were described in the HOB. We have to remember the handle so we can tell if\r
+ the protocol has been reinstalled and it needs updateing.\r
+\r
+ If you are using any of these lib functions.you must first call FvbInitialize ().\r
+\r
+Copyright (c) 2006 - 2008, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+\r
+#include "Fvb.h"\r
+\r
+//\r
+// Event for Set Virtual Map Changed Event\r
+//\r
+STATIC EFI_EVENT mSetVirtualMapChangedEvent = NULL;\r
+\r
+//\r
+// Lib will ASSERT if more FVB devices than this are added to the system.\r
+//\r
+STATIC FVB_ENTRY *mFvbEntry;\r
+STATIC EFI_EVENT mFvbRegistration;\r
+STATIC UINTN mFvbCount;\r
+\r
+/**\r
+ Check whether an address is runtime memory or not.\r
+\r
+ @param Address The Address being checked.\r
+\r
+ @retval TRUE The address is runtime memory.\r
+ @retval FALSE The address is not runtime memory.\r
+**/\r
+BOOLEAN\r
+IsRuntimeMemory (\r
+ IN VOID *Address\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ UINT8 TmpMemoryMap[1];\r
+ UINTN MapKey;\r
+ UINTN DescriptorSize;\r
+ UINT32 DescriptorVersion;\r
+ UINTN MemoryMapSize;\r
+ EFI_MEMORY_DESCRIPTOR *MemoryMap;\r
+ EFI_MEMORY_DESCRIPTOR *MemoryMapPtr;\r
+ BOOLEAN IsRuntime;\r
+ UINTN Index;\r
+\r
+ IsRuntime = FALSE;\r
+\r
+ //\r
+ // Get System MemoryMapSize\r
+ //\r
+ MemoryMapSize = 1;\r
+ Status = gBS->GetMemoryMap (\r
+ &MemoryMapSize,\r
+ (EFI_MEMORY_DESCRIPTOR *)TmpMemoryMap,\r
+ &MapKey,\r
+ &DescriptorSize,\r
+ &DescriptorVersion\r
+ );\r
+ ASSERT (Status == EFI_BUFFER_TOO_SMALL);\r
+ //\r
+ // Enlarge space here, because we will allocate pool now.\r
+ //\r
+ MemoryMapSize += EFI_PAGE_SIZE;\r
+ Status = gBS->AllocatePool (\r
+ EfiBootServicesData,\r
+ MemoryMapSize,\r
+ (VOID**)&MemoryMap\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ //\r
+ // Get System MemoryMap\r
+ //\r
+ Status = gBS->GetMemoryMap (\r
+ &MemoryMapSize,\r
+ MemoryMap,\r
+ &MapKey,\r
+ &DescriptorSize,\r
+ &DescriptorVersion\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ MemoryMapPtr = MemoryMap;\r
+ //\r
+ // Search the request Address\r
+ //\r
+ for (Index = 0; Index < (MemoryMapSize / DescriptorSize); Index++) {\r
+ if (((EFI_PHYSICAL_ADDRESS)(UINTN)Address >= MemoryMap->PhysicalStart) &&\r
+ ((EFI_PHYSICAL_ADDRESS)(UINTN)Address < MemoryMap->PhysicalStart\r
+ + LShiftU64 (MemoryMap->NumberOfPages, EFI_PAGE_SHIFT))) {\r
+ //\r
+ // Found it\r
+ //\r
+ if (MemoryMap->Attribute & EFI_MEMORY_RUNTIME) {\r
+ IsRuntime = TRUE;\r
+ }\r
+ break;\r
+ }\r
+ //\r
+ // Get next item\r
+ //\r
+ MemoryMap = (EFI_MEMORY_DESCRIPTOR *)((UINTN)MemoryMap + DescriptorSize);\r
+ }\r
+\r
+ //\r
+ // Done\r
+ //\r
+ gBS->FreePool (MemoryMapPtr);\r
+\r
+ return IsRuntime;\r
+}\r
+\r
+/**\r
+ Update mFvbEntry. Add new entry, or update existing entry if Fvb protocol is\r
+ reinstalled.\r
+\r
+ @param Event The Event that is being processed\r
+ @param Context Event Context\r
+\r
+**/\r
+STATIC\r
+VOID\r
+EFIAPI\r
+FvbNotificationEvent (\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN BufferSize;\r
+ EFI_HANDLE Handle;\r
+ UINTN Index;\r
+ UINTN UpdateIndex;\r
+\r
+ while (TRUE) {\r
+ BufferSize = sizeof (Handle);\r
+ Status = gBS->LocateHandle (\r
+ ByRegisterNotify,\r
+ &gEfiFirmwareVolumeBlockProtocolGuid,\r
+ mFvbRegistration,\r
+ &BufferSize,\r
+ &Handle\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ //\r
+ // Exit Path of While Loop....\r
+ //\r
+ break;\r
+ }\r
+\r
+ UpdateIndex = MAX_FVB_COUNT;\r
+ for (Index = 0; Index < mFvbCount; Index++) {\r
+ if (mFvbEntry[Index].Handle == Handle) {\r
+ //\r
+ // If the handle is already in the table just update the protocol\r
+ //\r
+ UpdateIndex = Index;\r
+ break;\r
+ }\r
+ }\r
+\r
+ if (UpdateIndex == MAX_FVB_COUNT) {\r
+ //\r
+ // Use the next free slot for a new entry\r
+ //\r
+ UpdateIndex = mFvbCount++;\r
+ //\r
+ // Check the UpdateIndex whether exceed the maximum value.\r
+ //\r
+ ASSERT (UpdateIndex < MAX_FVB_COUNT);\r
+ mFvbEntry[UpdateIndex].Handle = Handle;\r
+ }\r
+ //\r
+ // The array does not have enough entries\r
+ //\r
+ ASSERT (UpdateIndex < MAX_FVB_COUNT);\r
+\r
+ //\r
+ // Get the interface pointer and if it's ours, skip it\r
+ //\r
+ Status = gBS->HandleProtocol (\r
+ Handle,\r
+ &gEfiFirmwareVolumeBlockProtocolGuid,\r
+ (VOID **) &mFvbEntry[UpdateIndex].Fvb\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ Status = gBS->HandleProtocol (\r
+ Handle,\r
+ &gEfiFvbExtensionProtocolGuid,\r
+ (VOID **) &mFvbEntry[UpdateIndex].FvbExtension\r
+ );\r
+ if (Status != EFI_SUCCESS) {\r
+ mFvbEntry[UpdateIndex].FvbExtension = NULL;\r
+ }\r
+\r
+ //\r
+ // Check the FVB can be accessed in RUNTIME, The FVBs in FVB handle list comes\r
+ // from two way:\r
+ // 1) Dxe Core. (FVB information is transferred from FV HOB).\r
+ // 2) FVB driver.\r
+ // The FVB produced Dxe core is used for discoverying DXE driver and dispatch. These\r
+ // FVBs can only be accessed in boot time.\r
+ // FVB driver will discovery all FV in FLASH and these FVBs can be accessed in runtime.\r
+ // The FVB itself produced by FVB driver is allocated in runtime memory. So we can\r
+ // determine the what FVB can be accessed in RUNTIME by judging whether FVB itself is allocated\r
+ // in RUNTIME memory.\r
+ //\r
+ mFvbEntry[UpdateIndex].IsRuntimeAccess = IsRuntimeMemory (mFvbEntry[UpdateIndex].Fvb);\r
+ }\r
+}\r
+\r
+/**\r
+ Convert all pointers in mFvbEntry after ExitBootServices.\r
+\r
+ @param Event The Event that is being processed\r
+ @param Context Event Context\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+FvbVirtualAddressChangeNotifyEvent (\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
+ )\r
+{\r
+ UINTN Index;\r
+ if (mFvbEntry != NULL) {\r
+ for (Index = 0; Index < MAX_FVB_COUNT; Index++) {\r
+ if (!mFvbEntry[Index].IsRuntimeAccess) {\r
+ continue;\r
+ }\r
+\r
+ if (NULL != mFvbEntry[Index].Fvb) {\r
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb->GetBlockSize);\r
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb->GetPhysicalAddress);\r
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb->GetAttributes);\r
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb->SetAttributes);\r
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb->Read);\r
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb->Write);\r
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb->EraseBlocks);\r
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb);\r
+ }\r
+\r
+ if (NULL != mFvbEntry[Index].FvbExtension) {\r
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].FvbExtension->EraseFvbCustomBlock);\r
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].FvbExtension);\r
+ }\r
+ }\r
+\r
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry);\r
+ }\r
+}\r
+\r
+/**\r
+ Library constructor function entry.\r
+\r
+ @param ImageHandle The handle of image who call this libary.\r
+ @param SystemTable The point of System Table.\r
+\r
+ @retval EFI_SUCESS Sucess construct this library.\r
+ @retval Others Fail to contruct this libary.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FvbLibInitialize (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ UINTN Status;\r
+ mFvbCount = 0;\r
+\r
+ Status = gBS->AllocatePool (\r
+ EfiRuntimeServicesData,\r
+ (UINTN) sizeof (FVB_ENTRY) * MAX_FVB_COUNT,\r
+ (VOID *) &mFvbEntry\r
+ );\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ ZeroMem (mFvbEntry, sizeof (FVB_ENTRY) * MAX_FVB_COUNT);\r
+\r
+ EfiCreateProtocolNotifyEvent (\r
+ &gEfiFirmwareVolumeBlockProtocolGuid,\r
+ TPL_CALLBACK,\r
+ FvbNotificationEvent,\r
+ NULL,\r
+ &mFvbRegistration\r
+ );\r
+\r
+ //\r
+ // Register SetVirtualAddressMap () notify function\r
+ //\r
+ Status = gBS->CreateEvent (\r
+ EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,\r
+ TPL_NOTIFY,\r
+ FvbVirtualAddressChangeNotifyEvent,\r
+ NULL,\r
+ &mSetVirtualMapChangedEvent\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+//\r
+// =============================================================================\r
+// The following functions wrap Fvb protocol in the Runtime Lib functions.\r
+// The Instance translates into Fvb instance. The Fvb order defined by HOBs and\r
+// thus the sequence of FVB protocol addition define Instance.\r
+//\r
+// EfiFvbInitialize () must be called before any of the following functions\r
+// must be called.\r
+// =============================================================================\r
+//\r
+\r
+/**\r
+ Reads specified number of bytes into a buffer from the specified block.\r
+\r
+ The EfiFvbReadBlock() function reads the requested number of bytes from\r
+ the requested block in the specified firmware volume and stores them in\r
+ the provided buffer. Implementations should be mindful that the firmware\r
+ volume might be in the ReadDisabled state. If it is in this state, the \r
+ EfiFvbReadBlock() function must return the status code EFI_ACCESS_DENIED\r
+ without modifying the contents of the buffer.\r
+ \r
+ The EfiFvbReadBlock() function must also prevent spanning block boundaries.\r
+ If a read is requested that would span a block boundary, the read must read\r
+ up to the boundary but not beyond. The output parameter NumBytes must be\r
+ set to correctly indicate the number of bytes actually read. \r
+ The caller must be aware that a read may be partially completed.\r
+\r
+ If NumBytes is NULL, then ASSERT().\r
+\r
+ If Buffer is NULL, then ASSERT().\r
+\r
+ @param[in] Instance The FV instance to be read from.\r
+ @param[in] Lba The logical block address to be read from\r
+ @param[in] Offset The offset relative to the block, at which to begin reading.\r
+ @param[in, out] NumBytes Pointer to a UINTN. On input, *NumBytes contains the total\r
+ size of the buffer. On output, it contains the actual number\r
+ of bytes read.\r
+ @param[out] Buffer Pointer to a caller allocated buffer that will be\r
+ used to hold the data read.\r
+\r
+ @retval EFI_SUCCESS The firmware volume was read successfully and contents are in Buffer.\r
+ @retval EFI_BAD_BUFFER_SIZE Read attempted across an LBA boundary. On output, NumBytes contains the total number of bytes returned in Buffer.\r
+ @retval EFI_ACCESS_DENIED The firmware volume is in the ReadDisabled state.\r
+ @retval EFI_DEVICE_ERROR The block device is not functioning correctly and could not be read.\r
+ @retval EFI_INVALID_PARAMETER Invalid parameter, Instance is larger than the max FVB number. Lba index is larger than the last block of the firmware volume. Offset is larger than the block size.\r
+\r
+**/\r
+EFI_STATUS\r
+EfiFvbReadBlock (\r
+ IN UINTN Instance,\r
+ IN EFI_LBA Lba,\r
+ IN UINTN Offset,\r
+ IN OUT UINTN *NumBytes,\r
+ OUT UINT8 *Buffer\r
+ )\r
+{\r
+ ASSERT (NumBytes != NULL);\r
+ ASSERT (Buffer != NULL);\r
+ \r
+ if (Instance >= mFvbCount) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (EfiAtRuntime() && !mFvbEntry[Instance].IsRuntimeAccess) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ return mFvbEntry[Instance].Fvb->Read (mFvbEntry[Instance].Fvb, Lba, Offset, NumBytes, Buffer);\r
+}\r
+\r
+/**\r
+ Writes specified number of bytes from the input buffer to the block\r
+\r
+ The EfiFvbWriteBlock() function writes the specified number of bytes\r
+ from the provided buffer to the specified block and offset in the \r
+ requested firmware volume. \r
+\r
+ If the firmware volume is sticky write, the caller must ensure that\r
+ all the bits of the specified range to write are in the EFI_FVB_ERASE_POLARITY\r
+ state before calling the EfiFvbWriteBlock() function, or else the \r
+ result will be unpredictable. This unpredictability arises because,\r
+ for a sticky-write firmware volume, a write may negate a bit in the \r
+ EFI_FVB_ERASE_POLARITY state but it cannot flip it back again. In \r
+ general, before calling the EfiFvbWriteBlock() function, the caller\r
+ should call the EfiFvbEraseBlock() function first to erase the specified\r
+ block to write. A block erase cycle will transition bits from the\r
+ (NOT)EFI_FVB_ERASE_POLARITY state back to the EFI_FVB_ERASE_POLARITY state.\r
+ Implementations should be mindful that the firmware volume might be \r
+ in the WriteDisabled state. If it is in this state, the EfiFvbWriteBlock()\r
+ function must return the status code EFI_ACCESS_DENIED without modifying\r
+ the contents of the firmware volume.\r
+ \r
+ The EfiFvbWriteBlock() function must also prevent spanning block boundaries.\r
+ If a write is requested that spans a block boundary, the write must store\r
+ up to the boundary but not beyond. The output parameter NumBytes must be \r
+ set to correctly indicate the number of bytes actually written. The caller\r
+ must be aware that a write may be partially completed.\r
+ All writes, partial or otherwise, must be fully flushed to the hardware \r
+ before the EfiFvbWriteBlock() function returns. \r
+ \r
+ If NumBytes is NULL, then ASSERT().\r
+\r
+ @param Instance The FV instance to be written to\r
+ @param Lba The starting logical block index to write to\r
+ @param Offset The offset relative to the block, at which to begin writting.\r
+ @param NumBytes Pointer to a UINTN. On input, *NumBytes contains\r
+ the total size of the buffer. On output, it contains\r
+ the actual number of bytes written.\r
+ @param Buffer Pointer to a caller allocated buffer that contains\r
+ the source for the write\r
+\r
+ @retval EFI_SUCCESS The firmware volume was written successfully.\r
+ @retval EFI_BAD_BUFFER_SIZE The write was attempted across an LBA boundary. \r
+ On output, NumBytes contains the total number of bytes actually written.\r
+ @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled state.\r
+ @retval EFI_DEVICE_ERROR The block device is malfunctioning and could not be written.\r
+ @retval EFI_INVALID_PARAMETER Invalid parameter, Instance is larger than the max FVB number. \r
+ Lba index is larger than the last block of the firmware volume.\r
+ Offset is larger than the block size.\r
+**/\r
+EFI_STATUS\r
+EfiFvbWriteBlock (\r
+ IN UINTN Instance,\r
+ IN EFI_LBA Lba,\r
+ IN UINTN Offset,\r
+ IN OUT UINTN *NumBytes,\r
+ IN UINT8 *Buffer\r
+ )\r
+{\r
+ ASSERT (NumBytes != NULL);\r
+ \r
+ if (Instance >= mFvbCount) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (EfiAtRuntime() && !mFvbEntry[Instance].IsRuntimeAccess) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ return mFvbEntry[Instance].Fvb->Write (mFvbEntry[Instance].Fvb, Lba, Offset, NumBytes, Buffer);\r
+}\r
+\r
+/**\r
+ Erases and initializes a firmware volume block.\r
+\r
+ The EfiFvbEraseBlock() function erases one block specified by Lba.\r
+ Implementations should be mindful that the firmware volume might \r
+ be in the WriteDisabled state. If it is in this state, the EfiFvbEraseBlock()\r
+ function must return the status code EFI_ACCESS_DENIED without \r
+ modifying the contents of the firmware volume. If Instance is \r
+ larger than the max FVB number, or Lba index is larger than the\r
+ last block of the firmware volume, this function return the status\r
+ code EFI_INVALID_PARAMETER.\r
+ \r
+ All calls to EfiFvbEraseBlock() must be fully flushed to the \r
+ hardware before this function returns. \r
+\r
+ @param[in] Instance The FV instance to be erased.\r
+ @param[in] Lba The logical block index to be erased from.\r
+ \r
+ @retval EFI_SUCCESS The erase request was successfully completed.\r
+ @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled state.\r
+ @retval EFI_DEVICE_ERROR The block device is not functioning correctly and\r
+ could not be written. The firmware device may \r
+ have been partially erased.\r
+ @retval EFI_INVALID_PARAMETER Invalid parameter. Instance is larger than the max\r
+ FVB number. Lba index is larger than the last block\r
+ of the firmware volume. \r
+\r
+**/\r
+EFI_STATUS\r
+EfiFvbEraseBlock (\r
+ IN UINTN Instance,\r
+ IN EFI_LBA Lba\r
+ )\r
+{\r
+ if (Instance >= mFvbCount) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (EfiAtRuntime() && !mFvbEntry[Instance].IsRuntimeAccess) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ return mFvbEntry[Instance].Fvb->EraseBlocks (mFvbEntry[Instance].Fvb, Lba, 1, EFI_LBA_LIST_TERMINATOR);\r
+}\r
+\r
+/**\r
+ Retrieves the attributes and current settings of the specified block, \r
+ returns resulting attributes in output parameter.\r
+\r
+ The EfiFvbGetAttributes() function retrieves the attributes and current\r
+ settings of the block specified by Instance. If Instance is larger than\r
+ the max FVB number, this function returns the status code EFI_INVALID_PARAMETER.\r
+\r
+ If Attributes is NULL, then ASSERT().\r
+\r
+ @param[in] Instance The FV instance to be operated.\r
+ @param[out] Attributes Pointer to EFI_FVB_ATTRIBUTES_2 in which the\r
+ attributes and current settings are returned.\r
+\r
+ @retval EFI_EFI_SUCCESS The firmware volume attributes were returned.\r
+ @retval EFI_INVALID_PARAMETER Invalid parameter. Instance is larger than the max FVB number. \r
+**/\r
+EFI_STATUS\r
+EfiFvbGetVolumeAttributes (\r
+ IN UINTN Instance,\r
+ OUT EFI_FVB_ATTRIBUTES_2 *Attributes\r
+ )\r
+{\r
+ ASSERT (Attributes != NULL);\r
+ \r
+ if (Instance >= mFvbCount) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (EfiAtRuntime() && !mFvbEntry[Instance].IsRuntimeAccess) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ return mFvbEntry[Instance].Fvb->GetAttributes (mFvbEntry[Instance].Fvb, Attributes);\r
+}\r
+\r
+/**\r
+ Modify the attributes and current settings of the specified block\r
+ according to the input parameter.\r
+\r
+ The EfiFvbSetAttributes() function sets configurable firmware volume\r
+ attributes and returns the new settings of the firmware volume specified\r
+ by Instance. If Instance is larger than the max FVB number, this function\r
+ returns the status code EFI_INVALID_PARAMETER.\r
+\r
+ If Attributes is NULL, then ASSERT().\r
+\r
+ @param[in] Instance The FV instance to be operated.\r
+ @param[in, out]Attributes On input, Attributes is a pointer to EFI_FVB_ATTRIBUTES_2\r
+ that contains the desired firmware volume settings. \r
+ On successful return, it contains the new settings of the firmware volume.\r
+\r
+ @retval EFI_EFI_SUCCESS The firmware volume attributes were modified successfully.\r
+ @retval EFI_INVALID_PARAMETER Invalid parameter. Instance is larger than the max FVB number.\r
+\r
+**/\r
+EFI_STATUS\r
+EfiFvbSetVolumeAttributes (\r
+ IN UINTN Instance,\r
+ IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes\r
+ )\r
+{\r
+ ASSERT (Attributes != NULL);\r
+ \r
+ if (Instance >= mFvbCount) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (EfiAtRuntime() && !mFvbEntry[Instance].IsRuntimeAccess) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ return mFvbEntry[Instance].Fvb->SetAttributes (mFvbEntry[Instance].Fvb, Attributes);\r
+}\r
+\r
+/**\r
+ Retrieves the physical address of the specified memory mapped FV.\r
+\r
+ Retrieve the base address of a memory-mapped firmware volume specified by Instance.\r
+ If Instance is larger than the max FVB number, this function returns the status \r
+ code EFI_INVALID_PARAMETER.\r
+ \r
+ If BaseAddress is NULL, then ASSERT().\r
+\r
+ @param[in] Instance The FV instance to be operated.\r
+ @param[out] BaseAddress Pointer to a caller allocated EFI_PHYSICAL_ADDRESS \r
+ that on successful return, contains the base address\r
+ of the firmware volume. \r
+\r
+ @retval EFI_EFI_SUCCESS The firmware volume base address is returned.\r
+ @retval EFI_INVALID_PARAMETER Invalid parameter. Instance is larger than the max FVB number. \r
+\r
+**/\r
+EFI_STATUS\r
+EfiFvbGetPhysicalAddress (\r
+ IN UINTN Instance,\r
+ OUT EFI_PHYSICAL_ADDRESS *BaseAddress\r
+ )\r
+{\r
+ ASSERT (BaseAddress != NULL);\r
+ \r
+ if (Instance >= mFvbCount) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (EfiAtRuntime() && !mFvbEntry[Instance].IsRuntimeAccess) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ return mFvbEntry[Instance].Fvb->GetPhysicalAddress (mFvbEntry[Instance].Fvb, BaseAddress);\r
+}\r
+\r
+/**\r
+ Retrieve the block size of the specified fv.\r
+ \r
+ The EfiFvbGetBlockSize() function retrieves the size of the requested block. \r
+ It also returns the number of additional blocks with the identical size. \r
+ If Instance is larger than the max FVB number, or Lba index is larger than\r
+ the last block of the firmware volume, this function return the status code\r
+ EFI_INVALID_PARAMETER.\r
+\r
+ If BlockSize is NULL, then ASSERT().\r
+ \r
+ If NumOfBlocks is NULL, then ASSERT().\r
+\r
+ @param[in] Instance The FV instance to be operated.\r
+ @param[in] Lba Indicates which block to return the size for.\r
+ @param[out] BlockSize Pointer to a caller-allocated UINTN in which the\r
+ size of the block is returned.\r
+ @param[out] NumOfBlocks Pointer to a caller-allocated UINTN in which the \r
+ number of consecutive blocks, starting with Lba, \r
+ is returned. All blocks in this range have a size of BlockSize.\r
+\r
+ @retval EFI_EFI_SUCCESS The firmware volume base address is returned.\r
+ @retval EFI_INVALID_PARAMETER Invalid parameter. Instance is larger than the max FVB number.\r
+ Lba index is larger than the last block of the firmware volume.\r
+\r
+**/\r
+EFI_STATUS\r
+EfiFvbGetBlockSize (\r
+ IN UINTN Instance,\r
+ IN EFI_LBA Lba,\r
+ OUT UINTN *BlockSize,\r
+ OUT UINTN *NumOfBlocks\r
+ )\r
+{\r
+ ASSERT (BlockSize != NULL);\r
+ ASSERT (NumOfBlocks != NULL);\r
+ \r
+ if (Instance >= mFvbCount) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (EfiAtRuntime() && !mFvbEntry[Instance].IsRuntimeAccess) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ return mFvbEntry[Instance].Fvb->GetBlockSize (mFvbEntry[Instance].Fvb, Lba, BlockSize, NumOfBlocks);\r
+}\r
+\r
+/**\r
+ Erases and initializes a specified range of a firmware volume.\r
+\r
+ The EfiFvbEraseCustomBlockRange() function erases the specified range in the firmware\r
+ volume index by Instance. If Instance is larger than the max FVB number, StartLba or \r
+ LastLba index is larger than the last block of the firmware volume, StartLba > LastLba\r
+ or StartLba equal to LastLba but OffsetStartLba > OffsetLastLba, this function return \r
+ the status code EFI_INVALID_PARAMETER.\r
+\r
+ @param[in] Instance The FV instance to be operated.\r
+ @param[in] StartLba The starting logical block index to be erased.\r
+ @param[in] OffsetStartLba Offset into the starting block at which to \r
+ begin erasing. \r
+ @param[in] LastLba The last logical block index to be erased.\r
+ @param[in] OffsetLastLba Offset into the last block at which to end erasing. \r
+\r
+ @retval EFI_EFI_SUCCESS Successfully erase custom block range\r
+ @retval EFI_INVALID_PARAMETER Invalid parameter. Instance is larger than the max FVB number. \r
+ @retval EFI_UNSUPPORTED Firmware volume block device has no this capability.\r
+\r
+**/\r
+EFI_STATUS\r
+EfiFvbEraseCustomBlockRange (\r
+ IN UINTN Instance,\r
+ IN EFI_LBA StartLba,\r
+ IN UINTN OffsetStartLba,\r
+ IN EFI_LBA LastLba,\r
+ IN UINTN OffsetLastLba\r
+ )\r
+{\r
+ if (Instance >= mFvbCount) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (EfiAtRuntime() && !mFvbEntry[Instance].IsRuntimeAccess) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (!(mFvbEntry[Instance].FvbExtension)) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ if (!(mFvbEntry[Instance].FvbExtension->EraseFvbCustomBlock)) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ return mFvbEntry[Instance].FvbExtension->EraseFvbCustomBlock (\r
+ mFvbEntry[Instance].FvbExtension,\r
+ StartLba,\r
+ OffsetStartLba,\r
+ LastLba,\r
+ OffsetLastLba\r
+ );\r
+}\r
--- /dev/null
+/** @file \r
+ The internal header file includes the common header files, defines\r
+ internal structure FVB_ENTRY.\r
+\r
+Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
+\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions\r
+of the BSD License which accompanies this distribution. The\r
+full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef __FVB_H__\r
+#define __FVB_H__\r
+\r
+\r
+#include <PiDxe.h>\r
+\r
+#include <Protocol/FirmwareVolumeBlock.h>\r
+#include <Protocol/FvbExtension.h>\r
+\r
+#include <Library/FvbServiceLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/UefiRuntimeLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+\r
+#define MAX_FVB_COUNT 16\r
+\r
+typedef struct {\r
+ EFI_HANDLE Handle;\r
+ EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;\r
+ EFI_FVB_EXTENSION_PROTOCOL *FvbExtension;\r
+ BOOLEAN IsRuntimeAccess;\r
+} FVB_ENTRY;\r
+\r
+#endif\r
--- /dev/null
+/** @file\r
+ Library supports diplaying graphical splash screen,\r
+ locking of keyboard input and printing character on\r
+ screen. These basic graphics operations are based on UEFI HII, \r
+ Graphics Output protocol or UGA Draw protocol.\r
+\r
+Copyright (c) 2006 - 2008, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+\r
+#include <PiDxe.h>\r
+\r
+#include <Protocol/SimpleTextOut.h>\r
+#include <Protocol/OEMBadging.h>\r
+#include <Protocol/ConsoleControl.h>\r
+#include <Protocol/GraphicsOutput.h>\r
+#include <Protocol/UgaDraw.h>\r
+#include <Protocol/HiiFont.h>\r
+#include <Protocol/HiiImage.h>\r
+\r
+#include <Guid/Bmp.h>\r
+\r
+#include <Library/GraphicsLib.h>\r
+#include <Library/PrintLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/DxePiLib.h>\r
+#include <Library/PcdLib.h>\r
+\r
+STATIC EFI_GRAPHICS_OUTPUT_BLT_PIXEL mEfiColors[16] = {\r
+ { 0x00, 0x00, 0x00, 0x00 },\r
+ { 0x98, 0x00, 0x00, 0x00 },\r
+ { 0x00, 0x98, 0x00, 0x00 },\r
+ { 0x98, 0x98, 0x00, 0x00 },\r
+ { 0x00, 0x00, 0x98, 0x00 },\r
+ { 0x98, 0x00, 0x98, 0x00 },\r
+ { 0x00, 0x98, 0x98, 0x00 },\r
+ { 0x98, 0x98, 0x98, 0x00 },\r
+ { 0x10, 0x10, 0x10, 0x00 },\r
+ { 0xff, 0x10, 0x10, 0x00 },\r
+ { 0x10, 0xff, 0x10, 0x00 },\r
+ { 0xff, 0xff, 0x10, 0x00 },\r
+ { 0x10, 0x10, 0xff, 0x00 },\r
+ { 0xf0, 0x10, 0xff, 0x00 },\r
+ { 0x10, 0xff, 0xff, 0x00 },\r
+ { 0xff, 0xff, 0xff, 0x00 }\r
+};\r
+\r
+\r
+/**\r
+ Return the graphics image file named FileNameGuid into Image and return it's\r
+ size in ImageSize. All Firmware Volumes (FV) in the system are searched for the\r
+ file name.\r
+\r
+ @param FileNameGuid File Name of graphics file in the FV(s).\r
+ @param Image Pointer to pointer to return graphics image. If NULL, a \r
+ buffer will be allocated.\r
+ @param ImageSize Size of the graphics Image in bytes. Zero if no image found.\r
+\r
+ @retval EFI_SUCCESS Image and ImageSize are valid. \r
+ @retval EFI_BUFFER_TOO_SMALL Image not big enough. ImageSize has required size\r
+ @retval EFI_NOT_FOUND FileNameGuid not found\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GetGraphicsBitMapFromFV (\r
+ IN EFI_GUID *FileNameGuid,\r
+ OUT VOID **Image,\r
+ OUT UINTN *ImageSize\r
+ )\r
+{\r
+ return GetGraphicsBitMapFromFVEx (NULL, FileNameGuid, Image, ImageSize);\r
+}\r
+\r
+/**\r
+ Return the graphics image file named FileNameGuid into Image and return it's\r
+ size in ImageSize. All Firmware Volumes (FV) in the system are searched for the\r
+ file name.\r
+\r
+ @param ImageHandle The driver image handle of the caller. The parameter is used to\r
+ optimize the loading of the image file so that the FV from which\r
+ the driver image is loaded will be tried first. \r
+ @param FileNameGuid File Name of graphics file in the FV(s).\r
+ @param Image Pointer to pointer to return graphics image. If NULL, a \r
+ buffer will be allocated.\r
+ @param ImageSize Size of the graphics Image in bytes. Zero if no image found.\r
+\r
+ @retval EFI_SUCCESS Image and ImageSize are valid. \r
+ @retval EFI_BUFFER_TOO_SMALL Image not big enough. ImageSize has required size\r
+ @retval EFI_NOT_FOUND FileNameGuid not found\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GetGraphicsBitMapFromFVEx (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_GUID *FileNameGuid,\r
+ OUT VOID **Image,\r
+ OUT UINTN *ImageSize\r
+ )\r
+{\r
+ return PiLibGetSectionFromAnyFv (\r
+ FileNameGuid,\r
+ EFI_SECTION_RAW,\r
+ 0,\r
+ Image,\r
+ ImageSize\r
+ );\r
+}\r
+\r
+/**\r
+ Convert a *.BMP graphics image to a GOP blt buffer. If a NULL Blt buffer\r
+ is passed in a GopBlt buffer will be allocated by this routine. If a GopBlt\r
+ buffer is passed in it will be used if it is big enough.\r
+\r
+ @param BmpImage Pointer to BMP file\r
+ @param BmpImageSize Number of bytes in BmpImage\r
+ @param GopBlt Buffer containing GOP version of BmpImage.\r
+ @param GopBltSize Size of GopBlt in bytes.\r
+ @param PixelHeight Height of GopBlt/BmpImage in pixels\r
+ @param PixelWidth Width of GopBlt/BmpImage in pixels\r
+\r
+ @retval EFI_SUCCESS GopBlt and GopBltSize are returned. \r
+ @retval EFI_UNSUPPORTED BmpImage is not a valid *.BMP image\r
+ @retval EFI_BUFFER_TOO_SMALL The passed in GopBlt buffer is not big enough.\r
+ GopBltSize will contain the required size.\r
+ @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ConvertBmpToGopBlt (\r
+ IN VOID *BmpImage,\r
+ IN UINTN BmpImageSize,\r
+ IN OUT VOID **GopBlt,\r
+ IN OUT UINTN *GopBltSize,\r
+ OUT UINTN *PixelHeight,\r
+ OUT UINTN *PixelWidth\r
+ )\r
+{\r
+ UINT8 *Image;\r
+ UINT8 *ImageHeader;\r
+ BMP_IMAGE_HEADER *BmpHeader;\r
+ BMP_COLOR_MAP *BmpColorMap;\r
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer;\r
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;\r
+ UINTN BltBufferSize;\r
+ UINTN Index;\r
+ UINTN Height;\r
+ UINTN Width;\r
+ UINTN ImageIndex;\r
+ BOOLEAN IsAllocated;\r
+\r
+ BmpHeader = (BMP_IMAGE_HEADER *) BmpImage;\r
+\r
+ if (BmpHeader->CharB != 'B' || BmpHeader->CharM != 'M') {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ //\r
+ // Doesn't support compress.\r
+ //\r
+ if (BmpHeader->CompressionType != 0) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ //\r
+ // Calculate Color Map offset in the image.\r
+ //\r
+ Image = BmpImage;\r
+ BmpColorMap = (BMP_COLOR_MAP *) (Image + sizeof (BMP_IMAGE_HEADER));\r
+\r
+ //\r
+ // Calculate graphics image data address in the image\r
+ //\r
+ Image = ((UINT8 *) BmpImage) + BmpHeader->ImageOffset;\r
+ ImageHeader = Image;\r
+\r
+ //\r
+ // Calculate the BltBuffer needed size.\r
+ //\r
+ BltBufferSize = BmpHeader->PixelWidth * BmpHeader->PixelHeight * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);\r
+ IsAllocated = FALSE;\r
+ if (*GopBlt == NULL) {\r
+ //\r
+ // GopBlt is not allocated by caller.\r
+ //\r
+ *GopBltSize = BltBufferSize;\r
+ *GopBlt = AllocatePool (*GopBltSize);\r
+ IsAllocated = TRUE;\r
+ if (*GopBlt == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+ } else {\r
+ //\r
+ // GopBlt has been allocated by caller.\r
+ //\r
+ if (*GopBltSize < BltBufferSize) {\r
+ *GopBltSize = BltBufferSize;\r
+ return EFI_BUFFER_TOO_SMALL;\r
+ }\r
+ }\r
+\r
+ *PixelWidth = BmpHeader->PixelWidth;\r
+ *PixelHeight = BmpHeader->PixelHeight;\r
+\r
+ //\r
+ // Convert image from BMP to Blt buffer format\r
+ //\r
+ BltBuffer = *GopBlt;\r
+ for (Height = 0; Height < BmpHeader->PixelHeight; Height++) {\r
+ Blt = &BltBuffer[(BmpHeader->PixelHeight - Height - 1) * BmpHeader->PixelWidth];\r
+ for (Width = 0; Width < BmpHeader->PixelWidth; Width++, Image++, Blt++) {\r
+ switch (BmpHeader->BitPerPixel) {\r
+ case 1:\r
+ //\r
+ // Convert 1-bit (2 colors) BMP to 24-bit color\r
+ //\r
+ for (Index = 0; Index < 8 && Width < BmpHeader->PixelWidth; Index++) {\r
+ Blt->Red = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Red;\r
+ Blt->Green = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Green;\r
+ Blt->Blue = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Blue;\r
+ Blt++;\r
+ Width++;\r
+ }\r
+\r
+ Blt --;\r
+ Width --;\r
+ break;\r
+\r
+ case 4:\r
+ //\r
+ // Convert 4-bit (16 colors) BMP Palette to 24-bit color\r
+ //\r
+ Index = (*Image) >> 4;\r
+ Blt->Red = BmpColorMap[Index].Red;\r
+ Blt->Green = BmpColorMap[Index].Green;\r
+ Blt->Blue = BmpColorMap[Index].Blue;\r
+ if (Width < (BmpHeader->PixelWidth - 1)) {\r
+ Blt++;\r
+ Width++;\r
+ Index = (*Image) & 0x0f;\r
+ Blt->Red = BmpColorMap[Index].Red;\r
+ Blt->Green = BmpColorMap[Index].Green;\r
+ Blt->Blue = BmpColorMap[Index].Blue;\r
+ }\r
+ break;\r
+\r
+ case 8:\r
+ //\r
+ // Convert 8-bit (256 colors) BMP Palette to 24-bit color\r
+ //\r
+ Blt->Red = BmpColorMap[*Image].Red;\r
+ Blt->Green = BmpColorMap[*Image].Green;\r
+ Blt->Blue = BmpColorMap[*Image].Blue;\r
+ break;\r
+\r
+ case 24:\r
+ //\r
+ // It is 24-bit BMP.\r
+ //\r
+ Blt->Blue = *Image++;\r
+ Blt->Green = *Image++;\r
+ Blt->Red = *Image;\r
+ break;\r
+\r
+ default:\r
+ //\r
+ // Other bit format BMP is not supported.\r
+ //\r
+ if (IsAllocated) {\r
+ FreePool (*GopBlt);\r
+ *GopBlt = NULL;\r
+ }\r
+ return EFI_UNSUPPORTED;\r
+ break;\r
+ };\r
+\r
+ }\r
+\r
+ ImageIndex = (UINTN) (Image - ImageHeader);\r
+ if ((ImageIndex % 4) != 0) {\r
+ //\r
+ // Bmp Image starts each row on a 32-bit boundary!\r
+ //\r
+ Image = Image + (4 - (ImageIndex % 4));\r
+ }\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+ Use Console Control Protocol to lock the Console In Spliter virtual handle. \r
+ This is the ConInHandle and ConIn handle in the EFI system table. All key\r
+ presses will be ignored until the Password is typed in. The only way to\r
+ disable the password is to type it in to a ConIn device.\r
+\r
+ @param Password Password used to lock ConIn device.\r
+\r
+ @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.\r
+ @retval EFI_UNSUPPORTED Password not found.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+LockKeyboards (\r
+ IN CHAR16 *Password\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl;\r
+\r
+ Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, (VOID **) &ConsoleControl);\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ Status = ConsoleControl->LockStdIn (ConsoleControl, Password);\r
+ return Status;\r
+}\r
+\r
+\r
+/**\r
+ Use Console Control to turn off UGA based Simple Text Out consoles from going\r
+ to the UGA device. Put up LogoFile on every UGA device that is a console.\r
+\r
+ @param LogoFile File name of logo to display on the center of the screen.\r
+\r
+ @retval EFI_SUCCESS ConsoleControl has been flipped to graphics and logo displayed.\r
+ @retval EFI_UNSUPPORTED Logo not found.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EnableQuietBoot (\r
+ IN EFI_GUID *LogoFile\r
+ )\r
+{\r
+ return EnableQuietBootEx (LogoFile, NULL);\r
+}\r
+\r
+/**\r
+ Use Console Control to turn off UGA based Simple Text Out consoles from going\r
+ to the UGA device. Put up LogoFile on every UGA device that is a console\r
+\r
+ @param LogoFile File name of logo to display on the center of the screen.\r
+ @param ImageHandle The driver image handle of the caller. The parameter is used to\r
+ optimize the loading of the logo file so that the FV from which\r
+ the driver image is loaded will be tried first.\r
+\r
+ @retval EFI_SUCCESS ConsoleControl has been flipped to graphics and logo displayed.\r
+ @retval EFI_UNSUPPORTED Logo not found.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EnableQuietBootEx (\r
+ IN EFI_GUID *LogoFile,\r
+ IN EFI_HANDLE ImageHandle\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl;\r
+ EFI_OEM_BADGING_PROTOCOL *Badging;\r
+ UINT32 SizeOfX;\r
+ UINT32 SizeOfY;\r
+ INTN DestX;\r
+ INTN DestY;\r
+ UINT8 *ImageData;\r
+ UINTN ImageSize;\r
+ UINTN BltSize;\r
+ UINT32 Instance;\r
+ EFI_BADGING_FORMAT Format;\r
+ EFI_BADGING_DISPLAY_ATTRIBUTE Attribute;\r
+ UINTN CoordinateX;\r
+ UINTN CoordinateY;\r
+ UINTN Height;\r
+ UINTN Width;\r
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;\r
+ EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r
+ UINT32 ColorDepth;\r
+ UINT32 RefreshRate;\r
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
+\r
+ Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, (VOID **) &ConsoleControl);\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ UgaDraw = NULL;\r
+ //\r
+ // Try to open GOP first\r
+ //\r
+ Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiGraphicsOutputProtocolGuid, (VOID **) &GraphicsOutput);\r
+ if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {\r
+ GraphicsOutput = NULL;\r
+ //\r
+ // Open GOP failed, try to open UGA\r
+ //\r
+ Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiUgaDrawProtocolGuid, (VOID **) &UgaDraw);\r
+ }\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ Badging = NULL;\r
+ Status = gBS->LocateProtocol (&gEfiOEMBadgingProtocolGuid, NULL, (VOID **) &Badging);\r
+\r
+ //\r
+ // Set console control to graphics mode.\r
+ //\r
+ Status = ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenGraphics);\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ if (GraphicsOutput != NULL) {\r
+ SizeOfX = GraphicsOutput->Mode->Info->HorizontalResolution;\r
+ SizeOfY = GraphicsOutput->Mode->Info->VerticalResolution;\r
+ } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {\r
+ Status = UgaDraw->GetMode (UgaDraw, &SizeOfX, &SizeOfY, &ColorDepth, &RefreshRate);\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+ } else {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ Instance = 0;\r
+ while (1) {\r
+ ImageData = NULL;\r
+ ImageSize = 0;\r
+\r
+ if (Badging != NULL) {\r
+ //\r
+ // Get image from OEMBadging protocol.\r
+ //\r
+ Status = Badging->GetImage (\r
+ Badging,\r
+ &Instance,\r
+ &Format,\r
+ &ImageData,\r
+ &ImageSize,\r
+ &Attribute,\r
+ &CoordinateX,\r
+ &CoordinateY\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ //\r
+ // Currently only support BMP format.\r
+ //\r
+ if (Format != EfiBadgingFormatBMP) {\r
+ SafeFreePool (ImageData);\r
+ continue;\r
+ }\r
+ } else {\r
+ //\r
+ // Get the specified image from FV.\r
+ //\r
+ Status = GetGraphicsBitMapFromFVEx (ImageHandle, LogoFile, (VOID **) &ImageData, &ImageSize);\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ CoordinateX = 0;\r
+ CoordinateY = 0;\r
+ Attribute = EfiBadgingDisplayAttributeCenter;\r
+ }\r
+\r
+ Blt = NULL;\r
+ Status = ConvertBmpToGopBlt (\r
+ ImageData,\r
+ ImageSize,\r
+ (VOID **) &Blt,\r
+ &BltSize,\r
+ &Height,\r
+ &Width\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ SafeFreePool (ImageData);\r
+ if (Badging == NULL) {\r
+ return Status;\r
+ } else {\r
+ continue;\r
+ }\r
+ }\r
+\r
+ //\r
+ // Caculate the display position according to Attribute.\r
+ //\r
+ switch (Attribute) {\r
+ case EfiBadgingDisplayAttributeLeftTop:\r
+ DestX = CoordinateX;\r
+ DestY = CoordinateY;\r
+ break;\r
+\r
+ case EfiBadgingDisplayAttributeCenterTop:\r
+ DestX = (SizeOfX - Width) / 2;\r
+ DestY = CoordinateY;\r
+ break;\r
+\r
+ case EfiBadgingDisplayAttributeRightTop:\r
+ DestX = (SizeOfX - Width - CoordinateX);\r
+ DestY = CoordinateY;;\r
+ break;\r
+\r
+ case EfiBadgingDisplayAttributeCenterRight:\r
+ DestX = (SizeOfX - Width - CoordinateX);\r
+ DestY = (SizeOfY - Height) / 2;\r
+ break;\r
+\r
+ case EfiBadgingDisplayAttributeRightBottom:\r
+ DestX = (SizeOfX - Width - CoordinateX);\r
+ DestY = (SizeOfY - Height - CoordinateY);\r
+ break;\r
+\r
+ case EfiBadgingDisplayAttributeCenterBottom:\r
+ DestX = (SizeOfX - Width) / 2;\r
+ DestY = (SizeOfY - Height - CoordinateY);\r
+ break;\r
+\r
+ case EfiBadgingDisplayAttributeLeftBottom:\r
+ DestX = CoordinateX;\r
+ DestY = (SizeOfY - Height - CoordinateY);\r
+ break;\r
+\r
+ case EfiBadgingDisplayAttributeCenterLeft:\r
+ DestX = CoordinateX;\r
+ DestY = (SizeOfY - Height) / 2;\r
+ break;\r
+\r
+ case EfiBadgingDisplayAttributeCenter:\r
+ DestX = (SizeOfX - Width) / 2;\r
+ DestY = (SizeOfY - Height) / 2;\r
+ break;\r
+\r
+ default:\r
+ DestX = CoordinateX;\r
+ DestY = CoordinateY;\r
+ break;\r
+ }\r
+\r
+ if ((DestX >= 0) && (DestY >= 0)) {\r
+ if (GraphicsOutput != NULL) {\r
+ Status = GraphicsOutput->Blt (\r
+ GraphicsOutput,\r
+ Blt,\r
+ EfiBltBufferToVideo,\r
+ 0,\r
+ 0,\r
+ (UINTN) DestX,\r
+ (UINTN) DestY,\r
+ Width,\r
+ Height,\r
+ Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
+ );\r
+ } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {\r
+ Status = UgaDraw->Blt (\r
+ UgaDraw,\r
+ (EFI_UGA_PIXEL *) Blt,\r
+ EfiUgaBltBufferToVideo,\r
+ 0,\r
+ 0,\r
+ (UINTN) DestX,\r
+ (UINTN) DestY,\r
+ Width,\r
+ Height,\r
+ Width * sizeof (EFI_UGA_PIXEL)\r
+ );\r
+ } else {\r
+ Status = EFI_UNSUPPORTED;\r
+ }\r
+ }\r
+\r
+ SafeFreePool (ImageData);\r
+ SafeFreePool (Blt);\r
+\r
+ if (Badging == NULL) {\r
+ break;\r
+ }\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+/**\r
+ Use Console Control to turn on UGA based Simple Text Out consoles. The UGA \r
+ Simple Text Out screens will now be synced up with all non UGA output devices\r
+\r
+ @retval EFI_SUCCESS UGA devices are back in text mode and synced up.\r
+ @retval EFI_UNSUPPORTED Logo not found\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DisableQuietBoot (\r
+ VOID\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl;\r
+\r
+ Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, (VOID **) &ConsoleControl);\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ //\r
+ // Set console control to text mode.\r
+ //\r
+ return ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenText);\r
+}\r
+\r
+/**\r
+ Internal display string worker function.\r
+\r
+ @param GraphicsOutput Graphics output protocol interface.\r
+ @param UgaDraw UGA draw protocol interface.\r
+ @param Sto Simple text out protocol interface.\r
+ @param X X coordinate to start printing.\r
+ @param Y Y coordinate to start printing.\r
+ @param Foreground Foreground color.\r
+ @param Background Background color.\r
+ @param fmt Format string.\r
+ @param args Print arguments.\r
+\r
+ @return Number of Characters printed. Zero means no any character \r
+ displayed successfully.\r
+\r
+**/\r
+UINTN\r
+Print (\r
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,\r
+ IN EFI_UGA_DRAW_PROTOCOL *UgaDraw,\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Sto,\r
+ IN UINTN X,\r
+ IN UINTN Y,\r
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Foreground,\r
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Background,\r
+ IN CHAR16 *fmt,\r
+ IN VA_LIST args\r
+ )\r
+{\r
+ VOID *Buffer;\r
+ EFI_STATUS Status;\r
+ UINTN Index;\r
+ CHAR16 *UnicodeWeight;\r
+ UINT32 HorizontalResolution;\r
+ UINT32 VerticalResolution;\r
+ UINT32 ColorDepth;\r
+ UINT32 RefreshRate;\r
+ UINTN BufferLen;\r
+ UINTN LineBufferLen;\r
+ EFI_HII_FONT_PROTOCOL *HiiFont;\r
+ EFI_IMAGE_OUTPUT *Blt;\r
+ EFI_FONT_DISPLAY_INFO *FontInfo;\r
+ EFI_HII_ROW_INFO *RowInfoArray;\r
+ UINTN RowInfoArraySize;\r
+ UINTN PrintNum; \r
+\r
+ //\r
+ // For now, allocate an arbitrarily long buffer\r
+ //\r
+ Buffer = AllocateZeroPool (0x10000);\r
+ if (Buffer == NULL) {\r
+ return 0;\r
+ }\r
+\r
+ HorizontalResolution = 0;\r
+ VerticalResolution = 0;\r
+ Blt = NULL;\r
+ FontInfo = NULL;\r
+ PrintNum = 0;\r
+\r
+ if (GraphicsOutput != NULL) {\r
+ HorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution;\r
+ VerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution;\r
+ } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {\r
+ UgaDraw->GetMode (UgaDraw, &HorizontalResolution, &VerticalResolution, &ColorDepth, &RefreshRate);\r
+ } else {\r
+ Status = EFI_UNSUPPORTED;\r
+ goto Error;\r
+ }\r
+\r
+ ASSERT ((HorizontalResolution != 0) && (VerticalResolution !=0));\r
+\r
+ Status = gBS->LocateProtocol (&gEfiHiiFontProtocolGuid, NULL, (VOID **) &HiiFont);\r
+ if (EFI_ERROR (Status)) {\r
+ goto Error;\r
+ }\r
+\r
+ PrintNum = UnicodeVSPrint (Buffer, 0x10000, fmt, args);\r
+\r
+ UnicodeWeight = (CHAR16 *) Buffer;\r
+\r
+ for (Index = 0; UnicodeWeight[Index] != 0; Index++) {\r
+ if (UnicodeWeight[Index] == CHAR_BACKSPACE ||\r
+ UnicodeWeight[Index] == CHAR_LINEFEED ||\r
+ UnicodeWeight[Index] == CHAR_CARRIAGE_RETURN) {\r
+ UnicodeWeight[Index] = 0;\r
+ }\r
+ }\r
+\r
+ BufferLen = StrLen (Buffer);\r
+\r
+ LineBufferLen = sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * HorizontalResolution * EFI_GLYPH_HEIGHT;\r
+ if (EFI_GLYPH_WIDTH * EFI_GLYPH_HEIGHT * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * BufferLen > LineBufferLen) {\r
+ Status = EFI_INVALID_PARAMETER;\r
+ goto Error;\r
+ }\r
+\r
+ Blt = (EFI_IMAGE_OUTPUT *) AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT));\r
+ if (Blt == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Error;\r
+ }\r
+\r
+ Blt->Width = (UINT16) (HorizontalResolution);\r
+ Blt->Height = (UINT16) (VerticalResolution);\r
+\r
+ FontInfo = (EFI_FONT_DISPLAY_INFO *) AllocateZeroPool (sizeof (EFI_FONT_DISPLAY_INFO));\r
+ if (FontInfo == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Error;\r
+ }\r
+ if (Foreground != NULL) {\r
+ CopyMem (&FontInfo->ForegroundColor, Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
+ } else {\r
+ CopyMem (\r
+ &FontInfo->ForegroundColor,\r
+ &mEfiColors[Sto->Mode->Attribute & 0x0f],\r
+ sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
+ );\r
+ }\r
+ if (Background != NULL) {\r
+ CopyMem (&FontInfo->BackgroundColor, Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
+ } else {\r
+ CopyMem (\r
+ &FontInfo->BackgroundColor,\r
+ &mEfiColors[Sto->Mode->Attribute >> 4],\r
+ sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
+ );\r
+ }\r
+\r
+ if (GraphicsOutput != NULL) {\r
+ Blt->Image.Screen = GraphicsOutput;\r
+ \r
+ Status = HiiFont->StringToImage (\r
+ HiiFont,\r
+ EFI_HII_IGNORE_IF_NO_GLYPH | EFI_HII_DIRECT_TO_SCREEN,\r
+ Buffer,\r
+ FontInfo,\r
+ &Blt,\r
+ X,\r
+ Y,\r
+ NULL,\r
+ NULL,\r
+ NULL\r
+ );\r
+\r
+ } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {\r
+ ASSERT (UgaDraw!= NULL);\r
+\r
+ Blt->Image.Bitmap = AllocateZeroPool (Blt->Width * Blt->Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
+ if (Blt->Image.Bitmap == NULL) {\r
+ SafeFreePool (Blt);\r
+ SafeFreePool (Buffer);\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ RowInfoArray = NULL;\r
+ //\r
+ // StringToImage only support blt'ing image to device using GOP protocol. If GOP is not supported in this platform,\r
+ // we ask StringToImage to print the string to blt buffer, then blt to device using UgaDraw.\r
+ //\r
+ Status = HiiFont->StringToImage (\r
+ HiiFont,\r
+ EFI_HII_IGNORE_IF_NO_GLYPH,\r
+ Buffer,\r
+ FontInfo,\r
+ &Blt,\r
+ X,\r
+ Y,\r
+ &RowInfoArray,\r
+ &RowInfoArraySize,\r
+ NULL\r
+ );\r
+\r
+ if (!EFI_ERROR (Status)) {\r
+ //\r
+ // Line breaks are handled by caller of DrawUnicodeWeightAtCursorN, so the updated parameter RowInfoArraySize by StringToImage will\r
+ // always be 1 or 0 (if there is no valid Unicode Char can be printed). ASSERT here to make sure.\r
+ //\r
+ ASSERT (RowInfoArraySize <= 1);\r
+\r
+ Status = UgaDraw->Blt (\r
+ UgaDraw,\r
+ (EFI_UGA_PIXEL *) Blt->Image.Bitmap,\r
+ EfiUgaBltBufferToVideo,\r
+ X,\r
+ Y,\r
+ X,\r
+ Y,\r
+ RowInfoArray[0].LineWidth,\r
+ RowInfoArray[0].LineHeight,\r
+ Blt->Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
+ );\r
+ }\r
+\r
+ SafeFreePool (RowInfoArray);\r
+ SafeFreePool (Blt->Image.Bitmap);\r
+ } else {\r
+ Status = EFI_UNSUPPORTED;\r
+ }\r
+\r
+Error:\r
+ SafeFreePool (Blt);\r
+ SafeFreePool (FontInfo);\r
+ FreePool (Buffer);\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ return PrintNum;\r
+ } else {\r
+ return 0;\r
+ }\r
+}\r
+\r
+/**\r
+ Print Unicode string to graphics screen at the given X,Y coordinates of the graphics screen.\r
+ see definition of Print to find rules for constructing Fmt.\r
+\r
+ @param X Row to start printing at.\r
+ @param Y Column to start printing at.\r
+ @param ForeGround Foreground color.\r
+ @param BackGround background color.\r
+ @param Fmt Print format sting. See definition of Print.\r
+ @param ... Argumnet stream defined by Fmt string.\r
+\r
+ @return Number of Characters printed. Zero means no any character \r
+ displayed successfully.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+PrintXY (\r
+ IN UINTN X,\r
+ IN UINTN Y,\r
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *ForeGround, OPTIONAL\r
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BackGround, OPTIONAL\r
+ IN CHAR16 *Fmt,\r
+ ...\r
+ )\r
+{\r
+ EFI_HANDLE Handle;\r
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
+ EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Sto;\r
+ EFI_STATUS Status;\r
+ VA_LIST Args;\r
+\r
+ VA_START (Args, Fmt);\r
+\r
+ Handle = gST->ConsoleOutHandle;\r
+\r
+ Status = gBS->HandleProtocol (\r
+ Handle,\r
+ &gEfiGraphicsOutputProtocolGuid,\r
+ (VOID **) &GraphicsOutput\r
+ );\r
+\r
+ UgaDraw = NULL;\r
+ if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {\r
+ //\r
+ // If no GOP available, try to open UGA Draw protocol if supported.\r
+ //\r
+ GraphicsOutput = NULL;\r
+\r
+ Status = gBS->HandleProtocol (\r
+ Handle,\r
+ &gEfiUgaDrawProtocolGuid,\r
+ (VOID **) &UgaDraw\r
+ );\r
+ }\r
+ if (EFI_ERROR (Status)) {\r
+ return 0;\r
+ }\r
+\r
+ Status = gBS->HandleProtocol (\r
+ Handle,\r
+ &gEfiSimpleTextOutProtocolGuid,\r
+ (VOID **) &Sto\r
+ );\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ return 0;\r
+ }\r
+\r
+ return Print (GraphicsOutput, UgaDraw, Sto, X, Y, ForeGround, BackGround, Fmt, Args);\r
+}\r
+\r
--- /dev/null
+#/** @file\r
+# Library supports diplaying graphical splash screen,\r
+# locking of keyboard input and printing character on\r
+# screen.\r
+#\r
+# This library provides supports for basic graphic functions.\r
+# Copyright (c) 2006 - 2007, Intel Corporation.\r
+#\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = UefiGraphicsLib\r
+ FILE_GUID = 08c1a0e4-1208-47f8-a2c5-f42eabee653a\r
+ MODULE_TYPE = DXE_DRIVER\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = GraphicsLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
+ EDK_RELEASE_VERSION = 0x00020000\r
+ EFI_SPECIFICATION_VERSION = 0x00020000\r
+\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources.common]\r
+ Graphics.c\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ MdeModulePkg/MdeModulePkg.dec\r
+\r
+[LibraryClasses]\r
+ UefiBootServicesTableLib\r
+ MemoryAllocationLib\r
+ BaseLib\r
+ PrintLib\r
+ DebugLib\r
+ DxePiLib\r
+ BaseMemoryLib\r
+ PcdLib\r
+\r
+[Protocols]\r
+ gEfiSimpleTextOutProtocolGuid # PROTOCOL ALWAYS_CONSUMED\r
+ gEfiGraphicsOutputProtocolGuid # PROTOCOL ALWAYS_CONSUMED\r
+ gEfiUgaDrawProtocolGuid # PROTOCOL ALWAYS_CONSUMED\r
+ gEfiConsoleControlProtocolGuid # PROTOCOL ALWAYS_CONSUMED\r
+ gEfiFirmwareVolume2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED\r
+ gEfiOEMBadgingProtocolGuid # PROTOCOL ALWAYS_CONSUMED\r
+ gEfiHiiFontProtocolGuid # PROTOCOL ALWAYS_CONSUMED\r
+\r
+[FeaturePcd.common]\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdUgaConsumeSupport\r
DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf\r
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf\r
UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf\r
- FvbServiceLib|MdePkg/Library/FvbServiceLib/FvbServiceLib.inf\r
+ FvbServiceLib|MdeModulePkg/Library/EdkFvbServiceLib/EdkFvbServiceLib.inf\r
ScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf\r
HiiLib|MdePkg/Library/UefiHiiLib/UefiHiiLib.inf\r
ExtendedHiiLib|MdeModulePkg/Library/ExtendedHiiLib/ExtendedHiiLib.inf\r
UdpIoLib|MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf\r
DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf\r
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
- GraphicsLib|MdePkg/Library/GraphicsLib/GraphicsLib.inf\r
+ GraphicsLib|MdeModulePkg/Library/GraphicsLib/GraphicsLib.inf\r
IfrSupportLib|MdePkg/Library/UefiIfrSupportLib/UefiIfrSupportLib.inf\r
ExtendedIfrSupportLib|MdeModulePkg/Library/ExtendedIfrSupportLib/ExtendedIfrSupportLib.inf\r
CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf\r
DxePiLib|MdePkg/Library/DxePiLib/DxePiLib.inf\r
PlatformBdsLib|MdeModulePkg/Library/PlatformBdsLibNull/PlatformBdsLibNull.inf\r
GenericBdsLib|MdeModulePkg/Library/GenericBdsLib/GenericBdsLib.inf\r
- GraphicsLib|MdePkg/Library/GraphicsLib/GraphicsLib.inf\r
DxePiLib|MdePkg/Library/DxePiLib/DxePiLib.inf\r
PlatformBdsLib|MdeModulePkg/Library/PlatformBdsLibNull/PlatformBdsLibNull.inf\r
GenericBdsLib|MdeModulePkg/Library/GenericBdsLib/GenericBdsLib.inf\r
MdeModulePkg/Library/PeiRecoveryLibNull/PeiRecoveryLibNull.inf\r
MdeModulePkg/Library/PeiS3LibNull/PeiS3LibNull.inf\r
MdeModulePkg/Library/PlatformBdsLibNull/PlatformBdsLibNull.inf\r
+ MdeModulePkg/Library/EdkFvbServiceLib/EdkFvbServiceLib.inf\r
+ MdeModulePkg/Library/GraphicsLib/GraphicsLib.inf\r
\r
MdeModulePkg/Universal/BdsDxe/BdsDxe.inf\r
MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf\r
+++ /dev/null
-/** @file\r
- PAL Library Class implementation whose PAL entry is collected\r
- from HOB or SAL System Table.\r
-\r
- Copyright (c) 2007 - 2008 Intel Corporation. All rights reserved\r
- This software and associated documentation (if any) is furnished\r
- under a license and may only be used or copied in accordance\r
- with the terms of the license. Except as permitted by such\r
- license, no part of this software or documentation may be\r
- reproduced, stored in a retrieval system, or transmitted in any\r
- form or by any means without the express written consent of\r
- Intel Corporation.\r
-\r
- Module Name: DxePalCallLib.c\r
-\r
-**/\r
-\r
-#include <PiDxe.h>\r
-#include <ItaniumFamilyCpuDxe.h>\r
-#include <IndustryStandard/Sal.h>\r
-\r
-#include <Guid/PalEntryHob.h>\r
-#include <Guid/SalSystemTable.h>\r
-\r
-#include <Library/PalCallLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/HobLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiLib.h>\r
-\r
-\r
-BOOLEAN mPalCallAddressHob = FALSE;\r
-BOOLEAN mPalCallAddressSal = FALSE;\r
-UINT64 mPalCallAddress;\r
-\r
-/**\r
- Makes a PAL procedure call.\r
-\r
- This is a wrapper function to make a PAL procedure call. Based on the Index value,\r
- this API will make static or stacked PAL call. Architected procedures may be designated\r
- as required or optional. If a PAL procedure is specified as optional, a unique return\r
- code of 0xFFFFFFFFFFFFFFFF is returned in the Status field of the PAL_CALL_RETURN structure.\r
- This indicates that the procedure is not present in this PAL implementation. It is the\r
- caller's responsibility to check for this return code after calling any optional PAL\r
- procedure. No parameter checking is performed on the 4 input parameters, but there are\r
- some common rules that the caller should follow when making a PAL call. Any address\r
- passed to PAL as buffers for return parameters must be 8-byte aligned. Unaligned addresses\r
- may cause undefined results. For those parameters defined as reserved or some fields\r
- defined as reserved must be zero filled or the invalid argument return value may be\r
- returned or undefined result may occur during the execution of the procedure.\r
- This function is only available on IPF.\r
-\r
- @param Index The PAL procedure Index number.\r
- @param Arg2 The 2nd parameter for PAL procedure calls.\r
- @param Arg3 The 3rd parameter for PAL procedure calls.\r
- @param Arg4 The 4th parameter for PAL procedure calls.\r
-\r
- @return Structure returned from the PAL Call procedure, including the status and return value.\r
-\r
-**/\r
-PAL_CALL_RETURN\r
-EFIAPI\r
-PalCall (\r
- IN UINT64 Index,\r
- IN UINT64 Arg2,\r
- IN UINT64 Arg3,\r
- IN UINT64 Arg4\r
- )\r
-{\r
- EFI_HOB_GUID_TYPE *GuidHob;\r
- EFI_STATUS Status;\r
- SAL_ST_ENTRY_POINT_DESCRIPTOR *SalStEntryDes;\r
- SAL_SYSTEM_TABLE_HEADER *SalSystemTable;\r
-\r
-\r
- if (!mPalCallAddressHob) {\r
- //\r
- // Collect PAL entry from HOBs\r
- //\r
- GuidHob = GetFirstGuidHob (&gPalEntryHobGuid);\r
- ASSERT (GuidHob != NULL);\r
-\r
- mPalCallAddress = *((EFI_PHYSICAL_ADDRESS *) GET_GUID_HOB_DATA (GuidHob));\r
- ASSERT (mPalCallAddress != 0);\r
-\r
- mPalCallAddressHob = TRUE;\r
- }\r
-\r
- if (!mPalCallAddressSal) {\r
- Status = EfiGetSystemConfigurationTable (\r
- &gEfiSalSystemTableGuid,\r
- (VOID **) &SalSystemTable\r
- );\r
-\r
- if (!EFI_ERROR (Status)) {\r
- //\r
- // Move the SAL System Table point to the first Entry\r
- // Due to the SAL Entry is in ascending order with the Entry type,\r
- // the type 0 Entry should be the first if exist.\r
- //\r
- SalStEntryDes = (SAL_ST_ENTRY_POINT_DESCRIPTOR *)(SalSystemTable + 1);\r
-\r
- //\r
- // Assure the SAL ENTRY Type is 0\r
- //\r
- ASSERT (SalStEntryDes->Type == EFI_SAL_ST_ENTRY_POINT);\r
-\r
- if (SalStEntryDes->PalProcEntry != 0) {\r
- mPalCallAddress = SalStEntryDes->PalProcEntry;\r
- mPalCallAddressSal = TRUE;\r
- }\r
- }\r
- }\r
-\r
- return AsmPalCall (mPalCallAddress, Index, Arg2, Arg3, Arg4);\r
-}\r
+++ /dev/null
-# @file\r
-# Instance of PAL Library retrieving PAL entrypoint from HOB.\r
-#\r
-# Instance of PAL Library that uses a HOB to retrieve the PAL\r
-# Entry Point and layers on top of AsmPalCall() in the Base Library.\r
-#\r
-# Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.\r
-#\r
-# This software and associated documentation (if any) is furnished\r
-# under a license and may only be used or copied in accordance\r
-# with the terms of the license. Except as permitted by such\r
-# license, no part of this software or documentation may be\r
-# reproduced, stored in a retrieval system, or transmitted in any\r
-# form or by any means without the express written consent of\r
-# Intel Corporation.\r
-#\r
-#\r
-#\r
-\r
-[Defines]\r
- INF_VERSION = 0x00010005\r
- BASE_NAME = DxePalLib\r
- FILE_GUID = B05D4251-5BA5-46f2-A011-46CC46D9A590\r
- MODULE_TYPE = DXE_DRIVER\r
- VERSION_STRING = 1.0\r
- LIBRARY_CLASS = PalCallLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER UEFI_DRIVER UEFI_APPLICATION\r
- EDK_RELEASE_VERSION = 0x00020000\r
-\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-# VALID_ARCHITECTURES = IPF\r
-#\r
-\r
-[Sources.IPF]\r
- DxePalCallLib.c\r
-\r
-[Packages]\r
- MdePkg/MdePkg.dec\r
- IntelFrameworkPkg/IntelFrameworkPkg.dec\r
- ItaniumFamilyCpuPkg/ItaniumFamilyCpuPkg.dec\r
- ItaniumPlatformPkg/ItaniumPlatformPkg.dec \r
-\r
-[LibraryClasses]\r
- BaseLib\r
- HobLib\r
- UefiLib\r
- DebugLib\r
-\r
-[Guids]\r
- gPalEntryHobGuid # ALWAYS_CONSUMED\r
- gEfiSalSystemTableGuid # ALWAYS_CONSUMED\r
+++ /dev/null
-/**@file\r
-\r
- Firmware Volume Block Protocol Runtime Interface Abstraction\r
- And FVB Extension protocol Runtime Interface Abstraction\r
-\r
- mFvbEntry is an array of Handle Fvb pairs. The Fvb Lib Instance matches the\r
- index in the mFvbEntry array. This should be the same sequence as the FVB's\r
- were described in the HOB. We have to remember the handle so we can tell if\r
- the protocol has been reinstalled and it needs updateing.\r
-\r
- If you are using any of these lib functions.you must first call FvbInitialize ().\r
-\r
-Copyright (c) 2006 - 2008, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-\r
-#include "Fvb.h"\r
-\r
-//\r
-// Event for Set Virtual Map Changed Event\r
-//\r
-STATIC EFI_EVENT mSetVirtualMapChangedEvent = NULL;\r
-\r
-//\r
-// Lib will ASSERT if more FVB devices than this are added to the system.\r
-//\r
-STATIC FVB_ENTRY *mFvbEntry;\r
-STATIC EFI_EVENT mFvbRegistration;\r
-STATIC UINTN mFvbCount;\r
-\r
-/**\r
- Check whether an address is runtime memory or not.\r
-\r
- @param Address The Address being checked.\r
-\r
- @retval TRUE The address is runtime memory.\r
- @retval FALSE The address is not runtime memory.\r
-**/\r
-BOOLEAN\r
-IsRuntimeMemory (\r
- IN VOID *Address\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINT8 TmpMemoryMap[1];\r
- UINTN MapKey;\r
- UINTN DescriptorSize;\r
- UINT32 DescriptorVersion;\r
- UINTN MemoryMapSize;\r
- EFI_MEMORY_DESCRIPTOR *MemoryMap;\r
- EFI_MEMORY_DESCRIPTOR *MemoryMapPtr;\r
- BOOLEAN IsRuntime;\r
- UINTN Index;\r
-\r
- IsRuntime = FALSE;\r
-\r
- //\r
- // Get System MemoryMapSize\r
- //\r
- MemoryMapSize = 1;\r
- Status = gBS->GetMemoryMap (\r
- &MemoryMapSize,\r
- (EFI_MEMORY_DESCRIPTOR *)TmpMemoryMap,\r
- &MapKey,\r
- &DescriptorSize,\r
- &DescriptorVersion\r
- );\r
- ASSERT (Status == EFI_BUFFER_TOO_SMALL);\r
- //\r
- // Enlarge space here, because we will allocate pool now.\r
- //\r
- MemoryMapSize += EFI_PAGE_SIZE;\r
- Status = gBS->AllocatePool (\r
- EfiBootServicesData,\r
- MemoryMapSize,\r
- (VOID**)&MemoryMap\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- //\r
- // Get System MemoryMap\r
- //\r
- Status = gBS->GetMemoryMap (\r
- &MemoryMapSize,\r
- MemoryMap,\r
- &MapKey,\r
- &DescriptorSize,\r
- &DescriptorVersion\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- MemoryMapPtr = MemoryMap;\r
- //\r
- // Search the request Address\r
- //\r
- for (Index = 0; Index < (MemoryMapSize / DescriptorSize); Index++) {\r
- if (((EFI_PHYSICAL_ADDRESS)(UINTN)Address >= MemoryMap->PhysicalStart) &&\r
- ((EFI_PHYSICAL_ADDRESS)(UINTN)Address < MemoryMap->PhysicalStart\r
- + LShiftU64 (MemoryMap->NumberOfPages, EFI_PAGE_SHIFT))) {\r
- //\r
- // Found it\r
- //\r
- if (MemoryMap->Attribute & EFI_MEMORY_RUNTIME) {\r
- IsRuntime = TRUE;\r
- }\r
- break;\r
- }\r
- //\r
- // Get next item\r
- //\r
- MemoryMap = (EFI_MEMORY_DESCRIPTOR *)((UINTN)MemoryMap + DescriptorSize);\r
- }\r
-\r
- //\r
- // Done\r
- //\r
- gBS->FreePool (MemoryMapPtr);\r
-\r
- return IsRuntime;\r
-}\r
-\r
-/**\r
- Update mFvbEntry. Add new entry, or update existing entry if Fvb protocol is\r
- reinstalled.\r
-\r
- @param Event The Event that is being processed\r
- @param Context Event Context\r
-\r
-**/\r
-STATIC\r
-VOID\r
-EFIAPI\r
-FvbNotificationEvent (\r
- IN EFI_EVENT Event,\r
- IN VOID *Context\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN BufferSize;\r
- EFI_HANDLE Handle;\r
- UINTN Index;\r
- UINTN UpdateIndex;\r
-\r
- while (TRUE) {\r
- BufferSize = sizeof (Handle);\r
- Status = gBS->LocateHandle (\r
- ByRegisterNotify,\r
- &gEfiFirmwareVolumeBlockProtocolGuid,\r
- mFvbRegistration,\r
- &BufferSize,\r
- &Handle\r
- );\r
- if (EFI_ERROR (Status)) {\r
- //\r
- // Exit Path of While Loop....\r
- //\r
- break;\r
- }\r
-\r
- UpdateIndex = MAX_FVB_COUNT;\r
- for (Index = 0; Index < mFvbCount; Index++) {\r
- if (mFvbEntry[Index].Handle == Handle) {\r
- //\r
- // If the handle is already in the table just update the protocol\r
- //\r
- UpdateIndex = Index;\r
- break;\r
- }\r
- }\r
-\r
- if (UpdateIndex == MAX_FVB_COUNT) {\r
- //\r
- // Use the next free slot for a new entry\r
- //\r
- UpdateIndex = mFvbCount++;\r
- //\r
- // Check the UpdateIndex whether exceed the maximum value.\r
- //\r
- ASSERT (UpdateIndex < MAX_FVB_COUNT);\r
- mFvbEntry[UpdateIndex].Handle = Handle;\r
- }\r
- //\r
- // The array does not have enough entries\r
- //\r
- ASSERT (UpdateIndex < MAX_FVB_COUNT);\r
-\r
- //\r
- // Get the interface pointer and if it's ours, skip it\r
- //\r
- Status = gBS->HandleProtocol (\r
- Handle,\r
- &gEfiFirmwareVolumeBlockProtocolGuid,\r
- (VOID **) &mFvbEntry[UpdateIndex].Fvb\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- Status = gBS->HandleProtocol (\r
- Handle,\r
- &gEfiFvbExtensionProtocolGuid,\r
- (VOID **) &mFvbEntry[UpdateIndex].FvbExtension\r
- );\r
- if (Status != EFI_SUCCESS) {\r
- mFvbEntry[UpdateIndex].FvbExtension = NULL;\r
- }\r
-\r
- //\r
- // Check the FVB can be accessed in RUNTIME, The FVBs in FVB handle list comes\r
- // from two way:\r
- // 1) Dxe Core. (FVB information is transferred from FV HOB).\r
- // 2) FVB driver.\r
- // The FVB produced Dxe core is used for discoverying DXE driver and dispatch. These\r
- // FVBs can only be accessed in boot time.\r
- // FVB driver will discovery all FV in FLASH and these FVBs can be accessed in runtime.\r
- // The FVB itself produced by FVB driver is allocated in runtime memory. So we can\r
- // determine the what FVB can be accessed in RUNTIME by judging whether FVB itself is allocated\r
- // in RUNTIME memory.\r
- //\r
- mFvbEntry[UpdateIndex].IsRuntimeAccess = IsRuntimeMemory (mFvbEntry[UpdateIndex].Fvb);\r
- }\r
-}\r
-\r
-/**\r
- Convert all pointers in mFvbEntry after ExitBootServices.\r
-\r
- @param Event The Event that is being processed\r
- @param Context Event Context\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-FvbVirtualAddressChangeNotifyEvent (\r
- IN EFI_EVENT Event,\r
- IN VOID *Context\r
- )\r
-{\r
- UINTN Index;\r
- if (mFvbEntry != NULL) {\r
- for (Index = 0; Index < MAX_FVB_COUNT; Index++) {\r
- if (!mFvbEntry[Index].IsRuntimeAccess) {\r
- continue;\r
- }\r
-\r
- if (NULL != mFvbEntry[Index].Fvb) {\r
- EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb->GetBlockSize);\r
- EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb->GetPhysicalAddress);\r
- EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb->GetAttributes);\r
- EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb->SetAttributes);\r
- EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb->Read);\r
- EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb->Write);\r
- EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb->EraseBlocks);\r
- EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb);\r
- }\r
-\r
- if (NULL != mFvbEntry[Index].FvbExtension) {\r
- EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].FvbExtension->EraseFvbCustomBlock);\r
- EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].FvbExtension);\r
- }\r
- }\r
-\r
- EfiConvertPointer (0x0, (VOID **) &mFvbEntry);\r
- }\r
-}\r
-\r
-/**\r
- Library constructor function entry.\r
-\r
- @param ImageHandle The handle of image who call this libary.\r
- @param SystemTable The point of System Table.\r
-\r
- @retval EFI_SUCESS Sucess construct this library.\r
- @retval Others Fail to contruct this libary.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FvbLibInitialize (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
- )\r
-{\r
- UINTN Status;\r
- mFvbCount = 0;\r
-\r
- Status = gBS->AllocatePool (\r
- EfiRuntimeServicesData,\r
- (UINTN) sizeof (FVB_ENTRY) * MAX_FVB_COUNT,\r
- (VOID *) &mFvbEntry\r
- );\r
-\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- ZeroMem (mFvbEntry, sizeof (FVB_ENTRY) * MAX_FVB_COUNT);\r
-\r
- EfiCreateProtocolNotifyEvent (\r
- &gEfiFirmwareVolumeBlockProtocolGuid,\r
- TPL_CALLBACK,\r
- FvbNotificationEvent,\r
- NULL,\r
- &mFvbRegistration\r
- );\r
-\r
- //\r
- // Register SetVirtualAddressMap () notify function\r
- //\r
- Status = gBS->CreateEvent (\r
- EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,\r
- TPL_NOTIFY,\r
- FvbVirtualAddressChangeNotifyEvent,\r
- NULL,\r
- &mSetVirtualMapChangedEvent\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-//\r
-// =============================================================================\r
-// The following functions wrap Fvb protocol in the Runtime Lib functions.\r
-// The Instance translates into Fvb instance. The Fvb order defined by HOBs and\r
-// thus the sequence of FVB protocol addition define Instance.\r
-//\r
-// EfiFvbInitialize () must be called before any of the following functions\r
-// must be called.\r
-// =============================================================================\r
-//\r
-\r
-/**\r
- Reads specified number of bytes into a buffer from the specified block.\r
-\r
- The EfiFvbReadBlock() function reads the requested number of bytes from\r
- the requested block in the specified firmware volume and stores them in\r
- the provided buffer. Implementations should be mindful that the firmware\r
- volume might be in the ReadDisabled state. If it is in this state, the \r
- EfiFvbReadBlock() function must return the status code EFI_ACCESS_DENIED\r
- without modifying the contents of the buffer.\r
- \r
- The EfiFvbReadBlock() function must also prevent spanning block boundaries.\r
- If a read is requested that would span a block boundary, the read must read\r
- up to the boundary but not beyond. The output parameter NumBytes must be\r
- set to correctly indicate the number of bytes actually read. \r
- The caller must be aware that a read may be partially completed.\r
-\r
- If NumBytes is NULL, then ASSERT().\r
-\r
- If Buffer is NULL, then ASSERT().\r
-\r
- @param[in] Instance The FV instance to be read from.\r
- @param[in] Lba The logical block address to be read from\r
- @param[in] Offset The offset relative to the block, at which to begin reading.\r
- @param[in, out] NumBytes Pointer to a UINTN. On input, *NumBytes contains the total\r
- size of the buffer. On output, it contains the actual number\r
- of bytes read.\r
- @param[out] Buffer Pointer to a caller allocated buffer that will be\r
- used to hold the data read.\r
-\r
- @retval EFI_SUCCESS The firmware volume was read successfully and contents are in Buffer.\r
- @retval EFI_BAD_BUFFER_SIZE Read attempted across an LBA boundary. On output, NumBytes contains the total number of bytes returned in Buffer.\r
- @retval EFI_ACCESS_DENIED The firmware volume is in the ReadDisabled state.\r
- @retval EFI_DEVICE_ERROR The block device is not functioning correctly and could not be read.\r
- @retval EFI_INVALID_PARAMETER Invalid parameter, Instance is larger than the max FVB number. Lba index is larger than the last block of the firmware volume. Offset is larger than the block size.\r
-\r
-**/\r
-EFI_STATUS\r
-EfiFvbReadBlock (\r
- IN UINTN Instance,\r
- IN EFI_LBA Lba,\r
- IN UINTN Offset,\r
- IN OUT UINTN *NumBytes,\r
- OUT UINT8 *Buffer\r
- )\r
-{\r
- ASSERT (NumBytes != NULL);\r
- ASSERT (Buffer != NULL);\r
- \r
- if (Instance >= mFvbCount) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if (EfiAtRuntime() && !mFvbEntry[Instance].IsRuntimeAccess) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- return mFvbEntry[Instance].Fvb->Read (mFvbEntry[Instance].Fvb, Lba, Offset, NumBytes, Buffer);\r
-}\r
-\r
-/**\r
- Writes specified number of bytes from the input buffer to the block\r
-\r
- The EfiFvbWriteBlock() function writes the specified number of bytes\r
- from the provided buffer to the specified block and offset in the \r
- requested firmware volume. \r
-\r
- If the firmware volume is sticky write, the caller must ensure that\r
- all the bits of the specified range to write are in the EFI_FVB_ERASE_POLARITY\r
- state before calling the EfiFvbWriteBlock() function, or else the \r
- result will be unpredictable. This unpredictability arises because,\r
- for a sticky-write firmware volume, a write may negate a bit in the \r
- EFI_FVB_ERASE_POLARITY state but it cannot flip it back again. In \r
- general, before calling the EfiFvbWriteBlock() function, the caller\r
- should call the EfiFvbEraseBlock() function first to erase the specified\r
- block to write. A block erase cycle will transition bits from the\r
- (NOT)EFI_FVB_ERASE_POLARITY state back to the EFI_FVB_ERASE_POLARITY state.\r
- Implementations should be mindful that the firmware volume might be \r
- in the WriteDisabled state. If it is in this state, the EfiFvbWriteBlock()\r
- function must return the status code EFI_ACCESS_DENIED without modifying\r
- the contents of the firmware volume.\r
- \r
- The EfiFvbWriteBlock() function must also prevent spanning block boundaries.\r
- If a write is requested that spans a block boundary, the write must store\r
- up to the boundary but not beyond. The output parameter NumBytes must be \r
- set to correctly indicate the number of bytes actually written. The caller\r
- must be aware that a write may be partially completed.\r
- All writes, partial or otherwise, must be fully flushed to the hardware \r
- before the EfiFvbWriteBlock() function returns. \r
- \r
- If NumBytes is NULL, then ASSERT().\r
-\r
- @param Instance The FV instance to be written to\r
- @param Lba The starting logical block index to write to\r
- @param Offset The offset relative to the block, at which to begin writting.\r
- @param NumBytes Pointer to a UINTN. On input, *NumBytes contains\r
- the total size of the buffer. On output, it contains\r
- the actual number of bytes written.\r
- @param Buffer Pointer to a caller allocated buffer that contains\r
- the source for the write\r
-\r
- @retval EFI_SUCCESS The firmware volume was written successfully.\r
- @retval EFI_BAD_BUFFER_SIZE The write was attempted across an LBA boundary. \r
- On output, NumBytes contains the total number of bytes actually written.\r
- @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled state.\r
- @retval EFI_DEVICE_ERROR The block device is malfunctioning and could not be written.\r
- @retval EFI_INVALID_PARAMETER Invalid parameter, Instance is larger than the max FVB number. \r
- Lba index is larger than the last block of the firmware volume.\r
- Offset is larger than the block size.\r
-**/\r
-EFI_STATUS\r
-EfiFvbWriteBlock (\r
- IN UINTN Instance,\r
- IN EFI_LBA Lba,\r
- IN UINTN Offset,\r
- IN OUT UINTN *NumBytes,\r
- IN UINT8 *Buffer\r
- )\r
-{\r
- ASSERT (NumBytes != NULL);\r
- \r
- if (Instance >= mFvbCount) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if (EfiAtRuntime() && !mFvbEntry[Instance].IsRuntimeAccess) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- return mFvbEntry[Instance].Fvb->Write (mFvbEntry[Instance].Fvb, Lba, Offset, NumBytes, Buffer);\r
-}\r
-\r
-/**\r
- Erases and initializes a firmware volume block.\r
-\r
- The EfiFvbEraseBlock() function erases one block specified by Lba.\r
- Implementations should be mindful that the firmware volume might \r
- be in the WriteDisabled state. If it is in this state, the EfiFvbEraseBlock()\r
- function must return the status code EFI_ACCESS_DENIED without \r
- modifying the contents of the firmware volume. If Instance is \r
- larger than the max FVB number, or Lba index is larger than the\r
- last block of the firmware volume, this function return the status\r
- code EFI_INVALID_PARAMETER.\r
- \r
- All calls to EfiFvbEraseBlock() must be fully flushed to the \r
- hardware before this function returns. \r
-\r
- @param[in] Instance The FV instance to be erased.\r
- @param[in] Lba The logical block index to be erased from.\r
- \r
- @retval EFI_SUCCESS The erase request was successfully completed.\r
- @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled state.\r
- @retval EFI_DEVICE_ERROR The block device is not functioning correctly and\r
- could not be written. The firmware device may \r
- have been partially erased.\r
- @retval EFI_INVALID_PARAMETER Invalid parameter. Instance is larger than the max\r
- FVB number. Lba index is larger than the last block\r
- of the firmware volume. \r
-\r
-**/\r
-EFI_STATUS\r
-EfiFvbEraseBlock (\r
- IN UINTN Instance,\r
- IN EFI_LBA Lba\r
- )\r
-{\r
- if (Instance >= mFvbCount) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if (EfiAtRuntime() && !mFvbEntry[Instance].IsRuntimeAccess) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- return mFvbEntry[Instance].Fvb->EraseBlocks (mFvbEntry[Instance].Fvb, Lba, 1, EFI_LBA_LIST_TERMINATOR);\r
-}\r
-\r
-/**\r
- Retrieves the attributes and current settings of the specified block, \r
- returns resulting attributes in output parameter.\r
-\r
- The EfiFvbGetAttributes() function retrieves the attributes and current\r
- settings of the block specified by Instance. If Instance is larger than\r
- the max FVB number, this function returns the status code EFI_INVALID_PARAMETER.\r
-\r
- If Attributes is NULL, then ASSERT().\r
-\r
- @param[in] Instance The FV instance to be operated.\r
- @param[out] Attributes Pointer to EFI_FVB_ATTRIBUTES_2 in which the\r
- attributes and current settings are returned.\r
-\r
- @retval EFI_EFI_SUCCESS The firmware volume attributes were returned.\r
- @retval EFI_INVALID_PARAMETER Invalid parameter. Instance is larger than the max FVB number. \r
-**/\r
-EFI_STATUS\r
-EfiFvbGetVolumeAttributes (\r
- IN UINTN Instance,\r
- OUT EFI_FVB_ATTRIBUTES_2 *Attributes\r
- )\r
-{\r
- ASSERT (Attributes != NULL);\r
- \r
- if (Instance >= mFvbCount) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if (EfiAtRuntime() && !mFvbEntry[Instance].IsRuntimeAccess) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- return mFvbEntry[Instance].Fvb->GetAttributes (mFvbEntry[Instance].Fvb, Attributes);\r
-}\r
-\r
-/**\r
- Modify the attributes and current settings of the specified block\r
- according to the input parameter.\r
-\r
- The EfiFvbSetAttributes() function sets configurable firmware volume\r
- attributes and returns the new settings of the firmware volume specified\r
- by Instance. If Instance is larger than the max FVB number, this function\r
- returns the status code EFI_INVALID_PARAMETER.\r
-\r
- If Attributes is NULL, then ASSERT().\r
-\r
- @param[in] Instance The FV instance to be operated.\r
- @param[in, out]Attributes On input, Attributes is a pointer to EFI_FVB_ATTRIBUTES_2\r
- that contains the desired firmware volume settings. \r
- On successful return, it contains the new settings of the firmware volume.\r
-\r
- @retval EFI_EFI_SUCCESS The firmware volume attributes were modified successfully.\r
- @retval EFI_INVALID_PARAMETER Invalid parameter. Instance is larger than the max FVB number.\r
-\r
-**/\r
-EFI_STATUS\r
-EfiFvbSetVolumeAttributes (\r
- IN UINTN Instance,\r
- IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes\r
- )\r
-{\r
- ASSERT (Attributes != NULL);\r
- \r
- if (Instance >= mFvbCount) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if (EfiAtRuntime() && !mFvbEntry[Instance].IsRuntimeAccess) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- return mFvbEntry[Instance].Fvb->SetAttributes (mFvbEntry[Instance].Fvb, Attributes);\r
-}\r
-\r
-/**\r
- Retrieves the physical address of the specified memory mapped FV.\r
-\r
- Retrieve the base address of a memory-mapped firmware volume specified by Instance.\r
- If Instance is larger than the max FVB number, this function returns the status \r
- code EFI_INVALID_PARAMETER.\r
- \r
- If BaseAddress is NULL, then ASSERT().\r
-\r
- @param[in] Instance The FV instance to be operated.\r
- @param[out] BaseAddress Pointer to a caller allocated EFI_PHYSICAL_ADDRESS \r
- that on successful return, contains the base address\r
- of the firmware volume. \r
-\r
- @retval EFI_EFI_SUCCESS The firmware volume base address is returned.\r
- @retval EFI_INVALID_PARAMETER Invalid parameter. Instance is larger than the max FVB number. \r
-\r
-**/\r
-EFI_STATUS\r
-EfiFvbGetPhysicalAddress (\r
- IN UINTN Instance,\r
- OUT EFI_PHYSICAL_ADDRESS *BaseAddress\r
- )\r
-{\r
- ASSERT (BaseAddress != NULL);\r
- \r
- if (Instance >= mFvbCount) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if (EfiAtRuntime() && !mFvbEntry[Instance].IsRuntimeAccess) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- return mFvbEntry[Instance].Fvb->GetPhysicalAddress (mFvbEntry[Instance].Fvb, BaseAddress);\r
-}\r
-\r
-/**\r
- Retrieve the block size of the specified fv.\r
- \r
- The EfiFvbGetBlockSize() function retrieves the size of the requested block. \r
- It also returns the number of additional blocks with the identical size. \r
- If Instance is larger than the max FVB number, or Lba index is larger than\r
- the last block of the firmware volume, this function return the status code\r
- EFI_INVALID_PARAMETER.\r
-\r
- If BlockSize is NULL, then ASSERT().\r
- \r
- If NumOfBlocks is NULL, then ASSERT().\r
-\r
- @param[in] Instance The FV instance to be operated.\r
- @param[in] Lba Indicates which block to return the size for.\r
- @param[out] BlockSize Pointer to a caller-allocated UINTN in which the\r
- size of the block is returned.\r
- @param[out] NumOfBlocks Pointer to a caller-allocated UINTN in which the \r
- number of consecutive blocks, starting with Lba, \r
- is returned. All blocks in this range have a size of BlockSize.\r
-\r
- @retval EFI_EFI_SUCCESS The firmware volume base address is returned.\r
- @retval EFI_INVALID_PARAMETER Invalid parameter. Instance is larger than the max FVB number.\r
- Lba index is larger than the last block of the firmware volume.\r
-\r
-**/\r
-EFI_STATUS\r
-EfiFvbGetBlockSize (\r
- IN UINTN Instance,\r
- IN EFI_LBA Lba,\r
- OUT UINTN *BlockSize,\r
- OUT UINTN *NumOfBlocks\r
- )\r
-{\r
- ASSERT (BlockSize != NULL);\r
- ASSERT (NumOfBlocks != NULL);\r
- \r
- if (Instance >= mFvbCount) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if (EfiAtRuntime() && !mFvbEntry[Instance].IsRuntimeAccess) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- return mFvbEntry[Instance].Fvb->GetBlockSize (mFvbEntry[Instance].Fvb, Lba, BlockSize, NumOfBlocks);\r
-}\r
-\r
-/**\r
- Erases and initializes a specified range of a firmware volume.\r
-\r
- The EfiFvbEraseCustomBlockRange() function erases the specified range in the firmware\r
- volume index by Instance. If Instance is larger than the max FVB number, StartLba or \r
- LastLba index is larger than the last block of the firmware volume, StartLba > LastLba\r
- or StartLba equal to LastLba but OffsetStartLba > OffsetLastLba, this function return \r
- the status code EFI_INVALID_PARAMETER.\r
-\r
- @param[in] Instance The FV instance to be operated.\r
- @param[in] StartLba The starting logical block index to be erased.\r
- @param[in] OffsetStartLba Offset into the starting block at which to \r
- begin erasing. \r
- @param[in] LastLba The last logical block index to be erased.\r
- @param[in] OffsetLastLba Offset into the last block at which to end erasing. \r
-\r
- @retval EFI_EFI_SUCCESS Successfully erase custom block range\r
- @retval EFI_INVALID_PARAMETER Invalid parameter. Instance is larger than the max FVB number. \r
- @retval EFI_UNSUPPORTED Firmware volume block device has no this capability.\r
-\r
-**/\r
-EFI_STATUS\r
-EfiFvbEraseCustomBlockRange (\r
- IN UINTN Instance,\r
- IN EFI_LBA StartLba,\r
- IN UINTN OffsetStartLba,\r
- IN EFI_LBA LastLba,\r
- IN UINTN OffsetLastLba\r
- )\r
-{\r
- if (Instance >= mFvbCount) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if (EfiAtRuntime() && !mFvbEntry[Instance].IsRuntimeAccess) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if (!(mFvbEntry[Instance].FvbExtension)) {\r
- return EFI_UNSUPPORTED;\r
- }\r
-\r
- if (!(mFvbEntry[Instance].FvbExtension->EraseFvbCustomBlock)) {\r
- return EFI_UNSUPPORTED;\r
- }\r
-\r
- return mFvbEntry[Instance].FvbExtension->EraseFvbCustomBlock (\r
- mFvbEntry[Instance].FvbExtension,\r
- StartLba,\r
- OffsetStartLba,\r
- LastLba,\r
- OffsetLastLba\r
- );\r
-}\r
+++ /dev/null
-/** @file \r
- The internal header file includes the common header files, defines\r
- internal structure FVB_ENTRY.\r
-\r
-Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
-\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions\r
-of the BSD License which accompanies this distribution. The\r
-full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef __FVB_H__\r
-#define __FVB_H__\r
-\r
-\r
-#include <PiDxe.h>\r
-\r
-#include <Protocol/FirmwareVolumeBlock.h>\r
-#include <Protocol/FvbExtension.h>\r
-\r
-#include <Library/FvbServiceLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/UefiRuntimeLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-\r
-#define MAX_FVB_COUNT 16\r
-\r
-typedef struct {\r
- EFI_HANDLE Handle;\r
- EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;\r
- EFI_FVB_EXTENSION_PROTOCOL *FvbExtension;\r
- BOOLEAN IsRuntimeAccess;\r
-} FVB_ENTRY;\r
-\r
-#endif\r
+++ /dev/null
-#/** @file\r
-# Instance of FVB Service Library.\r
-#\r
-# This library instance provides service functions to access Firmware Volume Block protocol.\r
-#\r
-# Copyright (c) 2006 - 2008, Intel Corporation\r
-#\r
-# All rights reserved. This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-#**/\r
-\r
-[Defines]\r
- INF_VERSION = 0x00010005\r
- BASE_NAME = FvbServiceLib\r
- FILE_GUID = bd4d540e-04b0-4b10-8fd5-4a7bb533cf67\r
- MODULE_TYPE = DXE_DRIVER\r
- VERSION_STRING = 1.0\r
- LIBRARY_CLASS = FvbServiceLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
- EDK_RELEASE_VERSION = 0x00020000\r
-\r
- CONSTRUCTOR = FvbLibInitialize\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
-#\r
-# VIRTUAL_ADDRESS_MAP_CALLBACK = FvbVirtualAddressChangeNotifyEvent\r
-#\r
-\r
-[Sources.common]\r
- Fvb.h\r
- Fvb.c\r
-\r
-[Packages]\r
- MdePkg/MdePkg.dec\r
- MdeModulePkg/MdeModulePkg.dec\r
-\r
-[LibraryClasses]\r
- UefiBootServicesTableLib\r
- UefiRuntimeLib\r
- BaseMemoryLib\r
- DebugLib\r
- BaseLib\r
- UefiLib\r
-\r
-[Protocols]\r
- gEfiFirmwareVolumeBlockProtocolGuid # PROTOCOL_NOTIFY SOMETIMES_CONSUMED\r
- gEfiFvbExtensionProtocolGuid # PROTOCOL ALWAYS_CONSUMED\r
- gEfiFirmwareVolumeBlockProtocolGuid # PROTOCOL ALWAYS_CONSUMED\r
-\r
+++ /dev/null
-/** @file\r
- Library supports diplaying graphical splash screen,\r
- locking of keyboard input and printing character on\r
- screen. These basic graphics operations are based on UEFI HII, \r
- Graphics Output protocol or UGA Draw protocol.\r
-\r
-Copyright (c) 2006 - 2008, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-\r
-#include <PiDxe.h>\r
-\r
-#include <Protocol/SimpleTextOut.h>\r
-#include <Protocol/OEMBadging.h>\r
-#include <Protocol/ConsoleControl.h>\r
-#include <Protocol/GraphicsOutput.h>\r
-#include <Protocol/UgaDraw.h>\r
-#include <Protocol/HiiFont.h>\r
-#include <Protocol/HiiImage.h>\r
-\r
-#include <Guid/Bmp.h>\r
-\r
-#include <Library/GraphicsLib.h>\r
-#include <Library/PrintLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/DxePiLib.h>\r
-#include <Library/PcdLib.h>\r
-\r
-STATIC EFI_GRAPHICS_OUTPUT_BLT_PIXEL mEfiColors[16] = {\r
- { 0x00, 0x00, 0x00, 0x00 },\r
- { 0x98, 0x00, 0x00, 0x00 },\r
- { 0x00, 0x98, 0x00, 0x00 },\r
- { 0x98, 0x98, 0x00, 0x00 },\r
- { 0x00, 0x00, 0x98, 0x00 },\r
- { 0x98, 0x00, 0x98, 0x00 },\r
- { 0x00, 0x98, 0x98, 0x00 },\r
- { 0x98, 0x98, 0x98, 0x00 },\r
- { 0x10, 0x10, 0x10, 0x00 },\r
- { 0xff, 0x10, 0x10, 0x00 },\r
- { 0x10, 0xff, 0x10, 0x00 },\r
- { 0xff, 0xff, 0x10, 0x00 },\r
- { 0x10, 0x10, 0xff, 0x00 },\r
- { 0xf0, 0x10, 0xff, 0x00 },\r
- { 0x10, 0xff, 0xff, 0x00 },\r
- { 0xff, 0xff, 0xff, 0x00 }\r
-};\r
-\r
-\r
-/**\r
- Return the graphics image file named FileNameGuid into Image and return it's\r
- size in ImageSize. All Firmware Volumes (FV) in the system are searched for the\r
- file name.\r
-\r
- @param FileNameGuid File Name of graphics file in the FV(s).\r
- @param Image Pointer to pointer to return graphics image. If NULL, a \r
- buffer will be allocated.\r
- @param ImageSize Size of the graphics Image in bytes. Zero if no image found.\r
-\r
- @retval EFI_SUCCESS Image and ImageSize are valid. \r
- @retval EFI_BUFFER_TOO_SMALL Image not big enough. ImageSize has required size\r
- @retval EFI_NOT_FOUND FileNameGuid not found\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-GetGraphicsBitMapFromFV (\r
- IN EFI_GUID *FileNameGuid,\r
- OUT VOID **Image,\r
- OUT UINTN *ImageSize\r
- )\r
-{\r
- return GetGraphicsBitMapFromFVEx (NULL, FileNameGuid, Image, ImageSize);\r
-}\r
-\r
-/**\r
- Return the graphics image file named FileNameGuid into Image and return it's\r
- size in ImageSize. All Firmware Volumes (FV) in the system are searched for the\r
- file name.\r
-\r
- @param ImageHandle The driver image handle of the caller. The parameter is used to\r
- optimize the loading of the image file so that the FV from which\r
- the driver image is loaded will be tried first. \r
- @param FileNameGuid File Name of graphics file in the FV(s).\r
- @param Image Pointer to pointer to return graphics image. If NULL, a \r
- buffer will be allocated.\r
- @param ImageSize Size of the graphics Image in bytes. Zero if no image found.\r
-\r
- @retval EFI_SUCCESS Image and ImageSize are valid. \r
- @retval EFI_BUFFER_TOO_SMALL Image not big enough. ImageSize has required size\r
- @retval EFI_NOT_FOUND FileNameGuid not found\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-GetGraphicsBitMapFromFVEx (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_GUID *FileNameGuid,\r
- OUT VOID **Image,\r
- OUT UINTN *ImageSize\r
- )\r
-{\r
- return PiLibGetSectionFromAnyFv (\r
- FileNameGuid,\r
- EFI_SECTION_RAW,\r
- 0,\r
- Image,\r
- ImageSize\r
- );\r
-}\r
-\r
-/**\r
- Convert a *.BMP graphics image to a GOP blt buffer. If a NULL Blt buffer\r
- is passed in a GopBlt buffer will be allocated by this routine. If a GopBlt\r
- buffer is passed in it will be used if it is big enough.\r
-\r
- @param BmpImage Pointer to BMP file\r
- @param BmpImageSize Number of bytes in BmpImage\r
- @param GopBlt Buffer containing GOP version of BmpImage.\r
- @param GopBltSize Size of GopBlt in bytes.\r
- @param PixelHeight Height of GopBlt/BmpImage in pixels\r
- @param PixelWidth Width of GopBlt/BmpImage in pixels\r
-\r
- @retval EFI_SUCCESS GopBlt and GopBltSize are returned. \r
- @retval EFI_UNSUPPORTED BmpImage is not a valid *.BMP image\r
- @retval EFI_BUFFER_TOO_SMALL The passed in GopBlt buffer is not big enough.\r
- GopBltSize will contain the required size.\r
- @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ConvertBmpToGopBlt (\r
- IN VOID *BmpImage,\r
- IN UINTN BmpImageSize,\r
- IN OUT VOID **GopBlt,\r
- IN OUT UINTN *GopBltSize,\r
- OUT UINTN *PixelHeight,\r
- OUT UINTN *PixelWidth\r
- )\r
-{\r
- UINT8 *Image;\r
- UINT8 *ImageHeader;\r
- BMP_IMAGE_HEADER *BmpHeader;\r
- BMP_COLOR_MAP *BmpColorMap;\r
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer;\r
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;\r
- UINTN BltBufferSize;\r
- UINTN Index;\r
- UINTN Height;\r
- UINTN Width;\r
- UINTN ImageIndex;\r
- BOOLEAN IsAllocated;\r
-\r
- BmpHeader = (BMP_IMAGE_HEADER *) BmpImage;\r
-\r
- if (BmpHeader->CharB != 'B' || BmpHeader->CharM != 'M') {\r
- return EFI_UNSUPPORTED;\r
- }\r
-\r
- //\r
- // Doesn't support compress.\r
- //\r
- if (BmpHeader->CompressionType != 0) {\r
- return EFI_UNSUPPORTED;\r
- }\r
-\r
- //\r
- // Calculate Color Map offset in the image.\r
- //\r
- Image = BmpImage;\r
- BmpColorMap = (BMP_COLOR_MAP *) (Image + sizeof (BMP_IMAGE_HEADER));\r
-\r
- //\r
- // Calculate graphics image data address in the image\r
- //\r
- Image = ((UINT8 *) BmpImage) + BmpHeader->ImageOffset;\r
- ImageHeader = Image;\r
-\r
- //\r
- // Calculate the BltBuffer needed size.\r
- //\r
- BltBufferSize = BmpHeader->PixelWidth * BmpHeader->PixelHeight * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);\r
- IsAllocated = FALSE;\r
- if (*GopBlt == NULL) {\r
- //\r
- // GopBlt is not allocated by caller.\r
- //\r
- *GopBltSize = BltBufferSize;\r
- *GopBlt = AllocatePool (*GopBltSize);\r
- IsAllocated = TRUE;\r
- if (*GopBlt == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
- } else {\r
- //\r
- // GopBlt has been allocated by caller.\r
- //\r
- if (*GopBltSize < BltBufferSize) {\r
- *GopBltSize = BltBufferSize;\r
- return EFI_BUFFER_TOO_SMALL;\r
- }\r
- }\r
-\r
- *PixelWidth = BmpHeader->PixelWidth;\r
- *PixelHeight = BmpHeader->PixelHeight;\r
-\r
- //\r
- // Convert image from BMP to Blt buffer format\r
- //\r
- BltBuffer = *GopBlt;\r
- for (Height = 0; Height < BmpHeader->PixelHeight; Height++) {\r
- Blt = &BltBuffer[(BmpHeader->PixelHeight - Height - 1) * BmpHeader->PixelWidth];\r
- for (Width = 0; Width < BmpHeader->PixelWidth; Width++, Image++, Blt++) {\r
- switch (BmpHeader->BitPerPixel) {\r
- case 1:\r
- //\r
- // Convert 1-bit (2 colors) BMP to 24-bit color\r
- //\r
- for (Index = 0; Index < 8 && Width < BmpHeader->PixelWidth; Index++) {\r
- Blt->Red = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Red;\r
- Blt->Green = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Green;\r
- Blt->Blue = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Blue;\r
- Blt++;\r
- Width++;\r
- }\r
-\r
- Blt --;\r
- Width --;\r
- break;\r
-\r
- case 4:\r
- //\r
- // Convert 4-bit (16 colors) BMP Palette to 24-bit color\r
- //\r
- Index = (*Image) >> 4;\r
- Blt->Red = BmpColorMap[Index].Red;\r
- Blt->Green = BmpColorMap[Index].Green;\r
- Blt->Blue = BmpColorMap[Index].Blue;\r
- if (Width < (BmpHeader->PixelWidth - 1)) {\r
- Blt++;\r
- Width++;\r
- Index = (*Image) & 0x0f;\r
- Blt->Red = BmpColorMap[Index].Red;\r
- Blt->Green = BmpColorMap[Index].Green;\r
- Blt->Blue = BmpColorMap[Index].Blue;\r
- }\r
- break;\r
-\r
- case 8:\r
- //\r
- // Convert 8-bit (256 colors) BMP Palette to 24-bit color\r
- //\r
- Blt->Red = BmpColorMap[*Image].Red;\r
- Blt->Green = BmpColorMap[*Image].Green;\r
- Blt->Blue = BmpColorMap[*Image].Blue;\r
- break;\r
-\r
- case 24:\r
- //\r
- // It is 24-bit BMP.\r
- //\r
- Blt->Blue = *Image++;\r
- Blt->Green = *Image++;\r
- Blt->Red = *Image;\r
- break;\r
-\r
- default:\r
- //\r
- // Other bit format BMP is not supported.\r
- //\r
- if (IsAllocated) {\r
- FreePool (*GopBlt);\r
- *GopBlt = NULL;\r
- }\r
- return EFI_UNSUPPORTED;\r
- break;\r
- };\r
-\r
- }\r
-\r
- ImageIndex = (UINTN) (Image - ImageHeader);\r
- if ((ImageIndex % 4) != 0) {\r
- //\r
- // Bmp Image starts each row on a 32-bit boundary!\r
- //\r
- Image = Image + (4 - (ImageIndex % 4));\r
- }\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Use Console Control Protocol to lock the Console In Spliter virtual handle. \r
- This is the ConInHandle and ConIn handle in the EFI system table. All key\r
- presses will be ignored until the Password is typed in. The only way to\r
- disable the password is to type it in to a ConIn device.\r
-\r
- @param Password Password used to lock ConIn device.\r
-\r
- @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.\r
- @retval EFI_UNSUPPORTED Password not found.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LockKeyboards (\r
- IN CHAR16 *Password\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl;\r
-\r
- Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, (VOID **) &ConsoleControl);\r
- if (EFI_ERROR (Status)) {\r
- return EFI_UNSUPPORTED;\r
- }\r
-\r
- Status = ConsoleControl->LockStdIn (ConsoleControl, Password);\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
- Use Console Control to turn off UGA based Simple Text Out consoles from going\r
- to the UGA device. Put up LogoFile on every UGA device that is a console.\r
-\r
- @param LogoFile File name of logo to display on the center of the screen.\r
-\r
- @retval EFI_SUCCESS ConsoleControl has been flipped to graphics and logo displayed.\r
- @retval EFI_UNSUPPORTED Logo not found.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EnableQuietBoot (\r
- IN EFI_GUID *LogoFile\r
- )\r
-{\r
- return EnableQuietBootEx (LogoFile, NULL);\r
-}\r
-\r
-/**\r
- Use Console Control to turn off UGA based Simple Text Out consoles from going\r
- to the UGA device. Put up LogoFile on every UGA device that is a console\r
-\r
- @param LogoFile File name of logo to display on the center of the screen.\r
- @param ImageHandle The driver image handle of the caller. The parameter is used to\r
- optimize the loading of the logo file so that the FV from which\r
- the driver image is loaded will be tried first.\r
-\r
- @retval EFI_SUCCESS ConsoleControl has been flipped to graphics and logo displayed.\r
- @retval EFI_UNSUPPORTED Logo not found.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EnableQuietBootEx (\r
- IN EFI_GUID *LogoFile,\r
- IN EFI_HANDLE ImageHandle\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl;\r
- EFI_OEM_BADGING_PROTOCOL *Badging;\r
- UINT32 SizeOfX;\r
- UINT32 SizeOfY;\r
- INTN DestX;\r
- INTN DestY;\r
- UINT8 *ImageData;\r
- UINTN ImageSize;\r
- UINTN BltSize;\r
- UINT32 Instance;\r
- EFI_BADGING_FORMAT Format;\r
- EFI_BADGING_DISPLAY_ATTRIBUTE Attribute;\r
- UINTN CoordinateX;\r
- UINTN CoordinateY;\r
- UINTN Height;\r
- UINTN Width;\r
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;\r
- EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r
- UINT32 ColorDepth;\r
- UINT32 RefreshRate;\r
- EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
-\r
- Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, (VOID **) &ConsoleControl);\r
- if (EFI_ERROR (Status)) {\r
- return EFI_UNSUPPORTED;\r
- }\r
-\r
- UgaDraw = NULL;\r
- //\r
- // Try to open GOP first\r
- //\r
- Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiGraphicsOutputProtocolGuid, (VOID **) &GraphicsOutput);\r
- if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {\r
- GraphicsOutput = NULL;\r
- //\r
- // Open GOP failed, try to open UGA\r
- //\r
- Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiUgaDrawProtocolGuid, (VOID **) &UgaDraw);\r
- }\r
- if (EFI_ERROR (Status)) {\r
- return EFI_UNSUPPORTED;\r
- }\r
-\r
- Badging = NULL;\r
- Status = gBS->LocateProtocol (&gEfiOEMBadgingProtocolGuid, NULL, (VOID **) &Badging);\r
-\r
- //\r
- // Set console control to graphics mode.\r
- //\r
- Status = ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenGraphics);\r
- if (EFI_ERROR (Status)) {\r
- return EFI_UNSUPPORTED;\r
- }\r
-\r
- if (GraphicsOutput != NULL) {\r
- SizeOfX = GraphicsOutput->Mode->Info->HorizontalResolution;\r
- SizeOfY = GraphicsOutput->Mode->Info->VerticalResolution;\r
- } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {\r
- Status = UgaDraw->GetMode (UgaDraw, &SizeOfX, &SizeOfY, &ColorDepth, &RefreshRate);\r
- if (EFI_ERROR (Status)) {\r
- return EFI_UNSUPPORTED;\r
- }\r
- } else {\r
- return EFI_UNSUPPORTED;\r
- }\r
-\r
- Instance = 0;\r
- while (1) {\r
- ImageData = NULL;\r
- ImageSize = 0;\r
-\r
- if (Badging != NULL) {\r
- //\r
- // Get image from OEMBadging protocol.\r
- //\r
- Status = Badging->GetImage (\r
- Badging,\r
- &Instance,\r
- &Format,\r
- &ImageData,\r
- &ImageSize,\r
- &Attribute,\r
- &CoordinateX,\r
- &CoordinateY\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- //\r
- // Currently only support BMP format.\r
- //\r
- if (Format != EfiBadgingFormatBMP) {\r
- SafeFreePool (ImageData);\r
- continue;\r
- }\r
- } else {\r
- //\r
- // Get the specified image from FV.\r
- //\r
- Status = GetGraphicsBitMapFromFVEx (ImageHandle, LogoFile, (VOID **) &ImageData, &ImageSize);\r
- if (EFI_ERROR (Status)) {\r
- return EFI_UNSUPPORTED;\r
- }\r
-\r
- CoordinateX = 0;\r
- CoordinateY = 0;\r
- Attribute = EfiBadgingDisplayAttributeCenter;\r
- }\r
-\r
- Blt = NULL;\r
- Status = ConvertBmpToGopBlt (\r
- ImageData,\r
- ImageSize,\r
- (VOID **) &Blt,\r
- &BltSize,\r
- &Height,\r
- &Width\r
- );\r
- if (EFI_ERROR (Status)) {\r
- SafeFreePool (ImageData);\r
- if (Badging == NULL) {\r
- return Status;\r
- } else {\r
- continue;\r
- }\r
- }\r
-\r
- //\r
- // Caculate the display position according to Attribute.\r
- //\r
- switch (Attribute) {\r
- case EfiBadgingDisplayAttributeLeftTop:\r
- DestX = CoordinateX;\r
- DestY = CoordinateY;\r
- break;\r
-\r
- case EfiBadgingDisplayAttributeCenterTop:\r
- DestX = (SizeOfX - Width) / 2;\r
- DestY = CoordinateY;\r
- break;\r
-\r
- case EfiBadgingDisplayAttributeRightTop:\r
- DestX = (SizeOfX - Width - CoordinateX);\r
- DestY = CoordinateY;;\r
- break;\r
-\r
- case EfiBadgingDisplayAttributeCenterRight:\r
- DestX = (SizeOfX - Width - CoordinateX);\r
- DestY = (SizeOfY - Height) / 2;\r
- break;\r
-\r
- case EfiBadgingDisplayAttributeRightBottom:\r
- DestX = (SizeOfX - Width - CoordinateX);\r
- DestY = (SizeOfY - Height - CoordinateY);\r
- break;\r
-\r
- case EfiBadgingDisplayAttributeCenterBottom:\r
- DestX = (SizeOfX - Width) / 2;\r
- DestY = (SizeOfY - Height - CoordinateY);\r
- break;\r
-\r
- case EfiBadgingDisplayAttributeLeftBottom:\r
- DestX = CoordinateX;\r
- DestY = (SizeOfY - Height - CoordinateY);\r
- break;\r
-\r
- case EfiBadgingDisplayAttributeCenterLeft:\r
- DestX = CoordinateX;\r
- DestY = (SizeOfY - Height) / 2;\r
- break;\r
-\r
- case EfiBadgingDisplayAttributeCenter:\r
- DestX = (SizeOfX - Width) / 2;\r
- DestY = (SizeOfY - Height) / 2;\r
- break;\r
-\r
- default:\r
- DestX = CoordinateX;\r
- DestY = CoordinateY;\r
- break;\r
- }\r
-\r
- if ((DestX >= 0) && (DestY >= 0)) {\r
- if (GraphicsOutput != NULL) {\r
- Status = GraphicsOutput->Blt (\r
- GraphicsOutput,\r
- Blt,\r
- EfiBltBufferToVideo,\r
- 0,\r
- 0,\r
- (UINTN) DestX,\r
- (UINTN) DestY,\r
- Width,\r
- Height,\r
- Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
- );\r
- } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {\r
- Status = UgaDraw->Blt (\r
- UgaDraw,\r
- (EFI_UGA_PIXEL *) Blt,\r
- EfiUgaBltBufferToVideo,\r
- 0,\r
- 0,\r
- (UINTN) DestX,\r
- (UINTN) DestY,\r
- Width,\r
- Height,\r
- Width * sizeof (EFI_UGA_PIXEL)\r
- );\r
- } else {\r
- Status = EFI_UNSUPPORTED;\r
- }\r
- }\r
-\r
- SafeFreePool (ImageData);\r
- SafeFreePool (Blt);\r
-\r
- if (Badging == NULL) {\r
- break;\r
- }\r
- }\r
-\r
- return Status;\r
-}\r
-\r
-/**\r
- Use Console Control to turn on UGA based Simple Text Out consoles. The UGA \r
- Simple Text Out screens will now be synced up with all non UGA output devices\r
-\r
- @retval EFI_SUCCESS UGA devices are back in text mode and synced up.\r
- @retval EFI_UNSUPPORTED Logo not found\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-DisableQuietBoot (\r
- VOID\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl;\r
-\r
- Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, (VOID **) &ConsoleControl);\r
- if (EFI_ERROR (Status)) {\r
- return EFI_UNSUPPORTED;\r
- }\r
-\r
- //\r
- // Set console control to text mode.\r
- //\r
- return ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenText);\r
-}\r
-\r
-/**\r
- Internal display string worker function.\r
-\r
- @param GraphicsOutput Graphics output protocol interface.\r
- @param UgaDraw UGA draw protocol interface.\r
- @param Sto Simple text out protocol interface.\r
- @param X X coordinate to start printing.\r
- @param Y Y coordinate to start printing.\r
- @param Foreground Foreground color.\r
- @param Background Background color.\r
- @param fmt Format string.\r
- @param args Print arguments.\r
-\r
- @return Number of Characters printed. Zero means no any character \r
- displayed successfully.\r
-\r
-**/\r
-UINTN\r
-VPrintXY (\r
- IN EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,\r
- IN EFI_UGA_DRAW_PROTOCOL *UgaDraw,\r
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Sto,\r
- IN UINTN X,\r
- IN UINTN Y,\r
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Foreground,\r
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Background,\r
- IN CHAR16 *fmt,\r
- IN VA_LIST args\r
- )\r
-{\r
- VOID *Buffer;\r
- EFI_STATUS Status;\r
- UINTN Index;\r
- CHAR16 *UnicodeWeight;\r
- UINT32 HorizontalResolution;\r
- UINT32 VerticalResolution;\r
- UINT32 ColorDepth;\r
- UINT32 RefreshRate;\r
- UINTN BufferLen;\r
- UINTN LineBufferLen;\r
- EFI_HII_FONT_PROTOCOL *HiiFont;\r
- EFI_IMAGE_OUTPUT *Blt;\r
- EFI_FONT_DISPLAY_INFO *FontInfo;\r
- EFI_HII_ROW_INFO *RowInfoArray;\r
- UINTN RowInfoArraySize;\r
- UINTN PrintNum; \r
-\r
- //\r
- // For now, allocate an arbitrarily long buffer\r
- //\r
- Buffer = AllocateZeroPool (0x10000);\r
- if (Buffer == NULL) {\r
- return 0;\r
- }\r
-\r
- HorizontalResolution = 0;\r
- VerticalResolution = 0;\r
- Blt = NULL;\r
- FontInfo = NULL;\r
- PrintNum = 0;\r
-\r
- if (GraphicsOutput != NULL) {\r
- HorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution;\r
- VerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution;\r
- } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {\r
- UgaDraw->GetMode (UgaDraw, &HorizontalResolution, &VerticalResolution, &ColorDepth, &RefreshRate);\r
- } else {\r
- Status = EFI_UNSUPPORTED;\r
- goto Error;\r
- }\r
-\r
- ASSERT ((HorizontalResolution != 0) && (VerticalResolution !=0));\r
-\r
- Status = gBS->LocateProtocol (&gEfiHiiFontProtocolGuid, NULL, (VOID **) &HiiFont);\r
- if (EFI_ERROR (Status)) {\r
- goto Error;\r
- }\r
-\r
- PrintNum = UnicodeVSPrint (Buffer, 0x10000, fmt, args);\r
-\r
- UnicodeWeight = (CHAR16 *) Buffer;\r
-\r
- for (Index = 0; UnicodeWeight[Index] != 0; Index++) {\r
- if (UnicodeWeight[Index] == CHAR_BACKSPACE ||\r
- UnicodeWeight[Index] == CHAR_LINEFEED ||\r
- UnicodeWeight[Index] == CHAR_CARRIAGE_RETURN) {\r
- UnicodeWeight[Index] = 0;\r
- }\r
- }\r
-\r
- BufferLen = StrLen (Buffer);\r
-\r
- LineBufferLen = sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * HorizontalResolution * EFI_GLYPH_HEIGHT;\r
- if (EFI_GLYPH_WIDTH * EFI_GLYPH_HEIGHT * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * BufferLen > LineBufferLen) {\r
- Status = EFI_INVALID_PARAMETER;\r
- goto Error;\r
- }\r
-\r
- Blt = (EFI_IMAGE_OUTPUT *) AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT));\r
- if (Blt == NULL) {\r
- Status = EFI_OUT_OF_RESOURCES;\r
- goto Error;\r
- }\r
-\r
- Blt->Width = (UINT16) (HorizontalResolution);\r
- Blt->Height = (UINT16) (VerticalResolution);\r
-\r
- FontInfo = (EFI_FONT_DISPLAY_INFO *) AllocateZeroPool (sizeof (EFI_FONT_DISPLAY_INFO));\r
- if (FontInfo == NULL) {\r
- Status = EFI_OUT_OF_RESOURCES;\r
- goto Error;\r
- }\r
- if (Foreground != NULL) {\r
- CopyMem (&FontInfo->ForegroundColor, Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
- } else {\r
- CopyMem (\r
- &FontInfo->ForegroundColor,\r
- &mEfiColors[Sto->Mode->Attribute & 0x0f],\r
- sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
- );\r
- }\r
- if (Background != NULL) {\r
- CopyMem (&FontInfo->BackgroundColor, Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
- } else {\r
- CopyMem (\r
- &FontInfo->BackgroundColor,\r
- &mEfiColors[Sto->Mode->Attribute >> 4],\r
- sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
- );\r
- }\r
-\r
- if (GraphicsOutput != NULL) {\r
- Blt->Image.Screen = GraphicsOutput;\r
- \r
- Status = HiiFont->StringToImage (\r
- HiiFont,\r
- EFI_HII_IGNORE_IF_NO_GLYPH | EFI_HII_DIRECT_TO_SCREEN,\r
- Buffer,\r
- FontInfo,\r
- &Blt,\r
- X,\r
- Y,\r
- NULL,\r
- NULL,\r
- NULL\r
- );\r
-\r
- } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {\r
- ASSERT (UgaDraw!= NULL);\r
-\r
- Blt->Image.Bitmap = AllocateZeroPool (Blt->Width * Blt->Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
- if (Blt->Image.Bitmap == NULL) {\r
- SafeFreePool (Blt);\r
- SafeFreePool (Buffer);\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- RowInfoArray = NULL;\r
- //\r
- // StringToImage only support blt'ing image to device using GOP protocol. If GOP is not supported in this platform,\r
- // we ask StringToImage to print the string to blt buffer, then blt to device using UgaDraw.\r
- //\r
- Status = HiiFont->StringToImage (\r
- HiiFont,\r
- EFI_HII_IGNORE_IF_NO_GLYPH,\r
- Buffer,\r
- FontInfo,\r
- &Blt,\r
- X,\r
- Y,\r
- &RowInfoArray,\r
- &RowInfoArraySize,\r
- NULL\r
- );\r
-\r
- if (!EFI_ERROR (Status)) {\r
- //\r
- // Line breaks are handled by caller of DrawUnicodeWeightAtCursorN, so the updated parameter RowInfoArraySize by StringToImage will\r
- // always be 1 or 0 (if there is no valid Unicode Char can be printed). ASSERT here to make sure.\r
- //\r
- ASSERT (RowInfoArraySize <= 1);\r
-\r
- Status = UgaDraw->Blt (\r
- UgaDraw,\r
- (EFI_UGA_PIXEL *) Blt->Image.Bitmap,\r
- EfiUgaBltBufferToVideo,\r
- X,\r
- Y,\r
- X,\r
- Y,\r
- RowInfoArray[0].LineWidth,\r
- RowInfoArray[0].LineHeight,\r
- Blt->Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
- );\r
- }\r
-\r
- SafeFreePool (RowInfoArray);\r
- SafeFreePool (Blt->Image.Bitmap);\r
- } else {\r
- Status = EFI_UNSUPPORTED;\r
- }\r
-\r
-Error:\r
- SafeFreePool (Blt);\r
- SafeFreePool (FontInfo);\r
- FreePool (Buffer);\r
-\r
- if (EFI_ERROR (Status)) {\r
- return PrintNum;\r
- } else {\r
- return 0;\r
- }\r
-}\r
-\r
-/**\r
- Print Unicode string to graphics screen at the given X,Y coordinates of the graphics screen.\r
- see definition of Print to find rules for constructing Fmt.\r
-\r
- @param X Row to start printing at.\r
- @param Y Column to start printing at.\r
- @param ForeGround Foreground color.\r
- @param BackGround background color.\r
- @param Fmt Print format sting. See definition of Print.\r
- @param ... Argumnet stream defined by Fmt string.\r
-\r
- @return Number of Characters printed. Zero means no any character \r
- displayed successfully.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-PrintXY (\r
- IN UINTN X,\r
- IN UINTN Y,\r
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *ForeGround, OPTIONAL\r
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BackGround, OPTIONAL\r
- IN CHAR16 *Fmt,\r
- ...\r
- )\r
-{\r
- EFI_HANDLE Handle;\r
- EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
- EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r
- EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Sto;\r
- EFI_STATUS Status;\r
- VA_LIST Args;\r
-\r
- VA_START (Args, Fmt);\r
-\r
- Handle = gST->ConsoleOutHandle;\r
-\r
- Status = gBS->HandleProtocol (\r
- Handle,\r
- &gEfiGraphicsOutputProtocolGuid,\r
- (VOID **) &GraphicsOutput\r
- );\r
-\r
- UgaDraw = NULL;\r
- if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {\r
- //\r
- // If no GOP available, try to open UGA Draw protocol if supported.\r
- //\r
- GraphicsOutput = NULL;\r
-\r
- Status = gBS->HandleProtocol (\r
- Handle,\r
- &gEfiUgaDrawProtocolGuid,\r
- (VOID **) &UgaDraw\r
- );\r
- }\r
- if (EFI_ERROR (Status)) {\r
- return 0;\r
- }\r
-\r
- Status = gBS->HandleProtocol (\r
- Handle,\r
- &gEfiSimpleTextOutProtocolGuid,\r
- (VOID **) &Sto\r
- );\r
-\r
- if (EFI_ERROR (Status)) {\r
- return 0;\r
- }\r
-\r
- return VPrintXY (GraphicsOutput, UgaDraw, Sto, X, Y, ForeGround, BackGround, Fmt, Args);\r
-}\r
-\r
+++ /dev/null
-#/** @file\r
-# Instance of Graphics Library.\r
-#\r
-# This library supports displaying graphical splash screen,\r
-# locking of keyboard input and printing character on screen.\r
-#\r
-# Copyright (c) 2006 - 2008, Intel Corporation.\r
-#\r
-# All rights reserved. This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-#**/\r
-\r
-[Defines]\r
- INF_VERSION = 0x00010005\r
- BASE_NAME = UefiGraphicsLib\r
- FILE_GUID = 08c1a0e4-1208-47f8-a2c5-f42eabee653a\r
- MODULE_TYPE = DXE_DRIVER\r
- VERSION_STRING = 1.0\r
- LIBRARY_CLASS = GraphicsLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
- EDK_RELEASE_VERSION = 0x00020000\r
-\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources.common]\r
- Graphics.c\r
-\r
-[Packages]\r
- MdePkg/MdePkg.dec\r
- MdeModulePkg/MdeModulePkg.dec\r
-\r
-[LibraryClasses]\r
- UefiBootServicesTableLib\r
- MemoryAllocationLib\r
- BaseLib\r
- PrintLib\r
- DebugLib\r
- DxePiLib\r
- BaseMemoryLib\r
- PcdLib\r
-\r
-[Protocols]\r
- gEfiSimpleTextOutProtocolGuid # PROTOCOL ALWAYS_CONSUMED\r
- gEfiGraphicsOutputProtocolGuid # PROTOCOL ALWAYS_CONSUMED\r
- gEfiUgaDrawProtocolGuid # PROTOCOL ALWAYS_CONSUMED\r
- gEfiConsoleControlProtocolGuid # PROTOCOL ALWAYS_CONSUMED\r
- gEfiOEMBadgingProtocolGuid # PROTOCOL ALWAYS_CONSUMED\r
- gEfiHiiFontProtocolGuid # PROTOCOL ALWAYS_CONSUMED\r
-\r
-[FeaturePcd.common]\r
- gEfiMdeModulePkgTokenSpaceGuid.PcdUgaConsumeSupport\r
MdePkg/Library/DxePiLib/DxePiLib.inf\r
MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf\r
MdePkg/Library/DxeSmbusLib/DxeSmbusLib.inf\r
- MdePkg/Library/FvbServiceLib/FvbServiceLib.inf\r
- MdePkg/Library/GraphicsLib/GraphicsLib.inf\r
\r
\r
MdePkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.inf\r
[Components.IPF]\r
MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf\r
MdePkg/Library/BasePalCallLibNull/BasePalCallLibNull.inf\r
- MdePkg/Library/DxePalLib/DxePalLib.inf\r
MdePkg/Library/PeiPalLib/PeiPalLib.inf\r
MdePkg/Library/PeiServicesTablePointerLibKr7/PeiServicesTablePointerLibKr7.inf\r
MdePkg/Library/SecPeiDxeTimerLibCpu/SecPeiDxeTimerLibCpu.inf\r
PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf\r
PciIncompatibleDeviceSupportLib|IntelFrameworkModulePkg/Library/PciIncompatibleDeviceSupportLib/PciIncompatibleDeviceSupportLib.inf\r
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf\r
- GraphicsLib|MdePkg/Library/GraphicsLib/GraphicsLib.inf\r
- FvbServiceLib|MdePkg/Library/FvbServiceLib/FvbServiceLib.inf\r
+ GraphicsLib|MdeModulePkg/Library/GraphicsLib/GraphicsLib.inf\r
+ FvbServiceLib|MdeModulePkg/Library/EdkFvbServiceLib/EdkFvbServiceLib.inf\r
IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf\r
UefiDecompressLib|IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.inf\r
HiiLib|MdePkg/Library/UefiHiiLib/UefiHiiLib.inf\r