RedfishPkg: Apply uncrustify changes

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737

Apply uncrustify changes to .c/.h files in the RedfishPkg package

Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Abner Chang <abner.chang@hpe.com>
This commit is contained in:
Michael Kubacki
2021-12-05 14:54:11 -08:00
committed by mergify[bot]
parent 5220bd211d
commit 39de741e2d
56 changed files with 6067 additions and 4616 deletions

View File

@ -12,72 +12,72 @@
#include <IndustryStandard/SmBios.h> #include <IndustryStandard/SmBios.h>
#define REDFISH_HOST_INTERFACE_DEVICE_TYPE_USB 0x02 // We don't support this type of interface. #define REDFISH_HOST_INTERFACE_DEVICE_TYPE_USB 0x02 // We don't support this type of interface.
// Use REDFISH_HOST_INTERFACE_DEVICE_TYPE_USB_V2 instead. // Use REDFISH_HOST_INTERFACE_DEVICE_TYPE_USB_V2 instead.
#define REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE 0x03 // We don't support this type of interface. #define REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE 0x03 // We don't support this type of interface.
// Use REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2 instead. // Use REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2 instead.
#define REDFISH_HOST_INTERFACE_DEVICE_TYPE_USB_V2 0x04 #define REDFISH_HOST_INTERFACE_DEVICE_TYPE_USB_V2 0x04
#define REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2 0x05 #define REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2 0x05
#define REDFISH_HOST_INTERFACE_HOST_IP_ASSIGNMENT_TYPE_UNKNOWN 0x00 #define REDFISH_HOST_INTERFACE_HOST_IP_ASSIGNMENT_TYPE_UNKNOWN 0x00
#define REDFISH_HOST_INTERFACE_HOST_IP_ASSIGNMENT_TYPE_STATIC 0x01 #define REDFISH_HOST_INTERFACE_HOST_IP_ASSIGNMENT_TYPE_STATIC 0x01
#define REDFISH_HOST_INTERFACE_HOST_IP_ASSIGNMENT_TYPE_DHCP 0x02 #define REDFISH_HOST_INTERFACE_HOST_IP_ASSIGNMENT_TYPE_DHCP 0x02
#define REDFISH_HOST_INTERFACE_HOST_IP_ASSIGNMENT_TYPE_AUTO_CONFIGURE 0x03 #define REDFISH_HOST_INTERFACE_HOST_IP_ASSIGNMENT_TYPE_AUTO_CONFIGURE 0x03
#define REDFISH_HOST_INTERFACE_HOST_IP_ASSIGNMENT_TYPE_HOST_SELECTED 0x04 #define REDFISH_HOST_INTERFACE_HOST_IP_ASSIGNMENT_TYPE_HOST_SELECTED 0x04
#define REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN 0x00 #define REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN 0x00
#define REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP4 0x01 #define REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP4 0x01
#define REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP6 0x02 #define REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP6 0x02
#pragma pack(1) #pragma pack(1)
/// ///
/// Structure definitions of Host Interface device type 04h (USB Network Interface V2) /// Structure definitions of Host Interface device type 04h (USB Network Interface V2)
/// ///
typedef struct { typedef struct {
UINT8 Length; ///< Length of the structure, including Device Type UINT8 Length; ///< Length of the structure, including Device Type
///< and Length fields. ///< and Length fields.
UINT16 IdVendor; ///< The Vendor ID of the device, as read from the UINT16 IdVendor; ///< The Vendor ID of the device, as read from the
///< idVendor field of the USB descriptor. ///< idVendor field of the USB descriptor.
UINT16 IdProduct; ///< The Product ID of the device, as read from the UINT16 IdProduct; ///< The Product ID of the device, as read from the
///< idProduct field of the USB descriptor. ///< idProduct field of the USB descriptor.
UINT8 SecialNumberStr; ///< The string number for the Serial Number of the UINT8 SecialNumberStr; ///< The string number for the Serial Number of the
///< device. The string data is read from the ///< device. The string data is read from the
///< iSerialNumber.bDescriptorType field of the USB ///< iSerialNumber.bDescriptorType field of the USB
///< descriptor, and is converted from Unicode to ASCII ///< descriptor, and is converted from Unicode to ASCII
///< and is NULL terminated. ///< and is NULL terminated.
UINT8 MacAddress [6]; ///< The MAC address of the PCI/PCIe network device. UINT8 MacAddress[6]; ///< The MAC address of the PCI/PCIe network device.
} USB_INTERFACE_DEVICE_DESCRIPTOR_V2; } USB_INTERFACE_DEVICE_DESCRIPTOR_V2;
// //
// Structure definitions of Host Interface device type 05h (PCI/PCIE V2) // Structure definitions of Host Interface device type 05h (PCI/PCIE V2)
// //
typedef struct { typedef struct {
UINT8 Length; ///< Length of the structure, including Device Type and Length fields. UINT8 Length; ///< Length of the structure, including Device Type and Length fields.
UINT16 VendorId; ///< The Vendor ID of the PCI/PCIe device. UINT16 VendorId; ///< The Vendor ID of the PCI/PCIe device.
UINT16 DeviceId; ///< The Device ID of the PCI/PCIe device. UINT16 DeviceId; ///< The Device ID of the PCI/PCIe device.
UINT16 SubsystemVendorId; ///< The Subsystem Vendor ID of the PCI/PCIe device. UINT16 SubsystemVendorId; ///< The Subsystem Vendor ID of the PCI/PCIe device.
UINT16 SubsystemId; ///< The Subsystem ID of the PCI/PCIe device. UINT16 SubsystemId; ///< The Subsystem ID of the PCI/PCIe device.
UINT8 MacAddress [6]; ///< The MAC address of the PCI/PCIe network device. UINT8 MacAddress[6]; ///< The MAC address of the PCI/PCIe network device.
UINT16 SegmemtGroupNumber; ///< The Segment Group Number of the PCI/PCIe. UINT16 SegmemtGroupNumber; ///< The Segment Group Number of the PCI/PCIe.
UINT8 BusNumber; ///< The Bus Number of the PCI/PCIe device. UINT8 BusNumber; ///< The Bus Number of the PCI/PCIe device.
UINT8 DeviceFunctionNumber; ///< The Device/Function Number of the PCI/PCIe. UINT8 DeviceFunctionNumber; ///< The Device/Function Number of the PCI/PCIe.
} PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2; } PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2;
/// ///
/// Structure definitions of Host Interface device type 80-FFh (OEM) /// Structure definitions of Host Interface device type 80-FFh (OEM)
/// ///
typedef struct { typedef struct {
UINT32 VendorIana; ///< The IANA code for the vendor (MSB first). UINT32 VendorIana; ///< The IANA code for the vendor (MSB first).
UINT8 OemDefinedData[1]; ///< OEM defined data. UINT8 OemDefinedData[1]; ///< OEM defined data.
} OEM_DEVICE_DESCRIPTOR; } OEM_DEVICE_DESCRIPTOR;
/// ///
/// Define union for the Host Interface Device Descriptor /// Define union for the Host Interface Device Descriptor
/// ///
typedef union { typedef union {
USB_INTERFACE_DEVICE_DESCRIPTOR_V2 UsbDeviceV2; ///< Device type USB V2 device discriptor. USB_INTERFACE_DEVICE_DESCRIPTOR_V2 UsbDeviceV2; ///< Device type USB V2 device discriptor.
PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2 PciPcieDeviceV2; ///< Device type PCI/PCIe V2 device discriptor. PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2 PciPcieDeviceV2; ///< Device type PCI/PCIe V2 device discriptor.
OEM_DEVICE_DESCRIPTOR OemDevice; ///< OEM type device discriptor. OEM_DEVICE_DESCRIPTOR OemDevice; ///< OEM type device discriptor.
} DEVICE_DESCRITOR; /// Device descriptor data formated based on Device Type. } DEVICE_DESCRITOR; /// Device descriptor data formated based on Device Type.
/// ///
@ -87,15 +87,15 @@ typedef union {
/// specific Tape 42 table. /// specific Tape 42 table.
/// ///
typedef struct { typedef struct {
UINT8 DeviceType; ///< The Device Type of the interface. UINT8 DeviceType; ///< The Device Type of the interface.
DEVICE_DESCRITOR DeviceDescriptor; ///< The Device descriptor. DEVICE_DESCRITOR DeviceDescriptor; ///< The Device descriptor.
} REDFISH_INTERFACE_DATA; } REDFISH_INTERFACE_DATA;
// //
// the protocol-specific data for the "Redfish Over IP" protocol // the protocol-specific data for the "Redfish Over IP" protocol
// //
typedef struct { typedef struct {
EFI_GUID ServiceUuid; //same as Redfish Service UUID in Redfish Service Root resource EFI_GUID ServiceUuid; // same as Redfish Service UUID in Redfish Service Root resource
// //
// Unknown=00h, // Unknown=00h,
@ -105,7 +105,7 @@ typedef struct {
// HostSelected=04h, // HostSelected=04h,
// other values reserved // other values reserved
// //
UINT8 HostIpAssignmentType; UINT8 HostIpAssignmentType;
// //
// Unknown=00h, // Unknown=00h,
@ -113,19 +113,19 @@ typedef struct {
// Ipv6=02h, // Ipv6=02h,
// other values reserved // other values reserved
// //
UINT8 HostIpAddressFormat; UINT8 HostIpAddressFormat;
// //
// Used for Static and AutoConfigure. // Used for Static and AutoConfigure.
// For IPV4, use the first 4 Bytes and zero fill the remaining bytes. // For IPV4, use the first 4 Bytes and zero fill the remaining bytes.
// //
UINT8 HostIpAddress[16]; UINT8 HostIpAddress[16];
// //
// Used for Static and AutoConfigure. // Used for Static and AutoConfigure.
// For IPV4, use the first 4 Bytes and zero fill the remaining bytes. // For IPV4, use the first 4 Bytes and zero fill the remaining bytes.
// //
UINT8 HostIpMask[16]; UINT8 HostIpMask[16];
// //
// Unknown=00h, // Unknown=00h,
@ -135,7 +135,7 @@ typedef struct {
// HostSelected=04h, // HostSelected=04h,
// other values reserved // other values reserved
// //
UINT8 RedfishServiceIpDiscoveryType; UINT8 RedfishServiceIpDiscoveryType;
// //
// Unknown=00h, // Unknown=00h,
@ -143,27 +143,26 @@ typedef struct {
// Ipv6=02h, // Ipv6=02h,
// other values reserved // other values reserved
// //
UINT8 RedfishServiceIpAddressFormat; UINT8 RedfishServiceIpAddressFormat;
// //
// Used for Static and AutoConfigure. // Used for Static and AutoConfigure.
// For IPV4, use the first 4 Bytes and zero fill the remaining bytes. // For IPV4, use the first 4 Bytes and zero fill the remaining bytes.
// //
UINT8 RedfishServiceIpAddress[16]; UINT8 RedfishServiceIpAddress[16];
// //
// Used for Static and AutoConfigure. // Used for Static and AutoConfigure.
// For IPV4, use the first 4 Bytes and zero fill the remaining bytes. // For IPV4, use the first 4 Bytes and zero fill the remaining bytes.
// //
UINT8 RedfishServiceIpMask[16]; UINT8 RedfishServiceIpMask[16];
UINT16 RedfishServiceIpPort; // Used for Static and AutoConfigure. UINT16 RedfishServiceIpPort; // Used for Static and AutoConfigure.
UINT32 RedfishServiceVlanId; // Used for Static and AutoConfigure. UINT32 RedfishServiceVlanId; // Used for Static and AutoConfigure.
UINT8 RedfishServiceHostnameLength; // length of the following hostname string UINT8 RedfishServiceHostnameLength; // length of the following hostname string
UINT8 RedfishServiceHostname[1]; // hostname of Redfish Service UINT8 RedfishServiceHostname[1]; // hostname of Redfish Service
} REDFISH_OVER_IP_PROTOCOL_DATA; } REDFISH_OVER_IP_PROTOCOL_DATA;
#pragma pack() #pragma pack()
#endif #endif

View File

@ -14,11 +14,11 @@
/// ///
/// L"\u0000" /// L"\u0000"
/// ///
#define UNICODE_FORMAT_LEN 6 #define UNICODE_FORMAT_LEN 6
#define UNICODE_FORMAT_CHAR_LEN 2 #define UNICODE_FORMAT_CHAR_LEN 2
#define UNICODE_FORMAT_CHAR_SIZE 3 #define UNICODE_FORMAT_CHAR_SIZE 3
#define UTF8_BUFFER_FOR_UCS2_MAX_SIZE 3 #define UTF8_BUFFER_FOR_UCS2_MAX_SIZE 3
/** /**
Convert a UCS2 string to a UTF8 encoded string. Convert a UCS2 string to a UTF8 encoded string.
@ -34,8 +34,8 @@
**/ **/
EFI_STATUS EFI_STATUS
UCS2StrToUTF8 ( UCS2StrToUTF8 (
IN CHAR16 *Ucs2Str, IN CHAR16 *Ucs2Str,
OUT CHAR8 **Utf8StrAddr OUT CHAR8 **Utf8StrAddr
); );
/** /**
@ -54,8 +54,8 @@ UCS2StrToUTF8 (
**/ **/
EFI_STATUS EFI_STATUS
UTF8StrToUCS2 ( UTF8StrToUCS2 (
IN CHAR8 *Utf8Str, IN CHAR8 *Utf8Str,
OUT CHAR16 **Ucs2StrAddr OUT CHAR16 **Ucs2StrAddr
); );
#endif #endif

View File

@ -7,17 +7,18 @@
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef JSON_LIB_H_ #ifndef JSON_LIB_H_
#define JSON_LIB_H_ #define JSON_LIB_H_
typedef VOID* EDKII_JSON_VALUE; typedef VOID *EDKII_JSON_VALUE;
typedef VOID* EDKII_JSON_ARRAY; typedef VOID *EDKII_JSON_ARRAY;
typedef VOID* EDKII_JSON_OBJECT; typedef VOID *EDKII_JSON_OBJECT;
/// ///
/// Map to json_int_t in jansson.h /// Map to json_int_t in jansson.h
/// ///
typedef INT64 EDKII_JSON_INT_T; // #JSON_INTEGER_IS_LONG_LONG is set to 1 typedef INT64 EDKII_JSON_INT_T; // #JSON_INTEGER_IS_LONG_LONG is set to 1
// in jansson_Config.h // in jansson_Config.h
/// ///
@ -25,28 +26,28 @@ typedef INT64 EDKII_JSON_INT_T; // #JSON_INTEGER_IS_LONG_LONG is set to 1
/// See below URI for the JSON encoding flags reference. /// See below URI for the JSON encoding flags reference.
/// https://jansson.readthedocs.io/en/2.13/apiref.html#encoding /// https://jansson.readthedocs.io/en/2.13/apiref.html#encoding
/// ///
#define EDKII_JSON_MAX_INDENT 0x1F #define EDKII_JSON_MAX_INDENT 0x1F
#define EDKII_JSON_INDENT(n) ((n) & EDKII_JSON_MAX_INDENT) #define EDKII_JSON_INDENT(n) ((n) & EDKII_JSON_MAX_INDENT)
#define EDKII_JSON_COMPACT 0x20 #define EDKII_JSON_COMPACT 0x20
#define EDKII_JSON_ENSURE_ASCII 0x40 #define EDKII_JSON_ENSURE_ASCII 0x40
#define EDKII_JSON_SORT_KEYS 0x80 #define EDKII_JSON_SORT_KEYS 0x80
#define EDKII_JSON_PRESERVE_ORDER 0x100 #define EDKII_JSON_PRESERVE_ORDER 0x100
#define EDKII_JSON_ENCODE_ANY 0x200 #define EDKII_JSON_ENCODE_ANY 0x200
#define EDKII_JSON_ESCAPE_SLASH 0x400 #define EDKII_JSON_ESCAPE_SLASH 0x400
#define EDKII_JSON_REAL_PRECISION(n) (((n) & 0x1F) << 11) #define EDKII_JSON_REAL_PRECISION(n) (((n) & 0x1F) << 11)
#define EDKII_JSON_EMBED 0x10000 #define EDKII_JSON_EMBED 0x10000
/// ///
/// Map to the definitions in jansson.h /// Map to the definitions in jansson.h
/// See below URI for the JSON decoding flags reference. /// See below URI for the JSON decoding flags reference.
/// https://jansson.readthedocs.io/en/2.13/apiref.html?highlight=json_loadb#decoding /// https://jansson.readthedocs.io/en/2.13/apiref.html?highlight=json_loadb#decoding
/// ///
#define EDKII_JSON_REJECT_DUPLICATES 0x1 #define EDKII_JSON_REJECT_DUPLICATES 0x1
#define EDKII_JSON_DISABLE_EOF_CHECK 0x2 #define EDKII_JSON_DISABLE_EOF_CHECK 0x2
#define EDKII_JSON_DECODE_ANY 0x4 #define EDKII_JSON_DECODE_ANY 0x4
#define EDKII_JSON_DECODE_INT_AS_REAL 0x8 #define EDKII_JSON_DECODE_INT_AS_REAL 0x8
#define EDKII_JSON_ALLOW_NUL 0x10 #define EDKII_JSON_ALLOW_NUL 0x10
#define EDKII_JSON_ARRAY_FOREACH(Array, Index, Value) \ #define EDKII_JSON_ARRAY_FOREACH(Array, Index, Value) \
for(Index = 0; \ for(Index = 0; \
@ -63,28 +64,28 @@ typedef INT64 EDKII_JSON_INT_T; // #JSON_INTEGER_IS_LONG_LONG is set to 1
/// ///
/// Map to the json_error_t in jansson.h /// Map to the json_error_t in jansson.h
/// ///
#define EDKII_JSON_ERROR_TEXT_LENGTH 160 #define EDKII_JSON_ERROR_TEXT_LENGTH 160
#define EDKII_JSON_ERROR_SOURCE_LENGTH 80 #define EDKII_JSON_ERROR_SOURCE_LENGTH 80
typedef struct { typedef struct {
INTN Line; INTN Line;
INTN Column; INTN Column;
INTN Position; INTN Position;
CHAR8 Source [EDKII_JSON_ERROR_SOURCE_LENGTH]; CHAR8 Source[EDKII_JSON_ERROR_SOURCE_LENGTH];
CHAR8 Text [EDKII_JSON_ERROR_TEXT_LENGTH]; CHAR8 Text[EDKII_JSON_ERROR_TEXT_LENGTH];
} EDKII_JSON_ERROR; } EDKII_JSON_ERROR;
/// ///
/// Map to the json_type in jansson.h /// Map to the json_type in jansson.h
/// ///
typedef enum { typedef enum {
EdkiiJsonTypeObject, EdkiiJsonTypeObject,
EdkiiJsonTypeArray, EdkiiJsonTypeArray,
EdkiiJsonTypeString, EdkiiJsonTypeString,
EdkiiJsonTypeInteger, EdkiiJsonTypeInteger,
EdkiiJsonTypeReal, EdkiiJsonTypeReal,
EdkiiJsonTypeTrue, EdkiiJsonTypeTrue,
EdkiiJsonTypeFalse, EdkiiJsonTypeFalse,
EdkiiJsonTypeNull EdkiiJsonTypeNull
} EDKII_JSON_TYPE; } EDKII_JSON_TYPE;
/** /**
@ -147,7 +148,7 @@ JsonValueInitObject (
EDKII_JSON_VALUE EDKII_JSON_VALUE
EFIAPI EFIAPI
JsonValueInitAsciiString ( JsonValueInitAsciiString (
IN CONST CHAR8 *String IN CONST CHAR8 *String
); );
/** /**
@ -170,7 +171,7 @@ JsonValueInitAsciiString (
EDKII_JSON_VALUE EDKII_JSON_VALUE
EFIAPI EFIAPI
JsonValueInitUnicodeString ( JsonValueInitUnicodeString (
IN CHAR16 *String IN CHAR16 *String
); );
/** /**
@ -190,7 +191,7 @@ JsonValueInitUnicodeString (
EDKII_JSON_VALUE EDKII_JSON_VALUE
EFIAPI EFIAPI
JsonValueInitInteger ( JsonValueInitInteger (
IN INT64 Value IN INT64 Value
); );
/** /**
@ -207,7 +208,7 @@ JsonValueInitInteger (
EDKII_JSON_VALUE EDKII_JSON_VALUE
EFIAPI EFIAPI
JsonValueInitBoolean ( JsonValueInitBoolean (
IN BOOLEAN Value IN BOOLEAN Value
); );
/** /**
@ -278,7 +279,7 @@ JsonValueInitFalse (
VOID VOID
EFIAPI EFIAPI
JsonValueFree ( JsonValueFree (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
); );
/** /**
@ -301,7 +302,7 @@ JsonValueFree (
EDKII_JSON_VALUE EDKII_JSON_VALUE
EFIAPI EFIAPI
JsonValueClone ( JsonValueClone (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
); );
/** /**
@ -316,7 +317,7 @@ JsonValueClone (
BOOLEAN BOOLEAN
EFIAPI EFIAPI
JsonValueIsArray ( JsonValueIsArray (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
); );
/** /**
@ -331,7 +332,7 @@ JsonValueIsArray (
BOOLEAN BOOLEAN
EFIAPI EFIAPI
JsonValueIsObject ( JsonValueIsObject (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
); );
/** /**
@ -347,7 +348,7 @@ JsonValueIsObject (
BOOLEAN BOOLEAN
EFIAPI EFIAPI
JsonValueIsString ( JsonValueIsString (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
); );
/** /**
@ -362,7 +363,7 @@ JsonValueIsString (
BOOLEAN BOOLEAN
EFIAPI EFIAPI
JsonValueIsInteger ( JsonValueIsInteger (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
); );
/** /**
@ -377,7 +378,7 @@ JsonValueIsInteger (
BOOLEAN BOOLEAN
EFIAPI EFIAPI
JsonValueIsNumber ( JsonValueIsNumber (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
); );
/** /**
@ -392,7 +393,7 @@ JsonValueIsNumber (
BOOLEAN BOOLEAN
EFIAPI EFIAPI
JsonValueIsBoolean ( JsonValueIsBoolean (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
); );
/** /**
@ -407,7 +408,7 @@ JsonValueIsBoolean (
BOOLEAN BOOLEAN
EFIAPI EFIAPI
JsonValueIsTrue ( JsonValueIsTrue (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
); );
/** /**
@ -422,7 +423,7 @@ JsonValueIsTrue (
BOOLEAN BOOLEAN
EFIAPI EFIAPI
JsonValueIsFalse ( JsonValueIsFalse (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
); );
/** /**
@ -437,7 +438,7 @@ JsonValueIsFalse (
BOOLEAN BOOLEAN
EFIAPI EFIAPI
JsonValueIsNull ( JsonValueIsNull (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
); );
/** /**
@ -453,7 +454,7 @@ JsonValueIsNull (
EDKII_JSON_ARRAY EDKII_JSON_ARRAY
EFIAPI EFIAPI
JsonValueGetArray ( JsonValueGetArray (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
); );
/** /**
@ -469,7 +470,7 @@ JsonValueGetArray (
EDKII_JSON_OBJECT EDKII_JSON_OBJECT
EFIAPI EFIAPI
JsonValueGetObject ( JsonValueGetObject (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
); );
/** /**
@ -485,7 +486,7 @@ JsonValueGetObject (
CONST CHAR8 * CONST CHAR8 *
EFIAPI EFIAPI
JsonValueGetAsciiString ( JsonValueGetAsciiString (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
); );
/** /**
@ -499,10 +500,10 @@ JsonValueGetAsciiString (
@retval Return the associated Unicode string in JSON value or NULL. @retval Return the associated Unicode string in JSON value or NULL.
**/ **/
CHAR16* CHAR16 *
EFIAPI EFIAPI
JsonValueGetUnicodeString ( JsonValueGetUnicodeString (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
); );
/** /**
@ -519,7 +520,7 @@ JsonValueGetUnicodeString (
INT64 INT64
EFIAPI EFIAPI
JsonValueGetInteger ( JsonValueGetInteger (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
); );
/** /**
@ -536,7 +537,7 @@ JsonValueGetInteger (
BOOLEAN BOOLEAN
EFIAPI EFIAPI
JsonValueGetBoolean ( JsonValueGetBoolean (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
); );
/** /**
@ -549,10 +550,10 @@ JsonValueGetBoolean (
@retval Return the associated Ascii string in JSON value or NULL on errors. @retval Return the associated Ascii string in JSON value or NULL on errors.
**/ **/
CONST CHAR8* CONST CHAR8 *
EFIAPI EFIAPI
JsonValueGetString ( JsonValueGetString (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
); );
/** /**
@ -567,7 +568,7 @@ JsonValueGetString (
UINTN UINTN
EFIAPI EFIAPI
JsonObjectSize ( JsonObjectSize (
IN EDKII_JSON_OBJECT JsonObject IN EDKII_JSON_OBJECT JsonObject
); );
/** /**
@ -583,10 +584,10 @@ JsonObjectSize (
JsonObj is not an JSON object, key count is zero or on other errors. JsonObj is not an JSON object, key count is zero or on other errors.
**/ **/
CHAR8** CHAR8 **
JsonObjectGetKeys ( JsonObjectGetKeys (
IN EDKII_JSON_OBJECT JsonObj, IN EDKII_JSON_OBJECT JsonObj,
OUT UINTN *KeyCount OUT UINTN *KeyCount
); );
/** /**
@ -608,8 +609,8 @@ JsonObjectGetKeys (
EDKII_JSON_VALUE EDKII_JSON_VALUE
EFIAPI EFIAPI
JsonObjectGetValue ( JsonObjectGetValue (
IN CONST EDKII_JSON_OBJECT JsonObj, IN CONST EDKII_JSON_OBJECT JsonObj,
IN CONST CHAR8 *Key IN CONST CHAR8 *Key
); );
/** /**
@ -633,9 +634,9 @@ JsonObjectGetValue (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
JsonObjectSetValue ( JsonObjectSetValue (
IN EDKII_JSON_OBJECT JsonObj, IN EDKII_JSON_OBJECT JsonObj,
IN CONST CHAR8 *Key, IN CONST CHAR8 *Key,
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
); );
/** /**
@ -650,7 +651,7 @@ JsonObjectSetValue (
UINTN UINTN
EFIAPI EFIAPI
JsonArrayCount ( JsonArrayCount (
IN EDKII_JSON_ARRAY JsonArray IN EDKII_JSON_ARRAY JsonArray
); );
/** /**
@ -672,8 +673,8 @@ JsonArrayCount (
EDKII_JSON_VALUE EDKII_JSON_VALUE
EFIAPI EFIAPI
JsonArrayGetValue ( JsonArrayGetValue (
IN EDKII_JSON_ARRAY JsonArray, IN EDKII_JSON_ARRAY JsonArray,
IN UINTN Index IN UINTN Index
); );
/** /**
@ -692,8 +693,8 @@ JsonArrayGetValue (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
JsonArrayAppendValue ( JsonArrayAppendValue (
IN EDKII_JSON_ARRAY JsonArray, IN EDKII_JSON_ARRAY JsonArray,
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
); );
/** /**
@ -713,8 +714,8 @@ JsonArrayAppendValue (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
JsonArrayRemoveValue ( JsonArrayRemoveValue (
IN EDKII_JSON_ARRAY JsonArray, IN EDKII_JSON_ARRAY JsonArray,
IN UINTN Index IN UINTN Index
); );
/** /**
@ -742,8 +743,8 @@ JsonArrayRemoveValue (
CHAR8 * CHAR8 *
EFIAPI EFIAPI
JsonDumpString ( JsonDumpString (
IN EDKII_JSON_VALUE JsonValue, IN EDKII_JSON_VALUE JsonValue,
IN UINTN Flags IN UINTN Flags
); );
/** /**
@ -766,9 +767,9 @@ JsonDumpString (
EDKII_JSON_VALUE EDKII_JSON_VALUE
EFIAPI EFIAPI
JsonLoadString ( JsonLoadString (
IN CONST CHAR8* String, IN CONST CHAR8 *String,
IN UINT64 Flags, IN UINT64 Flags,
IN EDKII_JSON_ERROR *Error IN EDKII_JSON_ERROR *Error
); );
/** /**
@ -793,7 +794,7 @@ JsonLoadString (
EDKII_JSON_VALUE EDKII_JSON_VALUE
EFIAPI EFIAPI
JsonLoadBuffer ( JsonLoadBuffer (
IN CONST CHAR8 *Buffer, IN CONST CHAR8 *Buffer,
IN UINTN BufferLen, IN UINTN BufferLen,
IN UINTN Flags, IN UINTN Flags,
IN OUT EDKII_JSON_ERROR *Error IN OUT EDKII_JSON_ERROR *Error
@ -815,7 +816,7 @@ JsonLoadBuffer (
VOID VOID
EFIAPI EFIAPI
JsonDecreaseReference ( JsonDecreaseReference (
IN EDKII_JSON_VALUE JsonValue IN EDKII_JSON_VALUE JsonValue
); );
/** /**
@ -833,8 +834,9 @@ JsonDecreaseReference (
EDKII_JSON_VALUE EDKII_JSON_VALUE
EFIAPI EFIAPI
JsonIncreaseReference ( JsonIncreaseReference (
IN EDKII_JSON_VALUE JsonValue IN EDKII_JSON_VALUE JsonValue
); );
/** /**
Returns an opaque iterator which can be used to iterate over all key-value pairs Returns an opaque iterator which can be used to iterate over all key-value pairs
in object, or NULL if object is empty in object, or NULL if object is empty
@ -844,7 +846,7 @@ JsonIncreaseReference (
VOID * VOID *
EFIAPI EFIAPI
JsonObjectIterator ( JsonObjectIterator (
IN EDKII_JSON_VALUE JsonValue IN EDKII_JSON_VALUE JsonValue
); );
/** /**
@ -855,7 +857,7 @@ JsonObjectIterator (
EDKII_JSON_VALUE EDKII_JSON_VALUE
EFIAPI EFIAPI
JsonObjectIteratorValue ( JsonObjectIteratorValue (
IN VOID *Iterator IN VOID *Iterator
); );
/** /**
@ -869,8 +871,8 @@ JsonObjectIteratorValue (
VOID * VOID *
EFIAPI EFIAPI
JsonObjectIteratorNext ( JsonObjectIteratorNext (
IN EDKII_JSON_VALUE JsonValue, IN EDKII_JSON_VALUE JsonValue,
IN VOID *Iterator IN VOID *Iterator
); );
/** /**
@ -882,8 +884,8 @@ JsonObjectIteratorNext (
CHAR8 * CHAR8 *
EFIAPI EFIAPI
JsonObjectIteratorKey ( JsonObjectIteratorKey (
IN VOID *Iterator IN VOID *Iterator
); );
/** /**
Returns the pointer of iterator by key. Returns the pointer of iterator by key.
@ -894,8 +896,8 @@ JsonObjectIteratorKey (
VOID * VOID *
EFIAPI EFIAPI
JsonObjectKeyToIterator ( JsonObjectKeyToIterator (
IN CHAR8 *Key IN CHAR8 *Key
); );
/** /**
Returns the json type of this json value Returns the json type of this json value
@ -905,7 +907,8 @@ JsonObjectKeyToIterator (
**/ **/
EDKII_JSON_TYPE EDKII_JSON_TYPE
EFIAPI EFIAPI
JsonGetType( JsonGetType (
IN EDKII_JSON_VALUE JsonValue IN EDKII_JSON_VALUE JsonValue
); );
#endif #endif

View File

@ -6,6 +6,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef REDFISH_CONTENT_CODING_LIB_H_ #ifndef REDFISH_CONTENT_CODING_LIB_H_
#define REDFISH_CONTENT_CODING_LIB_H_ #define REDFISH_CONTENT_CODING_LIB_H_
@ -36,11 +37,11 @@
EFI_STATUS EFI_STATUS
RedfishContentEncode ( RedfishContentEncode (
IN CHAR8 *ContentEncodedValue, IN CHAR8 *ContentEncodedValue,
IN CHAR8 *OriginalContent, IN CHAR8 *OriginalContent,
IN UINTN OriginalContentLength, IN UINTN OriginalContentLength,
OUT VOID **EncodedContentPointer, OUT VOID **EncodedContentPointer,
OUT UINTN *EncodedLength OUT UINTN *EncodedLength
); );
/** /**
@ -69,10 +70,11 @@ RedfishContentEncode (
**/ **/
EFI_STATUS EFI_STATUS
RedfishContentDecode ( RedfishContentDecode (
IN CHAR8 *ContentEncodedValue, IN CHAR8 *ContentEncodedValue,
IN VOID *ContentPointer, IN VOID *ContentPointer,
IN UINTN ContentLength, IN UINTN ContentLength,
OUT VOID **DecodedContentPointer, OUT VOID **DecodedContentPointer,
OUT UINTN *DecodedLength OUT UINTN *DecodedLength
); );
#endif #endif

View File

@ -6,6 +6,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef REDFISH_CREDENTIAL_LIB_H_ #ifndef REDFISH_CREDENTIAL_LIB_H_
#define REDFISH_CREDENTIAL_LIB_H_ #define REDFISH_CREDENTIAL_LIB_H_
@ -20,7 +21,7 @@ VOID
EFIAPI EFIAPI
LibCredentialExitBootServicesNotify ( LibCredentialExitBootServicesNotify (
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This
); );
/** /**
Notification of End of DXe. Notification of End of DXe.
@ -31,7 +32,7 @@ VOID
EFIAPI EFIAPI
LibCredentialEndOfDxeNotify ( LibCredentialEndOfDxeNotify (
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This
); );
/** /**
Retrieve platform's Redfish authentication information. Retrieve platform's Redfish authentication information.
@ -64,7 +65,7 @@ LibCredentialGetAuthInfo (
OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod, OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod,
OUT CHAR8 **UserId, OUT CHAR8 **UserId,
OUT CHAR8 **Password OUT CHAR8 **Password
); );
/** /**
Notify the Redfish service provide to stop provide configuration service to this platform. Notify the Redfish service provide to stop provide configuration service to this platform.
@ -85,7 +86,8 @@ LibCredentialGetAuthInfo (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
LibStopRedfishService ( LibStopRedfishService (
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This, IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This,
IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType
); );
#endif #endif

View File

@ -19,74 +19,76 @@
#define MAX_STRING_SIZE 0x10000000 #define MAX_STRING_SIZE 0x10000000
// Minimum value for an object of type long long int. // Minimum value for an object of type long long int.
#define LLONG_MIN MIN_INT64 #define LLONG_MIN MIN_INT64
// Maximum value for an object of type long long int. // Maximum value for an object of type long long int.
#define LLONG_MAX MAX_INT64 #define LLONG_MAX MAX_INT64
// We dont support double on edk2 // We dont support double on edk2
#define HUGE_VAL 0 #define HUGE_VAL 0
#if defined(MDE_CPU_X64) || defined(MDE_CPU_AARCH64) || defined(MDE_CPU_RISCV64) #if defined (MDE_CPU_X64) || defined (MDE_CPU_AARCH64) || defined (MDE_CPU_RISCV64)
// //
// With GCC we would normally use SIXTY_FOUR_BIT_LONG, but MSVC needs // With GCC we would normally use SIXTY_FOUR_BIT_LONG, but MSVC needs
// SIXTY_FOUR_BIT, because 'long' is 32-bit and only 'long long' is // SIXTY_FOUR_BIT, because 'long' is 32-bit and only 'long long' is
// 64-bit. Since using 'long long' works fine on GCC too, just do that. // 64-bit. Since using 'long long' works fine on GCC too, just do that.
// //
#define SIXTY_FOUR_BIT #define SIXTY_FOUR_BIT
#elif defined(MDE_CPU_IA32) || defined(MDE_CPU_ARM) || defined(MDE_CPU_EBC) #elif defined (MDE_CPU_IA32) || defined (MDE_CPU_ARM) || defined (MDE_CPU_EBC)
#define THIRTY_TWO_BIT #define THIRTY_TWO_BIT
#endif #endif
// //
// Map all va_xxxx elements to VA_xxx defined in MdePkg/Include/Base.h // Map all va_xxxx elements to VA_xxx defined in MdePkg/Include/Base.h
// //
#if !defined(__CC_ARM) // if va_list is not already defined #if !defined (__CC_ARM) // if va_list is not already defined
#define va_list VA_LIST #define va_list VA_LIST
#define va_arg VA_ARG #define va_arg VA_ARG
#define va_start VA_START #define va_start VA_START
#define va_end VA_END #define va_end VA_END
#else // __CC_ARM #else // __CC_ARM
#define va_start(Marker, Parameter) __va_start(Marker, Parameter) #define va_start(Marker, Parameter) __va_start(Marker, Parameter)
#define va_arg(Marker, TYPE) __va_arg(Marker, TYPE) #define va_arg(Marker, TYPE) __va_arg(Marker, TYPE)
#define va_end(Marker) ((void)0) #define va_end(Marker) ((void)0)
#endif #endif
// //
// Definitions for global constants used by CRT library routines // Definitions for global constants used by CRT library routines
// //
#define INT_MAX MAX_INT32 /* Maximum (signed) int value */ #define INT_MAX MAX_INT32 /* Maximum (signed) int value */
#define LONG_MAX 0X7FFFFFFFL /* max value for a long */ #define LONG_MAX 0X7FFFFFFFL /* max value for a long */
#define LONG_MIN (-LONG_MAX-1) /* min value for a long */ #define LONG_MIN (-LONG_MAX-1) /* min value for a long */
#define ULONG_MAX 0xFFFFFFFF /* Maximum unsigned long value */ #define ULONG_MAX 0xFFFFFFFF /* Maximum unsigned long value */
#define CHAR_BIT 8 /* Number of bits in a char */ #define CHAR_BIT 8 /* Number of bits in a char */
// Maximum value for an object of type unsigned long long int. // Maximum value for an object of type unsigned long long int.
#define ULLONG_MAX 0xFFFFFFFFFFFFFFFFULL // 2^64 - 1 #define ULLONG_MAX 0xFFFFFFFFFFFFFFFFULL // 2^64 - 1
// Maximum value for an object of type unsigned char. // Maximum value for an object of type unsigned char.
#define UCHAR_MAX 255 // 2^8 - 1 #define UCHAR_MAX 255 // 2^8 - 1
// //
// Basic types mapping // Basic types mapping
// //
typedef UINTN size_t; typedef UINTN size_t;
typedef INTN ssize_t; typedef INTN ssize_t;
typedef INT32 time_t; typedef INT32 time_t;
typedef UINT8 __uint8_t; typedef UINT8 __uint8_t;
typedef UINT8 sa_family_t; typedef UINT8 sa_family_t;
typedef UINT32 uid_t; typedef UINT32 uid_t;
typedef UINT32 gid_t; typedef UINT32 gid_t;
typedef INT32 int32_t; typedef INT32 int32_t;
typedef UINT32 uint32_t; typedef UINT32 uint32_t;
typedef UINT16 uint16_t; typedef UINT16 uint16_t;
typedef UINT8 uint8_t; typedef UINT8 uint8_t;
typedef enum {false, true} bool; typedef enum {
false, true
} bool;
// //
// File operations are not required for EFI building, // File operations are not required for EFI building,
// so FILE is mapped to VOID * to pass build // so FILE is mapped to VOID * to pass build
// //
typedef VOID *FILE; typedef VOID *FILE;
/** /**
This is the Redfish version of CRT snprintf function, this function replaces "%s" to This is the Redfish version of CRT snprintf function, this function replaces "%s" to
@ -133,110 +135,406 @@ RedfishAsciiSPrint (
UINTN UINTN
EFIAPI EFIAPI
RedfishAsciiVSPrint ( RedfishAsciiVSPrint (
OUT CHAR8 *StartOfBuffer, OUT CHAR8 *StartOfBuffer,
IN UINTN BufferSize, IN UINTN BufferSize,
IN CONST CHAR8 *FormatString, IN CONST CHAR8 *FormatString,
IN VA_LIST Marker IN VA_LIST Marker
); );
// //
// Global variables // Global variables
// //
extern int errno; extern int errno;
extern FILE *stderr; extern FILE *stderr;
// //
// Function prototypes of CRT Library routines // Function prototypes of CRT Library routines
// //
void *malloc (size_t); void *
void *realloc (void *, size_t); malloc (
void *calloc (size_t Num, size_t Size); size_t
void free (void *); );
void *memset (void *, int, size_t);
int memcmp (const void *, const void *, size_t); void *
int isdigit (int); realloc (
int isspace (int); void *,
int tolower (int); size_t
int isupper (int); );
int isxdigit (int);
int isalnum (int); void *
void *memcpy (void *, const void *, size_t); calloc (
void *memset (void *, int, size_t); size_t Num,
void *memchr (const void *, int, size_t); size_t Size
int memcmp (const void *, const void *, size_t); );
void *memmove (void *, const void *, size_t);
int strcmp (const char *, const char *); void
int strncmp (const char *, const char *, size_t); free (
char *strcpy (char *, const char *); void *
size_t strlen (const char *); );
char *strcat (char *, const char *);
char *strchr (const char *, int); void *
int strcasecmp (const char *, const char *); memset (
int strncasecmp (const char *, const char *, size_t); void *,
char *strncpy (char *, size_t, const char *, size_t); int,
int strncmp (const char *, const char *, size_t); size_t
char *strrchr (const char *, int); );
unsigned long strtoul (const char *, char **, int);
char * strstr (const char *s1 , const char *s2); int
long strtol (const char *, char **, int); memcmp (
char *strerror (int); const void *,
size_t strspn (const char *, const char *); const void *,
char * strdup (const char *str); size_t
char * strpbrk (const char *s1, const char *s2); );
unsigned long long strtoull(const char * nptr, char ** endptr, int base);
long long strtoll (const char * nptr, char ** endptr, int base); int
long strtol (const char * nptr, char ** endptr, int base); isdigit (
double strtod (const char * __restrict nptr, char ** __restrict endptr); int
size_t strcspn (const char *, const char *); );
int printf (const char *, ...);
int sscanf (const char *, const char *, ...); int
FILE *fopen (const char *, const char *); isspace (
size_t fread (void *, size_t, size_t, FILE *); int
size_t fwrite (const void *, size_t, size_t, FILE *); );
int fclose (FILE *);
int fprintf (FILE *, const char *, ...); int
int fgetc (FILE * _File); tolower (
uid_t getuid (void); int
uid_t geteuid (void); );
gid_t getgid (void);
gid_t getegid (void); int
void qsort (void *, size_t, size_t, int (*)(const void *, const void *)); isupper (
char *getenv (const char *); int
#if defined(__GNUC__) && (__GNUC__ >= 2) );
void abort (void) __attribute__((__noreturn__));
int
isxdigit (
int
);
int
isalnum (
int
);
void *
memcpy (
void *,
const void *,
size_t
);
void *
memset (
void *,
int,
size_t
);
void *
memchr (
const void *,
int,
size_t
);
int
memcmp (
const void *,
const void *,
size_t
);
void *
memmove (
void *,
const void *,
size_t
);
int
strcmp (
const char *,
const char *
);
int
strncmp (
const char *,
const char *,
size_t
);
char *
strcpy (
char *,
const char *
);
size_t
strlen (
const char *
);
char *
strcat (
char *,
const char *
);
char *
strchr (
const char *,
int
);
int
strcasecmp (
const char *,
const char *
);
int
strncasecmp (
const char *,
const char *,
size_t
);
char *
strncpy (
char *,
size_t,
const char *,
size_t
);
int
strncmp (
const char *,
const char *,
size_t
);
char *
strrchr (
const char *,
int
);
unsigned long
strtoul (
const char *,
char **,
int
);
char *
strstr (
const char *s1,
const char *s2
);
long
strtol (
const char *,
char **,
int
);
char *
strerror (
int
);
size_t
strspn (
const char *,
const char *
);
char *
strdup (
const char *str
);
char *
strpbrk (
const char *s1,
const char *s2
);
unsigned long long
strtoull (
const char *nptr,
char **endptr,
int base
);
long long
strtoll (
const char *nptr,
char **endptr,
int base
);
long
strtol (
const char *nptr,
char **endptr,
int base
);
double
strtod (
const char *__restrict nptr,
char **__restrict endptr
);
size_t
strcspn (
const char *,
const char *
);
int
printf (
const char *,
...
);
int
sscanf (
const char *,
const char *,
...
);
FILE *
fopen (
const char *,
const char *
);
size_t
fread (
void *,
size_t,
size_t,
FILE *
);
size_t
fwrite (
const void *,
size_t,
size_t,
FILE *
);
int
fclose (
FILE *
);
int
fprintf (
FILE *,
const char *,
...
);
int
fgetc (
FILE *_File
);
uid_t
getuid (
void
);
uid_t
geteuid (
void
);
gid_t
getgid (
void
);
gid_t
getegid (
void
);
void
qsort (
void *,
size_t,
size_t,
int (*)(const void *, const void *)
);
char *
getenv (
const char *
);
#if defined (__GNUC__) && (__GNUC__ >= 2)
void
abort (
void
) __attribute__ ((__noreturn__));
#else #else
void abort (void); void
abort (
void
);
#endif #endif
int toupper (int); int
int Digit2Val (int); toupper (
time_t time (time_t *); int
);
int
Digit2Val (
int
);
time_t
time (
time_t *
);
// //
// Macros that directly map functions to BaseLib, BaseMemoryLib, and DebugLib functions // Macros that directly map functions to BaseLib, BaseMemoryLib, and DebugLib functions
// //
#define strcmp AsciiStrCmp #define strcmp AsciiStrCmp
#define memcpy(dest,source,count) CopyMem(dest,source,(UINTN)(count)) #define memcpy(dest, source, count) CopyMem(dest,source,(UINTN)(count))
#define memset(dest,ch,count) SetMem(dest,(UINTN)(count),(UINT8)(ch)) #define memset(dest, ch, count) SetMem(dest,(UINTN)(count),(UINT8)(ch))
#define memchr(buf,ch,count) ScanMem8(buf,(UINTN)(count),(UINT8)ch) #define memchr(buf, ch, count) ScanMem8(buf,(UINTN)(count),(UINT8)ch)
#define memcmp(buf1,buf2,count) (int)(CompareMem(buf1,buf2,(UINTN)(count))) #define memcmp(buf1, buf2, count) (int)(CompareMem(buf1,buf2,(UINTN)(count)))
#define memmove(dest,source,count) CopyMem(dest,source,(UINTN)(count)) #define memmove(dest, source, count) CopyMem(dest,source,(UINTN)(count))
#define strlen(str) (size_t)(AsciiStrnLenS(str,MAX_STRING_SIZE)) #define strlen(str) (size_t)(AsciiStrnLenS(str,MAX_STRING_SIZE))
#define strcpy(strDest,strSource) AsciiStrCpyS(strDest,(strlen(strSource)+1),strSource) #define strcpy(strDest, strSource) AsciiStrCpyS(strDest,(strlen(strSource)+1),strSource)
#define strncpy(strDest,strSource,count) AsciiStrnCpyS(strDest,(UINTN)count,strSource,(UINTN)count) #define strncpy(strDest, strSource, count) AsciiStrnCpyS(strDest,(UINTN)count,strSource,(UINTN)count)
#define strncpys(strDest, DestLen, strSource,count) AsciiStrnCpyS(strDest,DestLen,strSource,(UINTN)count) #define strncpys(strDest, DestLen, strSource, count) AsciiStrnCpyS(strDest,DestLen,strSource,(UINTN)count)
#define strcat(strDest,strSource) AsciiStrCatS(strDest,(strlen(strSource)+strlen(strDest)+1),strSource) #define strcat(strDest, strSource) AsciiStrCatS(strDest,(strlen(strSource)+strlen(strDest)+1),strSource)
#define strchr(str,ch) ScanMem8((VOID *)(str),AsciiStrSize(str),(UINT8)ch) #define strchr(str, ch) ScanMem8((VOID *)(str),AsciiStrSize(str),(UINT8)ch)
#define strcasecmp(str1,str2) (int)AsciiStriCmp(str1,str2) #define strcasecmp(str1, str2) (int)AsciiStriCmp(str1,str2)
#define strstr(s1,s2) AsciiStrStr(s1,s2) #define strstr(s1, s2) AsciiStrStr(s1,s2)
#define snprintf(buf,len,...) RedfishAsciiSPrint(buf,len,__VA_ARGS__) #define snprintf(buf, len, ...) RedfishAsciiSPrint(buf,len,__VA_ARGS__)
#define vsnprintf(buf,len,format,marker) RedfishAsciiVSPrint((buf),(len),(format),(marker)) #define vsnprintf(buf, len, format, marker) RedfishAsciiVSPrint((buf),(len),(format),(marker))
#define assert(expression) ASSERT(expression) #define assert(expression) ASSERT(expression)
#define offsetof(type,member) OFFSET_OF(type,member) #define offsetof(type, member) OFFSET_OF(type,member)
#define EOF (-1) #define EOF (-1)
extern int errno; extern int errno;
#define ERANGE 34 /* 34 Result too large */ #define ERANGE 34 /* 34 Result too large */
#endif #endif

View File

@ -6,6 +6,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef REDFISH_HOST_INTERFACE_LIB_H_ #ifndef REDFISH_HOST_INTERFACE_LIB_H_
#define REDFISH_HOST_INTERFACE_LIB_H_ #define REDFISH_HOST_INTERFACE_LIB_H_
@ -27,9 +28,10 @@
**/ **/
EFI_STATUS EFI_STATUS
RedfishPlatformHostInterfaceDeviceDescriptor ( RedfishPlatformHostInterfaceDeviceDescriptor (
IN UINT8 *DeviceType, IN UINT8 *DeviceType,
OUT REDFISH_INTERFACE_DATA **DeviceDescriptor OUT REDFISH_INTERFACE_DATA **DeviceDescriptor
); );
/** /**
Get platform Redfish host interface protocol data. Get platform Redfish host interface protocol data.
Caller should pass NULL in ProtocolRecord to retrive the first protocol record. Caller should pass NULL in ProtocolRecord to retrive the first protocol record.
@ -46,7 +48,8 @@ RedfishPlatformHostInterfaceDeviceDescriptor (
**/ **/
EFI_STATUS EFI_STATUS
RedfishPlatformHostInterfaceProtocolData ( RedfishPlatformHostInterfaceProtocolData (
IN OUT MC_HOST_INTERFACE_PROTOCOL_RECORD **ProtocolRecord, IN OUT MC_HOST_INTERFACE_PROTOCOL_RECORD **ProtocolRecord,
IN UINT8 IndexOfProtocolData IN UINT8 IndexOfProtocolData
); );
#endif #endif

View File

@ -32,11 +32,11 @@
**/ **/
EFI_STATUS EFI_STATUS
RestExLibCreateChild ( RestExLibCreateChild (
IN EFI_HANDLE Image, IN EFI_HANDLE Image,
IN EFI_REST_EX_SERVICE_ACCESS_MODE AccessMode, IN EFI_REST_EX_SERVICE_ACCESS_MODE AccessMode,
IN EFI_REST_EX_CONFIG_TYPE ConfigType, IN EFI_REST_EX_CONFIG_TYPE ConfigType,
IN EFI_REST_EX_SERVICE_TYPE ServiceType, IN EFI_REST_EX_SERVICE_TYPE ServiceType,
OUT EFI_HANDLE *ChildInstanceHandle OUT EFI_HANDLE *ChildInstanceHandle
); );
#endif #endif

View File

@ -21,8 +21,8 @@ typedef enum {
} DEVICE_PATH_MATCH_MODE; } DEVICE_PATH_MATCH_MODE;
typedef struct { typedef struct {
UINT32 DevicePathMatchMode; UINT32 DevicePathMatchMode;
UINT32 DevicePathNum; UINT32 DevicePathNum;
// //
// Example: // Example:
// {DEVICE_PATH("PciRoot(0)/Pci(0,0)/MAC(005056C00002,0x1)")} // {DEVICE_PATH("PciRoot(0)/Pci(0,0)/MAC(005056C00002,0x1)")}
@ -32,7 +32,7 @@ typedef struct {
// 0x03,0x0b,0x25,0x00,0x00,0x50,0x56,0xc0,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, // 0x03,0x0b,0x25,0x00,0x00,0x50,0x56,0xc0,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
// 0x7f,0xff,0x04,0x00} // 0x7f,0xff,0x04,0x00}
// //
EFI_DEVICE_PATH_PROTOCOL DevicePath[]; EFI_DEVICE_PATH_PROTOCOL DevicePath[];
} REST_EX_SERVICE_DEVICE_PATH_DATA; } REST_EX_SERVICE_DEVICE_PATH_DATA;
#endif #endif

View File

@ -19,15 +19,15 @@ typedef struct _EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL EDKII_REDFISH_CONFIG_HANDL
} }
typedef struct { typedef struct {
EFI_HANDLE RedfishServiceRestExHandle; ///< REST EX EFI handle associated with this Redfish service. EFI_HANDLE RedfishServiceRestExHandle; ///< REST EX EFI handle associated with this Redfish service.
UINTN RedfishServiceVersion; ///< Redfish service version. UINTN RedfishServiceVersion; ///< Redfish service version.
CHAR16 *RedfishServiceLocation; ///< Redfish service location. CHAR16 *RedfishServiceLocation; ///< Redfish service location.
CHAR16 *RedfishServiceUuid; ///< Redfish service UUID. CHAR16 *RedfishServiceUuid; ///< Redfish service UUID.
CHAR16 *RedfishServiceOs; ///< Redfish service OS. CHAR16 *RedfishServiceOs; ///< Redfish service OS.
CHAR16 *RedfishServiceOsVersion; ///< Redfish service OS version. CHAR16 *RedfishServiceOsVersion; ///< Redfish service OS version.
CHAR16 *RedfishServiceProduct; ///< Redfish service product name. CHAR16 *RedfishServiceProduct; ///< Redfish service product name.
CHAR16 *RedfishServiceProductVer; ///< Redfish service product version. CHAR16 *RedfishServiceProductVer; ///< Redfish service product version.
BOOLEAN RedfishServiceUseHttps; ///< Redfish service uses HTTPS. BOOLEAN RedfishServiceUseHttps; ///< Redfish service uses HTTPS.
} REDFISH_CONFIG_SERVICE_INFORMATION; } REDFISH_CONFIG_SERVICE_INFORMATION;
/** /**
@ -47,7 +47,7 @@ typedef struct {
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL_INIT) ( (EFIAPI *EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL_INIT)(
IN EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *This, IN EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *This,
IN REDFISH_CONFIG_SERVICE_INFORMATION *RedfishServiceinfo IN REDFISH_CONFIG_SERVICE_INFORMATION *RedfishServiceinfo
); );
@ -63,16 +63,15 @@ EFI_STATUS
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL_STOP) ( (EFIAPI *EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL_STOP)(
IN EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *This IN EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *This
); );
struct _EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL { struct _EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL {
EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL_INIT Init; EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL_INIT Init;
EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL_STOP Stop; EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL_STOP Stop;
}; };
extern EFI_GUID gdkIIRedfishConfigHandlerProtocolGuid;
extern EFI_GUID gdkIIRedfishConfigHandlerProtocolGuid;
#endif #endif

View File

@ -34,7 +34,6 @@ typedef enum {
ServiceStopTypeMax ServiceStopTypeMax
} EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE; } EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE;
/** /**
Retrieve platform's Redfish authentication information. Retrieve platform's Redfish authentication information.
@ -61,7 +60,7 @@ typedef enum {
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *EDKII_REDFISH_CREDENTIAL_PROTOCOL_GET_AUTH_INFO) ( (EFIAPI *EDKII_REDFISH_CREDENTIAL_PROTOCOL_GET_AUTH_INFO)(
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This, IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This,
OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod, OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod,
OUT CHAR8 **UserId, OUT CHAR8 **UserId,
@ -86,16 +85,16 @@ EFI_STATUS
**/ **/
typedef typedef
EFI_STATUS EFI_STATUS
(EFIAPI *EDKII_REDFISH_CREDENTIAL_PROTOCOL_STOP_SERVICE) ( (EFIAPI *EDKII_REDFISH_CREDENTIAL_PROTOCOL_STOP_SERVICE)(
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This, IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This,
IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType
); );
struct _EDKII_REDFISH_CREDENTIAL_PROTOCOL { struct _EDKII_REDFISH_CREDENTIAL_PROTOCOL {
EDKII_REDFISH_CREDENTIAL_PROTOCOL_GET_AUTH_INFO GetAuthInfo; EDKII_REDFISH_CREDENTIAL_PROTOCOL_GET_AUTH_INFO GetAuthInfo;
EDKII_REDFISH_CREDENTIAL_PROTOCOL_STOP_SERVICE StopService; EDKII_REDFISH_CREDENTIAL_PROTOCOL_STOP_SERVICE StopService;
}; };
extern EFI_GUID gEdkIIRedfishCredentialProtocolGuid; extern EFI_GUID gEdkIIRedfishCredentialProtocolGuid;
#endif #endif

View File

@ -26,17 +26,16 @@
**/ **/
UINT8 UINT8
GetUTF8SizeForUCS2 ( GetUTF8SizeForUCS2 (
IN CHAR8 *Utf8Buffer IN CHAR8 *Utf8Buffer
) )
{ {
CHAR8 TempChar; CHAR8 TempChar;
UINT8 Utf8Size; UINT8 Utf8Size;
ASSERT (Utf8Buffer != NULL); ASSERT (Utf8Buffer != NULL);
TempChar = *Utf8Buffer; TempChar = *Utf8Buffer;
if ((TempChar & 0xF0) == 0xF0) { if ((TempChar & 0xF0) == 0xF0) {
// //
// This format is not for UCS2. // This format is not for UCS2.
// //
@ -46,11 +45,9 @@ GetUTF8SizeForUCS2 (
Utf8Size = 1; Utf8Size = 1;
if ((TempChar & 0x80) == 0x80) { if ((TempChar & 0x80) == 0x80) {
if ((TempChar & 0xC0) == 0xC0) { if ((TempChar & 0xC0) == 0xC0) {
Utf8Size++;
Utf8Size ++;
if ((TempChar & 0xE0) == 0xE0) { if ((TempChar & 0xE0) == 0xE0) {
Utf8Size++;
Utf8Size ++;
} }
} }
} }
@ -74,16 +71,16 @@ GetUTF8SizeForUCS2 (
**/ **/
EFI_STATUS EFI_STATUS
GetUCS2CharByFormat ( GetUCS2CharByFormat (
IN CHAR8 *Utf8Buffer, IN CHAR8 *Utf8Buffer,
OUT CHAR16 *Ucs2Char OUT CHAR16 *Ucs2Char
) )
{ {
UINT8 Num1; UINT8 Num1;
UINT8 Num2; UINT8 Num2;
UINT8 Index; UINT8 Index;
CHAR8 Ucs2CharFormat[UNICODE_FORMAT_CHAR_SIZE]; /// two Hexadecimal digits Ascii string, like "3F" CHAR8 Ucs2CharFormat[UNICODE_FORMAT_CHAR_SIZE]; /// two Hexadecimal digits Ascii string, like "3F"
for (Index = 0; Index < 4; Index ++) { for (Index = 0; Index < 4; Index++) {
if ((*(Utf8Buffer + 2 + Index) & 0x80) != 0x00) { if ((*(Utf8Buffer + 2 + Index) & 0x80) != 0x00) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -95,19 +92,19 @@ GetUCS2CharByFormat (
// Get the First Number, Offset is 2 // Get the First Number, Offset is 2
// //
CopyMem (Ucs2CharFormat, Utf8Buffer + 2, UNICODE_FORMAT_CHAR_LEN); CopyMem (Ucs2CharFormat, Utf8Buffer + 2, UNICODE_FORMAT_CHAR_LEN);
Num1 = (UINT8) AsciiStrHexToUintn (Ucs2CharFormat); Num1 = (UINT8)AsciiStrHexToUintn (Ucs2CharFormat);
// //
// Get the Second Number, Offset is 4 // Get the Second Number, Offset is 4
// //
CopyMem (Ucs2CharFormat, Utf8Buffer + 4, UNICODE_FORMAT_CHAR_LEN); CopyMem (Ucs2CharFormat, Utf8Buffer + 4, UNICODE_FORMAT_CHAR_LEN);
Num2 = (UINT8) AsciiStrHexToUintn (Ucs2CharFormat); Num2 = (UINT8)AsciiStrHexToUintn (Ucs2CharFormat);
// //
// Ucs2Char is Little-Endian // Ucs2Char is Little-Endian
// //
*((CHAR8 *) Ucs2Char) = Num2; *((CHAR8 *)Ucs2Char) = Num2;
*(((CHAR8 *) Ucs2Char) + 1) = Num1; *(((CHAR8 *)Ucs2Char) + 1) = Num1;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -123,33 +120,30 @@ GetUCS2CharByFormat (
**/ **/
UINT8 UINT8
UCS2CharToUTF8 ( UCS2CharToUTF8 (
IN CHAR16 Ucs2Char, IN CHAR16 Ucs2Char,
OUT CHAR8 *Utf8Buffer OUT CHAR8 *Utf8Buffer
) )
{ {
UINT16 Ucs2Number; UINT16 Ucs2Number;
ASSERT (Utf8Buffer != NULL); ASSERT (Utf8Buffer != NULL);
Ucs2Number = (UINT16) Ucs2Char; Ucs2Number = (UINT16)Ucs2Char;
if (Ucs2Number <= 0x007F) { if (Ucs2Number <= 0x007F) {
// //
// UTF8 format: 0xxxxxxx // UTF8 format: 0xxxxxxx
// //
*Utf8Buffer = Ucs2Char & 0x7F; *Utf8Buffer = Ucs2Char & 0x7F;
return 1; return 1;
} else if ((Ucs2Number >= 0x0080) && (Ucs2Number <= 0x07FF)) {
} else if (Ucs2Number >= 0x0080 && Ucs2Number <= 0x07FF) {
// //
// UTF8 format: 110xxxxx 10xxxxxx // UTF8 format: 110xxxxx 10xxxxxx
// //
*(Utf8Buffer + 1) = (Ucs2Char & 0x3F) | 0x80; *(Utf8Buffer + 1) = (Ucs2Char & 0x3F) | 0x80;
*Utf8Buffer = ((Ucs2Char >> 6) & 0x1F) | 0xC0; *Utf8Buffer = ((Ucs2Char >> 6) & 0x1F) | 0xC0;
return 2; return 2;
} else {
} else { /// Ucs2Number >= 0x0800 && Ucs2Number <= 0xFFFF /// Ucs2Number >= 0x0800 && Ucs2Number <= 0xFFFF
// //
// UTF8 format: 1110xxxx 10xxxxxx 10xxxxxx // UTF8 format: 1110xxxx 10xxxxxx 10xxxxxx
@ -174,23 +168,22 @@ UCS2CharToUTF8 (
**/ **/
EFI_STATUS EFI_STATUS
UTF8ToUCS2Char ( UTF8ToUCS2Char (
IN CHAR8 *Utf8Buffer, IN CHAR8 *Utf8Buffer,
OUT CHAR16 *Ucs2Char OUT CHAR16 *Ucs2Char
) )
{ {
UINT8 Utf8Size; UINT8 Utf8Size;
CHAR8 *Ucs2Buffer; CHAR8 *Ucs2Buffer;
CHAR8 TempChar1; CHAR8 TempChar1;
CHAR8 TempChar2; CHAR8 TempChar2;
CHAR8 TempChar3; CHAR8 TempChar3;
ASSERT (Utf8Buffer != NULL && Ucs2Char != NULL); ASSERT (Utf8Buffer != NULL && Ucs2Char != NULL);
ZeroMem (Ucs2Char, sizeof (CHAR16)); ZeroMem (Ucs2Char, sizeof (CHAR16));
Ucs2Buffer = (CHAR8 *) Ucs2Char; Ucs2Buffer = (CHAR8 *)Ucs2Char;
Utf8Size = GetUTF8SizeForUCS2 (Utf8Buffer); Utf8Size = GetUTF8SizeForUCS2 (Utf8Buffer);
switch (Utf8Size) { switch (Utf8Size) {
case 1: case 1:
// //
@ -271,27 +264,26 @@ UTF8ToUCS2Char (
**/ **/
EFI_STATUS EFI_STATUS
UCS2StrToUTF8 ( UCS2StrToUTF8 (
IN CHAR16 *Ucs2Str, IN CHAR16 *Ucs2Str,
OUT CHAR8 **Utf8StrAddr OUT CHAR8 **Utf8StrAddr
) )
{ {
UINTN Ucs2StrIndex; UINTN Ucs2StrIndex;
UINTN Ucs2StrLength; UINTN Ucs2StrLength;
CHAR8 *Utf8Str; CHAR8 *Utf8Str;
UINTN Utf8StrLength; UINTN Utf8StrLength;
UINTN Utf8StrIndex; UINTN Utf8StrIndex;
CHAR8 Utf8Buffer[UTF8_BUFFER_FOR_UCS2_MAX_SIZE]; CHAR8 Utf8Buffer[UTF8_BUFFER_FOR_UCS2_MAX_SIZE];
UINT8 Utf8BufferSize; UINT8 Utf8BufferSize;
if (Ucs2Str == NULL || Utf8StrAddr == NULL) { if ((Ucs2Str == NULL) || (Utf8StrAddr == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
Ucs2StrLength = StrLen (Ucs2Str); Ucs2StrLength = StrLen (Ucs2Str);
Utf8StrLength = 0; Utf8StrLength = 0;
for (Ucs2StrIndex = 0; Ucs2StrIndex < Ucs2StrLength; Ucs2StrIndex ++) { for (Ucs2StrIndex = 0; Ucs2StrIndex < Ucs2StrLength; Ucs2StrIndex++) {
ZeroMem (Utf8Buffer, sizeof (Utf8Buffer)); ZeroMem (Utf8Buffer, sizeof (Utf8Buffer));
Utf8BufferSize = UCS2CharToUTF8 (Ucs2Str[Ucs2StrIndex], Utf8Buffer); Utf8BufferSize = UCS2CharToUTF8 (Ucs2Str[Ucs2StrIndex], Utf8Buffer);
Utf8StrLength += Utf8BufferSize; Utf8StrLength += Utf8BufferSize;
@ -303,8 +295,7 @@ UCS2StrToUTF8 (
} }
Utf8StrIndex = 0; Utf8StrIndex = 0;
for (Ucs2StrIndex = 0; Ucs2StrIndex < Ucs2StrLength; Ucs2StrIndex ++) { for (Ucs2StrIndex = 0; Ucs2StrIndex < Ucs2StrLength; Ucs2StrIndex++) {
ZeroMem (Utf8Buffer, sizeof (Utf8Buffer)); ZeroMem (Utf8Buffer, sizeof (Utf8Buffer));
Utf8BufferSize = UCS2CharToUTF8 (Ucs2Str[Ucs2StrIndex], Utf8Buffer); Utf8BufferSize = UCS2CharToUTF8 (Ucs2Str[Ucs2StrIndex], Utf8Buffer);
@ -313,7 +304,7 @@ UCS2StrToUTF8 (
} }
Utf8Str[Utf8StrIndex] = '\0'; Utf8Str[Utf8StrIndex] = '\0';
*Utf8StrAddr = Utf8Str; *Utf8StrAddr = Utf8Str;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -334,18 +325,18 @@ UCS2StrToUTF8 (
**/ **/
EFI_STATUS EFI_STATUS
UTF8StrToUCS2 ( UTF8StrToUCS2 (
IN CHAR8 *Utf8Str, IN CHAR8 *Utf8Str,
OUT CHAR16 **Ucs2StrAddr OUT CHAR16 **Ucs2StrAddr
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
UINTN Utf8StrIndex; UINTN Utf8StrIndex;
UINTN Utf8StrLength; UINTN Utf8StrLength;
UINTN Ucs2StrIndex; UINTN Ucs2StrIndex;
UINT8 Utf8BufferSize; UINT8 Utf8BufferSize;
CHAR16 *Ucs2StrTemp; CHAR16 *Ucs2StrTemp;
if (Utf8Str == NULL || Ucs2StrAddr == NULL) { if ((Utf8Str == NULL) || (Ucs2StrAddr == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -354,7 +345,7 @@ UTF8StrToUCS2 (
// //
Utf8StrLength = 0; Utf8StrLength = 0;
while (*(Utf8Str + Utf8StrLength) != '\0') { while (*(Utf8Str + Utf8StrLength) != '\0') {
Utf8StrLength ++; Utf8StrLength++;
} }
// //
@ -368,46 +359,39 @@ UTF8StrToUCS2 (
Utf8StrIndex = 0; Utf8StrIndex = 0;
Ucs2StrIndex = 0; Ucs2StrIndex = 0;
while (Utf8Str[Utf8StrIndex] != '\0') { while (Utf8Str[Utf8StrIndex] != '\0') {
if ((CompareMem (Utf8Str + Utf8StrIndex, "\\u", 2) == 0) &&
if (CompareMem (Utf8Str + Utf8StrIndex, "\\u", 2) == 0 && (Utf8StrLength - Utf8StrIndex >= UNICODE_FORMAT_LEN))
Utf8StrLength - Utf8StrIndex >= UNICODE_FORMAT_LEN) { {
Status = GetUCS2CharByFormat (Utf8Str + Utf8StrIndex, Ucs2StrTemp + Ucs2StrIndex); Status = GetUCS2CharByFormat (Utf8Str + Utf8StrIndex, Ucs2StrTemp + Ucs2StrIndex);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Utf8StrIndex += UNICODE_FORMAT_LEN; Utf8StrIndex += UNICODE_FORMAT_LEN;
Ucs2StrIndex ++; Ucs2StrIndex++;
} else { } else {
StrCpyS (Ucs2StrTemp + Ucs2StrIndex, 3, L"\\u"); StrCpyS (Ucs2StrTemp + Ucs2StrIndex, 3, L"\\u");
Ucs2StrIndex += 2; Ucs2StrIndex += 2;
Utf8StrIndex += 2; Utf8StrIndex += 2;
} }
} else { } else {
Utf8BufferSize = GetUTF8SizeForUCS2 (Utf8Str + Utf8StrIndex); Utf8BufferSize = GetUTF8SizeForUCS2 (Utf8Str + Utf8StrIndex);
if (Utf8BufferSize == 0 || Utf8StrLength - Utf8StrIndex < Utf8BufferSize) { if ((Utf8BufferSize == 0) || (Utf8StrLength - Utf8StrIndex < Utf8BufferSize)) {
FreePool (Ucs2StrTemp); FreePool (Ucs2StrTemp);
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
Status = UTF8ToUCS2Char (Utf8Str + Utf8StrIndex, Ucs2StrTemp + Ucs2StrIndex); Status = UTF8ToUCS2Char (Utf8Str + Utf8StrIndex, Ucs2StrTemp + Ucs2StrIndex);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
FreePool (Ucs2StrTemp); FreePool (Ucs2StrTemp);
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
Ucs2StrIndex ++; Ucs2StrIndex++;
Utf8StrIndex += Utf8BufferSize; Utf8StrIndex += Utf8BufferSize;
} }
} }
*Ucs2StrAddr = AllocateZeroPool ((Ucs2StrIndex + 1) * sizeof (CHAR16)); *Ucs2StrAddr = AllocateZeroPool ((Ucs2StrIndex + 1) * sizeof (CHAR16));
if (*Ucs2StrAddr == NULL) { if (*Ucs2StrAddr == NULL) {
FreePool (Ucs2StrTemp); FreePool (Ucs2StrTemp);
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
@ -418,4 +402,3 @@ UTF8StrToUCS2 (
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -15,7 +15,7 @@
#include <Protocol/Http.h> #include <Protocol/Http.h>
#include <Protocol/RestEx.h> #include <Protocol/RestEx.h>
#define REST_EX_CONFIG_DATA_LEN_UNKNOWN 0xff #define REST_EX_CONFIG_DATA_LEN_UNKNOWN 0xff
/** /**
This function allows the caller to create child handle for specific This function allows the caller to create child handle for specific
@ -33,27 +33,28 @@
**/ **/
EFI_STATUS EFI_STATUS
RestExLibCreateChild ( RestExLibCreateChild (
IN EFI_HANDLE Image, IN EFI_HANDLE Image,
IN EFI_REST_EX_SERVICE_ACCESS_MODE AccessMode, IN EFI_REST_EX_SERVICE_ACCESS_MODE AccessMode,
IN EFI_REST_EX_CONFIG_TYPE ConfigType, IN EFI_REST_EX_CONFIG_TYPE ConfigType,
IN EFI_REST_EX_SERVICE_TYPE ServiceType, IN EFI_REST_EX_SERVICE_TYPE ServiceType,
OUT EFI_HANDLE *ChildInstanceHandle OUT EFI_HANDLE *ChildInstanceHandle
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
UINTN NoBuffer; UINTN NoBuffer;
EFI_HANDLE *Handle; EFI_HANDLE *Handle;
EFI_HANDLE ChildHandle; EFI_HANDLE ChildHandle;
EFI_REST_EX_PROTOCOL *RestEx; EFI_REST_EX_PROTOCOL *RestEx;
EFI_REST_EX_SERVICE_INFO *RestExServiceInfo; EFI_REST_EX_SERVICE_INFO *RestExServiceInfo;
UINT8 LenOfConfig; UINT8 LenOfConfig;
if (Image == NULL || if ((Image == NULL) ||
AccessMode >= EfiRestExServiceModeMax || (AccessMode >= EfiRestExServiceModeMax) ||
ConfigType >= EfiRestExConfigTypeMax || (ConfigType >= EfiRestExConfigTypeMax) ||
ServiceType >= EfiRestExServiceTypeMax || (ServiceType >= EfiRestExServiceTypeMax) ||
ChildInstanceHandle == NULL (ChildInstanceHandle == NULL)
) { )
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -61,29 +62,31 @@ RestExLibCreateChild (
// //
// Locate all REST EX binding service. // Locate all REST EX binding service.
// //
Handle = NULL; Handle = NULL;
NoBuffer = 0; NoBuffer = 0;
Status = gBS->LocateHandleBuffer ( Status = gBS->LocateHandleBuffer (
ByProtocol, ByProtocol,
&gEfiRestExServiceBindingProtocolGuid, &gEfiRestExServiceBindingProtocolGuid,
NULL, NULL,
&NoBuffer, &NoBuffer,
&Handle &Handle
); );
if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) { if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
return Status; return Status;
} }
Handle = (EFI_HANDLE *)AllocateZeroPool (sizeof(EFI_HANDLE) * NoBuffer);
Handle = (EFI_HANDLE *)AllocateZeroPool (sizeof (EFI_HANDLE) * NoBuffer);
if (Handle == NULL) { if (Handle == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
Status = gBS->LocateHandleBuffer ( Status = gBS->LocateHandleBuffer (
ByProtocol, ByProtocol,
&gEfiRestExServiceBindingProtocolGuid, &gEfiRestExServiceBindingProtocolGuid,
NULL, NULL,
&NoBuffer, &NoBuffer,
&Handle &Handle
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
FreePool (Handle); FreePool (Handle);
return Status; return Status;
@ -94,21 +97,21 @@ RestExLibCreateChild (
// //
while (NoBuffer != 0) { while (NoBuffer != 0) {
ChildHandle = NULL; ChildHandle = NULL;
Status = NetLibCreateServiceChild ( Status = NetLibCreateServiceChild (
*(Handle + (NoBuffer - 1)), *(Handle + (NoBuffer - 1)),
Image, Image,
&gEfiRestExServiceBindingProtocolGuid, &gEfiRestExServiceBindingProtocolGuid,
&ChildHandle &ChildHandle
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ChildHandle, ChildHandle,
&gEfiRestExProtocolGuid, &gEfiRestExProtocolGuid,
(VOID **)&RestEx, (VOID **)&RestEx,
Image, Image,
NULL, NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ON_ERROR; goto ON_ERROR;
} }
@ -117,12 +120,13 @@ RestExLibCreateChild (
// Get the information of REST service provided by this EFI REST EX driver // Get the information of REST service provided by this EFI REST EX driver
// //
Status = RestEx->GetService ( Status = RestEx->GetService (
RestEx, RestEx,
&RestExServiceInfo &RestExServiceInfo
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ON_ERROR; goto ON_ERROR;
} }
// //
// Check REST EX property. // Check REST EX property.
// //
@ -138,13 +142,16 @@ RestExLibCreateChild (
default: default:
goto ON_ERROR; goto ON_ERROR;
} }
if (RestExServiceInfo->EfiRestExServiceInfoV10.RestServiceAccessMode != AccessMode ||
RestExServiceInfo->EfiRestExServiceInfoV10.RestServiceType != ServiceType || if ((RestExServiceInfo->EfiRestExServiceInfoV10.RestServiceAccessMode != AccessMode) ||
RestExServiceInfo->EfiRestExServiceInfoV10.RestExConfigType != ConfigType || (RestExServiceInfo->EfiRestExServiceInfoV10.RestServiceType != ServiceType) ||
((LenOfConfig != REST_EX_CONFIG_DATA_LEN_UNKNOWN) && (RestExServiceInfo->EfiRestExServiceInfoV10.RestExConfigDataLength != LenOfConfig))) { (RestExServiceInfo->EfiRestExServiceInfoV10.RestExConfigType != ConfigType) ||
((LenOfConfig != REST_EX_CONFIG_DATA_LEN_UNKNOWN) && (RestExServiceInfo->EfiRestExServiceInfoV10.RestExConfigDataLength != LenOfConfig)))
{
goto ON_ERROR; goto ON_ERROR;
} }
} }
// //
// This is proper REST EX instance. // This is proper REST EX instance.
// //
@ -159,8 +166,9 @@ ON_ERROR:;
&gEfiRestExServiceBindingProtocolGuid, &gEfiRestExServiceBindingProtocolGuid,
ChildHandle ChildHandle
); );
NoBuffer --; NoBuffer--;
}; }
FreePool (Handle); FreePool (Handle);
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }

View File

@ -36,7 +36,7 @@ JsonValueInitArray (
VOID VOID
) )
{ {
return (EDKII_JSON_VALUE)json_array(); return (EDKII_JSON_VALUE)json_array ();
} }
/** /**
@ -58,7 +58,7 @@ JsonValueInitObject (
VOID VOID
) )
{ {
return (EDKII_JSON_VALUE)json_object(); return (EDKII_JSON_VALUE)json_object ();
} }
/** /**
@ -83,10 +83,10 @@ JsonValueInitObject (
EDKII_JSON_VALUE EDKII_JSON_VALUE
EFIAPI EFIAPI
JsonValueInitAsciiString ( JsonValueInitAsciiString (
IN CONST CHAR8 *String IN CONST CHAR8 *String
) )
{ {
UINTN Index; UINTN Index;
if (String == NULL) { if (String == NULL) {
return NULL; return NULL;
@ -124,11 +124,11 @@ JsonValueInitAsciiString (
EDKII_JSON_VALUE EDKII_JSON_VALUE
EFIAPI EFIAPI
JsonValueInitUnicodeString ( JsonValueInitUnicodeString (
IN CHAR16 *String IN CHAR16 *String
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
CHAR8 *Utf8Str; CHAR8 *Utf8Str;
if (String == NULL) { if (String == NULL) {
return NULL; return NULL;
@ -160,7 +160,7 @@ JsonValueInitUnicodeString (
EDKII_JSON_VALUE EDKII_JSON_VALUE
EFIAPI EFIAPI
JsonValueInitInteger ( JsonValueInitInteger (
IN INT64 Value IN INT64 Value
) )
{ {
return (EDKII_JSON_VALUE)json_integer (Value); return (EDKII_JSON_VALUE)json_integer (Value);
@ -180,7 +180,7 @@ JsonValueInitInteger (
EDKII_JSON_VALUE EDKII_JSON_VALUE
EFIAPI EFIAPI
JsonValueInitBoolean ( JsonValueInitBoolean (
IN BOOLEAN Value IN BOOLEAN Value
) )
{ {
return (EDKII_JSON_VALUE)json_boolean (Value); return (EDKII_JSON_VALUE)json_boolean (Value);
@ -201,7 +201,7 @@ JsonValueInitTrue (
VOID VOID
) )
{ {
return (EDKII_JSON_VALUE)json_true(); return (EDKII_JSON_VALUE)json_true ();
} }
/** /**
@ -219,7 +219,7 @@ JsonValueInitFalse (
VOID VOID
) )
{ {
return (EDKII_JSON_VALUE)json_false(); return (EDKII_JSON_VALUE)json_false ();
} }
/** /**
@ -237,7 +237,7 @@ JsonValueInitNull (
VOID VOID
) )
{ {
return (EDKII_JSON_VALUE)json_null(); return (EDKII_JSON_VALUE)json_null ();
} }
/** /**
@ -263,10 +263,10 @@ JsonValueInitNull (
VOID VOID
EFIAPI EFIAPI
JsonValueFree ( JsonValueFree (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
json_decref((json_t *)Json); json_decref ((json_t *)Json);
} }
/** /**
@ -289,10 +289,10 @@ JsonValueFree (
EDKII_JSON_VALUE EDKII_JSON_VALUE
EFIAPI EFIAPI
JsonValueClone ( JsonValueClone (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
return (EDKII_JSON_VALUE)json_deep_copy ((json_t *) Json); return (EDKII_JSON_VALUE)json_deep_copy ((json_t *)Json);
} }
/** /**
@ -307,10 +307,10 @@ JsonValueClone (
BOOLEAN BOOLEAN
EFIAPI EFIAPI
JsonValueIsArray ( JsonValueIsArray (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
return json_is_array ((json_t *) Json); return json_is_array ((json_t *)Json);
} }
/** /**
@ -325,10 +325,10 @@ JsonValueIsArray (
BOOLEAN BOOLEAN
EFIAPI EFIAPI
JsonValueIsObject ( JsonValueIsObject (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
return json_is_object ((json_t *) Json); return json_is_object ((json_t *)Json);
} }
/** /**
@ -344,10 +344,10 @@ JsonValueIsObject (
BOOLEAN BOOLEAN
EFIAPI EFIAPI
JsonValueIsString ( JsonValueIsString (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
return json_is_string ((json_t *) Json); return json_is_string ((json_t *)Json);
} }
/** /**
@ -362,10 +362,10 @@ JsonValueIsString (
BOOLEAN BOOLEAN
EFIAPI EFIAPI
JsonValueIsInteger ( JsonValueIsInteger (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
return json_is_integer ((json_t *) Json); return json_is_integer ((json_t *)Json);
} }
/** /**
@ -380,10 +380,10 @@ JsonValueIsInteger (
BOOLEAN BOOLEAN
EFIAPI EFIAPI
JsonValueIsNumber ( JsonValueIsNumber (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
return json_is_number ((json_t *) Json); return json_is_number ((json_t *)Json);
} }
/** /**
@ -398,10 +398,10 @@ JsonValueIsNumber (
BOOLEAN BOOLEAN
EFIAPI EFIAPI
JsonValueIsBoolean ( JsonValueIsBoolean (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
return json_is_boolean ((json_t *) Json); return json_is_boolean ((json_t *)Json);
} }
/** /**
@ -416,12 +416,13 @@ JsonValueIsBoolean (
BOOLEAN BOOLEAN
EFIAPI EFIAPI
JsonValueIsTrue ( JsonValueIsTrue (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
if (json_is_true ((json_t *)Json)) { if (json_is_true ((json_t *)Json)) {
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
@ -437,14 +438,16 @@ JsonValueIsTrue (
BOOLEAN BOOLEAN
EFIAPI EFIAPI
JsonValueIsFalse ( JsonValueIsFalse (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
if (json_is_false ((json_t *)Json)) { if (json_is_false ((json_t *)Json)) {
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
/** /**
The function is used to return if the provided JSON value contains a JSON NULL. The function is used to return if the provided JSON value contains a JSON NULL.
@ -457,10 +460,10 @@ JsonValueIsFalse (
BOOLEAN BOOLEAN
EFIAPI EFIAPI
JsonValueIsNull ( JsonValueIsNull (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
return json_is_null ((json_t *) Json); return json_is_null ((json_t *)Json);
} }
/** /**
@ -476,10 +479,10 @@ JsonValueIsNull (
EDKII_JSON_ARRAY EDKII_JSON_ARRAY
EFIAPI EFIAPI
JsonValueGetArray ( JsonValueGetArray (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
if (Json == NULL || !JsonValueIsArray (Json)) { if ((Json == NULL) || !JsonValueIsArray (Json)) {
return NULL; return NULL;
} }
@ -499,10 +502,10 @@ JsonValueGetArray (
EDKII_JSON_OBJECT EDKII_JSON_OBJECT
EFIAPI EFIAPI
JsonValueGetObject ( JsonValueGetObject (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
if (Json == NULL || !JsonValueIsObject (Json)) { if ((Json == NULL) || !JsonValueIsObject (Json)) {
return NULL; return NULL;
} }
@ -522,13 +525,13 @@ JsonValueGetObject (
CONST CHAR8 * CONST CHAR8 *
EFIAPI EFIAPI
JsonValueGetAsciiString ( JsonValueGetAsciiString (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
CONST CHAR8 *AsciiStr; CONST CHAR8 *AsciiStr;
UINTN Index; UINTN Index;
AsciiStr = json_string_value ((json_t *) Json); AsciiStr = json_string_value ((json_t *)Json);
if (AsciiStr == NULL) { if (AsciiStr == NULL) {
return NULL; return NULL;
} }
@ -556,22 +559,22 @@ JsonValueGetAsciiString (
@retval Return the associated Unicode string in JSON value or NULL. @retval Return the associated Unicode string in JSON value or NULL.
**/ **/
CHAR16* CHAR16 *
EFIAPI EFIAPI
JsonValueGetUnicodeString ( JsonValueGetUnicodeString (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
CONST CHAR8 *Utf8Str; CONST CHAR8 *Utf8Str;
CHAR16 *Ucs2Str; CHAR16 *Ucs2Str;
Utf8Str = json_string_value ((json_t *) Json); Utf8Str = json_string_value ((json_t *)Json);
if (Utf8Str == NULL) { if (Utf8Str == NULL) {
return NULL; return NULL;
} }
Status = UTF8StrToUCS2 ((CHAR8*)Utf8Str, &Ucs2Str); Status = UTF8StrToUCS2 ((CHAR8 *)Utf8Str, &Ucs2Str);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return NULL; return NULL;
} }
@ -593,15 +596,15 @@ JsonValueGetUnicodeString (
INT64 INT64
EFIAPI EFIAPI
JsonValueGetInteger ( JsonValueGetInteger (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
ASSERT (Json != NULL && JsonValueIsInteger (Json)); ASSERT (Json != NULL && JsonValueIsInteger (Json));
if (Json == NULL || !JsonValueIsInteger (Json)) { if ((Json == NULL) || !JsonValueIsInteger (Json)) {
return 0; return 0;
} }
return json_integer_value ((json_t *) Json); return json_integer_value ((json_t *)Json);
} }
/** /**
@ -618,15 +621,15 @@ JsonValueGetInteger (
BOOLEAN BOOLEAN
EFIAPI EFIAPI
JsonValueGetBoolean ( JsonValueGetBoolean (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
ASSERT (Json != NULL && JsonValueIsBoolean (Json)); ASSERT (Json != NULL && JsonValueIsBoolean (Json));
if (Json == NULL || !JsonValueIsBoolean (Json)) { if ((Json == NULL) || !JsonValueIsBoolean (Json)) {
return FALSE; return FALSE;
} }
return json_is_true ((json_t *) Json); return json_is_true ((json_t *)Json);
} }
/** /**
@ -639,10 +642,10 @@ JsonValueGetBoolean (
@retval Return the associated Ascii string in JSON value or NULL on errors. @retval Return the associated Ascii string in JSON value or NULL on errors.
**/ **/
CONST CHAR8* CONST CHAR8 *
EFIAPI EFIAPI
JsonValueGetString ( JsonValueGetString (
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
return json_string_value ((const json_t *)Json); return json_string_value ((const json_t *)Json);
@ -660,10 +663,10 @@ JsonValueGetString (
UINTN UINTN
EFIAPI EFIAPI
JsonObjectSize ( JsonObjectSize (
IN EDKII_JSON_OBJECT JsonObject IN EDKII_JSON_OBJECT JsonObject
) )
{ {
return json_object_size ((json_t *) JsonObject); return json_object_size ((json_t *)JsonObject);
} }
/** /**
@ -679,24 +682,23 @@ JsonObjectSize (
JsonObj is not an JSON object, key count is zero or on other errors. JsonObj is not an JSON object, key count is zero or on other errors.
**/ **/
CHAR8** CHAR8 **
JsonObjectGetKeys ( JsonObjectGetKeys (
IN EDKII_JSON_OBJECT JsonObj, IN EDKII_JSON_OBJECT JsonObj,
OUT UINTN *KeyCount OUT UINTN *KeyCount
) )
{ {
UINTN Index;
CONST CHAR8 **KeyArray;
CONST CHAR8 *Key;
EDKII_JSON_VALUE Value;
UINTN Index; if ((JsonObj == NULL) || (KeyCount == NULL)) {
CONST CHAR8 **KeyArray;
CONST CHAR8 *Key;
EDKII_JSON_VALUE Value;
if (JsonObj == NULL || KeyCount == NULL) {
return NULL; return NULL;
} }
Index = 0; Index = 0;
json_object_foreach(JsonObj, Key, Value) { json_object_foreach (JsonObj, Key, Value) {
Index++; Index++;
} }
if (Index == 0) { if (Index == 0) {
@ -705,7 +707,7 @@ JsonObjectGetKeys (
} }
*KeyCount = Index; *KeyCount = Index;
KeyArray = (CONST CHAR8 **) AllocateZeroPool (*KeyCount * sizeof (CHAR8 *)); KeyArray = (CONST CHAR8 **)AllocateZeroPool (*KeyCount * sizeof (CHAR8 *));
if (KeyArray == NULL) { if (KeyArray == NULL) {
return NULL; return NULL;
} }
@ -713,7 +715,7 @@ JsonObjectGetKeys (
Key = NULL; Key = NULL;
Value = NULL; Value = NULL;
Index = 0; Index = 0;
json_object_foreach((json_t *) JsonObj, Key, Value) { json_object_foreach ((json_t *)JsonObj, Key, Value) {
KeyArray[Index] = Key; KeyArray[Index] = Key;
Index++; Index++;
} }
@ -740,8 +742,8 @@ JsonObjectGetKeys (
EDKII_JSON_VALUE EDKII_JSON_VALUE
EFIAPI EFIAPI
JsonObjectGetValue ( JsonObjectGetValue (
IN CONST EDKII_JSON_OBJECT JsonObj, IN CONST EDKII_JSON_OBJECT JsonObj,
IN CONST CHAR8 *Key IN CONST CHAR8 *Key
) )
{ {
return (EDKII_JSON_VALUE)json_object_get ((const json_t *)JsonObj, (const char *)Key); return (EDKII_JSON_VALUE)json_object_get ((const json_t *)JsonObj, (const char *)Key);
@ -768,12 +770,12 @@ JsonObjectGetValue (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
JsonObjectSetValue ( JsonObjectSetValue (
IN EDKII_JSON_OBJECT JsonObj, IN EDKII_JSON_OBJECT JsonObj,
IN CONST CHAR8 *Key, IN CONST CHAR8 *Key,
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
if (json_object_set ((json_t *) JsonObj, Key, (json_t *) Json) != 0) { if (json_object_set ((json_t *)JsonObj, Key, (json_t *)Json) != 0) {
return EFI_ABORTED; return EFI_ABORTED;
} else { } else {
return EFI_SUCCESS; return EFI_SUCCESS;
@ -792,10 +794,10 @@ JsonObjectSetValue (
UINTN UINTN
EFIAPI EFIAPI
JsonArrayCount ( JsonArrayCount (
IN EDKII_JSON_ARRAY JsonArray IN EDKII_JSON_ARRAY JsonArray
) )
{ {
return json_array_size ((json_t *) JsonArray); return json_array_size ((json_t *)JsonArray);
} }
/** /**
@ -817,11 +819,11 @@ JsonArrayCount (
EDKII_JSON_VALUE EDKII_JSON_VALUE
EFIAPI EFIAPI
JsonArrayGetValue ( JsonArrayGetValue (
IN EDKII_JSON_ARRAY JsonArray, IN EDKII_JSON_ARRAY JsonArray,
IN UINTN Index IN UINTN Index
) )
{ {
return (EDKII_JSON_VALUE)json_array_get ((json_t *) JsonArray, Index); return (EDKII_JSON_VALUE)json_array_get ((json_t *)JsonArray, Index);
} }
/** /**
@ -840,11 +842,11 @@ JsonArrayGetValue (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
JsonArrayAppendValue ( JsonArrayAppendValue (
IN EDKII_JSON_ARRAY JsonArray, IN EDKII_JSON_ARRAY JsonArray,
IN EDKII_JSON_VALUE Json IN EDKII_JSON_VALUE Json
) )
{ {
if (json_array_append ((json_t *) JsonArray, (json_t *) Json) != 0) { if (json_array_append ((json_t *)JsonArray, (json_t *)Json) != 0) {
return EFI_ABORTED; return EFI_ABORTED;
} else { } else {
return EFI_SUCCESS; return EFI_SUCCESS;
@ -868,11 +870,11 @@ JsonArrayAppendValue (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
JsonArrayRemoveValue ( JsonArrayRemoveValue (
IN EDKII_JSON_ARRAY JsonArray, IN EDKII_JSON_ARRAY JsonArray,
IN UINTN Index IN UINTN Index
) )
{ {
if (json_array_remove ((json_t *) JsonArray, Index) != 0) { if (json_array_remove ((json_t *)JsonArray, Index) != 0) {
return EFI_ABORTED; return EFI_ABORTED;
} else { } else {
return EFI_SUCCESS; return EFI_SUCCESS;
@ -904,14 +906,15 @@ JsonArrayRemoveValue (
CHAR8 * CHAR8 *
EFIAPI EFIAPI
JsonDumpString ( JsonDumpString (
IN EDKII_JSON_VALUE JsonValue, IN EDKII_JSON_VALUE JsonValue,
IN UINTN Flags IN UINTN Flags
) )
{ {
if (JsonValue == NULL) { if (JsonValue == NULL) {
return NULL; return NULL;
} }
return json_dumps((json_t *)JsonValue, Flags);
return json_dumps ((json_t *)JsonValue, Flags);
} }
/** /**
@ -934,12 +937,12 @@ JsonDumpString (
EDKII_JSON_VALUE EDKII_JSON_VALUE
EFIAPI EFIAPI
JsonLoadString ( JsonLoadString (
IN CONST CHAR8* String, IN CONST CHAR8 *String,
IN UINT64 Flags, IN UINT64 Flags,
IN EDKII_JSON_ERROR *Error IN EDKII_JSON_ERROR *Error
) )
{ {
return (EDKII_JSON_VALUE) json_loads ((const char *)String, Flags, (json_error_t *)Error); return (EDKII_JSON_VALUE)json_loads ((const char *)String, Flags, (json_error_t *)Error);
} }
/** /**
@ -964,13 +967,13 @@ JsonLoadString (
EDKII_JSON_VALUE EDKII_JSON_VALUE
EFIAPI EFIAPI
JsonLoadBuffer ( JsonLoadBuffer (
IN CONST CHAR8 *Buffer, IN CONST CHAR8 *Buffer,
IN UINTN BufferLen, IN UINTN BufferLen,
IN UINTN Flags, IN UINTN Flags,
IN OUT EDKII_JSON_ERROR *Error IN OUT EDKII_JSON_ERROR *Error
) )
{ {
return json_loadb(Buffer, BufferLen, Flags, (json_error_t *)Error); return json_loadb (Buffer, BufferLen, Flags, (json_error_t *)Error);
} }
/** /**
@ -989,7 +992,7 @@ JsonLoadBuffer (
VOID VOID
EFIAPI EFIAPI
JsonDecreaseReference ( JsonDecreaseReference (
IN EDKII_JSON_VALUE JsonValue IN EDKII_JSON_VALUE JsonValue
) )
{ {
json_decref (JsonValue); json_decref (JsonValue);
@ -1010,7 +1013,7 @@ JsonDecreaseReference (
EDKII_JSON_VALUE EDKII_JSON_VALUE
EFIAPI EFIAPI
JsonIncreaseReference ( JsonIncreaseReference (
IN EDKII_JSON_VALUE JsonValue IN EDKII_JSON_VALUE JsonValue
) )
{ {
return json_incref (JsonValue); return json_incref (JsonValue);
@ -1026,7 +1029,7 @@ JsonIncreaseReference (
VOID * VOID *
EFIAPI EFIAPI
JsonObjectIterator ( JsonObjectIterator (
IN EDKII_JSON_VALUE JsonValue IN EDKII_JSON_VALUE JsonValue
) )
{ {
return json_object_iter (JsonValue); return json_object_iter (JsonValue);
@ -1041,10 +1044,10 @@ JsonObjectIterator (
EDKII_JSON_VALUE EDKII_JSON_VALUE
EFIAPI EFIAPI
JsonObjectIteratorValue ( JsonObjectIteratorValue (
IN VOID *Iterator IN VOID *Iterator
) )
{ {
return json_object_iter_value(Iterator); return json_object_iter_value (Iterator);
} }
/** /**
@ -1058,11 +1061,11 @@ JsonObjectIteratorValue (
VOID * VOID *
EFIAPI EFIAPI
JsonObjectIteratorNext ( JsonObjectIteratorNext (
IN EDKII_JSON_VALUE JsonValue, IN EDKII_JSON_VALUE JsonValue,
IN VOID *Iterator IN VOID *Iterator
) )
{ {
return json_object_iter_next(JsonValue, Iterator); return json_object_iter_next (JsonValue, Iterator);
} }
/** /**
@ -1074,10 +1077,10 @@ JsonObjectIteratorNext (
CHAR8 * CHAR8 *
EFIAPI EFIAPI
JsonObjectIteratorKey ( JsonObjectIteratorKey (
IN VOID *Iterator IN VOID *Iterator
) )
{ {
return (CHAR8 *)json_object_iter_key(Iterator); return (CHAR8 *)json_object_iter_key (Iterator);
} }
/** /**
@ -1089,10 +1092,10 @@ JsonObjectIteratorKey (
VOID * VOID *
EFIAPI EFIAPI
JsonObjectKeyToIterator ( JsonObjectKeyToIterator (
IN CHAR8 *Key IN CHAR8 *Key
) )
{ {
return json_object_key_to_iter(Key); return json_object_key_to_iter (Key);
} }
/** /**
@ -1104,7 +1107,7 @@ JsonObjectKeyToIterator (
EDKII_JSON_TYPE EDKII_JSON_TYPE
EFIAPI EFIAPI
JsonGetType ( JsonGetType (
IN EDKII_JSON_VALUE JsonValue IN EDKII_JSON_VALUE JsonValue
) )
{ {
return ((json_t *)JsonValue)->type; return ((json_t *)JsonValue)->type;

View File

@ -16,26 +16,26 @@
/// ///
/// We support long long on edk2 /// We support long long on edk2
/// ///
#define JSON_INTEGER_IS_LONG_LONG 1 #define JSON_INTEGER_IS_LONG_LONG 1
/// ///
/// We don't support locale on edk2 /// We don't support locale on edk2
/// ///
#define JSON_HAVE_LOCALECONV 0 #define JSON_HAVE_LOCALECONV 0
/// ///
/// We don't support atomic builtins on edk2 /// We don't support atomic builtins on edk2
/// ///
#define JSON_HAVE_ATOMIC_BUILTINS 0 #define JSON_HAVE_ATOMIC_BUILTINS 0
/// ///
/// We don't support sync builtins on edk2 /// We don't support sync builtins on edk2
/// ///
#define JSON_HAVE_SYNC_BUILTINS 0 #define JSON_HAVE_SYNC_BUILTINS 0
/// ///
/// Mzximum deepth is set to 2048 /// Mzximum deepth is set to 2048
/// ///
#define JSON_PARSER_MAX_DEPTH 2048 #define JSON_PARSER_MAX_DEPTH 2048
#endif #endif

View File

@ -11,9 +11,9 @@
#ifndef JANSSON_PRIVATE_CONFIG_H_ #ifndef JANSSON_PRIVATE_CONFIG_H_
#define JANSSON_PRIVATE_CONFIG_H_ #define JANSSON_PRIVATE_CONFIG_H_
#define HAVE_SYS_TIME_H 1 #define HAVE_SYS_TIME_H 1
#define HAVE_SYS_TYPES_H 1 #define HAVE_SYS_TYPES_H 1
#define INITIAL_HASHTABLE_ORDER 3 #define INITIAL_HASHTABLE_ORDER 3
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -8,6 +8,7 @@
**/ **/
#include <Uefi.h> #include <Uefi.h>
#include <Protocol/EdkIIRedfishCredential.h> #include <Protocol/EdkIIRedfishCredential.h>
/** /**
Notification of Exit Boot Service. Notification of Exit Boot Service.
@ -17,7 +18,7 @@ VOID
EFIAPI EFIAPI
LibCredentialExitBootServicesNotify ( LibCredentialExitBootServicesNotify (
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This
) )
{ {
return; return;
} }
@ -31,7 +32,7 @@ VOID
EFIAPI EFIAPI
LibCredentialEndOfDxeNotify ( LibCredentialEndOfDxeNotify (
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This
) )
{ {
return; return;
} }
@ -67,7 +68,7 @@ LibCredentialGetAuthInfo (
OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod, OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod,
OUT CHAR8 **UserId, OUT CHAR8 **UserId,
OUT CHAR8 **Password OUT CHAR8 **Password
) )
{ {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
@ -92,10 +93,9 @@ LibCredentialGetAuthInfo (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
LibStopRedfishService ( LibStopRedfishService (
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This, IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This,
IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType
) )
{ {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }

View File

@ -23,12 +23,13 @@
**/ **/
EFI_STATUS EFI_STATUS
RedfishPlatformHostInterfaceDeviceDescriptor ( RedfishPlatformHostInterfaceDeviceDescriptor (
IN UINT8 *DeviceType, IN UINT8 *DeviceType,
OUT REDFISH_INTERFACE_DATA **DeviceDescriptor OUT REDFISH_INTERFACE_DATA **DeviceDescriptor
) )
{ {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
/** /**
Get platform Redfish host interface protocol data. Get platform Redfish host interface protocol data.
Caller should pass NULL in ProtocolRecord to retrive the first protocol record. Caller should pass NULL in ProtocolRecord to retrive the first protocol record.
@ -44,9 +45,9 @@ RedfishPlatformHostInterfaceDeviceDescriptor (
**/ **/
EFI_STATUS EFI_STATUS
RedfishPlatformHostInterfaceProtocolData ( RedfishPlatformHostInterfaceProtocolData (
IN OUT MC_HOST_INTERFACE_PROTOCOL_RECORD **ProtocolRecord, IN OUT MC_HOST_INTERFACE_PROTOCOL_RECORD **ProtocolRecord,
IN UINT8 IndexOfProtocolData IN UINT8 IndexOfProtocolData
) )
{ {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }

View File

@ -34,11 +34,11 @@
**/ **/
EFI_STATUS EFI_STATUS
RedfishContentEncode ( RedfishContentEncode (
IN CHAR8 *ContentEncodedValue, IN CHAR8 *ContentEncodedValue,
IN CHAR8 *OriginalContent, IN CHAR8 *OriginalContent,
IN UINTN OriginalContentLength, IN UINTN OriginalContentLength,
OUT VOID **EncodedContentPointer, OUT VOID **EncodedContentPointer,
OUT UINTN *EncodedContentLength OUT UINTN *EncodedContentLength
) )
{ {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
@ -70,11 +70,11 @@ RedfishContentEncode (
**/ **/
EFI_STATUS EFI_STATUS
RedfishContentDecode ( RedfishContentDecode (
IN CHAR8 *ContentDecodedValue, IN CHAR8 *ContentDecodedValue,
IN VOID *ContentPointer, IN VOID *ContentPointer,
IN UINTN ContentLength, IN UINTN ContentLength,
OUT VOID **DecodedContentPointer, OUT VOID **DecodedContentPointer,
OUT UINTN *DecodedContentLength OUT UINTN *DecodedContentLength
) )
{ {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;

View File

@ -7,6 +7,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef REDFISH_CRT_STDARG_H_ #ifndef REDFISH_CRT_STDARG_H_
#define REDFISH_CRT_STDARG_H_ #define REDFISH_CRT_STDARG_H_

View File

@ -7,6 +7,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef REDFISH_CRT_STDIO_H_ #ifndef REDFISH_CRT_STDIO_H_
#define REDFISH_CRT_STDIO_H_ #define REDFISH_CRT_STDIO_H_

View File

@ -7,6 +7,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef REDFISH_CRT_SYS_TIME_H_ #ifndef REDFISH_CRT_SYS_TIME_H_
#define REDFISH_CRT_SYS_TIME_H_ #define REDFISH_CRT_SYS_TIME_H_

View File

@ -7,6 +7,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef REDFISH_CRT_SYS_TYPES_H_ #ifndef REDFISH_CRT_SYS_TYPES_H_
#define REDFISH_CRT_SYS_TYPES_H_ #define REDFISH_CRT_SYS_TYPES_H_

View File

@ -7,6 +7,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef REDFISH_CRT_TIME_H_ #ifndef REDFISH_CRT_TIME_H_
#define REDFISH_CRT_TIME_H_ #define REDFISH_CRT_TIME_H_

View File

@ -80,25 +80,25 @@
/// ///
/// Library class public defines /// Library class public defines
/// ///
typedef VOID* REDFISH_SERVICE; typedef VOID *REDFISH_SERVICE;
typedef VOID* REDFISH_PAYLOAD; typedef VOID *REDFISH_PAYLOAD;
/// ///
/// Library class public structures/unions /// Library class public structures/unions
/// ///
typedef struct { typedef struct {
EFI_HTTP_STATUS_CODE *StatusCode; EFI_HTTP_STATUS_CODE *StatusCode;
UINTN HeaderCount; UINTN HeaderCount;
EFI_HTTP_HEADER *Headers; EFI_HTTP_HEADER *Headers;
REDFISH_PAYLOAD Payload; REDFISH_PAYLOAD Payload;
} REDFISH_RESPONSE; } REDFISH_RESPONSE;
/// ///
/// Odata type-name mapping structure. /// Odata type-name mapping structure.
/// ///
typedef struct { typedef struct {
CONST CHAR8 OdataTypeName [ODATA_TYPE_NAME_MAX_SIZE]; CONST CHAR8 OdataTypeName[ODATA_TYPE_NAME_MAX_SIZE];
CONST CHAR8 OdataType [ODATA_TYPE_MAX_SIZE]; CONST CHAR8 OdataType[ODATA_TYPE_MAX_SIZE];
} REDFISH_ODATA_TYPE_MAPPING; } REDFISH_ODATA_TYPE_MAPPING;
/** /**
@ -117,7 +117,7 @@ typedef struct {
REDFISH_SERVICE REDFISH_SERVICE
EFIAPI EFIAPI
RedfishCreateService ( RedfishCreateService (
IN REDFISH_CONFIG_SERVICE_INFORMATION *RedfishConfigServiceInfo IN REDFISH_CONFIG_SERVICE_INFORMATION *RedfishConfigServiceInfo
); );
/** /**
@ -129,7 +129,7 @@ RedfishCreateService (
VOID VOID
EFIAPI EFIAPI
RedfishCleanupService ( RedfishCleanupService (
IN REDFISH_SERVICE RedfishService IN REDFISH_SERVICE RedfishService
); );
/** /**
@ -150,8 +150,8 @@ RedfishCleanupService (
REDFISH_PAYLOAD REDFISH_PAYLOAD
EFIAPI EFIAPI
RedfishCreatePayload ( RedfishCreatePayload (
IN EDKII_JSON_VALUE Value, IN EDKII_JSON_VALUE Value,
IN REDFISH_SERVICE RedfishService IN REDFISH_SERVICE RedfishService
); );
/** /**
@ -163,7 +163,7 @@ RedfishCreatePayload (
VOID VOID
EFIAPI EFIAPI
RedfishCleanupPayload ( RedfishCleanupPayload (
IN REDFISH_PAYLOAD Payload IN REDFISH_PAYLOAD Payload
); );
/** /**
@ -180,7 +180,7 @@ RedfishCleanupPayload (
EDKII_JSON_VALUE EDKII_JSON_VALUE
EFIAPI EFIAPI
RedfishJsonInPayload ( RedfishJsonInPayload (
IN REDFISH_PAYLOAD Payload IN REDFISH_PAYLOAD Payload
); );
/** /**
@ -205,9 +205,9 @@ RedfishJsonInPayload (
CHAR8 * CHAR8 *
EFIAPI EFIAPI
RedfishBuildPathWithSystemUuid ( RedfishBuildPathWithSystemUuid (
IN CONST CHAR8 *RedPath, IN CONST CHAR8 *RedPath,
IN BOOLEAN FromSmbios, IN BOOLEAN FromSmbios,
IN CHAR8 *IdString OPTIONAL IN CHAR8 *IdString OPTIONAL
); );
/** /**
@ -236,9 +236,9 @@ RedfishBuildPathWithSystemUuid (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishGetByService ( RedfishGetByService (
IN REDFISH_SERVICE RedfishService, IN REDFISH_SERVICE RedfishService,
IN CONST CHAR8 *RedPath, IN CONST CHAR8 *RedPath,
OUT REDFISH_RESPONSE *RedResponse OUT REDFISH_RESPONSE *RedResponse
); );
/** /**
@ -266,9 +266,9 @@ RedfishGetByService (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishGetByUri ( RedfishGetByUri (
IN REDFISH_SERVICE RedfishService, IN REDFISH_SERVICE RedfishService,
IN CONST CHAR8 *Uri, IN CONST CHAR8 *Uri,
OUT REDFISH_RESPONSE *RedResponse OUT REDFISH_RESPONSE *RedResponse
); );
/** /**
@ -300,9 +300,9 @@ RedfishGetByUri (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishGetByPayload ( RedfishGetByPayload (
IN REDFISH_PAYLOAD Payload, IN REDFISH_PAYLOAD Payload,
IN CONST CHAR8 *RedPath, IN CONST CHAR8 *RedPath,
OUT REDFISH_RESPONSE *RedResponse OUT REDFISH_RESPONSE *RedResponse
); );
/** /**
@ -338,10 +338,10 @@ RedfishGetByPayload (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishPatchToUri ( RedfishPatchToUri (
IN REDFISH_SERVICE RedfishService, IN REDFISH_SERVICE RedfishService,
IN CONST CHAR8 *Uri, IN CONST CHAR8 *Uri,
IN CONST CHAR8 *Content, IN CONST CHAR8 *Content,
OUT REDFISH_RESPONSE *RedResponse OUT REDFISH_RESPONSE *RedResponse
); );
/** /**
@ -375,9 +375,9 @@ RedfishPatchToUri (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishPatchToPayload ( RedfishPatchToPayload (
IN REDFISH_PAYLOAD Target, IN REDFISH_PAYLOAD Target,
IN REDFISH_PAYLOAD Payload, IN REDFISH_PAYLOAD Payload,
OUT REDFISH_RESPONSE *RedResponse OUT REDFISH_RESPONSE *RedResponse
); );
/** /**
@ -410,9 +410,9 @@ RedfishPatchToPayload (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishPostToPayload ( RedfishPostToPayload (
IN REDFISH_PAYLOAD Target, IN REDFISH_PAYLOAD Target,
IN REDFISH_PAYLOAD Payload, IN REDFISH_PAYLOAD Payload,
OUT REDFISH_RESPONSE *RedResponse OUT REDFISH_RESPONSE *RedResponse
); );
/** /**
@ -445,9 +445,9 @@ RedfishPostToPayload (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishDeleteByUri ( RedfishDeleteByUri (
IN REDFISH_SERVICE RedfishService, IN REDFISH_SERVICE RedfishService,
IN CONST CHAR8 *Uri, IN CONST CHAR8 *Uri,
OUT REDFISH_RESPONSE *RedResponse OUT REDFISH_RESPONSE *RedResponse
); );
/** /**
@ -458,7 +458,7 @@ RedfishDeleteByUri (
**/ **/
VOID VOID
RedfishDumpJsonStringFractions ( RedfishDumpJsonStringFractions (
IN CHAR8 *String IN CHAR8 *String
); );
/** /**
@ -469,8 +469,9 @@ RedfishDumpJsonStringFractions (
**/ **/
VOID VOID
RedfishDumpPayload ( RedfishDumpPayload (
IN REDFISH_PAYLOAD Payload IN REDFISH_PAYLOAD Payload
); );
/** /**
Dump text in JSON value. Dump text in JSON value.
@ -481,6 +482,7 @@ VOID
RedfishDumpJson ( RedfishDumpJson (
IN EDKII_JSON_VALUE JsonValue IN EDKII_JSON_VALUE JsonValue
); );
/** /**
This function will cleanup the HTTP header and Redfish payload resources. This function will cleanup the HTTP header and Redfish payload resources.
@ -511,10 +513,10 @@ RedfishFreeResponse (
**/ **/
BOOLEAN BOOLEAN
RedfishIsValidOdataType ( RedfishIsValidOdataType (
IN REDFISH_PAYLOAD Payload, IN REDFISH_PAYLOAD Payload,
IN CONST CHAR8 *OdataTypeName, IN CONST CHAR8 *OdataTypeName,
IN REDFISH_ODATA_TYPE_MAPPING *OdataTypeMappingList, IN REDFISH_ODATA_TYPE_MAPPING *OdataTypeMappingList,
IN UINTN OdataTypeMappingListSize IN UINTN OdataTypeMappingListSize
); );
/** /**
@ -527,8 +529,9 @@ RedfishIsValidOdataType (
**/ **/
BOOLEAN BOOLEAN
RedfishIsPayloadCollection ( RedfishIsPayloadCollection (
IN REDFISH_PAYLOAD Payload IN REDFISH_PAYLOAD Payload
); );
/** /**
Get collection size. Get collection size.
@ -539,10 +542,11 @@ RedfishIsPayloadCollection (
@return EFI_INVALID_PARAMETER The payload is not a collection. @return EFI_INVALID_PARAMETER The payload is not a collection.
**/ **/
EFI_STATUS EFI_STATUS
RedfishGetCollectionSize( RedfishGetCollectionSize (
IN REDFISH_PAYLOAD Payload, IN REDFISH_PAYLOAD Payload,
IN UINTN *CollectionSize IN UINTN *CollectionSize
); );
/** /**
Get Redfish payload of collection member Get Redfish payload of collection member
@ -554,9 +558,9 @@ RedfishGetCollectionSize(
**/ **/
REDFISH_PAYLOAD REDFISH_PAYLOAD
RedfishGetPayloadByIndex ( RedfishGetPayloadByIndex (
IN REDFISH_PAYLOAD Payload, IN REDFISH_PAYLOAD Payload,
IN UINTN Index IN UINTN Index
); );
/** /**
Check and return Redfish resource of the given Redpath. Check and return Redfish resource of the given Redpath.
@ -569,10 +573,10 @@ RedfishGetPayloadByIndex (
**/ **/
EFI_STATUS EFI_STATUS
RedfishCheckIfRedpathExist ( RedfishCheckIfRedpathExist (
IN REDFISH_SERVICE RedfishService, IN REDFISH_SERVICE RedfishService,
IN CHAR8 *Redpath, IN CHAR8 *Redpath,
IN REDFISH_RESPONSE *Response OPTIONAL IN REDFISH_RESPONSE *Response OPTIONAL
); );
/** /**
This function returns the string of Redfish service version. This function returns the string of Redfish service version.
@ -584,9 +588,9 @@ RedfishCheckIfRedpathExist (
**/ **/
EFI_STATUS EFI_STATUS
RedfishGetServiceVersion( RedfishGetServiceVersion (
IN REDFISH_SERVICE RedfishService, IN REDFISH_SERVICE RedfishService,
OUT CHAR8 **ServiceVersionStr OUT CHAR8 **ServiceVersionStr
); );
/** /**
@ -603,9 +607,10 @@ RedfishGetServiceVersion(
**/ **/
EFI_STATUS EFI_STATUS
RedfishBuildRedpathUseId ( RedfishBuildRedpathUseId (
IN CHAR8 *ServiceVerisonStr, IN CHAR8 *ServiceVerisonStr,
IN CHAR8 *Url, IN CHAR8 *Url,
IN CHAR8 *Id, IN CHAR8 *Id,
OUT CHAR8 **Redpath OUT CHAR8 **Redpath
); );
#endif #endif

View File

@ -14,17 +14,20 @@
#include <Library/SortLib.h> #include <Library/SortLib.h>
#include <Library/UefiRuntimeServicesTableLib.h> #include <Library/UefiRuntimeServicesTableLib.h>
int errno = 0; int errno = 0;
char errnum_message [] = "We don't support to map errnum to the error message on edk2 Redfish\n"; char errnum_message[] = "We don't support to map errnum to the error message on edk2 Redfish\n";
// This is required to keep VC++ happy if you use floating-point // This is required to keep VC++ happy if you use floating-point
int _fltused = 1; int _fltused = 1;
/** /**
Determine if a particular character is an alphanumeric character Determine if a particular character is an alphanumeric character
@return Returns 1 if c is an alphanumeric character, otherwise returns 0. @return Returns 1 if c is an alphanumeric character, otherwise returns 0.
**/ **/
int isalnum (int c) int
isalnum (
int c
)
{ {
// //
// <alnum> ::= [0-9] | [a-z] | [A-Z] // <alnum> ::= [0-9] | [a-z] | [A-Z]
@ -39,7 +42,10 @@ int isalnum (int c)
@return Returns 1 if c is an digital character, otherwise returns 0. @return Returns 1 if c is an digital character, otherwise returns 0.
**/ **/
int isdchar (int c) int
isdchar (
int c
)
{ {
// //
// [0-9] | [e +-.] // [0-9] | [e +-.]
@ -55,7 +61,10 @@ int isdchar (int c)
@return Returns 1 if c is a space character @return Returns 1 if c is a space character
**/ **/
int isspace (int c) int
isspace (
int c
)
{ {
// //
// <space> ::= [ ] // <space> ::= [ ]
@ -66,15 +75,21 @@ int isspace (int c)
/** /**
Allocates memory blocks Allocates memory blocks
*/ */
void *malloc (size_t size) void *
malloc (
size_t size
)
{ {
return AllocatePool ((UINTN) size); return AllocatePool ((UINTN)size);
} }
/** /**
De-allocates or frees a memory block De-allocates or frees a memory block
*/ */
void free (void *ptr) void
free (
void *ptr
)
{ {
// //
// In Standard C, free() handles a null pointer argument transparently. This // In Standard C, free() handles a null pointer argument transparently. This
@ -90,15 +105,20 @@ void free (void *ptr)
@return Returns the pointer to duplicated string. @return Returns the pointer to duplicated string.
**/ **/
char * strdup(const char *str) char *
strdup (
const char *str
)
{ {
size_t len; size_t len;
char *copy; char *copy;
len = strlen(str) + 1; len = strlen (str) + 1;
if ((copy = malloc(len)) == NULL) if ((copy = malloc (len)) == NULL) {
return (NULL); return (NULL);
memcpy(copy, str, len); }
memcpy (copy, str, len);
return (copy); return (copy);
} }
@ -115,13 +135,14 @@ char * strdup(const char *str)
returned unchanged. returned unchanged.
**/ **/
int int
toupper( toupper (
IN int c IN int c
) )
{ {
if ( (c >= 'a') && (c <= 'z') ) { if ((c >= 'a') && (c <= 'z')) {
c = c - ('a' - 'A'); c = c - ('a' - 'A');
} }
return c; return c;
} }
@ -131,15 +152,18 @@ toupper(
@return Returns the value of digit. @return Returns the value of digit.
**/ **/
int int
Digit2Val( int c) Digit2Val (
int c
)
{ {
if (((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'))) { /* If c is one of [A-Za-z]... */ if (((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'))) {
c = toupper(c) - 7; // Adjust so 'A' is ('9' + 1) /* If c is one of [A-Za-z]... */
c = toupper (c) - 7; // Adjust so 'A' is ('9' + 1)
} }
return c - '0'; // Value returned is between 0 and 35, inclusive. return c - '0'; // Value returned is between 0 and 35, inclusive.
} }
/** The strtoll function converts the initial portion of the string pointed to /** The strtoll function converts the initial portion of the string pointed to
by nptr to long long int representation. by nptr to long long int representation.
@ -152,9 +176,13 @@ Digit2Val( int c)
and the value of the macro ERANGE is stored in errno. and the value of the macro ERANGE is stored in errno.
**/ **/
long long long long
strtoll(const char * nptr, char ** endptr, int base) strtoll (
const char *nptr,
char **endptr,
int base
)
{ {
const char *pEnd; const char *pEnd;
long long Result = 0; long long Result = 0;
long long Previous; long long Previous;
int temp; int temp;
@ -162,71 +190,86 @@ strtoll(const char * nptr, char ** endptr, int base)
pEnd = nptr; pEnd = nptr;
if((base < 0) || (base == 1) || (base > 36)) { if ((base < 0) || (base == 1) || (base > 36)) {
if(endptr != NULL) { if (endptr != NULL) {
*endptr = NULL; *endptr = NULL;
} }
return 0; return 0;
} }
// Skip leading spaces.
while(isspace(*nptr)) ++nptr;
// Process Subject sequence: optional sign followed by digits. // Skip leading spaces.
if(*nptr == '+') { while (isspace (*nptr)) {
Negative = FALSE;
++nptr; ++nptr;
} }
else if(*nptr == '-') {
// Process Subject sequence: optional sign followed by digits.
if (*nptr == '+') {
Negative = FALSE;
++nptr;
} else if (*nptr == '-') {
Negative = TRUE; Negative = TRUE;
++nptr; ++nptr;
} }
if(*nptr == '0') { /* Might be Octal or Hex */ if (*nptr == '0') {
if(toupper(nptr[1]) == 'X') { /* Looks like Hex */ /* Might be Octal or Hex */
if((base == 0) || (base == 16)) { if (toupper (nptr[1]) == 'X') {
/* Looks like Hex */
if ((base == 0) || (base == 16)) {
nptr += 2; /* Skip the "0X" */ nptr += 2; /* Skip the "0X" */
base = 16; /* In case base was 0 */ base = 16; /* In case base was 0 */
} }
} } else {
else { /* Looks like Octal */ /* Looks like Octal */
if((base == 0) || (base == 8)) { if ((base == 0) || (base == 8)) {
++nptr; /* Skip the leading "0" */ ++nptr; /* Skip the leading "0" */
base = 8; /* In case base was 0 */ base = 8; /* In case base was 0 */
} }
} }
} }
if(base == 0) { /* If still zero then must be decimal */
if (base == 0) {
/* If still zero then must be decimal */
base = 10; base = 10;
} }
if(*nptr == '0') {
for( ; *nptr == '0'; ++nptr); /* Skip any remaining leading zeros */ if (*nptr == '0') {
for ( ; *nptr == '0'; ++nptr) {
/* Skip any remaining leading zeros */
}
pEnd = nptr; pEnd = nptr;
} }
while( isalnum(*nptr) && ((temp = Digit2Val(*nptr)) < base)) { while ( isalnum (*nptr) && ((temp = Digit2Val (*nptr)) < base)) {
Previous = Result; Previous = Result;
Result = MultS64x64 (Result, base) + (long long int)temp; Result = MultS64x64 (Result, base) + (long long int)temp;
if( Result <= Previous) { // Detect Overflow if ( Result <= Previous) {
if(Negative) { // Detect Overflow
if (Negative) {
Result = LLONG_MIN; Result = LLONG_MIN;
} } else {
else {
Result = LLONG_MAX; Result = LLONG_MAX;
} }
Negative = FALSE; Negative = FALSE;
errno = ERANGE; errno = ERANGE;
break; break;
} }
pEnd = ++nptr; pEnd = ++nptr;
} }
if(Negative) {
if (Negative) {
Result = -Result; Result = -Result;
} }
// Save pointer to final sequence // Save pointer to final sequence
if(endptr != NULL) { if (endptr != NULL) {
*endptr = (char *)pEnd; *endptr = (char *)pEnd;
} }
return Result; return Result;
} }
@ -285,9 +328,13 @@ strtoll(const char * nptr, char ** endptr, int base)
is stored in errno. is stored in errno.
**/ **/
long long
strtol(const char * nptr, char ** endptr, int base) strtol (
const char *nptr,
char **endptr,
int base
)
{ {
const char *pEnd; const char *pEnd;
long Result = 0; long Result = 0;
long Previous; long Previous;
int temp; int temp;
@ -295,71 +342,86 @@ strtol(const char * nptr, char ** endptr, int base)
pEnd = nptr; pEnd = nptr;
if((base < 0) || (base == 1) || (base > 36)) { if ((base < 0) || (base == 1) || (base > 36)) {
if(endptr != NULL) { if (endptr != NULL) {
*endptr = NULL; *endptr = NULL;
} }
return 0; return 0;
} }
// Skip leading spaces.
while(isspace(*nptr)) ++nptr;
// Process Subject sequence: optional sign followed by digits. // Skip leading spaces.
if(*nptr == '+') { while (isspace (*nptr)) {
Negative = FALSE;
++nptr; ++nptr;
} }
else if(*nptr == '-') {
// Process Subject sequence: optional sign followed by digits.
if (*nptr == '+') {
Negative = FALSE;
++nptr;
} else if (*nptr == '-') {
Negative = TRUE; Negative = TRUE;
++nptr; ++nptr;
} }
if(*nptr == '0') { /* Might be Octal or Hex */ if (*nptr == '0') {
if(toupper(nptr[1]) == 'X') { /* Looks like Hex */ /* Might be Octal or Hex */
if((base == 0) || (base == 16)) { if (toupper (nptr[1]) == 'X') {
/* Looks like Hex */
if ((base == 0) || (base == 16)) {
nptr += 2; /* Skip the "0X" */ nptr += 2; /* Skip the "0X" */
base = 16; /* In case base was 0 */ base = 16; /* In case base was 0 */
} }
} } else {
else { /* Looks like Octal */ /* Looks like Octal */
if((base == 0) || (base == 8)) { if ((base == 0) || (base == 8)) {
++nptr; /* Skip the leading "0" */ ++nptr; /* Skip the leading "0" */
base = 8; /* In case base was 0 */ base = 8; /* In case base was 0 */
} }
} }
} }
if(base == 0) { /* If still zero then must be decimal */
if (base == 0) {
/* If still zero then must be decimal */
base = 10; base = 10;
} }
if(*nptr == '0') {
for( ; *nptr == '0'; ++nptr); /* Skip any remaining leading zeros */ if (*nptr == '0') {
for ( ; *nptr == '0'; ++nptr) {
/* Skip any remaining leading zeros */
}
pEnd = nptr; pEnd = nptr;
} }
while( isalnum(*nptr) && ((temp = Digit2Val(*nptr)) < base)) { while ( isalnum (*nptr) && ((temp = Digit2Val (*nptr)) < base)) {
Previous = Result; Previous = Result;
Result = (Result * base) + (long int)temp; Result = (Result * base) + (long int)temp;
if( Result <= Previous) { // Detect Overflow if ( Result <= Previous) {
if(Negative) { // Detect Overflow
if (Negative) {
Result = LONG_MIN; Result = LONG_MIN;
} } else {
else {
Result = LONG_MAX; Result = LONG_MAX;
} }
Negative = FALSE; Negative = FALSE;
errno = ERANGE; errno = ERANGE;
break; break;
} }
pEnd = ++nptr; pEnd = ++nptr;
} }
if(Negative) {
if (Negative) {
Result = -Result; Result = -Result;
} }
// Save pointer to final sequence // Save pointer to final sequence
if(endptr != NULL) { if (endptr != NULL) {
*endptr = (char *)pEnd; *endptr = (char *)pEnd;
} }
return Result; return Result;
} }
@ -374,66 +436,85 @@ strtol(const char * nptr, char ** endptr, int base)
returned and the value of the macro ERANGE is stored in errno. returned and the value of the macro ERANGE is stored in errno.
**/ **/
unsigned long long unsigned long long
strtoull(const char * nptr, char ** endptr, int base) strtoull (
const char *nptr,
char **endptr,
int base
)
{ {
const char *pEnd; const char *pEnd;
unsigned long long Result = 0; unsigned long long Result = 0;
unsigned long long Previous; unsigned long long Previous;
int temp; int temp;
pEnd = nptr; pEnd = nptr;
if((base < 0) || (base == 1) || (base > 36)) { if ((base < 0) || (base == 1) || (base > 36)) {
if(endptr != NULL) { if (endptr != NULL) {
*endptr = NULL; *endptr = NULL;
} }
return 0; return 0;
} }
// Skip leading spaces.
while(isspace(*nptr)) ++nptr;
// Process Subject sequence: optional + sign followed by digits. // Skip leading spaces.
if(*nptr == '+') { while (isspace (*nptr)) {
++nptr; ++nptr;
} }
if(*nptr == '0') { /* Might be Octal or Hex */ // Process Subject sequence: optional + sign followed by digits.
if(toupper(nptr[1]) == 'X') { /* Looks like Hex */ if (*nptr == '+') {
if((base == 0) || (base == 16)) { ++nptr;
}
if (*nptr == '0') {
/* Might be Octal or Hex */
if (toupper (nptr[1]) == 'X') {
/* Looks like Hex */
if ((base == 0) || (base == 16)) {
nptr += 2; /* Skip the "0X" */ nptr += 2; /* Skip the "0X" */
base = 16; /* In case base was 0 */ base = 16; /* In case base was 0 */
} }
} } else {
else { /* Looks like Octal */ /* Looks like Octal */
if((base == 0) || (base == 8)) { if ((base == 0) || (base == 8)) {
++nptr; /* Skip the leading "0" */ ++nptr; /* Skip the leading "0" */
base = 8; /* In case base was 0 */ base = 8; /* In case base was 0 */
} }
} }
} }
if(base == 0) { /* If still zero then must be decimal */
if (base == 0) {
/* If still zero then must be decimal */
base = 10; base = 10;
} }
if(*nptr == '0') {
for( ; *nptr == '0'; ++nptr); /* Skip any remaining leading zeros */ if (*nptr == '0') {
for ( ; *nptr == '0'; ++nptr) {
/* Skip any remaining leading zeros */
}
pEnd = nptr; pEnd = nptr;
} }
while( isalnum(*nptr) && ((temp = Digit2Val(*nptr)) < base)) { while ( isalnum (*nptr) && ((temp = Digit2Val (*nptr)) < base)) {
Previous = Result; Previous = Result;
Result = DivU64x32 (Result, base) + (unsigned long long)temp; Result = DivU64x32 (Result, base) + (unsigned long long)temp;
if( Result < Previous) { // If we overflowed if ( Result < Previous) {
// If we overflowed
Result = ULLONG_MAX; Result = ULLONG_MAX;
errno = ERANGE; errno = ERANGE;
break; break;
} }
pEnd = ++nptr; pEnd = ++nptr;
} }
// Save pointer to final sequence // Save pointer to final sequence
if(endptr != NULL) { if (endptr != NULL) {
*endptr = (char *)pEnd; *endptr = (char *)pEnd;
} }
return Result; return Result;
} }
@ -462,27 +543,34 @@ strtoull(const char * nptr, char ** endptr, int base)
@return Return 0. @return Return 0.
**/ **/
double double
strtod (const char * __restrict nptr, char ** __restrict endptr) { strtod (
const char *__restrict nptr,
DEBUG((DEBUG_INFO, "We don't supprot double type on edk2 yet!")); char **__restrict endptr
ASSERT(FALSE); )
return (double)0; {
DEBUG ((DEBUG_INFO, "We don't supprot double type on edk2 yet!"));
ASSERT (FALSE);
return (double)0;
} }
static UINT8 BitMask[] = { static UINT8 BitMask[] = {
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
}; };
#define WHICH8(c) ((unsigned char)(c) >> 3) #define WHICH8(c) ((unsigned char)(c) >> 3)
#define WHICH_BIT(c) (BitMask[((c) & 0x7)]) #define WHICH_BIT(c) (BitMask[((c) & 0x7)])
#define BITMAP64 ((UINT64 *)bitmap) #define BITMAP64 ((UINT64 *)bitmap)
static static
void void
BuildBitmap(unsigned char * bitmap, const char *s2, int n) BuildBitmap (
unsigned char *bitmap,
const char *s2,
int n
)
{ {
unsigned char bit; unsigned char bit;
int index; int index;
// Initialize bitmap. Bit 0 is always 1 which corresponds to '\0' // Initialize bitmap. Bit 0 is always 1 which corresponds to '\0'
for (BITMAP64[0] = index = 1; index < n; index++) { for (BITMAP64[0] = index = 1; index < n; index++) {
@ -490,9 +578,9 @@ BuildBitmap(unsigned char * bitmap, const char *s2, int n)
} }
// Set bits in bitmap corresponding to the characters in s2 // Set bits in bitmap corresponding to the characters in s2
for (; *s2 != '\0'; s2++) { for ( ; *s2 != '\0'; s2++) {
index = WHICH8(*s2); index = WHICH8 (*s2);
bit = WHICH_BIT(*s2); bit = WHICH_BIT (*s2);
bitmap[index] = bitmap[index] | bit; bitmap[index] = bitmap[index] | bit;
} }
} }
@ -504,21 +592,25 @@ BuildBitmap(unsigned char * bitmap, const char *s2, int n)
null pointer if no character from s2 occurs in s1. null pointer if no character from s2 occurs in s1.
**/ **/
char * char *
strpbrk(const char *s1, const char *s2) strpbrk (
const char *s1,
const char *s2
)
{ {
UINT8 bitmap[ (((UCHAR_MAX + 1) / CHAR_BIT) + (CHAR_BIT - 1)) & ~7U]; UINT8 bitmap[(((UCHAR_MAX + 1) / CHAR_BIT) + (CHAR_BIT - 1)) & ~7U];
UINT8 bit; UINT8 bit;
int index; int index;
BuildBitmap( bitmap, s2, sizeof(bitmap) / sizeof(UINT64)); BuildBitmap (bitmap, s2, sizeof (bitmap) / sizeof (UINT64));
for( ; *s1 != '\0'; ++s1) { for ( ; *s1 != '\0'; ++s1) {
index = WHICH8(*s1); index = WHICH8 (*s1);
bit = WHICH_BIT(*s1); bit = WHICH_BIT (*s1);
if( (bitmap[index] & bit) != 0) { if ((bitmap[index] & bit) != 0) {
return (char *)s1; return (char *)s1;
} }
} }
return NULL; return NULL;
} }
@ -535,7 +627,9 @@ strpbrk(const char *s1, const char *s2)
a subsequent call to the strerror function. a subsequent call to the strerror function.
**/ **/
char * char *
strerror(int errnum) strerror (
int errnum
)
{ {
return errnum_message; return errnum_message;
} }
@ -544,20 +638,24 @@ strerror(int errnum)
Allocate and zero-initialize array. Allocate and zero-initialize array.
**/ **/
void * void *
calloc(size_t Num, size_t Size) calloc (
size_t Num,
size_t Size
)
{ {
void *RetVal; void *RetVal;
size_t NumSize; size_t NumSize;
NumSize = Num * Size; NumSize = Num * Size;
RetVal = NULL; RetVal = NULL;
if (NumSize != 0) { if (NumSize != 0) {
RetVal = malloc(NumSize); RetVal = malloc (NumSize);
if( RetVal != NULL) { if ( RetVal != NULL) {
(VOID)ZeroMem( RetVal, NumSize); (VOID)ZeroMem (RetVal, NumSize);
}
} }
}
DEBUG((DEBUG_POOL, "0x%p = calloc(%d, %d)\n", RetVal, Num, Size)); DEBUG ((DEBUG_POOL, "0x%p = calloc(%d, %d)\n", RetVal, Num, Size));
return RetVal; return RetVal;
} }
@ -567,7 +665,7 @@ calloc(size_t Num, size_t Size)
// month number used as the index (1 -> 12) for regular and leap years. // month number used as the index (1 -> 12) for regular and leap years.
// The value at index 13 is for the whole year. // The value at index 13 is for the whole year.
// //
UINTN CumulativeDays[2][14] = { UINTN CumulativeDays[2][14] = {
{ {
0, 0,
0, 0,
@ -602,15 +700,18 @@ UINTN CumulativeDays[2][14] = {
} }
}; };
#define IsLeap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) #define IsLeap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
#define SECSPERMIN (60) #define SECSPERMIN (60)
#define SECSPERHOUR (60 * 60) #define SECSPERHOUR (60 * 60)
#define SECSPERDAY (24 * SECSPERHOUR) #define SECSPERDAY (24 * SECSPERHOUR)
/** /**
Get the system time as seconds elapsed since midnight, January 1, 1970. Get the system time as seconds elapsed since midnight, January 1, 1970.
**/ **/
time_t time (time_t *timer) time_t
time (
time_t *timer
)
{ {
EFI_TIME Time; EFI_TIME Time;
time_t CalTime; time_t CalTime;
@ -626,7 +727,7 @@ time_t time (time_t *timer)
// UTime should now be set to 00:00:00 on Jan 1 of the current year. // UTime should now be set to 00:00:00 on Jan 1 of the current year.
// //
for (Year = 1970, CalTime = 0; Year != Time.Year; Year++) { for (Year = 1970, CalTime = 0; Year != Time.Year; Year++) {
CalTime = CalTime + (time_t)(CumulativeDays[IsLeap(Year)][13] * SECSPERDAY); CalTime = CalTime + (time_t)(CumulativeDays[IsLeap (Year)][13] * SECSPERDAY);
} }
// //
@ -634,7 +735,7 @@ time_t time (time_t *timer)
// //
CalTime = CalTime + CalTime = CalTime +
(time_t)((Time.TimeZone != EFI_UNSPECIFIED_TIMEZONE) ? (Time.TimeZone * 60) : 0) + (time_t)((Time.TimeZone != EFI_UNSPECIFIED_TIMEZONE) ? (Time.TimeZone * 60) : 0) +
(time_t)(CumulativeDays[IsLeap(Time.Year)][Time.Month] * SECSPERDAY) + (time_t)(CumulativeDays[IsLeap (Time.Year)][Time.Month] * SECSPERDAY) +
(time_t)(((Time.Day > 0) ? Time.Day - 1 : 0) * SECSPERDAY) + (time_t)(((Time.Day > 0) ? Time.Day - 1 : 0) * SECSPERDAY) +
(time_t)(Time.Hour * SECSPERHOUR) + (time_t)(Time.Hour * SECSPERHOUR) +
(time_t)(Time.Minute * 60) + (time_t)(Time.Minute * 60) +
@ -650,9 +751,14 @@ time_t time (time_t *timer)
/** /**
Performs a quick sort Performs a quick sort
**/ **/
void qsort (void *base, size_t num, size_t width, int (*compare)(const void *, const void *)) void
qsort (
void *base,
size_t num,
size_t width,
int ( *compare )(const void *, const void *)
)
{ {
ASSERT (base != NULL); ASSERT (base != NULL);
ASSERT (compare != NULL); ASSERT (compare != NULL);
@ -666,54 +772,93 @@ void qsort (void *base, size_t num, size_t width, int (*compare)(const void *, c
@return Returns the character currently pointed by the internal file position indicator of the specified stream @return Returns the character currently pointed by the internal file position indicator of the specified stream
**/ **/
int fgetc(FILE * _File){ int
return EOF; fgetc (
FILE *_File
)
{
return EOF;
} }
/** /**
Open stream file, we don't support file operastion on edk2 JSON library. Open stream file, we don't support file operastion on edk2 JSON library.
@return 0 Unsupported @return 0 Unsupported
**/ **/
FILE *fopen (const char *filename, const char *mode) { FILE *
fopen (
const char *filename,
const char *mode
)
{
return NULL; return NULL;
} }
/** /**
Read stream from file, we don't support file operastion on edk2 JSON library. Read stream from file, we don't support file operastion on edk2 JSON library.
@return 0 Unsupported @return 0 Unsupported
**/ **/
size_t fread (void * ptr, size_t size, size_t count, FILE * stream) { size_t
fread (
void *ptr,
size_t size,
size_t count,
FILE *stream
)
{
return 0; return 0;
} }
/** /**
Write stream from file, we don't support file operastion on edk2 JSON library. Write stream from file, we don't support file operastion on edk2 JSON library.
@return 0 Unsupported @return 0 Unsupported
**/ **/
size_t fwrite (const void * ptr, size_t size, size_t count, FILE * stream) { size_t
fwrite (
const void *ptr,
size_t size,
size_t count,
FILE *stream
)
{
return 0; return 0;
} }
/** /**
Close file, we don't support file operastion on edk2 JSON library. Close file, we don't support file operastion on edk2 JSON library.
@return 0 Unsupported @return 0 Unsupported
**/ **/
int fclose (FILE * stream) { int
fclose (
FILE *stream
)
{
return EOF; return EOF;
} }
/** /**
Write the formatted string to file, we don't support file operastion on edk2 JSON library. Write the formatted string to file, we don't support file operastion on edk2 JSON library.
@return 0 Unsupported @return 0 Unsupported
**/ **/
int fprintf (FILE * stream, const char * format, ...) { int
fprintf (
FILE *stream,
const char *format,
...
)
{
return -1; return -1;
} }
/** /**
This function check if this is the formating string specifier. This function check if this is the formating string specifier.
@ -730,12 +875,12 @@ int fprintf (FILE * stream, const char * format, ...) {
**/ **/
BOOLEAN BOOLEAN
CheckFormatingString ( CheckFormatingString (
IN CONST CHAR8 *FormatString, IN CONST CHAR8 *FormatString,
IN OUT UINTN *CurrentPosition, IN OUT UINTN *CurrentPosition,
IN UINTN StrLength IN UINTN StrLength
) )
{ {
CHAR8 FormatStringParamater; CHAR8 FormatStringParamater;
while (*(FormatString + *CurrentPosition) != 's') { while (*(FormatString + *CurrentPosition) != 's') {
// //
@ -749,14 +894,17 @@ CheckFormatingString (
(FormatStringParamater != '*') && (FormatStringParamater != '*') &&
(FormatStringParamater != '.') && (FormatStringParamater != '.') &&
!(((UINTN)FormatStringParamater >= (UINTN)'0') && ((UINTN)FormatStringParamater <= (UINTN)'9')) !(((UINTN)FormatStringParamater >= (UINTN)'0') && ((UINTN)FormatStringParamater <= (UINTN)'9'))
) { )
{
return FALSE; return FALSE;
} }
(*CurrentPosition)++; (*CurrentPosition)++;
if (*CurrentPosition >= StrLength) { if (*CurrentPosition >= StrLength) {
return FALSE; return FALSE;
} }
}; }
return TRUE; return TRUE;
} }
@ -772,15 +920,15 @@ CheckFormatingString (
**/ **/
CHAR8 * CHAR8 *
ReplaceUnicodeToAsciiStrFormat ( ReplaceUnicodeToAsciiStrFormat (
IN CONST CHAR8 *FormatString IN CONST CHAR8 *FormatString
) )
{ {
UINTN FormatStrSize; UINTN FormatStrSize;
UINTN FormatStrIndex; UINTN FormatStrIndex;
UINTN FormatStrSpecifier; UINTN FormatStrSpecifier;
BOOLEAN PercentageMark; BOOLEAN PercentageMark;
CHAR8 *TempFormatBuffer; CHAR8 *TempFormatBuffer;
BOOLEAN IsFormatString; BOOLEAN IsFormatString;
// //
// Error checking. // Error checking.
@ -788,15 +936,18 @@ ReplaceUnicodeToAsciiStrFormat (
if (FormatString == NULL) { if (FormatString == NULL) {
return NULL; return NULL;
} }
FormatStrSize = AsciiStrSize(FormatString);
FormatStrSize = AsciiStrSize (FormatString);
if (FormatStrSize == 0) { if (FormatStrSize == 0) {
return NULL; return NULL;
} }
TempFormatBuffer = AllocatePool(FormatStrSize); // Allocate memory for the
// new string. TempFormatBuffer = AllocatePool (FormatStrSize); // Allocate memory for the
if (TempFormatBuffer== NULL) { // new string.
if (TempFormatBuffer == NULL) {
return NULL; return NULL;
} }
// //
// Clone *FormatString but replace "%s" wih "%a". // Clone *FormatString but replace "%s" wih "%a".
// "%%" is not considered as the format tag. // "%%" is not considered as the format tag.
@ -809,18 +960,21 @@ ReplaceUnicodeToAsciiStrFormat (
// Previous character is "%". // Previous character is "%".
// //
PercentageMark = FALSE; PercentageMark = FALSE;
if (*(FormatString + FormatStrIndex) != '%') { // Check if this is double "%". if (*(FormatString + FormatStrIndex) != '%') {
// Check if this is double "%".
FormatStrSpecifier = FormatStrIndex; FormatStrSpecifier = FormatStrIndex;
// //
// Check if this is the formating string specifier. // Check if this is the formating string specifier.
// //
IsFormatString = CheckFormatingString (FormatString, &FormatStrSpecifier, FormatStrSize); IsFormatString = CheckFormatingString (FormatString, &FormatStrSpecifier, FormatStrSize);
if ((FormatStrSpecifier - FormatStrIndex) != 0) { if ((FormatStrSpecifier - FormatStrIndex) != 0) {
CopyMem((VOID *)(TempFormatBuffer + FormatStrIndex), CopyMem (
(VOID *)(FormatString + FormatStrIndex), (VOID *)(TempFormatBuffer + FormatStrIndex),
FormatStrSpecifier - FormatStrIndex (VOID *)(FormatString + FormatStrIndex),
); FormatStrSpecifier - FormatStrIndex
);
} }
FormatStrIndex = FormatStrSpecifier; FormatStrIndex = FormatStrSpecifier;
if (IsFormatString == TRUE) { if (IsFormatString == TRUE) {
// //
@ -828,18 +982,22 @@ ReplaceUnicodeToAsciiStrFormat (
// format on edk2 environment. // format on edk2 environment.
// //
*(TempFormatBuffer + FormatStrSpecifier) = 'a'; *(TempFormatBuffer + FormatStrSpecifier) = 'a';
FormatStrIndex ++; FormatStrIndex++;
} }
continue; continue;
} }
goto ContinueCheck; goto ContinueCheck;
} }
if (*(FormatString + FormatStrIndex) == '%') { if (*(FormatString + FormatStrIndex) == '%') {
// //
// This character is "%", set the flag. // This character is "%", set the flag.
// //
PercentageMark = TRUE; PercentageMark = TRUE;
} }
ContinueCheck: ContinueCheck:
// //
// Clone character to the new string and advance FormatStrIndex // Clone character to the new string and advance FormatStrIndex
@ -847,7 +1005,8 @@ ContinueCheck:
// //
*(TempFormatBuffer + FormatStrIndex) = *(FormatString + FormatStrIndex); *(TempFormatBuffer + FormatStrIndex) = *(FormatString + FormatStrIndex);
FormatStrIndex++; FormatStrIndex++;
}; }
return TempFormatBuffer; return TempFormatBuffer;
} }
@ -870,14 +1029,14 @@ ContinueCheck:
UINTN UINTN
EFIAPI EFIAPI
RedfishAsciiVSPrint ( RedfishAsciiVSPrint (
OUT CHAR8 *StartOfBuffer, OUT CHAR8 *StartOfBuffer,
IN UINTN BufferSize, IN UINTN BufferSize,
IN CONST CHAR8 *FormatString, IN CONST CHAR8 *FormatString,
IN VA_LIST Marker IN VA_LIST Marker
) )
{ {
CHAR8 *TempFormatBuffer; CHAR8 *TempFormatBuffer;
UINTN LenStrProduced; UINTN LenStrProduced;
// //
// Looking for "%s" in the format string and replace it // Looking for "%s" in the format string and replace it
@ -888,6 +1047,7 @@ RedfishAsciiVSPrint (
if (TempFormatBuffer == NULL) { if (TempFormatBuffer == NULL) {
return 0; return 0;
} }
LenStrProduced = AsciiVSPrint (StartOfBuffer, BufferSize, (CONST CHAR8 *)TempFormatBuffer, Marker); LenStrProduced = AsciiVSPrint (StartOfBuffer, BufferSize, (CONST CHAR8 *)TempFormatBuffer, Marker);
FreePool (TempFormatBuffer); FreePool (TempFormatBuffer);
return LenStrProduced; return LenStrProduced;
@ -919,11 +1079,10 @@ RedfishAsciiSPrint (
... ...
) )
{ {
VA_LIST Marker; VA_LIST Marker;
UINTN LenStrProduced; UINTN LenStrProduced;
VA_START(Marker, FormatString); VA_START (Marker, FormatString);
LenStrProduced = RedfishAsciiVSPrint (StartOfBuffer, BufferSize, FormatString, Marker); LenStrProduced = RedfishAsciiVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);
return LenStrProduced; return LenStrProduced;
} }

View File

@ -27,7 +27,7 @@
REDFISH_SERVICE REDFISH_SERVICE
EFIAPI EFIAPI
RedfishCreateService ( RedfishCreateService (
IN REDFISH_CONFIG_SERVICE_INFORMATION *RedfishConfigServiceInfo IN REDFISH_CONFIG_SERVICE_INFORMATION *RedfishConfigServiceInfo
) )
{ {
REDFISH_SERVICE RedfishService; REDFISH_SERVICE RedfishService;
@ -69,7 +69,8 @@ ON_EXIT:
if (UserId != NULL) { if (UserId != NULL) {
FreePool (UserId); FreePool (UserId);
} }
if (Password!= NULL) {
if (Password != NULL) {
FreePool (Password); FreePool (Password);
} }
@ -85,7 +86,7 @@ ON_EXIT:
VOID VOID
EFIAPI EFIAPI
RedfishCleanupService ( RedfishCleanupService (
IN REDFISH_SERVICE RedfishService IN REDFISH_SERVICE RedfishService
) )
{ {
if (RedfishService == NULL) { if (RedfishService == NULL) {
@ -94,6 +95,7 @@ RedfishCleanupService (
cleanupServiceEnumerator (RedfishService); cleanupServiceEnumerator (RedfishService);
} }
/** /**
Create REDFISH_PAYLOAD instance in local with JSON represented resource value and Create REDFISH_PAYLOAD instance in local with JSON represented resource value and
the Redfish Service. the Redfish Service.
@ -112,11 +114,11 @@ RedfishCleanupService (
REDFISH_PAYLOAD REDFISH_PAYLOAD
EFIAPI EFIAPI
RedfishCreatePayload ( RedfishCreatePayload (
IN EDKII_JSON_VALUE Value, IN EDKII_JSON_VALUE Value,
IN REDFISH_SERVICE RedfishService IN REDFISH_SERVICE RedfishService
) )
{ {
EDKII_JSON_VALUE CopyValue; EDKII_JSON_VALUE CopyValue;
CopyValue = JsonValueClone (Value); CopyValue = JsonValueClone (Value);
return createRedfishPayload (CopyValue, RedfishService); return createRedfishPayload (CopyValue, RedfishService);
@ -131,14 +133,14 @@ RedfishCreatePayload (
VOID VOID
EFIAPI EFIAPI
RedfishCleanupPayload ( RedfishCleanupPayload (
IN REDFISH_PAYLOAD Payload IN REDFISH_PAYLOAD Payload
) )
{ {
if (Payload == NULL) { if (Payload == NULL) {
return; return;
} }
cleanupPayload ((redfishPayload *) Payload); cleanupPayload ((redfishPayload *)Payload);
} }
/** /**
@ -155,14 +157,14 @@ RedfishCleanupPayload (
EDKII_JSON_VALUE EDKII_JSON_VALUE
EFIAPI EFIAPI
RedfishJsonInPayload ( RedfishJsonInPayload (
IN REDFISH_PAYLOAD Payload IN REDFISH_PAYLOAD Payload
) )
{ {
if (Payload == NULL) { if (Payload == NULL) {
return NULL; return NULL;
} }
return ((redfishPayload*)Payload)->json; return ((redfishPayload *)Payload)->json;
} }
/** /**
@ -187,15 +189,15 @@ RedfishJsonInPayload (
CHAR8 * CHAR8 *
EFIAPI EFIAPI
RedfishBuildPathWithSystemUuid ( RedfishBuildPathWithSystemUuid (
IN CONST CHAR8 *RedPath, IN CONST CHAR8 *RedPath,
IN BOOLEAN FromSmbios, IN BOOLEAN FromSmbios,
IN CHAR8 *IdString OPTIONAL IN CHAR8 *IdString OPTIONAL
) )
{ {
UINTN BufSize; UINTN BufSize;
CHAR8* RetRedPath; CHAR8 *RetRedPath;
EFI_GUID SystemUuid; EFI_GUID SystemUuid;
EFI_STATUS Status; EFI_STATUS Status;
if (RedPath == NULL) { if (RedPath == NULL) {
return NULL; return NULL;
@ -205,10 +207,11 @@ RedfishBuildPathWithSystemUuid (
// Find system UUID from SMBIOS table. // Find system UUID from SMBIOS table.
// //
if (FromSmbios) { if (FromSmbios) {
Status = NetLibGetSystemGuid(&SystemUuid); Status = NetLibGetSystemGuid (&SystemUuid);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return NULL; return NULL;
} }
// AsciiStrLen ("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") = 36 // AsciiStrLen ("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") = 36
BufSize = AsciiStrSize (RedPath) + AsciiStrLen ("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"); BufSize = AsciiStrSize (RedPath) + AsciiStrLen ("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
} else { } else {
@ -219,13 +222,16 @@ RedfishBuildPathWithSystemUuid (
if (RetRedPath == NULL) { if (RetRedPath == NULL) {
return NULL; return NULL;
} }
if (FromSmbios) { if (FromSmbios) {
AsciiSPrint (RetRedPath, BufSize, RedPath, &SystemUuid); AsciiSPrint (RetRedPath, BufSize, RedPath, &SystemUuid);
} else { } else {
AsciiSPrint (RetRedPath, BufSize, RedPath, IdString); AsciiSPrint (RetRedPath, BufSize, RedPath, IdString);
} }
return RetRedPath; return RetRedPath;
} }
/** /**
Get a redfish response addressed by a RedPath string, including HTTP StatusCode, Headers Get a redfish response addressed by a RedPath string, including HTTP StatusCode, Headers
and Payload which record any HTTP response messages. and Payload which record any HTTP response messages.
@ -252,24 +258,24 @@ RedfishBuildPathWithSystemUuid (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishGetByService ( RedfishGetByService (
IN REDFISH_SERVICE RedfishService, IN REDFISH_SERVICE RedfishService,
IN CONST CHAR8 *RedPath, IN CONST CHAR8 *RedPath,
OUT REDFISH_RESPONSE *RedResponse OUT REDFISH_RESPONSE *RedResponse
) )
{ {
if (RedfishService == NULL || RedPath == NULL || RedResponse == NULL) { if ((RedfishService == NULL) || (RedPath == NULL) || (RedResponse == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE));
RedResponse->Payload = (REDFISH_PAYLOAD) getPayloadByPath (RedfishService, RedPath, &(RedResponse->StatusCode)); RedResponse->Payload = (REDFISH_PAYLOAD)getPayloadByPath (RedfishService, RedPath, &(RedResponse->StatusCode));
// //
// 1. If the returned Payload is NULL, indicates any error happen. // 1. If the returned Payload is NULL, indicates any error happen.
// 2. If the returned StatusCode is NULL, indicates any error happen. // 2. If the returned StatusCode is NULL, indicates any error happen.
// //
if (RedResponse->Payload == NULL || RedResponse->StatusCode == NULL) { if ((RedResponse->Payload == NULL) || (RedResponse->StatusCode == NULL)) {
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
@ -278,13 +284,15 @@ RedfishGetByService (
// NOTE: If there is any error message returned from server, it will be returned in // NOTE: If there is any error message returned from server, it will be returned in
// Payload within RedResponse. // Payload within RedResponse.
// //
if (*(RedResponse->StatusCode) < HTTP_STATUS_200_OK || \ if ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \
*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT) { (*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT))
{
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Get a redfish response addressed by URI, including HTTP StatusCode, Headers Get a redfish response addressed by URI, including HTTP StatusCode, Headers
and Payload which record any HTTP response messages. and Payload which record any HTTP response messages.
@ -310,27 +318,27 @@ RedfishGetByService (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishGetByUri ( RedfishGetByUri (
IN REDFISH_SERVICE RedfishService, IN REDFISH_SERVICE RedfishService,
IN CONST CHAR8 *Uri, IN CONST CHAR8 *Uri,
OUT REDFISH_RESPONSE *RedResponse OUT REDFISH_RESPONSE *RedResponse
) )
{ {
EDKII_JSON_VALUE JsonValue; EDKII_JSON_VALUE JsonValue;
if (RedfishService == NULL || Uri == NULL || RedResponse == NULL) { if ((RedfishService == NULL) || (Uri == NULL) || (RedResponse == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE));
JsonValue = getUriFromService (RedfishService, Uri, &RedResponse->StatusCode); JsonValue = getUriFromService (RedfishService, Uri, &RedResponse->StatusCode);
RedResponse->Payload = createRedfishPayload(JsonValue, RedfishService); RedResponse->Payload = createRedfishPayload (JsonValue, RedfishService);
// //
// 1. If the returned Payload is NULL, indicates any error happen. // 1. If the returned Payload is NULL, indicates any error happen.
// 2. If the returned StatusCode is NULL, indicates any error happen. // 2. If the returned StatusCode is NULL, indicates any error happen.
// //
if (RedResponse->Payload == NULL || RedResponse->StatusCode == NULL) { if ((RedResponse->Payload == NULL) || (RedResponse->StatusCode == NULL)) {
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
@ -339,12 +347,15 @@ RedfishGetByUri (
// NOTE: If there is any error message returned from server, it will be returned in // NOTE: If there is any error message returned from server, it will be returned in
// Payload within RedResponse. // Payload within RedResponse.
// //
if (*(RedResponse->StatusCode) < HTTP_STATUS_200_OK || \ if ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \
*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT) { (*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT))
{
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Get a redfish response addressed by the input Payload and relative RedPath string, Get a redfish response addressed by the input Payload and relative RedPath string,
including HTTP StatusCode, Headers and Payload which record any HTTP response messages. including HTTP StatusCode, Headers and Payload which record any HTTP response messages.
@ -374,18 +385,18 @@ RedfishGetByUri (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishGetByPayload ( RedfishGetByPayload (
IN REDFISH_PAYLOAD Payload, IN REDFISH_PAYLOAD Payload,
IN CONST CHAR8 *RedPath, IN CONST CHAR8 *RedPath,
OUT REDFISH_RESPONSE *RedResponse OUT REDFISH_RESPONSE *RedResponse
) )
{ {
if (Payload == NULL || RedPath == NULL || RedResponse == NULL) { if ((Payload == NULL) || (RedPath == NULL) || (RedResponse == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE));
RedResponse->Payload = (REDFISH_PAYLOAD) getPayloadForPathString (Payload, RedPath, &(RedResponse->StatusCode)); RedResponse->Payload = (REDFISH_PAYLOAD)getPayloadForPathString (Payload, RedPath, &(RedResponse->StatusCode));
// //
// 1. If the returned Payload is NULL, indicates any error happen. // 1. If the returned Payload is NULL, indicates any error happen.
@ -400,15 +411,17 @@ RedfishGetByPayload (
// NOTE: If there is any error message returned from server, it will be returned in // NOTE: If there is any error message returned from server, it will be returned in
// Payload within RedResponse. // Payload within RedResponse.
// //
if (RedResponse->StatusCode != NULL && \ if ((RedResponse->StatusCode != NULL) && \
(*(RedResponse->StatusCode) < HTTP_STATUS_200_OK || \ ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \
*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT (*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT)
)) { ))
{
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Use HTTP PATCH to perform updates on pre-existing Redfish resource. Use HTTP PATCH to perform updates on pre-existing Redfish resource.
@ -442,30 +455,30 @@ RedfishGetByPayload (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishPatchToUri ( RedfishPatchToUri (
IN REDFISH_SERVICE RedfishService, IN REDFISH_SERVICE RedfishService,
IN CONST CHAR8 *Uri, IN CONST CHAR8 *Uri,
IN CONST CHAR8 *Content, IN CONST CHAR8 *Content,
OUT REDFISH_RESPONSE *RedResponse OUT REDFISH_RESPONSE *RedResponse
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EDKII_JSON_VALUE JsonValue; EDKII_JSON_VALUE JsonValue;
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
JsonValue = NULL; JsonValue = NULL;
if (RedfishService == NULL || Uri == NULL || Content == NULL || RedResponse == NULL) { if ((RedfishService == NULL) || (Uri == NULL) || (Content == NULL) || (RedResponse == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE));
JsonValue = (EDKII_JSON_VALUE) patchUriFromService ( JsonValue = (EDKII_JSON_VALUE)patchUriFromService (
RedfishService, RedfishService,
Uri, Uri,
Content, Content,
&(RedResponse->StatusCode) &(RedResponse->StatusCode)
); );
// //
// 1. If the returned StatusCode is NULL, indicates any error happen. // 1. If the returned StatusCode is NULL, indicates any error happen.
@ -480,8 +493,9 @@ RedfishPatchToUri (
// NOTE: If there is any error message returned from server, it will be returned in // NOTE: If there is any error message returned from server, it will be returned in
// Payload within RedResponse. // Payload within RedResponse.
// //
if (*(RedResponse->StatusCode) < HTTP_STATUS_200_OK || \ if ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \
*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT) { (*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT))
{
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
} }
@ -499,6 +513,7 @@ ON_EXIT:
return Status; return Status;
} }
/** /**
Use HTTP PATCH to perform updates on target payload. Patch to odata.id in Payload directly. Use HTTP PATCH to perform updates on target payload. Patch to odata.id in Payload directly.
@ -530,22 +545,22 @@ ON_EXIT:
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishPatchToPayload ( RedfishPatchToPayload (
IN REDFISH_PAYLOAD Target, IN REDFISH_PAYLOAD Target,
IN REDFISH_PAYLOAD Payload, IN REDFISH_PAYLOAD Payload,
OUT REDFISH_RESPONSE *RedResponse OUT REDFISH_RESPONSE *RedResponse
) )
{ {
if (Target == NULL || Payload == NULL || RedResponse == NULL) { if ((Target == NULL) || (Payload == NULL) || (RedResponse == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE));
RedResponse->Payload = (REDFISH_PAYLOAD) patchPayload ( RedResponse->Payload = (REDFISH_PAYLOAD)patchPayload (
Target, Target,
Payload, Payload,
&(RedResponse->StatusCode) &(RedResponse->StatusCode)
); );
// //
// 1. If the returned StatusCode is NULL, indicates any error happen. // 1. If the returned StatusCode is NULL, indicates any error happen.
@ -559,13 +574,15 @@ RedfishPatchToPayload (
// NOTE: If there is any error message returned from server, it will be returned in // NOTE: If there is any error message returned from server, it will be returned in
// Payload within RedResponse. // Payload within RedResponse.
// //
if (*(RedResponse->StatusCode) < HTTP_STATUS_200_OK || \ if ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \
*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT) { (*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT))
{
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Use HTTP POST to create a new resource in target payload. Use HTTP POST to create a new resource in target payload.
@ -596,22 +613,22 @@ RedfishPatchToPayload (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishPostToPayload ( RedfishPostToPayload (
IN REDFISH_PAYLOAD Target, IN REDFISH_PAYLOAD Target,
IN REDFISH_PAYLOAD Payload, IN REDFISH_PAYLOAD Payload,
OUT REDFISH_RESPONSE *RedResponse OUT REDFISH_RESPONSE *RedResponse
) )
{ {
if (Target == NULL || Payload == NULL || RedResponse == NULL) { if ((Target == NULL) || (Payload == NULL) || (RedResponse == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE));
RedResponse->Payload = (REDFISH_PAYLOAD) postPayload ( RedResponse->Payload = (REDFISH_PAYLOAD)postPayload (
Target, Target,
Payload, Payload,
&(RedResponse->StatusCode) &(RedResponse->StatusCode)
); );
// //
// 1. If the returned StatusCode is NULL, indicates any error happen. // 1. If the returned StatusCode is NULL, indicates any error happen.
@ -625,13 +642,15 @@ RedfishPostToPayload (
// NOTE: If there is any error message returned from server, it will be returned in // NOTE: If there is any error message returned from server, it will be returned in
// Payload within RedResponse. // Payload within RedResponse.
// //
if (*(RedResponse->StatusCode) < HTTP_STATUS_200_OK || \ if ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \
*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT) { (*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT))
{
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Use HTTP DELETE to remove a resource. Use HTTP DELETE to remove a resource.
@ -662,28 +681,28 @@ RedfishPostToPayload (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishDeleteByUri ( RedfishDeleteByUri (
IN REDFISH_SERVICE RedfishService, IN REDFISH_SERVICE RedfishService,
IN CONST CHAR8 *Uri, IN CONST CHAR8 *Uri,
OUT REDFISH_RESPONSE *RedResponse OUT REDFISH_RESPONSE *RedResponse
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EDKII_JSON_VALUE JsonValue; EDKII_JSON_VALUE JsonValue;
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
JsonValue = NULL; JsonValue = NULL;
if (RedfishService == NULL || Uri == NULL || RedResponse == NULL) { if ((RedfishService == NULL) || (Uri == NULL) || (RedResponse == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE));
JsonValue = (EDKII_JSON_VALUE) deleteUriFromService ( JsonValue = (EDKII_JSON_VALUE)deleteUriFromService (
RedfishService, RedfishService,
Uri, Uri,
&(RedResponse->StatusCode) &(RedResponse->StatusCode)
); );
// //
// 1. If the returned StatusCode is NULL, indicates any error happen. // 1. If the returned StatusCode is NULL, indicates any error happen.
@ -698,8 +717,9 @@ RedfishDeleteByUri (
// NOTE: If there is any error message returned from server, it will be returned in // NOTE: If there is any error message returned from server, it will be returned in
// Payload within RedResponse. // Payload within RedResponse.
// //
if (*(RedResponse->StatusCode) < HTTP_STATUS_200_OK || \ if ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \
*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT) { (*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT))
{
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
} }
@ -717,6 +737,7 @@ ON_EXIT:
return Status; return Status;
} }
/** /**
Dump text in fractions. Dump text in fractions.
@ -725,37 +746,40 @@ ON_EXIT:
**/ **/
VOID VOID
RedfishDumpJsonStringFractions ( RedfishDumpJsonStringFractions (
IN CHAR8 *String IN CHAR8 *String
) )
{ {
CHAR8 *NextFraction; CHAR8 *NextFraction;
UINTN StringFractionSize; UINTN StringFractionSize;
UINTN StrLen; UINTN StrLen;
UINTN Count; UINTN Count;
CHAR8 BackupChar; CHAR8 BackupChar;
StringFractionSize = 200; StringFractionSize = 200;
if (String == NULL) { if (String == NULL) {
return ; return;
} }
DEBUG((DEBUG_INFO, "JSON text:\n")); DEBUG ((DEBUG_INFO, "JSON text:\n"));
NextFraction = String; NextFraction = String;
StrLen = AsciiStrLen (String); StrLen = AsciiStrLen (String);
if (StrLen == 0) { if (StrLen == 0) {
return; return;
} }
for (Count = 0; Count < (StrLen / StringFractionSize); Count++) { for (Count = 0; Count < (StrLen / StringFractionSize); Count++) {
BackupChar = *(NextFraction + StringFractionSize); BackupChar = *(NextFraction + StringFractionSize);
*(NextFraction + StringFractionSize) = 0; *(NextFraction + StringFractionSize) = 0;
DEBUG((DEBUG_INFO, "%a", NextFraction)); DEBUG ((DEBUG_INFO, "%a", NextFraction));
*(NextFraction + StringFractionSize) = BackupChar; *(NextFraction + StringFractionSize) = BackupChar;
NextFraction += StringFractionSize; NextFraction += StringFractionSize;
} }
if ((StrLen % StringFractionSize) != 0) { if ((StrLen % StringFractionSize) != 0) {
DEBUG((DEBUG_INFO, "%a\n\n", NextFraction)); DEBUG ((DEBUG_INFO, "%a\n\n", NextFraction));
} }
} }
/** /**
Dump text in JSON value. Dump text in JSON value.
@ -767,15 +791,17 @@ RedfishDumpJson (
IN EDKII_JSON_VALUE JsonValue IN EDKII_JSON_VALUE JsonValue
) )
{ {
CHAR8 *String; CHAR8 *String;
String = JsonDumpString (JsonValue, 0); String = JsonDumpString (JsonValue, 0);
if (String == NULL) { if (String == NULL) {
return; return;
} }
RedfishDumpJsonStringFractions (String); RedfishDumpJsonStringFractions (String);
FreePool(String); FreePool (String);
} }
/** /**
Extract the JSON text content from REDFISH_PAYLOAD and dump to debug console. Extract the JSON text content from REDFISH_PAYLOAD and dump to debug console.
@ -784,14 +810,14 @@ RedfishDumpJson (
**/ **/
VOID VOID
RedfishDumpPayload ( RedfishDumpPayload (
IN REDFISH_PAYLOAD Payload IN REDFISH_PAYLOAD Payload
) )
{ {
EDKII_JSON_VALUE JsonValue; EDKII_JSON_VALUE JsonValue;
CHAR8 *String; CHAR8 *String;
JsonValue = NULL; JsonValue = NULL;
String = NULL; String = NULL;
if (Payload == NULL) { if (Payload == NULL) {
return; return;
@ -808,8 +834,9 @@ RedfishDumpPayload (
} }
RedfishDumpJsonStringFractions (String); RedfishDumpJsonStringFractions (String);
FreePool(String); FreePool (String);
} }
/** /**
This function will cleanup the HTTP header and Redfish payload resources. This function will cleanup the HTTP header and Redfish payload resources.
@ -832,8 +859,8 @@ RedfishFreeResponse (
StatusCode = NULL; StatusCode = NULL;
} }
if (HeaderCount != 0 && Headers != NULL) { if ((HeaderCount != 0) && (Headers != NULL)) {
HttpFreeHeaderFields(Headers, HeaderCount); HttpFreeHeaderFields (Headers, HeaderCount);
Headers = NULL; Headers = NULL;
} }
@ -842,6 +869,7 @@ RedfishFreeResponse (
Payload = NULL; Payload = NULL;
} }
} }
/** /**
Check if the "@odata.type" in Payload is valid or not. Check if the "@odata.type" in Payload is valid or not.
@ -855,17 +883,17 @@ RedfishFreeResponse (
**/ **/
BOOLEAN BOOLEAN
RedfishIsValidOdataType ( RedfishIsValidOdataType (
IN REDFISH_PAYLOAD Payload, IN REDFISH_PAYLOAD Payload,
IN CONST CHAR8 *OdataTypeName, IN CONST CHAR8 *OdataTypeName,
IN REDFISH_ODATA_TYPE_MAPPING *OdataTypeMappingList, IN REDFISH_ODATA_TYPE_MAPPING *OdataTypeMappingList,
IN UINTN OdataTypeMappingListSize IN UINTN OdataTypeMappingListSize
) )
{ {
UINTN Index; UINTN Index;
EDKII_JSON_VALUE OdataType; EDKII_JSON_VALUE OdataType;
EDKII_JSON_VALUE JsonValue; EDKII_JSON_VALUE JsonValue;
if (Payload == NULL || OdataTypeName == NULL) { if ((Payload == NULL) || (OdataTypeName == NULL)) {
return FALSE; return FALSE;
} }
@ -875,19 +903,22 @@ RedfishIsValidOdataType (
} }
OdataType = JsonObjectGetValue (JsonValueGetObject (JsonValue), "@odata.type"); OdataType = JsonObjectGetValue (JsonValueGetObject (JsonValue), "@odata.type");
if (!JsonValueIsString (OdataType) || JsonValueGetAsciiString (OdataType) == NULL) { if (!JsonValueIsString (OdataType) || (JsonValueGetAsciiString (OdataType) == NULL)) {
return FALSE; return FALSE;
} }
for (Index = 0; Index < OdataTypeMappingListSize; Index ++) { for (Index = 0; Index < OdataTypeMappingListSize; Index++) {
if (AsciiStrCmp (OdataTypeMappingList[Index].OdataTypeName, OdataTypeName) == 0 && if ((AsciiStrCmp (OdataTypeMappingList[Index].OdataTypeName, OdataTypeName) == 0) &&
AsciiStrCmp (OdataTypeMappingList[Index].OdataType, JsonValueGetAsciiString (OdataType)) == 0) { (AsciiStrCmp (OdataTypeMappingList[Index].OdataType, JsonValueGetAsciiString (OdataType)) == 0))
{
return TRUE; return TRUE;
} }
} }
DEBUG ((DEBUG_INFO, "%a: This Odata type is not in the list.\n", __FUNCTION__)); DEBUG ((DEBUG_INFO, "%a: This Odata type is not in the list.\n", __FUNCTION__));
return FALSE; return FALSE;
} }
/** /**
Check if the payload is collection Check if the payload is collection
@ -898,11 +929,12 @@ RedfishIsValidOdataType (
**/ **/
BOOLEAN BOOLEAN
RedfishIsPayloadCollection ( RedfishIsPayloadCollection (
IN REDFISH_PAYLOAD Payload IN REDFISH_PAYLOAD Payload
) )
{ {
return isPayloadCollection (Payload); return isPayloadCollection (Payload);
} }
/** /**
Get collection size. Get collection size.
@ -913,21 +945,23 @@ RedfishIsPayloadCollection (
@return EFI_INVALID_PARAMETER The payload is not a collection. @return EFI_INVALID_PARAMETER The payload is not a collection.
**/ **/
EFI_STATUS EFI_STATUS
RedfishGetCollectionSize( RedfishGetCollectionSize (
IN REDFISH_PAYLOAD Payload, IN REDFISH_PAYLOAD Payload,
IN UINTN *CollectionSize IN UINTN *CollectionSize
) )
{ {
if (Payload == NULL || CollectionSize == NULL) { if ((Payload == NULL) || (CollectionSize == NULL)) {
return EFI_INVALID_PARAMETER;
}
if (!RedfishIsPayloadCollection(Payload)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
*CollectionSize = (UINTN)getCollectionSize(Payload); if (!RedfishIsPayloadCollection (Payload)) {
return EFI_INVALID_PARAMETER;
}
*CollectionSize = (UINTN)getCollectionSize (Payload);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Get Redfish payload of collection member Get Redfish payload of collection member
@ -939,20 +973,23 @@ RedfishGetCollectionSize(
**/ **/
REDFISH_PAYLOAD REDFISH_PAYLOAD
RedfishGetPayloadByIndex ( RedfishGetPayloadByIndex (
IN REDFISH_PAYLOAD Payload, IN REDFISH_PAYLOAD Payload,
IN UINTN Index IN UINTN Index
) )
{ {
REDFISH_RESPONSE RedfishResponse; REDFISH_RESPONSE RedfishResponse;
REDFISH_PAYLOAD PayloadReturn; REDFISH_PAYLOAD PayloadReturn;
PayloadReturn = (VOID *)getPayloadByIndex (Payload, Index, &RedfishResponse.StatusCode); PayloadReturn = (VOID *)getPayloadByIndex (Payload, Index, &RedfishResponse.StatusCode);
if(PayloadReturn == NULL || if ((PayloadReturn == NULL) ||
(*(RedfishResponse.StatusCode) < HTTP_STATUS_200_OK && *(RedfishResponse.StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT)){ ((*(RedfishResponse.StatusCode) < HTTP_STATUS_200_OK) && (*(RedfishResponse.StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT)))
{
return NULL; return NULL;
} }
return PayloadReturn; return PayloadReturn;
} }
/** /**
Check and return Redfish resource of the given Redpath. Check and return Redfish resource of the given Redpath.
@ -964,30 +1001,33 @@ RedfishGetPayloadByIndex (
**/ **/
EFI_STATUS EFI_STATUS
RedfishCheckIfRedpathExist ( RedfishCheckIfRedpathExist (
IN REDFISH_SERVICE RedfishService, IN REDFISH_SERVICE RedfishService,
IN CHAR8 *Redpath, IN CHAR8 *Redpath,
IN REDFISH_RESPONSE *Response OPTIONAL IN REDFISH_RESPONSE *Response OPTIONAL
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
REDFISH_RESPONSE TempResponse; REDFISH_RESPONSE TempResponse;
if (Redpath == NULL) { if (Redpath == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
Status = RedfishGetByService (RedfishService, Redpath, &TempResponse); Status = RedfishGetByService (RedfishService, Redpath, &TempResponse);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
if (Response == NULL) { if (Response == NULL) {
RedfishFreeResponse( RedfishFreeResponse (
TempResponse.StatusCode, TempResponse.StatusCode,
TempResponse.HeaderCount, TempResponse.HeaderCount,
TempResponse.Headers, TempResponse.Headers,
TempResponse.Payload TempResponse.Payload
); );
} else { } else {
CopyMem ((VOID *)Response, (VOID *)&TempResponse, sizeof (REDFISH_RESPONSE)); CopyMem ((VOID *)Response, (VOID *)&TempResponse, sizeof (REDFISH_RESPONSE));
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -10,7 +10,7 @@
#include "RedfishMisc.h" #include "RedfishMisc.h"
EDKII_REDFISH_CREDENTIAL_PROTOCOL *mCredentialProtocol = NULL; EDKII_REDFISH_CREDENTIAL_PROTOCOL *mCredentialProtocol = NULL;
/** /**
This function returns the string of Redfish service version. This function returns the string of Redfish service version.
@ -23,25 +23,28 @@ EDKII_REDFISH_CREDENTIAL_PROTOCOL *mCredentialProtocol = NULL;
**/ **/
EFI_STATUS EFI_STATUS
RedfishGetServiceVersion ( RedfishGetServiceVersion (
IN REDFISH_SERVICE RedfishService, IN REDFISH_SERVICE RedfishService,
OUT CHAR8 **ServiceVersionStr OUT CHAR8 **ServiceVersionStr
) )
{ {
redfishService *Redfish; redfishService *Redfish;
CHAR8 **KeysArray; CHAR8 **KeysArray;
UINTN KeysNum; UINTN KeysNum;
if (RedfishService == NULL || ServiceVersionStr == NULL) { if ((RedfishService == NULL) || (ServiceVersionStr == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
Redfish = (redfishService *)RedfishService; Redfish = (redfishService *)RedfishService;
if (Redfish->versions == NULL) { if (Redfish->versions == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
KeysArray = JsonObjectGetKeys (Redfish->versions, &KeysNum); KeysArray = JsonObjectGetKeys (Redfish->versions, &KeysNum);
if (KeysNum == 0 || KeysArray == NULL) { if ((KeysNum == 0) || (KeysArray == NULL)) {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
*ServiceVersionStr = *KeysArray; *ServiceVersionStr = *KeysArray;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -65,18 +68,17 @@ RedfishGetServiceVersion (
**/ **/
REDFISH_SERVICE REDFISH_SERVICE
RedfishCreateLibredfishService ( RedfishCreateLibredfishService (
IN REDFISH_CONFIG_SERVICE_INFORMATION *RedfishConfigServiceInfo, IN REDFISH_CONFIG_SERVICE_INFORMATION *RedfishConfigServiceInfo,
IN EDKII_REDFISH_AUTH_METHOD AuthMethod, IN EDKII_REDFISH_AUTH_METHOD AuthMethod,
IN CHAR8 *UserId, IN CHAR8 *UserId,
IN CHAR8 *Password IN CHAR8 *Password
) )
{ {
UINTN Flags;
enumeratorAuthentication Auth;
redfishService *Redfish;
UINTN Flags; Redfish = NULL;
enumeratorAuthentication Auth;
redfishService* Redfish;
Redfish = NULL;
ZeroMem (&Auth, sizeof (Auth)); ZeroMem (&Auth, sizeof (Auth));
if (AuthMethod == AuthMethodHttpBasic) { if (AuthMethod == AuthMethodHttpBasic) {
@ -84,25 +86,26 @@ RedfishCreateLibredfishService (
} else if (AuthMethod == AuthMethodRedfishSession) { } else if (AuthMethod == AuthMethodRedfishSession) {
Auth.authType = REDFISH_AUTH_SESSION; Auth.authType = REDFISH_AUTH_SESSION;
} }
Auth.authCodes.userPass.username = UserId; Auth.authCodes.userPass.username = UserId;
Auth.authCodes.userPass.password = Password; Auth.authCodes.userPass.password = Password;
Flags = REDFISH_FLAG_SERVICE_NO_VERSION_DOC; Flags = REDFISH_FLAG_SERVICE_NO_VERSION_DOC;
if (AuthMethod != AuthMethodNone) { if (AuthMethod != AuthMethodNone) {
Redfish = createServiceEnumerator(RedfishConfigServiceInfo, NULL, &Auth, (unsigned int ) Flags); Redfish = createServiceEnumerator (RedfishConfigServiceInfo, NULL, &Auth, (unsigned int)Flags);
} else { } else {
Redfish = createServiceEnumerator(RedfishConfigServiceInfo, NULL, NULL, (unsigned int) Flags); Redfish = createServiceEnumerator (RedfishConfigServiceInfo, NULL, NULL, (unsigned int)Flags);
} }
// //
// Zero the Password after use. // Zero the Password after use.
// //
if (Password != NULL) { if (Password != NULL) {
ZeroMem (Password, AsciiStrLen(Password)); ZeroMem (Password, AsciiStrLen (Password));
} }
return (REDFISH_SERVICE) Redfish; return (REDFISH_SERVICE)Redfish;
} }
/** /**
@ -130,14 +133,14 @@ RedfishCreateLibredfishService (
**/ **/
EFI_STATUS EFI_STATUS
RedfishGetAuthInfo ( RedfishGetAuthInfo (
OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod, OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod,
OUT CHAR8 **UserId, OUT CHAR8 **UserId,
OUT CHAR8 **Password OUT CHAR8 **Password
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
if (AuthMethod == NULL || UserId == NULL || Password == NULL) { if ((AuthMethod == NULL) || (UserId == NULL) || (Password == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -161,6 +164,7 @@ RedfishGetAuthInfo (
return Status; return Status;
} }
/** /**
This function returns the string of Redfish service version. This function returns the string of Redfish service version.
@ -175,15 +179,15 @@ RedfishGetAuthInfo (
**/ **/
EFI_STATUS EFI_STATUS
RedfishBuildRedpathUseId ( RedfishBuildRedpathUseId (
IN CHAR8 *ServiceVerisonStr, IN CHAR8 *ServiceVerisonStr,
IN CHAR8 *Url, IN CHAR8 *Url,
IN CHAR8 *Id, IN CHAR8 *Id,
OUT CHAR8 **Redpath OUT CHAR8 **Redpath
) )
{ {
UINTN RedpathSize; UINTN RedpathSize;
if (Redpath == NULL || ServiceVerisonStr == NULL || Url == NULL || Id == NULL) { if ((Redpath == NULL) || (ServiceVerisonStr == NULL) || (Url == NULL) || (Id == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -192,10 +196,11 @@ RedfishBuildRedpathUseId (
AsciiStrLen (Url) + AsciiStrLen (Url) +
AsciiStrLen ("[Id=]") + AsciiStrLen ("[Id=]") +
AsciiStrLen (Id) + 1; AsciiStrLen (Id) + 1;
*Redpath = AllocatePool(RedpathSize); *Redpath = AllocatePool (RedpathSize);
if (*Redpath == NULL) { if (*Redpath == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
AsciiSPrint (*Redpath, RedpathSize, "/%a%a[Id=%a]", ServiceVerisonStr, Url, Id); AsciiSPrint (*Redpath, RedpathSize, "/%a%a[Id=%a]", ServiceVerisonStr, Url, Id);
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -22,7 +22,7 @@
#include <Protocol/EdkIIRedfishCredential.h> #include <Protocol/EdkIIRedfishCredential.h>
#include <redfish.h> #include <redfish.h>
#define ARRAY_SIZE(Array) (sizeof (Array) / sizeof ((Array)[0])) #define ARRAY_SIZE(Array) (sizeof (Array) / sizeof ((Array)[0]))
/** /**
Creates a REDFISH_SERVICE which can be later used to access the Redfish resources. Creates a REDFISH_SERVICE which can be later used to access the Redfish resources.
@ -43,10 +43,10 @@
**/ **/
REDFISH_SERVICE REDFISH_SERVICE
RedfishCreateLibredfishService ( RedfishCreateLibredfishService (
IN REDFISH_CONFIG_SERVICE_INFORMATION *RedfishConfigServiceInfo, IN REDFISH_CONFIG_SERVICE_INFORMATION *RedfishConfigServiceInfo,
IN EDKII_REDFISH_AUTH_METHOD AuthMethod, IN EDKII_REDFISH_AUTH_METHOD AuthMethod,
IN CHAR8 *UserId, IN CHAR8 *UserId,
IN CHAR8 *Password IN CHAR8 *Password
); );
/** /**
@ -74,9 +74,9 @@ RedfishCreateLibredfishService (
**/ **/
EFI_STATUS EFI_STATUS
RedfishGetAuthInfo ( RedfishGetAuthInfo (
OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod, OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod,
OUT CHAR8 **UserId, OUT CHAR8 **UserId,
OUT CHAR8 **Password OUT CHAR8 **Password
); );
#endif #endif

View File

@ -14,6 +14,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef LIBREDFISH_REDFISH_H_ #ifndef LIBREDFISH_REDFISH_H_
#define LIBREDFISH_REDFISH_H_ #define LIBREDFISH_REDFISH_H_

View File

@ -14,6 +14,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef LIBREDFISH_REDFISH_PAYLOAD_H_ #ifndef LIBREDFISH_REDFISH_PAYLOAD_H_
#define LIBREDFISH_REDFISH_PAYLOAD_H_ #define LIBREDFISH_REDFISH_PAYLOAD_H_
@ -23,17 +24,83 @@
#include <redfishService.h> #include <redfishService.h>
#include <redpath.h> #include <redpath.h>
redfishPayload* createRedfishPayload(json_t* value, redfishService* service); redfishPayload *
redfishPayload* getPayloadByNodeName(redfishPayload* payload, const char* nodeName, EFI_HTTP_STATUS_CODE** StatusCode); createRedfishPayload (
redfishPayload* getPayloadByIndex(redfishPayload* payload, size_t index, EFI_HTTP_STATUS_CODE** StatusCode); json_t *value,
redfishPayload* getPayloadForPath(redfishPayload* payload, redPathNode* redpath, EFI_HTTP_STATUS_CODE** StatusCode); redfishService *service
redfishPayload* getPayloadForPathString(redfishPayload* payload, const char* string, EFI_HTTP_STATUS_CODE** StatusCode); );
redfishPayload* patchPayload(redfishPayload* target, redfishPayload* payload, EFI_HTTP_STATUS_CODE** StatusCode);
redfishPayload* postContentToPayload(redfishPayload* target, const char* data, size_t dataSize, const char* contentType, EFI_HTTP_STATUS_CODE** StatusCode); redfishPayload *
redfishPayload* postPayload(redfishPayload* target, redfishPayload* payload, EFI_HTTP_STATUS_CODE** StatusCode); getPayloadByNodeName (
void cleanupPayload(redfishPayload* payload); redfishPayload *payload,
bool isPayloadCollection (redfishPayload *Payload); const char *nodeName,
size_t getCollectionSize(redfishPayload* payload); EFI_HTTP_STATUS_CODE **StatusCode
redfishPayload* getPayloadByIndex (redfishPayload* payload, size_t index, EFI_HTTP_STATUS_CODE** StatusCode); );
redfishPayload *
getPayloadByIndex (
redfishPayload *payload,
size_t index,
EFI_HTTP_STATUS_CODE **StatusCode
);
redfishPayload *
getPayloadForPath (
redfishPayload *payload,
redPathNode *redpath,
EFI_HTTP_STATUS_CODE **StatusCode
);
redfishPayload *
getPayloadForPathString (
redfishPayload *payload,
const char *string,
EFI_HTTP_STATUS_CODE **StatusCode
);
redfishPayload *
patchPayload (
redfishPayload *target,
redfishPayload *payload,
EFI_HTTP_STATUS_CODE **StatusCode
);
redfishPayload *
postContentToPayload (
redfishPayload *target,
const char *data,
size_t dataSize,
const char *contentType,
EFI_HTTP_STATUS_CODE **StatusCode
);
redfishPayload *
postPayload (
redfishPayload *target,
redfishPayload *payload,
EFI_HTTP_STATUS_CODE **StatusCode
);
void
cleanupPayload (
redfishPayload *payload
);
bool
isPayloadCollection (
redfishPayload *Payload
);
size_t
getCollectionSize (
redfishPayload *payload
);
redfishPayload *
getPayloadByIndex (
redfishPayload *payload,
size_t index,
EFI_HTTP_STATUS_CODE **StatusCode
);
#endif #endif

View File

@ -38,64 +38,114 @@
#include <jansson.h> #include <jansson.h>
typedef struct { typedef struct {
char* host; char *host;
json_t* versions; json_t *versions;
unsigned int flags; unsigned int flags;
char* sessionToken; char *sessionToken;
char* basicAuthStr; char *basicAuthStr;
// //
// point to the <HOST> part in above "host" field, which will be put into // point to the <HOST> part in above "host" field, which will be put into
// the "Host" header of HTTP request message. // the "Host" header of HTTP request message.
// //
char* HostHeaderValue; char *HostHeaderValue;
EFI_REST_EX_PROTOCOL *RestEx; EFI_REST_EX_PROTOCOL *RestEx;
} redfishService; } redfishService;
typedef struct { typedef struct {
json_t* json; json_t *json;
redfishService* service; redfishService *service;
} redfishPayload; } redfishPayload;
#define REDFISH_AUTH_BASIC 0 #define REDFISH_AUTH_BASIC 0
#define REDFISH_AUTH_BEARER_TOKEN 1 #define REDFISH_AUTH_BEARER_TOKEN 1
#define REDFISH_AUTH_SESSION 2 #define REDFISH_AUTH_SESSION 2
#define REDFISH_HTTP_RESPONSE_TIMEOUT 5000 /// 5 seconds in uints of millisecond. #define REDFISH_HTTP_RESPONSE_TIMEOUT 5000 /// 5 seconds in uints of millisecond.
/// ///
/// Library class public defines /// Library class public defines
/// ///
#define HTTP_FLAG L"http://" #define HTTP_FLAG L"http://"
#define HTTPS_FLAG L"https://" #define HTTPS_FLAG L"https://"
/// ///
/// The redfish first URL should be "/redfish/v1/", while we use "/redfish/v1" here without "/" /// The redfish first URL should be "/redfish/v1/", while we use "/redfish/v1" here without "/"
/// in the end is to avoid the 301 Perment redirect response from Redfish profile simulator. /// in the end is to avoid the 301 Perment redirect response from Redfish profile simulator.
/// ///
#define REDFISH_FIRST_URL L"/redfish/v1" #define REDFISH_FIRST_URL L"/redfish/v1"
typedef struct { typedef struct {
unsigned int authType; unsigned int authType;
union { union {
struct { struct {
char* username; char *username;
char* password; char *password;
} userPass; } userPass;
struct { struct {
char* token; char *token;
} authToken; } authToken;
} authCodes; } authCodes;
} enumeratorAuthentication; } enumeratorAuthentication;
//Values for flags // Values for flags
#define REDFISH_FLAG_SERVICE_NO_VERSION_DOC 0x00000001 //The Redfish Service lacks the version document (in violation of the Redfish spec) #define REDFISH_FLAG_SERVICE_NO_VERSION_DOC 0x00000001// The Redfish Service lacks the version document (in violation of the Redfish spec)
redfishService* createServiceEnumerator(REDFISH_CONFIG_SERVICE_INFORMATION *RedfishConfigServiceInfo, const char* rootUri, enumeratorAuthentication* auth, unsigned int flags); redfishService *
json_t* getUriFromService(redfishService* service, const char* uri, EFI_HTTP_STATUS_CODE** StatusCode); createServiceEnumerator (
json_t* patchUriFromService(redfishService* service, const char* uri, const char* content, EFI_HTTP_STATUS_CODE** StatusCode); REDFISH_CONFIG_SERVICE_INFORMATION *RedfishConfigServiceInfo,
json_t* postUriFromService(redfishService* service, const char* uri, const char* content, size_t contentLength, const char* contentType, EFI_HTTP_STATUS_CODE** StatusCode); const char *rootUri,
json_t* deleteUriFromService(redfishService* service, const char* uri, EFI_HTTP_STATUS_CODE** StatusCode); enumeratorAuthentication *auth,
redfishPayload* getRedfishServiceRoot(redfishService* service, const char* version, EFI_HTTP_STATUS_CODE** StatusCode); unsigned int flags
redfishPayload* getPayloadByPath(redfishService* service, const char* path, EFI_HTTP_STATUS_CODE** StatusCode); );
void cleanupServiceEnumerator(redfishService* service);
json_t *
getUriFromService (
redfishService *service,
const char *uri,
EFI_HTTP_STATUS_CODE **StatusCode
);
json_t *
patchUriFromService (
redfishService *service,
const char *uri,
const char *content,
EFI_HTTP_STATUS_CODE **StatusCode
);
json_t *
postUriFromService (
redfishService *service,
const char *uri,
const char *content,
size_t contentLength,
const char *contentType,
EFI_HTTP_STATUS_CODE **StatusCode
);
json_t *
deleteUriFromService (
redfishService *service,
const char *uri,
EFI_HTTP_STATUS_CODE **StatusCode
);
redfishPayload *
getRedfishServiceRoot (
redfishService *service,
const char *version,
EFI_HTTP_STATUS_CODE **StatusCode
);
redfishPayload *
getPayloadByPath (
redfishService *service,
const char *path,
EFI_HTTP_STATUS_CODE **StatusCode
);
void
cleanupServiceEnumerator (
redfishService *service
);
#endif #endif

View File

@ -14,6 +14,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef LIBREDFISH_REDPATH_H_ #ifndef LIBREDFISH_REDPATH_H_
#define LIBREDFISH_REDPATH_H_ #define LIBREDFISH_REDPATH_H_
@ -21,22 +22,28 @@
#include <jansson.h> #include <jansson.h>
typedef struct _redPathNode typedef struct _redPathNode {
{ bool isRoot;
bool isRoot; bool isIndex;
bool isIndex;
char* version; char *version;
char* nodeName; char *nodeName;
size_t index; size_t index;
char* op; char *op;
char* propName; char *propName;
char* value; char *value;
struct _redPathNode* next; struct _redPathNode *next;
} redPathNode; } redPathNode;
redPathNode* parseRedPath(const char* path); redPathNode *
void cleanupRedPath(redPathNode* node); parseRedPath (
const char *path
);
void
cleanupRedPath (
redPathNode *node
);
#endif #endif

View File

@ -16,177 +16,209 @@
**/ **/
#include <redpath.h> #include <redpath.h>
static char* getVersion(const char* path, char** end); static char *
static void parseNode(const char* path, redPathNode* node, redPathNode** end); getVersion (
const char *path,
char **end
);
static char* getStringTill(const char* string, const char* terminator, char** retEnd); static void
parseNode (
const char *path,
redPathNode *node,
redPathNode **end
);
redPathNode* parseRedPath(const char* path) static char *
getStringTill (
const char *string,
const char *terminator,
char **retEnd
);
redPathNode *
parseRedPath (
const char *path
)
{ {
redPathNode* node; redPathNode *node;
redPathNode* endNode; redPathNode *endNode;
char* curPath; char *curPath;
char* end; char *end;
if(!path || strlen(path) == 0) if (!path || (strlen (path) == 0)) {
{ return NULL;
return NULL; }
}
node = (redPathNode*)calloc(1, sizeof(redPathNode)); node = (redPathNode *)calloc (1, sizeof (redPathNode));
if(!node) if (!node) {
{ return NULL;
return NULL; }
}
if(path[0] == '/') if (path[0] == '/') {
{ node->isRoot = true;
node->isRoot = true; if (path[1] == 'v') {
if(path[1] == 'v') node->version = getVersion (path+1, &curPath);
{ if (curPath == NULL) {
node->version = getVersion(path+1, &curPath);
if(curPath == NULL)
{
return node;
}
if(curPath[0] == '/')
{
curPath++;
}
node->next = parseRedPath(curPath);
}
else
{
node->next = parseRedPath(path+1);
}
return node; return node;
}
if (curPath[0] == '/') {
curPath++;
}
node->next = parseRedPath (curPath);
} else {
node->next = parseRedPath (path+1);
} }
node->isRoot = false;
curPath = getStringTill(path, "/", &end);
endNode = node;
parseNode(curPath, node, &endNode);
free(curPath);
if(end != NULL)
{
endNode->next = parseRedPath(end+1);
}
return node; return node;
}
node->isRoot = false;
curPath = getStringTill (path, "/", &end);
endNode = node;
parseNode (curPath, node, &endNode);
free (curPath);
if (end != NULL) {
endNode->next = parseRedPath (end+1);
}
return node;
} }
void cleanupRedPath(redPathNode* node) void
cleanupRedPath (
redPathNode *node
)
{ {
if(!node) if (!node) {
{ return;
return; }
}
cleanupRedPath(node->next); cleanupRedPath (node->next);
node->next = NULL; node->next = NULL;
if(node->version) if (node->version) {
{ free (node->version);
free(node->version); }
}
if(node->nodeName) if (node->nodeName) {
{ free (node->nodeName);
free(node->nodeName); }
}
if(node->op) if (node->op) {
{ free (node->op);
free(node->op); }
}
if(node->propName) if (node->propName) {
{ free (node->propName);
free(node->propName); }
}
if(node->value) if (node->value) {
{ free (node->value);
free(node->value); }
}
free(node); free (node);
} }
static char* getVersion(const char* path, char** end) static char *
getVersion (
const char *path,
char **end
)
{ {
return getStringTill(path, "/", end); return getStringTill (path, "/", end);
} }
static void parseNode(const char* path, redPathNode* node, redPathNode** end) static void
parseNode (
const char *path,
redPathNode *node,
redPathNode **end
)
{ {
char* indexStart; char *indexStart;
char* index; char *index;
char* indexEnd; char *indexEnd;
char* nodeName = getStringTill(path, "[", &indexStart); char *nodeName = getStringTill (path, "[", &indexStart);
size_t tmpIndex; size_t tmpIndex;
char* opChars; char *opChars;
node->nodeName = nodeName; node->nodeName = nodeName;
if(indexStart == NULL) if (indexStart == NULL) {
{ *end = node;
*end = node; return;
return; }
}
node->next = (redPathNode*)calloc(1, sizeof(redPathNode));
if(!node->next)
{
return;
}
//Skip past [
indexStart++;
*end = node->next;
index = getStringTill(indexStart, "]", NULL);
tmpIndex = (size_t)strtoull(index, &indexEnd, 0);
if(indexEnd != index)
{
free(index);
node->next->index = tmpIndex;
node->next->isIndex = true;
return;
}
opChars = strpbrk(index, "<>=~");
if(opChars == NULL)
{
//TODO handle last() and position()
node->next->op = strdup("exists");
node->next->propName = index;
return;
}
node->next->propName = (char*)malloc((opChars - index)+1);
memcpy(node->next->propName, index, (opChars - index));
node->next->propName[(opChars - index)] = 0;
tmpIndex = 1; node->next = (redPathNode *)calloc (1, sizeof (redPathNode));
while(1) if (!node->next) {
{ return;
if(opChars[tmpIndex] == '=' || opChars[tmpIndex] == '<' || opChars[tmpIndex] == '>' || opChars[tmpIndex] == '~') }
{
tmpIndex++; // Skip past [
continue; indexStart++;
} *end = node->next;
break; index = getStringTill (indexStart, "]", NULL);
tmpIndex = (size_t)strtoull (index, &indexEnd, 0);
if (indexEnd != index) {
free (index);
node->next->index = tmpIndex;
node->next->isIndex = true;
return;
}
opChars = strpbrk (index, "<>=~");
if (opChars == NULL) {
// TODO handle last() and position()
node->next->op = strdup ("exists");
node->next->propName = index;
return;
}
node->next->propName = (char *)malloc ((opChars - index)+1);
memcpy (node->next->propName, index, (opChars - index));
node->next->propName[(opChars - index)] = 0;
tmpIndex = 1;
while (1) {
if ((opChars[tmpIndex] == '=') || (opChars[tmpIndex] == '<') || (opChars[tmpIndex] == '>') || (opChars[tmpIndex] == '~')) {
tmpIndex++;
continue;
} }
node->next->op = (char*)malloc(tmpIndex+1); break;
memcpy(node->next->op, opChars, tmpIndex); }
node->next->op[tmpIndex] = 0;
node->next->value = strdup(opChars+tmpIndex); node->next->op = (char *)malloc (tmpIndex+1);
free(index); memcpy (node->next->op, opChars, tmpIndex);
node->next->op[tmpIndex] = 0;
node->next->value = strdup (opChars+tmpIndex);
free (index);
} }
static char* getStringTill(const char* string, const char* terminator, char** retEnd) static char *
getStringTill (
const char *string,
const char *terminator,
char **retEnd
)
{ {
char* ret; char *ret;
char* end; char *end;
end = strstr((char*)string, terminator);
if(retEnd) end = strstr ((char *)string, terminator);
{ if (retEnd) {
*retEnd = end; *retEnd = end;
} }
if(end == NULL)
{ if (end == NULL) {
//No terminator // No terminator
return strdup(string); return strdup (string);
} }
ret = (char*)malloc((end-string)+1);
memcpy(ret, string, (end-string)); ret = (char *)malloc ((end-string)+1);
ret[(end-string)] = 0; memcpy (ret, string, (end-string));
return ret; ret[(end-string)] = 0;
return ret;
} }

View File

@ -9,12 +9,12 @@
#include "RedfishConfigHandlerCommon.h" #include "RedfishConfigHandlerCommon.h"
REDFISH_CONFIG_DRIVER_DATA gRedfishConfigData; // Only one Redfish service supproted REDFISH_CONFIG_DRIVER_DATA gRedfishConfigData; // Only one Redfish service supproted
// on platform for the BIOS // on platform for the BIOS
// Redfish configuration. // Redfish configuration.
EFI_EVENT gEndOfDxeEvent = NULL; EFI_EVENT gEndOfDxeEvent = NULL;
EFI_EVENT gExitBootServiceEvent = NULL; EFI_EVENT gExitBootServiceEvent = NULL;
EDKII_REDFISH_CREDENTIAL_PROTOCOL *gCredential = NULL; EDKII_REDFISH_CREDENTIAL_PROTOCOL *gCredential = NULL;
/** /**
Callback function executed when the EndOfDxe event group is signaled. Callback function executed when the EndOfDxe event group is signaled.
@ -30,10 +30,10 @@ RedfishConfigOnEndOfDxe (
OUT VOID *Context OUT VOID *Context
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
Status = gCredential->StopService (gCredential, ServiceStopTypeSecureBootDisabled); Status = gCredential->StopService (gCredential, ServiceStopTypeSecureBootDisabled);
if (EFI_ERROR(Status) && Status != EFI_UNSUPPORTED) { if (EFI_ERROR (Status) && (Status != EFI_UNSUPPORTED)) {
DEBUG ((DEBUG_ERROR, "Redfish credential protocol faied to stop service on EndOfDxe: %r", Status)); DEBUG ((DEBUG_ERROR, "Redfish credential protocol faied to stop service on EndOfDxe: %r", Status));
} }
@ -58,10 +58,10 @@ RedfishConfigOnExitBootService (
OUT VOID *Context OUT VOID *Context
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
Status = gCredential->StopService (gCredential, ServiceStopTypeExitBootService); Status = gCredential->StopService (gCredential, ServiceStopTypeExitBootService);
if (EFI_ERROR(Status) && Status != EFI_UNSUPPORTED) { if (EFI_ERROR (Status) && (Status != EFI_UNSUPPORTED)) {
DEBUG ((DEBUG_ERROR, "Redfish credential protocol faied to stop service on ExitBootService: %r", Status)); DEBUG ((DEBUG_ERROR, "Redfish credential protocol faied to stop service on ExitBootService: %r", Status));
} }
} }
@ -113,16 +113,18 @@ RedfishConfigCommonInit (
IN EFI_SYSTEM_TABLE *SystemTable IN EFI_SYSTEM_TABLE *SystemTable
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
// //
// Locate Redfish Credential Protocol to get credential for // Locate Redfish Credential Protocol to get credential for
// accessing to Redfish service. // accessing to Redfish service.
// //
Status = gBS->LocateProtocol (&gEdkIIRedfishCredentialProtocolGuid, NULL, (VOID **) &gCredential); Status = gBS->LocateProtocol (&gEdkIIRedfishCredentialProtocolGuid, NULL, (VOID **)&gCredential);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "%a: No Redfish Credential Protocol is installed on system.", __FUNCTION__)); DEBUG ((DEBUG_INFO, "%a: No Redfish Credential Protocol is installed on system.", __FUNCTION__));
return Status; return Status;
} }
// //
// Create EndOfDxe Event. // Create EndOfDxe Event.
// //
@ -138,6 +140,7 @@ RedfishConfigCommonInit (
DEBUG ((DEBUG_ERROR, "%a: Fail to register End Of DXE event.", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: Fail to register End Of DXE event.", __FUNCTION__));
return Status; return Status;
} }
// //
// Create Exit Boot Service event. // Create Exit Boot Service event.
// //
@ -155,8 +158,10 @@ RedfishConfigCommonInit (
DEBUG ((DEBUG_ERROR, "%a: Fail to register Exit Boot Service event.", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: Fail to register Exit Boot Service event.", __FUNCTION__));
return Status; return Status;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
This is the common code to stop EDK2 Redfish feature driver. This is the common code to stop EDK2 Redfish feature driver.
@ -167,13 +172,13 @@ RedfishConfigCommonInit (
EFI_STATUS EFI_STATUS
RedfishConfigCommonStop ( RedfishConfigCommonStop (
VOID VOID
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_HANDLE *HandleBuffer; EFI_HANDLE *HandleBuffer;
UINTN NumberOfHandles; UINTN NumberOfHandles;
UINTN Index; UINTN Index;
EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *ConfigHandler; EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *ConfigHandler;
Status = gBS->LocateHandleBuffer ( Status = gBS->LocateHandleBuffer (
ByProtocol, ByProtocol,
@ -182,27 +187,29 @@ RedfishConfigCommonStop (
&NumberOfHandles, &NumberOfHandles,
&HandleBuffer &HandleBuffer
); );
if (EFI_ERROR (Status) && Status != EFI_NOT_FOUND) { if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
return Status; return Status;
} }
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
for (Index = 0; Index < NumberOfHandles; Index++) { for (Index = 0; Index < NumberOfHandles; Index++) {
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
HandleBuffer[Index], HandleBuffer[Index],
&gEdkIIRedfishConfigHandlerProtocolGuid, &gEdkIIRedfishConfigHandlerProtocolGuid,
(VOID**) &ConfigHandler (VOID **)&ConfigHandler
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
Status = ConfigHandler->Stop (ConfigHandler); Status = ConfigHandler->Stop (ConfigHandler);
if (EFI_ERROR (Status) && Status != EFI_UNSUPPORTED) { if (EFI_ERROR (Status) && (Status != EFI_UNSUPPORTED)) {
DEBUG ((DEBUG_ERROR, "ERROR: Failed to stop Redfish config handler %p.\n", ConfigHandler)); DEBUG ((DEBUG_ERROR, "ERROR: Failed to stop Redfish config handler %p.\n", ConfigHandler));
break; break;
} }
} }
return Status; return Status;
} }
/** /**
Callback function executed when a Redfish Config Handler Protocol is installed Callback function executed when a Redfish Config Handler Protocol is installed
by EDK2 Redfish Feature Drivers. by EDK2 Redfish Feature Drivers.
@ -213,12 +220,12 @@ RedfishConfigHandlerInitialization (
VOID VOID
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_HANDLE *HandleBuffer; EFI_HANDLE *HandleBuffer;
UINTN NumberOfHandles; UINTN NumberOfHandles;
EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *ConfigHandler; EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *ConfigHandler;
UINTN Index; UINTN Index;
UINT32 Id; UINT32 Id;
Status = gBS->LocateHandleBuffer ( Status = gBS->LocateHandleBuffer (
ByProtocol, ByProtocol,
@ -233,33 +240,34 @@ RedfishConfigHandlerInitialization (
for (Index = 0; Index < NumberOfHandles; Index++) { for (Index = 0; Index < NumberOfHandles; Index++) {
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
HandleBuffer [Index], HandleBuffer[Index],
&gEfiCallerIdGuid, &gEfiCallerIdGuid,
(VOID **) &Id (VOID **)&Id
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
continue; continue;
} }
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
HandleBuffer [Index], HandleBuffer[Index],
&gEdkIIRedfishConfigHandlerProtocolGuid, &gEdkIIRedfishConfigHandlerProtocolGuid,
(VOID**) &ConfigHandler (VOID **)&ConfigHandler
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
Status = ConfigHandler->Init (ConfigHandler, &gRedfishConfigData.RedfishServiceInfo); Status = ConfigHandler->Init (ConfigHandler, &gRedfishConfigData.RedfishServiceInfo);
if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) { if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
DEBUG ((DEBUG_ERROR, "ERROR: Failed to init Redfish config handler %p.\n", ConfigHandler)); DEBUG ((DEBUG_ERROR, "ERROR: Failed to init Redfish config handler %p.\n", ConfigHandler));
} }
// //
// Install caller ID to indicate Redfish Configure Handler is initialized. // Install caller ID to indicate Redfish Configure Handler is initialized.
// //
Status = gBS->InstallProtocolInterface ( Status = gBS->InstallProtocolInterface (
&HandleBuffer [Index], &HandleBuffer[Index],
&gEfiCallerIdGuid, &gEfiCallerIdGuid,
EFI_NATIVE_INTERFACE, EFI_NATIVE_INTERFACE,
(VOID *)&gRedfishConfigData.CallerId (VOID *)&gRedfishConfigData.CallerId
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
} }

View File

@ -40,11 +40,11 @@
/// Internal structure used by Redfish Config DXE driver. /// Internal structure used by Redfish Config DXE driver.
/// ///
typedef struct { typedef struct {
UINT32 CallerId; ///< Caller ID used to indicate Redfish Config Handler UINT32 CallerId; ///< Caller ID used to indicate Redfish Config Handler
///< has been initiated ///< has been initiated
EFI_HANDLE Image; ///< Image handle of Redfish Config Driver EFI_HANDLE Image; ///< Image handle of Redfish Config Driver
EFI_EVENT Event; ///< Event for the notification of EFI_REDFISH_CONFIG_HANDLER_PROTOCOL EFI_EVENT Event; ///< Event for the notification of EFI_REDFISH_CONFIG_HANDLER_PROTOCOL
REDFISH_CONFIG_SERVICE_INFORMATION RedfishServiceInfo; /// Redfish Service information discovered REDFISH_CONFIG_SERVICE_INFORMATION RedfishServiceInfo; /// Redfish Service information discovered
} REDFISH_CONFIG_DRIVER_DATA; } REDFISH_CONFIG_DRIVER_DATA;
/** /**
@ -86,7 +86,7 @@ RedfishConfigCommonInit (
EFI_STATUS EFI_STATUS
RedfishConfigCommonStop ( RedfishConfigCommonStop (
VOID VOID
); );
/** /**
Callback function executed when a Redfish Config Handler Protocol is installed Callback function executed when a Redfish Config Handler Protocol is installed

View File

@ -17,22 +17,22 @@ EFI_EVENT gEfiRedfishDiscoverProtocolEvent = NULL;
// //
// Variables for using RFI Redfish Discover Protocol // Variables for using RFI Redfish Discover Protocol
// //
VOID *gEfiRedfishDiscoverRegistration; VOID *gEfiRedfishDiscoverRegistration;
EFI_HANDLE gEfiRedfishDiscoverControllerHandle = NULL; EFI_HANDLE gEfiRedfishDiscoverControllerHandle = NULL;
EFI_REDFISH_DISCOVER_PROTOCOL *gEfiRedfishDiscoverProtocol = NULL; EFI_REDFISH_DISCOVER_PROTOCOL *gEfiRedfishDiscoverProtocol = NULL;
BOOLEAN gRedfishDiscoverActivated = FALSE; BOOLEAN gRedfishDiscoverActivated = FALSE;
BOOLEAN gRedfishServiceDiscovered = FALSE; BOOLEAN gRedfishServiceDiscovered = FALSE;
// //
// Network interfaces discovered by EFI Redfish Discover Protocol. // Network interfaces discovered by EFI Redfish Discover Protocol.
// //
UINTN gNumberOfNetworkInterfaces; UINTN gNumberOfNetworkInterfaces;
EFI_REDFISH_DISCOVER_NETWORK_INTERFACE *gNetworkInterfaceInstances = NULL; EFI_REDFISH_DISCOVER_NETWORK_INTERFACE *gNetworkInterfaceInstances = NULL;
EFI_REDFISH_DISCOVERED_TOKEN *gRedfishDiscoveredToken = NULL; EFI_REDFISH_DISCOVERED_TOKEN *gRedfishDiscoveredToken = NULL;
/// ///
/// Driver Binding Protocol instance /// Driver Binding Protocol instance
/// ///
EFI_DRIVER_BINDING_PROTOCOL gRedfishConfigDriverBinding = { EFI_DRIVER_BINDING_PROTOCOL gRedfishConfigDriverBinding = {
RedfishConfigDriverBindingSupported, RedfishConfigDriverBindingSupported,
RedfishConfigDriverBindingStart, RedfishConfigDriverBindingStart,
RedfishConfigDriverBindingStop, RedfishConfigDriverBindingStop,
@ -48,7 +48,7 @@ EFI_DRIVER_BINDING_PROTOCOL gRedfishConfigDriverBinding = {
VOID VOID
RedfishConfigStopRedfishDiscovery ( RedfishConfigStopRedfishDiscovery (
VOID VOID
) )
{ {
if (gRedfishDiscoverActivated) { if (gRedfishDiscoverActivated) {
// //
@ -57,6 +57,7 @@ RedfishConfigStopRedfishDiscovery (
if (gEfiRedfishDiscoverProtocolEvent != NULL) { if (gEfiRedfishDiscoverProtocolEvent != NULL) {
gBS->CloseEvent (gEfiRedfishDiscoverProtocolEvent); gBS->CloseEvent (gEfiRedfishDiscoverProtocolEvent);
} }
// //
// Stop Redfish service discovery. // Stop Redfish service discovery.
// //
@ -65,9 +66,9 @@ RedfishConfigStopRedfishDiscovery (
gNetworkInterfaceInstances gNetworkInterfaceInstances
); );
gEfiRedfishDiscoverControllerHandle = NULL; gEfiRedfishDiscoverControllerHandle = NULL;
gEfiRedfishDiscoverProtocol = NULL; gEfiRedfishDiscoverProtocol = NULL;
gRedfishDiscoverActivated = FALSE; gRedfishDiscoverActivated = FALSE;
gRedfishServiceDiscovered = FALSE; gRedfishServiceDiscovered = FALSE;
} }
} }
@ -138,9 +139,9 @@ RedfishConfigDriverBindingSupported (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
) )
{ {
EFI_REST_EX_PROTOCOL *RestEx; EFI_REST_EX_PROTOCOL *RestEx;
EFI_STATUS Status; EFI_STATUS Status;
EFI_HANDLE ChildHandle; EFI_HANDLE ChildHandle;
ChildHandle = NULL; ChildHandle = NULL;
@ -161,10 +162,10 @@ RedfishConfigDriverBindingSupported (
// //
// Test if REST EX protocol is ready. // Test if REST EX protocol is ready.
// //
Status = gBS->OpenProtocol( Status = gBS->OpenProtocol (
ChildHandle, ChildHandle,
&gEfiRestExProtocolGuid, &gEfiRestExProtocolGuid,
(VOID**) &RestEx, (VOID **)&RestEx,
This->DriverBindingHandle, This->DriverBindingHandle,
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -172,6 +173,7 @@ RedfishConfigDriverBindingSupported (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
} }
NetLibDestroyServiceChild ( NetLibDestroyServiceChild (
ControllerHandle, ControllerHandle,
This->ImageHandle, This->ImageHandle,
@ -222,19 +224,19 @@ RedfishConfigDriverBindingStart (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
) )
{ {
VOID *ConfigHandlerRegistration; VOID *ConfigHandlerRegistration;
if (gRedfishConfigData.Event != NULL) { if (gRedfishConfigData.Event != NULL) {
return EFI_ALREADY_STARTED; return EFI_ALREADY_STARTED;
} }
gRedfishConfigData.Event = EfiCreateProtocolNotifyEvent ( gRedfishConfigData.Event = EfiCreateProtocolNotifyEvent (
&gEdkIIRedfishConfigHandlerProtocolGuid, &gEdkIIRedfishConfigHandlerProtocolGuid,
TPL_CALLBACK, TPL_CALLBACK,
RedfishConfigHandlerInstalledCallback, RedfishConfigHandlerInstalledCallback,
(VOID *)&gRedfishConfigData, (VOID *)&gRedfishConfigData,
&ConfigHandlerRegistration &ConfigHandlerRegistration
); );
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -278,6 +280,7 @@ RedfishConfigDriverBindingStop (
if (ControllerHandle == gEfiRedfishDiscoverControllerHandle) { if (ControllerHandle == gEfiRedfishDiscoverControllerHandle) {
RedfishConfigStopRedfishDiscovery (); RedfishConfigStopRedfishDiscovery ();
} }
gBS->CloseProtocol ( gBS->CloseProtocol (
ControllerHandle, ControllerHandle,
&gEfiRedfishDiscoverProtocolGuid, &gEfiRedfishDiscoverProtocolGuid,
@ -294,6 +297,7 @@ RedfishConfigDriverBindingStop (
gBS->CloseEvent (gRedfishConfigData.Event); gBS->CloseEvent (gRedfishConfigData.Event);
gRedfishConfigData.Event = NULL; gRedfishConfigData.Event = NULL;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -311,8 +315,8 @@ RedfishServiceDiscoveredCallback (
OUT VOID *Context OUT VOID *Context
) )
{ {
EFI_REDFISH_DISCOVERED_TOKEN *RedfishDiscoveredToken; EFI_REDFISH_DISCOVERED_TOKEN *RedfishDiscoveredToken;
EFI_REDFISH_DISCOVERED_INSTANCE *RedfishInstance; EFI_REDFISH_DISCOVERED_INSTANCE *RedfishInstance;
if (gRedfishServiceDiscovered) { if (gRedfishServiceDiscovered) {
// //
@ -322,7 +326,7 @@ RedfishServiceDiscoveredCallback (
} }
RedfishDiscoveredToken = (EFI_REDFISH_DISCOVERED_TOKEN *)Context; RedfishDiscoveredToken = (EFI_REDFISH_DISCOVERED_TOKEN *)Context;
RedfishInstance = RedfishDiscoveredToken->DiscoverList.RedfishInstances; RedfishInstance = RedfishDiscoveredToken->DiscoverList.RedfishInstances;
// //
// Only pick up the first found Redfish service. // Only pick up the first found Redfish service.
// //
@ -336,7 +340,7 @@ RedfishServiceDiscoveredCallback (
gRedfishConfigData.RedfishServiceInfo.RedfishServiceProduct = RedfishInstance->Information.Product; gRedfishConfigData.RedfishServiceInfo.RedfishServiceProduct = RedfishInstance->Information.Product;
gRedfishConfigData.RedfishServiceInfo.RedfishServiceProductVer = RedfishInstance->Information.ProductVer; gRedfishConfigData.RedfishServiceInfo.RedfishServiceProductVer = RedfishInstance->Information.ProductVer;
gRedfishConfigData.RedfishServiceInfo.RedfishServiceUseHttps = RedfishInstance->Information.UseHttps; gRedfishConfigData.RedfishServiceInfo.RedfishServiceUseHttps = RedfishInstance->Information.UseHttps;
gRedfishServiceDiscovered = TRUE; gRedfishServiceDiscovered = TRUE;
} }
// //
@ -361,76 +365,79 @@ RedfishDiscoverProtocolInstalled (
OUT VOID *Context OUT VOID *Context
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
UINTN BufferSize; UINTN BufferSize;
EFI_HANDLE HandleBuffer; EFI_HANDLE HandleBuffer;
UINTN NetworkInterfaceIndex; UINTN NetworkInterfaceIndex;
EFI_REDFISH_DISCOVER_NETWORK_INTERFACE *ThisNetworkInterface; EFI_REDFISH_DISCOVER_NETWORK_INTERFACE *ThisNetworkInterface;
EFI_REDFISH_DISCOVERED_TOKEN *ThisRedfishDiscoveredToken; EFI_REDFISH_DISCOVERED_TOKEN *ThisRedfishDiscoveredToken;
DEBUG((DEBUG_INFO, "%a: New network interface is installed on system by EFI Redfish discover driver.\n", __FUNCTION__)); DEBUG ((DEBUG_INFO, "%a: New network interface is installed on system by EFI Redfish discover driver.\n", __FUNCTION__));
BufferSize = sizeof (EFI_HANDLE); BufferSize = sizeof (EFI_HANDLE);
Status = gBS->LocateHandle ( Status = gBS->LocateHandle (
ByRegisterNotify, ByRegisterNotify,
NULL, NULL,
gEfiRedfishDiscoverRegistration, gEfiRedfishDiscoverRegistration,
&BufferSize, &BufferSize,
&HandleBuffer &HandleBuffer
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG((DEBUG_ERROR, "%a: Can't locate handle with EFI_REDFISH_DISCOVER_PROTOCOL installed.\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: Can't locate handle with EFI_REDFISH_DISCOVER_PROTOCOL installed.\n", __FUNCTION__));
} }
gRedfishDiscoverActivated = TRUE; gRedfishDiscoverActivated = TRUE;
if (gEfiRedfishDiscoverProtocol == NULL) { if (gEfiRedfishDiscoverProtocol == NULL) {
gEfiRedfishDiscoverControllerHandle = HandleBuffer; gEfiRedfishDiscoverControllerHandle = HandleBuffer;
// //
// First time to open EFI_REDFISH_DISCOVER_PROTOCOL. // First time to open EFI_REDFISH_DISCOVER_PROTOCOL.
// //
Status = gBS->OpenProtocol( Status = gBS->OpenProtocol (
gEfiRedfishDiscoverControllerHandle, gEfiRedfishDiscoverControllerHandle,
&gEfiRedfishDiscoverProtocolGuid, &gEfiRedfishDiscoverProtocolGuid,
(VOID **)&gEfiRedfishDiscoverProtocol, (VOID **)&gEfiRedfishDiscoverProtocol,
gRedfishConfigData.Image, gRedfishConfigData.Image,
gRedfishConfigData.Image, gRedfishConfigData.Image,
EFI_OPEN_PROTOCOL_BY_DRIVER EFI_OPEN_PROTOCOL_BY_DRIVER
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
gEfiRedfishDiscoverProtocol = NULL; gEfiRedfishDiscoverProtocol = NULL;
gRedfishDiscoverActivated = FALSE; gRedfishDiscoverActivated = FALSE;
DEBUG((DEBUG_ERROR, "%a: Can't locate EFI_REDFISH_DISCOVER_PROTOCOL.\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: Can't locate EFI_REDFISH_DISCOVER_PROTOCOL.\n", __FUNCTION__));
return; return;
} }
} }
// //
// Check the new found network interface. // Check the new found network interface.
// //
if (gNetworkInterfaceInstances != NULL) { if (gNetworkInterfaceInstances != NULL) {
FreePool (gNetworkInterfaceInstances); FreePool (gNetworkInterfaceInstances);
} }
Status = gEfiRedfishDiscoverProtocol->GetNetworkInterfaceList(
Status = gEfiRedfishDiscoverProtocol->GetNetworkInterfaceList (
gEfiRedfishDiscoverProtocol, gEfiRedfishDiscoverProtocol,
gRedfishConfigData.Image, gRedfishConfigData.Image,
&gNumberOfNetworkInterfaces, &gNumberOfNetworkInterfaces,
&gNetworkInterfaceInstances &gNetworkInterfaceInstances
); );
if (EFI_ERROR (Status) || gNumberOfNetworkInterfaces == 0) { if (EFI_ERROR (Status) || (gNumberOfNetworkInterfaces == 0)) {
DEBUG((DEBUG_ERROR, "%a: No network interfaces found on the handle.\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: No network interfaces found on the handle.\n", __FUNCTION__));
return; return;
} }
gRedfishDiscoveredToken = AllocateZeroPool (gNumberOfNetworkInterfaces * sizeof (EFI_REDFISH_DISCOVERED_TOKEN)); gRedfishDiscoveredToken = AllocateZeroPool (gNumberOfNetworkInterfaces * sizeof (EFI_REDFISH_DISCOVERED_TOKEN));
if (gRedfishDiscoveredToken == NULL) { if (gRedfishDiscoveredToken == NULL) {
DEBUG((DEBUG_ERROR, "%a: Not enough memory for EFI_REDFISH_DISCOVERED_TOKEN.\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: Not enough memory for EFI_REDFISH_DISCOVERED_TOKEN.\n", __FUNCTION__));
return; return;
} }
ThisNetworkInterface = gNetworkInterfaceInstances; ThisNetworkInterface = gNetworkInterfaceInstances;
ThisRedfishDiscoveredToken = gRedfishDiscoveredToken; ThisRedfishDiscoveredToken = gRedfishDiscoveredToken;
// //
// Loop to discover Redfish service on each network interface. // Loop to discover Redfish service on each network interface.
// //
for (NetworkInterfaceIndex = 0; NetworkInterfaceIndex < gNumberOfNetworkInterfaces; NetworkInterfaceIndex ++) { for (NetworkInterfaceIndex = 0; NetworkInterfaceIndex < gNumberOfNetworkInterfaces; NetworkInterfaceIndex++) {
// //
// Initial this Redfish Discovered Token // Initial this Redfish Discovered Token
// //
@ -440,37 +447,40 @@ RedfishDiscoverProtocolInstalled (
RedfishServiceDiscoveredCallback, RedfishServiceDiscoveredCallback,
(VOID *)ThisRedfishDiscoveredToken, (VOID *)ThisRedfishDiscoveredToken,
&ThisRedfishDiscoveredToken->Event &ThisRedfishDiscoveredToken->Event
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG((DEBUG_ERROR, "%a: Failed to create event for Redfish discovered token.\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: Failed to create event for Redfish discovered token.\n", __FUNCTION__));
goto ErrorReturn; goto ErrorReturn;
} }
ThisRedfishDiscoveredToken->Signature = REDFISH_DISCOVER_TOKEN_SIGNATURE;
ThisRedfishDiscoveredToken->Signature = REDFISH_DISCOVER_TOKEN_SIGNATURE;
ThisRedfishDiscoveredToken->DiscoverList.NumberOfServiceFound = 0; ThisRedfishDiscoveredToken->DiscoverList.NumberOfServiceFound = 0;
ThisRedfishDiscoveredToken->DiscoverList.RedfishInstances = NULL; ThisRedfishDiscoveredToken->DiscoverList.RedfishInstances = NULL;
// //
// Acquire for Redfish service which is reported by // Acquire for Redfish service which is reported by
// Redfish Host Interface. // Redfish Host Interface.
// //
Status = gEfiRedfishDiscoverProtocol->AcquireRedfishService( Status = gEfiRedfishDiscoverProtocol->AcquireRedfishService (
gEfiRedfishDiscoverProtocol, gEfiRedfishDiscoverProtocol,
gRedfishConfigData.Image, gRedfishConfigData.Image,
ThisNetworkInterface, ThisNetworkInterface,
EFI_REDFISH_DISCOVER_HOST_INTERFACE, EFI_REDFISH_DISCOVER_HOST_INTERFACE,
ThisRedfishDiscoveredToken ThisRedfishDiscoveredToken
); );
ThisNetworkInterface ++; ThisNetworkInterface++;
ThisRedfishDiscoveredToken ++; ThisRedfishDiscoveredToken++;
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG((DEBUG_ERROR, "%a: Acquire Redfish service fail.\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: Acquire Redfish service fail.\n", __FUNCTION__));
goto ErrorReturn; goto ErrorReturn;
} }
return; return;
ErrorReturn: ErrorReturn:
if (gRedfishDiscoveredToken != NULL) { if (gRedfishDiscoveredToken != NULL) {
FreePool(gRedfishDiscoveredToken); FreePool (gRedfishDiscoveredToken);
} }
} }
@ -488,23 +498,26 @@ RedfishConfigHandlerDriverUnload (
IN EFI_HANDLE ImageHandle IN EFI_HANDLE ImageHandle
) )
{ {
EFI_REDFISH_DISCOVERED_TOKEN *ThisRedfishDiscoveredToken; EFI_REDFISH_DISCOVERED_TOKEN *ThisRedfishDiscoveredToken;
UINTN NumberOfNetworkInterfacesIndex; UINTN NumberOfNetworkInterfacesIndex;
RedfishConfigDriverCommonUnload (ImageHandle); RedfishConfigDriverCommonUnload (ImageHandle);
RedfishConfigStopRedfishDiscovery (); RedfishConfigStopRedfishDiscovery ();
if (gRedfishDiscoveredToken != NULL) { if (gRedfishDiscoveredToken != NULL) {
ThisRedfishDiscoveredToken = gRedfishDiscoveredToken; ThisRedfishDiscoveredToken = gRedfishDiscoveredToken;
for (NumberOfNetworkInterfacesIndex = 0; NumberOfNetworkInterfacesIndex < gNumberOfNetworkInterfaces; NumberOfNetworkInterfacesIndex ++) { for (NumberOfNetworkInterfacesIndex = 0; NumberOfNetworkInterfacesIndex < gNumberOfNetworkInterfaces; NumberOfNetworkInterfacesIndex++) {
if (ThisRedfishDiscoveredToken->Event != NULL) { if (ThisRedfishDiscoveredToken->Event != NULL) {
gBS->CloseEvent (ThisRedfishDiscoveredToken->Event); gBS->CloseEvent (ThisRedfishDiscoveredToken->Event);
} }
FreePool (ThisRedfishDiscoveredToken); FreePool (ThisRedfishDiscoveredToken);
ThisRedfishDiscoveredToken ++; ThisRedfishDiscoveredToken++;
} }
gRedfishDiscoveredToken = NULL; gRedfishDiscoveredToken = NULL;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -526,7 +539,7 @@ RedfishConfigHandlerDriverEntryPoint (
IN EFI_SYSTEM_TABLE *SystemTable IN EFI_SYSTEM_TABLE *SystemTable
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
ZeroMem ((VOID *)&gRedfishConfigData, sizeof (REDFISH_CONFIG_DRIVER_DATA)); ZeroMem ((VOID *)&gRedfishConfigData, sizeof (REDFISH_CONFIG_DRIVER_DATA));
gRedfishConfigData.Image = ImageHandle; gRedfishConfigData.Image = ImageHandle;
@ -546,11 +559,12 @@ RedfishConfigHandlerDriverEntryPoint (
DEBUG ((DEBUG_ERROR, "%a: Fail to create event for the installation of EFI_REDFISH_DISCOVER_PROTOCOL.", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: Fail to create event for the installation of EFI_REDFISH_DISCOVER_PROTOCOL.", __FUNCTION__));
return Status; return Status;
} }
Status = gBS->RegisterProtocolNotify ( Status = gBS->RegisterProtocolNotify (
&gEfiRedfishDiscoverProtocolGuid, &gEfiRedfishDiscoverProtocolGuid,
gEfiRedfishDiscoverProtocolEvent, gEfiRedfishDiscoverProtocolEvent,
&gEfiRedfishDiscoverRegistration &gEfiRedfishDiscoverRegistration
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: Fail to register event for the installation of EFI_REDFISH_DISCOVER_PROTOCOL.", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: Fail to register event for the installation of EFI_REDFISH_DISCOVER_PROTOCOL.", __FUNCTION__));
return Status; return Status;
@ -582,6 +596,6 @@ RedfishConfigHandlerDriverEntryPoint (
DEBUG ((DEBUG_ERROR, "%a: Fail to install EFI Binding Protocol of EFI Redfish Config driver.", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: Fail to install EFI Binding Protocol of EFI Redfish Config driver.", __FUNCTION__));
return Status; return Status;
} }
return Status; return Status;
} }

View File

@ -26,10 +26,10 @@
// //
extern EFI_DRIVER_BINDING_PROTOCOL gRedfishConfigDriverBinding; extern EFI_DRIVER_BINDING_PROTOCOL gRedfishConfigDriverBinding;
extern REDFISH_CONFIG_DRIVER_DATA gRedfishConfigData; extern REDFISH_CONFIG_DRIVER_DATA gRedfishConfigData;
extern EDKII_REDFISH_CREDENTIAL_PROTOCOL *gCredential; extern EDKII_REDFISH_CREDENTIAL_PROTOCOL *gCredential;
extern EFI_EVENT gEndOfDxeEvent; extern EFI_EVENT gEndOfDxeEvent;
extern EFI_EVENT gExitBootServiceEvent; extern EFI_EVENT gExitBootServiceEvent;
/** /**
Tests to see if this driver supports a given controller. If a child device is provided, Tests to see if this driver supports a given controller. If a child device is provided,
@ -151,9 +151,10 @@ RedfishConfigDriverBindingStart (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishConfigDriverBindingStop ( RedfishConfigDriverBindingStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ControllerHandle,
IN UINTN NumberOfChildren, IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer OPTIONAL IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
); );
#endif #endif

View File

@ -10,7 +10,7 @@
#include <RedfishCredentialDxe.h> #include <RedfishCredentialDxe.h>
EDKII_REDFISH_CREDENTIAL_PROTOCOL mRedfishCredentialProtocol = { EDKII_REDFISH_CREDENTIAL_PROTOCOL mRedfishCredentialProtocol = {
RedfishCredentialGetAuthInfo, RedfishCredentialGetAuthInfo,
RedfishCredentialStopService RedfishCredentialStopService
}; };
@ -79,17 +79,17 @@ RedfishCredentialEndOfDxeEventNotify (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishCredentialGetAuthInfo ( RedfishCredentialGetAuthInfo (
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This, IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This,
OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod, OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod,
OUT CHAR8 **UserId, OUT CHAR8 **UserId,
OUT CHAR8 **Password OUT CHAR8 **Password
) )
{ {
if (This == NULL || AuthMethod == NULL || UserId == NULL || Password == NULL) { if ((This == NULL) || (AuthMethod == NULL) || (UserId == NULL) || (Password == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
return LibCredentialGetAuthInfo (This, AuthMethod, UserId,Password); return LibCredentialGetAuthInfo (This, AuthMethod, UserId, Password);
} }
/** /**
@ -112,8 +112,8 @@ RedfishCredentialGetAuthInfo (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishCredentialStopService ( RedfishCredentialStopService (
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This, IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This,
IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType
) )
{ {
if (This == NULL) { if (This == NULL) {
@ -135,8 +135,8 @@ RedfishCredentialStopService (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishCredentialDxeDriverEntryPoint ( RedfishCredentialDxeDriverEntryPoint (
IN EFI_HANDLE ImageHandle, IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable IN EFI_SYSTEM_TABLE *SystemTable
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;

View File

@ -6,6 +6,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef EDKII_REDFISH_CREDENTIAL_DXE_H_ #ifndef EDKII_REDFISH_CREDENTIAL_DXE_H_
#define EDKII_REDFISH_CREDENTIAL_DXE_H_ #define EDKII_REDFISH_CREDENTIAL_DXE_H_
@ -45,10 +46,10 @@
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishCredentialGetAuthInfo ( RedfishCredentialGetAuthInfo (
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This, IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This,
OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod, OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod,
OUT CHAR8 **UserId, OUT CHAR8 **UserId,
OUT CHAR8 **Password OUT CHAR8 **Password
); );
/** /**
@ -69,7 +70,8 @@ RedfishCredentialGetAuthInfo (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishCredentialStopService ( RedfishCredentialStopService (
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This, IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This,
IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType
); );
#endif #endif

View File

@ -13,6 +13,7 @@
// //
// EFI Component Name Functions // EFI Component Name Functions
// //
/** /**
Retrieves a Unicode string that is the user-readable name of the EFI Driver. Retrieves a Unicode string that is the user-readable name of the EFI Driver.
@ -87,13 +88,12 @@ EFI_STATUS
EFIAPI EFIAPI
RedfishDiscoverComponentNameGetControllerName ( RedfishDiscoverComponentNameGetControllerName (
IN EFI_COMPONENT_NAME_PROTOCOL *This, IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL, IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language, IN CHAR8 *Language,
OUT CHAR16 **ControllerName OUT CHAR16 **ControllerName
); );
/// ///
/// Component Name Protocol instance /// Component Name Protocol instance
/// ///
@ -109,8 +109,8 @@ EFI_COMPONENT_NAME_PROTOCOL gRedfishDiscoverComponentName = {
/// ///
GLOBAL_REMOVE_IF_UNREFERENCED GLOBAL_REMOVE_IF_UNREFERENCED
EFI_COMPONENT_NAME2_PROTOCOL gRedfishDiscoverComponentName2 = { EFI_COMPONENT_NAME2_PROTOCOL gRedfishDiscoverComponentName2 = {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) RedfishDiscoverComponentNameGetDriverName, (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)RedfishDiscoverComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) RedfishDiscoverComponentNameGetControllerName, (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)RedfishDiscoverComponentNameGetControllerName,
"en" "en"
}; };
@ -118,12 +118,12 @@ EFI_COMPONENT_NAME2_PROTOCOL gRedfishDiscoverComponentName2 = {
/// Table of driver names /// Table of driver names
/// ///
GLOBAL_REMOVE_IF_UNREFERENCED GLOBAL_REMOVE_IF_UNREFERENCED
EFI_UNICODE_STRING_TABLE mRedfishDiscoverDriverNameTable[] = { EFI_UNICODE_STRING_TABLE mRedfishDiscoverDriverNameTable[] = {
{ "eng;en", (CHAR16 *)L"Redfish Discover UEFI Driver" }, { "eng;en", (CHAR16 *)L"Redfish Discover UEFI Driver" },
{ NULL, NULL } { NULL, NULL }
}; };
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gRedfishDiscoverControllerNameTable = NULL; GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gRedfishDiscoverControllerNameTable = NULL;
/** /**
Retrieves a Unicode string that is the user-readable name of the EFI Driver. Retrieves a Unicode string that is the user-readable name of the EFI Driver.
@ -208,10 +208,10 @@ EFI_STATUS
EFIAPI EFIAPI
RedfishDiscoverComponentNameGetControllerName ( RedfishDiscoverComponentNameGetControllerName (
IN EFI_COMPONENT_NAME_PROTOCOL *This, IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL, IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language, IN CHAR8 *Language,
OUT CHAR16 **ControllerName OUT CHAR16 **ControllerName
) )
{ {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;

File diff suppressed because it is too large Load Diff

View File

@ -33,11 +33,11 @@
#include <IndustryStandard/RedfishHostInterface.h> #include <IndustryStandard/RedfishHostInterface.h>
#define REDFISH_DISCOVER_VERSION 0x00010000 #define REDFISH_DISCOVER_VERSION 0x00010000
#define EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_TPL TPL_NOTIFY #define EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_TPL TPL_NOTIFY
// //
//GUID definitions // GUID definitions
// //
#define EFI_REDFISH_DISCOVER_TCP4_INSTANCE_GUID \ #define EFI_REDFISH_DISCOVER_TCP4_INSTANCE_GUID \
@ -75,11 +75,11 @@ typedef enum {
// the network interface. // the network interface.
// //
typedef struct { typedef struct {
EFI_GUID ProtocolGuid; ///< Network protocol GUID. EFI_GUID ProtocolGuid; ///< Network protocol GUID.
EFI_GUID ProtocolServiceGuid; ///< Network protocol service GUID. EFI_GUID ProtocolServiceGuid; ///< Network protocol service GUID.
UINT32 ProtocolDiscoverId; ///< The identifier installed on network protocol handle. UINT32 ProtocolDiscoverId; ///< The identifier installed on network protocol handle.
EFI_HANDLE ProtocolControllerHandle; ///< The controller handle on network protocol. EFI_HANDLE ProtocolControllerHandle; ///< The controller handle on network protocol.
VOID *NetworkProtocolInterface; ///< The protocol interface of network protocol. VOID *NetworkProtocolInterface; ///< The protocol interface of network protocol.
} REDFISH_DISCOVER_NETWORK_INTERFACE_PROTOCOL; } REDFISH_DISCOVER_NETWORK_INTERFACE_PROTOCOL;
// //
@ -87,39 +87,39 @@ typedef struct {
// interface properties. // interface properties.
// //
typedef struct { typedef struct {
LIST_ENTRY Entry; ///< Link list entry. LIST_ENTRY Entry; ///< Link list entry.
EFI_HANDLE OpenDriverAgentHandle; ///< The agent to open network protocol. EFI_HANDLE OpenDriverAgentHandle; ///< The agent to open network protocol.
EFI_HANDLE OpenDriverControllerHandle; ///< The controller handle to open network protocol. EFI_HANDLE OpenDriverControllerHandle; ///< The controller handle to open network protocol.
UINTN HwAddressSize; ///< The size of network interface hardware address. UINTN HwAddressSize; ///< The size of network interface hardware address.
EFI_MAC_ADDRESS MacAddress; ///< MAC address of network interface. EFI_MAC_ADDRESS MacAddress; ///< MAC address of network interface.
CHAR16 *StrMacAddr; ///< String to MAC address of network interface. CHAR16 *StrMacAddr; ///< String to MAC address of network interface.
BOOLEAN GotSubnetInfo; ///< Indicates sub net information is retrieved. BOOLEAN GotSubnetInfo; ///< Indicates sub net information is retrieved.
EFI_IP_ADDRESS SubnetAddr; ///< Subnet ID. EFI_IP_ADDRESS SubnetAddr; ///< Subnet ID.
EFI_IP_ADDRESS SubnetMask; ///< Subnet mask (IPv4 only) EFI_IP_ADDRESS SubnetMask; ///< Subnet mask (IPv4 only)
UINT8 SubnetPrefixLength; ///< Subnet prefix. UINT8 SubnetPrefixLength; ///< Subnet prefix.
UINT16 VlanId; ///< VLAN ID UINT16 VlanId; ///< VLAN ID
UINT32 SubnetAddrInfoIPv6Number; ///< IPv6 address info number. UINT32 SubnetAddrInfoIPv6Number; ///< IPv6 address info number.
EFI_IP6_ADDRESS_INFO *SubnetAddrInfoIPv6; ///< IPv6 address info. EFI_IP6_ADDRESS_INFO *SubnetAddrInfoIPv6; ///< IPv6 address info.
// //
// Network interface protocol and REST EX infor. // Network interface protocol and REST EX infor.
// //
UINT32 NetworkProtocolType; ///< Network protocol type. Refer to UINT32 NetworkProtocolType; ///< Network protocol type. Refer to
///< NETWORK_INTERFACE_PROTOCOL_TYPE. ///< NETWORK_INTERFACE_PROTOCOL_TYPE.
REDFISH_DISCOVER_NETWORK_INTERFACE_PROTOCOL NetworkInterfaceProtocolInfo; ///< Network interface protocol information. REDFISH_DISCOVER_NETWORK_INTERFACE_PROTOCOL NetworkInterfaceProtocolInfo; ///< Network interface protocol information.
EFI_HANDLE RestExHandle; ///< REST EX handle associated with this network interface. EFI_HANDLE RestExHandle; ///< REST EX handle associated with this network interface.
} EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL; } EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL;
// //
// Internal structure used to maintain REST EX properties. // Internal structure used to maintain REST EX properties.
// //
typedef struct { typedef struct {
LIST_ENTRY Entry; ///< Link list entry. LIST_ENTRY Entry; ///< Link list entry.
EFI_HANDLE OpenDriverAgentHandle; ///< The agent to open network protocol. EFI_HANDLE OpenDriverAgentHandle; ///< The agent to open network protocol.
EFI_HANDLE OpenDriverControllerHandle; ///< The controller handle to open network protocol. EFI_HANDLE OpenDriverControllerHandle; ///< The controller handle to open network protocol.
EFI_HANDLE RestExChildHandle; ///< The child handle created throught REST EX Service Protocol. EFI_HANDLE RestExChildHandle; ///< The child handle created throught REST EX Service Protocol.
EFI_HANDLE RestExControllerHandle; ///< The controller handle which provide REST EX protocol. EFI_HANDLE RestExControllerHandle; ///< The controller handle which provide REST EX protocol.
EFI_REST_EX_PROTOCOL *RestExProtocolInterface; ///< Pointer to EFI_REST_EX_PROTOCOL. EFI_REST_EX_PROTOCOL *RestExProtocolInterface; ///< Pointer to EFI_REST_EX_PROTOCOL.
UINT32 RestExId; ///< The identifier installed on REST EX controller handle. UINT32 RestExId; ///< The identifier installed on REST EX controller handle.
} EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL; } EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL;
/** /**
@ -135,46 +135,46 @@ EFI_STATUS
(EFIAPI *EFI_REDFISH_DISCOVER_GET_SUBNET_INFO)( (EFIAPI *EFI_REDFISH_DISCOVER_GET_SUBNET_INFO)(
IN EFI_HANDLE ImageHandle, IN EFI_HANDLE ImageHandle,
IN EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *Instance IN EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *Instance
); );
// //
// The require network protocol matrix. // The require network protocol matrix.
// //
typedef struct { typedef struct {
UINT32 ProtocolType; ///< Network protocol type, UINT32 ProtocolType; ///< Network protocol type,
///< Refer to NETWORK_INTERFACE_PROTOCOL_TYPE. ///< Refer to NETWORK_INTERFACE_PROTOCOL_TYPE.
CHAR16 *ProtocolName; ///< Protocol name. CHAR16 *ProtocolName; ///< Protocol name.
EFI_GUID *RequiredProtocolGuid; ///< Network protocol interface GUID. EFI_GUID *RequiredProtocolGuid; ///< Network protocol interface GUID.
EFI_GUID *RequiredServiceBindingProtocolGuid; ///< Network protocol service GUID. EFI_GUID *RequiredServiceBindingProtocolGuid; ///< Network protocol service GUID.
EFI_GUID *DiscoveredProtocolGuid; ///< Protocol interface GUID use to install identifier. EFI_GUID *DiscoveredProtocolGuid; ///< Protocol interface GUID use to install identifier.
EFI_REDFISH_DISCOVER_GET_SUBNET_INFO GetSubnetInfo; ///< Function of getting subnet information. EFI_REDFISH_DISCOVER_GET_SUBNET_INFO GetSubnetInfo; ///< Function of getting subnet information.
} REDFISH_DISCOVER_REQUIRED_PROTOCOL; } REDFISH_DISCOVER_REQUIRED_PROTOCOL;
// //
// Link list of Redfish discover instance. // Link list of Redfish discover instance.
// //
typedef struct { typedef struct {
LIST_ENTRY NextInstance; ///< Next list. LIST_ENTRY NextInstance; ///< Next list.
EFI_REDFISH_DISCOVERED_INSTANCE *Instance; ///< Pointer to EFI_REDFISH_DISCOVERED_INSTANCE. EFI_REDFISH_DISCOVERED_INSTANCE *Instance; ///< Pointer to EFI_REDFISH_DISCOVERED_INSTANCE.
} EFI_REDFISH_DISCOVERED_INTERNAL_LIST; } EFI_REDFISH_DISCOVERED_INTERNAL_LIST;
// //
// Internal structure of Redfish discover instance. // Internal structure of Redfish discover instance.
// //
typedef struct { typedef struct {
LIST_ENTRY Entry; ///< Link list entry. LIST_ENTRY Entry; ///< Link list entry.
EFI_HANDLE Owner; ///< The owner owns this Redfish service discovery. EFI_HANDLE Owner; ///< The owner owns this Redfish service discovery.
///< It's the EFI image handle of driver uses ///< It's the EFI image handle of driver uses
///< EFI Redfish Discover Protocol. ///< EFI Redfish Discover Protocol.
EFI_REDFISH_DISCOVER_FLAG DiscoverFlags; ///< EFI_REDFISH_DISCOVER_FLAG EFI_REDFISH_DISCOVER_FLAG DiscoverFlags; ///< EFI_REDFISH_DISCOVER_FLAG
EFI_REDFISH_DISCOVERED_TOKEN *DiscoverToken; ///< Token used to signal when Redfish service is discovered. EFI_REDFISH_DISCOVERED_TOKEN *DiscoverToken; ///< Token used to signal when Redfish service is discovered.
EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *NetworkInterface; ///< EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *NetworkInterface; ///< EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL
///< instance used to discover Redfish service. ///< instance used to discover Redfish service.
// //
// Below for Host insterface discovery. // Below for Host insterface discovery.
// //
BOOLEAN HostIntfValidation; ///< Indicates whether to validate Redfish Host interface. BOOLEAN HostIntfValidation; ///< Indicates whether to validate Redfish Host interface.
EFI_IP_ADDRESS TargetIpAddress; ///< Target IP address reported in Redfish Host interface. EFI_IP_ADDRESS TargetIpAddress; ///< Target IP address reported in Redfish Host interface.
} EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE; } EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE;
/** /**
@ -197,15 +197,15 @@ typedef struct {
**/ **/
EFI_STATUS EFI_STATUS
AddAndSignalNewRedfishService ( AddAndSignalNewRedfishService (
IN EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE *Instance, IN EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE *Instance,
IN UINTN *RedfishVersion OPTIONAL, IN UINTN *RedfishVersion OPTIONAL,
IN CHAR8 *RedfishLocation OPTIONAL, IN CHAR8 *RedfishLocation OPTIONAL,
IN CHAR8 *Uuid OPTIONAL, IN CHAR8 *Uuid OPTIONAL,
IN CHAR8 *Os OPTIONAL, IN CHAR8 *Os OPTIONAL,
IN CHAR8 *OsVer OPTIONAL, IN CHAR8 *OsVer OPTIONAL,
IN CHAR8 *Product OPTIONAL, IN CHAR8 *Product OPTIONAL,
IN CHAR8 *ProductVer OPTIONAL, IN CHAR8 *ProductVer OPTIONAL,
IN BOOLEAN UseHttps IN BOOLEAN UseHttps
); );
/** /**
@ -223,12 +223,12 @@ AddAndSignalNewRedfishService (
**/ **/
EFI_STATUS EFI_STATUS
RedfishGetHostInterfaceProtocolData ( RedfishGetHostInterfaceProtocolData (
IN EFI_SMBIOS_PROTOCOL *Smbios, IN EFI_SMBIOS_PROTOCOL *Smbios,
OUT REDFISH_INTERFACE_DATA **DeviceDescriptor, OUT REDFISH_INTERFACE_DATA **DeviceDescriptor,
OUT REDFISH_OVER_IP_PROTOCOL_DATA **ProtocolData OUT REDFISH_OVER_IP_PROTOCOL_DATA **ProtocolData
); );
extern EFI_GUID gRedfishDiscoverTcp4Instance; extern EFI_GUID gRedfishDiscoverTcp4Instance;
extern EFI_GUID gRedfishDiscoverTcp6Instance; extern EFI_GUID gRedfishDiscoverTcp6Instance;
extern EFI_GUID gRedfishDiscoverRestEXInstance; extern EFI_GUID gRedfishDiscoverRestEXInstance;
#endif #endif

View File

@ -28,41 +28,41 @@ SMBIOS_TABLE_TYPE42 *mType42Record;
**/ **/
EFI_STATUS EFI_STATUS
RedfishGetHostInterfaceProtocolData ( RedfishGetHostInterfaceProtocolData (
IN EFI_SMBIOS_PROTOCOL *Smbios, IN EFI_SMBIOS_PROTOCOL *Smbios,
OUT REDFISH_INTERFACE_DATA **DeviceDescriptor, OUT REDFISH_INTERFACE_DATA **DeviceDescriptor,
OUT REDFISH_OVER_IP_PROTOCOL_DATA **ProtocolData OUT REDFISH_OVER_IP_PROTOCOL_DATA **ProtocolData
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_SMBIOS_HANDLE SmbiosHandle; EFI_SMBIOS_HANDLE SmbiosHandle;
EFI_SMBIOS_TABLE_HEADER *Record; EFI_SMBIOS_TABLE_HEADER *Record;
UINT16 Offset; UINT16 Offset;
UINT8 *RecordTmp; UINT8 *RecordTmp;
UINT8 ProtocolLength; UINT8 ProtocolLength;
UINT8 SpecificDataLen; UINT8 SpecificDataLen;
if ((Smbios == NULL) || (ProtocolData == NULL)) { if ((Smbios == NULL) || (ProtocolData == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED; SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL); Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);
while (!EFI_ERROR (Status) && SmbiosHandle != SMBIOS_HANDLE_PI_RESERVED) { while (!EFI_ERROR (Status) && SmbiosHandle != SMBIOS_HANDLE_PI_RESERVED) {
if (Record->Type == SMBIOS_TYPE_MANAGEMENT_CONTROLLER_HOST_INTERFACE) { if (Record->Type == SMBIOS_TYPE_MANAGEMENT_CONTROLLER_HOST_INTERFACE) {
// //
// Check Interface Type, should be Network Host Interface = 40h // Check Interface Type, should be Network Host Interface = 40h
// //
mType42Record = (SMBIOS_TABLE_TYPE42 *) Record; mType42Record = (SMBIOS_TABLE_TYPE42 *)Record;
if (mType42Record->InterfaceType == MCHostInterfaceTypeNetworkHostInterface) { if (mType42Record->InterfaceType == MCHostInterfaceTypeNetworkHostInterface) {
ASSERT (Record->Length >= 9); ASSERT (Record->Length >= 9);
Offset = 5; Offset = 5;
RecordTmp = (UINT8 *) Record + Offset; RecordTmp = (UINT8 *)Record + Offset;
// //
// Get interface specific data length. // Get interface specific data length.
// //
SpecificDataLen = *RecordTmp; SpecificDataLen = *RecordTmp;
Offset += 1; Offset += 1;
RecordTmp = (UINT8 *) Record + Offset; RecordTmp = (UINT8 *)Record + Offset;
// //
// Check Device Type, only PCI/PCIe Network Interface v2 is supported now. // Check Device Type, only PCI/PCIe Network Interface v2 is supported now.
@ -70,24 +70,24 @@ RedfishGetHostInterfaceProtocolData (
if (*RecordTmp == REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2) { if (*RecordTmp == REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2) {
ASSERT (SpecificDataLen == sizeof (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1); ASSERT (SpecificDataLen == sizeof (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1);
*DeviceDescriptor = (REDFISH_INTERFACE_DATA *)RecordTmp; *DeviceDescriptor = (REDFISH_INTERFACE_DATA *)RecordTmp;
Offset = Offset + SpecificDataLen; Offset = Offset + SpecificDataLen;
RecordTmp = (UINT8 *) Record + Offset; RecordTmp = (UINT8 *)Record + Offset;
// //
// Check Protocol count. if > 1, only use the first protocol. // Check Protocol count. if > 1, only use the first protocol.
// //
ASSERT (*RecordTmp == 1); ASSERT (*RecordTmp == 1);
Offset += 1; Offset += 1;
RecordTmp = (UINT8 *) Record + Offset; RecordTmp = (UINT8 *)Record + Offset;
// //
// Check protocol identifier. // Check protocol identifier.
// //
if (*RecordTmp == MCHostInterfaceProtocolTypeRedfishOverIP) { if (*RecordTmp == MCHostInterfaceProtocolTypeRedfishOverIP) {
Offset += 1; Offset += 1;
RecordTmp = (UINT8 *) Record + Offset; RecordTmp = (UINT8 *)Record + Offset;
ProtocolLength = *RecordTmp; ProtocolLength = *RecordTmp;
Offset += 1; Offset += 1;
RecordTmp = (UINT8 *) Record + Offset; RecordTmp = (UINT8 *)Record + Offset;
// //
// This SMBIOS record is invalid, if the length of protocol specific data for // This SMBIOS record is invalid, if the length of protocol specific data for
@ -104,12 +104,14 @@ RedfishGetHostInterfaceProtocolData (
if (Offset > mType42Record->Hdr.Length) { if (Offset > mType42Record->Hdr.Length) {
return EFI_SECURITY_VIOLATION; return EFI_SECURITY_VIOLATION;
} }
*ProtocolData = (REDFISH_OVER_IP_PROTOCOL_DATA *)RecordTmp; *ProtocolData = (REDFISH_OVER_IP_PROTOCOL_DATA *)RecordTmp;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
} }
} }
} }
Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL); Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);
} }

View File

@ -33,20 +33,20 @@ RedfishCreateSmbiosTable42 (
VOID VOID
) )
{ {
REDFISH_INTERFACE_DATA *DeviceDescriptor; REDFISH_INTERFACE_DATA *DeviceDescriptor;
UINT8 DeviceDataLength; UINT8 DeviceDataLength;
UINT8 DeviceType; UINT8 DeviceType;
EFI_STATUS Status; EFI_STATUS Status;
MC_HOST_INTERFACE_PROTOCOL_RECORD *ProtocolRecord; MC_HOST_INTERFACE_PROTOCOL_RECORD *ProtocolRecord;
VOID *ProtocolRecords; VOID *ProtocolRecords;
VOID *NewProtocolRecords; VOID *NewProtocolRecords;
UINT8 ProtocolCount; UINT8 ProtocolCount;
UINT8 CurrentProtocolsDataLength; UINT8 CurrentProtocolsDataLength;
UINT8 NewProtocolsDataLength; UINT8 NewProtocolsDataLength;
UINT8 ProtocolDataSize; UINT8 ProtocolDataSize;
SMBIOS_TABLE_TYPE42 *Type42Record; SMBIOS_TABLE_TYPE42 *Type42Record;
EFI_SMBIOS_PROTOCOL *Smbios; EFI_SMBIOS_PROTOCOL *Smbios;
EFI_SMBIOS_HANDLE MemArrayMappedAddrSmbiosHandle; EFI_SMBIOS_HANDLE MemArrayMappedAddrSmbiosHandle;
// //
// Get platform Redfish host interface device type descriptor data. // Get platform Redfish host interface device type descriptor data.
@ -57,46 +57,55 @@ RedfishCreateSmbiosTable42 (
DEBUG ((DEBUG_ERROR, "%a: No Redfish host interface descriptor is provided on this platform.", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: No Redfish host interface descriptor is provided on this platform.", __FUNCTION__));
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
DEBUG((DEBUG_ERROR, "%a: Fail to get device descriptor, %r.", __FUNCTION__, Status));
DEBUG ((DEBUG_ERROR, "%a: Fail to get device descriptor, %r.", __FUNCTION__, Status));
return Status; return Status;
} }
if (DeviceType != REDFISH_HOST_INTERFACE_DEVICE_TYPE_USB_V2 &&
DeviceType != REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2 if ((DeviceType != REDFISH_HOST_INTERFACE_DEVICE_TYPE_USB_V2) &&
) { (DeviceType != REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2)
)
{
DEBUG ((DEBUG_ERROR, "%a: Only support either protocol type 04h or 05h as Redfish host interface.", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: Only support either protocol type 04h or 05h as Redfish host interface.", __FUNCTION__));
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
if (DeviceType == REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2) { if (DeviceType == REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2) {
DeviceDataLength = DeviceDescriptor->DeviceDescriptor.PciPcieDeviceV2.Length; DeviceDataLength = DeviceDescriptor->DeviceDescriptor.PciPcieDeviceV2.Length;
} else { } else {
DeviceDataLength = DeviceDescriptor->DeviceDescriptor.UsbDeviceV2.Length; DeviceDataLength = DeviceDescriptor->DeviceDescriptor.UsbDeviceV2.Length;
} }
// //
// Loop to get platform Redfish host interface protocol type data. // Loop to get platform Redfish host interface protocol type data.
// //
ProtocolRecord = NULL; ProtocolRecord = NULL;
ProtocolRecords = NULL; ProtocolRecords = NULL;
NewProtocolRecords = NULL; NewProtocolRecords = NULL;
Type42Record = NULL; Type42Record = NULL;
ProtocolCount = 0; ProtocolCount = 0;
CurrentProtocolsDataLength = 0; CurrentProtocolsDataLength = 0;
NewProtocolsDataLength = 0; NewProtocolsDataLength = 0;
while (TRUE) { while (TRUE) {
Status = RedfishPlatformHostInterfaceProtocolData (&ProtocolRecord, ProtocolCount); Status = RedfishPlatformHostInterfaceProtocolData (&ProtocolRecord, ProtocolCount);
if (Status == EFI_NOT_FOUND) { if (Status == EFI_NOT_FOUND) {
break; break;
} }
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: Fail to get Redfish host interafce protocol type data.", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: Fail to get Redfish host interafce protocol type data.", __FUNCTION__));
if (ProtocolRecords != NULL) { if (ProtocolRecords != NULL) {
FreePool (ProtocolRecords); FreePool (ProtocolRecords);
} }
if (ProtocolRecord != NULL) { if (ProtocolRecord != NULL) {
FreePool (ProtocolRecord); FreePool (ProtocolRecord);
} }
return Status; return Status;
} }
ProtocolDataSize = sizeof (MC_HOST_INTERFACE_PROTOCOL_RECORD) - sizeof(ProtocolRecord->ProtocolTypeData) + ProtocolRecord->ProtocolTypeDataLen;
ProtocolDataSize = sizeof (MC_HOST_INTERFACE_PROTOCOL_RECORD) - sizeof (ProtocolRecord->ProtocolTypeData) + ProtocolRecord->ProtocolTypeDataLen;
NewProtocolsDataLength += ProtocolDataSize; NewProtocolsDataLength += ProtocolDataSize;
if (ProtocolRecords == NULL) { if (ProtocolRecords == NULL) {
ProtocolRecords = AllocateZeroPool (NewProtocolsDataLength); ProtocolRecords = AllocateZeroPool (NewProtocolsDataLength);
@ -104,29 +113,34 @@ RedfishCreateSmbiosTable42 (
FreePool (ProtocolRecord); FreePool (ProtocolRecord);
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
CopyMem ((VOID *)ProtocolRecords, (VOID *)ProtocolRecord, ProtocolDataSize); CopyMem ((VOID *)ProtocolRecords, (VOID *)ProtocolRecord, ProtocolDataSize);
NewProtocolRecords = ProtocolRecords; NewProtocolRecords = ProtocolRecords;
} else { } else {
NewProtocolRecords = ReallocatePool(CurrentProtocolsDataLength, NewProtocolsDataLength, (VOID *)ProtocolRecords); NewProtocolRecords = ReallocatePool (CurrentProtocolsDataLength, NewProtocolsDataLength, (VOID *)ProtocolRecords);
if (NewProtocolRecords == NULL) { if (NewProtocolRecords == NULL) {
DEBUG ((DEBUG_ERROR, "%a: Fail to allocate memory for Redfish host interface protocol data.")); DEBUG ((DEBUG_ERROR, "%a: Fail to allocate memory for Redfish host interface protocol data."));
FreePool (ProtocolRecords); FreePool (ProtocolRecords);
FreePool (ProtocolRecord); FreePool (ProtocolRecord);
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
CopyMem ( CopyMem (
(VOID *)((UINT8 *)NewProtocolRecords + CurrentProtocolsDataLength), (VOID *)((UINT8 *)NewProtocolRecords + CurrentProtocolsDataLength),
(VOID *)ProtocolRecord, (VOID *)ProtocolRecord,
ProtocolDataSize ProtocolDataSize
); );
} }
FreePool (ProtocolRecord); FreePool (ProtocolRecord);
CurrentProtocolsDataLength = NewProtocolsDataLength; CurrentProtocolsDataLength = NewProtocolsDataLength;
ProtocolCount ++; ProtocolCount++;
}; }
if (ProtocolCount == 0) { if (ProtocolCount == 0) {
goto ON_EXIT; goto ON_EXIT;
} }
// //
// Construct SMBIOS Type 42h for Redfish host inteface. // Construct SMBIOS Type 42h for Redfish host inteface.
// //
@ -140,13 +154,13 @@ RedfishCreateSmbiosTable42 (
// 06h+n number of protocols defined for the host interface (typically 1) // 06h+n number of protocols defined for the host interface (typically 1)
// 07h+n Include a Protocol Record for each protocol supported. // 07h+n Include a Protocol Record for each protocol supported.
// //
Type42Record = (SMBIOS_TABLE_TYPE42 *) AllocateZeroPool ( Type42Record = (SMBIOS_TABLE_TYPE42 *)AllocateZeroPool (
sizeof (SMBIOS_TABLE_TYPE42) - 4 sizeof (SMBIOS_TABLE_TYPE42) - 4
+ DeviceDataLength + DeviceDataLength
+ 1 /// For Protocol Record Count + 1 /// For Protocol Record Count
+ CurrentProtocolsDataLength + CurrentProtocolsDataLength
+ 2 /// Double NULL terminator/ + 2 /// Double NULL terminator/
); );
if (Type42Record == NULL) { if (Type42Record == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
@ -154,10 +168,10 @@ RedfishCreateSmbiosTable42 (
Type42Record->Hdr.Type = EFI_SMBIOS_TYPE_MANAGEMENT_CONTROLLER_HOST_INTERFACE; Type42Record->Hdr.Type = EFI_SMBIOS_TYPE_MANAGEMENT_CONTROLLER_HOST_INTERFACE;
Type42Record->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE42) - 4 Type42Record->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE42) - 4
+ DeviceDataLength + DeviceDataLength
+ 1 + 1
+ CurrentProtocolsDataLength; + CurrentProtocolsDataLength;
Type42Record->Hdr.Handle = 0; Type42Record->Hdr.Handle = 0;
Type42Record->InterfaceType = MCHostInterfaceTypeNetworkHostInterface; // Network Host Interface Type42Record->InterfaceType = MCHostInterfaceTypeNetworkHostInterface; // Network Host Interface
// //
@ -189,34 +203,38 @@ RedfishCreateSmbiosTable42 (
// //
// 5. Add Redfish interface data record to SMBIOS table 42 // 5. Add Redfish interface data record to SMBIOS table 42
// //
Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID**)&Smbios); Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&Smbios);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ON_EXIT; goto ON_EXIT;
} }
MemArrayMappedAddrSmbiosHandle = SMBIOS_HANDLE_PI_RESERVED; MemArrayMappedAddrSmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
Status = Smbios->Add ( Status = Smbios->Add (
Smbios, Smbios,
NULL, NULL,
&MemArrayMappedAddrSmbiosHandle, &MemArrayMappedAddrSmbiosHandle,
(EFI_SMBIOS_TABLE_HEADER*) Type42Record (EFI_SMBIOS_TABLE_HEADER *)Type42Record
); );
DEBUG ((DEBUG_INFO, "RedfishPlatformDxe: Smbios->Add() - %r\n", Status)); DEBUG ((DEBUG_INFO, "RedfishPlatformDxe: Smbios->Add() - %r\n", Status));
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ON_EXIT; goto ON_EXIT;
} }
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
ON_EXIT: ON_EXIT:
if (DeviceDescriptor != NULL) { if (DeviceDescriptor != NULL) {
FreePool (DeviceDescriptor); FreePool (DeviceDescriptor);
} }
if (NewProtocolRecords != NULL) { if (NewProtocolRecords != NULL) {
FreePool (NewProtocolRecords); FreePool (NewProtocolRecords);
} }
if (Type42Record != NULL) { if (Type42Record != NULL) {
FreePool (Type42Record); FreePool (Type42Record);
} }
return Status; return Status;
} }
@ -232,8 +250,8 @@ ON_EXIT:
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishHostInterfaceDxeEntryPoint ( RedfishHostInterfaceDxeEntryPoint (
IN EFI_HANDLE ImageHandle, IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable IN EFI_SYSTEM_TABLE *SystemTable
) )
{ {
// //

View File

@ -18,6 +18,7 @@
// //
// EFI Component Name Functions // EFI Component Name Functions
// //
/** /**
Retrieves a Unicode string that is the user-readable name of the EFI Driver. Retrieves a Unicode string that is the user-readable name of the EFI Driver.
@ -92,10 +93,10 @@ EFI_STATUS
EFIAPI EFIAPI
RedfishRestExComponentNameGetControllerName ( RedfishRestExComponentNameGetControllerName (
IN EFI_COMPONENT_NAME_PROTOCOL *This, IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL, IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language, IN CHAR8 *Language,
OUT CHAR16 **ControllerName OUT CHAR16 **ControllerName
); );
/// ///
@ -113,8 +114,8 @@ EFI_COMPONENT_NAME_PROTOCOL gRedfishRestExComponentName = {
/// ///
GLOBAL_REMOVE_IF_UNREFERENCED GLOBAL_REMOVE_IF_UNREFERENCED
EFI_COMPONENT_NAME2_PROTOCOL gRedfishRestExComponentName2 = { EFI_COMPONENT_NAME2_PROTOCOL gRedfishRestExComponentName2 = {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) RedfishRestExComponentNameGetDriverName, (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)RedfishRestExComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) RedfishRestExComponentNameGetControllerName, (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)RedfishRestExComponentNameGetControllerName,
"en" "en"
}; };
@ -122,12 +123,12 @@ EFI_COMPONENT_NAME2_PROTOCOL gRedfishRestExComponentName2 = {
/// Table of driver names /// Table of driver names
/// ///
GLOBAL_REMOVE_IF_UNREFERENCED GLOBAL_REMOVE_IF_UNREFERENCED
EFI_UNICODE_STRING_TABLE mRedfishRestExDriverNameTable[] = { EFI_UNICODE_STRING_TABLE mRedfishRestExDriverNameTable[] = {
{ "eng;en", (CHAR16 *)L"Redfish RestEx Network Service Driver" }, { "eng;en", (CHAR16 *)L"Redfish RestEx Network Service Driver" },
{ NULL, NULL } { NULL, NULL }
}; };
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gRedfishRestExControllerNameTable = NULL; GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gRedfishRestExControllerNameTable = NULL;
/** /**
Retrieves a Unicode string that is the user-readable name of the EFI Driver. Retrieves a Unicode string that is the user-readable name of the EFI Driver.
@ -212,10 +213,10 @@ EFI_STATUS
EFIAPI EFIAPI
RedfishRestExComponentNameGetControllerName ( RedfishRestExComponentNameGetControllerName (
IN EFI_COMPONENT_NAME_PROTOCOL *This, IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL, IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language, IN CHAR8 *Language,
OUT CHAR16 **ControllerName OUT CHAR16 **ControllerName
) )
{ {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;

View File

@ -11,7 +11,7 @@
#include <Uefi.h> #include <Uefi.h>
#include "RedfishRestExDriver.h" #include "RedfishRestExDriver.h"
EFI_DRIVER_BINDING_PROTOCOL gRedfishRestExDriverBinding = { EFI_DRIVER_BINDING_PROTOCOL gRedfishRestExDriverBinding = {
RedfishRestExDriverBindingSupported, RedfishRestExDriverBindingSupported,
RedfishRestExDriverBindingStart, RedfishRestExDriverBindingStart,
RedfishRestExDriverBindingStop, RedfishRestExDriverBindingStop,
@ -20,7 +20,7 @@ EFI_DRIVER_BINDING_PROTOCOL gRedfishRestExDriverBinding = {
NULL NULL
}; };
EFI_SERVICE_BINDING_PROTOCOL mRedfishRestExServiceBinding = { EFI_SERVICE_BINDING_PROTOCOL mRedfishRestExServiceBinding = {
RedfishRestExServiceBindingCreateChild, RedfishRestExServiceBindingCreateChild,
RedfishRestExServiceBindingDestroyChild RedfishRestExServiceBindingDestroyChild
}; };
@ -38,8 +38,8 @@ EFI_SERVICE_BINDING_PROTOCOL mRedfishRestExServiceBinding = {
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RestExDestroyChildEntryInHandleBuffer ( RestExDestroyChildEntryInHandleBuffer (
IN LIST_ENTRY *Entry, IN LIST_ENTRY *Entry,
IN VOID *Context IN VOID *Context
) )
{ {
RESTEX_INSTANCE *Instance; RESTEX_INSTANCE *Instance;
@ -47,14 +47,14 @@ RestExDestroyChildEntryInHandleBuffer (
UINTN NumberOfChildren; UINTN NumberOfChildren;
EFI_HANDLE *ChildHandleBuffer; EFI_HANDLE *ChildHandleBuffer;
if (Entry == NULL || Context == NULL) { if ((Entry == NULL) || (Context == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
Instance = NET_LIST_USER_STRUCT_S (Entry, RESTEX_INSTANCE, Link, RESTEX_INSTANCE_SIGNATURE); Instance = NET_LIST_USER_STRUCT_S (Entry, RESTEX_INSTANCE, Link, RESTEX_INSTANCE_SIGNATURE);
ServiceBinding = ((RESTEX_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding; ServiceBinding = ((RESTEX_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ServiceBinding;
NumberOfChildren = ((RESTEX_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren; NumberOfChildren = ((RESTEX_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->NumberOfChildren;
ChildHandleBuffer = ((RESTEX_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer; ChildHandleBuffer = ((RESTEX_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ChildHandleBuffer;
if (!NetIsInHandleBuffer (Instance->ChildHandle, NumberOfChildren, ChildHandleBuffer)) { if (!NetIsInHandleBuffer (Instance->ChildHandle, NumberOfChildren, ChildHandleBuffer)) {
return EFI_SUCCESS; return EFI_SUCCESS;
@ -71,7 +71,7 @@ RestExDestroyChildEntryInHandleBuffer (
**/ **/
VOID VOID
RestExDestroyInstance ( RestExDestroyInstance (
IN RESTEX_INSTANCE *Instance IN RESTEX_INSTANCE *Instance
) )
{ {
HttpIoDestroyIo (&(Instance->HttpIo)); HttpIoDestroyIo (&(Instance->HttpIo));
@ -91,12 +91,12 @@ RestExDestroyInstance (
**/ **/
EFI_STATUS EFI_STATUS
RestExCreateInstance ( RestExCreateInstance (
IN RESTEX_SERVICE *Service, IN RESTEX_SERVICE *Service,
OUT RESTEX_INSTANCE **Instance OUT RESTEX_INSTANCE **Instance
) )
{ {
RESTEX_INSTANCE *RestExIns; RESTEX_INSTANCE *RestExIns;
EFI_STATUS Status; EFI_STATUS Status;
*Instance = NULL; *Instance = NULL;
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
@ -143,7 +143,7 @@ RestExCreateInstance (
**/ **/
VOID VOID
RestExDestroyService ( RestExDestroyService (
IN RESTEX_SERVICE *RestExSb IN RESTEX_SERVICE *RestExSb
) )
{ {
if (RestExSb->HttpChildHandle != NULL) { if (RestExSb->HttpChildHandle != NULL) {
@ -184,7 +184,7 @@ RestExDestroyService (
**/ **/
EFI_REST_EX_SERVICE_ACCESS_MODE EFI_REST_EX_SERVICE_ACCESS_MODE
RestExServiceAccessMode ( RestExServiceAccessMode (
IN EFI_HANDLE Controller IN EFI_HANDLE Controller
) )
{ {
// //
@ -213,18 +213,18 @@ RestExServiceAccessMode (
**/ **/
EFI_STATUS EFI_STATUS
RestExCreateService ( RestExCreateService (
IN EFI_HANDLE Controller, IN EFI_HANDLE Controller,
IN EFI_HANDLE Image, IN EFI_HANDLE Image,
OUT RESTEX_SERVICE **Service OUT RESTEX_SERVICE **Service
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
RESTEX_SERVICE *RestExSb; RESTEX_SERVICE *RestExSb;
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
RestExSb = NULL; RestExSb = NULL;
*Service = NULL; *Service = NULL;
RestExSb = AllocateZeroPool (sizeof (RESTEX_SERVICE)); RestExSb = AllocateZeroPool (sizeof (RESTEX_SERVICE));
if (RestExSb == NULL) { if (RestExSb == NULL) {
@ -241,13 +241,13 @@ RestExCreateService (
RestExSb->ControllerHandle = Controller; RestExSb->ControllerHandle = Controller;
RestExSb->ImageHandle = Image; RestExSb->ImageHandle = Image;
RestExSb->RestExServiceInfo.EfiRestExServiceInfoV10.EfiRestExServiceInfoHeader.Length = sizeof (EFI_REST_EX_SERVICE_INFO); RestExSb->RestExServiceInfo.EfiRestExServiceInfoV10.EfiRestExServiceInfoHeader.Length = sizeof (EFI_REST_EX_SERVICE_INFO);
RestExSb->RestExServiceInfo.EfiRestExServiceInfoV10.EfiRestExServiceInfoHeader.RestServiceInfoVer.Major = 1; RestExSb->RestExServiceInfo.EfiRestExServiceInfoV10.EfiRestExServiceInfoHeader.RestServiceInfoVer.Major = 1;
RestExSb->RestExServiceInfo.EfiRestExServiceInfoV10.EfiRestExServiceInfoHeader.RestServiceInfoVer.Minor = 0; RestExSb->RestExServiceInfo.EfiRestExServiceInfoV10.EfiRestExServiceInfoHeader.RestServiceInfoVer.Minor = 0;
RestExSb->RestExServiceInfo.EfiRestExServiceInfoV10.RestServiceType = EfiRestExServiceRedfish; RestExSb->RestExServiceInfo.EfiRestExServiceInfoV10.RestServiceType = EfiRestExServiceRedfish;
RestExSb->RestExServiceInfo.EfiRestExServiceInfoV10.RestServiceAccessMode = RestExServiceAccessMode (Controller); RestExSb->RestExServiceInfo.EfiRestExServiceInfoV10.RestServiceAccessMode = RestExServiceAccessMode (Controller);
RestExSb->RestExServiceInfo.EfiRestExServiceInfoV10.RestExConfigType = EfiRestExConfigHttp; RestExSb->RestExServiceInfo.EfiRestExServiceInfoV10.RestExConfigType = EfiRestExConfigHttp;
RestExSb->RestExServiceInfo.EfiRestExServiceInfoV10.RestExConfigDataLength = sizeof (EFI_REST_EX_HTTP_CONFIG_DATA); RestExSb->RestExServiceInfo.EfiRestExServiceInfoV10.RestExConfigDataLength = sizeof (EFI_REST_EX_HTTP_CONFIG_DATA);
Status = gBS->InstallProtocolInterface ( Status = gBS->InstallProtocolInterface (
&Controller, &Controller,
@ -354,7 +354,6 @@ RedfishRestExDriverBindingSupported (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
) )
{ {
// //
// Test for the HttpServiceBinding Protocol. // Test for the HttpServiceBinding Protocol.
// //
@ -366,7 +365,6 @@ RedfishRestExDriverBindingSupported (
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_TEST_PROTOCOL EFI_OPEN_PROTOCOL_TEST_PROTOCOL
); );
} }
/** /**
@ -412,15 +410,15 @@ RedfishRestExDriverBindingStart (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
) )
{ {
RESTEX_SERVICE *RestExSb; RESTEX_SERVICE *RestExSb;
EFI_STATUS Status; EFI_STATUS Status;
UINT32 *Id; UINT32 *Id;
VOID *Interface; VOID *Interface;
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ControllerHandle, ControllerHandle,
&gEfiCallerIdGuid, &gEfiCallerIdGuid,
(VOID **) &Id, (VOID **)&Id,
This->DriverBindingHandle, This->DriverBindingHandle,
ControllerHandle, ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -518,12 +516,12 @@ RedfishRestExDriverBindingStop (
IN EFI_HANDLE *ChildHandleBuffer OPTIONAL IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
) )
{ {
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
RESTEX_SERVICE *RestExSb; RESTEX_SERVICE *RestExSb;
EFI_HANDLE NicHandle; EFI_HANDLE NicHandle;
EFI_STATUS Status; EFI_STATUS Status;
LIST_ENTRY *List; LIST_ENTRY *List;
RESTEX_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context; RESTEX_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context;
// //
// RestEx driver opens HTTP child, So, Controller is a HTTP // RestEx driver opens HTTP child, So, Controller is a HTTP
@ -538,7 +536,7 @@ RedfishRestExDriverBindingStop (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
NicHandle, NicHandle,
&gEfiRestExServiceBindingProtocolGuid, &gEfiRestExServiceBindingProtocolGuid,
(VOID **) &ServiceBinding, (VOID **)&ServiceBinding,
This->DriverBindingHandle, This->DriverBindingHandle,
NicHandle, NicHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -553,19 +551,19 @@ RedfishRestExDriverBindingStop (
// //
// Destroy the RestEx child instance in ChildHandleBuffer. // Destroy the RestEx child instance in ChildHandleBuffer.
// //
List = &RestExSb->RestExChildrenList; List = &RestExSb->RestExChildrenList;
Context.ServiceBinding = ServiceBinding; Context.ServiceBinding = ServiceBinding;
Context.NumberOfChildren = NumberOfChildren; Context.NumberOfChildren = NumberOfChildren;
Context.ChildHandleBuffer = ChildHandleBuffer; Context.ChildHandleBuffer = ChildHandleBuffer;
Status = NetDestroyLinkList ( Status = NetDestroyLinkList (
List, List,
RestExDestroyChildEntryInHandleBuffer, RestExDestroyChildEntryInHandleBuffer,
&Context, &Context,
NULL NULL
); );
} }
if (NumberOfChildren == 0 && IsListEmpty (&RestExSb->RestExChildrenList)) { if ((NumberOfChildren == 0) && IsListEmpty (&RestExSb->RestExChildrenList)) {
gBS->UninstallProtocolInterface ( gBS->UninstallProtocolInterface (
NicHandle, NicHandle,
&gEfiRestExServiceBindingProtocolGuid, &gEfiRestExServiceBindingProtocolGuid,
@ -611,11 +609,11 @@ RedfishRestExServiceBindingCreateChild (
IN EFI_HANDLE *ChildHandle IN EFI_HANDLE *ChildHandle
) )
{ {
RESTEX_SERVICE *RestExSb; RESTEX_SERVICE *RestExSb;
RESTEX_INSTANCE *Instance; RESTEX_INSTANCE *Instance;
EFI_STATUS Status; EFI_STATUS Status;
EFI_TPL OldTpl; EFI_TPL OldTpl;
VOID *Http; VOID *Http;
if ((This == NULL) || (ChildHandle == NULL)) { if ((This == NULL) || (ChildHandle == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
@ -627,6 +625,7 @@ RedfishRestExServiceBindingCreateChild (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
ASSERT (Instance != NULL); ASSERT (Instance != NULL);
// //
@ -650,7 +649,7 @@ RedfishRestExServiceBindingCreateChild (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
RestExSb->HttpChildHandle, RestExSb->HttpChildHandle,
&gEfiHttpProtocolGuid, &gEfiHttpProtocolGuid,
(VOID **) &Http, (VOID **)&Http,
gRedfishRestExDriverBinding.DriverBindingHandle, gRedfishRestExDriverBinding.DriverBindingHandle,
Instance->ChildHandle, Instance->ChildHandle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@ -672,7 +671,7 @@ RedfishRestExServiceBindingCreateChild (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
Instance->HttpIo.Handle, Instance->HttpIo.Handle,
&gEfiHttpProtocolGuid, &gEfiHttpProtocolGuid,
(VOID **) &Http, (VOID **)&Http,
gRedfishRestExDriverBinding.DriverBindingHandle, gRedfishRestExDriverBinding.DriverBindingHandle,
Instance->ChildHandle, Instance->ChildHandle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@ -688,12 +687,12 @@ RedfishRestExServiceBindingCreateChild (
ChildHandle ChildHandle
); );
gBS->UninstallMultipleProtocolInterfaces ( gBS->UninstallMultipleProtocolInterfaces (
Instance->ChildHandle, Instance->ChildHandle,
&gEfiRestExProtocolGuid, &gEfiRestExProtocolGuid,
&Instance->RestEx, &Instance->RestEx,
NULL NULL
); );
goto ON_ERROR; goto ON_ERROR;
} }
@ -741,12 +740,12 @@ RedfishRestExServiceBindingDestroyChild (
IN EFI_HANDLE ChildHandle IN EFI_HANDLE ChildHandle
) )
{ {
RESTEX_SERVICE *RestExSb; RESTEX_SERVICE *RestExSb;
RESTEX_INSTANCE *Instance; RESTEX_INSTANCE *Instance;
EFI_REST_EX_PROTOCOL *RestEx; EFI_REST_EX_PROTOCOL *RestEx;
EFI_STATUS Status; EFI_STATUS Status;
EFI_TPL OldTpl; EFI_TPL OldTpl;
if ((This == NULL) || (ChildHandle == NULL)) { if ((This == NULL) || (ChildHandle == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
@ -758,7 +757,7 @@ RedfishRestExServiceBindingDestroyChild (
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
ChildHandle, ChildHandle,
&gEfiRestExProtocolGuid, &gEfiRestExProtocolGuid,
(VOID **) &RestEx, (VOID **)&RestEx,
NULL, NULL,
NULL, NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -768,8 +767,8 @@ RedfishRestExServiceBindingDestroyChild (
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
Instance = RESTEX_INSTANCE_FROM_THIS (RestEx); Instance = RESTEX_INSTANCE_FROM_THIS (RestEx);
RestExSb = RESTEX_SERVICE_FROM_THIS (This); RestExSb = RESTEX_SERVICE_FROM_THIS (This);
if (Instance->Service != RestExSb) { if (Instance->Service != RestExSb) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
@ -800,7 +799,6 @@ RedfishRestExServiceBindingDestroyChild (
ChildHandle ChildHandle
); );
gBS->RestoreTPL (OldTpl); gBS->RestoreTPL (OldTpl);
// //
@ -828,4 +826,3 @@ RedfishRestExServiceBindingDestroyChild (
RestExDestroyInstance (Instance); RestExDestroyInstance (Instance);
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -45,7 +45,7 @@ extern EFI_REST_EX_PROTOCOL mRedfishRestExProtocol;
/// ///
/// RestEx service block /// RestEx service block
/// ///
typedef struct _RESTEX_SERVICE RESTEX_SERVICE; typedef struct _RESTEX_SERVICE RESTEX_SERVICE;
/// ///
/// RestEx instance block /// RestEx instance block
@ -57,8 +57,8 @@ typedef struct _RESTEX_INSTANCE RESTEX_INSTANCE;
/// ///
#define REDFISH_RESTEX_DRIVER_VERSION 0x0100 #define REDFISH_RESTEX_DRIVER_VERSION 0x0100
#define RESTEX_SERVICE_SIGNATURE SIGNATURE_32 ('R', 'E', 'S', 'S') #define RESTEX_SERVICE_SIGNATURE SIGNATURE_32 ('R', 'E', 'S', 'S')
#define RESTEX_INSTANCE_SIGNATURE SIGNATURE_32 ('R', 'E', 'I', 'S') #define RESTEX_INSTANCE_SIGNATURE SIGNATURE_32 ('R', 'E', 'I', 'S')
#define RESTEX_SERVICE_FROM_THIS(a) \ #define RESTEX_SERVICE_FROM_THIS(a) \
CR (a, RESTEX_SERVICE, ServiceBinding, RESTEX_SERVICE_SIGNATURE) CR (a, RESTEX_SERVICE, ServiceBinding, RESTEX_SERVICE_SIGNATURE)
@ -66,59 +66,58 @@ typedef struct _RESTEX_INSTANCE RESTEX_INSTANCE;
#define RESTEX_INSTANCE_FROM_THIS(a) \ #define RESTEX_INSTANCE_FROM_THIS(a) \
CR (a, RESTEX_INSTANCE, RestEx, RESTEX_INSTANCE_SIGNATURE) CR (a, RESTEX_INSTANCE, RestEx, RESTEX_INSTANCE_SIGNATURE)
#define RESTEX_STATE_UNCONFIGED 0
#define RESTEX_STATE_UNCONFIGED 0 #define RESTEX_STATE_CONFIGED 1
#define RESTEX_STATE_CONFIGED 1
struct _RESTEX_SERVICE { struct _RESTEX_SERVICE {
UINT32 Signature; UINT32 Signature;
EFI_SERVICE_BINDING_PROTOCOL ServiceBinding; EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
UINT16 RestExChildrenNum; UINT16 RestExChildrenNum;
LIST_ENTRY RestExChildrenList; LIST_ENTRY RestExChildrenList;
EFI_HANDLE ControllerHandle; EFI_HANDLE ControllerHandle;
EFI_HANDLE ImageHandle; EFI_HANDLE ImageHandle;
// //
// Use to establish the parent-child relationship. // Use to establish the parent-child relationship.
// //
EFI_HANDLE HttpChildHandle; EFI_HANDLE HttpChildHandle;
UINT32 Id; UINT32 Id;
EFI_REST_EX_SERVICE_INFO RestExServiceInfo; EFI_REST_EX_SERVICE_INFO RestExServiceInfo;
}; };
#define RESTEX_INSTANCE_FLAGS_TLS_RETRY 0x00000001 #define RESTEX_INSTANCE_FLAGS_TLS_RETRY 0x00000001
#define RESTEX_INSTANCE_FLAGS_TCP_ERROR_RETRY 0x00000002 #define RESTEX_INSTANCE_FLAGS_TCP_ERROR_RETRY 0x00000002
struct _RESTEX_INSTANCE { struct _RESTEX_INSTANCE {
UINT32 Signature; UINT32 Signature;
LIST_ENTRY Link; LIST_ENTRY Link;
EFI_REST_EX_PROTOCOL RestEx; EFI_REST_EX_PROTOCOL RestEx;
INTN State; INTN State;
BOOLEAN InDestroy; BOOLEAN InDestroy;
RESTEX_SERVICE *Service; RESTEX_SERVICE *Service;
EFI_HANDLE ChildHandle; EFI_HANDLE ChildHandle;
EFI_REST_EX_CONFIG_DATA ConfigData; EFI_REST_EX_CONFIG_DATA ConfigData;
// //
// HTTP_IO to access the HTTP service // HTTP_IO to access the HTTP service
// //
HTTP_IO HttpIo; HTTP_IO HttpIo;
UINT32 Flags; UINT32 Flags;
}; };
typedef struct { typedef struct {
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
UINTN NumberOfChildren; UINTN NumberOfChildren;
EFI_HANDLE *ChildHandleBuffer; EFI_HANDLE *ChildHandleBuffer;
} RESTEX_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT; } RESTEX_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT;
/** /**
@ -143,9 +142,9 @@ typedef struct {
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishRestExSendReceive ( RedfishRestExSendReceive (
IN EFI_REST_EX_PROTOCOL *This, IN EFI_REST_EX_PROTOCOL *This,
IN EFI_HTTP_MESSAGE *RequestMessage, IN EFI_HTTP_MESSAGE *RequestMessage,
OUT EFI_HTTP_MESSAGE *ResponseMessage OUT EFI_HTTP_MESSAGE *ResponseMessage
); );
/** /**
@ -173,8 +172,8 @@ RedfishRestExSendReceive (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishRestExGetServiceTime ( RedfishRestExGetServiceTime (
IN EFI_REST_EX_PROTOCOL *This, IN EFI_REST_EX_PROTOCOL *This,
OUT EFI_TIME *Time OUT EFI_TIME *Time
); );
/** /**
@ -244,8 +243,8 @@ RedfishRestExGetService (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishRestExGetModeData ( RedfishRestExGetModeData (
IN EFI_REST_EX_PROTOCOL *This, IN EFI_REST_EX_PROTOCOL *This,
OUT EFI_REST_EX_CONFIG_DATA *RestExConfigData OUT EFI_REST_EX_CONFIG_DATA *RestExConfigData
); );
/** /**
@ -282,8 +281,8 @@ RedfishRestExGetModeData (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishRestExConfigure ( RedfishRestExConfigure (
IN EFI_REST_EX_PROTOCOL *This, IN EFI_REST_EX_PROTOCOL *This,
IN EFI_REST_EX_CONFIG_DATA RestExConfigData IN EFI_REST_EX_CONFIG_DATA RestExConfigData
); );
/** /**
@ -320,10 +319,10 @@ RedfishRestExConfigure (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishRestExAyncSendReceive ( RedfishRestExAyncSendReceive (
IN EFI_REST_EX_PROTOCOL *This, IN EFI_REST_EX_PROTOCOL *This,
IN EFI_HTTP_MESSAGE *RequestMessage OPTIONAL, IN EFI_HTTP_MESSAGE *RequestMessage OPTIONAL,
IN EFI_REST_EX_TOKEN *RestExToken, IN EFI_REST_EX_TOKEN *RestExToken,
IN UINTN *TimeOutInMilliSeconds OPTIONAL IN UINTN *TimeOutInMilliSeconds OPTIONAL
); );
/** /**
@ -355,10 +354,11 @@ RedfishRestExAyncSendReceive (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishRestExEventService ( RedfishRestExEventService (
IN EFI_REST_EX_PROTOCOL *This, IN EFI_REST_EX_PROTOCOL *This,
IN EFI_HTTP_MESSAGE *RequestMessage OPTIONAL, IN EFI_HTTP_MESSAGE *RequestMessage OPTIONAL,
IN EFI_REST_EX_TOKEN *RestExToken IN EFI_REST_EX_TOKEN *RestExToken
); );
/** /**
Create a new TLS session becuase the previous on is closed. Create a new TLS session becuase the previous on is closed.
status. status.
@ -372,8 +372,7 @@ RedfishRestExEventService (
EFI_STATUS EFI_STATUS
ResetHttpTslSession ( ResetHttpTslSession (
IN RESTEX_INSTANCE *Instance IN RESTEX_INSTANCE *Instance
); );
/** /**
Callback function which provided by user to remove one node in NetDestroyLinkList process. Callback function which provided by user to remove one node in NetDestroyLinkList process.
@ -388,8 +387,8 @@ ResetHttpTslSession (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RestExDestroyChildEntryInHandleBuffer ( RestExDestroyChildEntryInHandleBuffer (
IN LIST_ENTRY *Entry, IN LIST_ENTRY *Entry,
IN VOID *Context IN VOID *Context
); );
/** /**
@ -400,7 +399,7 @@ RestExDestroyChildEntryInHandleBuffer (
**/ **/
VOID VOID
RestExDestroyInstance ( RestExDestroyInstance (
IN RESTEX_INSTANCE *Instance IN RESTEX_INSTANCE *Instance
); );
/** /**
@ -415,11 +414,10 @@ RestExDestroyInstance (
**/ **/
EFI_STATUS EFI_STATUS
RestExCreateInstance ( RestExCreateInstance (
IN RESTEX_SERVICE *Service, IN RESTEX_SERVICE *Service,
OUT RESTEX_INSTANCE **Instance OUT RESTEX_INSTANCE **Instance
); );
/** /**
Release all the resource used the RestEx service binding instance. Release all the resource used the RestEx service binding instance.
@ -428,7 +426,7 @@ RestExCreateInstance (
**/ **/
VOID VOID
RestExDestroyService ( RestExDestroyService (
IN RESTEX_SERVICE *RestExSb IN RESTEX_SERVICE *RestExSb
); );
/** /**
@ -446,9 +444,9 @@ RestExDestroyService (
**/ **/
EFI_STATUS EFI_STATUS
RestExCreateService ( RestExCreateService (
IN EFI_HANDLE Controller, IN EFI_HANDLE Controller,
IN EFI_HANDLE Image, IN EFI_HANDLE Image,
OUT RESTEX_SERVICE **Service OUT RESTEX_SERVICE **Service
); );
/** /**
@ -647,4 +645,5 @@ RedfishRestExServiceBindingDestroyChild (
IN EFI_SERVICE_BINDING_PROTOCOL *This, IN EFI_SERVICE_BINDING_PROTOCOL *This,
IN EFI_HANDLE ChildHandle IN EFI_HANDLE ChildHandle
); );
#endif #endif

View File

@ -23,9 +23,9 @@
EFI_STATUS EFI_STATUS
ResetHttpTslSession ( ResetHttpTslSession (
IN RESTEX_INSTANCE *Instance IN RESTEX_INSTANCE *Instance
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
DEBUG ((DEBUG_INFO, "%a: TCP connection is finished. Could be TSL session closure, reset HTTP instance for the new TLS session.\n", __FUNCTION__)); DEBUG ((DEBUG_INFO, "%a: TCP connection is finished. Could be TSL session closure, reset HTTP instance for the new TLS session.\n", __FUNCTION__));
@ -34,12 +34,15 @@ ResetHttpTslSession (
DEBUG ((DEBUG_ERROR, "%a: Error to reset HTTP instance.\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: Error to reset HTTP instance.\n", __FUNCTION__));
return Status; return Status;
} }
Status = Instance->HttpIo.Http->Configure(Instance->HttpIo.Http, &((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData);
Status = Instance->HttpIo.Http->Configure (Instance->HttpIo.Http, &((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: Error to re-initiate HTTP instance.\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: Error to re-initiate HTTP instance.\n", __FUNCTION__));
} }
return Status; return Status;
} }
/** /**
This function check This function check
@ -55,16 +58,16 @@ ResetHttpTslSession (
**/ **/
EFI_STATUS EFI_STATUS
RedfishCheckHttpReceiveStatus ( RedfishCheckHttpReceiveStatus (
IN RESTEX_INSTANCE *Instance, IN RESTEX_INSTANCE *Instance,
IN EFI_STATUS HttpIoReceiveStatus IN EFI_STATUS HttpIoReceiveStatus
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_STATUS ReturnStatus; EFI_STATUS ReturnStatus;
if (!EFI_ERROR (HttpIoReceiveStatus)){ if (!EFI_ERROR (HttpIoReceiveStatus)) {
ReturnStatus = EFI_SUCCESS; ReturnStatus = EFI_SUCCESS;
} else if (EFI_ERROR (HttpIoReceiveStatus) && HttpIoReceiveStatus != EFI_CONNECTION_FIN) { } else if (EFI_ERROR (HttpIoReceiveStatus) && (HttpIoReceiveStatus != EFI_CONNECTION_FIN)) {
if ((Instance->Flags & RESTEX_INSTANCE_FLAGS_TCP_ERROR_RETRY) == 0) { if ((Instance->Flags & RESTEX_INSTANCE_FLAGS_TCP_ERROR_RETRY) == 0) {
DEBUG ((DEBUG_ERROR, "%a: TCP error, reset HTTP session.\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: TCP error, reset HTTP session.\n", __FUNCTION__));
Instance->Flags |= RESTEX_INSTANCE_FLAGS_TCP_ERROR_RETRY; Instance->Flags |= RESTEX_INSTANCE_FLAGS_TCP_ERROR_RETRY;
@ -80,24 +83,27 @@ RedfishCheckHttpReceiveStatus (
ReturnStatus = EFI_DEVICE_ERROR; ReturnStatus = EFI_DEVICE_ERROR;
} }
} else { } else {
if (HttpIoReceiveStatus == EFI_CONNECTION_FIN) { if (HttpIoReceiveStatus == EFI_CONNECTION_FIN) {
if ((Instance->Flags & RESTEX_INSTANCE_FLAGS_TLS_RETRY) != 0) { if ((Instance->Flags & RESTEX_INSTANCE_FLAGS_TLS_RETRY) != 0) {
DEBUG ((DEBUG_ERROR, "%a: REST_EX Send and receive fail even with a new TLS session.\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: REST_EX Send and receive fail even with a new TLS session.\n", __FUNCTION__));
ReturnStatus = EFI_DEVICE_ERROR; ReturnStatus = EFI_DEVICE_ERROR;
}
Instance->Flags |= RESTEX_INSTANCE_FLAGS_TLS_RETRY;
Status = ResetHttpTslSession (Instance);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: Reset HTTP instance fail.\n", __FUNCTION__));
ReturnStatus = EFI_DEVICE_ERROR;
}
return EFI_NOT_READY;
} }
Instance->Flags |= RESTEX_INSTANCE_FLAGS_TLS_RETRY;
Status = ResetHttpTslSession (Instance);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: Reset HTTP instance fail.\n", __FUNCTION__));
ReturnStatus = EFI_DEVICE_ERROR;
}
return EFI_NOT_READY;
}
} }
// //
// Clean TLS new session retry and error try flags. // Clean TLS new session retry and error try flags.
// //
Instance->Flags &= ~ (RESTEX_INSTANCE_FLAGS_TLS_RETRY | RESTEX_INSTANCE_FLAGS_TCP_ERROR_RETRY); Instance->Flags &= ~(RESTEX_INSTANCE_FLAGS_TLS_RETRY | RESTEX_INSTANCE_FLAGS_TCP_ERROR_RETRY);
return ReturnStatus; return ReturnStatus;
} }
@ -124,15 +130,15 @@ RedfishCheckHttpReceiveStatus (
**/ **/
EFI_STATUS EFI_STATUS
RedfishHttpAddExpectation ( RedfishHttpAddExpectation (
IN EFI_REST_EX_PROTOCOL *This, IN EFI_REST_EX_PROTOCOL *This,
IN EFI_HTTP_MESSAGE *RequestMessage, IN EFI_HTTP_MESSAGE *RequestMessage,
IN EFI_HTTP_HEADER **PreservedRequestHeaders, IN EFI_HTTP_HEADER **PreservedRequestHeaders,
IN BOOLEAN *ItsWrite IN BOOLEAN *ItsWrite
) )
{ {
EFI_HTTP_HEADER *NewHeaders; EFI_HTTP_HEADER *NewHeaders;
if (This == NULL || RequestMessage == NULL) { if ((This == NULL) || (RequestMessage == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -142,16 +148,17 @@ RedfishHttpAddExpectation (
} }
if ((RequestMessage->Data.Request->Method != HttpMethodPut) && (RequestMessage->Data.Request->Method != HttpMethodPost) && if ((RequestMessage->Data.Request->Method != HttpMethodPut) && (RequestMessage->Data.Request->Method != HttpMethodPost) &&
(RequestMessage->Data.Request->Method != HttpMethodPatch)) { (RequestMessage->Data.Request->Method != HttpMethodPatch))
{
return EFI_SUCCESS; return EFI_SUCCESS;
} }
*ItsWrite = TRUE; *ItsWrite = TRUE;
NewHeaders = AllocateZeroPool((RequestMessage->HeaderCount + 1) * sizeof(EFI_HTTP_HEADER)); NewHeaders = AllocateZeroPool ((RequestMessage->HeaderCount + 1) * sizeof (EFI_HTTP_HEADER));
CopyMem ((VOID*)NewHeaders, (VOID *)RequestMessage->Headers, RequestMessage->HeaderCount * sizeof (EFI_HTTP_HEADER)); CopyMem ((VOID *)NewHeaders, (VOID *)RequestMessage->Headers, RequestMessage->HeaderCount * sizeof (EFI_HTTP_HEADER));
HttpSetFieldNameAndValue (NewHeaders + RequestMessage->HeaderCount, HTTP_HEADER_EXPECT, HTTP_EXPECT_100_CONTINUE); HttpSetFieldNameAndValue (NewHeaders + RequestMessage->HeaderCount, HTTP_HEADER_EXPECT, HTTP_EXPECT_100_CONTINUE);
RequestMessage->HeaderCount ++; RequestMessage->HeaderCount++;
RequestMessage->Headers = NewHeaders; RequestMessage->Headers = NewHeaders;
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -49,8 +49,8 @@
**/ **/
EFI_STATUS EFI_STATUS
RedfishCheckHttpReceiveStatus ( RedfishCheckHttpReceiveStatus (
IN RESTEX_INSTANCE *Instance, IN RESTEX_INSTANCE *Instance,
IN EFI_STATUS HttpIoReceiveStatus IN EFI_STATUS HttpIoReceiveStatus
); );
/** /**
@ -76,10 +76,10 @@ RedfishCheckHttpReceiveStatus (
**/ **/
EFI_STATUS EFI_STATUS
RedfishHttpAddExpectation ( RedfishHttpAddExpectation (
IN EFI_REST_EX_PROTOCOL *This, IN EFI_REST_EX_PROTOCOL *This,
IN EFI_HTTP_MESSAGE *RequestMessage, IN EFI_HTTP_MESSAGE *RequestMessage,
IN EFI_HTTP_HEADER **PreservedRequestHeaders, IN EFI_HTTP_HEADER **PreservedRequestHeaders,
IN BOOLEAN *ItsWrite IN BOOLEAN *ItsWrite
); );
/** /**
@ -104,9 +104,9 @@ RedfishHttpAddExpectation (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishRestExSendReceive ( RedfishRestExSendReceive (
IN EFI_REST_EX_PROTOCOL *This, IN EFI_REST_EX_PROTOCOL *This,
IN EFI_HTTP_MESSAGE *RequestMessage, IN EFI_HTTP_MESSAGE *RequestMessage,
OUT EFI_HTTP_MESSAGE *ResponseMessage OUT EFI_HTTP_MESSAGE *ResponseMessage
); );
/** /**
@ -134,8 +134,8 @@ RedfishRestExSendReceive (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishRestExGetServiceTime ( RedfishRestExGetServiceTime (
IN EFI_REST_EX_PROTOCOL *This, IN EFI_REST_EX_PROTOCOL *This,
OUT EFI_TIME *Time OUT EFI_TIME *Time
); );
/** /**
@ -205,8 +205,8 @@ RedfishRestExGetService (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishRestExGetModeData ( RedfishRestExGetModeData (
IN EFI_REST_EX_PROTOCOL *This, IN EFI_REST_EX_PROTOCOL *This,
OUT EFI_REST_EX_CONFIG_DATA *RestExConfigData OUT EFI_REST_EX_CONFIG_DATA *RestExConfigData
); );
/** /**
@ -243,8 +243,8 @@ RedfishRestExGetModeData (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishRestExConfigure ( RedfishRestExConfigure (
IN EFI_REST_EX_PROTOCOL *This, IN EFI_REST_EX_PROTOCOL *This,
IN EFI_REST_EX_CONFIG_DATA RestExConfigData IN EFI_REST_EX_CONFIG_DATA RestExConfigData
); );
/** /**
@ -281,10 +281,10 @@ RedfishRestExConfigure (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishRestExAyncSendReceive ( RedfishRestExAyncSendReceive (
IN EFI_REST_EX_PROTOCOL *This, IN EFI_REST_EX_PROTOCOL *This,
IN EFI_HTTP_MESSAGE *RequestMessage OPTIONAL, IN EFI_HTTP_MESSAGE *RequestMessage OPTIONAL,
IN EFI_REST_EX_TOKEN *RestExToken, IN EFI_REST_EX_TOKEN *RestExToken,
IN UINTN *TimeOutInMilliSeconds OPTIONAL IN UINTN *TimeOutInMilliSeconds OPTIONAL
); );
/** /**
@ -316,10 +316,11 @@ RedfishRestExAyncSendReceive (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishRestExEventService ( RedfishRestExEventService (
IN EFI_REST_EX_PROTOCOL *This, IN EFI_REST_EX_PROTOCOL *This,
IN EFI_HTTP_MESSAGE *RequestMessage OPTIONAL, IN EFI_HTTP_MESSAGE *RequestMessage OPTIONAL,
IN EFI_REST_EX_TOKEN *RestExToken IN EFI_REST_EX_TOKEN *RestExToken
); );
/** /**
Create a new TLS session becuase the previous on is closed. Create a new TLS session becuase the previous on is closed.
status. status.
@ -333,8 +334,7 @@ RedfishRestExEventService (
EFI_STATUS EFI_STATUS
ResetHttpTslSession ( ResetHttpTslSession (
IN RESTEX_INSTANCE *Instance IN RESTEX_INSTANCE *Instance
); );
/** /**
Callback function which provided by user to remove one node in NetDestroyLinkList process. Callback function which provided by user to remove one node in NetDestroyLinkList process.
@ -349,8 +349,8 @@ ResetHttpTslSession (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RestExDestroyChildEntryInHandleBuffer ( RestExDestroyChildEntryInHandleBuffer (
IN LIST_ENTRY *Entry, IN LIST_ENTRY *Entry,
IN VOID *Context IN VOID *Context
); );
/** /**
@ -361,7 +361,7 @@ RestExDestroyChildEntryInHandleBuffer (
**/ **/
VOID VOID
RestExDestroyInstance ( RestExDestroyInstance (
IN RESTEX_INSTANCE *Instance IN RESTEX_INSTANCE *Instance
); );
/** /**
@ -376,11 +376,10 @@ RestExDestroyInstance (
**/ **/
EFI_STATUS EFI_STATUS
RestExCreateInstance ( RestExCreateInstance (
IN RESTEX_SERVICE *Service, IN RESTEX_SERVICE *Service,
OUT RESTEX_INSTANCE **Instance OUT RESTEX_INSTANCE **Instance
); );
/** /**
Release all the resource used the RestEx service binding instance. Release all the resource used the RestEx service binding instance.
@ -389,7 +388,7 @@ RestExCreateInstance (
**/ **/
VOID VOID
RestExDestroyService ( RestExDestroyService (
IN RESTEX_SERVICE *RestExSb IN RESTEX_SERVICE *RestExSb
); );
/** /**
@ -407,9 +406,9 @@ RestExDestroyService (
**/ **/
EFI_STATUS EFI_STATUS
RestExCreateService ( RestExCreateService (
IN EFI_HANDLE Controller, IN EFI_HANDLE Controller,
IN EFI_HANDLE Image, IN EFI_HANDLE Image,
OUT RESTEX_SERVICE **Service OUT RESTEX_SERVICE **Service
); );
/** /**
@ -608,4 +607,5 @@ RedfishRestExServiceBindingDestroyChild (
IN EFI_SERVICE_BINDING_PROTOCOL *This, IN EFI_SERVICE_BINDING_PROTOCOL *This,
IN EFI_HANDLE ChildHandle IN EFI_HANDLE ChildHandle
); );
#endif #endif

View File

@ -45,37 +45,37 @@ EFI_REST_EX_PROTOCOL mRedfishRestExProtocol = {
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishRestExSendReceive ( RedfishRestExSendReceive (
IN EFI_REST_EX_PROTOCOL *This, IN EFI_REST_EX_PROTOCOL *This,
IN EFI_HTTP_MESSAGE *RequestMessage, IN EFI_HTTP_MESSAGE *RequestMessage,
OUT EFI_HTTP_MESSAGE *ResponseMessage OUT EFI_HTTP_MESSAGE *ResponseMessage
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
RESTEX_INSTANCE *Instance; RESTEX_INSTANCE *Instance;
HTTP_IO_RESPONSE_DATA *ResponseData; HTTP_IO_RESPONSE_DATA *ResponseData;
UINTN TotalReceivedSize; UINTN TotalReceivedSize;
UINTN Index; UINTN Index;
LIST_ENTRY *ChunkListLink; LIST_ENTRY *ChunkListLink;
HTTP_IO_CHUNKS *ThisChunk; HTTP_IO_CHUNKS *ThisChunk;
BOOLEAN CopyChunkData; BOOLEAN CopyChunkData;
BOOLEAN MediaPresent; BOOLEAN MediaPresent;
EFI_HTTP_HEADER *PreservedRequestHeaders; EFI_HTTP_HEADER *PreservedRequestHeaders;
BOOLEAN ItsWrite; BOOLEAN ItsWrite;
BOOLEAN IsGetChunkedTransfer; BOOLEAN IsGetChunkedTransfer;
HTTP_IO_SEND_CHUNK_PROCESS SendChunkProcess; HTTP_IO_SEND_CHUNK_PROCESS SendChunkProcess;
HTTP_IO_SEND_NON_CHUNK_PROCESS SendNonChunkProcess; HTTP_IO_SEND_NON_CHUNK_PROCESS SendNonChunkProcess;
EFI_HTTP_MESSAGE ChunkTransferRequestMessage; EFI_HTTP_MESSAGE ChunkTransferRequestMessage;
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
ResponseData = NULL; ResponseData = NULL;
IsGetChunkedTransfer = FALSE; IsGetChunkedTransfer = FALSE;
SendChunkProcess = HttpIoSendChunkNone; SendChunkProcess = HttpIoSendChunkNone;
SendNonChunkProcess = HttpIoSendNonChunkNone; SendNonChunkProcess = HttpIoSendNonChunkNone;
// //
// Validate the parameters // Validate the parameters
// //
if ((This == NULL) || (RequestMessage == NULL) || ResponseMessage == NULL) { if ((This == NULL) || (RequestMessage == NULL) || (ResponseMessage == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -101,17 +101,19 @@ RedfishRestExSendReceive (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
if (ItsWrite == TRUE) { if (ItsWrite == TRUE) {
if (RequestMessage->BodyLength > HTTP_IO_MAX_SEND_PAYLOAD) { if (RequestMessage->BodyLength > HTTP_IO_MAX_SEND_PAYLOAD) {
// //
// Send chunked transfer. // Send chunked transfer.
// //
SendChunkProcess ++; SendChunkProcess++;
CopyMem ((VOID *)&ChunkTransferRequestMessage, (VOID *)RequestMessage, sizeof (EFI_HTTP_MESSAGE)); CopyMem ((VOID *)&ChunkTransferRequestMessage, (VOID *)RequestMessage, sizeof (EFI_HTTP_MESSAGE));
} else { } else {
SendNonChunkProcess ++; SendNonChunkProcess++;
} }
} }
ReSendRequest:; ReSendRequest:;
// //
// Send out the request to REST service. // Send out the request to REST service.
@ -127,7 +129,7 @@ ReSendRequest:;
// following request message body using chunk transfer. // following request message body using chunk transfer.
// //
do { do {
Status = HttpIoSendChunkedTransfer( Status = HttpIoSendChunkedTransfer (
&(Instance->HttpIo), &(Instance->HttpIo),
&SendChunkProcess, &SendChunkProcess,
&ChunkTransferRequestMessage &ChunkTransferRequestMessage
@ -141,20 +143,20 @@ ReSendRequest:;
// This is the non-chunk transfer, send request header first and then // This is the non-chunk transfer, send request header first and then
// handle the following request message body using chunk transfer. // handle the following request message body using chunk transfer.
// //
Status = HttpIoSendRequest( Status = HttpIoSendRequest (
&(Instance->HttpIo), &(Instance->HttpIo),
(SendNonChunkProcess == HttpIoSendNonChunkContent)? NULL: RequestMessage->Data.Request, (SendNonChunkProcess == HttpIoSendNonChunkContent) ? NULL : RequestMessage->Data.Request,
(SendNonChunkProcess == HttpIoSendNonChunkContent)? 0: RequestMessage->HeaderCount, (SendNonChunkProcess == HttpIoSendNonChunkContent) ? 0 : RequestMessage->HeaderCount,
(SendNonChunkProcess == HttpIoSendNonChunkContent)? NULL: RequestMessage->Headers, (SendNonChunkProcess == HttpIoSendNonChunkContent) ? NULL : RequestMessage->Headers,
(SendNonChunkProcess == HttpIoSendNonChunkHeaderZeroContent)? 0: RequestMessage->BodyLength, (SendNonChunkProcess == HttpIoSendNonChunkHeaderZeroContent) ? 0 : RequestMessage->BodyLength,
(SendNonChunkProcess == HttpIoSendNonChunkHeaderZeroContent)? NULL: RequestMessage->Body (SendNonChunkProcess == HttpIoSendNonChunkHeaderZeroContent) ? NULL : RequestMessage->Body
); );
} }
} else { } else {
// //
// This is read from URI. // This is read from URI.
// //
Status = HttpIoSendRequest( Status = HttpIoSendRequest (
&(Instance->HttpIo), &(Instance->HttpIo),
RequestMessage->Data.Request, RequestMessage->Data.Request,
RequestMessage->HeaderCount, RequestMessage->HeaderCount,
@ -163,6 +165,7 @@ ReSendRequest:;
RequestMessage->Body RequestMessage->Body
); );
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ON_EXIT; goto ON_EXIT;
} }
@ -173,20 +176,20 @@ ReSendRequest:;
// Clean the previous buffers and all of them will be allocated later according to the actual situation. // Clean the previous buffers and all of them will be allocated later according to the actual situation.
// //
if (ResponseMessage->Data.Response != NULL) { if (ResponseMessage->Data.Response != NULL) {
FreePool(ResponseMessage->Data.Response); FreePool (ResponseMessage->Data.Response);
ResponseMessage->Data.Response = NULL; ResponseMessage->Data.Response = NULL;
} }
ResponseMessage->BodyLength = 0; ResponseMessage->BodyLength = 0;
if (ResponseMessage->Body != NULL) { if (ResponseMessage->Body != NULL) {
FreePool(ResponseMessage->Body); FreePool (ResponseMessage->Body);
ResponseMessage->Body = NULL; ResponseMessage->Body = NULL;
} }
// //
// Use zero BodyLength to only receive the response headers. // Use zero BodyLength to only receive the response headers.
// //
ResponseData = AllocateZeroPool (sizeof(HTTP_IO_RESPONSE_DATA)); ResponseData = AllocateZeroPool (sizeof (HTTP_IO_RESPONSE_DATA));
if (ResponseData == NULL) { if (ResponseData == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
@ -194,25 +197,26 @@ ReSendRequest:;
DEBUG ((DEBUG_INFO, "Receiving HTTP response and headers...\n")); DEBUG ((DEBUG_INFO, "Receiving HTTP response and headers...\n"));
Status = RedfishCheckHttpReceiveStatus ( Status = RedfishCheckHttpReceiveStatus (
Instance, Instance,
HttpIoRecvResponse ( HttpIoRecvResponse (
&(Instance->HttpIo), &(Instance->HttpIo),
TRUE, TRUE,
ResponseData ResponseData
) )
); );
if (Status == EFI_NOT_READY) { if (Status == EFI_NOT_READY) {
goto ReSendRequest; goto ReSendRequest;
} else if (Status == EFI_DEVICE_ERROR) { } else if (Status == EFI_DEVICE_ERROR) {
goto ON_EXIT; goto ON_EXIT;
} }
// //
// Restore the headers if it ever changed in RedfishHttpAddExpectation(). // Restore the headers if it ever changed in RedfishHttpAddExpectation().
// //
if (RequestMessage->Headers != PreservedRequestHeaders) { if (RequestMessage->Headers != PreservedRequestHeaders) {
FreePool (RequestMessage->Headers); FreePool (RequestMessage->Headers);
RequestMessage->Headers = PreservedRequestHeaders; // Restore headers before we adding "Expect". RequestMessage->Headers = PreservedRequestHeaders; // Restore headers before we adding "Expect".
RequestMessage->HeaderCount --; // Minus one header count for "Expect". RequestMessage->HeaderCount--; // Minus one header count for "Expect".
} }
DEBUG ((DEBUG_INFO, "HTTP Response StatusCode - %d:", ResponseData->Response.StatusCode)); DEBUG ((DEBUG_INFO, "HTTP Response StatusCode - %d:", ResponseData->Response.StatusCode));
@ -221,7 +225,7 @@ ReSendRequest:;
if (SendChunkProcess == HttpIoSendChunkHeaderZeroContent) { if (SendChunkProcess == HttpIoSendChunkHeaderZeroContent) {
DEBUG ((DEBUG_INFO, "This is chunk transfer, start to send all chunks.", ResponseData->Response.StatusCode)); DEBUG ((DEBUG_INFO, "This is chunk transfer, start to send all chunks.", ResponseData->Response.StatusCode));
SendChunkProcess ++; SendChunkProcess++;
goto ReSendRequest; goto ReSendRequest;
} }
} else if (ResponseData->Response.StatusCode == HTTP_STATUS_413_REQUEST_ENTITY_TOO_LARGE) { } else if (ResponseData->Response.StatusCode == HTTP_STATUS_413_REQUEST_ENTITY_TOO_LARGE) {
@ -229,7 +233,7 @@ ReSendRequest:;
Status = EFI_BAD_BUFFER_SIZE; Status = EFI_BAD_BUFFER_SIZE;
goto ON_EXIT; goto ON_EXIT;
} else if (ResponseData->Response.StatusCode == HTTP_STATUS_405_METHOD_NOT_ALLOWED){ } else if (ResponseData->Response.StatusCode == HTTP_STATUS_405_METHOD_NOT_ALLOWED) {
DEBUG ((DEBUG_ERROR, "HTTP_STATUS_405_METHOD_NOT_ALLOWED\n")); DEBUG ((DEBUG_ERROR, "HTTP_STATUS_405_METHOD_NOT_ALLOWED\n"));
Status = EFI_ACCESS_DENIED; Status = EFI_ACCESS_DENIED;
@ -238,7 +242,7 @@ ReSendRequest:;
DEBUG ((DEBUG_INFO, "HTTP_STATUS_400_BAD_REQUEST\n")); DEBUG ((DEBUG_INFO, "HTTP_STATUS_400_BAD_REQUEST\n"));
if (SendChunkProcess == HttpIoSendChunkHeaderZeroContent) { if (SendChunkProcess == HttpIoSendChunkHeaderZeroContent) {
DEBUG ((DEBUG_INFO, "Bad request may caused by zero length chunk. Try to send all chunks...\n")); DEBUG ((DEBUG_INFO, "Bad request may caused by zero length chunk. Try to send all chunks...\n"));
SendChunkProcess ++; SendChunkProcess++;
goto ReSendRequest; goto ReSendRequest;
} }
} else if (ResponseData->Response.StatusCode == HTTP_STATUS_100_CONTINUE) { } else if (ResponseData->Response.StatusCode == HTTP_STATUS_100_CONTINUE) {
@ -248,22 +252,25 @@ ReSendRequest:;
// We get HTTP_STATUS_100_CONTINUE to send the body using chunk transfer. // We get HTTP_STATUS_100_CONTINUE to send the body using chunk transfer.
// //
DEBUG ((DEBUG_INFO, "HTTP_STATUS_100_CONTINUE for chunk transfer...\n")); DEBUG ((DEBUG_INFO, "HTTP_STATUS_100_CONTINUE for chunk transfer...\n"));
SendChunkProcess ++; SendChunkProcess++;
goto ReSendRequest; goto ReSendRequest;
} }
if (SendNonChunkProcess == HttpIoSendNonChunkHeaderZeroContent) { if (SendNonChunkProcess == HttpIoSendNonChunkHeaderZeroContent) {
DEBUG ((DEBUG_INFO, "HTTP_STATUS_100_CONTINUE for non chunk transfer...\n")); DEBUG ((DEBUG_INFO, "HTTP_STATUS_100_CONTINUE for non chunk transfer...\n"));
SendNonChunkProcess ++; SendNonChunkProcess++;
goto ReSendRequest; goto ReSendRequest;
} }
// //
// It's the REST protocol's responsibility to handle the interim HTTP response (e.g. 100 Continue Informational), // It's the REST protocol's responsibility to handle the interim HTTP response (e.g. 100 Continue Informational),
// and return the final response content to the caller. // and return the final response content to the caller.
// //
if (ResponseData->Headers != NULL && ResponseData->HeaderCount != 0) { if ((ResponseData->Headers != NULL) && (ResponseData->HeaderCount != 0)) {
FreePool (ResponseData->Headers); FreePool (ResponseData->Headers);
} }
ZeroMem (ResponseData, sizeof(HTTP_IO_RESPONSE_DATA));
ZeroMem (ResponseData, sizeof (HTTP_IO_RESPONSE_DATA));
Status = HttpIoRecvResponse ( Status = HttpIoRecvResponse (
&(Instance->HttpIo), &(Instance->HttpIo),
TRUE, TRUE,
@ -288,15 +295,15 @@ ReSendRequest:;
} }
ResponseMessage->Data.Response->StatusCode = ResponseData->Response.StatusCode; ResponseMessage->Data.Response->StatusCode = ResponseData->Response.StatusCode;
ResponseMessage->HeaderCount = ResponseData->HeaderCount; ResponseMessage->HeaderCount = ResponseData->HeaderCount;
ResponseMessage->Headers = ResponseData->Headers; ResponseMessage->Headers = ResponseData->Headers;
// //
// Get response message body. // Get response message body.
// //
if (ResponseMessage->HeaderCount > 0) { if (ResponseMessage->HeaderCount > 0) {
Status = HttpIoGetContentLength (ResponseMessage->HeaderCount, ResponseMessage->Headers, &ResponseMessage->BodyLength); Status = HttpIoGetContentLength (ResponseMessage->HeaderCount, ResponseMessage->Headers, &ResponseMessage->BodyLength);
if (EFI_ERROR (Status) && Status != EFI_NOT_FOUND) { if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
goto ON_EXIT; goto ON_EXIT;
} }
@ -315,46 +322,52 @@ ReSendRequest:;
&ChunkListLink, &ChunkListLink,
&ResponseMessage->BodyLength &ResponseMessage->BodyLength
); );
if (EFI_ERROR (Status) && Status != EFI_NOT_FOUND) { if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
goto ON_EXIT; goto ON_EXIT;
} }
if (Status == EFI_SUCCESS &&
ChunkListLink != NULL && if ((Status == EFI_SUCCESS) &&
!IsListEmpty(ChunkListLink) && (ChunkListLink != NULL) &&
ResponseMessage->BodyLength != 0) { !IsListEmpty (ChunkListLink) &&
(ResponseMessage->BodyLength != 0))
{
IsGetChunkedTransfer = TRUE; IsGetChunkedTransfer = TRUE;
// //
// Copy data to Message body. // Copy data to Message body.
// //
CopyChunkData = TRUE; CopyChunkData = TRUE;
ResponseMessage->Body = AllocateZeroPool (ResponseMessage->BodyLength); ResponseMessage->Body = AllocateZeroPool (ResponseMessage->BodyLength);
if (ResponseMessage->Body == NULL) { if (ResponseMessage->Body == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
CopyChunkData = FALSE; CopyChunkData = FALSE;
} }
Index = 0; Index = 0;
while (!IsListEmpty(ChunkListLink)) { while (!IsListEmpty (ChunkListLink)) {
ThisChunk = (HTTP_IO_CHUNKS *)GetFirstNode (ChunkListLink); ThisChunk = (HTTP_IO_CHUNKS *)GetFirstNode (ChunkListLink);
if (CopyChunkData) { if (CopyChunkData) {
CopyMem(((UINT8 *)ResponseMessage->Body + Index), (UINT8 *)ThisChunk->Data, ThisChunk->Length); CopyMem (((UINT8 *)ResponseMessage->Body + Index), (UINT8 *)ThisChunk->Data, ThisChunk->Length);
Index += ThisChunk->Length; Index += ThisChunk->Length;
} }
RemoveEntryList (&ThisChunk->NextChunk); RemoveEntryList (&ThisChunk->NextChunk);
FreePool ((VOID *)ThisChunk->Data); FreePool ((VOID *)ThisChunk->Data);
FreePool ((VOID *)ThisChunk); FreePool ((VOID *)ThisChunk);
}; }
FreePool ((VOID *)ChunkListLink); FreePool ((VOID *)ChunkListLink);
} }
} }
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
} }
// //
// Ready to return the Body from REST service if have any. // Ready to return the Body from REST service if have any.
// //
if (ResponseMessage->BodyLength > 0 && !IsGetChunkedTransfer) { if ((ResponseMessage->BodyLength > 0) && !IsGetChunkedTransfer) {
ResponseData->HeaderCount = 0; ResponseData->HeaderCount = 0;
ResponseData->Headers = NULL; ResponseData->Headers = NULL;
ResponseMessage->Body = AllocateZeroPool (ResponseMessage->BodyLength); ResponseMessage->Body = AllocateZeroPool (ResponseMessage->BodyLength);
if (ResponseMessage->Body == NULL) { if (ResponseMessage->Body == NULL) {
@ -368,20 +381,22 @@ ReSendRequest:;
TotalReceivedSize = 0; TotalReceivedSize = 0;
while (TotalReceivedSize < ResponseMessage->BodyLength) { while (TotalReceivedSize < ResponseMessage->BodyLength) {
ResponseData->BodyLength = ResponseMessage->BodyLength - TotalReceivedSize; ResponseData->BodyLength = ResponseMessage->BodyLength - TotalReceivedSize;
ResponseData->Body = (CHAR8 *) ResponseMessage->Body + TotalReceivedSize; ResponseData->Body = (CHAR8 *)ResponseMessage->Body + TotalReceivedSize;
Status = HttpIoRecvResponse ( Status = HttpIoRecvResponse (
&(Instance->HttpIo), &(Instance->HttpIo),
FALSE, FALSE,
ResponseData ResponseData
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ON_EXIT; goto ON_EXIT;
} }
TotalReceivedSize += ResponseData->BodyLength; TotalReceivedSize += ResponseData->BodyLength;
} }
DEBUG ((DEBUG_INFO, "Total of lengh of Response :%d\n", TotalReceivedSize)); DEBUG ((DEBUG_INFO, "Total of lengh of Response :%d\n", TotalReceivedSize));
} }
DEBUG ((DEBUG_INFO, "RedfishRestExSendReceive()- EFI_STATUS: %r\n", Status)); DEBUG ((DEBUG_INFO, "RedfishRestExSendReceive()- EFI_STATUS: %r\n", Status));
ON_EXIT: ON_EXIT:
@ -401,6 +416,7 @@ ON_EXIT:
ResponseMessage->Body = NULL; ResponseMessage->Body = NULL;
} }
} }
return Status; return Status;
} }
@ -429,8 +445,8 @@ ON_EXIT:
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishRestExGetServiceTime ( RedfishRestExGetServiceTime (
IN EFI_REST_EX_PROTOCOL *This, IN EFI_REST_EX_PROTOCOL *This,
OUT EFI_TIME *Time OUT EFI_TIME *Time
) )
{ {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
@ -474,17 +490,17 @@ RedfishRestExGetService (
OUT EFI_REST_EX_SERVICE_INFO **RestExServiceInfo OUT EFI_REST_EX_SERVICE_INFO **RestExServiceInfo
) )
{ {
EFI_TPL OldTpl; EFI_TPL OldTpl;
RESTEX_INSTANCE *Instance; RESTEX_INSTANCE *Instance;
EFI_REST_EX_SERVICE_INFO *ServiceInfo; EFI_REST_EX_SERVICE_INFO *ServiceInfo;
ServiceInfo = NULL; ServiceInfo = NULL;
if (This == NULL || RestExServiceInfo == NULL) { if ((This == NULL) || (RestExServiceInfo == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
OldTpl = gBS->RaiseTPL (TPL_CALLBACK); OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
Instance = RESTEX_INSTANCE_FROM_THIS (This); Instance = RESTEX_INSTANCE_FROM_THIS (This);
@ -531,8 +547,8 @@ RedfishRestExGetService (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishRestExGetModeData ( RedfishRestExGetModeData (
IN EFI_REST_EX_PROTOCOL *This, IN EFI_REST_EX_PROTOCOL *This,
OUT EFI_REST_EX_CONFIG_DATA *RestExConfigData OUT EFI_REST_EX_CONFIG_DATA *RestExConfigData
) )
{ {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
@ -572,15 +588,15 @@ RedfishRestExGetModeData (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishRestExConfigure ( RedfishRestExConfigure (
IN EFI_REST_EX_PROTOCOL *This, IN EFI_REST_EX_PROTOCOL *This,
IN EFI_REST_EX_CONFIG_DATA RestExConfigData IN EFI_REST_EX_CONFIG_DATA RestExConfigData
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_TPL OldTpl; EFI_TPL OldTpl;
RESTEX_INSTANCE *Instance; RESTEX_INSTANCE *Instance;
EFI_HTTP_CONFIG_DATA *HttpConfigData; EFI_HTTP_CONFIG_DATA *HttpConfigData;
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
HttpConfigData = NULL; HttpConfigData = NULL;
@ -589,7 +605,7 @@ RedfishRestExConfigure (
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
OldTpl = gBS->RaiseTPL (TPL_CALLBACK); OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
Instance = RESTEX_INSTANCE_FROM_THIS (This); Instance = RESTEX_INSTANCE_FROM_THIS (This);
@ -601,19 +617,21 @@ RedfishRestExConfigure (
if (Instance->ConfigData != NULL) { if (Instance->ConfigData != NULL) {
if (((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv4Node != NULL) { if (((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv4Node != NULL) {
FreePool(((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv4Node); FreePool (((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv4Node);
} }
FreePool(Instance->ConfigData);
FreePool (Instance->ConfigData);
Instance->ConfigData = NULL; Instance->ConfigData = NULL;
} }
Instance->State = RESTEX_STATE_UNCONFIGED; Instance->State = RESTEX_STATE_UNCONFIGED;
} else { } else {
HttpConfigData = &((EFI_REST_EX_HTTP_CONFIG_DATA *)RestExConfigData)->HttpConfigData; HttpConfigData = &((EFI_REST_EX_HTTP_CONFIG_DATA *)RestExConfigData)->HttpConfigData;
Status = Instance->HttpIo.Http->Configure (Instance->HttpIo.Http, HttpConfigData); Status = Instance->HttpIo.Http->Configure (Instance->HttpIo.Http, HttpConfigData);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ON_EXIT; goto ON_EXIT;
} }
Instance->HttpIo.Timeout = ((EFI_REST_EX_HTTP_CONFIG_DATA *)RestExConfigData)->SendReceiveTimeout; Instance->HttpIo.Timeout = ((EFI_REST_EX_HTTP_CONFIG_DATA *)RestExConfigData)->SendReceiveTimeout;
Instance->ConfigData = AllocateZeroPool (sizeof (EFI_REST_EX_HTTP_CONFIG_DATA)); Instance->ConfigData = AllocateZeroPool (sizeof (EFI_REST_EX_HTTP_CONFIG_DATA));
@ -621,6 +639,7 @@ RedfishRestExConfigure (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
} }
CopyMem (Instance->ConfigData, RestExConfigData, sizeof (EFI_REST_EX_HTTP_CONFIG_DATA)); CopyMem (Instance->ConfigData, RestExConfigData, sizeof (EFI_REST_EX_HTTP_CONFIG_DATA));
if (HttpConfigData->LocalAddressIsIPv6 == TRUE) { if (HttpConfigData->LocalAddressIsIPv6 == TRUE) {
((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv6Node = AllocateZeroPool (sizeof (EFI_HTTPv6_ACCESS_POINT)); ((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv6Node = AllocateZeroPool (sizeof (EFI_HTTPv6_ACCESS_POINT));
@ -628,6 +647,7 @@ RedfishRestExConfigure (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
} }
CopyMem ( CopyMem (
((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv6Node, ((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv6Node,
HttpConfigData->AccessPoint.IPv6Node, HttpConfigData->AccessPoint.IPv6Node,
@ -639,12 +659,14 @@ RedfishRestExConfigure (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
} }
CopyMem ( CopyMem (
((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv4Node, ((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv4Node,
HttpConfigData->AccessPoint.IPv4Node, HttpConfigData->AccessPoint.IPv4Node,
sizeof (EFI_HTTPv4_ACCESS_POINT) sizeof (EFI_HTTPv4_ACCESS_POINT)
); );
} }
Instance->State = RESTEX_STATE_CONFIGED; Instance->State = RESTEX_STATE_CONFIGED;
} }
@ -687,10 +709,10 @@ ON_EXIT:
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishRestExAyncSendReceive ( RedfishRestExAyncSendReceive (
IN EFI_REST_EX_PROTOCOL *This, IN EFI_REST_EX_PROTOCOL *This,
IN EFI_HTTP_MESSAGE *RequestMessage OPTIONAL, IN EFI_HTTP_MESSAGE *RequestMessage OPTIONAL,
IN EFI_REST_EX_TOKEN *RestExToken, IN EFI_REST_EX_TOKEN *RestExToken,
IN UINTN *TimeOutInMilliSeconds OPTIONAL IN UINTN *TimeOutInMilliSeconds OPTIONAL
) )
{ {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
@ -725,11 +747,10 @@ RedfishRestExAyncSendReceive (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RedfishRestExEventService ( RedfishRestExEventService (
IN EFI_REST_EX_PROTOCOL *This, IN EFI_REST_EX_PROTOCOL *This,
IN EFI_HTTP_MESSAGE *RequestMessage OPTIONAL, IN EFI_HTTP_MESSAGE *RequestMessage OPTIONAL,
IN EFI_REST_EX_TOKEN *RestExToken IN EFI_REST_EX_TOKEN *RestExToken
) )
{ {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }

View File

@ -13,8 +13,8 @@
#include <Protocol/RestJsonStructure.h> #include <Protocol/RestJsonStructure.h>
#include "RestJsonStructureInternal.h" #include "RestJsonStructureInternal.h"
LIST_ENTRY mRestJsonStructureList; LIST_ENTRY mRestJsonStructureList;
EFI_HANDLE mProtocolHandle; EFI_HANDLE mProtocolHandle;
/** /**
This function registers Restful resource interpreter for the This function registers Restful resource interpreter for the
@ -34,63 +34,66 @@ EFI_HANDLE mProtocolHandle;
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RestJsonStructureRegister ( RestJsonStructureRegister (
IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This,
IN EFI_REST_JSON_STRUCTURE_SUPPORTED *JsonStructureSupported, IN EFI_REST_JSON_STRUCTURE_SUPPORTED *JsonStructureSupported,
IN EFI_REST_JSON_STRUCTURE_TO_STRUCTURE ToStructure, IN EFI_REST_JSON_STRUCTURE_TO_STRUCTURE ToStructure,
IN EFI_REST_JSON_STRUCTURE_TO_JSON ToJson, IN EFI_REST_JSON_STRUCTURE_TO_JSON ToJson,
IN EFI_REST_JSON_STRUCTURE_DESTORY_STRUCTURE DestroyStructure IN EFI_REST_JSON_STRUCTURE_DESTORY_STRUCTURE DestroyStructure
) )
{ {
UINTN NumberOfNS; UINTN NumberOfNS;
UINTN Index; UINTN Index;
LIST_ENTRY *ThisList; LIST_ENTRY *ThisList;
REST_JSON_STRUCTURE_INSTANCE *Instance; REST_JSON_STRUCTURE_INSTANCE *Instance;
EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *CloneSupportedInterpId; EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *CloneSupportedInterpId;
EFI_REST_JSON_STRUCTURE_SUPPORTED *ThisSupportedInterp; EFI_REST_JSON_STRUCTURE_SUPPORTED *ThisSupportedInterp;
if (This == NULL || if ((This == NULL) ||
ToStructure == NULL || (ToStructure == NULL) ||
ToJson == NULL || (ToJson == NULL) ||
DestroyStructure == NULL || (DestroyStructure == NULL) ||
JsonStructureSupported == NULL (JsonStructureSupported == NULL)
) { )
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
// //
// Check how many name space interpreter can interpret. // Check how many name space interpreter can interpret.
// //
ThisList = &JsonStructureSupported->NextSupportedRsrcInterp; ThisList = &JsonStructureSupported->NextSupportedRsrcInterp;
NumberOfNS = 1; NumberOfNS = 1;
while (TRUE) { while (TRUE) {
if (ThisList->ForwardLink == &JsonStructureSupported->NextSupportedRsrcInterp) { if (ThisList->ForwardLink == &JsonStructureSupported->NextSupportedRsrcInterp) {
break; break;
} else { } else {
ThisList = ThisList->ForwardLink; ThisList = ThisList->ForwardLink;
NumberOfNS ++; NumberOfNS++;
} }
}; }
Instance = Instance =
(REST_JSON_STRUCTURE_INSTANCE *)AllocateZeroPool (sizeof (REST_JSON_STRUCTURE_INSTANCE) + NumberOfNS * sizeof (EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER)); (REST_JSON_STRUCTURE_INSTANCE *)AllocateZeroPool (sizeof (REST_JSON_STRUCTURE_INSTANCE) + NumberOfNS * sizeof (EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER));
if (Instance == NULL) { if (Instance == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
InitializeListHead (&Instance->NextRestJsonStructureInstance); InitializeListHead (&Instance->NextRestJsonStructureInstance);
Instance->NumberOfNameSpaceToConvert = NumberOfNS; Instance->NumberOfNameSpaceToConvert = NumberOfNS;
Instance->SupportedRsrcIndentifier = (EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *)((REST_JSON_STRUCTURE_INSTANCE *)Instance + 1); Instance->SupportedRsrcIndentifier = (EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *)((REST_JSON_STRUCTURE_INSTANCE *)Instance + 1);
// //
// Copy supported resource identifer interpreter. // Copy supported resource identifer interpreter.
// //
CloneSupportedInterpId = Instance->SupportedRsrcIndentifier; CloneSupportedInterpId = Instance->SupportedRsrcIndentifier;
ThisSupportedInterp = JsonStructureSupported; ThisSupportedInterp = JsonStructureSupported;
for (Index = 0; Index < NumberOfNS; Index ++) { for (Index = 0; Index < NumberOfNS; Index++) {
CopyMem ((VOID *)CloneSupportedInterpId, (VOID *)&ThisSupportedInterp->RestResourceInterp, sizeof (EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER)); CopyMem ((VOID *)CloneSupportedInterpId, (VOID *)&ThisSupportedInterp->RestResourceInterp, sizeof (EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER));
ThisSupportedInterp = (EFI_REST_JSON_STRUCTURE_SUPPORTED *)ThisSupportedInterp->NextSupportedRsrcInterp.ForwardLink; ThisSupportedInterp = (EFI_REST_JSON_STRUCTURE_SUPPORTED *)ThisSupportedInterp->NextSupportedRsrcInterp.ForwardLink;
CloneSupportedInterpId ++; CloneSupportedInterpId++;
} }
Instance->JsonToStructure = ToStructure;
Instance->StructureToJson = ToJson; Instance->JsonToStructure = ToStructure;
Instance->StructureToJson = ToJson;
Instance->DestroyStructure = DestroyStructure; Instance->DestroyStructure = DestroyStructure;
InsertTailList (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance); InsertTailList (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance);
return EFI_SUCCESS; return EFI_SUCCESS;
@ -111,23 +114,24 @@ RestJsonStructureRegister (
**/ **/
EFI_STATUS EFI_STATUS
InterpreterInstanceToStruct ( InterpreterInstanceToStruct (
IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This,
IN REST_JSON_STRUCTURE_INSTANCE *InterpreterInstance, IN REST_JSON_STRUCTURE_INSTANCE *InterpreterInstance,
IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcTypeIdentifier OPTIONAL, IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcTypeIdentifier OPTIONAL,
IN CHAR8 *ResourceRaw, IN CHAR8 *ResourceRaw,
OUT EFI_REST_JSON_STRUCTURE_HEADER **RestJSonHeader OUT EFI_REST_JSON_STRUCTURE_HEADER **RestJSonHeader
) )
{ {
UINTN Index; UINTN Index;
EFI_STATUS Status; EFI_STATUS Status;
EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *ThisSupportedRsrcTypeId; EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *ThisSupportedRsrcTypeId;
if (This == NULL || if ((This == NULL) ||
InterpreterInstance == NULL || (InterpreterInstance == NULL) ||
ResourceRaw == NULL || (ResourceRaw == NULL) ||
RestJSonHeader == NULL (RestJSonHeader == NULL)
) { )
return EFI_INVALID_PARAMETER; {
return EFI_INVALID_PARAMETER;
} }
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
@ -137,62 +141,72 @@ InterpreterInstanceToStruct (
// Interpreter may recognize this resource. // Interpreter may recognize this resource.
// //
Status = InterpreterInstance->JsonToStructure ( Status = InterpreterInstance->JsonToStructure (
This, This,
NULL, NULL,
ResourceRaw, ResourceRaw,
RestJSonHeader RestJSonHeader
); );
} else { } else {
// //
// Check if the namesapce and version is supported by this interpreter. // Check if the namesapce and version is supported by this interpreter.
// //
ThisSupportedRsrcTypeId = InterpreterInstance->SupportedRsrcIndentifier; ThisSupportedRsrcTypeId = InterpreterInstance->SupportedRsrcIndentifier;
for (Index = 0; Index < InterpreterInstance->NumberOfNameSpaceToConvert; Index ++){ for (Index = 0; Index < InterpreterInstance->NumberOfNameSpaceToConvert; Index++) {
if (AsciiStrCmp ( if (AsciiStrCmp (
RsrcTypeIdentifier->NameSpace.ResourceTypeName, RsrcTypeIdentifier->NameSpace.ResourceTypeName,
ThisSupportedRsrcTypeId->NameSpace.ResourceTypeName) == 0){ ThisSupportedRsrcTypeId->NameSpace.ResourceTypeName
) == 0)
{
if ((RsrcTypeIdentifier->NameSpace.MajorVersion == NULL) && if ((RsrcTypeIdentifier->NameSpace.MajorVersion == NULL) &&
(RsrcTypeIdentifier->NameSpace.MinorVersion == NULL) && (RsrcTypeIdentifier->NameSpace.MinorVersion == NULL) &&
(RsrcTypeIdentifier->NameSpace.ErrataVersion == NULL) (RsrcTypeIdentifier->NameSpace.ErrataVersion == NULL)
) { )
{
// //
// Don't check version of this resource type identifier. // Don't check version of this resource type identifier.
// //
Status = InterpreterInstance->JsonToStructure ( Status = InterpreterInstance->JsonToStructure (
This, This,
RsrcTypeIdentifier, RsrcTypeIdentifier,
ResourceRaw, ResourceRaw,
RestJSonHeader RestJSonHeader
); );
break; break;
} else { } else {
// //
// Check version. // Check version.
// //
if ((AsciiStrCmp ( if ((AsciiStrCmp (
RsrcTypeIdentifier->NameSpace.MajorVersion, RsrcTypeIdentifier->NameSpace.MajorVersion,
ThisSupportedRsrcTypeId->NameSpace.MajorVersion) == 0) && ThisSupportedRsrcTypeId->NameSpace.MajorVersion
) == 0) &&
(AsciiStrCmp ( (AsciiStrCmp (
RsrcTypeIdentifier->NameSpace.MinorVersion, RsrcTypeIdentifier->NameSpace.MinorVersion,
ThisSupportedRsrcTypeId->NameSpace.MinorVersion) == 0) && ThisSupportedRsrcTypeId->NameSpace.MinorVersion
) == 0) &&
(AsciiStrCmp ( (AsciiStrCmp (
RsrcTypeIdentifier->NameSpace.ErrataVersion, RsrcTypeIdentifier->NameSpace.ErrataVersion,
ThisSupportedRsrcTypeId->NameSpace.ErrataVersion) == 0)) { ThisSupportedRsrcTypeId->NameSpace.ErrataVersion
) == 0))
{
Status = InterpreterInstance->JsonToStructure ( Status = InterpreterInstance->JsonToStructure (
This, This,
RsrcTypeIdentifier, RsrcTypeIdentifier,
ResourceRaw, ResourceRaw,
RestJSonHeader RestJSonHeader
); );
break; break;
} }
} }
} }
ThisSupportedRsrcTypeId ++;
ThisSupportedRsrcTypeId++;
} }
} }
return Status; return Status;
} }
/** /**
This function converts JSON C structure to JSON property. This function converts JSON C structure to JSON property.
@ -207,65 +221,76 @@ InterpreterInstanceToStruct (
**/ **/
EFI_STATUS EFI_STATUS
InterpreterEfiStructToInstance ( InterpreterEfiStructToInstance (
IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This,
IN REST_JSON_STRUCTURE_INSTANCE *InterpreterInstance, IN REST_JSON_STRUCTURE_INSTANCE *InterpreterInstance,
IN EFI_REST_JSON_STRUCTURE_HEADER *RestJSonHeader, IN EFI_REST_JSON_STRUCTURE_HEADER *RestJSonHeader,
OUT CHAR8 **ResourceRaw OUT CHAR8 **ResourceRaw
) )
{ {
UINTN Index; UINTN Index;
EFI_STATUS Status; EFI_STATUS Status;
EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *ThisSupportedRsrcTypeId; EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *ThisSupportedRsrcTypeId;
EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcTypeIdentifier; EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcTypeIdentifier;
if (This == NULL || if ((This == NULL) ||
InterpreterInstance == NULL || (InterpreterInstance == NULL) ||
RestJSonHeader == NULL || (RestJSonHeader == NULL) ||
ResourceRaw == NULL (ResourceRaw == NULL)
) { )
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
RsrcTypeIdentifier = &RestJSonHeader->JsonRsrcIdentifier; RsrcTypeIdentifier = &RestJSonHeader->JsonRsrcIdentifier;
if (RsrcTypeIdentifier == NULL || if ((RsrcTypeIdentifier == NULL) ||
RsrcTypeIdentifier->NameSpace.ResourceTypeName == NULL || (RsrcTypeIdentifier->NameSpace.ResourceTypeName == NULL) ||
RsrcTypeIdentifier->NameSpace.MajorVersion == NULL || (RsrcTypeIdentifier->NameSpace.MajorVersion == NULL) ||
RsrcTypeIdentifier->NameSpace.MinorVersion == NULL || (RsrcTypeIdentifier->NameSpace.MinorVersion == NULL) ||
RsrcTypeIdentifier->NameSpace.ErrataVersion == NULL (RsrcTypeIdentifier->NameSpace.ErrataVersion == NULL)
) { )
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
// //
// Check if the namesapce and version is supported by this interpreter. // Check if the namesapce and version is supported by this interpreter.
// //
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
ThisSupportedRsrcTypeId = InterpreterInstance->SupportedRsrcIndentifier; ThisSupportedRsrcTypeId = InterpreterInstance->SupportedRsrcIndentifier;
for (Index = 0; Index < InterpreterInstance->NumberOfNameSpaceToConvert; Index ++){ for (Index = 0; Index < InterpreterInstance->NumberOfNameSpaceToConvert; Index++) {
if (AsciiStrCmp ( if (AsciiStrCmp (
RsrcTypeIdentifier->NameSpace.ResourceTypeName, RsrcTypeIdentifier->NameSpace.ResourceTypeName,
ThisSupportedRsrcTypeId->NameSpace.ResourceTypeName) == 0){ ThisSupportedRsrcTypeId->NameSpace.ResourceTypeName
) == 0)
{
// //
// Check version. // Check version.
// //
if ((AsciiStrCmp ( if ((AsciiStrCmp (
RsrcTypeIdentifier->NameSpace.MajorVersion, RsrcTypeIdentifier->NameSpace.MajorVersion,
ThisSupportedRsrcTypeId->NameSpace.MajorVersion) == 0) && ThisSupportedRsrcTypeId->NameSpace.MajorVersion
) == 0) &&
(AsciiStrCmp ( (AsciiStrCmp (
RsrcTypeIdentifier->NameSpace.MinorVersion, RsrcTypeIdentifier->NameSpace.MinorVersion,
ThisSupportedRsrcTypeId->NameSpace.MinorVersion) == 0) && ThisSupportedRsrcTypeId->NameSpace.MinorVersion
) == 0) &&
(AsciiStrCmp ( (AsciiStrCmp (
RsrcTypeIdentifier->NameSpace.ErrataVersion, RsrcTypeIdentifier->NameSpace.ErrataVersion,
ThisSupportedRsrcTypeId->NameSpace.ErrataVersion) == 0)) { ThisSupportedRsrcTypeId->NameSpace.ErrataVersion
) == 0))
{
Status = InterpreterInstance->StructureToJson ( Status = InterpreterInstance->StructureToJson (
This, This,
RestJSonHeader, RestJSonHeader,
ResourceRaw ResourceRaw
); );
break; break;
} }
} }
ThisSupportedRsrcTypeId ++;
ThisSupportedRsrcTypeId++;
} }
return Status; return Status;
} }
@ -282,19 +307,20 @@ InterpreterEfiStructToInstance (
**/ **/
EFI_STATUS EFI_STATUS
InterpreterInstanceDestoryJsonStruct ( InterpreterInstanceDestoryJsonStruct (
IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This,
IN REST_JSON_STRUCTURE_INSTANCE *InterpreterInstance, IN REST_JSON_STRUCTURE_INSTANCE *InterpreterInstance,
IN EFI_REST_JSON_STRUCTURE_HEADER *RestJSonHeader IN EFI_REST_JSON_STRUCTURE_HEADER *RestJSonHeader
) )
{ {
UINTN Index; UINTN Index;
EFI_STATUS Status; EFI_STATUS Status;
EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *ThisSupportedRsrcTypeId; EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *ThisSupportedRsrcTypeId;
if (This == NULL || if ((This == NULL) ||
InterpreterInstance == NULL || (InterpreterInstance == NULL) ||
RestJSonHeader == NULL (RestJSonHeader == NULL)
) { )
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -303,45 +329,54 @@ InterpreterInstanceDestoryJsonStruct (
// Check if the namesapce and version is supported by this interpreter. // Check if the namesapce and version is supported by this interpreter.
// //
ThisSupportedRsrcTypeId = InterpreterInstance->SupportedRsrcIndentifier; ThisSupportedRsrcTypeId = InterpreterInstance->SupportedRsrcIndentifier;
for (Index = 0; Index < InterpreterInstance->NumberOfNameSpaceToConvert; Index ++){ for (Index = 0; Index < InterpreterInstance->NumberOfNameSpaceToConvert; Index++) {
if (AsciiStrCmp ( if (AsciiStrCmp (
RestJSonHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, RestJSonHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName,
ThisSupportedRsrcTypeId->NameSpace.ResourceTypeName) == 0) { ThisSupportedRsrcTypeId->NameSpace.ResourceTypeName
) == 0)
{
if ((RestJSonHeader->JsonRsrcIdentifier.NameSpace.MajorVersion == NULL) && if ((RestJSonHeader->JsonRsrcIdentifier.NameSpace.MajorVersion == NULL) &&
(RestJSonHeader->JsonRsrcIdentifier.NameSpace.MinorVersion == NULL) && (RestJSonHeader->JsonRsrcIdentifier.NameSpace.MinorVersion == NULL) &&
(RestJSonHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion == NULL) (RestJSonHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion == NULL)
) { )
{
// //
// Don't check version of this resource type identifier. // Don't check version of this resource type identifier.
// //
Status = InterpreterInstance->DestroyStructure ( Status = InterpreterInstance->DestroyStructure (
This, This,
RestJSonHeader RestJSonHeader
); );
break; break;
} else { } else {
// //
// Check version. // Check version.
// //
if ((AsciiStrCmp ( if ((AsciiStrCmp (
RestJSonHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, RestJSonHeader->JsonRsrcIdentifier.NameSpace.MajorVersion,
ThisSupportedRsrcTypeId->NameSpace.MajorVersion) == 0) && ThisSupportedRsrcTypeId->NameSpace.MajorVersion
) == 0) &&
(AsciiStrCmp ( (AsciiStrCmp (
RestJSonHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, RestJSonHeader->JsonRsrcIdentifier.NameSpace.MinorVersion,
ThisSupportedRsrcTypeId->NameSpace.MinorVersion) == 0) && ThisSupportedRsrcTypeId->NameSpace.MinorVersion
) == 0) &&
(AsciiStrCmp ( (AsciiStrCmp (
RestJSonHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, RestJSonHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion,
ThisSupportedRsrcTypeId->NameSpace.ErrataVersion) == 0)) { ThisSupportedRsrcTypeId->NameSpace.ErrataVersion
) == 0))
{
Status = InterpreterInstance->DestroyStructure ( Status = InterpreterInstance->DestroyStructure (
This, This,
RestJSonHeader RestJSonHeader
); );
break; break;
} }
} }
} }
ThisSupportedRsrcTypeId ++;
ThisSupportedRsrcTypeId++;
} }
return Status; return Status;
} }
@ -360,44 +395,49 @@ InterpreterInstanceDestoryJsonStruct (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RestJsonStructureToStruct ( RestJsonStructureToStruct (
IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This,
IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcTypeIdentifier OPTIONAL, IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcTypeIdentifier OPTIONAL,
IN CHAR8 *ResourceJsonText, IN CHAR8 *ResourceJsonText,
OUT EFI_REST_JSON_STRUCTURE_HEADER **JsonStructure OUT EFI_REST_JSON_STRUCTURE_HEADER **JsonStructure
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
REST_JSON_STRUCTURE_INSTANCE *Instance; REST_JSON_STRUCTURE_INSTANCE *Instance;
if (This == NULL || if ((This == NULL) ||
ResourceJsonText == NULL || (ResourceJsonText == NULL) ||
JsonStructure == NULL (JsonStructure == NULL)
) { )
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (IsListEmpty (&mRestJsonStructureList)) { if (IsListEmpty (&mRestJsonStructureList)) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
Status = EFI_SUCCESS;
Status = EFI_SUCCESS;
Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode (&mRestJsonStructureList); Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode (&mRestJsonStructureList);
while (TRUE) { while (TRUE) {
Status = InterpreterInstanceToStruct ( Status = InterpreterInstanceToStruct (
This, This,
Instance, Instance,
RsrcTypeIdentifier, RsrcTypeIdentifier,
ResourceJsonText, ResourceJsonText,
JsonStructure JsonStructure
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
break; break;
} }
if (IsNodeAtEnd(&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) {
if (IsNodeAtEnd (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) {
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
break; break;
} }
Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance); Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance);
}; }
return Status; return Status;
} }
@ -415,37 +455,41 @@ RestJsonStructureToStruct (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RestJsonStructureDestroyStruct ( RestJsonStructureDestroyStruct (
IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This,
IN EFI_REST_JSON_STRUCTURE_HEADER *RestJSonHeader IN EFI_REST_JSON_STRUCTURE_HEADER *RestJSonHeader
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
REST_JSON_STRUCTURE_INSTANCE *Instance; REST_JSON_STRUCTURE_INSTANCE *Instance;
if (This == NULL || RestJSonHeader == NULL) { if ((This == NULL) || (RestJSonHeader == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (IsListEmpty (&mRestJsonStructureList)) { if (IsListEmpty (&mRestJsonStructureList)) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
Status = EFI_SUCCESS;
Status = EFI_SUCCESS;
Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode (&mRestJsonStructureList); Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode (&mRestJsonStructureList);
while (TRUE) { while (TRUE) {
Status = InterpreterInstanceDestoryJsonStruct ( Status = InterpreterInstanceDestoryJsonStruct (
This, This,
Instance, Instance,
RestJSonHeader RestJSonHeader
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
break; break;
} }
if (IsNodeAtEnd(&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) {
if (IsNodeAtEnd (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) {
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
break; break;
} }
Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance); Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance);
}; }
return Status; return Status;
} }
@ -463,43 +507,47 @@ RestJsonStructureDestroyStruct (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RestJsonStructureToJson ( RestJsonStructureToJson (
IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This,
IN EFI_REST_JSON_STRUCTURE_HEADER *RestJSonHeader, IN EFI_REST_JSON_STRUCTURE_HEADER *RestJSonHeader,
OUT CHAR8 **ResourceRaw OUT CHAR8 **ResourceRaw
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
REST_JSON_STRUCTURE_INSTANCE *Instance; REST_JSON_STRUCTURE_INSTANCE *Instance;
if (This == NULL || RestJSonHeader == NULL || ResourceRaw == NULL) { if ((This == NULL) || (RestJSonHeader == NULL) || (ResourceRaw == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (IsListEmpty (&mRestJsonStructureList)) { if (IsListEmpty (&mRestJsonStructureList)) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
Status = EFI_SUCCESS;
Status = EFI_SUCCESS;
Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode (&mRestJsonStructureList); Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode (&mRestJsonStructureList);
while (TRUE) { while (TRUE) {
Status = InterpreterEfiStructToInstance ( Status = InterpreterEfiStructToInstance (
This, This,
Instance, Instance,
RestJSonHeader, RestJSonHeader,
ResourceRaw ResourceRaw
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
break; break;
} }
if (IsNodeAtEnd(&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) {
if (IsNodeAtEnd (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) {
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
break; break;
} }
Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance); Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance);
}; }
return Status; return Status;
} }
EFI_REST_JSON_STRUCTURE_PROTOCOL mRestJsonStructureProtocol = { EFI_REST_JSON_STRUCTURE_PROTOCOL mRestJsonStructureProtocol = {
RestJsonStructureRegister, RestJsonStructureRegister,
RestJsonStructureToStruct, RestJsonStructureToStruct,
RestJsonStructureToJson, RestJsonStructureToJson,
@ -522,19 +570,19 @@ RestJsonStructureEntryPoint (
IN EFI_SYSTEM_TABLE *SystemTable IN EFI_SYSTEM_TABLE *SystemTable
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
InitializeListHead (&mRestJsonStructureList); InitializeListHead (&mRestJsonStructureList);
// //
// Install the Restful Resource Interpreter Protocol. // Install the Restful Resource Interpreter Protocol.
// //
mProtocolHandle = NULL; mProtocolHandle = NULL;
Status = gBS->InstallProtocolInterface ( Status = gBS->InstallProtocolInterface (
&mProtocolHandle, &mProtocolHandle,
&gEfiRestJsonStructureProtocolGuid, &gEfiRestJsonStructureProtocolGuid,
EFI_NATIVE_INTERFACE, EFI_NATIVE_INTERFACE,
(VOID *)&mRestJsonStructureProtocol (VOID *)&mRestJsonStructureProtocol
); );
return Status; return Status;
} }
@ -553,12 +601,12 @@ RestJsonStructureEntryPoint (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
RestJsonStructureUnload ( RestJsonStructureUnload (
IN EFI_HANDLE ImageHandle IN EFI_HANDLE ImageHandle
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
REST_JSON_STRUCTURE_INSTANCE *Instance; REST_JSON_STRUCTURE_INSTANCE *Instance;
REST_JSON_STRUCTURE_INSTANCE *NextInstance; REST_JSON_STRUCTURE_INSTANCE *NextInstance;
Status = gBS->UninstallProtocolInterface ( Status = gBS->UninstallProtocolInterface (
mProtocolHandle, mProtocolHandle,
@ -569,15 +617,17 @@ RestJsonStructureUnload (
if (IsListEmpty (&mRestJsonStructureList)) { if (IsListEmpty (&mRestJsonStructureList)) {
return Status; return Status;
} }
// //
// Free memory of REST_JSON_STRUCTURE_INSTANCE instance. // Free memory of REST_JSON_STRUCTURE_INSTANCE instance.
// //
Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode (&mRestJsonStructureList); Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode (&mRestJsonStructureList);
do { do {
NextInstance = NULL; NextInstance = NULL;
if (!IsNodeAtEnd(&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) { if (!IsNodeAtEnd (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) {
NextInstance = (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance); NextInstance = (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance);
} }
FreePool ((VOID *)Instance); FreePool ((VOID *)Instance);
Instance = NextInstance; Instance = NextInstance;
} while (Instance != NULL); } while (Instance != NULL);

View File

@ -23,11 +23,11 @@
/// C structure convertor. /// C structure convertor.
/// ///
typedef struct _REST_JSON_STRUCTURE_INSTANCE { typedef struct _REST_JSON_STRUCTURE_INSTANCE {
LIST_ENTRY NextRestJsonStructureInstance; ///< Next convertor instance LIST_ENTRY NextRestJsonStructureInstance; ///< Next convertor instance
UINTN NumberOfNameSpaceToConvert; ///< Number of resource type this convertor supports. UINTN NumberOfNameSpaceToConvert; ///< Number of resource type this convertor supports.
EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *SupportedRsrcIndentifier; ///< The resource type linklist EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *SupportedRsrcIndentifier; ///< The resource type linklist
EFI_REST_JSON_STRUCTURE_TO_STRUCTURE JsonToStructure; ///< JSON to C structure function EFI_REST_JSON_STRUCTURE_TO_STRUCTURE JsonToStructure; ///< JSON to C structure function
EFI_REST_JSON_STRUCTURE_TO_JSON StructureToJson; ///< C structure to JSON function EFI_REST_JSON_STRUCTURE_TO_JSON StructureToJson; ///< C structure to JSON function
EFI_REST_JSON_STRUCTURE_DESTORY_STRUCTURE DestroyStructure; ///< Destory C struture function. EFI_REST_JSON_STRUCTURE_DESTORY_STRUCTURE DestroyStructure; ///< Destory C struture function.
} REST_JSON_STRUCTURE_INSTANCE; } REST_JSON_STRUCTURE_INSTANCE;
#endif #endif