Skip to content

Commit ee7cab4

Browse files
committed
LMS: use metee cpp wrapper
Use meteepp in code and refactor LMEClient into own class. Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
1 parent 9a39436 commit ee7cab4

16 files changed

Lines changed: 371 additions & 500 deletions

File tree

MEIClient/AMTHITestProject/AMTHITestProject.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
/* SPDX-License-Identifier: Apache-2.0 */
22
/*
3-
* Copyright (C) 2013-2023 Intel Corporation
3+
* Copyright (C) 2013-2025 Intel Corporation
44
*/
55
// AMTHITestProject.cpp : main project file.
66

77
#include "AMTHICommand.h"
88
#include "MEIClientException.h"
9-
#include "HECIException.h"
109

1110
#include "gtest/gtest.h"
1211

@@ -542,7 +541,7 @@ TEST(MCHI, testReadFileExCommand)
542541
<< " 0x" << (uint32_t)theFile.Data[3]
543542
<< std::endl;
544543
}
545-
catch (const Intel::MEI_Client::HeciNoClientException&) {}
544+
catch (const Intel::MEI_Client::MEIClientExceptionNoClient&) {}
546545
catch (const Intel::MEI_Client::MCHI_Client::MCHIErrorExceptionNoFile&) {}
547546
}
548547

@@ -554,7 +553,7 @@ TEST(UPID, testGetUPIDFeatureSupportCommand)
554553
UPID_PLATFORM_ID_FEATURE_SUPPORT_GET_Response support = getSupport.getResponse();
555554
EXPECT_EQ(support.platformIdSupported & ~(UPID_PLATFORM_ID_UPID_IS_SUPPORTED | UPID_PLATFORM_ID_ATTESTATION_IS_SUPPORTED), 0);
556555
}
557-
catch (const Intel::MEI_Client::HeciNoClientException&) {}
556+
catch (const Intel::MEI_Client::MEIClientExceptionNoClient&) {}
558557
}
559558

560559
TEST(UPID, testGetUPIDFeatureOSControlCommand)
@@ -564,7 +563,7 @@ TEST(UPID, testGetUPIDFeatureOSControlCommand)
564563
GetUPIDFeatureOSControlCommand getOSControl;
565564
UPID_PLATFORM_ID_FEATURE_OSCONTROL_GET_Response support = getOSControl.getResponse();
566565
}
567-
catch (const Intel::MEI_Client::HeciNoClientException&) {}
566+
catch (const Intel::MEI_Client::MEIClientExceptionNoClient&) {}
568567
}
569568

570569
TEST(Manageabiltiy, testMNGIsChangeToAMTEnabledCommand)

MEIClient/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
# SPDX-License-Identifier: Apache-2.0
2-
# Copyright (C) 2010-2024 Intel Corporation
2+
# Copyright (C) 2010-2025 Intel Corporation
33
cmake_minimum_required (VERSION 3.15)
44

55
include (metee.cmake)
66

77
add_library (MEIClient STATIC
88
src/MEICommand.cpp
99
src/MEIparser.cpp
10-
src/heci.cpp
1110
AMTHIClient/Src/AmtAnsiString.cpp
1211
AMTHIClient/Src/AMTHICommand.cpp
1312
FWUpdateClient/Src/FWUpdateCommand.cpp
@@ -17,6 +16,7 @@ add_library (MEIClient STATIC
1716
UPIDClient/Src/UPIDCommand.cpp
1817
PSRClient/Src/PSRCommand.cpp
1918
MCHIClient/Src/MCHICommand.cpp
19+
LMEClient/Src/LMEClient.cpp
2020
)
2121

2222
set_target_properties (MEIClient PROPERTIES POSITION_INDEPENDENT_CODE ON)
@@ -37,6 +37,7 @@ target_include_directories (MEIClient PUBLIC
3737
"UPIDClient/Include/"
3838
"PSRClient/Include/"
3939
"MCHIClient/Include/"
40+
"LMEClient/Include/"
4041
)
4142
if (BUILD_TESTS)
4243
add_subdirectory ("AMTHITestProject" "AMTHITestProject")

MEIClient/Include/HECIException.h

Lines changed: 0 additions & 39 deletions
This file was deleted.

MEIClient/Include/MEIClientException.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* SPDX-License-Identifier: Apache-2.0 */
22
/*
3-
* Copyright (C) 2009-2020 Intel Corporation
3+
* Copyright (C) 2009-2025 Intel Corporation
44
*/
55
/*++
66
@@ -34,12 +34,20 @@ namespace Intel { namespace MEI_Client {
3434
: std::system_error(err, cat, what) {}
3535
virtual ~MEIClientException() noexcept {}
3636
};
37+
3738
class MEIClientExceptionZeroBuffer : public MEIClientException
3839
{
3940
public:
4041
MEIClientExceptionZeroBuffer(const std::string &what, int err = 0) : MEIClientException(what, err) {}
4142
virtual ~MEIClientExceptionZeroBuffer() noexcept {}
4243
};
44+
45+
class MEIClientExceptionNoClient : public MEIClientException
46+
{
47+
public:
48+
MEIClientExceptionNoClient(const std::string &what, int err = 0) : MEIClientException(what, err) {}
49+
virtual ~MEIClientExceptionNoClient() noexcept {}
50+
};
4351
} /* namespace MEI_Client */ } /* namespace Intel */
4452

45-
#endif //__MEI_CLIENT_EXCEPTION_H
53+
#endif //__MEI_CLIENT_EXCEPTION_H

MEIClient/Include/MEICommand.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* SPDX-License-Identifier: Apache-2.0 */
22
/*
3-
* Copyright (C) 2010-2023 Intel Corporation
3+
* Copyright (C) 2010-2025 Intel Corporation
44
*/
55
/*++
66
@@ -10,7 +10,7 @@
1010

1111
#ifndef __MEI_COMMAND_H__
1212
#define __MEI_COMMAND_H__
13-
#include "heci.h"
13+
#include <meteepp.h>
1414
#include "MEIClientException.h"
1515
#include <cstdint>
1616
#include <memory>
@@ -23,7 +23,7 @@ namespace MEI_Client
2323
{
2424
class MEICommandRequest;
2525

26-
HECI* GenerateLMEClient(bool verbose = false);
26+
intel::security::metee heciClientByGUID(const GUID& guid);
2727
void GetHeciDriverVersion(std::string &ver);
2828

2929
class MEICommand

MEIClient/Include/heci.h

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/* SPDX-License-Identifier: Apache-2.0 */
2+
/*
3+
* Copyright (C) 2021-2026 Intel Corporation
4+
*/
5+
/*++
6+
7+
@file: LMEClient.h
8+
9+
--*/
10+
11+
#ifndef __LME_CLIENT_H__
12+
#define __LME_CLIENT_H__
13+
14+
#include <vector>
15+
#include <memory>
16+
#include <mutex>
17+
#include <meteepp.h>
18+
#include "MEIClientException.h"
19+
20+
namespace Intel
21+
{
22+
namespace MEI_Client
23+
{
24+
namespace LME_Client
25+
{
26+
27+
class LMEClient {
28+
public:
29+
LMEClient() : _heci(nullptr) {}
30+
31+
void Connect();
32+
void Disconnect();
33+
void Cancel();
34+
std::vector<uint8_t> Read();
35+
size_t Write(const std::vector<uint8_t> &buffer);
36+
size_t GetBufferSize() const;
37+
TEE_DEVICE_HANDLE GetDeviceHandle() const;
38+
private:
39+
std::unique_ptr<intel::security::metee> _heci;
40+
std::mutex _sendMessageLock;
41+
};
42+
} // namespace LME_Client
43+
} // namespace MEI_Client
44+
} // namespace Intel
45+
46+
#endif //__LME_CLIENT_H__
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/* SPDX-License-Identifier: Apache-2.0 */
2+
/*
3+
* Copyright (C) 2021-2026 Intel Corporation
4+
*/
5+
/*++
6+
7+
@file: LMEClient.cpp
8+
9+
--*/
10+
11+
#include "LMEClient.h"
12+
#include "MEICommand.h"
13+
#include <meteepp.h>
14+
#include "HECI_if.h"
15+
16+
namespace Intel
17+
{
18+
namespace MEI_Client
19+
{
20+
namespace LME_Client
21+
{
22+
const uint32_t HECI_IO_TIMEOUT = 5000;
23+
void LMEClient::Connect()
24+
{
25+
_heci.reset(new intel::security::metee(heciClientByGUID(LME_GUID)));
26+
}
27+
28+
void LMEClient::Disconnect()
29+
{
30+
_heci.reset(nullptr);
31+
}
32+
33+
std::vector<uint8_t> LMEClient::Read()
34+
{
35+
if (_heci == nullptr)
36+
throw MEIClientException("Not initialized", TEE_INTERNAL_ERROR);
37+
try
38+
{
39+
return _heci->read(0);
40+
}
41+
catch (const intel::security::metee_exception& e)
42+
{
43+
throw MEIClientException(e.what(), e.code().value());
44+
}
45+
}
46+
47+
void LMEClient::Cancel()
48+
{
49+
if (_heci == nullptr)
50+
throw MEIClientException("Not initialized", TEE_INTERNAL_ERROR);
51+
try
52+
{
53+
_heci->cancel_io();
54+
}
55+
catch (const intel::security::metee_exception& e)
56+
{
57+
throw MEIClientException(e.what(), e.code().value());
58+
}
59+
}
60+
61+
size_t LMEClient::Write(const std::vector<uint8_t> &buffer)
62+
{
63+
if (_heci == nullptr)
64+
throw MEIClientException("Not initialized", TEE_INTERNAL_ERROR);
65+
66+
std::lock_guard<std::mutex> lock(_sendMessageLock);
67+
68+
try
69+
{
70+
return _heci->write(buffer, HECI_IO_TIMEOUT);
71+
}
72+
catch (const intel::security::metee_exception& e)
73+
{
74+
throw MEIClientException(e.what(), e.code().value());
75+
}
76+
}
77+
78+
size_t LMEClient::GetBufferSize() const
79+
{
80+
if (_heci == nullptr)
81+
throw MEIClientException("Not initialized", TEE_INTERNAL_ERROR);
82+
return _heci->max_msg_len();
83+
}
84+
85+
TEE_DEVICE_HANDLE LMEClient::GetDeviceHandle() const
86+
{
87+
if (_heci == nullptr)
88+
throw MEIClientException("Not initialized", TEE_INTERNAL_ERROR);
89+
return _heci->device_handle();
90+
}
91+
} // namespace LME_Client
92+
} // namespace MEI_Client
93+
} // namespace Intel

MEIClient/metee-down.cmake.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# SPDX-License-Identifier: Apache-2.0
2-
# Copyright (C) 2019-2024 Intel Corporation
2+
# Copyright (C) 2019-2025 Intel Corporation
33
#
44
# Inspired by GTest example
55
cmake_minimum_required (VERSION 3.15)
@@ -9,7 +9,7 @@ project (metee-download NONE)
99
include (ExternalProject)
1010
ExternalProject_Add (metee
1111
GIT_REPOSITORY https://github.com/intel/metee.git
12-
GIT_TAG 6.0.2
12+
GIT_TAG 6.1.0
1313
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/metee"
1414
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/metee-build"
1515
CONFIGURE_COMMAND ""

0 commit comments

Comments
 (0)