From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web11.100689.1683523969170226818 for ; Sun, 07 May 2023 22:32:51 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=CRWJk14t; spf=pass (domain: intel.com, ip: 134.134.136.31, 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=1683523970; x=1715059970; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QWakzJ2nNnl2lhmTcz/ABRbI9COiv1CvSaB4p6kfp+M=; b=CRWJk14t3yVstiHZMtbTl0oRw+DVDWzdtyiPSgKJZL9S4j0o2tEVh/LP r+/dvH8QHOMEhvfaLxvnxm/FIF5yryfMAJWX2iQRPN10mLSqORnEa+nx3 FiXG9KRNZ7VfUwDJantoCmOGh7ZMDxz0bxMXz5BYw6xfAEo1iZ1rXe/p+ yqunK+mBL5syngBo3demCKOYMkqSR6EOA2+hB4c2WWN2Kc3Hnflqs/N/z fWXyawNXRZXaRbh4c8gW3McyNQtTxZJdXFRaJ8Nf70ggkvmvfacMmbHVx 6R4SQSnu01N++pSuI3sEFuUqaaq+a0NOk9ipzcceMGS1AbFOv63Acvmyc g==; X-IronPort-AV: E=McAfee;i="6600,9927,10703"; a="412819028" X-IronPort-AV: E=Sophos;i="5.99,258,1677571200"; d="scan'208";a="412819028" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2023 22:32:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10703"; a="767934608" X-IronPort-AV: E=Sophos;i="5.99,258,1677571200"; d="scan'208";a="767934608" Received: from hsuc1x-desk2.gar.corp.intel.com ([10.227.107.44]) by fmsmga004.fm.intel.com with ESMTP; 07 May 2023 22:32:31 -0700 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: Mon, 8 May 2023 13:31:53 +0800 Message-Id: <59aea36354ae4ef266ec1478104eb0d40c7d1d58.1683523672.git.victorx.hsu@intel.com> X-Mailer: git-send-email 2.40.0.windows.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: VictorX Hsu REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4144 This Library provides functions consuming MIPI SYS-T submodule. Cc: Michael D Kinney Cc: Guo Gua Cc: Chan Laura Cc: Prakashan Krishnadas Veliyathuparambil Cc: K N Karthik Signed-off-by: VictorX Hsu --- .gitmodules | 11 +- .pytool/CISettings.py | 2 + MdePkg/Include/Library/MipiSysTLib.h | 66 ++ MdePkg/Library/MipiSysTLib/GenMipiSystH.py | 132 ++++ MdePkg/Library/MipiSysTLib/MipiSysTLib.c | 123 ++++ MdePkg/Library/MipiSysTLib/MipiSysTLib.inf | 55 ++ MdePkg/Library/MipiSysTLib/Platform.c | 164 +++++ MdePkg/Library/MipiSysTLib/Platform.h | 138 ++++ MdePkg/Library/MipiSysTLib/Readme.md | 25 + MdePkg/Library/MipiSysTLib/mipi_syst.h | 789 +++++++++++++++++++++ MdePkg/Library/MipiSysTLib/mipisyst | 1 + MdePkg/MdePkg.ci.yaml | 12 +- MdePkg/MdePkg.dec | 5 + MdePkg/MdePkg.dsc | 1 + ReadMe.rst | 1 + 15 files changed, 1518 insertions(+), 7 deletions(-) create mode 100644 MdePkg/Include/Library/MipiSysTLib.h create mode 100644 MdePkg/Library/MipiSysTLib/GenMipiSystH.py 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/Readme.md create mode 100644 MdePkg/Library/MipiSysTLib/mipi_syst.h create mode 160000 MdePkg/Library/MipiSysTLib/mipisyst diff --git a/.gitmodules b/.gitmodules index 6211c59724..fb79ebfb72 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,7 +16,7 @@ [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 @@ -26,6 +26,9 @@ [submodule "UnitTestFrameworkPkg/Library/SubhookLib/subhook"] path =3D UnitTestFrameworkPkg/Library/SubhookLib/subhook url =3D https://github.com/Zeex/subhook.git -[submodule "MdePkg/Library/BaseFdtLib/libfdt"]=0D - path =3D MdePkg/Library/BaseFdtLib/libfdt=0D - url =3D https://github.com/devicetree-org/pylibfdt.git=0D +[submodule "MdePkg/Library/BaseFdtLib/libfdt"] + path =3D MdePkg/Library/BaseFdtLib/libfdt + url =3D https://github.com/devicetree-org/pylibfdt.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 2fb99f2a17..6fb7342f81 100644 --- a/.pytool/CISettings.py +++ b/.pytool/CISettings.py @@ -197,6 +197,8 @@ class Settings(CiBuildSettingsManager, UpdateSettingsMa= nager, SetupSettingsManag "UnitTestFrameworkPkg/Library/SubhookLib/subhook", False))=0D rs.append(RequiredSubmodule(=0D "MdePkg/Library/BaseFdtLib/libfdt", 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..4ced1c02cd --- /dev/null +++ b/MdePkg/Include/Library/MipiSysTLib.h @@ -0,0 +1,66 @@ +/** @file=0D +This header file declares functions consuming MIPI Sys-T submodule.=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 +/**=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 RETURN_SUCCESS MIPI_SYST_HANDLE instance was initialized.=0D + @retval Other MIPI_SYST_HANDLE instance was not initialize= d.=0D +**/=0D +RETURN_STATUS=0D +EFIAPI=0D +InitMipiSystHandle (=0D + IN OUT VOID *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 Severity type of input message.=0D + @param[in] Len Length of data buffer.=0D + @param[in] Str A pointer to data buffer.=0D +=0D + @retval RETURN_SUCCESS Data in buffer was processed.=0D + @retval RETURN_ABORTED No data need to be written to Trace= Hub.=0D + @retval RETURN_INVALID_PARAMETER On entry, MipiSystHandle or Str is = a NULL pointer.=0D +**/=0D +RETURN_STATUS=0D +EFIAPI=0D +MipiSystWriteDebug (=0D + IN VOID *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 Severity type of input message.=0D + @param[in] CatId Catalog Id.=0D +=0D + @retval RETURN_SUCCESS Data in buffer was processed.=0D + @retval RETURN_INVALID_PARAMETER On entry, MipiSystHandle is a NULL = pointer.=0D +**/=0D +RETURN_STATUS=0D +EFIAPI=0D +MipiSystWriteCatalog (=0D + IN VOID *MipiSystHandle,=0D + IN UINT32 Severity,=0D + IN UINT64 CatId=0D + );=0D +=0D +#endif // MIPI_SYST_LIB_H_=0D diff --git a/MdePkg/Library/MipiSysTLib/GenMipiSystH.py b/MdePkg/Library/Mi= piSysTLib/GenMipiSystH.py new file mode 100644 index 0000000000..ee48285590 --- /dev/null +++ b/MdePkg/Library/MipiSysTLib/GenMipiSystH.py @@ -0,0 +1,132 @@ +## @file=0D +# This python script update content from mipi_syst.h.in in mipi sys-T sub= module=0D +# and generate it as mipi_syst.h. mipi_syst.h include necessary data stru= cture and=0D +# definition that will be consumed by MipiSysTLib itself, mipi sys-T subm= odule=0D +# and other library.=0D +#=0D +# This script needs to be done once by a developer when adding some=0D +# project-relating definition or a new version of mipi_syst.h.in is relea= sed.=0D +# Normal users do not need to do this, since the resulting file is stored= =0D +# in the EDK2 git repository.=0D +#=0D +# Customize structures mentioned below to generate updated mipi_syst.h fi= le:=0D +# 1. ExistingValueToBeReplaced=0D +# -> To replace existing value in mipi_syst.h.in to newer one.=0D +# 2. ExistingDefinitionToBeRemoved=0D +# -> To #undef a existing definition in mipi_syst.h.in.=0D +# 3. NewItemToBeAdded=0D +# -> Items in this structure will be placed at the end of mipi_syst.= h as a customized section.=0D +#=0D +# Run GenMipiSystH.py without any parameters as normal python script afte= r customizing.=0D +#=0D +# Copyright (c) 2023, Intel Corporation. All rights reserved.
=0D +#=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +##=0D +import os=0D +import re=0D +=0D +#=0D +# A existing value to be customized should place this structure=0D +# Definitions in this customizable structure will be processed by ReplaceO= ldValue()=0D +# e.g:=0D +# Before: @SYST_CFG_VERSION_MAJOR@=0D +# After: 1=0D +#=0D +ExistingValueToBeReplaced =3D [=0D + ["@SYST_CFG_VERSION_MAJOR@", "1"], # Major version=0D + ["@SYST_CFG_VERSION_MINOR@", "0"], # Minor version=0D + ["@SYST_CFG_VERSION_PATCH@", "0"], # Patch version=0D + ["@SYST_CFG_CONFORMANCE_LEVEL@", "30"], # Feature level of mipi sys-T = submodule=0D + ["mipi_syst/platform.h", "Platform.h"],=0D +]=0D +=0D +#=0D +# A existing definition to be removed should place this structure=0D +# Definitions in this customizable structure will be processed by RemoveDe= finition()=0D +# e.g:=0D +# Before:=0D +# #define MIPI_SYST_PCFG_ENABLE_PLATFORM_STATE_DATA=0D +# After:=0D +# #define MIPI_SYST_PCFG_ENABLE_PLATFORM_STATE_DATA=0D +# #undef MIPI_SYST_PCFG_ENABLE_PLATFORM_STATE_DATA=0D +#=0D +ExistingDefinitionToBeRemoved =3D [=0D + "MIPI_SYST_PCFG_ENABLE_PLATFORM_STATE_DATA",=0D + "MIPI_SYST_PCFG_ENABLE_HEAP_MEMORY",=0D + "MIPI_SYST_PCFG_ENABLE_PRINTF_API",=0D + "MIPI_SYST_PCFG_ENABLE_LOCATION_RECORD",=0D + "MIPI_SYST_PCFG_ENABLE_LOCATION_ADDRESS",=0D +]=0D +=0D +#=0D +# Items in this structure will be placed at the end of mipi_syst.h as a cu= stomized section.=0D +#=0D +NewItemToBeAdded =3D [=0D + "typedef struct mipi_syst_handle_flags MIPI_SYST_HANDLE_FLAGS;",=0D + "typedef struct mipi_syst_msg_tag MIPI_SYST_MSG_TAG;",=0D + "typedef struct mipi_syst_guid MIPI_SYST_GUID;",=0D + "typedef enum mipi_syst_severity MIPI_SYST_SEVERITY;",=0D + "typedef struct mipi_syst_handle MIPI_SYST_HANDLE;",=0D + "typedef struct mipi_syst_header MIPI_SYST_HEADER;",=0D +]=0D +=0D +def ProcessSpecialCharacter(Str):=0D + Str =3D Str.rstrip(" \n")=0D + Str =3D Str.replace("\t", " ")=0D + Str +=3D "\n"=0D + return Str=0D +=0D +def ReplaceOldValue(Str):=0D + for i in range(len(ExistingValueToBeReplaced)):=0D + Result =3D re.search(ExistingValueToBeReplaced[i][0], Str)=0D + if Result is not None:=0D + Str =3D Str.replace(ExistingValueToBeReplaced[i][0], ExistingV= alueToBeReplaced[i][1])=0D + break=0D + return Str=0D +=0D +def RemoveDefinition(Str):=0D + Result =3D re.search("\*", Str)=0D + if Result is None:=0D + for i in range(len(ExistingDefinitionToBeRemoved)):=0D + Result =3D re.search(ExistingDefinitionToBeRemoved[i], Str)=0D + if Result is not None:=0D + Result =3D re.search("defined", Str)=0D + if Result is None:=0D + Str =3D Str + "#undef " + ExistingDefinitionToBeRemove= d[i]=0D + break=0D + return Str=0D +=0D +def main():=0D + MipiSystHSrcDir =3D "mipisyst/library/include/mipi_syst.h.in"=0D + MipiSystHRealSrcDir =3D os.path.join(os.getcwd(), os.path.normpath(Mip= iSystHSrcDir))=0D + MipiSystHRealDstDir =3D os.path.join(os.getcwd(), "mipi_syst.h")=0D +=0D + #=0D + # Read content from mipi_syst.h.in and process each line by demand=0D + #=0D + with open(MipiSystHRealSrcDir, "r") as rfObj:=0D + SrcFile =3D rfObj.readlines()=0D + for lineIndex in range(len(SrcFile)):=0D + SrcFile[lineIndex] =3D ProcessSpecialCharacter(SrcFile[lineInd= ex])=0D + SrcFile[lineIndex] =3D ReplaceOldValue(SrcFile[lineIndex])=0D + SrcFile[lineIndex] =3D RemoveDefinition(SrcFile[lineIndex])=0D +=0D + #=0D + # Typedef a structure or enum type=0D + #=0D + i =3D -1=0D + for struct in NewItemToBeAdded:=0D + struct +=3D "\n"=0D + SrcFile.insert(i, struct)=0D + i -=3D 1=0D +=0D + #=0D + # Save edited content to mipi_syst.h=0D + #=0D + with open(MipiSystHRealDstDir, "w") as wfObj:=0D + wfObj.writelines(SrcFile)=0D +=0D +if __name__ =3D=3D '__main__':=0D + main()=0D diff --git a/MdePkg/Library/MipiSysTLib/MipiSysTLib.c b/MdePkg/Library/Mipi= SysTLib/MipiSysTLib.c new file mode 100644 index 0000000000..3a15a2af58 --- /dev/null +++ b/MdePkg/Library/MipiSysTLib/MipiSysTLib.c @@ -0,0 +1,123 @@ +/** @file=0D +This file provide functions to communicate with mipi sys-T submodule.=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 RETURN_SUCCESS MIPI_SYST_HANDLE instance was initialized.=0D + @retval Other MIPI_SYST_HANDLE instance was not initialize= d.=0D +**/=0D +RETURN_STATUS=0D +EFIAPI=0D +InitMipiSystHandle (=0D + IN OUT VOID *MipiSystHandle=0D + )=0D +{=0D + MIPI_SYST_HANDLE *MipiSystH;=0D +=0D + MipiSystH =3D (MIPI_SYST_HANDLE *)MipiSystHandle;=0D + if (MipiSystH =3D=3D NULL) {=0D + return RETURN_INVALID_PARAMETER;=0D + }=0D +=0D + mipi_syst_init (MipiSystH->systh_header, 0, NULL);=0D +=0D + return RETURN_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 Severity type of input message.=0D + @param[in] Len Length of data buffer.=0D + @param[in] Str A pointer to data buffer.=0D +=0D + @retval RETURN_SUCCESS Data in buffer was processed.=0D + @retval RETURN_ABORTED No data need to be written to Trace= Hub.=0D + @retval RETURN_INVALID_PARAMETER On entry, MipiSystHandle or Str is = a NULL pointer.=0D +**/=0D +RETURN_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 + MIPI_SYST_HANDLE *MipiSystH;=0D +=0D + MipiSystH =3D (MIPI_SYST_HANDLE *)MipiSystHandle;=0D + if (MipiSystH =3D=3D NULL) {=0D + return RETURN_INVALID_PARAMETER;=0D + }=0D +=0D + if (Len =3D=3D 0) {=0D + //=0D + // No data need to be written to Trace Hub=0D + //=0D + return RETURN_ABORTED;=0D + }=0D +=0D + if (Str =3D=3D NULL) {=0D + return RETURN_INVALID_PARAMETER;=0D + }=0D +=0D + mipi_syst_write_debug_string (=0D + MipiSystH,=0D + MIPI_SYST_NOLOCATION,=0D + MIPI_SYST_STRING_GENERIC,=0D + Severity,=0D + Len,=0D + Str=0D + );=0D +=0D + return RETURN_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 Severity type of input message.=0D + @param[in] CatId Catalog Id.=0D +=0D + @retval RETURN_SUCCESS Data in buffer was processed.=0D + @retval RETURN_INVALID_PARAMETER On entry, MipiSystHandle is a NULL = pointer.=0D +**/=0D +RETURN_STATUS=0D +EFIAPI=0D +MipiSystWriteCatalog (=0D + IN MIPI_SYST_HANDLE *MipiSystHandle,=0D + IN UINT32 Severity,=0D + IN UINT64 CatId=0D + )=0D +{=0D + MIPI_SYST_HANDLE *MipiSystH;=0D +=0D + MipiSystH =3D (MIPI_SYST_HANDLE *)MipiSystHandle;=0D + if (MipiSystH =3D=3D NULL) {=0D + return RETURN_INVALID_PARAMETER;=0D + }=0D +=0D + mipi_syst_write_catalog64_message (=0D + MipiSystH,=0D + MIPI_SYST_NOLOCATION,=0D + Severity,=0D + CatId=0D + );=0D +=0D + return RETURN_SUCCESS;=0D +}=0D diff --git a/MdePkg/Library/MipiSysTLib/MipiSysTLib.inf b/MdePkg/Library/Mi= piSysTLib/MipiSysTLib.inf new file mode 100644 index 0000000000..b2aefcc9cc --- /dev/null +++ b/MdePkg/Library/MipiSysTLib/MipiSysTLib.inf @@ -0,0 +1,55 @@ +## @file=0D +# A library providing funcitons to communicate with mipi sys-T submodule.= =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:*_*_IA32_CC_FLAGS =3D /DMIPI_SYST_STATIC=0D + MSFT:*_*_X64_CC_FLAGS =3D /DMIPI_SYST_STATIC=0D + GCC:*_*_IA32_CC_FLAGS =3D -DMIPI_SYST_STATIC=0D + GCC:*_*_X64_CC_FLAGS =3D -DMIPI_SYST_STATIC=0D diff --git a/MdePkg/Library/MipiSysTLib/Platform.c b/MdePkg/Library/MipiSys= TLib/Platform.c new file mode 100644 index 0000000000..90a524bc1e --- /dev/null +++ b/MdePkg/Library/MipiSysTLib/Platform.c @@ -0,0 +1,164 @@ +/** @file=0D +This file defines functions that output Trace Hub message.=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 VOID *MipiSystHandle,=0D + IN UINT32 Data=0D + )=0D +{=0D + MIPI_SYST_HANDLE *MipiSystH;=0D +=0D + MipiSystH =3D (MIPI_SYST_HANDLE *)MipiSystHandle;=0D + MmioWrite32 ((UINTN)(MipiSystH->systh_platform.TraceHubPlatformData.Mmio= Addr + 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 VOID *MipiSystHandle,=0D + IN UINT32 Data=0D + )=0D +{=0D + MIPI_SYST_HANDLE *MipiSystH;=0D +=0D + MipiSystH =3D (MIPI_SYST_HANDLE *)MipiSystHandle;=0D + MmioWrite32 ((UINTN)(MipiSystH->systh_platform.TraceHubPlatformData.Mmio= Addr + 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 VOID *MipiSystHandle,=0D + IN UINT64 Data=0D + )=0D +{=0D + MIPI_SYST_HANDLE *MipiSystH;=0D +=0D + MipiSystH =3D (MIPI_SYST_HANDLE *)MipiSystHandle;=0D + MmioWrite64 ((UINTN)(MipiSystH->systh_platform.TraceHubPlatformData.Mmio= Addr + 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 VOID *MipiSystHandle,=0D + IN UINT8 Data=0D + )=0D +{=0D + MIPI_SYST_HANDLE *MipiSystH;=0D +=0D + MipiSystH =3D (MIPI_SYST_HANDLE *)MipiSystHandle;=0D + MmioWrite8 ((UINTN)(MipiSystH->systh_platform.TraceHubPlatformData.MmioA= ddr + 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 VOID *MipiSystHandle,=0D + IN UINT16 Data=0D + )=0D +{=0D + MIPI_SYST_HANDLE *MipiSystH;=0D +=0D + MipiSystH =3D (MIPI_SYST_HANDLE *)MipiSystHandle;=0D + MmioWrite16 ((UINTN)(MipiSystH->systh_platform.TraceHubPlatformData.Mmio= Addr + 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 VOID *MipiSystHandle,=0D + IN UINT32 Data=0D + )=0D +{=0D + MIPI_SYST_HANDLE *MipiSystH;=0D +=0D + MipiSystH =3D (MIPI_SYST_HANDLE *)MipiSystHandle;=0D + MmioWrite32 ((UINTN)(MipiSystH->systh_platform.TraceHubPlatformData.Mmio= Addr + 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 VOID *MipiSystHandle,=0D + IN UINT64 Data=0D + )=0D +{=0D + MIPI_SYST_HANDLE *MipiSystH;=0D +=0D + MipiSystH =3D (MIPI_SYST_HANDLE *)MipiSystHandle;=0D + MmioWrite64 ((UINTN)(MipiSystH->systh_platform.TraceHubPlatformData.Mmio= Addr + 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 VOID *MipiSystHandle=0D + )=0D +{=0D + MIPI_SYST_HANDLE *MipiSystH;=0D +=0D + MipiSystH =3D (MIPI_SYST_HANDLE *)MipiSystHandle;=0D +=0D + MmioWrite32 ((UINTN)(MipiSystH->systh_platform.TraceHubPlatformData.Mmio= Addr + 0x30), 0x0);=0D +}=0D diff --git a/MdePkg/Library/MipiSysTLib/Platform.h b/MdePkg/Library/MipiSys= TLib/Platform.h new file mode 100644 index 0000000000..ac77edf33d --- /dev/null +++ b/MdePkg/Library/MipiSysTLib/Platform.h @@ -0,0 +1,138 @@ +/** @file=0D +This header file declares functions and structures.=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 +typedef struct {=0D + UINT64 MmioAddr;=0D +} TRACE_HUB_PLATFORM_SYST_DATA;=0D +=0D +struct mipi_syst_platform_handle {=0D + TRACE_HUB_PLATFORM_SYST_DATA TraceHubPlatformData;=0D +};=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 VOID *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 VOID *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 VOID *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 VOID *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 VOID *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 VOID *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 VOID *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 VOID *MipiSystHandle=0D + );=0D +=0D +#define MIPI_SYST_PLATFORM_CLOCK() 1000 // (unit: MicroSecond)=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/Readme.md b/MdePkg/Library/MipiSysT= Lib/Readme.md new file mode 100644 index 0000000000..2e5df0194e --- /dev/null +++ b/MdePkg/Library/MipiSysTLib/Readme.md @@ -0,0 +1,25 @@ +## Introduction of MipiSysTLib ##=0D +MipiSysTLib library is a upper level library consuming MIPI SYS-T submodul= e.=0D +It provides MIPI-related APIs in EDK2 format to be consumed.=0D +=0D +## MipiSysTLib Version ##=0D +EDK2 supports building with v1.1+edk2 official version which was fully val= idated.=0D +=0D +## HOW to Install MipiSysTLib for UEFI Building ##=0D +MIPI SYS-T repository was added as a submodule of EDK2 project. Please=0D +refer to edk2/Readme.md for how to clone the code.=0D +=0D +## About GenMipiSystH.py ##=0D +"GenMipiSystH.py" is a Python script which is used for customizing the=0D +mipi_syst.h.in in mipi sys-T repository. The resulting file, mipi_syst.h, = will=0D +be put to same folder level as this script.=0D +```=0D + mipisyst submodule MipiSysTLib library=0D +|---------------------| GenMipiSystH.py |---------------------|=0D +| mipi_syst.h.in |-----------------> | mipi_syst.h |=0D +|---------------------| |---------------------|=0D +```=0D +This script needs to be done once by a developer when adding some=0D +project-related definition or a new version of mipi_syst.h.in was released= .=0D +Normal users do not need to do this, since the resulting file is stored=0D +in the EDK2 git repository.=0D diff --git a/MdePkg/Library/MipiSysTLib/mipi_syst.h b/MdePkg/Library/MipiSy= sTLib/mipi_syst.h new file mode 100644 index 0000000000..3cf67a1ee5 --- /dev/null +++ b/MdePkg/Library/MipiSysTLib/mipi_syst.h @@ -0,0 +1,789 @@ +/*=0D +Copyright (c) 2018, MIPI Alliance, Inc.=0D +All rights reserved.=0D +=0D +Redistribution and use in source and binary forms, with or without=0D +modification, are permitted provided that the following conditions=0D +are met:=0D +=0D +* Redistributions of source code must retain the above copyright=0D + notice, this list of conditions and the following disclaimer.=0D +=0D +* Redistributions in binary form must reproduce the above copyright=0D + notice, this list of conditions and the following disclaimer in=0D + the documentation and/or other materials provided with the=0D + distribution.=0D +=0D +* Neither the name of the copyright holder nor the names of its=0D + contributors may be used to endorse or promote products derived=0D + from this software without specific prior written permission.=0D +=0D +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS=0D +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT=0D +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR=0D +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT=0D +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,=0D +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT=0D +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,=0D +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY=0D +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT=0D +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE=0D +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.=0D +*/=0D +=0D +/*=0D + * Contributors:=0D + * Norbert Schulz (Intel Corporation) - Initial API and implementation=0D + */=0D +=0D +#ifndef MIPI_SYST_H_INCLUDED=0D +#define MIPI_SYST_H_INCLUDED=0D +=0D +/* SyS-T API version information=0D + */=0D +#define MIPI_SYST_VERSION_MAJOR 1 /**< Major version, incremented if API= changes */=0D +#define MIPI_SYST_VERSION_MINOR 0 /**< Minor version, incremented on com= patible 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 +#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_HASH1(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_HASH4(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_HASH16= (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(s= tr, sizeof(str)-1) + (offset))=0D +#define _MIPI_SYST_HASH_AT_RUN_TIME(str, offset) (mipi_syst_hash_x65599(st= r, 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 +#if defined(__cplusplus)=0D +extern "C" {=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 s= ync */=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 +struct mipi_syst_header;=0D +struct mipi_syst_handle;=0D +struct mipi_syst_scatter_prog;=0D +=0D +/** 128-bit GUID style message origin ID */=0D +struct mipi_syst_guid {=0D + union {=0D + mipi_syst_u8 b[16];=0D + mipi_syst_u64 ll[2];=0D + } u;=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 + * 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)(struct mipi_syst_h= eader *systh,=0D + const void *p);=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)(struct mipi_sys= t_header *systh);=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)(struct mipi_syst_handle *systh= );=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)(struct mipi_syst_handle *sy= sth);=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 +#ifdef __cplusplus=0D +} /* extern C */=0D +#endif=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 + /**=0D + * Extend Platform global SyS-T data state=0D + *=0D + * This define extends the global SyS-T state data structure=0D + * mipi_syst_header with platform private content. A platform typically=0D + * stores data for SyS-T handle creation processing in this structure.=0D + *=0D + * Note: This data is not touched by the library code itself, but typicall= y=0D + * is used by platform hook functions for handle creation and destruction= .=0D + * **These hook function calls are not lock protected and may happen=0D + * concurrently!** The hook functions need to implement locking if they=0D + * modify the platform state data.=0D + *=0D + * The platform example uses #mipi_syst_platform_state as data state exten= sion.=0D + */=0D +#define MIPI_SYST_PCFG_ENABLE_PLATFORM_STATE_DATA=0D +#undef MIPI_SYST_PCFG_ENABLE_PLATFORM_STATE_DATA=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 +/**=0D + * Enable HEAP usage for handle generation=0D + *=0D + * This macro tells the SyS-T library to enable the heap allocation handle= =0D + * creation API #MIPI_SYST_ALLOC_HANDLE.=0D + * The platform must provide the macros #MIPI_SYST_HEAP_MALLOC and=0D + * #MIPI_SYST_HEAP_FREE to point SyS-T to the platform malloc and free=0D + * functions.=0D + *=0D + * Note: In OS kernel space environments, you must use unpaged memory=0D + * allocation functions.=0D + */=0D +#define MIPI_SYST_PCFG_ENABLE_HEAP_MEMORY=0D +#undef MIPI_SYST_PCFG_ENABLE_HEAP_MEMORY=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 + * 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 + * 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 + * Enable printf API support=0D + *=0D + * Note:=0D + * Enabling printf requires compiler var_arg support as defined by the=0D + * header files stdarg.h stddef.h.=0D + */=0D +=0D +#define MIPI_SYST_PCFG_ENABLE_PRINTF_API=0D +#undef MIPI_SYST_PCFG_ENABLE_PRINTF_API=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 + * Enable 128-bit origin GUID support.=0D + */=0D +#define MIPI_SYST_PCFG_ENABLE_ORIGIN_GUID=0D +=0D +/**=0D + * Enable the API variants that send file:line ID pair location records.=0D + */=0D +#define MIPI_SYST_PCFG_ENABLE_LOCATION_RECORD=0D +#undef MIPI_SYST_PCFG_ENABLE_LOCATION_RECORD=0D +/**=0D + * Enable the API variants that send the address of the instrumentation lo= cation.=0D + *=0D + * This API requires #MIPI_SYST_PCFG_ENABLE_LOCATION_RECORD to be set as w= ell.=0D + * It uses its own define as it additionally requires the function=0D + * @ref mipi_syst_return_addr() to be implemented for your platform.=0D + */=0D +#define MIPI_SYST_PCFG_ENABLE_LOCATION_ADDRESS=0D +#undef MIPI_SYST_PCFG_ENABLE_LOCATION_ADDRESS=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 enable */= =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 + * 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 +#ifdef __cplusplus=0D +extern "C" {=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 +/** SyS-T global state structure.=0D + * This structure is holding the global SyS-T library state=0D + */=0D +struct mipi_syst_header {=0D + mipi_syst_u32 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 fun= ction*/=0D + mipi_syst_releasehandle_hook_t systh_releaseh; /**< handle release hook = */=0D +#endif=0D +=0D +#if MIPI_SYST_CONFORMANCE_LEVEL > 10=0D + mipi_syst_msg_write_t systh_writer; /**< message output routi= ne */=0D +#endif=0D +#if defined(MIPI_SYST_PCFG_ENABLE_PLATFORM_STATE_DATA)=0D + struct mipi_syst_platform_state systh_platform;=0D + /**< platform specific state */=0D +#endif=0D +};=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 +struct mipi_syst_msg_tag {=0D +#if defined(MIPI_SYST_BIG_ENDIAN)=0D + mipi_syst_u32 et_res31 : 1; /**< reserved for future use */=0D + mipi_syst_u32 et_res30 : 1; /**< reserved for future use */=0D + mipi_syst_u32 et_subtype : 6; /**< type dependent sub category */=0D + mipi_syst_u32 et_guid : 1; /**< 128-bit GUID present */=0D + mipi_syst_u32 et_modunit : 11; /**< unit for GUID or module:unit */=0D + mipi_syst_u32 et_timestamp : 1;/**< indicate 64-bit timestamp */=0D + mipi_syst_u32 et_chksum : 1; /**< indicate 32-bit CRC */=0D + mipi_syst_u32 et_length : 1; /**< indicate length field */=0D + mipi_syst_u32 et_location : 1; /**< indicate location information */=0D + mipi_syst_u32 et_res7 : 1; /**< reserved for future use */=0D + mipi_syst_u32 et_severity : 3; /**< severity level of message */=0D + mipi_syst_u32 et_type : 4; /**< SyS-T message type ID */=0D +#else=0D + mipi_syst_u32 et_type : 4; /**< SyS-T message type ID */=0D + mipi_syst_u32 et_severity : 3; /**< severity level of message */=0D + mipi_syst_u32 et_res7 : 1; /**< reserved for future use */=0D + mipi_syst_u32 et_location : 1; /**< indicate location information */=0D + mipi_syst_u32 et_length : 1; /**< indicate length field */=0D + mipi_syst_u32 et_chksum : 1; /**< indicate 32-bit CRC */=0D + mipi_syst_u32 et_timestamp : 1;/**< indicate 64-bit timestamp */=0D + mipi_syst_u32 et_modunit : 11; /**< unit for GUID or module:unit */=0D + mipi_syst_u32 et_guid : 1; /**< 128-bit GUID present */=0D + mipi_syst_u32 et_subtype : 6; /**< type dependent sub category */=0D + mipi_syst_u32 et_res30 : 1; /**< reserved for future use */=0D + mipi_syst_u32 et_res31 : 1; /**< reserved for future use */=0D +#endif=0D +};=0D +#define _MIPI_SYST_MK_MODUNIT_ORIGIN(m,u) (((u) & 0xF)|(m<<4))=0D +=0D +/**=0D + * Message severity level enumeration=0D + */=0D +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 +};=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 +/** internal handle state flags=0D + */=0D +struct mipi_syst_handle_flags {=0D + mipi_syst_u32 shf_alloc:1; /**< set to 1 if heap allocated handle */=0D +};=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 + struct mipi_syst_handle {=0D + struct mipi_syst_header* systh_header; /**< global state = */=0D + struct mipi_syst_handle_flags systh_flags; /**< handle state = */=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 record = */=0D +#endif=0D +=0D + mipi_syst_u32 systh_param_count; /**< number of parameters = */=0D + mipi_syst_u32 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;=0D + /**< platform specific state */=0D +#endif=0D +};=0D +=0D +=0D +#ifdef __cplusplus=0D +} /* extern C */=0D +#endif=0D +#ifndef MIPI_SYST_API_INCLUDED=0D +#include "mipi_syst/api.h"=0D +#endif=0D +=0D +typedef struct mipi_syst_header MIPI_SYST_HEADER;=0D +typedef struct mipi_syst_handle MIPI_SYST_HANDLE;=0D +typedef enum mipi_syst_severity MIPI_SYST_SEVERITY;=0D +typedef struct mipi_syst_guid MIPI_SYST_GUID;=0D +typedef struct mipi_syst_msg_tag MIPI_SYST_MSG_TAG;=0D +typedef struct mipi_syst_handle_flags MIPI_SYST_HANDLE_FLAGS;=0D +#endif=0D diff --git a/MdePkg/Library/MipiSysTLib/mipisyst b/MdePkg/Library/MipiSysTL= ib/mipisyst new file mode 160000 index 0000000000..370b5944c0 --- /dev/null +++ b/MdePkg/Library/MipiSysTLib/mipisyst @@ -0,0 +1 @@ +Subproject commit 370b5944c046bab043dd8b133727b2135af7747a diff --git a/MdePkg/MdePkg.ci.yaml b/MdePkg/MdePkg.ci.yaml index 035c34b3ad..f024b48685 100644 --- a/MdePkg/MdePkg.ci.yaml +++ b/MdePkg/MdePkg.ci.yaml @@ -10,7 +10,10 @@ {=0D ## options defined .pytool/Plugin/LicenseCheck=0D "LicenseCheck": {=0D - "IgnoreFiles": []=0D + "IgnoreFiles": [=0D + # This file is copied from mipi sys-T submodule and generated = by python script with customization.=0D + "Library/MipiSysTLib/mipi_syst.h"=0D + ]=0D },=0D "EccCheck": {=0D ## Exception sample looks like below:=0D @@ -68,7 +71,8 @@ "Include/Library/SafeIntLib.h",=0D "Include/Protocol/DebugSupport.h",=0D "Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLib.c",=0D - "Library/BaseFdtLib"=0D + "Library/BaseFdtLib",=0D + "Library/MipiSysTLib/mipi_syst.h"=0D ]=0D },=0D ## options defined ci/Plugin/CompilerPlugin=0D @@ -166,6 +170,7 @@ "IgnoreStandardPaths": [], # Standard Plugin defined paths that = should be ignore=0D "AdditionalIncludePaths": [] # Additional paths to spell check (wi= ldcards supported)=0D },=0D +=0D # options defined in .pytool/Plugin/UncrustifyCheck=0D "UncrustifyCheck": {=0D "IgnoreFiles": [=0D @@ -175,7 +180,8 @@ "Library/BaseFdtLib/stddef.h",=0D "Library/BaseFdtLib/stdint.h",=0D "Library/BaseFdtLib/stdlib.h",=0D - "Library/BaseFdtLib/string.h"=0D + "Library/BaseFdtLib/string.h",=0D + "mipi_syst.h"=0D ]=0D }=0D }=0D diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index d6c4179b2a..d68ed988c0 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -28,6 +28,7 @@ Include=0D Test/UnitTest/Include=0D Test/Mock/Include=0D + Library/MipiSysTLib/mipisyst/library/include=0D =0D [Includes.IA32]=0D Include/Ia32=0D @@ -293,6 +294,10 @@ #=0D FdtLib|Include/Library/FdtLib.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 b38c863812..902a39cffc 100644 --- a/MdePkg/MdePkg.dsc +++ b/MdePkg/MdePkg.dsc @@ -184,6 +184,7 @@ MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf=0D MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf=0D MdePkg/Library/TdxLib/TdxLib.inf=0D + MdePkg/Library/MipiSysTLib/MipiSysTLib.inf=0D =0D [Components.EBC]=0D MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf=0D diff --git a/ReadMe.rst b/ReadMe.rst index d46c534229..ed1d482245 100644 --- a/ReadMe.rst +++ b/ReadMe.rst @@ -97,6 +97,7 @@ that are covered by additional licenses. - `UnitTestFrameworkPkg/Library/SubhookLib/subhook `__=0D - `RedfishPkg/Library/JsonLib/jansson `__=0D - `MdePkg/Library/BaseFdtLib/libfdt `__=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.40.0.windows.1