blob: 947571be2d2f90a28d03703f6dbff4c556521f33 [file] [log] [blame]
Gilbert Chen6c7fed42022-02-22 15:40:17 +00001#include "terminus.hpp"
2
3#include "libpldm/platform.h"
4
5#include "terminus_manager.hpp"
6
7namespace pldm
8{
9namespace platform_mc
10{
11
12Terminus::Terminus(pldm_tid_t tid, uint64_t supportedTypes) :
13 initialized(false), tid(tid), supportedTypes(supportedTypes)
14{}
15
16bool Terminus::doesSupportType(uint8_t type)
17{
18 return supportedTypes.test(type);
19}
20
21bool Terminus::doesSupportCommand(uint8_t type, uint8_t command)
22{
23 if (!doesSupportType(type))
24 {
25 return false;
26 }
27
28 try
29 {
30 const size_t idx = type * (PLDM_MAX_CMDS_PER_TYPE / 8) + (command / 8);
31 if (idx >= supportedCmds.size())
32 {
33 return false;
34 }
35
36 if (supportedCmds[idx] & (1 << (command % 8)))
37 {
38 lg2::info(
39 "PLDM type {TYPE} command {CMD} is supported by terminus {TID}",
40 "TYPE", type, "CMD", command, "TID", getTid());
41 return true;
42 }
43 }
44 catch (const std::exception& e)
45 {
46 return false;
47 }
48
49 return false;
50}
51
52} // namespace platform_mc
53} // namespace pldm