OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
OcDevicePropertyLib.c File Reference
#include <AppleMacEfi.h>
#include <Guid/AppleVariable.h>
#include <Protocol/DevicePath.h>
#include <Protocol/DevicePathPropertyDatabase.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/BaseOverflowLib.h>
#include <Library/DebugLib.h>
#include <Library/DevicePathLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PcdLib.h>
#include <Library/PrintLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/OcMiscLib.h>

Go to the source code of this file.

Data Structures

struct  DEVICE_PATH_PROPERTY_DATA
 
struct  EFI_DEVICE_PATH_PROPERTY_NODE_HDR
 
struct  EFI_DEVICE_PATH_PROPERTY_NODE
 
struct  EFI_DEVICE_PATH_PROPERTY
 

Macros

#define DEVICE_PATH_PROPERTY_DATA_SIGNATURE    SIGNATURE_32 ('D', 'p', 'p', 'P')
 
#define PROPERTY_DATABASE_FROM_PROTOCOL(This)
 
#define APPLE_PATH_PROPERTIES_VARIABLE_NAME   L"AAPL,PathProperties"
 
#define APPLE_PATH_PROPERTY_VARIABLE_MAX_SIZE   768
 
#define APPLE_PATH_PROPERTY_VARIABLE_MAX_NUM   0x10000
 
#define EFI_DEVICE_PATH_PROPERTY_NODE_SIGNATURE    SIGNATURE_32 ('D', 'p', 'n', '\0')
 
#define PROPERTY_NODE_FROM_LIST_ENTRY(Entry)
 
#define EFI_DEVICE_PATH_PROPERTY_NODE_SIZE(Node)
 
#define EFI_DEVICE_PATH_PROPERTY_SIGNATURE    SIGNATURE_32 ('D', 'p', 'p', '\0')
 
#define EFI_DEVICE_PATH_PROPERTY_DATABASE_VERSION   1
 
#define EFI_DEVICE_PATH_PROPERTY_FROM_LIST_ENTRY(Entry)
 
#define EFI_DEVICE_PATH_PROPERTY_SIZE(Property)
 
#define EFI_DEVICE_PATH_PROPERTY_VALUE_SIZE(Property)
 
#define NEXT_EFI_DEVICE_PATH_PROPERTY(Property)
 
#define APPLE_THUNDERBOLT_NATIVE_HOST_INTERFACE_PROTOCOL_GUID
 

Functions

STATIC EFI_DEVICE_PATH_PROPERTY_NODEInternalGetPropertyNode (IN DEVICE_PATH_PROPERTY_DATA *DevicePathPropertyData, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
 
STATIC EFI_DEVICE_PATH_PROPERTYInternalGetProperty (IN EFI_DEVICE_PATH_PROPERTY_NODE *Node, IN CONST CHAR16 *Name)
 
STATIC VOID InternalSyncWithThunderboltDevices (VOID)
 
EFI_STATUS EFIAPI DppDbGetProperty (IN EFI_DEVICE_PATH_PROPERTY_DATABASE_PROTOCOL *This, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN CONST CHAR16 *Name, OUT VOID *Value OPTIONAL, IN OUT UINTN *Size)
 
EFI_STATUS EFIAPI DppDbSetProperty (IN EFI_DEVICE_PATH_PROPERTY_DATABASE_PROTOCOL *This, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN CONST CHAR16 *Name, IN VOID *Value, IN UINTN Size)
 
EFI_STATUS EFIAPI DppDbRemoveProperty (IN EFI_DEVICE_PATH_PROPERTY_DATABASE_PROTOCOL *This, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN CONST CHAR16 *Name)
 
EFI_STATUS EFIAPI DppDbGetPropertyBuffer (IN EFI_DEVICE_PATH_PROPERTY_DATABASE_PROTOCOL *This, OUT EFI_DEVICE_PATH_PROPERTY_BUFFER *Buffer OPTIONAL, IN OUT UINTN *Size)
 
STATIC EFI_STATUS InternalReadEfiVariableProperties (IN EFI_GUID *VendorGuid, IN BOOLEAN DeleteVariables, IN DEVICE_PATH_PROPERTY_DATA *DevicePathPropertyData)
 
EFI_DEVICE_PATH_PROPERTY_DATABASE_PROTOCOLOcDevicePathPropertyInstallProtocol (IN BOOLEAN Reinstall)
 

Variables

EFI_GUID mAppleThunderboltNativeHostInterfaceProtocolGuid = APPLE_THUNDERBOLT_NATIVE_HOST_INTERFACE_PROTOCOL_GUID
 
STATIC EFI_DEVICE_PATH_PROPERTY_DATABASE_PROTOCOL DppDbProtocolTemplate
 

Detailed Description

Copyright (C) 2017, vit9696. All rights reserved.

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.

Definition in file OcDevicePropertyLib.c.

Macro Definition Documentation

◆ APPLE_PATH_PROPERTIES_VARIABLE_NAME

#define APPLE_PATH_PROPERTIES_VARIABLE_NAME   L"AAPL,PathProperties"

Definition at line 54 of file OcDevicePropertyLib.c.

◆ APPLE_PATH_PROPERTY_VARIABLE_MAX_NUM

#define APPLE_PATH_PROPERTY_VARIABLE_MAX_NUM   0x10000

Definition at line 56 of file OcDevicePropertyLib.c.

◆ APPLE_PATH_PROPERTY_VARIABLE_MAX_SIZE

#define APPLE_PATH_PROPERTY_VARIABLE_MAX_SIZE   768

Definition at line 55 of file OcDevicePropertyLib.c.

◆ APPLE_THUNDERBOLT_NATIVE_HOST_INTERFACE_PROTOCOL_GUID

#define APPLE_THUNDERBOLT_NATIVE_HOST_INTERFACE_PROTOCOL_GUID
Value:
{ 0xC649D4F3, 0xD502, 0x4DAA, \
{ 0xA1, 0x39, 0x39, 0x4A, 0xCC, 0xF2, 0xA6, 0x3B } }

Definition at line 126 of file OcDevicePropertyLib.c.

◆ DEVICE_PATH_PROPERTY_DATA_SIGNATURE

#define DEVICE_PATH_PROPERTY_DATA_SIGNATURE    SIGNATURE_32 ('D', 'p', 'p', 'P')

Definition at line 34 of file OcDevicePropertyLib.c.

◆ EFI_DEVICE_PATH_PROPERTY_DATABASE_VERSION

#define EFI_DEVICE_PATH_PROPERTY_DATABASE_VERSION   1

Definition at line 91 of file OcDevicePropertyLib.c.

◆ EFI_DEVICE_PATH_PROPERTY_FROM_LIST_ENTRY

#define EFI_DEVICE_PATH_PROPERTY_FROM_LIST_ENTRY ( Entry)
Value:

Definition at line 93 of file OcDevicePropertyLib.c.

◆ EFI_DEVICE_PATH_PROPERTY_NODE_SIGNATURE

#define EFI_DEVICE_PATH_PROPERTY_NODE_SIGNATURE    SIGNATURE_32 ('D', 'p', 'n', '\0')

Definition at line 58 of file OcDevicePropertyLib.c.

◆ EFI_DEVICE_PATH_PROPERTY_NODE_SIZE

#define EFI_DEVICE_PATH_PROPERTY_NODE_SIZE ( Node)
Value:
(sizeof (EFI_DEVICE_PATH_PROPERTY_BUFFER_NODE_HDR) + GetDevicePathSize (&(Node)->DevicePath))

Definition at line 71 of file OcDevicePropertyLib.c.

◆ EFI_DEVICE_PATH_PROPERTY_SIGNATURE

#define EFI_DEVICE_PATH_PROPERTY_SIGNATURE    SIGNATURE_32 ('D', 'p', 'p', '\0')

Definition at line 88 of file OcDevicePropertyLib.c.

◆ EFI_DEVICE_PATH_PROPERTY_SIZE

#define EFI_DEVICE_PATH_PROPERTY_SIZE ( Property)
Value:
((Property)->Name->Size + (Property)->Value->Size)

Definition at line 101 of file OcDevicePropertyLib.c.

◆ EFI_DEVICE_PATH_PROPERTY_VALUE_SIZE

#define EFI_DEVICE_PATH_PROPERTY_VALUE_SIZE ( Property)
Value:
((Property)->Value->Size - sizeof (*(Property)->Value))

Definition at line 104 of file OcDevicePropertyLib.c.

◆ NEXT_EFI_DEVICE_PATH_PROPERTY

#define NEXT_EFI_DEVICE_PATH_PROPERTY ( Property)
Value:
(UINTN)(Property) + EFI_DEVICE_PATH_PROPERTY_SIZE (Property) \
)
#define EFI_DEVICE_PATH_PROPERTY_SIZE(Property)

Definition at line 107 of file OcDevicePropertyLib.c.

◆ PROPERTY_DATABASE_FROM_PROTOCOL

#define PROPERTY_DATABASE_FROM_PROTOCOL ( This)
Value:

Definition at line 38 of file OcDevicePropertyLib.c.

◆ PROPERTY_NODE_FROM_LIST_ENTRY

#define PROPERTY_NODE_FROM_LIST_ENTRY ( Entry)

Function Documentation

◆ DppDbGetProperty()

EFI_STATUS EFIAPI DppDbGetProperty ( IN EFI_DEVICE_PATH_PROPERTY_DATABASE_PROTOCOL * This,
IN EFI_DEVICE_PATH_PROTOCOL * DevicePath,
IN CONST CHAR16 * Name,
OUT VOID *Value OPTIONAL,
IN OUT UINTN * Size )

Locates a device property in the database and returns its value into Value.

Parameters
[in]ThisA pointer to the protocol instance.
[in]DevicePathThe device path of the device to get the property of.
[in]NameThe Name of the requested property.
[out]ValueThe Buffer allocated by the caller to return the value of the property into.
[in,out]SizeOn input the size of the allocated Value Buffer. On output the size required to fill the Buffer.
Returns
The status of the operation is returned.
Return values
EFI_BUFFER_TOO_SMALLThe memory required to return the value exceeds the size of the allocated Buffer. The required size to complete the operation has been returned into Size.
EFI_NOT_FOUNDThe given device path does not have a property with the specified Name.
EFI_SUCCESSThe operation completed successfully and the Value Buffer has been filled.

Definition at line 251 of file OcDevicePropertyLib.c.

◆ DppDbGetPropertyBuffer()

EFI_STATUS EFIAPI DppDbGetPropertyBuffer ( IN EFI_DEVICE_PATH_PROPERTY_DATABASE_PROTOCOL * This,
OUT EFI_DEVICE_PATH_PROPERTY_BUFFER *Buffer OPTIONAL,
IN OUT UINTN * Size )

Returns a Buffer of all device properties into Buffer.

Parameters
[in]ThisA pointer to the protocol instance.
[out]BufferThe Buffer allocated by the caller to return the property Buffer into.
[in,out]SizeOn input the size of the allocated Buffer. On output the size required to fill the Buffer.
Returns
The status of the operation is returned.
Return values
EFI_BUFFER_TOO_SMALLThe memory required to return the value exceeds the size of the allocated Buffer. The required size to complete the operation has been returned into Size.
EFI_SUCCESSThe operation completed successfully.

Definition at line 481 of file OcDevicePropertyLib.c.

◆ DppDbRemoveProperty()

EFI_STATUS EFIAPI DppDbRemoveProperty ( IN EFI_DEVICE_PATH_PROPERTY_DATABASE_PROTOCOL * This,
IN EFI_DEVICE_PATH_PROTOCOL * DevicePath,
IN CONST CHAR16 * Name )

Removes the sepcified property from the given device path.

Parameters
[in]ThisA pointer to the protocol instance.
[in]DevicePathThe device path of the device to set the property of.
[in]NameThe Name of the desired property.
Returns
The status of the operation is returned.
Return values
EFI_NOT_FOUNDThe given device path does not have a property with the specified Name.
EFI_SUCCESSThe operation completed successfully.

Definition at line 422 of file OcDevicePropertyLib.c.

◆ DppDbSetProperty()

EFI_STATUS EFIAPI DppDbSetProperty ( IN EFI_DEVICE_PATH_PROPERTY_DATABASE_PROTOCOL * This,
IN EFI_DEVICE_PATH_PROTOCOL * DevicePath,
IN CONST CHAR16 * Name,
IN VOID * Value,
IN UINTN Size )

Sets the sepcified property of the given device path to the provided Value.

Parameters
[in]ThisA pointer to the protocol instance.
[in]DevicePathThe device path of the device to set the property of.
[in]NameThe Name of the desired property.
[in]ValueThe Buffer holding the value to set the property to.
[in]SizeThe size of the Value Buffer.
Returns
The status of the operation is returned.
Return values
EFI_OUT_OF_RESOURCESThe memory necessary to complete the operation could not be allocated.
EFI_SUCCESSThe operation completed successfully and the Value Buffer has been filled.

Definition at line 306 of file OcDevicePropertyLib.c.

◆ InternalGetProperty()

STATIC EFI_DEVICE_PATH_PROPERTY * InternalGetProperty ( IN EFI_DEVICE_PATH_PROPERTY_NODE * Node,
IN CONST CHAR16 * Name )

Definition at line 165 of file OcDevicePropertyLib.c.

◆ InternalGetPropertyNode()

STATIC EFI_DEVICE_PATH_PROPERTY_NODE * InternalGetPropertyNode ( IN DEVICE_PATH_PROPERTY_DATA * DevicePathPropertyData,
IN EFI_DEVICE_PATH_PROTOCOL * DevicePath )

Definition at line 135 of file OcDevicePropertyLib.c.

◆ InternalReadEfiVariableProperties()

STATIC EFI_STATUS InternalReadEfiVariableProperties ( IN EFI_GUID * VendorGuid,
IN BOOLEAN DeleteVariables,
IN DEVICE_PATH_PROPERTY_DATA * DevicePathPropertyData )

Definition at line 593 of file OcDevicePropertyLib.c.

◆ InternalSyncWithThunderboltDevices()

STATIC VOID InternalSyncWithThunderboltDevices ( VOID )

Definition at line 188 of file OcDevicePropertyLib.c.

◆ OcDevicePathPropertyInstallProtocol()

EFI_DEVICE_PATH_PROPERTY_DATABASE_PROTOCOL * OcDevicePathPropertyInstallProtocol ( IN BOOLEAN Reinstall)

Install and initialise EFI DevicePath property protocol.

Parameters
[in]ReinstallOverwrite installed protocol.
Return values
installedor located protocol or NULL.

Definition at line 787 of file OcDevicePropertyLib.c.

Variable Documentation

◆ DppDbProtocolTemplate

STATIC EFI_DEVICE_PATH_PROPERTY_DATABASE_PROTOCOL DppDbProtocolTemplate
Initial value:
= {
}
#define EFI_DEVICE_PATH_PROPERTY_DATABASE_PROTOCOL_REVISION
EFI_STATUS EFIAPI DppDbGetPropertyBuffer(IN EFI_DEVICE_PATH_PROPERTY_DATABASE_PROTOCOL *This, OUT EFI_DEVICE_PATH_PROPERTY_BUFFER *Buffer OPTIONAL, IN OUT UINTN *Size)
EFI_STATUS EFIAPI DppDbGetProperty(IN EFI_DEVICE_PATH_PROPERTY_DATABASE_PROTOCOL *This, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN CONST CHAR16 *Name, OUT VOID *Value OPTIONAL, IN OUT UINTN *Size)
EFI_STATUS EFIAPI DppDbSetProperty(IN EFI_DEVICE_PATH_PROPERTY_DATABASE_PROTOCOL *This, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN CONST CHAR16 *Name, IN VOID *Value, IN UINTN Size)
EFI_STATUS EFIAPI DppDbRemoveProperty(IN EFI_DEVICE_PATH_PROPERTY_DATABASE_PROTOCOL *This, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN CONST CHAR16 *Name)

Definition at line 778 of file OcDevicePropertyLib.c.

◆ mAppleThunderboltNativeHostInterfaceProtocolGuid

EFI_GUID mAppleThunderboltNativeHostInterfaceProtocolGuid = APPLE_THUNDERBOLT_NATIVE_HOST_INTERFACE_PROTOCOL_GUID

Definition at line 130 of file OcDevicePropertyLib.c.