summaryrefslogtreecommitdiffstats
path: root/sensorhandler.cpp
diff options
context:
space:
mode:
authorPatrick Venture <venture@google.com>2019-07-19 18:37:15 -0700
committerPatrick Venture <venture@google.com>2019-07-31 14:13:54 +0000
commit83a0b8483e3adf12b2568ddb9529de26d96e8ae1 (patch)
treef9f050e9383bb9bb8902d804ed4f495c96ab8c99 /sensorhandler.cpp
parentd957823e99cd30067818ceb2a32ef110a26aef35 (diff)
downloadphosphor-host-ipmid-83a0b8483e3adf12b2568ddb9529de26d96e8ae1.tar.gz
phosphor-host-ipmid-83a0b8483e3adf12b2568ddb9529de26d96e8ae1.zip
sensorhandler: add accessor for entities singleton
Add an accessor to grab the entities singleton as a step towards building it on first access from json. Tested: This change has not been tested beyond build verification. Signed-off-by: Patrick Venture <venture@google.com> Change-Id: I2cf1fbd7ad10b4e1b63af347c824ad37bc8a56c9
Diffstat (limited to 'sensorhandler.cpp')
-rw-r--r--sensorhandler.cpp23
1 files changed, 16 insertions, 7 deletions
diff --git a/sensorhandler.cpp b/sensorhandler.cpp
index f649ce7..d67e7f5 100644
--- a/sensorhandler.cpp
+++ b/sensorhandler.cpp
@@ -76,6 +76,11 @@ struct sensorreadingresp_t
uint8_t indication[2];
} __attribute__((packed));
+const ipmi::sensor::EntityInfoMap& getIpmiEntityRecords()
+{
+ return entities;
+}
+
int get_bus_for_path(const char* path, char** busname)
{
return mapper_get_service(bus, path, busname);
@@ -573,7 +578,8 @@ ipmi::RspType<uint8_t, // respcount
if (count.value_or(0) == getSdrCount)
{
// Get SDR count. This returns the total number of SDRs in the device.
- sdrCount = sensors.size() + frus.size() + entities.size();
+ const auto& entityRecords = getIpmiEntityRecords();
+ sdrCount = sensors.size() + frus.size() + entityRecords.size();
}
else if (count.value_or(0) == getSensorCount)
{
@@ -740,9 +746,11 @@ ipmi_ret_t ipmi_fru_get_sdr(ipmi_request_t request, ipmi_response_t response,
{
// we have reached till end of fru, so assign the next record id to
// 512(Max fru ID = 511) + Entity Record ID(may start with 0).
+ const auto& entityRecords = getIpmiEntityRecords();
auto next_record_id =
- (entities.size()) ? entities.begin()->first + ENTITY_RECORD_ID_START
- : END_OF_RECORD;
+ (entityRecords.size())
+ ? entityRecords.begin()->first + ENTITY_RECORD_ID_START
+ : END_OF_RECORD;
get_sdr::response::set_next_record_id(next_record_id, resp);
}
else
@@ -777,13 +785,14 @@ ipmi_ret_t ipmi_entity_get_sdr(ipmi_request_t request, ipmi_response_t response,
get_sdr::SensorDataEntityRecord record{};
auto dataLength = 0;
- auto entity = entities.begin();
+ const auto& entityRecords = getIpmiEntityRecords();
+ auto entity = entityRecords.begin();
uint8_t entityRecordID;
auto recordID = get_sdr::request::get_record_id(req);
entityRecordID = recordID - ENTITY_RECORD_ID_START;
- entity = entities.find(entityRecordID);
- if (entity == entities.end())
+ entity = entityRecords.find(entityRecordID);
+ if (entity == entityRecords.end())
{
return IPMI_CC_SENSOR_INVALID;
}
@@ -810,7 +819,7 @@ ipmi_ret_t ipmi_entity_get_sdr(ipmi_request_t request, ipmi_response_t response,
record.body.entityId4 = entity->second.containedEntities[3].first;
record.body.entityInstance4 = entity->second.containedEntities[3].second;
- if (++entity == entities.end())
+ if (++entity == entityRecords.end())
{
get_sdr::response::set_next_record_id(END_OF_RECORD,
resp); // last record
OpenPOWER on IntegriCloud