--- /dev/null
+Language: Cpp
+BreakBeforeBraces: Stroustrup
+PointerAlignment: Right
+IndentWidth: 2
+AccessModifierOffset: 0
+ColumnLimit: 80
+NamespaceIndentation: All
+AlignTrailingComments: true
+AllowAllParametersOfDeclarationOnNextLine: true
+AlwaysBreakTemplateDeclarations: true
+AlignAfterOpenBracket: AlwaysBreak
+UseTab: Never
+IncludeBlocks: Preserve
+AlignConsecutiveDeclarations: true
+AlignConsecutiveAssignments: true
+SpacesInParentheses: false
+SpaceBeforeParens: ControlStatements
\ No newline at end of file
* along with this program. If not, see <https://www.gnu.org/licenses/
*/
-#include <Library/UefiApplicationEntryPoint.h>
#include <Library/BootSlotLib.h>
+#include <Library/UefiApplicationEntryPoint.h>
EFI_STATUS
EFIAPI
-SwitchSlotsAppEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
+SwitchSlotsAppEntryPoint(
+ IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
{
MemCardType Type = CheckRootDeviceType();
if (Type == UNKNOWN) {
- PrintAndWaitAnyKey(SystemTable, L"Unknown device storage. Press any key to exit.\n");
+ PrintAndWaitAnyKey(
+ SystemTable, L"Unknown device storage. Press any key to exit.\n");
return EFI_UNSUPPORTED;
}
EFI_STATUS Status = EnumeratePartitions();
- if (EFI_ERROR (Status)) {
- Print (L"Could not enumerate partitions. Code %d\n", Status);
+ if (EFI_ERROR(Status)) {
+ Print(L"Could not enumerate partitions. Code %d\n", Status);
WaitAnyKey(SystemTable);
return Status;
}
UpdatePartitionEntries();
/*Check for multislot boot support*/
- BOOLEAN MultiSlotSupported = PartitionHasMultiSlot ((CONST CHAR16 *)L"boot");
+ BOOLEAN MultiSlotSupported = PartitionHasMultiSlot((CONST CHAR16 *)L"boot");
if (!MultiSlotSupported) {
- PrintAndWaitAnyKey(SystemTable, L"A/B slots aren't supported on this device. Press any key to exit.\n");
+ PrintAndWaitAnyKey(
+ SystemTable,
+ L"A/B slots aren't supported on this device. Press any key to exit.\n");
return EFI_UNSUPPORTED;
}
Slot CurrentSlot = GetCurrentSlotSuffix();
if (IsSuffixEmpty(&CurrentSlot)) {
- PrintAndWaitAnyKey(SystemTable, L"Current active slot not found, try to boot Android first. Press any key to exit.\n");
+ PrintAndWaitAnyKey(
+ SystemTable, L"Current active slot not found, try to boot Android "
+ L"first. Press any key to exit.\n");
return EFI_NOT_READY;
}
Slot *NewSlot = NULL;
- Slot Slots[] = {{L"_a"}, {L"_b"}};
- if (StrnCmp (CurrentSlot.Suffix, Slots[0].Suffix, StrLen (Slots[0].Suffix)) == 0) {
+ Slot Slots[] = {{L"_a"}, {L"_b"}};
+ if (StrnCmp(CurrentSlot.Suffix, Slots[0].Suffix, StrLen(Slots[0].Suffix)) ==
+ 0) {
NewSlot = &Slots[1];
- } else {
+ }
+ else {
NewSlot = &Slots[0];
}
- //Print (L"Current active slot suffix is: %s, next slot suffix is: %s\n", &CurrentSlot.Suffix, &NewSlot->Suffix);
+ // Print (L"Current active slot suffix is: %s, next slot suffix is: %s\n",
+ // &CurrentSlot.Suffix, &NewSlot->Suffix);
Status = SetActiveSlot(NewSlot, TRUE, FALSE);
if (EFI_ERROR(Status)) {
- Print (L"Could not update active slot. Code %d\n", Status);
+ Print(L"Could not update active slot. Code %d\n", Status);
WaitAnyKey(SystemTable);
return Status;
}
- //Print (L"Current active slot has been updated successfully! Press any key to reboot.\n");
- //WaitAnyKey(SystemTable);
- gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);
- CpuDeadLoop ();
+ // Print (L"Current active slot has been updated successfully! Press any key
+ // to reboot.\n"); WaitAnyKey(SystemTable);
+ gRT->ResetSystem(EfiResetWarm, EFI_SUCCESS, 0, NULL);
+ CpuDeadLoop();
return EFI_SUCCESS;
}
\ No newline at end of file
* along with this program. If not, see <https://www.gnu.org/licenses/
*/
-#include <Uefi.h>
-#include <Library/UefiLib.h>
#include <Library/BootSlotLib.h>
+#include <Library/UefiLib.h>
+#include <Uefi.h>
-EFI_STATUS
-EFIAPI
-BootSlotMain(
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
-) {
+EFI_STATUS
+EFIAPI
+BootSlotMain(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
+{
MemCardType Type = CheckRootDeviceType();
if (Type == UNKNOWN) {
- DEBUG ((EFI_D_ERROR, "Device storage is not supported \n"));
+ DEBUG((EFI_D_ERROR, "Device storage is not supported \n"));
return EFI_SUCCESS;
}
EFI_STATUS Status = EnumeratePartitions();
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Could not enumerate partitions. Code %d\n", Status));
+ if (EFI_ERROR(Status)) {
+ DEBUG((EFI_D_ERROR, "Could not enumerate partitions. Code %d\n", Status));
return Status;
}
UpdatePartitionEntries();
/*Check for multislot boot support*/
- BOOLEAN MultiSlotSupported = PartitionHasMultiSlot ((CONST CHAR16 *)L"boot");
+ BOOLEAN MultiSlotSupported = PartitionHasMultiSlot((CONST CHAR16 *)L"boot");
if (!MultiSlotSupported) {
- DEBUG ((EFI_D_ERROR, "A/B slots aren't supported on this device. Press any key to exit.\n"));
+ DEBUG((
+ EFI_D_ERROR,
+ "A/B slots aren't supported on this device. Press any key to exit.\n"));
return EFI_SUCCESS;
}
Slot CurrentSlot = GetCurrentSlotSuffix();
if (IsSuffixEmpty(&CurrentSlot)) {
- CurrentSlot = Slots[0]; // Set A as active if there is no slot available (shouldn't happen though)
+ CurrentSlot = Slots[0]; // Set A as active if there is no slot available
+ // (shouldn't happen though)
}
// Clear all unbootable bits if exists
- for (UINTN SlotIndex = 0; SlotIndex < ARRAY_SIZE (Slots); SlotIndex++) {
+ for (UINTN SlotIndex = 0; SlotIndex < ARRAY_SIZE(Slots); SlotIndex++) {
Slot *SlotEntry = &Slots[SlotIndex];
if (!IsSlotBootable(SlotEntry)) {
ClearUnbootable(SlotEntry);
}
}
- // Set current slot as active again just refresh its attributes + mark it successful
+ // Set current slot as active again just refresh its attributes + mark it
+ // successful
Status = SetActiveSlot(&CurrentSlot, FALSE, TRUE);
if (EFI_ERROR(Status)) {
- DEBUG ((EFI_D_ERROR, "Could not update active slot. Code %d\n", Status));
+ DEBUG((EFI_D_ERROR, "Could not update active slot. Code %d\n", Status));
return Status;
}
-#include <PiDxe.h>
-#include <Protocol/KeypadDevice.h>
#include <Library/DebugLib.h>
#include <Library/KeypadDeviceImplLib.h>
#include <Library/UefiBootServicesTableLib.h>
+#include <PiDxe.h>
+#include <Protocol/KeypadDevice.h>
typedef struct {
- VENDOR_DEVICE_PATH Keypad;
- EFI_DEVICE_PATH End;
+ VENDOR_DEVICE_PATH Keypad;
+ EFI_DEVICE_PATH End;
} KEYPAD_DEVICE_PATH;
KEYPAD_DEVICE_PATH mInternalDevicePath = {
- {
{
- HARDWARE_DEVICE_PATH,
- HW_VENDOR_DP,
- {
- (UINT8)(sizeof(VENDOR_DEVICE_PATH)),
- (UINT8)((sizeof(VENDOR_DEVICE_PATH)) >> 8),
- },
+ {
+ HARDWARE_DEVICE_PATH,
+ HW_VENDOR_DP,
+ {
+ (UINT8)(sizeof(VENDOR_DEVICE_PATH)),
+ (UINT8)((sizeof(VENDOR_DEVICE_PATH)) >> 8),
+ },
+ },
+ EFI_CALLER_ID_GUID,
},
- EFI_CALLER_ID_GUID,
- },
- {
- END_DEVICE_PATH_TYPE,
- END_ENTIRE_DEVICE_PATH_SUBTYPE,
- { sizeof (EFI_DEVICE_PATH_PROTOCOL), 0 }
- }
-};
+ {END_DEVICE_PATH_TYPE,
+ END_ENTIRE_DEVICE_PATH_SUBTYPE,
+ {sizeof(EFI_DEVICE_PATH_PROTOCOL), 0}}};
STATIC KEYPAD_DEVICE_PROTOCOL mInternalKeypadDevice = {
- KeypadDeviceImplReset,
- KeypadDeviceImplGetKeys,
+ KeypadDeviceImplReset,
+ KeypadDeviceImplGetKeys,
};
EFI_STATUS
EFIAPI
-KeypadDeviceDxeInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
+KeypadDeviceDxeInitialize(
+ IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
{
EFI_STATUS Status;
Status = gBS->InstallMultipleProtocolInterfaces(
- &ImageHandle,
- &gEFIDroidKeypadDeviceProtocolGuid,
- &mInternalKeypadDevice,
- &gEfiDevicePathProtocolGuid,
- &mInternalDevicePath,
- NULL
- );
+ &ImageHandle, &gEFIDroidKeypadDeviceProtocolGuid, &mInternalKeypadDevice,
+ &gEfiDevicePathProtocolGuid, &mInternalDevicePath, NULL);
ASSERT_EFI_ERROR(Status);
return Status;
Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
+are licensed and made available under the terms and conditions of the BSD
+License which accompanies this distribution. The full text of the license may
+be found at http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
EFI_STATUS
EFIAPI
-KeypadComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- );
-
+KeypadComponentNameGetDriverName(
+ IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language,
+ OUT CHAR16 **DriverName);
/**
Retrieves a Unicode string that is the user readable name of the controller
**/
EFI_STATUS
EFIAPI
-KeypadComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- );
-
+KeypadComponentNameGetControllerName(
+ IN EFI_COMPONENT_NAME_PROTOCOL *This, IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL, IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName);
//
// EFI Component Name Protocol
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gKeypadComponentName = {
- KeypadComponentNameGetDriverName,
- KeypadComponentNameGetControllerName,
- "eng"
-};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gKeypadComponentName =
+ {KeypadComponentNameGetDriverName, KeypadComponentNameGetControllerName,
+ "eng"};
//
// EFI Component Name 2 Protocol
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gKeypadComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) KeypadComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) KeypadComponentNameGetControllerName,
- "en"
-};
-
-
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mKeypadDriverNameTable[] = {
- {
- "eng;en",
- L"Keypad Driver"
- },
- {
- NULL,
- NULL
- }
-};
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL
+ gKeypadComponentName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)KeypadComponentNameGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)
+ KeypadComponentNameGetControllerName,
+ "en"};
+
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
+ mKeypadDriverNameTable[] = {{"eng;en", L"Keypad Driver"}, {NULL, NULL}};
/**
Retrieves a Unicode string that is the user readable name of the driver.
**/
EFI_STATUS
EFIAPI
-KeypadComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- )
+KeypadComponentNameGetDriverName(
+ IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language,
+ OUT CHAR16 **DriverName)
{
- return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- mKeypadDriverNameTable,
- DriverName,
- (BOOLEAN)(This == &gKeypadComponentName)
- );
+ return LookupUnicodeString2(
+ Language, This->SupportedLanguages, mKeypadDriverNameTable, DriverName,
+ (BOOLEAN)(This == &gKeypadComponentName));
}
/**
**/
EFI_STATUS
EFIAPI
-KeypadComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- )
+KeypadComponentNameGetControllerName(
+ IN EFI_COMPONENT_NAME_PROTOCOL *This, IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL, IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName)
{
- EFI_STATUS Status;
- EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn;
- KEYPAD_CONSOLE_IN_DEV *ConsoleIn;
+ EFI_STATUS Status;
+ EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn;
+ KEYPAD_CONSOLE_IN_DEV * ConsoleIn;
//
// This is a device driver, so ChildHandle must be NULL.
//
//
// Check Controller's handle
//
- Status = EfiTestManagedDevice (ControllerHandle, gKeypadControllerDriver.DriverBindingHandle, &gEFIDroidKeypadDeviceProtocolGuid);
- if (EFI_ERROR (Status)) {
+ Status = EfiTestManagedDevice(
+ ControllerHandle, gKeypadControllerDriver.DriverBindingHandle,
+ &gEFIDroidKeypadDeviceProtocolGuid);
+ if (EFI_ERROR(Status)) {
return Status;
}
//
// Get the device context
//
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiSimpleTextInProtocolGuid,
- (VOID **) &ConIn,
- gKeypadControllerDriver.DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
+ Status = gBS->OpenProtocol(
+ ControllerHandle, &gEfiSimpleTextInProtocolGuid, (VOID **)&ConIn,
+ gKeypadControllerDriver.DriverBindingHandle, ControllerHandle,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ if (EFI_ERROR(Status)) {
return Status;
}
- ConsoleIn = KEYPAD_CONSOLE_IN_DEV_FROM_THIS (ConIn);
+ ConsoleIn = KEYPAD_CONSOLE_IN_DEV_FROM_THIS(ConIn);
- return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- ConsoleIn->ControllerNameTable,
- ControllerName,
- (BOOLEAN)(This == &gKeypadComponentName)
- );
+ return LookupUnicodeString2(
+ Language, This->SupportedLanguages, ConsoleIn->ControllerNameTable,
+ ControllerName, (BOOLEAN)(This == &gKeypadComponentName));
}
Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
+are licensed and made available under the terms and conditions of the BSD
+License which accompanies this distribution. The full text of the license may
+be found at http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
EFI_STATUS
EFIAPI
-KeypadControllerDriverSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- );
+KeypadControllerDriverSupported(
+ IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath);
/**
Create KEYPAD_CONSOLE_IN_DEV instance on controller.
**/
EFI_STATUS
EFIAPI
-KeypadControllerDriverStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- );
+KeypadControllerDriverStart(
+ IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath);
/**
Stop this driver on ControllerHandle. Support stopping any child handles
**/
EFI_STATUS
EFIAPI
-KeypadControllerDriverStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- );
+KeypadControllerDriverStop(
+ IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer);
/**
Free the waiting key notify list.
@retval EFI_SUCCESS Sucess to free NotifyList
**/
EFI_STATUS
-KbdFreeNotifyList (
- IN OUT LIST_ENTRY *ListHead
- );
+KbdFreeNotifyList(IN OUT LIST_ENTRY *ListHead);
//
// DriverBinding Protocol Instance
//
EFI_DRIVER_BINDING_PROTOCOL gKeypadControllerDriver = {
- KeypadControllerDriverSupported,
- KeypadControllerDriverStart,
- KeypadControllerDriverStop,
- 0xa,
- NULL,
- NULL
-};
+ KeypadControllerDriverSupported,
+ KeypadControllerDriverStart,
+ KeypadControllerDriverStop,
+ 0xa,
+ NULL,
+ NULL};
/**
Test controller is a keypad Controller.
**/
EFI_STATUS
EFIAPI
-KeypadControllerDriverSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
+KeypadControllerDriverSupported(
+ IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
{
- EFI_STATUS Status;
- KEYPAD_DEVICE_PROTOCOL *KeypadDevice;
+ EFI_STATUS Status;
+ KEYPAD_DEVICE_PROTOCOL *KeypadDevice;
//
// Open the IO Abstraction(s) needed to perform the supported test
//
- Status = gBS->OpenProtocol (
- Controller,
- &gEFIDroidKeypadDeviceProtocolGuid,
- (VOID **) &KeypadDevice,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
+ Status = gBS->OpenProtocol(
+ Controller, &gEFIDroidKeypadDeviceProtocolGuid, (VOID **)&KeypadDevice,
+ This->DriverBindingHandle, Controller, EFI_OPEN_PROTOCOL_BY_DRIVER);
+ if (EFI_ERROR(Status)) {
return Status;
}
//
// Close the I/O Abstraction(s) used to perform the supported test
//
- gBS->CloseProtocol (
- Controller,
- &gEFIDroidKeypadDeviceProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ gBS->CloseProtocol(
+ Controller, &gEFIDroidKeypadDeviceProtocolGuid, This->DriverBindingHandle,
+ Controller);
return Status;
}
-
STATIC
-VOID
-EFIAPI
-KeypadReturnApiPushEfikeyBufTail (
- KEYPAD_RETURN_API *This,
- EFI_KEY_DATA *KeyData
- )
+VOID EFIAPI
+KeypadReturnApiPushEfikeyBufTail(KEYPAD_RETURN_API *This, EFI_KEY_DATA *KeyData)
{
- KEYPAD_CONSOLE_IN_DEV *ConsoleIn;
- LIST_ENTRY *Link;
- KEYPAD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
+ KEYPAD_CONSOLE_IN_DEV * ConsoleIn;
+ LIST_ENTRY * Link;
+ KEYPAD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
- ConsoleIn = KEYPAD_CONSOLE_IN_DEV_FROM_KEYPAD_RETURN_API (This);
+ ConsoleIn = KEYPAD_CONSOLE_IN_DEV_FROM_KEYPAD_RETURN_API(This);
//
// If the key can not be converted then just return.
//
- if (KeyData->Key.ScanCode == SCAN_NULL && KeyData->Key.UnicodeChar == CHAR_NULL) {
+ if (KeyData->Key.ScanCode == SCAN_NULL &&
+ KeyData->Key.UnicodeChar == CHAR_NULL) {
if (!ConsoleIn->IsSupportPartialKey) {
return;
}
}
//
- // Signal KeyNotify process event if this key pressed matches any key registered.
+ // Signal KeyNotify process event if this key pressed matches any key
+ // registered.
//
- for (Link = GetFirstNode (&ConsoleIn->NotifyList); !IsNull (&ConsoleIn->NotifyList, Link); Link = GetNextNode (&ConsoleIn->NotifyList, Link)) {
- CurrentNotify = CR (
- Link,
- KEYPAD_CONSOLE_IN_EX_NOTIFY,
- NotifyEntry,
- KEYPAD_CONSOLE_IN_EX_NOTIFY_SIGNATURE
- );
- if (IsKeyRegistered (&CurrentNotify->KeyData, KeyData)) {
+ for (Link = GetFirstNode(&ConsoleIn->NotifyList);
+ !IsNull(&ConsoleIn->NotifyList, Link);
+ Link = GetNextNode(&ConsoleIn->NotifyList, Link)) {
+ CurrentNotify =
+ CR(Link, KEYPAD_CONSOLE_IN_EX_NOTIFY, NotifyEntry,
+ KEYPAD_CONSOLE_IN_EX_NOTIFY_SIGNATURE);
+ if (IsKeyRegistered(&CurrentNotify->KeyData, KeyData)) {
//
// The key notification function needs to run at TPL_CALLBACK
// while current TPL is TPL_NOTIFY. It will be invoked in
// KeyNotifyProcessHandler() which runs at TPL_CALLBACK.
//
- PushEfikeyBufTail (&ConsoleIn->EfiKeyQueueForNotify, KeyData);
- gBS->SignalEvent (ConsoleIn->KeyNotifyProcessEvent);
+ PushEfikeyBufTail(&ConsoleIn->EfiKeyQueueForNotify, KeyData);
+ gBS->SignalEvent(ConsoleIn->KeyNotifyProcessEvent);
}
}
- PushEfikeyBufTail (&ConsoleIn->EfiKeyQueue, KeyData);
+ PushEfikeyBufTail(&ConsoleIn->EfiKeyQueue, KeyData);
}
/**
**/
EFI_STATUS
EFIAPI
-KeypadControllerDriverStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
+KeypadControllerDriverStart(
+ IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
{
- EFI_STATUS Status;
- KEYPAD_DEVICE_PROTOCOL *KeypadDevice;
- KEYPAD_CONSOLE_IN_DEV *ConsoleIn;
+ EFI_STATUS Status;
+ KEYPAD_DEVICE_PROTOCOL *KeypadDevice;
+ KEYPAD_CONSOLE_IN_DEV * ConsoleIn;
//
// Get the ISA I/O Protocol on Controller's handle
//
- Status = gBS->OpenProtocol (
- Controller,
- &gEFIDroidKeypadDeviceProtocolGuid,
- (VOID **) &KeypadDevice,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
+ Status = gBS->OpenProtocol(
+ Controller, &gEFIDroidKeypadDeviceProtocolGuid, (VOID **)&KeypadDevice,
+ This->DriverBindingHandle, Controller, EFI_OPEN_PROTOCOL_BY_DRIVER);
+ if (EFI_ERROR(Status)) {
return Status;
}
//
// Allocate private data
//
- ConsoleIn = AllocateZeroPool (sizeof (KEYPAD_CONSOLE_IN_DEV));
+ ConsoleIn = AllocateZeroPool(sizeof(KEYPAD_CONSOLE_IN_DEV));
if (ConsoleIn == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
+ Status = EFI_OUT_OF_RESOURCES;
goto ErrorExit;
}
//
// Setup the device instance
//
- ConsoleIn->Signature = KEYPAD_CONSOLE_IN_DEV_SIGNATURE;
- ConsoleIn->Handle = Controller;
- (ConsoleIn->ConIn).Reset = KeypadEfiReset;
- (ConsoleIn->ConIn).ReadKeyStroke = KeypadReadKeyStroke;
- ConsoleIn->KeypadDevice = KeypadDevice;
- ConsoleIn->KeypadReturnApi.PushEfikeyBufTail = KeypadReturnApiPushEfikeyBufTail;
- ConsoleIn->Last = (UINT64)-1;
+ ConsoleIn->Signature = KEYPAD_CONSOLE_IN_DEV_SIGNATURE;
+ ConsoleIn->Handle = Controller;
+ (ConsoleIn->ConIn).Reset = KeypadEfiReset;
+ (ConsoleIn->ConIn).ReadKeyStroke = KeypadReadKeyStroke;
+ ConsoleIn->KeypadDevice = KeypadDevice;
+ ConsoleIn->KeypadReturnApi.PushEfikeyBufTail =
+ KeypadReturnApiPushEfikeyBufTail;
+ ConsoleIn->Last = (UINT64)-1;
ConsoleIn->ConInEx.Reset = KeypadEfiResetEx;
ConsoleIn->ConInEx.ReadKeyStrokeEx = KeypadReadKeyStrokeEx;
ConsoleIn->ConInEx.RegisterKeyNotify = KeypadRegisterKeyNotify;
ConsoleIn->ConInEx.UnregisterKeyNotify = KeypadUnregisterKeyNotify;
- InitializeListHead (&ConsoleIn->NotifyList);
+ InitializeListHead(&ConsoleIn->NotifyList);
//
- // Fix for random hangs in System waiting for the Key if no KBC is present in BIOS.
- // When KBC decode (IO port 0x60/0x64 decode) is not enabled,
- // KeypadRead will read back as 0xFF and return status is EFI_SUCCESS.
- // So instead we read status register to detect after read if KBC decode is enabled.
+ // Fix for random hangs in System waiting for the Key if no KBC is present in
+ // BIOS. When KBC decode (IO port 0x60/0x64 decode) is not enabled, KeypadRead
+ // will read back as 0xFF and return status is EFI_SUCCESS. So instead we read
+ // status register to detect after read if KBC decode is enabled.
//
//
// Setup the WaitForKey event
//
- Status = gBS->CreateEvent (
- EVT_NOTIFY_WAIT,
- TPL_NOTIFY,
- KeypadWaitForKey,
- ConsoleIn,
- &((ConsoleIn->ConIn).WaitForKey)
- );
- if (EFI_ERROR (Status)) {
- Status = EFI_OUT_OF_RESOURCES;
+ Status = gBS->CreateEvent(
+ EVT_NOTIFY_WAIT, TPL_NOTIFY, KeypadWaitForKey, ConsoleIn,
+ &((ConsoleIn->ConIn).WaitForKey));
+ if (EFI_ERROR(Status)) {
+ Status = EFI_OUT_OF_RESOURCES;
goto ErrorExit;
}
//
// Setup the WaitForKeyEx event
//
- Status = gBS->CreateEvent (
- EVT_NOTIFY_WAIT,
- TPL_NOTIFY,
- KeypadWaitForKeyEx,
- ConsoleIn,
- &(ConsoleIn->ConInEx.WaitForKeyEx)
- );
- if (EFI_ERROR (Status)) {
- Status = EFI_OUT_OF_RESOURCES;
+ Status = gBS->CreateEvent(
+ EVT_NOTIFY_WAIT, TPL_NOTIFY, KeypadWaitForKeyEx, ConsoleIn,
+ &(ConsoleIn->ConInEx.WaitForKeyEx));
+ if (EFI_ERROR(Status)) {
+ Status = EFI_OUT_OF_RESOURCES;
goto ErrorExit;
}
// Setup a periodic timer, used for reading keystrokes at a fixed interval
//
- Status = gBS->CreateEvent (
- EVT_TIMER | EVT_NOTIFY_SIGNAL,
- TPL_NOTIFY,
- KeypadTimerHandler,
- ConsoleIn,
- &ConsoleIn->TimerEvent
- );
- if (EFI_ERROR (Status)) {
- Status = EFI_OUT_OF_RESOURCES;
+ Status = gBS->CreateEvent(
+ EVT_TIMER | EVT_NOTIFY_SIGNAL, TPL_NOTIFY, KeypadTimerHandler, ConsoleIn,
+ &ConsoleIn->TimerEvent);
+ if (EFI_ERROR(Status)) {
+ Status = EFI_OUT_OF_RESOURCES;
goto ErrorExit;
}
- Status = gBS->SetTimer (
- ConsoleIn->TimerEvent,
- TimerPeriodic,
- KEYPAD_TIMER_INTERVAL
- );
- if (EFI_ERROR (Status)) {
- Status = EFI_OUT_OF_RESOURCES;
+ Status = gBS->SetTimer(
+ ConsoleIn->TimerEvent, TimerPeriodic, KEYPAD_TIMER_INTERVAL);
+ if (EFI_ERROR(Status)) {
+ Status = EFI_OUT_OF_RESOURCES;
goto ErrorExit;
}
- Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- KeyNotifyProcessHandler,
- ConsoleIn,
- &ConsoleIn->KeyNotifyProcessEvent
- );
- if (EFI_ERROR (Status)) {
- Status = EFI_OUT_OF_RESOURCES;
+ Status = gBS->CreateEvent(
+ EVT_NOTIFY_SIGNAL, TPL_CALLBACK, KeyNotifyProcessHandler, ConsoleIn,
+ &ConsoleIn->KeyNotifyProcessEvent);
+ if (EFI_ERROR(Status)) {
+ Status = EFI_OUT_OF_RESOURCES;
goto ErrorExit;
}
//
// Reset the keypad device
//
- Status = ConsoleIn->ConInEx.Reset (&ConsoleIn->ConInEx, FALSE);
- if (EFI_ERROR (Status)) {
- Status = EFI_DEVICE_ERROR;
+ Status = ConsoleIn->ConInEx.Reset(&ConsoleIn->ConInEx, FALSE);
+ if (EFI_ERROR(Status)) {
+ Status = EFI_DEVICE_ERROR;
goto ErrorExit;
}
ConsoleIn->ControllerNameTable = NULL;
- AddUnicodeString2 (
- "eng",
- gKeypadComponentName.SupportedLanguages,
- &ConsoleIn->ControllerNameTable,
- L"Keypad Device",
- TRUE
- );
- AddUnicodeString2 (
- "en",
- gKeypadComponentName2.SupportedLanguages,
- &ConsoleIn->ControllerNameTable,
- L"Keypad Device",
- FALSE
- );
-
+ AddUnicodeString2(
+ "eng", gKeypadComponentName.SupportedLanguages,
+ &ConsoleIn->ControllerNameTable, L"Keypad Device", TRUE);
+ AddUnicodeString2(
+ "en", gKeypadComponentName2.SupportedLanguages,
+ &ConsoleIn->ControllerNameTable, L"Keypad Device", FALSE);
//
// Install protocol interfaces for the keypad device.
//
- Status = gBS->InstallMultipleProtocolInterfaces (
- &Controller,
- &gEfiSimpleTextInProtocolGuid,
- &ConsoleIn->ConIn,
- &gEfiSimpleTextInputExProtocolGuid,
- &ConsoleIn->ConInEx,
- NULL
- );
- if (EFI_ERROR (Status)) {
+ Status = gBS->InstallMultipleProtocolInterfaces(
+ &Controller, &gEfiSimpleTextInProtocolGuid, &ConsoleIn->ConIn,
+ &gEfiSimpleTextInputExProtocolGuid, &ConsoleIn->ConInEx, NULL);
+ if (EFI_ERROR(Status)) {
goto ErrorExit;
}
ErrorExit:
if ((ConsoleIn != NULL) && (ConsoleIn->ConIn.WaitForKey != NULL)) {
- gBS->CloseEvent (ConsoleIn->ConIn.WaitForKey);
+ gBS->CloseEvent(ConsoleIn->ConIn.WaitForKey);
}
if ((ConsoleIn != NULL) && (ConsoleIn->TimerEvent != NULL)) {
- gBS->CloseEvent (ConsoleIn->TimerEvent);
+ gBS->CloseEvent(ConsoleIn->TimerEvent);
}
if ((ConsoleIn != NULL) && (ConsoleIn->ConInEx.WaitForKeyEx != NULL)) {
- gBS->CloseEvent (ConsoleIn->ConInEx.WaitForKeyEx);
+ gBS->CloseEvent(ConsoleIn->ConInEx.WaitForKeyEx);
}
if ((ConsoleIn != NULL) && (ConsoleIn->KeyNotifyProcessEvent != NULL)) {
- gBS->CloseEvent (ConsoleIn->KeyNotifyProcessEvent);
+ gBS->CloseEvent(ConsoleIn->KeyNotifyProcessEvent);
}
- KbdFreeNotifyList (&ConsoleIn->NotifyList);
+ KbdFreeNotifyList(&ConsoleIn->NotifyList);
if ((ConsoleIn != NULL) && (ConsoleIn->ControllerNameTable != NULL)) {
- FreeUnicodeStringTable (ConsoleIn->ControllerNameTable);
+ FreeUnicodeStringTable(ConsoleIn->ControllerNameTable);
}
if (ConsoleIn != NULL) {
- gBS->FreePool (ConsoleIn);
+ gBS->FreePool(ConsoleIn);
}
- gBS->CloseProtocol (
- Controller,
- &gEFIDroidKeypadDeviceProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ gBS->CloseProtocol(
+ Controller, &gEFIDroidKeypadDeviceProtocolGuid, This->DriverBindingHandle,
+ Controller);
return Status;
}
**/
EFI_STATUS
EFIAPI
-KeypadControllerDriverStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- )
+KeypadControllerDriverStop(
+ IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn;
- KEYPAD_CONSOLE_IN_DEV *ConsoleIn;
+ KEYPAD_CONSOLE_IN_DEV * ConsoleIn;
//
// Disable Keypad
//
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiSimpleTextInProtocolGuid,
- (VOID **) &ConIn,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
+ Status = gBS->OpenProtocol(
+ Controller, &gEfiSimpleTextInProtocolGuid, (VOID **)&ConIn,
+ This->DriverBindingHandle, Controller, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ if (EFI_ERROR(Status)) {
return Status;
}
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiSimpleTextInputExProtocolGuid,
- NULL,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
+ Status = gBS->OpenProtocol(
+ Controller, &gEfiSimpleTextInputExProtocolGuid, NULL,
+ This->DriverBindingHandle, Controller, EFI_OPEN_PROTOCOL_TEST_PROTOCOL);
+ if (EFI_ERROR(Status)) {
return Status;
}
- ConsoleIn = KEYPAD_CONSOLE_IN_DEV_FROM_THIS (ConIn);
+ ConsoleIn = KEYPAD_CONSOLE_IN_DEV_FROM_THIS(ConIn);
if (ConsoleIn->TimerEvent != NULL) {
- gBS->CloseEvent (ConsoleIn->TimerEvent);
+ gBS->CloseEvent(ConsoleIn->TimerEvent);
ConsoleIn->TimerEvent = NULL;
}
//
// Uninstall the SimpleTextIn and SimpleTextInEx protocols
//
- Status = gBS->UninstallMultipleProtocolInterfaces (
- Controller,
- &gEfiSimpleTextInProtocolGuid,
- &ConsoleIn->ConIn,
- &gEfiSimpleTextInputExProtocolGuid,
- &ConsoleIn->ConInEx,
- NULL
- );
- if (EFI_ERROR (Status)) {
+ Status = gBS->UninstallMultipleProtocolInterfaces(
+ Controller, &gEfiSimpleTextInProtocolGuid, &ConsoleIn->ConIn,
+ &gEfiSimpleTextInputExProtocolGuid, &ConsoleIn->ConInEx, NULL);
+ if (EFI_ERROR(Status)) {
return Status;
}
- gBS->CloseProtocol (
- Controller,
- &gEFIDroidKeypadDeviceProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ gBS->CloseProtocol(
+ Controller, &gEFIDroidKeypadDeviceProtocolGuid, This->DriverBindingHandle,
+ Controller);
//
// Free other resources
//
if ((ConsoleIn->ConIn).WaitForKey != NULL) {
- gBS->CloseEvent ((ConsoleIn->ConIn).WaitForKey);
+ gBS->CloseEvent((ConsoleIn->ConIn).WaitForKey);
(ConsoleIn->ConIn).WaitForKey = NULL;
}
if (ConsoleIn->ConInEx.WaitForKeyEx != NULL) {
- gBS->CloseEvent (ConsoleIn->ConInEx.WaitForKeyEx);
+ gBS->CloseEvent(ConsoleIn->ConInEx.WaitForKeyEx);
ConsoleIn->ConInEx.WaitForKeyEx = NULL;
}
if (ConsoleIn->KeyNotifyProcessEvent != NULL) {
- gBS->CloseEvent (ConsoleIn->KeyNotifyProcessEvent);
+ gBS->CloseEvent(ConsoleIn->KeyNotifyProcessEvent);
ConsoleIn->KeyNotifyProcessEvent = NULL;
}
- KbdFreeNotifyList (&ConsoleIn->NotifyList);
- FreeUnicodeStringTable (ConsoleIn->ControllerNameTable);
- gBS->FreePool (ConsoleIn);
+ KbdFreeNotifyList(&ConsoleIn->NotifyList);
+ FreeUnicodeStringTable(ConsoleIn->ControllerNameTable);
+ gBS->FreePool(ConsoleIn);
return EFI_SUCCESS;
}
@retval EFI_SUCCESS Sucess to free NotifyList
**/
EFI_STATUS
-KbdFreeNotifyList (
- IN OUT LIST_ENTRY *ListHead
- )
+KbdFreeNotifyList(IN OUT LIST_ENTRY *ListHead)
{
KEYPAD_CONSOLE_IN_EX_NOTIFY *NotifyNode;
if (ListHead == NULL) {
return EFI_INVALID_PARAMETER;
}
- while (!IsListEmpty (ListHead)) {
- NotifyNode = CR (
- ListHead->ForwardLink,
- KEYPAD_CONSOLE_IN_EX_NOTIFY,
- NotifyEntry,
- KEYPAD_CONSOLE_IN_EX_NOTIFY_SIGNATURE
- );
- RemoveEntryList (ListHead->ForwardLink);
- gBS->FreePool (NotifyNode);
+ while (!IsListEmpty(ListHead)) {
+ NotifyNode =
+ CR(ListHead->ForwardLink, KEYPAD_CONSOLE_IN_EX_NOTIFY, NotifyEntry,
+ KEYPAD_CONSOLE_IN_EX_NOTIFY_SIGNATURE);
+ RemoveEntryList(ListHead->ForwardLink);
+ gBS->FreePool(NotifyNode);
}
return EFI_SUCCESS;
**/
EFI_STATUS
EFIAPI
-InitializeKeypad(
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
+InitializeKeypad(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Install driver model protocol(s).
//
- Status = EfiLibInstallDriverBindingComponentName2 (
- ImageHandle,
- SystemTable,
- &gKeypadControllerDriver,
- ImageHandle,
- &gKeypadComponentName,
- &gKeypadComponentName2
- );
- ASSERT_EFI_ERROR (Status);
-
+ Status = EfiLibInstallDriverBindingComponentName2(
+ ImageHandle, SystemTable, &gKeypadControllerDriver, ImageHandle,
+ &gKeypadComponentName, &gKeypadComponentName2);
+ ASSERT_EFI_ERROR(Status);
return Status;
}
-
Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
+are licensed and made available under the terms and conditions of the BSD
+License which accompanies this distribution. The full text of the license may
+be found at http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Uefi.h>
+#include <Protocol/KeypadDevice.h>
#include <Protocol/SimpleTextIn.h>
#include <Protocol/SimpleTextInEx.h>
-#include <Protocol/KeypadDevice.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
#include <Library/IoLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/PcdLib.h>
+#include <Library/TimerLib.h>
+#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/UefiLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/DebugLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/TimerLib.h>
-#include <Library/PcdLib.h>
//
// Global Variables
//
-extern EFI_DRIVER_BINDING_PROTOCOL gKeypadControllerDriver;
-extern EFI_COMPONENT_NAME_PROTOCOL gKeypadComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gKeypadComponentName2;
+extern EFI_DRIVER_BINDING_PROTOCOL gKeypadControllerDriver;
+extern EFI_COMPONENT_NAME_PROTOCOL gKeypadComponentName;
+extern EFI_COMPONENT_NAME2_PROTOCOL gKeypadComponentName2;
//
// Driver Private Data
//
-#define KEYPAD_CONSOLE_IN_DEV_SIGNATURE SIGNATURE_32 ('k', 'k', 'e', 'y')
-#define KEYPAD_CONSOLE_IN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('k', 'c', 'e', 'n')
+#define KEYPAD_CONSOLE_IN_DEV_SIGNATURE SIGNATURE_32('k', 'k', 'e', 'y')
+#define KEYPAD_CONSOLE_IN_EX_NOTIFY_SIGNATURE SIGNATURE_32('k', 'c', 'e', 'n')
typedef struct _KEYPAD_CONSOLE_IN_EX_NOTIFY {
- UINTN Signature;
- EFI_KEY_DATA KeyData;
- EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn;
- LIST_ENTRY NotifyEntry;
+ UINTN Signature;
+ EFI_KEY_DATA KeyData;
+ EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn;
+ LIST_ENTRY NotifyEntry;
} KEYPAD_CONSOLE_IN_EX_NOTIFY;
-#define KEYPAD_EFI_KEY_MAX_COUNT 256
+#define KEYPAD_EFI_KEY_MAX_COUNT 256
typedef struct {
- EFI_KEY_DATA Buffer[KEYPAD_EFI_KEY_MAX_COUNT];
- UINTN Head;
- UINTN Tail;
+ EFI_KEY_DATA Buffer[KEYPAD_EFI_KEY_MAX_COUNT];
+ UINTN Head;
+ UINTN Tail;
} EFI_KEY_QUEUE;
typedef struct {
- UINTN Signature;
+ UINTN Signature;
- EFI_HANDLE Handle;
- EFI_SIMPLE_TEXT_INPUT_PROTOCOL ConIn;
- EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL ConInEx;
+ EFI_HANDLE Handle;
+ EFI_SIMPLE_TEXT_INPUT_PROTOCOL ConIn;
+ EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL ConInEx;
- EFI_EVENT TimerEvent;
+ EFI_EVENT TimerEvent;
- KEYPAD_DEVICE_PROTOCOL *KeypadDevice;
- KEYPAD_RETURN_API KeypadReturnApi;
+ KEYPAD_DEVICE_PROTOCOL *KeypadDevice;
+ KEYPAD_RETURN_API KeypadReturnApi;
// counter value of the last poll
- UINT64 Last;
-
- BOOLEAN LeftCtrl;
- BOOLEAN RightCtrl;
- BOOLEAN LeftAlt;
- BOOLEAN RightAlt;
- BOOLEAN LeftShift;
- BOOLEAN RightShift;
- BOOLEAN LeftLogo;
- BOOLEAN RightLogo;
- BOOLEAN Menu;
- BOOLEAN SysReq;
-
- BOOLEAN CapsLock;
- BOOLEAN NumLock;
- BOOLEAN ScrollLock;
-
- BOOLEAN IsSupportPartialKey;
+ UINT64 Last;
+
+ BOOLEAN LeftCtrl;
+ BOOLEAN RightCtrl;
+ BOOLEAN LeftAlt;
+ BOOLEAN RightAlt;
+ BOOLEAN LeftShift;
+ BOOLEAN RightShift;
+ BOOLEAN LeftLogo;
+ BOOLEAN RightLogo;
+ BOOLEAN Menu;
+ BOOLEAN SysReq;
+
+ BOOLEAN CapsLock;
+ BOOLEAN NumLock;
+ BOOLEAN ScrollLock;
+
+ BOOLEAN IsSupportPartialKey;
//
// Queue storing key scancodes
//
- EFI_KEY_QUEUE EfiKeyQueue;
- EFI_KEY_QUEUE EfiKeyQueueForNotify;
+ EFI_KEY_QUEUE EfiKeyQueue;
+ EFI_KEY_QUEUE EfiKeyQueueForNotify;
//
// Error state
//
- BOOLEAN KeypadErr;
+ BOOLEAN KeypadErr;
- EFI_UNICODE_STRING_TABLE *ControllerNameTable;
+ EFI_UNICODE_STRING_TABLE *ControllerNameTable;
//
// Notification Function List
//
- LIST_ENTRY NotifyList;
- EFI_EVENT KeyNotifyProcessEvent;
+ LIST_ENTRY NotifyList;
+ EFI_EVENT KeyNotifyProcessEvent;
} KEYPAD_CONSOLE_IN_DEV;
-#define KEYPAD_CONSOLE_IN_DEV_FROM_KEYPAD_RETURN_API(a) CR (a, KEYPAD_CONSOLE_IN_DEV, KeypadReturnApi, KEYPAD_CONSOLE_IN_DEV_SIGNATURE)
-#define KEYPAD_CONSOLE_IN_DEV_FROM_THIS(a) CR (a, KEYPAD_CONSOLE_IN_DEV, ConIn, KEYPAD_CONSOLE_IN_DEV_SIGNATURE)
-#define TEXT_INPUT_EX_KEYPAD_CONSOLE_IN_DEV_FROM_THIS(a) \
- CR (a, \
- KEYPAD_CONSOLE_IN_DEV, \
- ConInEx, \
- KEYPAD_CONSOLE_IN_DEV_SIGNATURE \
- )
+#define KEYPAD_CONSOLE_IN_DEV_FROM_KEYPAD_RETURN_API(a) \
+ CR(a, KEYPAD_CONSOLE_IN_DEV, KeypadReturnApi, KEYPAD_CONSOLE_IN_DEV_SIGNATURE)
+#define KEYPAD_CONSOLE_IN_DEV_FROM_THIS(a) \
+ CR(a, KEYPAD_CONSOLE_IN_DEV, ConIn, KEYPAD_CONSOLE_IN_DEV_SIGNATURE)
+#define TEXT_INPUT_EX_KEYPAD_CONSOLE_IN_DEV_FROM_THIS(a) \
+ CR(a, KEYPAD_CONSOLE_IN_DEV, ConInEx, KEYPAD_CONSOLE_IN_DEV_SIGNATURE)
#define TABLE_END 0x0
-#define KEYPAD_TIMER_INTERVAL 200000 // 0.02s
+#define KEYPAD_TIMER_INTERVAL 200000 // 0.02s
//
// Driver entry point
//
/**
- The user Entry Point for module KeypadDxe. The user code starts with this function.
+ The user Entry Point for module KeypadDxe. The user code starts with this
+function.
@param[in] ImageHandle The firmware allocated handle for the EFI image.
@param[in] SystemTable A pointer to the EFI System Table.
**/
EFI_STATUS
EFIAPI
-InstallKeypadDriver (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
+InstallKeypadDriver(
+ IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable);
//
// Other functions that are used among .c files
@param Event Indicates the event that invoke this function.
@param Context Indicates the calling context.
**/
-VOID
-EFIAPI
-KeyNotifyProcessHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
- );
+VOID EFIAPI KeyNotifyProcessHandler(IN EFI_EVENT Event, IN VOID *Context);
/**
Perform 8042 controller and keypad Initialization.
@retval EFI_SUCCESS Success to init keypad
**/
EFI_STATUS
-InitKeypad (
- IN OUT KEYPAD_CONSOLE_IN_DEV *ConsoleIn,
- IN BOOLEAN ExtendedVerification
- );
+InitKeypad(
+ IN OUT KEYPAD_CONSOLE_IN_DEV *ConsoleIn, IN BOOLEAN ExtendedVerification);
/**
Timer event handler: read a series of scancodes from 8042
@param Context - A KEYPAD_CONSOLE_IN_DEV pointer
**/
-VOID
-EFIAPI
-KeypadTimerHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
- );
+VOID EFIAPI KeypadTimerHandler(IN EFI_EVENT Event, IN VOID *Context);
/**
logic reset keypad
@param This Pointer to instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL
@param ExtendedVerification Indicate that the driver may perform a more
- exhaustive verification operation of the device during
- reset, now this par is ignored in this driver
+ exhaustive verification operation of the device
+during reset, now this par is ignored in this driver
**/
EFI_STATUS
EFIAPI
-KeypadEfiReset (
- IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
- );
+KeypadEfiReset(
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, IN BOOLEAN ExtendedVerification);
/**
Implement SIMPLE_TEXT_IN.ReadKeyStroke().
**/
EFI_STATUS
EFIAPI
-KeypadReadKeyStroke (
- IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
- OUT EFI_INPUT_KEY *Key
- );
+KeypadReadKeyStroke(
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, OUT EFI_INPUT_KEY *Key);
/**
Event notification function for SIMPLE_TEXT_IN.WaitForKey event
@param Context waitting context
**/
-VOID
-EFIAPI
-KeypadWaitForKey (
- IN EFI_EVENT Event,
- IN VOID *Context
- );
+VOID EFIAPI KeypadWaitForKey(IN EFI_EVENT Event, IN VOID *Context);
/**
- Event notification function for SIMPLE_TEXT_INPUT_EX_PROTOCOL.WaitForKeyEx event
- Signal the event if there is key available
+ Event notification function for SIMPLE_TEXT_INPUT_EX_PROTOCOL.WaitForKeyEx
+event Signal the event if there is key available
@param Event event object
@param Context waiting context
**/
-VOID
-EFIAPI
-KeypadWaitForKeyEx (
- IN EFI_EVENT Event,
- IN VOID *Context
- );
+VOID EFIAPI KeypadWaitForKeyEx(IN EFI_EVENT Event, IN VOID *Context);
//
// Simple Text Input Ex protocol function prototypes
@param ExtendedVerification - Driver may perform diagnostics on reset.
@retval EFI_SUCCESS - The device was reset.
- @retval EFI_DEVICE_ERROR - The device is not functioning properly and could
- not be reset.
+ @retval EFI_DEVICE_ERROR - The device is not functioning properly and
+could not be reset.
**/
EFI_STATUS
EFIAPI
-KeypadEfiResetEx (
- IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
- );
+KeypadEfiResetEx(
+ IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification);
/**
Reads the next keystroke from the input device. The WaitForKey Event can
@param This - Protocol instance pointer.
- @param KeyData - A pointer to a buffer that is filled in with the keystroke
- state data for the key that was pressed.
+ @param KeyData - A pointer to a buffer that is filled in with the
+keystroke state data for the key that was pressed.
@retval EFI_SUCCESS - The keystroke information was returned.
@retval EFI_NOT_READY - There was no keystroke data availiable.
- @retval EFI_DEVICE_ERROR - The keystroke information was not returned due to
- hardware errors.
+ @retval EFI_DEVICE_ERROR - The keystroke information was not returned
+due to hardware errors.
@retval EFI_INVALID_PARAMETER - KeyData is NULL.
**/
EFI_STATUS
EFIAPI
-KeypadReadKeyStrokeEx (
- IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
- OUT EFI_KEY_DATA *KeyData
- );
+KeypadReadKeyStrokeEx(
+ IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, OUT EFI_KEY_DATA *KeyData);
/**
Set certain state for the input device.
state for the input device.
@retval EFI_SUCCESS - The device state was set successfully.
- @retval EFI_DEVICE_ERROR - The device is not functioning correctly and could
- not have the setting adjusted.
- @retval EFI_UNSUPPORTED - The device does not have the ability to set its state.
+ @retval EFI_DEVICE_ERROR - The device is not functioning correctly and
+could not have the setting adjusted.
+ @retval EFI_UNSUPPORTED - The device does not have the ability to set
+its state.
@retval EFI_INVALID_PARAMETER - KeyToggleState is NULL.
**/
EFI_STATUS
EFIAPI
-KeypadSetState (
- IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
- IN EFI_KEY_TOGGLE_STATE *KeyToggleState
- );
+KeypadSetState(
+ IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
+ IN EFI_KEY_TOGGLE_STATE *KeyToggleState);
/**
- Register a notification function for a particular keystroke for the input device.
+ Register a notification function for a particular keystroke for the input
+device.
@param This - Protocol instance pointer.
- @param KeyData - A pointer to a buffer that is filled in with the keystroke
- information data for the key that was pressed.
- @param KeyNotificationFunction - Points to the function to be called when the key
- sequence is typed specified by KeyData.
- @param NotifyHandle - Points to the unique handle assigned to the registered notification.
-
- @retval EFI_SUCCESS - The notification function was registered successfully.
- @retval EFI_OUT_OF_RESOURCES - Unable to allocate resources for necesssary data structures.
+ @param KeyData - A pointer to a buffer that is filled in
+with the keystroke information data for the key that was pressed.
+ @param KeyNotificationFunction - Points to the function to be called when
+the key sequence is typed specified by KeyData.
+ @param NotifyHandle - Points to the unique handle assigned to the
+registered notification.
+
+ @retval EFI_SUCCESS - The notification function was registered
+successfully.
+ @retval EFI_OUT_OF_RESOURCES - Unable to allocate resources for
+necesssary data structures.
@retval EFI_INVALID_PARAMETER - KeyData or NotifyHandle is NULL.
**/
EFI_STATUS
EFIAPI
-KeypadRegisterKeyNotify (
- IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
- IN EFI_KEY_DATA *KeyData,
- IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction,
- OUT VOID **NotifyHandle
- );
+KeypadRegisterKeyNotify(
+ IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN EFI_KEY_DATA *KeyData,
+ IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction,
+ OUT VOID **NotifyHandle);
/**
Remove a registered notification function from a particular keystroke.
@param This - Protocol instance pointer.
- @param NotificationHandle - The handle of the notification function being unregistered.
+ @param NotificationHandle - The handle of the notification function
+being unregistered.
- @retval EFI_SUCCESS - The notification function was unregistered successfully.
+ @retval EFI_SUCCESS - The notification function was unregistered
+successfully.
@retval EFI_INVALID_PARAMETER - The NotificationHandle is invalid.
- @retval EFI_NOT_FOUND - Can not find the matching entry in database.
+ @retval EFI_NOT_FOUND - Can not find the matching entry in
+database.
**/
EFI_STATUS
EFIAPI
-KeypadUnregisterKeyNotify (
- IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
- IN VOID *NotificationHandle
- );
+KeypadUnregisterKeyNotify(
+ IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN VOID *NotificationHandle);
/**
Push one key data to the EFI key buffer.
@param Queue Pointer to instance of EFI_KEY_QUEUE.
@param KeyData The key data to push.
**/
-VOID
-PushEfikeyBufTail (
- IN EFI_KEY_QUEUE *Queue,
- IN EFI_KEY_DATA *KeyData
- );
+VOID PushEfikeyBufTail(IN EFI_KEY_QUEUE *Queue, IN EFI_KEY_DATA *KeyData);
/**
Judge whether is a registed key
- @param RegsiteredData A pointer to a buffer that is filled in with the keystroke
- state data for the key that was registered.
- @param InputData A pointer to a buffer that is filled in with the keystroke
- state data for the key that was pressed.
+ @param RegsiteredData A pointer to a buffer that is filled in with the
+keystroke state data for the key that was registered.
+ @param InputData A pointer to a buffer that is filled in with the
+keystroke state data for the key that was pressed.
@retval TRUE Key be pressed matches a registered key.
@retval FLASE Match failed.
**/
BOOLEAN
-IsKeyRegistered (
- IN EFI_KEY_DATA *RegsiteredData,
- IN EFI_KEY_DATA *InputData
- );
+IsKeyRegistered(IN EFI_KEY_DATA *RegsiteredData, IN EFI_KEY_DATA *InputData);
#endif
Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
+are licensed and made available under the terms and conditions of the BSD
+License which accompanies this distribution. The full text of the license may
+be found at http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@param ErrMsg Unicode string of error message
**/
-VOID
-KeypadError (
- IN KEYPAD_CONSOLE_IN_DEV *ConsoleIn,
- IN CHAR16 *ErrMsg
- )
+VOID KeypadError(IN KEYPAD_CONSOLE_IN_DEV *ConsoleIn, IN CHAR16 *ErrMsg)
{
ConsoleIn->KeypadErr = TRUE;
}
@param Context A KEYPAD_CONSOLE_IN_DEV pointer
**/
-VOID
-EFIAPI
-KeypadTimerHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
+VOID EFIAPI KeypadTimerHandler(IN EFI_EVENT Event, IN VOID *Context)
{
- EFI_TPL OldTpl;
- KEYPAD_CONSOLE_IN_DEV *ConsoleIn;
+ EFI_TPL OldTpl;
+ KEYPAD_CONSOLE_IN_DEV *ConsoleIn;
- ConsoleIn = (KEYPAD_CONSOLE_IN_DEV *) Context;
+ ConsoleIn = (KEYPAD_CONSOLE_IN_DEV *)Context;
//
// Enter critical section
//
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+ OldTpl = gBS->RaiseTPL(TPL_NOTIFY);
- if (((KEYPAD_CONSOLE_IN_DEV *) Context)->KeypadErr) {
+ if (((KEYPAD_CONSOLE_IN_DEV *)Context)->KeypadErr) {
//
// Leave critical section and return
//
- gBS->RestoreTPL (OldTpl);
- return ;
+ gBS->RestoreTPL(OldTpl);
+ return;
}
UINT64 CurrentCounterValue = GetPerformanceCounter();
- UINT64 DeltaCounter = CurrentCounterValue - ConsoleIn->Last;
- ConsoleIn->Last = CurrentCounterValue;
+ UINT64 DeltaCounter = CurrentCounterValue - ConsoleIn->Last;
+ ConsoleIn->Last = CurrentCounterValue;
- ConsoleIn->KeypadDevice->GetKeys(ConsoleIn->KeypadDevice, &ConsoleIn->KeypadReturnApi, GetTimeInNanoSecond(DeltaCounter));
+ ConsoleIn->KeypadDevice->GetKeys(
+ ConsoleIn->KeypadDevice, &ConsoleIn->KeypadReturnApi,
+ GetTimeInNanoSecond(DeltaCounter));
//
// Leave critical section and return
//
- gBS->RestoreTPL (OldTpl);
+ gBS->RestoreTPL(OldTpl);
}
/**
@retval EFI_SUCCESS Success to init keypad
**/
EFI_STATUS
-InitKeypad (
- IN OUT KEYPAD_CONSOLE_IN_DEV *ConsoleIn,
- IN BOOLEAN ExtendedVerification
- )
+InitKeypad(
+ IN OUT KEYPAD_CONSOLE_IN_DEV *ConsoleIn, IN BOOLEAN ExtendedVerification)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
ConsoleIn->KeypadDevice->Reset(ConsoleIn->KeypadDevice);
//
// Clear Memory Scancode Buffer
//
- ConsoleIn->EfiKeyQueue.Head = 0;
- ConsoleIn->EfiKeyQueue.Tail = 0;
+ ConsoleIn->EfiKeyQueue.Head = 0;
+ ConsoleIn->EfiKeyQueue.Tail = 0;
ConsoleIn->EfiKeyQueueForNotify.Head = 0;
ConsoleIn->EfiKeyQueueForNotify.Tail = 0;
ConsoleIn->IsSupportPartialKey = FALSE;
- if (!EFI_ERROR (Status)) {
+ if (!EFI_ERROR(Status)) {
return EFI_SUCCESS;
- } else {
+ }
+ else {
return EFI_DEVICE_ERROR;
}
-
}
Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
+are licensed and made available under the terms and conditions of the BSD
+License which accompanies this distribution. The full text of the license may
+be found at http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
-
#include "Keypad.h"
/**
@retval FALSE The EFI key buffer isn't empty.
**/
BOOLEAN
-IsEfikeyBufEmpty (
- IN EFI_KEY_QUEUE *Queue
- )
+IsEfikeyBufEmpty(IN EFI_KEY_QUEUE *Queue)
{
- return (BOOLEAN) (Queue->Head == Queue->Tail);
+ return (BOOLEAN)(Queue->Head == Queue->Tail);
}
/**
@retval EFI_NOT_READY There is no key data available.
**/
EFI_STATUS
-PopEfikeyBufHead (
- IN EFI_KEY_QUEUE *Queue,
- OUT EFI_KEY_DATA *KeyData OPTIONAL
- )
+PopEfikeyBufHead(IN EFI_KEY_QUEUE *Queue, OUT EFI_KEY_DATA *KeyData OPTIONAL)
{
- if (IsEfikeyBufEmpty (Queue)) {
+ if (IsEfikeyBufEmpty(Queue)) {
return EFI_NOT_READY;
}
//
// Retrieve and remove the values
//
if (KeyData != NULL) {
- CopyMem (KeyData, &Queue->Buffer[Queue->Head], sizeof (EFI_KEY_DATA));
+ CopyMem(KeyData, &Queue->Buffer[Queue->Head], sizeof(EFI_KEY_DATA));
}
Queue->Head = (Queue->Head + 1) % KEYPAD_EFI_KEY_MAX_COUNT;
return EFI_SUCCESS;
@param Queue Pointer to instance of EFI_KEY_QUEUE.
@param KeyData The key data to push.
**/
-VOID
-PushEfikeyBufTail (
- IN EFI_KEY_QUEUE *Queue,
- IN EFI_KEY_DATA *KeyData
- )
+VOID PushEfikeyBufTail(IN EFI_KEY_QUEUE *Queue, IN EFI_KEY_DATA *KeyData)
{
if ((Queue->Tail + 1) % KEYPAD_EFI_KEY_MAX_COUNT == Queue->Head) {
//
// If Queue is full, pop the one from head.
//
- PopEfikeyBufHead (Queue, NULL);
+ PopEfikeyBufHead(Queue, NULL);
}
- CopyMem (&Queue->Buffer[Queue->Tail], KeyData, sizeof (EFI_KEY_DATA));
+ CopyMem(&Queue->Buffer[Queue->Tail], KeyData, sizeof(EFI_KEY_DATA));
Queue->Tail = (Queue->Tail + 1) % KEYPAD_EFI_KEY_MAX_COUNT;
}
/**
Judge whether is a registed key
- @param RegsiteredData A pointer to a buffer that is filled in with the keystroke
- state data for the key that was registered.
- @param InputData A pointer to a buffer that is filled in with the keystroke
- state data for the key that was pressed.
+ @param RegsiteredData A pointer to a buffer that is filled in with the
+keystroke state data for the key that was registered.
+ @param InputData A pointer to a buffer that is filled in with the
+keystroke state data for the key that was pressed.
@retval TRUE Key be pressed matches a registered key.
@retval FLASE Match failed.
**/
BOOLEAN
-IsKeyRegistered (
- IN EFI_KEY_DATA *RegsiteredData,
- IN EFI_KEY_DATA *InputData
- )
+IsKeyRegistered(IN EFI_KEY_DATA *RegsiteredData, IN EFI_KEY_DATA *InputData)
{
- ASSERT (RegsiteredData != NULL && InputData != NULL);
+ ASSERT(RegsiteredData != NULL && InputData != NULL);
- if ((RegsiteredData->Key.ScanCode != InputData->Key.ScanCode) ||
+ if ((RegsiteredData->Key.ScanCode != InputData->Key.ScanCode) ||
(RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar)) {
return FALSE;
}
//
- // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
+ // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these
+ // state could be ignored.
//
if (RegsiteredData->KeyState.KeyShiftState != 0 &&
- RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState) {
+ RegsiteredData->KeyState.KeyShiftState !=
+ InputData->KeyState.KeyShiftState) {
return FALSE;
}
if (RegsiteredData->KeyState.KeyToggleState != 0 &&
- RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState) {
+ RegsiteredData->KeyState.KeyToggleState !=
+ InputData->KeyState.KeyToggleState) {
return FALSE;
}
return TRUE;
-
}
/**
be used to test for existance of a keystroke via WaitForEvent () call.
@param ConsoleInDev Keypad private structure
- @param KeyData A pointer to a buffer that is filled in with the keystroke
- state data for the key that was pressed.
+ @param KeyData A pointer to a buffer that is filled in with
+the keystroke state data for the key that was pressed.
@retval EFI_SUCCESS The keystroke information was returned.
@retval EFI_NOT_READY There was no keystroke data availiable.
- @retval EFI_DEVICE_ERROR The keystroke information was not returned due to
- hardware errors.
+ @retval EFI_DEVICE_ERROR The keystroke information was not returned
+due to hardware errors.
@retval EFI_INVALID_PARAMETER KeyData is NULL.
**/
EFI_STATUS
-KeypadReadKeyStrokeWorker (
- IN KEYPAD_CONSOLE_IN_DEV *ConsoleInDev,
- OUT EFI_KEY_DATA *KeyData
- )
+KeypadReadKeyStrokeWorker(
+ IN KEYPAD_CONSOLE_IN_DEV *ConsoleInDev, OUT EFI_KEY_DATA *KeyData)
{
- EFI_STATUS Status;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
if (KeyData == NULL) {
return EFI_INVALID_PARAMETER;
//
// Enter critical section
//
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+ OldTpl = gBS->RaiseTPL(TPL_NOTIFY);
- KeypadTimerHandler (NULL, ConsoleInDev);
+ KeypadTimerHandler(NULL, ConsoleInDev);
if (ConsoleInDev->KeypadErr) {
Status = EFI_DEVICE_ERROR;
- } else {
- Status = PopEfikeyBufHead (&ConsoleInDev->EfiKeyQueue, KeyData);
+ }
+ else {
+ Status = PopEfikeyBufHead(&ConsoleInDev->EfiKeyQueue, KeyData);
}
- gBS->RestoreTPL (OldTpl);
+ gBS->RestoreTPL(OldTpl);
return Status;
}
/**
- Perform 8042 controller and keypad initialization which implement SIMPLE_TEXT_IN.Reset()
+ Perform 8042 controller and keypad initialization which implement
+SIMPLE_TEXT_IN.Reset()
- @param This Pointer to instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL
+ @param This Pointer to instance of
+EFI_SIMPLE_TEXT_INPUT_PROTOCOL
@param ExtendedVerification Indicate that the driver may perform a more
- exhaustive verification operation of the device during
- reset, now this par is ignored in this driver
+ exhaustive verification operation of the device
+during reset, now this par is ignored in this driver
**/
EFI_STATUS
EFIAPI
-KeypadEfiReset (
- IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
- )
+KeypadEfiReset(
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
{
- EFI_STATUS Status;
- KEYPAD_CONSOLE_IN_DEV *ConsoleIn;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ KEYPAD_CONSOLE_IN_DEV *ConsoleIn;
+ EFI_TPL OldTpl;
- ConsoleIn = KEYPAD_CONSOLE_IN_DEV_FROM_THIS (This);
+ ConsoleIn = KEYPAD_CONSOLE_IN_DEV_FROM_THIS(This);
if (ConsoleIn->KeypadErr) {
return EFI_DEVICE_ERROR;
}
//
// Enter critical section
//
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+ OldTpl = gBS->RaiseTPL(TPL_NOTIFY);
//
// Call InitKeypad to initialize the keypad
//
- Status = InitKeypad (ConsoleIn, ExtendedVerification);
- if (EFI_ERROR (Status)) {
+ Status = InitKeypad(ConsoleIn, ExtendedVerification);
+ if (EFI_ERROR(Status)) {
//
// Leave critical section and return
//
- gBS->RestoreTPL (OldTpl);
+ gBS->RestoreTPL(OldTpl);
return EFI_DEVICE_ERROR;
}
//
// Leave critical section and return
//
- gBS->RestoreTPL (OldTpl);
+ gBS->RestoreTPL(OldTpl);
return EFI_SUCCESS;
}
/**
- Retrieve key values for driver user which implement SIMPLE_TEXT_IN.ReadKeyStroke().
+ Retrieve key values for driver user which implement
+SIMPLE_TEXT_IN.ReadKeyStroke().
@param This Pointer to instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL
@param Key The output buffer for key value
**/
EFI_STATUS
EFIAPI
-KeypadReadKeyStroke (
- IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
- OUT EFI_INPUT_KEY *Key
- )
+KeypadReadKeyStroke(
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, OUT EFI_INPUT_KEY *Key)
{
- EFI_STATUS Status;
- KEYPAD_CONSOLE_IN_DEV *ConsoleIn;
- EFI_KEY_DATA KeyData;
+ EFI_STATUS Status;
+ KEYPAD_CONSOLE_IN_DEV *ConsoleIn;
+ EFI_KEY_DATA KeyData;
- ConsoleIn = KEYPAD_CONSOLE_IN_DEV_FROM_THIS (This);
+ ConsoleIn = KEYPAD_CONSOLE_IN_DEV_FROM_THIS(This);
//
// Considering if the partial keystroke is enabled, there maybe a partial
//
// If there is no pending key, then return.
//
- Status = KeypadReadKeyStrokeWorker (ConsoleIn, &KeyData);
- if (EFI_ERROR (Status)) {
+ Status = KeypadReadKeyStrokeWorker(ConsoleIn, &KeyData);
+ if (EFI_ERROR(Status)) {
return Status;
}
//
// If it is partial keystroke, skip it.
//
- if (KeyData.Key.ScanCode == SCAN_NULL && KeyData.Key.UnicodeChar == CHAR_NULL) {
+ if (KeyData.Key.ScanCode == SCAN_NULL &&
+ KeyData.Key.UnicodeChar == CHAR_NULL) {
continue;
}
//
// Translate the CTRL-Alpha characters to their corresponding control value
// (ctrl-a = 0x0001 through ctrl-Z = 0x001A)
//
- if ((KeyData.KeyState.KeyShiftState & (EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) != 0) {
+ if ((KeyData.KeyState.KeyShiftState &
+ (EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) != 0) {
if (KeyData.Key.UnicodeChar >= L'a' && KeyData.Key.UnicodeChar <= L'z') {
- KeyData.Key.UnicodeChar = (CHAR16) (KeyData.Key.UnicodeChar - L'a' + 1);
- } else if (KeyData.Key.UnicodeChar >= L'A' && KeyData.Key.UnicodeChar <= L'Z') {
- KeyData.Key.UnicodeChar = (CHAR16) (KeyData.Key.UnicodeChar - L'A' + 1);
+ KeyData.Key.UnicodeChar = (CHAR16)(KeyData.Key.UnicodeChar - L'a' + 1);
+ }
+ else if (
+ KeyData.Key.UnicodeChar >= L'A' && KeyData.Key.UnicodeChar <= L'Z') {
+ KeyData.Key.UnicodeChar = (CHAR16)(KeyData.Key.UnicodeChar - L'A' + 1);
}
}
- CopyMem (Key, &KeyData.Key, sizeof (EFI_INPUT_KEY));
+ CopyMem(Key, &KeyData.Key, sizeof(EFI_INPUT_KEY));
return EFI_SUCCESS;
}
}
@param Context waitting context
**/
-VOID
-EFIAPI
-KeypadWaitForKey (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
+VOID EFIAPI KeypadWaitForKey(IN EFI_EVENT Event, IN VOID *Context)
{
- EFI_TPL OldTpl;
- KEYPAD_CONSOLE_IN_DEV *ConsoleIn;
- EFI_KEY_DATA KeyData;
+ EFI_TPL OldTpl;
+ KEYPAD_CONSOLE_IN_DEV *ConsoleIn;
+ EFI_KEY_DATA KeyData;
- ConsoleIn = (KEYPAD_CONSOLE_IN_DEV *) Context;
+ ConsoleIn = (KEYPAD_CONSOLE_IN_DEV *)Context;
//
// Enter critical section
//
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+ OldTpl = gBS->RaiseTPL(TPL_NOTIFY);
- KeypadTimerHandler (NULL, ConsoleIn);
+ KeypadTimerHandler(NULL, ConsoleIn);
if (!ConsoleIn->KeypadErr) {
//
// keystroke in the queue, so here skip the partial keystroke and get the
// next key from the queue
//
- while (!IsEfikeyBufEmpty (&ConsoleIn->EfiKeyQueue)) {
- CopyMem (
- &KeyData,
- &(ConsoleIn->EfiKeyQueue.Buffer[ConsoleIn->EfiKeyQueue.Head]),
- sizeof (EFI_KEY_DATA)
- );
- if (KeyData.Key.ScanCode == SCAN_NULL && KeyData.Key.UnicodeChar == CHAR_NULL) {
- PopEfikeyBufHead (&ConsoleIn->EfiKeyQueue, &KeyData);
+ while (!IsEfikeyBufEmpty(&ConsoleIn->EfiKeyQueue)) {
+ CopyMem(
+ &KeyData,
+ &(ConsoleIn->EfiKeyQueue.Buffer[ConsoleIn->EfiKeyQueue.Head]),
+ sizeof(EFI_KEY_DATA));
+ if (KeyData.Key.ScanCode == SCAN_NULL &&
+ KeyData.Key.UnicodeChar == CHAR_NULL) {
+ PopEfikeyBufHead(&ConsoleIn->EfiKeyQueue, &KeyData);
continue;
}
//
// if there is pending value key, signal the event.
//
- gBS->SignalEvent (Event);
+ gBS->SignalEvent(Event);
break;
}
}
//
// Leave critical section and return
//
- gBS->RestoreTPL (OldTpl);
+ gBS->RestoreTPL(OldTpl);
}
/**
- Event notification function for SIMPLE_TEXT_INPUT_EX_PROTOCOL.WaitForKeyEx event
- Signal the event if there is key available
+ Event notification function for SIMPLE_TEXT_INPUT_EX_PROTOCOL.WaitForKeyEx
+event Signal the event if there is key available
@param Event event object
@param Context waiting context
**/
-VOID
-EFIAPI
-KeypadWaitForKeyEx (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
+VOID EFIAPI KeypadWaitForKeyEx(IN EFI_EVENT Event, IN VOID *Context)
{
- KeypadWaitForKey (Event, Context);
+ KeypadWaitForKey(Event, Context);
}
/**
@param ExtendedVerification Driver may perform diagnostics on reset.
@retval EFI_SUCCESS The device was reset.
- @retval EFI_DEVICE_ERROR The device is not functioning properly and could
- not be reset.
+ @retval EFI_DEVICE_ERROR The device is not functioning properly and
+could not be reset.
**/
EFI_STATUS
EFIAPI
-KeypadEfiResetEx (
- IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
- )
+KeypadEfiResetEx(
+ IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
{
- KEYPAD_CONSOLE_IN_DEV *ConsoleInDev;
+ KEYPAD_CONSOLE_IN_DEV *ConsoleInDev;
- ConsoleInDev = TEXT_INPUT_EX_KEYPAD_CONSOLE_IN_DEV_FROM_THIS (This);
+ ConsoleInDev = TEXT_INPUT_EX_KEYPAD_CONSOLE_IN_DEV_FROM_THIS(This);
- return ConsoleInDev->ConIn.Reset (
- &ConsoleInDev->ConIn,
- ExtendedVerification
- );
+ return ConsoleInDev->ConIn.Reset(&ConsoleInDev->ConIn, ExtendedVerification);
}
/**
@param This Protocol instance pointer.
- @param KeyData A pointer to a buffer that is filled in with the keystroke
- state data for the key that was pressed.
+ @param KeyData A pointer to a buffer that is filled in with the
+keystroke state data for the key that was pressed.
@retval EFI_SUCCESS The keystroke information was returned.
@retval EFI_NOT_READY There was no keystroke data availiable.
- @retval EFI_DEVICE_ERROR The keystroke information was not returned due to
- hardware errors.
+ @retval EFI_DEVICE_ERROR The keystroke information was not returned due
+to hardware errors.
@retval EFI_INVALID_PARAMETER KeyData is NULL.
**/
EFI_STATUS
EFIAPI
-KeypadReadKeyStrokeEx (
- IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
- OUT EFI_KEY_DATA *KeyData
- )
+KeypadReadKeyStrokeEx(
+ IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, OUT EFI_KEY_DATA *KeyData)
{
- KEYPAD_CONSOLE_IN_DEV *ConsoleInDev;
+ KEYPAD_CONSOLE_IN_DEV *ConsoleInDev;
if (KeyData == NULL) {
return EFI_INVALID_PARAMETER;
}
- ConsoleInDev = TEXT_INPUT_EX_KEYPAD_CONSOLE_IN_DEV_FROM_THIS (This);
- return KeypadReadKeyStrokeWorker (ConsoleInDev, KeyData);
+ ConsoleInDev = TEXT_INPUT_EX_KEYPAD_CONSOLE_IN_DEV_FROM_THIS(This);
+ return KeypadReadKeyStrokeWorker(ConsoleInDev, KeyData);
}
/**
state for the input device.
@retval EFI_SUCCESS The device state was set successfully.
- @retval EFI_DEVICE_ERROR The device is not functioning correctly and could
- not have the setting adjusted.
- @retval EFI_UNSUPPORTED The device does not have the ability to set its state.
+ @retval EFI_DEVICE_ERROR The device is not functioning correctly and
+could not have the setting adjusted.
+ @retval EFI_UNSUPPORTED The device does not have the ability to set its
+state.
@retval EFI_INVALID_PARAMETER KeyToggleState is NULL.
**/
EFI_STATUS
EFIAPI
-KeypadSetState (
- IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
- IN EFI_KEY_TOGGLE_STATE *KeyToggleState
- )
+KeypadSetState(
+ IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
+ IN EFI_KEY_TOGGLE_STATE *KeyToggleState)
{
- EFI_STATUS Status;
- KEYPAD_CONSOLE_IN_DEV *ConsoleInDev;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ KEYPAD_CONSOLE_IN_DEV *ConsoleInDev;
+ EFI_TPL OldTpl;
if (KeyToggleState == NULL) {
return EFI_INVALID_PARAMETER;
}
- ConsoleInDev = TEXT_INPUT_EX_KEYPAD_CONSOLE_IN_DEV_FROM_THIS (This);
+ ConsoleInDev = TEXT_INPUT_EX_KEYPAD_CONSOLE_IN_DEV_FROM_THIS(This);
//
// Enter critical section
//
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+ OldTpl = gBS->RaiseTPL(TPL_NOTIFY);
if (ConsoleInDev->KeypadErr) {
Status = EFI_DEVICE_ERROR;
//
// Leave critical section and return
//
- gBS->RestoreTPL (OldTpl);
+ gBS->RestoreTPL(OldTpl);
return Status;
-
}
/**
- Register a notification function for a particular keystroke for the input device.
+ Register a notification function for a particular keystroke for the input
+device.
@param This Protocol instance pointer.
- @param KeyData A pointer to a buffer that is filled in with the keystroke
- information data for the key that was pressed.
- @param KeyNotificationFunction Points to the function to be called when the key
- sequence is typed specified by KeyData.
- @param NotifyHandle Points to the unique handle assigned to the registered notification.
-
- @retval EFI_SUCCESS The notification function was registered successfully.
- @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data structures.
- @retval EFI_INVALID_PARAMETER KeyData or NotifyHandle or KeyNotificationFunction is NULL.
+ @param KeyData A pointer to a buffer that is filled in
+with the keystroke information data for the key that was pressed.
+ @param KeyNotificationFunction Points to the function to be called when
+the key sequence is typed specified by KeyData.
+ @param NotifyHandle Points to the unique handle assigned to
+the registered notification.
+
+ @retval EFI_SUCCESS The notification function was registered
+successfully.
+ @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for
+necesssary data structures.
+ @retval EFI_INVALID_PARAMETER KeyData or NotifyHandle or
+KeyNotificationFunction is NULL.
**/
EFI_STATUS
EFIAPI
-KeypadRegisterKeyNotify (
- IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
- IN EFI_KEY_DATA *KeyData,
- IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction,
- OUT VOID **NotifyHandle
- )
+KeypadRegisterKeyNotify(
+ IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN EFI_KEY_DATA *KeyData,
+ IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction, OUT VOID **NotifyHandle)
{
- EFI_STATUS Status;
- KEYPAD_CONSOLE_IN_DEV *ConsoleInDev;
- EFI_TPL OldTpl;
- LIST_ENTRY *Link;
- KEYPAD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
- KEYPAD_CONSOLE_IN_EX_NOTIFY *NewNotify;
-
- if (KeyData == NULL || NotifyHandle == NULL || KeyNotificationFunction == NULL) {
+ EFI_STATUS Status;
+ KEYPAD_CONSOLE_IN_DEV * ConsoleInDev;
+ EFI_TPL OldTpl;
+ LIST_ENTRY * Link;
+ KEYPAD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
+ KEYPAD_CONSOLE_IN_EX_NOTIFY *NewNotify;
+
+ if (KeyData == NULL || NotifyHandle == NULL ||
+ KeyNotificationFunction == NULL) {
return EFI_INVALID_PARAMETER;
}
- ConsoleInDev = TEXT_INPUT_EX_KEYPAD_CONSOLE_IN_DEV_FROM_THIS (This);
+ ConsoleInDev = TEXT_INPUT_EX_KEYPAD_CONSOLE_IN_DEV_FROM_THIS(This);
//
// Enter critical section
//
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+ OldTpl = gBS->RaiseTPL(TPL_NOTIFY);
//
- // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.
+ // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already
+ // registered.
//
- for (Link = ConsoleInDev->NotifyList.ForwardLink; Link != &ConsoleInDev->NotifyList; Link = Link->ForwardLink) {
- CurrentNotify = CR (
- Link,
- KEYPAD_CONSOLE_IN_EX_NOTIFY,
- NotifyEntry,
- KEYPAD_CONSOLE_IN_EX_NOTIFY_SIGNATURE
- );
- if (IsKeyRegistered (&CurrentNotify->KeyData, KeyData)) {
+ for (Link = ConsoleInDev->NotifyList.ForwardLink;
+ Link != &ConsoleInDev->NotifyList; Link = Link->ForwardLink) {
+ CurrentNotify =
+ CR(Link, KEYPAD_CONSOLE_IN_EX_NOTIFY, NotifyEntry,
+ KEYPAD_CONSOLE_IN_EX_NOTIFY_SIGNATURE);
+ if (IsKeyRegistered(&CurrentNotify->KeyData, KeyData)) {
if (CurrentNotify->KeyNotificationFn == KeyNotificationFunction) {
*NotifyHandle = CurrentNotify;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
goto Exit;
}
}
//
// Allocate resource to save the notification function
//
- NewNotify = (KEYPAD_CONSOLE_IN_EX_NOTIFY *) AllocateZeroPool (sizeof (KEYPAD_CONSOLE_IN_EX_NOTIFY));
+ NewNotify = (KEYPAD_CONSOLE_IN_EX_NOTIFY *)AllocateZeroPool(
+ sizeof(KEYPAD_CONSOLE_IN_EX_NOTIFY));
if (NewNotify == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Exit;
NewNotify->Signature = KEYPAD_CONSOLE_IN_EX_NOTIFY_SIGNATURE;
NewNotify->KeyNotificationFn = KeyNotificationFunction;
- CopyMem (&NewNotify->KeyData, KeyData, sizeof (EFI_KEY_DATA));
- InsertTailList (&ConsoleInDev->NotifyList, &NewNotify->NotifyEntry);
+ CopyMem(&NewNotify->KeyData, KeyData, sizeof(EFI_KEY_DATA));
+ InsertTailList(&ConsoleInDev->NotifyList, &NewNotify->NotifyEntry);
- *NotifyHandle = NewNotify;
- Status = EFI_SUCCESS;
+ *NotifyHandle = NewNotify;
+ Status = EFI_SUCCESS;
Exit:
//
// Leave critical section and return
//
- gBS->RestoreTPL (OldTpl);
+ gBS->RestoreTPL(OldTpl);
return Status;
-
}
/**
Remove a registered notification function from a particular keystroke.
@param This Protocol instance pointer.
- @param NotificationHandle The handle of the notification function being unregistered.
+ @param NotificationHandle The handle of the notification function
+being unregistered.
- @retval EFI_SUCCESS The notification function was unregistered successfully.
+ @retval EFI_SUCCESS The notification function was unregistered
+successfully.
@retval EFI_INVALID_PARAMETER The NotificationHandle is invalid.
**/
EFI_STATUS
EFIAPI
-KeypadUnregisterKeyNotify (
- IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
- IN VOID *NotificationHandle
- )
+KeypadUnregisterKeyNotify(
+ IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN VOID *NotificationHandle)
{
- EFI_STATUS Status;
- KEYPAD_CONSOLE_IN_DEV *ConsoleInDev;
- EFI_TPL OldTpl;
- LIST_ENTRY *Link;
- KEYPAD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
+ EFI_STATUS Status;
+ KEYPAD_CONSOLE_IN_DEV * ConsoleInDev;
+ EFI_TPL OldTpl;
+ LIST_ENTRY * Link;
+ KEYPAD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
if (NotificationHandle == NULL) {
return EFI_INVALID_PARAMETER;
}
- ConsoleInDev = TEXT_INPUT_EX_KEYPAD_CONSOLE_IN_DEV_FROM_THIS (This);
+ ConsoleInDev = TEXT_INPUT_EX_KEYPAD_CONSOLE_IN_DEV_FROM_THIS(This);
//
// Enter critical section
//
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+ OldTpl = gBS->RaiseTPL(TPL_NOTIFY);
- for (Link = ConsoleInDev->NotifyList.ForwardLink; Link != &ConsoleInDev->NotifyList; Link = Link->ForwardLink) {
- CurrentNotify = CR (
- Link,
- KEYPAD_CONSOLE_IN_EX_NOTIFY,
- NotifyEntry,
- KEYPAD_CONSOLE_IN_EX_NOTIFY_SIGNATURE
- );
+ for (Link = ConsoleInDev->NotifyList.ForwardLink;
+ Link != &ConsoleInDev->NotifyList; Link = Link->ForwardLink) {
+ CurrentNotify =
+ CR(Link, KEYPAD_CONSOLE_IN_EX_NOTIFY, NotifyEntry,
+ KEYPAD_CONSOLE_IN_EX_NOTIFY_SIGNATURE);
if (CurrentNotify == NotificationHandle) {
//
// Remove the notification function from NotifyList and free resources
//
- RemoveEntryList (&CurrentNotify->NotifyEntry);
+ RemoveEntryList(&CurrentNotify->NotifyEntry);
- gBS->FreePool (CurrentNotify);
+ gBS->FreePool(CurrentNotify);
Status = EFI_SUCCESS;
goto Exit;
}
//
// Leave critical section and return
//
- gBS->RestoreTPL (OldTpl);
+ gBS->RestoreTPL(OldTpl);
return Status;
}
@param Event Indicates the event that invoke this function.
@param Context Indicates the calling context.
**/
-VOID
-EFIAPI
-KeyNotifyProcessHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
+VOID EFIAPI KeyNotifyProcessHandler(IN EFI_EVENT Event, IN VOID *Context)
{
- EFI_STATUS Status;
- KEYPAD_CONSOLE_IN_DEV *ConsoleIn;
- EFI_KEY_DATA KeyData;
- LIST_ENTRY *Link;
- LIST_ENTRY *NotifyList;
- KEYPAD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ KEYPAD_CONSOLE_IN_DEV * ConsoleIn;
+ EFI_KEY_DATA KeyData;
+ LIST_ENTRY * Link;
+ LIST_ENTRY * NotifyList;
+ KEYPAD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
+ EFI_TPL OldTpl;
- ConsoleIn = (KEYPAD_CONSOLE_IN_DEV *) Context;
+ ConsoleIn = (KEYPAD_CONSOLE_IN_DEV *)Context;
//
// Invoke notification functions.
while (TRUE) {
//
// Enter critical section
- //
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
- Status = PopEfikeyBufHead (&ConsoleIn->EfiKeyQueueForNotify, &KeyData);
+ //
+ OldTpl = gBS->RaiseTPL(TPL_NOTIFY);
+ Status = PopEfikeyBufHead(&ConsoleIn->EfiKeyQueueForNotify, &KeyData);
//
// Leave critical section
//
- gBS->RestoreTPL (OldTpl);
- if (EFI_ERROR (Status)) {
+ gBS->RestoreTPL(OldTpl);
+ if (EFI_ERROR(Status)) {
break;
}
- for (Link = GetFirstNode (NotifyList); !IsNull (NotifyList, Link); Link = GetNextNode (NotifyList, Link)) {
- CurrentNotify = CR (Link, KEYPAD_CONSOLE_IN_EX_NOTIFY, NotifyEntry, KEYPAD_CONSOLE_IN_EX_NOTIFY_SIGNATURE);
- if (IsKeyRegistered (&CurrentNotify->KeyData, &KeyData)) {
- CurrentNotify->KeyNotificationFn (&KeyData);
+ for (Link = GetFirstNode(NotifyList); !IsNull(NotifyList, Link);
+ Link = GetNextNode(NotifyList, Link)) {
+ CurrentNotify =
+ CR(Link, KEYPAD_CONSOLE_IN_EX_NOTIFY, NotifyEntry,
+ KEYPAD_CONSOLE_IN_EX_NOTIFY_SIGNATURE);
+ if (IsKeyRegistered(&CurrentNotify->KeyData, &KeyData)) {
+ CurrentNotify->KeyNotificationFn(&KeyData);
}
}
}
}
-
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/
*/
-
+
#include "crc32.h"
#include <Library/UefiLib.h>
-EFI_STATUS FixGptCRC32(EFI_BLOCK_IO_PROTOCOL *mBlockIoProtocol,
- EFI_DISK_IO_PROTOCOL *mDiskIoProtocol,
- EFI_SYSTEM_TABLE *mSystemTable){
- EFI_STATUS status;
- UINT32 mMediaId;
- UINT32 mBlockSize;
- mMediaId = mBlockIoProtocol->Media->MediaId;
- mBlockSize = mBlockIoProtocol->Media->BlockSize;
- unsigned char crc32_header[GPT_CRC32_LEN];
- unsigned char crc32_entry[GPT_CRC32_LEN];
- unsigned char *bufGptHeader;
- unsigned char *bufGptEntry;
- // try to allocate pool for bufGptEntry
- status = mSystemTable->BootServices->AllocatePool(EfiBootServicesCode, GPT_ENTRY_COUNT * mBlockSize, (VOID**)&bufGptEntry);
- if (EFI_ERROR(status)) {
- return status;
- }
- // read gpt entry list
- status = mDiskIoProtocol->ReadDisk(mDiskIoProtocol,
- mMediaId,
- 2 * mBlockSize,
- GPT_ENTRY_COUNT * mBlockSize,
- bufGptEntry);
+EFI_STATUS FixGptCRC32(
+ EFI_BLOCK_IO_PROTOCOL *mBlockIoProtocol,
+ EFI_DISK_IO_PROTOCOL *mDiskIoProtocol, EFI_SYSTEM_TABLE *mSystemTable)
+{
+ EFI_STATUS status;
+ UINT32 mMediaId;
+ UINT32 mBlockSize;
+ mMediaId = mBlockIoProtocol->Media->MediaId;
+ mBlockSize = mBlockIoProtocol->Media->BlockSize;
+ unsigned char crc32_header[GPT_CRC32_LEN];
+ unsigned char crc32_entry[GPT_CRC32_LEN];
+ unsigned char *bufGptHeader;
+ unsigned char *bufGptEntry;
+ // try to allocate pool for bufGptEntry
+ status = mSystemTable->BootServices->AllocatePool(
+ EfiBootServicesCode, GPT_ENTRY_COUNT * mBlockSize, (VOID **)&bufGptEntry);
+ if (EFI_ERROR(status)) {
+ return status;
+ }
+ // read gpt entry list
+ status = mDiskIoProtocol->ReadDisk(
+ mDiskIoProtocol, mMediaId, 2 * mBlockSize, GPT_ENTRY_COUNT * mBlockSize,
+ bufGptEntry);
- if (EFI_ERROR(status))
- return status;
- // get gpt entry crc32 value
- get_result_array(calculate_crc32(bufGptEntry, GPT_ENTRY_COUNT * mBlockSize), crc32_entry);
-
- // write gpt entry crc32 value to disk
- status = mDiskIoProtocol->WriteDisk(mDiskIoProtocol,
- mMediaId,
- mBlockSize + GPT_ENTRY_CRC32_LBA1_OFFSET,
- GPT_CRC32_LEN,
- crc32_entry);
- if (EFI_ERROR(status))
- return status;
- // try to release bufGptEntry
- status = mSystemTable->BootServices->FreePool(bufGptEntry);
- if (EFI_ERROR(status)) {
- return status;
- }
- // try to allocate pool for bufGptHeader
- status = mSystemTable->BootServices->AllocatePool(EfiBootServicesCode, GPT_HEADER_SIZE, (VOID**)&bufGptHeader);
- // get gpt header
- status = mDiskIoProtocol->ReadDisk(mDiskIoProtocol,
- mMediaId,
- mBlockSize,
- GPT_HEADER_SIZE,
- bufGptHeader);
- if (EFI_ERROR(status))
- return status;
- // set previous crc32 value to 0x00
- for (int i = GPT_HEADER_CRC32_LBA1_OFFSET; i < GPT_HEADER_CRC32_LBA1_OFFSET + GPT_CRC32_LEN; i++) {
- bufGptHeader[i] = 0x00;
- }
- // get gpt header crc32 value
- get_result_array(calculate_crc32(bufGptHeader, GPT_HEADER_SIZE), crc32_header);
- // write gpt header crc32 value to disk
- status = mDiskIoProtocol->WriteDisk(mDiskIoProtocol,
- mMediaId,
- mBlockSize + GPT_HEADER_CRC32_LBA1_OFFSET,
- GPT_CRC32_LEN,
- crc32_header);
- if (EFI_ERROR(status))
- return status;
- // try to release bufGptHeader
- status = mSystemTable->BootServices->FreePool(bufGptHeader);
- if (EFI_ERROR(status)) {
- return status;
- }
- return EFI_SUCCESS;
+ if (EFI_ERROR(status))
+ return status;
+ // get gpt entry crc32 value
+ get_result_array(
+ calculate_crc32(bufGptEntry, GPT_ENTRY_COUNT * mBlockSize), crc32_entry);
+
+ // write gpt entry crc32 value to disk
+ status = mDiskIoProtocol->WriteDisk(
+ mDiskIoProtocol, mMediaId, mBlockSize + GPT_ENTRY_CRC32_LBA1_OFFSET,
+ GPT_CRC32_LEN, crc32_entry);
+ if (EFI_ERROR(status))
+ return status;
+ // try to release bufGptEntry
+ status = mSystemTable->BootServices->FreePool(bufGptEntry);
+ if (EFI_ERROR(status)) {
+ return status;
+ }
+ // try to allocate pool for bufGptHeader
+ status = mSystemTable->BootServices->AllocatePool(
+ EfiBootServicesCode, GPT_HEADER_SIZE, (VOID **)&bufGptHeader);
+ // get gpt header
+ status = mDiskIoProtocol->ReadDisk(
+ mDiskIoProtocol, mMediaId, mBlockSize, GPT_HEADER_SIZE, bufGptHeader);
+ if (EFI_ERROR(status))
+ return status;
+ // set previous crc32 value to 0x00
+ for (int i = GPT_HEADER_CRC32_LBA1_OFFSET;
+ i < GPT_HEADER_CRC32_LBA1_OFFSET + GPT_CRC32_LEN; i++) {
+ bufGptHeader[i] = 0x00;
+ }
+ // get gpt header crc32 value
+ get_result_array(
+ calculate_crc32(bufGptHeader, GPT_HEADER_SIZE), crc32_header);
+ // write gpt header crc32 value to disk
+ status = mDiskIoProtocol->WriteDisk(
+ mDiskIoProtocol, mMediaId, mBlockSize + GPT_HEADER_CRC32_LBA1_OFFSET,
+ GPT_CRC32_LEN, crc32_header);
+ if (EFI_ERROR(status))
+ return status;
+ // try to release bufGptHeader
+ status = mSystemTable->BootServices->FreePool(bufGptHeader);
+ if (EFI_ERROR(status)) {
+ return status;
+ }
+ return EFI_SUCCESS;
}
/*
-* A8h reflected is 15h, i.e. 10101000 <--> 00010101
-*/
+ * A8h reflected is 15h, i.e. 10101000 <--> 00010101
+ */
int reflect(int data, int len)
{
- int ref = 0;
-
- for (int i = 0; i < len; i++) {
- if (data & 0x1) {
- ref |= (1 << ((len - 1) - i));
- }
- data = (data >> 1);
- }
-
- return ref;
+ int ref = 0;
+
+ for (int i = 0; i < len; i++) {
+ if (data & 0x1) {
+ ref |= (1 << ((len - 1) - i));
+ }
+ data = (data >> 1);
+ }
+
+ return ref;
}
-
+
/*
-* Function to calculate the CRC32
-*/
+ * Function to calculate the CRC32
+ */
unsigned int calculate_crc32(unsigned char *buffer, int len)
{
- int byte_length = 8; /*length of unit (i.e. byte) */
- int msb = 0;
- int polynomial = 0x04C11DB7; /* IEEE 32bit polynomial */
- unsigned int regs = 0xFFFFFFFF; /* init to all ones */
- int regs_mask = 0xFFFFFFFF; /* ensure only 32 bit answer */
- int regs_msb = 0;
- unsigned int reflected_regs;
-
- for (int i = 0; i < len; i++) {
- int data_byte = buffer[i];
- data_byte = reflect(data_byte, 8);
- for (int j = 0; j < byte_length; j++) {
- msb = data_byte >> (byte_length - 1); /* get MSB */
- msb &= 1; /* ensure just 1 bit */
- regs_msb = (regs >> 31) & 1; /* MSB of regs */
- regs = regs << 1; /* shift regs for CRC-CCITT */
- if (regs_msb ^ msb) { /* MSB is a 1 */
- regs = regs ^ polynomial; /* XOR with generator poly */
- }
- regs = regs & regs_mask; /* Mask off excess upper bits */
- data_byte <<= 1; /* get to next bit */
- }
- }
- regs = regs & regs_mask;
- reflected_regs = reflect(regs, 32) ^ 0xFFFFFFFF;
-
- return reflected_regs;
+ int byte_length = 8; /*length of unit (i.e. byte) */
+ int msb = 0;
+ int polynomial = 0x04C11DB7; /* IEEE 32bit polynomial */
+ unsigned int regs = 0xFFFFFFFF; /* init to all ones */
+ int regs_mask = 0xFFFFFFFF; /* ensure only 32 bit answer */
+ int regs_msb = 0;
+ unsigned int reflected_regs;
+
+ for (int i = 0; i < len; i++) {
+ int data_byte = buffer[i];
+ data_byte = reflect(data_byte, 8);
+ for (int j = 0; j < byte_length; j++) {
+ msb = data_byte >> (byte_length - 1); /* get MSB */
+ msb &= 1; /* ensure just 1 bit */
+ regs_msb = (regs >> 31) & 1; /* MSB of regs */
+ regs = regs << 1; /* shift regs for CRC-CCITT */
+ if (regs_msb ^ msb) { /* MSB is a 1 */
+ regs = regs ^ polynomial; /* XOR with generator poly */
+ }
+ regs = regs & regs_mask; /* Mask off excess upper bits */
+ data_byte <<= 1; /* get to next bit */
+ }
+ }
+ regs = regs & regs_mask;
+ reflected_regs = reflect(regs, 32) ^ 0xFFFFFFFF;
+
+ return reflected_regs;
}
// Convert Function
-//unsigned char** convert(unsigned int reflected_regs, int *size)
-void get_result_array(unsigned int reflected_regs, unsigned char * res)
+// unsigned char** convert(unsigned int reflected_regs, int *size)
+void get_result_array(unsigned int reflected_regs, unsigned char *res)
{
- for (int i = 0; i < 4; i++) {
- res[i] = reflected_regs & 0xff;
- reflected_regs >>= 8;
- }
-
+ for (int i = 0; i < 4; i++) {
+ res[i] = reflected_regs & 0xff;
+ reflected_regs >>= 8;
+ }
}
int reflect(int, int);
-unsigned int calculate_crc32(unsigned char*, int);
+unsigned int calculate_crc32(unsigned char *, int);
-void get_result_array(unsigned int, unsigned char*);
+void get_result_array(unsigned int, unsigned char *);
-EFI_STATUS FixGptCRC32(EFI_BLOCK_IO_PROTOCOL*, EFI_DISK_IO_PROTOCOL*, EFI_SYSTEM_TABLE*);
+EFI_STATUS FixGptCRC32(
+ EFI_BLOCK_IO_PROTOCOL *, EFI_DISK_IO_PROTOCOL *, EFI_SYSTEM_TABLE *);
* along with this program. If not, see <https://www.gnu.org/licenses/
*/
-#include <Uefi.h>
-#include <Library/UefiLib.h>
-#include <Protocol/DiskIo.h>
-#include <Protocol/BlockIo.h>
#include "slot.h"
#include "crc32.h"
+#include <Library/UefiLib.h>
+#include <Protocol/BlockIo.h>
+#include <Protocol/DiskIo.h>
+#include <Uefi.h>
void WaitAnyKey(EFI_SYSTEM_TABLE *mSystemTable);
-EFI_STATUS EFIAPI SlotMain(IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable)
+EFI_STATUS EFIAPI
+SlotMain(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
{
- EFI_STATUS status;
- EFI_HANDLE *controllerHandles = NULL;
- UINTN handleIndex, numHandles;
- EFI_DISK_IO_PROTOCOL *mDiskIoProtocol = NULL;
- EFI_BLOCK_IO_PROTOCOL *mBlockIoProtocol = NULL;
- UINT32 mMediaId;
- UINT32 mBlockSize;
- int index;
- unsigned char currentSlotA[OP6T_SLOT_FLAG_SIZE];
- unsigned char currentSlotB[OP6T_SLOT_FLAG_SIZE];
- // list all Handles that installed DiskIoProtocol
- status = SystemTable->BootServices->LocateHandleBuffer(ByProtocol,
- &gEfiDiskIoProtocolGuid,
- NULL,
- &numHandles,
- &controllerHandles);
+ EFI_STATUS status;
+ EFI_HANDLE * controllerHandles = NULL;
+ UINTN handleIndex, numHandles;
+ EFI_DISK_IO_PROTOCOL * mDiskIoProtocol = NULL;
+ EFI_BLOCK_IO_PROTOCOL *mBlockIoProtocol = NULL;
+ UINT32 mMediaId;
+ UINT32 mBlockSize;
+ int index;
+ unsigned char currentSlotA[OP6T_SLOT_FLAG_SIZE];
+ unsigned char currentSlotB[OP6T_SLOT_FLAG_SIZE];
+ // list all Handles that installed DiskIoProtocol
+ status = SystemTable->BootServices->LocateHandleBuffer(
+ ByProtocol, &gEfiDiskIoProtocolGuid, NULL, &numHandles,
+ &controllerHandles);
+ if (EFI_ERROR(status)) {
+ // WaitAnyKey(SystemTable);
+ return status;
+ }
+ // ergodic the handles
+ for (handleIndex = 0; handleIndex < numHandles; handleIndex++) {
+ // open DiskIoProtocol on target handle
+ status = SystemTable->BootServices->HandleProtocol(
+ controllerHandles[handleIndex], &gEfiDiskIoProtocolGuid,
+ (VOID **)&mDiskIoProtocol);
+ unsigned char slotNameBuffer[OP6T_SLOT_BOOT_BUFFER_LEN];
+ if (EFI_ERROR(status))
+ continue;
+ // open BlockIoProtocol on target handle
+ status = SystemTable->BootServices->HandleProtocol(
+ controllerHandles[handleIndex], &gEfiBlockIoProtocolGuid,
+ (VOID **)&mBlockIoProtocol);
if (EFI_ERROR(status)) {
- //WaitAnyKey(SystemTable);
- return status;
+ continue;
}
- // ergodic the handles
- for (handleIndex = 0; handleIndex < numHandles; handleIndex++) {
- // open DiskIoProtocol on target handle
- status = SystemTable->BootServices->HandleProtocol(
- controllerHandles[handleIndex],
- &gEfiDiskIoProtocolGuid,
- (VOID**)&mDiskIoProtocol);
- unsigned char slotNameBuffer[OP6T_SLOT_BOOT_BUFFER_LEN];
- if (EFI_ERROR(status))
- continue;
- // open BlockIoProtocol on target handle
- status = SystemTable->BootServices->HandleProtocol(
- controllerHandles[handleIndex],
- &gEfiBlockIoProtocolGuid,
- (VOID**)&mBlockIoProtocol);
- if (EFI_ERROR(status)) {
- continue;
- } else {
- // filter disk device by LogicalPartition
- if (mBlockIoProtocol->Media->LogicalPartition)
- continue;
- SystemTable->ConOut->OutputString(SystemTable->ConOut, L"The media is disk.\n");
- mMediaId = mBlockIoProtocol->Media->MediaId;
- mBlockSize = mBlockIoProtocol->Media->BlockSize;
- // read buffers from disk
- status = mDiskIoProtocol->ReadDisk(
- mDiskIoProtocol,
- mMediaId,
- 2 * mBlockSize + OP6T_SLOT_A_BOOT_BUFFER_LBA2_OFFSET,
- OP6T_SLOT_BOOT_BUFFER_LEN,
- slotNameBuffer);
- if (EFI_ERROR(status))
- continue;
- // filter disk device by the name of boot partition
- int i = 0;
- for (index = 0; index < OP6T_SLOT_BOOT_BUFFER_LEN; index++) {
- if (slotNameBuffer[index] != OP6T_SLOT_A_BOOT_BUFFER[index]) {
- i = 1;
- break;
- }
- }
- if (i == 1)
- continue;
- SystemTable->ConOut->OutputString(SystemTable->ConOut, L"The name of target partition is matched.\n");
- // read flag of slot A
- status = mDiskIoProtocol->ReadDisk(
- mDiskIoProtocol,
- mMediaId,
- 2 * mBlockSize + OP6T_SLOT_A_BOOT_FLAG_LBA2_OFFSET,
- OP6T_SLOT_FLAG_SIZE,
- currentSlotA);
- if (EFI_ERROR(status))
- return status;
- // read flag of slot B
- status = mDiskIoProtocol->ReadDisk(
- mDiskIoProtocol,
- mMediaId,
- 3 * mBlockSize + OP6T_SLOT_B_BOOT_FLAG_LBA3_OFFSET,
- OP6T_SLOT_FLAG_SIZE,
- currentSlotB);
- if (EFI_ERROR(status))
- return status;
-
- // analyze A/B flags
- int flag_offset = 0;
- if (currentSlotA[0] == OP6T_SLOT_FLAG_ACTIVE)
- return EFI_SUCCESS;
- else if (currentSlotA[0] == OP6T_SLOT_FLAG_UNBOOTABLE)
- if (currentSlotB[0] == OP6T_SLOT_FLAG_ACTIVE)
- return EFI_SUCCESS;
- else if (currentSlotB[0] == OP6T_SLOT_FLAG_UNBOOTABLE)
- flag_offset = 2 * mBlockSize + OP6T_SLOT_A_BOOT_FLAG_LBA2_OFFSET;
- else
- flag_offset = 3 * mBlockSize + OP6T_SLOT_B_BOOT_FLAG_LBA3_OFFSET;
- else
- flag_offset = 2 * mBlockSize + OP6T_SLOT_A_BOOT_FLAG_LBA2_OFFSET;
-
-
- // write flag into disk
- unsigned char f[1] = {OP6T_SLOT_FLAG_ACTIVE};
- status = mDiskIoProtocol->WriteDisk(
- mDiskIoProtocol,
- mMediaId,
- flag_offset,
- OP6T_SLOT_FLAG_SIZE,
- f);
- if (EFI_ERROR(status)) {
- SystemTable->ConOut->OutputString(SystemTable->ConOut, L"Failed to write flag into disk.\n");
- continue;
- } else {
- SystemTable->ConOut->OutputString(SystemTable->ConOut, L"Succeed to write flag into disk.\n");
- break;
- }
+ else {
+ // filter disk device by LogicalPartition
+ if (mBlockIoProtocol->Media->LogicalPartition)
+ continue;
+ SystemTable->ConOut->OutputString(
+ SystemTable->ConOut, L"The media is disk.\n");
+ mMediaId = mBlockIoProtocol->Media->MediaId;
+ mBlockSize = mBlockIoProtocol->Media->BlockSize;
+ // read buffers from disk
+ status = mDiskIoProtocol->ReadDisk(
+ mDiskIoProtocol, mMediaId,
+ 2 * mBlockSize + OP6T_SLOT_A_BOOT_BUFFER_LBA2_OFFSET,
+ OP6T_SLOT_BOOT_BUFFER_LEN, slotNameBuffer);
+ if (EFI_ERROR(status))
+ continue;
+ // filter disk device by the name of boot partition
+ int i = 0;
+ for (index = 0; index < OP6T_SLOT_BOOT_BUFFER_LEN; index++) {
+ if (slotNameBuffer[index] != OP6T_SLOT_A_BOOT_BUFFER[index]) {
+ i = 1;
+ break;
}
- }
- //try to fix gpt crc32
- if (mBlockIoProtocol != NULL) {
- status = (FixGptCRC32(mBlockIoProtocol, mDiskIoProtocol, SystemTable));
- if (EFI_ERROR(status))
- SystemTable->ConOut->OutputString(SystemTable->ConOut, L"Failed to fix CRC32 value.\n");
+ }
+ if (i == 1)
+ continue;
+ SystemTable->ConOut->OutputString(
+ SystemTable->ConOut, L"The name of target partition is matched.\n");
+ // read flag of slot A
+ status = mDiskIoProtocol->ReadDisk(
+ mDiskIoProtocol, mMediaId,
+ 2 * mBlockSize + OP6T_SLOT_A_BOOT_FLAG_LBA2_OFFSET,
+ OP6T_SLOT_FLAG_SIZE, currentSlotA);
+ if (EFI_ERROR(status))
+ return status;
+ // read flag of slot B
+ status = mDiskIoProtocol->ReadDisk(
+ mDiskIoProtocol, mMediaId,
+ 3 * mBlockSize + OP6T_SLOT_B_BOOT_FLAG_LBA3_OFFSET,
+ OP6T_SLOT_FLAG_SIZE, currentSlotB);
+ if (EFI_ERROR(status))
+ return status;
+
+ // analyze A/B flags
+ int flag_offset = 0;
+ if (currentSlotA[0] == OP6T_SLOT_FLAG_ACTIVE)
+ return EFI_SUCCESS;
+ else if (currentSlotA[0] == OP6T_SLOT_FLAG_UNBOOTABLE)
+ if (currentSlotB[0] == OP6T_SLOT_FLAG_ACTIVE)
+ return EFI_SUCCESS;
+ else if (currentSlotB[0] == OP6T_SLOT_FLAG_UNBOOTABLE)
+ flag_offset = 2 * mBlockSize + OP6T_SLOT_A_BOOT_FLAG_LBA2_OFFSET;
else
- SystemTable->ConOut->OutputString(SystemTable->ConOut, L"Succeed to fix CRC32 value.\n");
+ flag_offset = 3 * mBlockSize + OP6T_SLOT_B_BOOT_FLAG_LBA3_OFFSET;
+ else
+ flag_offset = 2 * mBlockSize + OP6T_SLOT_A_BOOT_FLAG_LBA2_OFFSET;
+
+ // write flag into disk
+ unsigned char f[1] = {OP6T_SLOT_FLAG_ACTIVE};
+ status = mDiskIoProtocol->WriteDisk(
+ mDiskIoProtocol, mMediaId, flag_offset, OP6T_SLOT_FLAG_SIZE, f);
+ if (EFI_ERROR(status)) {
+ SystemTable->ConOut->OutputString(
+ SystemTable->ConOut, L"Failed to write flag into disk.\n");
+ continue;
+ }
+ else {
+ SystemTable->ConOut->OutputString(
+ SystemTable->ConOut, L"Succeed to write flag into disk.\n");
+ break;
+ }
}
+ }
+ // try to fix gpt crc32
+ if (mBlockIoProtocol != NULL) {
+ status = (FixGptCRC32(mBlockIoProtocol, mDiskIoProtocol, SystemTable));
+ if (EFI_ERROR(status))
+ SystemTable->ConOut->OutputString(
+ SystemTable->ConOut, L"Failed to fix CRC32 value.\n");
+ else
+ SystemTable->ConOut->OutputString(
+ SystemTable->ConOut, L"Succeed to fix CRC32 value.\n");
+ }
- // release memory
- if (controllerHandles != NULL)
- SystemTable->BootServices->FreePool(controllerHandles);
- //WaitAnyKey(SystemTable);
- return EFI_SUCCESS;
+ // release memory
+ if (controllerHandles != NULL)
+ SystemTable->BootServices->FreePool(controllerHandles);
+ // WaitAnyKey(SystemTable);
+ return EFI_SUCCESS;
}
-void WaitAnyKey(EFI_SYSTEM_TABLE *mSystemTable) {
- UINTN index = 0;
- EFI_INPUT_KEY Key;
- mSystemTable->BootServices->WaitForEvent(1, &mSystemTable->ConIn->WaitForKey, &index);
- mSystemTable->ConIn->ReadKeyStroke(mSystemTable->ConIn, &Key);
+void WaitAnyKey(EFI_SYSTEM_TABLE *mSystemTable)
+{
+ UINTN index = 0;
+ EFI_INPUT_KEY Key;
+ mSystemTable->BootServices->WaitForEvent(
+ 1, &mSystemTable->ConIn->WaitForKey, &index);
+ mSystemTable->ConIn->ReadKeyStroke(mSystemTable->ConIn, &Key);
}
-
* along with this program. If not, see <https://www.gnu.org/licenses/
*/
-/*
-* Flags of OP6T slots
-*/
+/*
+ * Flags of OP6T slots
+ */
const unsigned char OP6T_SLOT_FLAG_ACTIVE = 0x6F;
const unsigned OP6T_SLOT_FLAG_BOOTABLE_7 = 0x37;
-const unsigned OP6T_SLOT_FLAG_BOOTABLE = 0x37; /* defaultly set bootable the same as bootable_7 */
+const unsigned OP6T_SLOT_FLAG_BOOTABLE =
+ 0x37; /* defaultly set bootable the same as bootable_7 */
const unsigned OP6T_SLOT_FLAG_UNBOOTABLE = 0xBA;
-// const unsigned OP6T_SLOT_FLAG_SUCCESSFUL = 0xFF; /* OP6T_SLOT_FLAG_SUCCESSFUL maybe uncorrect in this file */
+// const unsigned OP6T_SLOT_FLAG_SUCCESSFUL = 0xFF; /* OP6T_SLOT_FLAG_SUCCESSFUL
+// maybe uncorrect in this file */
#define OP6T_SLOT_FLAG_SIZE 1
/*
-* Flag's offset on disk
-* The offset may very from device to device
-* Make sure the offset is correct before using it
-*/
+ * Flag's offset on disk
+ * The offset may very from device to device
+ * Make sure the offset is correct before using it
+ */
#define OP6T_SLOT_A_BOOT_FLAG_LBA2_OFFSET 0x536
#define OP6T_SLOT_B_BOOT_FLAG_LBA3_OFFSET 0x336
/*
-* Boot partitions name and their offsets
-* Find the right device by comparaing the partition name on the offset
-*/
+ * Boot partitions name and their offsets
+ * Find the right device by comparaing the partition name on the offset
+ */
-const unsigned char OP6T_SLOT_A_BOOT_BUFFER[] = {0x62, 0x00, 0x6F, 0x00, 0x6F,
- 0x00, 0x74, 0x00, 0x5F, 0x00, 0x61}; /* ACSII: b.o.o.t._.a */
+const unsigned char OP6T_SLOT_A_BOOT_BUFFER[] = {
+ 0x62, 0x00, 0x6F, 0x00, 0x6F, 0x00,
+ 0x74, 0x00, 0x5F, 0x00, 0x61}; /* ACSII: b.o.o.t._.a */
-const unsigned char OP6T_SLOT_B_BOOT_BUFFER[] = {0x62, 0x00, 0x6F, 0x00, 0x6F,
- 0x00, 0x74, 0x00, 0x5F, 0x00, 0x62}; /* ACSII: b.o.o.t._.b */
+const unsigned char OP6T_SLOT_B_BOOT_BUFFER[] = {
+ 0x62, 0x00, 0x6F, 0x00, 0x6F, 0x00,
+ 0x74, 0x00, 0x5F, 0x00, 0x62}; /* ACSII: b.o.o.t._.b */
#define OP6T_SLOT_BOOT_BUFFER_LEN 11
#define OP6T_SLOT_A_BOOT_BUFFER_LBA2_OFFSET 0x538
#define OP6T_SLOT_B_BOOT_BUFFER_LBA3_OFFSET 0x338
-
**/\r
\r
#include <Base.h>\r
-#include <IndustryStandard/SmBios.h>\r
-#include <Protocol/Smbios.h>\r
#include <Guid/SmBios.h>\r
+#include <IndustryStandard/SmBios.h>\r
#include <Library/ArmLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/UefiLib.h>\r
#include <Library/BaseLib.h>\r
-#include <Library/PcdLib.h>\r
#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugLib.h>\r
#include <Library/MemoryAllocationLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/PrintLib.h>\r
#include <Library/TimeBaseLib.h>\r
#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiLib.h>\r
#include <Library/UefiRuntimeServicesTableLib.h>\r
-#include <Library/PrintLib.h>\r
+#include <Protocol/Smbios.h>\r
\r
/***********************************************************************\r
SMBIOS data definition TYPE0 BIOS Information\r
************************************************************************/\r
SMBIOS_TABLE_TYPE0 mBIOSInfoType0 = {\r
- { EFI_SMBIOS_TYPE_BIOS_INFORMATION, sizeof (SMBIOS_TABLE_TYPE0), 0 },\r
- 1, // Vendor String\r
- 2, // BiosVersion String\r
- 0xE800, // BiosSegment\r
- 3, // BiosReleaseDate String\r
- 0, // BiosSize (in 64KB)\r
- { // BiosCharacteristics\r
- 0, // Reserved :2; ///< Bits 0-1.\r
- 0, // Unknown :1;\r
- 0, // BiosCharacteristicsNotSupported :1;\r
- 0, // IsaIsSupported :1;\r
- 0, // McaIsSupported :1;\r
- 0, // EisaIsSupported :1;\r
- 1, // PciIsSupported :1; /// No PCIe support since we hide ECAM from the OS\r
- 0, // PcmciaIsSupported :1;\r
- 1, // PlugAndPlayIsSupported :1;\r
- 0, // ApmIsSupported :1;\r
- 1, // BiosIsUpgradable :1;\r
- 0, // BiosShadowingAllowed :1;\r
- 0, // VlVesaIsSupported :1;\r
- 0, // EscdSupportIsAvailable :1;\r
- 0, // BootFromCdIsSupported :1;\r
- 1, // SelectableBootIsSupported :1;\r
- 0, // RomBiosIsSocketed :1;\r
- 0, // BootFromPcmciaIsSupported :1;\r
- 0, // EDDSpecificationIsSupported :1;\r
- 0, // JapaneseNecFloppyIsSupported :1;\r
- 0, // JapaneseToshibaFloppyIsSupported :1;\r
- 0, // Floppy525_360IsSupported :1;\r
- 0, // Floppy525_12IsSupported :1;\r
- 0, // Floppy35_720IsSupported :1;\r
- 0, // Floppy35_288IsSupported :1;\r
- 0, // PrintScreenIsSupported :1;\r
- 0, // Keyboard8042IsSupported :1;\r
- 1, // SerialIsSupported :1;\r
- 0, // PrinterIsSupported :1;\r
- 0, // CgaMonoIsSupported :1;\r
- 0, // NecPc98 :1;\r
- 0 // ReservedForVendor :32; ///< Bits 32-63. Bits 32-47 reserved for BIOS vendor\r
- ///< and bits 48-63 reserved for System Vendor.\r
- },\r
- { // BIOSCharacteristicsExtensionBytes[]\r
- 0x03, // AcpiIsSupported :1;\r
- // UsbLegacyIsSupported :1;\r
- // AgpIsSupported :1;\r
- // I2OBootIsSupported :1;\r
- // Ls120BootIsSupported :1;\r
- // AtapiZipDriveBootIsSupported :1;\r
- // Boot1394IsSupported :1;\r
- // SmartBatteryIsSupported :1;\r
- // BIOSCharacteristicsExtensionBytes[1]\r
- 0x0C, // BiosBootSpecIsSupported :1;\r
- // FunctionKeyNetworkBootIsSupported :1;\r
- // TargetContentDistributionEnabled :1;\r
- // UefiSpecificationSupported :1;\r
- // VirtualMachineSupported :1;\r
- // ExtensionByte2Reserved :3;\r
- },\r
- 0, // SystemBiosMajorRelease\r
- 0, // SystemBiosMinorRelease\r
- 0xFF, // EmbeddedControllerFirmwareMajorRelease\r
- 0xFF, // EmbeddedControllerFirmwareMinorRelease\r
+ {EFI_SMBIOS_TYPE_BIOS_INFORMATION, sizeof(SMBIOS_TABLE_TYPE0), 0},\r
+ 1, // Vendor String\r
+ 2, // BiosVersion String\r
+ 0xE800, // BiosSegment\r
+ 3, // BiosReleaseDate String\r
+ 0, // BiosSize (in 64KB)\r
+ {\r
+ // BiosCharacteristics\r
+ 0, // Reserved :2; ///< Bits 0-1.\r
+ 0, // Unknown :1;\r
+ 0, // BiosCharacteristicsNotSupported :1;\r
+ 0, // IsaIsSupported :1;\r
+ 0, // McaIsSupported :1;\r
+ 0, // EisaIsSupported :1;\r
+ 1, // PciIsSupported :1; /// No PCIe support since\r
+ // we hide ECAM from the OS\r
+ 0, // PcmciaIsSupported :1;\r
+ 1, // PlugAndPlayIsSupported :1;\r
+ 0, // ApmIsSupported :1;\r
+ 1, // BiosIsUpgradable :1;\r
+ 0, // BiosShadowingAllowed :1;\r
+ 0, // VlVesaIsSupported :1;\r
+ 0, // EscdSupportIsAvailable :1;\r
+ 0, // BootFromCdIsSupported :1;\r
+ 1, // SelectableBootIsSupported :1;\r
+ 0, // RomBiosIsSocketed :1;\r
+ 0, // BootFromPcmciaIsSupported :1;\r
+ 0, // EDDSpecificationIsSupported :1;\r
+ 0, // JapaneseNecFloppyIsSupported :1;\r
+ 0, // JapaneseToshibaFloppyIsSupported :1;\r
+ 0, // Floppy525_360IsSupported :1;\r
+ 0, // Floppy525_12IsSupported :1;\r
+ 0, // Floppy35_720IsSupported :1;\r
+ 0, // Floppy35_288IsSupported :1;\r
+ 0, // PrintScreenIsSupported :1;\r
+ 0, // Keyboard8042IsSupported :1;\r
+ 1, // SerialIsSupported :1;\r
+ 0, // PrinterIsSupported :1;\r
+ 0, // CgaMonoIsSupported :1;\r
+ 0, // NecPc98 :1;\r
+ 0 // ReservedForVendor :32; ///< Bits 32-63. Bits 32-47\r
+ // reserved for BIOS vendor\r
+ ///< and bits 48-63 reserved for System Vendor.\r
+ },\r
+ {\r
+ // BIOSCharacteristicsExtensionBytes[]\r
+ 0x03, // AcpiIsSupported :1;\r
+ // UsbLegacyIsSupported :1;\r
+ // AgpIsSupported :1;\r
+ // I2OBootIsSupported :1;\r
+ // Ls120BootIsSupported :1;\r
+ // AtapiZipDriveBootIsSupported :1;\r
+ // Boot1394IsSupported :1;\r
+ // SmartBatteryIsSupported :1;\r
+ // BIOSCharacteristicsExtensionBytes[1]\r
+ 0x0C, // BiosBootSpecIsSupported :1;\r
+ // FunctionKeyNetworkBootIsSupported :1;\r
+ // TargetContentDistributionEnabled :1;\r
+ // UefiSpecificationSupported :1;\r
+ // VirtualMachineSupported :1;\r
+ // ExtensionByte2Reserved :3;\r
+ },\r
+ 0, // SystemBiosMajorRelease\r
+ 0, // SystemBiosMinorRelease\r
+ 0xFF, // EmbeddedControllerFirmwareMajorRelease\r
+ 0xFF, // EmbeddedControllerFirmwareMinorRelease\r
};\r
\r
CHAR8 mBiosVendor[128] = "Renegade-Project";\r
CHAR8 mBiosDate[12] = __DATE__;\r
\r
CHAR8 *mBIOSInfoType0Strings[] = {\r
- mBiosVendor, // Vendor\r
- mBiosVersion, // Version\r
- mBiosDate, // Release Date\r
- NULL\r
-};\r
+ mBiosVendor, // Vendor\r
+ mBiosVersion, // Version\r
+ mBiosDate, // Release Date\r
+ NULL};\r
\r
/***********************************************************************\r
SMBIOS data definition TYPE1 System Information\r
************************************************************************/\r
SMBIOS_TABLE_TYPE1 mSysInfoType1 = {\r
- { EFI_SMBIOS_TYPE_SYSTEM_INFORMATION, sizeof (SMBIOS_TABLE_TYPE1), 0 },\r
- 1, // Manufacturer String\r
- 2, // ProductName String\r
- 3, // Version String\r
- 4, // SerialNumber String\r
- { 0x8A95D198, 0x7F46, 0x11E5, { 0xBF, 0x8B, 0x08, 0x00, 0x27, 0x04, 0xD4, 0x8E }},\r
- SystemWakeupTypePowerSwitch,\r
- 5, // SKUNumber String\r
- 6, // Family String\r
+ {EFI_SMBIOS_TYPE_SYSTEM_INFORMATION, sizeof(SMBIOS_TABLE_TYPE1), 0},\r
+ 1, // Manufacturer String\r
+ 2, // ProductName String\r
+ 3, // Version String\r
+ 4, // SerialNumber String\r
+ {0x8A95D198,\r
+ 0x7F46,\r
+ 0x11E5,\r
+ {0xBF, 0x8B, 0x08, 0x00, 0x27, 0x04, 0xD4, 0x8E}},\r
+ SystemWakeupTypePowerSwitch,\r
+ 5, // SKUNumber String\r
+ 6, // Family String\r
};\r
\r
CHAR8 mSysInfoManufName[128];\r
CHAR8 mSysInfoProductName[128];\r
CHAR8 mSysInfoVersionName[128];\r
-CHAR8 mSysInfoSerial[sizeof (UINT64) * 2 + 1] = "Serial Not Set";\r
-CHAR8 mSysInfoSKU[sizeof (UINT64) * 2 + 1] = "SKU Not Set";\r
+CHAR8 mSysInfoSerial[sizeof(UINT64) * 2 + 1] = "Serial Not Set";\r
+CHAR8 mSysInfoSKU[sizeof(UINT64) * 2 + 1] = "SKU Not Set";\r
\r
CHAR8 *mSysInfoType1Strings[] = {\r
- mSysInfoManufName,\r
- mSysInfoProductName,\r
- mSysInfoVersionName,\r
- mSysInfoSerial,\r
- mSysInfoSKU,\r
- "Snapdragon 845 Device",\r
- NULL\r
-};\r
+ mSysInfoManufName,\r
+ mSysInfoProductName,\r
+ mSysInfoVersionName,\r
+ mSysInfoSerial,\r
+ mSysInfoSKU,\r
+ "Snapdragon 845 Device",\r
+ NULL};\r
\r
/***********************************************************************\r
SMBIOS data definition TYPE2 Board Information\r
************************************************************************/\r
SMBIOS_TABLE_TYPE2 mBoardInfoType2 = {\r
- { EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION, sizeof (SMBIOS_TABLE_TYPE2), 0 },\r
- 1, // Manufacturer String\r
- 2, // ProductName String\r
- 3, // Version String\r
- 4, // SerialNumber String\r
- 5, // AssetTag String\r
- { // FeatureFlag\r
- 1, // Motherboard :1;\r
- 0, // RequiresDaughterCard :1;\r
- 0, // Removable :1;\r
- 0, // Replaceable :1;\r
- 0, // HotSwappable :1;\r
- 0, // Reserved :3;\r
- },\r
- 6, // LocationInChassis String\r
- 0, // ChassisHandle;\r
- BaseBoardTypeMotherBoard, // BoardType;\r
- 0, // NumberOfContainedObjectHandles;\r
- { 0 } // ContainedObjectHandles[1];\r
+ {EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION, sizeof(SMBIOS_TABLE_TYPE2), 0},\r
+ 1, // Manufacturer String\r
+ 2, // ProductName String\r
+ 3, // Version String\r
+ 4, // SerialNumber String\r
+ 5, // AssetTag String\r
+ {\r
+ // FeatureFlag\r
+ 1, // Motherboard :1;\r
+ 0, // RequiresDaughterCard :1;\r
+ 0, // Removable :1;\r
+ 0, // Replaceable :1;\r
+ 0, // HotSwappable :1;\r
+ 0, // Reserved :3;\r
+ },\r
+ 6, // LocationInChassis String\r
+ 0, // ChassisHandle;\r
+ BaseBoardTypeMotherBoard, // BoardType;\r
+ 0, // NumberOfContainedObjectHandles;\r
+ {0} // ContainedObjectHandles[1];\r
};\r
\r
CHAR8 mChassisAssetTag[128];\r
\r
CHAR8 *mBoardInfoType2Strings[] = {\r
- mSysInfoManufName,\r
- mSysInfoProductName,\r
- mSysInfoVersionName,\r
- mSysInfoSerial,\r
- mChassisAssetTag,\r
- "Portable",\r
- NULL\r
-};\r
+ mSysInfoManufName,\r
+ mSysInfoProductName,\r
+ mSysInfoVersionName,\r
+ mSysInfoSerial,\r
+ mChassisAssetTag,\r
+ "Portable",\r
+ NULL};\r
\r
/***********************************************************************\r
SMBIOS data definition TYPE3 Enclosure Information\r
************************************************************************/\r
SMBIOS_TABLE_TYPE3 mEnclosureInfoType3 = {\r
- { EFI_SMBIOS_TYPE_SYSTEM_ENCLOSURE, sizeof (SMBIOS_TABLE_TYPE3), 0 },\r
- 1, // Manufacturer String\r
- MiscChassisTypePortable, // Type;\r
- 2, // Version String\r
- 3, // SerialNumber String\r
- 4, // AssetTag String\r
- ChassisStateSafe, // BootupState;\r
- ChassisStateSafe, // PowerSupplyState;\r
- ChassisStateSafe, // ThermalState;\r
- ChassisSecurityStatusNone, // SecurityStatus;\r
- { 0, 0, 0, 0 }, // OemDefined[4];\r
- 1, // Height;\r
- 1, // NumberofPowerCords;\r
- 0, // ContainedElementCount;\r
- 0, // ContainedElementRecordLength;\r
- { { 0 } }, // ContainedElements[1];\r
+ {EFI_SMBIOS_TYPE_SYSTEM_ENCLOSURE, sizeof(SMBIOS_TABLE_TYPE3), 0},\r
+ 1, // Manufacturer String\r
+ MiscChassisTypePortable, // Type;\r
+ 2, // Version String\r
+ 3, // SerialNumber String\r
+ 4, // AssetTag String\r
+ ChassisStateSafe, // BootupState;\r
+ ChassisStateSafe, // PowerSupplyState;\r
+ ChassisStateSafe, // ThermalState;\r
+ ChassisSecurityStatusNone, // SecurityStatus;\r
+ {0, 0, 0, 0}, // OemDefined[4];\r
+ 1, // Height;\r
+ 1, // NumberofPowerCords;\r
+ 0, // ContainedElementCount;\r
+ 0, // ContainedElementRecordLength;\r
+ {{0}}, // ContainedElements[1];\r
};\r
CHAR8 *mEnclosureInfoType3Strings[] = {\r
- mSysInfoManufName,\r
- mSysInfoProductName,\r
- mSysInfoSerial,\r
- mChassisAssetTag,\r
- NULL\r
-};\r
+ mSysInfoManufName, mSysInfoProductName, mSysInfoSerial, mChassisAssetTag,\r
+ NULL};\r
\r
/***********************************************************************\r
SMBIOS data definition TYPE4 Processor Information\r
************************************************************************/\r
SMBIOS_TABLE_TYPE4 mProcessorInfoType4_a75 = {\r
- { EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION, sizeof (SMBIOS_TABLE_TYPE4), 0},\r
- 1, // Socket String\r
- CentralProcessor, // ProcessorType; ///< The enumeration value from PROCESSOR_TYPE_DATA.\r
- ProcessorFamilyIndicatorFamily2, // ProcessorFamily; ///< The enumeration value from PROCESSOR_FAMILY2_DATA.\r
- 2, // ProcessorManufacture String;\r
- { // ProcessorId;\r
- { 0x00, 0x00, 0x00, 0x00 },\r
- { 0x00, 0x00, 0x00, 0x00 }\r
- },\r
- 3, // ProcessorVersion String;\r
- { // Voltage;\r
- 0, // ProcessorVoltageCapability5V :1;\r
- 0, // ProcessorVoltageCapability3_3V :1;\r
- 0, // ProcessorVoltageCapability2_9V :1;\r
- 0, // ProcessorVoltageCapabilityReserved :1; ///< Bit 3, must be zero.\r
- 0, // ProcessorVoltageReserved :3; ///< Bits 4-6, must be zero.\r
- 1 // ProcessorVoltageIndicateLegacy :1;\r
- },\r
- 0, // ExternalClock;\r
- 2803, // MaxSpeed;\r
- 2803, // CurrentSpeed;\r
- 0x41, // Status;\r
- ProcessorUpgradeOther, // ProcessorUpgrade; ///< The enumeration value from PROCESSOR_UPGRADE.\r
- 0, // L1CacheHandle;\r
- 0, // L2CacheHandle;\r
- 0xFFFF, // L3CacheHandle;\r
- 0, // SerialNumber;\r
- 0, // AssetTag;\r
- 7, // PartNumber;\r
- 4, // CoreCount;\r
- 4, // EnabledCoreCount;\r
- 0, // ThreadCount;\r
- 0xEC, // ProcessorCharacteristics; ///< The enumeration value from PROCESSOR_CHARACTERISTIC_FLAGS\r
- // ProcessorReserved1 :1;\r
- // ProcessorUnknown :1;\r
- // Processor64BitCapble :1;\r
- // ProcessorMultiCore :1;\r
- // ProcessorHardwareThread :1;\r
- // ProcessorExecuteProtection :1;\r
- // ProcessorEnhancedVirtualization :1;\r
- // ProcessorPowerPerformanceCtrl :1;\r
- // Processor128bitCapble :1;\r
- // ProcessorReserved2 :7;\r
- ProcessorFamilyARM, // ARM Processor Family;\r
- 0, // CoreCount2;\r
- 0, // EnabledCoreCount2;\r
- 0, // ThreadCount2;\r
+ {EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION, sizeof(SMBIOS_TABLE_TYPE4), 0},\r
+ 1, // Socket String\r
+ CentralProcessor, // ProcessorType; ///< The enumeration value from\r
+ // PROCESSOR_TYPE_DATA.\r
+ ProcessorFamilyIndicatorFamily2, // ProcessorFamily; ///< The\r
+ // enumeration value from\r
+ // PROCESSOR_FAMILY2_DATA.\r
+ 2, // ProcessorManufacture String;\r
+ { // ProcessorId;\r
+ {0x00, 0x00, 0x00, 0x00},\r
+ {0x00, 0x00, 0x00, 0x00}},\r
+ 3, // ProcessorVersion String;\r
+ {\r
+ // Voltage;\r
+ 0, // ProcessorVoltageCapability5V :1;\r
+ 0, // ProcessorVoltageCapability3_3V :1;\r
+ 0, // ProcessorVoltageCapability2_9V :1;\r
+ 0, // ProcessorVoltageCapabilityReserved :1; ///< Bit 3, must be zero.\r
+ 0, // ProcessorVoltageReserved :3; ///< Bits 4-6, must be\r
+ // zero.\r
+ 1 // ProcessorVoltageIndicateLegacy :1;\r
+ },\r
+ 0, // ExternalClock;\r
+ 2803, // MaxSpeed;\r
+ 2803, // CurrentSpeed;\r
+ 0x41, // Status;\r
+ ProcessorUpgradeOther, // ProcessorUpgrade; ///< The enumeration\r
+ // value from PROCESSOR_UPGRADE.\r
+ 0, // L1CacheHandle;\r
+ 0, // L2CacheHandle;\r
+ 0xFFFF, // L3CacheHandle;\r
+ 0, // SerialNumber;\r
+ 0, // AssetTag;\r
+ 7, // PartNumber;\r
+ 4, // CoreCount;\r
+ 4, // EnabledCoreCount;\r
+ 0, // ThreadCount;\r
+ 0xEC, // ProcessorCharacteristics; ///< The enumeration value from\r
+ // PROCESSOR_CHARACTERISTIC_FLAGS ProcessorReserved1 :1;\r
+ // ProcessorUnknown :1;\r
+ // Processor64BitCapble :1;\r
+ // ProcessorMultiCore :1;\r
+ // ProcessorHardwareThread :1;\r
+ // ProcessorExecuteProtection :1;\r
+ // ProcessorEnhancedVirtualization :1;\r
+ // ProcessorPowerPerformanceCtrl :1;\r
+ // Processor128bitCapble :1;\r
+ // ProcessorReserved2 :7;\r
+ ProcessorFamilyARM, // ARM Processor Family;\r
+ 0, // CoreCount2;\r
+ 0, // EnabledCoreCount2;\r
+ 0, // ThreadCount2;\r
};\r
\r
SMBIOS_TABLE_TYPE4 mProcessorInfoType4_a55 = {\r
- { EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION, sizeof (SMBIOS_TABLE_TYPE4), 0},\r
- 1, // Socket String\r
- CentralProcessor, // ProcessorType; ///< The enumeration value from PROCESSOR_TYPE_DATA.\r
- ProcessorFamilyIndicatorFamily2, // ProcessorFamily; ///< The enumeration value from PROCESSOR_FAMILY2_DATA.\r
- 2, // ProcessorManufacture String;\r
- { // ProcessorId;\r
- { 0x00, 0x00, 0x00, 0x00 },\r
- { 0x00, 0x00, 0x00, 0x00 }\r
- },\r
- 3, // ProcessorVersion String;\r
- { // Voltage;\r
- 0, // ProcessorVoltageCapability5V :1;\r
- 0, // ProcessorVoltageCapability3_3V :1;\r
- 0, // ProcessorVoltageCapability2_9V :1;\r
- 0, // ProcessorVoltageCapabilityReserved :1; ///< Bit 3, must be zero.\r
- 0, // ProcessorVoltageReserved :3; ///< Bits 4-6, must be zero.\r
- 1 // ProcessorVoltageIndicateLegacy :1;\r
- },\r
- 0, // ExternalClock;\r
- 1766, // MaxSpeed;\r
- 1766, // CurrentSpeed;\r
- 0x41, // Status;\r
- ProcessorUpgradeOther, // ProcessorUpgrade; ///< The enumeration value from PROCESSOR_UPGRADE.\r
- 0, // L1CacheHandle;\r
- 0, // L2CacheHandle;\r
- 0xFFFF, // L3CacheHandle;\r
- 0, // SerialNumber;\r
- 0, // AssetTag;\r
- 6, // PartNumber;\r
- 4, // CoreCount;\r
- 4, // EnabledCoreCount;\r
- 0, // ThreadCount;\r
- 0xEC, // ProcessorCharacteristics; ///< The enumeration value from PROCESSOR_CHARACTERISTIC_FLAGS\r
- // ProcessorReserved1 :1;\r
- // ProcessorUnknown :1;\r
- // Processor64BitCapble :1;\r
- // ProcessorMultiCore :1;\r
- // ProcessorHardwareThread :1;\r
- // ProcessorExecuteProtection :1;\r
- // ProcessorEnhancedVirtualization :1;\r
- // ProcessorPowerPerformanceCtrl :1;\r
- // Processor128bitCapble :1;\r
- // ProcessorReserved2 :7;\r
- ProcessorFamilyARM, // ARM Processor Family;\r
- 0, // CoreCount2;\r
- 0, // EnabledCoreCount2;\r
- 0, // ThreadCount2;\r
+ {EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION, sizeof(SMBIOS_TABLE_TYPE4), 0},\r
+ 1, // Socket String\r
+ CentralProcessor, // ProcessorType; ///< The enumeration value from\r
+ // PROCESSOR_TYPE_DATA.\r
+ ProcessorFamilyIndicatorFamily2, // ProcessorFamily; ///< The\r
+ // enumeration value from\r
+ // PROCESSOR_FAMILY2_DATA.\r
+ 2, // ProcessorManufacture String;\r
+ { // ProcessorId;\r
+ {0x00, 0x00, 0x00, 0x00},\r
+ {0x00, 0x00, 0x00, 0x00}},\r
+ 3, // ProcessorVersion String;\r
+ {\r
+ // Voltage;\r
+ 0, // ProcessorVoltageCapability5V :1;\r
+ 0, // ProcessorVoltageCapability3_3V :1;\r
+ 0, // ProcessorVoltageCapability2_9V :1;\r
+ 0, // ProcessorVoltageCapabilityReserved :1; ///< Bit 3, must be zero.\r
+ 0, // ProcessorVoltageReserved :3; ///< Bits 4-6, must be\r
+ // zero.\r
+ 1 // ProcessorVoltageIndicateLegacy :1;\r
+ },\r
+ 0, // ExternalClock;\r
+ 1766, // MaxSpeed;\r
+ 1766, // CurrentSpeed;\r
+ 0x41, // Status;\r
+ ProcessorUpgradeOther, // ProcessorUpgrade; ///< The enumeration\r
+ // value from PROCESSOR_UPGRADE.\r
+ 0, // L1CacheHandle;\r
+ 0, // L2CacheHandle;\r
+ 0xFFFF, // L3CacheHandle;\r
+ 0, // SerialNumber;\r
+ 0, // AssetTag;\r
+ 6, // PartNumber;\r
+ 4, // CoreCount;\r
+ 4, // EnabledCoreCount;\r
+ 0, // ThreadCount;\r
+ 0xEC, // ProcessorCharacteristics; ///< The enumeration value from\r
+ // PROCESSOR_CHARACTERISTIC_FLAGS ProcessorReserved1 :1;\r
+ // ProcessorUnknown :1;\r
+ // Processor64BitCapble :1;\r
+ // ProcessorMultiCore :1;\r
+ // ProcessorHardwareThread :1;\r
+ // ProcessorExecuteProtection :1;\r
+ // ProcessorEnhancedVirtualization :1;\r
+ // ProcessorPowerPerformanceCtrl :1;\r
+ // Processor128bitCapble :1;\r
+ // ProcessorReserved2 :7;\r
+ ProcessorFamilyARM, // ARM Processor Family;\r
+ 0, // CoreCount2;\r
+ 0, // EnabledCoreCount2;\r
+ 0, // ThreadCount2;\r
};\r
\r
CHAR8 mCpuName[128] = "Qualcomm Snapdragon 845";\r
\r
CHAR8 *mProcessorInfoType4Strings[] = {\r
- "BGA-1156",\r
- "Qualcomm",\r
- "Snapdragon 845",\r
- NULL\r
-};\r
+ "BGA-1156", "Qualcomm", "Snapdragon 845", NULL};\r
\r
/***********************************************************************\r
SMBIOS data definition TYPE7 Cache Information\r
************************************************************************/\r
SMBIOS_TABLE_TYPE7 mCacheInfoType7_a75_L1I = {\r
- { EFI_SMBIOS_TYPE_CACHE_INFORMATION, sizeof (SMBIOS_TABLE_TYPE7), 0 },\r
- 1, // SocketDesignation String\r
- 0x380, // Cache Configuration\r
- //Cache Level :3 (L1)\r
- //Cache Socketed :1 (Not Socketed)\r
- //Reserved :1\r
- //Location :2 (Internal)\r
- //Enabled/Disabled :1 (Enabled)\r
- //Operational Mode :2 (Unknown)\r
- //Reserved :6\r
- 0x0030, // Maximum Size\r
- 0x0030, // Install Size\r
- { // Supported SRAM Type\r
- 0, //Other :1\r
- 1, //Unknown :1\r
- 0, //NonBurst :1\r
- 0, //Burst :1\r
- 0, //PiplelineBurst :1\r
- 0, //Synchronous :1\r
- 0, //Asynchronous :1\r
- 0 //Reserved :9\r
- },\r
- { // Current SRAM Type\r
- 0, //Other :1\r
- 1, //Unknown :1\r
- 0, //NonBurst :1\r
- 0, //Burst :1\r
- 0, //PiplelineBurst :1\r
- 0, //Synchronous :1\r
- 0, //Asynchronous :1\r
- 0 //Reserved :9\r
- },\r
- 0, // Cache Speed unknown\r
- CacheErrorParity, // Error Correction\r
- CacheTypeInstruction, // System Cache Type\r
- CacheAssociativityOther // Associativity\r
+ {EFI_SMBIOS_TYPE_CACHE_INFORMATION, sizeof(SMBIOS_TABLE_TYPE7), 0},\r
+ 1, // SocketDesignation String\r
+ 0x380, // Cache Configuration\r
+ // Cache Level :3 (L1)\r
+ // Cache Socketed :1 (Not Socketed)\r
+ // Reserved :1\r
+ // Location :2 (Internal)\r
+ // Enabled/Disabled :1 (Enabled)\r
+ // Operational Mode :2 (Unknown)\r
+ // Reserved :6\r
+ 0x0030, // Maximum Size\r
+ 0x0030, // Install Size\r
+ {\r
+ // Supported SRAM Type\r
+ 0, // Other :1\r
+ 1, // Unknown :1\r
+ 0, // NonBurst :1\r
+ 0, // Burst :1\r
+ 0, // PiplelineBurst :1\r
+ 0, // Synchronous :1\r
+ 0, // Asynchronous :1\r
+ 0 // Reserved :9\r
+ },\r
+ {\r
+ // Current SRAM Type\r
+ 0, // Other :1\r
+ 1, // Unknown :1\r
+ 0, // NonBurst :1\r
+ 0, // Burst :1\r
+ 0, // PiplelineBurst :1\r
+ 0, // Synchronous :1\r
+ 0, // Asynchronous :1\r
+ 0 // Reserved :9\r
+ },\r
+ 0, // Cache Speed unknown\r
+ CacheErrorParity, // Error Correction\r
+ CacheTypeInstruction, // System Cache Type\r
+ CacheAssociativityOther // Associativity\r
};\r
\r
SMBIOS_TABLE_TYPE7 mCacheInfoType7_a55_L1I = {\r
- { EFI_SMBIOS_TYPE_CACHE_INFORMATION, sizeof (SMBIOS_TABLE_TYPE7), 0 },\r
- 1, // SocketDesignation String\r
- 0x380, // Cache Configuration\r
- //Cache Level :3 (L1)\r
- //Cache Socketed :1 (Not Socketed)\r
- //Reserved :1\r
- //Location :2 (Internal)\r
- //Enabled/Disabled :1 (Enabled)\r
- //Operational Mode :2 (Unknown)\r
- //Reserved :6\r
- 0x0030, // Maximum Size\r
- 0x0030, // Install Size\r
- { // Supported SRAM Type\r
- 0, //Other :1\r
- 1, //Unknown :1\r
- 0, //NonBurst :1\r
- 0, //Burst :1\r
- 0, //PiplelineBurst :1\r
- 0, //Synchronous :1\r
- 0, //Asynchronous :1\r
- 0 //Reserved :9\r
- },\r
- { // Current SRAM Type\r
- 0, //Other :1\r
- 1, //Unknown :1\r
- 0, //NonBurst :1\r
- 0, //Burst :1\r
- 0, //PiplelineBurst :1\r
- 0, //Synchronous :1\r
- 0, //Asynchronous :1\r
- 0 //Reserved :9\r
- },\r
- 0, // Cache Speed unknown\r
- CacheErrorParity, // Error Correction\r
- CacheTypeInstruction, // System Cache Type\r
- CacheAssociativity2Way // Associativity\r
-};\r
-CHAR8 *mCacheInfoType7Strings[] = {\r
- "L1 Instruction",\r
- "L1 Data",\r
- "L2",\r
- NULL\r
+ {EFI_SMBIOS_TYPE_CACHE_INFORMATION, sizeof(SMBIOS_TABLE_TYPE7), 0},\r
+ 1, // SocketDesignation String\r
+ 0x380, // Cache Configuration\r
+ // Cache Level :3 (L1)\r
+ // Cache Socketed :1 (Not Socketed)\r
+ // Reserved :1\r
+ // Location :2 (Internal)\r
+ // Enabled/Disabled :1 (Enabled)\r
+ // Operational Mode :2 (Unknown)\r
+ // Reserved :6\r
+ 0x0030, // Maximum Size\r
+ 0x0030, // Install Size\r
+ {\r
+ // Supported SRAM Type\r
+ 0, // Other :1\r
+ 1, // Unknown :1\r
+ 0, // NonBurst :1\r
+ 0, // Burst :1\r
+ 0, // PiplelineBurst :1\r
+ 0, // Synchronous :1\r
+ 0, // Asynchronous :1\r
+ 0 // Reserved :9\r
+ },\r
+ {\r
+ // Current SRAM Type\r
+ 0, // Other :1\r
+ 1, // Unknown :1\r
+ 0, // NonBurst :1\r
+ 0, // Burst :1\r
+ 0, // PiplelineBurst :1\r
+ 0, // Synchronous :1\r
+ 0, // Asynchronous :1\r
+ 0 // Reserved :9\r
+ },\r
+ 0, // Cache Speed unknown\r
+ CacheErrorParity, // Error Correction\r
+ CacheTypeInstruction, // System Cache Type\r
+ CacheAssociativity2Way // Associativity\r
};\r
+CHAR8 *mCacheInfoType7Strings[] = {"L1 Instruction", "L1 Data", "L2", NULL};\r
\r
SMBIOS_TABLE_TYPE7 mCacheInfoType7_a75_L1D = {\r
- { EFI_SMBIOS_TYPE_CACHE_INFORMATION, sizeof (SMBIOS_TABLE_TYPE7), 0 },\r
- 2, // SocketDesignation String\r
- 0x180, // Cache Configuration\r
- //Cache Level :3 (L1)\r
- //Cache Socketed :1 (Not Socketed)\r
- //Reserved :1\r
- //Location :2 (Internal)\r
- //Enabled/Disabled :1 (Enabled)\r
- //Operational Mode :2 (WB)\r
- //Reserved :6\r
- 0x0020, // Maximum Size\r
- 0x0020, // Install Size\r
- { // Supported SRAM Type\r
- 0, //Other :1\r
- 1, //Unknown :1\r
- 0, //NonBurst :1\r
- 0, //Burst :1\r
- 0, //PiplelineBurst :1\r
- 0, //Synchronous :1\r
- 0, //Asynchronous :1\r
- 0 //Reserved :9\r
- },\r
- { // Current SRAM Type\r
- 0, //Other :1\r
- 1, //Unknown :1\r
- 0, //NonBurst :1\r
- 0, //Burst :1\r
- 0, //PiplelineBurst :1\r
- 0, //Synchronous :1\r
- 0, //Asynchronous :1\r
- 0 //Reserved :9\r
- },\r
- 0, // Cache Speed unknown\r
- CacheErrorSingleBit, // Error Correction\r
- CacheTypeData, // System Cache Type\r
- CacheAssociativity2Way // Associativity\r
+ {EFI_SMBIOS_TYPE_CACHE_INFORMATION, sizeof(SMBIOS_TABLE_TYPE7), 0},\r
+ 2, // SocketDesignation String\r
+ 0x180, // Cache Configuration\r
+ // Cache Level :3 (L1)\r
+ // Cache Socketed :1 (Not Socketed)\r
+ // Reserved :1\r
+ // Location :2 (Internal)\r
+ // Enabled/Disabled :1 (Enabled)\r
+ // Operational Mode :2 (WB)\r
+ // Reserved :6\r
+ 0x0020, // Maximum Size\r
+ 0x0020, // Install Size\r
+ {\r
+ // Supported SRAM Type\r
+ 0, // Other :1\r
+ 1, // Unknown :1\r
+ 0, // NonBurst :1\r
+ 0, // Burst :1\r
+ 0, // PiplelineBurst :1\r
+ 0, // Synchronous :1\r
+ 0, // Asynchronous :1\r
+ 0 // Reserved :9\r
+ },\r
+ {\r
+ // Current SRAM Type\r
+ 0, // Other :1\r
+ 1, // Unknown :1\r
+ 0, // NonBurst :1\r
+ 0, // Burst :1\r
+ 0, // PiplelineBurst :1\r
+ 0, // Synchronous :1\r
+ 0, // Asynchronous :1\r
+ 0 // Reserved :9\r
+ },\r
+ 0, // Cache Speed unknown\r
+ CacheErrorSingleBit, // Error Correction\r
+ CacheTypeData, // System Cache Type\r
+ CacheAssociativity2Way // Associativity\r
};\r
\r
SMBIOS_TABLE_TYPE7 mCacheInfoType7_a55_L1D = {\r
- { EFI_SMBIOS_TYPE_CACHE_INFORMATION, sizeof (SMBIOS_TABLE_TYPE7), 0 },\r
- 2, // SocketDesignation String\r
- 0x180, // Cache Configuration\r
- //Cache Level :3 (L1)\r
- //Cache Socketed :1 (Not Socketed)\r
- //Reserved :1\r
- //Location :2 (Internal)\r
- //Enabled/Disabled :1 (Enabled)\r
- //Operational Mode :2 (WB)\r
- //Reserved :6\r
- 0x0020, // Maximum Size\r
- 0x0020, // Install Size\r
- { // Supported SRAM Type\r
- 0, //Other :1\r
- 1, //Unknown :1\r
- 0, //NonBurst :1\r
- 0, //Burst :1\r
- 0, //PiplelineBurst :1\r
- 0, //Synchronous :1\r
- 0, //Asynchronous :1\r
- 0 //Reserved :9\r
- },\r
- { // Current SRAM Type\r
- 0, //Other :1\r
- 1, //Unknown :1\r
- 0, //NonBurst :1\r
- 0, //Burst :1\r
- 0, //PiplelineBurst :1\r
- 0, //Synchronous :1\r
- 0, //Asynchronous :1\r
- 0 //Reserved :9\r
- },\r
- 0, // Cache Speed unknown\r
- CacheErrorSingleBit, // Error Correction\r
- CacheTypeData, // System Cache Type\r
- CacheAssociativity4Way // Associativity\r
+ {EFI_SMBIOS_TYPE_CACHE_INFORMATION, sizeof(SMBIOS_TABLE_TYPE7), 0},\r
+ 2, // SocketDesignation String\r
+ 0x180, // Cache Configuration\r
+ // Cache Level :3 (L1)\r
+ // Cache Socketed :1 (Not Socketed)\r
+ // Reserved :1\r
+ // Location :2 (Internal)\r
+ // Enabled/Disabled :1 (Enabled)\r
+ // Operational Mode :2 (WB)\r
+ // Reserved :6\r
+ 0x0020, // Maximum Size\r
+ 0x0020, // Install Size\r
+ {\r
+ // Supported SRAM Type\r
+ 0, // Other :1\r
+ 1, // Unknown :1\r
+ 0, // NonBurst :1\r
+ 0, // Burst :1\r
+ 0, // PiplelineBurst :1\r
+ 0, // Synchronous :1\r
+ 0, // Asynchronous :1\r
+ 0 // Reserved :9\r
+ },\r
+ {\r
+ // Current SRAM Type\r
+ 0, // Other :1\r
+ 1, // Unknown :1\r
+ 0, // NonBurst :1\r
+ 0, // Burst :1\r
+ 0, // PiplelineBurst :1\r
+ 0, // Synchronous :1\r
+ 0, // Asynchronous :1\r
+ 0 // Reserved :9\r
+ },\r
+ 0, // Cache Speed unknown\r
+ CacheErrorSingleBit, // Error Correction\r
+ CacheTypeData, // System Cache Type\r
+ CacheAssociativity4Way // Associativity\r
};\r
\r
SMBIOS_TABLE_TYPE7 mCacheInfoType7_a75_L2 = {\r
- { EFI_SMBIOS_TYPE_CACHE_INFORMATION, sizeof (SMBIOS_TABLE_TYPE7), 0 },\r
- 3, // SocketDesignation String\r
- 0x0181, // Cache Configuration\r
- //Cache Level :3 (L2)\r
- //Cache Socketed :1 (Not Socketed)\r
- //Reserved :1\r
- //Location :2 (Internal)\r
- //Enabled/Disabled :1 (Enabled)\r
- //Operational Mode :2 (WB)\r
- //Reserved :6\r
- 0x0800, // Maximum Size\r
- 0x0800, // Install Size\r
- { // Supported SRAM Type\r
- 0, //Other :1\r
- 0, //Unknown :1\r
- 1, //NonBurst :1\r
- 0, //Burst :1\r
- 0, //PiplelineBurst :1\r
- 0, //Synchronous :1\r
- 0, //Asynchronous :1\r
- 0 //Reserved :9\r
- },\r
- { // Current SRAM Type\r
- 0, //Other :1\r
- 0, //Unknown :1\r
- 1, //NonBurst :1\r
- 0, //Burst :1\r
- 0, //PiplelineBurst :1\r
- 0, //Synchronous :1\r
- 0, //Asynchronous :1\r
- 0 //Reserved :9\r
- },\r
- 0, // Cache Speed unknown\r
- CacheErrorSingleBit, // Error Correction Multi\r
- CacheTypeUnified, // System Cache Type\r
- CacheAssociativity16Way // Associativity\r
+ {EFI_SMBIOS_TYPE_CACHE_INFORMATION, sizeof(SMBIOS_TABLE_TYPE7), 0},\r
+ 3, // SocketDesignation String\r
+ 0x0181, // Cache Configuration\r
+ // Cache Level :3 (L2)\r
+ // Cache Socketed :1 (Not Socketed)\r
+ // Reserved :1\r
+ // Location :2 (Internal)\r
+ // Enabled/Disabled :1 (Enabled)\r
+ // Operational Mode :2 (WB)\r
+ // Reserved :6\r
+ 0x0800, // Maximum Size\r
+ 0x0800, // Install Size\r
+ {\r
+ // Supported SRAM Type\r
+ 0, // Other :1\r
+ 0, // Unknown :1\r
+ 1, // NonBurst :1\r
+ 0, // Burst :1\r
+ 0, // PiplelineBurst :1\r
+ 0, // Synchronous :1\r
+ 0, // Asynchronous :1\r
+ 0 // Reserved :9\r
+ },\r
+ {\r
+ // Current SRAM Type\r
+ 0, // Other :1\r
+ 0, // Unknown :1\r
+ 1, // NonBurst :1\r
+ 0, // Burst :1\r
+ 0, // PiplelineBurst :1\r
+ 0, // Synchronous :1\r
+ 0, // Asynchronous :1\r
+ 0 // Reserved :9\r
+ },\r
+ 0, // Cache Speed unknown\r
+ CacheErrorSingleBit, // Error Correction Multi\r
+ CacheTypeUnified, // System Cache Type\r
+ CacheAssociativity16Way // Associativity\r
};\r
\r
SMBIOS_TABLE_TYPE7 mCacheInfoType7_a55_L2 = {\r
- { EFI_SMBIOS_TYPE_CACHE_INFORMATION, sizeof (SMBIOS_TABLE_TYPE7), 0 },\r
- 3, // SocketDesignation String\r
- 0x0181, // Cache Configuration\r
- //Cache Level :3 (L2)\r
- //Cache Socketed :1 (Not Socketed)\r
- //Reserved :1\r
- //Location :2 (Internal)\r
- //Enabled/Disabled :1 (Enabled)\r
- //Operational Mode :2 (WB)\r
- //Reserved :6\r
- 0x0800, // Maximum Size\r
- 0x0800, // Install Size\r
- { // Supported SRAM Type\r
- 0, //Other :1\r
- 1, //Unknown :1\r
- 0, //NonBurst :1\r
- 0, //Burst :1\r
- 0, //PiplelineBurst :1\r
- 0, //Synchronous :1\r
- 0, //Asynchronous :1\r
- 0 //Reserved :9\r
- },\r
- { // Current SRAM Type\r
- 0, //Other :1\r
- 0, //Unknown :1\r
- 1, //NonBurst :1\r
- 0, //Burst :1\r
- 0, //PiplelineBurst :1\r
- 0, //Synchronous :1\r
- 0, //Asynchronous :1\r
- 0 //Reserved :9\r
- },\r
- 0, // Cache Speed unknown\r
- CacheErrorSingleBit, // Error Correction Multi\r
- CacheTypeUnified, // System Cache Type\r
- CacheAssociativity16Way // Associativity\r
+ {EFI_SMBIOS_TYPE_CACHE_INFORMATION, sizeof(SMBIOS_TABLE_TYPE7), 0},\r
+ 3, // SocketDesignation String\r
+ 0x0181, // Cache Configuration\r
+ // Cache Level :3 (L2)\r
+ // Cache Socketed :1 (Not Socketed)\r
+ // Reserved :1\r
+ // Location :2 (Internal)\r
+ // Enabled/Disabled :1 (Enabled)\r
+ // Operational Mode :2 (WB)\r
+ // Reserved :6\r
+ 0x0800, // Maximum Size\r
+ 0x0800, // Install Size\r
+ {\r
+ // Supported SRAM Type\r
+ 0, // Other :1\r
+ 1, // Unknown :1\r
+ 0, // NonBurst :1\r
+ 0, // Burst :1\r
+ 0, // PiplelineBurst :1\r
+ 0, // Synchronous :1\r
+ 0, // Asynchronous :1\r
+ 0 // Reserved :9\r
+ },\r
+ {\r
+ // Current SRAM Type\r
+ 0, // Other :1\r
+ 0, // Unknown :1\r
+ 1, // NonBurst :1\r
+ 0, // Burst :1\r
+ 0, // PiplelineBurst :1\r
+ 0, // Synchronous :1\r
+ 0, // Asynchronous :1\r
+ 0 // Reserved :9\r
+ },\r
+ 0, // Cache Speed unknown\r
+ CacheErrorSingleBit, // Error Correction Multi\r
+ CacheTypeUnified, // System Cache Type\r
+ CacheAssociativity16Way // Associativity\r
};\r
\r
/***********************************************************************\r
SMBIOS data definition TYPE9 System Slot Information\r
************************************************************************/\r
-SMBIOS_TABLE_TYPE9 mSysSlotInfoType9_0 = {\r
- { EFI_SMBIOS_TYPE_SYSTEM_SLOTS, sizeof (SMBIOS_TABLE_TYPE9), 0 },\r
- 1, // SlotDesignation String\r
- SlotTypePciExpressGen2X4, // SlotType; ///< The enumeration value from MISC_SLOT_TYPE.\r
- SlotDataBusWidth1X, // SlotDataBusWidth; ///< The enumeration value from MISC_SLOT_DATA_BUS_WIDTH.\r
- SlotUsageUnknown, // CurrentUsage; ///< The enumeration value from MISC_SLOT_USAGE.\r
- SlotLengthShort, // SlotLength; ///< The enumeration value from MISC_SLOT_LENGTH.\r
- 0, // SlotID;\r
- { // SlotCharacteristics1;\r
- 1, // CharacteristicsUnknown :1;\r
- 0, // Provides50Volts :1;\r
- 0, // Provides33Volts :1;\r
- 0, // SharedSlot :1;\r
- 0, // PcCard16Supported :1;\r
- 0, // CardBusSupported :1;\r
- 0, // ZoomVideoSupported :1;\r
- 0, // ModemRingResumeSupported:1;\r
- },\r
- { // SlotCharacteristics2;\r
- 1, // PmeSignalSupported :1;\r
- 0, // HotPlugDevicesSupported :1;\r
- 1, // SmbusSignalSupported :1;\r
- 0, // Reserved :5; ///< Set to 0.\r
- },\r
- 0, // SegmentGroupNum;\r
- 2, // BusNum;\r
- 1, // DevFuncNum;\r
+SMBIOS_TABLE_TYPE9 mSysSlotInfoType9_0 = {\r
+ {EFI_SMBIOS_TYPE_SYSTEM_SLOTS, sizeof(SMBIOS_TABLE_TYPE9), 0},\r
+ 1, // SlotDesignation String\r
+ SlotTypePciExpressGen2X4, // SlotType; ///< The enumeration\r
+ // value from MISC_SLOT_TYPE.\r
+ SlotDataBusWidth1X, // SlotDataBusWidth; ///< The enumeration value\r
+ // from MISC_SLOT_DATA_BUS_WIDTH.\r
+ SlotUsageUnknown, // CurrentUsage; ///< The enumeration value\r
+ // from MISC_SLOT_USAGE.\r
+ SlotLengthShort, // SlotLength; ///< The enumeration value\r
+ // from MISC_SLOT_LENGTH.\r
+ 0, // SlotID;\r
+ {\r
+ // SlotCharacteristics1;\r
+ 1, // CharacteristicsUnknown :1;\r
+ 0, // Provides50Volts :1;\r
+ 0, // Provides33Volts :1;\r
+ 0, // SharedSlot :1;\r
+ 0, // PcCard16Supported :1;\r
+ 0, // CardBusSupported :1;\r
+ 0, // ZoomVideoSupported :1;\r
+ 0, // ModemRingResumeSupported:1;\r
+ },\r
+ {\r
+ // SlotCharacteristics2;\r
+ 1, // PmeSignalSupported :1;\r
+ 0, // HotPlugDevicesSupported :1;\r
+ 1, // SmbusSignalSupported :1;\r
+ 0, // Reserved :5; ///< Set to 0.\r
+ },\r
+ 0, // SegmentGroupNum;\r
+ 2, // BusNum;\r
+ 1, // DevFuncNum;\r
};\r
\r
-SMBIOS_TABLE_TYPE9 mSysSlotInfoType9_1 = {\r
- { EFI_SMBIOS_TYPE_SYSTEM_SLOTS, sizeof (SMBIOS_TABLE_TYPE9), 0 },\r
- 2, // SlotDesignation String\r
- SlotTypePciExpressGen2X4, // SlotType; ///< The enumeration value from MISC_SLOT_TYPE.\r
- SlotDataBusWidth1X, // SlotDataBusWidth; ///< The enumeration value from MISC_SLOT_DATA_BUS_WIDTH.\r
- SlotUsageUnknown, // CurrentUsage; ///< The enumeration value from MISC_SLOT_USAGE.\r
- SlotLengthShort, // SlotLength; ///< The enumeration value from MISC_SLOT_LENGTH.\r
- 0, // SlotID;\r
- { // SlotCharacteristics1;\r
- 1, // CharacteristicsUnknown :1;\r
- 0, // Provides50Volts :1;\r
- 0, // Provides33Volts :1;\r
- 0, // SharedSlot :1;\r
- 0, // PcCard16Supported :1;\r
- 0, // CardBusSupported :1;\r
- 0, // ZoomVideoSupported :1;\r
- 0, // ModemRingResumeSupported:1;\r
- },\r
- { // SlotCharacteristics2;\r
- 1, // PmeSignalSupported :1;\r
- 0, // HotPlugDevicesSupported :1;\r
- 1, // SmbusSignalSupported :1;\r
- 0, // Reserved :5; ///< Set to 0.\r
- },\r
- 0, // SegmentGroupNum;\r
- 2, // BusNum;\r
- 2, // DevFuncNum;\r
+SMBIOS_TABLE_TYPE9 mSysSlotInfoType9_1 = {\r
+ {EFI_SMBIOS_TYPE_SYSTEM_SLOTS, sizeof(SMBIOS_TABLE_TYPE9), 0},\r
+ 2, // SlotDesignation String\r
+ SlotTypePciExpressGen2X4, // SlotType; ///< The enumeration\r
+ // value from MISC_SLOT_TYPE.\r
+ SlotDataBusWidth1X, // SlotDataBusWidth; ///< The enumeration value\r
+ // from MISC_SLOT_DATA_BUS_WIDTH.\r
+ SlotUsageUnknown, // CurrentUsage; ///< The enumeration value\r
+ // from MISC_SLOT_USAGE.\r
+ SlotLengthShort, // SlotLength; ///< The enumeration value\r
+ // from MISC_SLOT_LENGTH.\r
+ 0, // SlotID;\r
+ {\r
+ // SlotCharacteristics1;\r
+ 1, // CharacteristicsUnknown :1;\r
+ 0, // Provides50Volts :1;\r
+ 0, // Provides33Volts :1;\r
+ 0, // SharedSlot :1;\r
+ 0, // PcCard16Supported :1;\r
+ 0, // CardBusSupported :1;\r
+ 0, // ZoomVideoSupported :1;\r
+ 0, // ModemRingResumeSupported:1;\r
+ },\r
+ {\r
+ // SlotCharacteristics2;\r
+ 1, // PmeSignalSupported :1;\r
+ 0, // HotPlugDevicesSupported :1;\r
+ 1, // SmbusSignalSupported :1;\r
+ 0, // Reserved :5; ///< Set to 0.\r
+ },\r
+ 0, // SegmentGroupNum;\r
+ 2, // BusNum;\r
+ 2, // DevFuncNum;\r
};\r
\r
-SMBIOS_TABLE_TYPE9 mSysSlotInfoType9_2 = {\r
- { EFI_SMBIOS_TYPE_SYSTEM_SLOTS, sizeof (SMBIOS_TABLE_TYPE9), 0 },\r
- 3, // SlotDesignation String\r
- SlotTypePciExpressGen2X8, // SlotType; ///< The enumeration value from MISC_SLOT_TYPE.\r
- SlotDataBusWidth4X, // SlotDataBusWidth; ///< The enumeration value from MISC_SLOT_DATA_BUS_WIDTH.\r
- SlotUsageUnknown, // CurrentUsage; ///< The enumeration value from MISC_SLOT_USAGE.\r
- SlotLengthShort, // SlotLength; ///< The enumeration value from MISC_SLOT_LENGTH.\r
- 0, // SlotID;\r
- { // SlotCharacteristics1;\r
- 1, // CharacteristicsUnknown :1;\r
- 0, // Provides50Volts :1;\r
- 0, // Provides33Volts :1;\r
- 0, // SharedSlot :1;\r
- 0, // PcCard16Supported :1;\r
- 0, // CardBusSupported :1;\r
- 0, // ZoomVideoSupported :1;\r
- 0, // ModemRingResumeSupported:1;\r
- },\r
- { // SlotCharacteristics2;\r
- 1, // PmeSignalSupported :1;\r
- 0, // HotPlugDevicesSupported :1;\r
- 1, // SmbusSignalSupported :1;\r
- 0, // Reserved :5; ///< Set to 0.\r
- },\r
- 0, // SegmentGroupNum;\r
- 2, // BusNum;\r
- 3, // DevFuncNum;\r
+SMBIOS_TABLE_TYPE9 mSysSlotInfoType9_2 = {\r
+ {EFI_SMBIOS_TYPE_SYSTEM_SLOTS, sizeof(SMBIOS_TABLE_TYPE9), 0},\r
+ 3, // SlotDesignation String\r
+ SlotTypePciExpressGen2X8, // SlotType; ///< The enumeration\r
+ // value from MISC_SLOT_TYPE.\r
+ SlotDataBusWidth4X, // SlotDataBusWidth; ///< The enumeration value\r
+ // from MISC_SLOT_DATA_BUS_WIDTH.\r
+ SlotUsageUnknown, // CurrentUsage; ///< The enumeration value\r
+ // from MISC_SLOT_USAGE.\r
+ SlotLengthShort, // SlotLength; ///< The enumeration value\r
+ // from MISC_SLOT_LENGTH.\r
+ 0, // SlotID;\r
+ {\r
+ // SlotCharacteristics1;\r
+ 1, // CharacteristicsUnknown :1;\r
+ 0, // Provides50Volts :1;\r
+ 0, // Provides33Volts :1;\r
+ 0, // SharedSlot :1;\r
+ 0, // PcCard16Supported :1;\r
+ 0, // CardBusSupported :1;\r
+ 0, // ZoomVideoSupported :1;\r
+ 0, // ModemRingResumeSupported:1;\r
+ },\r
+ {\r
+ // SlotCharacteristics2;\r
+ 1, // PmeSignalSupported :1;\r
+ 0, // HotPlugDevicesSupported :1;\r
+ 1, // SmbusSignalSupported :1;\r
+ 0, // Reserved :5; ///< Set to 0.\r
+ },\r
+ 0, // SegmentGroupNum;\r
+ 2, // BusNum;\r
+ 3, // DevFuncNum;\r
};\r
\r
-SMBIOS_TABLE_TYPE9 mSysSlotInfoType9_3 = {\r
- { EFI_SMBIOS_TYPE_SYSTEM_SLOTS, sizeof (SMBIOS_TABLE_TYPE9), 0 },\r
- 4, // SlotDesignation String\r
- SlotTypePciExpressGen2X16,// SlotType; ///< The enumeration value from MISC_SLOT_TYPE.\r
- SlotDataBusWidth4X, // SlotDataBusWidth; ///< The enumeration value from MISC_SLOT_DATA_BUS_WIDTH.\r
- SlotUsageUnknown, // CurrentUsage; ///< The enumeration value from MISC_SLOT_USAGE.\r
- SlotLengthShort, // SlotLength; ///< The enumeration value from MISC_SLOT_LENGTH.\r
- 0, // SlotID;\r
- { // SlotCharacteristics1;\r
- 1, // CharacteristicsUnknown :1;\r
- 0, // Provides50Volts :1;\r
- 0, // Provides33Volts :1;\r
- 0, // SharedSlot :1;\r
- 0, // PcCard16Supported :1;\r
- 0, // CardBusSupported :1;\r
- 0, // ZoomVideoSupported :1;\r
- 0, // ModemRingResumeSupported:1;\r
- },\r
- { // SlotCharacteristics2;\r
- 1, // PmeSignalSupported :1;\r
- 0, // HotPlugDevicesSupported :1;\r
- 1, // SmbusSignalSupported :1;\r
- 0, // Reserved :5; ///< Set to 0.\r
- },\r
- 0, // SegmentGroupNum;\r
- 2, // BusNum;\r
- 0xC // DevFuncNum;\r
+SMBIOS_TABLE_TYPE9 mSysSlotInfoType9_3 = {\r
+ {EFI_SMBIOS_TYPE_SYSTEM_SLOTS, sizeof(SMBIOS_TABLE_TYPE9), 0},\r
+ 4, // SlotDesignation String\r
+ SlotTypePciExpressGen2X16, // SlotType; ///< The enumeration\r
+ // value from MISC_SLOT_TYPE.\r
+ SlotDataBusWidth4X, // SlotDataBusWidth; ///< The enumeration value\r
+ // from MISC_SLOT_DATA_BUS_WIDTH.\r
+ SlotUsageUnknown, // CurrentUsage; ///< The enumeration value\r
+ // from MISC_SLOT_USAGE.\r
+ SlotLengthShort, // SlotLength; ///< The enumeration value\r
+ // from MISC_SLOT_LENGTH.\r
+ 0, // SlotID;\r
+ {\r
+ // SlotCharacteristics1;\r
+ 1, // CharacteristicsUnknown :1;\r
+ 0, // Provides50Volts :1;\r
+ 0, // Provides33Volts :1;\r
+ 0, // SharedSlot :1;\r
+ 0, // PcCard16Supported :1;\r
+ 0, // CardBusSupported :1;\r
+ 0, // ZoomVideoSupported :1;\r
+ 0, // ModemRingResumeSupported:1;\r
+ },\r
+ {\r
+ // SlotCharacteristics2;\r
+ 1, // PmeSignalSupported :1;\r
+ 0, // HotPlugDevicesSupported :1;\r
+ 1, // SmbusSignalSupported :1;\r
+ 0, // Reserved :5; ///< Set to 0.\r
+ },\r
+ 0, // SegmentGroupNum;\r
+ 2, // BusNum;\r
+ 0xC // DevFuncNum;\r
};\r
\r
CHAR8 *mSysSlotInfoType9Strings[] = {\r
- "PCIE Slot 0",\r
- "PCIE Slot 1",\r
- "PCIE Slot 2",\r
- "PCIE Slot 3",\r
- NULL\r
-};\r
-\r
+ "PCIE Slot 0", "PCIE Slot 1", "PCIE Slot 2", "PCIE Slot 3", NULL};\r
\r
/***********************************************************************\r
SMBIOS data definition TYPE 11 OEM Strings\r
************************************************************************/\r
\r
SMBIOS_TABLE_TYPE11 mOemStringsType11 = {\r
- { EFI_SMBIOS_TYPE_OEM_STRINGS, sizeof (SMBIOS_TABLE_TYPE11), 0 },\r
- 1 // StringCount\r
+ {EFI_SMBIOS_TYPE_OEM_STRINGS, sizeof(SMBIOS_TABLE_TYPE11), 0},\r
+ 1 // StringCount\r
};\r
CHAR8 *mOemStringsType11Strings[] = {\r
- "https://github.com/edk2-porting/edk2-sdm845",\r
- NULL\r
-};\r
+ "https://github.com/edk2-porting/edk2-sdm845", NULL};\r
\r
/***********************************************************************\r
SMBIOS data definition TYPE16 Physical Memory ArrayInformation\r
************************************************************************/\r
SMBIOS_TABLE_TYPE16 mPhyMemArrayInfoType16 = {\r
- { EFI_SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY, sizeof (SMBIOS_TABLE_TYPE16), 0 },\r
- MemoryArrayLocationSystemBoard, // Location; ///< The enumeration value from MEMORY_ARRAY_LOCATION.\r
- MemoryArrayUseSystemMemory, // Use; ///< The enumeration value from MEMORY_ARRAY_USE.\r
- MemoryErrorCorrectionNone, // MemoryErrorCorrection; ///< The enumeration value from MEMORY_ERROR_CORRECTION.\r
- 0x800000, // MaximumCapacity;\r
- 0xFFFE, // MemoryErrorInformationHandle;\r
- 1, // NumberOfMemoryDevices;\r
- 0x00000000ULL, // ExtendedMaximumCapacity;\r
-};\r
-CHAR8 *mPhyMemArrayInfoType16Strings[] = {\r
- NULL\r
+ {EFI_SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY, sizeof(SMBIOS_TABLE_TYPE16), 0},\r
+ MemoryArrayLocationSystemBoard, // Location; ///< The\r
+ // enumeration value from\r
+ // MEMORY_ARRAY_LOCATION.\r
+ MemoryArrayUseSystemMemory, // Use; ///< The\r
+ // enumeration value from MEMORY_ARRAY_USE.\r
+ MemoryErrorCorrectionNone, // MemoryErrorCorrection; ///< The\r
+ // enumeration value from\r
+ // MEMORY_ERROR_CORRECTION.\r
+ 0x800000, // MaximumCapacity;\r
+ 0xFFFE, // MemoryErrorInformationHandle;\r
+ 1, // NumberOfMemoryDevices;\r
+ 0x00000000ULL, // ExtendedMaximumCapacity;\r
};\r
+CHAR8 *mPhyMemArrayInfoType16Strings[] = {NULL};\r
\r
/***********************************************************************\r
SMBIOS data definition TYPE17 Memory Device Information\r
************************************************************************/\r
SMBIOS_TABLE_TYPE17 mMemDevInfoType17 = {\r
- { EFI_SMBIOS_TYPE_MEMORY_DEVICE, sizeof (SMBIOS_TABLE_TYPE17), 0 },\r
- 0, // MemoryArrayHandle; // Should match SMBIOS_TABLE_TYPE16.Handle, initialized at runtime, refer to PhyMemArrayInfoUpdateSmbiosType16()\r
- 0xFFFE, // MemoryErrorInformationHandle; (not provided)\r
- 64, // TotalWidth; (unknown)\r
- 64, // DataWidth; (unknown)\r
- 0x2000, // Size; // When bit 15 is 0: Size in MB\r
- // When bit 15 is 1: Size in KB, and continues in ExtendedSize\r
- // initialized at runtime, refer to PhyMemArrayInfoUpdateSmbiosType16()\r
- MemoryFormFactorRowOfChips, // FormFactor; ///< The enumeration value from MEMORY_FORM_FACTOR.\r
- 0, // DeviceSet;\r
- 1, // DeviceLocator String\r
- 2, // BankLocator String\r
- MemoryTypeLpddr4, // MemoryType; ///< The enumeration value from MEMORY_DEVICE_TYPE.\r
- { // TypeDetail;\r
- 0, // Reserved :1;\r
- 0, // Other :1;\r
- 0, // Unknown :1;\r
- 0, // FastPaged :1;\r
- 0, // StaticColumn :1;\r
- 0, // PseudoStatic :1;\r
- 0, // Rambus :1;\r
- 0, // Synchronous :1;\r
- 0, // Cmos :1;\r
- 0, // Edo :1;\r
- 0, // WindowDram :1;\r
- 0, // CacheDram :1;\r
- 0, // Nonvolatile :1;\r
- 0, // Registered :1;\r
- 1, // Unbuffered :1;\r
- 0, // Reserved1 :1;\r
- },\r
- 1866, // Speed; (unknown)\r
- 2, // Manufacturer String\r
- 0, // SerialNumber String\r
- 0, // AssetTag String\r
- 0, // PartNumber String\r
- 0, // Attributes; (unknown rank)\r
- 0, // ExtendedSize; (since Size < 32GB-1)\r
- 0, // ConfiguredMemoryClockSpeed; (unknown)\r
- 0, // MinimumVoltage; (unknown)\r
- 0, // MaximumVoltage; (unknown)\r
- 0, // ConfiguredVoltage; (unknown)\r
- MemoryTechnologyDram, // MemoryTechnology ///< The enumeration value from MEMORY_DEVICE_TECHNOLOGY\r
- {{ // MemoryOperatingModeCapability\r
- 0, // Reserved :1;\r
- 0, // Other :1;\r
- 0, // Unknown :1;\r
- 1, // VolatileMemory :1;\r
- 0, // ByteAccessiblePersistentMemory :1;\r
- 0, // BlockAccessiblePersistentMemory :1;\r
- 0 // Reserved :10;\r
- }},\r
- 0, // FirwareVersion\r
- 0, // ModuleManufacturerID (unknown)\r
- 0, // ModuleProductID (unknown)\r
- 0, // MemorySubsystemControllerManufacturerID (unknown)\r
- 0, // MemorySubsystemControllerProductID (unknown)\r
- 0, // NonVolatileSize\r
- 0xFFFFFFFFFFFFFFFFULL,// VolatileSize // initialized at runtime, refer to PhyMemArrayInfoUpdateSmbiosType16()\r
- 0, // CacheSize\r
- 0, // LogicalSize (since MemoryType is not MemoryTypeLogicalNonVolatileDevice)\r
- 0, // ExtendedSpeed,\r
- 0 // ExtendedConfiguredMemorySpeed\r
-};\r
-CHAR8 *mMemDevInfoType17Strings[] = {\r
- "Builtin",\r
- "BANK 0",\r
- NULL\r
+ {EFI_SMBIOS_TYPE_MEMORY_DEVICE, sizeof(SMBIOS_TABLE_TYPE17), 0},\r
+ 0, // MemoryArrayHandle; // Should match SMBIOS_TABLE_TYPE16.Handle,\r
+ // initialized at runtime, refer to PhyMemArrayInfoUpdateSmbiosType16()\r
+ 0xFFFE, // MemoryErrorInformationHandle; (not provided)\r
+ 64, // TotalWidth; (unknown)\r
+ 64, // DataWidth; (unknown)\r
+ 0x2000, // Size; // When bit 15 is 0: Size in MB\r
+ // When bit 15 is 1: Size in KB, and continues in ExtendedSize\r
+ // initialized at runtime, refer to\r
+ // PhyMemArrayInfoUpdateSmbiosType16()\r
+ MemoryFormFactorRowOfChips, // FormFactor; ///< The\r
+ // enumeration value from MEMORY_FORM_FACTOR.\r
+ 0, // DeviceSet;\r
+ 1, // DeviceLocator String\r
+ 2, // BankLocator String\r
+ MemoryTypeLpddr4, // MemoryType; ///< The enumeration\r
+ // value from MEMORY_DEVICE_TYPE.\r
+ {\r
+ // TypeDetail;\r
+ 0, // Reserved :1;\r
+ 0, // Other :1;\r
+ 0, // Unknown :1;\r
+ 0, // FastPaged :1;\r
+ 0, // StaticColumn :1;\r
+ 0, // PseudoStatic :1;\r
+ 0, // Rambus :1;\r
+ 0, // Synchronous :1;\r
+ 0, // Cmos :1;\r
+ 0, // Edo :1;\r
+ 0, // WindowDram :1;\r
+ 0, // CacheDram :1;\r
+ 0, // Nonvolatile :1;\r
+ 0, // Registered :1;\r
+ 1, // Unbuffered :1;\r
+ 0, // Reserved1 :1;\r
+ },\r
+ 1866, // Speed; (unknown)\r
+ 2, // Manufacturer String\r
+ 0, // SerialNumber String\r
+ 0, // AssetTag String\r
+ 0, // PartNumber String\r
+ 0, // Attributes; (unknown rank)\r
+ 0, // ExtendedSize; (since Size < 32GB-1)\r
+ 0, // ConfiguredMemoryClockSpeed; (unknown)\r
+ 0, // MinimumVoltage; (unknown)\r
+ 0, // MaximumVoltage; (unknown)\r
+ 0, // ConfiguredVoltage; (unknown)\r
+ MemoryTechnologyDram, // MemoryTechnology ///< The\r
+ // enumeration value from MEMORY_DEVICE_TECHNOLOGY\r
+ {{\r
+ // MemoryOperatingModeCapability\r
+ 0, // Reserved :1;\r
+ 0, // Other :1;\r
+ 0, // Unknown :1;\r
+ 1, // VolatileMemory :1;\r
+ 0, // ByteAccessiblePersistentMemory :1;\r
+ 0, // BlockAccessiblePersistentMemory :1;\r
+ 0 // Reserved :10;\r
+ }},\r
+ 0, // FirwareVersion\r
+ 0, // ModuleManufacturerID (unknown)\r
+ 0, // ModuleProductID (unknown)\r
+ 0, // MemorySubsystemControllerManufacturerID (unknown)\r
+ 0, // MemorySubsystemControllerProductID (unknown)\r
+ 0, // NonVolatileSize\r
+ 0xFFFFFFFFFFFFFFFFULL, // VolatileSize // initialized at runtime, refer to\r
+ // PhyMemArrayInfoUpdateSmbiosType16()\r
+ 0, // CacheSize\r
+ 0, // LogicalSize (since MemoryType is not\r
+ // MemoryTypeLogicalNonVolatileDevice)\r
+ 0, // ExtendedSpeed,\r
+ 0 // ExtendedConfiguredMemorySpeed\r
};\r
+CHAR8 *mMemDevInfoType17Strings[] = {"Builtin", "BANK 0", NULL};\r
\r
/***********************************************************************\r
SMBIOS data definition TYPE19 Memory Array Mapped Address Information\r
************************************************************************/\r
SMBIOS_TABLE_TYPE19 mMemArrMapInfoType19 = {\r
- { EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS, sizeof (SMBIOS_TABLE_TYPE19), 0 },\r
- 0xFFFFFFFF, // StartingAddress;\r
- 0xFFFFFFFF, // EndingAddress;\r
- 0, // MemoryArrayHandle; // Should match SMBIOS_TABLE_TYPE16.Handle, initialized at runtime, refer to PhyMemArrayInfoUpdateSmbiosType16()\r
- 1, // PartitionWidth;\r
- 0x080000000, // ExtendedStartingAddress; // not used\r
- 0x100000000, // ExtendedEndingAddress; // not used\r
-};\r
-CHAR8 *mMemArrMapInfoType19Strings[] = {\r
- NULL\r
+ {EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS, sizeof(SMBIOS_TABLE_TYPE19),\r
+ 0},\r
+ 0xFFFFFFFF, // StartingAddress;\r
+ 0xFFFFFFFF, // EndingAddress;\r
+ 0, // MemoryArrayHandle; // Should match SMBIOS_TABLE_TYPE16.Handle,\r
+ // initialized at runtime, refer to PhyMemArrayInfoUpdateSmbiosType16()\r
+ 1, // PartitionWidth;\r
+ 0x080000000, // ExtendedStartingAddress; // not used\r
+ 0x100000000, // ExtendedEndingAddress; // not used\r
};\r
+CHAR8 *mMemArrMapInfoType19Strings[] = {NULL};\r
\r
/***********************************************************************\r
SMBIOS data definition TYPE32 Boot Information\r
************************************************************************/\r
SMBIOS_TABLE_TYPE32 mBootInfoType32 = {\r
- { EFI_SMBIOS_TYPE_SYSTEM_BOOT_INFORMATION, sizeof (SMBIOS_TABLE_TYPE32), 0 },\r
- { 0, 0, 0, 0, 0, 0 }, // Reserved[6];\r
- BootInformationStatusNoError // BootStatus\r
+ {EFI_SMBIOS_TYPE_SYSTEM_BOOT_INFORMATION, sizeof(SMBIOS_TABLE_TYPE32), 0},\r
+ {0, 0, 0, 0, 0, 0}, // Reserved[6];\r
+ BootInformationStatusNoError // BootStatus\r
};\r
\r
-CHAR8 *mBootInfoType32Strings[] = {\r
- NULL\r
-};\r
+CHAR8 *mBootInfoType32Strings[] = {NULL};\r
\r
/**\r
\r
and terminated via a double NULL and add to SMBIOS table.\r
\r
SMBIOS_TABLE_TYPE32 gSmbiosType12 = {\r
- { EFI_SMBIOS_TYPE_SYSTEM_CONFIGURATION_OPTIONS, sizeof (SMBIOS_TABLE_TYPE12), 0 },\r
- 1 // StringCount\r
+ { EFI_SMBIOS_TYPE_SYSTEM_CONFIGURATION_OPTIONS, sizeof (SMBIOS_TABLE_TYPE12),\r
+0 }, 1 // StringCount\r
};\r
\r
CHAR8 *gSmbiosType12Strings[] = {\r
\r
EFI_STATUS\r
EFIAPI\r
-LogSmbiosData (\r
- IN EFI_SMBIOS_TABLE_HEADER *Template,\r
- IN CHAR8 **StringPack,\r
- OUT EFI_SMBIOS_HANDLE *DataSmbiosHandle\r
- )\r
+LogSmbiosData(\r
+ IN EFI_SMBIOS_TABLE_HEADER *Template, IN CHAR8 **StringPack,\r
+ OUT EFI_SMBIOS_HANDLE *DataSmbiosHandle)\r
{\r
- EFI_STATUS Status;\r
- EFI_SMBIOS_PROTOCOL *Smbios;\r
- EFI_SMBIOS_HANDLE SmbiosHandle;\r
- EFI_SMBIOS_TABLE_HEADER *Record;\r
- UINTN Index;\r
- UINTN StringSize;\r
- UINTN Size;\r
- CHAR8 *Str;\r
+ EFI_STATUS Status;\r
+ EFI_SMBIOS_PROTOCOL * Smbios;\r
+ EFI_SMBIOS_HANDLE SmbiosHandle;\r
+ EFI_SMBIOS_TABLE_HEADER *Record;\r
+ UINTN Index;\r
+ UINTN StringSize;\r
+ UINTN Size;\r
+ CHAR8 * Str;\r
\r
//\r
// Locate Smbios protocol.\r
//\r
- Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID**)&Smbios);\r
+ Status = gBS->LocateProtocol(&gEfiSmbiosProtocolGuid, NULL, (VOID **)&Smbios);\r
\r
- if (EFI_ERROR (Status)) {\r
+ if (EFI_ERROR(Status)) {\r
return Status;\r
}\r
\r
if (StringPack == NULL) {\r
// At least a double null is required\r
Size += 2;\r
- } else {\r
+ }\r
+ else {\r
for (Index = 0; StringPack[Index] != NULL; Index++) {\r
- StringSize = AsciiStrSize (StringPack[Index]);\r
+ StringSize = AsciiStrSize(StringPack[Index]);\r
Size += StringSize;\r
}\r
if (StringPack[0] == NULL) {\r
}\r
\r
// Copy over Template\r
- Record = (EFI_SMBIOS_TABLE_HEADER*)AllocateZeroPool (Size);\r
+ Record = (EFI_SMBIOS_TABLE_HEADER *)AllocateZeroPool(Size);\r
if (Record == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
- CopyMem (Record, Template, Template->Length);\r
+ CopyMem(Record, Template, Template->Length);\r
\r
// Append string pack\r
- Str = ((CHAR8*)Record) + Record->Length;\r
+ Str = ((CHAR8 *)Record) + Record->Length;\r
\r
for (Index = 0; StringPack[Index] != NULL; Index++) {\r
- StringSize = AsciiStrSize (StringPack[Index]);\r
- CopyMem (Str, StringPack[Index], StringSize);\r
+ StringSize = AsciiStrSize(StringPack[Index]);\r
+ CopyMem(Str, StringPack[Index], StringSize);\r
Str += StringSize;\r
}\r
\r
- *Str = 0;\r
+ *Str = 0;\r
SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;\r
- Status = Smbios->Add (\r
- Smbios,\r
- gImageHandle,\r
- &SmbiosHandle,\r
- Record\r
- );\r
+ Status = Smbios->Add(Smbios, gImageHandle, &SmbiosHandle, Record);\r
\r
if ((Status == EFI_SUCCESS) && (DataSmbiosHandle != NULL)) {\r
*DataSmbiosHandle = SmbiosHandle;\r
}\r
\r
- ASSERT_EFI_ERROR (Status);\r
- FreePool (Record);\r
+ ASSERT_EFI_ERROR(Status);\r
+ FreePool(Record);\r
return Status;\r
}\r
\r
EFI_STATUS\r
EFIAPI\r
-PlatformSmbiosDriverEntryPoint (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
- )\r
+PlatformSmbiosDriverEntryPoint(\r
+ IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)\r
{\r
EFI_SMBIOS_HANDLE SmbiosHandle;\r
\r
// TYPE0 BIOS Information\r
- AsciiSPrint (mBiosVersion, sizeof (mBiosVersion), "edk2-sdm845 %s", (CHAR16 *)FixedPcdGetPtr(PcdFirmwareVersionString));\r
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mBIOSInfoType0, mBIOSInfoType0Strings, NULL);\r
+ AsciiSPrint(\r
+ mBiosVersion, sizeof(mBiosVersion), "edk2-sdm845 %s",\r
+ (CHAR16 *)FixedPcdGetPtr(PcdFirmwareVersionString));\r
+ LogSmbiosData(\r
+ (EFI_SMBIOS_TABLE_HEADER *)&mBIOSInfoType0, mBIOSInfoType0Strings, NULL);\r
\r
// TYPE1 System Information\r
- AsciiStrCpyS (mSysInfoManufName, sizeof(mSysInfoManufName), (CHAR8*)PcdGetPtr(PcdDeviceVendor));\r
- AsciiStrCpyS (mSysInfoProductName, sizeof(mSysInfoProductName), (CHAR8*)PcdGetPtr(PcdDeviceProduct));\r
- AsciiStrCpyS (mSysInfoVersionName, sizeof(mSysInfoVersionName), (CHAR8*)PcdGetPtr(PcdDeviceCodeName));\r
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mSysInfoType1, mSysInfoType1Strings, NULL);\r
+ AsciiStrCpyS(\r
+ mSysInfoManufName, sizeof(mSysInfoManufName),\r
+ (CHAR8 *)PcdGetPtr(PcdDeviceVendor));\r
+ AsciiStrCpyS(\r
+ mSysInfoProductName, sizeof(mSysInfoProductName),\r
+ (CHAR8 *)PcdGetPtr(PcdDeviceProduct));\r
+ AsciiStrCpyS(\r
+ mSysInfoVersionName, sizeof(mSysInfoVersionName),\r
+ (CHAR8 *)PcdGetPtr(PcdDeviceCodeName));\r
+ LogSmbiosData(\r
+ (EFI_SMBIOS_TABLE_HEADER *)&mSysInfoType1, mSysInfoType1Strings, NULL);\r
\r
// TYPE3 Enclosure Information\r
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mEnclosureInfoType3, mEnclosureInfoType3Strings, &SmbiosHandle);\r
- mBoardInfoType2.ChassisHandle = (UINT16) SmbiosHandle;\r
+ LogSmbiosData(\r
+ (EFI_SMBIOS_TABLE_HEADER *)&mEnclosureInfoType3,\r
+ mEnclosureInfoType3Strings, &SmbiosHandle);\r
+ mBoardInfoType2.ChassisHandle = (UINT16)SmbiosHandle;\r
\r
// TYPE2 Board Information\r
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mBoardInfoType2, mBoardInfoType2Strings, NULL);\r
+ LogSmbiosData(\r
+ (EFI_SMBIOS_TABLE_HEADER *)&mBoardInfoType2, mBoardInfoType2Strings,\r
+ NULL);\r
\r
// TYPE7 Cache Information\r
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mCacheInfoType7_a75_L1I, mCacheInfoType7Strings, NULL);\r
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mCacheInfoType7_a55_L1I, mCacheInfoType7Strings, NULL);\r
-\r
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mCacheInfoType7_a75_L1D, mCacheInfoType7Strings, &SmbiosHandle);\r
- mProcessorInfoType4_a75.L1CacheHandle = (UINT16) SmbiosHandle;\r
-\r
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mCacheInfoType7_a55_L1D, mCacheInfoType7Strings, &SmbiosHandle);\r
- mProcessorInfoType4_a55.L1CacheHandle = (UINT16) SmbiosHandle;\r
-\r
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mCacheInfoType7_a75_L2, mCacheInfoType7Strings, &SmbiosHandle);\r
- mProcessorInfoType4_a75.L2CacheHandle = (UINT16) SmbiosHandle;\r
-\r
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mCacheInfoType7_a55_L2, mCacheInfoType7Strings, &SmbiosHandle);\r
- mProcessorInfoType4_a55.L2CacheHandle = (UINT16) SmbiosHandle;\r
+ LogSmbiosData(\r
+ (EFI_SMBIOS_TABLE_HEADER *)&mCacheInfoType7_a75_L1I,\r
+ mCacheInfoType7Strings, NULL);\r
+ LogSmbiosData(\r
+ (EFI_SMBIOS_TABLE_HEADER *)&mCacheInfoType7_a55_L1I,\r
+ mCacheInfoType7Strings, NULL);\r
+\r
+ LogSmbiosData(\r
+ (EFI_SMBIOS_TABLE_HEADER *)&mCacheInfoType7_a75_L1D,\r
+ mCacheInfoType7Strings, &SmbiosHandle);\r
+ mProcessorInfoType4_a75.L1CacheHandle = (UINT16)SmbiosHandle;\r
+\r
+ LogSmbiosData(\r
+ (EFI_SMBIOS_TABLE_HEADER *)&mCacheInfoType7_a55_L1D,\r
+ mCacheInfoType7Strings, &SmbiosHandle);\r
+ mProcessorInfoType4_a55.L1CacheHandle = (UINT16)SmbiosHandle;\r
+\r
+ LogSmbiosData(\r
+ (EFI_SMBIOS_TABLE_HEADER *)&mCacheInfoType7_a75_L2,\r
+ mCacheInfoType7Strings, &SmbiosHandle);\r
+ mProcessorInfoType4_a75.L2CacheHandle = (UINT16)SmbiosHandle;\r
+\r
+ LogSmbiosData(\r
+ (EFI_SMBIOS_TABLE_HEADER *)&mCacheInfoType7_a55_L2,\r
+ mCacheInfoType7Strings, &SmbiosHandle);\r
+ mProcessorInfoType4_a55.L2CacheHandle = (UINT16)SmbiosHandle;\r
\r
// TYPE4 Processor Information\r
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mProcessorInfoType4_a75, mProcessorInfoType4Strings, NULL);\r
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mProcessorInfoType4_a55, mProcessorInfoType4Strings, NULL);\r
+ LogSmbiosData(\r
+ (EFI_SMBIOS_TABLE_HEADER *)&mProcessorInfoType4_a75,\r
+ mProcessorInfoType4Strings, NULL);\r
+ LogSmbiosData(\r
+ (EFI_SMBIOS_TABLE_HEADER *)&mProcessorInfoType4_a55,\r
+ mProcessorInfoType4Strings, NULL);\r
\r
// TYPE9 System Slot Information\r
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mSysSlotInfoType9_0, mSysSlotInfoType9Strings, NULL);\r
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mSysSlotInfoType9_1, mSysSlotInfoType9Strings, NULL);\r
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mSysSlotInfoType9_2, mSysSlotInfoType9Strings, NULL);\r
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mSysSlotInfoType9_3, mSysSlotInfoType9Strings, NULL);\r
+ LogSmbiosData(\r
+ (EFI_SMBIOS_TABLE_HEADER *)&mSysSlotInfoType9_0, mSysSlotInfoType9Strings,\r
+ NULL);\r
+ LogSmbiosData(\r
+ (EFI_SMBIOS_TABLE_HEADER *)&mSysSlotInfoType9_1, mSysSlotInfoType9Strings,\r
+ NULL);\r
+ LogSmbiosData(\r
+ (EFI_SMBIOS_TABLE_HEADER *)&mSysSlotInfoType9_2, mSysSlotInfoType9Strings,\r
+ NULL);\r
+ LogSmbiosData(\r
+ (EFI_SMBIOS_TABLE_HEADER *)&mSysSlotInfoType9_3, mSysSlotInfoType9Strings,\r
+ NULL);\r
\r
// TYPE11 OEM Strings\r
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mOemStringsType11, mOemStringsType11Strings, NULL);\r
+ LogSmbiosData(\r
+ (EFI_SMBIOS_TABLE_HEADER *)&mOemStringsType11, mOemStringsType11Strings,\r
+ NULL);\r
\r
// TYPE16 Physical Memory Array Information\r
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mPhyMemArrayInfoType16, mPhyMemArrayInfoType16Strings, &SmbiosHandle);\r
- mMemDevInfoType17.MemoryArrayHandle = SmbiosHandle;\r
+ LogSmbiosData(\r
+ (EFI_SMBIOS_TABLE_HEADER *)&mPhyMemArrayInfoType16,\r
+ mPhyMemArrayInfoType16Strings, &SmbiosHandle);\r
+ mMemDevInfoType17.MemoryArrayHandle = SmbiosHandle;\r
mMemArrMapInfoType19.MemoryArrayHandle = SmbiosHandle;\r
\r
// TYPE17 Memory Device Information\r
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mMemDevInfoType17, mMemDevInfoType17Strings, NULL);\r
+ LogSmbiosData(\r
+ (EFI_SMBIOS_TABLE_HEADER *)&mMemDevInfoType17, mMemDevInfoType17Strings,\r
+ NULL);\r
\r
// TYPE19 Memory Array Map Information\r
- mMemArrMapInfoType19.ExtendedStartingAddress = PcdGet64 (PcdSystemMemoryBase);\r
- mMemArrMapInfoType19.ExtendedEndingAddress = PcdGet64 (PcdSystemMemoryBase) + PcdGet64 (PcdSystemMemorySize);\r
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mMemArrMapInfoType19, mMemArrMapInfoType19Strings, NULL);\r
+ mMemArrMapInfoType19.ExtendedStartingAddress = PcdGet64(PcdSystemMemoryBase);\r
+ mMemArrMapInfoType19.ExtendedEndingAddress =\r
+ PcdGet64(PcdSystemMemoryBase) + PcdGet64(PcdSystemMemorySize);\r
+ LogSmbiosData(\r
+ (EFI_SMBIOS_TABLE_HEADER *)&mMemArrMapInfoType19,\r
+ mMemArrMapInfoType19Strings, NULL);\r
\r
// TYPE32 Boot Information\r
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mBootInfoType32, mBootInfoType32Strings, NULL);\r
+ LogSmbiosData(\r
+ (EFI_SMBIOS_TABLE_HEADER *)&mBootInfoType32, mBootInfoType32Strings,\r
+ NULL);\r
\r
return EFI_SUCCESS;\r
}\r
/* SimpleFbDxe: Simple FrameBuffer */
-#include <PiDxe.h>
-#include <Uefi.h>
-#include <Library/UefiLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/DebugLib.h>
-#include <Library/PcdLib.h>
+#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
+#include <Library/CacheMaintenanceLib.h>
+#include <Library/DebugLib.h>
#include <Library/DxeServicesTableLib.h>
-#include <Protocol/GraphicsOutput.h>
-#include <Library/BaseLib.h>
#include <Library/FrameBufferBltLib.h>
-#include <Library/CacheMaintenanceLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/PcdLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+#include <PiDxe.h>
+#include <Protocol/GraphicsOutput.h>
+#include <Uefi.h>
/// Defines
/*
* Convert enum video_log2_bpp to bytes and bits. Note we omit the outer
* brackets to allow multiplication by fractional pixels.
*/
-#define VNBYTES(bpix) (1 << (bpix)) / 8
-#define VNBITS(bpix) (1 << (bpix))
+#define VNBYTES(bpix) (1 << (bpix)) / 8
+#define VNBITS(bpix) (1 << (bpix))
-#define FB_BITS_PER_PIXEL (32)
-#define FB_BYTES_PER_PIXEL (FB_BITS_PER_PIXEL / 8)
+#define FB_BITS_PER_PIXEL (32)
+#define FB_BYTES_PER_PIXEL (FB_BITS_PER_PIXEL / 8)
/*
* Bits per pixel selector. Each value n is such that the bits-per-pixel is
* 2 ^ n
*/
enum video_log2_bpp {
- VIDEO_BPP1 = 0,
- VIDEO_BPP2,
- VIDEO_BPP4,
- VIDEO_BPP8,
- VIDEO_BPP16,
- VIDEO_BPP32,
+ VIDEO_BPP1 = 0,
+ VIDEO_BPP2,
+ VIDEO_BPP4,
+ VIDEO_BPP8,
+ VIDEO_BPP16,
+ VIDEO_BPP32,
};
typedef struct {
VENDOR_DEVICE_PATH DisplayDevicePath;
- EFI_DEVICE_PATH EndDevicePath;
+ EFI_DEVICE_PATH EndDevicePath;
} DISPLAY_DEVICE_PATH;
-DISPLAY_DEVICE_PATH mDisplayDevicePath =
-{
- {
+DISPLAY_DEVICE_PATH mDisplayDevicePath = {
+ {{HARDWARE_DEVICE_PATH,
+ HW_VENDOR_DP,
{
- HARDWARE_DEVICE_PATH,
- HW_VENDOR_DP,
- {
(UINT8)(sizeof(VENDOR_DEVICE_PATH)),
(UINT8)((sizeof(VENDOR_DEVICE_PATH)) >> 8),
- }
- },
- EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID
- },
- {
- END_DEVICE_PATH_TYPE,
- END_ENTIRE_DEVICE_PATH_SUBTYPE,
- {
- sizeof(EFI_DEVICE_PATH_PROTOCOL),
- 0
- }
- }
-};
+ }},
+ EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID},
+ {END_DEVICE_PATH_TYPE,
+ END_ENTIRE_DEVICE_PATH_SUBTYPE,
+ {sizeof(EFI_DEVICE_PATH_PROTOCOL), 0}}};
/// Declares
-STATIC FRAME_BUFFER_CONFIGURE *mFrameBufferBltLibConfigure;
-STATIC UINTN mFrameBufferBltLibConfigureSize;
+STATIC FRAME_BUFFER_CONFIGURE *mFrameBufferBltLibConfigure;
+STATIC UINTN mFrameBufferBltLibConfigureSize;
STATIC
EFI_STATUS
EFIAPI
-DisplayQueryMode
-(
- IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
- IN UINT32 ModeNumber,
- OUT UINTN *SizeOfInfo,
- OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info
-);
+DisplayQueryMode(
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, IN UINT32 ModeNumber,
+ OUT UINTN *SizeOfInfo, OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info);
STATIC
EFI_STATUS
EFIAPI
-DisplaySetMode
-(
- IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
- IN UINT32 ModeNumber
-);
+DisplaySetMode(IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, IN UINT32 ModeNumber);
STATIC
EFI_STATUS
EFIAPI
-DisplayBlt
-(
- IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL
- IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,
- IN UINTN SourceX,
- IN UINTN SourceY,
- IN UINTN DestinationX,
- IN UINTN DestinationY,
- IN UINTN Width,
- IN UINTN Height,
- IN UINTN Delta OPTIONAL
-);
+DisplayBlt(
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL * BltBuffer,
+ OPTIONAL IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,
+ IN UINTN SourceX, IN UINTN SourceY, IN UINTN DestinationX,
+ IN UINTN DestinationY, IN UINTN Width, IN UINTN Height,
+ IN UINTN Delta OPTIONAL);
STATIC EFI_GRAPHICS_OUTPUT_PROTOCOL mDisplay = {
- DisplayQueryMode,
- DisplaySetMode,
- DisplayBlt,
- NULL
-};
+ DisplayQueryMode, DisplaySetMode, DisplayBlt, NULL};
STATIC
EFI_STATUS
EFIAPI
-DisplayQueryMode
-(
- IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
- IN UINT32 ModeNumber,
- OUT UINTN *SizeOfInfo,
- OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info
-)
+DisplayQueryMode(
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, IN UINT32 ModeNumber,
+ OUT UINTN *SizeOfInfo, OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info)
{
- EFI_STATUS Status;
- Status = gBS->AllocatePool(
- EfiBootServicesData,
- sizeof(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION),
- (VOID **) Info);
+ EFI_STATUS Status;
+ Status = gBS->AllocatePool(
+ EfiBootServicesData, sizeof(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION),
+ (VOID **)Info);
- ASSERT_EFI_ERROR(Status);
+ ASSERT_EFI_ERROR(Status);
- *SizeOfInfo = sizeof(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
- (*Info)->Version = This->Mode->Info->Version;
- (*Info)->HorizontalResolution = This->Mode->Info->HorizontalResolution;
- (*Info)->VerticalResolution = This->Mode->Info->VerticalResolution;
- (*Info)->PixelFormat = This->Mode->Info->PixelFormat;
- (*Info)->PixelsPerScanLine = This->Mode->Info->PixelsPerScanLine;
+ *SizeOfInfo = sizeof(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
+ (*Info)->Version = This->Mode->Info->Version;
+ (*Info)->HorizontalResolution = This->Mode->Info->HorizontalResolution;
+ (*Info)->VerticalResolution = This->Mode->Info->VerticalResolution;
+ (*Info)->PixelFormat = This->Mode->Info->PixelFormat;
+ (*Info)->PixelsPerScanLine = This->Mode->Info->PixelsPerScanLine;
- return EFI_SUCCESS;
+ return EFI_SUCCESS;
}
STATIC
EFI_STATUS
EFIAPI
-DisplaySetMode
-(
- IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
- IN UINT32 ModeNumber
-)
+DisplaySetMode(IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, IN UINT32 ModeNumber)
{
return EFI_SUCCESS;
}
STATIC
EFI_STATUS
EFIAPI
-DisplayBlt
-(
- IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL
- IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,
- IN UINTN SourceX,
- IN UINTN SourceY,
- IN UINTN DestinationX,
- IN UINTN DestinationY,
- IN UINTN Width,
- IN UINTN Height,
- IN UINTN Delta OPTIONAL
-)
+DisplayBlt(
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL * BltBuffer,
+ OPTIONAL IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,
+ IN UINTN SourceX, IN UINTN SourceY, IN UINTN DestinationX,
+ IN UINTN DestinationY, IN UINTN Width, IN UINTN Height,
+ IN UINTN Delta OPTIONAL)
{
- RETURN_STATUS Status;
- EFI_TPL Tpl;
+ RETURN_STATUS Status;
+ EFI_TPL Tpl;
//
- // We have to raise to TPL_NOTIFY, so we make an atomic write to the frame buffer.
- // We would not want a timer based event (Cursor, ...) to come in while we are
- // doing this operation.
+ // We have to raise to TPL_NOTIFY, so we make an atomic write to the frame
+ // buffer. We would not want a timer based event (Cursor, ...) to come in
+ // while we are doing this operation.
//
- Tpl = gBS->RaiseTPL (TPL_NOTIFY);
- Status = FrameBufferBlt (
- mFrameBufferBltLibConfigure,
- BltBuffer,
- BltOperation,
- SourceX, SourceY,
- DestinationX, DestinationY, Width, Height,
- Delta
- );
- gBS->RestoreTPL (Tpl);
-
- // zhuowei: hack: flush the cache manually since my memory maps are still broken
- WriteBackInvalidateDataCacheRange((void*)mDisplay.Mode->FrameBufferBase,
- mDisplay.Mode->FrameBufferSize);
+ Tpl = gBS->RaiseTPL(TPL_NOTIFY);
+ Status = FrameBufferBlt(
+ mFrameBufferBltLibConfigure, BltBuffer, BltOperation, SourceX, SourceY,
+ DestinationX, DestinationY, Width, Height, Delta);
+ gBS->RestoreTPL(Tpl);
+
+ // zhuowei: hack: flush the cache manually since my memory maps are still
+ // broken
+ WriteBackInvalidateDataCacheRange(
+ (void *)mDisplay.Mode->FrameBufferBase, mDisplay.Mode->FrameBufferSize);
// zhuowei: end hack
- return RETURN_ERROR (Status) ? EFI_INVALID_PARAMETER : EFI_SUCCESS;
+ return RETURN_ERROR(Status) ? EFI_INVALID_PARAMETER : EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
-SimpleFbDxeInitialize
-(
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
-)
+SimpleFbDxeInitialize(
+ IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
{
- EFI_STATUS Status = EFI_SUCCESS;
- EFI_HANDLE hUEFIDisplayHandle = NULL;
+ EFI_STATUS Status = EFI_SUCCESS;
+ EFI_HANDLE hUEFIDisplayHandle = NULL;
+
+ /* Retrieve simple frame buffer from pre-SEC bootloader */
+ DEBUG(
+ (EFI_D_ERROR,
+ "SimpleFbDxe: Retrieve MIPI FrameBuffer parameters from PCD\n"));
+ UINT32 MipiFrameBufferAddr = FixedPcdGet32(PcdMipiFrameBufferAddress);
+ UINT32 MipiFrameBufferWidth = FixedPcdGet32(PcdMipiFrameBufferWidth);
+ UINT32 MipiFrameBufferHeight = FixedPcdGet32(PcdMipiFrameBufferHeight);
+
+ /* Sanity check */
+ if (MipiFrameBufferAddr == 0 || MipiFrameBufferWidth == 0 ||
+ MipiFrameBufferHeight == 0) {
+ DEBUG((EFI_D_ERROR, "SimpleFbDxe: Invalid FrameBuffer parameters\n"));
+ return EFI_DEVICE_ERROR;
+ }
+
+ /* Prepare struct */
+ if (mDisplay.Mode == NULL) {
+ Status = gBS->AllocatePool(
+ EfiBootServicesData, sizeof(EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE),
+ (VOID **)&mDisplay.Mode);
- /* Retrieve simple frame buffer from pre-SEC bootloader */
- DEBUG((EFI_D_ERROR, "SimpleFbDxe: Retrieve MIPI FrameBuffer parameters from PCD\n"));
- UINT32 MipiFrameBufferAddr = FixedPcdGet32(PcdMipiFrameBufferAddress);
- UINT32 MipiFrameBufferWidth = FixedPcdGet32(PcdMipiFrameBufferWidth);
- UINT32 MipiFrameBufferHeight = FixedPcdGet32(PcdMipiFrameBufferHeight);
+ ASSERT_EFI_ERROR(Status);
+ if (EFI_ERROR(Status))
+ return Status;
- /* Sanity check */
- if (MipiFrameBufferAddr == 0 || MipiFrameBufferWidth == 0 || MipiFrameBufferHeight == 0)
- {
- DEBUG((EFI_D_ERROR, "SimpleFbDxe: Invalid FrameBuffer parameters\n"));
- return EFI_DEVICE_ERROR;
- }
+ ZeroMem(mDisplay.Mode, sizeof(EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE));
+ }
- /* Prepare struct */
- if (mDisplay.Mode == NULL)
- {
- Status = gBS->AllocatePool(
- EfiBootServicesData,
- sizeof(EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE),
- (VOID **) &mDisplay.Mode
- );
+ if (mDisplay.Mode->Info == NULL) {
+ Status = gBS->AllocatePool(
+ EfiBootServicesData, sizeof(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION),
+ (VOID **)&mDisplay.Mode->Info);
- ASSERT_EFI_ERROR(Status);
- if (EFI_ERROR(Status)) return Status;
+ ASSERT_EFI_ERROR(Status);
+ if (EFI_ERROR(Status))
+ return Status;
- ZeroMem(mDisplay.Mode, sizeof(EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE));
- }
-
- if (mDisplay.Mode->Info == NULL)
- {
- Status = gBS->AllocatePool(
- EfiBootServicesData,
- sizeof(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION),
- (VOID **) &mDisplay.Mode->Info
- );
-
- ASSERT_EFI_ERROR(Status);
- if (EFI_ERROR(Status)) return Status;
-
- ZeroMem(mDisplay.Mode->Info, sizeof(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));
- }
+ ZeroMem(mDisplay.Mode->Info, sizeof(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));
+ }
- /* Set information */
- mDisplay.Mode->MaxMode = 1;
- mDisplay.Mode->Mode = 0;
- mDisplay.Mode->Info->Version = 0;
-
- mDisplay.Mode->Info->HorizontalResolution = MipiFrameBufferWidth;
- mDisplay.Mode->Info->VerticalResolution = MipiFrameBufferHeight;
-
- /* SimpleFB runs on a8r8g8b8 (VIDEO_BPP32) for DB410c */
- UINT32 LineLength = MipiFrameBufferWidth * VNBYTES(VIDEO_BPP32);
- UINT32 FrameBufferSize = LineLength * MipiFrameBufferHeight;
- EFI_PHYSICAL_ADDRESS FrameBufferAddress = MipiFrameBufferAddr;
-
- mDisplay.Mode->Info->PixelsPerScanLine = MipiFrameBufferWidth;
- mDisplay.Mode->Info->PixelFormat = PixelBlueGreenRedReserved8BitPerColor;
- mDisplay.Mode->SizeOfInfo = sizeof(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
- mDisplay.Mode->FrameBufferBase = FrameBufferAddress;
- mDisplay.Mode->FrameBufferSize = FrameBufferSize;
-
- //
- // Create the FrameBufferBltLib configuration.
- //
- Status = FrameBufferBltConfigure (
- (VOID *) (UINTN) mDisplay.Mode->FrameBufferBase,
- mDisplay.Mode->Info,
- mFrameBufferBltLibConfigure,
- &mFrameBufferBltLibConfigureSize
- );
- if (Status == RETURN_BUFFER_TOO_SMALL) {
- mFrameBufferBltLibConfigure = AllocatePool (mFrameBufferBltLibConfigureSize);
- if (mFrameBufferBltLibConfigure != NULL) {
- Status = FrameBufferBltConfigure (
- (VOID *) (UINTN) mDisplay.Mode->FrameBufferBase,
- mDisplay.Mode->Info,
- mFrameBufferBltLibConfigure,
- &mFrameBufferBltLibConfigureSize
- );
- }
- }
- ASSERT_EFI_ERROR (Status);
-
- // zhuowei: clear the screen to black
- // UEFI standard requires this, since text is white - see OvmfPkg/QemuVideoDxe/Gop.c
- ZeroMem((void*)FrameBufferAddress, FrameBufferSize);
- // hack: clear cache
- WriteBackInvalidateDataCacheRange((void*)FrameBufferAddress, FrameBufferSize);
- // zhuowei: end
-
- /* Register handle */
- Status = gBS->InstallMultipleProtocolInterfaces(
- &hUEFIDisplayHandle,
- &gEfiDevicePathProtocolGuid,
- &mDisplayDevicePath,
- &gEfiGraphicsOutputProtocolGuid,
- &mDisplay,
- NULL);
-
- ASSERT_EFI_ERROR (Status);
-
- return Status;
+ /* Set information */
+ mDisplay.Mode->MaxMode = 1;
+ mDisplay.Mode->Mode = 0;
+ mDisplay.Mode->Info->Version = 0;
+
+ mDisplay.Mode->Info->HorizontalResolution = MipiFrameBufferWidth;
+ mDisplay.Mode->Info->VerticalResolution = MipiFrameBufferHeight;
+ /* SimpleFB runs on a8r8g8b8 (VIDEO_BPP32) for DB410c */
+ UINT32 LineLength = MipiFrameBufferWidth * VNBYTES(VIDEO_BPP32);
+ UINT32 FrameBufferSize = LineLength * MipiFrameBufferHeight;
+ EFI_PHYSICAL_ADDRESS FrameBufferAddress = MipiFrameBufferAddr;
+
+ mDisplay.Mode->Info->PixelsPerScanLine = MipiFrameBufferWidth;
+ mDisplay.Mode->Info->PixelFormat = PixelBlueGreenRedReserved8BitPerColor;
+ mDisplay.Mode->SizeOfInfo = sizeof(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
+ mDisplay.Mode->FrameBufferBase = FrameBufferAddress;
+ mDisplay.Mode->FrameBufferSize = FrameBufferSize;
+
+ //
+ // Create the FrameBufferBltLib configuration.
+ //
+ Status = FrameBufferBltConfigure(
+ (VOID *)(UINTN)mDisplay.Mode->FrameBufferBase, mDisplay.Mode->Info,
+ mFrameBufferBltLibConfigure, &mFrameBufferBltLibConfigureSize);
+ if (Status == RETURN_BUFFER_TOO_SMALL) {
+ mFrameBufferBltLibConfigure = AllocatePool(mFrameBufferBltLibConfigureSize);
+ if (mFrameBufferBltLibConfigure != NULL) {
+ Status = FrameBufferBltConfigure(
+ (VOID *)(UINTN)mDisplay.Mode->FrameBufferBase, mDisplay.Mode->Info,
+ mFrameBufferBltLibConfigure, &mFrameBufferBltLibConfigureSize);
+ }
+ }
+ ASSERT_EFI_ERROR(Status);
+
+ // zhuowei: clear the screen to black
+ // UEFI standard requires this, since text is white - see
+ // OvmfPkg/QemuVideoDxe/Gop.c
+ ZeroMem((void *)FrameBufferAddress, FrameBufferSize);
+ // hack: clear cache
+ WriteBackInvalidateDataCacheRange(
+ (void *)FrameBufferAddress, FrameBufferSize);
+ // zhuowei: end
+
+ /* Register handle */
+ Status = gBS->InstallMultipleProtocolInterfaces(
+ &hUEFIDisplayHandle, &gEfiDevicePathProtocolGuid, &mDisplayDevicePath,
+ &gEfiGraphicsOutputProtocolGuid, &mDisplay, NULL);
+
+ ASSERT_EFI_ERROR(Status);
+
+ return Status;
}
Copyright (c) 2015, ARM Limited. All rights reserved.
This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
+ are licensed and made available under the terms and conditions of the BSD
+License which accompanies this distribution. The full text of the license may
+be found at http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <PiDxe.h>
#include <Protocol/Smbios.h>
-#define TYPE0_STRINGS \
- "EFI Development Kit II / ARM LTD\0" /* Vendor */ \
- "EDK II\0" /* BiosVersion */ \
- __DATE__"\0" /* BiosReleaseDate */
-
-#define TYPE1_STRINGS \
- "Unknown Manufacturer\0" /* Manufacturer */ \
- "Unknown Device\0" /* Product Name */ \
- "Version Unknown\0" /* Version */ \
- " \0" /* 20 character buffer */
-
-#define TYPE2_STRINGS \
- "Unknown Manufacturer\0" /* Manufacturer */ \
- "Unknown Device\0" /* Product Name */ \
- "R0\0" /* Version */ \
- "Serial Not Set\0" /* Serial */ \
- "Base of Chassis\0" /* board location */ \
- "R1\0" /* Version */ \
- "R2\0" /* Version */
-
-#define TYPE3_STRINGS \
- "ARM LTD\0" /* Manufacturer */ \
- "Version SHIT\0" /* Version */ \
- "Serial Not Set\0" /* Serial */
-
-#define TYPE4_STRINGS \
- "BGA-1156\0" /* socket type */ \
- "ARM LTD\0" /* manufactuer */ \
- "Snapdragon 845 Extreme Edition\0" /* processor 1 description */ \
- "Snapdragon 845 Extreme Edition\0" /* processor 2 description */ \
- "Snapdragon 845 Extreme Edition\0" /* processor 2 description */ \
- "0xd03\0" /* A53 part number */ \
- "0xd07\0" /* A57 part number */ \
+#define TYPE0_STRINGS \
+ "EFI Development Kit II / ARM LTD\0" /* Vendor */ \
+ "EDK II\0" /* BiosVersion */ \
+ __DATE__ "\0" /* BiosReleaseDate */
+
+#define TYPE1_STRINGS \
+ "Unknown Manufacturer\0" /* Manufacturer */ \
+ "Unknown Device\0" /* Product Name */ \
+ "Version Unknown\0" /* Version */ \
+ " \0" /* 20 character buffer */
+
+#define TYPE2_STRINGS \
+ "Unknown Manufacturer\0" /* Manufacturer */ \
+ "Unknown Device\0" /* Product Name */ \
+ "R0\0" /* Version */ \
+ "Serial Not Set\0" /* Serial */ \
+ "Base of Chassis\0" /* board location */ \
+ "R1\0" /* Version */ \
+ "R2\0" /* Version */
+
+#define TYPE3_STRINGS \
+ "ARM LTD\0" /* Manufacturer */ \
+ "Version SHIT\0" /* Version */ \
+ "Serial Not Set\0" /* Serial */
+
+#define TYPE4_STRINGS \
+ "BGA-1156\0" /* socket type */ \
+ "ARM LTD\0" /* manufactuer */ \
+ "Snapdragon 845 Extreme Edition\0" /* processor 1 description */ \
+ "Snapdragon 845 Extreme Edition\0" /* processor 2 description */ \
+ "Snapdragon 845 Extreme Edition\0" /* processor 2 description */ \
+ "0xd03\0" /* A53 part number */ \
+ "0xd07\0" /* A57 part number */ \
"0xd08\0" /* A72 part number */
-#define TYPE7_STRINGS \
- "L1 Instruction\0" /* L1I */ \
- "L1 Data\0" /* L1D */ \
- "L2\0" /* L2 */
+#define TYPE7_STRINGS \
+ "L1 Instruction\0" /* L1I */ \
+ "L1 Data\0" /* L1D */ \
+ "L2\0" /* L2 */
-#define TYPE9_STRINGS \
- "PCIE_SLOT0\0" /* Slot0 */ \
- "PCIE_SLOT1\0" /* Slot1 */ \
- "PCIE_SLOT2\0" /* Slot2 */ \
- "PCIE_SLOT3\0" /* Slot3 */
+#define TYPE9_STRINGS \
+ "PCIE_SLOT0\0" /* Slot0 */ \
+ "PCIE_SLOT1\0" /* Slot1 */ \
+ "PCIE_SLOT2\0" /* Slot2 */ \
+ "PCIE_SLOT3\0" /* Slot3 */
-#define TYPE16_STRINGS \
- "\0" /* nothing */
+#define TYPE16_STRINGS "\0" /* nothing */
-#define TYPE17_STRINGS \
- "RIGHT SIDE\0" /* location */ \
- "BANK 0\0" /* bank description */
+#define TYPE17_STRINGS \
+ "RIGHT SIDE\0" /* location */ \
+ "BANK 0\0" /* bank description */
-#define TYPE19_STRINGS \
- "\0" /* nothing */
-
-#define TYPE32_STRINGS \
- "\0" /* nothing */
+#define TYPE19_STRINGS "\0" /* nothing */
+#define TYPE32_STRINGS "\0" /* nothing */
//
// Type definition and contents of the default SMBIOS table.
#pragma pack(1)
typedef struct {
SMBIOS_TABLE_TYPE0 Base;
- INT8 Strings[sizeof(TYPE0_STRINGS)];
+ INT8 Strings[sizeof(TYPE0_STRINGS)];
} ARM_TYPE0;
typedef struct {
typedef struct {
SMBIOS_TABLE_TYPE16 Base;
- UINT8 Strings[sizeof(TYPE16_STRINGS)];
+ UINT8 Strings[sizeof(TYPE16_STRINGS)];
} ARM_TYPE16;
typedef struct {
SMBIOS_TABLE_TYPE17 Base;
- UINT8 Strings[sizeof(TYPE17_STRINGS)];
+ UINT8 Strings[sizeof(TYPE17_STRINGS)];
} ARM_TYPE17;
typedef struct {
SMBIOS_TABLE_TYPE19 Base;
- UINT8 Strings[sizeof(TYPE19_STRINGS)];
+ UINT8 Strings[sizeof(TYPE19_STRINGS)];
} ARM_TYPE19;
typedef struct {
SMBIOS_TABLE_TYPE32 Base;
- UINT8 Strings[sizeof(TYPE32_STRINGS)];
+ UINT8 Strings[sizeof(TYPE32_STRINGS)];
} ARM_TYPE32;
// SMBIOS tables often reference each other using
SMBIOS_HANDLE_DIMM
};
-#define SERIAL_LEN 10 //this must be less than the buffer len allocated in the type1 structure
+#define SERIAL_LEN \
+ 10 // this must be less than the buffer len allocated in the type1 structure
#pragma pack()
// BIOS information (section 7.1)
STATIC ARM_TYPE0 mArmDefaultType0 = {
- {
- { // SMBIOS_STRUCTURE Hdr
- EFI_SMBIOS_TYPE_BIOS_INFORMATION, // UINT8 Type
- sizeof (SMBIOS_TABLE_TYPE0), // UINT8 Length
- SMBIOS_HANDLE_PI_RESERVED,
- },
- 1, // SMBIOS_TABLE_STRING Vendor
- 2, // SMBIOS_TABLE_STRING BiosVersion
- 0xE800,// UINT16 BiosSegment
- 3, // SMBIOS_TABLE_STRING BiosReleaseDate
- 0, // UINT8 BiosSize
{
- 0,0,0,0,0,0,
- 1, //PCI supported
- 0,
- 1, //PNP supported
- 0,
- 1, //BIOS upgradable
- 0, 0, 0,
- 1, //Boot from CD
- 1, //selectable boot
- }, // MISC_BIOS_CHARACTERISTICS BiosCharacteristics
- { // BIOSCharacteristicsExtensionBytes[2]
- 0x3,
- 0xC,
+ {
+ // SMBIOS_STRUCTURE Hdr
+ EFI_SMBIOS_TYPE_BIOS_INFORMATION, // UINT8 Type
+ sizeof(SMBIOS_TABLE_TYPE0), // UINT8 Length
+ SMBIOS_HANDLE_PI_RESERVED,
+ },
+ 1, // SMBIOS_TABLE_STRING Vendor
+ 2, // SMBIOS_TABLE_STRING BiosVersion
+ 0xE800, // UINT16 BiosSegment
+ 3, // SMBIOS_TABLE_STRING BiosReleaseDate
+ 0, // UINT8 BiosSize
+ {
+ 0, 0, 0, 0, 0, 0,
+ 1, // PCI supported
+ 0,
+ 1, // PNP supported
+ 0,
+ 1, // BIOS upgradable
+ 0, 0, 0,
+ 1, // Boot from CD
+ 1, // selectable boot
+ }, // MISC_BIOS_CHARACTERISTICS BiosCharacteristics
+ {
+ // BIOSCharacteristicsExtensionBytes[2]
+ 0x3,
+ 0xC,
+ },
+ 0, // UINT8 SystemBiosMajorRelease
+ 0, // UINT8 SystemBiosMinorRelease
+ 0xFF, // UINT8 EmbeddedControllerFirmwareMajorRelease
+ 0xFF // UINT8 EmbeddedControllerFirmwareMinorRelease
},
- 0, // UINT8 SystemBiosMajorRelease
- 0, // UINT8 SystemBiosMinorRelease
- 0xFF, // UINT8 EmbeddedControllerFirmwareMajorRelease
- 0xFF // UINT8 EmbeddedControllerFirmwareMinorRelease
- },
- // Text strings (unformatted area)
- TYPE0_STRINGS
-};
+ // Text strings (unformatted area)
+ TYPE0_STRINGS};
// System information (section 7.2)
STATIC CONST ARM_TYPE1 mArmDefaultType1 = {
- {
- { // SMBIOS_STRUCTURE Hdr
- EFI_SMBIOS_TYPE_SYSTEM_INFORMATION,
- sizeof(SMBIOS_TABLE_TYPE1),
- SMBIOS_HANDLE_PI_RESERVED,
+ {
+ {
+ // SMBIOS_STRUCTURE Hdr
+ EFI_SMBIOS_TYPE_SYSTEM_INFORMATION,
+ sizeof(SMBIOS_TABLE_TYPE1),
+ SMBIOS_HANDLE_PI_RESERVED,
+ },
+ 1, // Manufacturer
+ 2, // Product Name
+ 3, // Version
+ 4, // Serial
+ {0x8a95d198,
+ 0x7f46,
+ 0x11e5,
+ {0xbf, 0x8b, 0x08, 0x00, 0x27, 0x04, 0xd4, 0x8e}}, // UUID
+ 6, // Wakeup type
+ 0, // SKU
+ 0, // Family
},
- 1, //Manufacturer
- 2, //Product Name
- 3, //Version
- 4, //Serial
- { 0x8a95d198, 0x7f46, 0x11e5, { 0xbf,0x8b,0x08,0x00,0x27,0x04,0xd4,0x8e }}, //UUID
- 6, //Wakeup type
- 0, //SKU
- 0, //Family
- },
- // Text strings (unformatted)
- TYPE1_STRINGS
-};
+ // Text strings (unformatted)
+ TYPE1_STRINGS};
// Baseboard (section 7.3)
STATIC ARM_TYPE2 mArmDefaultType2 = {
- {
- { // SMBIOS_STRUCTURE Hdr
- EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION, // UINT8 Type
- sizeof (SMBIOS_TABLE_TYPE2), // UINT8 Length
- SMBIOS_HANDLE_MOTHERBOARD,
+ {
+ {
+ // SMBIOS_STRUCTURE Hdr
+ EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION, // UINT8 Type
+ sizeof(SMBIOS_TABLE_TYPE2), // UINT8 Length
+ SMBIOS_HANDLE_MOTHERBOARD,
+ },
+ 1, // Manufacturer
+ 2, // Product Name
+ 3, // Version
+ 4, // Serial
+ 0, // Asset tag
+ {1}, // motherboard, not replaceable
+ 5, // location of board
+ SMBIOS_HANDLE_CHASSIS,
+ BaseBoardTypeMotherBoard,
+ 1,
+ {SMBIOS_HANDLE_A53_CLUSTER}, //,SMBIOS_HANDLE_A53_CLUSTER,SMBIOS_HANDLE_MEMORY},
},
- 1, //Manufacturer
- 2, //Product Name
- 3, //Version
- 4, //Serial
- 0, //Asset tag
- {1}, //motherboard, not replaceable
- 5, //location of board
- SMBIOS_HANDLE_CHASSIS,
- BaseBoardTypeMotherBoard,
- 1,
- {SMBIOS_HANDLE_A53_CLUSTER}, //,SMBIOS_HANDLE_A53_CLUSTER,SMBIOS_HANDLE_MEMORY},
- },
- TYPE2_STRINGS
-};
+ TYPE2_STRINGS};
// Enclosure
STATIC CONST ARM_TYPE3 mArmDefaultType3 = {
- {
- { // SMBIOS_STRUCTURE Hdr
- EFI_SMBIOS_TYPE_SYSTEM_ENCLOSURE, // UINT8 Type
- sizeof (SMBIOS_TABLE_TYPE3), // UINT8 Length
- SMBIOS_HANDLE_CHASSIS,
+ {
+ {
+ // SMBIOS_STRUCTURE Hdr
+ EFI_SMBIOS_TYPE_SYSTEM_ENCLOSURE, // UINT8 Type
+ sizeof(SMBIOS_TABLE_TYPE3), // UINT8 Length
+ SMBIOS_HANDLE_CHASSIS,
+ },
+ 1, // Manufacturer
+ 4, // enclosure type (low profile desktop)
+ 2, // version
+ 3, // serial
+ 0, // asset tag
+ ChassisStateUnknown, // boot chassis state
+ ChassisStateSafe, // power supply state
+ ChassisStateSafe, // thermal state
+ ChassisSecurityStatusNone, // security state
+ {
+ 0,
+ 0,
+ 0,
+ 0,
+ }, // OEM defined
+ 1, // 1U height
+ 1, // number of power cords
+ 0, // no contained elements
},
- 1, //Manufacturer
- 4, //enclosure type (low profile desktop)
- 2, //version
- 3, //serial
- 0, //asset tag
- ChassisStateUnknown, //boot chassis state
- ChassisStateSafe, //power supply state
- ChassisStateSafe, //thermal state
- ChassisSecurityStatusNone, //security state
- {0,0,0,0,}, //OEM defined
- 1, //1U height
- 1, //number of power cords
- 0, //no contained elements
- },
- TYPE3_STRINGS
-};
+ TYPE3_STRINGS};
// Processor
STATIC CONST ARM_TYPE4 mArmDefaultType4_a72 = {
- {
- { // SMBIOS_STRUCTURE Hdr
- EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION, // UINT8 Type
- sizeof (SMBIOS_TABLE_TYPE4), // UINT8 Length
- SMBIOS_HANDLE_A72_CLUSTER,
+ {
+ {
+ // SMBIOS_STRUCTURE Hdr
+ EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION, // UINT8 Type
+ sizeof(SMBIOS_TABLE_TYPE4), // UINT8 Length
+ SMBIOS_HANDLE_A72_CLUSTER,
+ },
+ 1, // socket type
+ 3, // processor type CPU
+ ProcessorFamilyIndicatorFamily2, // processor family, acquire from
+ // field2
+ 2, // manufactuer
+ {{
+ 0,
+ },
+ {0.}}, // processor id
+ 5, // version
+ {0, 0, 0, 0, 0, 1}, // voltage
+ 0, // external clock
+ 1200, // max speed
+ 1200, // current speed
+ 0x41, // status
+ ProcessorUpgradeOther,
+ SMBIOS_HANDLE_A57_L1I, // l1 cache handle
+ SMBIOS_HANDLE_A57_L2, // l2 cache handle
+ 0xFFFF, // l3 cache handle
+ 0, // serial not set
+ 0, // asset not set
+ 8, // part number
+ 2, // core count in socket
+ 2, // enabled core count in socket
+ 0, // threads per socket
+ 0xEC, // processor characteristics
+ ProcessorFamilyARM, // ARM core
},
- 1, //socket type
- 3, //processor type CPU
- ProcessorFamilyIndicatorFamily2, //processor family, acquire from field2
- 2, //manufactuer
- {{0,},{0.}}, //processor id
- 5, //version
- {0,0,0,0,0,1}, //voltage
- 0, //external clock
- 1200, //max speed
- 1200, //current speed
- 0x41, //status
- ProcessorUpgradeOther,
- SMBIOS_HANDLE_A57_L1I, //l1 cache handle
- SMBIOS_HANDLE_A57_L2, //l2 cache handle
- 0xFFFF, //l3 cache handle
- 0, //serial not set
- 0, //asset not set
- 8, //part number
- 2, //core count in socket
- 2, //enabled core count in socket
- 0, //threads per socket
- 0xEC, // processor characteristics
- ProcessorFamilyARM, //ARM core
- },
- TYPE4_STRINGS
-};
+ TYPE4_STRINGS};
STATIC CONST ARM_TYPE4 mArmDefaultType4_a57 = {
- {
- { // SMBIOS_STRUCTURE Hdr
- EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION, // UINT8 Type
- sizeof (SMBIOS_TABLE_TYPE4), // UINT8 Length
- SMBIOS_HANDLE_A57_CLUSTER,
+ {
+ {
+ // SMBIOS_STRUCTURE Hdr
+ EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION, // UINT8 Type
+ sizeof(SMBIOS_TABLE_TYPE4), // UINT8 Length
+ SMBIOS_HANDLE_A57_CLUSTER,
+ },
+ 1, // socket type
+ 3, // processor type CPU
+ ProcessorFamilyIndicatorFamily2, // processor family, acquire from
+ // field2
+ 2, // manufactuer
+ {{
+ 0,
+ },
+ {0.}}, // processor id
+ 3, // version
+ {0, 0, 0, 0, 0, 1}, // voltage
+ 0, // external clock
+ 1200, // max speed
+ 1200, // current speed
+ 0x41, // status
+ ProcessorUpgradeOther,
+ SMBIOS_HANDLE_A57_L1I, // l1 cache handle
+ SMBIOS_HANDLE_A57_L2, // l2 cache handle
+ 0xFFFF, // l3 cache handle
+ 0, // serial not set
+ 0, // asset not set
+ 7, // part number
+ 2, // core count in socket
+ 2, // enabled core count in socket
+ 0, // threads per socket
+ 0xEC, // processor characteristics
+ ProcessorFamilyARM, // ARM core
},
- 1, //socket type
- 3, //processor type CPU
- ProcessorFamilyIndicatorFamily2, //processor family, acquire from field2
- 2, //manufactuer
- {{0,},{0.}}, //processor id
- 3, //version
- {0,0,0,0,0,1}, //voltage
- 0, //external clock
- 1200, //max speed
- 1200, //current speed
- 0x41, //status
- ProcessorUpgradeOther,
- SMBIOS_HANDLE_A57_L1I, //l1 cache handle
- SMBIOS_HANDLE_A57_L2, //l2 cache handle
- 0xFFFF, //l3 cache handle
- 0, //serial not set
- 0, //asset not set
- 7, //part number
- 2, //core count in socket
- 2, //enabled core count in socket
- 0, //threads per socket
- 0xEC, // processor characteristics
- ProcessorFamilyARM, //ARM core
- },
- TYPE4_STRINGS
-};
+ TYPE4_STRINGS};
STATIC CONST ARM_TYPE4 mArmDefaultType4_a53 = {
- {
- { // SMBIOS_STRUCTURE Hdr
- EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION, // UINT8 Type
- sizeof (SMBIOS_TABLE_TYPE4), // UINT8 Length
- SMBIOS_HANDLE_A53_CLUSTER,
+ {
+ {
+ // SMBIOS_STRUCTURE Hdr
+ EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION, // UINT8 Type
+ sizeof(SMBIOS_TABLE_TYPE4), // UINT8 Length
+ SMBIOS_HANDLE_A53_CLUSTER,
+ },
+ 1, // socket type
+ 3, // processor type CPU
+ ProcessorFamilyIndicatorFamily2, // processor family, acquire from
+ // field2
+ 2, // manufactuer
+ {{
+ 0,
+ },
+ {0.}}, // processor id
+ 4, // version
+ {0, 0, 0, 0, 0, 1}, // voltage
+ 0, // external clock
+ 650, // max speed
+ 650, // current speed
+ 0x41, // status
+ ProcessorUpgradeOther,
+ SMBIOS_HANDLE_A53_L1I, // l1 cache handle
+ SMBIOS_HANDLE_A53_L2, // l2 cache handle
+ 0xFFFF, // l3 cache handle
+ 0, // serial not set
+ 0, // asset not set
+ 6, // part number
+ 4, // core count in socket
+ 4, // enabled core count in socket
+ 0, // threads per socket
+ 0xEC, // processor characteristics
+ ProcessorFamilyARM, // ARM core
},
- 1, //socket type
- 3, //processor type CPU
- ProcessorFamilyIndicatorFamily2, //processor family, acquire from field2
- 2, //manufactuer
- {{0,},{0.}}, //processor id
- 4, //version
- {0,0,0,0,0,1}, //voltage
- 0, //external clock
- 650, //max speed
- 650, //current speed
- 0x41, //status
- ProcessorUpgradeOther,
- SMBIOS_HANDLE_A53_L1I, //l1 cache handle
- SMBIOS_HANDLE_A53_L2, //l2 cache handle
- 0xFFFF, //l3 cache handle
- 0, //serial not set
- 0, //asset not set
- 6, //part number
- 4, //core count in socket
- 4, //enabled core count in socket
- 0, //threads per socket
- 0xEC, // processor characteristics
- ProcessorFamilyARM, //ARM core
- },
- TYPE4_STRINGS
-};
+ TYPE4_STRINGS};
// Cache
STATIC CONST ARM_TYPE7 mArmDefaultType7_a57_l1i = {
- {
- { // SMBIOS_STRUCTURE Hdr
- EFI_SMBIOS_TYPE_CACHE_INFORMATION, // UINT8 Type
- sizeof (SMBIOS_TABLE_TYPE7), // UINT8 Length
- SMBIOS_HANDLE_A57_L1I,
+ {
+ {
+ // SMBIOS_STRUCTURE Hdr
+ EFI_SMBIOS_TYPE_CACHE_INFORMATION, // UINT8 Type
+ sizeof(SMBIOS_TABLE_TYPE7), // UINT8 Length
+ SMBIOS_HANDLE_A57_L1I,
+ },
+ 1,
+ 0x380, // L1 enabled, unknown WB
+ 48, // 48k i cache max
+ 48, // 48k installed
+ {0, 1}, // SRAM type
+ {0, 1}, // SRAM type
+ 0, // unkown speed
+ CacheErrorParity, // parity checking
+ CacheTypeInstruction, // instruction cache
+ CacheAssociativityOther, // three way
},
- 1,
- 0x380, //L1 enabled, unknown WB
- 48, //48k i cache max
- 48, //48k installed
- {0,1}, //SRAM type
- {0,1}, //SRAM type
- 0, //unkown speed
- CacheErrorParity, //parity checking
- CacheTypeInstruction, //instruction cache
- CacheAssociativityOther, //three way
- },
- TYPE7_STRINGS
-};
+ TYPE7_STRINGS};
STATIC CONST ARM_TYPE7 mArmDefaultType7_a53_l1i = {
- {
- { // SMBIOS_STRUCTURE Hdr
- EFI_SMBIOS_TYPE_CACHE_INFORMATION, // UINT8 Type
- sizeof (SMBIOS_TABLE_TYPE7), // UINT8 Length
- SMBIOS_HANDLE_A53_L1I,
+ {
+ {
+ // SMBIOS_STRUCTURE Hdr
+ EFI_SMBIOS_TYPE_CACHE_INFORMATION, // UINT8 Type
+ sizeof(SMBIOS_TABLE_TYPE7), // UINT8 Length
+ SMBIOS_HANDLE_A53_L1I,
+ },
+ 1,
+ 0x380, // L1 enabled, unknown WB
+ 32, // 32k i cache max
+ 32, // 32k installed
+ {0, 1}, // SRAM type
+ {0, 1}, // SRAM type
+ 0, // unkown speed
+ CacheErrorParity, // parity checking
+ CacheTypeInstruction, // instruction cache
+ CacheAssociativity2Way, // two way
},
- 1,
- 0x380, //L1 enabled, unknown WB
- 32, //32k i cache max
- 32, //32k installed
- {0,1}, //SRAM type
- {0,1}, //SRAM type
- 0, //unkown speed
- CacheErrorParity, //parity checking
- CacheTypeInstruction, //instruction cache
- CacheAssociativity2Way, //two way
- },
- TYPE7_STRINGS
-};
+ TYPE7_STRINGS};
STATIC CONST ARM_TYPE7 mArmDefaultType7_a57_l1d = {
- {
- { // SMBIOS_STRUCTURE Hdr
- EFI_SMBIOS_TYPE_CACHE_INFORMATION, // UINT8 Type
- sizeof (SMBIOS_TABLE_TYPE7), // UINT8 Length
- SMBIOS_HANDLE_A57_L1D,
+ {
+ {
+ // SMBIOS_STRUCTURE Hdr
+ EFI_SMBIOS_TYPE_CACHE_INFORMATION, // UINT8 Type
+ sizeof(SMBIOS_TABLE_TYPE7), // UINT8 Length
+ SMBIOS_HANDLE_A57_L1D,
+ },
+ 2,
+ 0x180, // L1 enabled, WB
+ 32, // 32k d cache max
+ 32, // 32k installed
+ {0, 1}, // SRAM type
+ {0, 1}, // SRAM type
+ 0, // unkown speed
+ CacheErrorSingleBit, // ECC checking
+ CacheTypeData, // instruction cache
+ CacheAssociativity2Way, // two way associative
},
- 2,
- 0x180, //L1 enabled, WB
- 32, //32k d cache max
- 32, //32k installed
- {0,1}, //SRAM type
- {0,1}, //SRAM type
- 0, //unkown speed
- CacheErrorSingleBit, //ECC checking
- CacheTypeData, //instruction cache
- CacheAssociativity2Way, //two way associative
- },
- TYPE7_STRINGS
-};
+ TYPE7_STRINGS};
STATIC CONST ARM_TYPE7 mArmDefaultType7_a53_l1d = {
- {
- { // SMBIOS_STRUCTURE Hdr
- EFI_SMBIOS_TYPE_CACHE_INFORMATION, // UINT8 Type
- sizeof (SMBIOS_TABLE_TYPE7), // UINT8 Length
- SMBIOS_HANDLE_A53_L1D,
+ {
+ {
+ // SMBIOS_STRUCTURE Hdr
+ EFI_SMBIOS_TYPE_CACHE_INFORMATION, // UINT8 Type
+ sizeof(SMBIOS_TABLE_TYPE7), // UINT8 Length
+ SMBIOS_HANDLE_A53_L1D,
+ },
+ 2,
+ 0x180, // L1 enabled, WB
+ 32, // 32k d cache max
+ 32, // 32k installed
+ {0, 1}, // SRAM type
+ {0, 1}, // SRAM type
+ 0, // unkown speed
+ CacheErrorSingleBit, // ECC checking
+ CacheTypeData, // instruction cache
+ CacheAssociativity4Way, // four way associative
},
- 2,
- 0x180, //L1 enabled, WB
- 32, //32k d cache max
- 32, //32k installed
- {0,1}, //SRAM type
- {0,1}, //SRAM type
- 0, //unkown speed
- CacheErrorSingleBit, //ECC checking
- CacheTypeData, //instruction cache
- CacheAssociativity4Way, //four way associative
- },
- TYPE7_STRINGS
-};
+ TYPE7_STRINGS};
STATIC CONST ARM_TYPE7 mArmDefaultType7_a57_l2 = {
- {
- { // SMBIOS_STRUCTURE Hdr
- EFI_SMBIOS_TYPE_CACHE_INFORMATION, // UINT8 Type
- sizeof (SMBIOS_TABLE_TYPE7), // UINT8 Length
- SMBIOS_HANDLE_A57_L2,
+ {
+ {
+ // SMBIOS_STRUCTURE Hdr
+ EFI_SMBIOS_TYPE_CACHE_INFORMATION, // UINT8 Type
+ sizeof(SMBIOS_TABLE_TYPE7), // UINT8 Length
+ SMBIOS_HANDLE_A57_L2,
+ },
+ 3,
+ 0x181, // L2 enabled, WB
+ 2048, // 2M d cache max
+ 2048, // 2M installed
+ {0, 1}, // SRAM type
+ {0, 1}, // SRAM type
+ 0, // unkown speed
+ CacheErrorSingleBit, // ECC checking
+ CacheTypeUnified, // instruction cache
+ CacheAssociativity16Way, // 16 way associative
},
- 3,
- 0x181, //L2 enabled, WB
- 2048, //2M d cache max
- 2048, //2M installed
- {0,1}, //SRAM type
- {0,1}, //SRAM type
- 0, //unkown speed
- CacheErrorSingleBit, //ECC checking
- CacheTypeUnified, //instruction cache
- CacheAssociativity16Way, //16 way associative
- },
- TYPE7_STRINGS
-};
+ TYPE7_STRINGS};
STATIC CONST ARM_TYPE7 mArmDefaultType7_a53_l2 = {
- {
- { // SMBIOS_STRUCTURE Hdr
- EFI_SMBIOS_TYPE_CACHE_INFORMATION, // UINT8 Type
- sizeof (SMBIOS_TABLE_TYPE7), // UINT8 Length
- SMBIOS_HANDLE_A53_L2,
+ {
+ {
+ // SMBIOS_STRUCTURE Hdr
+ EFI_SMBIOS_TYPE_CACHE_INFORMATION, // UINT8 Type
+ sizeof(SMBIOS_TABLE_TYPE7), // UINT8 Length
+ SMBIOS_HANDLE_A53_L2,
+ },
+ 3,
+ 0x181, // L2 enabled, WB
+ 1024, // 1M D cache max
+ 1024, // 1M installed
+ {0, 1}, // SRAM type
+ {0, 1}, // SRAM type
+ 0, // unkown speed
+ CacheErrorSingleBit, // ECC checking
+ CacheTypeUnified, // instruction cache
+ CacheAssociativity16Way, // 16 way associative
},
- 3,
- 0x181, //L2 enabled, WB
- 1024, //1M D cache max
- 1024, //1M installed
- {0,1}, //SRAM type
- {0,1}, //SRAM type
- 0, //unkown speed
- CacheErrorSingleBit, //ECC checking
- CacheTypeUnified, //instruction cache
- CacheAssociativity16Way, //16 way associative
- },
- TYPE7_STRINGS
-};
+ TYPE7_STRINGS};
// Slots
STATIC CONST ARM_TYPE9 mArmDefaultType9_0 = {
- {
- { // SMBIOS_STRUCTURE Hdr
- EFI_SMBIOS_TYPE_SYSTEM_SLOTS, // UINT8 Type
- sizeof (SMBIOS_TABLE_TYPE9), // UINT8 Length
- SMBIOS_HANDLE_PI_RESERVED,
+ {
+ {
+ // SMBIOS_STRUCTURE Hdr
+ EFI_SMBIOS_TYPE_SYSTEM_SLOTS, // UINT8 Type
+ sizeof(SMBIOS_TABLE_TYPE9), // UINT8 Length
+ SMBIOS_HANDLE_PI_RESERVED,
+ },
+ 1, // slot 0
+ SlotTypePciExpressGen2X4,
+ SlotDataBusWidth1X,
+ SlotUsageUnknown,
+ SlotLengthShort,
+ 0,
+ {1}, // unknown
+ {1, 0, 1}, // PME and SMBUS
+ 0,
+ 2,
+ 1,
},
- 1, //slot 0
- SlotTypePciExpressGen2X4,
- SlotDataBusWidth1X,
- SlotUsageUnknown,
- SlotLengthShort,
- 0,
- {1}, //unknown
- {1,0,1}, //PME and SMBUS
- 0,
- 2,
- 1,
- },
- TYPE9_STRINGS
-};
+ TYPE9_STRINGS};
STATIC CONST ARM_TYPE9 mArmDefaultType9_1 = {
- {
- { // SMBIOS_STRUCTURE Hdr
- EFI_SMBIOS_TYPE_SYSTEM_SLOTS, // UINT8 Type
- sizeof (SMBIOS_TABLE_TYPE9), // UINT8 Length
- SMBIOS_HANDLE_PI_RESERVED,
+ {
+ {
+ // SMBIOS_STRUCTURE Hdr
+ EFI_SMBIOS_TYPE_SYSTEM_SLOTS, // UINT8 Type
+ sizeof(SMBIOS_TABLE_TYPE9), // UINT8 Length
+ SMBIOS_HANDLE_PI_RESERVED,
+ },
+ 1, // slot 0
+ SlotTypePciExpressGen2X4,
+ SlotDataBusWidth1X,
+ SlotUsageUnknown,
+ SlotLengthShort,
+ 0,
+ {1},
+ {1, 0, 1}, // PME and SMBUS
+ 0,
+ 2,
+ 2,
},
- 1, //slot 0
- SlotTypePciExpressGen2X4,
- SlotDataBusWidth1X,
- SlotUsageUnknown,
- SlotLengthShort,
- 0,
- {1},
- {1,0,1}, //PME and SMBUS
- 0,
- 2,
- 2,
- },
- TYPE9_STRINGS
-};
+ TYPE9_STRINGS};
STATIC CONST ARM_TYPE9 mArmDefaultType9_2 = {
- {
- { // SMBIOS_STRUCTURE Hdr
- EFI_SMBIOS_TYPE_SYSTEM_SLOTS, // UINT8 Type
- sizeof (SMBIOS_TABLE_TYPE9), // UINT8 Length
- SMBIOS_HANDLE_PI_RESERVED,
+ {
+ {
+ // SMBIOS_STRUCTURE Hdr
+ EFI_SMBIOS_TYPE_SYSTEM_SLOTS, // UINT8 Type
+ sizeof(SMBIOS_TABLE_TYPE9), // UINT8 Length
+ SMBIOS_HANDLE_PI_RESERVED,
+ },
+ 1, // slot 0
+ SlotTypePciExpressGen2X8,
+ SlotDataBusWidth4X,
+ SlotUsageUnknown,
+ SlotLengthShort,
+ 0,
+ {1},
+ {1, 0, 1}, // PME and SMBUS
+ 0,
+ 2,
+ 3,
},
- 1, //slot 0
- SlotTypePciExpressGen2X8,
- SlotDataBusWidth4X,
- SlotUsageUnknown,
- SlotLengthShort,
- 0,
- {1},
- {1,0,1}, //PME and SMBUS
- 0,
- 2,
- 3,
- },
- TYPE9_STRINGS
-};
+ TYPE9_STRINGS};
STATIC CONST ARM_TYPE9 mArmDefaultType9_3 = {
- {
- { // SMBIOS_STRUCTURE Hdr
- EFI_SMBIOS_TYPE_SYSTEM_SLOTS, // UINT8 Type
- sizeof (SMBIOS_TABLE_TYPE9), // UINT8 Length
- SMBIOS_HANDLE_PI_RESERVED,
+ {
+ {
+ // SMBIOS_STRUCTURE Hdr
+ EFI_SMBIOS_TYPE_SYSTEM_SLOTS, // UINT8 Type
+ sizeof(SMBIOS_TABLE_TYPE9), // UINT8 Length
+ SMBIOS_HANDLE_PI_RESERVED,
+ },
+ 1, // slot 0
+ SlotTypePciExpressGen2X16,
+ SlotDataBusWidth4X,
+ SlotUsageUnknown,
+ SlotLengthShort,
+ 0,
+ {1},
+ {1, 0, 1}, // PME and SMBUS
+ 0,
+ 2,
+ 0xc,
},
- 1, //slot 0
- SlotTypePciExpressGen2X16,
- SlotDataBusWidth4X,
- SlotUsageUnknown,
- SlotLengthShort,
- 0,
- {1},
- {1,0,1}, //PME and SMBUS
- 0,
- 2,
- 0xc,
- },
- TYPE9_STRINGS
-};
+ TYPE9_STRINGS};
// Memory array
STATIC CONST ARM_TYPE16 mArmDefaultType16 = {
- {
- { // SMBIOS_STRUCTURE Hdr
- EFI_SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY, // UINT8 Type
- sizeof (SMBIOS_TABLE_TYPE16), // UINT8 Length
- SMBIOS_HANDLE_MEMORY,
+ {
+ {
+ // SMBIOS_STRUCTURE Hdr
+ EFI_SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY, // UINT8 Type
+ sizeof(SMBIOS_TABLE_TYPE16), // UINT8 Length
+ SMBIOS_HANDLE_MEMORY,
+ },
+ MemoryArrayLocationSystemBoard, // on motherboard
+ MemoryArrayUseSystemMemory, // system RAM
+ MemoryErrorCorrectionNone, // Juno doesn't have ECC RAM
+ 0x800000, // 8GB
+ 0xFFFE, // No error information structure
+ 0x1, // soldered memory
},
- MemoryArrayLocationSystemBoard, //on motherboard
- MemoryArrayUseSystemMemory, //system RAM
- MemoryErrorCorrectionNone, //Juno doesn't have ECC RAM
- 0x800000, //8GB
- 0xFFFE, //No error information structure
- 0x1, //soldered memory
- },
- TYPE16_STRINGS
-};
+ TYPE16_STRINGS};
// Memory device
STATIC CONST ARM_TYPE17 mArmDefaultType17 = {
- {
- { // SMBIOS_STRUCTURE Hdr
- EFI_SMBIOS_TYPE_MEMORY_DEVICE, // UINT8 Type
- sizeof (SMBIOS_TABLE_TYPE17), // UINT8 Length
- SMBIOS_HANDLE_DIMM,
+ {
+ {
+ // SMBIOS_STRUCTURE Hdr
+ EFI_SMBIOS_TYPE_MEMORY_DEVICE, // UINT8 Type
+ sizeof(SMBIOS_TABLE_TYPE17), // UINT8 Length
+ SMBIOS_HANDLE_DIMM,
+ },
+ SMBIOS_HANDLE_MEMORY, // array to which this module belongs
+ 0xFFFE, // no errors
+ 64, // single DIMM, no ECC is 64bits (for ecc this would be 72)
+ 64, // data width of this device (64-bits)
+ 0x2000, // 8GB
+ 0x0B, // row of chips
+ 0, // not part of a set
+ 1, // right side of board
+ 2, // bank 0
+ MemoryTypeLpddr4, // LP DDR4
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, // unbuffered
+ 1866, // 1866Mhz DDR
+ 0, // varies between diffrent production runs
+ 0, // serial
+ 0, // asset tag
+ 0, // part number
+ 0, // rank
},
- SMBIOS_HANDLE_MEMORY, //array to which this module belongs
- 0xFFFE, //no errors
- 64, //single DIMM, no ECC is 64bits (for ecc this would be 72)
- 64, //data width of this device (64-bits)
- 0x2000, //8GB
- 0x0B, //row of chips
- 0, //not part of a set
- 1, //right side of board
- 2, //bank 0
- MemoryTypeLpddr4, //LP DDR4
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, //unbuffered
- 1866, //1866Mhz DDR
- 0, //varies between diffrent production runs
- 0, //serial
- 0, //asset tag
- 0, //part number
- 0, //rank
- },
- TYPE17_STRINGS
-};
+ TYPE17_STRINGS};
// Memory array mapped address, this structure
// is overridden by InstallMemoryStructure
STATIC CONST ARM_TYPE19 mArmDefaultType19 = {
- {
- { // SMBIOS_STRUCTURE Hdr
- EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS, // UINT8 Type
- sizeof (SMBIOS_TABLE_TYPE19), // UINT8 Length
- SMBIOS_HANDLE_PI_RESERVED,
+ {
+ {
+ // SMBIOS_STRUCTURE Hdr
+ EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS, // UINT8 Type
+ sizeof(SMBIOS_TABLE_TYPE19), // UINT8 Length
+ SMBIOS_HANDLE_PI_RESERVED,
+ },
+ 0xFFFFFFFF, // invalid, look at extended addr field
+ 0xFFFFFFFF,
+ SMBIOS_HANDLE_DIMM, // handle
+ 1,
+ 0x080000000, // starting addr of first 2GB
+ 0x100000000, // ending addr of first 2GB
},
- 0xFFFFFFFF, //invalid, look at extended addr field
- 0xFFFFFFFF,
- SMBIOS_HANDLE_DIMM, //handle
- 1,
- 0x080000000, //starting addr of first 2GB
- 0x100000000, //ending addr of first 2GB
- },
- TYPE19_STRINGS
-};
+ TYPE19_STRINGS};
// System boot info
STATIC CONST ARM_TYPE32 mArmDefaultType32 = {
- {
- { // SMBIOS_STRUCTURE Hdr
- EFI_SMBIOS_TYPE_SYSTEM_BOOT_INFORMATION, // UINT8 Type
- sizeof (SMBIOS_TABLE_TYPE32), // UINT8 Length
- SMBIOS_HANDLE_PI_RESERVED,
+ {
+ {
+ // SMBIOS_STRUCTURE Hdr
+ EFI_SMBIOS_TYPE_SYSTEM_BOOT_INFORMATION, // UINT8 Type
+ sizeof(SMBIOS_TABLE_TYPE32), // UINT8 Length
+ SMBIOS_HANDLE_PI_RESERVED,
+ },
+ {0, 0, 0, 0, 0, 0}, // reserved
+ BootInformationStatusNoError,
},
- {0,0,0,0,0,0}, //reserved
- BootInformationStatusNoError,
- },
- TYPE32_STRINGS
-};
+ TYPE32_STRINGS};
-STATIC CONST VOID *DefaultCommonTables[]=
-{
- &mArmDefaultType0,
- &mArmDefaultType1,
- &mArmDefaultType2,
- &mArmDefaultType3,
- &mArmDefaultType7_a53_l1i,
- &mArmDefaultType7_a53_l1d,
- &mArmDefaultType7_a53_l2,
- &mArmDefaultType4_a53,
- &mArmDefaultType9_0,
- &mArmDefaultType9_1,
- &mArmDefaultType9_2,
- &mArmDefaultType9_3,
- &mArmDefaultType16,
- &mArmDefaultType17,
-// &mArmDefaultType19, //memory range type 19 dynamically generated
- &mArmDefaultType32,
- NULL
-};
+STATIC CONST VOID *DefaultCommonTables[] = {
+ &mArmDefaultType0, &mArmDefaultType1, &mArmDefaultType2, &mArmDefaultType3,
+ &mArmDefaultType7_a53_l1i, &mArmDefaultType7_a53_l1d,
+ &mArmDefaultType7_a53_l2, &mArmDefaultType4_a53, &mArmDefaultType9_0,
+ &mArmDefaultType9_1, &mArmDefaultType9_2, &mArmDefaultType9_3,
+ &mArmDefaultType16, &mArmDefaultType17,
+ // &mArmDefaultType19, //memory range type 19 dynamically generated
+ &mArmDefaultType32, NULL};
-STATIC CONST VOID *DefaultTablesR0R1[]=
-{
- &mArmDefaultType7_a57_l1i,
- &mArmDefaultType7_a57_l1d,
- &mArmDefaultType7_a57_l2,
- &mArmDefaultType4_a57,
- NULL
-};
+STATIC CONST VOID *DefaultTablesR0R1[] = {
+ &mArmDefaultType7_a57_l1i, &mArmDefaultType7_a57_l1d,
+ &mArmDefaultType7_a57_l2, &mArmDefaultType4_a57, NULL};
/*
**/
EFI_STATUS
-InstallMemoryStructure (
- IN EFI_SMBIOS_PROTOCOL *Smbios,
- IN UINT64 StartingAddress,
- IN UINT64 RegionLength
- )
+InstallMemoryStructure(
+ IN EFI_SMBIOS_PROTOCOL *Smbios, IN UINT64 StartingAddress,
+ IN UINT64 RegionLength)
{
- EFI_SMBIOS_HANDLE SmbiosHandle;
- ARM_TYPE19 MemoryDescriptor;
- EFI_STATUS Status = EFI_SUCCESS;
+ EFI_SMBIOS_HANDLE SmbiosHandle;
+ ARM_TYPE19 MemoryDescriptor;
+ EFI_STATUS Status = EFI_SUCCESS;
- CopyMem( &MemoryDescriptor, &mArmDefaultType19, sizeof(ARM_TYPE19));
+ CopyMem(&MemoryDescriptor, &mArmDefaultType19, sizeof(ARM_TYPE19));
MemoryDescriptor.Base.ExtendedStartingAddress = StartingAddress;
- MemoryDescriptor.Base.ExtendedEndingAddress = StartingAddress+RegionLength;
+ MemoryDescriptor.Base.ExtendedEndingAddress = StartingAddress + RegionLength;
SmbiosHandle = MemoryDescriptor.Base.Hdr.Handle;
- Status = Smbios->Add (
- Smbios,
- NULL,
- &SmbiosHandle,
- (EFI_SMBIOS_TABLE_HEADER*) &MemoryDescriptor
- );
+ Status = Smbios->Add(
+ Smbios, NULL, &SmbiosHandle,
+ (EFI_SMBIOS_TABLE_HEADER *)&MemoryDescriptor);
return Status;
}
@parm
**/
EFI_STATUS
-InstallStructures (
- IN EFI_SMBIOS_PROTOCOL *Smbios,
- IN CONST VOID *DefaultTables[]
- )
+InstallStructures(
+ IN EFI_SMBIOS_PROTOCOL *Smbios, IN CONST VOID *DefaultTables[])
{
- EFI_STATUS Status = EFI_SUCCESS;
- EFI_SMBIOS_HANDLE SmbiosHandle;
-
- int TableEntry;
- for ( TableEntry=0; DefaultTables[TableEntry] != NULL; TableEntry++)
- {
- SmbiosHandle = ((EFI_SMBIOS_TABLE_HEADER*)DefaultTables[TableEntry])->Handle;
- Status = Smbios->Add (
- Smbios,
- NULL,
- &SmbiosHandle,
- (EFI_SMBIOS_TABLE_HEADER*) DefaultTables[TableEntry]
- );
- if (EFI_ERROR(Status))
- break;
- }
- return Status;
+ EFI_STATUS Status = EFI_SUCCESS;
+ EFI_SMBIOS_HANDLE SmbiosHandle;
+
+ int TableEntry;
+ for (TableEntry = 0; DefaultTables[TableEntry] != NULL; TableEntry++) {
+ SmbiosHandle =
+ ((EFI_SMBIOS_TABLE_HEADER *)DefaultTables[TableEntry])->Handle;
+ Status = Smbios->Add(
+ Smbios, NULL, &SmbiosHandle,
+ (EFI_SMBIOS_TABLE_HEADER *)DefaultTables[TableEntry]);
+ if (EFI_ERROR(Status))
+ break;
+ }
+ return Status;
}
-
/**
Install all structures from the DefaultTables structure
**/
EFI_STATUS
-InstallAllStructures (
- IN EFI_SMBIOS_PROTOCOL *Smbios
- )
+InstallAllStructures(IN EFI_SMBIOS_PROTOCOL *Smbios)
{
- EFI_STATUS Status = EFI_SUCCESS;
- VOID *ExtraTables = DefaultTablesR0R1;
+ EFI_STATUS Status = EFI_SUCCESS;
+ VOID * ExtraTables = DefaultTablesR0R1;
//
// Add all Juno table entries
//
- Status=InstallStructures (Smbios,DefaultCommonTables);
- ASSERT_EFI_ERROR (Status);
+ Status = InstallStructures(Smbios, DefaultCommonTables);
+ ASSERT_EFI_ERROR(Status);
- Status=InstallStructures (Smbios,ExtraTables);
- ASSERT_EFI_ERROR (Status);
+ Status = InstallStructures(Smbios, ExtraTables);
+ ASSERT_EFI_ERROR(Status);
// Generate memory descriptors for the two memory ranges we know about
- Status = InstallMemoryStructure ( Smbios, PcdGet64 (PcdSystemMemoryBase), PcdGet64 (PcdSystemMemorySize));
- ASSERT_EFI_ERROR (Status);
+ Status = InstallMemoryStructure(
+ Smbios, PcdGet64(PcdSystemMemoryBase), PcdGet64(PcdSystemMemorySize));
+ ASSERT_EFI_ERROR(Status);
return Status;
}
**/
EFI_STATUS
EFIAPI
-SmbiosTablePublishEntry (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
+SmbiosTablePublishEntry(
+ IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
{
- EFI_STATUS Status;
- EFI_SMBIOS_PROTOCOL *Smbios;
+ EFI_STATUS Status;
+ EFI_SMBIOS_PROTOCOL *Smbios;
//
// Find the SMBIOS protocol
//
- Status = gBS->LocateProtocol (
- &gEfiSmbiosProtocolGuid,
- NULL,
- (VOID**)&Smbios
- );
- if (EFI_ERROR (Status)) {
+ Status = gBS->LocateProtocol(&gEfiSmbiosProtocolGuid, NULL, (VOID **)&Smbios);
+ if (EFI_ERROR(Status)) {
return Status;
}
- Status = InstallAllStructures (Smbios);
+ Status = InstallAllStructures(Smbios);
return Status;
}
/** @file
-*
-* Copyright (c) 2018, Linaro Ltd. All rights reserved.
-*
-* This program and the accompanying materials
-* are licensed and made available under the terms and conditions of the BSD License
-* which accompanies this distribution. The full text of the license may be found at
-* http://opensource.org/licenses/bsd-license.php
-*
-* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-*
-**/
+ *
+ * Copyright (c) 2018, Linaro Ltd. All rights reserved.
+ *
+ * This program and the accompanying materials
+ * are licensed and made available under the terms and conditions of the BSD
+ *License which accompanies this distribution. The full text of the license may
+ *be found at http://opensource.org/licenses/bsd-license.php
+ *
+ * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
+ *IMPLIED.
+ *
+ **/
#include <Guid/EventGroup.h>
#include "sdm845Dxe.h"
-EFI_CPU_ARCH_PROTOCOL *gCpu;
+EFI_CPU_ARCH_PROTOCOL *gCpu;
-VOID
-InitPeripherals (
- IN VOID
- )
+VOID InitPeripherals(IN VOID)
{
- //Lock the QcomWdogTimer in a cage on certain devices
- MmioWrite32(0x17980008,0x000000);
- DEBUG ((EFI_D_WARN, "\n \v The Dog has been locked in a cage :)\v"));
-
+ // Lock the QcomWdogTimer in a cage on certain devices
+ MmioWrite32(0x17980008, 0x000000);
+ DEBUG((EFI_D_WARN, "\n \v The Dog has been locked in a cage :)\v"));
}
/**
@param[in] Context NULL
**/
STATIC
-VOID
-OnEndOfDxe (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
-}
+VOID OnEndOfDxe(IN EFI_EVENT Event, IN VOID *Context) {}
EFI_STATUS
EFIAPI
-sdm845EntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
+sdm845EntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
{
- EFI_STATUS Status;
- EFI_EVENT EndOfDxeEvent;
+ EFI_STATUS Status;
+ EFI_EVENT EndOfDxeEvent;
- Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **)&gCpu);
+ Status = gBS->LocateProtocol(&gEfiCpuArchProtocolGuid, NULL, (VOID **)&gCpu);
ASSERT_EFI_ERROR(Status);
- InitPeripherals ();
+ InitPeripherals();
//
// Create an event belonging to the "gEfiEndOfDxeEventGroupGuid" group.
// same group is signalled to inform about the end of the DXE phase.
// Install the INSTALL_FDT_PROTOCOL protocol.
//
- Status = gBS->CreateEventEx (
- EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- OnEndOfDxe,
- NULL,
- &gEfiEndOfDxeEventGroupGuid,
- &EndOfDxeEvent
- );
+ Status = gBS->CreateEventEx(
+ EVT_NOTIFY_SIGNAL, TPL_CALLBACK, OnEndOfDxe, NULL,
+ &gEfiEndOfDxeEventGroupGuid, &EndOfDxeEvent);
return Status;
}
/** @file
-*
-* Copyright (c) 2013-2017, ARM Limited. All rights reserved.
-*
-* This program and the accompanying materials
-* are licensed and made available under the terms and conditions of the BSD License
-* which accompanies this distribution. The full text of the license may be found at
-* http://opensource.org/licenses/bsd-license.php
-*
-* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-*
-**/
+ *
+ * Copyright (c) 2013-2017, ARM Limited. All rights reserved.
+ *
+ * This program and the accompanying materials
+ * are licensed and made available under the terms and conditions of the BSD
+ *License which accompanies this distribution. The full text of the license may
+ *be found at http://opensource.org/licenses/bsd-license.php
+ *
+ * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
+ *IMPLIED.
+ *
+ **/
#ifndef __ARM_JUNO_H__
#define __ARM_JUNO_H__
//
// ACPI table information used to initialize tables.
//
-#define EFI_ACPI_ARM_OEM_ID 'A','R','M','L','T','D' // OEMID 6 bytes long
-#define EFI_ACPI_ARM_OEM_TABLE_ID SIGNATURE_64('A','R','M','-','J','U','N','O') // OEM table id 8 bytes long
-#define EFI_ACPI_ARM_OEM_REVISION 0x20140727
-#define EFI_ACPI_ARM_CREATOR_ID SIGNATURE_32('A','R','M',' ')
+#define EFI_ACPI_ARM_OEM_ID 'A', 'R', 'M', 'L', 'T', 'D' // OEMID 6 bytes long
+#define EFI_ACPI_ARM_OEM_TABLE_ID \
+ SIGNATURE_64( \
+ 'A', 'R', 'M', '-', 'J', 'U', 'N', 'O') // OEM table id 8 bytes long
+#define EFI_ACPI_ARM_OEM_REVISION 0x20140727
+#define EFI_ACPI_ARM_CREATOR_ID SIGNATURE_32('A', 'R', 'M', ' ')
#define EFI_ACPI_ARM_CREATOR_REVISION 0x00000099
// A macro to initialise the common header part of EFI ACPI tables as defined by
// EFI_ACPI_DESCRIPTION_HEADER structure.
-#define ARM_ACPI_HEADER(Signature, Type, Revision) { \
- Signature, /* UINT32 Signature */ \
- sizeof (Type), /* UINT32 Length */ \
- Revision, /* UINT8 Revision */ \
- 0, /* UINT8 Checksum */ \
- { EFI_ACPI_ARM_OEM_ID }, /* UINT8 OemId[6] */ \
- EFI_ACPI_ARM_OEM_TABLE_ID, /* UINT64 OemTableId */ \
- EFI_ACPI_ARM_OEM_REVISION, /* UINT32 OemRevision */ \
- EFI_ACPI_ARM_CREATOR_ID, /* UINT32 CreatorId */ \
- EFI_ACPI_ARM_CREATOR_REVISION /* UINT32 CreatorRevision */ \
+#define ARM_ACPI_HEADER(Signature, Type, Revision) \
+ { \
+ Signature, /* UINT32 Signature */ \
+ sizeof(Type), /* UINT32 Length */ \
+ Revision, /* UINT8 Revision */ \
+ 0, /* UINT8 Checksum */ \
+ {EFI_ACPI_ARM_OEM_ID}, /* UINT8 OemId[6] */ \
+ EFI_ACPI_ARM_OEM_TABLE_ID, /* UINT64 OemTableId */ \
+ EFI_ACPI_ARM_OEM_REVISION, /* UINT32 OemRevision */ \
+ EFI_ACPI_ARM_CREATOR_ID, /* UINT32 CreatorId */ \
+ EFI_ACPI_ARM_CREATOR_REVISION /* UINT32 CreatorRevision */ \
}
//
// Hardware platform identifiers
//
#define JUNO_REVISION_PROTOTYPE 0
-#define JUNO_REVISION_R0 1
-#define JUNO_REVISION_R1 2
-#define JUNO_REVISION_R2 3
-#define JUNO_REVISION_UKNOWN 0xFF
+#define JUNO_REVISION_R0 1
+#define JUNO_REVISION_R1 2
+#define JUNO_REVISION_R2 3
+#define JUNO_REVISION_UKNOWN 0xFF
// Define if the exported ACPI Tables are based on ACPI 5.0 spec or latest
//#define ARM_JUNO_ACPI_5_0
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES,\r
ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK, AddMem, EfiBootServicesCode},\r
/* HLOS1 */\r
- {0x81AC0000, 0x03C40000, EFI_RESOURCE_SYSTEM_MEMORY,\r
+ {0x81AC0000, 0x03C40000, EFI_RESOURCE_SYSTEM_MEMORY,\r
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES,\r
- ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK, AddMem,\r
- EfiBootServicesData},\r
- /* MPSS_EFS */\r
- {0x85D00000, 0x00200000, EFI_RESOURCE_SYSTEM_MEMORY,\r
+ ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK, AddMem, EfiBootServicesData},\r
+ /* MPSS_EFS */\r
+ {0x85D00000, 0x00200000, EFI_RESOURCE_SYSTEM_MEMORY,\r
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES,\r
ARM_MEMORY_REGION_ATTRIBUTE_DEVICE, AddMem, EfiReservedMemoryType},\r
- /* GPU PRR */\r
- {0x85F00000, 0x00010000, EFI_RESOURCE_SYSTEM_MEMORY,\r
+ /* GPU PRR */\r
+ {0x85F00000, 0x00010000, EFI_RESOURCE_SYSTEM_MEMORY,\r
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES,\r
ARM_MEMORY_REGION_ATTRIBUTE_DEVICE, AddMem, EfiReservedMemoryType},\r
- /* HLOS2 */\r
- {0x85F10000, 0x000B0000, EFI_RESOURCE_SYSTEM_MEMORY,\r
+ /* HLOS2 */\r
+ {0x85F10000, 0x000B0000, EFI_RESOURCE_SYSTEM_MEMORY,\r
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES,\r
ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK, AddMem, EfiBootServicesData},\r
/* AOP CMD DB */\r
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE,\r
ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED, AddMem,\r
EfiReservedMemoryType},\r
- /* TZApps */\r
- {0x86D00000, 0x00E00000, EFI_RESOURCE_SYSTEM_MEMORY,\r
+ /* TZApps */\r
+ {0x86D00000, 0x00E00000, EFI_RESOURCE_SYSTEM_MEMORY,\r
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES,\r
ARM_MEMORY_REGION_ATTRIBUTE_DEVICE, NoHob, EfiReservedMemoryType},\r
- /* TGCM */\r
- {0x8B500000, 0x00A00000, EFI_RESOURCE_SYSTEM_MEMORY,\r
+ /* TGCM */\r
+ {0x8B500000, 0x00A00000, EFI_RESOURCE_SYSTEM_MEMORY,\r
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES,\r
ARM_MEMORY_REGION_ATTRIBUTE_DEVICE, AddMem, EfiReservedMemoryType},\r
#ifdef XIAOMI_PIL_FIXED\r
- /* PIL_REGION */\r
- {0x8BF00000, 0x0C100000, EFI_RESOURCE_SYSTEM_MEMORY,\r
+ /* PIL_REGION */\r
+ {0x8BF00000, 0x0C100000, EFI_RESOURCE_SYSTEM_MEMORY,\r
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES,\r
ARM_MEMORY_REGION_ATTRIBUTE_DEVICE, AddMem, EfiReservedMemoryType},\r
/* DXE Heap */\r
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES,\r
ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK, AddMem, EfiConventionalMemory},\r
#else\r
- /* PIL_REGION */\r
- {0x8BF00000, 0x0BD00000, EFI_RESOURCE_SYSTEM_MEMORY,\r
+ /* PIL_REGION */\r
+ {0x8BF00000, 0x0BD00000, EFI_RESOURCE_SYSTEM_MEMORY,\r
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES,\r
ARM_MEMORY_REGION_ATTRIBUTE_DEVICE, AddMem, EfiReservedMemoryType},\r
/* DXE Heap */\r
{0x9FF90000, 0x00040000, EFI_RESOURCE_SYSTEM_MEMORY,\r
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES,\r
ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK, AddMem, EfiBootServicesData},\r
- \r
- {0x9FFD0000, 0x0000A000, EFI_RESOURCE_SYSTEM_MEMORY,\r
+\r
+ {0x9FFD0000, 0x0000A000, EFI_RESOURCE_SYSTEM_MEMORY,\r
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES,\r
ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED, AddMem,\r
EfiRuntimeServicesData},\r
- {0x9FFDA000, 0x00003000, EFI_RESOURCE_SYSTEM_MEMORY,\r
+ {0x9FFDA000, 0x00003000, EFI_RESOURCE_SYSTEM_MEMORY,\r
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES,\r
ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED, AddMem,\r
EfiRuntimeServicesData},\r
- {0x9FFDD000, 0x00004000, EFI_RESOURCE_SYSTEM_MEMORY,\r
+ {0x9FFDD000, 0x00004000, EFI_RESOURCE_SYSTEM_MEMORY,\r
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES,\r
ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED, AddMem,\r
EfiRuntimeServicesData},\r
- {0x9FFE1000, 0x00001000, EFI_RESOURCE_SYSTEM_MEMORY,\r
+ {0x9FFE1000, 0x00001000, EFI_RESOURCE_SYSTEM_MEMORY,\r
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES,\r
ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED, AddMem,\r
EfiRuntimeServicesData},\r
- {0x9FFE2000, 0x00001000, EFI_RESOURCE_SYSTEM_MEMORY,\r
+ {0x9FFE2000, 0x00001000, EFI_RESOURCE_SYSTEM_MEMORY,\r
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES,\r
ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED, AddMem,\r
EfiRuntimeServicesData},\r
- {0x9FFE3000, 0x00014000, EFI_RESOURCE_SYSTEM_MEMORY,\r
+ {0x9FFE3000, 0x00014000, EFI_RESOURCE_SYSTEM_MEMORY,\r
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES,\r
ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED, AddMem,\r
EfiRuntimeServicesData},\r
- {0x9FFF7000, 0x00008000, EFI_RESOURCE_SYSTEM_MEMORY,\r
+ {0x9FFF7000, 0x00008000, EFI_RESOURCE_SYSTEM_MEMORY,\r
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES,\r
ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED, AddMem,\r
EfiRuntimeServicesData},\r
- {0x9FFFF000, 0x00001000, EFI_RESOURCE_SYSTEM_MEMORY,\r
+ {0x9FFFF000, 0x00001000, EFI_RESOURCE_SYSTEM_MEMORY,\r
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES,\r
ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED, AddMem,\r
EfiRuntimeServicesData},\r
\r
#ifdef MEMORY_4G\r
- {0xA0000000, 0xDDFA0000, EFI_RESOURCE_SYSTEM_MEMORY,\r
+ {0xA0000000, 0xDDFA0000, EFI_RESOURCE_SYSTEM_MEMORY,\r
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES,\r
ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK, AddMem, EfiConventionalMemory},\r
#else\r
#ifdef MEMORY_8G\r
- {0xA0000000, 0xE0000000, EFI_RESOURCE_SYSTEM_MEMORY,\r
+ {0xA0000000, 0xE0000000, EFI_RESOURCE_SYSTEM_MEMORY,\r
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES,\r
ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK, AddMem, EfiConventionalMemory},\r
- {0x180000000,0xFC8A0000, EFI_RESOURCE_SYSTEM_MEMORY,\r
+ {0x180000000, 0xFC8A0000, EFI_RESOURCE_SYSTEM_MEMORY,\r
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES,\r
ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK, AddMem, EfiConventionalMemory},\r
#else\r
- {0xA0000000, 0x15AE00000, EFI_RESOURCE_SYSTEM_MEMORY,\r
+ {0xA0000000, 0x15AE00000, EFI_RESOURCE_SYSTEM_MEMORY,\r
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES,\r
ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK, AddMem, EfiConventionalMemory},\r
\r
{0x00A00000, 0x000D0000, EFI_RESOURCE_MEMORY_MAPPED_IO,\r
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_DEVICE,\r
AddDev, EfiMemoryMappedIO},\r
- /* PCIE_0_WRAPPER_AHB */\r
- {0x01C00000, 0x00008000, EFI_RESOURCE_MEMORY_MAPPED_IO,\r
+ /* PCIE_0_WRAPPER_AHB */\r
+ {0x01C00000, 0x00008000, EFI_RESOURCE_MEMORY_MAPPED_IO,\r
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_DEVICE,\r
AddDev, EfiMemoryMappedIO},\r
- /* PCIE_1_WRAPPER_AHB */\r
- {0x01C08000, 0x00008000, EFI_RESOURCE_MEMORY_MAPPED_IO,\r
+ /* PCIE_1_WRAPPER_AHB */\r
+ {0x01C08000, 0x00008000, EFI_RESOURCE_MEMORY_MAPPED_IO,\r
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_DEVICE,\r
AddDev, EfiMemoryMappedIO},\r
/* UFS UFS REGS */\r
{0x0AB00000, 0x00010000, EFI_RESOURCE_MEMORY_MAPPED_IO,\r
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_DEVICE,\r
AddDev, EfiMemoryMappedIO},\r
- /* TITAN_A_CCI */\r
- {0x0AC4A000, 0x00004000, EFI_RESOURCE_MEMORY_MAPPED_IO,\r
+ /* TITAN_A_CCI */\r
+ {0x0AC4A000, 0x00004000, EFI_RESOURCE_MEMORY_MAPPED_IO,\r
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_DEVICE,\r
- AddDev, EfiMemoryMappedIO}, \r
+ AddDev, EfiMemoryMappedIO},\r
/* TITAN_CAM_CC */\r
{0x0AD00000, 0x00010000, EFI_RESOURCE_MEMORY_MAPPED_IO,\r
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_DEVICE,\r
{0x17D20000, 0x000B0000, EFI_RESOURCE_MEMORY_MAPPED_IO,\r
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_DEVICE,\r
AddDev, EfiMemoryMappedIO},\r
- /* PCIE_1_WRAPPER_AXI */\r
- {0x40000000, 0x02000000, EFI_RESOURCE_MEMORY_MAPPED_IO,\r
+ /* PCIE_1_WRAPPER_AXI */\r
+ {0x40000000, 0x02000000, EFI_RESOURCE_MEMORY_MAPPED_IO,\r
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_DEVICE,\r
AddDev, EfiMemoryMappedIO},\r
- /* PCIE_0_WRAPPER_AXI */\r
- {0x60000000, 0x01000000, EFI_RESOURCE_MEMORY_MAPPED_IO,\r
+ /* PCIE_0_WRAPPER_AXI */\r
+ {0x60000000, 0x01000000, EFI_RESOURCE_MEMORY_MAPPED_IO,\r
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_DEVICE,\r
AddDev, EfiMemoryMappedIO},\r
/* Terminator */\r
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
+ */
#ifndef __BSL_BLOCK_UTILS_H__
#define __BSL_BLOCK_UTILS_H__
typedef struct {
EFI_GUID *RootDeviceType; /* GUID Selecting the root device type */
EFI_GUID *PartitionType; /* Partition Type to match */
- CHAR8 *VolumeName; /* Mounted filesystem volume name to match */
- CHAR16 *PartitionLabel; /* Partition label to match */
+ CHAR8 * VolumeName; /* Mounted filesystem volume name to match */
+ CHAR16 * PartitionLabel; /* Partition label to match */
} PartiSelectFilter;
EFI_STATUS
EFIAPI
-GetPartitionEntry (IN EFI_HANDLE Handle,
- OUT EFI_PARTITION_ENTRY **PartEntry);
+GetPartitionEntry(IN EFI_HANDLE Handle, OUT EFI_PARTITION_ENTRY **PartEntry);
/**
Returns a list of BlkIo handles based on required criteria
*/
EFI_STATUS
EFIAPI
-GetBlkIOHandles (IN UINT32 SelectionAttrib,
- IN PartiSelectFilter *FilterData,
- OUT HandleInfo *HandleInfoPtr,
- IN OUT UINT32 *MaxBlkIopCnt);
+GetBlkIOHandles(
+ IN UINT32 SelectionAttrib, IN PartiSelectFilter *FilterData,
+ OUT HandleInfo *HandleInfoPtr, IN OUT UINT32 *MaxBlkIopCnt);
#endif
\ No newline at end of file
((UINT32) * (x + 3) << 24))
#define PUT_LONG(x, y) \
- *(x) = y & 0xff; \
+ *(x) = y & 0xff; \
*(x + 1) = (y >> 8) & 0xff; \
*(x + 2) = (y >> 16) & 0xff; \
*(x + 3) = (y >> 24) & 0xff;
do { \
Status = (code); \
if (Status != EFI_SUCCESS) { \
- DEBUG ((EFI_D_ERROR, "Err: line:%d %a() status: %r\n", __LINE__, \
- __FUNCTION__, Status)); \
+ DEBUG( \
+ (EFI_D_ERROR, "Err: line:%d %a() status: %r\n", __LINE__, \
+ __FUNCTION__, Status)); \
return Status; \
} \
} while (0)
struct StoragePartInfo {
HandleInfo HandleInfoList[MAX_NUM_PARTITIONS];
- UINT32 MaxHandles;
+ UINT32 MaxHandles;
};
extern struct StoragePartInfo Ptable[MAX_LUNS];
CHAR16 Suffix[MAX_SLOT_SUFFIX_SZ];
} Slot;
-Slot GetCurrentSlotSuffix ();
-UINT32 GetMaxLuns ();
-VOID GetPartitionCount (UINT32 *Val);
-VOID SetMultiSlotBootVal (BOOLEAN Val);
+Slot GetCurrentSlotSuffix();
+UINT32 GetMaxLuns();
+VOID GetPartitionCount(UINT32 *Val);
+VOID SetMultiSlotBootVal(BOOLEAN Val);
struct PartitionEntry {
EFI_PARTITION_ENTRY PartEntry;
- UINT32 lun;
+ UINT32 lun;
};
extern struct PartitionEntry PtnEntries[MAX_NUM_PARTITIONS];
struct BootPartsLinkedList {
- CHAR16 PartName[BOOT_PART_SIZE];
+ CHAR16 PartName[BOOT_PART_SIZE];
struct BootPartsLinkedList *Next;
};
-INT32 GetPartitionIndex (CHAR16 *PartitionName);
-BOOLEAN PartitionHasMultiSlot (CONST CHAR16 *Pname);
-EFI_STATUS EnumeratePartitions (VOID);
-VOID UpdatePartitionEntries (VOID);
-VOID UpdatePartitionAttributes (UINT32 UpdateType);
-BOOLEAN IsSuffixEmpty (Slot *CheckSlot);
-EFI_STATUS SetActiveSlot (Slot *NewSlot, BOOLEAN ResetSuccessBit, BOOLEAN SetSuccessBit);
-BOOLEAN IsSlotBootable (Slot *CheckSlot);
-EFI_STATUS ClearUnbootable (Slot *CheckSlot);
-UINT64 GetPartitionSize (EFI_BLOCK_IO_PROTOCOL *BlockIo);
+INT32 GetPartitionIndex(CHAR16 *PartitionName);
+BOOLEAN PartitionHasMultiSlot(CONST CHAR16 *Pname);
+EFI_STATUS EnumeratePartitions(VOID);
+VOID UpdatePartitionEntries(VOID);
+VOID UpdatePartitionAttributes(UINT32 UpdateType);
+BOOLEAN IsSuffixEmpty(Slot *CheckSlot);
+EFI_STATUS
+SetActiveSlot(Slot *NewSlot, BOOLEAN ResetSuccessBit, BOOLEAN SetSuccessBit);
+BOOLEAN IsSlotBootable(Slot *CheckSlot);
+EFI_STATUS ClearUnbootable(Slot *CheckSlot);
+UINT64 GetPartitionSize(EFI_BLOCK_IO_PROTOCOL *BlockIo);
#endif
-/* Copyright (c) 2015-2018, 2020-2021, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2015-2018, 2020-2021, The Linux Foundation. All rights
+ * reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
+ */
#ifndef __BSL_BOARD_H__
#define __BSL_BOARD_H__
-#include <Uefi.h>
-#include <Library/PrintLib.h>
+#include <Library/BootSlotLib/EFICardInfo.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
+#include <Library/PrintLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
-#include <Library/BootSlotLib/EFICardInfo.h>
+#include <Uefi.h>
#define HANDLE_MAX_INFO_LIST 128
typedef enum {
EMMC = 0,
- UFS = 1,
+ UFS = 1,
UNKNOWN,
} MemCardType;
-VOID
-GetRootDeviceType (CHAR8 *StrDeviceType, UINT32 Len);
-MemCardType
-CheckRootDeviceType (VOID);
+VOID GetRootDeviceType(CHAR8 *StrDeviceType, UINT32 Len);
+MemCardType CheckRootDeviceType(VOID);
EFI_STATUS
-UfsGetSetBootLun (UINT32 *UfsBootlun, BOOLEAN IsGet);
+UfsGetSetBootLun(UINT32 *UfsBootlun, BOOLEAN IsGet);
#endif
\ No newline at end of file
#define _FRAMEBUFFER_SERIALPORT_LIB_H_
typedef struct _FBCON_POSITION {
- INTN x;
- INTN y;
+ INTN x;
+ INTN y;
} FBCON_POSITION, *PFBCON_POSITION;
typedef struct _FBCON_COLOR {
- UINTN Foreground;
- UINTN Background;
+ UINTN Foreground;
+ UINTN Background;
} FBCON_COLOR, *PFBCON_COLOR;
enum FbConMsgType {
- /* type for menu */
- FBCON_COMMON_MSG = 0,
- FBCON_UNLOCK_TITLE_MSG,
- FBCON_TITLE_MSG,
- FBCON_SUBTITLE_MSG,
-
- /* type for warning */
- FBCON_YELLOW_MSG,
- FBCON_ORANGE_MSG,
- FBCON_RED_MSG,
- FBCON_GREEN_MSG,
-
- /* and the select message's background */
- FBCON_SELECT_MSG_BG_COLOR,
+ /* type for menu */
+ FBCON_COMMON_MSG = 0,
+ FBCON_UNLOCK_TITLE_MSG,
+ FBCON_TITLE_MSG,
+ FBCON_SUBTITLE_MSG,
+
+ /* type for warning */
+ FBCON_YELLOW_MSG,
+ FBCON_ORANGE_MSG,
+ FBCON_RED_MSG,
+ FBCON_GREEN_MSG,
+
+ /* and the select message's background */
+ FBCON_SELECT_MSG_BG_COLOR,
};
void ResetFb(void);
UINTN
EFIAPI
-SerialPortWriteCritical
-(
- IN UINT8 *Buffer,
- IN UINTN NumberOfBytes
-);
+SerialPortWriteCritical(IN UINT8 *Buffer, IN UINTN NumberOfBytes);
#endif
#ifndef _FB_COLOR_H_
#define _FB_COLOR_H_
-#define FB_BGRA8888_BLACK 0xff000000
-#define FB_BGRA8888_WHITE 0xffffffff
-#define FB_BGRA8888_CYAN 0xff00ffff
-#define FB_BGRA8888_BLUE 0xff0000ff
-#define FB_BGRA8888_SILVER 0xffc0c0c0
-#define FB_BGRA8888_YELLOW 0xffffff00
-#define FB_BGRA8888_ORANGE 0xffffa500
-#define FB_BGRA8888_RED 0xffff0000
-#define FB_BGRA8888_GREEN 0xff00ff00
+#define FB_BGRA8888_BLACK 0xff000000
+#define FB_BGRA8888_WHITE 0xffffffff
+#define FB_BGRA8888_CYAN 0xff00ffff
+#define FB_BGRA8888_BLUE 0xff0000ff
+#define FB_BGRA8888_SILVER 0xffc0c0c0
+#define FB_BGRA8888_YELLOW 0xffffff00
+#define FB_BGRA8888_ORANGE 0xffffa500
+#define FB_BGRA8888_RED 0xffff0000
+#define FB_BGRA8888_GREEN 0xff00ff00
#endif
\ No newline at end of file
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
+ * the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
#ifndef _FONT_5x12_DATA_
#define _FONT_5x12_DATA_
-#define FONT_WIDTH 5
-#define FONT_HEIGHT 12
+#define FONT_WIDTH 5
+#define FONT_HEIGHT 12
-#define SCALE_FACTOR 2
+#define SCALE_FACTOR 2
unsigned font5x12[] = {
- 0x00000000, 0x00000000,
- 0x08421080, 0x00020084,
- 0x00052940, 0x00000000,
- 0x15f52800, 0x0000295f,
- 0x1c52f880, 0x00023e94,
- 0x08855640, 0x0004d542,
- 0x04528800, 0x000b2725,
- 0x00021080, 0x00000000,
- 0x04211088, 0x00821042,
- 0x10841082, 0x00221108,
- 0x09575480, 0x00000000,
- 0x3e420000, 0x00000084,
- 0x00000000, 0x00223000,
- 0x3e000000, 0x00000000,
- 0x00000000, 0x00471000,
- 0x08844200, 0x00008442,
- 0x2318a880, 0x00022a31,
- 0x08429880, 0x000f9084,
- 0x1108c5c0, 0x000f8444,
- 0x1c4443e0, 0x00074610,
- 0x14a62100, 0x000423e9,
- 0x26d087e0, 0x00074610,
- 0x1e10c5c0, 0x00074631,
- 0x088443e0, 0x00010844,
- 0x1d18c5c0, 0x00074631,
- 0x3d18c5c0, 0x00074610,
- 0x08e20000, 0x00471000,
- 0x08e20000, 0x00223000,
- 0x02222200, 0x00082082,
- 0x01f00000, 0x000003e0,
- 0x20820820, 0x00008888,
- 0x1108c5c0, 0x00020084,
- 0x2b98c5c0, 0x000f05b5,
- 0x2318a880, 0x0008c63f,
- 0x1d2949e0, 0x0007ca52,
- 0x0210c5c0, 0x00074421,
- 0x252949e0, 0x0007ca52,
- 0x1e1087e0, 0x000f8421,
- 0x1e1087e0, 0x00008421,
- 0x0210c5c0, 0x00074639,
- 0x3f18c620, 0x0008c631,
- 0x084211c0, 0x00071084,
- 0x10842380, 0x00032508,
- 0x0654c620, 0x0008c525,
- 0x02108420, 0x000f8421,
- 0x2b5dc620, 0x0008c631,
- 0x2b59ce20, 0x0008c739,
- 0x2318c5c0, 0x00074631,
- 0x1f18c5e0, 0x00008421,
- 0x2318c5c0, 0x01075631,
- 0x1f18c5e0, 0x0008c525,
- 0x1c10c5c0, 0x00074610,
- 0x084213e0, 0x00021084,
- 0x2318c620, 0x00074631,
- 0x1518c620, 0x0002114a,
- 0x2b18c620, 0x000556b5,
- 0x08a54620, 0x0008c54a,
- 0x08a54620, 0x00021084,
- 0x088443e0, 0x000f8442,
- 0x0421084e, 0x00e10842,
- 0x08210420, 0x00084108,
- 0x1084210e, 0x00e42108,
- 0x0008a880, 0x00000000,
- 0x00000000, 0x01f00000,
- 0x00000104, 0x00000000,
- 0x20e00000, 0x000b663e,
- 0x22f08420, 0x0007c631,
- 0x22e00000, 0x00074421,
- 0x23e84200, 0x000f4631,
- 0x22e00000, 0x0007443f,
- 0x1e214980, 0x00010842,
- 0x22e00000, 0x1d187a31,
- 0x26d08420, 0x0008c631,
- 0x08601000, 0x00071084,
- 0x10c02000, 0x0c94a108,
- 0x0a908420, 0x0008a4a3,
- 0x084210c0, 0x00071084,
- 0x2ab00000, 0x0008d6b5,
- 0x26d00000, 0x0008c631,
- 0x22e00000, 0x00074631,
- 0x22f00000, 0x0210be31,
- 0x23e00000, 0x21087a31,
- 0x26d00000, 0x00008421,
- 0x22e00000, 0x00074506,
- 0x04f10800, 0x00064842,
- 0x23100000, 0x000b6631,
- 0x23100000, 0x00022951,
- 0x23100000, 0x000556b5,
- 0x15100000, 0x0008a884,
- 0x23100000, 0x1d185b31,
- 0x11f00000, 0x000f8444,
- 0x06421098, 0x01821084,
- 0x08421080, 0x00021084,
- 0x30421083, 0x00321084,
- 0x0004d640, 0x00000000,
- 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x08421080, 0x00020084, 0x00052940, 0x00000000,
+ 0x15f52800, 0x0000295f, 0x1c52f880, 0x00023e94, 0x08855640, 0x0004d542,
+ 0x04528800, 0x000b2725, 0x00021080, 0x00000000, 0x04211088, 0x00821042,
+ 0x10841082, 0x00221108, 0x09575480, 0x00000000, 0x3e420000, 0x00000084,
+ 0x00000000, 0x00223000, 0x3e000000, 0x00000000, 0x00000000, 0x00471000,
+ 0x08844200, 0x00008442, 0x2318a880, 0x00022a31, 0x08429880, 0x000f9084,
+ 0x1108c5c0, 0x000f8444, 0x1c4443e0, 0x00074610, 0x14a62100, 0x000423e9,
+ 0x26d087e0, 0x00074610, 0x1e10c5c0, 0x00074631, 0x088443e0, 0x00010844,
+ 0x1d18c5c0, 0x00074631, 0x3d18c5c0, 0x00074610, 0x08e20000, 0x00471000,
+ 0x08e20000, 0x00223000, 0x02222200, 0x00082082, 0x01f00000, 0x000003e0,
+ 0x20820820, 0x00008888, 0x1108c5c0, 0x00020084, 0x2b98c5c0, 0x000f05b5,
+ 0x2318a880, 0x0008c63f, 0x1d2949e0, 0x0007ca52, 0x0210c5c0, 0x00074421,
+ 0x252949e0, 0x0007ca52, 0x1e1087e0, 0x000f8421, 0x1e1087e0, 0x00008421,
+ 0x0210c5c0, 0x00074639, 0x3f18c620, 0x0008c631, 0x084211c0, 0x00071084,
+ 0x10842380, 0x00032508, 0x0654c620, 0x0008c525, 0x02108420, 0x000f8421,
+ 0x2b5dc620, 0x0008c631, 0x2b59ce20, 0x0008c739, 0x2318c5c0, 0x00074631,
+ 0x1f18c5e0, 0x00008421, 0x2318c5c0, 0x01075631, 0x1f18c5e0, 0x0008c525,
+ 0x1c10c5c0, 0x00074610, 0x084213e0, 0x00021084, 0x2318c620, 0x00074631,
+ 0x1518c620, 0x0002114a, 0x2b18c620, 0x000556b5, 0x08a54620, 0x0008c54a,
+ 0x08a54620, 0x00021084, 0x088443e0, 0x000f8442, 0x0421084e, 0x00e10842,
+ 0x08210420, 0x00084108, 0x1084210e, 0x00e42108, 0x0008a880, 0x00000000,
+ 0x00000000, 0x01f00000, 0x00000104, 0x00000000, 0x20e00000, 0x000b663e,
+ 0x22f08420, 0x0007c631, 0x22e00000, 0x00074421, 0x23e84200, 0x000f4631,
+ 0x22e00000, 0x0007443f, 0x1e214980, 0x00010842, 0x22e00000, 0x1d187a31,
+ 0x26d08420, 0x0008c631, 0x08601000, 0x00071084, 0x10c02000, 0x0c94a108,
+ 0x0a908420, 0x0008a4a3, 0x084210c0, 0x00071084, 0x2ab00000, 0x0008d6b5,
+ 0x26d00000, 0x0008c631, 0x22e00000, 0x00074631, 0x22f00000, 0x0210be31,
+ 0x23e00000, 0x21087a31, 0x26d00000, 0x00008421, 0x22e00000, 0x00074506,
+ 0x04f10800, 0x00064842, 0x23100000, 0x000b6631, 0x23100000, 0x00022951,
+ 0x23100000, 0x000556b5, 0x15100000, 0x0008a884, 0x23100000, 0x1d185b31,
+ 0x11f00000, 0x000f8444, 0x06421098, 0x01821084, 0x08421080, 0x00021084,
+ 0x30421083, 0x00321084, 0x0004d640, 0x00000000, 0x00000000, 0x00000000,
};
#endif
/** @file\r
-* File managing the MMU for ARMv8 architecture\r
-*\r
-* Copyright (c) 2011-2014, ARM Limited. All rights reserved.\r
-* Copyright (c) 2016, Linaro Limited. All rights reserved.\r
-* Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
-*\r
-* SPDX-License-Identifier: BSD-2-Clause-Patent\r
-*\r
-**/\r
+ * File managing the MMU for ARMv8 architecture\r
+ *\r
+ * Copyright (c) 2011-2014, ARM Limited. All rights reserved.\r
+ * Copyright (c) 2016, Linaro Limited. All rights reserved.\r
+ * Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
+ *\r
+ * SPDX-License-Identifier: BSD-2-Clause-Patent\r
+ *\r
+ **/\r
\r
-#include <Uefi.h>\r
#include <Chipset/AArch64.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/CacheMaintenanceLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
#include <Library/ArmLib.h>\r
#include <Library/ArmMmuLib.h>\r
#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/CacheMaintenanceLib.h>\r
#include <Library/DebugLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Uefi.h>\r
\r
// We use this index definition to define an invalid block entry\r
-#define TT_ATTR_INDX_INVALID ((UINT32)~0)\r
+#define TT_ATTR_INDX_INVALID ((UINT32)~0)\r
\r
STATIC\r
UINT64\r
-ArmMemoryAttributeToPageAttribute (\r
- IN ARM_MEMORY_REGION_ATTRIBUTES Attributes\r
- )\r
+ArmMemoryAttributeToPageAttribute(IN ARM_MEMORY_REGION_ATTRIBUTES Attributes)\r
{\r
switch (Attributes) {\r
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_NONSHAREABLE:\r
ASSERT(0);\r
case ARM_MEMORY_REGION_ATTRIBUTE_DEVICE:\r
case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE:\r
- if (ArmReadCurrentEL () == AARCH64_EL2)\r
+ if (ArmReadCurrentEL() == AARCH64_EL2)\r
return TT_ATTR_INDX_DEVICE_MEMORY | TT_XN_MASK;\r
else\r
return TT_ATTR_INDX_DEVICE_MEMORY | TT_UXN_MASK | TT_PXN_MASK;\r
}\r
\r
UINT64\r
-PageAttributeToGcdAttribute (\r
- IN UINT64 PageAttributes\r
- )\r
+PageAttributeToGcdAttribute(IN UINT64 PageAttributes)\r
{\r
- UINT64 GcdAttributes;\r
+ UINT64 GcdAttributes;\r
\r
switch (PageAttributes & TT_ATTR_INDX_MASK) {\r
case TT_ATTR_INDX_DEVICE_MEMORY:\r
GcdAttributes = EFI_MEMORY_WB;\r
break;\r
default:\r
- DEBUG ((EFI_D_ERROR, "PageAttributeToGcdAttribute: PageAttributes:0x%lX not supported.\n", PageAttributes));\r
- ASSERT (0);\r
+ DEBUG(\r
+ (EFI_D_ERROR,\r
+ "PageAttributeToGcdAttribute: PageAttributes:0x%lX not supported.\n",\r
+ PageAttributes));\r
+ ASSERT(0);\r
// The Global Coherency Domain (GCD) value is defined as a bit set.\r
// Returning 0 means no attribute has been set.\r
GcdAttributes = 0;\r
}\r
\r
// Determine protection attributes\r
- if (((PageAttributes & TT_AP_MASK) == TT_AP_NO_RO) || ((PageAttributes & TT_AP_MASK) == TT_AP_RO_RO)) {\r
+ if (((PageAttributes & TT_AP_MASK) == TT_AP_NO_RO) ||\r
+ ((PageAttributes & TT_AP_MASK) == TT_AP_RO_RO)) {\r
// Read only cases map to write-protect\r
GcdAttributes |= EFI_MEMORY_RO;\r
}\r
\r
// Process eXecute Never attribute\r
- if ((PageAttributes & (TT_PXN_MASK | TT_UXN_MASK)) != 0 ) {\r
+ if ((PageAttributes & (TT_PXN_MASK | TT_UXN_MASK)) != 0) {\r
GcdAttributes |= EFI_MEMORY_XP;\r
}\r
\r
return GcdAttributes;\r
}\r
\r
-#define MIN_T0SZ 16\r
-#define BITS_PER_LEVEL 9\r
+#define MIN_T0SZ 16\r
+#define BITS_PER_LEVEL 9\r
\r
-VOID\r
-GetRootTranslationTableInfo (\r
- IN UINTN T0SZ,\r
- OUT UINTN *TableLevel,\r
- OUT UINTN *TableEntryCount\r
- )\r
+VOID GetRootTranslationTableInfo(\r
+ IN UINTN T0SZ, OUT UINTN *TableLevel, OUT UINTN *TableEntryCount)\r
{\r
// Get the level of the root table\r
if (TableLevel) {\r
}\r
\r
if (TableEntryCount) {\r
- *TableEntryCount = 1UL << (BITS_PER_LEVEL - (T0SZ - MIN_T0SZ) % BITS_PER_LEVEL);\r
+ *TableEntryCount =\r
+ 1UL << (BITS_PER_LEVEL - (T0SZ - MIN_T0SZ) % BITS_PER_LEVEL);\r
}\r
}\r
\r
*/\r
\r
STATIC\r
-VOID\r
-LookupAddresstoRootTable (\r
- IN UINT64 MaxAddress,\r
- OUT UINTN *T0SZ,\r
- OUT UINTN *TableEntryCount\r
- )\r
+VOID LookupAddresstoRootTable(\r
+ IN UINT64 MaxAddress, OUT UINTN *T0SZ, OUT UINTN *TableEntryCount)\r
{\r
UINTN TopBit;\r
\r
// Check the parameters are not NULL\r
- ASSERT ((T0SZ != NULL) && (TableEntryCount != NULL));\r
+ ASSERT((T0SZ != NULL) && (TableEntryCount != NULL));\r
\r
// Look for the highest bit set in MaxAddress\r
for (TopBit = 63; TopBit != 0; TopBit--) {\r
break;\r
}\r
}\r
- ASSERT (TopBit != 0);\r
+ ASSERT(TopBit != 0);\r
\r
// Calculate T0SZ from the top bit of the MaxAddress\r
*T0SZ = 64 - TopBit;\r
\r
// Get the Table info from T0SZ\r
- GetRootTranslationTableInfo (*T0SZ, NULL, TableEntryCount);\r
+ GetRootTranslationTableInfo(*T0SZ, NULL, TableEntryCount);\r
}\r
\r
STATIC\r
-UINT64*\r
-GetBlockEntryListFromAddress (\r
- IN UINT64 *RootTable,\r
- IN UINT64 RegionStart,\r
- OUT UINTN *TableLevel,\r
- IN OUT UINT64 *BlockEntrySize,\r
- OUT UINT64 **LastBlockEntry\r
- )\r
+UINT64 *GetBlockEntryListFromAddress(\r
+ IN UINT64 *RootTable, IN UINT64 RegionStart, OUT UINTN *TableLevel,\r
+ IN OUT UINT64 *BlockEntrySize, OUT UINT64 **LastBlockEntry)\r
{\r
UINTN RootTableLevel;\r
UINTN RootTableEntryCount;\r
\r
// Ensure the parameters are valid\r
if (!(TableLevel && BlockEntrySize && LastBlockEntry)) {\r
- ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);\r
+ ASSERT_EFI_ERROR(EFI_INVALID_PARAMETER);\r
return NULL;\r
}\r
\r
// Ensure the Region is aligned on 4KB boundary\r
if ((RegionStart & (SIZE_4KB - 1)) != 0) {\r
- ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);\r
+ ASSERT_EFI_ERROR(EFI_INVALID_PARAMETER);\r
return NULL;\r
}\r
\r
// Ensure the required size is aligned on 4KB boundary and not 0\r
if ((*BlockEntrySize & (SIZE_4KB - 1)) != 0 || *BlockEntrySize == 0) {\r
- ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);\r
+ ASSERT_EFI_ERROR(EFI_INVALID_PARAMETER);\r
return NULL;\r
}\r
\r
- T0SZ = ArmGetTCR () & TCR_T0SZ_MASK;\r
+ T0SZ = ArmGetTCR() & TCR_T0SZ_MASK;\r
// Get the Table info from T0SZ\r
- GetRootTranslationTableInfo (T0SZ, &RootTableLevel, &RootTableEntryCount);\r
+ GetRootTranslationTableInfo(T0SZ, &RootTableLevel, &RootTableEntryCount);\r
\r
- // If the start address is 0x0 then we use the size of the region to identify the alignment\r
+ // If the start address is 0x0 then we use the size of the region to identify\r
+ // the alignment\r
if (RegionStart == 0) {\r
// Identify the highest possible alignment for the Region Size\r
- BaseAddressAlignment = LowBitSet64 (*BlockEntrySize);\r
- } else {\r
+ BaseAddressAlignment = LowBitSet64(*BlockEntrySize);\r
+ }\r
+ else {\r
// Identify the highest possible alignment for the Base Address\r
- BaseAddressAlignment = LowBitSet64 (RegionStart);\r
+ BaseAddressAlignment = LowBitSet64(RegionStart);\r
}\r
\r
// Identify the Page Level the RegionStart must belong to. Note that PageLevel\r
// should be at least 1 since block translations are not supported at level 0\r
- PageLevel = MAX (3 - ((BaseAddressAlignment - 12) / 9), 1);\r
+ PageLevel = MAX(3 - ((BaseAddressAlignment - 12) / 9), 1);\r
\r
- // If the required size is smaller than the current block size then we need to go to the page below.\r
- // The PageLevel was calculated on the Base Address alignment but did not take in account the alignment\r
- // of the allocation size\r
- while (*BlockEntrySize < TT_BLOCK_ENTRY_SIZE_AT_LEVEL (PageLevel)) {\r
+ // If the required size is smaller than the current block size then we need to\r
+ // go to the page below. The PageLevel was calculated on the Base Address\r
+ // alignment but did not take in account the alignment of the allocation size\r
+ while (*BlockEntrySize < TT_BLOCK_ENTRY_SIZE_AT_LEVEL(PageLevel)) {\r
// It does not fit so we need to go a page level above\r
PageLevel++;\r
}\r
\r
//\r
- // Get the Table Descriptor for the corresponding PageLevel. We need to decompose RegionStart to get appropriate entries\r
+ // Get the Table Descriptor for the corresponding PageLevel. We need to\r
+ // decompose RegionStart to get appropriate entries\r
//\r
\r
TranslationTable = RootTable;\r
for (IndexLevel = RootTableLevel; IndexLevel <= PageLevel; IndexLevel++) {\r
- BlockEntry = (UINT64*)TT_GET_ENTRY_FOR_ADDRESS (TranslationTable, IndexLevel, RegionStart);\r
+ BlockEntry = (UINT64 *)TT_GET_ENTRY_FOR_ADDRESS(\r
+ TranslationTable, IndexLevel, RegionStart);\r
\r
- if ((IndexLevel != 3) && ((*BlockEntry & TT_TYPE_MASK) == TT_TYPE_TABLE_ENTRY)) {\r
+ if ((IndexLevel != 3) &&\r
+ ((*BlockEntry & TT_TYPE_MASK) == TT_TYPE_TABLE_ENTRY)) {\r
// Go to the next table\r
- TranslationTable = (UINT64*)(*BlockEntry & TT_ADDRESS_MASK_DESCRIPTION_TABLE);\r
+ TranslationTable =\r
+ (UINT64 *)(*BlockEntry & TT_ADDRESS_MASK_DESCRIPTION_TABLE);\r
\r
// If we are at the last level then update the last level to next level\r
if (IndexLevel == PageLevel) {\r
// Enter the next level\r
PageLevel++;\r
}\r
- } else if ((*BlockEntry & TT_TYPE_MASK) == TT_TYPE_BLOCK_ENTRY) {\r
+ }\r
+ else if ((*BlockEntry & TT_TYPE_MASK) == TT_TYPE_BLOCK_ENTRY) {\r
// If we are not at the last level then we need to split this BlockEntry\r
if (IndexLevel != PageLevel) {\r
// Retrieve the attributes from the block entry\r
\r
// Get the address corresponding at this entry\r
BlockEntryAddress = RegionStart;\r
- BlockEntryAddress = BlockEntryAddress >> TT_ADDRESS_OFFSET_AT_LEVEL(IndexLevel);\r
+ BlockEntryAddress =\r
+ BlockEntryAddress >> TT_ADDRESS_OFFSET_AT_LEVEL(IndexLevel);\r
// Shift back to right to set zero before the effective address\r
- BlockEntryAddress = BlockEntryAddress << TT_ADDRESS_OFFSET_AT_LEVEL(IndexLevel);\r
+ BlockEntryAddress = BlockEntryAddress\r
+ << TT_ADDRESS_OFFSET_AT_LEVEL(IndexLevel);\r
\r
// Set the correct entry type for the next page level\r
if ((IndexLevel + 1) == 3) {\r
Attributes |= TT_TYPE_BLOCK_ENTRY_LEVEL3;\r
- } else {\r
+ }\r
+ else {\r
Attributes |= TT_TYPE_BLOCK_ENTRY;\r
}\r
\r
// Create a new translation table\r
- TranslationTable = AllocatePages (1);\r
+ TranslationTable = AllocatePages(1);\r
if (TranslationTable == NULL) {\r
return NULL;\r
}\r
// Populate the newly created lower level table\r
SubTableBlockEntry = TranslationTable;\r
for (Index = 0; Index < TT_ENTRY_COUNT; Index++) {\r
- *SubTableBlockEntry = Attributes | (BlockEntryAddress + (Index << TT_ADDRESS_OFFSET_AT_LEVEL(IndexLevel + 1)));\r
+ *SubTableBlockEntry =\r
+ Attributes |\r
+ (BlockEntryAddress +\r
+ (Index << TT_ADDRESS_OFFSET_AT_LEVEL(IndexLevel + 1)));\r
SubTableBlockEntry++;\r
}\r
\r
// Fill the BlockEntry with the new TranslationTable\r
- *BlockEntry = ((UINTN)TranslationTable & TT_ADDRESS_MASK_DESCRIPTION_TABLE) | TableAttributes | TT_TYPE_TABLE_ENTRY;\r
+ *BlockEntry =\r
+ ((UINTN)TranslationTable & TT_ADDRESS_MASK_DESCRIPTION_TABLE) |\r
+ TableAttributes | TT_TYPE_TABLE_ENTRY;\r
}\r
- } else {\r
+ }\r
+ else {\r
if (IndexLevel != PageLevel) {\r
//\r
- // Case when we have an Invalid Entry and we are at a page level above of the one targetted.\r
+ // Case when we have an Invalid Entry and we are at a page level above\r
+ // of the one targetted.\r
//\r
\r
// Create a new translation table\r
- TranslationTable = AllocatePages (1);\r
+ TranslationTable = AllocatePages(1);\r
if (TranslationTable == NULL) {\r
return NULL;\r
}\r
\r
- ZeroMem (TranslationTable, TT_ENTRY_COUNT * sizeof(UINT64));\r
+ ZeroMem(TranslationTable, TT_ENTRY_COUNT * sizeof(UINT64));\r
\r
// Fill the new BlockEntry with the TranslationTable\r
- *BlockEntry = ((UINTN)TranslationTable & TT_ADDRESS_MASK_DESCRIPTION_TABLE) | TT_TYPE_TABLE_ENTRY;\r
+ *BlockEntry =\r
+ ((UINTN)TranslationTable & TT_ADDRESS_MASK_DESCRIPTION_TABLE) |\r
+ TT_TYPE_TABLE_ENTRY;\r
}\r
}\r
}\r
// Expose the found PageLevel to the caller\r
*TableLevel = PageLevel;\r
\r
- // Now, we have the Table Level we can get the Block Size associated to this table\r
- *BlockEntrySize = TT_BLOCK_ENTRY_SIZE_AT_LEVEL (PageLevel);\r
+ // Now, we have the Table Level we can get the Block Size associated to this\r
+ // table\r
+ *BlockEntrySize = TT_BLOCK_ENTRY_SIZE_AT_LEVEL(PageLevel);\r
\r
- // The last block of the root table depends on the number of entry in this table,\r
- // otherwise it is always the (TT_ENTRY_COUNT - 1)th entry in the table.\r
- *LastBlockEntry = TT_LAST_BLOCK_ADDRESS(TranslationTable,\r
+ // The last block of the root table depends on the number of entry in this\r
+ // table, otherwise it is always the (TT_ENTRY_COUNT - 1)th entry in the\r
+ // table.\r
+ *LastBlockEntry = TT_LAST_BLOCK_ADDRESS(\r
+ TranslationTable,\r
(PageLevel == RootTableLevel) ? RootTableEntryCount : TT_ENTRY_COUNT);\r
\r
return BlockEntry;\r
\r
STATIC\r
EFI_STATUS\r
-UpdateRegionMapping (\r
- IN UINT64 *RootTable,\r
- IN UINT64 RegionStart,\r
- IN UINT64 RegionLength,\r
- IN UINT64 Attributes,\r
- IN UINT64 BlockEntryMask\r
- )\r
+UpdateRegionMapping(\r
+ IN UINT64 *RootTable, IN UINT64 RegionStart, IN UINT64 RegionLength,\r
+ IN UINT64 Attributes, IN UINT64 BlockEntryMask)\r
{\r
UINT32 Type;\r
- UINT64 *BlockEntry;\r
- UINT64 *LastBlockEntry;\r
+ UINT64 *BlockEntry;\r
+ UINT64 *LastBlockEntry;\r
UINT64 BlockEntrySize;\r
UINTN TableLevel;\r
\r
// Ensure the Length is aligned on 4KB boundary\r
if ((RegionLength == 0) || ((RegionLength & (SIZE_4KB - 1)) != 0)) {\r
- ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);\r
+ ASSERT_EFI_ERROR(EFI_INVALID_PARAMETER);\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
do {\r
- // Get the first Block Entry that matches the Virtual Address and also the information on the Table Descriptor\r
- // such as the size of the Block Entry and the address of the last BlockEntry of the Table Descriptor\r
+ // Get the first Block Entry that matches the Virtual Address and also the\r
+ // information on the Table Descriptor such as the size of the Block Entry\r
+ // and the address of the last BlockEntry of the Table Descriptor\r
BlockEntrySize = RegionLength;\r
- BlockEntry = GetBlockEntryListFromAddress (RootTable, RegionStart, &TableLevel, &BlockEntrySize, &LastBlockEntry);\r
+ BlockEntry = GetBlockEntryListFromAddress(\r
+ RootTable, RegionStart, &TableLevel, &BlockEntrySize, &LastBlockEntry);\r
if (BlockEntry == NULL) {\r
- // GetBlockEntryListFromAddress() return NULL when it fails to allocate new pages from the Translation Tables\r
+ // GetBlockEntryListFromAddress() return NULL when it fails to allocate\r
+ // new pages from the Translation Tables\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
if (TableLevel != 3) {\r
Type = TT_TYPE_BLOCK_ENTRY;\r
- } else {\r
+ }\r
+ else {\r
Type = TT_TYPE_BLOCK_ENTRY_LEVEL3;\r
}\r
\r
do {\r
// Fill the Block Entry with attribute and output block address\r
*BlockEntry &= BlockEntryMask;\r
- *BlockEntry |= (RegionStart & TT_ADDRESS_MASK_BLOCK_ENTRY) | Attributes | Type;\r
+ *BlockEntry |=\r
+ (RegionStart & TT_ADDRESS_MASK_BLOCK_ENTRY) | Attributes | Type;\r
\r
- ArmUpdateTranslationTableEntry (BlockEntry, (VOID *)RegionStart);\r
+ ArmUpdateTranslationTableEntry(BlockEntry, (VOID *)RegionStart);\r
\r
// Go to the next BlockEntry\r
RegionStart += BlockEntrySize;\r
// Rerun GetBlockEntryListFromAddress to avoid page table memory leak\r
if (TableLevel != 3 && BlockEntry <= LastBlockEntry &&\r
(*BlockEntry & TT_TYPE_MASK) == TT_TYPE_TABLE_ENTRY) {\r
- break;\r
+ break;\r
}\r
- } while ((RegionLength >= BlockEntrySize) && (BlockEntry <= LastBlockEntry));\r
+ } while ((RegionLength >= BlockEntrySize) &&\r
+ (BlockEntry <= LastBlockEntry));\r
} while (RegionLength != 0);\r
\r
return EFI_SUCCESS;\r
\r
STATIC\r
EFI_STATUS\r
-FillTranslationTable (\r
- IN UINT64 *RootTable,\r
- IN ARM_MEMORY_REGION_DESCRIPTOR *MemoryRegion\r
- )\r
+FillTranslationTable(\r
+ IN UINT64 *RootTable, IN ARM_MEMORY_REGION_DESCRIPTOR *MemoryRegion)\r
{\r
- return UpdateRegionMapping (\r
- RootTable,\r
- MemoryRegion->VirtualBase,\r
- MemoryRegion->Length,\r
- ArmMemoryAttributeToPageAttribute (MemoryRegion->Attributes) | TT_AF,\r
- 0\r
- );\r
+ return UpdateRegionMapping(\r
+ RootTable, MemoryRegion->VirtualBase, MemoryRegion->Length,\r
+ ArmMemoryAttributeToPageAttribute(MemoryRegion->Attributes) | TT_AF, 0);\r
}\r
\r
STATIC\r
UINT64\r
-GcdAttributeToPageAttribute (\r
- IN UINT64 GcdAttributes\r
- )\r
+GcdAttributeToPageAttribute(IN UINT64 GcdAttributes)\r
{\r
UINT64 PageAttributes;\r
\r
\r
if ((GcdAttributes & EFI_MEMORY_XP) != 0 ||\r
(GcdAttributes & EFI_MEMORY_CACHETYPE_MASK) == EFI_MEMORY_UC) {\r
- if (ArmReadCurrentEL () == AARCH64_EL2) {\r
+ if (ArmReadCurrentEL() == AARCH64_EL2) {\r
PageAttributes |= TT_XN_MASK;\r
- } else {\r
+ }\r
+ else {\r
PageAttributes |= TT_UXN_MASK | TT_PXN_MASK;\r
}\r
}\r
}\r
\r
EFI_STATUS\r
-ArmSetMemoryAttributes (\r
- IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
- IN UINT64 Length,\r
- IN UINT64 Attributes\r
- )\r
+ArmSetMemoryAttributes(\r
+ IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes)\r
{\r
- EFI_STATUS Status;\r
- UINT64 *TranslationTable;\r
- UINT64 PageAttributes;\r
- UINT64 PageAttributeMask;\r
+ EFI_STATUS Status;\r
+ UINT64 * TranslationTable;\r
+ UINT64 PageAttributes;\r
+ UINT64 PageAttributeMask;\r
\r
- PageAttributes = GcdAttributeToPageAttribute (Attributes);\r
+ PageAttributes = GcdAttributeToPageAttribute(Attributes);\r
PageAttributeMask = 0;\r
\r
if ((Attributes & EFI_MEMORY_CACHETYPE_MASK) == 0) {\r
// permissions only.\r
//\r
PageAttributes &= TT_AP_MASK | TT_UXN_MASK | TT_PXN_MASK;\r
- PageAttributeMask = ~(TT_ADDRESS_MASK_BLOCK_ENTRY | TT_AP_MASK |\r
- TT_PXN_MASK | TT_XN_MASK);\r
+ PageAttributeMask =\r
+ ~(TT_ADDRESS_MASK_BLOCK_ENTRY | TT_AP_MASK | TT_PXN_MASK | TT_XN_MASK);\r
}\r
\r
- TranslationTable = ArmGetTTBR0BaseAddress ();\r
+ TranslationTable = ArmGetTTBR0BaseAddress();\r
\r
- Status = UpdateRegionMapping (\r
- TranslationTable,\r
- BaseAddress,\r
- Length,\r
- PageAttributes,\r
- PageAttributeMask);\r
- if (EFI_ERROR (Status)) {\r
+ Status = UpdateRegionMapping(\r
+ TranslationTable, BaseAddress, Length, PageAttributes, PageAttributeMask);\r
+ if (EFI_ERROR(Status)) {\r
return Status;\r
}\r
\r
\r
STATIC\r
EFI_STATUS\r
-SetMemoryRegionAttribute (\r
- IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
- IN UINT64 Length,\r
- IN UINT64 Attributes,\r
- IN UINT64 BlockEntryMask\r
- )\r
+SetMemoryRegionAttribute(\r
+ IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes,\r
+ IN UINT64 BlockEntryMask)\r
{\r
- EFI_STATUS Status;\r
- UINT64 *RootTable;\r
+ EFI_STATUS Status;\r
+ UINT64 * RootTable;\r
\r
- RootTable = ArmGetTTBR0BaseAddress ();\r
+ RootTable = ArmGetTTBR0BaseAddress();\r
\r
- Status = UpdateRegionMapping (RootTable, BaseAddress, Length, Attributes, BlockEntryMask);\r
- if (EFI_ERROR (Status)) {\r
+ Status = UpdateRegionMapping(\r
+ RootTable, BaseAddress, Length, Attributes, BlockEntryMask);\r
+ if (EFI_ERROR(Status)) {\r
return Status;\r
}\r
\r
}\r
\r
EFI_STATUS\r
-ArmSetMemoryRegionNoExec (\r
- IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
- IN UINT64 Length\r
- )\r
+ArmSetMemoryRegionNoExec(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length)\r
{\r
- UINT64 Val;\r
+ UINT64 Val;\r
\r
- if (ArmReadCurrentEL () == AARCH64_EL1) {\r
+ if (ArmReadCurrentEL() == AARCH64_EL1) {\r
Val = TT_PXN_MASK | TT_UXN_MASK;\r
- } else {\r
+ }\r
+ else {\r
Val = TT_XN_MASK;\r
}\r
\r
- return SetMemoryRegionAttribute (\r
- BaseAddress,\r
- Length,\r
- Val,\r
- ~TT_ADDRESS_MASK_BLOCK_ENTRY);\r
+ return SetMemoryRegionAttribute(\r
+ BaseAddress, Length, Val, ~TT_ADDRESS_MASK_BLOCK_ENTRY);\r
}\r
\r
EFI_STATUS\r
-ArmClearMemoryRegionNoExec (\r
- IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
- IN UINT64 Length\r
- )\r
+ArmClearMemoryRegionNoExec(\r
+ IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length)\r
{\r
UINT64 Mask;\r
\r
// XN maps to UXN in the EL1&0 translation regime\r
Mask = ~(TT_ADDRESS_MASK_BLOCK_ENTRY | TT_PXN_MASK | TT_XN_MASK);\r
\r
- return SetMemoryRegionAttribute (\r
- BaseAddress,\r
- Length,\r
- 0,\r
- Mask);\r
+ return SetMemoryRegionAttribute(BaseAddress, Length, 0, Mask);\r
}\r
\r
EFI_STATUS\r
-ArmSetMemoryRegionReadOnly (\r
- IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
- IN UINT64 Length\r
- )\r
+ArmSetMemoryRegionReadOnly(\r
+ IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length)\r
{\r
- return SetMemoryRegionAttribute (\r
- BaseAddress,\r
- Length,\r
- TT_AP_RO_RO,\r
- ~TT_ADDRESS_MASK_BLOCK_ENTRY);\r
+ return SetMemoryRegionAttribute(\r
+ BaseAddress, Length, TT_AP_RO_RO, ~TT_ADDRESS_MASK_BLOCK_ENTRY);\r
}\r
\r
EFI_STATUS\r
-ArmClearMemoryRegionReadOnly (\r
- IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
- IN UINT64 Length\r
- )\r
+ArmClearMemoryRegionReadOnly(\r
+ IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length)\r
{\r
- return SetMemoryRegionAttribute (\r
- BaseAddress,\r
- Length,\r
- TT_AP_RW_RW,\r
- ~(TT_ADDRESS_MASK_BLOCK_ENTRY | TT_AP_MASK));\r
+ return SetMemoryRegionAttribute(\r
+ BaseAddress, Length, TT_AP_RW_RW,\r
+ ~(TT_ADDRESS_MASK_BLOCK_ENTRY | TT_AP_MASK));\r
}\r
\r
EFI_STATUS\r
EFIAPI\r
-ArmConfigureMmu (\r
- IN ARM_MEMORY_REGION_DESCRIPTOR *MemoryTable,\r
- OUT VOID **TranslationTableBase OPTIONAL,\r
- OUT UINTN *TranslationTableSize OPTIONAL\r
- )\r
+ArmConfigureMmu(\r
+ IN ARM_MEMORY_REGION_DESCRIPTOR *MemoryTable,\r
+ OUT VOID **TranslationTableBase OPTIONAL,\r
+ OUT UINTN *TranslationTableSize OPTIONAL)\r
{\r
- VOID* TranslationTable;\r
- UINT32 TranslationTableAttribute;\r
- UINT64 MaxAddress;\r
- UINTN T0SZ;\r
- UINTN RootTableEntryCount;\r
- UINT64 TCR;\r
- EFI_STATUS Status;\r
-\r
- if(MemoryTable == NULL) {\r
- ASSERT (MemoryTable != NULL);\r
+ VOID * TranslationTable;\r
+ UINT32 TranslationTableAttribute;\r
+ UINT64 MaxAddress;\r
+ UINTN T0SZ;\r
+ UINTN RootTableEntryCount;\r
+ UINT64 TCR;\r
+ EFI_STATUS Status;\r
+\r
+ if (MemoryTable == NULL) {\r
+ ASSERT(MemoryTable != NULL);\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
// into account the architectural limitations that result from UEFI's\r
// use of 4 KB pages.\r
//\r
- MaxAddress = MIN (LShiftU64 (1ULL, ArmGetPhysicalAddressBits ()) - 1,\r
- MAX_ALLOC_ADDRESS);\r
+ MaxAddress =\r
+ MIN(LShiftU64(1ULL, ArmGetPhysicalAddressBits()) - 1, MAX_ALLOC_ADDRESS);\r
\r
// Lookup the Table Level to get the information\r
- LookupAddresstoRootTable (MaxAddress, &T0SZ, &RootTableEntryCount);\r
+ LookupAddresstoRootTable(MaxAddress, &T0SZ, &RootTableEntryCount);\r
\r
//\r
// Set TCR that allows us to retrieve T0SZ in the subsequent functions\r
//\r
// Ideally we will be running at EL2, but should support EL1 as well.\r
// UEFI should not run at EL3.\r
- if (ArmReadCurrentEL () == AARCH64_EL2) {\r
- //Note: Bits 23 and 31 are reserved(RES1) bits in TCR_EL2\r
+ if (ArmReadCurrentEL() == AARCH64_EL2) {\r
+ // Note: Bits 23 and 31 are reserved(RES1) bits in TCR_EL2\r
TCR = T0SZ | (1UL << 31) | (1UL << 23) | TCR_TG0_4KB;\r
\r
// Set the Physical Address Size using MaxAddress\r
if (MaxAddress < SIZE_4GB) {\r
TCR |= TCR_PS_4GB;\r
- } else if (MaxAddress < SIZE_64GB) {\r
+ }\r
+ else if (MaxAddress < SIZE_64GB) {\r
TCR |= TCR_PS_64GB;\r
- } else if (MaxAddress < SIZE_1TB) {\r
+ }\r
+ else if (MaxAddress < SIZE_1TB) {\r
TCR |= TCR_PS_1TB;\r
- } else if (MaxAddress < SIZE_4TB) {\r
+ }\r
+ else if (MaxAddress < SIZE_4TB) {\r
TCR |= TCR_PS_4TB;\r
- } else if (MaxAddress < SIZE_16TB) {\r
+ }\r
+ else if (MaxAddress < SIZE_16TB) {\r
TCR |= TCR_PS_16TB;\r
- } else if (MaxAddress < SIZE_256TB) {\r
+ }\r
+ else if (MaxAddress < SIZE_256TB) {\r
TCR |= TCR_PS_256TB;\r
- } else {\r
- DEBUG ((EFI_D_ERROR, "ArmConfigureMmu: The MaxAddress 0x%lX is not supported by this MMU configuration.\n", MaxAddress));\r
- ASSERT (0); // Bigger than 48-bit memory space are not supported\r
+ }\r
+ else {\r
+ DEBUG(\r
+ (EFI_D_ERROR,\r
+ "ArmConfigureMmu: The MaxAddress 0x%lX is not supported by this MMU "\r
+ "configuration.\n",\r
+ MaxAddress));\r
+ ASSERT(0); // Bigger than 48-bit memory space are not supported\r
return EFI_UNSUPPORTED;\r
}\r
- } else if (ArmReadCurrentEL () == AARCH64_EL1) {\r
- // Due to Cortex-A57 erratum #822227 we must set TG1[1] == 1, regardless of EPD1.\r
+ }\r
+ else if (ArmReadCurrentEL() == AARCH64_EL1) {\r
+ // Due to Cortex-A57 erratum #822227 we must set TG1[1] == 1, regardless of\r
+ // EPD1.\r
TCR = T0SZ | TCR_TG0_4KB | TCR_TG1_4KB | TCR_EPD1;\r
\r
// Set the Physical Address Size using MaxAddress\r
if (MaxAddress < SIZE_4GB) {\r
TCR |= TCR_IPS_4GB;\r
- } else if (MaxAddress < SIZE_64GB) {\r
+ }\r
+ else if (MaxAddress < SIZE_64GB) {\r
TCR |= TCR_IPS_64GB;\r
- } else if (MaxAddress < SIZE_1TB) {\r
+ }\r
+ else if (MaxAddress < SIZE_1TB) {\r
TCR |= TCR_IPS_1TB;\r
- } else if (MaxAddress < SIZE_4TB) {\r
+ }\r
+ else if (MaxAddress < SIZE_4TB) {\r
TCR |= TCR_IPS_4TB;\r
- } else if (MaxAddress < SIZE_16TB) {\r
+ }\r
+ else if (MaxAddress < SIZE_16TB) {\r
TCR |= TCR_IPS_16TB;\r
- } else if (MaxAddress < SIZE_256TB) {\r
+ }\r
+ else if (MaxAddress < SIZE_256TB) {\r
TCR |= TCR_IPS_256TB;\r
- } else {\r
- DEBUG ((EFI_D_ERROR, "ArmConfigureMmu: The MaxAddress 0x%lX is not supported by this MMU configuration.\n", MaxAddress));\r
- ASSERT (0); // Bigger than 48-bit memory space are not supported\r
+ }\r
+ else {\r
+ DEBUG(\r
+ (EFI_D_ERROR,\r
+ "ArmConfigureMmu: The MaxAddress 0x%lX is not supported by this MMU "\r
+ "configuration.\n",\r
+ MaxAddress));\r
+ ASSERT(0); // Bigger than 48-bit memory space are not supported\r
return EFI_UNSUPPORTED;\r
}\r
- } else {\r
- ASSERT (0); // UEFI is only expected to run at EL2 and EL1, not EL3.\r
+ }\r
+ else {\r
+ ASSERT(0); // UEFI is only expected to run at EL2 and EL1, not EL3.\r
return EFI_UNSUPPORTED;\r
}\r
\r
// assert below that that matches the attributes we use for CPU accesses to\r
// the region.\r
//\r
- TCR |= TCR_SH_INNER_SHAREABLE |\r
- TCR_RGN_OUTER_WRITE_BACK_ALLOC |\r
+ TCR |= TCR_SH_INNER_SHAREABLE | TCR_RGN_OUTER_WRITE_BACK_ALLOC |\r
TCR_RGN_INNER_WRITE_BACK_ALLOC;\r
\r
// Set TCR\r
- ArmSetTCR (TCR);\r
+ ArmSetTCR(TCR);\r
\r
// Allocate pages for translation table\r
- TranslationTable = AllocatePages (1);\r
+ TranslationTable = AllocatePages(1);\r
if (TranslationTable == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
- // We set TTBR0 just after allocating the table to retrieve its location from the subsequent\r
- // functions without needing to pass this value across the functions. The MMU is only enabled\r
- // after the translation tables are populated.\r
- ArmSetTTBR0 (TranslationTable);\r
+ // We set TTBR0 just after allocating the table to retrieve its location from\r
+ // the subsequent functions without needing to pass this value across the\r
+ // functions. The MMU is only enabled after the translation tables are\r
+ // populated.\r
+ ArmSetTTBR0(TranslationTable);\r
\r
if (TranslationTableBase != NULL) {\r
*TranslationTableBase = TranslationTable;\r
*TranslationTableSize = RootTableEntryCount * sizeof(UINT64);\r
}\r
\r
- ZeroMem (TranslationTable, RootTableEntryCount * sizeof(UINT64));\r
+ ZeroMem(TranslationTable, RootTableEntryCount * sizeof(UINT64));\r
\r
// Disable MMU and caches. ArmDisableMmu() also invalidates the TLBs\r
- ArmDisableMmu ();\r
- ArmDisableDataCache ();\r
- ArmDisableInstructionCache ();\r
+ ArmDisableMmu();\r
+ ArmDisableDataCache();\r
+ ArmDisableInstructionCache();\r
\r
// Make sure nothing sneaked into the cache\r
- ArmCleanInvalidateDataCache ();\r
- ArmInvalidateInstructionCache ();\r
+ ArmCleanInvalidateDataCache();\r
+ ArmInvalidateInstructionCache();\r
\r
TranslationTableAttribute = TT_ATTR_INDX_INVALID;\r
- UINTN idx = 0;\r
+ UINTN idx = 0;\r
while (MemoryTable->Length != 0) {\r
if ((MemoryTable->Length & (SIZE_4KB - 1)) != 0) {\r
- DEBUG ((DEBUG_ERROR, "bruh: %d\n", idx));\r
+ DEBUG((DEBUG_ERROR, "bruh: %d\n", idx));\r
}\r
\r
- DEBUG_CODE_BEGIN ();\r
- // Find the memory attribute for the Translation Table\r
- if ((UINTN)TranslationTable >= MemoryTable->PhysicalBase &&\r
- (UINTN)TranslationTable + EFI_PAGE_SIZE <= MemoryTable->PhysicalBase +\r
- MemoryTable->Length) {\r
- TranslationTableAttribute = MemoryTable->Attributes;\r
- }\r
- DEBUG_CODE_END ();\r
+ DEBUG_CODE_BEGIN();\r
+ // Find the memory attribute for the Translation Table\r
+ if ((UINTN)TranslationTable >= MemoryTable->PhysicalBase &&\r
+ (UINTN)TranslationTable + EFI_PAGE_SIZE <=\r
+ MemoryTable->PhysicalBase + MemoryTable->Length) {\r
+ TranslationTableAttribute = MemoryTable->Attributes;\r
+ }\r
+ DEBUG_CODE_END();\r
\r
- Status = FillTranslationTable (TranslationTable, MemoryTable);\r
- if (EFI_ERROR (Status)) {\r
+ Status = FillTranslationTable(TranslationTable, MemoryTable);\r
+ if (EFI_ERROR(Status)) {\r
goto FREE_TRANSLATION_TABLE;\r
}\r
MemoryTable++;\r
idx++;\r
}\r
\r
- ASSERT (TranslationTableAttribute == ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK ||\r
- TranslationTableAttribute == ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK);\r
-\r
- ArmSetMAIR (MAIR_ATTR(TT_ATTR_INDX_DEVICE_MEMORY, MAIR_ATTR_DEVICE_MEMORY) | // mapped to EFI_MEMORY_UC\r
- MAIR_ATTR(TT_ATTR_INDX_MEMORY_NON_CACHEABLE, MAIR_ATTR_NORMAL_MEMORY_NON_CACHEABLE) | // mapped to EFI_MEMORY_WC\r
- MAIR_ATTR(TT_ATTR_INDX_MEMORY_WRITE_THROUGH, MAIR_ATTR_NORMAL_MEMORY_WRITE_THROUGH) | // mapped to EFI_MEMORY_WT\r
- MAIR_ATTR(TT_ATTR_INDX_MEMORY_WRITE_BACK, MAIR_ATTR_NORMAL_MEMORY_WRITE_BACK)); // mapped to EFI_MEMORY_WB\r
-\r
- ArmDisableAlignmentCheck ();\r
- ArmEnableStackAlignmentCheck ();\r
- ArmEnableInstructionCache ();\r
- ArmEnableDataCache ();\r
-\r
- ArmEnableMmu ();\r
+ ASSERT(\r
+ TranslationTableAttribute == ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK ||\r
+ TranslationTableAttribute ==\r
+ ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK);\r
+\r
+ ArmSetMAIR(\r
+ MAIR_ATTR(\r
+ TT_ATTR_INDX_DEVICE_MEMORY,\r
+ MAIR_ATTR_DEVICE_MEMORY) | // mapped to EFI_MEMORY_UC\r
+ MAIR_ATTR(\r
+ TT_ATTR_INDX_MEMORY_NON_CACHEABLE,\r
+ MAIR_ATTR_NORMAL_MEMORY_NON_CACHEABLE) | // mapped to EFI_MEMORY_WC\r
+ MAIR_ATTR(\r
+ TT_ATTR_INDX_MEMORY_WRITE_THROUGH,\r
+ MAIR_ATTR_NORMAL_MEMORY_WRITE_THROUGH) | // mapped to EFI_MEMORY_WT\r
+ MAIR_ATTR(\r
+ TT_ATTR_INDX_MEMORY_WRITE_BACK,\r
+ MAIR_ATTR_NORMAL_MEMORY_WRITE_BACK)); // mapped to EFI_MEMORY_WB\r
+\r
+ ArmDisableAlignmentCheck();\r
+ ArmEnableStackAlignmentCheck();\r
+ ArmEnableInstructionCache();\r
+ ArmEnableDataCache();\r
+\r
+ ArmEnableMmu();\r
return EFI_SUCCESS;\r
\r
FREE_TRANSLATION_TABLE:\r
- FreePages (TranslationTable, 1);\r
+ FreePages(TranslationTable, 1);\r
return Status;\r
}\r
\r
RETURN_STATUS\r
EFIAPI\r
-ArmMmuBaseLibConstructor (\r
- VOID\r
- )\r
+ArmMmuBaseLibConstructor(VOID)\r
{\r
extern UINT32 ArmReplaceLiveTranslationEntrySize;\r
\r
// The ArmReplaceLiveTranslationEntry () helper function may be invoked\r
// with the MMU off so we have to ensure that it gets cleaned to the PoC\r
//\r
- WriteBackDataCacheRange (ArmReplaceLiveTranslationEntry,\r
- ArmReplaceLiveTranslationEntrySize);\r
+ WriteBackDataCacheRange(\r
+ ArmReplaceLiveTranslationEntry, ArmReplaceLiveTranslationEntrySize);\r
\r
return RETURN_SUCCESS;\r
}\r
\r
EFI_STATUS\r
EFIAPI\r
-ArmMmuPeiLibConstructor (\r
- IN EFI_PEI_FILE_HANDLE FileHandle,\r
- IN CONST EFI_PEI_SERVICES **PeiServices\r
- )\r
+ArmMmuPeiLibConstructor(\r
+ IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)\r
{\r
- extern UINT32 ArmReplaceLiveTranslationEntrySize;\r
+ extern UINT32 ArmReplaceLiveTranslationEntrySize;\r
\r
- EFI_FV_FILE_INFO FileInfo;\r
- EFI_STATUS Status;\r
+ EFI_FV_FILE_INFO FileInfo;\r
+ EFI_STATUS Status;\r
\r
- ASSERT (FileHandle != NULL);\r
+ ASSERT(FileHandle != NULL);\r
\r
- Status = (*PeiServices)->FfsGetFileInfo (FileHandle, &FileInfo);\r
- ASSERT_EFI_ERROR (Status);\r
+ Status = (*PeiServices)->FfsGetFileInfo(FileHandle, &FileInfo);\r
+ ASSERT_EFI_ERROR(Status);\r
\r
//\r
// Some platforms do not cope very well with cache maintenance being\r
//\r
if ((UINTN)FileInfo.Buffer <= (UINTN)ArmReplaceLiveTranslationEntry &&\r
((UINTN)FileInfo.Buffer + FileInfo.BufferSize >=\r
- (UINTN)ArmReplaceLiveTranslationEntry + ArmReplaceLiveTranslationEntrySize)) {\r
- DEBUG ((EFI_D_INFO, "ArmMmuLib: skipping cache maintenance on XIP PEIM\n"));\r
- } else {\r
- DEBUG ((EFI_D_INFO, "ArmMmuLib: performing cache maintenance on shadowed PEIM\n"));\r
+ (UINTN)ArmReplaceLiveTranslationEntry +\r
+ ArmReplaceLiveTranslationEntrySize)) {\r
+ DEBUG((EFI_D_INFO, "ArmMmuLib: skipping cache maintenance on XIP PEIM\n"));\r
+ }\r
+ else {\r
+ DEBUG(\r
+ (EFI_D_INFO,\r
+ "ArmMmuLib: performing cache maintenance on shadowed PEIM\n"));\r
//\r
// The ArmReplaceLiveTranslationEntry () helper function may be invoked\r
// with the MMU off so we have to ensure that it gets cleaned to the PoC\r
//\r
- WriteBackDataCacheRange (ArmReplaceLiveTranslationEntry,\r
- ArmReplaceLiveTranslationEntrySize);\r
+ WriteBackDataCacheRange(\r
+ ArmReplaceLiveTranslationEntry, ArmReplaceLiveTranslationEntrySize);\r
}\r
\r
return RETURN_SUCCESS;\r
/** @file\r
-* File managing the MMU for ARMv7 architecture\r
-*\r
-* Copyright (c) 2011-2016, ARM Limited. All rights reserved.\r
-*\r
-* SPDX-License-Identifier: BSD-2-Clause-Patent\r
-*\r
-**/\r
+ * File managing the MMU for ARMv7 architecture\r
+ *\r
+ * Copyright (c) 2011-2016, ARM Limited. All rights reserved.\r
+ *\r
+ * SPDX-License-Identifier: BSD-2-Clause-Patent\r
+ *\r
+ **/\r
\r
-#include <Uefi.h>\r
#include <Chipset/ArmV7.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/CacheMaintenanceLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
#include <Library/ArmLib.h>\r
#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/CacheMaintenanceLib.h>\r
#include <Library/DebugLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
#include <Library/PcdLib.h>\r
+#include <Uefi.h>\r
\r
-#define ID_MMFR0_SHARELVL_SHIFT 12\r
-#define ID_MMFR0_SHARELVL_MASK 0xf\r
-#define ID_MMFR0_SHARELVL_ONE 0\r
-#define ID_MMFR0_SHARELVL_TWO 1\r
+#define ID_MMFR0_SHARELVL_SHIFT 12\r
+#define ID_MMFR0_SHARELVL_MASK 0xf\r
+#define ID_MMFR0_SHARELVL_ONE 0\r
+#define ID_MMFR0_SHARELVL_TWO 1\r
\r
-#define ID_MMFR0_INNERSHR_SHIFT 28\r
-#define ID_MMFR0_INNERSHR_MASK 0xf\r
-#define ID_MMFR0_OUTERSHR_SHIFT 8\r
-#define ID_MMFR0_OUTERSHR_MASK 0xf\r
+#define ID_MMFR0_INNERSHR_SHIFT 28\r
+#define ID_MMFR0_INNERSHR_MASK 0xf\r
+#define ID_MMFR0_OUTERSHR_SHIFT 8\r
+#define ID_MMFR0_OUTERSHR_MASK 0xf\r
\r
-#define ID_MMFR0_SHR_IMP_UNCACHED 0\r
-#define ID_MMFR0_SHR_IMP_HW_COHERENT 1\r
-#define ID_MMFR0_SHR_IGNORED 0xf\r
+#define ID_MMFR0_SHR_IMP_UNCACHED 0\r
+#define ID_MMFR0_SHR_IMP_HW_COHERENT 1\r
+#define ID_MMFR0_SHR_IGNORED 0xf\r
\r
-#define __EFI_MEMORY_RWX 0 // no restrictions\r
+#define __EFI_MEMORY_RWX 0 // no restrictions\r
\r
-#define CACHE_ATTRIBUTE_MASK (EFI_MEMORY_UC | \\r
- EFI_MEMORY_WC | \\r
- EFI_MEMORY_WT | \\r
- EFI_MEMORY_WB | \\r
- EFI_MEMORY_UCE | \\r
- EFI_MEMORY_WP)\r
+#define CACHE_ATTRIBUTE_MASK \\r
+ (EFI_MEMORY_UC | EFI_MEMORY_WC | EFI_MEMORY_WT | EFI_MEMORY_WB | \\r
+ EFI_MEMORY_UCE | EFI_MEMORY_WP)\r
\r
UINTN\r
EFIAPI\r
-ArmReadIdMmfr0 (\r
- VOID\r
- );\r
+ArmReadIdMmfr0(VOID);\r
\r
BOOLEAN\r
EFIAPI\r
-ArmHasMpExtensions (\r
- VOID\r
- );\r
+ArmHasMpExtensions(VOID);\r
\r
UINT32\r
-ConvertSectionAttributesToPageAttributes (\r
- IN UINT32 SectionAttributes,\r
- IN BOOLEAN IsLargePage\r
- )\r
+ConvertSectionAttributesToPageAttributes(\r
+ IN UINT32 SectionAttributes, IN BOOLEAN IsLargePage)\r
{\r
UINT32 PageAttributes;\r
\r
PageAttributes = 0;\r
- PageAttributes |= TT_DESCRIPTOR_CONVERT_TO_PAGE_CACHE_POLICY (SectionAttributes, IsLargePage);\r
- PageAttributes |= TT_DESCRIPTOR_CONVERT_TO_PAGE_AP (SectionAttributes);\r
- PageAttributes |= TT_DESCRIPTOR_CONVERT_TO_PAGE_XN (SectionAttributes, IsLargePage);\r
- PageAttributes |= TT_DESCRIPTOR_CONVERT_TO_PAGE_NG (SectionAttributes);\r
- PageAttributes |= TT_DESCRIPTOR_CONVERT_TO_PAGE_S (SectionAttributes);\r
+ PageAttributes |= TT_DESCRIPTOR_CONVERT_TO_PAGE_CACHE_POLICY(\r
+ SectionAttributes, IsLargePage);\r
+ PageAttributes |= TT_DESCRIPTOR_CONVERT_TO_PAGE_AP(SectionAttributes);\r
+ PageAttributes |=\r
+ TT_DESCRIPTOR_CONVERT_TO_PAGE_XN(SectionAttributes, IsLargePage);\r
+ PageAttributes |= TT_DESCRIPTOR_CONVERT_TO_PAGE_NG(SectionAttributes);\r
+ PageAttributes |= TT_DESCRIPTOR_CONVERT_TO_PAGE_S(SectionAttributes);\r
\r
return PageAttributes;\r
}\r
\r
STATIC\r
BOOLEAN\r
-PreferNonshareableMemory (\r
- VOID\r
- )\r
+PreferNonshareableMemory(VOID)\r
{\r
- UINTN Mmfr;\r
- UINTN Val;\r
+ UINTN Mmfr;\r
+ UINTN Val;\r
\r
- if (FeaturePcdGet (PcdNormalMemoryNonshareableOverride)) {\r
+ if (FeaturePcdGet(PcdNormalMemoryNonshareableOverride)) {\r
return TRUE;\r
}\r
\r
// by default to map normal memory) is implemented with hardware coherency\r
// support. Otherwise, revert to mapping as non-shareable.\r
//\r
- Mmfr = ArmReadIdMmfr0 ();\r
+ Mmfr = ArmReadIdMmfr0();\r
switch ((Mmfr >> ID_MMFR0_SHARELVL_SHIFT) & ID_MMFR0_SHARELVL_MASK) {\r
case ID_MMFR0_SHARELVL_ONE:\r
// one level of shareability\r
break;\r
default:\r
// unexpected value -> shareable is the safe option\r
- ASSERT (FALSE);\r
+ ASSERT(FALSE);\r
return FALSE;\r
}\r
return Val != ID_MMFR0_SHR_IMP_HW_COHERENT;\r
}\r
\r
STATIC\r
-VOID\r
-PopulateLevel2PageTable (\r
- IN UINT32 *SectionEntry,\r
- IN UINT32 PhysicalBase,\r
- IN UINT32 RemainLength,\r
- IN ARM_MEMORY_REGION_ATTRIBUTES Attributes\r
- )\r
+VOID PopulateLevel2PageTable(\r
+ IN UINT32 *SectionEntry, IN UINT32 PhysicalBase, IN UINT32 RemainLength,\r
+ IN ARM_MEMORY_REGION_ATTRIBUTES Attributes)\r
{\r
- UINT32* PageEntry;\r
+ UINT32 *PageEntry;\r
UINT32 Pages;\r
UINT32 Index;\r
UINT32 PageAttributes;\r
UINT32 FirstPageOffset;\r
\r
switch (Attributes) {\r
- case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK:\r
- case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK:\r
- PageAttributes = TT_DESCRIPTOR_PAGE_WRITE_BACK;\r
- break;\r
- case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_NONSHAREABLE:\r
- case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK_NONSHAREABLE:\r
- PageAttributes = TT_DESCRIPTOR_PAGE_WRITE_BACK;\r
- PageAttributes &= ~TT_DESCRIPTOR_PAGE_S_SHARED;\r
- break;\r
- case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_THROUGH:\r
- case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_THROUGH:\r
- PageAttributes = TT_DESCRIPTOR_PAGE_WRITE_THROUGH;\r
- break;\r
- case ARM_MEMORY_REGION_ATTRIBUTE_DEVICE:\r
- case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE:\r
- PageAttributes = TT_DESCRIPTOR_PAGE_DEVICE;\r
- break;\r
- case ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED:\r
- case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_UNCACHED_UNBUFFERED:\r
- PageAttributes = TT_DESCRIPTOR_PAGE_UNCACHED;\r
- break;\r
- default:\r
- PageAttributes = TT_DESCRIPTOR_PAGE_UNCACHED;\r
- break;\r
+ case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK:\r
+ case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK:\r
+ PageAttributes = TT_DESCRIPTOR_PAGE_WRITE_BACK;\r
+ break;\r
+ case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_NONSHAREABLE:\r
+ case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK_NONSHAREABLE:\r
+ PageAttributes = TT_DESCRIPTOR_PAGE_WRITE_BACK;\r
+ PageAttributes &= ~TT_DESCRIPTOR_PAGE_S_SHARED;\r
+ break;\r
+ case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_THROUGH:\r
+ case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_THROUGH:\r
+ PageAttributes = TT_DESCRIPTOR_PAGE_WRITE_THROUGH;\r
+ break;\r
+ case ARM_MEMORY_REGION_ATTRIBUTE_DEVICE:\r
+ case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE:\r
+ PageAttributes = TT_DESCRIPTOR_PAGE_DEVICE;\r
+ break;\r
+ case ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED:\r
+ case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_UNCACHED_UNBUFFERED:\r
+ PageAttributes = TT_DESCRIPTOR_PAGE_UNCACHED;\r
+ break;\r
+ default:\r
+ PageAttributes = TT_DESCRIPTOR_PAGE_UNCACHED;\r
+ break;\r
}\r
\r
- if (PreferNonshareableMemory ()) {\r
+ if (PreferNonshareableMemory()) {\r
PageAttributes &= ~TT_DESCRIPTOR_PAGE_S_SHARED;\r
}\r
\r
// Check if the Section Entry has already been populated. Otherwise attach a\r
// Level 2 Translation Table to it\r
if (*SectionEntry != 0) {\r
- // The entry must be a page table. Otherwise it exists an overlapping in the memory map\r
+ // The entry must be a page table. Otherwise it exists an overlapping in the\r
+ // memory map\r
if (TT_DESCRIPTOR_SECTION_TYPE_IS_PAGE_TABLE(*SectionEntry)) {\r
- TranslationTable = *SectionEntry & TT_DESCRIPTOR_SECTION_PAGETABLE_ADDRESS_MASK;\r
- } else if ((*SectionEntry & TT_DESCRIPTOR_SECTION_TYPE_MASK) == TT_DESCRIPTOR_SECTION_TYPE_SECTION) {\r
+ TranslationTable =\r
+ *SectionEntry & TT_DESCRIPTOR_SECTION_PAGETABLE_ADDRESS_MASK;\r
+ }\r
+ else if (\r
+ (*SectionEntry & TT_DESCRIPTOR_SECTION_TYPE_MASK) ==\r
+ TT_DESCRIPTOR_SECTION_TYPE_SECTION) {\r
// Case where a virtual memory map descriptor overlapped a section entry\r
\r
// Allocate a Level2 Page Table for this Section\r
- TranslationTable = (UINTN)AllocatePages(EFI_SIZE_TO_PAGES(TRANSLATION_TABLE_PAGE_SIZE + TRANSLATION_TABLE_PAGE_ALIGNMENT));\r
- TranslationTable = ((UINTN)TranslationTable + TRANSLATION_TABLE_PAGE_ALIGNMENT_MASK) & ~TRANSLATION_TABLE_PAGE_ALIGNMENT_MASK;\r
+ TranslationTable = (UINTN)AllocatePages(EFI_SIZE_TO_PAGES(\r
+ TRANSLATION_TABLE_PAGE_SIZE + TRANSLATION_TABLE_PAGE_ALIGNMENT));\r
+ TranslationTable =\r
+ ((UINTN)TranslationTable + TRANSLATION_TABLE_PAGE_ALIGNMENT_MASK) &\r
+ ~TRANSLATION_TABLE_PAGE_ALIGNMENT_MASK;\r
\r
// Translate the Section Descriptor into Page Descriptor\r
- SectionDescriptor = TT_DESCRIPTOR_PAGE_TYPE_PAGE | ConvertSectionAttributesToPageAttributes (*SectionEntry, FALSE);\r
+ SectionDescriptor =\r
+ TT_DESCRIPTOR_PAGE_TYPE_PAGE |\r
+ ConvertSectionAttributesToPageAttributes(*SectionEntry, FALSE);\r
\r
BaseSectionAddress = TT_DESCRIPTOR_SECTION_BASE_ADDRESS(*SectionEntry);\r
\r
// Populate the new Level2 Page Table for the section\r
- PageEntry = (UINT32*)TranslationTable;\r
+ PageEntry = (UINT32 *)TranslationTable;\r
for (Index = 0; Index < TRANSLATION_TABLE_PAGE_COUNT; Index++) {\r
- PageEntry[Index] = TT_DESCRIPTOR_PAGE_BASE_ADDRESS(BaseSectionAddress + (Index << 12)) | SectionDescriptor;\r
+ PageEntry[Index] = TT_DESCRIPTOR_PAGE_BASE_ADDRESS(\r
+ BaseSectionAddress + (Index << 12)) |\r
+ SectionDescriptor;\r
}\r
\r
- // Overwrite the section entry to point to the new Level2 Translation Table\r
- *SectionEntry = (TranslationTable & TT_DESCRIPTOR_SECTION_PAGETABLE_ADDRESS_MASK) |\r
+ // Overwrite the section entry to point to the new Level2 Translation\r
+ // Table\r
+ *SectionEntry =\r
+ (TranslationTable & TT_DESCRIPTOR_SECTION_PAGETABLE_ADDRESS_MASK) |\r
(IS_ARM_MEMORY_REGION_ATTRIBUTES_SECURE(Attributes) ? (1 << 3) : 0) |\r
TT_DESCRIPTOR_SECTION_TYPE_PAGE_TABLE;\r
- } else {\r
+ }\r
+ else {\r
// We do not support the other section type (16MB Section)\r
ASSERT(0);\r
return;\r
}\r
- } else {\r
- TranslationTable = (UINTN)AllocatePages(EFI_SIZE_TO_PAGES(TRANSLATION_TABLE_PAGE_SIZE + TRANSLATION_TABLE_PAGE_ALIGNMENT));\r
- TranslationTable = ((UINTN)TranslationTable + TRANSLATION_TABLE_PAGE_ALIGNMENT_MASK) & ~TRANSLATION_TABLE_PAGE_ALIGNMENT_MASK;\r
+ }\r
+ else {\r
+ TranslationTable = (UINTN)AllocatePages(EFI_SIZE_TO_PAGES(\r
+ TRANSLATION_TABLE_PAGE_SIZE + TRANSLATION_TABLE_PAGE_ALIGNMENT));\r
+ TranslationTable =\r
+ ((UINTN)TranslationTable + TRANSLATION_TABLE_PAGE_ALIGNMENT_MASK) &\r
+ ~TRANSLATION_TABLE_PAGE_ALIGNMENT_MASK;\r
\r
- ZeroMem ((VOID *)TranslationTable, TRANSLATION_TABLE_PAGE_SIZE);\r
+ ZeroMem((VOID *)TranslationTable, TRANSLATION_TABLE_PAGE_SIZE);\r
\r
- *SectionEntry = (TranslationTable & TT_DESCRIPTOR_SECTION_PAGETABLE_ADDRESS_MASK) |\r
+ *SectionEntry =\r
+ (TranslationTable & TT_DESCRIPTOR_SECTION_PAGETABLE_ADDRESS_MASK) |\r
(IS_ARM_MEMORY_REGION_ATTRIBUTES_SECURE(Attributes) ? (1 << 3) : 0) |\r
TT_DESCRIPTOR_SECTION_TYPE_PAGE_TABLE;\r
}\r
\r
- FirstPageOffset = (PhysicalBase & TT_DESCRIPTOR_PAGE_INDEX_MASK) >> TT_DESCRIPTOR_PAGE_BASE_SHIFT;\r
+ FirstPageOffset = (PhysicalBase & TT_DESCRIPTOR_PAGE_INDEX_MASK) >>\r
+ TT_DESCRIPTOR_PAGE_BASE_SHIFT;\r
PageEntry = (UINT32 *)TranslationTable + FirstPageOffset;\r
Pages = RemainLength / TT_DESCRIPTOR_PAGE_SIZE;\r
\r
- ASSERT (FirstPageOffset + Pages <= TRANSLATION_TABLE_PAGE_COUNT);\r
+ ASSERT(FirstPageOffset + Pages <= TRANSLATION_TABLE_PAGE_COUNT);\r
\r
for (Index = 0; Index < Pages; Index++) {\r
- *PageEntry++ = TT_DESCRIPTOR_PAGE_BASE_ADDRESS(PhysicalBase) | PageAttributes;\r
+ *PageEntry++ =\r
+ TT_DESCRIPTOR_PAGE_BASE_ADDRESS(PhysicalBase) | PageAttributes;\r
PhysicalBase += TT_DESCRIPTOR_PAGE_SIZE;\r
}\r
-\r
}\r
\r
STATIC\r
-VOID\r
-FillTranslationTable (\r
- IN UINT32 *TranslationTable,\r
- IN ARM_MEMORY_REGION_DESCRIPTOR *MemoryRegion\r
- )\r
+VOID FillTranslationTable(\r
+ IN UINT32 *TranslationTable, IN ARM_MEMORY_REGION_DESCRIPTOR *MemoryRegion)\r
{\r
- UINT32 *SectionEntry;\r
+ UINT32 *SectionEntry;\r
UINT32 Attributes;\r
UINT32 PhysicalBase;\r
UINT64 RemainLength;\r
RemainLength = MIN(MemoryRegion->Length, SIZE_4GB - PhysicalBase);\r
\r
switch (MemoryRegion->Attributes) {\r
- case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK:\r
- Attributes = TT_DESCRIPTOR_SECTION_WRITE_BACK(0);\r
- break;\r
- case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_NONSHAREABLE:\r
- Attributes = TT_DESCRIPTOR_SECTION_WRITE_BACK(0);\r
- Attributes &= ~TT_DESCRIPTOR_SECTION_S_SHARED;\r
- break;\r
- case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_THROUGH:\r
- Attributes = TT_DESCRIPTOR_SECTION_WRITE_THROUGH(0);\r
- break;\r
- case ARM_MEMORY_REGION_ATTRIBUTE_DEVICE:\r
- Attributes = TT_DESCRIPTOR_SECTION_DEVICE(0);\r
- break;\r
- case ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED:\r
- Attributes = TT_DESCRIPTOR_SECTION_UNCACHED(0);\r
- break;\r
- case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK:\r
- Attributes = TT_DESCRIPTOR_SECTION_WRITE_BACK(1);\r
- break;\r
- case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK_NONSHAREABLE:\r
- Attributes = TT_DESCRIPTOR_SECTION_WRITE_BACK(1);\r
- Attributes &= ~TT_DESCRIPTOR_SECTION_S_SHARED;\r
- break;\r
- case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_THROUGH:\r
- Attributes = TT_DESCRIPTOR_SECTION_WRITE_THROUGH(1);\r
- break;\r
- case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE:\r
- Attributes = TT_DESCRIPTOR_SECTION_DEVICE(1);\r
- break;\r
- case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_UNCACHED_UNBUFFERED:\r
- Attributes = TT_DESCRIPTOR_SECTION_UNCACHED(1);\r
- break;\r
- default:\r
- Attributes = TT_DESCRIPTOR_SECTION_UNCACHED(0);\r
- break;\r
+ case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK:\r
+ Attributes = TT_DESCRIPTOR_SECTION_WRITE_BACK(0);\r
+ break;\r
+ case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_NONSHAREABLE:\r
+ Attributes = TT_DESCRIPTOR_SECTION_WRITE_BACK(0);\r
+ Attributes &= ~TT_DESCRIPTOR_SECTION_S_SHARED;\r
+ break;\r
+ case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_THROUGH:\r
+ Attributes = TT_DESCRIPTOR_SECTION_WRITE_THROUGH(0);\r
+ break;\r
+ case ARM_MEMORY_REGION_ATTRIBUTE_DEVICE:\r
+ Attributes = TT_DESCRIPTOR_SECTION_DEVICE(0);\r
+ break;\r
+ case ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED:\r
+ Attributes = TT_DESCRIPTOR_SECTION_UNCACHED(0);\r
+ break;\r
+ case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK:\r
+ Attributes = TT_DESCRIPTOR_SECTION_WRITE_BACK(1);\r
+ break;\r
+ case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK_NONSHAREABLE:\r
+ Attributes = TT_DESCRIPTOR_SECTION_WRITE_BACK(1);\r
+ Attributes &= ~TT_DESCRIPTOR_SECTION_S_SHARED;\r
+ break;\r
+ case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_THROUGH:\r
+ Attributes = TT_DESCRIPTOR_SECTION_WRITE_THROUGH(1);\r
+ break;\r
+ case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE:\r
+ Attributes = TT_DESCRIPTOR_SECTION_DEVICE(1);\r
+ break;\r
+ case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_UNCACHED_UNBUFFERED:\r
+ Attributes = TT_DESCRIPTOR_SECTION_UNCACHED(1);\r
+ break;\r
+ default:\r
+ Attributes = TT_DESCRIPTOR_SECTION_UNCACHED(0);\r
+ break;\r
}\r
\r
- if (PreferNonshareableMemory ()) {\r
+ if (PreferNonshareableMemory()) {\r
Attributes &= ~TT_DESCRIPTOR_SECTION_S_SHARED;\r
}\r
\r
// Get the first section entry for this mapping\r
- SectionEntry = TRANSLATION_TABLE_ENTRY_FOR_VIRTUAL_ADDRESS(TranslationTable, MemoryRegion->VirtualBase);\r
+ SectionEntry = TRANSLATION_TABLE_ENTRY_FOR_VIRTUAL_ADDRESS(\r
+ TranslationTable, MemoryRegion->VirtualBase);\r
\r
while (RemainLength != 0) {\r
if (PhysicalBase % TT_DESCRIPTOR_SECTION_SIZE == 0 &&\r
RemainLength >= TT_DESCRIPTOR_SECTION_SIZE) {\r
// Case: Physical address aligned on the Section Size (1MB) && the length\r
// is greater than the Section Size\r
- *SectionEntry++ = TT_DESCRIPTOR_SECTION_BASE_ADDRESS(PhysicalBase) | Attributes;\r
+ *SectionEntry++ =\r
+ TT_DESCRIPTOR_SECTION_BASE_ADDRESS(PhysicalBase) | Attributes;\r
PhysicalBase += TT_DESCRIPTOR_SECTION_SIZE;\r
RemainLength -= TT_DESCRIPTOR_SECTION_SIZE;\r
- } else {\r
- PageMapLength = MIN (RemainLength, TT_DESCRIPTOR_SECTION_SIZE -\r
- (PhysicalBase % TT_DESCRIPTOR_SECTION_SIZE));\r
+ }\r
+ else {\r
+ PageMapLength =\r
+ MIN(RemainLength, TT_DESCRIPTOR_SECTION_SIZE -\r
+ (PhysicalBase % TT_DESCRIPTOR_SECTION_SIZE));\r
\r
// Case: Physical address aligned on the Section Size (1MB) && the length\r
// does not fill a section\r
// Case: Physical address NOT aligned on the Section Size (1MB)\r
- PopulateLevel2PageTable (SectionEntry++, PhysicalBase, PageMapLength,\r
- MemoryRegion->Attributes);\r
+ PopulateLevel2PageTable(\r
+ SectionEntry++, PhysicalBase, PageMapLength,\r
+ MemoryRegion->Attributes);\r
\r
// If it is the last entry\r
if (RemainLength < TT_DESCRIPTOR_SECTION_SIZE) {\r
\r
RETURN_STATUS\r
EFIAPI\r
-ArmConfigureMmu (\r
- IN ARM_MEMORY_REGION_DESCRIPTOR *MemoryTable,\r
- OUT VOID **TranslationTableBase OPTIONAL,\r
- OUT UINTN *TranslationTableSize OPTIONAL\r
- )\r
+ArmConfigureMmu(\r
+ IN ARM_MEMORY_REGION_DESCRIPTOR *MemoryTable,\r
+ OUT VOID **TranslationTableBase OPTIONAL,\r
+ OUT UINTN *TranslationTableSize OPTIONAL)\r
{\r
- VOID* TranslationTable;\r
- ARM_MEMORY_REGION_ATTRIBUTES TranslationTableAttribute;\r
- UINT32 TTBRAttributes;\r
+ VOID * TranslationTable;\r
+ ARM_MEMORY_REGION_ATTRIBUTES TranslationTableAttribute;\r
+ UINT32 TTBRAttributes;\r
\r
// Allocate pages for translation table.\r
- TranslationTable = AllocatePages (EFI_SIZE_TO_PAGES (TRANSLATION_TABLE_SECTION_SIZE + TRANSLATION_TABLE_SECTION_ALIGNMENT));\r
+ TranslationTable = AllocatePages(EFI_SIZE_TO_PAGES(\r
+ TRANSLATION_TABLE_SECTION_SIZE + TRANSLATION_TABLE_SECTION_ALIGNMENT));\r
if (TranslationTable == NULL) {\r
return RETURN_OUT_OF_RESOURCES;\r
}\r
- TranslationTable = (VOID*)(((UINTN)TranslationTable + TRANSLATION_TABLE_SECTION_ALIGNMENT_MASK) & ~TRANSLATION_TABLE_SECTION_ALIGNMENT_MASK);\r
+ TranslationTable =\r
+ (VOID\r
+ *)(((UINTN)TranslationTable + TRANSLATION_TABLE_SECTION_ALIGNMENT_MASK) & ~TRANSLATION_TABLE_SECTION_ALIGNMENT_MASK);\r
\r
if (TranslationTableBase != NULL) {\r
*TranslationTableBase = TranslationTable;\r
*TranslationTableSize = TRANSLATION_TABLE_SECTION_SIZE;\r
}\r
\r
- ZeroMem (TranslationTable, TRANSLATION_TABLE_SECTION_SIZE);\r
+ ZeroMem(TranslationTable, TRANSLATION_TABLE_SECTION_SIZE);\r
\r
// By default, mark the translation table as belonging to a uncached region\r
TranslationTableAttribute = ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED;\r
while (MemoryTable->Length != 0) {\r
// Find the memory attribute for the Translation Table\r
- if (((UINTN)TranslationTable >= MemoryTable->PhysicalBase) && ((UINTN)TranslationTable <= MemoryTable->PhysicalBase - 1 + MemoryTable->Length)) {\r
+ if (((UINTN)TranslationTable >= MemoryTable->PhysicalBase) &&\r
+ ((UINTN)TranslationTable <=\r
+ MemoryTable->PhysicalBase - 1 + MemoryTable->Length)) {\r
TranslationTableAttribute = MemoryTable->Attributes;\r
}\r
\r
- FillTranslationTable (TranslationTable, MemoryTable);\r
+ FillTranslationTable(TranslationTable, MemoryTable);\r
MemoryTable++;\r
}\r
\r
// Translate the Memory Attributes into Translation Table Register Attributes\r
if ((TranslationTableAttribute == ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK) ||\r
- (TranslationTableAttribute == ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK)) {\r
- TTBRAttributes = ArmHasMpExtensions () ? TTBR_MP_WRITE_BACK_ALLOC : TTBR_WRITE_BACK_ALLOC;\r
- } else {\r
+ (TranslationTableAttribute ==\r
+ ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK)) {\r
+ TTBRAttributes =\r
+ ArmHasMpExtensions() ? TTBR_MP_WRITE_BACK_ALLOC : TTBR_WRITE_BACK_ALLOC;\r
+ }\r
+ else {\r
// Page tables must reside in memory mapped as write-back cacheable\r
- ASSERT (0);\r
+ ASSERT(0);\r
return RETURN_UNSUPPORTED;\r
}\r
\r
if (TTBRAttributes & TTBR_SHAREABLE) {\r
- if (PreferNonshareableMemory ()) {\r
+ if (PreferNonshareableMemory()) {\r
TTBRAttributes ^= TTBR_SHAREABLE;\r
- } else {\r
+ }\r
+ else {\r
//\r
- // Unlike the S bit in the short descriptors, which implies inner shareable\r
- // on an implementation that supports two levels, the meaning of the S bit\r
- // in the TTBR depends on the NOS bit, which defaults to Outer Shareable.\r
- // However, we should only set this bit after we have confirmed that the\r
- // implementation supports multiple levels, or else the NOS bit is UNK/SBZP\r
+ // Unlike the S bit in the short descriptors, which implies inner\r
+ // shareable on an implementation that supports two levels, the meaning of\r
+ // the S bit in the TTBR depends on the NOS bit, which defaults to Outer\r
+ // Shareable. However, we should only set this bit after we have confirmed\r
+ // that the implementation supports multiple levels, or else the NOS bit\r
+ // is UNK/SBZP\r
//\r
- if (((ArmReadIdMmfr0 () >> 12) & 0xf) != 0) {\r
+ if (((ArmReadIdMmfr0() >> 12) & 0xf) != 0) {\r
TTBRAttributes |= TTBR_NOT_OUTER_SHAREABLE;\r
}\r
}\r
}\r
\r
- ArmCleanInvalidateDataCache ();\r
- ArmInvalidateInstructionCache ();\r
+ ArmCleanInvalidateDataCache();\r
+ ArmInvalidateInstructionCache();\r
\r
- ArmDisableDataCache ();\r
+ ArmDisableDataCache();\r
ArmDisableInstructionCache();\r
// TLBs are also invalidated when calling ArmDisableMmu()\r
- ArmDisableMmu ();\r
+ ArmDisableMmu();\r
\r
// Make sure nothing sneaked into the cache\r
- ArmCleanInvalidateDataCache ();\r
- ArmInvalidateInstructionCache ();\r
+ ArmCleanInvalidateDataCache();\r
+ ArmInvalidateInstructionCache();\r
\r
- ArmSetTTBR0 ((VOID *)(UINTN)(((UINTN)TranslationTable & ~TRANSLATION_TABLE_SECTION_ALIGNMENT_MASK) | (TTBRAttributes & 0x7F)));\r
+ ArmSetTTBR0((\r
+ VOID\r
+ *)(UINTN)(((UINTN)TranslationTable & ~TRANSLATION_TABLE_SECTION_ALIGNMENT_MASK) | (TTBRAttributes & 0x7F)));\r
\r
//\r
// The TTBCR register value is undefined at reset in the Non-Secure world.\r
// (0 is the default reset value in systems not implementing\r
// the Security Extensions.)\r
//\r
- ArmSetTTBCR (0);\r
-\r
- ArmSetDomainAccessControl (DOMAIN_ACCESS_CONTROL_NONE(15) |\r
- DOMAIN_ACCESS_CONTROL_NONE(14) |\r
- DOMAIN_ACCESS_CONTROL_NONE(13) |\r
- DOMAIN_ACCESS_CONTROL_NONE(12) |\r
- DOMAIN_ACCESS_CONTROL_NONE(11) |\r
- DOMAIN_ACCESS_CONTROL_NONE(10) |\r
- DOMAIN_ACCESS_CONTROL_NONE( 9) |\r
- DOMAIN_ACCESS_CONTROL_NONE( 8) |\r
- DOMAIN_ACCESS_CONTROL_NONE( 7) |\r
- DOMAIN_ACCESS_CONTROL_NONE( 6) |\r
- DOMAIN_ACCESS_CONTROL_NONE( 5) |\r
- DOMAIN_ACCESS_CONTROL_NONE( 4) |\r
- DOMAIN_ACCESS_CONTROL_NONE( 3) |\r
- DOMAIN_ACCESS_CONTROL_NONE( 2) |\r
- DOMAIN_ACCESS_CONTROL_NONE( 1) |\r
- DOMAIN_ACCESS_CONTROL_CLIENT(0));\r
+ ArmSetTTBCR(0);\r
+\r
+ ArmSetDomainAccessControl(\r
+ DOMAIN_ACCESS_CONTROL_NONE(15) | DOMAIN_ACCESS_CONTROL_NONE(14) |\r
+ DOMAIN_ACCESS_CONTROL_NONE(13) | DOMAIN_ACCESS_CONTROL_NONE(12) |\r
+ DOMAIN_ACCESS_CONTROL_NONE(11) | DOMAIN_ACCESS_CONTROL_NONE(10) |\r
+ DOMAIN_ACCESS_CONTROL_NONE(9) | DOMAIN_ACCESS_CONTROL_NONE(8) |\r
+ DOMAIN_ACCESS_CONTROL_NONE(7) | DOMAIN_ACCESS_CONTROL_NONE(6) |\r
+ DOMAIN_ACCESS_CONTROL_NONE(5) | DOMAIN_ACCESS_CONTROL_NONE(4) |\r
+ DOMAIN_ACCESS_CONTROL_NONE(3) | DOMAIN_ACCESS_CONTROL_NONE(2) |\r
+ DOMAIN_ACCESS_CONTROL_NONE(1) | DOMAIN_ACCESS_CONTROL_CLIENT(0));\r
\r
ArmEnableInstructionCache();\r
ArmEnableDataCache();\r
\r
STATIC\r
EFI_STATUS\r
-ConvertSectionToPages (\r
- IN EFI_PHYSICAL_ADDRESS BaseAddress\r
- )\r
+ConvertSectionToPages(IN EFI_PHYSICAL_ADDRESS BaseAddress)\r
{\r
- UINT32 FirstLevelIdx;\r
- UINT32 SectionDescriptor;\r
- UINT32 PageTableDescriptor;\r
- UINT32 PageDescriptor;\r
- UINT32 Index;\r
+ UINT32 FirstLevelIdx;\r
+ UINT32 SectionDescriptor;\r
+ UINT32 PageTableDescriptor;\r
+ UINT32 PageDescriptor;\r
+ UINT32 Index;\r
\r
- volatile ARM_FIRST_LEVEL_DESCRIPTOR *FirstLevelTable;\r
- volatile ARM_PAGE_TABLE_ENTRY *PageTable;\r
+ volatile ARM_FIRST_LEVEL_DESCRIPTOR *FirstLevelTable;\r
+ volatile ARM_PAGE_TABLE_ENTRY * PageTable;\r
\r
- DEBUG ((EFI_D_PAGE, "Converting section at 0x%x to pages\n", (UINTN)BaseAddress));\r
+ DEBUG((\r
+ EFI_D_PAGE, "Converting section at 0x%x to pages\n", (UINTN)BaseAddress));\r
\r
// Obtain page table base\r
- FirstLevelTable = (ARM_FIRST_LEVEL_DESCRIPTOR *)ArmGetTTBR0BaseAddress ();\r
+ FirstLevelTable = (ARM_FIRST_LEVEL_DESCRIPTOR *)ArmGetTTBR0BaseAddress();\r
\r
- // Calculate index into first level translation table for start of modification\r
- FirstLevelIdx = TT_DESCRIPTOR_SECTION_BASE_ADDRESS(BaseAddress) >> TT_DESCRIPTOR_SECTION_BASE_SHIFT;\r
- ASSERT (FirstLevelIdx < TRANSLATION_TABLE_SECTION_COUNT);\r
+ // Calculate index into first level translation table for start of\r
+ // modification\r
+ FirstLevelIdx = TT_DESCRIPTOR_SECTION_BASE_ADDRESS(BaseAddress) >>\r
+ TT_DESCRIPTOR_SECTION_BASE_SHIFT;\r
+ ASSERT(FirstLevelIdx < TRANSLATION_TABLE_SECTION_COUNT);\r
\r
// Get section attributes and convert to page attributes\r
SectionDescriptor = FirstLevelTable[FirstLevelIdx];\r
- PageDescriptor = TT_DESCRIPTOR_PAGE_TYPE_PAGE | ConvertSectionAttributesToPageAttributes (SectionDescriptor, FALSE);\r
+ PageDescriptor =\r
+ TT_DESCRIPTOR_PAGE_TYPE_PAGE |\r
+ ConvertSectionAttributesToPageAttributes(SectionDescriptor, FALSE);\r
\r
- // Allocate a page table for the 4KB entries (we use up a full page even though we only need 1KB)\r
- PageTable = (volatile ARM_PAGE_TABLE_ENTRY *)AllocatePages (1);\r
+ // Allocate a page table for the 4KB entries (we use up a full page even\r
+ // though we only need 1KB)\r
+ PageTable = (volatile ARM_PAGE_TABLE_ENTRY *)AllocatePages(1);\r
if (PageTable == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
// Write the page table entries out\r
for (Index = 0; Index < TRANSLATION_TABLE_PAGE_COUNT; Index++) {\r
- PageTable[Index] = TT_DESCRIPTOR_PAGE_BASE_ADDRESS(BaseAddress + (Index << 12)) | PageDescriptor;\r
+ PageTable[Index] =\r
+ TT_DESCRIPTOR_PAGE_BASE_ADDRESS(BaseAddress + (Index << 12)) |\r
+ PageDescriptor;\r
}\r
\r
// Formulate page table entry, Domain=0, NS=0\r
- PageTableDescriptor = (((UINTN)PageTable) & TT_DESCRIPTOR_SECTION_PAGETABLE_ADDRESS_MASK) | TT_DESCRIPTOR_SECTION_TYPE_PAGE_TABLE;\r
+ PageTableDescriptor =\r
+ (((UINTN)PageTable) & TT_DESCRIPTOR_SECTION_PAGETABLE_ADDRESS_MASK) |\r
+ TT_DESCRIPTOR_SECTION_TYPE_PAGE_TABLE;\r
\r
// Write the page table entry out, replacing section entry\r
FirstLevelTable[FirstLevelIdx] = PageTableDescriptor;\r
\r
STATIC\r
EFI_STATUS\r
-UpdatePageEntries (\r
- IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
- IN UINT64 Length,\r
- IN UINT64 Attributes,\r
- OUT BOOLEAN *FlushTlbs OPTIONAL\r
- )\r
+UpdatePageEntries(\r
+ IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes,\r
+ OUT BOOLEAN *FlushTlbs OPTIONAL)\r
{\r
- EFI_STATUS Status;\r
- UINT32 EntryValue;\r
- UINT32 EntryMask;\r
- UINT32 FirstLevelIdx;\r
- UINT32 Offset;\r
- UINT32 NumPageEntries;\r
- UINT32 Descriptor;\r
- UINT32 p;\r
- UINT32 PageTableIndex;\r
- UINT32 PageTableEntry;\r
- UINT32 CurrentPageTableEntry;\r
- VOID *Mva;\r
-\r
- volatile ARM_FIRST_LEVEL_DESCRIPTOR *FirstLevelTable;\r
- volatile ARM_PAGE_TABLE_ENTRY *PageTable;\r
+ EFI_STATUS Status;\r
+ UINT32 EntryValue;\r
+ UINT32 EntryMask;\r
+ UINT32 FirstLevelIdx;\r
+ UINT32 Offset;\r
+ UINT32 NumPageEntries;\r
+ UINT32 Descriptor;\r
+ UINT32 p;\r
+ UINT32 PageTableIndex;\r
+ UINT32 PageTableEntry;\r
+ UINT32 CurrentPageTableEntry;\r
+ VOID * Mva;\r
+\r
+ volatile ARM_FIRST_LEVEL_DESCRIPTOR *FirstLevelTable;\r
+ volatile ARM_PAGE_TABLE_ENTRY * PageTable;\r
\r
Status = EFI_SUCCESS;\r
\r
- // EntryMask: bitmask of values to change (1 = change this value, 0 = leave alone)\r
- // EntryValue: values at bit positions specified by EntryMask\r
+ // EntryMask: bitmask of values to change (1 = change this value, 0 = leave\r
+ // alone) EntryValue: values at bit positions specified by EntryMask\r
EntryMask = TT_DESCRIPTOR_PAGE_TYPE_MASK | TT_DESCRIPTOR_PAGE_AP_MASK;\r
if (Attributes & EFI_MEMORY_XP) {\r
EntryValue = TT_DESCRIPTOR_PAGE_TYPE_PAGE_XN;\r
- } else {\r
+ }\r
+ else {\r
EntryValue = TT_DESCRIPTOR_PAGE_TYPE_PAGE;\r
}\r
\r
// modify cacheability attributes\r
EntryMask |= TT_DESCRIPTOR_PAGE_CACHE_POLICY_MASK;\r
// map to strongly ordered\r
- EntryValue |= TT_DESCRIPTOR_PAGE_CACHE_POLICY_STRONGLY_ORDERED; // TEX[2:0] = 0, C=0, B=0\r
- } else if (Attributes & EFI_MEMORY_WC) {\r
+ EntryValue |=\r
+ TT_DESCRIPTOR_PAGE_CACHE_POLICY_STRONGLY_ORDERED; // TEX[2:0] = 0, C=0,\r
+ // B=0\r
+ }\r
+ else if (Attributes & EFI_MEMORY_WC) {\r
// modify cacheability attributes\r
EntryMask |= TT_DESCRIPTOR_PAGE_CACHE_POLICY_MASK;\r
// map to normal non-cachable\r
- EntryValue |= TT_DESCRIPTOR_PAGE_CACHE_POLICY_NON_CACHEABLE; // TEX [2:0]= 001 = 0x2, B=0, C=0\r
- } else if (Attributes & EFI_MEMORY_WT) {\r
+ EntryValue |=\r
+ TT_DESCRIPTOR_PAGE_CACHE_POLICY_NON_CACHEABLE; // TEX [2:0]= 001 = 0x2,\r
+ // B=0, C=0\r
+ }\r
+ else if (Attributes & EFI_MEMORY_WT) {\r
// modify cacheability attributes\r
EntryMask |= TT_DESCRIPTOR_PAGE_CACHE_POLICY_MASK;\r
// write through with no-allocate\r
- EntryValue |= TT_DESCRIPTOR_PAGE_CACHE_POLICY_WRITE_THROUGH_NO_ALLOC; // TEX [2:0] = 0, C=1, B=0\r
- } else if (Attributes & EFI_MEMORY_WB) {\r
+ EntryValue |=\r
+ TT_DESCRIPTOR_PAGE_CACHE_POLICY_WRITE_THROUGH_NO_ALLOC; // TEX [2:0] =\r
+ // 0, C=1, B=0\r
+ }\r
+ else if (Attributes & EFI_MEMORY_WB) {\r
// modify cacheability attributes\r
EntryMask |= TT_DESCRIPTOR_PAGE_CACHE_POLICY_MASK;\r
// write back (with allocate)\r
- EntryValue |= TT_DESCRIPTOR_PAGE_CACHE_POLICY_WRITE_BACK_ALLOC; // TEX [2:0] = 001, C=1, B=1\r
- } else if (Attributes & CACHE_ATTRIBUTE_MASK) {\r
+ EntryValue |=\r
+ TT_DESCRIPTOR_PAGE_CACHE_POLICY_WRITE_BACK_ALLOC; // TEX [2:0] = 001,\r
+ // C=1, B=1\r
+ }\r
+ else if (Attributes & CACHE_ATTRIBUTE_MASK) {\r
// catch unsupported memory type attributes\r
- ASSERT (FALSE);\r
+ ASSERT(FALSE);\r
return EFI_UNSUPPORTED;\r
}\r
\r
if (Attributes & EFI_MEMORY_RO) {\r
EntryValue |= TT_DESCRIPTOR_PAGE_AP_RO_RO;\r
- } else {\r
+ }\r
+ else {\r
EntryValue |= TT_DESCRIPTOR_PAGE_AP_RW_RW;\r
}\r
\r
// Obtain page table base\r
- FirstLevelTable = (ARM_FIRST_LEVEL_DESCRIPTOR *)ArmGetTTBR0BaseAddress ();\r
+ FirstLevelTable = (ARM_FIRST_LEVEL_DESCRIPTOR *)ArmGetTTBR0BaseAddress();\r
\r
// Calculate number of 4KB page table entries to change\r
NumPageEntries = Length / TT_DESCRIPTOR_PAGE_SIZE;\r
\r
// Iterate for the number of 4KB pages to change\r
Offset = 0;\r
- for(p = 0; p < NumPageEntries; p++) {\r
+ for (p = 0; p < NumPageEntries; p++) {\r
// Calculate index into first level translation table for page table value\r
\r
- FirstLevelIdx = TT_DESCRIPTOR_SECTION_BASE_ADDRESS(BaseAddress + Offset) >> TT_DESCRIPTOR_SECTION_BASE_SHIFT;\r
- ASSERT (FirstLevelIdx < TRANSLATION_TABLE_SECTION_COUNT);\r
+ FirstLevelIdx = TT_DESCRIPTOR_SECTION_BASE_ADDRESS(BaseAddress + Offset) >>\r
+ TT_DESCRIPTOR_SECTION_BASE_SHIFT;\r
+ ASSERT(FirstLevelIdx < TRANSLATION_TABLE_SECTION_COUNT);\r
\r
// Read the descriptor from the first level page table\r
Descriptor = FirstLevelTable[FirstLevelIdx];\r
\r
// Does this descriptor need to be converted from section entry to 4K pages?\r
if (!TT_DESCRIPTOR_SECTION_TYPE_IS_PAGE_TABLE(Descriptor)) {\r
- Status = ConvertSectionToPages (FirstLevelIdx << TT_DESCRIPTOR_SECTION_BASE_SHIFT);\r
+ Status = ConvertSectionToPages(\r
+ FirstLevelIdx << TT_DESCRIPTOR_SECTION_BASE_SHIFT);\r
if (EFI_ERROR(Status)) {\r
// Exit for loop\r
break;\r
}\r
\r
// Obtain page table base address\r
- PageTable = (ARM_PAGE_TABLE_ENTRY *)TT_DESCRIPTOR_PAGE_BASE_ADDRESS(Descriptor);\r
+ PageTable =\r
+ (ARM_PAGE_TABLE_ENTRY *)TT_DESCRIPTOR_PAGE_BASE_ADDRESS(Descriptor);\r
\r
// Calculate index into the page table\r
- PageTableIndex = ((BaseAddress + Offset) & TT_DESCRIPTOR_PAGE_INDEX_MASK) >> TT_DESCRIPTOR_PAGE_BASE_SHIFT;\r
- ASSERT (PageTableIndex < TRANSLATION_TABLE_PAGE_COUNT);\r
+ PageTableIndex = ((BaseAddress + Offset) & TT_DESCRIPTOR_PAGE_INDEX_MASK) >>\r
+ TT_DESCRIPTOR_PAGE_BASE_SHIFT;\r
+ ASSERT(PageTableIndex < TRANSLATION_TABLE_PAGE_COUNT);\r
\r
// Get the entry\r
CurrentPageTableEntry = PageTable[PageTableIndex];\r
// Mask in new attributes and/or permissions\r
PageTableEntry |= EntryValue;\r
\r
- if (CurrentPageTableEntry != PageTableEntry) {\r
- Mva = (VOID *)(UINTN)((((UINTN)FirstLevelIdx) << TT_DESCRIPTOR_SECTION_BASE_SHIFT) + (PageTableIndex << TT_DESCRIPTOR_PAGE_BASE_SHIFT));\r
+ if (CurrentPageTableEntry != PageTableEntry) {\r
+ Mva =\r
+ (VOID\r
+ *)(UINTN)((((UINTN)FirstLevelIdx) << TT_DESCRIPTOR_SECTION_BASE_SHIFT) + (PageTableIndex << TT_DESCRIPTOR_PAGE_BASE_SHIFT));\r
\r
// Only need to update if we are changing the entry\r
PageTable[PageTableIndex] = PageTableEntry;\r
- ArmUpdateTranslationTableEntry ((VOID *)&PageTable[PageTableIndex], Mva);\r
+ ArmUpdateTranslationTableEntry((VOID *)&PageTable[PageTableIndex], Mva);\r
}\r
\r
Status = EFI_SUCCESS;\r
\r
STATIC\r
EFI_STATUS\r
-UpdateSectionEntries (\r
- IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
- IN UINT64 Length,\r
- IN UINT64 Attributes\r
- )\r
+UpdateSectionEntries(\r
+ IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes)\r
{\r
- EFI_STATUS Status = EFI_SUCCESS;\r
- UINT32 EntryMask;\r
- UINT32 EntryValue;\r
- UINT32 FirstLevelIdx;\r
- UINT32 NumSections;\r
- UINT32 i;\r
- UINT32 CurrentDescriptor;\r
- UINT32 Descriptor;\r
- VOID *Mva;\r
- volatile ARM_FIRST_LEVEL_DESCRIPTOR *FirstLevelTable;\r
-\r
- // EntryMask: bitmask of values to change (1 = change this value, 0 = leave alone)\r
- // EntryValue: values at bit positions specified by EntryMask\r
+ EFI_STATUS Status = EFI_SUCCESS;\r
+ UINT32 EntryMask;\r
+ UINT32 EntryValue;\r
+ UINT32 FirstLevelIdx;\r
+ UINT32 NumSections;\r
+ UINT32 i;\r
+ UINT32 CurrentDescriptor;\r
+ UINT32 Descriptor;\r
+ VOID * Mva;\r
+ volatile ARM_FIRST_LEVEL_DESCRIPTOR *FirstLevelTable;\r
+\r
+ // EntryMask: bitmask of values to change (1 = change this value, 0 = leave\r
+ // alone) EntryValue: values at bit positions specified by EntryMask\r
\r
// Make sure we handle a section range that is unmapped\r
EntryMask = TT_DESCRIPTOR_SECTION_TYPE_MASK | TT_DESCRIPTOR_SECTION_XN_MASK |\r
// modify cacheability attributes\r
EntryMask |= TT_DESCRIPTOR_SECTION_CACHE_POLICY_MASK;\r
// map to strongly ordered\r
- EntryValue |= TT_DESCRIPTOR_SECTION_CACHE_POLICY_STRONGLY_ORDERED; // TEX[2:0] = 0, C=0, B=0\r
- } else if (Attributes & EFI_MEMORY_WC) {\r
+ EntryValue |=\r
+ TT_DESCRIPTOR_SECTION_CACHE_POLICY_STRONGLY_ORDERED; // TEX[2:0] = 0,\r
+ // C=0, B=0\r
+ }\r
+ else if (Attributes & EFI_MEMORY_WC) {\r
// modify cacheability attributes\r
EntryMask |= TT_DESCRIPTOR_SECTION_CACHE_POLICY_MASK;\r
// map to normal non-cachable\r
- EntryValue |= TT_DESCRIPTOR_SECTION_CACHE_POLICY_NON_CACHEABLE; // TEX [2:0]= 001 = 0x2, B=0, C=0\r
- } else if (Attributes & EFI_MEMORY_WT) {\r
+ EntryValue |=\r
+ TT_DESCRIPTOR_SECTION_CACHE_POLICY_NON_CACHEABLE; // TEX [2:0]= 001 =\r
+ // 0x2, B=0, C=0\r
+ }\r
+ else if (Attributes & EFI_MEMORY_WT) {\r
// modify cacheability attributes\r
EntryMask |= TT_DESCRIPTOR_SECTION_CACHE_POLICY_MASK;\r
// write through with no-allocate\r
- EntryValue |= TT_DESCRIPTOR_SECTION_CACHE_POLICY_WRITE_THROUGH_NO_ALLOC; // TEX [2:0] = 0, C=1, B=0\r
- } else if (Attributes & EFI_MEMORY_WB) {\r
+ EntryValue |=\r
+ TT_DESCRIPTOR_SECTION_CACHE_POLICY_WRITE_THROUGH_NO_ALLOC; // TEX [2:0]\r
+ // = 0, C=1,\r
+ // B=0\r
+ }\r
+ else if (Attributes & EFI_MEMORY_WB) {\r
// modify cacheability attributes\r
EntryMask |= TT_DESCRIPTOR_SECTION_CACHE_POLICY_MASK;\r
// write back (with allocate)\r
- EntryValue |= TT_DESCRIPTOR_SECTION_CACHE_POLICY_WRITE_BACK_ALLOC; // TEX [2:0] = 001, C=1, B=1\r
- } else if (Attributes & CACHE_ATTRIBUTE_MASK) {\r
+ EntryValue |=\r
+ TT_DESCRIPTOR_SECTION_CACHE_POLICY_WRITE_BACK_ALLOC; // TEX [2:0] = 001,\r
+ // C=1, B=1\r
+ }\r
+ else if (Attributes & CACHE_ATTRIBUTE_MASK) {\r
// catch unsupported memory type attributes\r
- ASSERT (FALSE);\r
+ ASSERT(FALSE);\r
return EFI_UNSUPPORTED;\r
}\r
\r
if (Attributes & EFI_MEMORY_RO) {\r
EntryValue |= TT_DESCRIPTOR_SECTION_AP_RO_RO;\r
- } else {\r
+ }\r
+ else {\r
EntryValue |= TT_DESCRIPTOR_SECTION_AP_RW_RW;\r
}\r
\r
}\r
\r
// obtain page table base\r
- FirstLevelTable = (ARM_FIRST_LEVEL_DESCRIPTOR *)ArmGetTTBR0BaseAddress ();\r
+ FirstLevelTable = (ARM_FIRST_LEVEL_DESCRIPTOR *)ArmGetTTBR0BaseAddress();\r
\r
- // calculate index into first level translation table for start of modification\r
- FirstLevelIdx = TT_DESCRIPTOR_SECTION_BASE_ADDRESS(BaseAddress) >> TT_DESCRIPTOR_SECTION_BASE_SHIFT;\r
- ASSERT (FirstLevelIdx < TRANSLATION_TABLE_SECTION_COUNT);\r
+ // calculate index into first level translation table for start of\r
+ // modification\r
+ FirstLevelIdx = TT_DESCRIPTOR_SECTION_BASE_ADDRESS(BaseAddress) >>\r
+ TT_DESCRIPTOR_SECTION_BASE_SHIFT;\r
+ ASSERT(FirstLevelIdx < TRANSLATION_TABLE_SECTION_COUNT);\r
\r
// calculate number of 1MB first level entries this applies to\r
NumSections = Length / TT_DESCRIPTOR_SECTION_SIZE;\r
\r
// iterate through each descriptor\r
- for(i=0; i<NumSections; i++) {\r
+ for (i = 0; i < NumSections; i++) {\r
CurrentDescriptor = FirstLevelTable[FirstLevelIdx + i];\r
\r
// has this descriptor already been converted to pages?\r
if (TT_DESCRIPTOR_SECTION_TYPE_IS_PAGE_TABLE(CurrentDescriptor)) {\r
// forward this 1MB range to page table function instead\r
- Status = UpdatePageEntries (\r
- (FirstLevelIdx + i) << TT_DESCRIPTOR_SECTION_BASE_SHIFT,\r
- TT_DESCRIPTOR_SECTION_SIZE,\r
- Attributes,\r
- NULL);\r
- } else {\r
+ Status = UpdatePageEntries(\r
+ (FirstLevelIdx + i) << TT_DESCRIPTOR_SECTION_BASE_SHIFT,\r
+ TT_DESCRIPTOR_SECTION_SIZE, Attributes, NULL);\r
+ }\r
+ else {\r
// still a section entry\r
\r
if (CurrentDescriptor != 0) {\r
// mask off appropriate fields\r
Descriptor = CurrentDescriptor & ~EntryMask;\r
- } else {\r
- Descriptor = ((UINTN)FirstLevelIdx + i) << TT_DESCRIPTOR_SECTION_BASE_SHIFT;\r
+ }\r
+ else {\r
+ Descriptor = ((UINTN)FirstLevelIdx + i)\r
+ << TT_DESCRIPTOR_SECTION_BASE_SHIFT;\r
}\r
\r
// mask in new attributes and/or permissions\r
Descriptor |= EntryValue;\r
\r
- if (CurrentDescriptor != Descriptor) {\r
- Mva = (VOID *)(UINTN)(((UINTN)FirstLevelIdx + i) << TT_DESCRIPTOR_SECTION_BASE_SHIFT);\r
+ if (CurrentDescriptor != Descriptor) {\r
+ Mva =\r
+ (VOID\r
+ *)(UINTN)(((UINTN)FirstLevelIdx + i) << TT_DESCRIPTOR_SECTION_BASE_SHIFT);\r
\r
// Only need to update if we are changing the descriptor\r
FirstLevelTable[FirstLevelIdx + i] = Descriptor;\r
- ArmUpdateTranslationTableEntry ((VOID *)&FirstLevelTable[FirstLevelIdx + i], Mva);\r
+ ArmUpdateTranslationTableEntry(\r
+ (VOID *)&FirstLevelTable[FirstLevelIdx + i], Mva);\r
}\r
\r
Status = EFI_SUCCESS;\r
}\r
\r
EFI_STATUS\r
-ArmSetMemoryAttributes (\r
- IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
- IN UINT64 Length,\r
- IN UINT64 Attributes\r
- )\r
+ArmSetMemoryAttributes(\r
+ IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes)\r
{\r
- EFI_STATUS Status;\r
- UINT64 ChunkLength;\r
- BOOLEAN FlushTlbs;\r
+ EFI_STATUS Status;\r
+ UINT64 ChunkLength;\r
+ BOOLEAN FlushTlbs;\r
\r
if (BaseAddress > (UINT64)MAX_ADDRESS) {\r
return EFI_UNSUPPORTED;\r
}\r
\r
- Length = MIN (Length, (UINT64)MAX_ADDRESS - BaseAddress + 1);\r
+ Length = MIN(Length, (UINT64)MAX_ADDRESS - BaseAddress + 1);\r
if (Length == 0) {\r
return EFI_SUCCESS;\r
}\r
\r
ChunkLength = Length - Length % TT_DESCRIPTOR_SECTION_SIZE;\r
\r
- DEBUG ((DEBUG_PAGE,\r
- "SetMemoryAttributes(): MMU section 0x%lx length 0x%lx to %lx\n",\r
- BaseAddress, ChunkLength, Attributes));\r
+ DEBUG(\r
+ (DEBUG_PAGE,\r
+ "SetMemoryAttributes(): MMU section 0x%lx length 0x%lx to %lx\n",\r
+ BaseAddress, ChunkLength, Attributes));\r
\r
- Status = UpdateSectionEntries (BaseAddress, ChunkLength, Attributes);\r
+ Status = UpdateSectionEntries(BaseAddress, ChunkLength, Attributes);\r
\r
FlushTlbs = TRUE;\r
- } else {\r
+ }\r
+ else {\r
\r
//\r
// Process page by page until the next section boundary, but only if\r
ChunkLength = Length;\r
}\r
\r
- DEBUG ((DEBUG_PAGE,\r
- "SetMemoryAttributes(): MMU page 0x%lx length 0x%lx to %lx\n",\r
- BaseAddress, ChunkLength, Attributes));\r
+ DEBUG(\r
+ (DEBUG_PAGE,\r
+ "SetMemoryAttributes(): MMU page 0x%lx length 0x%lx to %lx\n",\r
+ BaseAddress, ChunkLength, Attributes));\r
\r
- Status = UpdatePageEntries (BaseAddress, ChunkLength, Attributes,\r
- &FlushTlbs);\r
+ Status =\r
+ UpdatePageEntries(BaseAddress, ChunkLength, Attributes, &FlushTlbs);\r
}\r
\r
- if (EFI_ERROR (Status)) {\r
+ if (EFI_ERROR(Status)) {\r
break;\r
}\r
\r
}\r
\r
if (FlushTlbs) {\r
- ArmInvalidateTlb ();\r
+ ArmInvalidateTlb();\r
}\r
return Status;\r
}\r
\r
EFI_STATUS\r
-ArmSetMemoryRegionNoExec (\r
- IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
- IN UINT64 Length\r
- )\r
+ArmSetMemoryRegionNoExec(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length)\r
{\r
- return ArmSetMemoryAttributes (BaseAddress, Length, EFI_MEMORY_XP);\r
+ return ArmSetMemoryAttributes(BaseAddress, Length, EFI_MEMORY_XP);\r
}\r
\r
EFI_STATUS\r
-ArmClearMemoryRegionNoExec (\r
- IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
- IN UINT64 Length\r
- )\r
+ArmClearMemoryRegionNoExec(\r
+ IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length)\r
{\r
- return ArmSetMemoryAttributes (BaseAddress, Length, __EFI_MEMORY_RWX);\r
+ return ArmSetMemoryAttributes(BaseAddress, Length, __EFI_MEMORY_RWX);\r
}\r
\r
EFI_STATUS\r
-ArmSetMemoryRegionReadOnly (\r
- IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
- IN UINT64 Length\r
- )\r
+ArmSetMemoryRegionReadOnly(\r
+ IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length)\r
{\r
- return ArmSetMemoryAttributes (BaseAddress, Length, EFI_MEMORY_RO);\r
+ return ArmSetMemoryAttributes(BaseAddress, Length, EFI_MEMORY_RO);\r
}\r
\r
EFI_STATUS\r
-ArmClearMemoryRegionReadOnly (\r
- IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
- IN UINT64 Length\r
- )\r
+ArmClearMemoryRegionReadOnly(\r
+ IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length)\r
{\r
- return ArmSetMemoryAttributes (BaseAddress, Length, __EFI_MEMORY_RWX);\r
+ return ArmSetMemoryAttributes(BaseAddress, Length, __EFI_MEMORY_RWX);\r
}\r
\r
RETURN_STATUS\r
EFIAPI\r
-ArmMmuBaseLibConstructor (\r
- VOID\r
- )\r
-{\r
- return RETURN_SUCCESS;\r
-}\r
+ArmMmuBaseLibConstructor(VOID) { return RETURN_SUCCESS; }\r
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
+ */
#include "AutoGen.h"
#include <Library/BootSlotLib/BlockIoUtils.h>
BLK_IO_SEL_MATCH_ROOT_DEVICE)
/* Returns 0 if the volume label matches otherwise non zero */
-STATIC UINTN
-CompareVolumeLabel (IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL* Fs,
- IN CHAR8* ReqVolumeName)
+STATIC UINTN CompareVolumeLabel(
+ IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs, IN CHAR8 *ReqVolumeName)
{
- INT32 CmpResult;
- UINT32 j;
- UINT16 VolumeLabel[VOLUME_LABEL_SIZE];
- EFI_FILE_PROTOCOL *FsVolume = NULL;
- EFI_STATUS Status;
- UINTN Size;
- EFI_FILE_SYSTEM_INFO *FsInfo;
+ INT32 CmpResult;
+ UINT32 j;
+ UINT16 VolumeLabel[VOLUME_LABEL_SIZE];
+ EFI_FILE_PROTOCOL * FsVolume = NULL;
+ EFI_STATUS Status;
+ UINTN Size;
+ EFI_FILE_SYSTEM_INFO *FsInfo;
// Get information about the volume
- Status = Fs->OpenVolume (Fs, &FsVolume);
+ Status = Fs->OpenVolume(Fs, &FsVolume);
if (Status != EFI_SUCCESS) {
return 1;
}
/* Get the Volume name */
- Size = 0;
+ Size = 0;
FsInfo = NULL;
- Status = FsVolume->GetInfo (FsVolume, &gEfiFileSystemInfoGuid, &Size, FsInfo);
+ Status = FsVolume->GetInfo(FsVolume, &gEfiFileSystemInfoGuid, &Size, FsInfo);
if (Status == EFI_BUFFER_TOO_SMALL) {
- FsInfo = AllocateZeroPool (Size);
- Status = FsVolume->GetInfo (FsVolume,
- &gEfiFileSystemInfoGuid, &Size, FsInfo);
+ FsInfo = AllocateZeroPool(Size);
+ Status =
+ FsVolume->GetInfo(FsVolume, &gEfiFileSystemInfoGuid, &Size, FsInfo);
if (Status != EFI_SUCCESS) {
- FreePool (FsInfo);
+ FreePool(FsInfo);
return 1;
}
}
for (j = 0; (j < VOLUME_LABEL_SIZE - 1) && ReqVolumeName[j]; ++j) {
VolumeLabel[j] = ReqVolumeName[j];
- if ((VolumeLabel[j] >= 'a') &&
- (VolumeLabel[j] <= 'z')) {
+ if ((VolumeLabel[j] >= 'a') && (VolumeLabel[j] <= 'z')) {
VolumeLabel[j] -= ('a' - 'A');
}
}
/* Change any lower chars in volume name to upper
* (ideally this is not needed) */
for (j = 0; (j < VOLUME_LABEL_SIZE - 1) && FsInfo->VolumeLabel[j]; ++j) {
- if ((FsInfo->VolumeLabel[j] >= 'a') &&
- (FsInfo->VolumeLabel[j] <= 'z')) {
+ if ((FsInfo->VolumeLabel[j] >= 'a') && (FsInfo->VolumeLabel[j] <= 'z')) {
FsInfo->VolumeLabel[j] -= ('a' - 'A');
}
}
- CmpResult = StrnCmp (FsInfo->VolumeLabel, VolumeLabel, VOLUME_LABEL_SIZE);
+ CmpResult = StrnCmp(FsInfo->VolumeLabel, VolumeLabel, VOLUME_LABEL_SIZE);
- FreePool (FsInfo);
- FsVolume->Close (FsVolume);
+ FreePool(FsInfo);
+ FsVolume->Close(FsVolume);
return CmpResult;
}
EFI_STATUS
EFIAPI
-GetPartitionEntry (IN EFI_HANDLE Handle,
- OUT EFI_PARTITION_ENTRY **PartEntry)
+GetPartitionEntry(IN EFI_HANDLE Handle, OUT EFI_PARTITION_ENTRY **PartEntry)
{
EFI_PARTITION_INFO_PROTOCOL *PartInfo;
- EFI_STATUS Status = gBS->HandleProtocol (Handle, &gEfiPartitionInfoProtocolGuid, (VOID **)&PartInfo);
+ EFI_STATUS Status = gBS->HandleProtocol(
+ Handle, &gEfiPartitionInfoProtocolGuid, (VOID **)&PartInfo);
if (!EFI_ERROR(Status)) {
*PartEntry = &PartInfo->Info.Gpt;
}
*/
EFI_STATUS
EFIAPI
-GetBlkIOHandles (IN UINT32 SelectionAttrib,
- IN PartiSelectFilter *FilterData,
- OUT HandleInfo *HandleInfoPtr,
- IN OUT UINT32* MaxBlkIopCnt)
+GetBlkIOHandles(
+ IN UINT32 SelectionAttrib, IN PartiSelectFilter *FilterData,
+ OUT HandleInfo *HandleInfoPtr, IN OUT UINT32 *MaxBlkIopCnt)
{
- EFI_BLOCK_IO_PROTOCOL *BlkIo;
- EFI_HANDLE *BlkIoHandles;
- UINTN BlkIoHandleCount;
- UINTN i;
- UINTN DevicePathDepth;
- HARDDRIVE_DEVICE_PATH *Partition, *PartitionOut;
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *DevPathInst;
- EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
- VENDOR_DEVICE_PATH *RootDevicePath;
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs;
- UINT32 BlkIoCnt = 0;
- EFI_PARTITION_ENTRY *PartEntry;
+ EFI_BLOCK_IO_PROTOCOL * BlkIo;
+ EFI_HANDLE * BlkIoHandles;
+ UINTN BlkIoHandleCount;
+ UINTN i;
+ UINTN DevicePathDepth;
+ HARDDRIVE_DEVICE_PATH * Partition, *PartitionOut;
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL * DevPathInst;
+ EFI_DEVICE_PATH_PROTOCOL * TempDevicePath;
+ VENDOR_DEVICE_PATH * RootDevicePath;
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs;
+ UINT32 BlkIoCnt = 0;
+ EFI_PARTITION_ENTRY * PartEntry;
if ((MaxBlkIopCnt == NULL) || (HandleInfoPtr == NULL))
return EFI_INVALID_PARAMETER;
* than BlkIo */
if (SelectionAttrib & (BLK_IO_SEL_SELECT_MOUNTED_FILESYSTEM |
BLK_IO_SEL_SELECT_BY_VOLUME_NAME)) {
- Status =
- gBS->LocateHandleBuffer (ByProtocol, &gEfiSimpleFileSystemProtocolGuid,
- NULL, &BlkIoHandleCount, &BlkIoHandles);
- } else {
- Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiBlockIoProtocolGuid,
- NULL, &BlkIoHandleCount, &BlkIoHandles);
+ Status = gBS->LocateHandleBuffer(
+ ByProtocol, &gEfiSimpleFileSystemProtocolGuid, NULL, &BlkIoHandleCount,
+ &BlkIoHandles);
+ }
+ else {
+ Status = gBS->LocateHandleBuffer(
+ ByProtocol, &gEfiBlockIoProtocolGuid, NULL, &BlkIoHandleCount,
+ &BlkIoHandles);
}
if (Status != EFI_SUCCESS) {
- DEBUG (
- (EFI_D_ERROR, "Unable to get Filesystem Handle buffer %r\n", Status));
+ DEBUG((EFI_D_ERROR, "Unable to get Filesystem Handle buffer %r\n", Status));
return Status;
}
/* Loop through to search for the ones we are interested in. */
for (i = 0; i < BlkIoHandleCount; i++) {
- Status = gBS->HandleProtocol (BlkIoHandles[i], &gEfiBlockIoProtocolGuid,
- (VOID **)&BlkIo);
+ Status = gBS->HandleProtocol(
+ BlkIoHandles[i], &gEfiBlockIoProtocolGuid, (VOID **)&BlkIo);
/* Fv volumes will not support Blk I/O protocol */
if (Status == EFI_UNSUPPORTED) {
continue;
}
if (Status != EFI_SUCCESS) {
- DEBUG ((EFI_D_ERROR, "Unable to get Filesystem Handle %r\n", Status));
+ DEBUG((EFI_D_ERROR, "Unable to get Filesystem Handle %r\n", Status));
return Status;
}
if (BlkIo->Media->RemovableMedia) {
if ((SelectionAttrib & BLK_IO_SEL_MEDIA_TYPE_REMOVABLE) == 0)
continue;
- } else {
+ }
+ else {
if ((SelectionAttrib & BLK_IO_SEL_MEDIA_TYPE_NON_REMOVABLE) == 0)
continue;
}
/* Check if partition related criteria satisfies */
if ((SelectionAttrib & FILTERS_NEEDING_DEVICEPATH) != 0) {
- Status = gBS->HandleProtocol (
+ Status = gBS->HandleProtocol(
BlkIoHandles[i], &gEfiDevicePathProtocolGuid, (VOID **)&DevPathInst);
/* If we didn't get the DevicePath Protocol then this handle
* cannot be used */
- if (EFI_ERROR (Status))
+ if (EFI_ERROR(Status))
continue;
DevicePathDepth = 0;
/* Get the device path */
TempDevicePath = DevPathInst;
RootDevicePath = (VENDOR_DEVICE_PATH *)DevPathInst;
- Partition = (HARDDRIVE_DEVICE_PATH *)TempDevicePath;
+ Partition = (HARDDRIVE_DEVICE_PATH *)TempDevicePath;
if ((SelectionAttrib & (BLK_IO_SEL_SELECT_ROOT_DEVICE_ONLY |
BLK_IO_SEL_MATCH_ROOT_DEVICE)) != 0) {
RootDevicePath->Header.SubType != HW_VENDOR_DP ||
(RootDevicePath->Header.Length[0] |
(RootDevicePath->Header.Length[1] << 8)) !=
- sizeof (VENDOR_DEVICE_PATH) ||
+ sizeof(VENDOR_DEVICE_PATH) ||
((FilterData->RootDeviceType != NULL) &&
- (CompareGuid (FilterData->RootDeviceType,
- &RootDevicePath->Guid) == FALSE)))
+ (CompareGuid(FilterData->RootDeviceType, &RootDevicePath->Guid) ==
+ FALSE)))
continue;
}
/* Locate the last Device Path Node */
- while (!IsDevicePathEnd (TempDevicePath)) {
+ while (!IsDevicePathEnd(TempDevicePath)) {
DevicePathDepth++;
- Partition = (HARDDRIVE_DEVICE_PATH *)TempDevicePath;
- TempDevicePath = NextDevicePathNode (TempDevicePath);
+ Partition = (HARDDRIVE_DEVICE_PATH *)TempDevicePath;
+ TempDevicePath = NextDevicePathNode(TempDevicePath);
}
/* If we need the handle for root device only and if this is representing
if (Partition->Header.Type == MEDIA_DEVICE_PATH &&
Partition->Header.SubType == MEDIA_HARDDRIVE_DP &&
(Partition->Header.Length[0] | (Partition->Header.Length[1] << 8)) ==
- sizeof (*Partition)) {
+ sizeof(*Partition)) {
PartitionOut = Partition;
if ((SelectionAttrib & BLK_IO_SEL_PARTITIONED_GPT) == 0)
if ((SelectionAttrib & BLK_IO_SEL_MATCH_PARTITION_TYPE_GUID) != 0) {
VOID *Interface;
- if (!FilterData ||
- FilterData->PartitionType == NULL) {
+ if (!FilterData || FilterData->PartitionType == NULL) {
return EFI_INVALID_PARAMETER;
}
- Status = gBS->HandleProtocol (BlkIoHandles[i],
- FilterData->PartitionType,
- (VOID**)&Interface);
- if (EFI_ERROR (Status)) {
- Status = GetPartitionEntry(BlkIoHandles[i], &PartEntry);
- if (EFI_ERROR (Status)) {
- continue;
- }
- if (CompareGuid (&PartEntry->PartitionTypeGUID, FilterData->PartitionType) == FALSE) {
- continue;
- }
+ Status = gBS->HandleProtocol(
+ BlkIoHandles[i], FilterData->PartitionType, (VOID **)&Interface);
+ if (EFI_ERROR(Status)) {
+ Status = GetPartitionEntry(BlkIoHandles[i], &PartEntry);
+ if (EFI_ERROR(Status)) {
+ continue;
+ }
+ if (CompareGuid(
+ &PartEntry->PartitionTypeGUID, FilterData->PartitionType) ==
+ FALSE) {
+ continue;
+ }
}
}
}
/* If we wanted a particular partition and didn't get the HDD DP,
then this handle is probably not the interested ones */
else if ((SelectionAttrib & BLK_IO_SEL_MATCH_PARTITION_TYPE_GUID) != 0)
- continue;
+ continue;
}
/* Check if the Filesystem related criteria satisfies */
if ((SelectionAttrib & BLK_IO_SEL_SELECT_MOUNTED_FILESYSTEM) != 0) {
- Status = gBS->HandleProtocol (BlkIoHandles[i],
- &gEfiSimpleFileSystemProtocolGuid, (VOID **)&Fs);
- if (EFI_ERROR (Status)) {
+ Status = gBS->HandleProtocol(
+ BlkIoHandles[i], &gEfiSimpleFileSystemProtocolGuid, (VOID **)&Fs);
+ if (EFI_ERROR(Status)) {
continue;
}
if ((SelectionAttrib & BLK_IO_SEL_SELECT_BY_VOLUME_NAME) != 0) {
- if (!FilterData ||
- FilterData->VolumeName == NULL) {
+ if (!FilterData || FilterData->VolumeName == NULL) {
return EFI_INVALID_PARAMETER;
}
- if (CompareVolumeLabel (Fs, FilterData->VolumeName) != 0) {
+ if (CompareVolumeLabel(Fs, FilterData->VolumeName) != 0) {
continue;
}
}
Status = GetPartitionEntry(BlkIoHandles[i], &PartEntry);
if (Status != EFI_SUCCESS)
continue;
- if (StrnCmp (PartEntry->PartitionName, FilterData->PartitionLabel,
- MAX (StrLen (PartEntry->PartitionName),
- StrLen (FilterData->PartitionLabel))))
+ if (StrnCmp(
+ PartEntry->PartitionName, FilterData->PartitionLabel,
+ MAX(StrLen(PartEntry->PartitionName),
+ StrLen(FilterData->PartitionLabel))))
continue;
}
/* We came here means, this handle satisfies all the conditions needed,
* Add it into the list */
- HandleInfoPtr[BlkIoCnt].Handle = BlkIoHandles[i];
- HandleInfoPtr[BlkIoCnt].BlkIo = BlkIo;
+ HandleInfoPtr[BlkIoCnt].Handle = BlkIoHandles[i];
+ HandleInfoPtr[BlkIoCnt].BlkIo = BlkIo;
HandleInfoPtr[BlkIoCnt].PartitionInfo = PartitionOut;
BlkIoCnt++;
if (BlkIoCnt >= *MaxBlkIopCnt)
/* Free the handle buffer */
if (BlkIoHandles != NULL) {
- FreePool (BlkIoHandles);
+ FreePool(BlkIoHandles);
BlkIoHandles = NULL;
}
#include <Library/BootSlotLib/EFIUtils.h>
#include <Library/UefiLib.h>
-void WaitAnyKey(EFI_SYSTEM_TABLE *mSystemTable) {
- UINTN index = 0;
- EFI_INPUT_KEY Key;
- mSystemTable->BootServices->WaitForEvent(1, &mSystemTable->ConIn->WaitForKey, &index);
- mSystemTable->ConIn->ReadKeyStroke(mSystemTable->ConIn, &Key);
+void WaitAnyKey(EFI_SYSTEM_TABLE *mSystemTable)
+{
+ UINTN index = 0;
+ EFI_INPUT_KEY Key;
+ mSystemTable->BootServices->WaitForEvent(
+ 1, &mSystemTable->ConIn->WaitForKey, &index);
+ mSystemTable->ConIn->ReadKeyStroke(mSystemTable->ConIn, &Key);
}
-void PrintAndWaitAnyKey(EFI_SYSTEM_TABLE *mSystemTable, CHAR16 *Message) {
- Print(Message);
- WaitAnyKey(mSystemTable);
+void PrintAndWaitAnyKey(EFI_SYSTEM_TABLE *mSystemTable, CHAR16 *Message)
+{
+ Print(Message);
+ WaitAnyKey(mSystemTable);
}
\ No newline at end of file
*/
#include "AutoGen.h"
+#include <Library/BootSlotLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
#include <Uefi.h>
#include <Uefi/UefiSpec.h>
-#include <Library/UefiLib.h>
-#include <Library/DebugLib.h>
-#include <Library/BootSlotLib.h>
-struct StoragePartInfo Ptable[MAX_LUNS];
-struct PartitionEntry PtnEntries[MAX_NUM_PARTITIONS];
-STATIC UINT32 MaxLuns;
-STATIC UINT32 PartitionCount;
+struct StoragePartInfo Ptable[MAX_LUNS];
+struct PartitionEntry PtnEntries[MAX_NUM_PARTITIONS];
+STATIC UINT32 MaxLuns;
+STATIC UINT32 PartitionCount;
STATIC struct PartitionEntry PtnEntriesBak[MAX_NUM_PARTITIONS];
STATIC struct BootPartsLinkedList *HeadNode;
-STATIC EFI_STATUS
-GetActiveSlot (Slot *ActiveSlot);
+STATIC EFI_STATUS GetActiveSlot(Slot *ActiveSlot);
-Slot GetCurrentSlotSuffix (VOID)
+Slot GetCurrentSlotSuffix(VOID)
{
- Slot CurrentSlot = {{0}};
- BOOLEAN IsMultiSlot = PartitionHasMultiSlot ((CONST CHAR16 *)L"boot");
+ Slot CurrentSlot = {{0}};
+ BOOLEAN IsMultiSlot = PartitionHasMultiSlot((CONST CHAR16 *)L"boot");
if (IsMultiSlot == FALSE) {
return CurrentSlot;
}
- GetActiveSlot (&CurrentSlot);
+ GetActiveSlot(&CurrentSlot);
return CurrentSlot;
}
-VOID
-GetPartitionCount (UINT32 *Val)
+VOID GetPartitionCount(UINT32 *Val)
{
*Val = PartitionCount;
return;
}
-VOID UpdatePartitionEntries (VOID)
+VOID UpdatePartitionEntries(VOID)
{
- UINT32 i;
- UINT32 j;
- UINT32 Index = 0;
- EFI_STATUS Status;
+ UINT32 i;
+ UINT32 j;
+ UINT32 Index = 0;
+ EFI_STATUS Status;
EFI_PARTITION_ENTRY *PartEntry;
PartitionCount = 0;
/*Nullify the PtnEntries array before using it*/
- gBS->SetMem ((VOID *)PtnEntries,
- (sizeof (PtnEntries[0]) * MAX_NUM_PARTITIONS), 0);
+ gBS->SetMem(
+ (VOID *)PtnEntries, (sizeof(PtnEntries[0]) * MAX_NUM_PARTITIONS), 0);
for (i = 0; i < MaxLuns; i++) {
for (j = 0; (j < Ptable[i].MaxHandles) && (Index < MAX_NUM_PARTITIONS);
j++, Index++) {
- Status = GetPartitionEntry(Ptable[i].HandleInfoList[j].Handle, &PartEntry);
+ Status =
+ GetPartitionEntry(Ptable[i].HandleInfoList[j].Handle, &PartEntry);
PartitionCount++;
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_VERBOSE, "Selected Lun : %d, handle: %d does not have "
- "partition record, ignore\n",
- i, j));
+ if (EFI_ERROR(Status)) {
+ DEBUG(
+ (EFI_D_VERBOSE,
+ "Selected Lun : %d, handle: %d does not have "
+ "partition record, ignore\n",
+ i, j));
PtnEntries[Index].lun = i;
continue;
}
- gBS->CopyMem ((&PtnEntries[Index]), PartEntry, sizeof (PartEntry[0]));
+ gBS->CopyMem((&PtnEntries[Index]), PartEntry, sizeof(PartEntry[0]));
PtnEntries[Index].lun = i;
}
}
/* Back up the ptn entries */
- gBS->CopyMem (PtnEntriesBak, PtnEntries, sizeof (PtnEntries));
+ gBS->CopyMem(PtnEntriesBak, PtnEntries, sizeof(PtnEntries));
}
INT32
-GetPartitionIndex (CHAR16 *Pname)
+GetPartitionIndex(CHAR16 *Pname)
{
INT32 i;
for (i = 0; i < PartitionCount; i++) {
- if (!StrnCmp (PtnEntries[i].PartEntry.PartitionName, Pname,
- ARRAY_SIZE (PtnEntries[i].PartEntry.PartitionName))) {
+ if (!StrnCmp(
+ PtnEntries[i].PartEntry.PartitionName, Pname,
+ ARRAY_SIZE(PtnEntries[i].PartEntry.PartitionName))) {
return i;
}
}
}
STATIC EFI_STATUS
-GetStorageHandle (INT32 Lun, HandleInfo *BlockIoHandle, UINT32 *MaxHandles)
+GetStorageHandle(INT32 Lun, HandleInfo *BlockIoHandle, UINT32 *MaxHandles)
{
- EFI_STATUS Status = EFI_INVALID_PARAMETER;
- UINT32 Attribs = 0;
+ EFI_STATUS Status = EFI_INVALID_PARAMETER;
+ UINT32 Attribs = 0;
PartiSelectFilter HandleFilter;
// UFS LUN GUIDs
EFI_GUID LunGuids[] = {
Attribs |= BLK_IO_SEL_SELECT_ROOT_DEVICE_ONLY;
HandleFilter.PartitionType = NULL;
- HandleFilter.VolumeName = NULL;
+ HandleFilter.VolumeName = NULL;
if (Lun == NO_LUN) {
HandleFilter.RootDeviceType = &gEfiEmmcUserPartitionGuid;
- Status =
- GetBlkIOHandles (Attribs, &HandleFilter, BlockIoHandle, MaxHandles);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Error getting block IO handle for Emmc\n"));
+ Status = GetBlkIOHandles(Attribs, &HandleFilter, BlockIoHandle, MaxHandles);
+ if (EFI_ERROR(Status)) {
+ DEBUG((EFI_D_ERROR, "Error getting block IO handle for Emmc\n"));
return Status;
}
- } else {
+ }
+ else {
HandleFilter.RootDeviceType = &LunGuids[Lun];
- Status =
- GetBlkIOHandles (Attribs, &HandleFilter, BlockIoHandle, MaxHandles);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Error getting block IO handle for Lun:%x\n", Lun));
+ Status = GetBlkIOHandles(Attribs, &HandleFilter, BlockIoHandle, MaxHandles);
+ if (EFI_ERROR(Status)) {
+ DEBUG((EFI_D_ERROR, "Error getting block IO handle for Lun:%x\n", Lun));
return Status;
}
}
return Status;
}
-STATIC BOOLEAN IsUpdatePartitionAttributes ()
+STATIC BOOLEAN IsUpdatePartitionAttributes()
{
- if (CompareMem (PtnEntries, PtnEntriesBak, sizeof (PtnEntries))) {
+ if (CompareMem(PtnEntries, PtnEntriesBak, sizeof(PtnEntries))) {
return TRUE;
}
return FALSE;
}
-UINT64 GetPartitionSize (EFI_BLOCK_IO_PROTOCOL *BlockIo)
+UINT64 GetPartitionSize(EFI_BLOCK_IO_PROTOCOL *BlockIo)
{
UINT64 PartitionSize;
if (!BlockIo) {
- DEBUG ((EFI_D_ERROR, "Invalid parameter, pleae check BlockIo info!!!\n"));
+ DEBUG((EFI_D_ERROR, "Invalid parameter, pleae check BlockIo info!!!\n"));
return 0;
}
- if (CHECK_ADD64 (BlockIo->Media->LastBlock, 1)) {
- DEBUG ((EFI_D_ERROR, "Integer overflow while adding LastBlock and 1\n"));
+ if (CHECK_ADD64(BlockIo->Media->LastBlock, 1)) {
+ DEBUG((EFI_D_ERROR, "Integer overflow while adding LastBlock and 1\n"));
return 0;
}
if ((MAX_UINT64 / (BlockIo->Media->LastBlock + 1)) <
- (UINT64)BlockIo->Media->BlockSize) {
- DEBUG ((EFI_D_ERROR,
- "Integer overflow while multiplying LastBlock and BlockSize\n"));
+ (UINT64)BlockIo->Media->BlockSize) {
+ DEBUG(
+ (EFI_D_ERROR,
+ "Integer overflow while multiplying LastBlock and BlockSize\n"));
return 0;
}
PartitionSize = (BlockIo->Media->LastBlock + 1) * BlockIo->Media->BlockSize;
- return PartitionSize;
+ return PartitionSize;
}
-VOID UpdatePartitionAttributes (UINT32 UpdateType)
+VOID UpdatePartitionAttributes(UINT32 UpdateType)
{
- UINT32 BlkSz;
- UINT8 *GptHdr = NULL;
- UINT8 *GptHdrPtr = NULL;
- UINTN MaxGptPartEntrySzBytes;
- UINT32 Offset;
- UINT32 MaxPtnCount = 0;
- UINT32 PtnEntrySz = 0;
- UINT32 i = 0;
- UINT8 *PtnEntriesPtr;
- UINT8 *Ptn_Entries;
- UINT32 CrcVal = 0;
- UINT32 Iter;
- UINT32 HdrSz = GPT_HEADER_SIZE;
- UINT64 DeviceDensity;
- UINT64 CardSizeSec;
- EFI_STATUS Status;
- INT32 Lun;
+ UINT32 BlkSz;
+ UINT8 * GptHdr = NULL;
+ UINT8 * GptHdrPtr = NULL;
+ UINTN MaxGptPartEntrySzBytes;
+ UINT32 Offset;
+ UINT32 MaxPtnCount = 0;
+ UINT32 PtnEntrySz = 0;
+ UINT32 i = 0;
+ UINT8 * PtnEntriesPtr;
+ UINT8 * Ptn_Entries;
+ UINT32 CrcVal = 0;
+ UINT32 Iter;
+ UINT32 HdrSz = GPT_HEADER_SIZE;
+ UINT64 DeviceDensity;
+ UINT64 CardSizeSec;
+ EFI_STATUS Status;
+ INT32 Lun;
EFI_BLOCK_IO_PROTOCOL *BlockIo = NULL;
- HandleInfo BlockIoHandle[MAX_HANDLEINF_LST_SIZE];
- UINT32 MaxHandles = MAX_HANDLEINF_LST_SIZE;
- CHAR8 BootDeviceType[BOOT_DEV_NAME_SIZE_MAX];
- UINT32 PartEntriesblocks = 0;
- BOOLEAN SkipUpdation;
- UINT64 Attr;
+ HandleInfo BlockIoHandle[MAX_HANDLEINF_LST_SIZE];
+ UINT32 MaxHandles = MAX_HANDLEINF_LST_SIZE;
+ CHAR8 BootDeviceType[BOOT_DEV_NAME_SIZE_MAX];
+ UINT32 PartEntriesblocks = 0;
+ BOOLEAN SkipUpdation;
+ UINT64 Attr;
struct PartitionEntry *InMemPtnEnt;
/* The PtnEntries is the same as PtnEntriesBak by default
* It needs to update attributes or GUID when PtnEntries is changed
*/
- if (!IsUpdatePartitionAttributes ()) {
+ if (!IsUpdatePartitionAttributes()) {
return;
}
- GetRootDeviceType (BootDeviceType, BOOT_DEV_NAME_SIZE_MAX);
+ GetRootDeviceType(BootDeviceType, BOOT_DEV_NAME_SIZE_MAX);
for (Lun = 0; Lun < MaxLuns; Lun++) {
- if (!AsciiStrnCmp (BootDeviceType, "EMMC", AsciiStrLen ("EMMC"))) {
- Status = GetStorageHandle (NO_LUN, BlockIoHandle, &MaxHandles);
- } else if (!AsciiStrnCmp (BootDeviceType, "UFS", AsciiStrLen ("UFS"))) {
- Status = GetStorageHandle (Lun, BlockIoHandle, &MaxHandles);
- } else {
- DEBUG ((EFI_D_ERROR, "Unsupported boot device type\n"));
+ if (!AsciiStrnCmp(BootDeviceType, "EMMC", AsciiStrLen("EMMC"))) {
+ Status = GetStorageHandle(NO_LUN, BlockIoHandle, &MaxHandles);
+ }
+ else if (!AsciiStrnCmp(BootDeviceType, "UFS", AsciiStrLen("UFS"))) {
+ Status = GetStorageHandle(Lun, BlockIoHandle, &MaxHandles);
+ }
+ else {
+ DEBUG((EFI_D_ERROR, "Unsupported boot device type\n"));
return;
}
if (Status != EFI_SUCCESS) {
- DEBUG ((EFI_D_ERROR,
- "Failed to get BlkIo for device. MaxHandles:%d - %r\n",
- MaxHandles, Status));
+ DEBUG(
+ (EFI_D_ERROR, "Failed to get BlkIo for device. MaxHandles:%d - %r\n",
+ MaxHandles, Status));
return;
}
if (MaxHandles != 1) {
- DEBUG ((EFI_D_VERBOSE,
- "Failed to get the BlockIo for device. MaxHandle:%d, %r\n",
- MaxHandles, Status));
+ DEBUG(
+ (EFI_D_VERBOSE,
+ "Failed to get the BlockIo for device. MaxHandle:%d, %r\n",
+ MaxHandles, Status));
continue;
}
- BlockIo = BlockIoHandle[0].BlkIo;
- DeviceDensity = GetPartitionSize (BlockIo);
+ BlockIo = BlockIoHandle[0].BlkIo;
+ DeviceDensity = GetPartitionSize(BlockIo);
if (!DeviceDensity) {
return;
}
- BlkSz = BlockIo->Media->BlockSize;
- PartEntriesblocks = MAX_PARTITION_ENTRIES_SZ / BlkSz;
+ BlkSz = BlockIo->Media->BlockSize;
+ PartEntriesblocks = MAX_PARTITION_ENTRIES_SZ / BlkSz;
MaxGptPartEntrySzBytes = (GPT_HDR_BLOCKS + PartEntriesblocks) * BlkSz;
- CardSizeSec = (DeviceDensity) / BlkSz;
- Offset = PRIMARY_HDR_LBA;
- GptHdr = AllocateZeroPool (MaxGptPartEntrySzBytes);
+ CardSizeSec = (DeviceDensity) / BlkSz;
+ Offset = PRIMARY_HDR_LBA;
+ GptHdr = AllocateZeroPool(MaxGptPartEntrySzBytes);
if (!GptHdr) {
- DEBUG ((EFI_D_ERROR, "Unable to Allocate Memory for GptHdr \n"));
+ DEBUG((EFI_D_ERROR, "Unable to Allocate Memory for GptHdr \n"));
return;
}
for (Iter = 0; Iter < 2;
Iter++, (Offset = CardSizeSec - MaxGptPartEntrySzBytes / BlkSz)) {
SkipUpdation = TRUE;
- Status = BlockIo->ReadBlocks (BlockIo, BlockIo->Media->MediaId, Offset,
- MaxGptPartEntrySzBytes, GptHdr);
+ Status = BlockIo->ReadBlocks(
+ BlockIo, BlockIo->Media->MediaId, Offset, MaxGptPartEntrySzBytes,
+ GptHdr);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Unable to read the media \n"));
+ if (EFI_ERROR(Status)) {
+ DEBUG((EFI_D_ERROR, "Unable to read the media \n"));
goto Exit;
}
if (Iter == 0x1) {
/* This is the back up GPT */
Ptn_Entries = GptHdr;
- GptHdr = GptHdr + ((PartEntriesblocks)*BlkSz);
- } else
+ GptHdr = GptHdr + ((PartEntriesblocks)*BlkSz);
+ }
+ else
/* otherwise we are at the primary gpt */
Ptn_Entries = GptHdr + BlkSz;
InMemPtnEnt = (struct PartitionEntry *)PtnEntriesPtr;
/*If GUID is not present, then it is BlkIo Handle of the Lun. Skip*/
if (!(PtnEntries[i].PartEntry.PartitionTypeGUID.Data1)) {
- DEBUG ((EFI_D_VERBOSE, " Skipping Lun:%d, i=%d\n", Lun, i));
+ DEBUG((EFI_D_VERBOSE, " Skipping Lun:%d, i=%d\n", Lun, i));
continue;
}
- if (!AsciiStrnCmp (BootDeviceType, "UFS", AsciiStrLen ("UFS"))) {
+ if (!AsciiStrnCmp(BootDeviceType, "UFS", AsciiStrLen("UFS"))) {
/* Partition table is populated with entries from lun 0 to max lun.
* break out of the loop once we see the partition lun is > current
* lun */
if (PtnEntries[i].lun != Lun)
continue;
}
- Attr = GET_LLWORD_FROM_BYTE (&PtnEntriesPtr[ATTRIBUTE_FLAG_OFFSET]);
+ Attr = GET_LLWORD_FROM_BYTE(&PtnEntriesPtr[ATTRIBUTE_FLAG_OFFSET]);
if (UpdateType & PARTITION_GUID_MASK) {
- if (CompareMem (&InMemPtnEnt->PartEntry.PartitionTypeGUID,
- &PtnEntries[i].PartEntry.PartitionTypeGUID,
- sizeof (EFI_GUID))) {
+ if (CompareMem(
+ &InMemPtnEnt->PartEntry.PartitionTypeGUID,
+ &PtnEntries[i].PartEntry.PartitionTypeGUID,
+ sizeof(EFI_GUID))) {
/* Update the partition GUID values */
- gBS->CopyMem ((VOID *)PtnEntriesPtr,
- (VOID *)&PtnEntries[i].PartEntry.PartitionTypeGUID,
- GUID_SIZE);
+ gBS->CopyMem(
+ (VOID *)PtnEntriesPtr,
+ (VOID *)&PtnEntries[i].PartEntry.PartitionTypeGUID, GUID_SIZE);
/* Update the PtnEntriesBak for next comparison */
- gBS->CopyMem (
- (VOID *)&PtnEntriesBak[i].PartEntry.PartitionTypeGUID,
- (VOID *)&PtnEntries[i].PartEntry.PartitionTypeGUID,
- GUID_SIZE);
+ gBS->CopyMem(
+ (VOID *)&PtnEntriesBak[i].PartEntry.PartitionTypeGUID,
+ (VOID *)&PtnEntries[i].PartEntry.PartitionTypeGUID, GUID_SIZE);
SkipUpdation = FALSE;
}
}
* If GUID is present, and the GUID is matched, update it
*/
if (!(InMemPtnEnt->PartEntry.PartitionTypeGUID.Data1) ||
- !CompareMem (&InMemPtnEnt->PartEntry.PartitionTypeGUID,
- &PtnEntries[i].PartEntry.PartitionTypeGUID,
- sizeof (EFI_GUID))) {
+ !CompareMem(
+ &InMemPtnEnt->PartEntry.PartitionTypeGUID,
+ &PtnEntries[i].PartEntry.PartitionTypeGUID,
+ sizeof(EFI_GUID))) {
if (Attr != PtnEntries[i].PartEntry.Attributes) {
/* Update the partition attributes */
- PUT_LONG_LONG (&PtnEntriesPtr[ATTRIBUTE_FLAG_OFFSET],
- PtnEntries[i].PartEntry.Attributes);
+ PUT_LONG_LONG(
+ &PtnEntriesPtr[ATTRIBUTE_FLAG_OFFSET],
+ PtnEntries[i].PartEntry.Attributes);
/* Update the PtnEntriesBak for next comparison */
PtnEntriesBak[i].PartEntry.Attributes =
- PtnEntries[i].PartEntry.Attributes;
+ PtnEntries[i].PartEntry.Attributes;
SkipUpdation = FALSE;
}
- } else {
+ }
+ else {
if (InMemPtnEnt->PartEntry.PartitionTypeGUID.Data1) {
- DEBUG ((EFI_D_ERROR,
- "Error in GPT header, GUID is not match!\n"));
+ DEBUG((EFI_D_ERROR, "Error in GPT header, GUID is not match!\n"));
continue;
}
}
if (SkipUpdation)
continue;
- MaxPtnCount = GET_LWORD_FROM_BYTE (&GptHdr[PARTITION_COUNT_OFFSET]);
- PtnEntrySz = GET_LWORD_FROM_BYTE (&GptHdr[PENTRY_SIZE_OFFSET]);
+ MaxPtnCount = GET_LWORD_FROM_BYTE(&GptHdr[PARTITION_COUNT_OFFSET]);
+ PtnEntrySz = GET_LWORD_FROM_BYTE(&GptHdr[PENTRY_SIZE_OFFSET]);
- if (((UINT64) (MaxPtnCount)*PtnEntrySz) > MAX_PARTITION_ENTRIES_SZ) {
- DEBUG ((EFI_D_ERROR,
- "Invalid GPT header fields MaxPtnCount = %x, PtnEntrySz = %x\n",
- MaxPtnCount, PtnEntrySz));
+ if (((UINT64)(MaxPtnCount)*PtnEntrySz) > MAX_PARTITION_ENTRIES_SZ) {
+ DEBUG(
+ (EFI_D_ERROR,
+ "Invalid GPT header fields MaxPtnCount = %x, PtnEntrySz = %x\n",
+ MaxPtnCount, PtnEntrySz));
goto Exit;
}
- Status = gBS->CalculateCrc32 (Ptn_Entries, ((MaxPtnCount) * (PtnEntrySz)),
- &CrcVal);
+ Status = gBS->CalculateCrc32(
+ Ptn_Entries, ((MaxPtnCount) * (PtnEntrySz)), &CrcVal);
if (Status != EFI_SUCCESS) {
- DEBUG ((EFI_D_ERROR, "Error Calculating CRC32 on the Gpt header: %x\n",
- Status));
+ DEBUG(
+ (EFI_D_ERROR, "Error Calculating CRC32 on the Gpt header: %x\n",
+ Status));
goto Exit;
}
- PUT_LONG (&GptHdr[PARTITION_CRC_OFFSET], CrcVal);
+ PUT_LONG(&GptHdr[PARTITION_CRC_OFFSET], CrcVal);
/*Write CRC to 0 before we calculate the crc of the GPT header*/
CrcVal = 0;
- PUT_LONG (&GptHdr[HEADER_CRC_OFFSET], CrcVal);
+ PUT_LONG(&GptHdr[HEADER_CRC_OFFSET], CrcVal);
- Status = gBS->CalculateCrc32 (GptHdr, HdrSz, &CrcVal);
+ Status = gBS->CalculateCrc32(GptHdr, HdrSz, &CrcVal);
if (Status != EFI_SUCCESS) {
- DEBUG ((EFI_D_ERROR, "Error Calculating CRC32 on the Gpt header: %x\n",
- Status));
+ DEBUG(
+ (EFI_D_ERROR, "Error Calculating CRC32 on the Gpt header: %x\n",
+ Status));
goto Exit;
}
- PUT_LONG (&GptHdr[HEADER_CRC_OFFSET], CrcVal);
+ PUT_LONG(&GptHdr[HEADER_CRC_OFFSET], CrcVal);
if (Iter == 0x1)
/* Write the backup GPT header, which is at an offset of CardSizeSec -
* MaxGptPartEntrySzBytes/BlkSz in blocks*/
- Status =
- BlockIo->WriteBlocks (BlockIo, BlockIo->Media->MediaId, Offset,
- MaxGptPartEntrySzBytes, (VOID *)Ptn_Entries);
+ Status = BlockIo->WriteBlocks(
+ BlockIo, BlockIo->Media->MediaId, Offset, MaxGptPartEntrySzBytes,
+ (VOID *)Ptn_Entries);
else
/* Write the primary GPT header, which is at an offset of BlkSz */
- Status = BlockIo->WriteBlocks (BlockIo, BlockIo->Media->MediaId, Offset,
- MaxGptPartEntrySzBytes, (VOID *)GptHdr);
+ Status = BlockIo->WriteBlocks(
+ BlockIo, BlockIo->Media->MediaId, Offset, MaxGptPartEntrySzBytes,
+ (VOID *)GptHdr);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Error writing primary GPT header: %r\n", Status));
+ if (EFI_ERROR(Status)) {
+ DEBUG((EFI_D_ERROR, "Error writing primary GPT header: %r\n", Status));
goto Exit;
}
}
- FreePool (GptHdrPtr);
+ FreePool(GptHdrPtr);
GptHdrPtr = NULL;
}
Exit:
if (GptHdrPtr) {
- FreePool (GptHdrPtr);
+ FreePool(GptHdrPtr);
GptHdrPtr = NULL;
}
}
-STATIC VOID
-MarkPtnActive (CHAR16 *ActiveSlot)
+STATIC VOID MarkPtnActive(CHAR16 *ActiveSlot)
{
UINT32 i;
for (i = 0; i < PartitionCount; i++) {
/* Mark all the slots with current ActiveSlot as active */
- if (StrStr (PtnEntries[i].PartEntry.PartitionName, ActiveSlot))
+ if (StrStr(PtnEntries[i].PartEntry.PartitionName, ActiveSlot))
PtnEntries[i].PartEntry.Attributes |= PART_ATT_ACTIVE_VAL;
else
PtnEntries[i].PartEntry.Attributes &= ~PART_ATT_ACTIVE_VAL;
}
/* Update the partition table */
- UpdatePartitionAttributes (PARTITION_ATTRIBUTES);
+ UpdatePartitionAttributes(PARTITION_ATTRIBUTES);
}
-STATIC VOID
-SwapPtnGuid (EFI_PARTITION_ENTRY *p1, EFI_PARTITION_ENTRY *p2)
+STATIC VOID SwapPtnGuid(EFI_PARTITION_ENTRY *p1, EFI_PARTITION_ENTRY *p2)
{
EFI_GUID Temp;
if (p1 == NULL || p2 == NULL)
return;
- gBS->CopyMem ((VOID *)&Temp, (VOID *)&p1->PartitionTypeGUID,
- sizeof (EFI_GUID));
- gBS->CopyMem ((VOID *)&p1->PartitionTypeGUID, (VOID *)&p2->PartitionTypeGUID,
- sizeof (EFI_GUID));
- gBS->CopyMem ((VOID *)&p2->PartitionTypeGUID, (VOID *)&Temp,
- sizeof (EFI_GUID));
+ gBS->CopyMem((VOID *)&Temp, (VOID *)&p1->PartitionTypeGUID, sizeof(EFI_GUID));
+ gBS->CopyMem(
+ (VOID *)&p1->PartitionTypeGUID, (VOID *)&p2->PartitionTypeGUID,
+ sizeof(EFI_GUID));
+ gBS->CopyMem((VOID *)&p2->PartitionTypeGUID, (VOID *)&Temp, sizeof(EFI_GUID));
}
-STATIC EFI_STATUS GetMultiSlotPartsList (VOID)
+STATIC EFI_STATUS GetMultiSlotPartsList(VOID)
{
- UINT32 i = 0;
- UINT32 j = 0;
- UINT32 Len = 0;
- UINT32 PtnLen = 0;
- CHAR16 *SearchString = NULL;
- struct BootPartsLinkedList *TempNode = NULL;
+ UINT32 i = 0;
+ UINT32 j = 0;
+ UINT32 Len = 0;
+ UINT32 PtnLen = 0;
+ CHAR16 * SearchString = NULL;
+ struct BootPartsLinkedList *TempNode = NULL;
for (i = 0; i < PartitionCount; i++) {
SearchString = PtnEntries[i].PartEntry.PartitionName;
for (j = i + 1; j < PartitionCount; j++) {
if (!PtnEntries[j].PartEntry.PartitionName[0])
continue;
- Len = StrLen (SearchString);
- PtnLen = StrLen (PtnEntries[j].PartEntry.PartitionName);
+ Len = StrLen(SearchString);
+ PtnLen = StrLen(PtnEntries[j].PartEntry.PartitionName);
/*Need to compare till "boot_"a hence skip last Char from StrLen value*/
if ((PtnLen == Len) &&
- !StrnCmp (PtnEntries[j].PartEntry.PartitionName,
- SearchString, Len - 1) &&
- (StrStr (SearchString, (CONST CHAR16 *)L"_a") ||
- StrStr (SearchString, (CONST CHAR16 *)L"_b"))) {
- TempNode = AllocateZeroPool (sizeof (struct BootPartsLinkedList));
+ !StrnCmp(
+ PtnEntries[j].PartEntry.PartitionName, SearchString, Len - 1) &&
+ (StrStr(SearchString, (CONST CHAR16 *)L"_a") ||
+ StrStr(SearchString, (CONST CHAR16 *)L"_b"))) {
+ TempNode = AllocateZeroPool(sizeof(struct BootPartsLinkedList));
if (TempNode) {
/*Skip _a/_b from partition name*/
- StrnCpyS (TempNode->PartName, sizeof (TempNode->PartName),
- SearchString, Len - 2);
+ StrnCpyS(
+ TempNode->PartName, sizeof(TempNode->PartName), SearchString,
+ Len - 2);
TempNode->Next = HeadNode;
- HeadNode = TempNode;
- } else {
- DEBUG ((EFI_D_ERROR,
- "Unable to Allocate Memory for MultiSlot Partition list\n"));
+ HeadNode = TempNode;
+ }
+ else {
+ DEBUG(
+ (EFI_D_ERROR,
+ "Unable to Allocate Memory for MultiSlot Partition list\n"));
return EFI_OUT_OF_RESOURCES;
}
break;
return EFI_SUCCESS;
}
-STATIC VOID
-SwitchPtnSlots (CONST CHAR16 *SetActive)
+STATIC VOID SwitchPtnSlots(CONST CHAR16 *SetActive)
{
- UINT32 i;
- struct PartitionEntry *PtnCurrent = NULL;
- struct PartitionEntry *PtnNew = NULL;
- CHAR16 CurSlot[BOOT_PART_SIZE];
- CHAR16 NewSlot[BOOT_PART_SIZE];
- CHAR16 SetInactive[MAX_SLOT_SUFFIX_SZ];
- UINT32 UfsBootLun = 0;
- BOOLEAN UfsGet = TRUE;
- BOOLEAN UfsSet = FALSE;
- struct BootPartsLinkedList *TempNode = NULL;
- EFI_STATUS Status;
- CHAR8 BootDeviceType[BOOT_DEV_NAME_SIZE_MAX];
+ UINT32 i;
+ struct PartitionEntry * PtnCurrent = NULL;
+ struct PartitionEntry * PtnNew = NULL;
+ CHAR16 CurSlot[BOOT_PART_SIZE];
+ CHAR16 NewSlot[BOOT_PART_SIZE];
+ CHAR16 SetInactive[MAX_SLOT_SUFFIX_SZ];
+ UINT32 UfsBootLun = 0;
+ BOOLEAN UfsGet = TRUE;
+ BOOLEAN UfsSet = FALSE;
+ struct BootPartsLinkedList *TempNode = NULL;
+ EFI_STATUS Status;
+ CHAR8 BootDeviceType[BOOT_DEV_NAME_SIZE_MAX];
/* Create the partition name string for active and non active slots*/
- if (!StrnCmp (SetActive, (CONST CHAR16 *)L"_a",
- StrLen ((CONST CHAR16 *)L"_a")))
- StrnCpyS (SetInactive, MAX_SLOT_SUFFIX_SZ, (CONST CHAR16 *)L"_b",
- StrLen ((CONST CHAR16 *)L"_b"));
+ if (!StrnCmp(SetActive, (CONST CHAR16 *)L"_a", StrLen((CONST CHAR16 *)L"_a")))
+ StrnCpyS(
+ SetInactive, MAX_SLOT_SUFFIX_SZ, (CONST CHAR16 *)L"_b",
+ StrLen((CONST CHAR16 *)L"_b"));
else
- StrnCpyS (SetInactive, MAX_SLOT_SUFFIX_SZ, (CONST CHAR16 *)L"_a",
- StrLen ((CONST CHAR16 *)L"_a"));
+ StrnCpyS(
+ SetInactive, MAX_SLOT_SUFFIX_SZ, (CONST CHAR16 *)L"_a",
+ StrLen((CONST CHAR16 *)L"_a"));
if (!HeadNode) {
- Status = GetMultiSlotPartsList ();
+ Status = GetMultiSlotPartsList();
if (Status != EFI_SUCCESS) {
- DEBUG ((EFI_D_INFO, "Unable to get GetMultiSlotPartsList\n"));
+ DEBUG((EFI_D_INFO, "Unable to get GetMultiSlotPartsList\n"));
return;
}
}
for (TempNode = HeadNode; TempNode; TempNode = TempNode->Next) {
- gBS->SetMem (CurSlot, BOOT_PART_SIZE, 0);
- gBS->SetMem (NewSlot, BOOT_PART_SIZE, 0);
+ gBS->SetMem(CurSlot, BOOT_PART_SIZE, 0);
+ gBS->SetMem(NewSlot, BOOT_PART_SIZE, 0);
- StrnCpyS (CurSlot, BOOT_PART_SIZE, TempNode->PartName,
- StrLen (TempNode->PartName));
- StrnCatS (CurSlot, BOOT_PART_SIZE, SetInactive, StrLen (SetInactive));
+ StrnCpyS(
+ CurSlot, BOOT_PART_SIZE, TempNode->PartName,
+ StrLen(TempNode->PartName));
+ StrnCatS(CurSlot, BOOT_PART_SIZE, SetInactive, StrLen(SetInactive));
- StrnCpyS (NewSlot, BOOT_PART_SIZE, TempNode->PartName,
- StrLen (TempNode->PartName));
- StrnCatS (NewSlot, BOOT_PART_SIZE, SetActive, StrLen (SetActive));
+ StrnCpyS(
+ NewSlot, BOOT_PART_SIZE, TempNode->PartName,
+ StrLen(TempNode->PartName));
+ StrnCatS(NewSlot, BOOT_PART_SIZE, SetActive, StrLen(SetActive));
/* Find the pointer to partition table entry for active and non-active
* slots*/
for (i = 0; i < PartitionCount; i++) {
- if (!StrnCmp (PtnEntries[i].PartEntry.PartitionName, CurSlot,
- StrLen (CurSlot))) {
+ if (!StrnCmp(
+ PtnEntries[i].PartEntry.PartitionName, CurSlot,
+ StrLen(CurSlot))) {
PtnCurrent = &PtnEntries[i];
- } else if (!StrnCmp (PtnEntries[i].PartEntry.PartitionName, NewSlot,
- StrLen (NewSlot))) {
+ }
+ else if (!StrnCmp(
+ PtnEntries[i].PartEntry.PartitionName, NewSlot,
+ StrLen(NewSlot))) {
PtnNew = &PtnEntries[i];
}
}
/* Swap the guids for the slots */
- SwapPtnGuid (&PtnCurrent->PartEntry, &PtnNew->PartEntry);
+ SwapPtnGuid(&PtnCurrent->PartEntry, &PtnNew->PartEntry);
PtnCurrent = PtnNew = NULL;
}
- GetRootDeviceType (BootDeviceType, BOOT_DEV_NAME_SIZE_MAX);
- if (!AsciiStrnCmp (BootDeviceType, "UFS", AsciiStrLen ("UFS"))) {
- UfsGetSetBootLun (&UfsBootLun, UfsGet);
+ GetRootDeviceType(BootDeviceType, BOOT_DEV_NAME_SIZE_MAX);
+ if (!AsciiStrnCmp(BootDeviceType, "UFS", AsciiStrLen("UFS"))) {
+ UfsGetSetBootLun(&UfsBootLun, UfsGet);
// Special case for XBL is to change the bootlun instead of swapping the
// guid
if (UfsBootLun == 0x1 &&
- !StrnCmp (SetActive, (CONST CHAR16 *)L"_b",
- StrLen ((CONST CHAR16 *)L"_b"))) {
- DEBUG ((EFI_D_INFO, "Switching the boot lun from 1 to 2\n"));
+ !StrnCmp(
+ SetActive, (CONST CHAR16 *)L"_b", StrLen((CONST CHAR16 *)L"_b"))) {
+ DEBUG((EFI_D_INFO, "Switching the boot lun from 1 to 2\n"));
UfsBootLun = 0x2;
- } else if (UfsBootLun == 0x2 &&
- !StrnCmp (SetActive, (CONST CHAR16 *)L"_a",
- StrLen ((CONST CHAR16 *)L"_a"))) {
- DEBUG ((EFI_D_INFO, "Switching the boot lun from 2 to 1\n"));
+ }
+ else if (
+ UfsBootLun == 0x2 &&
+ !StrnCmp(
+ SetActive, (CONST CHAR16 *)L"_a", StrLen((CONST CHAR16 *)L"_a"))) {
+ DEBUG((EFI_D_INFO, "Switching the boot lun from 2 to 1\n"));
UfsBootLun = 0x1;
}
- UfsGetSetBootLun (&UfsBootLun, UfsSet);
+ UfsGetSetBootLun(&UfsBootLun, UfsSet);
}
- UpdatePartitionAttributes (PARTITION_GUID);
+ UpdatePartitionAttributes(PARTITION_GUID);
}
EFI_STATUS
-EnumeratePartitions (VOID)
+EnumeratePartitions(VOID)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
PartiSelectFilter HandleFilter;
- UINT32 Attribs = 0;
- UINT32 i;
+ UINT32 Attribs = 0;
+ UINT32 i;
// UFS LUN GUIDs
EFI_GUID LunGuids[] = {
gEfiUfsLU0Guid, gEfiUfsLU1Guid, gEfiUfsLU2Guid, gEfiUfsLU3Guid,
gEfiUfsLU4Guid, gEfiUfsLU5Guid, gEfiUfsLU6Guid, gEfiUfsLU7Guid,
};
- gBS->SetMem ((VOID *)Ptable, (sizeof (struct StoragePartInfo) * MAX_LUNS), 0);
+ gBS->SetMem((VOID *)Ptable, (sizeof(struct StoragePartInfo) * MAX_LUNS), 0);
/* By default look for emmc partitions if not found look for UFS */
Attribs |= BLK_IO_SEL_MATCH_ROOT_DEVICE;
- Ptable[0].MaxHandles = ARRAY_SIZE (Ptable[0].HandleInfoList);
- HandleFilter.PartitionType = NULL;
- HandleFilter.VolumeName = NULL;
+ Ptable[0].MaxHandles = ARRAY_SIZE(Ptable[0].HandleInfoList);
+ HandleFilter.PartitionType = NULL;
+ HandleFilter.VolumeName = NULL;
HandleFilter.RootDeviceType = &gEfiEmmcUserPartitionGuid;
- Status =
- GetBlkIOHandles (Attribs, &HandleFilter, &Ptable[0].HandleInfoList[0],
- &Ptable[0].MaxHandles);
+ Status = GetBlkIOHandles(
+ Attribs, &HandleFilter, &Ptable[0].HandleInfoList[0],
+ &Ptable[0].MaxHandles);
if (Status == EFI_SUCCESS && Ptable[0].MaxHandles > 0) {
MaxLuns = 1;
}
/* If the media is not emmc then look for UFS */
- else if (EFI_ERROR (Status) || Ptable[0].MaxHandles == 0) {
+ else if (EFI_ERROR(Status) || Ptable[0].MaxHandles == 0) {
/* By default max 8 luns are supported but HW could be configured to use
* only few of them or all of them
* Based on the information read update the MaxLuns to reflect the max
* supported luns */
for (i = 0; i < MAX_LUNS; i++) {
- Ptable[i].MaxHandles = ARRAY_SIZE (Ptable[i].HandleInfoList);
- HandleFilter.PartitionType = NULL;
- HandleFilter.VolumeName = NULL;
+ Ptable[i].MaxHandles = ARRAY_SIZE(Ptable[i].HandleInfoList);
+ HandleFilter.PartitionType = NULL;
+ HandleFilter.VolumeName = NULL;
HandleFilter.RootDeviceType = &LunGuids[i];
- Status =
- GetBlkIOHandles (Attribs, &HandleFilter, &Ptable[i].HandleInfoList[0],
- &Ptable[i].MaxHandles);
+ Status = GetBlkIOHandles(
+ Attribs, &HandleFilter, &Ptable[i].HandleInfoList[0],
+ &Ptable[i].MaxHandles);
/* If we fail to get block for a lun that means the lun is not configured
* and unsed, ignore the error
* and continue with the next Lun */
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR,
- "Error getting block IO handle for %d lun, Lun may be unused\n",
- i));
+ if (EFI_ERROR(Status)) {
+ DEBUG(
+ (EFI_D_ERROR,
+ "Error getting block IO handle for %d lun, Lun may be unused\n",
+ i));
continue;
}
}
MaxLuns = i;
- } else {
- DEBUG ((EFI_D_ERROR, "Error populating block IO handles\n"));
+ }
+ else {
+ DEBUG((EFI_D_ERROR, "Error populating block IO handles\n"));
return EFI_NOT_FOUND;
}
*return: 1 or 0.
*/
BOOLEAN
-PartitionHasMultiSlot (CONST CHAR16 *Pname)
+PartitionHasMultiSlot(CONST CHAR16 *Pname)
{
UINT32 i;
UINT32 SlotCount = 0;
- UINT32 Len = StrLen (Pname);
+ UINT32 Len = StrLen(Pname);
for (i = 0; i < PartitionCount; i++) {
- if (!(StrnCmp (PtnEntries[i].PartEntry.PartitionName, Pname, Len))) {
+ if (!(StrnCmp(PtnEntries[i].PartEntry.PartitionName, Pname, Len))) {
if (PtnEntries[i].PartEntry.PartitionName[Len] == L'_' &&
(PtnEntries[i].PartEntry.PartitionName[Len + 1] == L'a' ||
PtnEntries[i].PartEntry.PartitionName[Len + 1] == L'b'))
return FALSE;
}
-STATIC struct PartitionEntry *
-GetBootPartitionEntry (Slot *BootSlot)
+STATIC struct PartitionEntry *GetBootPartitionEntry(Slot *BootSlot)
{
INT32 Index = INVALID_PTN;
- if (StrnCmp ((CONST CHAR16 *)L"_a", BootSlot->Suffix,
- StrLen (BootSlot->Suffix)) == 0) {
- Index = GetPartitionIndex ((CHAR16 *)L"boot_a");
- } else if (StrnCmp ((CONST CHAR16 *)L"_b", BootSlot->Suffix,
- StrLen (BootSlot->Suffix)) == 0) {
- Index = GetPartitionIndex ((CHAR16 *)L"boot_b");
- } else {
- DEBUG ((EFI_D_ERROR, "GetBootPartitionEntry: No boot partition "
- "entry for slot %s\n",
- BootSlot->Suffix));
+ if (StrnCmp(
+ (CONST CHAR16 *)L"_a", BootSlot->Suffix, StrLen(BootSlot->Suffix)) ==
+ 0) {
+ Index = GetPartitionIndex((CHAR16 *)L"boot_a");
+ }
+ else if (
+ StrnCmp(
+ (CONST CHAR16 *)L"_b", BootSlot->Suffix, StrLen(BootSlot->Suffix)) ==
+ 0) {
+ Index = GetPartitionIndex((CHAR16 *)L"boot_b");
+ }
+ else {
+ DEBUG(
+ (EFI_D_ERROR,
+ "GetBootPartitionEntry: No boot partition "
+ "entry for slot %s\n",
+ BootSlot->Suffix));
return NULL;
}
if (Index == INVALID_PTN) {
- DEBUG ((EFI_D_ERROR, "GetBootPartitionEntry: No boot partition entry "
- "for slot %s, invalid index\n",
- BootSlot->Suffix));
+ DEBUG(
+ (EFI_D_ERROR,
+ "GetBootPartitionEntry: No boot partition entry "
+ "for slot %s, invalid index\n",
+ BootSlot->Suffix));
return NULL;
}
return &PtnEntries[Index];
}
-BOOLEAN IsSlotBootable (Slot *BootSlot)
+BOOLEAN IsSlotBootable(Slot *BootSlot)
{
struct PartitionEntry *BootPartition = NULL;
- BootPartition = GetBootPartitionEntry (BootSlot);
+ BootPartition = GetBootPartitionEntry(BootSlot);
if (BootPartition == NULL) {
- DEBUG ((EFI_D_ERROR, "IsCurrentSlotBootable: No boot partition "
- "entry for slot %s\n",
- BootSlot->Suffix));
+ DEBUG(
+ (EFI_D_ERROR,
+ "IsCurrentSlotBootable: No boot partition "
+ "entry for slot %s\n",
+ BootSlot->Suffix));
return FALSE;
}
- DEBUG ((EFI_D_VERBOSE, "Slot suffix %s Part Attr 0x%lx\n", BootSlot->Suffix,
- BootPartition->PartEntry.Attributes));
+ DEBUG(
+ (EFI_D_VERBOSE, "Slot suffix %s Part Attr 0x%lx\n", BootSlot->Suffix,
+ BootPartition->PartEntry.Attributes));
if (!(BootPartition->PartEntry.Attributes & PART_ATT_UNBOOTABLE_VAL) &&
BootPartition->PartEntry.Attributes & PART_ATT_SUCCESSFUL_VAL) {
- DEBUG ((EFI_D_VERBOSE, "Slot %s is bootable\n", BootSlot->Suffix));
+ DEBUG((EFI_D_VERBOSE, "Slot %s is bootable\n", BootSlot->Suffix));
return TRUE;
}
- DEBUG ((EFI_D_VERBOSE, "Slot %s is unbootable \n", BootSlot->Suffix));
+ DEBUG((EFI_D_VERBOSE, "Slot %s is unbootable \n", BootSlot->Suffix));
return FALSE;
}
-EFI_STATUS ClearUnbootable (Slot *BootSlot)
+EFI_STATUS ClearUnbootable(Slot *BootSlot)
{
struct PartitionEntry *BootEntry = NULL;
- BootEntry = GetBootPartitionEntry (BootSlot);
+ BootEntry = GetBootPartitionEntry(BootSlot);
if (BootEntry == NULL) {
- DEBUG ((EFI_D_ERROR,
- "ClearUnbootable: No boot partition entry for slot %s\n",
- BootSlot->Suffix));
+ DEBUG(
+ (EFI_D_ERROR, "ClearUnbootable: No boot partition entry for slot %s\n",
+ BootSlot->Suffix));
return EFI_NOT_FOUND;
}
BootEntry->PartEntry.Attributes &= ~PART_ATT_UNBOOTABLE_VAL;
BootEntry->PartEntry.Attributes |= PART_ATT_MAX_RETRY_COUNT_VAL;
- UpdatePartitionAttributes (PARTITION_ATTRIBUTES);
+ UpdatePartitionAttributes(PARTITION_ATTRIBUTES);
return EFI_SUCCESS;
}
BOOLEAN
-IsSuffixEmpty (Slot *CheckSlot)
+IsSuffixEmpty(Slot *CheckSlot)
{
if (CheckSlot == NULL) {
return TRUE;
}
- if (StrLen (CheckSlot->Suffix) == 0) {
+ if (StrLen(CheckSlot->Suffix) == 0) {
return TRUE;
}
return FALSE;
}
-STATIC EFI_STATUS
-GetActiveSlot (Slot *ActiveSlot)
+STATIC EFI_STATUS GetActiveSlot(Slot *ActiveSlot)
{
- EFI_STATUS Status = EFI_SUCCESS;
- Slot Slots[] = {{L"_a"}, {L"_b"}};
- UINT64 Priority = 0;
+ EFI_STATUS Status = EFI_SUCCESS;
+ Slot Slots[] = {{L"_a"}, {L"_b"}};
+ UINT64 Priority = 0;
if (ActiveSlot == NULL) {
- DEBUG ((EFI_D_ERROR, "GetActiveSlot: bad parameter\n"));
+ DEBUG((EFI_D_ERROR, "GetActiveSlot: bad parameter\n"));
return EFI_INVALID_PARAMETER;
}
- for (UINTN SlotIndex = 0; SlotIndex < ARRAY_SIZE (Slots); SlotIndex++) {
+ for (UINTN SlotIndex = 0; SlotIndex < ARRAY_SIZE(Slots); SlotIndex++) {
struct PartitionEntry *BootPartition =
- GetBootPartitionEntry (&Slots[SlotIndex]);
+ GetBootPartitionEntry(&Slots[SlotIndex]);
UINT64 BootPriority = 0;
if (BootPartition == NULL) {
- DEBUG ((EFI_D_ERROR, "GetActiveSlot: No boot partition "
- "entry for slot %s\n",
- Slots[SlotIndex].Suffix));
+ DEBUG(
+ (EFI_D_ERROR,
+ "GetActiveSlot: No boot partition "
+ "entry for slot %s\n",
+ Slots[SlotIndex].Suffix));
return EFI_NOT_FOUND;
}
if ((BootPartition->PartEntry.Attributes & PART_ATT_ACTIVE_VAL) &&
(BootPriority > Priority)) {
- GUARD (StrnCpyS (ActiveSlot->Suffix, ARRAY_SIZE (ActiveSlot->Suffix),
- Slots[SlotIndex].Suffix,
- StrLen (Slots[SlotIndex].Suffix)));
+ GUARD(StrnCpyS(
+ ActiveSlot->Suffix, ARRAY_SIZE(ActiveSlot->Suffix),
+ Slots[SlotIndex].Suffix, StrLen(Slots[SlotIndex].Suffix)));
Priority = BootPriority;
}
}
- DEBUG ((EFI_D_VERBOSE, "GetActiveSlot: found active slot %s, priority %d\n",
- ActiveSlot->Suffix, Priority));
+ DEBUG(
+ (EFI_D_VERBOSE, "GetActiveSlot: found active slot %s, priority %d\n",
+ ActiveSlot->Suffix, Priority));
- if (IsSuffixEmpty (ActiveSlot) == TRUE) {
+ if (IsSuffixEmpty(ActiveSlot) == TRUE) {
/* Check for first boot and set default slot */
/* For First boot all A/B attributes for the slot would be 0 */
- UINT64 BootPriority = 0;
- UINT64 RetryCount = 0;
- struct PartitionEntry *SlotA = GetBootPartitionEntry (&Slots[0]);
+ UINT64 BootPriority = 0;
+ UINT64 RetryCount = 0;
+ struct PartitionEntry *SlotA = GetBootPartitionEntry(&Slots[0]);
if (SlotA == NULL) {
- DEBUG ((EFI_D_ERROR, "GetActiveSlot: First Boot: No boot partition "
- "entry for slot %s\n",
- Slots[0].Suffix));
+ DEBUG(
+ (EFI_D_ERROR,
+ "GetActiveSlot: First Boot: No boot partition "
+ "entry for slot %s\n",
+ Slots[0].Suffix));
return EFI_NOT_FOUND;
}
(SlotA->PartEntry.Attributes & PART_ATT_UNBOOTABLE_VAL) == 0 &&
BootPriority == 0) {
- DEBUG ((EFI_D_INFO, "GetActiveSlot: First boot: set "
- "default slot _a\n"));
+ DEBUG(
+ (EFI_D_INFO, "GetActiveSlot: First boot: set "
+ "default slot _a\n"));
SlotA->PartEntry.Attributes &=
(~PART_ATT_SUCCESSFUL_VAL & ~PART_ATT_UNBOOTABLE_VAL);
SlotA->PartEntry.Attributes |=
(PART_ATT_PRIORITY_VAL | PART_ATT_ACTIVE_VAL |
PART_ATT_MAX_RETRY_COUNT_VAL);
- GUARD (StrnCpyS (ActiveSlot->Suffix, ARRAY_SIZE (ActiveSlot->Suffix),
- Slots[0].Suffix, StrLen (Slots[0].Suffix)));
- UpdatePartitionAttributes (PARTITION_ATTRIBUTES);
+ GUARD(StrnCpyS(
+ ActiveSlot->Suffix, ARRAY_SIZE(ActiveSlot->Suffix), Slots[0].Suffix,
+ StrLen(Slots[0].Suffix)));
+ UpdatePartitionAttributes(PARTITION_ATTRIBUTES);
return EFI_SUCCESS;
}
- DEBUG ((EFI_D_ERROR, "GetActiveSlot: No active slot found\n"));
- DEBUG ((EFI_D_ERROR, "GetActiveSlot: Slot attr: Priority %ld, Retry "
- "%ld, Active %ld, Success %ld, unboot %ld\n",
- BootPriority, RetryCount,
- (SlotA->PartEntry.Attributes & PART_ATT_ACTIVE_VAL) >>
- PART_ATT_ACTIVE_BIT,
- (SlotA->PartEntry.Attributes & PART_ATT_SUCCESSFUL_VAL),
- (SlotA->PartEntry.Attributes & PART_ATT_UNBOOTABLE_VAL)));
+ DEBUG((EFI_D_ERROR, "GetActiveSlot: No active slot found\n"));
+ DEBUG(
+ (EFI_D_ERROR,
+ "GetActiveSlot: Slot attr: Priority %ld, Retry "
+ "%ld, Active %ld, Success %ld, unboot %ld\n",
+ BootPriority, RetryCount,
+ (SlotA->PartEntry.Attributes & PART_ATT_ACTIVE_VAL) >>
+ PART_ATT_ACTIVE_BIT,
+ (SlotA->PartEntry.Attributes & PART_ATT_SUCCESSFUL_VAL),
+ (SlotA->PartEntry.Attributes & PART_ATT_UNBOOTABLE_VAL)));
return EFI_NOT_FOUND;
}
}
EFI_STATUS
-SetActiveSlot (Slot *NewSlot, BOOLEAN ResetSuccessBit, BOOLEAN SetSuccessBit)
+SetActiveSlot(Slot *NewSlot, BOOLEAN ResetSuccessBit, BOOLEAN SetSuccessBit)
{
- EFI_STATUS Status = EFI_SUCCESS;
- Slot CurrentSlot = {{0}};
- Slot *AlternateSlot = NULL;
- Slot Slots[] = {{L"_a"}, {L"_b"}};
- BOOLEAN UfsGet = TRUE;
- BOOLEAN UfsSet = FALSE;
- UINT32 UfsBootLun = 0;
- CHAR8 BootDeviceType[BOOT_DEV_NAME_SIZE_MAX];
+ EFI_STATUS Status = EFI_SUCCESS;
+ Slot CurrentSlot = {{0}};
+ Slot * AlternateSlot = NULL;
+ Slot Slots[] = {{L"_a"}, {L"_b"}};
+ BOOLEAN UfsGet = TRUE;
+ BOOLEAN UfsSet = FALSE;
+ UINT32 UfsBootLun = 0;
+ CHAR8 BootDeviceType[BOOT_DEV_NAME_SIZE_MAX];
struct PartitionEntry *BootEntry = NULL;
if (NewSlot == NULL) {
- DEBUG ((EFI_D_ERROR, "SetActiveSlot: input parameter invalid\n"));
+ DEBUG((EFI_D_ERROR, "SetActiveSlot: input parameter invalid\n"));
return EFI_INVALID_PARAMETER;
}
- GUARD (GetActiveSlot (&CurrentSlot));
+ GUARD(GetActiveSlot(&CurrentSlot));
- if (StrnCmp (NewSlot->Suffix, Slots[0].Suffix, StrLen (Slots[0].Suffix)) == 0) {
+ if (StrnCmp(NewSlot->Suffix, Slots[0].Suffix, StrLen(Slots[0].Suffix)) == 0) {
AlternateSlot = &Slots[1];
- } else {
+ }
+ else {
AlternateSlot = &Slots[0];
}
- BootEntry = GetBootPartitionEntry (NewSlot);
+ BootEntry = GetBootPartitionEntry(NewSlot);
if (BootEntry == NULL) {
- DEBUG ((EFI_D_ERROR, "SetActiveSlot: No boot partition entry for slot %s\n",
- NewSlot->Suffix));
+ DEBUG(
+ (EFI_D_ERROR, "SetActiveSlot: No boot partition entry for slot %s\n",
+ NewSlot->Suffix));
return EFI_NOT_FOUND;
}
}
/* Reduce the priority and clear the active flag for alternate slot*/
- BootEntry = GetBootPartitionEntry (AlternateSlot);
+ BootEntry = GetBootPartitionEntry(AlternateSlot);
if (BootEntry == NULL) {
- DEBUG ((EFI_D_ERROR, "SetActiveSlot: No boot partition entry for slot %s\n",
- AlternateSlot->Suffix));
+ DEBUG(
+ (EFI_D_ERROR, "SetActiveSlot: No boot partition entry for slot %s\n",
+ AlternateSlot->Suffix));
return EFI_NOT_FOUND;
}
BootEntry->PartEntry.Attributes |=
(((UINT64)MAX_PRIORITY - 1) << PART_ATT_PRIORITY_BIT);
- UpdatePartitionAttributes (PARTITION_ATTRIBUTES);
- if (StrnCmp (CurrentSlot.Suffix, NewSlot->Suffix,
- StrLen (CurrentSlot.Suffix)) == 0) {
- DEBUG ((EFI_D_INFO, "SetActiveSlot: %s already active slot\n",
- NewSlot->Suffix));
+ UpdatePartitionAttributes(PARTITION_ATTRIBUTES);
+ if (StrnCmp(
+ CurrentSlot.Suffix, NewSlot->Suffix, StrLen(CurrentSlot.Suffix)) ==
+ 0) {
+ DEBUG(
+ (EFI_D_INFO, "SetActiveSlot: %s already active slot\n",
+ NewSlot->Suffix));
/* Check if BootLun is matching with Slot */
- GetRootDeviceType (BootDeviceType, BOOT_DEV_NAME_SIZE_MAX);
- if (!AsciiStrnCmp (BootDeviceType, "UFS", AsciiStrLen ("UFS"))) {
- UfsGetSetBootLun (&UfsBootLun, UfsGet);
- if (UfsBootLun == 0x1 &&
- !StrnCmp (CurrentSlot.Suffix, (CONST CHAR16 *)L"_b",
- StrLen ((CONST CHAR16 *)L"_b"))) {
- DEBUG ((EFI_D_INFO, "Boot lun mismatch switch from 1 to 2\n"));
- DEBUG ((EFI_D_INFO, "Reboot Required\n"));
+ GetRootDeviceType(BootDeviceType, BOOT_DEV_NAME_SIZE_MAX);
+ if (!AsciiStrnCmp(BootDeviceType, "UFS", AsciiStrLen("UFS"))) {
+ UfsGetSetBootLun(&UfsBootLun, UfsGet);
+ if (UfsBootLun == 0x1 && !StrnCmp(
+ CurrentSlot.Suffix, (CONST CHAR16 *)L"_b",
+ StrLen((CONST CHAR16 *)L"_b"))) {
+ DEBUG((EFI_D_INFO, "Boot lun mismatch switch from 1 to 2\n"));
+ DEBUG((EFI_D_INFO, "Reboot Required\n"));
UfsBootLun = 0x2;
- UfsGetSetBootLun (&UfsBootLun, UfsSet);
- } else if (UfsBootLun == 0x2 &&
- !StrnCmp (CurrentSlot.Suffix, (CONST CHAR16 *)L"_a",
- StrLen ((CONST CHAR16 *)L"_a"))) {
- DEBUG ((EFI_D_INFO, "Boot lun mismatch switch from 2 to 1\n"));
- DEBUG ((EFI_D_INFO, "Reboot Required\n"));
+ UfsGetSetBootLun(&UfsBootLun, UfsSet);
+ }
+ else if (
+ UfsBootLun == 0x2 && !StrnCmp(
+ CurrentSlot.Suffix, (CONST CHAR16 *)L"_a",
+ StrLen((CONST CHAR16 *)L"_a"))) {
+ DEBUG((EFI_D_INFO, "Boot lun mismatch switch from 2 to 1\n"));
+ DEBUG((EFI_D_INFO, "Reboot Required\n"));
UfsBootLun = 0x1;
- UfsGetSetBootLun (&UfsBootLun, UfsSet);
+ UfsGetSetBootLun(&UfsBootLun, UfsSet);
}
}
- } else {
- DEBUG ((EFI_D_INFO, "Alternate slot %s, New slot %s\n",
- AlternateSlot->Suffix, NewSlot->Suffix));
- SwitchPtnSlots (NewSlot->Suffix);
- MarkPtnActive (NewSlot->Suffix);
+ }
+ else {
+ DEBUG(
+ (EFI_D_INFO, "Alternate slot %s, New slot %s\n", AlternateSlot->Suffix,
+ NewSlot->Suffix));
+ SwitchPtnSlots(NewSlot->Suffix);
+ MarkPtnActive(NewSlot->Suffix);
}
return EFI_SUCCESS;
}
\ No newline at end of file
-/* Copyright (c) 2015-2018, 2020-2021, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2015-2018, 2020-2021, The Linux Foundation. All rights
+ * reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
+ */
#include "AutoGen.h"
-#include <Library/BootSlotLib/StorageUtils.h>
#include <Library/BootSlotLib/BlockIoUtils.h>
+#include <Library/BootSlotLib/StorageUtils.h>
STATIC CONST CHAR8 *DeviceType[] = {
- [EMMC] = "EMMC", [UFS] = "UFS", [UNKNOWN] = "Unknown",
+ [EMMC] = "EMMC",
+ [UFS] = "UFS",
+ [UNKNOWN] = "Unknown",
};
/**
**/
STATIC EFI_STATUS
-GetDeviceHandleInfo (VOID *HndlInfo, UINT32 MaxHandles, MemCardType Type)
+GetDeviceHandleInfo(VOID *HndlInfo, UINT32 MaxHandles, MemCardType Type)
{
- EFI_STATUS Status = EFI_INVALID_PARAMETER;
- UINT32 Attribs = 0;
+ EFI_STATUS Status = EFI_INVALID_PARAMETER;
+ UINT32 Attribs = 0;
PartiSelectFilter HandleFilter;
- HandleInfo *HandleInfoList = HndlInfo;
+ HandleInfo * HandleInfoList = HndlInfo;
Attribs |= BLK_IO_SEL_MATCH_ROOT_DEVICE;
HandleFilter.PartitionType = NULL;
- HandleFilter.VolumeName = NULL;
+ HandleFilter.VolumeName = NULL;
switch (Type) {
case UFS:
HandleFilter.RootDeviceType = &gEfiEmmcUserPartitionGuid;
break;
case UNKNOWN:
- DEBUG ((EFI_D_ERROR, "Device type unknown\n"));
+ DEBUG((EFI_D_ERROR, "Device type unknown\n"));
return Status;
}
- Status =
- GetBlkIOHandles (Attribs, &HandleFilter, HandleInfoList, &MaxHandles);
- if (EFI_ERROR (Status) ||
- MaxHandles == 0) {
- DEBUG ((EFI_D_ERROR, "Get BlkIohandles failed\n"));
+ Status = GetBlkIOHandles(Attribs, &HandleFilter, HandleInfoList, &MaxHandles);
+ if (EFI_ERROR(Status) || MaxHandles == 0) {
+ DEBUG((EFI_D_ERROR, "Get BlkIohandles failed\n"));
return Status;
}
return Status;
Return a device type
@retval Device type : UNKNOWN | UFS | EMMC | NAND
**/
-STATIC UINT32
-GetCompatibleRootDeviceType (VOID)
+STATIC UINT32 GetCompatibleRootDeviceType(VOID)
{
EFI_STATUS Status = EFI_INVALID_PARAMETER;
HandleInfo HandleInfoList[HANDLE_MAX_INFO_LIST];
- UINT32 MaxHandles = ARRAY_SIZE (HandleInfoList);
- UINT32 Index;
+ UINT32 MaxHandles = ARRAY_SIZE(HandleInfoList);
+ UINT32 Index;
for (Index = 0; Index < UNKNOWN; Index++) {
- Status = GetDeviceHandleInfo (HandleInfoList, MaxHandles, Index);
+ Status = GetDeviceHandleInfo(HandleInfoList, MaxHandles, Index);
if (Status == EFI_SUCCESS) {
return Index;
}
@retval Device type : UNKNOWN | UFS | EMMC, default is UNKNOWN
**/
-MemCardType
-CheckRootDeviceType (VOID)
+MemCardType CheckRootDeviceType(VOID)
{
- EFI_STATUS Status = EFI_INVALID_PARAMETER;
- STATIC MemCardType Type = UNKNOWN;
- MEM_CARD_INFO CardInfoData;
+ EFI_STATUS Status = EFI_INVALID_PARAMETER;
+ STATIC MemCardType Type = UNKNOWN;
+ MEM_CARD_INFO CardInfoData;
EFI_MEM_CARDINFO_PROTOCOL *CardInfo;
if (Type == UNKNOWN) {
- Status = gBS->LocateProtocol (&gEfiMemCardInfoProtocolGuid, NULL,
- (VOID **)&CardInfo);
- if (!EFI_ERROR (Status)) {
+ Status = gBS->LocateProtocol(
+ &gEfiMemCardInfoProtocolGuid, NULL, (VOID **)&CardInfo);
+ if (!EFI_ERROR(Status)) {
- Status = CardInfo->GetCardInfo (CardInfo, &CardInfoData);
+ Status = CardInfo->GetCardInfo(CardInfo, &CardInfoData);
- if (!EFI_ERROR (Status)) {
+ if (!EFI_ERROR(Status)) {
- if (!AsciiStrnCmp ((CHAR8 *)CardInfoData.card_type, "UFS",
- AsciiStrLen ("UFS"))) {
+ if (!AsciiStrnCmp(
+ (CHAR8 *)CardInfoData.card_type, "UFS", AsciiStrLen("UFS"))) {
Type = UFS;
- } else if (!AsciiStrnCmp ((CHAR8 *)CardInfoData.card_type, "EMMC",
- AsciiStrLen ("EMMC"))) {
+ }
+ else if (!AsciiStrnCmp(
+ (CHAR8 *)CardInfoData.card_type, "EMMC",
+ AsciiStrLen("EMMC"))) {
Type = EMMC;
- } else {
- Type = GetCompatibleRootDeviceType ();
+ }
+ else {
+ Type = GetCompatibleRootDeviceType();
}
}
}
@param[out] StrDeviceType : Pointer to array of device type string.
@param[in] Len : The size of the device type string
**/
-VOID
-GetRootDeviceType (CHAR8 *StrDeviceType, UINT32 Len)
+VOID GetRootDeviceType(CHAR8 *StrDeviceType, UINT32 Len)
{
UINT32 Type;
- Type = CheckRootDeviceType ();
- AsciiSPrint (StrDeviceType, Len, "%a", DeviceType[Type]);
+ Type = CheckRootDeviceType();
+ AsciiSPrint(StrDeviceType, Len, "%a", DeviceType[Type]);
}
EFI_STATUS
-UfsGetSetBootLun (UINT32 *UfsBootlun, BOOLEAN IsGet)
+UfsGetSetBootLun(UINT32 *UfsBootlun, BOOLEAN IsGet)
{
- EFI_STATUS Status = EFI_INVALID_PARAMETER;
+ EFI_STATUS Status = EFI_INVALID_PARAMETER;
EFI_MEM_CARDINFO_PROTOCOL *CardInfo;
- HandleInfo HandleInfoList[MAX_HANDLE_INFO_LIST];
- UINT32 Attribs = 0;
- UINT32 MaxHandles;
- PartiSelectFilter HandleFilter;
+ HandleInfo HandleInfoList[MAX_HANDLE_INFO_LIST];
+ UINT32 Attribs = 0;
+ UINT32 MaxHandles;
+ PartiSelectFilter HandleFilter;
Attribs |= BLK_IO_SEL_MATCH_ROOT_DEVICE;
- MaxHandles = ARRAY_SIZE (HandleInfoList);
- HandleFilter.PartitionType = NULL;
- HandleFilter.VolumeName = NULL;
+ MaxHandles = ARRAY_SIZE(HandleInfoList);
+ HandleFilter.PartitionType = NULL;
+ HandleFilter.VolumeName = NULL;
HandleFilter.RootDeviceType = &gEfiUfsLU0Guid;
- Status =
- GetBlkIOHandles (Attribs, &HandleFilter, HandleInfoList, &MaxHandles);
- if (EFI_ERROR (Status))
+ Status = GetBlkIOHandles(Attribs, &HandleFilter, HandleInfoList, &MaxHandles);
+ if (EFI_ERROR(Status))
return EFI_NOT_FOUND;
- Status =
- gBS->HandleProtocol (HandleInfoList[0].Handle,
- &gEfiMemCardInfoProtocolGuid, (VOID **)&CardInfo);
+ Status = gBS->HandleProtocol(
+ HandleInfoList[0].Handle, &gEfiMemCardInfoProtocolGuid,
+ (VOID **)&CardInfo);
if (Status != EFI_SUCCESS) {
- DEBUG ((EFI_D_ERROR, "Error locating MemCardInfoProtocol:%x\n", Status));
+ DEBUG((EFI_D_ERROR, "Error locating MemCardInfoProtocol:%x\n", Status));
return Status;
}
if (CardInfo->Revision < EFI_MEM_CARD_INFO_PROTOCOL_REVISION) {
- DEBUG ((EFI_D_ERROR, "This API not supported in Revision =%u\n",
- CardInfo->Revision));
+ DEBUG(
+ (EFI_D_ERROR, "This API not supported in Revision =%u\n",
+ CardInfo->Revision));
return EFI_NOT_FOUND;
}
if (IsGet == TRUE) {
- if (CardInfo->GetBootLU (CardInfo, UfsBootlun) == EFI_SUCCESS)
- DEBUG ((EFI_D_VERBOSE, "Get BootLun =%u\n", *UfsBootlun));
- } else {
- if (CardInfo->SetBootLU (CardInfo, *UfsBootlun) == EFI_SUCCESS)
- DEBUG ((EFI_D_VERBOSE, "SetBootLun =%u\n", *UfsBootlun));
+ if (CardInfo->GetBootLU(CardInfo, UfsBootlun) == EFI_SUCCESS)
+ DEBUG((EFI_D_VERBOSE, "Get BootLun =%u\n", *UfsBootlun));
+ }
+ else {
+ if (CardInfo->SetBootLU(CardInfo, *UfsBootlun) == EFI_SUCCESS)
+ DEBUG((EFI_D_VERBOSE, "SetBootLun =%u\n", *UfsBootlun));
}
return Status;
}
\ No newline at end of file
#include <Library/HobLib.h>
#include <Library/SerialPortLib.h>
-#include <Resources/font5x12.h>
#include <Resources/FbColor.h>
+#include <Resources/font5x12.h>
#include "FrameBufferSerialPortLib.h"
FBCON_POSITION m_Position;
FBCON_POSITION m_MaxPosition;
-FBCON_COLOR m_Color;
-BOOLEAN m_Initialized = FALSE;
+FBCON_COLOR m_Color;
+BOOLEAN m_Initialized = FALSE;
UINTN gWidth = FixedPcdGet32(PcdMipiFrameBufferWidth);
// Reserve half screen for output
UINTN gHeight = FixedPcdGet32(PcdMipiFrameBufferHeight);
-UINTN gBpp = FixedPcdGet32(PcdMipiFrameBufferPixelBpp);
+UINTN gBpp = FixedPcdGet32(PcdMipiFrameBufferPixelBpp);
// Module-used internal routine
-void FbConPutCharWithFactor
-(
- char c,
- int type,
- unsigned scale_factor
-);
-
-void FbConDrawglyph
-(
- char *pixels,
- unsigned stride,
- unsigned bpp,
- unsigned *glyph,
- unsigned scale_factor
-);
+void FbConPutCharWithFactor(char c, int type, unsigned scale_factor);
+
+void FbConDrawglyph(
+ char *pixels, unsigned stride, unsigned bpp, unsigned *glyph,
+ unsigned scale_factor);
void FbConReset(void);
void FbConScrollUp(void);
RETURN_STATUS
EFIAPI
-SerialPortInitialize
-(
- VOID
-)
+SerialPortInitialize(VOID)
{
- UINTN InterruptState = 0;
+ UINTN InterruptState = 0;
- // Prevent dup initialization
- if (m_Initialized) return RETURN_SUCCESS;
+ // Prevent dup initialization
+ if (m_Initialized)
+ return RETURN_SUCCESS;
- // Interrupt Disable
- InterruptState = ArmGetInterruptState();
- ArmDisableInterrupts();
+ // Interrupt Disable
+ InterruptState = ArmGetInterruptState();
+ ArmDisableInterrupts();
- // Reset console
- FbConReset();
+ // Reset console
+ FbConReset();
- // Set flag
- m_Initialized = TRUE;
+ // Set flag
+ m_Initialized = TRUE;
- if (InterruptState) ArmEnableInterrupts();
- return RETURN_SUCCESS;
+ if (InterruptState)
+ ArmEnableInterrupts();
+ return RETURN_SUCCESS;
}
void ResetFb(void)
{
- // Clear current screen.
- char* Pixels = (void*)FixedPcdGet32(PcdMipiFrameBufferAddress);
- UINTN BgColor = FB_BGRA8888_BLACK;
-
- // Set to black color.
- for (UINTN i = 0; i < gWidth; i++)
- {
- for (UINTN j = 0; j < gHeight; j++)
- {
- BgColor = FB_BGRA8888_BLACK;
- // Set pixel bit
- for (UINTN p = 0; p < (gBpp / 8); p++)
- {
- *Pixels = (unsigned char)BgColor;
- BgColor = BgColor >> 8;
- Pixels++;
- }
- }
- }
+ // Clear current screen.
+ char *Pixels = (void *)FixedPcdGet32(PcdMipiFrameBufferAddress);
+ UINTN BgColor = FB_BGRA8888_BLACK;
+
+ // Set to black color.
+ for (UINTN i = 0; i < gWidth; i++) {
+ for (UINTN j = 0; j < gHeight; j++) {
+ BgColor = FB_BGRA8888_BLACK;
+ // Set pixel bit
+ for (UINTN p = 0; p < (gBpp / 8); p++) {
+ *Pixels = (unsigned char)BgColor;
+ BgColor = BgColor >> 8;
+ Pixels++;
+ }
+ }
+ }
}
void FbConReset(void)
{
- // Reset position.
- m_Position.x = 0;
- m_Position.y = 0;
+ // Reset position.
+ m_Position.x = 0;
+ m_Position.y = 0;
- // Calc max position.
- m_MaxPosition.x = gWidth / (FONT_WIDTH + 1);
- m_MaxPosition.y = (gHeight - 1) / FONT_HEIGHT;
+ // Calc max position.
+ m_MaxPosition.x = gWidth / (FONT_WIDTH + 1);
+ m_MaxPosition.y = (gHeight - 1) / FONT_HEIGHT;
- // Reset color.
- m_Color.Foreground = FB_BGRA8888_WHITE;
- m_Color.Background = FB_BGRA8888_BLACK;
+ // Reset color.
+ m_Color.Foreground = FB_BGRA8888_WHITE;
+ m_Color.Background = FB_BGRA8888_BLACK;
}
-void FbConPutCharWithFactor
-(
- char c,
- int type,
- unsigned scale_factor
-)
+void FbConPutCharWithFactor(char c, int type, unsigned scale_factor)
{
- char* Pixels;
+ char *Pixels;
- if (!m_Initialized) return;
+ if (!m_Initialized)
+ return;
paint:
- if ((unsigned char)c > 127) return;
-
- if ((unsigned char)c < 32)
- {
- if (c == '\n')
- {
- goto newline;
- }
- else if (c == '\r')
- {
- m_Position.x = 0;
- return;
- }
- else
- {
- return;
- }
- }
-
- // Save some space
- if (m_Position.x == 0 && (unsigned char)c == ' ' &&
- type != FBCON_SUBTITLE_MSG &&
- type != FBCON_TITLE_MSG)
- return;
-
- BOOLEAN intstate = ArmGetInterruptState();
- ArmDisableInterrupts();
-
- Pixels = (void*)FixedPcdGet32(PcdMipiFrameBufferAddress);
- Pixels += m_Position.y * ((gBpp / 8) * FONT_HEIGHT * gWidth);
- Pixels += m_Position.x * scale_factor * ((gBpp / 8) * (FONT_WIDTH + 1));
-
- FbConDrawglyph(
- Pixels,
- gWidth,
- (gBpp / 8),
- font5x12 + (c - 32) * 2,
- scale_factor);
-
- m_Position.x++;
-
- if (m_Position.x >= (int)(m_MaxPosition.x / scale_factor)) goto newline;
-
- if (intstate) ArmEnableInterrupts();
- return;
+ if ((unsigned char)c > 127)
+ return;
-newline:
- m_Position.y += scale_factor;
- m_Position.x = 0;
- if (m_Position.y >= m_MaxPosition.y - scale_factor)
- {
- ResetFb();
- FbConFlush();
- m_Position.y = 0;
-
- if (intstate) ArmEnableInterrupts();
- goto paint;
- }
- else
- {
- FbConFlush();
- if (intstate) ArmEnableInterrupts();
- }
+ if ((unsigned char)c < 32) {
+ if (c == '\n') {
+ goto newline;
+ }
+ else if (c == '\r') {
+ m_Position.x = 0;
+ return;
+ }
+ else {
+ return;
+ }
+ }
+
+ // Save some space
+ if (m_Position.x == 0 && (unsigned char)c == ' ' &&
+ type != FBCON_SUBTITLE_MSG && type != FBCON_TITLE_MSG)
+ return;
+
+ BOOLEAN intstate = ArmGetInterruptState();
+ ArmDisableInterrupts();
+
+ Pixels = (void *)FixedPcdGet32(PcdMipiFrameBufferAddress);
+ Pixels += m_Position.y * ((gBpp / 8) * FONT_HEIGHT * gWidth);
+ Pixels += m_Position.x * scale_factor * ((gBpp / 8) * (FONT_WIDTH + 1));
+ FbConDrawglyph(
+ Pixels, gWidth, (gBpp / 8), font5x12 + (c - 32) * 2, scale_factor);
+
+ m_Position.x++;
+
+ if (m_Position.x >= (int)(m_MaxPosition.x / scale_factor))
+ goto newline;
+
+ if (intstate)
+ ArmEnableInterrupts();
+ return;
+
+newline:
+ m_Position.y += scale_factor;
+ m_Position.x = 0;
+ if (m_Position.y >= m_MaxPosition.y - scale_factor) {
+ ResetFb();
+ FbConFlush();
+ m_Position.y = 0;
+
+ if (intstate)
+ ArmEnableInterrupts();
+ goto paint;
+ }
+ else {
+ FbConFlush();
+ if (intstate)
+ ArmEnableInterrupts();
+ }
}
-void FbConDrawglyph
-(
- char *pixels,
- unsigned stride,
- unsigned bpp,
- unsigned *glyph,
- unsigned scale_factor
-)
+void FbConDrawglyph(
+ char *pixels, unsigned stride, unsigned bpp, unsigned *glyph,
+ unsigned scale_factor)
{
- char *bg_pixels = pixels;
- unsigned x, y, i, j, k;
- unsigned data, temp;
- unsigned int fg_color = m_Color.Foreground;
- unsigned int bg_color = m_Color.Background;
- stride -= FONT_WIDTH * scale_factor;
-
- for (y = 0; y < FONT_HEIGHT / 2; ++y)
- {
- for (i = 0; i < scale_factor; i++)
- {
- for (x = 0; x < FONT_WIDTH; ++x)
- {
- for (j = 0; j < scale_factor; j++)
- {
- bg_color = m_Color.Background;
- for (k = 0; k < bpp; k++)
- {
- *bg_pixels = (unsigned char)bg_color;
- bg_color = bg_color >> 8;
- bg_pixels++;
- }
- }
- }
- bg_pixels += (stride * bpp);
- }
- }
-
- for (y = 0; y < FONT_HEIGHT / 2; ++y)
- {
- for (i = 0; i < scale_factor; i++)
- {
- for (x = 0; x < FONT_WIDTH; ++x)
- {
- for (j = 0; j < scale_factor; j++)
- {
- bg_color = m_Color.Background;
- for (k = 0; k < bpp; k++)
- {
- *bg_pixels = (unsigned char)bg_color;
- bg_color = bg_color >> 8;
- bg_pixels++;
- }
- }
- }
- bg_pixels += (stride * bpp);
- }
- }
-
- data = glyph[0];
- for (y = 0; y < FONT_HEIGHT / 2; ++y)
- {
- temp = data;
- for (i = 0; i < scale_factor; i++)
- {
- data = temp;
- for (x = 0; x < FONT_WIDTH; ++x)
- {
- if (data & 1)
- {
- for (j = 0; j < scale_factor; j++)
- {
- fg_color = m_Color.Foreground;
- for (k = 0; k < bpp; k++)
- {
- *pixels = (unsigned char)fg_color;
- fg_color = fg_color >> 8;
- pixels++;
- }
- }
- }
- else
- {
- for (j = 0; j < scale_factor; j++)
- {
- pixels = pixels + bpp;
- }
- }
- data >>= 1;
- }
- pixels += (stride * bpp);
- }
- }
-
- data = glyph[1];
- for (y = 0; y < FONT_HEIGHT / 2; ++y)
- {
- temp = data;
- for (i = 0; i < scale_factor; i++)
- {
- data = temp;
- for (x = 0; x < FONT_WIDTH; ++x)
- {
- if (data & 1)
- {
- for (j = 0; j < scale_factor; j++)
- {
- fg_color = m_Color.Foreground;
- for (k = 0; k < bpp; k++)
- {
- *pixels = (unsigned char)fg_color;
- fg_color = fg_color >> 8;
- pixels++;
- }
- }
- }
- else
- {
- for (j = 0; j < scale_factor; j++)
- {
- pixels = pixels + bpp;
- }
- }
- data >>= 1;
- }
- pixels += (stride * bpp);
- }
- }
+ char * bg_pixels = pixels;
+ unsigned x, y, i, j, k;
+ unsigned data, temp;
+ unsigned int fg_color = m_Color.Foreground;
+ unsigned int bg_color = m_Color.Background;
+ stride -= FONT_WIDTH * scale_factor;
+
+ for (y = 0; y < FONT_HEIGHT / 2; ++y) {
+ for (i = 0; i < scale_factor; i++) {
+ for (x = 0; x < FONT_WIDTH; ++x) {
+ for (j = 0; j < scale_factor; j++) {
+ bg_color = m_Color.Background;
+ for (k = 0; k < bpp; k++) {
+ *bg_pixels = (unsigned char)bg_color;
+ bg_color = bg_color >> 8;
+ bg_pixels++;
+ }
+ }
+ }
+ bg_pixels += (stride * bpp);
+ }
+ }
+
+ for (y = 0; y < FONT_HEIGHT / 2; ++y) {
+ for (i = 0; i < scale_factor; i++) {
+ for (x = 0; x < FONT_WIDTH; ++x) {
+ for (j = 0; j < scale_factor; j++) {
+ bg_color = m_Color.Background;
+ for (k = 0; k < bpp; k++) {
+ *bg_pixels = (unsigned char)bg_color;
+ bg_color = bg_color >> 8;
+ bg_pixels++;
+ }
+ }
+ }
+ bg_pixels += (stride * bpp);
+ }
+ }
+
+ data = glyph[0];
+ for (y = 0; y < FONT_HEIGHT / 2; ++y) {
+ temp = data;
+ for (i = 0; i < scale_factor; i++) {
+ data = temp;
+ for (x = 0; x < FONT_WIDTH; ++x) {
+ if (data & 1) {
+ for (j = 0; j < scale_factor; j++) {
+ fg_color = m_Color.Foreground;
+ for (k = 0; k < bpp; k++) {
+ *pixels = (unsigned char)fg_color;
+ fg_color = fg_color >> 8;
+ pixels++;
+ }
+ }
+ }
+ else {
+ for (j = 0; j < scale_factor; j++) {
+ pixels = pixels + bpp;
+ }
+ }
+ data >>= 1;
+ }
+ pixels += (stride * bpp);
+ }
+ }
+
+ data = glyph[1];
+ for (y = 0; y < FONT_HEIGHT / 2; ++y) {
+ temp = data;
+ for (i = 0; i < scale_factor; i++) {
+ data = temp;
+ for (x = 0; x < FONT_WIDTH; ++x) {
+ if (data & 1) {
+ for (j = 0; j < scale_factor; j++) {
+ fg_color = m_Color.Foreground;
+ for (k = 0; k < bpp; k++) {
+ *pixels = (unsigned char)fg_color;
+ fg_color = fg_color >> 8;
+ pixels++;
+ }
+ }
+ }
+ else {
+ for (j = 0; j < scale_factor; j++) {
+ pixels = pixels + bpp;
+ }
+ }
+ data >>= 1;
+ }
+ pixels += (stride * bpp);
+ }
+ }
}
/* TODO: Take stride into account */
void FbConScrollUp(void)
{
- unsigned short *dst = (void*)FixedPcdGet32(PcdMipiFrameBufferAddress);
- unsigned short *src = dst + (gWidth * FONT_HEIGHT);
- unsigned count = gWidth * (gHeight - FONT_HEIGHT);
-
- while (count--)
- {
- *dst++ = *src++;
- }
-
- count = gWidth * FONT_HEIGHT;
- while (count--)
- {
- *dst++ = m_Color.Background;
- }
-
- FbConFlush();
+ unsigned short *dst = (void *)FixedPcdGet32(PcdMipiFrameBufferAddress);
+ unsigned short *src = dst + (gWidth * FONT_HEIGHT);
+ unsigned count = gWidth * (gHeight - FONT_HEIGHT);
+
+ while (count--) {
+ *dst++ = *src++;
+ }
+
+ count = gWidth * FONT_HEIGHT;
+ while (count--) {
+ *dst++ = m_Color.Background;
+ }
+
+ FbConFlush();
}
void FbConFlush(void)
{
- unsigned total_x, total_y;
- unsigned bytes_per_bpp;
+ unsigned total_x, total_y;
+ unsigned bytes_per_bpp;
- total_x = gWidth;
- total_y = gHeight;
- bytes_per_bpp = (gBpp / 8);
+ total_x = gWidth;
+ total_y = gHeight;
+ bytes_per_bpp = (gBpp / 8);
- WriteBackInvalidateDataCacheRange(
- (void*)FixedPcdGet32(PcdMipiFrameBufferAddress),
- (total_x * total_y * bytes_per_bpp)
- );
+ WriteBackInvalidateDataCacheRange(
+ (void *)FixedPcdGet32(PcdMipiFrameBufferAddress),
+ (total_x * total_y * bytes_per_bpp));
}
UINTN
EFIAPI
-SerialPortWrite
-(
- IN UINT8 *Buffer,
- IN UINTN NumberOfBytes
-)
+SerialPortWrite(IN UINT8 *Buffer, IN UINTN NumberOfBytes)
{
- UINT8* CONST Final = &Buffer[NumberOfBytes];
- UINTN InterruptState = ArmGetInterruptState();
- ArmDisableInterrupts();
+ UINT8 *CONST Final = &Buffer[NumberOfBytes];
+ UINTN InterruptState = ArmGetInterruptState();
+ ArmDisableInterrupts();
- while (Buffer < Final)
- {
- FbConPutCharWithFactor(*Buffer++, FBCON_COMMON_MSG, SCALE_FACTOR);
- }
+ while (Buffer < Final) {
+ FbConPutCharWithFactor(*Buffer++, FBCON_COMMON_MSG, SCALE_FACTOR);
+ }
- if (InterruptState) ArmEnableInterrupts();
- return NumberOfBytes;
+ if (InterruptState)
+ ArmEnableInterrupts();
+ return NumberOfBytes;
}
UINTN
EFIAPI
-SerialPortWriteCritical
-(
- IN UINT8 *Buffer,
- IN UINTN NumberOfBytes
-)
+SerialPortWriteCritical(IN UINT8 *Buffer, IN UINTN NumberOfBytes)
{
- UINT8* CONST Final = &Buffer[NumberOfBytes];
- UINTN CurrentForeground = m_Color.Foreground;
- UINTN InterruptState = ArmGetInterruptState();
+ UINT8 *CONST Final = &Buffer[NumberOfBytes];
+ UINTN CurrentForeground = m_Color.Foreground;
+ UINTN InterruptState = ArmGetInterruptState();
- ArmDisableInterrupts();
- m_Color.Foreground = FB_BGRA8888_YELLOW;
+ ArmDisableInterrupts();
+ m_Color.Foreground = FB_BGRA8888_YELLOW;
- while (Buffer < Final)
- {
- FbConPutCharWithFactor(*Buffer++, FBCON_COMMON_MSG, SCALE_FACTOR);
- }
+ while (Buffer < Final) {
+ FbConPutCharWithFactor(*Buffer++, FBCON_COMMON_MSG, SCALE_FACTOR);
+ }
- m_Color.Foreground = CurrentForeground;
+ m_Color.Foreground = CurrentForeground;
- if (InterruptState) ArmEnableInterrupts();
- return NumberOfBytes;
+ if (InterruptState)
+ ArmEnableInterrupts();
+ return NumberOfBytes;
}
UINTN
EFIAPI
-SerialPortRead
-(
- OUT UINT8 *Buffer,
- IN UINTN NumberOfBytes
-)
-{
- return 0;
-}
+SerialPortRead(OUT UINT8 *Buffer, IN UINTN NumberOfBytes) { return 0; }
BOOLEAN
EFIAPI
-SerialPortPoll
-(
- VOID
-)
-{
- return FALSE;
-}
+SerialPortPoll(VOID) { return FALSE; }
RETURN_STATUS
EFIAPI
-SerialPortSetControl
-(
- IN UINT32 Control
-)
-{
- return RETURN_UNSUPPORTED;
-}
+SerialPortSetControl(IN UINT32 Control) { return RETURN_UNSUPPORTED; }
RETURN_STATUS
EFIAPI
-SerialPortGetControl
-(
- OUT UINT32 *Control
-)
-{
- return RETURN_UNSUPPORTED;
-}
+SerialPortGetControl(OUT UINT32 *Control) { return RETURN_UNSUPPORTED; }
RETURN_STATUS
EFIAPI
-SerialPortSetAttributes
-(
- IN OUT UINT64 *BaudRate,
- IN OUT UINT32 *ReceiveFifoDepth,
- IN OUT UINT32 *Timeout,
- IN OUT EFI_PARITY_TYPE *Parity,
- IN OUT UINT8 *DataBits,
- IN OUT EFI_STOP_BITS_TYPE *StopBits
-)
+SerialPortSetAttributes(
+ IN OUT UINT64 *BaudRate, IN OUT UINT32 *ReceiveFifoDepth,
+ IN OUT UINT32 *Timeout, IN OUT EFI_PARITY_TYPE *Parity,
+ IN OUT UINT8 *DataBits, IN OUT EFI_STOP_BITS_TYPE *StopBits)
{
- return RETURN_UNSUPPORTED;
+ return RETURN_UNSUPPORTED;
}
-UINTN SerialPortFlush(VOID)
-{
- return 0;
-}
+UINTN SerialPortFlush(VOID) { return 0; }
-VOID
-EnableSynchronousSerialPortIO(VOID)
+VOID EnableSynchronousSerialPortIO(VOID)
{
- // Already synchronous
+ // Already synchronous
}
\ No newline at end of file
#define _FRAMEBUFFER_SERIALPORT_LIB_H_
typedef struct _FBCON_POSITION {
- INTN x;
- INTN y;
+ INTN x;
+ INTN y;
} FBCON_POSITION, *PFBCON_POSITION;
typedef struct _FBCON_COLOR {
- UINTN Foreground;
- UINTN Background;
+ UINTN Foreground;
+ UINTN Background;
} FBCON_COLOR, *PFBCON_COLOR;
enum FbConMsgType {
- /* type for menu */
- FBCON_COMMON_MSG = 0,
- FBCON_UNLOCK_TITLE_MSG,
- FBCON_TITLE_MSG,
- FBCON_SUBTITLE_MSG,
-
- /* type for warning */
- FBCON_YELLOW_MSG,
- FBCON_ORANGE_MSG,
- FBCON_RED_MSG,
- FBCON_GREEN_MSG,
-
- /* and the select message's background */
- FBCON_SELECT_MSG_BG_COLOR,
+ /* type for menu */
+ FBCON_COMMON_MSG = 0,
+ FBCON_UNLOCK_TITLE_MSG,
+ FBCON_TITLE_MSG,
+ FBCON_SUBTITLE_MSG,
+
+ /* type for warning */
+ FBCON_YELLOW_MSG,
+ FBCON_ORANGE_MSG,
+ FBCON_RED_MSG,
+ FBCON_GREEN_MSG,
+
+ /* and the select message's background */
+ FBCON_SELECT_MSG_BG_COLOR,
};
void ResetFb(void);
UINTN
EFIAPI
-SerialPortWriteCritical
-(
- IN UINT8 *Buffer,
- IN UINTN NumberOfBytes
-);
+SerialPortWriteCritical(IN UINT8 *Buffer, IN UINTN NumberOfBytes);
#endif
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php.
+ are licensed and made available under the terms and conditions of the BSD
+License which accompanies this distribution. The full text of the license may
+be found at http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
-
#include <Base.h>
-#include <Library/SerialPortLib.h>
#include <Library/CacheMaintenanceLib.h>
+#include <Library/SerialPortLib.h>
/**
Initialize the serial device hardware.
If no initialization is required, then return RETURN_SUCCESS.
If the serial device was successfully initialized, then return RETURN_SUCCESS.
- If the serial device could not be initialized, then return RETURN_DEVICE_ERROR.
+ If the serial device could not be initialized, then return
+RETURN_DEVICE_ERROR.
@retval RETURN_SUCCESS The serial device was initialized.
@retval RETURN_DEVICE_ERROR The serial device could not be initialized.
**/
RETURN_STATUS
EFIAPI
-SerialPortInitialize (
- VOID
- )
+SerialPortInitialize(VOID)
{
#if 0
UINT8* base = (UINT8*)0xa1a10000ull;
return RETURN_SUCCESS;
}
-static void mem_putchar(UINT8 c) {
- static const UINTN size = 0x200000;
- static UINTN offset = 0;
- UINT8* base = (UINT8*)0xa1a10000ull;
- base[offset++] = c;
+static void mem_putchar(UINT8 c)
+{
+ static const UINTN size = 0x200000;
+ static UINTN offset = 0;
+ UINT8 * base = (UINT8 *)0xa1a10000ull;
+ base[offset++] = c;
if (offset >= size) {
offset = 0;
}
Writes NumberOfBytes data bytes from Buffer to the serial device.
The number of bytes actually written to the serial device is returned.
- If the return value is less than NumberOfBytes, then the write operation failed.
- If Buffer is NULL, then ASSERT().
- If NumberOfBytes is zero, then return 0.
+ If the return value is less than NumberOfBytes, then the write operation
+failed. If Buffer is NULL, then ASSERT(). If NumberOfBytes is zero, then return
+0.
@param Buffer The pointer to the data buffer to be written.
@param NumberOfBytes The number of bytes to written to the serial device.
@retval 0 NumberOfBytes is 0.
@retval >0 The number of bytes written to the serial device.
- If this value is less than NumberOfBytes, then the write operation failed.
+ If this value is less than NumberOfBytes, then the
+write operation failed.
**/
UINTN
EFIAPI
-SerialPortWrite (
- IN UINT8 *Buffer,
- IN UINTN NumberOfBytes
-)
+SerialPortWrite(IN UINT8 *Buffer, IN UINTN NumberOfBytes)
{
for (UINTN i = 0; i < NumberOfBytes; i++) {
mem_putchar(Buffer[i]);
return NumberOfBytes;
}
-
/**
Read data from serial device and save the datas in buffer.
Reads NumberOfBytes data bytes from a serial device into the buffer
specified by Buffer. The number of bytes actually read is returned.
- If the return value is less than NumberOfBytes, then the rest operation failed.
- If Buffer is NULL, then ASSERT().
- If NumberOfBytes is zero, then return 0.
+ If the return value is less than NumberOfBytes, then the rest operation
+failed. If Buffer is NULL, then ASSERT(). If NumberOfBytes is zero, then return
+0.
- @param Buffer The pointer to the data buffer to store the data read from the serial device.
+ @param Buffer The pointer to the data buffer to store the data read
+from the serial device.
@param NumberOfBytes The number of bytes which will be read.
@retval 0 Read data failed; No data is to be read.
**/
UINTN
EFIAPI
-SerialPortRead (
- OUT UINT8 *Buffer,
- IN UINTN NumberOfBytes
-)
-{
- return 0;
-}
+SerialPortRead(OUT UINT8 *Buffer, IN UINTN NumberOfBytes) { return 0; }
/**
Polls a serial device to see if there is any data waiting to be read.
Polls a serial device to see if there is any data waiting to be read.
- If there is data waiting to be read from the serial device, then TRUE is returned.
- If there is no data waiting to be read from the serial device, then FALSE is returned.
+ If there is data waiting to be read from the serial device, then TRUE is
+returned. If there is no data waiting to be read from the serial device, then
+FALSE is returned.
@retval TRUE Data is waiting to be read from the serial device.
- @retval FALSE There is no data waiting to be read from the serial device.
+ @retval FALSE There is no data waiting to be read from the serial
+device.
**/
BOOLEAN
EFIAPI
-SerialPortPoll (
- VOID
- )
-{
- return FALSE;
-}
+SerialPortPoll(VOID) { return FALSE; }
/**
Sets the control bits on a serial device.
@param Control Sets the bits of Control that are settable.
- @retval RETURN_SUCCESS The new control bits were set on the serial device.
- @retval RETURN_UNSUPPORTED The serial device does not support this operation.
+ @retval RETURN_SUCCESS The new control bits were set on the serial
+device.
+ @retval RETURN_UNSUPPORTED The serial device does not support this
+operation.
@retval RETURN_DEVICE_ERROR The serial device is not functioning correctly.
**/
RETURN_STATUS
EFIAPI
-SerialPortSetControl (
- IN UINT32 Control
- )
-{
- return RETURN_UNSUPPORTED;
-}
+SerialPortSetControl(IN UINT32 Control) { return RETURN_UNSUPPORTED; }
/**
Retrieve the status of the control bits on a serial device.
- @param Control A pointer to return the current control signals from the serial device.
+ @param Control A pointer to return the current control signals
+from the serial device.
- @retval RETURN_SUCCESS The control bits were read from the serial device.
- @retval RETURN_UNSUPPORTED The serial device does not support this operation.
+ @retval RETURN_SUCCESS The control bits were read from the serial
+device.
+ @retval RETURN_UNSUPPORTED The serial device does not support this
+operation.
@retval RETURN_DEVICE_ERROR The serial device is not functioning correctly.
**/
RETURN_STATUS
EFIAPI
-SerialPortGetControl (
- OUT UINT32 *Control
- )
-{
- return RETURN_UNSUPPORTED;
-}
+SerialPortGetControl(OUT UINT32 *Control) { return RETURN_UNSUPPORTED; }
/**
Sets the baud rate, receive FIFO depth, transmit/receice time out, parity,
data bits, and stop bits on a serial device.
- @param BaudRate The requested baud rate. A BaudRate value of 0 will use the
- device's default interface speed.
- On output, the value actually set.
- @param ReveiveFifoDepth The requested depth of the FIFO on the receive side of the
- serial interface. A ReceiveFifoDepth value of 0 will use
- the device's default FIFO depth.
- On output, the value actually set.
- @param Timeout The requested time out for a single character in microseconds.
- This timeout applies to both the transmit and receive side of the
- interface. A Timeout value of 0 will use the device's default time
- out value.
- On output, the value actually set.
- @param Parity The type of parity to use on this serial device. A Parity value of
- DefaultParity will use the device's default parity value.
- On output, the value actually set.
- @param DataBits The number of data bits to use on the serial device. A DataBits
- vaule of 0 will use the device's default data bit setting.
- On output, the value actually set.
- @param StopBits The number of stop bits to use on this serial device. A StopBits
- value of DefaultStopBits will use the device's default number of
- stop bits.
- On output, the value actually set.
-
- @retval RETURN_SUCCESS The new attributes were set on the serial device.
- @retval RETURN_UNSUPPORTED The serial device does not support this operation.
- @retval RETURN_INVALID_PARAMETER One or more of the attributes has an unsupported value.
- @retval RETURN_DEVICE_ERROR The serial device is not functioning correctly.
+ @param BaudRate The requested baud rate. A BaudRate value of 0 will
+use the device's default interface speed. On output, the value actually set.
+ @param ReveiveFifoDepth The requested depth of the FIFO on the receive side
+of the serial interface. A ReceiveFifoDepth value of 0 will use the device's
+default FIFO depth. On output, the value actually set.
+ @param Timeout The requested time out for a single character in
+microseconds. This timeout applies to both the transmit and receive side of the
+ interface. A Timeout value of 0 will use the
+device's default time out value. On output, the value actually set.
+ @param Parity The type of parity to use on this serial device. A
+Parity value of DefaultParity will use the device's default parity value. On
+output, the value actually set.
+ @param DataBits The number of data bits to use on the serial device.
+A DataBits vaule of 0 will use the device's default data bit setting. On output,
+the value actually set.
+ @param StopBits The number of stop bits to use on this serial
+device. A StopBits value of DefaultStopBits will use the device's default number
+of stop bits. On output, the value actually set.
+
+ @retval RETURN_SUCCESS The new attributes were set on the serial
+device.
+ @retval RETURN_UNSUPPORTED The serial device does not support this
+operation.
+ @retval RETURN_INVALID_PARAMETER One or more of the attributes has an
+unsupported value.
+ @retval RETURN_DEVICE_ERROR The serial device is not functioning
+correctly.
**/
RETURN_STATUS
EFIAPI
-SerialPortSetAttributes (
- IN OUT UINT64 *BaudRate,
- IN OUT UINT32 *ReceiveFifoDepth,
- IN OUT UINT32 *Timeout,
- IN OUT EFI_PARITY_TYPE *Parity,
- IN OUT UINT8 *DataBits,
- IN OUT EFI_STOP_BITS_TYPE *StopBits
- )
+SerialPortSetAttributes(
+ IN OUT UINT64 *BaudRate, IN OUT UINT32 *ReceiveFifoDepth,
+ IN OUT UINT32 *Timeout, IN OUT EFI_PARITY_TYPE *Parity,
+ IN OUT UINT8 *DataBits, IN OUT EFI_STOP_BITS_TYPE *StopBits)
{
return RETURN_UNSUPPORTED;
}
-
PARM_MEMORY_REGION_DESCRIPTOR_EX MemoryDescriptorEx =
gDeviceMemoryDescriptorEx;
ARM_MEMORY_REGION_DESCRIPTOR
- MemoryDescriptor[MAX_ARM_MEMORY_REGION_DESCRIPTOR_COUNT];
+ MemoryDescriptor[MAX_ARM_MEMORY_REGION_DESCRIPTOR_COUNT];
UINTN Index = 0;
// Ensure PcdSystemMemorySize has been set
**/
+#include <Guid/EventGroup.h>
+#include <Guid/SerialPortLibVendor.h>
+#include <Guid/TtyTerm.h>
#include <IndustryStandard/Pci22.h>
#include <Library/BootLogoLib.h>
#include <Library/CapsuleLib.h>
#include <Protocol/PciIo.h>
#include <Protocol/PciRootBridgeIo.h>
#include <Protocol/PlatformBootManager.h>
-#include <Guid/EventGroup.h>
-#include <Guid/TtyTerm.h>
-#include <Guid/SerialPortLibVendor.h>
#include "PlatformBm.h"
+#define DP_NODE_LEN(Type) \
+ { \
+ (UINT8)sizeof(Type), (UINT8)(sizeof(Type) >> 8) \
+ }
-
-#define DP_NODE_LEN(Type) { (UINT8)sizeof (Type), (UINT8)(sizeof (Type) >> 8) }
-
-#pragma pack (1)
+#pragma pack(1)
typedef struct {
VENDOR_DEVICE_PATH SerialDxe;
UART_DEVICE_PATH Uart;
VENDOR_DEFINED_DEVICE_PATH TermType;
EFI_DEVICE_PATH_PROTOCOL End;
} PLATFORM_SERIAL_CONSOLE;
-#pragma pack ()
+#pragma pack()
STATIC PLATFORM_SERIAL_CONSOLE mSerialConsole = {
- //
- // VENDOR_DEVICE_PATH SerialDxe
- //
- {
- { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DP_NODE_LEN (VENDOR_DEVICE_PATH) },
- EDKII_SERIAL_PORT_LIB_VENDOR_GUID
- },
-
- //
- // UART_DEVICE_PATH Uart
- //
- {
- { MESSAGING_DEVICE_PATH, MSG_UART_DP, DP_NODE_LEN (UART_DEVICE_PATH) },
- 0, // Reserved
- FixedPcdGet64 (PcdUartDefaultBaudRate), // BaudRate
- FixedPcdGet8 (PcdUartDefaultDataBits), // DataBits
- FixedPcdGet8 (PcdUartDefaultParity), // Parity
- FixedPcdGet8 (PcdUartDefaultStopBits) // StopBits
- },
+ //
+ // VENDOR_DEVICE_PATH SerialDxe
+ //
+ {{HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DP_NODE_LEN(VENDOR_DEVICE_PATH)},
+ EDKII_SERIAL_PORT_LIB_VENDOR_GUID},
- //
- // VENDOR_DEFINED_DEVICE_PATH TermType
- //
- {
- {
- MESSAGING_DEVICE_PATH, MSG_VENDOR_DP,
- DP_NODE_LEN (VENDOR_DEFINED_DEVICE_PATH)
- }
//
- // Guid to be filled in dynamically
+ // UART_DEVICE_PATH Uart
//
- },
+ {
+ {MESSAGING_DEVICE_PATH, MSG_UART_DP, DP_NODE_LEN(UART_DEVICE_PATH)},
+ 0, // Reserved
+ FixedPcdGet64(PcdUartDefaultBaudRate), // BaudRate
+ FixedPcdGet8(PcdUartDefaultDataBits), // DataBits
+ FixedPcdGet8(PcdUartDefaultParity), // Parity
+ FixedPcdGet8(PcdUartDefaultStopBits) // StopBits
+ },
- //
- // EFI_DEVICE_PATH_PROTOCOL End
- //
- {
- END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE,
- DP_NODE_LEN (EFI_DEVICE_PATH_PROTOCOL)
- }
-};
+ //
+ // VENDOR_DEFINED_DEVICE_PATH TermType
+ //
+ {
+ {MESSAGING_DEVICE_PATH, MSG_VENDOR_DP,
+ DP_NODE_LEN(VENDOR_DEFINED_DEVICE_PATH)}
+ //
+ // Guid to be filled in dynamically
+ //
+ },
+ //
+ // EFI_DEVICE_PATH_PROTOCOL End
+ //
+ {END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE,
+ DP_NODE_LEN(EFI_DEVICE_PATH_PROTOCOL)}};
-#pragma pack (1)
+#pragma pack(1)
typedef struct {
USB_CLASS_DEVICE_PATH Keyboard;
EFI_DEVICE_PATH_PROTOCOL End;
} PLATFORM_USB_KEYBOARD;
-#pragma pack ()
+#pragma pack()
STATIC PLATFORM_USB_KEYBOARD mUsbKeyboard = {
- //
- // USB_CLASS_DEVICE_PATH Keyboard
- //
- {
+ //
+ // USB_CLASS_DEVICE_PATH Keyboard
+ //
{
- MESSAGING_DEVICE_PATH, MSG_USB_CLASS_DP,
- DP_NODE_LEN (USB_CLASS_DEVICE_PATH)
+ {MESSAGING_DEVICE_PATH, MSG_USB_CLASS_DP,
+ DP_NODE_LEN(USB_CLASS_DEVICE_PATH)},
+ 0xFFFF, // VendorId: any
+ 0xFFFF, // ProductId: any
+ 3, // DeviceClass: HID
+ 1, // DeviceSubClass: boot
+ 1 // DeviceProtocol: keyboard
},
- 0xFFFF, // VendorId: any
- 0xFFFF, // ProductId: any
- 3, // DeviceClass: HID
- 1, // DeviceSubClass: boot
- 1 // DeviceProtocol: keyboard
- },
-
- //
- // EFI_DEVICE_PATH_PROTOCOL End
- //
- {
- END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE,
- DP_NODE_LEN (EFI_DEVICE_PATH_PROTOCOL)
- }
-};
+ //
+ // EFI_DEVICE_PATH_PROTOCOL End
+ //
+ {END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE,
+ DP_NODE_LEN(EFI_DEVICE_PATH_PROTOCOL)}};
/**
Check if the handle satisfies a particular condition.
@retval FALSE Otherwise. This includes the case when the condition could not
be fully evaluated due to an error.
**/
-typedef
-BOOLEAN
-(EFIAPI *FILTER_FUNCTION) (
- IN EFI_HANDLE Handle,
- IN CONST CHAR16 *ReportText
- );
-
+typedef BOOLEAN(EFIAPI *FILTER_FUNCTION)(
+ IN EFI_HANDLE Handle, IN CONST CHAR16 *ReportText);
/**
Process a handle.
@param[in] ReportText A caller-allocated string passed in for reporting
purposes. It must never be NULL.
**/
-typedef
-VOID
-(EFIAPI *CALLBACK_FUNCTION) (
- IN EFI_HANDLE Handle,
- IN CONST CHAR16 *ReportText
- );
+typedef VOID(EFIAPI *CALLBACK_FUNCTION)(
+ IN EFI_HANDLE Handle, IN CONST CHAR16 *ReportText);
/**
Locate all handles that carry the specified protocol, filter them with a
clears the filter.
**/
STATIC
-VOID
-FilterAndProcess (
- IN EFI_GUID *ProtocolGuid,
- IN FILTER_FUNCTION Filter OPTIONAL,
- IN CALLBACK_FUNCTION Process
- )
+VOID FilterAndProcess(
+ IN EFI_GUID *ProtocolGuid, IN FILTER_FUNCTION Filter OPTIONAL,
+ IN CALLBACK_FUNCTION Process)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
EFI_HANDLE *Handles;
- UINTN NoHandles;
- UINTN Idx;
+ UINTN NoHandles;
+ UINTN Idx;
- Status = gBS->LocateHandleBuffer (ByProtocol, ProtocolGuid,
- NULL /* SearchKey */, &NoHandles, &Handles);
- if (EFI_ERROR (Status)) {
+ Status = gBS->LocateHandleBuffer(
+ ByProtocol, ProtocolGuid, NULL /* SearchKey */, &NoHandles, &Handles);
+ if (EFI_ERROR(Status)) {
//
// This is not an error, just an informative condition.
//
- DEBUG ((EFI_D_VERBOSE, "%a: %g: %r\n", __FUNCTION__, ProtocolGuid,
- Status));
+ DEBUG((EFI_D_VERBOSE, "%a: %g: %r\n", __FUNCTION__, ProtocolGuid, Status));
return;
}
- ASSERT (NoHandles > 0);
+ ASSERT(NoHandles > 0);
for (Idx = 0; Idx < NoHandles; ++Idx) {
- CHAR16 *DevicePathText;
+ CHAR16 * DevicePathText;
STATIC CHAR16 Fallback[] = L"<device path unavailable>";
//
// The ConvertDevicePathToText() function handles NULL input transparently.
//
- DevicePathText = ConvertDevicePathToText (
- DevicePathFromHandle (Handles[Idx]),
- FALSE, // DisplayOnly
- FALSE // AllowShortcuts
- );
+ DevicePathText = ConvertDevicePathToText(
+ DevicePathFromHandle(Handles[Idx]),
+ FALSE, // DisplayOnly
+ FALSE // AllowShortcuts
+ );
if (DevicePathText == NULL) {
DevicePathText = Fallback;
}
- if (Filter == NULL || Filter (Handles[Idx], DevicePathText)) {
- Process (Handles[Idx], DevicePathText);
+ if (Filter == NULL || Filter(Handles[Idx], DevicePathText)) {
+ Process(Handles[Idx], DevicePathText);
}
if (DevicePathText != Fallback) {
- FreePool (DevicePathText);
+ FreePool(DevicePathText);
}
}
- gBS->FreePool (Handles);
+ gBS->FreePool(Handles);
}
-
/**
This FILTER_FUNCTION checks if a handle corresponds to a PCI display device.
**/
STATIC
BOOLEAN
EFIAPI
-IsPciDisplay (
- IN EFI_HANDLE Handle,
- IN CONST CHAR16 *ReportText
- )
+IsPciDisplay(IN EFI_HANDLE Handle, IN CONST CHAR16 *ReportText)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
EFI_PCI_IO_PROTOCOL *PciIo;
- PCI_TYPE00 Pci;
+ PCI_TYPE00 Pci;
- Status = gBS->HandleProtocol (Handle, &gEfiPciIoProtocolGuid,
- (VOID**)&PciIo);
- if (EFI_ERROR (Status)) {
+ Status = gBS->HandleProtocol(Handle, &gEfiPciIoProtocolGuid, (VOID **)&PciIo);
+ if (EFI_ERROR(Status)) {
//
// This is not an error worth reporting.
//
return FALSE;
}
- Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint32, 0 /* Offset */,
- sizeof Pci / sizeof (UINT32), &Pci);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "%a: %s: %r\n", __FUNCTION__, ReportText, Status));
+ Status = PciIo->Pci.Read(
+ PciIo, EfiPciIoWidthUint32, 0 /* Offset */, sizeof Pci / sizeof(UINT32),
+ &Pci);
+ if (EFI_ERROR(Status)) {
+ DEBUG((EFI_D_ERROR, "%a: %s: %r\n", __FUNCTION__, ReportText, Status));
return FALSE;
}
- return IS_PCI_DISPLAY (&Pci);
+ return IS_PCI_DISPLAY(&Pci);
}
-
/**
This CALLBACK_FUNCTION attempts to connect a handle non-recursively, asking
the matching driver to produce all first-level child handles.
**/
STATIC
-VOID
-EFIAPI
-Connect (
- IN EFI_HANDLE Handle,
- IN CONST CHAR16 *ReportText
- )
+VOID EFIAPI Connect(IN EFI_HANDLE Handle, IN CONST CHAR16 *ReportText)
{
EFI_STATUS Status;
- Status = gBS->ConnectController (
- Handle, // ControllerHandle
- NULL, // DriverImageHandle
- NULL, // RemainingDevicePath -- produce all children
- FALSE // Recursive
- );
- DEBUG ((EFI_ERROR (Status) ? EFI_D_ERROR : EFI_D_VERBOSE, "%a: %s: %r\n",
- __FUNCTION__, ReportText, Status));
+ Status = gBS->ConnectController(
+ Handle, // ControllerHandle
+ NULL, // DriverImageHandle
+ NULL, // RemainingDevicePath -- produce all children
+ FALSE // Recursive
+ );
+ DEBUG(
+ (EFI_ERROR(Status) ? EFI_D_ERROR : EFI_D_VERBOSE, "%a: %s: %r\n",
+ __FUNCTION__, ReportText, Status));
}
-
/**
This CALLBACK_FUNCTION retrieves the EFI_DEVICE_PATH_PROTOCOL from the
handle, and adds it to ConOut and ErrOut.
**/
STATIC
-VOID
-EFIAPI
-AddOutput (
- IN EFI_HANDLE Handle,
- IN CONST CHAR16 *ReportText
- )
+VOID EFIAPI AddOutput(IN EFI_HANDLE Handle, IN CONST CHAR16 *ReportText)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- DevicePath = DevicePathFromHandle (Handle);
+ DevicePath = DevicePathFromHandle(Handle);
if (DevicePath == NULL) {
- DEBUG ((EFI_D_ERROR, "%a: %s: handle %p: device path not found\n",
- __FUNCTION__, ReportText, Handle));
+ DEBUG(
+ (EFI_D_ERROR, "%a: %s: handle %p: device path not found\n",
+ __FUNCTION__, ReportText, Handle));
return;
}
- Status = EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "%a: %s: adding to ConOut: %r\n", __FUNCTION__,
- ReportText, Status));
+ Status = EfiBootManagerUpdateConsoleVariable(ConOut, DevicePath, NULL);
+ if (EFI_ERROR(Status)) {
+ DEBUG(
+ (EFI_D_ERROR, "%a: %s: adding to ConOut: %r\n", __FUNCTION__,
+ ReportText, Status));
return;
}
- Status = EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "%a: %s: adding to ErrOut: %r\n", __FUNCTION__,
- ReportText, Status));
+ Status = EfiBootManagerUpdateConsoleVariable(ErrOut, DevicePath, NULL);
+ if (EFI_ERROR(Status)) {
+ DEBUG(
+ (EFI_D_ERROR, "%a: %s: adding to ErrOut: %r\n", __FUNCTION__,
+ ReportText, Status));
return;
}
- DEBUG ((EFI_D_VERBOSE, "%a: %s: added to ConOut and ErrOut\n", __FUNCTION__,
- ReportText));
+ DEBUG(
+ (EFI_D_VERBOSE, "%a: %s: added to ConOut and ErrOut\n", __FUNCTION__,
+ ReportText));
}
STATIC
UINT16
-PlatformRegisterFvBootOption (
- CONST EFI_GUID *FileGuid,
- CHAR16 *Description,
- UINT32 Attributes
- )
+PlatformRegisterFvBootOption(
+ CONST EFI_GUID *FileGuid, CHAR16 *Description, UINT32 Attributes)
{
EFI_STATUS Status;
INTN OptionIndex;
EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
- EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
+ EFI_BOOT_MANAGER_LOAD_OPTION * BootOptions;
UINTN BootOptionCount;
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
- EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_LOADED_IMAGE_PROTOCOL * LoadedImage;
+ EFI_DEVICE_PATH_PROTOCOL * DevicePath;
UINT16 OptionNumber;
- Status = gBS->HandleProtocol (
- gImageHandle,
- &gEfiLoadedImageProtocolGuid,
- (VOID **) &LoadedImage
- );
- ASSERT_EFI_ERROR (Status);
-
- EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);
- DevicePath = DevicePathFromHandle (LoadedImage->DeviceHandle);
- ASSERT (DevicePath != NULL);
- DevicePath = AppendDevicePathNode (
- DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
- );
- ASSERT (DevicePath != NULL);
-
- Status = EfiBootManagerInitializeLoadOption (
- &NewOption,
- LoadOptionNumberUnassigned,
- LoadOptionTypeBoot,
- Attributes,
- Description,
- DevicePath,
- NULL,
- 0
- );
- ASSERT_EFI_ERROR (Status);
- FreePool (DevicePath);
-
- BootOptions = EfiBootManagerGetLoadOptions (
- &BootOptionCount, LoadOptionTypeBoot
- );
-
- OptionIndex = EfiBootManagerFindLoadOption (
- &NewOption, BootOptions, BootOptionCount
- );
+ Status = gBS->HandleProtocol(
+ gImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **)&LoadedImage);
+ ASSERT_EFI_ERROR(Status);
+
+ EfiInitializeFwVolDevicepathNode(&FileNode, FileGuid);
+ DevicePath = DevicePathFromHandle(LoadedImage->DeviceHandle);
+ ASSERT(DevicePath != NULL);
+ DevicePath =
+ AppendDevicePathNode(DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&FileNode);
+ ASSERT(DevicePath != NULL);
+
+ Status = EfiBootManagerInitializeLoadOption(
+ &NewOption, LoadOptionNumberUnassigned, LoadOptionTypeBoot, Attributes,
+ Description, DevicePath, NULL, 0);
+ ASSERT_EFI_ERROR(Status);
+ FreePool(DevicePath);
+
+ BootOptions =
+ EfiBootManagerGetLoadOptions(&BootOptionCount, LoadOptionTypeBoot);
+
+ OptionIndex =
+ EfiBootManagerFindLoadOption(&NewOption, BootOptions, BootOptionCount);
if (OptionIndex == -1) {
- Status = EfiBootManagerAddLoadOptionVariable (&NewOption, MAX_UINTN);
- ASSERT_EFI_ERROR (Status);
+ Status = EfiBootManagerAddLoadOptionVariable(&NewOption, MAX_UINTN);
+ ASSERT_EFI_ERROR(Status);
}
OptionNumber = NewOption.OptionNumber;
- EfiBootManagerFreeLoadOption (&NewOption);
- EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
+ EfiBootManagerFreeLoadOption(&NewOption);
+ EfiBootManagerFreeLoadOptions(BootOptions, BootOptionCount);
return OptionNumber;
}
-
STATIC
-VOID
-GetPlatformOptions (
- VOID
- )
+VOID GetPlatformOptions(VOID)
{
EFI_STATUS Status;
- EFI_BOOT_MANAGER_LOAD_OPTION *CurrentBootOptions;
- EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
- EFI_INPUT_KEY *BootKeys;
- PLATFORM_BOOT_MANAGER_PROTOCOL *PlatformBootManager;
+ EFI_BOOT_MANAGER_LOAD_OPTION * CurrentBootOptions;
+ EFI_BOOT_MANAGER_LOAD_OPTION * BootOptions;
+ EFI_INPUT_KEY * BootKeys;
+ PLATFORM_BOOT_MANAGER_PROTOCOL *PlatformBootManager;
UINTN CurrentBootOptionCount;
UINTN Index;
UINTN BootCount;
- Status = gBS->LocateProtocol (&gPlatformBootManagerProtocolGuid, NULL,
- (VOID **)&PlatformBootManager);
- if (EFI_ERROR (Status)) {
+ Status = gBS->LocateProtocol(
+ &gPlatformBootManagerProtocolGuid, NULL, (VOID **)&PlatformBootManager);
+ if (EFI_ERROR(Status)) {
return;
}
- Status = PlatformBootManager->GetPlatformBootOptionsAndKeys (
- &BootCount,
- &BootOptions,
- &BootKeys
- );
- if (EFI_ERROR (Status)) {
+ Status = PlatformBootManager->GetPlatformBootOptionsAndKeys(
+ &BootCount, &BootOptions, &BootKeys);
+ if (EFI_ERROR(Status)) {
return;
}
//
// Fetch the existent boot options. If there are none, CurrentBootCount
// will be zeroed.
//
- CurrentBootOptions = EfiBootManagerGetLoadOptions (
- &CurrentBootOptionCount,
- LoadOptionTypeBoot
- );
+ CurrentBootOptions =
+ EfiBootManagerGetLoadOptions(&CurrentBootOptionCount, LoadOptionTypeBoot);
//
// Process the platform boot options.
//
for (Index = 0; Index < BootCount; Index++) {
- INTN Match;
- UINTN BootOptionNumber;
+ INTN Match;
+ UINTN BootOptionNumber;
//
// If there are any preexistent boot options, and the subject platform boot
// that EfiBootManagerFindLoadOption() deals fine with (CurrentBootOptions
// == NULL) if (CurrentBootCount == 0).
//
- Match = EfiBootManagerFindLoadOption (
- &BootOptions[Index],
- CurrentBootOptions,
- CurrentBootOptionCount
- );
+ Match = EfiBootManagerFindLoadOption(
+ &BootOptions[Index], CurrentBootOptions, CurrentBootOptionCount);
if (Match >= 0) {
BootOptionNumber = CurrentBootOptions[Match].OptionNumber;
- } else {
+ }
+ else {
//
// Add the platform boot options as a new one, at the end of the boot
// order. Note that if the platform provided this boot option with an
// unassigned option number, then the below function call will assign a
// number.
//
- Status = EfiBootManagerAddLoadOptionVariable (
- &BootOptions[Index],
- MAX_UINTN
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: failed to register \"%s\": %r\n",
- __FUNCTION__, BootOptions[Index].Description, Status));
+ Status =
+ EfiBootManagerAddLoadOptionVariable(&BootOptions[Index], MAX_UINTN);
+ if (EFI_ERROR(Status)) {
+ DEBUG(
+ (DEBUG_ERROR, "%a: failed to register \"%s\": %r\n", __FUNCTION__,
+ BootOptions[Index].Description, Status));
continue;
}
BootOptionNumber = BootOptions[Index].OptionNumber;
continue;
}
- Status = EfiBootManagerAddKeyOptionVariable (
- NULL,
- BootOptionNumber,
- 0,
- &BootKeys[Index],
- NULL
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: failed to register hotkey for \"%s\": %r\n",
- __FUNCTION__, BootOptions[Index].Description, Status));
+ Status = EfiBootManagerAddKeyOptionVariable(
+ NULL, BootOptionNumber, 0, &BootKeys[Index], NULL);
+ if (EFI_ERROR(Status)) {
+ DEBUG(
+ (DEBUG_ERROR, "%a: failed to register hotkey for \"%s\": %r\n",
+ __FUNCTION__, BootOptions[Index].Description, Status));
}
}
- EfiBootManagerFreeLoadOptions (CurrentBootOptions, CurrentBootOptionCount);
- EfiBootManagerFreeLoadOptions (BootOptions, BootCount);
- FreePool (BootKeys);
+ EfiBootManagerFreeLoadOptions(CurrentBootOptions, CurrentBootOptionCount);
+ EfiBootManagerFreeLoadOptions(BootOptions, BootCount);
+ FreePool(BootKeys);
}
-
-
-
STATIC
-VOID
-PlatformRegisterOptionsAndKeys (
- VOID
- )
+VOID PlatformRegisterOptionsAndKeys(VOID)
{
EFI_STATUS Status;
EFI_INPUT_KEY Enter;
EFI_INPUT_KEY Esc;
EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
- GetPlatformOptions ();
+ GetPlatformOptions();
//
// Register ENTER as CONTINUE key
//
Enter.ScanCode = SCAN_NULL;
Enter.UnicodeChar = CHAR_CARRIAGE_RETURN;
- Status = EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL);
- ASSERT_EFI_ERROR (Status);
+ Status = EfiBootManagerRegisterContinueKeyOption(0, &Enter, NULL);
+ ASSERT_EFI_ERROR(Status);
//
// Map UP and ESC to Boot Manager Menu or SimpleInitGUI
UP.UnicodeChar = CHAR_NULL;
Esc.ScanCode = SCAN_ESC;
Esc.UnicodeChar = CHAR_NULL;
- Status = EfiBootManagerGetBootManagerMenu (&BootOption);
- ASSERT_EFI_ERROR (Status);
- #ifdef ENABLE_SIMPLE_INIT
+ Status = EfiBootManagerGetBootManagerMenu(&BootOption);
+ ASSERT_EFI_ERROR(Status);
+#ifdef ENABLE_SIMPLE_INIT
//
// Search all boot options
//
- EfiBootManagerRefreshAllBootOption ();
+ EfiBootManagerRefreshAllBootOption();
//
// Register Simple Init GUI APP
//
- UINT16 OptionSimpleInit = PlatformRegisterFvBootOption (
- &gSimpleInitFileGuid, L"Simple Init", LOAD_OPTION_ACTIVE
- );
- Status = EfiBootManagerAddKeyOptionVariable (
- NULL, (UINT16) OptionSimpleInit, 0, &UP, NULL
- );
- #else
- Status = EfiBootManagerAddKeyOptionVariable (
- NULL, (UINT16) BootOption.OptionNumber, 0, &UP, NULL
- );
- #endif
- ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
- Status = EfiBootManagerAddKeyOptionVariable (
- NULL, (UINT16) BootOption.OptionNumber, 0, &Esc, NULL
- );
- ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
+ UINT16 OptionSimpleInit = PlatformRegisterFvBootOption(
+ &gSimpleInitFileGuid, L"Simple Init", LOAD_OPTION_ACTIVE);
+ Status = EfiBootManagerAddKeyOptionVariable(
+ NULL, (UINT16)OptionSimpleInit, 0, &UP, NULL);
+#else
+ Status = EfiBootManagerAddKeyOptionVariable(
+ NULL, (UINT16)BootOption.OptionNumber, 0, &UP, NULL);
+#endif
+ ASSERT(Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
+ Status = EfiBootManagerAddKeyOptionVariable(
+ NULL, (UINT16)BootOption.OptionNumber, 0, &Esc, NULL);
+ ASSERT(Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
}
-
//
// BDS Platform Functions
//
> Authentication action: 1. connect Auth devices;
> 2. Identify auto logon user.
**/
-VOID
-EFIAPI
-PlatformBootManagerBeforeConsole (
- VOID
- )
+VOID EFIAPI PlatformBootManagerBeforeConsole(VOID)
{
//
// Signal EndOfDxe PI Event
//
- EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);
+ EfiEventGroupSignal(&gEfiEndOfDxeEventGroupGuid);
//
// Dispatch deferred images after EndOfDxe event.
//
- EfiBootManagerDispatchDeferredImages ();
+ EfiBootManagerDispatchDeferredImages();
//
// Locate the PCI root bridges and make the PCI bus driver connect each,
// non-recursively. This will produce a number of child handles with PciIo on
// them.
//
- FilterAndProcess (&gEfiPciRootBridgeIoProtocolGuid, NULL, Connect);
+ FilterAndProcess(&gEfiPciRootBridgeIoProtocolGuid, NULL, Connect);
//
// Find all display class PCI devices (using the handles from the previous
// step), and connect them non-recursively. This should produce a number of
// child handles with GOPs on them.
//
- FilterAndProcess (&gEfiPciIoProtocolGuid, IsPciDisplay, Connect);
+ FilterAndProcess(&gEfiPciIoProtocolGuid, IsPciDisplay, Connect);
//
// Now add the device path of all handles with GOP on them to ConOut and
// ErrOut.
//
- FilterAndProcess (&gEfiGraphicsOutputProtocolGuid, NULL, AddOutput);
+ FilterAndProcess(&gEfiGraphicsOutputProtocolGuid, NULL, AddOutput);
//
// Add the hardcoded short-form USB keyboard device path to ConIn.
//
- EfiBootManagerUpdateConsoleVariable (ConIn,
- (EFI_DEVICE_PATH_PROTOCOL *)&mUsbKeyboard, NULL);
-
- EFI_HANDLE *handles;
- UINTN NoHandles;
+ EfiBootManagerUpdateConsoleVariable(
+ ConIn, (EFI_DEVICE_PATH_PROTOCOL *)&mUsbKeyboard, NULL);
+
+ EFI_HANDLE * handles;
+ UINTN NoHandles;
EFI_DEVICE_PATH_PROTOCOL *devicehandle;
/*CHAR16 *devicepathtxt;*/
- //EfiBootManagerUpdateConsoleVariable(ConIn,
- // (EFI_DEVICE_PATH_PROTOCOL*)&gQcomKeypadDeviceGuid, NULL);
- gBS->LocateHandleBuffer(ByProtocol,&gEfiSimpleTextInputExProtocolGuid,NULL, &NoHandles,&handles);
+ // EfiBootManagerUpdateConsoleVariable(ConIn,
+ // (EFI_DEVICE_PATH_PROTOCOL*)&gQcomKeypadDeviceGuid, NULL);
+ gBS->LocateHandleBuffer(
+ ByProtocol, &gEfiSimpleTextInputExProtocolGuid, NULL, &NoHandles,
+ &handles);
devicehandle = DevicePathFromHandle(handles[1]);
- EfiBootManagerUpdateConsoleVariable (ConIn,
- devicehandle, NULL);/*
- devicepathtxt = ConvertDevicePathToText(devicehandle,TRUE,TRUE);
- DEBUG((DEBUG_ERROR,"There are %s handles\n",devicepathtxt));
- ASSERT(0);*/
-
-
-
+ EfiBootManagerUpdateConsoleVariable(
+ ConIn, devicehandle, NULL); /*
+ devicepathtxt = ConvertDevicePathToText(devicehandle,TRUE,TRUE);
+ DEBUG((DEBUG_ERROR,"There are %s handles\n",devicepathtxt));
+ ASSERT(0);*/
//
// Add the hardcoded serial console device path to ConIn, ConOut, ErrOut.
//
- ASSERT (FixedPcdGet8 (PcdDefaultTerminalType) == 4);
- CopyGuid (&mSerialConsole.TermType.Guid, &gEfiTtyTermGuid);
+ ASSERT(FixedPcdGet8(PcdDefaultTerminalType) == 4);
+ CopyGuid(&mSerialConsole.TermType.Guid, &gEfiTtyTermGuid);
- EfiBootManagerUpdateConsoleVariable (ConIn,
- (EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole, NULL);
- EfiBootManagerUpdateConsoleVariable (ConOut,
- (EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole, NULL);
- EfiBootManagerUpdateConsoleVariable (ErrOut,
- (EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole, NULL);
+ EfiBootManagerUpdateConsoleVariable(
+ ConIn, (EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole, NULL);
+ EfiBootManagerUpdateConsoleVariable(
+ ConOut, (EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole, NULL);
+ EfiBootManagerUpdateConsoleVariable(
+ ErrOut, (EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole, NULL);
//
// Register platform-specific boot options and keyboard shortcuts.
//
- PlatformRegisterOptionsAndKeys ();
+ PlatformRegisterOptionsAndKeys();
}
STATIC
-VOID
-HandleCapsules (
- VOID
- )
+VOID HandleCapsules(VOID)
{
- ESRT_MANAGEMENT_PROTOCOL *EsrtManagement;
- EFI_PEI_HOB_POINTERS HobPointer;
- EFI_CAPSULE_HEADER *CapsuleHeader;
- BOOLEAN NeedReset;
- EFI_STATUS Status;
-
- DEBUG ((DEBUG_INFO, "%a: processing capsules ...\n", __FUNCTION__));
-
- Status = gBS->LocateProtocol (&gEsrtManagementProtocolGuid, NULL,
- (VOID **)&EsrtManagement);
- if (!EFI_ERROR (Status)) {
- EsrtManagement->SyncEsrtFmp ();
+ ESRT_MANAGEMENT_PROTOCOL *EsrtManagement;
+ EFI_PEI_HOB_POINTERS HobPointer;
+ EFI_CAPSULE_HEADER * CapsuleHeader;
+ BOOLEAN NeedReset;
+ EFI_STATUS Status;
+
+ DEBUG((DEBUG_INFO, "%a: processing capsules ...\n", __FUNCTION__));
+
+ Status = gBS->LocateProtocol(
+ &gEsrtManagementProtocolGuid, NULL, (VOID **)&EsrtManagement);
+ if (!EFI_ERROR(Status)) {
+ EsrtManagement->SyncEsrtFmp();
}
//
// Find all capsule images from hob
//
- HobPointer.Raw = GetHobList ();
- NeedReset = FALSE;
- while ((HobPointer.Raw = GetNextHob (EFI_HOB_TYPE_UEFI_CAPSULE,
- HobPointer.Raw)) != NULL) {
+ HobPointer.Raw = GetHobList();
+ NeedReset = FALSE;
+ while ((HobPointer.Raw =
+ GetNextHob(EFI_HOB_TYPE_UEFI_CAPSULE, HobPointer.Raw)) != NULL) {
CapsuleHeader = (VOID *)(UINTN)HobPointer.Capsule->BaseAddress;
- Status = ProcessCapsuleImage (CapsuleHeader);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: failed to process capsule %p - %r\n",
- __FUNCTION__, CapsuleHeader, Status));
+ Status = ProcessCapsuleImage(CapsuleHeader);
+ if (EFI_ERROR(Status)) {
+ DEBUG(
+ (DEBUG_ERROR, "%a: failed to process capsule %p - %r\n", __FUNCTION__,
+ CapsuleHeader, Status));
return;
}
- NeedReset = TRUE;
- HobPointer.Raw = GET_NEXT_HOB (HobPointer);
+ NeedReset = TRUE;
+ HobPointer.Raw = GET_NEXT_HOB(HobPointer);
}
if (NeedReset) {
- DEBUG ((DEBUG_WARN, "%a: capsule update successful, resetting ...\n",
- __FUNCTION__));
+ DEBUG(
+ (DEBUG_WARN, "%a: capsule update successful, resetting ...\n",
+ __FUNCTION__));
- gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
- CpuDeadLoop();
+ gRT->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL);
+ CpuDeadLoop();
}
}
-
-#define VERSION_STRING_PREFIX L"Tianocore/EDK2 firmware version "
+#define VERSION_STRING_PREFIX L"Tianocore/EDK2 firmware version "
/**
Do the platform specific action after the console is ready
> Dispatch additional option roms
> Special boot: e.g.: USB boot, enter UI
**/
-VOID
-EFIAPI
-PlatformBootManagerAfterConsole (
- VOID
- )
+VOID EFIAPI PlatformBootManagerAfterConsole(VOID)
{
EFI_STATUS Status;
- EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
UINTN FirmwareVerLength;
UINTN PosX;
UINTN PosY;
- FirmwareVerLength = StrLen (PcdGetPtr (PcdFirmwareVersionString));
+ FirmwareVerLength = StrLen(PcdGetPtr(PcdFirmwareVersionString));
//
// Show the splash screen.
//
- Status = BootLogoEnableLogo ();
- if (EFI_ERROR (Status)) {
+ Status = BootLogoEnableLogo();
+ if (EFI_ERROR(Status)) {
if (FirmwareVerLength > 0) {
- Print (VERSION_STRING_PREFIX L"%s\n",
- PcdGetPtr (PcdFirmwareVersionString));
+ Print(VERSION_STRING_PREFIX L"%s\n", PcdGetPtr(PcdFirmwareVersionString));
}
- #ifdef ENABLE_SIMPLE_INIT
- Print (L"Press any side button for SimpleInitGUI");
- #else
- Print (L"Press any side button for Boot Options");
- #endif
- } else if (FirmwareVerLength > 0) {
- Status = gBS->HandleProtocol (gST->ConsoleOutHandle,
- &gEfiGraphicsOutputProtocolGuid, (VOID **)&GraphicsOutput);
- if (!EFI_ERROR (Status)) {
+#ifdef ENABLE_SIMPLE_INIT
+ Print(L"Press any side button for SimpleInitGUI");
+#else
+ Print(L"Press any side button for Boot Options");
+#endif
+ }
+ else if (FirmwareVerLength > 0) {
+ Status = gBS->HandleProtocol(
+ gST->ConsoleOutHandle, &gEfiGraphicsOutputProtocolGuid,
+ (VOID **)&GraphicsOutput);
+ if (!EFI_ERROR(Status)) {
PosX = (GraphicsOutput->Mode->Info->HorizontalResolution -
- (StrLen (VERSION_STRING_PREFIX) + FirmwareVerLength) *
- EFI_GLYPH_WIDTH) / 2;
+ (StrLen(VERSION_STRING_PREFIX) + FirmwareVerLength) *
+ EFI_GLYPH_WIDTH) /
+ 2;
PosY = 0;
- PrintXY (PosX, PosY, NULL, NULL, VERSION_STRING_PREFIX L"%s",
- PcdGetPtr (PcdFirmwareVersionString));
+ PrintXY(
+ PosX, PosY, NULL, NULL, VERSION_STRING_PREFIX L"%s",
+ PcdGetPtr(PcdFirmwareVersionString));
}
}
//
// Connect the rest of the devices.
//
- EfiBootManagerConnectAll ();
+ EfiBootManagerConnectAll();
//
// On ARM, there is currently no reason to use the phased capsule
// when the console is up and we can actually give the user some
// feedback about what is going on.
//
- HandleCapsules ();
+ HandleCapsules();
//
// Enumerate all possible boot options.
//
- EfiBootManagerRefreshAllBootOption ();
+ EfiBootManagerRefreshAllBootOption();
//
// Register UEFI Shell
//
- PlatformRegisterFvBootOption (
- &gUefiShellFileGuid, L"UEFI Shell", LOAD_OPTION_ACTIVE
- );
-
+ PlatformRegisterFvBootOption(
+ &gUefiShellFileGuid, L"UEFI Shell", LOAD_OPTION_ACTIVE);
+
//
// Register Mass Storage App
//
- PlatformRegisterFvBootOption (
- &gUsbfnMsdAppFileGuid, L"Mass Storage", LOAD_OPTION_ACTIVE
- );
-
+ PlatformRegisterFvBootOption(
+ &gUsbfnMsdAppFileGuid, L"Mass Storage", LOAD_OPTION_ACTIVE);
+
#ifdef AB_SLOTS_SUPPORT
//
// Register Switch Slots App
//
- PlatformRegisterFvBootOption (
- &gSwitchSlotsAppFileGuid, L"Reboot to other slot", LOAD_OPTION_ACTIVE
- );
+ PlatformRegisterFvBootOption(
+ &gSwitchSlotsAppFileGuid, L"Reboot to other slot", LOAD_OPTION_ACTIVE);
#endif
}
@param TimeoutRemain The remaining timeout.
**/
-VOID
-EFIAPI
-PlatformBootManagerWaitCallback (
- UINT16 TimeoutRemain
- )
+VOID EFIAPI PlatformBootManagerWaitCallback(UINT16 TimeoutRemain)
{
EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White;
UINT16 Timeout;
EFI_STATUS Status;
- Timeout = PcdGet16 (PcdPlatformBootTimeOut);
+ Timeout = PcdGet16(PcdPlatformBootTimeOut);
Black.Raw = 0x00000000;
White.Raw = 0x00FFFFFF;
- Status = BootLogoUpdateProgress (
- White.Pixel,
- Black.Pixel,
- #ifdef ENABLE_SIMPLE_INIT
- L"Press any side button for SimpleInitGUI",
- #else
- L"Press any side button for Boot Options",
- #endif
- White.Pixel,
- (Timeout - TimeoutRemain) * 100 / Timeout,
- 0
- );
- if (EFI_ERROR (Status)) {
- Print (L".");
+ Status = BootLogoUpdateProgress(
+ White.Pixel, Black.Pixel,
+#ifdef ENABLE_SIMPLE_INIT
+ L"Press any side button for SimpleInitGUI",
+#else
+ L"Press any side button for Boot Options",
+#endif
+ White.Pixel, (Timeout - TimeoutRemain) * 100 / Timeout, 0);
+ if (EFI_ERROR(Status)) {
+ Print(L".");
}
}
If this function returns, BDS attempts to enter an infinite loop.
**/
-VOID
-EFIAPI
-PlatformBootManagerUnableToBoot (
- VOID
- )
-{
- return;
-}
+VOID EFIAPI PlatformBootManagerUnableToBoot(VOID) { return; }
@retval EFI_UNSUPPORTED Logo not found
**/
EFI_STATUS
-EnableQuietBoot (
- IN EFI_GUID *LogoFile
- );
+EnableQuietBoot(IN EFI_GUID *LogoFile);
/**
Use SystemTable Conout to turn on video based Simple Text Out consoles. The
@retval EFI_SUCCESS UGA devices are back in text mode and synced up.
**/
EFI_STATUS
-DisableQuietBoot (
- VOID
- );
+DisableQuietBoot(VOID);
#endif // _PLATFORM_BM_H_
/** @file
-*
-* Copyright (c) 2018, Linaro Limited. All rights reserved.
-*
-* This program and the accompanying materials
-* are licensed and made available under the terms and conditions of the BSD License
-* which accompanies this distribution. The full text of the license may be found at
-* http://opensource.org/licenses/bsd-license.php
-*
-* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-*
-**/
+ *
+ * Copyright (c) 2018, Linaro Limited. All rights reserved.
+ *
+ * This program and the accompanying materials
+ * are licensed and made available under the terms and conditions of the BSD
+ *License which accompanies this distribution. The full text of the license may
+ *be found at http://opensource.org/licenses/bsd-license.php
+ *
+ * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
+ *IMPLIED.
+ *
+ **/
#include <Library/ArmPlatformLib.h>
#include <Library/DebugLib.h>
#include <Ppi/ArmMpCoreInfo.h>
ARM_CORE_INFO mHiKey960InfoTable[] = {
- {
- // Cluster 0, Core 0
- 0x0, 0x0,
-
- // MP Core MailBox Set/Get/Clear Addresses and Clear Value
- (UINT64)0xFFFFFFFF
- },
-/*
- {
- // Cluster 0, Core 1
- 0x0, 0x1,
-
- // MP Core MailBox Set/Get/Clear Addresses and Clear Value
- (UINT64)0xFFFFFFFF
- },
- {
- // Cluster 0, Core 2
- 0x0, 0x2,
-
- // MP Core MailBox Set/Get/Clear Addresses and Clear Value
- (UINT64)0xFFFFFFFF
- },
- {
- // Cluster 0, Core 3
- 0x0, 0x3,
-
- // MP Core MailBox Set/Get/Clear Addresses and Clear Value
- (UINT64)0xFFFFFFFF
- },
- {
- // Cluster 1, Core 0
- 0x1, 0x0,
-
- // MP Core MailBox Set/Get/Clear Addresses and Clear Value
- (UINT64)0xFFFFFFFF
- },
- {
- // Cluster 1, Core 1
- 0x1, 0x1,
-
- // MP Core MailBox Set/Get/Clear Addresses and Clear Value
- (UINT64)0xFFFFFFFF
- },
- {
- // Cluster 1, Core 2
- 0x1, 0x2,
-
- // MP Core MailBox Set/Get/Clear Addresses and Clear Value
- (UINT64)0xFFFFFFFF
- },
- {
- // Cluster 1, Core 3
- 0x1, 0x3,
-
- // MP Core MailBox Set/Get/Clear Addresses and Clear Value
- (UINT64)0xFFFFFFFF
- }
-*/
+ {// Cluster 0, Core 0
+ 0x0, 0x0,
+
+ // MP Core MailBox Set/Get/Clear Addresses and Clear Value
+ (UINT64)0xFFFFFFFF},
+ /*
+ {
+ // Cluster 0, Core 1
+ 0x0, 0x1,
+
+ // MP Core MailBox Set/Get/Clear Addresses and Clear Value
+ (UINT64)0xFFFFFFFF
+ },
+ {
+ // Cluster 0, Core 2
+ 0x0, 0x2,
+
+ // MP Core MailBox Set/Get/Clear Addresses and Clear Value
+ (UINT64)0xFFFFFFFF
+ },
+ {
+ // Cluster 0, Core 3
+ 0x0, 0x3,
+
+ // MP Core MailBox Set/Get/Clear Addresses and Clear Value
+ (UINT64)0xFFFFFFFF
+ },
+ {
+ // Cluster 1, Core 0
+ 0x1, 0x0,
+
+ // MP Core MailBox Set/Get/Clear Addresses and Clear Value
+ (UINT64)0xFFFFFFFF
+ },
+ {
+ // Cluster 1, Core 1
+ 0x1, 0x1,
+
+ // MP Core MailBox Set/Get/Clear Addresses and Clear Value
+ (UINT64)0xFFFFFFFF
+ },
+ {
+ // Cluster 1, Core 2
+ 0x1, 0x2,
+
+ // MP Core MailBox Set/Get/Clear Addresses and Clear Value
+ (UINT64)0xFFFFFFFF
+ },
+ {
+ // Cluster 1, Core 3
+ 0x1, 0x3,
+
+ // MP Core MailBox Set/Get/Clear Addresses and Clear Value
+ (UINT64)0xFFFFFFFF
+ }
+ */
};
/**
**/
EFI_BOOT_MODE
-ArmPlatformGetBootMode (
- VOID
- )
-{
- return BOOT_WITH_FULL_CONFIGURATION;
-}
+ArmPlatformGetBootMode(VOID) { return BOOT_WITH_FULL_CONFIGURATION; }
/**
Initialize controllers that must setup in the normal world
- This function is called by the ArmPlatformPkg/Pei or ArmPlatformPkg/Pei/PlatformPeim
- in the PEI phase.
+ This function is called by the ArmPlatformPkg/Pei or
+ArmPlatformPkg/Pei/PlatformPeim in the PEI phase.
**/
RETURN_STATUS
-ArmPlatformInitialize (
- IN UINTN MpId
- )
-{
- return RETURN_SUCCESS;
-}
+ArmPlatformInitialize(IN UINTN MpId) { return RETURN_SUCCESS; }
EFI_STATUS
-PrePeiCoreGetMpCoreInfo (
- OUT UINTN *CoreCount,
- OUT ARM_CORE_INFO **ArmCoreTable
- )
+PrePeiCoreGetMpCoreInfo(OUT UINTN *CoreCount, OUT ARM_CORE_INFO **ArmCoreTable)
{
// Only support one cluster
*CoreCount = sizeof(mHiKey960InfoTable) / sizeof(ARM_CORE_INFO);
return EFI_SUCCESS;
}
-// Needs to be declared in the file. Otherwise gArmMpCoreInfoPpiGuid is undefined in the contect of PrePeiCore
-EFI_GUID mArmMpCoreInfoPpiGuid = ARM_MP_CORE_INFO_PPI_GUID;
-ARM_MP_CORE_INFO_PPI mMpCoreInfoPpi = { PrePeiCoreGetMpCoreInfo };
+// Needs to be declared in the file. Otherwise gArmMpCoreInfoPpiGuid is
+// undefined in the contect of PrePeiCore
+EFI_GUID mArmMpCoreInfoPpiGuid = ARM_MP_CORE_INFO_PPI_GUID;
+ARM_MP_CORE_INFO_PPI mMpCoreInfoPpi = {PrePeiCoreGetMpCoreInfo};
-EFI_PEI_PPI_DESCRIPTOR gPlatformPpiTable[] = {
- {
- EFI_PEI_PPI_DESCRIPTOR_PPI,
- &mArmMpCoreInfoPpiGuid,
- &mMpCoreInfoPpi
- }
-};
+EFI_PEI_PPI_DESCRIPTOR gPlatformPpiTable[] = {
+ {EFI_PEI_PPI_DESCRIPTOR_PPI, &mArmMpCoreInfoPpiGuid, &mMpCoreInfoPpi}};
-VOID
-ArmPlatformGetPlatformPpiList (
- OUT UINTN *PpiListSize,
- OUT EFI_PEI_PPI_DESCRIPTOR **PpiList
- )
+VOID ArmPlatformGetPlatformPpiList(
+ OUT UINTN *PpiListSize, OUT EFI_PEI_PPI_DESCRIPTOR **PpiList)
{
*PpiListSize = sizeof(gPlatformPpiTable);
- *PpiList = gPlatformPpiTable;
+ *PpiList = gPlatformPpiTable;
}
/** @file
-*
-* Copyright (c) 2011, ARM Limited. All rights reserved.
-* Copyright (c) 2019, RUIKAI LIU and MR TUNNEL. All rights reserved.
-*
-* This program and the accompanying materials
-* are licensed and made available under the terms and conditions of the BSD License
-* which accompanies this distribution. The full text of the license may be found at
-* http://opensource.org/licenses/bsd-license.php
-*
-* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-*
-**/
+ *
+ * Copyright (c) 2011, ARM Limited. All rights reserved.
+ * Copyright (c) 2019, RUIKAI LIU and MR TUNNEL. All rights reserved.
+ *
+ * This program and the accompanying materials
+ * are licensed and made available under the terms and conditions of the BSD
+ *License which accompanies this distribution. The full text of the license may
+ *be found at http://opensource.org/licenses/bsd-license.php
+ *
+ * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
+ *IMPLIED.
+ *
+ **/
+#include <Configuration/DeviceMemoryMap.h>
#include <Library/ArmPlatformLib.h>
-#include <Library/MemoryAllocationLib.h>
#include <Library/DebugLib.h>
#include <Library/HobLib.h>
-#include <Configuration/DeviceMemoryMap.h>
+#include <Library/MemoryAllocationLib.h>
/**
Return the Virtual Memory Map of your platform
- This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU on your platform.
- @param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR describing a Physical-to-
- Virtual Memory mapping. This array must be ended by a zero-filled
- entry
+ This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU
+on your platform.
+ @param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR
+describing a Physical-to- Virtual Memory mapping. This array must be ended by a
+zero-filled entry
**/
STATIC
-VOID
-AddHob
-(
- ARM_MEMORY_REGION_DESCRIPTOR_EX Desc
-)
+VOID AddHob(ARM_MEMORY_REGION_DESCRIPTOR_EX Desc)
{
- BuildResourceDescriptorHob(
- Desc.ResourceType,
- Desc.ResourceAttribute,
- Desc.Address,
- Desc.Length
- );
+ BuildResourceDescriptorHob(
+ Desc.ResourceType, Desc.ResourceAttribute, Desc.Address, Desc.Length);
- BuildMemoryAllocationHob(
- Desc.Address,
- Desc.Length,
- Desc.MemoryType
- );
+ BuildMemoryAllocationHob(Desc.Address, Desc.Length, Desc.MemoryType);
}
-VOID
-ArmPlatformGetVirtualMemoryMap (
- IN ARM_MEMORY_REGION_DESCRIPTOR** VirtualMemoryMap
- )
+VOID ArmPlatformGetVirtualMemoryMap(
+ IN ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap)
{
- //TO-DO:ADD MEMORY MAP HERE
- ARM_MEMORY_REGION_DESCRIPTOR* MemoryDescriptor;
- UINTN Index = 0;
+ // TO-DO:ADD MEMORY MAP HERE
+ ARM_MEMORY_REGION_DESCRIPTOR *MemoryDescriptor;
+ UINTN Index = 0;
- MemoryDescriptor = (ARM_MEMORY_REGION_DESCRIPTOR*)AllocatePages
- (EFI_SIZE_TO_PAGES (sizeof (ARM_MEMORY_REGION_DESCRIPTOR) *
- MAX_ARM_MEMORY_REGION_DESCRIPTOR_COUNT));
+ MemoryDescriptor =
+ (ARM_MEMORY_REGION_DESCRIPTOR *)AllocatePages(EFI_SIZE_TO_PAGES(
+ sizeof(ARM_MEMORY_REGION_DESCRIPTOR) *
+ MAX_ARM_MEMORY_REGION_DESCRIPTOR_COUNT));
- // Run through each memory descriptor
- while (gDeviceMemoryDescriptorEx[Index].Address != (EFI_PHYSICAL_ADDRESS)0xFFFFFFFF)
- {
- switch (gDeviceMemoryDescriptorEx[Index].HobOption)
- {
- case AddMem:
- case AddDev:
- AddHob(gDeviceMemoryDescriptorEx[Index]);
- break;
- case NoHob:
- default:
- goto update;
- }
+ // Run through each memory descriptor
+ while (gDeviceMemoryDescriptorEx[Index].Address !=
+ (EFI_PHYSICAL_ADDRESS)0xFFFFFFFF) {
+ switch (gDeviceMemoryDescriptorEx[Index].HobOption) {
+ case AddMem:
+ case AddDev:
+ AddHob(gDeviceMemoryDescriptorEx[Index]);
+ break;
+ case NoHob:
+ default:
+ goto update;
+ }
- update:
- ASSERT(Index < MAX_ARM_MEMORY_REGION_DESCRIPTOR_COUNT);
+ update:
+ ASSERT(Index < MAX_ARM_MEMORY_REGION_DESCRIPTOR_COUNT);
- MemoryDescriptor[Index].PhysicalBase = gDeviceMemoryDescriptorEx[Index].Address;
- MemoryDescriptor[Index].VirtualBase = gDeviceMemoryDescriptorEx[Index].Address;
- MemoryDescriptor[Index].Length = gDeviceMemoryDescriptorEx[Index].Length;
- MemoryDescriptor[Index].Attributes = gDeviceMemoryDescriptorEx[Index].ArmAttributes;
+ MemoryDescriptor[Index].PhysicalBase =
+ gDeviceMemoryDescriptorEx[Index].Address;
+ MemoryDescriptor[Index].VirtualBase =
+ gDeviceMemoryDescriptorEx[Index].Address;
+ MemoryDescriptor[Index].Length = gDeviceMemoryDescriptorEx[Index].Length;
+ MemoryDescriptor[Index].Attributes =
+ gDeviceMemoryDescriptorEx[Index].ArmAttributes;
- Index++;
- }
+ Index++;
+ }
- // Last one (terminator)
- MemoryDescriptor[Index].PhysicalBase = 0;
- MemoryDescriptor[Index].VirtualBase = 0;
- MemoryDescriptor[Index].Length = 0;
- MemoryDescriptor[Index++].Attributes = (ARM_MEMORY_REGION_ATTRIBUTES)0;
- ASSERT(Index <= MAX_ARM_MEMORY_REGION_DESCRIPTOR_COUNT);
+ // Last one (terminator)
+ MemoryDescriptor[Index].PhysicalBase = 0;
+ MemoryDescriptor[Index].VirtualBase = 0;
+ MemoryDescriptor[Index].Length = 0;
+ MemoryDescriptor[Index++].Attributes = (ARM_MEMORY_REGION_ATTRIBUTES)0;
+ ASSERT(Index <= MAX_ARM_MEMORY_REGION_DESCRIPTOR_COUNT);
- *VirtualMemoryMap = &MemoryDescriptor[0];
- //ASSERT(0);
+ *VirtualMemoryMap = &MemoryDescriptor[0];
+ // ASSERT(0);
}
\ No newline at end of file