xref: /openbmc/pldm/platform-mc/terminus.cpp (revision 06b443ec)
1 #include "terminus.hpp"
2 
3 #include "libpldm/platform.h"
4 
5 #include "terminus_manager.hpp"
6 
7 namespace pldm
8 {
9 namespace platform_mc
10 {
11 
12 Terminus::Terminus(pldm_tid_t tid, uint64_t supportedTypes) :
13     initialized(false), tid(tid), supportedTypes(supportedTypes)
14 {}
15 
16 bool Terminus::doesSupportType(uint8_t type)
17 {
18     return supportedTypes.test(type);
19 }
20 
21 bool 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
54