You've already forked slimbootloader
mirror of
https://github.com/Dasharo/slimbootloader.git
synced 2026-03-06 15:26:20 -08:00
Convert the line endings stored for all text files in the repository to LF. The majority previously used DOS-style CRLF line endings. Add a .gitattributes file to enforce this and treat certain extensions as never being text files. Update PatchCheck.py to insist on LF line endings rather than CRLF. However, its other checks fail on this commit due to lots of pre-existing complaints that it only notices because the line endings have changed. Silicon/QemuSocPkg/FspBin/Patches/0001-Build-QEMU-FSP-2.0-binaries.patch needs to be treated as binary since it contains a mixture of line endings. This change has implications depending on the client platform you are using the repository from: * Windows The usual configuration for Git on Windows means that text files will be checked out to the work tree with DOS-style CRLF line endings. If that's not the case then you can configure Git to do so for the entire machine with: git config --global core.autocrlf true or for just the repository with: git config core.autocrlf true Line endings will be normalised to LF when they are committed to the repository. If you commit a text file with only LF line endings then it will be converted to CRLF line endings in your work tree. * Linux, MacOS and other Unices The usual configuration for Git on such platforms is to check files out of the repository with LF line endings. This is probably the right thing for you. In the unlikely even that you are using Git on Unix but editing or compiling on Windows for some reason then you may need to tweak your configuration to force the use of CRLF line endings as described above. * General For more information see https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings . Fixes: https://github.com/slimbootloader/slimbootloader/issues/1400 Signed-off-by: Mike Crowe <mac@mcrowe.com>
281 lines
6.6 KiB
C
281 lines
6.6 KiB
C
/** @file
|
|
|
|
Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
|
|
**/
|
|
|
|
#ifndef _USB_DEVICE_LIB_H_
|
|
#define _USB_DEVICE_LIB_H_
|
|
|
|
#include <Library/DebugLib.h>
|
|
#include <Library/BaseMemoryLib.h>
|
|
#include <Uefi/UefiBaseType.h>
|
|
#include <IndustryStandard/Usb.h>
|
|
#include <Library/MemoryAllocationLib.h>
|
|
|
|
//
|
|
// USB standard descriptors and reqeust
|
|
//
|
|
typedef USB_DEVICE_REQUEST EFI_USB_DEVICE_REQUEST;
|
|
typedef USB_DEVICE_DESCRIPTOR EFI_USB_DEVICE_DESCRIPTOR;
|
|
typedef USB_CONFIG_DESCRIPTOR EFI_USB_CONFIG_DESCRIPTOR;
|
|
typedef USB_INTERFACE_DESCRIPTOR EFI_USB_INTERFACE_DESCRIPTOR;
|
|
typedef USB_ENDPOINT_DESCRIPTOR EFI_USB_ENDPOINT_DESCRIPTOR;
|
|
|
|
#define MAX_DESCRIPTOR_SIZE 64
|
|
#define STRING_ARR_SIZE (MAX_DESCRIPTOR_SIZE - 2)
|
|
|
|
#ifdef SUPPORT_SUPER_SPEED
|
|
//
|
|
// USB device capability Type Codes
|
|
// USB3 Table 9-13
|
|
//
|
|
typedef enum {
|
|
WirelessUSB = 0x01,
|
|
USB2Extension,
|
|
SuperSpeedUSB,
|
|
ContainerID,
|
|
SuperSpeedPlusUSB = 0x0A
|
|
} USB_DEVICE_CAP_TYPE_CODE;
|
|
#endif
|
|
|
|
|
|
//
|
|
// USB device states from USB spec sec 9.1
|
|
//
|
|
typedef enum {
|
|
UsbDevStateOff = 0,
|
|
UsbDevStateInit,
|
|
UsbDevStateAttached,
|
|
UsbDevStatePowered,
|
|
UsbDevStateDefault,
|
|
UsbDevStateAddress,
|
|
UsbDevStateConfigured,
|
|
UsbDevStateSuspended,
|
|
UsbDevStateError
|
|
} USB_DEVICE_STATE;
|
|
|
|
|
|
//
|
|
// The following set of structs are used during USB data transaction
|
|
// operatitions, including requests and completion events.
|
|
//
|
|
#pragma pack(1)
|
|
|
|
typedef struct {
|
|
UINT32 EndpointNum;
|
|
UINT8 EndpointDir;
|
|
UINT8 EndpointType;
|
|
UINT32 Length;
|
|
VOID *Buffer;
|
|
} EFI_USB_DEVICE_XFER_INFO;
|
|
|
|
//
|
|
// SuperSpeed Endpoint companion descriptor
|
|
// USB3 table 9-22
|
|
//
|
|
typedef struct {
|
|
UINT8 Length;
|
|
UINT8 DescriptorType;
|
|
UINT8 MaxBurst;
|
|
UINT8 Attributes;
|
|
UINT16 BytesPerInterval;
|
|
} EFI_USB_ENDPOINT_COMPANION_DESCRIPTOR;
|
|
|
|
typedef struct {
|
|
EFI_USB_ENDPOINT_DESCRIPTOR *EndpointDesc;
|
|
EFI_USB_ENDPOINT_COMPANION_DESCRIPTOR *EndpointCompDesc;
|
|
} USB_DEVICE_ENDPOINT_INFO, USB_DEVICE_ENDPOINT_OBJ;
|
|
|
|
typedef struct {
|
|
VOID *Buffer;
|
|
UINT32 Length;
|
|
} USB_DEVICE_IO_INFO;
|
|
|
|
typedef struct {
|
|
USB_DEVICE_IO_INFO IoInfo;
|
|
USB_DEVICE_ENDPOINT_INFO EndpointInfo;
|
|
} USB_DEVICE_IO_REQ;
|
|
|
|
//
|
|
// Optional string descriptor
|
|
//
|
|
typedef struct {
|
|
UINT8 Length;
|
|
UINT8 DescriptorType;
|
|
UINT16 LangID[STRING_ARR_SIZE];
|
|
} USB_STRING_DESCRIPTOR;
|
|
|
|
|
|
//
|
|
// The following structures abstract the device descriptors a class
|
|
// driver needs to provide to the USBD core.
|
|
// These structures are filled & owned by the class/function layer.
|
|
//
|
|
typedef struct {
|
|
EFI_USB_INTERFACE_DESCRIPTOR *InterfaceDesc;
|
|
USB_DEVICE_ENDPOINT_OBJ *EndpointObjs;
|
|
} USB_DEVICE_INTERFACE_OBJ;
|
|
|
|
typedef struct {
|
|
EFI_USB_CONFIG_DESCRIPTOR *ConfigDesc;
|
|
VOID *ConfigAll;
|
|
USB_DEVICE_INTERFACE_OBJ *InterfaceObjs;
|
|
} USB_DEVICE_CONFIG_OBJ;
|
|
|
|
#ifdef SUPPORT_SUPER_SPEED
|
|
//
|
|
// SuperSpeed Binary Device Object Store(BOS) descriptor
|
|
// USB3 9.6.2
|
|
//
|
|
typedef struct {
|
|
UINT8 Length;
|
|
UINT8 DescriptorType;
|
|
UINT16 TotalLength;
|
|
UINT8 NumDeviceCaps;
|
|
} EFI_USB_BOS_DESCRIPTOR;
|
|
|
|
//
|
|
// Generic Header of Device Capability descriptor
|
|
// USB3 9.6.2.2
|
|
//
|
|
typedef struct {
|
|
UINT8 Length;
|
|
UINT8 DescriptorType;
|
|
UINT8 DevCapabilityType;
|
|
UINT8 CapDependent;
|
|
} EFI_USB_SS_DEVICE_CAP_DESCRIPTOR;
|
|
|
|
//
|
|
// USB2.0 Extension descriptor
|
|
// USB3 Table 9-14
|
|
//
|
|
typedef struct {
|
|
UINT8 Length;
|
|
UINT8 DescriptorType;
|
|
UINT8 DeviceCapabilityType;
|
|
UINT32 Attributes;
|
|
} EFI_USB_USB2_EXT_CAP_DESCRIPTOR;
|
|
|
|
|
|
//
|
|
// SuperSpeed USB Device Capability descriptor
|
|
// USB3 Table 9-15
|
|
//
|
|
typedef struct {
|
|
UINT8 Length;
|
|
UINT8 DescriptorType;
|
|
UINT8 DeviceCapabilityType;
|
|
UINT8 Attributes;
|
|
UINT16 SpeedSupported;
|
|
UINT8 FunctionalitySupport;
|
|
UINT8 U1DevExitLat;
|
|
UINT16 U2DevExitLat;
|
|
} EFI_USB_SS_USB_DEV_CAP_DESCRIPTOR;
|
|
|
|
//
|
|
// Container ID descriptor
|
|
// USB3 Table 9-16
|
|
//
|
|
typedef struct {
|
|
UINT8 Length;
|
|
UINT8 DescriptorType;
|
|
UINT8 DeviceCapabilityType;
|
|
UINT8 Reserved;
|
|
UINT8 UUID[16];
|
|
} EFI_USB_CONTAINER_ID_DESCRIPTOR;
|
|
|
|
//
|
|
// Container ID descriptor
|
|
// USB3 Table 9-16
|
|
//
|
|
typedef struct {
|
|
UINT8 Length;
|
|
UINT8 DescriptorType;
|
|
UINT8 DeviceCapabilityType;
|
|
UINT8 ReservedByte;
|
|
UINT32 Attributes;
|
|
UINT16 FunctionalitySupport;
|
|
UINT16 ReservedWord;
|
|
UINT32 SublinkSpeedAttr[2];
|
|
} EFI_USB_SS_PLUS_USB_DEV_CAP_DESCRIPTOR;
|
|
|
|
#endif
|
|
|
|
typedef
|
|
EFI_STATUS
|
|
(EFIAPI *EFI_USB_CONFIG_CALLBACK) (
|
|
IN UINT8 CfgVal
|
|
);
|
|
|
|
typedef
|
|
EFI_STATUS
|
|
(EFIAPI *EFI_USB_SETUP_CALLBACK) (
|
|
IN EFI_USB_DEVICE_REQUEST *CtrlRequest,
|
|
IN USB_DEVICE_IO_INFO *IoInfo
|
|
);
|
|
|
|
typedef
|
|
EFI_STATUS
|
|
(EFIAPI *EFI_USB_DATA_CALLBACK) (
|
|
IN EFI_USB_DEVICE_XFER_INFO *XferInfo
|
|
);
|
|
|
|
typedef struct {
|
|
USB_DEVICE_DESCRIPTOR *DeviceDesc;
|
|
USB_DEVICE_CONFIG_OBJ *ConfigObjs;
|
|
USB_STRING_DESCRIPTOR *StringTable;
|
|
#ifdef SUPPORT_SUPER_SPEED
|
|
EFI_USB_BOS_DESCRIPTOR *BosDesc;
|
|
#endif
|
|
UINT8 StrTblEntries;
|
|
EFI_USB_CONFIG_CALLBACK ConfigCallback;
|
|
EFI_USB_SETUP_CALLBACK SetupCallback;
|
|
EFI_USB_DATA_CALLBACK DataCallback;
|
|
} USB_DEVICE_OBJ;
|
|
|
|
|
|
//
|
|
// Main USBD driver object structure containing all data necessary
|
|
// for USB device mode processing at this layer
|
|
//
|
|
typedef struct {
|
|
USB_DEVICE_OBJ *UsbdDevObj; /* pointer to a Device Object */
|
|
VOID *XdciDrvObj; /* Opaque handle to XDCI driver */
|
|
BOOLEAN XdciInitialized; /* flag to specify if the XDCI driver is initialized */
|
|
USB_DEVICE_CONFIG_OBJ *ActiveConfigObj; /* pointer to currently active configuraiton */
|
|
USB_DEVICE_STATE State; /* current state of the USB Device state machine */
|
|
UINT8 Address; /* configured device address */
|
|
} USB_DEVICE_DRIVER_OBJ;
|
|
|
|
typedef struct {
|
|
UINT8 Bus;
|
|
UINT8 Device;
|
|
UINT8 Func;
|
|
UINT8 Reserved;
|
|
} PCI_ADDRESS;
|
|
|
|
typedef struct {
|
|
PCI_ADDRESS XhciDeviceAddress;
|
|
PCI_ADDRESS XdciDeviceAddress;
|
|
} USB_DEVICE_PLATFORM_INFO;
|
|
#pragma pack()
|
|
|
|
|
|
/**
|
|
This function performs device initialization.
|
|
|
|
@param[in,out] Prot USB device mode protocol
|
|
|
|
@retval EFI_SUCCESS Successfully polled the value.
|
|
@retval EFI_TIMEOUT Timeout while polling the value.
|
|
**/
|
|
EFI_STATUS
|
|
EFIAPI
|
|
UsbDeviceInitialization (
|
|
IN OUT VOID **Prot
|
|
);
|
|
|
|
#endif
|