mirror of
https://github.com/Dasharo/edk2-upstream.git
synced 2026-06-13 19:16:19 -07:00
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>
115 lines
3.5 KiB
C
115 lines
3.5 KiB
C
/** @file
|
|
EBC Simple Debugger protocol for debug EBC code.
|
|
|
|
Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
|
|
**/
|
|
|
|
#pragma once
|
|
|
|
#include <Protocol/DebugSupport.h>
|
|
#include <Protocol/EbcVmTest.h>
|
|
|
|
#define EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL_GUID \
|
|
{ \
|
|
0x2a72d11e, 0x7376, 0x40f6, { 0x9c, 0x68, 0x23, 0xfa, 0x2f, 0xe3, 0x63, 0xf1 } \
|
|
}
|
|
|
|
//
|
|
// Defines for a simple EBC debugger interface
|
|
//
|
|
typedef struct _EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL;
|
|
|
|
/**
|
|
Trig Exception on EBC VM.
|
|
|
|
@param[in] This A pointer to the EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL structure.
|
|
@param[in] VmPtr A pointer to a VM context.
|
|
@param[in] ExceptionType Exception to be trigged.
|
|
|
|
@retval EFI_UNSUPPORTED No support for it.
|
|
@retval EFI_SUCCESS Exception is trigged.
|
|
|
|
**/
|
|
typedef
|
|
EFI_STATUS
|
|
(EFIAPI *EBC_DEBUGGER_SIGNAL_EXCEPTION)(
|
|
IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL *This,
|
|
IN VM_CONTEXT *VmPtr,
|
|
IN EFI_EXCEPTION_TYPE ExceptionType
|
|
);
|
|
|
|
/**
|
|
Given a pointer to a new VM context, debug one or more instructions.
|
|
|
|
@param[in] This A pointer to the EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL structure.
|
|
@param[in] VmPtr A pointer to a VM context.
|
|
|
|
@retval EFI_UNSUPPORTED No support for it.
|
|
@retval EFI_SUCCESS Debug one or more instructions.
|
|
|
|
**/
|
|
typedef
|
|
VOID
|
|
(EFIAPI *EBC_DEBUGGER_DEBUG)(
|
|
IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL *This,
|
|
IN VM_CONTEXT *VmPtr
|
|
);
|
|
|
|
/**
|
|
Given a pointer to a new VM context, dump one or more instructions.
|
|
|
|
@param[in] This A pointer to the EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL structure.
|
|
@param[in] VmPtr A pointer to a VM context.
|
|
@param[in] DasmString Dump string buffer.
|
|
@param[in] DasmStringSize Dump string size.
|
|
|
|
@retval EFI_UNSUPPORTED No support for it.
|
|
@retval EFI_SUCCESS Dump one or more instructions.
|
|
|
|
**/
|
|
typedef
|
|
UINT32
|
|
(EFIAPI *EBC_DEBUGGER_DASM)(
|
|
IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL *This,
|
|
IN VM_CONTEXT *VmPtr,
|
|
IN UINT16 *DasmString OPTIONAL,
|
|
IN UINT32 DasmStringSize
|
|
);
|
|
|
|
/**
|
|
This interface allows you to configure the EBC debug support
|
|
driver. For example, turn on or off saving and printing of
|
|
delta VM even if called. Or to even disable the entire interface,
|
|
in which case all functions become no-ops.
|
|
|
|
@param[in] This A pointer to the EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL structure.
|
|
@param[in] ConfigId ID to be configured.
|
|
@param[in] ConfigValue Value to be set.
|
|
|
|
@retval EFI_UNSUPPORTED No support for it.
|
|
@retval EFI_SUCCESS Configure EBC debug.
|
|
|
|
**/
|
|
typedef
|
|
EFI_STATUS
|
|
(EFIAPI *EBC_DEBUGGER_CONFIGURE)(
|
|
IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL *This,
|
|
IN UINT32 ConfigId,
|
|
IN UINTN ConfigValue
|
|
);
|
|
|
|
//
|
|
// Prototype for the actual EBC debug support protocol interface
|
|
//
|
|
struct _EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL {
|
|
EBC_DEBUGGER_DEBUG Debugger;
|
|
EBC_DEBUGGER_SIGNAL_EXCEPTION SignalException;
|
|
EBC_DEBUGGER_DASM Dasm;
|
|
EBC_DEBUGGER_CONFIGURE Configure;
|
|
};
|
|
|
|
extern EFI_GUID gEfiEbcSimpleDebuggerProtocolGuid;
|