Ronak Kanabar | 1ae366f | 2023-06-07 01:21:56 +0530 | [diff] [blame^] | 1 | /** @file |
| 2 | SMM Software Dispatch Protocol introduced from PI 1.2 Specification |
| 3 | Volume 4 System Management Mode Core Interface. |
| 4 | |
| 5 | This protocol provides the parent dispatch service for a given SMI source generator. |
| 6 | |
| 7 | Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR> |
| 8 | SPDX-License-Identifier: BSD-2-Clause-Patent |
| 9 | |
| 10 | **/ |
| 11 | |
| 12 | #ifndef _SMM_SW_DISPATCH2_H_ |
| 13 | #define _SMM_SW_DISPATCH2_H_ |
| 14 | |
| 15 | #include <Protocol/MmSwDispatch.h> |
| 16 | #include <Pi/PiSmmCis.h> |
| 17 | |
| 18 | #define EFI_SMM_SW_DISPATCH2_PROTOCOL_GUID EFI_MM_SW_DISPATCH_PROTOCOL_GUID |
| 19 | |
| 20 | /// |
| 21 | /// A particular chipset may not support all possible software SMI input values. |
| 22 | /// For example, the ICH supports only values 00h to 0FFh. The parent only allows a single |
| 23 | /// child registration for each SwSmiInputValue. |
| 24 | /// |
| 25 | typedef struct { |
| 26 | UINTN SwSmiInputValue; |
| 27 | } EFI_SMM_SW_REGISTER_CONTEXT; |
| 28 | |
| 29 | /// |
| 30 | /// The DispatchFunction will be called with Context set to the same value as was passed into |
| 31 | /// this function in RegisterContext and with CommBuffer (and CommBufferSize) pointing |
| 32 | /// to an instance of EFI_SMM_SW_CONTEXT indicating the index of the CPU which generated the |
| 33 | /// software SMI. |
| 34 | /// |
| 35 | typedef struct { |
| 36 | /// |
| 37 | /// The 0-based index of the CPU which generated the software SMI. |
| 38 | /// |
| 39 | UINTN SwSmiCpuIndex; |
| 40 | /// |
| 41 | /// This value corresponds directly to the CommandPort parameter used in the call to Trigger(). |
| 42 | /// |
| 43 | UINT8 CommandPort; |
| 44 | /// |
| 45 | /// This value corresponds directly to the DataPort parameter used in the call to Trigger(). |
| 46 | /// |
| 47 | UINT8 DataPort; |
| 48 | } EFI_SMM_SW_CONTEXT; |
| 49 | |
| 50 | typedef struct _EFI_SMM_SW_DISPATCH2_PROTOCOL EFI_SMM_SW_DISPATCH2_PROTOCOL; |
| 51 | |
| 52 | /** |
| 53 | Register a child SMI source dispatch function for the specified software SMI. |
| 54 | |
| 55 | This service registers a function (DispatchFunction) which will be called when the software |
| 56 | SMI source specified by RegisterContext->SwSmiCpuIndex is detected. On return, |
| 57 | DispatchHandle contains a unique handle which may be used later to unregister the function |
| 58 | using UnRegister(). |
| 59 | |
| 60 | @param[in] This Pointer to the EFI_SMM_SW_DISPATCH2_PROTOCOL instance. |
| 61 | @param[in] DispatchFunction Function to register for handler when the specified software |
| 62 | SMI is generated. |
| 63 | @param[in, out] RegisterContext Pointer to the dispatch function's context. |
| 64 | The caller fills this context in before calling |
| 65 | the register function to indicate to the register |
| 66 | function which Software SMI input value the |
| 67 | dispatch function should be invoked for. |
| 68 | @param[out] DispatchHandle Handle generated by the dispatcher to track the |
| 69 | function instance. |
| 70 | |
| 71 | @retval EFI_SUCCESS The dispatch function has been successfully |
| 72 | registered and the SMI source has been enabled. |
| 73 | @retval EFI_DEVICE_ERROR The SW driver was unable to enable the SMI source. |
| 74 | @retval EFI_INVALID_PARAMETER RegisterContext is invalid. The SW SMI input value |
| 75 | is not within a valid range or is already in use. |
| 76 | @retval EFI_OUT_OF_RESOURCES There is not enough memory (system or SMM) to manage this |
| 77 | child. |
| 78 | @retval EFI_OUT_OF_RESOURCES A unique software SMI value could not be assigned |
| 79 | for this dispatch. |
| 80 | **/ |
| 81 | typedef |
| 82 | EFI_STATUS |
| 83 | (EFIAPI *EFI_SMM_SW_REGISTER2)( |
| 84 | IN CONST EFI_SMM_SW_DISPATCH2_PROTOCOL *This, |
| 85 | IN EFI_SMM_HANDLER_ENTRY_POINT2 DispatchFunction, |
| 86 | IN OUT EFI_SMM_SW_REGISTER_CONTEXT *RegisterContext, |
| 87 | OUT EFI_HANDLE *DispatchHandle |
| 88 | ); |
| 89 | |
| 90 | /** |
| 91 | Unregister a child SMI source dispatch function for the specified software SMI. |
| 92 | |
| 93 | This service removes the handler associated with DispatchHandle so that it will no longer be |
| 94 | called in response to a software SMI. |
| 95 | |
| 96 | @param[in] This Pointer to the EFI_SMM_SW_DISPATCH2_PROTOCOL instance. |
| 97 | @param[in] DispatchHandle Handle of dispatch function to deregister. |
| 98 | |
| 99 | @retval EFI_SUCCESS The dispatch function has been successfully unregistered. |
| 100 | @retval EFI_INVALID_PARAMETER The DispatchHandle was not valid. |
| 101 | **/ |
| 102 | typedef |
| 103 | EFI_STATUS |
| 104 | (EFIAPI *EFI_SMM_SW_UNREGISTER2)( |
| 105 | IN CONST EFI_SMM_SW_DISPATCH2_PROTOCOL *This, |
| 106 | IN EFI_HANDLE DispatchHandle |
| 107 | ); |
| 108 | |
| 109 | /// |
| 110 | /// Interface structure for the SMM Software SMI Dispatch Protocol. |
| 111 | /// |
| 112 | /// The EFI_SMM_SW_DISPATCH2_PROTOCOL provides the ability to install child handlers for the |
| 113 | /// given software. These handlers will respond to software interrupts, and the maximum software |
| 114 | /// interrupt in the EFI_SMM_SW_REGISTER_CONTEXT is denoted by MaximumSwiValue. |
| 115 | /// |
| 116 | struct _EFI_SMM_SW_DISPATCH2_PROTOCOL { |
| 117 | EFI_SMM_SW_REGISTER2 Register; |
| 118 | EFI_SMM_SW_UNREGISTER2 UnRegister; |
| 119 | /// |
| 120 | /// A read-only field that describes the maximum value that can be used in the |
| 121 | /// EFI_SMM_SW_DISPATCH2_PROTOCOL.Register() service. |
| 122 | /// |
| 123 | UINTN MaximumSwiValue; |
| 124 | }; |
| 125 | |
| 126 | extern EFI_GUID gEfiSmmSwDispatch2ProtocolGuid; |
| 127 | |
| 128 | #endif |