bios: Use the new APIs in bios table commands
Use new APIs(BIOSConfig) in bios table commands.
The previous code built bios tables after receiving
the GetBIOSTable command. But A BIOS can send
GetBIOSAttributeCurrentValueByHandle or
SetBIOSAttributeCurrentValue before GetBIOSTable, then
we should build bios tables in those commands.
This change builds bios tables in the command handler's
constructor, which avoids building bios tables in multiple
places.
Tested: Build tables and verify that built tables are as expected
(same as before)
Tested on fp5280g2, with json file
https://gist.github.com/wangzqbj/b24558331cb35d14fca3b555ef03e458
$ pldmtool bios GetBIOSTable -t StringTable
...
...
PLDM StringTable:
BIOSStringHandle : BIOSString
0 : CodeUpdatePolicy
1 : Concurrent
2 : Disruptive
3 : Led
4 : Model
5 : OUTLET
6 : Off
7 : On
8 : str_example3
$ pldmtool bios GetBIOSTable -t AttributeTable
...
...
PLDM AttributeTable:
AttributeHandle: 0, AttributeNameHandle: 4(Model)
AttributeType: BIOSString
StringType: 0x01
MinimumStringLength: 1
MaximumStringLength: 100
DefaultStringLength: 8
DefaultString: FP5280G2
AttributeHandle: 1, AttributeNameHandle: 8(str_example3)
AttributeType: BIOSStringReadOnly
StringType: 0x00
MinimumStringLength: 1
MaximumStringLength: 100
DefaultStringLength: 2
DefaultString: ef
AttributeHandle: 2, AttributeNameHandle: 5(OUTLET)
AttributeType: BIOSInteger
LowerBound: 0
UpperBound: 68002
ScalarIncrement: 1
DefaultValue: 0
AttributeHandle: 3, AttributeNameHandle: 3(Led)
AttributeType: BIOSEnumeration
NumberOfPossibleValues: 2
PossibleValueStringHandle[0] = 7(On)
PossibleValueStringHandle[1] = 6(Off)
NumberOfDefaultValues: 1
DefaultValueStringHandleIndex[0] = 1, StringHandle = 6(Off)
AttributeHandle: 4, AttributeNameHandle: 0(CodeUpdatePolicy)
AttributeType: BIOSEnumerationReadOnly
NumberOfPossibleValues: 2
PossibleValueStringHandle[0] = 1(Concurrent)
PossibleValueStringHandle[1] = 2(Disruptive)
NumberOfDefaultValues: 1
DefaultValueStringHandleIndex[0] = 0, StringHandle = 1(Concurrent)
$ pldmtool bios GetBIOSTable -t AttributeValueTable
...
...
PLDM AttributeValueTable:
AttributeHandle: 0
AttributeType: BIOSString
CurrentStringLength: 12
CurrentString: powersupply0
AttributeHandle: 1
AttributeType: BIOSStringReadOnly
CurrentStringLength: 2
CurrentString: ef
AttributeHandle: 2
AttributeType: BIOSInteger
CurrentValue: 0
AttributeHandle: 3
AttributeType: BIOSEnumeration
NumberOfCurrentValues: 1
CurrentValueStringHandleIndex[0] = 1, StringHandle = 6(Off)
AttributeHandle: 4
AttributeType: BIOSEnumerationReadOnly
NumberOfCurrentValues: 1
CurrentValueStringHandleIndex[0] = 0, StringHandle = 1(Concurrent)
Signed-off-by: John Wang <wangzqbj@inspur.com>
Change-Id: Icb698971ccd78023e8532be947f2150ea903ff8d
diff --git a/libpldmresponder/bios.hpp b/libpldmresponder/bios.hpp
index d023ce9..be0d403 100644
--- a/libpldmresponder/bios.hpp
+++ b/libpldmresponder/bios.hpp
@@ -2,7 +2,7 @@
#include "config.h"
-#include "bios_parser.hpp"
+#include "bios_config.hpp"
#include "bios_table.hpp"
#include "handler.hpp"
@@ -19,36 +19,12 @@
namespace pldm
{
-using AttributeHandle = uint16_t;
-using StringHandle = uint16_t;
-using PossibleValuesByHandle = std::vector<StringHandle>;
-
namespace responder
{
namespace bios
{
-using AttrTableEntryHandler =
- std::function<void(const struct pldm_bios_attr_table_entry*)>;
-
-void traverseBIOSAttrTable(const bios::Table& BIOSAttrTable,
- AttrTableEntryHandler handler);
-
-namespace internal
-{
-
-/** @brief Constructs all the BIOS Tables
- *
- * @param[in] request - Request message
- * @param[in] payload_length - Request message payload length
- * @param[in] biosJsonDir - path to fetch the BIOS json files
- * @param[in] biosTablePath - path where the BIOS tables will be persisted
- */
-Response buildBIOSTables(const pldm_msg* request, size_t payloadLength,
- const char* biosJsonDir, const char* biosTablePath);
-} // namespace internal
-
class Handler : public CmdHandler
{
public:
@@ -94,6 +70,9 @@
*/
Response setBIOSAttributeCurrentValue(const pldm_msg* request,
size_t payloadLength);
+
+ private:
+ BIOSConfig biosConfig;
};
} // namespace bios