]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/MmIoTrapDispatch.h
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Include / Protocol / MmIoTrapDispatch.h
CommitLineData
07c6a47e
ED
1/** @file\r
2 MM IO Trap Dispatch Protocol as defined in PI 1.5 Specification\r
3 Volume 4 Management Mode Core Interface.\r
4\r
5 This protocol provides a parent dispatch service for IO trap MMI sources.\r
6\r
7 Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
9344f092 8 SPDX-License-Identifier: BSD-2-Clause-Patent\r
07c6a47e
ED
9\r
10 @par Revision Reference:\r
11 This protocol is from PI Version 1.5.\r
12\r
13**/\r
14\r
15#ifndef _MM_IO_TRAP_DISPATCH_H_\r
16#define _MM_IO_TRAP_DISPATCH_H_\r
17\r
18#include <Pi/PiMmCis.h>\r
19\r
20#define EFI_MM_IO_TRAP_DISPATCH_PROTOCOL_GUID \\r
21 { \\r
22 0x58dc368d, 0x7bfa, 0x4e77, {0xab, 0xbc, 0xe, 0x29, 0x41, 0x8d, 0xf9, 0x30 } \\r
23 }\r
24\r
25///\r
26/// IO Trap valid types\r
27///\r
28typedef enum {\r
29 WriteTrap,\r
30 ReadTrap,\r
31 ReadWriteTrap,\r
32 IoTrapTypeMaximum\r
33} EFI_MM_IO_TRAP_DISPATCH_TYPE;\r
34\r
35///\r
36/// IO Trap context structure containing information about the\r
37/// IO trap event that should invoke the handler\r
38///\r
39typedef struct {\r
40 UINT16 Address;\r
41 UINT16 Length;\r
42 EFI_MM_IO_TRAP_DISPATCH_TYPE Type;\r
43} EFI_MM_IO_TRAP_REGISTER_CONTEXT;\r
44\r
45///\r
46/// IO Trap context structure containing information about the IO trap that occurred\r
47///\r
48typedef struct {\r
49 UINT32 WriteData;\r
50} EFI_MM_IO_TRAP_CONTEXT;\r
51\r
52typedef struct _EFI_MM_IO_TRAP_DISPATCH_PROTOCOL EFI_MM_IO_TRAP_DISPATCH_PROTOCOL;\r
53\r
54/**\r
55 Register an IO trap MMI child handler for a specified MMI.\r
56\r
57 This service registers a function (DispatchFunction) which will be called when an MMI is\r
58 generated because of an access to an I/O port specified by RegisterContext. On return,\r
59 DispatchHandle contains a unique handle which may be used later to unregister the function\r
60 using UnRegister(). If the base of the I/O range specified is zero, then an I/O range with the\r
61 specified length and characteristics will be allocated and the Address field in RegisterContext\r
62 updated. If no range could be allocated, then EFI_OUT_OF_RESOURCES will be returned.\r
63\r
64 The service will not perform GCD allocation if the base address is non-zero or\r
65 EFI_MM_READY_TO_LOCK has been installed. In this case, the caller is responsible for the\r
66 existence and allocation of the specific IO range.\r
67 An error may be returned if some or all of the requested resources conflict with an existing IO trap\r
68 child handler.\r
69\r
70 It is not required that implementations will allow multiple children for a single IO trap MMI source.\r
71 Some implementations may support multiple children.\r
72 The DispatchFunction will be called with Context updated to contain information\r
73 concerning the I/O action that actually happened and is passed in RegisterContext, with\r
74 CommBuffer pointing to the data actually written and CommBufferSize pointing to the size of\r
75 the data in CommBuffer.\r
76\r
77 @param[in] This Pointer to the EFI_MM_IO_TRAP_DISPATCH_PROTOCOL instance.\r
78 @param[in] DispatchFunction Function to register for handler when I/O trap location is accessed.\r
79 @param[in] RegisterContext Pointer to the dispatch function's context. The caller fills this\r
80 context in before calling the register function to indicate to the register\r
81 function the IO trap MMI source for which the dispatch function should be invoked.\r
82 @param[out] DispatchHandle Handle of the dispatch function, for when interfacing with the parent MM driver.\r
83\r
84 @retval EFI_SUCCESS The dispatch function has been successfully registered.\r
85 @retval EFI_DEVICE_ERROR The driver was unable to complete due to hardware error.\r
86 @retval EFI_OUT_OF_RESOURCES Insufficient resources are available to fulfill the IO trap range request.\r
87 @retval EFI_INVALID_PARAMETER RegisterContext is invalid. The input value is not within a valid range.\r
88**/\r
89typedef\r
90EFI_STATUS\r
91(EFIAPI *EFI_MM_IO_TRAP_DISPATCH_REGISTER)(\r
92 IN CONST EFI_MM_IO_TRAP_DISPATCH_PROTOCOL *This,\r
93 IN EFI_MM_HANDLER_ENTRY_POINT DispatchFunction,\r
94 IN OUT EFI_MM_IO_TRAP_REGISTER_CONTEXT *RegisterContext,\r
95 OUT EFI_HANDLE *DispatchHandle\r
96 );\r
97\r
98/**\r
99 Unregister a child MMI source dispatch function with a parent MM driver.\r
100\r
101 This service removes a previously installed child dispatch handler. This does not guarantee that the\r
102 system resources will be freed from the GCD.\r
103\r
104 @param[in] This Pointer to the EFI_MM_IO_TRAP_DISPATCH_PROTOCOL instance.\r
105 @param[in] DispatchHandle Handle of the child service to remove.\r
106\r
107 @retval EFI_SUCCESS The dispatch function has been successfully unregistered.\r
108 @retval EFI_INVALID_PARAMETER The DispatchHandle was not valid.\r
109**/\r
110typedef\r
111EFI_STATUS\r
112(EFIAPI *EFI_MM_IO_TRAP_DISPATCH_UNREGISTER)(\r
113 IN CONST EFI_MM_IO_TRAP_DISPATCH_PROTOCOL *This,\r
114 IN EFI_HANDLE DispatchHandle\r
115 );\r
116\r
117///\r
118/// Interface structure for the MM IO Trap Dispatch Protocol.\r
119///\r
120/// This protocol provides a parent dispatch service for IO trap MMI sources.\r
121///\r
122struct _EFI_MM_IO_TRAP_DISPATCH_PROTOCOL {\r
123 EFI_MM_IO_TRAP_DISPATCH_REGISTER Register;\r
124 EFI_MM_IO_TRAP_DISPATCH_UNREGISTER UnRegister;\r
125};\r
126\r
127extern EFI_GUID gEfiMmIoTrapDispatchProtocolGuid;\r
128\r
129#endif\r
130\r