Home | History | Annotate | Download | only in Protocol
      1 /** @file
      2   SMM IO Trap Dispatch2 Protocol as defined in PI 1.1 Specification
      3   Volume 4 System Management Mode Core Interface.
      4 
      5   This protocol provides a parent dispatch service for IO trap SMI sources.
      6 
      7   Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>
      8   This program and the accompanying materials
      9   are licensed and made available under the terms and conditions of the BSD License
     10   which accompanies this distribution.  The full text of the license may be found at
     11   http://opensource.org/licenses/bsd-license.php
     12 
     13   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     14   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     15 
     16   @par Revision Reference:
     17   This protocol is from PI Version 1.1.
     18 
     19 **/
     20 
     21 #ifndef _SMM_IO_TRAP_DISPATCH2_H_
     22 #define _SMM_IO_TRAP_DISPATCH2_H_
     23 
     24 #include <Pi/PiSmmCis.h>
     25 
     26 #define EFI_SMM_IO_TRAP_DISPATCH2_PROTOCOL_GUID \
     27   { \
     28     0x58dc368d, 0x7bfa, 0x4e77, {0xab, 0xbc, 0xe, 0x29, 0x41, 0x8d, 0xf9, 0x30 } \
     29   }
     30 
     31 ///
     32 /// IO Trap valid types
     33 ///
     34 typedef enum {
     35   WriteTrap,
     36   ReadTrap,
     37   ReadWriteTrap,
     38   IoTrapTypeMaximum
     39 } EFI_SMM_IO_TRAP_DISPATCH_TYPE;
     40 
     41 ///
     42 /// IO Trap context structure containing information about the
     43 /// IO trap event that should invoke the handler
     44 ///
     45 typedef struct {
     46   UINT16                         Address;
     47   UINT16                         Length;
     48   EFI_SMM_IO_TRAP_DISPATCH_TYPE  Type;
     49 } EFI_SMM_IO_TRAP_REGISTER_CONTEXT;
     50 
     51 ///
     52 /// IO Trap context structure containing information about the IO trap that occurred
     53 ///
     54 typedef struct {
     55   UINT32  WriteData;
     56 } EFI_SMM_IO_TRAP_CONTEXT;
     57 
     58 typedef struct _EFI_SMM_IO_TRAP_DISPATCH2_PROTOCOL EFI_SMM_IO_TRAP_DISPATCH2_PROTOCOL;
     59 
     60 /**
     61   Register an IO trap SMI child handler for a specified SMI.
     62 
     63   This service registers a function (DispatchFunction) which will be called when an SMI is
     64   generated because of an access to an I/O port specified by RegisterContext. On return,
     65   DispatchHandle contains a unique handle which may be used later to unregister the function
     66   using UnRegister(). If the base of the I/O range specified is zero, then an I/O range with the
     67   specified length and characteristics will be allocated and the Address field in RegisterContext
     68   updated. If no range could be allocated, then EFI_OUT_OF_RESOURCES will be returned.
     69 
     70   The service will not perform GCD allocation if the base address is non-zero or
     71   EFI_SMM_READY_TO_LOCK has been installed.  In this case, the caller is responsible for the
     72   existence and allocation of the specific IO range.
     73   An error may be returned if some or all of the requested resources conflict with an existing IO trap
     74   child handler.
     75 
     76   It is not required that implementations will allow multiple children for a single IO trap SMI source.
     77   Some implementations may support multiple children.
     78   The DispatchFunction will be called with Context updated to contain information
     79   concerning the I/O action that actually happened and is passed in RegisterContext, with
     80   CommBuffer pointing to the data actually written and CommBufferSize pointing to the size of
     81   the data in CommBuffer.
     82 
     83   @param[in]  This               Pointer to the EFI_SMM_IO_TRAP_DISPATCH2_PROTOCOL instance.
     84   @param[in]  DispatchFunction   Function to register for handler when I/O trap location is accessed.
     85   @param[in]  RegisterContext    Pointer to the dispatch function's context.  The caller fills this
     86                                  context in before calling the register function to indicate to the register
     87                                  function the IO trap SMI source for which the dispatch function should be invoked.
     88   @param[out] DispatchHandle     Handle of the dispatch function, for when interfacing with the parent SMM driver.
     89 
     90   @retval EFI_SUCCESS            The dispatch function has been successfully registered.
     91   @retval EFI_DEVICE_ERROR       The driver was unable to complete due to hardware error.
     92   @retval EFI_OUT_OF_RESOURCES   Insufficient resources are available to fulfill the IO trap range request.
     93   @retval EFI_INVALID_PARAMETER  RegisterContext is invalid.  The input value is not within a valid range.
     94 **/
     95 typedef
     96 EFI_STATUS
     97 (EFIAPI *EFI_SMM_IO_TRAP_DISPATCH2_REGISTER)(
     98   IN CONST EFI_SMM_IO_TRAP_DISPATCH2_PROTOCOL  *This,
     99   IN       EFI_SMM_HANDLER_ENTRY_POINT2        DispatchFunction,
    100   IN OUT   EFI_SMM_IO_TRAP_REGISTER_CONTEXT    *RegisterContext,
    101      OUT   EFI_HANDLE                          *DispatchHandle
    102   );
    103 
    104 /**
    105   Unregister a child SMI source dispatch function with a parent SMM driver.
    106 
    107   This service removes a previously installed child dispatch handler. This does not guarantee that the
    108   system resources will be freed from the GCD.
    109 
    110   @param[in] This                Pointer to the EFI_SMM_IO_TRAP_DISPATCH2_PROTOCOL instance.
    111   @param[in] DispatchHandle      Handle of the child service to remove.
    112 
    113   @retval EFI_SUCCESS            The dispatch function has been successfully unregistered.
    114   @retval EFI_INVALID_PARAMETER  The DispatchHandle was not valid.
    115 **/
    116 typedef
    117 EFI_STATUS
    118 (EFIAPI *EFI_SMM_IO_TRAP_DISPATCH2_UNREGISTER)(
    119   IN CONST EFI_SMM_IO_TRAP_DISPATCH2_PROTOCOL  *This,
    120   IN       EFI_HANDLE                          DispatchHandle
    121   );
    122 
    123 ///
    124 /// Interface structure for the SMM IO Trap Dispatch2 Protocol.
    125 ///
    126 /// This protocol provides a parent dispatch service for IO trap SMI sources.
    127 ///
    128 struct _EFI_SMM_IO_TRAP_DISPATCH2_PROTOCOL {
    129   EFI_SMM_IO_TRAP_DISPATCH2_REGISTER    Register;
    130   EFI_SMM_IO_TRAP_DISPATCH2_UNREGISTER  UnRegister;
    131 };
    132 
    133 extern EFI_GUID gEfiSmmIoTrapDispatch2ProtocolGuid;
    134 
    135 #endif
    136 
    137