/** @file\r
Mde UEFI library functions.\r
\r
- Copyright (c) 2006, Intel Corporation<BR>\r
+ Copyright (c) 2006 - 2007, Intel Corporation<BR>\r
All rights reserved. This program and the accompanying materials \r
are licensed and made available under the terms and conditions of the BSD License \r
which accompanies this distribution. The full text of the license may be found at \r
@retval FALSE Language 1 and language 2 are not the same.\r
\r
**/\r
+STATIC\r
BOOLEAN\r
CompareIso639LanguageCode (\r
IN CONST CHAR8 *Language1,\r
IN CONST CHAR8 *Language2\r
)\r
{\r
- return (BOOLEAN) (ReadUnaligned24 ((CONST UINT32 *) Language1) == ReadUnaligned24 ((CONST UINT32 *) Language2));\r
+ UINT32 Name1;\r
+ UINT32 Name2;\r
+\r
+ Name1 = ReadUnaligned24 ((CONST UINT32 *) Language1);\r
+ Name2 = ReadUnaligned24 ((CONST UINT32 *) Language2);\r
+\r
+ return (BOOLEAN) (Name1 == Name2);\r
}\r
\r
/**\r
IN EFI_TPL NotifyTpl,\r
IN EFI_EVENT_NOTIFY NotifyFunction,\r
IN VOID *NotifyContext, OPTIONAL\r
- OUT VOID *Registration\r
+ OUT VOID **Registration\r
)\r
{\r
EFI_STATUS Status;\r
IN EFI_TPL NotifyTpl,\r
IN EFI_EVENT_NOTIFY NotifyFunction,\r
IN CONST VOID *NotifyContext, OPTIONAL\r
- OUT VOID *Registration OPTIONAL\r
+ OUT VOID *Registration OPTIONAL\r
)\r
{\r
EFI_STATUS Status;\r
return EFI_SUCCESS;\r
}\r
\r
+/** \r
+ Returns the current TPL.\r
+\r
+ This function returns the current TPL. There is no EFI service to directly \r
+ retrieve the current TPL. Instead, the RaiseTPL() function is used to raise \r
+ the TPL to TPL_HIGH_LEVEL. This will return the current TPL. The TPL level \r
+ can then immediately be restored back to the current TPL level with a call \r
+ to RestoreTPL().\r
+\r
+ @param VOID\r
+\r
+ @retvale EFI_TPL The current TPL.\r
+\r
+**/\r
+EFI_TPL\r
+EFIAPI\r
+EfiGetCurrentTpl (\r
+ VOID\r
+ )\r
+{\r
+ EFI_TPL Tpl;\r
+\r
+ Tpl = gBS->RaiseTPL (EFI_TPL_HIGH_LEVEL); \r
+ gBS->RestoreTPL (Tpl);\r
+\r
+ return Tpl;\r
+}\r
+\r
\r
/**\r
This function initializes a basic mutual exclusion lock to the released state \r
gBS->RestoreTPL (Tpl);\r
}\r
\r
+/**
+ Tests whether a controller handle is being managed by a specific driver.
+
+ This function tests whether the driver specified by DriverBindingHandle is\r
+ currently managing the controller specified by ControllerHandle. This test\r
+ is performed by evaluating if the the protocol specified by ProtocolGuid is\r
+ present on ControllerHandle and is was opened by DriverBindingHandle with an\r
+ attribute of EFI_OPEN_PROTOCOL_BY_DRIVER. \r
+ If ProtocolGuid is NULL, then ASSERT().\r
+
+ @param ControllerHandle A handle for a controller to test.
+ @param DriverBindingHandle Specifies the driver binding handle for the
+ driver.
+ @param ProtocolGuid Specifies the protocol that the driver specified
+ by DriverBindingHandle opens in its Start()
+ function.
+
+ @retval EFI_SUCCESS ControllerHandle is managed by the driver
+ specifed by DriverBindingHandle.
+ @retval EFI_UNSUPPORTED ControllerHandle is not managed by the driver
+ specifed by DriverBindingHandle.
+
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiTestManagedDevice (\r
+ IN CONST EFI_HANDLE ControllerHandle,\r
+ IN CONST EFI_HANDLE DriverBindingHandle,\r
+ IN CONST EFI_GUID *ProtocolGuid\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ VOID *ManagedInterface;\r
+\r
+ ASSERT (ProtocolGuid != NULL);\r
+\r
+ Status = gBS->OpenProtocol (\r
+ ControllerHandle,\r
+ (EFI_GUID *) ProtocolGuid,\r
+ &ManagedInterface,\r
+ DriverBindingHandle,\r
+ ControllerHandle,\r
+ EFI_OPEN_PROTOCOL_BY_DRIVER\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ gBS->CloseProtocol (\r
+ ControllerHandle,\r
+ (EFI_GUID *) ProtocolGuid,\r
+ DriverBindingHandle,\r
+ ControllerHandle\r
+ );\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ if (Status != EFI_ALREADY_STARTED) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**
+ Tests whether a child handle is a child device of the controller.
+
+ This function tests whether ChildHandle is one of the children of\r
+ ControllerHandle. This test is performed by checking to see if the protocol\r
+ specified by ProtocolGuid is present on ControllerHandle and opened by\r
+ ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
+ If ProtocolGuid is NULL, then ASSERT().\r
+
+ @param ControllerHandle A handle for a (parent) controller to test.
+ @param ChildHandle A child handle to test.
+ @param ConsumsedGuid Supplies the protocol that the child controller
+ opens on its parent controller.
+
+ @retval EFI_SUCCESS ChildHandle is a child of the ControllerHandle.
+ @retval EFI_UNSUPPORTED ChildHandle is not a child of the
+ ControllerHandle.
+
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiTestChildHandle (\r
+ IN CONST EFI_HANDLE ControllerHandle,\r
+ IN CONST EFI_HANDLE ChildHandle,\r
+ IN CONST EFI_GUID *ProtocolGuid\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;\r
+ UINTN EntryCount;\r
+ UINTN Index;\r
+\r
+ ASSERT (ProtocolGuid != NULL);\r
+\r
+ //\r
+ // Retrieve the list of agents that are consuming the specific protocol\r
+ // on ControllerHandle.\r
+ //\r
+ Status = gBS->OpenProtocolInformation (\r
+ ControllerHandle,\r
+ (EFI_GUID *) ProtocolGuid,\r
+ &OpenInfoBuffer,\r
+ &EntryCount\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ //\r
+ // Inspect if ChildHandle is one of the agents.\r
+ //\r
+ Status = EFI_UNSUPPORTED;\r
+ for (Index = 0; Index < EntryCount; Index++) {\r
+ if ((OpenInfoBuffer[Index].ControllerHandle == ChildHandle) &&\r
+ (OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {\r
+ Status = EFI_SUCCESS;\r
+ break;\r
+ }\r
+ }\r
+ \r
+ FreePool (OpenInfoBuffer);\r
+ return Status;\r
+}\r
+\r
/**\r
This function looks up a Unicode string in UnicodeStringTable. If Language is \r
a member of SupportedLanguages and a Unicode string is found in UnicodeStringTable\r
\r
return EFI_SUCCESS;\r
}\r
+\r