Subrata Banik | 20fe24b | 2021-12-09 02:46:38 +0530 | [diff] [blame] | 1 | /** @file |
| 2 | MM USB Dispatch Protocol as defined in PI 1.5 Specification |
| 3 | Volume 4 Management Mode Core Interface. |
| 4 | |
| 5 | Provides the parent dispatch service for the USB MMI source generator. |
| 6 | |
| 7 | Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> |
| 8 | SPDX-License-Identifier: BSD-2-Clause-Patent |
| 9 | |
| 10 | @par Revision Reference: |
| 11 | This protocol is from PI Version 1.5. |
| 12 | |
| 13 | **/ |
| 14 | |
| 15 | #ifndef _MM_USB_DISPATCH_H_ |
| 16 | #define _MM_USB_DISPATCH_H_ |
| 17 | |
| 18 | #include <Pi/PiMmCis.h> |
| 19 | |
| 20 | #define EFI_MM_USB_DISPATCH_PROTOCOL_GUID \ |
| 21 | { \ |
| 22 | 0xee9b8d90, 0xc5a6, 0x40a2, {0xbd, 0xe2, 0x52, 0x55, 0x8d, 0x33, 0xcc, 0xa1 } \ |
| 23 | } |
| 24 | |
| 25 | /// |
| 26 | /// USB MMI event types |
| 27 | /// |
| 28 | typedef enum { |
| 29 | UsbLegacy, |
| 30 | UsbWake |
| 31 | } EFI_USB_MMI_TYPE; |
| 32 | |
| 33 | /// |
| 34 | /// The dispatch function's context. |
| 35 | /// |
| 36 | typedef struct { |
| 37 | /// |
| 38 | /// Describes whether this child handler will be invoked in response to a USB legacy |
| 39 | /// emulation event, such as port-trap on the PS/2* keyboard control registers, or to a |
| 40 | /// USB wake event, such as resumption from a sleep state. |
| 41 | /// |
| 42 | EFI_USB_MMI_TYPE Type; |
| 43 | /// |
| 44 | /// The device path is part of the context structure and describes the location of the |
| 45 | /// particular USB host controller in the system for which this register event will occur. |
| 46 | /// This location is important because of the possible integration of several USB host |
| 47 | /// controllers in a system. |
| 48 | /// |
| 49 | EFI_DEVICE_PATH_PROTOCOL *Device; |
| 50 | } EFI_MM_USB_REGISTER_CONTEXT; |
| 51 | |
| 52 | typedef struct _EFI_MM_USB_DISPATCH_PROTOCOL EFI_MM_USB_DISPATCH_PROTOCOL; |
| 53 | |
| 54 | /** |
| 55 | Provides the parent dispatch service for the USB MMI source generator. |
| 56 | |
| 57 | This service registers a function (DispatchFunction) which will be called when the USB- |
| 58 | related MMI specified by RegisterContext has occurred. On return, DispatchHandle |
| 59 | contains a unique handle which may be used later to unregister the function using UnRegister(). |
| 60 | The DispatchFunction will be called with Context set to the same value as was passed into |
| 61 | this function in RegisterContext and with CommBuffer containing NULL and |
| 62 | CommBufferSize containing zero. |
| 63 | |
| 64 | @param[in] This Pointer to the EFI_MM_USB_DISPATCH_PROTOCOL instance. |
| 65 | @param[in] DispatchFunction Function to register for handler when a USB-related MMI occurs. |
| 66 | @param[in] RegisterContext Pointer to the dispatch function's context. |
| 67 | The caller fills this context in before calling |
| 68 | the register function to indicate to the register |
| 69 | function the USB MMI types for which the dispatch |
| 70 | function should be invoked. |
| 71 | @param[out] DispatchHandle Handle generated by the dispatcher to track the function instance. |
| 72 | |
| 73 | @retval EFI_SUCCESS The dispatch function has been successfully |
| 74 | registered and the MMI source has been enabled. |
| 75 | @retval EFI_DEVICE_ERROR The driver was unable to enable the MMI source. |
| 76 | @retval EFI_INVALID_PARAMETER RegisterContext is invalid. The USB MMI type |
| 77 | is not within valid range. |
| 78 | @retval EFI_OUT_OF_RESOURCES There is not enough memory (system or MM) to manage this child. |
| 79 | **/ |
| 80 | typedef |
| 81 | EFI_STATUS |
| 82 | (EFIAPI *EFI_MM_USB_REGISTER)( |
| 83 | IN CONST EFI_MM_USB_DISPATCH_PROTOCOL *This, |
| 84 | IN EFI_MM_HANDLER_ENTRY_POINT DispatchFunction, |
| 85 | IN CONST EFI_MM_USB_REGISTER_CONTEXT *RegisterContext, |
| 86 | OUT EFI_HANDLE *DispatchHandle |
| 87 | ); |
| 88 | |
| 89 | /** |
| 90 | Unregisters a USB service. |
| 91 | |
| 92 | This service removes the handler associated with DispatchHandle so that it will no longer be |
| 93 | called when the USB event occurs. |
| 94 | |
| 95 | @param[in] This Pointer to the EFI_MM_USB_DISPATCH_PROTOCOL instance. |
| 96 | @param[in] DispatchHandle Handle of the service to remove. |
| 97 | |
| 98 | @retval EFI_SUCCESS The dispatch function has been successfully |
| 99 | unregistered and the MMI source has been disabled |
| 100 | if there are no other registered child dispatch |
| 101 | functions for this MMI source. |
| 102 | @retval EFI_INVALID_PARAMETER The DispatchHandle was not valid. |
| 103 | **/ |
| 104 | typedef |
| 105 | EFI_STATUS |
| 106 | (EFIAPI *EFI_MM_USB_UNREGISTER)( |
| 107 | IN CONST EFI_MM_USB_DISPATCH_PROTOCOL *This, |
| 108 | IN EFI_HANDLE DispatchHandle |
| 109 | ); |
| 110 | |
| 111 | /// |
| 112 | /// Interface structure for the MM USB MMI Dispatch Protocol |
| 113 | /// |
| 114 | /// This protocol provides the parent dispatch service for the USB MMI source generator. |
| 115 | /// |
| 116 | struct _EFI_MM_USB_DISPATCH_PROTOCOL { |
| 117 | EFI_MM_USB_REGISTER Register; |
| 118 | EFI_MM_USB_UNREGISTER UnRegister; |
| 119 | }; |
| 120 | |
| 121 | extern EFI_GUID gEfiMmUsbDispatchProtocolGuid; |
| 122 | |
| 123 | #endif |
| 124 | |