From 0789f48d70b7593808f18dc4f1dbce2ca67df0f4 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Fri, 29 Jan 2021 15:11:18 -0500 Subject: Always use lower case for our local include file names. clang-format doesn't allow you to specify an include sort order, and just assumes asciibetical is a pretty good order, which doesn't work as well as you would hope. This makes them all lower case so they don't need to be re-sorted. I also went through and checked that we're using quoted local includes at all the appropriate places. Signed-off-by: Peter Jones --- include/Http.h | 507 ----------------------------- include/Ip4Config2.h | 310 ------------------ include/Ip6Config.h | 361 --------------------- include/PasswordCrypt.h | 27 -- include/PeImage.h | 790 --------------------------------------------- include/efiauthenticated.h | 2 +- include/http.h | 507 +++++++++++++++++++++++++++++ include/ip4config2.h | 310 ++++++++++++++++++ include/ip6config.h | 361 +++++++++++++++++++++ include/passwordcrypt.h | 27 ++ include/pe.h | 790 +++++++++++++++++++++++++++++++++++++++++++++ include/variables.h | 4 +- lib/security_policy.c | 5 - shim.h | 10 +- 14 files changed, 2003 insertions(+), 2008 deletions(-) delete mode 100644 include/Http.h delete mode 100644 include/Ip4Config2.h delete mode 100644 include/Ip6Config.h delete mode 100644 include/PasswordCrypt.h delete mode 100644 include/PeImage.h create mode 100644 include/http.h create mode 100644 include/ip4config2.h create mode 100644 include/ip6config.h create mode 100644 include/passwordcrypt.h create mode 100644 include/pe.h diff --git a/include/Http.h b/include/Http.h deleted file mode 100644 index 4b3746a7..00000000 --- a/include/Http.h +++ /dev/null @@ -1,507 +0,0 @@ -/** @file - This file defines the EFI HTTP Protocol interface. It is split into - the following two main sections: - HTTP Service Binding Protocol (HTTPSB) - HTTP Protocol (HTTP) - - Copyright (c) 2016, Intel Corporation. All rights reserved.
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - @par Revision Reference: - This Protocol is introduced in UEFI Specification 2.5 - -**/ - -#ifndef SHIM_HTTP_H -#define SHIM_HTTP_H - -typedef struct _EFI_HTTP_PROTOCOL EFI_HTTP_PROTOCOL; - -/// -/// EFI_HTTP_VERSION -/// -typedef enum { - HttpVersion10, - HttpVersion11, - HttpVersionUnsupported -} EFI_HTTP_VERSION; - -/// -/// EFI_HTTP_METHOD -/// -typedef enum { - HttpMethodGet, - HttpMethodPost, - HttpMethodPatch, - HttpMethodOptions, - HttpMethodConnect, - HttpMethodHead, - HttpMethodPut, - HttpMethodDelete, - HttpMethodTrace, - HttpMethodMax -} EFI_HTTP_METHOD; - -/// -/// EFI_HTTP_STATUS_CODE -/// -typedef enum { - HTTP_STATUS_UNSUPPORTED_STATUS = 0, - HTTP_STATUS_100_CONTINUE, - HTTP_STATUS_101_SWITCHING_PROTOCOLS, - HTTP_STATUS_200_OK, - HTTP_STATUS_201_CREATED, - HTTP_STATUS_202_ACCEPTED, - HTTP_STATUS_203_NON_AUTHORITATIVE_INFORMATION, - HTTP_STATUS_204_NO_CONTENT, - HTTP_STATUS_205_RESET_CONTENT, - HTTP_STATUS_206_PARTIAL_CONTENT, - HTTP_STATUS_300_MULTIPLE_CHIOCES, - HTTP_STATUS_301_MOVED_PERMANENTLY, - HTTP_STATUS_302_FOUND, - HTTP_STATUS_303_SEE_OTHER, - HTTP_STATUS_304_NOT_MODIFIED, - HTTP_STATUS_305_USE_PROXY, - HTTP_STATUS_307_TEMPORARY_REDIRECT, - HTTP_STATUS_400_BAD_REQUEST, - HTTP_STATUS_401_UNAUTHORIZED, - HTTP_STATUS_402_PAYMENT_REQUIRED, - HTTP_STATUS_403_FORBIDDEN, - HTTP_STATUS_404_NOT_FOUND, - HTTP_STATUS_405_METHOD_NOT_ALLOWED, - HTTP_STATUS_406_NOT_ACCEPTABLE, - HTTP_STATUS_407_PROXY_AUTHENTICATION_REQUIRED, - HTTP_STATUS_408_REQUEST_TIME_OUT, - HTTP_STATUS_409_CONFLICT, - HTTP_STATUS_410_GONE, - HTTP_STATUS_411_LENGTH_REQUIRED, - HTTP_STATUS_412_PRECONDITION_FAILED, - HTTP_STATUS_413_REQUEST_ENTITY_TOO_LARGE, - HTTP_STATUS_414_REQUEST_URI_TOO_LARGE, - HTTP_STATUS_415_UNSUPPORTED_MEDIA_TYPE, - HTTP_STATUS_416_REQUESTED_RANGE_NOT_SATISFIED, - HTTP_STATUS_417_EXPECTATION_FAILED, - HTTP_STATUS_500_INTERNAL_SERVER_ERROR, - HTTP_STATUS_501_NOT_IMPLEMENTED, - HTTP_STATUS_502_BAD_GATEWAY, - HTTP_STATUS_503_SERVICE_UNAVAILABLE, - HTTP_STATUS_504_GATEWAY_TIME_OUT, - HTTP_STATUS_505_HTTP_VERSION_NOT_SUPPORTED -} EFI_HTTP_STATUS_CODE; - -/// -/// EFI_HTTPv4_ACCESS_POINT -/// -typedef struct { - /// - /// Set to TRUE to instruct the EFI HTTP instance to use the default address - /// information in every TCP connection made by this instance. In addition, when set - /// to TRUE, LocalAddress and LocalSubnet are ignored. - /// - BOOLEAN UseDefaultAddress; - /// - /// If UseDefaultAddress is set to FALSE, this defines the local IP address to be - /// used in every TCP connection opened by this instance. - /// - EFI_IPv4_ADDRESS LocalAddress; - /// - /// If UseDefaultAddress is set to FALSE, this defines the local subnet to be used - /// in every TCP connection opened by this instance. - /// - EFI_IPv4_ADDRESS LocalSubnet; - /// - /// This defines the local port to be used in - /// every TCP connection opened by this instance. - /// - UINT16 LocalPort; -} EFI_HTTPv4_ACCESS_POINT; - -/// -/// EFI_HTTPv6_ACCESS_POINT -/// -typedef struct { - /// - /// Local IP address to be used in every TCP connection opened by this instance. - /// - EFI_IPv6_ADDRESS LocalAddress; - /// - /// Local port to be used in every TCP connection opened by this instance. - /// - UINT16 LocalPort; -} EFI_HTTPv6_ACCESS_POINT; - -/// -/// EFI_HTTP_CONFIG_DATA_ACCESS_POINT -/// - - -typedef struct { - /// - /// HTTP version that this instance will support. - /// - EFI_HTTP_VERSION HttpVersion; - /// - /// Time out (in milliseconds) when blocking for requests. - /// - UINT32 TimeOutMillisec; - /// - /// Defines behavior of EFI DNS and TCP protocols consumed by this instance. If - /// FALSE, this instance will use EFI_DNS4_PROTOCOL and EFI_TCP4_PROTOCOL. If TRUE, - /// this instance will use EFI_DNS6_PROTOCOL and EFI_TCP6_PROTOCOL. - /// - BOOLEAN LocalAddressIsIPv6; - - union { - /// - /// When LocalAddressIsIPv6 is FALSE, this points to the local address, subnet, and - /// port used by the underlying TCP protocol. - /// - EFI_HTTPv4_ACCESS_POINT *IPv4Node; - /// - /// When LocalAddressIsIPv6 is TRUE, this points to the local IPv6 address and port - /// used by the underlying TCP protocol. - /// - EFI_HTTPv6_ACCESS_POINT *IPv6Node; - } AccessPoint; -} EFI_HTTP_CONFIG_DATA; - -/// -/// EFI_HTTP_REQUEST_DATA -/// -typedef struct { - /// - /// The HTTP method (e.g. GET, POST) for this HTTP Request. - /// - EFI_HTTP_METHOD Method; - /// - /// The URI of a remote host. From the information in this field, the HTTP instance - /// will be able to determine whether to use HTTP or HTTPS and will also be able to - /// determine the port number to use. If no port number is specified, port 80 (HTTP) - /// is assumed. See RFC 3986 for more details on URI syntax. - /// - CHAR16 *Url; -} EFI_HTTP_REQUEST_DATA; - -/// -/// EFI_HTTP_RESPONSE_DATA -/// -typedef struct { - /// - /// Response status code returned by the remote host. - /// - EFI_HTTP_STATUS_CODE StatusCode; -} EFI_HTTP_RESPONSE_DATA; - -/// -/// EFI_HTTP_HEADER -/// -typedef struct { - /// - /// Null terminated string which describes a field name. See RFC 2616 Section 14 for - /// detailed information about field names. - /// - CHAR8 *FieldName; - /// - /// Null terminated string which describes the corresponding field value. See RFC 2616 - /// Section 14 for detailed information about field values. - /// - CHAR8 *FieldValue; -} EFI_HTTP_HEADER; - -/// -/// EFI_HTTP_MESSAGE -/// -typedef struct { - /// - /// HTTP message data. - /// - union { - /// - /// When the token is used to send a HTTP request, Request is a pointer to storage that - /// contains such data as URL and HTTP method. - /// - EFI_HTTP_REQUEST_DATA *Request; - /// - /// When used to await a response, Response points to storage containing HTTP response - /// status code. - /// - EFI_HTTP_RESPONSE_DATA *Response; - } Data; - /// - /// Number of HTTP header structures in Headers list. On request, this count is - /// provided by the caller. On response, this count is provided by the HTTP driver. - /// - UINTN HeaderCount; - /// - /// Array containing list of HTTP headers. On request, this array is populated by the - /// caller. On response, this array is allocated and populated by the HTTP driver. It - /// is the responsibility of the caller to free this memory on both request and - /// response. - /// - EFI_HTTP_HEADER *Headers; - /// - /// Length in bytes of the HTTP body. This can be zero depending on the HttpMethod type. - /// - UINTN BodyLength; - /// - /// Body associated with the HTTP request or response. This can be NULL depending on - /// the HttpMethod type. - /// - VOID *Body; -} EFI_HTTP_MESSAGE; - - -/// -/// EFI_HTTP_TOKEN -/// -typedef struct { - /// - /// This Event will be signaled after the Status field is updated by the EFI HTTP - /// Protocol driver. The type of Event must be EFI_NOTIFY_SIGNAL. The Task Priority - /// Level (TPL) of Event must be lower than or equal to TPL_CALLBACK. - /// - EFI_EVENT Event; - /// - /// Status will be set to one of the following value if the HTTP request is - /// successfully sent or if an unexpected error occurs: - /// EFI_SUCCESS: The HTTP request was successfully sent to the remote host. - /// EFI_HTTP_ERROR: The response message was successfully received but contains a - /// HTTP error. The response status code is returned in token. - /// EFI_ABORTED: The HTTP request was cancelled by the caller and removed from - /// the transmit queue. - /// EFI_TIMEOUT: The HTTP request timed out before reaching the remote host. - /// EFI_DEVICE_ERROR: An unexpected system or network error occurred. - /// - EFI_STATUS Status; - /// - /// Pointer to storage containing HTTP message data. - /// - EFI_HTTP_MESSAGE *Message; -} EFI_HTTP_TOKEN; - -/** - Returns the operational parameters for the current HTTP child instance. - - The GetModeData() function is used to read the current mode data (operational - parameters) for this HTTP protocol instance. - - @param[in] This Pointer to EFI_HTTP_PROTOCOL instance. - @param[out] HttpConfigData Point to buffer for operational parameters of this - HTTP instance. - - @retval EFI_SUCCESS Operation succeeded. - @retval EFI_INVALID_PARAMETER This is NULL. - HttpConfigData is NULL. - HttpInstance->LocalAddressIsIPv6 is FALSE and - HttpConfigData->IPv4Node is NULL. - HttpInstance->LocalAddressIsIPv6 is TRUE and - HttpConfigData->IPv6Node is NULL. - @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started. -**/ -typedef -EFI_STATUS -(EFIAPI * EFI_HTTP_GET_MODE_DATA)( - IN EFI_HTTP_PROTOCOL *This, - OUT EFI_HTTP_CONFIG_DATA *HttpConfigData - ); - -/** - Initialize or brutally reset the operational parameters for this EFI HTTP instance. - - The Configure() function does the following: - When HttpConfigData is not NULL Initialize this EFI HTTP instance by configuring - timeout, local address, port, etc. - When HttpConfigData is NULL, reset this EFI HTTP instance by closing all active - connections with remote hosts, canceling all asynchronous tokens, and flush request - and response buffers without informing the appropriate hosts. - - No other EFI HTTP function can be executed by this instance until the Configure() - function is executed and returns successfully. - - @param[in] This Pointer to EFI_HTTP_PROTOCOL instance. - @param[in] HttpConfigData Pointer to the configure data to configure the instance. - - @retval EFI_SUCCESS Operation succeeded. - @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: - This is NULL. - HttpConfigData is NULL. - HttpConfigData->LocalAddressIsIPv6 is FALSE and - HttpConfigData->IPv4Node is NULL. - HttpConfigData->LocalAddressIsIPv6 is TRUE and - HttpConfigData->IPv6Node is NULL. - @retval EFI_ALREADY_STARTED Reinitialize this HTTP instance without calling - Configure() with NULL to reset it. - @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. - @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when - executing Configure(). - @retval EFI_UNSUPPORTED One or more options in ConfigData are not supported - in the implementation. -**/ -typedef -EFI_STATUS -(EFIAPI * EFI_HTTP_CONFIGURE)( - IN EFI_HTTP_PROTOCOL *This, - IN EFI_HTTP_CONFIG_DATA *HttpConfigData - ); - -/** - The Request() function queues an HTTP request to this HTTP instance, - similar to Transmit() function in the EFI TCP driver. When the HTTP request is sent - successfully, or if there is an error, Status in token will be updated and Event will - be signaled. - - @param[in] This Pointer to EFI_HTTP_PROTOCOL instance. - @param[in] Token Pointer to storage containing HTTP request token. - - @retval EFI_SUCCESS Outgoing data was processed. - @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started. - @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. - @retval EFI_TIMEOUT Data was dropped out of the transmit or receive queue. - @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: - This is NULL. - Token is NULL. - Token->Message is NULL. - Token->Message->Body is not NULL, - Token->Message->BodyLength is non-zero, and - Token->Message->Data is NULL, but a previous call to - Request()has not been completed successfully. - @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources. - @retval EFI_UNSUPPORTED The HTTP method is not supported in current implementation. -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_HTTP_REQUEST) ( - IN EFI_HTTP_PROTOCOL *This, - IN EFI_HTTP_TOKEN *Token - ); - -/** - Abort an asynchronous HTTP request or response token. - - The Cancel() function aborts a pending HTTP request or response transaction. If - Token is not NULL and the token is in transmit or receive queues when it is being - cancelled, its Token->Status will be set to EFI_ABORTED and then Token->Event will - be signaled. If the token is not in one of the queues, which usually means that the - asynchronous operation has completed, EFI_NOT_FOUND is returned. If Token is NULL, - all asynchronous tokens issued by Request() or Response() will be aborted. - - @param[in] This Pointer to EFI_HTTP_PROTOCOL instance. - @param[in] Token Point to storage containing HTTP request or response - token. - - @retval EFI_SUCCESS Request and Response queues are successfully flushed. - @retval EFI_INVALID_PARAMETER This is NULL. - @retval EFI_NOT_STARTED This instance hasn't been configured. - @retval EFI_NOT_FOUND The asynchronous request or response token is not - found. - @retval EFI_UNSUPPORTED The implementation does not support this function. -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_HTTP_CANCEL)( - IN EFI_HTTP_PROTOCOL *This, - IN EFI_HTTP_TOKEN *Token - ); - -/** - The Response() function queues an HTTP response to this HTTP instance, similar to - Receive() function in the EFI TCP driver. When the HTTP Response is received successfully, - or if there is an error, Status in token will be updated and Event will be signaled. - - The HTTP driver will queue a receive token to the underlying TCP instance. When data - is received in the underlying TCP instance, the data will be parsed and Token will - be populated with the response data. If the data received from the remote host - contains an incomplete or invalid HTTP header, the HTTP driver will continue waiting - (asynchronously) for more data to be sent from the remote host before signaling - Event in Token. - - It is the responsibility of the caller to allocate a buffer for Body and specify the - size in BodyLength. If the remote host provides a response that contains a content - body, up to BodyLength bytes will be copied from the receive buffer into Body and - BodyLength will be updated with the amount of bytes received and copied to Body. This - allows the client to download a large file in chunks instead of into one contiguous - block of memory. Similar to HTTP request, if Body is not NULL and BodyLength is - non-zero and all other fields are NULL or 0, the HTTP driver will queue a receive - token to underlying TCP instance. If data arrives in the receive buffer, up to - BodyLength bytes of data will be copied to Body. The HTTP driver will then update - BodyLength with the amount of bytes received and copied to Body. - - If the HTTP driver does not have an open underlying TCP connection with the host - specified in the response URL, Request() will return EFI_ACCESS_DENIED. This is - consistent with RFC 2616 recommendation that HTTP clients should attempt to maintain - an open TCP connection between client and host. - - @param[in] This Pointer to EFI_HTTP_PROTOCOL instance. - @param[in] Token Pointer to storage containing HTTP response token. - - @retval EFI_SUCCESS Allocation succeeded. - @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been - initialized. - @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: - This is NULL. - Token is NULL. - Token->Message->Headers is NULL. - Token->Message is NULL. - Token->Message->Body is not NULL, - Token->Message->BodyLength is non-zero, and - Token->Message->Data is NULL, but a previous call to - Response() has not been completed successfully. - @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources. - @retval EFI_ACCESS_DENIED An open TCP connection is not present with the host - specified by response URL. -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_HTTP_RESPONSE) ( - IN EFI_HTTP_PROTOCOL *This, - IN EFI_HTTP_TOKEN *Token - ); - -/** - The Poll() function can be used by network drivers and applications to increase the - rate that data packets are moved between the communication devices and the transmit - and receive queues. - - In some systems, the periodic timer event in the managed network driver may not poll - the underlying communications device fast enough to transmit and/or receive all data - packets without missing incoming packets or dropping outgoing packets. Drivers and - applications that are experiencing packet loss should try calling the Poll() function - more often. - - @param[in] This Pointer to EFI_HTTP_PROTOCOL instance. - - @retval EFI_SUCCESS Incoming or outgoing data was processed.. - @retval EFI_DEVICE_ERROR An unexpected system or network error occurred - @retval EFI_INVALID_PARAMETER This is NULL. - @retval EFI_NOT_READY No incoming or outgoing data is processed. - @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started. -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_HTTP_POLL) ( - IN EFI_HTTP_PROTOCOL *This - ); - -/// -/// The EFI HTTP protocol is designed to be used by EFI drivers and applications to -/// create and transmit HTTP Requests, as well as handle HTTP responses that are -/// returned by a remote host. This EFI protocol uses and relies on an underlying EFI -/// TCP protocol. -/// -struct _EFI_HTTP_PROTOCOL { - EFI_HTTP_GET_MODE_DATA GetModeData; - EFI_HTTP_CONFIGURE Configure; - EFI_HTTP_REQUEST Request; - EFI_HTTP_CANCEL Cancel; - EFI_HTTP_RESPONSE Response; - EFI_HTTP_POLL Poll; -}; - -#endif /* SHIM_HTTP_H */ diff --git a/include/Ip4Config2.h b/include/Ip4Config2.h deleted file mode 100644 index efacaf83..00000000 --- a/include/Ip4Config2.h +++ /dev/null @@ -1,310 +0,0 @@ -/** @file - This file provides a definition of the EFI IPv4 Configuration II - Protocol. - -Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -@par Revision Reference: -This Protocol is introduced in UEFI Specification 2.5 - -**/ -#ifndef SHIM_IP4CONFIG2_H -#define SHIM_IP4CONFIG2_H - -#include - -typedef struct _EFI_IP4_CONFIG2_PROTOCOL EFI_IP4_CONFIG2_PROTOCOL; - - -/// -/// EFI_IP4_CONFIG2_DATA_TYPE -/// -typedef enum { - /// - /// The interface information of the communication device this EFI - /// IPv4 Configuration II Protocol instance manages. This type of - /// data is read only. The corresponding Data is of type - /// EFI_IP4_CONFIG2_INTERFACE_INFO. - /// - Ip4Config2DataTypeInterfaceInfo, - /// - /// The general configuration policy for the EFI IPv4 network stack - /// running on the communication device this EFI IPv4 - /// Configuration II Protocol instance manages. The policy will - /// affect other configuration settings. The corresponding Data is of - /// type EFI_IP4_CONFIG2_POLICY. - /// - Ip4Config2DataTypePolicy, - /// - /// The station addresses set manually for the EFI IPv4 network - /// stack. It is only configurable when the policy is - /// Ip4Config2PolicyStatic. The corresponding Data is of - /// type EFI_IP4_CONFIG2_MANUAL_ADDRESS. - /// - Ip4Config2DataTypeManualAddress, - /// - /// The gateway addresses set manually for the EFI IPv4 network - /// stack running on the communication device this EFI IPv4 - /// Configuration II Protocol manages. It is not configurable when - /// the policy is Ip4Config2PolicyDhcp. The gateway - /// addresses must be unicast IPv4 addresses. The corresponding - /// Data is a pointer to an array of EFI_IPv4_ADDRESS instances. - /// - Ip4Config2DataTypeGateway, - /// - /// The DNS server list for the EFI IPv4 network stack running on - /// the communication device this EFI IPv4 Configuration II - /// Protocol manages. It is not configurable when the policy is - /// Ip4Config2PolicyDhcp. The DNS server addresses must be - /// unicast IPv4 addresses. The corresponding Data is a pointer to - /// an array of EFI_IPv4_ADDRESS instances. - /// - Ip4Config2DataTypeDnsServer, - Ip4Config2DataTypeMaximum -} EFI_IP4_CONFIG2_DATA_TYPE; - -/// -/// EFI_IP4_CONFIG2_INTERFACE_INFO related definitions -/// -#define EFI_IP4_CONFIG2_INTERFACE_INFO_NAME_SIZE 32 - -/// -/// EFI_IP4_CONFIG2_INTERFACE_INFO -/// -typedef struct { - /// - /// The name of the interface. It is a NULL-terminated Unicode string. - /// - CHAR16 Name[EFI_IP4_CONFIG2_INTERFACE_INFO_NAME_SIZE]; - /// - /// The interface type of the network interface. See RFC 1700, - /// section "Number Hardware Type". - /// - UINT8 IfType; - /// - /// The size, in bytes, of the network interface's hardware address. - /// - UINT32 HwAddressSize; - /// - /// The hardware address for the network interface. - /// - EFI_MAC_ADDRESS HwAddress; - /// - /// The station IPv4 address of this EFI IPv4 network stack. - /// - EFI_IPv4_ADDRESS StationAddress; - /// - /// The subnet address mask that is associated with the station address. - /// - EFI_IPv4_ADDRESS SubnetMask; - /// - /// Size of the following RouteTable, in bytes. May be zero. - /// - UINT32 RouteTableSize; - /// - /// The route table of the IPv4 network stack runs on this interface. - /// Set to NULL if RouteTableSize is zero. Type EFI_IP4_ROUTE_TABLE is defined in - /// EFI_IP4_PROTOCOL.GetModeData(). - /// - EFI_IP4_ROUTE_TABLE *RouteTable OPTIONAL; -} EFI_IP4_CONFIG2_INTERFACE_INFO; - -/// -/// EFI_IP4_CONFIG2_POLICY -/// -typedef enum { - /// - /// Under this policy, the Ip4Config2DataTypeManualAddress, - /// Ip4Config2DataTypeGateway and Ip4Config2DataTypeDnsServer configuration - /// data are required to be set manually. The EFI IPv4 Protocol will get all - /// required configuration such as IPv4 address, subnet mask and - /// gateway settings from the EFI IPv4 Configuration II protocol. - /// - Ip4Config2PolicyStatic, - /// - /// Under this policy, the Ip4Config2DataTypeManualAddress, - /// Ip4Config2DataTypeGateway and Ip4Config2DataTypeDnsServer configuration data are - /// not allowed to set via SetData(). All of these configurations are retrieved from DHCP - /// server or other auto-configuration mechanism. - /// - Ip4Config2PolicyDhcp, - Ip4Config2PolicyMax -} EFI_IP4_CONFIG2_POLICY; - -/// -/// EFI_IP4_CONFIG2_MANUAL_ADDRESS -/// -typedef struct { - /// - /// The IPv4 unicast address. - /// - EFI_IPv4_ADDRESS Address; - /// - /// The subnet mask. - /// - EFI_IPv4_ADDRESS SubnetMask; -} EFI_IP4_CONFIG2_MANUAL_ADDRESS; - -/** - Set the configuration for the EFI IPv4 network stack running on the communication device this EFI - IPv4 Configuration II Protocol instance manages. - - This function is used to set the configuration data of type DataType for the EFI IPv4 network stack - running on the communication device this EFI IPv4 Configuration II Protocol instance manages. - The successfully configured data is valid after system reset or power-off. - The DataSize is used to calculate the count of structure instances in the Data for some - DataType that multiple structure instances are allowed. - This function is always non-blocking. When setting some typeof configuration data, an - asynchronous process is invoked to check the correctness of the data, such as doing address conflict - detection on the manually set local IPv4 address. EFI_NOT_READY is returned immediately to - indicate that such an asynchronous process is invoked and the process is not finished yet. The caller - willing to get the result of the asynchronous process is required to call RegisterDataNotify() - to register an event on the specified configuration data. Once the event is signaled, the caller can call - GetData()to get back the configuration data in order to know the result. For other types of - configuration data that do not require an asynchronous configuration process, the result of the - operation is immediately returned. - - @param[in] This Pointer to the EFI_IP4_CONFIG2_PROTOCOL instance. - @param[in] DataType The type of data to set. - @param[in] DataSize Size of the buffer pointed to by Data in bytes. - @param[in] Data The data buffer to set. The type ofthe data buffer is associated - with the DataType. - - @retval EFI_SUCCESS The specified configuration data for the EFI IPv4 network stack is set - successfully. - @retval EFI_INVALID_PARAMETER One or more of the following are TRUE: - This is NULL. - Data is NULL. - One or more fields in Data do not match the requirement of the data type - indicated by DataType. - @retval EFI_WRITE_PROTECTED The specified configuration data is read-only or the specified configuration - data can not be set under the current policy. - @retval EFI_ACCESS_DENIED Another set operation on the specified configuration data is already in process. - @retval EFI_NOT_READY An asynchronous process is invoked to set the specified configuration data and - the process is not finished yet. - @retval EFI_BAD_BUFFER_SIZE The DataSize does not match the size of the type indicated by DataType. - @retval EFI_UNSUPPORTED This DataType is not supported. - @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. - @retval EFI_DEVICE_ERROR An unexpected system error or network error occurred. -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_IP4_CONFIG2_SET_DATA) ( - IN EFI_IP4_CONFIG2_PROTOCOL *This, - IN EFI_IP4_CONFIG2_DATA_TYPE DataType, - IN UINTN DataSize, - IN VOID *Data - ); - -/** - Get the configuration data for the EFI IPv4 network stack running on the communication device this - EFI IPv4 Configuration II Protocol instance manages. - - This function returns the configuration data of type DataType for the EFI IPv4 network stack - running on the communication device this EFI IPv4 Configuration II Protocol instance manages. - The caller is responsible for allocating the buffer usedto return the specified configuration data and - the required size will be returned to the caller if the size of the buffer is too small. - EFI_NOT_READY is returned if the specified configuration data is not ready due to an already in - progress asynchronous configuration process. The caller can call RegisterDataNotify() to - register an event on the specified configuration data. Once the asynchronous configuration process is - finished, the event will be signaled and a subsequent GetData() call will return the specified - configuration data. - - @param[in] This Pointer to the EFI_IP4_CONFIG2_PROTOCOL instance. - @param[in] DataType The type of data to get. - @param[out] DataSize On input, in bytes, the size of Data. On output, in bytes, the size - of buffer required to store the specified configuration data. - @param[in] Data The data buffer in which the configuration data is returned. The - type of the data buffer is associated with the DataType. Ignored - if DataSize is 0. - - @retval EFI_SUCCESS The specified configuration data is got successfully. - @retval EFI_INVALID_PARAMETER One or more of the followings are TRUE: - This is NULL. - DataSize is NULL. - Data is NULL if *DataSizeis not zero. - @retval EFI_BUFFER_TOO_SMALL The size of Data is too small for the specified configuration data - and the required size is returned in DataSize. - @retval EFI_NOT_READY The specified configuration data is not ready due to an already in - progress asynchronous configuration process. - @retval EFI_NOT_FOUND The specified configuration data is not found. -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_IP4_CONFIG2_GET_DATA) ( - IN EFI_IP4_CONFIG2_PROTOCOL *This, - IN EFI_IP4_CONFIG2_DATA_TYPE DataType, - IN OUT UINTN *DataSize, - IN VOID *Data OPTIONAL - ); - -/** - Register an event that is to be signaled whenever a configuration process on the specified - configuration data is done. - - This function registers an event that is to be signaled whenever a configuration process on the - specified configuration data is done. An event can be registered for different DataType - simultaneously and the caller is responsible for determining which type of configuration data causes - the signaling of the event in such case. - - @param[in] This Pointer to the EFI_IP4_CONFIG2_PROTOCOL instance. - @param[in] DataType The type of data to unregister the event for. - @param[in] Event The event to register. - - @retval EFI_SUCCESS The notification event for the specified configuration data is - registered. - @retval EFI_INVALID_PARAMETER This is NULL or Event is NULL. - @retval EFI_UNSUPPORTED The configuration data type specified by DataType is not supported. - @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. - @retval EFI_ACCESS_DENIED The Event is already registered for the DataType. -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_IP4_CONFIG2_REGISTER_NOTIFY) ( - IN EFI_IP4_CONFIG2_PROTOCOL *This, - IN EFI_IP4_CONFIG2_DATA_TYPE DataType, - IN EFI_EVENT Event - ); - -/** - Remove a previously registered event for the specified configuration data. - - This function removes a previously registeredevent for the specified configuration data. - - @param[in] This Pointer to the EFI_IP4_CONFIG2_PROTOCOL instance. - @param[in] DataType The type of data to remove the previously registered event for. - @param[in] Event The event to unregister. - - @retval EFI_SUCCESS The event registered for the specified configuration data is removed. - @retval EFI_INVALID_PARAMETER This is NULL or Event is NULL. - @retval EFI_NOT_FOUND The Eventhas not been registered for the specified DataType. -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_IP4_CONFIG2_UNREGISTER_NOTIFY) ( - IN EFI_IP4_CONFIG2_PROTOCOL *This, - IN EFI_IP4_CONFIG2_DATA_TYPE DataType, - IN EFI_EVENT Event - ); - -/// -/// The EFI_IP4_CONFIG2_PROTOCOL is designed to be the central repository for the common -/// configurations and the administrator configurable settings for the EFI IPv4 network stack. -/// An EFI IPv4 Configuration II Protocol instance will be installed on each communication device that -/// the EFI IPv4 network stack runs on. -/// -struct _EFI_IP4_CONFIG2_PROTOCOL { - EFI_IP4_CONFIG2_SET_DATA SetData; - EFI_IP4_CONFIG2_GET_DATA GetData; - EFI_IP4_CONFIG2_REGISTER_NOTIFY RegisterDataNotify; - EFI_IP4_CONFIG2_UNREGISTER_NOTIFY UnregisterDataNotify; -}; - -#endif /* SHIM_IP4CONFIG2_H */ diff --git a/include/Ip6Config.h b/include/Ip6Config.h deleted file mode 100644 index f99ce013..00000000 --- a/include/Ip6Config.h +++ /dev/null @@ -1,361 +0,0 @@ -/** @file - This file provides a definition of the EFI IPv6 Configuration - Protocol. - -Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ -#ifndef SHIM_IP6CONFIG_H -#define SHIM_IP6CONFIG_H - -#include - -typedef struct _EFI_IP6_CONFIG_PROTOCOL EFI_IP6_CONFIG_PROTOCOL; - -/// -/// EFI_IP6_CONFIG_DATA_TYPE -/// -typedef enum { - /// - /// The interface information of the communication - /// device this EFI IPv6 Configuration Protocol instance manages. - /// This type of data is read only.The corresponding Data is of type - /// EFI_IP6_CONFIG_INTERFACE_INFO. - /// - Ip6ConfigDataTypeInterfaceInfo, - /// - /// The alternative interface ID for the - /// communication device this EFI IPv6 Configuration Protocol - /// instance manages if the link local IPv6 address generated from - /// the interfaced ID based on the default source the EFI IPv6 - /// Protocol uses is a duplicate address. The length of the interface - /// ID is 64 bit. The corresponding Data is of type - /// EFI_IP6_CONFIG_INTERFACE_ID. - /// - Ip6ConfigDataTypeAltInterfaceId, - /// - /// The general configuration policy for the EFI IPv6 network - /// stack running on the communication device this EFI IPv6 - /// Configuration Protocol instance manages. The policy will affect - /// other configuration settings. The corresponding Data is of type - /// EFI_IP6_CONFIG_POLICY. - /// - Ip6ConfigDataTypePolicy, - /// - /// The number of consecutive - /// Neighbor Solicitation messages sent while performing Duplicate - /// Address Detection on a tentative address. A value of zero - /// indicates that Duplicate Address Detection will not be performed - /// on tentative addresses. The corresponding Data is of type - /// EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS. - /// - Ip6ConfigDataTypeDupAddrDetectTransmits, - /// - /// The station addresses set manually for the EFI - /// IPv6 network stack. It is only configurable when the policy is - /// Ip6ConfigPolicyManual. The corresponding Data is a - /// pointer to an array of EFI_IPv6_ADDRESS instances. - /// - Ip6ConfigDataTypeManualAddress, - /// - /// The gateway addresses set manually for the EFI IPv6 - /// network stack running on the communication device this EFI - /// IPv6 Configuration Protocol manages. It is not configurable when - /// the policy is Ip6ConfigPolicyAutomatic. The gateway - /// addresses must be unicast IPv6 addresses. The corresponding - /// Data is a pointer to an array of EFI_IPv6_ADDRESS instances. - /// - Ip6ConfigDataTypeGateway, - /// - /// The DNS server list for the EFI IPv6 network stack - /// running on the communication device this EFI IPv6 - /// Configuration Protocol manages. It is not configurable when the - /// policy is Ip6ConfigPolicyAutomatic.The DNS server - /// addresses must be unicast IPv6 addresses. The corresponding - /// Data is a pointer to an array of EFI_IPv6_ADDRESS instances. - /// - Ip6ConfigDataTypeDnsServer, - /// - /// The number of this enumeration memebers. - /// - Ip6ConfigDataTypeMaximum -} EFI_IP6_CONFIG_DATA_TYPE; - -/// -/// EFI_IP6_CONFIG_INTERFACE_INFO -/// describes the operational state of the interface this -/// EFI IPv6 Configuration Protocol instance manages. -/// -typedef struct { - /// - /// The name of the interface. It is a NULL-terminated string. - /// - CHAR16 Name[32]; - /// - /// The interface type of the network interface. - /// - UINT8 IfType; - /// - /// The size, in bytes, of the network interface's hardware address. - /// - UINT32 HwAddressSize; - /// - /// The hardware address for the network interface. - /// - EFI_MAC_ADDRESS HwAddress; - /// - /// Number of EFI_IP6_ADDRESS_INFO structures pointed to by AddressInfo. - /// - UINT32 AddressInfoCount; - /// - /// Pointer to an array of EFI_IP6_ADDRESS_INFO instances - /// which contain the local IPv6 addresses and the corresponding - /// prefix length information. Set to NULL if AddressInfoCount - /// is zero. - /// - EFI_IP6_ADDRESS_INFO *AddressInfo; - /// - /// Number of route table entries in the following RouteTable. - /// - UINT32 RouteCount; - /// - /// The route table of the IPv6 network stack runs on this interface. - /// Set to NULL if RouteCount is zero. - /// - EFI_IP6_ROUTE_TABLE *RouteTable; -} EFI_IP6_CONFIG_INTERFACE_INFO; - -/// -/// EFI_IP6_CONFIG_INTERFACE_ID -/// describes the 64-bit interface ID. -/// -typedef struct { - UINT8 Id[8]; -} EFI_IP6_CONFIG_INTERFACE_ID; - -/// -/// EFI_IP6_CONFIG_POLICY -/// defines the general configuration policy the EFI IPv6 -/// Configuration Protocol supports. -/// -typedef enum { - /// - /// Under this policy, the IpI6ConfigDataTypeManualAddress, - /// Ip6ConfigDataTypeGateway and Ip6ConfigDataTypeDnsServer - /// configuration data are required to be set manually. - /// The EFI IPv6 Protocol will get all required configuration - /// such as address, prefix and gateway settings from the EFI - /// IPv6 Configuration protocol. - /// - Ip6ConfigPolicyManual, - /// - /// Under this policy, the IpI6ConfigDataTypeManualAddress, - /// Ip6ConfigDataTypeGateway and Ip6ConfigDataTypeDnsServer - /// configuration data are not allowed to set via SetData(). - /// All of these configurations are retrieved from some auto - /// configuration mechanism. - /// The EFI IPv6 Protocol will use the IPv6 stateless address - /// autoconfiguration mechanism and/or the IPv6 stateful address - /// autoconfiguration mechanism described in the related RFCs to - /// get address and other configuration information - /// - Ip6ConfigPolicyAutomatic -} EFI_IP6_CONFIG_POLICY; - -/// -/// EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS -/// describes the number of consecutive Neighbor Solicitation messages sent -/// while performing Duplicate Address Detection on a tentative address. -/// The default value for a newly detected communication device is 1. -/// -typedef struct { - UINT32 DupAddrDetectTransmits; ///< The number of consecutive Neighbor Solicitation messages sent. -} EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS; - -/// -/// EFI_IP6_CONFIG_MANUAL_ADDRESS -/// is used to set the station address information for the EFI IPv6 network -/// stack manually when the policy is Ip6ConfigPolicyManual. -/// -typedef struct { - EFI_IPv6_ADDRESS Address; ///< The IPv6 unicast address. - BOOLEAN IsAnycast; ///< Set to TRUE if Address is anycast. - UINT8 PrefixLength; ///< The length, in bits, of the prefix associated with this Address. -} EFI_IP6_CONFIG_MANUAL_ADDRESS; - - -/** - Set the configuration for the EFI IPv6 network stack running on the communication - device this EFI IPv6 Configuration Protocol instance manages. - - This function is used to set the configuration data of type DataType for the EFI - IPv6 network stack running on the communication device this EFI IPv6 Configuration - Protocol instance manages. - - The DataSize is used to calculate the count of structure instances in the Data for - some DataType that multiple structure instances are allowed. - - This function is always non-blocking. When setting some type of configuration data, - an asynchronous process is invoked to check the correctness of the data, such as - doing Duplicate Address Detection on the manually set local IPv6 addresses. - EFI_NOT_READY is returned immediately to indicate that such an asynchronous process - is invoked and the process is not finished yet. The caller willing to get the result - of the asynchronous process is required to call RegisterDataNotify() to register an - event on the specified configuration data. Once the event is signaled, the caller - can call GetData() to get back the configuration data in order to know the result. - For other types of configuration data that do not require an asynchronous configuration - process, the result of the operation is immediately returned. - - @param[in] This Pointer to the EFI_IP6_CONFIG_PROTOCOL instance. - @param[in] DataType The type of data to set. - @param[in] DataSize Size of the buffer pointed to by Data in bytes. - @param[in] Data The data buffer to set. The type of the data buffer is - associated with the DataType. - - @retval EFI_SUCCESS The specified configuration data for the EFI IPv6 - network stack is set successfully. - @retval EFI_INVALID_PARAMETER One or more of the following are TRUE: - - This is NULL. - - Data is NULL. - - One or more fields in Data do not match the requirement of the - data type indicated by DataType. - @retval EFI_WRITE_PROTECTED The specified configuration data is read-only or the specified - configuration data can not be set under the current policy - @retval EFI_ACCESS_DENIED Another set operation on the specified configuration - data is already in process. - @retval EFI_NOT_READY An asynchronous process is invoked to set the specified - configuration data and the process is not finished yet. - @retval EFI_BAD_BUFFER_SIZE The DataSize does not match the size of the type - indicated by DataType. - @retval EFI_UNSUPPORTED This DataType is not supported. - @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. - @retval EFI_DEVICE_ERROR An unexpected system error or network error occurred. - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_IP6_CONFIG_SET_DATA)( - IN EFI_IP6_CONFIG_PROTOCOL *This, - IN EFI_IP6_CONFIG_DATA_TYPE DataType, - IN UINTN DataSize, - IN VOID *Data - ); - -/** - Get the configuration data for the EFI IPv6 network stack running on the communication - device this EFI IPv6 Configuration Protocol instance manages. - - This function returns the configuration data of type DataType for the EFI IPv6 network - stack running on the communication device this EFI IPv6 Configuration Protocol instance - manages. - - The caller is responsible for allocating the buffer used to return the specified - configuration data and the required size will be returned to the caller if the size of - the buffer is too small. - - EFI_NOT_READY is returned if the specified configuration data is not ready due to an - already in progress asynchronous configuration process. The caller can call RegisterDataNotify() - to register an event on the specified configuration data. Once the asynchronous configuration - process is finished, the event will be signaled and a subsequent GetData() call will return - the specified configuration data. - - @param[in] This Pointer to the EFI_IP6_CONFIG_PROTOCOL instance. - @param[in] DataType The type of data to get. - @param[in,out] DataSize On input, in bytes, the size of Data. On output, in bytes, the - size of buffer required to store the specified configuration data. - @param[in] Data The data buffer in which the configuration data is returned. The - type of the data buffer is associated with the DataType. - - @retval EFI_SUCCESS The specified configuration data is got successfully. - @retval EFI_INVALID_PARAMETER One or more of the followings are TRUE: - - This is NULL. - - DataSize is NULL. - - Data is NULL if *DataSize is not zero. - @retval EFI_BUFFER_TOO_SMALL The size of Data is too small for the specified configuration data - and the required size is returned in DataSize. - @retval EFI_NOT_READY The specified configuration data is not ready due to an already in - progress asynchronous configuration process. - @retval EFI_NOT_FOUND The specified configuration data is not found. - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_IP6_CONFIG_GET_DATA)( - IN EFI_IP6_CONFIG_PROTOCOL *This, - IN EFI_IP6_CONFIG_DATA_TYPE DataType, - IN OUT UINTN *DataSize, - IN VOID *Data OPTIONAL - ); - -/** - Register an event that is to be signaled whenever a configuration process on the specified - configuration data is done. - - This function registers an event that is to be signaled whenever a configuration process - on the specified configuration data is done. An event can be registered for different DataType - simultaneously and the caller is responsible for determining which type of configuration data - causes the signaling of the event in such case. - - @param[in] This Pointer to the EFI_IP6_CONFIG_PROTOCOL instance. - @param[in] DataType The type of data to unregister the event for. - @param[in] Event The event to register. - - @retval EFI_SUCCESS The notification event for the specified configuration data is - registered. - @retval EFI_INVALID_PARAMETER This is NULL or Event is NULL. - @retval EFI_UNSUPPORTED The configuration data type specified by DataType is not - supported. - @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. - @retval EFI_ACCESS_DENIED The Event is already registered for the DataType. - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_IP6_CONFIG_REGISTER_NOTIFY)( - IN EFI_IP6_CONFIG_PROTOCOL *This, - IN EFI_IP6_CONFIG_DATA_TYPE DataType, - IN EFI_EVENT Event - ); - -/** - Remove a previously registered event for the specified configuration data. - - This function removes a previously registered event for the specified configuration data. - - @param[in] This Pointer to the EFI_IP6_CONFIG_PROTOCOL instance. - @param[in] DataType The type of data to remove the previously registered event for. - @param[in] Event The event to unregister. - - @retval EFI_SUCCESS The event registered for the specified configuration data is removed. - @retval EFI_INVALID_PARAMETER This is NULL or Event is NULL. - @retval EFI_NOT_FOUND The Event has not been registered for the specified - DataType. - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_IP6_CONFIG_UNREGISTER_NOTIFY)( - IN EFI_IP6_CONFIG_PROTOCOL *This, - IN EFI_IP6_CONFIG_DATA_TYPE DataType, - IN EFI_EVENT Event - ); - -/// -/// The EFI_IP6_CONFIG_PROTOCOL provides the mechanism to set and get various -/// types of configurations for the EFI IPv6 network stack. -/// -struct _EFI_IP6_CONFIG_PROTOCOL { - EFI_IP6_CONFIG_SET_DATA SetData; - EFI_IP6_CONFIG_GET_DATA GetData; - EFI_IP6_CONFIG_REGISTER_NOTIFY RegisterDataNotify; - EFI_IP6_CONFIG_UNREGISTER_NOTIFY UnregisterDataNotify; -}; - -#endif /* SHIM_IP6CONFIG_H */ diff --git a/include/PasswordCrypt.h b/include/PasswordCrypt.h deleted file mode 100644 index cadad727..00000000 --- a/include/PasswordCrypt.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef SHIM_PASSWORDCRYPT_H -#define SHIM_PASSWORDCRYPT_H - -enum HashMethod { - TRADITIONAL_DES = 0, - EXTEND_BSDI_DES, - MD5_BASED, - SHA256_BASED, - SHA512_BASED, - BLOWFISH_BASED -}; - -typedef struct { - UINT16 method; - UINT64 iter_count; - UINT16 salt_size; - UINT8 salt[32]; - UINT8 hash[128]; -} __attribute__ ((packed)) PASSWORD_CRYPT; - -#define PASSWORD_CRYPT_SIZE sizeof(PASSWORD_CRYPT) - -EFI_STATUS password_crypt (const char *password, UINT32 pw_length, - const PASSWORD_CRYPT *pw_hash, UINT8 *hash); -UINT16 get_hash_size (const UINT16 method); - -#endif /* SHIM_PASSWORDCRYPT_H */ diff --git a/include/PeImage.h b/include/PeImage.h deleted file mode 100644 index 209b96fb..00000000 --- a/include/PeImage.h +++ /dev/null @@ -1,790 +0,0 @@ -/** @file - EFI image format for PE32, PE32+ and TE. Please note some data structures are - different for PE32 and PE32+. EFI_IMAGE_NT_HEADERS32 is for PE32 and - EFI_IMAGE_NT_HEADERS64 is for PE32+. - - This file is coded to the Visual Studio, Microsoft Portable Executable and - Common Object File Format Specification, Revision 8.0 - May 16, 2006. - This file also includes some definitions in PI Specification, Revision 1.0. - -Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
-Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php. - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef SHIM_PEIMAGE_H -#define SHIM_PEIMAGE_H - -#include - -#define SIGNATURE_16(A, B) ((A) | (B << 8)) -#define SIGNATURE_32(A, B, C, D) (SIGNATURE_16 (A, B) | (SIGNATURE_16 (C, D) << 16)) -#define SIGNATURE_64(A, B, C, D, E, F, G, H) \ - (SIGNATURE_32 (A, B, C, D) | ((UINT64) (SIGNATURE_32 (E, F, G, H)) << 32)) - -#define ALIGN_VALUE(Value, Alignment) ((Value) + (((Alignment) - (Value)) & ((Alignment) - 1))) -#define ALIGN_POINTER(Pointer, Alignment) ((VOID *) (ALIGN_VALUE ((UINTN)(Pointer), (Alignment)))) - -// -// PE32+ Subsystem type for EFI images -// -#define EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION 10 -#define EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11 -#define EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12 -#define EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER 13 ///< defined PI Specification, 1.0 - - -// -// PE32+ Machine type for EFI images -// -#define IMAGE_FILE_MACHINE_I386 0x014c -#define IMAGE_FILE_MACHINE_IA64 0x0200 -#define IMAGE_FILE_MACHINE_EBC 0x0EBC -#define IMAGE_FILE_MACHINE_X64 0x8664 -#define IMAGE_FILE_MACHINE_ARMTHUMB_MIXED 0x01c2 -#define IMAGE_FILE_MACHINE_ARM64 0xaa64 - -// -// EXE file formats -// -#define EFI_IMAGE_DOS_SIGNATURE SIGNATURE_16('M', 'Z') -#define EFI_IMAGE_OS2_SIGNATURE SIGNATURE_16('N', 'E') -#define EFI_IMAGE_OS2_SIGNATURE_LE SIGNATURE_16('L', 'E') -#define EFI_IMAGE_NT_SIGNATURE SIGNATURE_32('P', 'E', '\0', '\0') - -/// -/// PE images can start with an optional DOS header, so if an image is run -/// under DOS it can print an error message. -/// -typedef struct { - UINT16 e_magic; ///< Magic number. - UINT16 e_cblp; ///< Bytes on last page of file. - UINT16 e_cp; ///< Pages in file. - UINT16 e_crlc; ///< Relocations. - UINT16 e_cparhdr; ///< Size of header in paragraphs. - UINT16 e_minalloc; ///< Minimum extra paragraphs needed. - UINT16 e_maxalloc; ///< Maximum extra paragraphs needed. - UINT16 e_ss; ///< Initial (relative) SS value. - UINT16 e_sp; ///< Initial SP value. - UINT16 e_csum; ///< Checksum. - UINT16 e_ip; ///< Initial IP value. - UINT16 e_cs; ///< Initial (relative) CS value. - UINT16 e_lfarlc; ///< File address of relocation table. - UINT16 e_ovno; ///< Overlay number. - UINT16 e_res[4]; ///< Reserved words. - UINT16 e_oemid; ///< OEM identifier (for e_oeminfo). - UINT16 e_oeminfo; ///< OEM information; e_oemid specific. - UINT16 e_res2[10]; ///< Reserved words. - UINT32 e_lfanew; ///< File address of new exe header. -} EFI_IMAGE_DOS_HEADER; - -/// -/// COFF File Header (Object and Image). -/// -typedef struct { - UINT16 Machine; - UINT16 NumberOfSections; - UINT32 TimeDateStamp; - UINT32 PointerToSymbolTable; - UINT32 NumberOfSymbols; - UINT16 SizeOfOptionalHeader; - UINT16 Characteristics; -} EFI_IMAGE_FILE_HEADER; - -/// -/// Size of EFI_IMAGE_FILE_HEADER. -/// -#define EFI_IMAGE_SIZEOF_FILE_HEADER 20 - -// -// Characteristics -// -#define EFI_IMAGE_FILE_RELOCS_STRIPPED (1 << 0) ///< 0x0001 Relocation info stripped from file. -#define EFI_IMAGE_FILE_EXECUTABLE_IMAGE (1 << 1) ///< 0x0002 File is executable (i.e. no unresolved externel references). -#define EFI_IMAGE_FILE_LINE_NUMS_STRIPPED (1 << 2) ///< 0x0004 Line nunbers stripped from file. -#define EFI_IMAGE_FILE_LOCAL_SYMS_STRIPPED (1 << 3) ///< 0x0008 Local symbols stripped from file. -#define EFI_IMAGE_FILE_BYTES_REVERSED_LO (1 << 7) ///< 0x0080 Bytes of machine word are reversed. -#define EFI_IMAGE_FILE_32BIT_MACHINE (1 << 8) ///< 0x0100 32 bit word machine. -#define EFI_IMAGE_FILE_DEBUG_STRIPPED (1 << 9) ///< 0x0200 Debugging info stripped from file in .DBG file. -#define EFI_IMAGE_FILE_SYSTEM (1 << 12) ///< 0x1000 System File. -#define EFI_IMAGE_FILE_DLL (1 << 13) ///< 0x2000 File is a DLL. -#define EFI_IMAGE_FILE_BYTES_REVERSED_HI (1 << 15) ///< 0x8000 Bytes of machine word are reversed. - -/// -/// Header Data Directories. -/// -typedef struct { - UINT32 VirtualAddress; - UINT32 Size; -} EFI_IMAGE_DATA_DIRECTORY; - -// -// Directory Entries -// -#define EFI_IMAGE_DIRECTORY_ENTRY_EXPORT 0 -#define EFI_IMAGE_DIRECTORY_ENTRY_IMPORT 1 -#define EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE 2 -#define EFI_IMAGE_DIRECTORY_ENTRY_EXCEPTION 3 -#define EFI_IMAGE_DIRECTORY_ENTRY_SECURITY 4 -#define EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC 5 -#define EFI_IMAGE_DIRECTORY_ENTRY_DEBUG 6 -#define EFI_IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7 -#define EFI_IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 -#define EFI_IMAGE_DIRECTORY_ENTRY_TLS 9 -#define EFI_IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10 - -#define EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES 16 - -/// -/// @attention -/// EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC means PE32 and -/// EFI_IMAGE_OPTIONAL_HEADER32 must be used. The data structures only vary -/// after NT additional fields. -/// -#define EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b - -/// -/// Optional Header Standard Fields for PE32. -/// -typedef struct { - /// - /// Standard fields. - /// - UINT16 Magic; - UINT8 MajorLinkerVersion; - UINT8 MinorLinkerVersion; - UINT32 SizeOfCode; - UINT32 SizeOfInitializedData; - UINT32 SizeOfUninitializedData; - UINT32 AddressOfEntryPoint; - UINT32 BaseOfCode; - UINT32 BaseOfData; ///< PE32 contains this additional field, which is absent in PE32+. - /// - /// Optional Header Windows-Specific Fields. - /// - UINT32 ImageBase; - UINT32 SectionAlignment; - UINT32 FileAlignment; - UINT16 MajorOperatingSystemVersion; - UINT16 MinorOperatingSystemVersion; - UINT16 MajorImageVersion; - UINT16 MinorImageVersion; - UINT16 MajorSubsystemVersion; - UINT16 MinorSubsystemVersion; - UINT32 Win32VersionValue; - UINT32 SizeOfImage; - UINT32 SizeOfHeaders; - UINT32 CheckSum; - UINT16 Subsystem; - UINT16 DllCharacteristics; - UINT32 SizeOfStackReserve; - UINT32 SizeOfStackCommit; - UINT32 SizeOfHeapReserve; - UINT32 SizeOfHeapCommit; - UINT32 LoaderFlags; - UINT32 NumberOfRvaAndSizes; - EFI_IMAGE_DATA_DIRECTORY DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES]; -} EFI_IMAGE_OPTIONAL_HEADER32; - -/// -/// @attention -/// EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC means PE32+ and -/// EFI_IMAGE_OPTIONAL_HEADER64 must be used. The data structures only vary -/// after NT additional fields. -/// -#define EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b - -/// -/// Optional Header Standard Fields for PE32+. -/// -typedef struct { - /// - /// Standard fields. - /// - UINT16 Magic; - UINT8 MajorLinkerVersion; - UINT8 MinorLinkerVersion; - UINT32 SizeOfCode; - UINT32 SizeOfInitializedData; - UINT32 SizeOfUninitializedData; - UINT32 AddressOfEntryPoint; - UINT32 BaseOfCode; - /// - /// Optional Header Windows-Specific Fields. - /// - UINT64 ImageBase; - UINT32 SectionAlignment; - UINT32 FileAlignment; - UINT16 MajorOperatingSystemVersion; - UINT16 MinorOperatingSystemVersion; - UINT16 MajorImageVersion; - UINT16 MinorImageVersion; - UINT16 MajorSubsystemVersion; - UINT16 MinorSubsystemVersion; - UINT32 Win32VersionValue; - UINT32 SizeOfImage; - UINT32 SizeOfHeaders; - UINT32 CheckSum; - UINT16 Subsystem; - UINT16 DllCharacteristics; - UINT64 SizeOfStackReserve; - UINT64 SizeOfStackCommit; - UINT64 SizeOfHeapReserve; - UINT64 SizeOfHeapCommit; - UINT32 LoaderFlags; - UINT32 NumberOfRvaAndSizes; - EFI_IMAGE_DATA_DIRECTORY DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES]; -} EFI_IMAGE_OPTIONAL_HEADER64; - - -/// -/// @attention -/// EFI_IMAGE_NT_HEADERS32 is for use ONLY by tools. -/// -typedef struct { - UINT32 Signature; - EFI_IMAGE_FILE_HEADER FileHeader; - EFI_IMAGE_OPTIONAL_HEADER32 OptionalHeader; -} EFI_IMAGE_NT_HEADERS32; - -#define EFI_IMAGE_SIZEOF_NT_OPTIONAL32_HEADER sizeof (EFI_IMAGE_NT_HEADERS32) - -/// -/// @attention -/// EFI_IMAGE_HEADERS64 is for use ONLY by tools. -/// -typedef struct { - UINT32 Signature; - EFI_IMAGE_FILE_HEADER FileHeader; - EFI_IMAGE_OPTIONAL_HEADER64 OptionalHeader; -} EFI_IMAGE_NT_HEADERS64; - -#define EFI_IMAGE_SIZEOF_NT_OPTIONAL64_HEADER sizeof (EFI_IMAGE_NT_HEADERS64) - -// -// Other Windows Subsystem Values -// -#define EFI_IMAGE_SUBSYSTEM_UNKNOWN 0 -#define EFI_IMAGE_SUBSYSTEM_NATIVE 1 -#define EFI_IMAGE_SUBSYSTEM_WINDOWS_GUI 2 -#define EFI_IMAGE_SUBSYSTEM_WINDOWS_CUI 3 -#define EFI_IMAGE_SUBSYSTEM_OS2_CUI 5 -#define EFI_IMAGE_SUBSYSTEM_POSIX_CUI 7 - -/// -/// Length of ShortName. -/// -#define EFI_IMAGE_SIZEOF_SHORT_NAME 8 - -/// -/// Section Table. This table immediately follows the optional header. -/// -typedef struct { - UINT8 Name[EFI_IMAGE_SIZEOF_SHORT_NAME]; - union { - UINT32 PhysicalAddress; - UINT32 VirtualSize; - } Misc; - UINT32 VirtualAddress; - UINT32 SizeOfRawData; - UINT32 PointerToRawData; - UINT32 PointerToRelocations; - UINT32 PointerToLinenumbers; - UINT16 NumberOfRelocations; - UINT16 NumberOfLinenumbers; - UINT32 Characteristics; -} EFI_IMAGE_SECTION_HEADER; - -/// -/// Size of EFI_IMAGE_SECTION_HEADER. -/// -#define EFI_IMAGE_SIZEOF_SECTION_HEADER 40 - -// -// Section Flags Values -// -#define EFI_IMAGE_SCN_TYPE_NO_PAD 0x00000008 ///< Reserved. -#define EFI_IMAGE_SCN_CNT_CODE 0x00000020 -#define EFI_IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040 -#define EFI_IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080 - -#define EFI_IMAGE_SCN_LNK_OTHER 0x00000100 ///< Reserved. -#define EFI_IMAGE_SCN_LNK_INFO 0x00000200 ///< Section contains comments or some other type of information. -#define EFI_IMAGE_SCN_LNK_REMOVE 0x00000800 ///< Section contents will not become part of image. -#define EFI_IMAGE_SCN_LNK_COMDAT 0x00001000 - -#define EFI_IMAGE_SCN_ALIGN_1BYTES 0x00100000 -#define EFI_IMAGE_SCN_ALIGN_2BYTES 0x00200000 -#define EFI_IMAGE_SCN_ALIGN_4BYTES 0x00300000 -#define EFI_IMAGE_SCN_ALIGN_8BYTES 0x00400000 -#define EFI_IMAGE_SCN_ALIGN_16BYTES 0x00500000 -#define EFI_IMAGE_SCN_ALIGN_32BYTES 0x00600000 -#define EFI_IMAGE_SCN_ALIGN_64BYTES 0x00700000 - -#define EFI_IMAGE_SCN_MEM_DISCARDABLE 0x02000000 -#define EFI_IMAGE_SCN_MEM_NOT_CACHED 0x04000000 -#define EFI_IMAGE_SCN_MEM_NOT_PAGED 0x08000000 -#define EFI_IMAGE_SCN_MEM_SHARED 0x10000000 -#define EFI_IMAGE_SCN_MEM_EXECUTE 0x20000000 -#define EFI_IMAGE_SCN_MEM_READ 0x40000000 -#define EFI_IMAGE_SCN_MEM_WRITE 0x80000000 - -/// -/// Size of a Symbol Table Record. -/// -#define EFI_IMAGE_SIZEOF_SYMBOL 18 - -// -// Symbols have a section number of the section in which they are -// defined. Otherwise, section numbers have the following meanings: -// -#define EFI_IMAGE_SYM_UNDEFINED (UINT16) 0 ///< Symbol is undefined or is common. -#define EFI_IMAGE_SYM_ABSOLUTE (UINT16) -1 ///< Symbol is an absolute value. -#define EFI_IMAGE_SYM_DEBUG (UINT16) -2 ///< Symbol is a special debug item. - -// -// Symbol Type (fundamental) values. -// -#define EFI_IMAGE_SYM_TYPE_NULL 0 ///< no type. -#define EFI_IMAGE_SYM_TYPE_VOID 1 ///< no valid type. -#define EFI_IMAGE_SYM_TYPE_CHAR 2 ///< type character. -#define EFI_IMAGE_SYM_TYPE_SHORT 3 ///< type short integer. -#define EFI_IMAGE_SYM_TYPE_INT 4 -#define EFI_IMAGE_SYM_TYPE_LONG 5 -#define EFI_IMAGE_SYM_TYPE_FLOAT 6 -#define EFI_IMAGE_SYM_TYPE_DOUBLE 7 -#define EFI_IMAGE_SYM_TYPE_STRUCT 8 -#define EFI_IMAGE_SYM_TYPE_UNION 9 -#define EFI_IMAGE_SYM_TYPE_ENUM 10 ///< enumeration. -#define EFI_IMAGE_SYM_TYPE_MOE 11 ///< member of enumeration. -#define EFI_IMAGE_SYM_TYPE_BYTE 12 -#define EFI_IMAGE_SYM_TYPE_WORD 13 -#define EFI_IMAGE_SYM_TYPE_UINT 14 -#define EFI_IMAGE_SYM_TYPE_DWORD 15 - -// -// Symbol Type (derived) values. -// -#define EFI_IMAGE_SYM_DTYPE_NULL 0 ///< no derived type. -#define EFI_IMAGE_SYM_DTYPE_POINTER 1 -#define EFI_IMAGE_SYM_DTYPE_FUNCTION 2 -#define EFI_IMAGE_SYM_DTYPE_ARRAY 3 - -// -// Storage classes. -// -#define EFI_IMAGE_SYM_CLASS_END_OF_FUNCTION ((UINT8) -1) -#define EFI_IMAGE_SYM_CLASS_NULL 0 -#define EFI_IMAGE_SYM_CLASS_AUTOMATIC 1 -#define EFI_IMAGE_SYM_CLASS_EXTERNAL 2 -#define EFI_IMAGE_SYM_CLASS_STATIC 3 -#define EFI_IMAGE_SYM_CLASS_REGISTER 4 -#define EFI_IMAGE_SYM_CLASS_EXTERNAL_DEF 5 -#define EFI_IMAGE_SYM_CLASS_LABEL 6 -#define EFI_IMAGE_SYM_CLASS_UNDEFINED_LABEL 7 -#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 8 -#define EFI_IMAGE_SYM_CLASS_ARGUMENT 9 -#define EFI_IMAGE_SYM_CLASS_STRUCT_TAG 10 -#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_UNION 11 -#define EFI_IMAGE_SYM_CLASS_UNION_TAG 12 -#define EFI_IMAGE_SYM_CLASS_TYPE_DEFINITION 13 -#define EFI_IMAGE_SYM_CLASS_UNDEFINED_STATIC 14 -#define EFI_IMAGE_SYM_CLASS_ENUM_TAG 15 -#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_ENUM 16 -#define EFI_IMAGE_SYM_CLASS_REGISTER_PARAM 17 -#define EFI_IMAGE_SYM_CLASS_BIT_FIELD 18 -#define EFI_IMAGE_SYM_CLASS_BLOCK 100 -#define EFI_IMAGE_SYM_CLASS_FUNCTION 101 -#define EFI_IMAGE_SYM_CLASS_END_OF_STRUCT 102 -#define EFI_IMAGE_SYM_CLASS_FILE 103 -#define EFI_IMAGE_SYM_CLASS_SECTION 104 -#define EFI_IMAGE_SYM_CLASS_WEAK_EXTERNAL 105 - -// -// type packing constants -// -#define EFI_IMAGE_N_BTMASK 017 -#define EFI_IMAGE_N_TMASK 060 -#define EFI_IMAGE_N_TMASK1 0300 -#define EFI_IMAGE_N_TMASK2 0360 -#define EFI_IMAGE_N_BTSHFT 4 -#define EFI_IMAGE_N_TSHIFT 2 - -// -// Communal selection types. -// -#define EFI_IMAGE_COMDAT_SELECT_NODUPLICATES 1 -#define EFI_IMAGE_COMDAT_SELECT_ANY 2 -#define EFI_IMAGE_COMDAT_SELECT_SAME_SIZE 3 -#define EFI_IMAGE_COMDAT_SELECT_EXACT_MATCH 4 -#define EFI_IMAGE_COMDAT_SELECT_ASSOCIATIVE 5 - -// -// the following values only be referred in PeCoff, not defined in PECOFF. -// -#define EFI_IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1 -#define EFI_IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2 -#define EFI_IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3 - -/// -/// Relocation format. -/// -typedef struct { - UINT32 VirtualAddress; - UINT32 SymbolTableIndex; - UINT16 Type; -} EFI_IMAGE_RELOCATION; - -/// -/// Size of EFI_IMAGE_RELOCATION -/// -#define EFI_IMAGE_SIZEOF_RELOCATION 10 - -// -// I386 relocation types. -// -#define EFI_IMAGE_REL_I386_ABSOLUTE 0x0000 ///< Reference is absolute, no relocation is necessary. -#define EFI_IMAGE_REL_I386_DIR16 0x0001 ///< Direct 16-bit reference to the symbols virtual address. -#define EFI_IMAGE_REL_I386_REL16 0x0002 ///< PC-relative 16-bit reference to the symbols virtual address. -#define EFI_IMAGE_REL_I386_DIR32 0x0006 ///< Direct 32-bit reference to the symbols virtual address. -#define EFI_IMAGE_REL_I386_DIR32NB 0x0007 ///< Direct 32-bit reference to the symbols virtual address, base not included. -#define EFI_IMAGE_REL_I386_SEG12 0x0009 ///< Direct 16-bit reference to the segment-selector bits of a 32-bit virtual address. -#define EFI_IMAGE_REL_I386_SECTION 0x000A -#define EFI_IMAGE_REL_I386_SECREL 0x000B -#define EFI_IMAGE_REL_I386_REL32 0x0014 ///< PC-relative 32-bit reference to the symbols virtual address. - -// -// x64 processor relocation types. -// -#define IMAGE_REL_AMD64_ABSOLUTE 0x0000 -#define IMAGE_REL_AMD64_ADDR64 0x0001 -#define IMAGE_REL_AMD64_ADDR32 0x0002 -#define IMAGE_REL_AMD64_ADDR32NB 0x0003 -#define IMAGE_REL_AMD64_REL32 0x0004 -#define IMAGE_REL_AMD64_REL32_1 0x0005 -#define IMAGE_REL_AMD64_REL32_2 0x0006 -#define IMAGE_REL_AMD64_REL32_3 0x0007 -#define IMAGE_REL_AMD64_REL32_4 0x0008 -#define IMAGE_REL_AMD64_REL32_5 0x0009 -#define IMAGE_REL_AMD64_SECTION 0x000A -#define IMAGE_REL_AMD64_SECREL 0x000B -#define IMAGE_REL_AMD64_SECREL7 0x000C -#define IMAGE_REL_AMD64_TOKEN 0x000D -#define IMAGE_REL_AMD64_SREL32 0x000E -#define IMAGE_REL_AMD64_PAIR 0x000F -#define IMAGE_REL_AMD64_SSPAN32 0x0010 - -/// -/// Based relocation format. -/// -typedef struct { - UINT32 VirtualAddress; - UINT32 SizeOfBlock; -} EFI_IMAGE_BASE_RELOCATION; - -/// -/// Size of EFI_IMAGE_BASE_RELOCATION. -/// -#define EFI_IMAGE_SIZEOF_BASE_RELOCATION 8 - -// -// Based relocation types. -// -#define EFI_IMAGE_REL_BASED_ABSOLUTE 0 -#define EFI_IMAGE_REL_BASED_HIGH 1 -#define EFI_IMAGE_REL_BASED_LOW 2 -#define EFI_IMAGE_REL_BASED_HIGHLOW 3 -#define EFI_IMAGE_REL_BASED_HIGHADJ 4 -#define EFI_IMAGE_REL_BASED_MIPS_JMPADDR 5 -#define EFI_IMAGE_REL_BASED_ARM_MOV32A 5 -#define EFI_IMAGE_REL_BASED_ARM_MOV32T 7 -#define EFI_IMAGE_REL_BASED_IA64_IMM64 9 -#define EFI_IMAGE_REL_BASED_MIPS_JMPADDR16 9 -#define EFI_IMAGE_REL_BASED_DIR64 10 - -/// -/// Line number format. -/// -typedef struct { - union { - UINT32 SymbolTableIndex; ///< Symbol table index of function name if Linenumber is 0. - UINT32 VirtualAddress; ///< Virtual address of line number. - } Type; - UINT16 Linenumber; ///< Line number. -} EFI_IMAGE_LINENUMBER; - -/// -/// Size of EFI_IMAGE_LINENUMBER. -/// -#define EFI_IMAGE_SIZEOF_LINENUMBER 6 - -// -// Archive format. -// -#define EFI_IMAGE_ARCHIVE_START_SIZE 8 -#define EFI_IMAGE_ARCHIVE_START "!\n" -#define EFI_IMAGE_ARCHIVE_END "`\n" -#define EFI_IMAGE_ARCHIVE_PAD "\n" -#define EFI_IMAGE_ARCHIVE_LINKER_MEMBER "/ " -#define EFI_IMAGE_ARCHIVE_LONGNAMES_MEMBER "// " - -/// -/// Archive Member Headers -/// -typedef struct { - UINT8 Name[16]; ///< File member name - `/' terminated. - UINT8 Date[12]; ///< File member date - decimal. - UINT8 UserID[6]; ///< File member user id - decimal. - UINT8 GroupID[6]; ///< File member group id - decimal. - UINT8 Mode[8]; ///< File member mode - octal. - UINT8 Size[10]; ///< File member size - decimal. - UINT8 EndHeader[2]; ///< String to end header. (0x60 0x0A). -} EFI_IMAGE_ARCHIVE_MEMBER_HEADER; - -/// -/// Size of EFI_IMAGE_ARCHIVE_MEMBER_HEADER. -/// -#define EFI_IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60 - - -// -// DLL Support -// - -/// -/// Export Directory Table. -/// -typedef struct { - UINT32 Characteristics; - UINT32 TimeDateStamp; - UINT16 MajorVersion; - UINT16 MinorVersion; - UINT32 Name; - UINT32 Base; - UINT32 NumberOfFunctions; - UINT32 NumberOfNames; - UINT32 AddressOfFunctions; - UINT32 AddressOfNames; - UINT32 AddressOfNameOrdinals; -} EFI_IMAGE_EXPORT_DIRECTORY; - -/// -/// Hint/Name Table. -/// -typedef struct { - UINT16 Hint; - UINT8 Name[1]; -} EFI_IMAGE_IMPORT_BY_NAME; - -/// -/// Import Address Table RVA (Thunk Table). -/// -typedef struct { - union { - UINT32 Function; - UINT32 Ordinal; - EFI_IMAGE_IMPORT_BY_NAME *AddressOfData; - } u1; -} EFI_IMAGE_THUNK_DATA; - -#define EFI_IMAGE_ORDINAL_FLAG BIT31 ///< Flag for PE32. -#define EFI_IMAGE_SNAP_BY_ORDINAL(Ordinal) ((Ordinal & EFI_IMAGE_ORDINAL_FLAG) != 0) -#define EFI_IMAGE_ORDINAL(Ordinal) (Ordinal & 0xffff) - -/// -/// Import Directory Table -/// -typedef struct { - UINT32 Characteristics; - UINT32 TimeDateStamp; - UINT32 ForwarderChain; - UINT32 Name; - EFI_IMAGE_THUNK_DATA *FirstThunk; -} EFI_IMAGE_IMPORT_DESCRIPTOR; - - -/// -/// Debug Directory Format. -/// -typedef struct { - UINT32 Characteristics; - UINT32 TimeDateStamp; - UINT16 MajorVersion; - UINT16 MinorVersion; - UINT32 Type; - UINT32 SizeOfData; - UINT32 RVA; ///< The address of the debug data when loaded, relative to the image base. - UINT32 FileOffset; ///< The file pointer to the debug data. -} EFI_IMAGE_DEBUG_DIRECTORY_ENTRY; - -#define EFI_IMAGE_DEBUG_TYPE_CODEVIEW 2 ///< The Visual C++ debug information. - -/// -/// Debug Data Structure defined in Microsoft C++. -/// -#define CODEVIEW_SIGNATURE_NB10 SIGNATURE_32('N', 'B', '1', '0') -typedef struct { - UINT32 Signature; ///< "NB10" - UINT32 Unknown; - UINT32 Unknown2; - UINT32 Unknown3; - // - // Filename of .PDB goes here - // -} EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY; - -/// -/// Debug Data Structure defined in Microsoft C++. -/// -#define CODEVIEW_SIGNATURE_RSDS SIGNATURE_32('R', 'S', 'D', 'S') -typedef struct { - UINT32 Signature; ///< "RSDS". - UINT32 Unknown; - UINT32 Unknown2; - UINT32 Unknown3; - UINT32 Unknown4; - UINT32 Unknown5; - // - // Filename of .PDB goes here - // -} EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY; - - -/// -/// Debug Data Structure defined by Apple Mach-O to Coff utility. -/// -#define CODEVIEW_SIGNATURE_MTOC SIGNATURE_32('M', 'T', 'O', 'C') -typedef struct { - UINT32 Signature; ///< "MTOC". - EFI_GUID MachOUuid; - // - // Filename of .DLL (Mach-O with debug info) goes here - // -} EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY; - -/// -/// Resource format. -/// -typedef struct { - UINT32 Characteristics; - UINT32 TimeDateStamp; - UINT16 MajorVersion; - UINT16 MinorVersion; - UINT16 NumberOfNamedEntries; - UINT16 NumberOfIdEntries; - // - // Array of EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY entries goes here. - // -} EFI_IMAGE_RESOURCE_DIRECTORY; - -/// -/// Resource directory entry format. -/// -typedef struct { - union { - struct { - UINT32 NameOffset:31; - UINT32 NameIsString:1; - } s; - UINT32 Id; - } u1; - union { - UINT32 OffsetToData; - struct { - UINT32 OffsetToDirectory:31; - UINT32 DataIsDirectory:1; - } s; - } u2; -} EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY; - -/// -/// Resource directory entry for string. -/// -typedef struct { - UINT16 Length; - CHAR16 String[1]; -} EFI_IMAGE_RESOURCE_DIRECTORY_STRING; - -/// -/// Resource directory entry for data array. -/// -typedef struct { - UINT32 OffsetToData; - UINT32 Size; - UINT32 CodePage; - UINT32 Reserved; -} EFI_IMAGE_RESOURCE_DATA_ENTRY; - -/// -/// Header format for TE images, defined in the PI Specification, 1.0. -/// -typedef struct { - UINT16 Signature; ///< The signature for TE format = "VZ". - UINT16 Machine; ///< From the original file header. - UINT8 NumberOfSections; ///< From the original file header. - UINT8 Subsystem; ///< From original optional header. - UINT16 StrippedSize; ///< Number of bytes we removed from the header. - UINT32 AddressOfEntryPoint; ///< Offset to entry point -- from original optional header. - UINT32 BaseOfCode; ///< From original image -- required for ITP debug. - UINT64 ImageBase; ///< From original file header. - EFI_IMAGE_DATA_DIRECTORY DataDirectory[2]; ///< Only base relocation and debug directory. -} EFI_TE_IMAGE_HEADER; - - -#define EFI_TE_IMAGE_HEADER_SIGNATURE SIGNATURE_16('V', 'Z') - -// -// Data directory indexes in our TE image header -// -#define EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC 0 -#define EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG 1 - - -/// -/// Union of PE32, PE32+, and TE headers. -/// -typedef union { - EFI_IMAGE_NT_HEADERS32 Pe32; - EFI_IMAGE_NT_HEADERS64 Pe32Plus; - EFI_TE_IMAGE_HEADER Te; -} EFI_IMAGE_OPTIONAL_HEADER_UNION; - -typedef union { - EFI_IMAGE_NT_HEADERS32 *Pe32; - EFI_IMAGE_NT_HEADERS64 *Pe32Plus; - EFI_TE_IMAGE_HEADER *Te; - EFI_IMAGE_OPTIONAL_HEADER_UNION *Union; -} EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION; - -typedef struct { - WIN_CERTIFICATE Hdr; - UINT8 CertData[1]; -} WIN_CERTIFICATE_EFI_PKCS; - -#define SHA1_DIGEST_SIZE 20 -#define SHA256_DIGEST_SIZE 32 -#define WIN_CERT_TYPE_PKCS_SIGNED_DATA 0x0002 - -typedef struct { - UINT64 ImageAddress; - UINT64 ImageSize; - UINT64 EntryPoint; - UINTN SizeOfHeaders; - UINT16 ImageType; - UINT16 NumberOfSections; - UINT32 SectionAlignment; - EFI_IMAGE_SECTION_HEADER *FirstSection; - EFI_IMAGE_DATA_DIRECTORY *RelocDir; - EFI_IMAGE_DATA_DIRECTORY *SecDir; - UINT64 NumberOfRvaAndSizes; - EFI_IMAGE_OPTIONAL_HEADER_UNION *PEHdr; -} PE_COFF_LOADER_IMAGE_CONTEXT; - -#endif /* SHIM_PEIMAGE_H */ diff --git a/include/efiauthenticated.h b/include/efiauthenticated.h index 7157ffd2..7c683e36 100644 --- a/include/efiauthenticated.h +++ b/include/efiauthenticated.h @@ -1,7 +1,7 @@ #ifndef SHIM_EFIAUTHENTICATED_H #define SHIM_EFIAUTHENTICATED_H -#include +#include "wincert.h" /*********************************************************************** * Signature Database diff --git a/include/http.h b/include/http.h new file mode 100644 index 00000000..4b3746a7 --- /dev/null +++ b/include/http.h @@ -0,0 +1,507 @@ +/** @file + This file defines the EFI HTTP Protocol interface. It is split into + the following two main sections: + HTTP Service Binding Protocol (HTTPSB) + HTTP Protocol (HTTP) + + Copyright (c) 2016, Intel Corporation. All rights reserved.
+ (C) Copyright 2015 Hewlett Packard Enterprise Development LP
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Revision Reference: + This Protocol is introduced in UEFI Specification 2.5 + +**/ + +#ifndef SHIM_HTTP_H +#define SHIM_HTTP_H + +typedef struct _EFI_HTTP_PROTOCOL EFI_HTTP_PROTOCOL; + +/// +/// EFI_HTTP_VERSION +/// +typedef enum { + HttpVersion10, + HttpVersion11, + HttpVersionUnsupported +} EFI_HTTP_VERSION; + +/// +/// EFI_HTTP_METHOD +/// +typedef enum { + HttpMethodGet, + HttpMethodPost, + HttpMethodPatch, + HttpMethodOptions, + HttpMethodConnect, + HttpMethodHead, + HttpMethodPut, + HttpMethodDelete, + HttpMethodTrace, + HttpMethodMax +} EFI_HTTP_METHOD; + +/// +/// EFI_HTTP_STATUS_CODE +/// +typedef enum { + HTTP_STATUS_UNSUPPORTED_STATUS = 0, + HTTP_STATUS_100_CONTINUE, + HTTP_STATUS_101_SWITCHING_PROTOCOLS, + HTTP_STATUS_200_OK, + HTTP_STATUS_201_CREATED, + HTTP_STATUS_202_ACCEPTED, + HTTP_STATUS_203_NON_AUTHORITATIVE_INFORMATION, + HTTP_STATUS_204_NO_CONTENT, + HTTP_STATUS_205_RESET_CONTENT, + HTTP_STATUS_206_PARTIAL_CONTENT, + HTTP_STATUS_300_MULTIPLE_CHIOCES, + HTTP_STATUS_301_MOVED_PERMANENTLY, + HTTP_STATUS_302_FOUND, + HTTP_STATUS_303_SEE_OTHER, + HTTP_STATUS_304_NOT_MODIFIED, + HTTP_STATUS_305_USE_PROXY, + HTTP_STATUS_307_TEMPORARY_REDIRECT, + HTTP_STATUS_400_BAD_REQUEST, + HTTP_STATUS_401_UNAUTHORIZED, + HTTP_STATUS_402_PAYMENT_REQUIRED, + HTTP_STATUS_403_FORBIDDEN, + HTTP_STATUS_404_NOT_FOUND, + HTTP_STATUS_405_METHOD_NOT_ALLOWED, + HTTP_STATUS_406_NOT_ACCEPTABLE, + HTTP_STATUS_407_PROXY_AUTHENTICATION_REQUIRED, + HTTP_STATUS_408_REQUEST_TIME_OUT, + HTTP_STATUS_409_CONFLICT, + HTTP_STATUS_410_GONE, + HTTP_STATUS_411_LENGTH_REQUIRED, + HTTP_STATUS_412_PRECONDITION_FAILED, + HTTP_STATUS_413_REQUEST_ENTITY_TOO_LARGE, + HTTP_STATUS_414_REQUEST_URI_TOO_LARGE, + HTTP_STATUS_415_UNSUPPORTED_MEDIA_TYPE, + HTTP_STATUS_416_REQUESTED_RANGE_NOT_SATISFIED, + HTTP_STATUS_417_EXPECTATION_FAILED, + HTTP_STATUS_500_INTERNAL_SERVER_ERROR, + HTTP_STATUS_501_NOT_IMPLEMENTED, + HTTP_STATUS_502_BAD_GATEWAY, + HTTP_STATUS_503_SERVICE_UNAVAILABLE, + HTTP_STATUS_504_GATEWAY_TIME_OUT, + HTTP_STATUS_505_HTTP_VERSION_NOT_SUPPORTED +} EFI_HTTP_STATUS_CODE; + +/// +/// EFI_HTTPv4_ACCESS_POINT +/// +typedef struct { + /// + /// Set to TRUE to instruct the EFI HTTP instance to use the default address + /// information in every TCP connection made by this instance. In addition, when set + /// to TRUE, LocalAddress and LocalSubnet are ignored. + /// + BOOLEAN UseDefaultAddress; + /// + /// If UseDefaultAddress is set to FALSE, this defines the local IP address to be + /// used in every TCP connection opened by this instance. + /// + EFI_IPv4_ADDRESS LocalAddress; + /// + /// If UseDefaultAddress is set to FALSE, this defines the local subnet to be used + /// in every TCP connection opened by this instance. + /// + EFI_IPv4_ADDRESS LocalSubnet; + /// + /// This defines the local port to be used in + /// every TCP connection opened by this instance. + /// + UINT16 LocalPort; +} EFI_HTTPv4_ACCESS_POINT; + +/// +/// EFI_HTTPv6_ACCESS_POINT +/// +typedef struct { + /// + /// Local IP address to be used in every TCP connection opened by this instance. + /// + EFI_IPv6_ADDRESS LocalAddress; + /// + /// Local port to be used in every TCP connection opened by this instance. + /// + UINT16 LocalPort; +} EFI_HTTPv6_ACCESS_POINT; + +/// +/// EFI_HTTP_CONFIG_DATA_ACCESS_POINT +/// + + +typedef struct { + /// + /// HTTP version that this instance will support. + /// + EFI_HTTP_VERSION HttpVersion; + /// + /// Time out (in milliseconds) when blocking for requests. + /// + UINT32 TimeOutMillisec; + /// + /// Defines behavior of EFI DNS and TCP protocols consumed by this instance. If + /// FALSE, this instance will use EFI_DNS4_PROTOCOL and EFI_TCP4_PROTOCOL. If TRUE, + /// this instance will use EFI_DNS6_PROTOCOL and EFI_TCP6_PROTOCOL. + /// + BOOLEAN LocalAddressIsIPv6; + + union { + /// + /// When LocalAddressIsIPv6 is FALSE, this points to the local address, subnet, and + /// port used by the underlying TCP protocol. + /// + EFI_HTTPv4_ACCESS_POINT *IPv4Node; + /// + /// When LocalAddressIsIPv6 is TRUE, this points to the local IPv6 address and port + /// used by the underlying TCP protocol. + /// + EFI_HTTPv6_ACCESS_POINT *IPv6Node; + } AccessPoint; +} EFI_HTTP_CONFIG_DATA; + +/// +/// EFI_HTTP_REQUEST_DATA +/// +typedef struct { + /// + /// The HTTP method (e.g. GET, POST) for this HTTP Request. + /// + EFI_HTTP_METHOD Method; + /// + /// The URI of a remote host. From the information in this field, the HTTP instance + /// will be able to determine whether to use HTTP or HTTPS and will also be able to + /// determine the port number to use. If no port number is specified, port 80 (HTTP) + /// is assumed. See RFC 3986 for more details on URI syntax. + /// + CHAR16 *Url; +} EFI_HTTP_REQUEST_DATA; + +/// +/// EFI_HTTP_RESPONSE_DATA +/// +typedef struct { + /// + /// Response status code returned by the remote host. + /// + EFI_HTTP_STATUS_CODE StatusCode; +} EFI_HTTP_RESPONSE_DATA; + +/// +/// EFI_HTTP_HEADER +/// +typedef struct { + /// + /// Null terminated string which describes a field name. See RFC 2616 Section 14 for + /// detailed information about field names. + /// + CHAR8 *FieldName; + /// + /// Null terminated string which describes the corresponding field value. See RFC 2616 + /// Section 14 for detailed information about field values. + /// + CHAR8 *FieldValue; +} EFI_HTTP_HEADER; + +/// +/// EFI_HTTP_MESSAGE +/// +typedef struct { + /// + /// HTTP message data. + /// + union { + /// + /// When the token is used to send a HTTP request, Request is a pointer to storage that + /// contains such data as URL and HTTP method. + /// + EFI_HTTP_REQUEST_DATA *Request; + /// + /// When used to await a response, Response points to storage containing HTTP response + /// status code. + /// + EFI_HTTP_RESPONSE_DATA *Response; + } Data; + /// + /// Number of HTTP header structures in Headers list. On request, this count is + /// provided by the caller. On response, this count is provided by the HTTP driver. + /// + UINTN HeaderCount; + /// + /// Array containing list of HTTP headers. On request, this array is populated by the + /// caller. On response, this array is allocated and populated by the HTTP driver. It + /// is the responsibility of the caller to free this memory on both request and + /// response. + /// + EFI_HTTP_HEADER *Headers; + /// + /// Length in bytes of the HTTP body. This can be zero depending on the HttpMethod type. + /// + UINTN BodyLength; + /// + /// Body associated with the HTTP request or response. This can be NULL depending on + /// the HttpMethod type. + /// + VOID *Body; +} EFI_HTTP_MESSAGE; + + +/// +/// EFI_HTTP_TOKEN +/// +typedef struct { + /// + /// This Event will be signaled after the Status field is updated by the EFI HTTP + /// Protocol driver. The type of Event must be EFI_NOTIFY_SIGNAL. The Task Priority + /// Level (TPL) of Event must be lower than or equal to TPL_CALLBACK. + /// + EFI_EVENT Event; + /// + /// Status will be set to one of the following value if the HTTP request is + /// successfully sent or if an unexpected error occurs: + /// EFI_SUCCESS: The HTTP request was successfully sent to the remote host. + /// EFI_HTTP_ERROR: The response message was successfully received but contains a + /// HTTP error. The response status code is returned in token. + /// EFI_ABORTED: The HTTP request was cancelled by the caller and removed from + /// the transmit queue. + /// EFI_TIMEOUT: The HTTP request timed out before reaching the remote host. + /// EFI_DEVICE_ERROR: An unexpected system or network error occurred. + /// + EFI_STATUS Status; + /// + /// Pointer to storage containing HTTP message data. + /// + EFI_HTTP_MESSAGE *Message; +} EFI_HTTP_TOKEN; + +/** + Returns the operational parameters for the current HTTP child instance. + + The GetModeData() function is used to read the current mode data (operational + parameters) for this HTTP protocol instance. + + @param[in] This Pointer to EFI_HTTP_PROTOCOL instance. + @param[out] HttpConfigData Point to buffer for operational parameters of this + HTTP instance. + + @retval EFI_SUCCESS Operation succeeded. + @retval EFI_INVALID_PARAMETER This is NULL. + HttpConfigData is NULL. + HttpInstance->LocalAddressIsIPv6 is FALSE and + HttpConfigData->IPv4Node is NULL. + HttpInstance->LocalAddressIsIPv6 is TRUE and + HttpConfigData->IPv6Node is NULL. + @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started. +**/ +typedef +EFI_STATUS +(EFIAPI * EFI_HTTP_GET_MODE_DATA)( + IN EFI_HTTP_PROTOCOL *This, + OUT EFI_HTTP_CONFIG_DATA *HttpConfigData + ); + +/** + Initialize or brutally reset the operational parameters for this EFI HTTP instance. + + The Configure() function does the following: + When HttpConfigData is not NULL Initialize this EFI HTTP instance by configuring + timeout, local address, port, etc. + When HttpConfigData is NULL, reset this EFI HTTP instance by closing all active + connections with remote hosts, canceling all asynchronous tokens, and flush request + and response buffers without informing the appropriate hosts. + + No other EFI HTTP function can be executed by this instance until the Configure() + function is executed and returns successfully. + + @param[in] This Pointer to EFI_HTTP_PROTOCOL instance. + @param[in] HttpConfigData Pointer to the configure data to configure the instance. + + @retval EFI_SUCCESS Operation succeeded. + @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: + This is NULL. + HttpConfigData is NULL. + HttpConfigData->LocalAddressIsIPv6 is FALSE and + HttpConfigData->IPv4Node is NULL. + HttpConfigData->LocalAddressIsIPv6 is TRUE and + HttpConfigData->IPv6Node is NULL. + @retval EFI_ALREADY_STARTED Reinitialize this HTTP instance without calling + Configure() with NULL to reset it. + @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. + @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when + executing Configure(). + @retval EFI_UNSUPPORTED One or more options in ConfigData are not supported + in the implementation. +**/ +typedef +EFI_STATUS +(EFIAPI * EFI_HTTP_CONFIGURE)( + IN EFI_HTTP_PROTOCOL *This, + IN EFI_HTTP_CONFIG_DATA *HttpConfigData + ); + +/** + The Request() function queues an HTTP request to this HTTP instance, + similar to Transmit() function in the EFI TCP driver. When the HTTP request is sent + successfully, or if there is an error, Status in token will be updated and Event will + be signaled. + + @param[in] This Pointer to EFI_HTTP_PROTOCOL instance. + @param[in] Token Pointer to storage containing HTTP request token. + + @retval EFI_SUCCESS Outgoing data was processed. + @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started. + @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. + @retval EFI_TIMEOUT Data was dropped out of the transmit or receive queue. + @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: + This is NULL. + Token is NULL. + Token->Message is NULL. + Token->Message->Body is not NULL, + Token->Message->BodyLength is non-zero, and + Token->Message->Data is NULL, but a previous call to + Request()has not been completed successfully. + @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources. + @retval EFI_UNSUPPORTED The HTTP method is not supported in current implementation. +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_HTTP_REQUEST) ( + IN EFI_HTTP_PROTOCOL *This, + IN EFI_HTTP_TOKEN *Token + ); + +/** + Abort an asynchronous HTTP request or response token. + + The Cancel() function aborts a pending HTTP request or response transaction. If + Token is not NULL and the token is in transmit or receive queues when it is being + cancelled, its Token->Status will be set to EFI_ABORTED and then Token->Event will + be signaled. If the token is not in one of the queues, which usually means that the + asynchronous operation has completed, EFI_NOT_FOUND is returned. If Token is NULL, + all asynchronous tokens issued by Request() or Response() will be aborted. + + @param[in] This Pointer to EFI_HTTP_PROTOCOL instance. + @param[in] Token Point to storage containing HTTP request or response + token. + + @retval EFI_SUCCESS Request and Response queues are successfully flushed. + @retval EFI_INVALID_PARAMETER This is NULL. + @retval EFI_NOT_STARTED This instance hasn't been configured. + @retval EFI_NOT_FOUND The asynchronous request or response token is not + found. + @retval EFI_UNSUPPORTED The implementation does not support this function. +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_HTTP_CANCEL)( + IN EFI_HTTP_PROTOCOL *This, + IN EFI_HTTP_TOKEN *Token + ); + +/** + The Response() function queues an HTTP response to this HTTP instance, similar to + Receive() function in the EFI TCP driver. When the HTTP Response is received successfully, + or if there is an error, Status in token will be updated and Event will be signaled. + + The HTTP driver will queue a receive token to the underlying TCP instance. When data + is received in the underlying TCP instance, the data will be parsed and Token will + be populated with the response data. If the data received from the remote host + contains an incomplete or invalid HTTP header, the HTTP driver will continue waiting + (asynchronously) for more data to be sent from the remote host before signaling + Event in Token. + + It is the responsibility of the caller to allocate a buffer for Body and specify the + size in BodyLength. If the remote host provides a response that contains a content + body, up to BodyLength bytes will be copied from the receive buffer into Body and + BodyLength will be updated with the amount of bytes received and copied to Body. This + allows the client to download a large file in chunks instead of into one contiguous + block of memory. Similar to HTTP request, if Body is not NULL and BodyLength is + non-zero and all other fields are NULL or 0, the HTTP driver will queue a receive + token to underlying TCP instance. If data arrives in the receive buffer, up to + BodyLength bytes of data will be copied to Body. The HTTP driver will then update + BodyLength with the amount of bytes received and copied to Body. + + If the HTTP driver does not have an open underlying TCP connection with the host + specified in the response URL, Request() will return EFI_ACCESS_DENIED. This is + consistent with RFC 2616 recommendation that HTTP clients should attempt to maintain + an open TCP connection between client and host. + + @param[in] This Pointer to EFI_HTTP_PROTOCOL instance. + @param[in] Token Pointer to storage containing HTTP response token. + + @retval EFI_SUCCESS Allocation succeeded. + @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been + initialized. + @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: + This is NULL. + Token is NULL. + Token->Message->Headers is NULL. + Token->Message is NULL. + Token->Message->Body is not NULL, + Token->Message->BodyLength is non-zero, and + Token->Message->Data is NULL, but a previous call to + Response() has not been completed successfully. + @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources. + @retval EFI_ACCESS_DENIED An open TCP connection is not present with the host + specified by response URL. +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_HTTP_RESPONSE) ( + IN EFI_HTTP_PROTOCOL *This, + IN EFI_HTTP_TOKEN *Token + ); + +/** + The Poll() function can be used by network drivers and applications to increase the + rate that data packets are moved between the communication devices and the transmit + and receive queues. + + In some systems, the periodic timer event in the managed network driver may not poll + the underlying communications device fast enough to transmit and/or receive all data + packets without missing incoming packets or dropping outgoing packets. Drivers and + applications that are experiencing packet loss should try calling the Poll() function + more often. + + @param[in] This Pointer to EFI_HTTP_PROTOCOL instance. + + @retval EFI_SUCCESS Incoming or outgoing data was processed.. + @retval EFI_DEVICE_ERROR An unexpected system or network error occurred + @retval EFI_INVALID_PARAMETER This is NULL. + @retval EFI_NOT_READY No incoming or outgoing data is processed. + @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started. +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_HTTP_POLL) ( + IN EFI_HTTP_PROTOCOL *This + ); + +/// +/// The EFI HTTP protocol is designed to be used by EFI drivers and applications to +/// create and transmit HTTP Requests, as well as handle HTTP responses that are +/// returned by a remote host. This EFI protocol uses and relies on an underlying EFI +/// TCP protocol. +/// +struct _EFI_HTTP_PROTOCOL { + EFI_HTTP_GET_MODE_DATA GetModeData; + EFI_HTTP_CONFIGURE Configure; + EFI_HTTP_REQUEST Request; + EFI_HTTP_CANCEL Cancel; + EFI_HTTP_RESPONSE Response; + EFI_HTTP_POLL Poll; +}; + +#endif /* SHIM_HTTP_H */ diff --git a/include/ip4config2.h b/include/ip4config2.h new file mode 100644 index 00000000..efacaf83 --- /dev/null +++ b/include/ip4config2.h @@ -0,0 +1,310 @@ +/** @file + This file provides a definition of the EFI IPv4 Configuration II + Protocol. + +Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +@par Revision Reference: +This Protocol is introduced in UEFI Specification 2.5 + +**/ +#ifndef SHIM_IP4CONFIG2_H +#define SHIM_IP4CONFIG2_H + +#include + +typedef struct _EFI_IP4_CONFIG2_PROTOCOL EFI_IP4_CONFIG2_PROTOCOL; + + +/// +/// EFI_IP4_CONFIG2_DATA_TYPE +/// +typedef enum { + /// + /// The interface information of the communication device this EFI + /// IPv4 Configuration II Protocol instance manages. This type of + /// data is read only. The corresponding Data is of type + /// EFI_IP4_CONFIG2_INTERFACE_INFO. + /// + Ip4Config2DataTypeInterfaceInfo, + /// + /// The general configuration policy for the EFI IPv4 network stack + /// running on the communication device this EFI IPv4 + /// Configuration II Protocol instance manages. The policy will + /// affect other configuration settings. The corresponding Data is of + /// type EFI_IP4_CONFIG2_POLICY. + /// + Ip4Config2DataTypePolicy, + /// + /// The station addresses set manually for the EFI IPv4 network + /// stack. It is only configurable when the policy is + /// Ip4Config2PolicyStatic. The corresponding Data is of + /// type EFI_IP4_CONFIG2_MANUAL_ADDRESS. + /// + Ip4Config2DataTypeManualAddress, + /// + /// The gateway addresses set manually for the EFI IPv4 network + /// stack running on the communication device this EFI IPv4 + /// Configuration II Protocol manages. It is not configurable when + /// the policy is Ip4Config2PolicyDhcp. The gateway + /// addresses must be unicast IPv4 addresses. The corresponding + /// Data is a pointer to an array of EFI_IPv4_ADDRESS instances. + /// + Ip4Config2DataTypeGateway, + /// + /// The DNS server list for the EFI IPv4 network stack running on + /// the communication device this EFI IPv4 Configuration II + /// Protocol manages. It is not configurable when the policy is + /// Ip4Config2PolicyDhcp. The DNS server addresses must be + /// unicast IPv4 addresses. The corresponding Data is a pointer to + /// an array of EFI_IPv4_ADDRESS instances. + /// + Ip4Config2DataTypeDnsServer, + Ip4Config2DataTypeMaximum +} EFI_IP4_CONFIG2_DATA_TYPE; + +/// +/// EFI_IP4_CONFIG2_INTERFACE_INFO related definitions +/// +#define EFI_IP4_CONFIG2_INTERFACE_INFO_NAME_SIZE 32 + +/// +/// EFI_IP4_CONFIG2_INTERFACE_INFO +/// +typedef struct { + /// + /// The name of the interface. It is a NULL-terminated Unicode string. + /// + CHAR16 Name[EFI_IP4_CONFIG2_INTERFACE_INFO_NAME_SIZE]; + /// + /// The interface type of the network interface. See RFC 1700, + /// section "Number Hardware Type". + /// + UINT8 IfType; + /// + /// The size, in bytes, of the network interface's hardware address. + /// + UINT32 HwAddressSize; + /// + /// The hardware address for the network interface. + /// + EFI_MAC_ADDRESS HwAddress; + /// + /// The station IPv4 address of this EFI IPv4 network stack. + /// + EFI_IPv4_ADDRESS StationAddress; + /// + /// The subnet address mask that is associated with the station address. + /// + EFI_IPv4_ADDRESS SubnetMask; + /// + /// Size of the following RouteTable, in bytes. May be zero. + /// + UINT32 RouteTableSize; + /// + /// The route table of the IPv4 network stack runs on this interface. + /// Set to NULL if RouteTableSize is zero. Type EFI_IP4_ROUTE_TABLE is defined in + /// EFI_IP4_PROTOCOL.GetModeData(). + /// + EFI_IP4_ROUTE_TABLE *RouteTable OPTIONAL; +} EFI_IP4_CONFIG2_INTERFACE_INFO; + +/// +/// EFI_IP4_CONFIG2_POLICY +/// +typedef enum { + /// + /// Under this policy, the Ip4Config2DataTypeManualAddress, + /// Ip4Config2DataTypeGateway and Ip4Config2DataTypeDnsServer configuration + /// data are required to be set manually. The EFI IPv4 Protocol will get all + /// required configuration such as IPv4 address, subnet mask and + /// gateway settings from the EFI IPv4 Configuration II protocol. + /// + Ip4Config2PolicyStatic, + /// + /// Under this policy, the Ip4Config2DataTypeManualAddress, + /// Ip4Config2DataTypeGateway and Ip4Config2DataTypeDnsServer configuration data are + /// not allowed to set via SetData(). All of these configurations are retrieved from DHCP + /// server or other auto-configuration mechanism. + /// + Ip4Config2PolicyDhcp, + Ip4Config2PolicyMax +} EFI_IP4_CONFIG2_POLICY; + +/// +/// EFI_IP4_CONFIG2_MANUAL_ADDRESS +/// +typedef struct { + /// + /// The IPv4 unicast address. + /// + EFI_IPv4_ADDRESS Address; + /// + /// The subnet mask. + /// + EFI_IPv4_ADDRESS SubnetMask; +} EFI_IP4_CONFIG2_MANUAL_ADDRESS; + +/** + Set the configuration for the EFI IPv4 network stack running on the communication device this EFI + IPv4 Configuration II Protocol instance manages. + + This function is used to set the configuration data of type DataType for the EFI IPv4 network stack + running on the communication device this EFI IPv4 Configuration II Protocol instance manages. + The successfully configured data is valid after system reset or power-off. + The DataSize is used to calculate the count of structure instances in the Data for some + DataType that multiple structure instances are allowed. + This function is always non-blocking. When setting some typeof configuration data, an + asynchronous process is invoked to check the correctness of the data, such as doing address conflict + detection on the manually set local IPv4 address. EFI_NOT_READY is returned immediately to + indicate that such an asynchronous process is invoked and the process is not finished yet. The caller + willing to get the result of the asynchronous process is required to call RegisterDataNotify() + to register an event on the specified configuration data. Once the event is signaled, the caller can call + GetData()to get back the configuration data in order to know the result. For other types of + configuration data that do not require an asynchronous configuration process, the result of the + operation is immediately returned. + + @param[in] This Pointer to the EFI_IP4_CONFIG2_PROTOCOL instance. + @param[in] DataType The type of data to set. + @param[in] DataSize Size of the buffer pointed to by Data in bytes. + @param[in] Data The data buffer to set. The type ofthe data buffer is associated + with the DataType. + + @retval EFI_SUCCESS The specified configuration data for the EFI IPv4 network stack is set + successfully. + @retval EFI_INVALID_PARAMETER One or more of the following are TRUE: + This is NULL. + Data is NULL. + One or more fields in Data do not match the requirement of the data type + indicated by DataType. + @retval EFI_WRITE_PROTECTED The specified configuration data is read-only or the specified configuration + data can not be set under the current policy. + @retval EFI_ACCESS_DENIED Another set operation on the specified configuration data is already in process. + @retval EFI_NOT_READY An asynchronous process is invoked to set the specified configuration data and + the process is not finished yet. + @retval EFI_BAD_BUFFER_SIZE The DataSize does not match the size of the type indicated by DataType. + @retval EFI_UNSUPPORTED This DataType is not supported. + @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. + @retval EFI_DEVICE_ERROR An unexpected system error or network error occurred. +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_CONFIG2_SET_DATA) ( + IN EFI_IP4_CONFIG2_PROTOCOL *This, + IN EFI_IP4_CONFIG2_DATA_TYPE DataType, + IN UINTN DataSize, + IN VOID *Data + ); + +/** + Get the configuration data for the EFI IPv4 network stack running on the communication device this + EFI IPv4 Configuration II Protocol instance manages. + + This function returns the configuration data of type DataType for the EFI IPv4 network stack + running on the communication device this EFI IPv4 Configuration II Protocol instance manages. + The caller is responsible for allocating the buffer usedto return the specified configuration data and + the required size will be returned to the caller if the size of the buffer is too small. + EFI_NOT_READY is returned if the specified configuration data is not ready due to an already in + progress asynchronous configuration process. The caller can call RegisterDataNotify() to + register an event on the specified configuration data. Once the asynchronous configuration process is + finished, the event will be signaled and a subsequent GetData() call will return the specified + configuration data. + + @param[in] This Pointer to the EFI_IP4_CONFIG2_PROTOCOL instance. + @param[in] DataType The type of data to get. + @param[out] DataSize On input, in bytes, the size of Data. On output, in bytes, the size + of buffer required to store the specified configuration data. + @param[in] Data The data buffer in which the configuration data is returned. The + type of the data buffer is associated with the DataType. Ignored + if DataSize is 0. + + @retval EFI_SUCCESS The specified configuration data is got successfully. + @retval EFI_INVALID_PARAMETER One or more of the followings are TRUE: + This is NULL. + DataSize is NULL. + Data is NULL if *DataSizeis not zero. + @retval EFI_BUFFER_TOO_SMALL The size of Data is too small for the specified configuration data + and the required size is returned in DataSize. + @retval EFI_NOT_READY The specified configuration data is not ready due to an already in + progress asynchronous configuration process. + @retval EFI_NOT_FOUND The specified configuration data is not found. +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_CONFIG2_GET_DATA) ( + IN EFI_IP4_CONFIG2_PROTOCOL *This, + IN EFI_IP4_CONFIG2_DATA_TYPE DataType, + IN OUT UINTN *DataSize, + IN VOID *Data OPTIONAL + ); + +/** + Register an event that is to be signaled whenever a configuration process on the specified + configuration data is done. + + This function registers an event that is to be signaled whenever a configuration process on the + specified configuration data is done. An event can be registered for different DataType + simultaneously and the caller is responsible for determining which type of configuration data causes + the signaling of the event in such case. + + @param[in] This Pointer to the EFI_IP4_CONFIG2_PROTOCOL instance. + @param[in] DataType The type of data to unregister the event for. + @param[in] Event The event to register. + + @retval EFI_SUCCESS The notification event for the specified configuration data is + registered. + @retval EFI_INVALID_PARAMETER This is NULL or Event is NULL. + @retval EFI_UNSUPPORTED The configuration data type specified by DataType is not supported. + @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. + @retval EFI_ACCESS_DENIED The Event is already registered for the DataType. +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_CONFIG2_REGISTER_NOTIFY) ( + IN EFI_IP4_CONFIG2_PROTOCOL *This, + IN EFI_IP4_CONFIG2_DATA_TYPE DataType, + IN EFI_EVENT Event + ); + +/** + Remove a previously registered event for the specified configuration data. + + This function removes a previously registeredevent for the specified configuration data. + + @param[in] This Pointer to the EFI_IP4_CONFIG2_PROTOCOL instance. + @param[in] DataType The type of data to remove the previously registered event for. + @param[in] Event The event to unregister. + + @retval EFI_SUCCESS The event registered for the specified configuration data is removed. + @retval EFI_INVALID_PARAMETER This is NULL or Event is NULL. + @retval EFI_NOT_FOUND The Eventhas not been registered for the specified DataType. +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_CONFIG2_UNREGISTER_NOTIFY) ( + IN EFI_IP4_CONFIG2_PROTOCOL *This, + IN EFI_IP4_CONFIG2_DATA_TYPE DataType, + IN EFI_EVENT Event + ); + +/// +/// The EFI_IP4_CONFIG2_PROTOCOL is designed to be the central repository for the common +/// configurations and the administrator configurable settings for the EFI IPv4 network stack. +/// An EFI IPv4 Configuration II Protocol instance will be installed on each communication device that +/// the EFI IPv4 network stack runs on. +/// +struct _EFI_IP4_CONFIG2_PROTOCOL { + EFI_IP4_CONFIG2_SET_DATA SetData; + EFI_IP4_CONFIG2_GET_DATA GetData; + EFI_IP4_CONFIG2_REGISTER_NOTIFY RegisterDataNotify; + EFI_IP4_CONFIG2_UNREGISTER_NOTIFY UnregisterDataNotify; +}; + +#endif /* SHIM_IP4CONFIG2_H */ diff --git a/include/ip6config.h b/include/ip6config.h new file mode 100644 index 00000000..f99ce013 --- /dev/null +++ b/include/ip6config.h @@ -0,0 +1,361 @@ +/** @file + This file provides a definition of the EFI IPv6 Configuration + Protocol. + +Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ +#ifndef SHIM_IP6CONFIG_H +#define SHIM_IP6CONFIG_H + +#include + +typedef struct _EFI_IP6_CONFIG_PROTOCOL EFI_IP6_CONFIG_PROTOCOL; + +/// +/// EFI_IP6_CONFIG_DATA_TYPE +/// +typedef enum { + /// + /// The interface information of the communication + /// device this EFI IPv6 Configuration Protocol instance manages. + /// This type of data is read only.The corresponding Data is of type + /// EFI_IP6_CONFIG_INTERFACE_INFO. + /// + Ip6ConfigDataTypeInterfaceInfo, + /// + /// The alternative interface ID for the + /// communication device this EFI IPv6 Configuration Protocol + /// instance manages if the link local IPv6 address generated from + /// the interfaced ID based on the default source the EFI IPv6 + /// Protocol uses is a duplicate address. The length of the interface + /// ID is 64 bit. The corresponding Data is of type + /// EFI_IP6_CONFIG_INTERFACE_ID. + /// + Ip6ConfigDataTypeAltInterfaceId, + /// + /// The general configuration policy for the EFI IPv6 network + /// stack running on the communication device this EFI IPv6 + /// Configuration Protocol instance manages. The policy will affect + /// other configuration settings. The corresponding Data is of type + /// EFI_IP6_CONFIG_POLICY. + /// + Ip6ConfigDataTypePolicy, + /// + /// The number of consecutive + /// Neighbor Solicitation messages sent while performing Duplicate + /// Address Detection on a tentative address. A value of zero + /// indicates that Duplicate Address Detection will not be performed + /// on tentative addresses. The corresponding Data is of type + /// EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS. + /// + Ip6ConfigDataTypeDupAddrDetectTransmits, + /// + /// The station addresses set manually for the EFI + /// IPv6 network stack. It is only configurable when the policy is + /// Ip6ConfigPolicyManual. The corresponding Data is a + /// pointer to an array of EFI_IPv6_ADDRESS instances. + /// + Ip6ConfigDataTypeManualAddress, + /// + /// The gateway addresses set manually for the EFI IPv6 + /// network stack running on the communication device this EFI + /// IPv6 Configuration Protocol manages. It is not configurable when + /// the policy is Ip6ConfigPolicyAutomatic. The gateway + /// addresses must be unicast IPv6 addresses. The corresponding + /// Data is a pointer to an array of EFI_IPv6_ADDRESS instances. + /// + Ip6ConfigDataTypeGateway, + /// + /// The DNS server list for the EFI IPv6 network stack + /// running on the communication device this EFI IPv6 + /// Configuration Protocol manages. It is not configurable when the + /// policy is Ip6ConfigPolicyAutomatic.The DNS server + /// addresses must be unicast IPv6 addresses. The corresponding + /// Data is a pointer to an array of EFI_IPv6_ADDRESS instances. + /// + Ip6ConfigDataTypeDnsServer, + /// + /// The number of this enumeration memebers. + /// + Ip6ConfigDataTypeMaximum +} EFI_IP6_CONFIG_DATA_TYPE; + +/// +/// EFI_IP6_CONFIG_INTERFACE_INFO +/// describes the operational state of the interface this +/// EFI IPv6 Configuration Protocol instance manages. +/// +typedef struct { + /// + /// The name of the interface. It is a NULL-terminated string. + /// + CHAR16 Name[32]; + /// + /// The interface type of the network interface. + /// + UINT8 IfType; + /// + /// The size, in bytes, of the network interface's hardware address. + /// + UINT32 HwAddressSize; + /// + /// The hardware address for the network interface. + /// + EFI_MAC_ADDRESS HwAddress; + /// + /// Number of EFI_IP6_ADDRESS_INFO structures pointed to by AddressInfo. + /// + UINT32 AddressInfoCount; + /// + /// Pointer to an array of EFI_IP6_ADDRESS_INFO instances + /// which contain the local IPv6 addresses and the corresponding + /// prefix length information. Set to NULL if AddressInfoCount + /// is zero. + /// + EFI_IP6_ADDRESS_INFO *AddressInfo; + /// + /// Number of route table entries in the following RouteTable. + /// + UINT32 RouteCount; + /// + /// The route table of the IPv6 network stack runs on this interface. + /// Set to NULL if RouteCount is zero. + /// + EFI_IP6_ROUTE_TABLE *RouteTable; +} EFI_IP6_CONFIG_INTERFACE_INFO; + +/// +/// EFI_IP6_CONFIG_INTERFACE_ID +/// describes the 64-bit interface ID. +/// +typedef struct { + UINT8 Id[8]; +} EFI_IP6_CONFIG_INTERFACE_ID; + +/// +/// EFI_IP6_CONFIG_POLICY +/// defines the general configuration policy the EFI IPv6 +/// Configuration Protocol supports. +/// +typedef enum { + /// + /// Under this policy, the IpI6ConfigDataTypeManualAddress, + /// Ip6ConfigDataTypeGateway and Ip6ConfigDataTypeDnsServer + /// configuration data are required to be set manually. + /// The EFI IPv6 Protocol will get all required configuration + /// such as address, prefix and gateway settings from the EFI + /// IPv6 Configuration protocol. + /// + Ip6ConfigPolicyManual, + /// + /// Under this policy, the IpI6ConfigDataTypeManualAddress, + /// Ip6ConfigDataTypeGateway and Ip6ConfigDataTypeDnsServer + /// configuration data are not allowed to set via SetData(). + /// All of these configurations are retrieved from some auto + /// configuration mechanism. + /// The EFI IPv6 Protocol will use the IPv6 stateless address + /// autoconfiguration mechanism and/or the IPv6 stateful address + /// autoconfiguration mechanism described in the related RFCs to + /// get address and other configuration information + /// + Ip6ConfigPolicyAutomatic +} EFI_IP6_CONFIG_POLICY; + +/// +/// EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS +/// describes the number of consecutive Neighbor Solicitation messages sent +/// while performing Duplicate Address Detection on a tentative address. +/// The default value for a newly detected communication device is 1. +/// +typedef struct { + UINT32 DupAddrDetectTransmits; ///< The number of consecutive Neighbor Solicitation messages sent. +} EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS; + +/// +/// EFI_IP6_CONFIG_MANUAL_ADDRESS +/// is used to set the station address information for the EFI IPv6 network +/// stack manually when the policy is Ip6ConfigPolicyManual. +/// +typedef struct { + EFI_IPv6_ADDRESS Address; ///< The IPv6 unicast address. + BOOLEAN IsAnycast; ///< Set to TRUE if Address is anycast. + UINT8 PrefixLength; ///< The length, in bits, of the prefix associated with this Address. +} EFI_IP6_CONFIG_MANUAL_ADDRESS; + + +/** + Set the configuration for the EFI IPv6 network stack running on the communication + device this EFI IPv6 Configuration Protocol instance manages. + + This function is used to set the configuration data of type DataType for the EFI + IPv6 network stack running on the communication device this EFI IPv6 Configuration + Protocol instance manages. + + The DataSize is used to calculate the count of structure instances in the Data for + some DataType that multiple structure instances are allowed. + + This function is always non-blocking. When setting some type of configuration data, + an asynchronous process is invoked to check the correctness of the data, such as + doing Duplicate Address Detection on the manually set local IPv6 addresses. + EFI_NOT_READY is returned immediately to indicate that such an asynchronous process + is invoked and the process is not finished yet. The caller willing to get the result + of the asynchronous process is required to call RegisterDataNotify() to register an + event on the specified configuration data. Once the event is signaled, the caller + can call GetData() to get back the configuration data in order to know the result. + For other types of configuration data that do not require an asynchronous configuration + process, the result of the operation is immediately returned. + + @param[in] This Pointer to the EFI_IP6_CONFIG_PROTOCOL instance. + @param[in] DataType The type of data to set. + @param[in] DataSize Size of the buffer pointed to by Data in bytes. + @param[in] Data The data buffer to set. The type of the data buffer is + associated with the DataType. + + @retval EFI_SUCCESS The specified configuration data for the EFI IPv6 + network stack is set successfully. + @retval EFI_INVALID_PARAMETER One or more of the following are TRUE: + - This is NULL. + - Data is NULL. + - One or more fields in Data do not match the requirement of the + data type indicated by DataType. + @retval EFI_WRITE_PROTECTED The specified configuration data is read-only or the specified + configuration data can not be set under the current policy + @retval EFI_ACCESS_DENIED Another set operation on the specified configuration + data is already in process. + @retval EFI_NOT_READY An asynchronous process is invoked to set the specified + configuration data and the process is not finished yet. + @retval EFI_BAD_BUFFER_SIZE The DataSize does not match the size of the type + indicated by DataType. + @retval EFI_UNSUPPORTED This DataType is not supported. + @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. + @retval EFI_DEVICE_ERROR An unexpected system error or network error occurred. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_IP6_CONFIG_SET_DATA)( + IN EFI_IP6_CONFIG_PROTOCOL *This, + IN EFI_IP6_CONFIG_DATA_TYPE DataType, + IN UINTN DataSize, + IN VOID *Data + ); + +/** + Get the configuration data for the EFI IPv6 network stack running on the communication + device this EFI IPv6 Configuration Protocol instance manages. + + This function returns the configuration data of type DataType for the EFI IPv6 network + stack running on the communication device this EFI IPv6 Configuration Protocol instance + manages. + + The caller is responsible for allocating the buffer used to return the specified + configuration data and the required size will be returned to the caller if the size of + the buffer is too small. + + EFI_NOT_READY is returned if the specified configuration data is not ready due to an + already in progress asynchronous configuration process. The caller can call RegisterDataNotify() + to register an event on the specified configuration data. Once the asynchronous configuration + process is finished, the event will be signaled and a subsequent GetData() call will return + the specified configuration data. + + @param[in] This Pointer to the EFI_IP6_CONFIG_PROTOCOL instance. + @param[in] DataType The type of data to get. + @param[in,out] DataSize On input, in bytes, the size of Data. On output, in bytes, the + size of buffer required to store the specified configuration data. + @param[in] Data The data buffer in which the configuration data is returned. The + type of the data buffer is associated with the DataType. + + @retval EFI_SUCCESS The specified configuration data is got successfully. + @retval EFI_INVALID_PARAMETER One or more of the followings are TRUE: + - This is NULL. + - DataSize is NULL. + - Data is NULL if *DataSize is not zero. + @retval EFI_BUFFER_TOO_SMALL The size of Data is too small for the specified configuration data + and the required size is returned in DataSize. + @retval EFI_NOT_READY The specified configuration data is not ready due to an already in + progress asynchronous configuration process. + @retval EFI_NOT_FOUND The specified configuration data is not found. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_IP6_CONFIG_GET_DATA)( + IN EFI_IP6_CONFIG_PROTOCOL *This, + IN EFI_IP6_CONFIG_DATA_TYPE DataType, + IN OUT UINTN *DataSize, + IN VOID *Data OPTIONAL + ); + +/** + Register an event that is to be signaled whenever a configuration process on the specified + configuration data is done. + + This function registers an event that is to be signaled whenever a configuration process + on the specified configuration data is done. An event can be registered for different DataType + simultaneously and the caller is responsible for determining which type of configuration data + causes the signaling of the event in such case. + + @param[in] This Pointer to the EFI_IP6_CONFIG_PROTOCOL instance. + @param[in] DataType The type of data to unregister the event for. + @param[in] Event The event to register. + + @retval EFI_SUCCESS The notification event for the specified configuration data is + registered. + @retval EFI_INVALID_PARAMETER This is NULL or Event is NULL. + @retval EFI_UNSUPPORTED The configuration data type specified by DataType is not + supported. + @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. + @retval EFI_ACCESS_DENIED The Event is already registered for the DataType. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_IP6_CONFIG_REGISTER_NOTIFY)( + IN EFI_IP6_CONFIG_PROTOCOL *This, + IN EFI_IP6_CONFIG_DATA_TYPE DataType, + IN EFI_EVENT Event + ); + +/** + Remove a previously registered event for the specified configuration data. + + This function removes a previously registered event for the specified configuration data. + + @param[in] This Pointer to the EFI_IP6_CONFIG_PROTOCOL instance. + @param[in] DataType The type of data to remove the previously registered event for. + @param[in] Event The event to unregister. + + @retval EFI_SUCCESS The event registered for the specified configuration data is removed. + @retval EFI_INVALID_PARAMETER This is NULL or Event is NULL. + @retval EFI_NOT_FOUND The Event has not been registered for the specified + DataType. + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_IP6_CONFIG_UNREGISTER_NOTIFY)( + IN EFI_IP6_CONFIG_PROTOCOL *This, + IN EFI_IP6_CONFIG_DATA_TYPE DataType, + IN EFI_EVENT Event + ); + +/// +/// The EFI_IP6_CONFIG_PROTOCOL provides the mechanism to set and get various +/// types of configurations for the EFI IPv6 network stack. +/// +struct _EFI_IP6_CONFIG_PROTOCOL { + EFI_IP6_CONFIG_SET_DATA SetData; + EFI_IP6_CONFIG_GET_DATA GetData; + EFI_IP6_CONFIG_REGISTER_NOTIFY RegisterDataNotify; + EFI_IP6_CONFIG_UNREGISTER_NOTIFY UnregisterDataNotify; +}; + +#endif /* SHIM_IP6CONFIG_H */ diff --git a/include/passwordcrypt.h b/include/passwordcrypt.h new file mode 100644 index 00000000..cadad727 --- /dev/null +++ b/include/passwordcrypt.h @@ -0,0 +1,27 @@ +#ifndef SHIM_PASSWORDCRYPT_H +#define SHIM_PASSWORDCRYPT_H + +enum HashMethod { + TRADITIONAL_DES = 0, + EXTEND_BSDI_DES, + MD5_BASED, + SHA256_BASED, + SHA512_BASED, + BLOWFISH_BASED +}; + +typedef struct { + UINT16 method; + UINT64 iter_count; + UINT16 salt_size; + UINT8 salt[32]; + UINT8 hash[128]; +} __attribute__ ((packed)) PASSWORD_CRYPT; + +#define PASSWORD_CRYPT_SIZE sizeof(PASSWORD_CRYPT) + +EFI_STATUS password_crypt (const char *password, UINT32 pw_length, + const PASSWORD_CRYPT *pw_hash, UINT8 *hash); +UINT16 get_hash_size (const UINT16 method); + +#endif /* SHIM_PASSWORDCRYPT_H */ diff --git a/include/pe.h b/include/pe.h new file mode 100644 index 00000000..49b89ae0 --- /dev/null +++ b/include/pe.h @@ -0,0 +1,790 @@ +/** @file + EFI image format for PE32, PE32+ and TE. Please note some data structures are + different for PE32 and PE32+. EFI_IMAGE_NT_HEADERS32 is for PE32 and + EFI_IMAGE_NT_HEADERS64 is for PE32+. + + This file is coded to the Visual Studio, Microsoft Portable Executable and + Common Object File Format Specification, Revision 8.0 - May 16, 2006. + This file also includes some definitions in PI Specification, Revision 1.0. + +Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php. + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef SHIM_PEIMAGE_H +#define SHIM_PEIMAGE_H + +#include "wincert.h" + +#define SIGNATURE_16(A, B) ((A) | (B << 8)) +#define SIGNATURE_32(A, B, C, D) (SIGNATURE_16 (A, B) | (SIGNATURE_16 (C, D) << 16)) +#define SIGNATURE_64(A, B, C, D, E, F, G, H) \ + (SIGNATURE_32 (A, B, C, D) | ((UINT64) (SIGNATURE_32 (E, F, G, H)) << 32)) + +#define ALIGN_VALUE(Value, Alignment) ((Value) + (((Alignment) - (Value)) & ((Alignment) - 1))) +#define ALIGN_POINTER(Pointer, Alignment) ((VOID *) (ALIGN_VALUE ((UINTN)(Pointer), (Alignment)))) + +// +// PE32+ Subsystem type for EFI images +// +#define EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION 10 +#define EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11 +#define EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12 +#define EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER 13 ///< defined PI Specification, 1.0 + + +// +// PE32+ Machine type for EFI images +// +#define IMAGE_FILE_MACHINE_I386 0x014c +#define IMAGE_FILE_MACHINE_IA64 0x0200 +#define IMAGE_FILE_MACHINE_EBC 0x0EBC +#define IMAGE_FILE_MACHINE_X64 0x8664 +#define IMAGE_FILE_MACHINE_ARMTHUMB_MIXED 0x01c2 +#define IMAGE_FILE_MACHINE_ARM64 0xaa64 + +// +// EXE file formats +// +#define EFI_IMAGE_DOS_SIGNATURE SIGNATURE_16('M', 'Z') +#define EFI_IMAGE_OS2_SIGNATURE SIGNATURE_16('N', 'E') +#define EFI_IMAGE_OS2_SIGNATURE_LE SIGNATURE_16('L', 'E') +#define EFI_IMAGE_NT_SIGNATURE SIGNATURE_32('P', 'E', '\0', '\0') + +/// +/// PE images can start with an optional DOS header, so if an image is run +/// under DOS it can print an error message. +/// +typedef struct { + UINT16 e_magic; ///< Magic number. + UINT16 e_cblp; ///< Bytes on last page of file. + UINT16 e_cp; ///< Pages in file. + UINT16 e_crlc; ///< Relocations. + UINT16 e_cparhdr; ///< Size of header in paragraphs. + UINT16 e_minalloc; ///< Minimum extra paragraphs needed. + UINT16 e_maxalloc; ///< Maximum extra paragraphs needed. + UINT16 e_ss; ///< Initial (relative) SS value. + UINT16 e_sp; ///< Initial SP value. + UINT16 e_csum; ///< Checksum. + UINT16 e_ip; ///< Initial IP value. + UINT16 e_cs; ///< Initial (relative) CS value. + UINT16 e_lfarlc; ///< File address of relocation table. + UINT16 e_ovno; ///< Overlay number. + UINT16 e_res[4]; ///< Reserved words. + UINT16 e_oemid; ///< OEM identifier (for e_oeminfo). + UINT16 e_oeminfo; ///< OEM information; e_oemid specific. + UINT16 e_res2[10]; ///< Reserved words. + UINT32 e_lfanew; ///< File address of new exe header. +} EFI_IMAGE_DOS_HEADER; + +/// +/// COFF File Header (Object and Image). +/// +typedef struct { + UINT16 Machine; + UINT16 NumberOfSections; + UINT32 TimeDateStamp; + UINT32 PointerToSymbolTable; + UINT32 NumberOfSymbols; + UINT16 SizeOfOptionalHeader; + UINT16 Characteristics; +} EFI_IMAGE_FILE_HEADER; + +/// +/// Size of EFI_IMAGE_FILE_HEADER. +/// +#define EFI_IMAGE_SIZEOF_FILE_HEADER 20 + +// +// Characteristics +// +#define EFI_IMAGE_FILE_RELOCS_STRIPPED (1 << 0) ///< 0x0001 Relocation info stripped from file. +#define EFI_IMAGE_FILE_EXECUTABLE_IMAGE (1 << 1) ///< 0x0002 File is executable (i.e. no unresolved externel references). +#define EFI_IMAGE_FILE_LINE_NUMS_STRIPPED (1 << 2) ///< 0x0004 Line nunbers stripped from file. +#define EFI_IMAGE_FILE_LOCAL_SYMS_STRIPPED (1 << 3) ///< 0x0008 Local symbols stripped from file. +#define EFI_IMAGE_FILE_BYTES_REVERSED_LO (1 << 7) ///< 0x0080 Bytes of machine word are reversed. +#define EFI_IMAGE_FILE_32BIT_MACHINE (1 << 8) ///< 0x0100 32 bit word machine. +#define EFI_IMAGE_FILE_DEBUG_STRIPPED (1 << 9) ///< 0x0200 Debugging info stripped from file in .DBG file. +#define EFI_IMAGE_FILE_SYSTEM (1 << 12) ///< 0x1000 System File. +#define EFI_IMAGE_FILE_DLL (1 << 13) ///< 0x2000 File is a DLL. +#define EFI_IMAGE_FILE_BYTES_REVERSED_HI (1 << 15) ///< 0x8000 Bytes of machine word are reversed. + +/// +/// Header Data Directories. +/// +typedef struct { + UINT32 VirtualAddress; + UINT32 Size; +} EFI_IMAGE_DATA_DIRECTORY; + +// +// Directory Entries +// +#define EFI_IMAGE_DIRECTORY_ENTRY_EXPORT 0 +#define EFI_IMAGE_DIRECTORY_ENTRY_IMPORT 1 +#define EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE 2 +#define EFI_IMAGE_DIRECTORY_ENTRY_EXCEPTION 3 +#define EFI_IMAGE_DIRECTORY_ENTRY_SECURITY 4 +#define EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC 5 +#define EFI_IMAGE_DIRECTORY_ENTRY_DEBUG 6 +#define EFI_IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7 +#define EFI_IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 +#define EFI_IMAGE_DIRECTORY_ENTRY_TLS 9 +#define EFI_IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10 + +#define EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES 16 + +/// +/// @attention +/// EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC means PE32 and +/// EFI_IMAGE_OPTIONAL_HEADER32 must be used. The data structures only vary +/// after NT additional fields. +/// +#define EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b + +/// +/// Optional Header Standard Fields for PE32. +/// +typedef struct { + /// + /// Standard fields. + /// + UINT16 Magic; + UINT8 MajorLinkerVersion; + UINT8 MinorLinkerVersion; + UINT32 SizeOfCode; + UINT32 SizeOfInitializedData; + UINT32 SizeOfUninitializedData; + UINT32 AddressOfEntryPoint; + UINT32 BaseOfCode; + UINT32 BaseOfData; ///< PE32 contains this additional field, which is absent in PE32+. + /// + /// Optional Header Windows-Specific Fields. + /// + UINT32 ImageBase; + UINT32 SectionAlignment; + UINT32 FileAlignment; + UINT16 MajorOperatingSystemVersion; + UINT16 MinorOperatingSystemVersion; + UINT16 MajorImageVersion; + UINT16 MinorImageVersion; + UINT16 MajorSubsystemVersion; + UINT16 MinorSubsystemVersion; + UINT32 Win32VersionValue; + UINT32 SizeOfImage; + UINT32 SizeOfHeaders; + UINT32 CheckSum; + UINT16 Subsystem; + UINT16 DllCharacteristics; + UINT32 SizeOfStackReserve; + UINT32 SizeOfStackCommit; + UINT32 SizeOfHeapReserve; + UINT32 SizeOfHeapCommit; + UINT32 LoaderFlags; + UINT32 NumberOfRvaAndSizes; + EFI_IMAGE_DATA_DIRECTORY DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES]; +} EFI_IMAGE_OPTIONAL_HEADER32; + +/// +/// @attention +/// EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC means PE32+ and +/// EFI_IMAGE_OPTIONAL_HEADER64 must be used. The data structures only vary +/// after NT additional fields. +/// +#define EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b + +/// +/// Optional Header Standard Fields for PE32+. +/// +typedef struct { + /// + /// Standard fields. + /// + UINT16 Magic; + UINT8 MajorLinkerVersion; + UINT8 MinorLinkerVersion; + UINT32 SizeOfCode; + UINT32 SizeOfInitializedData; + UINT32 SizeOfUninitializedData; + UINT32 AddressOfEntryPoint; + UINT32 BaseOfCode; + /// + /// Optional Header Windows-Specific Fields. + /// + UINT64 ImageBase; + UINT32 SectionAlignment; + UINT32 FileAlignment; + UINT16 MajorOperatingSystemVersion; + UINT16 MinorOperatingSystemVersion; + UINT16 MajorImageVersion; + UINT16 MinorImageVersion; + UINT16 MajorSubsystemVersion; + UINT16 MinorSubsystemVersion; + UINT32 Win32VersionValue; + UINT32 SizeOfImage; + UINT32 SizeOfHeaders; + UINT32 CheckSum; + UINT16 Subsystem; + UINT16 DllCharacteristics; + UINT64 SizeOfStackReserve; + UINT64 SizeOfStackCommit; + UINT64 SizeOfHeapReserve; + UINT64 SizeOfHeapCommit; + UINT32 LoaderFlags; + UINT32 NumberOfRvaAndSizes; + EFI_IMAGE_DATA_DIRECTORY DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES]; +} EFI_IMAGE_OPTIONAL_HEADER64; + + +/// +/// @attention +/// EFI_IMAGE_NT_HEADERS32 is for use ONLY by tools. +/// +typedef struct { + UINT32 Signature; + EFI_IMAGE_FILE_HEADER FileHeader; + EFI_IMAGE_OPTIONAL_HEADER32 OptionalHeader; +} EFI_IMAGE_NT_HEADERS32; + +#define EFI_IMAGE_SIZEOF_NT_OPTIONAL32_HEADER sizeof (EFI_IMAGE_NT_HEADERS32) + +/// +/// @attention +/// EFI_IMAGE_HEADERS64 is for use ONLY by tools. +/// +typedef struct { + UINT32 Signature; + EFI_IMAGE_FILE_HEADER FileHeader; + EFI_IMAGE_OPTIONAL_HEADER64 OptionalHeader; +} EFI_IMAGE_NT_HEADERS64; + +#define EFI_IMAGE_SIZEOF_NT_OPTIONAL64_HEADER sizeof (EFI_IMAGE_NT_HEADERS64) + +// +// Other Windows Subsystem Values +// +#define EFI_IMAGE_SUBSYSTEM_UNKNOWN 0 +#define EFI_IMAGE_SUBSYSTEM_NATIVE 1 +#define EFI_IMAGE_SUBSYSTEM_WINDOWS_GUI 2 +#define EFI_IMAGE_SUBSYSTEM_WINDOWS_CUI 3 +#define EFI_IMAGE_SUBSYSTEM_OS2_CUI 5 +#define EFI_IMAGE_SUBSYSTEM_POSIX_CUI 7 + +/// +/// Length of ShortName. +/// +#define EFI_IMAGE_SIZEOF_SHORT_NAME 8 + +/// +/// Section Table. This table immediately follows the optional header. +/// +typedef struct { + UINT8 Name[EFI_IMAGE_SIZEOF_SHORT_NAME]; + union { + UINT32 PhysicalAddress; + UINT32 VirtualSize; + } Misc; + UINT32 VirtualAddress; + UINT32 SizeOfRawData; + UINT32 PointerToRawData; + UINT32 PointerToRelocations; + UINT32 PointerToLinenumbers; + UINT16 NumberOfRelocations; + UINT16 NumberOfLinenumbers; + UINT32 Characteristics; +} EFI_IMAGE_SECTION_HEADER; + +/// +/// Size of EFI_IMAGE_SECTION_HEADER. +/// +#define EFI_IMAGE_SIZEOF_SECTION_HEADER 40 + +// +// Section Flags Values +// +#define EFI_IMAGE_SCN_TYPE_NO_PAD 0x00000008 ///< Reserved. +#define EFI_IMAGE_SCN_CNT_CODE 0x00000020 +#define EFI_IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040 +#define EFI_IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080 + +#define EFI_IMAGE_SCN_LNK_OTHER 0x00000100 ///< Reserved. +#define EFI_IMAGE_SCN_LNK_INFO 0x00000200 ///< Section contains comments or some other type of information. +#define EFI_IMAGE_SCN_LNK_REMOVE 0x00000800 ///< Section contents will not become part of image. +#define EFI_IMAGE_SCN_LNK_COMDAT 0x00001000 + +#define EFI_IMAGE_SCN_ALIGN_1BYTES 0x00100000 +#define EFI_IMAGE_SCN_ALIGN_2BYTES 0x00200000 +#define EFI_IMAGE_SCN_ALIGN_4BYTES 0x00300000 +#define EFI_IMAGE_SCN_ALIGN_8BYTES 0x00400000 +#define EFI_IMAGE_SCN_ALIGN_16BYTES 0x00500000 +#define EFI_IMAGE_SCN_ALIGN_32BYTES 0x00600000 +#define EFI_IMAGE_SCN_ALIGN_64BYTES 0x00700000 + +#define EFI_IMAGE_SCN_MEM_DISCARDABLE 0x02000000 +#define EFI_IMAGE_SCN_MEM_NOT_CACHED 0x04000000 +#define EFI_IMAGE_SCN_MEM_NOT_PAGED 0x08000000 +#define EFI_IMAGE_SCN_MEM_SHARED 0x10000000 +#define EFI_IMAGE_SCN_MEM_EXECUTE 0x20000000 +#define EFI_IMAGE_SCN_MEM_READ 0x40000000 +#define EFI_IMAGE_SCN_MEM_WRITE 0x80000000 + +/// +/// Size of a Symbol Table Record. +/// +#define EFI_IMAGE_SIZEOF_SYMBOL 18 + +// +// Symbols have a section number of the section in which they are +// defined. Otherwise, section numbers have the following meanings: +// +#define EFI_IMAGE_SYM_UNDEFINED (UINT16) 0 ///< Symbol is undefined or is common. +#define EFI_IMAGE_SYM_ABSOLUTE (UINT16) -1 ///< Symbol is an absolute value. +#define EFI_IMAGE_SYM_DEBUG (UINT16) -2 ///< Symbol is a special debug item. + +// +// Symbol Type (fundamental) values. +// +#define EFI_IMAGE_SYM_TYPE_NULL 0 ///< no type. +#define EFI_IMAGE_SYM_TYPE_VOID 1 ///< no valid type. +#define EFI_IMAGE_SYM_TYPE_CHAR 2 ///< type character. +#define EFI_IMAGE_SYM_TYPE_SHORT 3 ///< type short integer. +#define EFI_IMAGE_SYM_TYPE_INT 4 +#define EFI_IMAGE_SYM_TYPE_LONG 5 +#define EFI_IMAGE_SYM_TYPE_FLOAT 6 +#define EFI_IMAGE_SYM_TYPE_DOUBLE 7 +#define EFI_IMAGE_SYM_TYPE_STRUCT 8 +#define EFI_IMAGE_SYM_TYPE_UNION 9 +#define EFI_IMAGE_SYM_TYPE_ENUM 10 ///< enumeration. +#define EFI_IMAGE_SYM_TYPE_MOE 11 ///< member of enumeration. +#define EFI_IMAGE_SYM_TYPE_BYTE 12 +#define EFI_IMAGE_SYM_TYPE_WORD 13 +#define EFI_IMAGE_SYM_TYPE_UINT 14 +#define EFI_IMAGE_SYM_TYPE_DWORD 15 + +// +// Symbol Type (derived) values. +// +#define EFI_IMAGE_SYM_DTYPE_NULL 0 ///< no derived type. +#define EFI_IMAGE_SYM_DTYPE_POINTER 1 +#define EFI_IMAGE_SYM_DTYPE_FUNCTION 2 +#define EFI_IMAGE_SYM_DTYPE_ARRAY 3 + +// +// Storage classes. +// +#define EFI_IMAGE_SYM_CLASS_END_OF_FUNCTION ((UINT8) -1) +#define EFI_IMAGE_SYM_CLASS_NULL 0 +#define EFI_IMAGE_SYM_CLASS_AUTOMATIC 1 +#define EFI_IMAGE_SYM_CLASS_EXTERNAL 2 +#define EFI_IMAGE_SYM_CLASS_STATIC 3 +#define EFI_IMAGE_SYM_CLASS_REGISTER 4 +#define EFI_IMAGE_SYM_CLASS_EXTERNAL_DEF 5 +#define EFI_IMAGE_SYM_CLASS_LABEL 6 +#define EFI_IMAGE_SYM_CLASS_UNDEFINED_LABEL 7 +#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 8 +#define EFI_IMAGE_SYM_CLASS_ARGUMENT 9 +#define EFI_IMAGE_SYM_CLASS_STRUCT_TAG 10 +#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_UNION 11 +#define EFI_IMAGE_SYM_CLASS_UNION_TAG 12 +#define EFI_IMAGE_SYM_CLASS_TYPE_DEFINITION 13 +#define EFI_IMAGE_SYM_CLASS_UNDEFINED_STATIC 14 +#define EFI_IMAGE_SYM_CLASS_ENUM_TAG 15 +#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_ENUM 16 +#define EFI_IMAGE_SYM_CLASS_REGISTER_PARAM 17 +#define EFI_IMAGE_SYM_CLASS_BIT_FIELD 18 +#define EFI_IMAGE_SYM_CLASS_BLOCK 100 +#define EFI_IMAGE_SYM_CLASS_FUNCTION 101 +#define EFI_IMAGE_SYM_CLASS_END_OF_STRUCT 102 +#define EFI_IMAGE_SYM_CLASS_FILE 103 +#define EFI_IMAGE_SYM_CLASS_SECTION 104 +#define EFI_IMAGE_SYM_CLASS_WEAK_EXTERNAL 105 + +// +// type packing constants +// +#define EFI_IMAGE_N_BTMASK 017 +#define EFI_IMAGE_N_TMASK 060 +#define EFI_IMAGE_N_TMASK1 0300 +#define EFI_IMAGE_N_TMASK2 0360 +#define EFI_IMAGE_N_BTSHFT 4 +#define EFI_IMAGE_N_TSHIFT 2 + +// +// Communal selection types. +// +#define EFI_IMAGE_COMDAT_SELECT_NODUPLICATES 1 +#define EFI_IMAGE_COMDAT_SELECT_ANY 2 +#define EFI_IMAGE_COMDAT_SELECT_SAME_SIZE 3 +#define EFI_IMAGE_COMDAT_SELECT_EXACT_MATCH 4 +#define EFI_IMAGE_COMDAT_SELECT_ASSOCIATIVE 5 + +// +// the following values only be referred in PeCoff, not defined in PECOFF. +// +#define EFI_IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1 +#define EFI_IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2 +#define EFI_IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3 + +/// +/// Relocation format. +/// +typedef struct { + UINT32 VirtualAddress; + UINT32 SymbolTableIndex; + UINT16 Type; +} EFI_IMAGE_RELOCATION; + +/// +/// Size of EFI_IMAGE_RELOCATION +/// +#define EFI_IMAGE_SIZEOF_RELOCATION 10 + +// +// I386 relocation types. +// +#define EFI_IMAGE_REL_I386_ABSOLUTE 0x0000 ///< Reference is absolute, no relocation is necessary. +#define EFI_IMAGE_REL_I386_DIR16 0x0001 ///< Direct 16-bit reference to the symbols virtual address. +#define EFI_IMAGE_REL_I386_REL16 0x0002 ///< PC-relative 16-bit reference to the symbols virtual address. +#define EFI_IMAGE_REL_I386_DIR32 0x0006 ///< Direct 32-bit reference to the symbols virtual address. +#define EFI_IMAGE_REL_I386_DIR32NB 0x0007 ///< Direct 32-bit reference to the symbols virtual address, base not included. +#define EFI_IMAGE_REL_I386_SEG12 0x0009 ///< Direct 16-bit reference to the segment-selector bits of a 32-bit virtual address. +#define EFI_IMAGE_REL_I386_SECTION 0x000A +#define EFI_IMAGE_REL_I386_SECREL 0x000B +#define EFI_IMAGE_REL_I386_REL32 0x0014 ///< PC-relative 32-bit reference to the symbols virtual address. + +// +// x64 processor relocation types. +// +#define IMAGE_REL_AMD64_ABSOLUTE 0x0000 +#define IMAGE_REL_AMD64_ADDR64 0x0001 +#define IMAGE_REL_AMD64_ADDR32 0x0002 +#define IMAGE_REL_AMD64_ADDR32NB 0x0003 +#define IMAGE_REL_AMD64_REL32 0x0004 +#define IMAGE_REL_AMD64_REL32_1 0x0005 +#define IMAGE_REL_AMD64_REL32_2 0x0006 +#define IMAGE_REL_AMD64_REL32_3 0x0007 +#define IMAGE_REL_AMD64_REL32_4 0x0008 +#define IMAGE_REL_AMD64_REL32_5 0x0009 +#define IMAGE_REL_AMD64_SECTION 0x000A +#define IMAGE_REL_AMD64_SECREL 0x000B +#define IMAGE_REL_AMD64_SECREL7 0x000C +#define IMAGE_REL_AMD64_TOKEN 0x000D +#define IMAGE_REL_AMD64_SREL32 0x000E +#define IMAGE_REL_AMD64_PAIR 0x000F +#define IMAGE_REL_AMD64_SSPAN32 0x0010 + +/// +/// Based relocation format. +/// +typedef struct { + UINT32 VirtualAddress; + UINT32 SizeOfBlock; +} EFI_IMAGE_BASE_RELOCATION; + +/// +/// Size of EFI_IMAGE_BASE_RELOCATION. +/// +#define EFI_IMAGE_SIZEOF_BASE_RELOCATION 8 + +// +// Based relocation types. +// +#define EFI_IMAGE_REL_BASED_ABSOLUTE 0 +#define EFI_IMAGE_REL_BASED_HIGH 1 +#define EFI_IMAGE_REL_BASED_LOW 2 +#define EFI_IMAGE_REL_BASED_HIGHLOW 3 +#define EFI_IMAGE_REL_BASED_HIGHADJ 4 +#define EFI_IMAGE_REL_BASED_MIPS_JMPADDR 5 +#define EFI_IMAGE_REL_BASED_ARM_MOV32A 5 +#define EFI_IMAGE_REL_BASED_ARM_MOV32T 7 +#define EFI_IMAGE_REL_BASED_IA64_IMM64 9 +#define EFI_IMAGE_REL_BASED_MIPS_JMPADDR16 9 +#define EFI_IMAGE_REL_BASED_DIR64 10 + +/// +/// Line number format. +/// +typedef struct { + union { + UINT32 SymbolTableIndex; ///< Symbol table index of function name if Linenumber is 0. + UINT32 VirtualAddress; ///< Virtual address of line number. + } Type; + UINT16 Linenumber; ///< Line number. +} EFI_IMAGE_LINENUMBER; + +/// +/// Size of EFI_IMAGE_LINENUMBER. +/// +#define EFI_IMAGE_SIZEOF_LINENUMBER 6 + +// +// Archive format. +// +#define EFI_IMAGE_ARCHIVE_START_SIZE 8 +#define EFI_IMAGE_ARCHIVE_START "!\n" +#define EFI_IMAGE_ARCHIVE_END "`\n" +#define EFI_IMAGE_ARCHIVE_PAD "\n" +#define EFI_IMAGE_ARCHIVE_LINKER_MEMBER "/ " +#define EFI_IMAGE_ARCHIVE_LONGNAMES_MEMBER "// " + +/// +/// Archive Member Headers +/// +typedef struct { + UINT8 Name[16]; ///< File member name - `/' terminated. + UINT8 Date[12]; ///< File member date - decimal. + UINT8 UserID[6]; ///< File member user id - decimal. + UINT8 GroupID[6]; ///< File member group id - decimal. + UINT8 Mode[8]; ///< File member mode - octal. + UINT8 Size[10]; ///< File member size - decimal. + UINT8 EndHeader[2]; ///< String to end header. (0x60 0x0A). +} EFI_IMAGE_ARCHIVE_MEMBER_HEADER; + +/// +/// Size of EFI_IMAGE_ARCHIVE_MEMBER_HEADER. +/// +#define EFI_IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60 + + +// +// DLL Support +// + +/// +/// Export Directory Table. +/// +typedef struct { + UINT32 Characteristics; + UINT32 TimeDateStamp; + UINT16 MajorVersion; + UINT16 MinorVersion; + UINT32 Name; + UINT32 Base; + UINT32 NumberOfFunctions; + UINT32 NumberOfNames; + UINT32 AddressOfFunctions; + UINT32 AddressOfNames; + UINT32 AddressOfNameOrdinals; +} EFI_IMAGE_EXPORT_DIRECTORY; + +/// +/// Hint/Name Table. +/// +typedef struct { + UINT16 Hint; + UINT8 Name[1]; +} EFI_IMAGE_IMPORT_BY_NAME; + +/// +/// Import Address Table RVA (Thunk Table). +/// +typedef struct { + union { + UINT32 Function; + UINT32 Ordinal; + EFI_IMAGE_IMPORT_BY_NAME *AddressOfData; + } u1; +} EFI_IMAGE_THUNK_DATA; + +#define EFI_IMAGE_ORDINAL_FLAG BIT31 ///< Flag for PE32. +#define EFI_IMAGE_SNAP_BY_ORDINAL(Ordinal) ((Ordinal & EFI_IMAGE_ORDINAL_FLAG) != 0) +#define EFI_IMAGE_ORDINAL(Ordinal) (Ordinal & 0xffff) + +/// +/// Import Directory Table +/// +typedef struct { + UINT32 Characteristics; + UINT32 TimeDateStamp; + UINT32 ForwarderChain; + UINT32 Name; + EFI_IMAGE_THUNK_DATA *FirstThunk; +} EFI_IMAGE_IMPORT_DESCRIPTOR; + + +/// +/// Debug Directory Format. +/// +typedef struct { + UINT32 Characteristics; + UINT32 TimeDateStamp; + UINT16 MajorVersion; + UINT16 MinorVersion; + UINT32 Type; + UINT32 SizeOfData; + UINT32 RVA; ///< The address of the debug data when loaded, relative to the image base. + UINT32 FileOffset; ///< The file pointer to the debug data. +} EFI_IMAGE_DEBUG_DIRECTORY_ENTRY; + +#define EFI_IMAGE_DEBUG_TYPE_CODEVIEW 2 ///< The Visual C++ debug information. + +/// +/// Debug Data Structure defined in Microsoft C++. +/// +#define CODEVIEW_SIGNATURE_NB10 SIGNATURE_32('N', 'B', '1', '0') +typedef struct { + UINT32 Signature; ///< "NB10" + UINT32 Unknown; + UINT32 Unknown2; + UINT32 Unknown3; + // + // Filename of .PDB goes here + // +} EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY; + +/// +/// Debug Data Structure defined in Microsoft C++. +/// +#define CODEVIEW_SIGNATURE_RSDS SIGNATURE_32('R', 'S', 'D', 'S') +typedef struct { + UINT32 Signature; ///< "RSDS". + UINT32 Unknown; + UINT32 Unknown2; + UINT32 Unknown3; + UINT32 Unknown4; + UINT32 Unknown5; + // + // Filename of .PDB goes here + // +} EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY; + + +/// +/// Debug Data Structure defined by Apple Mach-O to Coff utility. +/// +#define CODEVIEW_SIGNATURE_MTOC SIGNATURE_32('M', 'T', 'O', 'C') +typedef struct { + UINT32 Signature; ///< "MTOC". + EFI_GUID MachOUuid; + // + // Filename of .DLL (Mach-O with debug info) goes here + // +} EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY; + +/// +/// Resource format. +/// +typedef struct { + UINT32 Characteristics; + UINT32 TimeDateStamp; + UINT16 MajorVersion; + UINT16 MinorVersion; + UINT16 NumberOfNamedEntries; + UINT16 NumberOfIdEntries; + // + // Array of EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY entries goes here. + // +} EFI_IMAGE_RESOURCE_DIRECTORY; + +/// +/// Resource directory entry format. +/// +typedef struct { + union { + struct { + UINT32 NameOffset:31; + UINT32 NameIsString:1; + } s; + UINT32 Id; + } u1; + union { + UINT32 OffsetToData; + struct { + UINT32 OffsetToDirectory:31; + UINT32 DataIsDirectory:1; + } s; + } u2; +} EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY; + +/// +/// Resource directory entry for string. +/// +typedef struct { + UINT16 Length; + CHAR16 String[1]; +} EFI_IMAGE_RESOURCE_DIRECTORY_STRING; + +/// +/// Resource directory entry for data array. +/// +typedef struct { + UINT32 OffsetToData; + UINT32 Size; + UINT32 CodePage; + UINT32 Reserved; +} EFI_IMAGE_RESOURCE_DATA_ENTRY; + +/// +/// Header format for TE images, defined in the PI Specification, 1.0. +/// +typedef struct { + UINT16 Signature; ///< The signature for TE format = "VZ". + UINT16 Machine; ///< From the original file header. + UINT8 NumberOfSections; ///< From the original file header. + UINT8 Subsystem; ///< From original optional header. + UINT16 StrippedSize; ///< Number of bytes we removed from the header. + UINT32 AddressOfEntryPoint; ///< Offset to entry point -- from original optional header. + UINT32 BaseOfCode; ///< From original image -- required for ITP debug. + UINT64 ImageBase; ///< From original file header. + EFI_IMAGE_DATA_DIRECTORY DataDirectory[2]; ///< Only base relocation and debug directory. +} EFI_TE_IMAGE_HEADER; + + +#define EFI_TE_IMAGE_HEADER_SIGNATURE SIGNATURE_16('V', 'Z') + +// +// Data directory indexes in our TE image header +// +#define EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC 0 +#define EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG 1 + + +/// +/// Union of PE32, PE32+, and TE headers. +/// +typedef union { + EFI_IMAGE_NT_HEADERS32 Pe32; + EFI_IMAGE_NT_HEADERS64 Pe32Plus; + EFI_TE_IMAGE_HEADER Te; +} EFI_IMAGE_OPTIONAL_HEADER_UNION; + +typedef union { + EFI_IMAGE_NT_HEADERS32 *Pe32; + EFI_IMAGE_NT_HEADERS64 *Pe32Plus; + EFI_TE_IMAGE_HEADER *Te; + EFI_IMAGE_OPTIONAL_HEADER_UNION *Union; +} EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION; + +typedef struct { + WIN_CERTIFICATE Hdr; + UINT8 CertData[1]; +} WIN_CERTIFICATE_EFI_PKCS; + +#define SHA1_DIGEST_SIZE 20 +#define SHA256_DIGEST_SIZE 32 +#define WIN_CERT_TYPE_PKCS_SIGNED_DATA 0x0002 + +typedef struct { + UINT64 ImageAddress; + UINT64 ImageSize; + UINT64 EntryPoint; + UINTN SizeOfHeaders; + UINT16 ImageType; + UINT16 NumberOfSections; + UINT32 SectionAlignment; + EFI_IMAGE_SECTION_HEADER *FirstSection; + EFI_IMAGE_DATA_DIRECTORY *RelocDir; + EFI_IMAGE_DATA_DIRECTORY *SecDir; + UINT64 NumberOfRvaAndSizes; + EFI_IMAGE_OPTIONAL_HEADER_UNION *PEHdr; +} PE_COFF_LOADER_IMAGE_CONTEXT; + +#endif /* SHIM_PEIMAGE_H */ diff --git a/include/variables.h b/include/variables.h index 436adb46..ee746ff6 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1,8 +1,8 @@ #ifndef SHIM_VARIABLES_H #define SHIM_VARIABLES_H -#include -#include /* for SHA256_DIGEST_SIZE */ +#include "efiauthenticated.h" +#include "pe.h" /* for SHA256_DIGEST_SIZE */ #define certlist_for_each_certentry(cl, cl_init, s, s_init) \ for (cl = (EFI_SIGNATURE_LIST *)(cl_init), s = (s_init); \ diff --git a/lib/security_policy.c b/lib/security_policy.c index 211f1cfd..b51bcf77 100644 --- a/lib/security_policy.c +++ b/lib/security_policy.c @@ -11,12 +11,7 @@ #include "shim.h" -#include -#include -#include - #if defined(OVERRIDE_SECURITY_POLICY) -#include /* * See the UEFI Platform Initialization manual (Vol2: DXE) for this diff --git a/shim.h b/shim.h index 0b3ad4f2..db372df4 100644 --- a/shim.h +++ b/shim.h @@ -128,13 +128,13 @@ #include "include/errors.h" #include "include/execute.h" #include "include/guid.h" -#include "include/Http.h" +#include "include/http.h" #include "include/httpboot.h" -#include "include/Ip4Config2.h" -#include "include/Ip6Config.h" +#include "include/ip4config2.h" +#include "include/ip6config.h" #include "include/netboot.h" -#include "include/PasswordCrypt.h" -#include "include/PeImage.h" +#include "include/passwordcrypt.h" +#include "include/pe.h" #include "include/replacements.h" #if defined(OVERRIDE_SECURITY_POLICY) #include "include/security_policy.h" -- cgit v1.2.3