edk2/MdeModulePkg/Include/Ppi/SmmControl.h
Michael Kubacki 7a934d0bef MdeModulePkg: Replace include guards with #pragma once
Replace traditional `#ifndef`/`#define`/`#endif` include guards with
`#pragma` once.

`#pragma once` is a widely supported preprocessor directive that
prevents header files from being included multiple times. It is
supported by all toolchains used to build edk2: GCC, Clang/LLVM, and
MSVC.

Compared to macro-based include guards, `#pragma once`:

- Eliminates the risk of macro name collisions or copy/paste errors
  where two headers inadvertently use the same guard macro.
- Eliminate inconsistency in the way include guard macros are named
  (e.g., some files use `__FILE_H__`, others use `FILE_H_`, etc.).
- Reduces boilerplate (three lines replaced by one).
- Avoids polluting the macro namespace with guard symbols.
- Can improve build times as the preprocessor can skip re-opening the
  file entirely, rather than re-reading it to find the matching
  `#endif` ("multiple-include optimization").
  - Note that some compilers may already optimize traditional include
    guards, by recognzining the idiomatic pattern.

This change is made acknowledging that overall portability of the
code will technically be reduced, as `#pragma once` is not part of the
C/C++ standards.

However, this is considered acceptable given:

1. edk2 already defines a subset of supported compilers in
   BaseTools/Conf/tools_def.template, all of which have supported
   `#pragma once` for over two decades.
2. There have been concerns raised to the project about inconsistent
   include guard naming and potential macro collisions.

Approximate compiler support dates:

- MSVC: Supported since Visual C++ 4.2 (1996)
- GCC: Supported since 3.4 (2004)
  (http://gnu.ist.utl.pt/software/gcc/gcc-3.4/changes.html)
- Clang (LLVM based): Since initial release in 2007

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2026-02-23 21:01:28 +00:00

85 lines
3.5 KiB
C

/** @file
EFI SMM Control PPI definition.
This PPI is used to initiate SMI/PMI activations. This protocol could be published by either:
- A processor driver to abstract the SMI/PMI IPI
- The driver that abstracts the ASIC that is supporting the APM port, such as the ICH in an
Intel chipset
Because of the possibility of performing SMI or PMI IPI transactions, the ability to generate this
event from a platform chipset agent is an optional capability for both IA-32 and Itanium-based
systems.
Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#pragma once
#define PEI_SMM_CONTROL_PPI_GUID \
{ 0x61c68702, 0x4d7e, 0x4f43, 0x8d, 0xef, 0xa7, 0x43, 0x5, 0xce, 0x74, 0xc5 }
typedef struct _PEI_SMM_CONTROL_PPI PEI_SMM_CONTROL_PPI;
/**
Invokes SMI activation from either the preboot or runtime environment.
@param PeiServices General purpose services available to every PEIM.
@param This The PEI_SMM_CONTROL_PPI instance.
@param ArgumentBuffer The optional sized data to pass into the protocol activation.
@param ArgumentBufferSize The optional size of the data.
@param Periodic An optional mechanism to periodically repeat activation.
@param ActivationInterval An optional parameter to repeat at this period one
time or, if the Periodic Boolean is set, periodically.
@retval EFI_SUCCESS The SMI/PMI has been engendered.
@retval EFI_DEVICE_ERROR The timing is unsupported.
@retval EFI_INVALID_PARAMETER The activation period is unsupported.
@retval EFI_NOT_STARTED The SMM base service has not been initialized.
**/
typedef
EFI_STATUS
(EFIAPI *PEI_SMM_ACTIVATE)(
IN EFI_PEI_SERVICES **PeiServices,
IN PEI_SMM_CONTROL_PPI *This,
IN OUT INT8 *ArgumentBuffer OPTIONAL,
IN OUT UINTN *ArgumentBufferSize OPTIONAL,
IN BOOLEAN Periodic OPTIONAL,
IN UINTN ActivationInterval OPTIONAL
);
/**
Clears any system state that was created in response to the Active call.
@param PeiServices General purpose services available to every PEIM.
@param This The PEI_SMM_CONTROL_PPI instance.
@param Periodic Optional parameter to repeat at this period one
time or, if the Periodic Boolean is set, periodically.
@retval EFI_SUCCESS The SMI/PMI has been engendered.
@retval EFI_DEVICE_ERROR The source could not be cleared.
@retval EFI_INVALID_PARAMETER The service did not support the Periodic input argument.
**/
typedef
EFI_STATUS
(EFIAPI *PEI_SMM_DEACTIVATE)(
IN EFI_PEI_SERVICES **PeiServices,
IN PEI_SMM_CONTROL_PPI *This,
IN BOOLEAN Periodic OPTIONAL
);
///
/// PEI SMM Control PPI is used to initiate SMI/PMI activations. This protocol could be published by either:
/// - A processor driver to abstract the SMI/PMI IPI
/// - The driver that abstracts the ASIC that is supporting the APM port, such as the ICH in an
/// Intel chipset
///
struct _PEI_SMM_CONTROL_PPI {
PEI_SMM_ACTIVATE Trigger;
PEI_SMM_DEACTIVATE Clear;
};
extern EFI_GUID gPeiSmmControlPpiGuid;