Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## [6.1.0]

### Fixed
- fix cpp wrapper and add sample
- efi: use %s in external debug prefix

### Changed
- Linux: import libmei 1.8.0

### Added
- samples: gsc: search for gscfi device
- samples: print FW status in GSC
- CMake: Windows: add release and debug 64 all preset

## [6.0.2]
- Windows: drop un-needed assert
- EFI: do not send disconnect when not connected
Expand Down
72 changes: 36 additions & 36 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,6 @@
"BUILD_MSVC_RUNTIME_STATIC": "YES"
}
},
{
"name": "Debug32AllStatic",
"displayName": "Windows x86 Debug Static All",
"description": "Build x86 Debug, VS2019, including test and samples",
"inherits": "base32",
"binaryDir": "${sourceDir}/Debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BUILD_TEST": "YES",
"BUILD_SAMPLES": "YES",
"BUILD_SHARED_LIBS": "NO"
}
},
{
"name": "Release32AllStatic",
"displayName": "Windows x86 Release Static All",
"description": "Build x86 Release, VS2019, including test and samples",
"inherits": "base32",
"binaryDir": "${sourceDir}/Release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BUILD_TEST": "YES",
"BUILD_SAMPLES": "YES",
"BUILD_SHARED_LIBS": "NO"
}
},
{
"name": "Release32Static",
"displayName": "Windows x86 Release Static",
Expand Down Expand Up @@ -99,6 +73,19 @@
"BUILD_SHARED_LIBS": "NO"
}
},
{
"name": "Release64AllStatic",
"displayName": "Windows x86-64 Release Static",
"description": "Build x86-64 Release, VS2019",
"inherits": "base64",
"binaryDir": "${sourceDir}/Release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BUILD_TEST": "YES",
"BUILD_SAMPLES": "YES",
"BUILD_SHARED_LIBS": "NO"
}
},
{
"name": "Debug64All",
"displayName": "Windows x86-64 Debug All",
Expand All @@ -110,19 +97,22 @@
"BUILD_TEST": "YES",
"BUILD_SAMPLES": "YES"
}
},
{
"name": "Debug64AllStatic",
"displayName": "Windows x86-64 Debug Static All",
"description": "Build x86-64 Debug, VS2019, including test and samples",
"inherits": "base64",
"binaryDir": "${sourceDir}/Debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BUILD_TEST": "YES",
"BUILD_SAMPLES": "YES",
"BUILD_SHARED_LIBS": "NO"
}
}
],
"buildPresets": [
{
"name": "Debug32AllStatic",
"configurePreset": "Debug32AllStatic",
"configuration": "Debug"
},
{
"name": "Release32AllStatic",
"configurePreset": "Release32AllStatic",
"configuration": "Release"
},
{
"name": "Release32Static",
"configurePreset": "Release32Static",
Expand All @@ -143,10 +133,20 @@
"configurePreset": "Release64Static",
"configuration": "Release"
},
{
"name": "Release64AllStatic",
"configurePreset": "Release64AllStatic",
"configuration": "Release"
},
{
"name": "Debug64All",
"configurePreset": "Debug64All",
"configuration": "Debug"
},
{
"name": "Debug64AllStatic",
"configurePreset": "Debug64AllStatic",
"configuration": "Debug"
}
]
}
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.0.2
6.1.0
4 changes: 2 additions & 2 deletions include/helpers.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: Apache-2.0 */
/*
* Copyright (C) 2014-2024 Intel Corporation
* Copyright (C) 2014-2025 Intel Corporation
*/
#ifndef __HELPERS_H
#define __HELPERS_H
Expand Down Expand Up @@ -34,7 +34,7 @@ extern "C" {
#define INIT_STATUS TEE_INTERNAL_ERROR
#elif defined(EFI)
#define DEBUG_PRINT_ME_PREFIX_INTERNAL "TEELIB: (%a:%a():%d) "
#define DEBUG_PRINT_ME_PREFIX_EXTERNAL "TEELIB: (%a:%a():%d) "
#define DEBUG_PRINT_ME_PREFIX_EXTERNAL "TEELIB: (%s:%s():%d) "
#define DebugPrintMe(fmt, ...) AsciiPrint(fmt, ##__VA_ARGS__)
#define ErrorPrintMe(fmt, ...) AsciiPrint(fmt, ##__VA_ARGS__)
#else
Expand Down
60 changes: 49 additions & 11 deletions include/meteepp.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,63 @@ namespace intel {
class metee
{
public:
/*! Default constructor */
metee()
/*! Default constructor, when connection to specific client is not required */
metee() : metee(METEE_GUID_ZERO) {}

/*! Constructor without client GUID, when connection to specific client is not required
* \param log_level log level to set (from enum tee_log_level)
* \param log_callback pointer to function to run for log write (type 2)
*/
metee(uint32_t log_level, TeeLogCallback2 log_callback) : metee(METEE_GUID_ZERO, log_level, log_callback) {}

/*! Constructor
* \param guid GUID of the FW client that want to start a session
*/
metee(const GUID& guid)
{
TEESTATUS status = TeeInit(&_handle, &METEE_GUID_ZERO, NULL);
TEESTATUS status = TeeInit(&_handle, &guid, nullptr);
if (!TEE_IS_SUCCESS(status)) {
throw metee_exception("Init failed", status);
}
}
/*! Constructor
* \param guid GUID of the FW client that want to start a session
* \param log_level log level to set (from enum tee_log_level)
*/
metee(const GUID& guid, uint32_t log_level) : metee(guid, log_level, static_cast<TeeLogCallback2>(nullptr)) {}

/*! Constructor
* \param guid GUID of the FW client that want to start a session
* \param log_level log level to set (from enum tee_log_level)
* \param log_callback pointer to function to run for log write, set NULL to use built-in function
* \param log_callback pointer to function to run for log write
*/
metee(const GUID &guid,
uint32_t log_level = TEE_LOG_LEVEL_VERBOSE, TeeLogCallback log_callback = nullptr)
metee(const GUID& guid, uint32_t log_level, TeeLogCallback log_callback) :
metee(guid, { tee_device_address::TEE_DEVICE_TYPE_NONE , nullptr }, log_level, log_callback) {}

/*! Constructor
* \param guid GUID of the FW client that want to start a session
* \param log_level log level to set (from enum tee_log_level)
* \param log_callback pointer to function to run for log write (type 2)
*/
metee(const GUID& guid, uint32_t log_level, TeeLogCallback2 log_callback) :
metee(guid, { tee_device_address::TEE_DEVICE_TYPE_NONE , nullptr }, log_level, log_callback) {}

/*! Constructor
* \param guid GUID of the FW client that want to start a session
* \param device device address structure
* \param log_level log level to set (from enum tee_log_level)
*/
metee(const GUID& guid, const struct tee_device_address& device, uint32_t log_level) :
metee(guid, device, log_level, static_cast<TeeLogCallback2>(nullptr)) {}

/*! Constructor
* \param guid GUID of the FW client that want to start a session
* \param device device address structure
* \param log_level log level to set (from enum tee_log_level)
* \param log_callback pointer to function to run for log write
*/
metee(const GUID &guid, const struct tee_device_address &device, uint32_t log_level, TeeLogCallback log_callback)
{
struct tee_device_address device = { tee_device_address::TEE_DEVICE_TYPE_NONE , nullptr };
TEESTATUS status = TeeInitFull(&_handle, &guid, device, log_level, log_callback);
if (!TEE_IS_SUCCESS(status)) {
throw metee_exception("Init failed", status);
Expand All @@ -112,12 +151,11 @@ namespace intel {
* \param guid GUID of the FW client that want to start a session
* \param device device address structure
* \param log_level log level to set (from enum tee_log_level)
* \param log_callback pointer to function to run for log write, set NULL to use built-in function
* \param log_callback pointer to function to run for log write (type 2)
*/
metee(const GUID &guid, const struct tee_device_address &device,
uint32_t log_level = TEE_LOG_LEVEL_VERBOSE, TeeLogCallback log_callback = nullptr)
metee(const GUID& guid, const struct tee_device_address& device, uint32_t log_level, TeeLogCallback2 log_callback)
{
TEESTATUS status = TeeInitFull(&_handle, &guid, device, log_level, log_callback);
TEESTATUS status = TeeInitFull2(&_handle, &guid, device, log_level, log_callback);
if (!TEE_IS_SUCCESS(status)) {
throw metee_exception("Init failed", status);
}
Expand Down
4 changes: 4 additions & 0 deletions samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ add_executable(metee-basic metee_basic.c)
target_link_libraries(metee-basic metee)
install(TARGETS metee-basic RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

add_executable(meteepp-basic meteepp_basic.cpp)
target_link_libraries(meteepp-basic metee)
install(TARGETS meteepp-basic RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

if(BUILD_SHARED_LIBS AND WIN32)
add_subdirectory(csharp)
endif(BUILD_SHARED_LIBS AND WIN32)
71 changes: 65 additions & 6 deletions samples/metee_gsc.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: Apache-2.0 */
/*
* Copyright (C) 2020-2024 Intel Corporation
* Copyright (C) 2020-2025 Intel Corporation
*/
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -106,23 +106,82 @@ struct mk_host_if {
bool verbose;
};

static void mk_host_if_fw_status(struct mk_host_if *acmd)
{
uint32_t fwStatus = 0;

for (uint32_t i = 0; i < 6; i++)
if (TeeFWStatus(&acmd->mei_cl, i, &fwStatus) == TEE_SUCCESS)
printf("FW Status[%u] = 0x%08X\n", i, fwStatus);
}

static bool mk_host_if_is_gscfi(struct mk_host_if *acmd)
{
char kind[32];
size_t kind_size = sizeof(kind);

if (TeeGetKind(&acmd->mei_cl, kind, &kind_size) != TEE_SUCCESS)
return false;

return !strcmp(kind, "gscfi");
}

static bool mk_host_if_connect(struct mk_host_if *acmd)
{
acmd->initialized = (TeeConnect(&acmd->mei_cl) == 0);
return acmd->initialized;
}

static void mk_host_if_log(bool is_error, const char* data)
{
fprintf((is_error) ? stderr : stdout, "LIB: %s", data);
}

static bool mk_host_if_init(struct mk_host_if *acmd, const GUID *guid,
bool reconnect, bool verbose)
{
acmd->reconnect = reconnect;
acmd->verbose = verbose;
#ifdef WIN32
TeeInitGUID(&acmd->mei_cl, guid, &GUID_DEVINTERFACE_HECI_GSC_CHILD);
#define ADDR_NUM 1
struct tee_device_address addr[ADDR_NUM] = {
{
.type = TEE_DEVICE_TYPE_GUID,
.data.guid = &GUID_DEVINTERFACE_HECI_GSC_CHILD
}
};
#else
TeeInit(&acmd->mei_cl, guid, NULL);
#define ADDR_NUM 3
struct tee_device_address addr[ADDR_NUM] = {
{
.type = TEE_DEVICE_TYPE_PATH,
.data.path = "/dev/mei0"
},
{
.type = TEE_DEVICE_TYPE_PATH,
.data.path = "/dev/mei1"
},
{
.type = TEE_DEVICE_TYPE_PATH,
.data.path = "/dev/mei2"
},
};
#endif /* WIN32 */
return mk_host_if_connect(acmd);

acmd->reconnect = reconnect;
acmd->verbose = verbose;
for (size_t i = 0; i < ADDR_NUM; i++) {
if (TeeInitFull2(&acmd->mei_cl, guid, addr[i],
(verbose) ? TEE_LOG_LEVEL_VERBOSE : TEE_LOG_LEVEL_ERROR,
mk_host_if_log) != TEE_SUCCESS)
return false;

if (!mk_host_if_is_gscfi(acmd)) {
TeeDisconnect(&acmd->mei_cl);
continue;
}
mk_host_if_fw_status(acmd);
return mk_host_if_connect(acmd);
}
return false;
}

static void mk_host_if_deinit(struct mk_host_if *acmd)
Expand Down
Loading
Loading