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>
140 lines
4.3 KiB
C
140 lines
4.3 KiB
C
/** @file
|
|
EDKII_UFS_HC_PLATFORM_PROTOCOL definition.
|
|
|
|
Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.<BR>
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
|
|
**/
|
|
|
|
#pragma once
|
|
|
|
#include <Protocol/UfsHostController.h>
|
|
|
|
#define EDKII_UFS_HC_PLATFORM_PROTOCOL_VERSION 3
|
|
|
|
extern EFI_GUID gEdkiiUfsHcPlatformProtocolGuid;
|
|
|
|
typedef struct _EDKII_UFS_HC_PLATFORM_PROTOCOL EDKII_UFS_HC_PLATFORM_PROTOCOL;
|
|
|
|
typedef struct _EDKII_UFS_HC_DRIVER_INTERFACE EDKII_UFS_HC_DRIVER_INTERFACE;
|
|
|
|
typedef struct {
|
|
UINT32 Opcode;
|
|
UINT32 Arg1;
|
|
UINT32 Arg2;
|
|
UINT32 Arg3;
|
|
} EDKII_UIC_COMMAND;
|
|
|
|
/**
|
|
Execute UIC command
|
|
|
|
@param[in] This Pointer to driver interface produced by the UFS controller.
|
|
@param[in, out] UicCommand Descriptor of the command that will be executed.
|
|
|
|
@retval EFI_SUCCESS Command executed successfully.
|
|
@retval EFI_INVALID_PARAMETER This or UicCommand is NULL.
|
|
@retval Others Command failed to execute.
|
|
**/
|
|
typedef
|
|
EFI_STATUS
|
|
(EFIAPI *EDKII_UFS_EXEC_UIC_COMMAND)(
|
|
IN EDKII_UFS_HC_DRIVER_INTERFACE *This,
|
|
IN OUT EDKII_UIC_COMMAND *UicCommand
|
|
);
|
|
|
|
struct _EDKII_UFS_HC_DRIVER_INTERFACE {
|
|
///
|
|
/// Protocol to accesss host controller MMIO and PCI registers.
|
|
///
|
|
EDKII_UFS_HOST_CONTROLLER_PROTOCOL *UfsHcProtocol;
|
|
///
|
|
/// Function implementing UIC command execution.
|
|
///
|
|
EDKII_UFS_EXEC_UIC_COMMAND UfsExecUicCommand;
|
|
};
|
|
|
|
typedef struct {
|
|
UINT32 Capabilities;
|
|
UINT32 Version;
|
|
} EDKII_UFS_HC_INFO;
|
|
|
|
/**
|
|
Allows platform protocol to override host controller information
|
|
|
|
@param[in] ControllerHandle Handle of the UFS controller.
|
|
@param[in, out] HcInfo Pointer EDKII_UFS_HC_INFO associated with host controller.
|
|
|
|
@retval EFI_SUCCESS Function completed successfully.
|
|
@retval EFI_INVALID_PARAMETER HcInfo is NULL.
|
|
@retval Others Function failed to complete.
|
|
**/
|
|
typedef
|
|
EFI_STATUS
|
|
(EFIAPI *EDKII_UFS_HC_PLATFORM_OVERRIDE_HC_INFO)(
|
|
IN EFI_HANDLE ControllerHandle,
|
|
IN OUT EDKII_UFS_HC_INFO *HcInfo
|
|
);
|
|
|
|
typedef enum {
|
|
EdkiiUfsHcPreHce,
|
|
EdkiiUfsHcPostHce,
|
|
EdkiiUfsHcPreLinkStartup,
|
|
EdkiiUfsHcPostLinkStartup
|
|
} EDKII_UFS_HC_PLATFORM_CALLBACK_PHASE;
|
|
|
|
typedef enum {
|
|
EdkiiUfsCardRefClkFreq19p2Mhz,
|
|
EdkiiUfsCardRefClkFreq26Mhz,
|
|
EdkiiUfsCardRefClkFreq38p4Mhz,
|
|
EdkiiUfsCardRefClkFreqObsolete
|
|
} EDKII_UFS_CARD_REF_CLK_FREQ_ATTRIBUTE;
|
|
|
|
/**
|
|
Callback function for platform driver.
|
|
|
|
@param[in] ControllerHandle Handle of the UFS controller.
|
|
@param[in] CallbackPhase Specifies when the platform protocol is called
|
|
@param[in, out] CallbackData Data specific to the callback phase.
|
|
For PreHce and PostHce - EDKII_UFS_HC_DRIVER_INTERFACE.
|
|
For PreLinkStartup and PostLinkStartup - EDKII_UFS_HC_DRIVER_INTERFACE.
|
|
|
|
@retval EFI_SUCCESS Override function completed successfully.
|
|
@retval EFI_INVALID_PARAMETER CallbackPhase is invalid or CallbackData is NULL when phase expects valid data.
|
|
@retval Others Function failed to complete.
|
|
**/
|
|
typedef
|
|
EFI_STATUS
|
|
(EFIAPI *EDKII_UFS_HC_PLATFORM_CALLBACK)(
|
|
IN EFI_HANDLE ControllerHandle,
|
|
IN EDKII_UFS_HC_PLATFORM_CALLBACK_PHASE CallbackPhase,
|
|
IN OUT VOID *CallbackData
|
|
);
|
|
|
|
struct _EDKII_UFS_HC_PLATFORM_PROTOCOL {
|
|
///
|
|
/// Version of the protocol.
|
|
///
|
|
UINT32 Version;
|
|
///
|
|
/// Allows platform driver to override host controller information.
|
|
///
|
|
EDKII_UFS_HC_PLATFORM_OVERRIDE_HC_INFO OverrideHcInfo;
|
|
///
|
|
/// Allows platform driver to implement platform specific flows
|
|
/// for host controller.
|
|
///
|
|
EDKII_UFS_HC_PLATFORM_CALLBACK Callback;
|
|
///
|
|
/// Reference Clock Frequency Ufs Card Attribute that need to be set in this Ufs Host Environment.
|
|
///
|
|
EDKII_UFS_CARD_REF_CLK_FREQ_ATTRIBUTE RefClkFreq;
|
|
///
|
|
/// Flag to skip HCE re-enable.
|
|
///
|
|
BOOLEAN SkipHceReenable;
|
|
///
|
|
/// Flag to skip link startup.
|
|
///
|
|
BOOLEAN SkipLinkStartup;
|
|
};
|