Remove findStringName/Handle functions
Use the `find` functions in BiosStringTable.
Tested: all the code changes are about building bios tables.
tested on fp5280g2, with json
https://gist.github.com/wangzqbj/b24558331cb35d14fca3b555ef03e458
saw the built tables are as expected.
$ pldmtool bios GetBIOSTable -t 0
...
...
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 1
...
...
PLDM AttributeTable:
AttributeHandle: 0, AttributeNameHandle: 0(CodeUpdatePolicy)
AttributeType: BIOSEnumerationReadOnly
NumberOfPossibleValues: 2
PossibleValueStringHandle[0] = 1(Concurrent)
PossibleValueStringHandle[1] = 2(Disruptive)
NumberOfDefaultValues: 1
DefaultValueStringHandleIndex[0] = 0, StringHandle = 1(Concurrent)
AttributeHandle: 1, AttributeNameHandle: 3(Led)
AttributeType: BIOSEnumeration
NumberOfPossibleValues: 2
PossibleValueStringHandle[0] = 7(On)
PossibleValueStringHandle[1] = 6(Off)
NumberOfDefaultValues: 1
DefaultValueStringHandleIndex[0] = 1, StringHandle = 6(Off)
AttributeHandle: 2, AttributeNameHandle: 5(OUTLET)
AttributeType: BIOSInteger
LowerBound: 0
UpperBound: 68002
ScalarIncrement: 1
DefaultValue: 0
AttributeHandle: 3, AttributeNameHandle: 4(Model)
AttributeType: BIOSString
StringType: 0x01
MinimumStringLength: 1
MaximumStringLength: 100
DefaultStringLength: 8
DefaultString: FP5280G2
AttributeHandle: 4, AttributeNameHandle: 8(str_example3)
AttributeType: BIOSStringReadOnly
StringType: 0x00
MinimumStringLength: 1
MaximumStringLength: 100
DefaultStringLength: 2
DefaultString: ef
$ pldmtool bios GetBIOSTable -t 2
...
...
PLDM AttributeValueTable:
AttributeHandle: 0
AttributeType: BIOSEnumerationReadOnly
NumberOfCurrentValues: 1
CurrentValueStringHandleIndex[0] = 0, StringHandle = 1(Concurrent)
AttributeHandle: 1
AttributeType: BIOSEnumeration
NumberOfCurrentValues: 1
CurrentValueStringHandleIndex[0] = 1, StringHandle = 6(Off)
AttributeHandle: 2
AttributeType: BIOSInteger
CurrentValue: 0
AttributeHandle: 3
AttributeType: BIOSString
CurrentStringLength: 12
CurrentString: powersupply0
AttributeHandle: 4
AttributeType: BIOSStringReadOnly
CurrentStringLength: 2
CurrentString: ef
Signed-off-by: John Wang <wangzqbj@inspur.com>
Change-Id: Iba775caffcdfa51d780cd9c211572d3a359b80b4
diff --git a/libpldmresponder/bios_table.hpp b/libpldmresponder/bios_table.hpp
index b99b7a6..67503df 100644
--- a/libpldmresponder/bios_table.hpp
+++ b/libpldmresponder/bios_table.hpp
@@ -71,22 +71,37 @@
fs::path filePath;
};
-class BIOSStringTable : public BIOSTable
+class BIOSStringTable
{
public:
- /** @brief Ctor - set file path to persist BIOS String table
+ /** @brief Constructs BIOSStringTable
*
- * @param[in] filePath - file where BIOS table should be persisted
+ * @param[in] stringTable - The stringTable in RAM
*/
- BIOSStringTable(const char* filePath);
+ BIOSStringTable(const Table& stringTable);
+
+ /** @brief Constructs BIOSStringTable
+ *
+ * @param[in] biosTable - The BIOSTable
+ */
+ BIOSStringTable(const BIOSTable& biosTable);
/** @brief Find the string name from the BIOS string table for a string
* handle
* @param[in] handle - string handle
- * @return - std::string - name of the corresponding BIOS string
+ * @return name of the corresponding BIOS string
+ * @throw std::invalid_argument if the string can not be found.
*/
std::string findString(uint16_t handle) const;
+ /** @brief Find the string handle from the BIOS string table by the given
+ * name
+ * @param[in] name - name of the BIOS string
+ * @return handle of the string
+ * @throw std::invalid_argument if the string can not be found
+ */
+ uint16_t findHandle(const std::string& name) const;
+
private:
Table stringTable;
};