From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web10.3767.1675133364505010001 for ; Mon, 30 Jan 2023 18:49:24 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=N90gar6p; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: victorx.hsu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675133364; x=1706669364; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=1nTx1D2OWa3tZ/LJNO6Pi+Pe794jXCEPo9hyCIhbClw=; b=N90gar6pE8mulR+BMFhnpke7wdru82qR+4IedWy295Z+OEZbeUd7YnVm FpJucboXNI3vnQb95iurg2zfWWNsLFTnmwJmIs5X5IXJVVejy/SEHWEjB RIXt7EMG/OPfov37rnLLWzblOZeIr/ef1yYSTXFdmUmDGfB2iAPI2MeDa 2WpNfKgk6bZB+U7F8yTyPKydNCuZJlDWxB4kIjo8lMDamiwgT9+5hEjfN 1RL4IGAaEm3gY0jpa1Mb3tLIaNx9Lv6YI0Ak+ilcEUGDG9mUDhMaSUzgR Obki8PZYirS6uJV1syT+xPdYU6c7oIE29MzCGY5Yr+SHJR/UQQm/w2VAt g==; X-IronPort-AV: E=McAfee;i="6500,9779,10606"; a="329008458" X-IronPort-AV: E=Sophos;i="5.97,259,1669104000"; d="scan'208";a="329008458" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jan 2023 18:49:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10606"; a="753077479" X-IronPort-AV: E=Sophos;i="5.97,259,1669104000"; d="scan'208";a="753077479" Received: from hsuc1x-desk1.gar.corp.intel.com ([10.227.107.38]) by FMSMGA003.fm.intel.com with ESMTP; 30 Jan 2023 18:49:21 -0800 From: victorx.hsu@intel.com To: devel@edk2.groups.io Cc: VictorX Hsu , Michael D Kinney , Guo Gua , Chan Laura , Prakashan Krishnadas Veliyathuparambil , K N Karthik Subject: [PATCH 1/4] MdePkg: Add MipiSysTLib library Date: Tue, 31 Jan 2023 10:48:59 +0800 Message-Id: <29c690501f493d9d003ee7089228a7273c3ff091.1675131785.git.victorx.hsu@intel.com> X-Mailer: git-send-email 2.28.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: VictorX Hsu REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4144 Wrap mipi sys-T submodule as a MipiSysTLib. This Library provide mipi sys-T API to be consumed. Cc: Michael D Kinney Cc: Guo Gua Cc: Chan Laura Cc: Prakashan Krishnadas Veliyathuparambil Cc: K N Karthik Signed-off-by: VictorX Hsu --- .gitmodules | 5 +- .pytool/CISettings.py | 2 + MdePkg/Include/Library/MipiSysTLib.h | 242 +++++++++ MdePkg/Library/MipiSysTLib/MipiSysTLib.c | 110 +++++ MdePkg/Library/MipiSysTLib/MipiSysTLib.inf | 52 ++ MdePkg/Library/MipiSysTLib/Platform.c | 160 ++++++ MdePkg/Library/MipiSysTLib/Platform.h | 140 ++++++ MdePkg/Library/MipiSysTLib/mipi_syst.h | 539 +++++++++++++++++++++ MdePkg/Library/MipiSysTLib/mipisyst | 1 + MdePkg/MdePkg.ci.yaml | 4 +- MdePkg/MdePkg.dec | 5 + MdePkg/MdePkg.dsc | 2 + ReadMe.rst | 1 + 13 files changed, 1261 insertions(+), 2 deletions(-) create mode 100644 MdePkg/Include/Library/MipiSysTLib.h create mode 100644 MdePkg/Library/MipiSysTLib/MipiSysTLib.c create mode 100644 MdePkg/Library/MipiSysTLib/MipiSysTLib.inf create mode 100644 MdePkg/Library/MipiSysTLib/Platform.c create mode 100644 MdePkg/Library/MipiSysTLib/Platform.h create mode 100644 MdePkg/Library/MipiSysTLib/mipi_syst.h create mode 160000 MdePkg/Library/MipiSysTLib/mipisyst diff --git a/.gitmodules b/.gitmodules index 8011a88d9d..4a0500eea4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,10 +16,13 @@ [submodule "BaseTools/Source/C/BrotliCompress/brotli"] path =3D BaseTools/Source/C/BrotliCompress/brotli url =3D https://github.com/google/brotli - ignore =3D untracked=0D + ignore =3D untracked [submodule "RedfishPkg/Library/JsonLib/jansson"] path =3D RedfishPkg/Library/JsonLib/jansson url =3D https://github.com/akheron/jansson [submodule "UnitTestFrameworkPkg/Library/GoogleTestLib/googletest"] path =3D UnitTestFrameworkPkg/Library/GoogleTestLib/googletest url =3D https://github.com/google/googletest.git +[submodule "MdePkg/Library/MipiSysTLib/mipisyst"] + path =3D MdePkg/Library/MipiSysTLib/mipisyst + url =3D https://github.com/MIPI-Alliance/public-mipi-sys-t.git diff --git a/.pytool/CISettings.py b/.pytool/CISettings.py index d87c8e838e..0118820680 100644 --- a/.pytool/CISettings.py +++ b/.pytool/CISettings.py @@ -193,6 +193,8 @@ class Settings(CiBuildSettingsManager, UpdateSettingsMa= nager, SetupSettingsManag "BaseTools/Source/C/BrotliCompress/brotli", False))=0D rs.append(RequiredSubmodule(=0D "RedfishPkg/Library/JsonLib/jansson", False))=0D + rs.append(RequiredSubmodule(=0D + "MdePkg/Library/MipiSysTLib/mipisyst", False))=0D return rs=0D =0D def GetName(self):=0D diff --git a/MdePkg/Include/Library/MipiSysTLib.h b/MdePkg/Include/Library/= MipiSysTLib.h new file mode 100644 index 0000000000..6282baac8e --- /dev/null +++ b/MdePkg/Include/Library/MipiSysTLib.h @@ -0,0 +1,242 @@ +/** @file=0D +=0D +Copyright (c) 2023, Intel Corporation. All rights reserved.
=0D +=0D +SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#ifndef MIPI_SYST_LIB_H_=0D +#define MIPI_SYST_LIB_H_=0D +=0D +#include =0D +=0D +#define MIPI_SYST_CONFORMANCE_LEVEL 30=0D +#define MIPI_SYST_PCFG_ENABLE_PLATFORM_HANDLE_DATA=0D +#define MIPI_SYST_PCFG_ENABLE_ORIGIN_GUID=0D +=0D +struct mipi_syst_header;=0D +struct mipi_syst_handle;=0D +struct mipi_syst_scatter_prog;=0D +=0D +/**=0D + * SyS-T handle state initialization hook definition=0D + *=0D + * This function gets called in the context of IO handle generation.=0D + * Its purpose is to initialize the platform dependent portion of=0D +* the handle and other necessary platform specific initialization steps.= =0D + *=0D + * @param systh Pointer to new SyS-T handle=0D + * @see syst_handle_t=0D + */=0D +typedef void (*mipi_syst_inithandle_hook_t)(=0D + struct mipi_syst_handle *systh=0D + );=0D +=0D +/**=0D + * SyS-T handle state release hook definition=0D + *=0D + * This function gets called when a handle is about to be destroyed..=0D + * Its purpose is to free any resources allocated during the handle=0D + * generation.=0D + *=0D + * @param systh Pointer to handle that is destroyed=0D + * @see syst_handle_t=0D + */=0D +typedef void (*mipi_syst_releasehandle_hook_t)(=0D + struct mipi_syst_handle *systh=0D + );=0D +=0D +/**=0D + * Low level message write routine definition=0D + *=0D + * This function is called at the end of an instrumentation API to output= =0D + * the raw message data.=0D + *=0D + * @param systh pointer to a SyS-T handle structure used in the API call,= =0D + * @param scatterprog pointer to a list of scatter write instructions that= =0D + * encodes how to convert the descriptor pointer by=0D + * pdesc into raw binary data. This list doesn't includ= e=0D + * the mandatory first 32 tag byte value pointed by pde= sc.=0D + * @param pdesc pointer to a message descriptor, which containing at least= =0D + * the 32-bit message tag data=0D + */=0D +typedef void (*mipi_syst_msg_write_t)(=0D + struct mipi_syst_handle *systh,=0D + struct mipi_syst_scatter_prog *scatterprog,=0D + const void *pdesc=0D + );=0D +=0D +typedef struct {=0D + UINTN MmioAddr;=0D +} TRACE_HUB_PLATFORM_SYST_DATA;=0D +=0D +struct mipi_syst_platform_handle {=0D + TRACE_HUB_PLATFORM_SYST_DATA TraceHubPlatformData;=0D +};=0D +=0D +/** internal handle state flags=0D + */=0D +typedef struct mipi_syst_handle_flags {=0D + UINT32 shf_alloc : 1; /**< set to 1 if heap allocated handle */=0D +} MIPI_SYST_HANDLE_FLAGS;=0D +=0D +/**=0D + * Message data header tag definition=0D + *=0D + * Each SyS-T message starts with a 32-bit message tag. The tag defines th= e=0D + * message originator and decoding information for the data following=0D + * the tag.=0D + */=0D +=0D +typedef struct mipi_syst_msg_tag {=0D + #if defined (MIPI_SYST_BIG_ENDIAN)=0D + UINT32 et_res31 : 1; /**< reserved for future use */=0D + UINT32 et_res30 : 1; /**< reserved for future use */=0D + UINT32 et_subtype : 6; /**< type dependent sub category */=0D + UINT32 et_guid : 1; /**< 128-bit GUID present */=0D + UINT32 et_modunit : 11; /**< unit for GUID or module:unit */=0D + UINT32 et_timestamp : 1; /**< indicate 64-bit timestamp */=0D + UINT32 et_chksum : 1; /**< indicate 32-bit CRC */=0D + UINT32 et_length : 1; /**< indicate length field */=0D + UINT32 et_location : 1; /**< indicate location information */=0D + UINT32 et_res7 : 1; /**< reserved for future use */=0D + UINT32 et_severity : 3; /**< severity level of message */=0D + UINT32 et_type : 4; /**< SyS-T message type ID */=0D + #else=0D + UINT32 et_type : 4; /**< SyS-T message type ID */=0D + UINT32 et_severity : 3; /**< severity level of message */=0D + UINT32 et_res7 : 1; /**< reserved for future use */=0D + UINT32 et_location : 1; /**< indicate location information */=0D + UINT32 et_length : 1; /**< indicate length field */=0D + UINT32 et_chksum : 1; /**< indicate 32-bit CRC */=0D + UINT32 et_timestamp : 1; /**< indicate 64-bit timestamp */=0D + UINT32 et_modunit : 11; /**< unit for GUID or module:unit */=0D + UINT32 et_guid : 1; /**< 128-bit GUID present */=0D + UINT32 et_subtype : 6; /**< type dependent sub category */=0D + UINT32 et_res30 : 1; /**< reserved for future use */=0D + UINT32 et_res31 : 1; /**< reserved for future use */=0D + #endif=0D +} MIPI_SYST_MSG_TAG;=0D +=0D +/** 128-bit GUID style message origin ID */=0D +typedef struct mipi_syst_guid {=0D + union {=0D + UINT8 b[16];=0D + UINT64 ll[2];=0D + } u;=0D +} MIPI_SYST_GUID;=0D +=0D +/**=0D + * Message severity level enumeration=0D + */=0D +typedef enum mipi_syst_severity {=0D + MIPI_SYST_SEVERITY_MAX =3D 0, /**< no assigned severity */=0D + MIPI_SYST_SEVERITY_FATAL =3D 1, /**< critical error level */=0D + MIPI_SYST_SEVERITY_ERROR =3D 2, /**< error message level */=0D + MIPI_SYST_SEVERITY_WARNING =3D 3, /**< warning message level */=0D + MIPI_SYST_SEVERITY_INFO =3D 4, /**< information message level */=0D + MIPI_SYST_SEVERITY_USER1 =3D 5, /**< user defined level 5 */=0D + MIPI_SYST_SEVERITY_USER2 =3D 6, /**< user defined level 6 */=0D + MIPI_SYST_SEVERITY_DEBUG =3D 7 /**< debug information level */=0D +} MIPI_SYST_SEVERITY;=0D +=0D +/** SyS-T connection handle state structure=0D + *=0D + * This structure connects the instrumentation API with the underlying SyS= -T=0D + * infrastructure. It plays a similar role to a FILE * in traditional=0D + * C file IO.=0D + */=0D +typedef struct mipi_syst_handle {=0D + struct mipi_syst_header *systh_header; /**< global stat= e */=0D + struct mipi_syst_handle_flags systh_flags; /**< handle stat= e */=0D + struct mipi_syst_msg_tag systh_tag; /**< tag flags = */=0D +=0D + #if defined (MIPI_SYST_PCFG_ENABLE_ORIGIN_GUID)=0D + struct mipi_syst_guid systh_guid; /**< module GUID= */=0D + #endif=0D +=0D + #if defined (MIPI_SYST_PCFG_ENABLE_LOCATION_RECORD)=0D + struct mipi_syst_msglocation systh_location; /**< location re= cord */=0D + #endif=0D +=0D + UINT32 systh_param_count; /**< number of p= arameters */=0D + UINT32 systh_param[6]; /**< catalog msg= parameters */=0D +=0D + #if defined (MIPI_SYST_PCFG_ENABLE_PLATFORM_HANDLE_DATA)=0D + struct mipi_syst_platform_handle systh_platform; /**< platform sp= ecific state */=0D + #endif=0D +} MIPI_SYST_HANDLE;=0D +=0D +/** SyS-T global state structure.=0D + * This structure is holding the global SyS-T library state=0D + */=0D +typedef struct mipi_syst_header {=0D + UINT32 systh_version; /**< SyS-T version ID= */=0D +=0D + #if defined (MIPI_SYST_PCFG_ENABLE_PLATFORM_HANDLE_DATA)=0D + mipi_syst_inithandle_hook_t systh_inith; /**< handle init hook= function*/=0D + mipi_syst_releasehandle_hook_t systh_releaseh; /**< handle release h= ook */=0D + #endif=0D +=0D + #if MIPI_SYST_CONFORMANCE_LEVEL > 10=0D + mipi_syst_msg_write_t systh_writer; /**< message output r= outine */=0D + #endif=0D + #if defined (MIPI_SYST_PCFG_ENABLE_PLATFORM_STATE_DATA)=0D + struct mipi_syst_platform_state systh_platform; /**< platform specifi= c state */=0D + #endif=0D +} MIPI_SYST_HEADER;=0D +=0D +/**=0D + Invoke initialization function in Mipi Sys-T module to initialize Mipi S= ys-T handle.=0D +=0D + @param[in, out] MipiSystHandle A pointer to MIPI_SYST_HANDLE structure= .=0D +=0D + @retval EFI_SUCCESS MIPI_SYST_HANDLE instance was initiali= zed.=0D + @retval EFI_INVALID_PARAMETER On entry, MipiSystHandle is a NULL poi= nter.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +InitMipiSystHandle (=0D + IN OUT MIPI_SYST_HANDLE *MipiSystHandle=0D + );=0D +=0D +/**=0D + Invoke write_debug_string function in Mipi Sys-T module.=0D +=0D + @param[in] MipiSystHandle A pointer to MIPI_SYST_HANDLE structure.=0D + @param[in] Severity An error level to decide whether to enable T= race Hub data.=0D + @param[in] Len Length of data buffer.=0D + @param[in] Str A pointer to data buffer.=0D +=0D + @retval EFI_SUCCESS Data in buffer was processed.=0D + @retval EFI_ABORTED No data need to be written to Trace Hu= b.=0D + @retval EFI_INVALID_PARAMETER On entry, MipiSystHandle is a NULL poi= nter.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +MipiSystWriteDebug (=0D + IN MIPI_SYST_HANDLE *MipiSystHandle,=0D + IN UINT32 Severity,=0D + IN UINT16 Len,=0D + IN CONST CHAR8 *Str=0D + );=0D +=0D +/**=0D + Invoke catalog_write_message function in Mipi Sys-T module.=0D +=0D + @param[in] MipiSystHandle A pointer to MIPI_SYST_HANDLE structure.=0D + @param[in] Severity An error level to decide whether to enable T= race Hub data.=0D + @param[in] CatId Catalog Id.=0D +=0D + @retval EFI_SUCCESS Data in buffer was processed.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +MipiSystWriteCatalog (=0D + IN MIPI_SYST_HANDLE *MipiSystHandle,=0D + IN UINT32 Severity,=0D + IN UINT64 CatId=0D + );=0D +=0D +#endif // MIPI_SYST_LIB_H_=0D diff --git a/MdePkg/Library/MipiSysTLib/MipiSysTLib.c b/MdePkg/Library/Mipi= SysTLib/MipiSysTLib.c new file mode 100644 index 0000000000..0195ad85b0 --- /dev/null +++ b/MdePkg/Library/MipiSysTLib/MipiSysTLib.c @@ -0,0 +1,110 @@ +/** @file=0D +=0D +Copyright (c) 2023, Intel Corporation. All rights reserved.
=0D +=0D +SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#include =0D +#include "mipi_syst.h"=0D +=0D +/**=0D + Invoke initialization function in Mipi Sys-T module to initialize Mipi S= ys-T handle.=0D +=0D + @param[in, out] MipiSystHandle A pointer to MIPI_SYST_HANDLE structure= .=0D +=0D + @retval EFI_SUCCESS MIPI_SYST_HANDLE instance was initiali= zed.=0D + @retval EFI_INVALID_PARAMETER On entry, MipiSystHandle is a NULL poi= nter.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +InitMipiSystHandle (=0D + IN OUT MIPI_SYST_HANDLE *MipiSystHandle=0D + )=0D +{=0D + if (MipiSystHandle =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + mipi_syst_init (MipiSystHandle->systh_header, 0, NULL);=0D + mipi_syst_init_handle (MipiSystHandle->systh_header, MipiSystHandle, NUL= L, 0);=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Invoke write_debug_string function in Mipi Sys-T module.=0D +=0D + @param[in] MipiSystHandle A pointer to MIPI_SYST_HANDLE structure.=0D + @param[in] Severity An error level to decide whether to enable T= race Hub data.=0D + @param[in] Len Length of data buffer.=0D + @param[in] Str A pointer to data buffer.=0D +=0D + @retval EFI_SUCCESS Data in buffer was processed.=0D + @retval EFI_ABORTED No data need to be written to Trace Hu= b.=0D + @retval EFI_INVALID_PARAMETER On entry, MipiSystHandle is a NULL poi= nter.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +MipiSystWriteDebug (=0D + IN MIPI_SYST_HANDLE *MipiSystHandle,=0D + IN UINT32 Severity,=0D + IN UINT16 Len,=0D + IN CONST CHAR8 *Str=0D + )=0D +{=0D + if (MipiSystHandle =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + if ((Len =3D=3D 0) || (Str =3D=3D NULL)) {=0D + //=0D + // No data need to be written to Trace Hub=0D + //=0D + return EFI_ABORTED;=0D + }=0D +=0D + mipi_syst_write_debug_string (=0D + MipiSystHandle,=0D + MIPI_SYST_NOLOCATION,=0D + MIPI_SYST_STRING_GENERIC,=0D + Severity,=0D + Len,=0D + Str=0D + );=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Invoke catalog_write_message function in Mipi Sys-T module.=0D +=0D + @param[in] MipiSystHandle A pointer to MIPI_SYST_HANDLE structure.=0D + @param[in] Severity An error level to decide whether to enable T= race Hub data.=0D + @param[in] CatId Catalog Id.=0D +=0D + @retval EFI_SUCCESS Data in buffer was processed.=0D + @retval EFI_INVALID_PARAMETER On entry, MipiSystHandle is a NULL poi= nter.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +MipiSystWriteCatalog (=0D + IN MIPI_SYST_HANDLE *MipiSystHandle,=0D + IN UINT32 Severity,=0D + IN UINT64 CatId=0D + )=0D +{=0D + if (MipiSystHandle =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + mipi_syst_write_catalog64_message (=0D + MipiSystHandle,=0D + MIPI_SYST_NOLOCATION,=0D + Severity,=0D + CatId=0D + );=0D +=0D + return EFI_SUCCESS;=0D +}=0D diff --git a/MdePkg/Library/MipiSysTLib/MipiSysTLib.inf b/MdePkg/Library/Mi= piSysTLib/MipiSysTLib.inf new file mode 100644 index 0000000000..17ede382cc --- /dev/null +++ b/MdePkg/Library/MipiSysTLib/MipiSysTLib.inf @@ -0,0 +1,52 @@ +## @file=0D +# This library provides Mipi Sys-T API.=0D +#=0D +# Copyright (c) 2023, Intel Corporation. All rights reserved.
=0D +#=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +##=0D +=0D +[Defines]=0D + INF_VERSION =3D 0x00010005=0D + BASE_NAME =3D MipiSysTLib=0D + FILE_GUID =3D A58B0510-9E6D-4747-95D8-E5B8AF4633E6= =0D + MODULE_TYPE =3D BASE=0D + VERSION_STRING =3D 1.0=0D + LIBRARY_CLASS =3D MipiSysTLib=0D +=0D + DEFINE MIPI_HEADER_PATH =3D mipisyst/library/include/mipi_syst=0D + DEFINE MIPI_SOURCE_PATH =3D mipisyst/library/src=0D +=0D +#=0D +# The following information is for reference only and not required by the = build tools.=0D +#=0D +# VALID_ARCHITECTURES =3D IA32 X64=0D +#=0D +=0D +[LibraryClasses]=0D + IoLib=0D + BaseMemoryLib=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D +=0D +[Sources]=0D + MipiSysTLib.c=0D + mipi_syst.h=0D + Platform.c=0D + Platform.h=0D + $(MIPI_HEADER_PATH)/api.h=0D + $(MIPI_HEADER_PATH)/crc32.h=0D + $(MIPI_HEADER_PATH)/compiler.h=0D + $(MIPI_HEADER_PATH)/message.h=0D + $(MIPI_HEADER_PATH)/inline.h=0D + $(MIPI_SOURCE_PATH)/mipi_syst_init.c=0D + $(MIPI_SOURCE_PATH)/mipi_syst_api.c=0D + $(MIPI_SOURCE_PATH)/mipi_syst_crc32.c=0D + $(MIPI_SOURCE_PATH)/mipi_syst_writer.c=0D + $(MIPI_SOURCE_PATH)/mipi_syst_inline.c=0D + $(MIPI_SOURCE_PATH)/mipi_syst_compiler.c=0D +=0D +[BuildOptions]=0D + MSFT:*_*_*_CC_FLAGS =3D /Od=0D diff --git a/MdePkg/Library/MipiSysTLib/Platform.c b/MdePkg/Library/MipiSys= TLib/Platform.c new file mode 100644 index 0000000000..4079ccb1b8 --- /dev/null +++ b/MdePkg/Library/MipiSysTLib/Platform.c @@ -0,0 +1,160 @@ +/** @file=0D +=0D +Copyright (c) 2023, Intel Corporation. All rights reserved.
=0D +=0D +SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#include =0D +#include =0D +#include =0D +#include "mipi_syst.h"=0D +=0D +/**=0D + Write 4 bytes to Trace Hub MMIO addr + 0x10.=0D +=0D + @param[in] MipiSystHandle A pointer to MIPI_SYST_HANDLE structure.=0D + @param[in] Data Data to be written.=0D +**/=0D +VOID=0D +EFIAPI=0D +MipiSystWriteD32Ts (=0D + IN MIPI_SYST_HANDLE *MipiSystHandle,=0D + IN UINT32 Data=0D + )=0D +{=0D + MmioWrite32 (MipiSystHandle->systh_platform.TraceHubPlatformData.MmioAdd= r + 0x10, Data);=0D +}=0D +=0D +/**=0D + Write 4 bytes to Trace Hub MMIO addr + 0x18.=0D +=0D + @param[in] MipiSystHandle A pointer to MIPI_SYST_HANDLE structure.=0D + @param[in] Data Data to be written.=0D +**/=0D +VOID=0D +EFIAPI=0D +MipiSystWriteD32Mts (=0D + IN MIPI_SYST_HANDLE *MipiSystHandle,=0D + IN UINT32 Data=0D + )=0D +{=0D + MmioWrite32 (MipiSystHandle->systh_platform.TraceHubPlatformData.MmioAdd= r + 0x18, Data);=0D +}=0D +=0D +/**=0D + Write 8 bytes to Trace Hub MMIO addr + 0x18.=0D +=0D + @param[in] MipiSystHandle A pointer to MIPI_SYST_HANDLE structure.=0D + @param[in] Data Data to be written.=0D +**/=0D +VOID=0D +EFIAPI=0D +MipiSystWriteD64Mts (=0D + IN MIPI_SYST_HANDLE *MipiSystHandle,=0D + IN UINT64 Data=0D + )=0D +{=0D + MmioWrite64 (MipiSystHandle->systh_platform.TraceHubPlatformData.MmioAdd= r + 0x18, Data);=0D +}=0D +=0D +/**=0D + Write 1 byte to Trace Hub MMIO addr + 0x0.=0D +=0D + @param[in] MipiSystHandle A pointer to MIPI_SYST_HANDLE structure.=0D + @param[in] Data Data to be written.=0D +**/=0D +VOID=0D +EFIAPI=0D +MipiSystWriteD8 (=0D + IN MIPI_SYST_HANDLE *MipiSystHandle,=0D + IN UINT8 Data=0D + )=0D +{=0D + MmioWrite8 (MipiSystHandle->systh_platform.TraceHubPlatformData.MmioAddr= + 0x0, Data);=0D +}=0D +=0D +/**=0D + Write 2 bytes to Trace Hub MMIO mmio addr + 0x0.=0D +=0D + @param[in] MipiSystHandle A pointer to MIPI_SYST_HANDLE structure.=0D + @param[in] Data Data to be written.=0D +**/=0D +VOID=0D +EFIAPI=0D +MipiSystWriteD16 (=0D + IN MIPI_SYST_HANDLE *MipiSystHandle,=0D + IN UINT16 Data=0D + )=0D +{=0D + MmioWrite16 (MipiSystHandle->systh_platform.TraceHubPlatformData.MmioAdd= r + 0x0, Data);=0D +}=0D +=0D +/**=0D + Write 4 bytes to Trace Hub MMIO addr + 0x0.=0D +=0D + @param[in] MipiSystHandle A pointer to MIPI_SYST_HANDLE structure.=0D + @param[in] Data Data to be written.=0D +**/=0D +VOID=0D +EFIAPI=0D +MipiSystWriteD32 (=0D + IN MIPI_SYST_HANDLE *MipiSystHandle,=0D + IN UINT32 Data=0D + )=0D +{=0D + MmioWrite32 (MipiSystHandle->systh_platform.TraceHubPlatformData.MmioAdd= r + 0x0, Data);=0D +}=0D +=0D +/**=0D + Write 8 bytes to Trace Hub MMIO addr + 0x0.=0D +=0D + @param[in] MipiSystHandle A pointer to MIPI_SYST_HANDLE structure.=0D + @param[in] Data Data to be written.=0D +**/=0D +VOID=0D +EFIAPI=0D +MipiSystWriteD64 (=0D + IN MIPI_SYST_HANDLE *MipiSystHandle,=0D + IN UINT64 Data=0D + )=0D +{=0D + MmioWrite64 (MipiSystHandle->systh_platform.TraceHubPlatformData.MmioAdd= r + 0x0, Data);=0D +}=0D +=0D +/**=0D + Clear data in Trace Hub MMIO addr + 0x30.=0D +=0D + @param[in] MipiSystHandle A pointer to MIPI_SYST_HANDLE structure.=0D +**/=0D +VOID=0D +EFIAPI=0D +MipiSystWriteFlag (=0D + IN MIPI_SYST_HANDLE *MipiSystHandle=0D + )=0D +{=0D + UINT32 Flag;=0D +=0D + Flag =3D 0;=0D +=0D + MmioWrite32 (MipiSystHandle->systh_platform.TraceHubPlatformData.MmioAdd= r + 0x30, Flag);=0D +}=0D +=0D +/**=0D + Get Epoch time.=0D +=0D + @retval UINT64 A numeric number for timestamp.=0D +**/=0D +UINT64=0D +EFIAPI=0D +MipiSystGetEpochUs (=0D + VOID=0D + )=0D +{=0D + UINT64 Epoch;=0D +=0D + Epoch =3D 1000;=0D +=0D + return Epoch;=0D +}=0D diff --git a/MdePkg/Library/MipiSysTLib/Platform.h b/MdePkg/Library/MipiSys= TLib/Platform.h new file mode 100644 index 0000000000..b36ab6b84b --- /dev/null +++ b/MdePkg/Library/MipiSysTLib/Platform.h @@ -0,0 +1,140 @@ +/** @file=0D +=0D +Copyright (c) 2023, Intel Corporation. All rights reserved.
=0D +=0D +SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#ifndef MIPI_SYST_PLATFORM_H_=0D +#define MIPI_SYST_PLATFORM_H_=0D +=0D +/**=0D + Write 4 bytes to Trace Hub MMIO addr + 0x10.=0D +=0D + @param[in] MipiSystHandle A pointer to MIPI_SYST_HANDLE structure.=0D + @param[in] Data Data to be written.=0D +**/=0D +VOID=0D +EFIAPI=0D +MipiSystWriteD32Ts (=0D + IN MIPI_SYST_HANDLE *MipiSystHandle,=0D + IN UINT32 Data=0D + );=0D +=0D +/**=0D + Write 4 bytes to Trace Hub MMIO addr + 0x18.=0D +=0D + @param[in] MipiSystHandle A pointer to MIPI_SYST_HANDLE structure.=0D + @param[in] Data Data to be written.=0D +**/=0D +VOID=0D +EFIAPI=0D +MipiSystWriteD32Mts (=0D + IN MIPI_SYST_HANDLE *MipiSystHandle,=0D + IN UINT32 Data=0D + );=0D +=0D +/**=0D + Write 8 bytes to Trace Hub MMIO addr + 0x18.=0D +=0D + @param[in] MipiSystHandle A pointer to MIPI_SYST_HANDLE structure.=0D + @param[in] Data Data to be written.=0D +**/=0D +VOID=0D +EFIAPI=0D +MipiSystWriteD64Mts (=0D + IN MIPI_SYST_HANDLE *MipiSystHandle,=0D + IN UINT64 Data=0D + );=0D +=0D +/**=0D + Write 1 byte to Trace Hub MMIO addr + 0x0.=0D +=0D + @param[in] MipiSystHandle A pointer to MIPI_SYST_HANDLE structure.=0D + @param[in] Data Data to be written.=0D +**/=0D +VOID=0D +EFIAPI=0D +MipiSystWriteD8 (=0D + IN MIPI_SYST_HANDLE *MipiSystHandle,=0D + IN UINT8 Data=0D + );=0D +=0D +/**=0D + Write 2 bytes to Trace Hub MMIO mmio addr + 0x0.=0D +=0D + @param[in] MipiSystHandle A pointer to MIPI_SYST_HANDLE structure.=0D + @param[in] Data Data to be written.=0D +**/=0D +VOID=0D +EFIAPI=0D +MipiSystWriteD16 (=0D + IN MIPI_SYST_HANDLE *MipiSystHandle,=0D + IN UINT16 Data=0D + );=0D +=0D +/**=0D + Write 4 bytes to Trace Hub MMIO addr + 0x0.=0D +=0D + @param[in] MipiSystHandle A pointer to MIPI_SYST_HANDLE structure.=0D + @param[in] Data Data to be written.=0D +**/=0D +VOID=0D +EFIAPI=0D +MipiSystWriteD32 (=0D + IN MIPI_SYST_HANDLE *MipiSystHandle,=0D + IN UINT32 Data=0D + );=0D +=0D +/**=0D + Write 8 bytes to Trace Hub MMIO addr + 0x0.=0D +=0D + @param[in] MipiSystHandle A pointer to MIPI_SYST_HANDLE structure.=0D + @param[in] Data Data to be written.=0D +**/=0D +VOID=0D +EFIAPI=0D +MipiSystWriteD64 (=0D + IN MIPI_SYST_HANDLE *MipiSystHandle,=0D + IN UINT64 Data=0D + );=0D +=0D +/**=0D + Clear data in Trace Hub MMIO addr + 0x30.=0D +=0D + @param[in] MipiSystHandle A pointer to MIPI_SYST_HANDLE structure.=0D +**/=0D +VOID=0D +EFIAPI=0D +MipiSystWriteFlag (=0D + IN MIPI_SYST_HANDLE *MipiSystHandle=0D + );=0D +=0D +/**=0D + Get Epoch time.=0D +=0D + @retval UINT64 A numeric number for timestamp.=0D +**/=0D +UINT64=0D +EFIAPI=0D +MipiSystGetEpochUs (=0D + VOID=0D + );=0D +=0D +#define MIPI_SYST_PLATFORM_CLOCK() MipiSystGetEpochUs ()=0D +=0D +#ifndef MIPI_SYST_PCFG_ENABLE_PLATFORM_STATE_DATA=0D +#define MIPI_SYST_OUTPUT_D32TS(MipiSystHandle, Data) MipiSystWriteD32Ts = ((MipiSystHandle), (Data))=0D +#define MIPI_SYST_OUTPUT_D32MTS(MipiSystHandle, Data) MipiSystWriteD32Mts= ((MipiSystHandle), (Data))=0D +#define MIPI_SYST_OUTPUT_D64MTS(MipiSystHandle, Data) MipiSystWriteD64Mts= ((MipiSystHandle), (Data))=0D +#define MIPI_SYST_OUTPUT_D8(MipiSystHandle, Data) MipiSystWriteD8 ((M= ipiSystHandle), (Data))=0D +#define MIPI_SYST_OUTPUT_D16(MipiSystHandle, Data) MipiSystWriteD16 ((= MipiSystHandle), (Data))=0D +#define MIPI_SYST_OUTPUT_D32(MipiSystHandle, Data) MipiSystWriteD32 ((= MipiSystHandle), (Data))=0D + #if defined (MIPI_SYST_PCFG_ENABLE_64BIT_IO)=0D +#define MIPI_SYST_OUTPUT_D64(MipiSystHandle, Data) MipiSystWriteD64 ((Mip= iSystHandle), (Data))=0D + #endif=0D +#define MIPI_SYST_OUTPUT_FLAG(MipiSystHandle) MipiSystWriteFlag ((MipiSys= tHandle))=0D +#endif=0D +=0D +#endif // MIPI_SYST_PLATFORM_H_=0D diff --git a/MdePkg/Library/MipiSysTLib/mipi_syst.h b/MdePkg/Library/MipiSy= sTLib/mipi_syst.h new file mode 100644 index 0000000000..29a1aa431b --- /dev/null +++ b/MdePkg/Library/MipiSysTLib/mipi_syst.h @@ -0,0 +1,539 @@ +/** @file=0D +=0D +This header file is a customized version of mipi_syst.h.in in mipi module.= =0D +=0D +Copyright (c) 2023, Intel Corporation. All rights reserved.
=0D +=0D +SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#ifndef MIPI_SYST_H_INCLUDED=0D +#define MIPI_SYST_H_INCLUDED=0D +=0D +#include =0D +=0D +/* SyS-T API version information=0D + */=0D +#define MIPI_SYST_VERSION_MAJOR 1 /**< Major version, incremented if AP= I changes */=0D +#define MIPI_SYST_VERSION_MINOR 0 /**< Minor version, incremented on co= mpatible extensions */=0D +#define MIPI_SYST_VERSION_PATCH 0 /**< Patch for existing major, minor,= usually 0 */=0D +=0D +/** Define SyS-T API conformance level=0D + *=0D + * 10 =3D minimal (only short events)=0D + * 20 =3D low overhead (exluding varag functions and CRC32)=0D + * 30 =3D full implementation=0D + */=0D +#define MIPI_SYST_CONFORMANCE_LEVEL 30=0D +=0D +/** Compute SYS-T version value=0D + *=0D + * Used to compare SYS-T Major.Minor.patch versions numerically at runtime= .=0D + *=0D + * @param ma major version number=0D + * @param mi minor version number=0D + * @param p patch version number=0D + *=0D + * Example:=0D + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.c}=0D + *=0D + * #if MIPI_SYST_VERSION_CODE >=3D MIPI_SYST_MAKE_VERSION_CODE(1,5,0)=0D + * // do what only >=3D 1.5.x supports=0D + * #endif=0D + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=0D + */=0D +#define MIPI_SYST_MAKE_VERSION_CODE(ma, mi, p) (((ma) << 16) | ((mi)<<8) = | (p))=0D +=0D +/** Numeric SYS-T version code */=0D +#define MIPI_SYST_VERSION_CODE MIPI_SYST_MAKE_VERSION_CODE(\=0D + MIPI_SYST_VERSION_MAJOR,\=0D + MIPI_SYST_VERSION_MINOR,\=0D + MIPI_SYST_VERSION_PATCH)=0D +=0D +/* Macros to trick numeric values like __LINE__ into a string=0D + */=0D +#define _MIPI_SYST_STRINGIFY(x) #x=0D +#define _MIPI_SYST_CPP_TOSTR(x) _MIPI_SYST_STRINGIFY(x)=0D +=0D +#define _MIPI_SYST_VERSION_STRING(a, b, c) \=0D + _MIPI_SYST_CPP_TOSTR(a)"."_MIPI_SYST_CPP_TOSTR(b)"."_MIPI_SYST_CPP= _TOSTR(c)=0D +=0D +/** Textual version string */=0D +#define MIPI_SYST_VERSION_STRING \=0D + _MIPI_SYST_VERSION_STRING(\=0D + MIPI_SYST_VERSION_MAJOR,\=0D + MIPI_SYST_VERSION_MINOR,\=0D + MIPI_SYST_VERSION_PATCH)=0D +=0D +#ifndef MIPI_SYST_COMPILER_INCLUDED=0D +#define MIPI_SYST_STATIC=0D + #include "mipi_syst/compiler.h"=0D +#endif=0D +=0D +/* String hash macros for compile time computation of catalog ID's.=0D + * Notes:=0D + * These macros will only be used with optimized builds, otherwise=0D + * a lot of runtime code will be generated.=0D + *=0D + * Only the last 64 bytes of the string are considered for hashing=0D + */=0D +#define _MIPI_SYST_HASH1(s, i, x, l) (x*65599u+(mipi_syst_u8)s[(i)<(l)?(= (l)-1-(i)):(l)])=0D +#define _MIPI_SYST_HASH4(s, i, x, l) _MIPI_SYST_HASH1(s,i,_MIPI_SYST_HAS= H1(s,i+1,_MIPI_SYST_HASH1(s,i+2,_MIPI_SYST_HASH1(s,i+3,x,l),l),l),l)=0D +#define _MIPI_SYST_HASH16(s, i, x, l) _MIPI_SYST_HASH4(s,i,_MIPI_SYST_HAS= H4(s,i+4,_MIPI_SYST_HASH4(s,i+8,_MIPI_SYST_HASH4(s,i+12,x,l),l),l),l)=0D +#define _MIPI_SYST_HASH64(s, i, x, l) _MIPI_SYST_HASH16(s,i,_MIPI_SYST_HA= SH16(s,i+16,_MIPI_SYST_HASH16(s,i+32,_MIPI_SYST_HASH16(s,i+48,x,l),l),l),l)= =0D +=0D +#define _MIPI_SYST_HASH_x65599(s, l) ((mipi_syst_u32)_MIPI_SYST_HASH64(s,= 0,0,l))=0D +=0D +#define _MIPI_SYST_HASH_AT_CPP_TIME(str, offset) (_MIPI_SYST_HASH_x65599(= str, sizeof(str)-1) + (offset))=0D +#define _MIPI_SYST_HASH_AT_RUN_TIME(str, offset) (mipi_syst_hash_x65599(s= tr, sizeof(str)-1) + (offset))=0D +=0D +#if defined (_MIPI_SYST_OPTIMIZER_ON)=0D +#define MIPI_SYST_HASH(a, b) _MIPI_SYST_HASH_AT_CPP_TIME((a), (b))=0D +#else=0D +#define MIPI_SYST_HASH(a, b) _MIPI_SYST_HASH_AT_RUN_TIME((a), (b))=0D +#endif=0D +=0D +/** Major Message Types=0D + */=0D +enum mipi_syst_msgtype {=0D + MIPI_SYST_TYPE_BUILD =3D 0, /**< client build id message */=0D + MIPI_SYST_TYPE_SHORT32 =3D 1, /**< value only message */=0D + MIPI_SYST_TYPE_STRING =3D 2, /**< text message output */=0D + MIPI_SYST_TYPE_CATALOG =3D 3, /**< catalog message output */=0D + MIPI_SYST_TYPE_RAW =3D 6, /**< raw binary data */=0D + MIPI_SYST_TYPE_SHORT64 =3D 7, /**< value only message */=0D + MIPI_SYST_TYPE_CLOCK =3D 8, /**< clock sync message */=0D +=0D + MIPI_SYST_TYPE_MAX=0D +};=0D +=0D +/** MIPI_SYST_TYPE_DEBUG_STRING Sub-Types=0D + */=0D +enum mipi_syst_subtype_string {=0D + MIPI_SYST_STRING_GENERIC =3D 1, /**< string generic debug = */=0D + MIPI_SYST_STRING_FUNCTIONENTER =3D 2, /**< string is function name = */=0D + MIPI_SYST_STRING_FUNCTIONEXIT =3D 3, /**< string is function name = */=0D + MIPI_SYST_STRING_INVALIDPARAM =3D 5, /**< invalid SyS-T APIcall = */=0D + MIPI_SYST_STRING_ASSERT =3D 7, /**< Software Assert: failure = */=0D + MIPI_SYST_STRING_PRINTF_32 =3D 11, /**< printf with 32-bit packing = */=0D + MIPI_SYST_STRING_PRINTF_64 =3D 12, /**< printf with 64-bit packing = */=0D +=0D + MIPI_SYST_STRING_MAX=0D +};=0D +=0D +/** MIPI_SYST_TYPE_CATALOG Sub-Types=0D + */=0D +enum mipi_syst_subtype_catalog {=0D + MIPI_SYST_CATALOG_ID32_P32 =3D 1, /**< 32-bit catalog ID, 32-bit packi= ng */=0D + MIPI_SYST_CATALOG_ID64_P32 =3D 2, /**< 64-bit catalog ID, 32-bit packi= ng */=0D + MIPI_SYST_CATALOG_ID32_P64 =3D 5, /**< 32-bit catalog ID, 64-bit packi= ng */=0D + MIPI_SYST_CATALOG_ID64_P64 =3D 6, /**< 64-bit catalog ID, 64-bit packi= ng */=0D +=0D + MIPI_SYST_CATALOG_MAX=0D +};=0D +=0D +/** MIPI_SYST_TYPE_CLOCK Sub-Types=0D + */=0D +enum mipi_syst_subtype_clock {=0D + MIPI_SYST_CLOCK_TRANSPORT_SYNC =3D 1, /**< SyS-T clock & frequency sync= */=0D + MIPI_SYST_CLOCK_MAX=0D +};=0D +=0D +enum mipi_syst_subtype_build {=0D + MIPI_SYST_BUILD_ID_COMPACT32 =3D 0, /**< compact32 build id */=0D + MIPI_SYST_BUILD_ID_COMPACT64 =3D 1, /**< compact64 build id */=0D + MIPI_SYST_BUILD_ID_LONG =3D 2, /**< normal build message */=0D + MIPI_SYST_BUILD_MAX=0D +};=0D +=0D +/** GUID initializer code=0D + *=0D + * This macro simplifies converting a GUID from its string representation= =0D + * into the mipi_syst_guid data structure. The following example shows=0D + * how the values from a GUID string are used with the macro. Each numeric= =0D + * component from the GUID string gets converted into a hex value paramete= r=0D + * when invoking the macro.=0D + *=0D + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.c}=0D + *=0D + * // Guid: f614b99d-99a1-4c04-8c30-90999ab5fe05=0D + *=0D + * struct mipi_syst_guid guid =3D=0D + * MIPI_SYST_GEN_GUID(0xf614b99d, 0x99a1, 0x4c04, 0x8c30, 0x90999ab5f= e05);=0D + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=0D + */=0D +#define MIPI_SYST_GEN_GUID(l1, w1, w2, w3, l2) \=0D + {{\=0D + (mipi_syst_u8)((mipi_syst_u32)(l1) >> 24), \=0D + (mipi_syst_u8)((mipi_syst_u32)(l1) >> 16), \=0D + (mipi_syst_u8)((mipi_syst_u32)(l1) >> 8), \=0D + (mipi_syst_u8)((mipi_syst_u32)(l1) >> 0), \=0D + (mipi_syst_u8)((mipi_syst_u16)(w1) >> 8), \=0D + (mipi_syst_u8)((mipi_syst_u16)(w1) >> 0), \=0D + (mipi_syst_u8)((mipi_syst_u16)(w2) >> 8), \=0D + (mipi_syst_u8)((mipi_syst_u16)(w2) >> 0), \=0D + (mipi_syst_u8)((mipi_syst_u16)(w3) >> 8), \=0D + (mipi_syst_u8)((mipi_syst_u16)(w3) >> 0), \=0D + (mipi_syst_u8)((mipi_syst_u64)(l2) >> 40), \=0D + (mipi_syst_u8)((mipi_syst_u64)(l2) >> 32), \=0D + (mipi_syst_u8)((mipi_syst_u64)(l2) >> 24), \=0D + (mipi_syst_u8)((mipi_syst_u64)(l2) >> 16), \=0D + (mipi_syst_u8)((mipi_syst_u64)(l2) >> 8), \=0D + (mipi_syst_u8)((mipi_syst_u64)(l2) >> 0) \=0D + }}=0D +=0D +/** SyS-T client origin data=0D + *=0D + * This structure holds the GUID or header origin and unit data=0D + * used by SyS-T handles. The structure gets passed into the handle=0D + * creation functions to initialize the values that identify clients.=0D + * @see MIPI_SYST_SET_HANDLE_GUID_UNIT=0D + * @see MIPI_SYST_SET_HANDLE_MODULE_UNIT=0D + * @see MIPI_SYST_SET_HANDLE_ORIGIN=0D + */=0D +struct mipi_syst_origin {=0D + struct mipi_syst_guid guid; /**< origin GUID or module value */=0D + mipi_syst_u16 unit; /**< unit value */=0D +};=0D +=0D +/** Origin structure initializer code using GUID=0D +*=0D +* This macro simplifies initializing a mipi_syst_origin structure. The=0D +* first 5 parameters are GUID values as used by the MIPI_SYST_GEN_GUID=0D +* macro. The last parameter is the unit value (11-Bits).=0D +* @see MIPI_SYST_GEN_GUID=0D +*=0D +*=0D +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.c}=0D +*=0D +* // Guid: {494E5443-B659-45AF-B786-9DB0786248AE}=0D +=0D +*=0D +* struct mipi_syst_origin =3D origin=0D +* MIPI_SYST_GEN_ORIGIN_GUID(=0D +* 0x494E5443, 0xB659, 0x45AF, 0xB786, 0x9DB0786248AE,=0D +* 0x1);=0D +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=0D +*/=0D +#define MIPI_SYST_GEN_ORIGIN_GUID(l1, w1, w2, w3, l2, u) \=0D + {\=0D + MIPI_SYST_GEN_GUID(l1, w1, w2, w3, l2) ,\=0D + u\=0D + }=0D +=0D +/** Origin structure initializer code using header module value=0D +*=0D +* This macro simplifies initializing a mipi_syst_origin structure. The=0D +* first parameter is the header origin value (7-Bits). The second paramete= r=0D +* is the unit value (4-bits)=0D +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.c}=0D +*=0D +* // Guid: {494E5443-B659-45AF-B786-9DB0786248AE}=0D +=0D +* #define MODULE_X 0x10=0D +* struct mipi_syst_origin =3D=0D +* MIPI_SYST_GEN_ORIGIN_MODULE(MODULE_X, 0x1);=0D +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=0D +*/=0D +#define MIPI_SYST_GEN_ORIGIN_MODULE(m, u) \=0D + {\=0D + MIPI_SYST_GEN_GUID(0,0,0, ((mipi_syst_u16)(m & 0x7F)) << 8= , 0 ),\=0D + u\=0D + }=0D +=0D +/**=0D + * Global state initialization hook definition=0D + *=0D + * This function gets called in the context of the mipi_syst_init() API=0D + * function after the generic state members of the global state=0D + * structure syst_hdr have been setup. It's purpose is to initialize the=0D + * platform dependent portion of the state and other necessary=0D + * platform specific initialization steps.=0D + *=0D + * @param systh Pointer to global state structure=0D + * @param p user defined value or pointer to data=0D + * @see mipi_syst_header=0D + */=0D +typedef void (MIPI_SYST_CALLCONV *mipi_syst_inithook_t)(=0D + struct mipi_syst_header *systh,=0D + const void *p=0D + );=0D +=0D +/**=0D + * Global state destroy hook definition=0D + *=0D + * This function gets called in the context of the mipi_syst_destroy() API= =0D + * function before the generic state members of the global state=0D + * structure syst_hdr have been destroyed. Its purpose is to free resource= s=0D + * used by the platform dependent portion of the global state.=0D + *=0D + * @param systh Pointer to global state structure=0D + */=0D +typedef void (MIPI_SYST_CALLCONV *mipi_syst_destroyhook_t)(=0D + struct mipi_syst_header *systh=0D + );=0D +=0D +#ifndef MIPI_SYST_PLATFORM_INCLUDED=0D +=0D +/**=0D + * @defgroup PCFG_Config Platform Feature Configuration Defines=0D + *=0D + * Defines to customize the SyS-T feature set to match the platform needs.= =0D + *=0D + * Each optional library feature can be disabled by not defining the relat= ed=0D + * MIPI_SYST_PCFG_ENABLE define. Removing unused features in this way redu= ces=0D + * both memory footprint and runtime overhead of SyS-T.=0D + */=0D +=0D +/**=0D + * @defgroup PCFG_Global Platform Wide Configuration=0D + * @ingroup PCFG_Config=0D + *=0D + * These defines enable global features in the SyS-T library.=0D + * @{=0D + */=0D +=0D +/**=0D + * Extend SyS-T handle data state=0D + *=0D + * This define extends the SyS-T handle state data structure=0D + * mipi_syst_handle with platform private content. A platform typically=0D + * stores data for fast trace hardware access in the handle data, for=0D + * example a volatile pointer to an MMIO space.=0D + *=0D + * The platform example uses #mipi_syst_platform_handle as handle state=0D + * extension.=0D + */=0D +#define MIPI_SYST_PCFG_ENABLE_PLATFORM_HANDLE_DATA=0D +=0D +/* MSVC and GNU compiler 64-bit mode */=0D +=0D +/**=0D + * Enable 64-bit instruction addresses=0D + *=0D + * Set this define if running in 64-bit code address space.=0D + */=0D + #if defined (_WIN64) || defined (__x86_64__) || defined (__LP64__)=0D +#define MIPI_SYST_PCFG_ENABLE_64BIT_ADDR=0D + #endif=0D +=0D +/**=0D + * Enable atomic 64-bit write operations=0D + *=0D + * Set this define if your platform supports an atomic 64-bit data write=0D + * operation. This results in fewer MMIO accesses.The SyS-T library=0D + * defaults to 2 consecutive 32-Bit writes otherwise.=0D + */=0D + #if defined (_WIN64) || defined (__x86_64__) || defined (__LP64__)=0D +#define MIPI_SYST_PCFG_ENABLE_64BIT_IO=0D + #endif=0D +=0D +/**=0D + * Enable helper function code inlining=0D + *=0D + * Set this define if speed is more important than code size on your platf= orm.=0D + * It causes several helper function to get inlined, producing faster, but= =0D + * also larger, code.=0D + */=0D +#define MIPI_SYST_PCFG_ENABLE_INLINE=0D +=0D +/** @} */=0D +=0D +/**=0D + * @defgroup PCFG_ApiSet Supported API sets=0D + * @ingroup PCFG_Config=0D + *=0D + * These defines enable API sets in the SyS-T library. They are set by def= ault=0D + * depending on the SyS-T API conformance level. The level is specified us= ing=0D + * the define #MIPI_SYST_CONFORMANCE_LEVEL.=0D + * @{=0D + */=0D +=0D + #if MIPI_SYST_CONFORMANCE_LEVEL > 10=0D +=0D +/**=0D + * Use SyS-T scatter write output function=0D + *=0D + * The library comes with an output routine that is intended to write data= out=0D + * to an MMIO space. It simplifies a SyS-T platform integration as=0D + * only low-level access macros must be provided for outputting data. Thes= e=0D + * macros follow MIPI System Trace Protocol (STP) naming convention, also= =0D + * non STP generators can use this interface.=0D + *=0D + * These low level output macros are:=0D + *=0D + * #MIPI_SYST_OUTPUT_D32MTS, #MIPI_SYST_OUTPUT_D64MTS,=0D + * #MIPI_SYST_OUTPUT_D32TS, #MIPI_SYST_OUTPUT_D64,=0D + * #MIPI_SYST_OUTPUT_D32, #MIPI_SYST_OUTPUT_D16, #MIPI_SYST_OUTPUT_D8 and= =0D + * #MIPI_SYST_OUTPUT_FLAG=0D + *=0D + * Note: This version of the write function always starts messages=0D + * using a 32-bit timestamped record also other sized timestamped=0D + * packets are allowed by the SyS-T specification.=0D + */=0D +#define MIPI_SYST_PCFG_ENABLE_DEFAULT_SCATTER_WRITE=0D +=0D +/**=0D + * Enable the Catalog API for 32-Bit Catalog IDs.=0D + */=0D +#define MIPI_SYST_PCFG_ENABLE_CATID32_API=0D +=0D +/**=0D + * Enable the Catalog API for 64-Bit Catalog IDs.=0D + */=0D +#define MIPI_SYST_PCFG_ENABLE_CATID64_API=0D +=0D +/**=0D + * Enable plain UTF-8 string output APIs.=0D + */=0D +#define MIPI_SYST_PCFG_ENABLE_STRING_API=0D +=0D +/**=0D + * Enable raw data output APIs=0D + */=0D +#define MIPI_SYST_PCFG_ENABLE_WRITE_API=0D +=0D +/**=0D + * Enable Build API=0D + */=0D +#define MIPI_SYST_PCFG_ENABLE_BUILD_API=0D + #endif /* MIPI_SYST_CONFORMANCE_LEVEL > 10 */=0D +=0D + #if MIPI_SYST_CONFORMANCE_LEVEL > 20=0D +=0D +/**=0D + * Maximum size of printf payload in bytes.=0D + * Adjust this value if larger strings shall be supported by the library.= =0D + * The buffer space is located in stack memory when calling one of the pri= ntf=0D + * style APIs.=0D + */=0D +#define MIPI_SYST_PCFG_PRINTF_ARGBUF_SIZE 1024=0D +=0D + #endif /* #if MIPI_SYST_CONFORMANCE_LEVEL > 20 */=0D +=0D +/* @} */=0D +=0D +/**=0D + * @defgroup PCFG_Message Optional Message Attributes=0D + * @ingroup PCFG_Config=0D + *=0D + * These defines enable optional message components. They are set by defau= lt=0D + * depending on the SyS-T API conformance level. The level is specified us= ing=0D + * the define #MIPI_SYST_CONFORMANCE_LEVEL.=0D + * @{=0D + */=0D +=0D + #if MIPI_SYST_CONFORMANCE_LEVEL > 10=0D +=0D +/**=0D + * Enable 128-bit origin GUID support.=0D + */=0D +#define MIPI_SYST_PCFG_ENABLE_ORIGIN_GUID=0D +=0D +/**=0D + * Enable protocol timestamp.=0D + *=0D + * This option adds a timestamp into the SyS-T protocol. This=0D + * option is used if the SyS-T protocol is not embedded into a hardware=0D + * timestamped trace protocol like MIPI STP or if the HW timestamp cannot= =0D + * be used for other reasons. Setting this option creates the need to defi= ne=0D + * the macros #MIPI_SYST_PLATFORM_CLOCK and #MIPI_SYST_PLATFORM_FREQ to=0D + * return a 64-bit clock tick value and its frequency.=0D + */=0D +#define MIPI_SYST_PCFG_ENABLE_TIMESTAMP=0D +=0D + #if defined (_DOXYGEN_) /* only for doxygen, remove the #if to enabl= e */=0D +=0D +/**=0D +* Enable generation of length field=0D +*=0D +* Set this define if the message data shall include the optional length=0D +* field that indicates how many payload bytes follow.=0D +*/=0D +#define MIPI_SYST_PCFG_LENGTH_FIELD=0D + #endif=0D +=0D + #endif=0D +=0D + #if MIPI_SYST_CONFORMANCE_LEVEL > 20=0D +=0D +/**=0D + * Enable message data CRC32 generation.=0D + */=0D +#define MIPI_SYST_PCFG_ENABLE_CHECKSUM=0D +=0D + #endif /* #if MIPI_SYST_CONFORMANCE_LEVEL */=0D +=0D +/** @} */=0D +=0D + #include "Platform.h"=0D +#endif=0D +=0D +#if defined (MIPI_SYST_PCFG_ENABLE_INLINE)=0D +#define MIPI_SYST_INLINE static MIPI_SYST_CC_INLINE=0D +#else=0D +#define MIPI_SYST_INLINE MIPI_SYST_EXPORT=0D +#endif=0D +=0D +#define _MIPI_SYST_MK_MODUNIT_ORIGIN(m, u) (((u) & 0xF)|(m<<4))=0D +=0D +/**=0D + * Location information inside a message (64-bit format)=0D + * Location is either the source position of the instrumentation call, or= =0D + * the call instruction pointer value.=0D + */=0D +union mipi_syst_msglocation32 {=0D + struct {=0D + #if defined (MIPI_SYST_BIG_ENDIAN)=0D + mipi_syst_u16 etls_lineNo; /**< line number in file */=0D + mipi_syst_u16 etls_fileID; /**< ID of instrumented file */=0D + #else=0D + mipi_syst_u16 etls_fileID; /**< ID of instrumented file */=0D + mipi_syst_u16 etls_lineNo; /**< line number in file */=0D + #endif=0D + } etls_source_location;=0D +=0D + mipi_syst_u32 etls_code_location : 32; /**< instruction pointer value= */=0D +};=0D +=0D +/**=0D + * Location information inside a message (32-bit format)=0D + * Location is either the source position of the instrumentation call, or= =0D + * the call instruction pointer value.=0D + */=0D +union mipi_syst_msglocation64 {=0D + struct {=0D + #if defined (MIPI_SYST_BIG_ENDIAN)=0D + mipi_syst_u32 etls_lineNo; /**< line number in file */=0D + mipi_syst_u32 etls_fileID; /**< ID of instrumented file */=0D + #else=0D + mipi_syst_u32 etls_fileID; /**< ID of instrumented file */=0D + mipi_syst_u32 etls_lineNo; /**< line number in file */=0D + #endif=0D + } etls_source_location;=0D + mipi_syst_u64 etls_code_location; /**< instruction pointer value */=0D +};=0D +=0D +/**=0D + * Location information record descriptor=0D + */=0D +struct mipi_syst_msglocation {=0D + /** Message format=0D + * 0 =3D 16-Bit file and 16-Bit line (total: 32-bit)=0D + * 1 =3D 32-Bit file and 32-Bit line (total: 64-bit)=0D + * 2 =3D 32-bit code address=0D + * 3 =3D 64-bit code address=0D + */=0D + mipi_syst_u8 el_format;=0D + union {=0D + union mipi_syst_msglocation32 loc32; /**< data for 32-bit variant = */=0D + union mipi_syst_msglocation64 loc64; /**< data for 64-bit variant = */=0D + } el_u;=0D +};=0D +=0D +#ifndef MIPI_SYST_API_INCLUDED=0D + #include "mipi_syst/api.h"=0D +#endif=0D +=0D +#endif=0D diff --git a/MdePkg/Library/MipiSysTLib/mipisyst b/MdePkg/Library/MipiSysTL= ib/mipisyst new file mode 160000 index 0000000000..aae857d0d0 --- /dev/null +++ b/MdePkg/Library/MipiSysTLib/mipisyst @@ -0,0 +1 @@ +Subproject commit aae857d0d05ac65152ed24992a4acd834a0a107c diff --git a/MdePkg/MdePkg.ci.yaml b/MdePkg/MdePkg.ci.yaml index 19bc0138cb..590cb85fd5 100644 --- a/MdePkg/MdePkg.ci.yaml +++ b/MdePkg/MdePkg.ci.yaml @@ -64,8 +64,10 @@ "Include/IndustryStandard/UefiTcgPlatform.h",=0D "Include/Library/PcdLib.h",=0D "Include/Library/SafeIntLib.h",=0D + "Include/Library/MipiSysTLib.h",=0D "Include/Protocol/DebugSupport.h",=0D - "Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLib.c"=0D + "Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLib.c",=0D + "Library/MipiSysTLib/mipi_syst.h"=0D ]=0D },=0D ## options defined ci/Plugin/CompilerPlugin=0D diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index 3d08f20d15..bee7ac538a 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -26,6 +26,7 @@ [Includes]=0D Include=0D Test/UnitTest/Include=0D + Library/MipiSysTLib/mipisyst/library/include=0D =0D [Includes.IA32]=0D Include/Ia32=0D @@ -284,6 +285,10 @@ #=0D ArmTrngLib|Include/Library/ArmTrngLib.h=0D =0D + ## @libraryclass Provides general mipi sys-T services.=0D + #=0D + MipiSysTLib|Include/Library/MipiSysTLib.h=0D +=0D [LibraryClasses.IA32, LibraryClasses.X64, LibraryClasses.AARCH64]=0D ## @libraryclass Provides services to generate random number.=0D #=0D diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc index 32a852dc46..cbcf4a6047 100644 --- a/MdePkg/MdePkg.dsc +++ b/MdePkg/MdePkg.dsc @@ -34,6 +34,7 @@ =0D [LibraryClasses]=0D SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf=0D + MipiSysTLib|MdePkg/Library/MipiSysTLib/MipiSysTLib.inf=0D =0D [Components]=0D MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf=0D @@ -135,6 +136,7 @@ MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibNull.inf=0D MdePkg/Library/CcProbeLibNull/CcProbeLibNull.inf=0D MdePkg/Library/SmmCpuRendezvousLibNull/SmmCpuRendezvousLibNull.inf=0D + MdePkg/Library/MipiSysTLib/MipiSysTLib.inf=0D =0D [Components.IA32, Components.X64, Components.ARM, Components.AARCH64]=0D #=0D diff --git a/ReadMe.rst b/ReadMe.rst index 497d963559..283f807ab5 100644 --- a/ReadMe.rst +++ b/ReadMe.rst @@ -95,6 +95,7 @@ that are covered by additional licenses. - `UnitTestFrameworkPkg/Library/CmockaLib/cmocka `__= =0D - `UnitTestFrameworkPkg/Library/GoogleTestLib/googletest `__=0D - `RedfishPkg/Library/JsonLib/jansson `__=0D +- `MdePkg/Library/MipiSysTLib/mipisyst `__= =0D =0D The EDK II Project is composed of packages. The maintainers for each packa= ge=0D are listed in `Maintainers.txt `__.=0D --=20 2.28.0.windows.1