return Count;\r
}\r
\r
-/**\r
- Adjusts the size of a previously allocated buffer.\r
-\r
-\r
- @param OldPool - A pointer to the buffer whose size is being adjusted.\r
- @param OldSize - The size of the current buffer.\r
- @param NewSize - The size of the new buffer.\r
-\r
- @return The newly allocated buffer.\r
- @retval NULL Allocation failed.\r
-\r
-**/\r
-VOID *\r
-EfiReallocatePool (\r
- IN VOID *OldPool,\r
- IN UINTN OldSize,\r
- IN UINTN NewSize\r
- )\r
-{\r
- VOID *NewPool;\r
-\r
- NewPool = NULL;\r
- if (NewSize != 0) {\r
- NewPool = AllocateZeroPool (NewSize);\r
- }\r
-\r
- if (OldPool != NULL) {\r
- if (NewPool != NULL) {\r
- CopyMem (NewPool, OldPool, OldSize < NewSize ? OldSize : NewSize);\r
- }\r
-\r
- FreePool (OldPool);\r
- }\r
-\r
- return NewPool;\r
-}\r
\r
/**\r
Get a string from the Data Hub record based on\r
IN UINT16 *FileName\r
);\r
\r
-/**\r
-\r
- Check whether current FileName point to a valid Efi Application\r
-\r
- @param Dir Pointer to current Directory\r
- @param FileName Pointer to current File name.\r
-\r
- @retval TRUE Is a valid Efi Application\r
- @retval FALSE not a valid Efi Application\r
-\r
-**/\r
-BOOLEAN\r
-BOpt_IsEfiApp (\r
- IN EFI_FILE_HANDLE Dir,\r
- IN UINT16 *FileName\r
- );\r
\r
/**\r
\r
VOID\r
);\r
\r
-/**\r
- Update the device path that describing a terminal device\r
- based on the new BaudRate, Data Bits, parity and Stop Bits\r
- set.\r
-\r
- @param DevicePath The devicepath protocol instance wanted to be updated.\r
-\r
-**/\r
-VOID\r
-ChangeVariableDevicePath (\r
- IN OUT EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
- );\r
\r
/**\r
Update the multi-instance device path of Terminal Device based on\r
VOID\r
);\r
\r
-/**\r
- Update the device path of "ConOut", "ConIn" and "ErrOut" based on the new BaudRate, Data Bits,\r
- parity and stop Bits set.\r
-\r
-**/\r
-VOID\r
-Var_UpdateAllConsoleOption (\r
- VOID\r
- );\r
\r
/**\r
This function update the "BootNext" EFI Variable. If there is no "BootNex" specified in BMM,\r
IN EFI_FILE_HANDLE FHand\r
);\r
\r
-/**\r
- Adjusts the size of a previously allocated buffer.\r
-\r
- @param OldPool A pointer to the buffer whose size is being adjusted.\r
- @param OldSize The size of the current buffer.\r
- @param NewSize The size of the new buffer.\r
-\r
- @return The newly allocated buffer. if NULL, allocation failed.\r
-\r
-**/\r
-VOID*\r
-EfiReallocatePool (\r
- IN VOID *OldPool,\r
- IN UINTN OldSize,\r
- IN UINTN NewSize\r
- );\r
\r
/**\r
Function deletes the variable specified by VarName and VarGuid.\r
return FALSE;\r
}\r
\r
-/**\r
-\r
- Check whether current FileName point to a valid Efi Application\r
-\r
- @param Dir Pointer to current Directory\r
- @param FileName Pointer to current File name.\r
-\r
- @retval TRUE Is a valid Efi Application\r
- @retval FALSE not a valid Efi Application\r
-\r
-**/\r
-BOOLEAN\r
-BOpt_IsEfiApp (\r
- IN EFI_FILE_HANDLE Dir,\r
- IN UINT16 *FileName\r
- )\r
-{\r
- UINTN BufferSize;\r
- EFI_IMAGE_DOS_HEADER DosHdr;\r
- UINT16 Subsystem;\r
- EFI_FILE_HANDLE File;\r
- EFI_STATUS Status;\r
- EFI_IMAGE_OPTIONAL_HEADER_UNION PeHdr;\r
-\r
- Status = Dir->Open (Dir, &File, FileName, EFI_FILE_MODE_READ, 0);\r
-\r
- if (EFI_ERROR (Status)) {\r
- return FALSE;\r
- }\r
-\r
- BufferSize = sizeof (EFI_IMAGE_DOS_HEADER);\r
- File->Read (File, &BufferSize, &DosHdr);\r
- if (DosHdr.e_magic != EFI_IMAGE_DOS_SIGNATURE) {\r
- File->Close (File);\r
- return FALSE;\r
- }\r
\r
- File->SetPosition (File, DosHdr.e_lfanew);\r
- BufferSize = sizeof (EFI_IMAGE_OPTIONAL_HEADER_UNION);\r
- File->Read (File, &BufferSize, &PeHdr);\r
- if (PeHdr.Pe32.Signature != EFI_IMAGE_NT_SIGNATURE) {\r
- File->Close (File);\r
- return FALSE;\r
- }\r
- //\r
- // Determine PE type and read subsytem\r
- //\r
- if (PeHdr.Pe32.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
- Subsystem = PeHdr.Pe32.OptionalHeader.Subsystem;\r
- } else if (PeHdr.Pe32.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {\r
- Subsystem = PeHdr.Pe32Plus.OptionalHeader.Subsystem;\r
- } else {\r
- return FALSE;\r
- }\r
-\r
- if (Subsystem == EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION) {\r
- File->Close (File);\r
- return TRUE;\r
- } else {\r
- File->Close (File);\r
- return FALSE;\r
- }\r
-}\r
\r
/**\r
\r
\r
}\r
\r
-/**\r
- Update the device path that describing a terminal device\r
- based on the new BaudRate, Data Bits, parity and Stop Bits\r
- set.\r
-\r
- @param DevicePath terminal device's path\r
-\r
-**/\r
-VOID\r
-ChangeVariableDevicePath (\r
- IN OUT EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
- )\r
-{\r
- EFI_DEVICE_PATH_PROTOCOL *Node;\r
- ACPI_HID_DEVICE_PATH *Acpi;\r
- UART_DEVICE_PATH *Uart;\r
- UINTN Com;\r
- BM_TERMINAL_CONTEXT *NewTerminalContext;\r
- BM_MENU_ENTRY *NewMenuEntry;\r
\r
- Node = DevicePath;\r
- Node = NextDevicePathNode (Node);\r
- Com = 0;\r
- while (!IsDevicePathEnd (Node)) {\r
- Acpi = (ACPI_HID_DEVICE_PATH *) Node;\r
- if (IsIsaSerialNode (Acpi)) {\r
- CopyMem (&Com, &Acpi->UID, sizeof (UINT32));\r
- }\r
-\r
- if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (Node) == MSG_UART_DP)) {\r
- NewMenuEntry = BOpt_GetMenuEntry (\r
- &TerminalMenu,\r
- Com\r
- );\r
- ASSERT (NewMenuEntry != NULL);\r
- NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r
- Uart = (UART_DEVICE_PATH *) Node;\r
- CopyMem (\r
- &Uart->BaudRate,\r
- &NewTerminalContext->BaudRate,\r
- sizeof (UINT64)\r
- );\r
-\r
- CopyMem (\r
- &Uart->DataBits,\r
- &NewTerminalContext->DataBits,\r
- sizeof (UINT8)\r
- );\r
-\r
- CopyMem (\r
- &Uart->Parity,\r
- &NewTerminalContext->Parity,\r
- sizeof (UINT8)\r
- );\r
-\r
- CopyMem (\r
- &Uart->StopBits,\r
- &NewTerminalContext->StopBits,\r
- sizeof (UINT8)\r
- );\r
- }\r
-\r
- Node = NextDevicePathNode (Node);\r
- }\r
-}\r
\r
/**\r
Retrieve ACPI UID of UART from device path\r
return EFI_SUCCESS;\r
}\r
\r
-/**\r
- Update the device path of "ConOut", "ConIn" and "ErrOut"\r
- based on the new BaudRate, Data Bits, parity and Stop Bits\r
- set.\r
-\r
-**/\r
-VOID\r
-Var_UpdateAllConsoleOption (\r
- VOID\r
- )\r
-{\r
- EFI_DEVICE_PATH_PROTOCOL *OutDevicePath;\r
- EFI_DEVICE_PATH_PROTOCOL *InpDevicePath;\r
- EFI_DEVICE_PATH_PROTOCOL *ErrDevicePath;\r
- EFI_STATUS Status;\r
\r
- OutDevicePath = EfiLibGetVariable (L"ConOut", &gEfiGlobalVariableGuid);\r
- InpDevicePath = EfiLibGetVariable (L"ConIn", &gEfiGlobalVariableGuid);\r
- ErrDevicePath = EfiLibGetVariable (L"ErrOut", &gEfiGlobalVariableGuid);\r
- if (OutDevicePath != NULL) {\r
- ChangeVariableDevicePath (OutDevicePath);\r
- Status = gRT->SetVariable (\r
- L"ConOut",\r
- &gEfiGlobalVariableGuid,\r
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
- GetDevicePathSize (OutDevicePath),\r
- OutDevicePath\r
- );\r
- //\r
- // Changing variable without increasing its size with current variable implementation shouldn't fail.\r
- //\r
- ASSERT_EFI_ERROR (Status);\r
- }\r
-\r
- if (InpDevicePath != NULL) {\r
- ChangeVariableDevicePath (InpDevicePath);\r
- Status = gRT->SetVariable (\r
- L"ConIn",\r
- &gEfiGlobalVariableGuid,\r
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
- GetDevicePathSize (InpDevicePath),\r
- InpDevicePath\r
- );\r
- //\r
- // Changing variable without increasing its size with current variable implementation shouldn't fail.\r
- //\r
- ASSERT_EFI_ERROR (Status);\r
- }\r
-\r
- if (ErrDevicePath != NULL) {\r
- ChangeVariableDevicePath (ErrDevicePath);\r
- Status = gRT->SetVariable (\r
- L"ErrOut",\r
- &gEfiGlobalVariableGuid,\r
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
- GetDevicePathSize (ErrDevicePath),\r
- ErrDevicePath\r
- );\r
- //\r
- // Changing variable without increasing its size with current variable implementation shouldn't fail.\r
- //\r
- ASSERT_EFI_ERROR (Status);\r
- }\r
-}\r
\r
/**\r
This function delete and build multi-instance device path for\r
return Status;\r
}\r
\r
-/**\r
- Acquire the string associated with the ProducerGuid and return it.\r
-\r
-\r
- @param ProducerGuid The Guid to search the HII database for\r
- @param Token The token value of the string to extract\r
- @param String The string that is extracted\r
-\r
- @retval EFI_SUCCESS The function returns EFI_SUCCESS always.\r
-\r
-**/\r
-EFI_STATUS\r
-GetProducerString (\r
- IN EFI_GUID *ProducerGuid,\r
- IN EFI_STRING_ID Token,\r
- OUT CHAR16 **String\r
- )\r
-{\r
- EFI_STRING TmpString;\r
-\r
- TmpString = HiiGetPackageString (ProducerGuid, Token, NULL);\r
- if (TmpString == NULL) {\r
- *String = GetStringById (STRING_TOKEN (STR_MISSING_STRING));\r
- } else {\r
- *String = TmpString;\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
\r
/**\r
Convert Processor Frequency Data to a string.\r
IN BOOLEAN InitializeHiiData\r
);\r
\r
-/**\r
- Acquire the string associated with the ProducerGuid and return it.\r
-\r
-\r
- @param ProducerGuid - The Guid to search the HII database for\r
- @param Token - The token value of the string to extract\r
- @param String - The string that is extracted\r
-\r
- @retval EFI_SUCCESS The function returns EFI_SUCCESS always.\r
-\r
-**/\r
-EFI_STATUS\r
-GetProducerString (\r
- IN EFI_GUID *ProducerGuid,\r
- IN EFI_STRING_ID Token,\r
- OUT CHAR16 **String\r
- );\r
\r
/**\r
This function is the main entry of the platform setup entry.\r