/**
* HttpUtilitiesDxe.h - Type definitions, GUID externs, and helper prototypes
* for the AMI HTTP Utilities DXE driver.
*
* Source: AmiNetworkPkg/UefiNetworkStack/Common/HttpUtilitiesDxe/HttpUtilitiesProtocol.c
*/
#ifndef __HTTP_UTILITIES_DXE_H__
#define __HTTP_UTILITIES_DXE_H__
#include "../uefi_headers/Uefi.h"
/* -------------------------------------------------------------------
* GUID Definitions
* ------------------------------------------------------------------- */
/* EFI_LOADED_IMAGE_PROTOCOL - standard UEFI protocol */
#define EFI_LOADED_IMAGE_PROTOCOL_GUID \
{ 0x5B1B31A1, 0x9562, 0x11D2, \
{ 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B } }
/* HTTP Utilities Protocol - custom AMI protocol */
#define HTTP_UTILITIES_PROTOCOL_GUID \
{ 0x3E35C163, 0x4074, 0x45DD, \
{ 0x43, 0x1E, 0x23, 0x98, 0x9D, 0xD8, 0x6B, 0x32 } }
/* AMI Debug Library Protocol - custom AMI protocol for debug printing */
#define AMI_DEBUG_LIBRARY_PROTOCOL_GUID \
{ 0x36232936, 0x0E76, 0x31C8, \
{ 0xA1, 0x3A, 0x3A, 0xF2, 0xFC, 0x1C, 0x39, 0x32 } }
/* gEfiHobListGuid (PI Spec) */
#define EFI_HOB_LIST_GUID \
{ 0x7739F24C, 0x93D7, 0x11D4, \
{ 0x9A, 0x3A, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D } }
/* -------------------------------------------------------------------
* Protocol Interface Structures
* ------------------------------------------------------------------- */
/**
* HTTP_UTILITIES_PROTOCOL - Provides HTTP message building and parsing
* services for UEFI HTTP drivers.
*
* Build() constructs an HTTP message from header+body components.
* Parse() breaks an HTTP message into its header+body constituents.
*/
typedef struct _HTTP_UTILITIES_PROTOCOL {
UINT64 Revision; /**< Protocol revision */
/** Build an HTTP message from header-value pairs and optional body */
EFI_STATUS (EFIAPI *Build)(IN VOID *This,
IN CHAR8 *Method OPTIONAL,
IN CHAR8 *Url OPTIONAL,
IN EFI_HTTP_HEADER *Headers,
IN UINTN HeaderCount,
IN UINTN BodyLength,
IN VOID *Body OPTIONAL,
OUT CHAR8 **Message,
OUT UINTN *MessageSize);
/** Parse an HTTP message into header-value pairs and body */
EFI_STATUS (EFIAPI *Parse)(IN VOID *This,
IN CHAR8 *Message,
IN UINTN MessageSize,
OUT EFI_HTTP_HEADER **Headers,
OUT UINTN *HeaderCount);
} HTTP_UTILITIES_PROTOCOL;
/**
* AMI_DEBUG_PRINT_PROTOCOL - AMI custom protocol for debug output.
* Located via LocateProtocol() during driver init.
*/
typedef struct _AMI_DEBUG_PRINT_PROTOCOL {
UINT64 Signature;
VOID (EFIAPI *Print)(IN UINTN ErrorLevel,
IN CONST CHAR8 *Format,
...);
VOID (EFIAPI *Assert)(IN CONST CHAR8 *FileName,
IN UINTN LineNumber,
IN CONST CHAR8 *AssertText);
} AMI_DEBUG_PRINT_PROTOCOL;
/* -------------------------------------------------------------------
* HTTP Header types
* ------------------------------------------------------------------- */
/** A single HTTP header name-value pair */
typedef struct {
CHAR8 *FieldName; /**< e.g. "Content-Type" */
CHAR8 *FieldValue; /**< e.g. "text/html" */
} EFI_HTTP_HEADER;
/* -------------------------------------------------------------------
* Global variables (defined in HttpUtilitiesDxe.c)
* ------------------------------------------------------------------- */
extern EFI_HANDLE gImageHandle;
extern EFI_SYSTEM_TABLE *gSystemTable;
extern EFI_BOOT_SERVICES *gBootServices;
extern EFI_RUNTIME_SERVICES *gRuntimeServices;
extern VOID *gHobList;
/* -------------------------------------------------------------------
* Internal Helper Prototypes
* ------------------------------------------------------------------- */
/* Memory copy with overlap handling (forward-only or backward copy) */
CHAR8 *
EFIAPI
InternalCopyMem (
OUT VOID *Destination,
IN CONST VOID *Source,
IN UINTN Length
);
/* Zero memory */
VOID *
EFIAPI
InternalZeroMem (
OUT VOID *Buffer,
IN UINTN Length
);
/* Ascii string length with max bound check */
UINTN
EFIAPI
AsciiStrLen (
IN CONST CHAR8 *String
);
/* Ascii string comparison (case-insensitive) */
INTN
EFIAPI
AsciiStriCmp (
IN CONST CHAR8 *FirstString,
IN CONST CHAR8 *SecondString
);
/* Copy memory with bounds checks */
VOID *
EFIAPI
CopyMem (
OUT VOID *Destination,
IN CONST VOID *Source,
IN UINTN Length
);
/* Zero memory with bounds checks */
VOID *
EFIAPI
ZeroMem (
OUT VOID *Buffer,
IN UINTN Length
);
/* Allocate zero-filled pool */
VOID *
EFIAPI
AllocateZeroPool (
IN UINTN Size
);
/* Free pool with error assert */
VOID
EFIAPI
FreePool (
IN VOID *Buffer
);
/* Read unaligned 64-bit value */
UINT64
EFIAPI
ReadUnaligned64 (
IN CONST VOID *Buffer
);
/* Debug assert */
VOID
EFIAPI
Assert (
IN CONST CHAR8 *FileName,
IN UINTN LineNumber,
IN CONST CHAR8 *AssertText
);
/* Debug print with error level */
UINTN
EFIAPI
DebugPrint (
IN UINTN ErrorLevel,
IN CONST CHAR8 *Format,
...
);
/* Initialize HOB list pointer */
EFI_STATUS
EFIAPI
GetHobList (
VOID
);
/* Locate the AMI debug print protocol */
VOID *
EFIAPI
LocateDebugPrintProtocol (
VOID
);
/* Free an array of HTTP header name-value pairs */
VOID
EFIAPI
FreeHeaderPairs (
IN EFI_HTTP_HEADER *Headers,
IN UINTN Count
);
/* Store a header name-value pair into an array slot */
EFI_STATUS
EFIAPI
SetHeaderPair (
IN OUT EFI_HTTP_HEADER *Header,
IN CHAR8 *FieldName,
IN CHAR8 *FieldValue
);
/* Find a header entry by field name (case-insensitive) */
EFI_HTTP_HEADER *
EFIAPI
FindHeaderByName (
IN EFI_HTTP_HEADER *Headers,
IN UINTN Count,
IN CHAR8 *FieldName
);
/* Parse the next header line from a message string, advancing the cursor */
CHAR8 *
EFIAPI
ParseNextHeaderLine (
IN CHAR8 *Cursor,
OUT CHAR8 **FieldName,
OUT CHAR8 **FieldValue
);
/* Check if a header name matches any in a filter list */
BOOLEAN
EFIAPI
MatchHeaderFilter (
IN CHAR8 **FilterList,
IN UINTN FilterCount,
IN CHAR8 *FieldName
);
#endif /* __HTTP_UTILITIES_DXE_H__ */