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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## [6.2.2]

### Changed
- reshuffle log macros
- Linux: import libmei 1.8.2

### Added
- samples: add fw status print to cpp sample
- EFI: introduce new define to enable stdlib support

## [6.2.1]

### Fixed
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ By default, CMake links with dynamic runtime (/MD), set BUILD_MSVC_RUNTIME_STATI
2. Run `cmake <srcdir>` from the `build` directory
3. Run `make -j$(nproc) package` from the `build` directory to build .deb and .rpm packages and .tgz archive

### EFI

When building application with C Standard support, add following preprocessor variable to build options
`METEE_EFI_STDLIB_SUPPORT`

## Meson Build

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.2.1
6.2.2
91 changes: 41 additions & 50 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-2025 Intel Corporation
* Copyright (C) 2014-2026 Intel Corporation
*/
#ifndef __HELPERS_H
#define __HELPERS_H
Expand All @@ -9,75 +9,66 @@ extern "C" {
#endif

#define DEBUG_MSG_LEN 1024
#if DEBUG
#define TEE_DEFAULT_LOG_LEVEL TEE_LOG_LEVEL_VERBOSE
#else
#define TEE_DEFAULT_LOG_LEVEL TEE_LOG_LEVEL_QUIET
#endif

#ifdef EFI
#define DEBUG_PRINT_ME_PREFIX_INTERNAL "TEELIB: (%a:%a():%d) "
#else /* EFI */
#define DEBUG_PRINT_ME_PREFIX_INTERNAL "TEELIB: (%s:%s():%d) "
#endif /* EFI */
#define DEBUG_PRINT_ME_PREFIX_EXTERNAL "TEELIB: (%s:%s():%d) "

#ifdef _WIN32
#include <windows.h>
#include <stdio.h>
#include <stdarg.h>
#include "metee.h"

#if _DEBUG
#define TEE_DEFAULT_LOG_LEVEL TEE_LOG_LEVEL_VERBOSE
#else
#define TEE_DEFAULT_LOG_LEVEL TEE_LOG_LEVEL_QUIET
#endif
#define DEBUG_PRINT_ME_PREFIX_EXTERNAL "TEELIB: (%s:%s():%d) "
#define DEBUG_PRINT_ME_PREFIX_INTERNAL "TEELIB: (%s:%s():%d) "

#define MALLOC(X) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, X)
#define FREE(X) {if(X) { HeapFree(GetProcessHeap(), 0, X); X = NULL ; } }

void DebugPrintMe(const char* args, ...);

#define ErrorPrintMe(fmt, ...) DebugPrintMe(fmt, __VA_ARGS__)
#define IS_HANDLE_INVALID(h) (NULL == h || 0 == h->handle || INVALID_HANDLE_VALUE == h->handle)
#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: (%s:%s():%d) "
#define DebugPrintMe(fmt, ...) AsciiPrint(fmt, ##__VA_ARGS__)
#define ErrorPrintMe(fmt, ...) AsciiPrint(fmt, ##__VA_ARGS__)
#else
#define DEBUG_PRINT_ME_PREFIX_INTERNAL "TEELIB: (%s:%s():%d) "
#define DEBUG_PRINT_ME_PREFIX_EXTERNAL "TEELIB: (%s:%s():%d) "
#ifdef ANDROID
// For debugging
//#define LOG_NDEBUG 0
#define LOG_TAG "metee"
#include <android/log_macros.h>
#define DebugPrintMe(fmt, ...) ALOGV(fmt, ##__VA_ARGS__)
#define ErrorPrintMe(fmt, ...) ALOGE(fmt, ##__VA_ARGS__)
#ifdef LOG_NDEBUG
#define TEE_DEFAULT_LOG_LEVEL TEE_LOG_LEVEL_VERBOSE
#else
#define TEE_DEFAULT_LOG_LEVEL TEE_LOG_LEVEL_QUIET
#endif
#else /* LINUX */
#ifdef SYSLOG
#include <syslog.h>
#define DebugPrintMe(fmt, ...) syslog(LOG_DEBUG, fmt, ##__VA_ARGS__)
#define ErrorPrintMe(fmt, ...) syslog(LOG_ERR, fmt, ##__VA_ARGS__)
#else
#include <stdlib.h>
#define DebugPrintMe(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
#define ErrorPrintMe(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
#endif /* SYSLOG */

#ifdef DEBUG
#define TEE_DEFAULT_LOG_LEVEL TEE_LOG_LEVEL_VERBOSE
#else
#define TEE_DEFAULT_LOG_LEVEL TEE_LOG_LEVEL_QUIET
#endif

#endif /* ANDROID */

#define MALLOC(X) malloc(X)
#define FREE(X) { if(X) { free(X); X = NULL ; } }

#define IS_HANDLE_INVALID(h) (NULL == h || 0 == h->handle || -1 == h->handle)
#define INIT_STATUS -EPERM
#endif /* _WIN32 */

#if SYSLOG
#ifdef _WIN32
void DebugPrintMe(const char* args, ...);
#define ErrorPrintMe(fmt, ...) DebugPrintMe(fmt, __VA_ARGS__)
#elif defined(ANDROID)
#define LOG_TAG "metee"
#include <android/log_macros.h>
#define DebugPrintMe(fmt, ...) ALOGV(fmt, ##__VA_ARGS__)
#define ErrorPrintMe(fmt, ...) ALOGE(fmt, ##__VA_ARGS__)
#elif defined(EFI)
#define DebugPrintMe(fmt, ...) AsciiPrint(fmt, ##__VA_ARGS__)
#define ErrorPrintMe(fmt, ...) AsciiPrint(fmt, ##__VA_ARGS__)
#else
#include <syslog.h>
#define DebugPrintMe(fmt, ...) syslog(LOG_DEBUG, fmt, ##__VA_ARGS__)
#define ErrorPrintMe(fmt, ...) syslog(LOG_ERR, fmt, ##__VA_ARGS__)
#endif
#else /* SYSLOG */
#ifdef EFI
#define DebugPrintMe(fmt, ...) AsciiPrint(fmt, ##__VA_ARGS__)
#define ErrorPrintMe(fmt, ...) AsciiPrint(fmt, ##__VA_ARGS__)
#else
#include <stdlib.h>
#define DebugPrintMe(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
#define ErrorPrintMe(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
#endif
#endif /* SYSLOG */

#define LEGACY_CALLBACK_SET(h) ((h)->log_callback ? 1 : 0)
#define STANDARD_CALLBACK_SET(h) ((h)->log_callback2 ? 1 : 0)

Expand Down
3 changes: 3 additions & 0 deletions samples/meteepp_basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ int main(int argc, char* argv[])
std::cout << "Version: " << rsp->version.code.major << "." << rsp->version.code.minor << "."
<< rsp->version.code.hotFix << "." << rsp->version.code.buildNo << std::endl;

for (size_t i = 0; i < 6; i++)
std::cout << "FW Status " << i + 1 << " : " << metee.fw_status(i) << std::endl;

return 0;
}
catch (const intel::security::metee_exception& ex) {
Expand Down
6 changes: 1 addition & 5 deletions src/Windows/metee_winhelpers.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: Apache-2.0 */
/*
* Copyright (C) 2014-2025 Intel Corporation
* Copyright (C) 2014-2026 Intel Corporation
*/
#include <windows.h>
#include <initguid.h>
Expand All @@ -23,11 +23,7 @@ void DebugPrintMe(const char* args, ...)
vsprintf_s(msg, DEBUG_MSG_LEN, args, varl);
va_end(varl);

#ifdef SYSLOG
OutputDebugStringA(msg);
#else
fprintf(stderr, "%s", msg);
#endif /* SYSLOG */
}

void CallbackPrintHelper(IN PTEEHANDLE handle, bool is_error, const char* args, ...)
Expand Down
35 changes: 11 additions & 24 deletions src/linux/mei.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright(c) 2013 - 2025 Intel Corporation. All rights reserved.
* Copyright(c) 2013 - 2026 Intel Corporation. All rights reserved.
*
* Intel Management Engine Interface (Intel MEI) Library
*/
Expand All @@ -23,27 +23,17 @@
/*****************************************************************************
* Intel Management Engine Interface
*****************************************************************************/
#ifdef ANDROID
#define LOG_TAG "libmei"
#include <android/log_macros.h>
#define mei_msg(_me, fmt, ARGS...) \
((_me->log_level >= MEI_LOG_LEVEL_VERBOSE) \
? (void)ALOGV(fmt, ##ARGS) \
: (void)0)

#define mei_err(_me, fmt, ARGS...) ALOGE(fmt, ##ARGS)
#ifdef DEBUG
static inline void __dump_buffer(const char *buf)
{
ALOGV("%s\n", buf);
}
#endif /* DEBUG */

#else /* ! ANDROID */
#ifdef SYSLOG
#include <syslog.h>
#define __mei_msg(fmt, ...) syslog(LOG_DEBUG, fmt, ##__VA_ARGS__)
#define __mei_err(fmt, ...) syslog(LOG_ERR, fmt, ##__VA_ARGS__)
#ifdef ANDROID
#define LOG_TAG "libmei"
#include <android/log_macros.h>
#define __mei_msg(fmt, ...) ALOGV(fmt, ##__VA_ARGS__)
#define __mei_err(fmt, ...) ALOGE(fmt, ##__VA_ARGS__)
#else /* ANDROID */
#include <syslog.h>
#define __mei_msg(fmt, ...) syslog(LOG_DEBUG, fmt, ##__VA_ARGS__)
#define __mei_err(fmt, ...) syslog(LOG_ERR, fmt, ##__VA_ARGS__)
#endif /* ANDROID */
#else
#include <stdlib.h>
#define __mei_msg(fmt, ...) fprintf(stdout, fmt, ##__VA_ARGS__)
Expand Down Expand Up @@ -80,10 +70,7 @@ static inline void __dump_buffer(const char *buf)
{
__mei_msg("%s\n", buf);
}
#endif /* DEBUG */
#endif /* ANDROID */

#ifdef DEBUG
static void dump_hex_buffer(const unsigned char *buf, size_t len)
{
#define LINE_LEN 16
Expand Down
8 changes: 8 additions & 0 deletions src/uefi/metee_efi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
/*
* Copyright (C) 2024-2025 Intel Corporation
*/

#ifdef METEE_EFI_STDLIB_SUPPORT
#include <stdio.h>
#endif
#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/BaseLib.h>
Expand Down Expand Up @@ -97,7 +101,11 @@ void CallbackPrintHelper(IN PTEEHANDLE handle, bool is_error, const char* args,
char msg[DEBUG_MSG_LEN + 1];
VA_LIST varl;
VA_START(varl, args);
#ifdef METEE_EFI_STDLIB_SUPPORT
vsnprintf(msg, DEBUG_MSG_LEN, args, varl);
#else
AsciiVSPrint(msg, DEBUG_MSG_LEN, args, varl);
#endif
VA_END(varl);
handle->log_callback2(is_error, msg);
}
Expand Down
Loading