summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cfam_access.cpp59
-rw-r--r--elog-errors.hpp1044
-rw-r--r--filedescriptor.cpp15
-rw-r--r--org/open_power/Proc/CFAM.errors.yaml15
-rw-r--r--org/open_power/Proc/CFAM.metadata.yaml25
-rw-r--r--proc_control.cpp32
-rw-r--r--procedures/p9/cfam_overrides.cpp3
-rw-r--r--targeting.cpp14
-rw-r--r--test/Makefile.am16
9 files changed, 91 insertions, 1132 deletions
diff --git a/cfam_access.cpp b/cfam_access.cpp
index d1d5c8f..e764c86 100644
--- a/cfam_access.cpp
+++ b/cfam_access.cpp
@@ -13,11 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/elog-errors.hpp>
+#include <xyz/openbmc_project/Common/Device/error.hpp>
+#include <xyz/openbmc_project/Common/File/error.hpp>
#include <unistd.h>
#include "cfam_access.hpp"
#include "targeting.hpp"
-#include <phosphor-logging/elog.hpp>
-#include "elog-errors.hpp"
namespace openpower
{
@@ -30,6 +32,10 @@ constexpr auto cfamRegSize = 4;
using namespace openpower::targeting;
using namespace openpower::util;
+namespace file_error = sdbusplus::xyz::openbmc_project::
+ Common::File::Error;
+namespace device_error = sdbusplus::xyz::openbmc_project::
+ Common::Device::Error;
/**
* Converts the CFAM register address used by the calling
@@ -50,11 +56,16 @@ void writeReg(const std::unique_ptr<Target>& target,
int rc = lseek(target->getCFAMFD(), makeOffset(address), SEEK_SET);
if (rc < 0)
{
- elog<org::open_power::Proc::CFAM::SeekFailure>(
- org::open_power::Proc::CFAM::SeekFailure::ERRNO(errno),
- org::open_power::Proc::CFAM::SeekFailure::ADDRESS(address),
- org::open_power::Proc::CFAM::SeekFailure::OFFSET(makeOffset(address)),
- org::open_power::Proc::CFAM::SeekFailure::PATH(target->getCFAMPath().c_str()));
+ log<level::ERR>("Failed seeking on a processor CFAM",
+ entry("CFAM_ADDRESS=0x%X", address));
+
+ using metadata = xyz::openbmc_project::Common::File::Seek;
+
+ elog<file_error::Seek>(
+ metadata::OFFSET(makeOffset(address)),
+ metadata::WHENCE(SEEK_SET),
+ metadata::ERRNO(errno),
+ metadata::PATH(target->getCFAMPath().c_str()));
}
data = target->swapEndian(data);
@@ -62,10 +73,12 @@ void writeReg(const std::unique_ptr<Target>& target,
rc = write(target->getCFAMFD(), &data, cfamRegSize);
if (rc < 0)
{
- elog<org::open_power::Proc::CFAM::WriteFailure>(
- org::open_power::Proc::CFAM::WriteFailure::CALLOUT_ERRNO(errno),
- org::open_power::Proc::CFAM::WriteFailure::CALLOUT_DEVICE_PATH(
- target->getCFAMPath().c_str()));
+ using metadata = xyz::openbmc_project::Common::Device::WriteFailure;
+
+ elog<device_error::WriteFailure>(
+ metadata::CALLOUT_ERRNO(errno),
+ metadata::CALLOUT_DEVICE_PATH(
+ target->getCFAMPath().c_str()));
}
}
@@ -80,20 +93,26 @@ cfam_data_t readReg(const std::unique_ptr<Target>& target,
int rc = lseek(target->getCFAMFD(), makeOffset(address), SEEK_SET);
if (rc < 0)
{
- elog<org::open_power::Proc::CFAM::SeekFailure>(
- org::open_power::Proc::CFAM::SeekFailure::ERRNO(errno),
- org::open_power::Proc::CFAM::SeekFailure::ADDRESS(address),
- org::open_power::Proc::CFAM::SeekFailure::OFFSET(makeOffset(address)),
- org::open_power::Proc::CFAM::SeekFailure::PATH(target->getCFAMPath().c_str()));
+ log<level::ERR>("Failed seeking on a processor CFAM",
+ entry("CFAM_ADDRESS=0x%X", address));
+
+ using metadata = xyz::openbmc_project::Common::File::Seek;
+
+ elog<file_error::Seek>(
+ metadata::OFFSET(makeOffset(address)),
+ metadata::WHENCE(SEEK_SET),
+ metadata::ERRNO(errno),
+ metadata::PATH(target->getCFAMPath().c_str()));
}
rc = read(target->getCFAMFD(), &data, cfamRegSize);
if (rc < 0)
{
- elog<org::open_power::Proc::CFAM::ReadFailure>(
- org::open_power::Proc::CFAM::WriteFailure::CALLOUT_ERRNO(errno),
- org::open_power::Proc::CFAM::WriteFailure::CALLOUT_DEVICE_PATH(
- target->getCFAMPath().c_str()));
+ using metadata = xyz::openbmc_project::Common::Device::ReadFailure;
+
+ elog<device_error::ReadFailure>(
+ metadata::CALLOUT_ERRNO(errno),
+ metadata::CALLOUT_DEVICE_PATH(target->getCFAMPath().c_str()));
}
return target->swapEndian(data);
diff --git a/elog-errors.hpp b/elog-errors.hpp
deleted file mode 100644
index 9443399..0000000
--- a/elog-errors.hpp
+++ /dev/null
@@ -1,1044 +0,0 @@
-// This file was autogenerated. Do not edit!
-// See elog-gen.py for more details
-#pragma once
-
-#include <string>
-#include <tuple>
-#include <type_traits>
-#include <sdbusplus/exception.hpp>
-#include <phosphor-logging/log.hpp>
-#include <phosphor-logging/elog.hpp>
-
-namespace sdbusplus
-{
-namespace xyz
-{
-namespace openbmc_project
-{
-namespace Common
-{
-namespace Error
-{
- struct Timeout;
-} // namespace Error
-} // namespace Common
-} // namespace openbmc_project
-} // namespace xyz
-} // namespace sdbusplus
-
-namespace sdbusplus
-{
-namespace xyz
-{
-namespace openbmc_project
-{
-namespace Common
-{
-namespace Callout
-{
-namespace Error
-{
- struct GPIO;
-} // namespace Error
-} // namespace Callout
-} // namespace Common
-} // namespace openbmc_project
-} // namespace xyz
-} // namespace sdbusplus
-
-namespace sdbusplus
-{
-namespace org
-{
-namespace open_power
-{
-namespace Proc
-{
-namespace CFAM
-{
-namespace Error
-{
- struct ReadFailure;
-} // namespace Error
-} // namespace CFAM
-} // namespace Proc
-} // namespace open_power
-} // namespace org
-} // namespace sdbusplus
-
-namespace sdbusplus
-{
-namespace xyz
-{
-namespace openbmc_project
-{
-namespace Common
-{
-namespace Callout
-{
-namespace Error
-{
- struct Inventory;
-} // namespace Error
-} // namespace Callout
-} // namespace Common
-} // namespace openbmc_project
-} // namespace xyz
-} // namespace sdbusplus
-
-namespace sdbusplus
-{
-namespace xyz
-{
-namespace openbmc_project
-{
-namespace Common
-{
-namespace Callout
-{
-namespace Error
-{
- struct IIC;
-} // namespace Error
-} // namespace Callout
-} // namespace Common
-} // namespace openbmc_project
-} // namespace xyz
-} // namespace sdbusplus
-
-namespace sdbusplus
-{
-namespace org
-{
-namespace open_power
-{
-namespace Proc
-{
-namespace CFAM
-{
-namespace Error
-{
- struct WriteFailure;
-} // namespace Error
-} // namespace CFAM
-} // namespace Proc
-} // namespace open_power
-} // namespace org
-} // namespace sdbusplus
-
-namespace sdbusplus
-{
-namespace xyz
-{
-namespace openbmc_project
-{
-namespace Common
-{
-namespace Error
-{
- struct InternalFailure;
-} // namespace Error
-} // namespace Common
-} // namespace openbmc_project
-} // namespace xyz
-} // namespace sdbusplus
-
-namespace sdbusplus
-{
-namespace xyz
-{
-namespace openbmc_project
-{
-namespace Common
-{
-namespace Callout
-{
-namespace Error
-{
- struct Device;
-} // namespace Error
-} // namespace Callout
-} // namespace Common
-} // namespace openbmc_project
-} // namespace xyz
-} // namespace sdbusplus
-
-namespace sdbusplus
-{
-namespace org
-{
-namespace open_power
-{
-namespace Proc
-{
-namespace CFAM
-{
-namespace Error
-{
- struct OpenFailure;
-} // namespace Error
-} // namespace CFAM
-} // namespace Proc
-} // namespace open_power
-} // namespace org
-} // namespace sdbusplus
-
-namespace sdbusplus
-{
-namespace org
-{
-namespace open_power
-{
-namespace Proc
-{
-namespace CFAM
-{
-namespace Error
-{
- struct SeekFailure;
-} // namespace Error
-} // namespace CFAM
-} // namespace Proc
-} // namespace open_power
-} // namespace org
-} // namespace sdbusplus
-
-namespace sdbusplus
-{
-namespace xyz
-{
-namespace openbmc_project
-{
-namespace Common
-{
-namespace Error
-{
- struct InvalidArgument;
-} // namespace Error
-} // namespace Common
-} // namespace openbmc_project
-} // namespace xyz
-} // namespace sdbusplus
-
-namespace sdbusplus
-{
-namespace xyz
-{
-namespace openbmc_project
-{
-namespace Common
-{
-namespace Callout
-{
-namespace Error
-{
- struct IPMISensor;
-} // namespace Error
-} // namespace Callout
-} // namespace Common
-} // namespace openbmc_project
-} // namespace xyz
-} // namespace sdbusplus
-
-
-namespace phosphor
-{
-
-namespace logging
-{
-
-namespace xyz
-{
-namespace openbmc_project
-{
-namespace Common
-{
-namespace Callout
-{
-namespace _Device
-{
-
-struct CALLOUT_ERRNO
-{
- static constexpr auto str = "CALLOUT_ERRNO=%d";
- static constexpr auto str_short = "CALLOUT_ERRNO";
- using type = std::tuple<std::decay_t<decltype(str)>,int32_t>;
- explicit constexpr CALLOUT_ERRNO(int32_t a) : _entry(entry(str, a)) {};
- type _entry;
-};
-struct CALLOUT_DEVICE_PATH
-{
- static constexpr auto str = "CALLOUT_DEVICE_PATH=%s";
- static constexpr auto str_short = "CALLOUT_DEVICE_PATH";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr CALLOUT_DEVICE_PATH(const char* a) : _entry(entry(str, a)) {};
- type _entry;
-};
-
-} // namespace _Device
-
-struct Device : public sdbusplus::exception_t
-{
- static constexpr auto errName = "xyz.openbmc_project.Common.Callout.Device";
- static constexpr auto errDesc = "Generic device callout";
- static constexpr auto L = level::INFO;
- using CALLOUT_ERRNO = _Device::CALLOUT_ERRNO;
- using CALLOUT_DEVICE_PATH = _Device::CALLOUT_DEVICE_PATH;
- using metadata_types = std::tuple<CALLOUT_ERRNO, CALLOUT_DEVICE_PATH>;
-
- const char* name() const noexcept
- {
- return errName;
- }
-
- const char* description() const noexcept
- {
- return errDesc;
- }
-
- const char* what() const noexcept
- {
- return errName;
- }
-};
-
-} // namespace Callout
-} // namespace Common
-} // namespace openbmc_project
-} // namespace xyz
-
-
-namespace details
-{
-
-template <>
-struct map_exception_type<sdbusplus::xyz::openbmc_project::Common::Callout::Error::Device>
-{
- using type = xyz::openbmc_project::Common::Callout::Device;
-};
-
-}
-
-namespace xyz
-{
-namespace openbmc_project
-{
-namespace Common
-{
-namespace Callout
-{
-namespace _GPIO
-{
-
-struct CALLOUT_GPIO_NUM
-{
- static constexpr auto str = "CALLOUT_GPIO_NUM=%u";
- static constexpr auto str_short = "CALLOUT_GPIO_NUM";
- using type = std::tuple<std::decay_t<decltype(str)>,uint32_t>;
- explicit constexpr CALLOUT_GPIO_NUM(uint32_t a) : _entry(entry(str, a)) {};
- type _entry;
-};
-
-} // namespace _GPIO
-
-struct GPIO : public sdbusplus::exception_t
-{
- static constexpr auto errName = "xyz.openbmc_project.Common.Callout.GPIO";
- static constexpr auto errDesc = "Callout GPIO pin";
- static constexpr auto L = level::INFO;
- using CALLOUT_GPIO_NUM = _GPIO::CALLOUT_GPIO_NUM;
- using CALLOUT_ERRNO = xyz::openbmc_project::Common::Callout::Device::CALLOUT_ERRNO;
- using CALLOUT_DEVICE_PATH = xyz::openbmc_project::Common::Callout::Device::CALLOUT_DEVICE_PATH;
- using metadata_types = std::tuple<CALLOUT_GPIO_NUM, CALLOUT_ERRNO, CALLOUT_DEVICE_PATH>;
-
- const char* name() const noexcept
- {
- return errName;
- }
-
- const char* description() const noexcept
- {
- return errDesc;
- }
-
- const char* what() const noexcept
- {
- return errName;
- }
-};
-
-} // namespace Callout
-} // namespace Common
-} // namespace openbmc_project
-} // namespace xyz
-
-
-namespace details
-{
-
-template <>
-struct map_exception_type<sdbusplus::xyz::openbmc_project::Common::Callout::Error::GPIO>
-{
- using type = xyz::openbmc_project::Common::Callout::GPIO;
-};
-
-}
-
-namespace xyz
-{
-namespace openbmc_project
-{
-namespace Common
-{
-namespace Callout
-{
-namespace _IIC
-{
-
-struct CALLOUT_IIC_BUS
-{
- static constexpr auto str = "CALLOUT_IIC_BUS=%s";
- static constexpr auto str_short = "CALLOUT_IIC_BUS";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr CALLOUT_IIC_BUS(const char* a) : _entry(entry(str, a)) {};
- type _entry;
-};
-struct CALLOUT_IIC_ADDR
-{
- static constexpr auto str = "CALLOUT_IIC_ADDR=0x%hx";
- static constexpr auto str_short = "CALLOUT_IIC_ADDR";
- using type = std::tuple<std::decay_t<decltype(str)>,uint16_t>;
- explicit constexpr CALLOUT_IIC_ADDR(uint16_t a) : _entry(entry(str, a)) {};
- type _entry;
-};
-
-} // namespace _IIC
-
-struct IIC : public sdbusplus::exception_t
-{
- static constexpr auto errName = "xyz.openbmc_project.Common.Callout.IIC";
- static constexpr auto errDesc = "Callout IIC device";
- static constexpr auto L = level::INFO;
- using CALLOUT_IIC_BUS = _IIC::CALLOUT_IIC_BUS;
- using CALLOUT_IIC_ADDR = _IIC::CALLOUT_IIC_ADDR;
- using CALLOUT_ERRNO = xyz::openbmc_project::Common::Callout::Device::CALLOUT_ERRNO;
- using CALLOUT_DEVICE_PATH = xyz::openbmc_project::Common::Callout::Device::CALLOUT_DEVICE_PATH;
- using metadata_types = std::tuple<CALLOUT_IIC_BUS, CALLOUT_IIC_ADDR, CALLOUT_ERRNO, CALLOUT_DEVICE_PATH>;
-
- const char* name() const noexcept
- {
- return errName;
- }
-
- const char* description() const noexcept
- {
- return errDesc;
- }
-
- const char* what() const noexcept
- {
- return errName;
- }
-};
-
-} // namespace Callout
-} // namespace Common
-} // namespace openbmc_project
-} // namespace xyz
-
-
-namespace details
-{
-
-template <>
-struct map_exception_type<sdbusplus::xyz::openbmc_project::Common::Callout::Error::IIC>
-{
- using type = xyz::openbmc_project::Common::Callout::IIC;
-};
-
-}
-
-namespace xyz
-{
-namespace openbmc_project
-{
-namespace Common
-{
-namespace Callout
-{
-namespace _Inventory
-{
-
-struct CALLOUT_INVENTORY_PATH
-{
- static constexpr auto str = "CALLOUT_INVENTORY_PATH=%s";
- static constexpr auto str_short = "CALLOUT_INVENTORY_PATH";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr CALLOUT_INVENTORY_PATH(const char* a) : _entry(entry(str, a)) {};
- type _entry;
-};
-
-} // namespace _Inventory
-
-struct Inventory : public sdbusplus::exception_t
-{
- static constexpr auto errName = "xyz.openbmc_project.Common.Callout.Inventory";
- static constexpr auto errDesc = "Inventory item callout";
- static constexpr auto L = level::INFO;
- using CALLOUT_INVENTORY_PATH = _Inventory::CALLOUT_INVENTORY_PATH;
- using metadata_types = std::tuple<CALLOUT_INVENTORY_PATH>;
-
- const char* name() const noexcept
- {
- return errName;
- }
-
- const char* description() const noexcept
- {
- return errDesc;
- }
-
- const char* what() const noexcept
- {
- return errName;
- }
-};
-
-} // namespace Callout
-} // namespace Common
-} // namespace openbmc_project
-} // namespace xyz
-
-
-namespace details
-{
-
-template <>
-struct map_exception_type<sdbusplus::xyz::openbmc_project::Common::Callout::Error::Inventory>
-{
- using type = xyz::openbmc_project::Common::Callout::Inventory;
-};
-
-}
-
-namespace xyz
-{
-namespace openbmc_project
-{
-namespace Common
-{
-namespace Callout
-{
-namespace _IPMISensor
-{
-
-struct CALLOUT_IPMI_SENSOR_NUM
-{
- static constexpr auto str = "CALLOUT_IPMI_SENSOR_NUM=%u";
- static constexpr auto str_short = "CALLOUT_IPMI_SENSOR_NUM";
- using type = std::tuple<std::decay_t<decltype(str)>,uint32_t>;
- explicit constexpr CALLOUT_IPMI_SENSOR_NUM(uint32_t a) : _entry(entry(str, a)) {};
- type _entry;
-};
-
-} // namespace _IPMISensor
-
-struct IPMISensor : public sdbusplus::exception_t
-{
- static constexpr auto errName = "xyz.openbmc_project.Common.Callout.IPMISensor";
- static constexpr auto errDesc = "Callout IPMI sensor";
- static constexpr auto L = level::INFO;
- using CALLOUT_IPMI_SENSOR_NUM = _IPMISensor::CALLOUT_IPMI_SENSOR_NUM;
- using metadata_types = std::tuple<CALLOUT_IPMI_SENSOR_NUM>;
-
- const char* name() const noexcept
- {
- return errName;
- }
-
- const char* description() const noexcept
- {
- return errDesc;
- }
-
- const char* what() const noexcept
- {
- return errName;
- }
-};
-
-} // namespace Callout
-} // namespace Common
-} // namespace openbmc_project
-} // namespace xyz
-
-
-namespace details
-{
-
-template <>
-struct map_exception_type<sdbusplus::xyz::openbmc_project::Common::Callout::Error::IPMISensor>
-{
- using type = xyz::openbmc_project::Common::Callout::IPMISensor;
-};
-
-}
-
-namespace org
-{
-namespace open_power
-{
-namespace Proc
-{
-namespace CFAM
-{
-namespace _OpenFailure
-{
-
-struct ERRNO
-{
- static constexpr auto str = "ERRNO=%d";
- static constexpr auto str_short = "ERRNO";
- using type = std::tuple<std::decay_t<decltype(str)>,int32_t>;
- explicit constexpr ERRNO(int32_t a) : _entry(entry(str, a)) {};
- type _entry;
-};
-struct PATH
-{
- static constexpr auto str = "PATH=%s";
- static constexpr auto str_short = "PATH";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr PATH(const char* a) : _entry(entry(str, a)) {};
- type _entry;
-};
-
-} // namespace _OpenFailure
-
-struct OpenFailure : public sdbusplus::exception_t
-{
- static constexpr auto errName = "org.open_power.Proc.CFAM.OpenFailure";
- static constexpr auto errDesc = "Failed to open the device.";
- static constexpr auto L = level::INFO;
- using ERRNO = _OpenFailure::ERRNO;
- using PATH = _OpenFailure::PATH;
- using metadata_types = std::tuple<ERRNO, PATH>;
-
- const char* name() const noexcept
- {
- return errName;
- }
-
- const char* description() const noexcept
- {
- return errDesc;
- }
-
- const char* what() const noexcept
- {
- return errName;
- }
-};
-
-} // namespace CFAM
-} // namespace Proc
-} // namespace open_power
-} // namespace org
-
-
-namespace details
-{
-
-template <>
-struct map_exception_type<sdbusplus::org::open_power::Proc::CFAM::Error::OpenFailure>
-{
- using type = org::open_power::Proc::CFAM::OpenFailure;
-};
-
-}
-
-namespace org
-{
-namespace open_power
-{
-namespace Proc
-{
-namespace CFAM
-{
-namespace _ReadFailure
-{
-
-
-} // namespace _ReadFailure
-
-struct ReadFailure : public sdbusplus::exception_t
-{
- static constexpr auto errName = "org.open_power.Proc.CFAM.ReadFailure";
- static constexpr auto errDesc = "Failed to read from the device.";
- static constexpr auto L = level::INFO;
- using CALLOUT_ERRNO = xyz::openbmc_project::Common::Callout::Device::CALLOUT_ERRNO;
- using CALLOUT_DEVICE_PATH = xyz::openbmc_project::Common::Callout::Device::CALLOUT_DEVICE_PATH;
- using metadata_types = std::tuple<CALLOUT_ERRNO, CALLOUT_DEVICE_PATH>;
-
- const char* name() const noexcept
- {
- return errName;
- }
-
- const char* description() const noexcept
- {
- return errDesc;
- }
-
- const char* what() const noexcept
- {
- return errName;
- }
-};
-
-} // namespace CFAM
-} // namespace Proc
-} // namespace open_power
-} // namespace org
-
-
-namespace details
-{
-
-template <>
-struct map_exception_type<sdbusplus::org::open_power::Proc::CFAM::Error::ReadFailure>
-{
- using type = org::open_power::Proc::CFAM::ReadFailure;
-};
-
-}
-
-namespace org
-{
-namespace open_power
-{
-namespace Proc
-{
-namespace CFAM
-{
-namespace _WriteFailure
-{
-
-
-} // namespace _WriteFailure
-
-struct WriteFailure : public sdbusplus::exception_t
-{
- static constexpr auto errName = "org.open_power.Proc.CFAM.WriteFailure";
- static constexpr auto errDesc = "Failed to write to the device.";
- static constexpr auto L = level::INFO;
- using CALLOUT_ERRNO = xyz::openbmc_project::Common::Callout::Device::CALLOUT_ERRNO;
- using CALLOUT_DEVICE_PATH = xyz::openbmc_project::Common::Callout::Device::CALLOUT_DEVICE_PATH;
- using metadata_types = std::tuple<CALLOUT_ERRNO, CALLOUT_DEVICE_PATH>;
-
- const char* name() const noexcept
- {
- return errName;
- }
-
- const char* description() const noexcept
- {
- return errDesc;
- }
-
- const char* what() const noexcept
- {
- return errName;
- }
-};
-
-} // namespace CFAM
-} // namespace Proc
-} // namespace open_power
-} // namespace org
-
-
-namespace details
-{
-
-template <>
-struct map_exception_type<sdbusplus::org::open_power::Proc::CFAM::Error::WriteFailure>
-{
- using type = org::open_power::Proc::CFAM::WriteFailure;
-};
-
-}
-
-namespace org
-{
-namespace open_power
-{
-namespace Proc
-{
-namespace CFAM
-{
-namespace _SeekFailure
-{
-
-struct ERRNO
-{
- static constexpr auto str = "ERRNO=%d";
- static constexpr auto str_short = "ERRNO";
- using type = std::tuple<std::decay_t<decltype(str)>,int32_t>;
- explicit constexpr ERRNO(int32_t a) : _entry(entry(str, a)) {};
- type _entry;
-};
-struct ADDRESS
-{
- static constexpr auto str = "ADDRESS=0x%0x";
- static constexpr auto str_short = "ADDRESS";
- using type = std::tuple<std::decay_t<decltype(str)>,uint16_t>;
- explicit constexpr ADDRESS(uint16_t a) : _entry(entry(str, a)) {};
- type _entry;
-};
-struct OFFSET
-{
- static constexpr auto str = "OFFSET=%d";
- static constexpr auto str_short = "OFFSET";
- using type = std::tuple<std::decay_t<decltype(str)>,uint16_t>;
- explicit constexpr OFFSET(uint16_t a) : _entry(entry(str, a)) {};
- type _entry;
-};
-struct PATH
-{
- static constexpr auto str = "PATH=%s";
- static constexpr auto str_short = "PATH";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr PATH(const char* a) : _entry(entry(str, a)) {};
- type _entry;
-};
-
-} // namespace _SeekFailure
-
-struct SeekFailure : public sdbusplus::exception_t
-{
- static constexpr auto errName = "org.open_power.Proc.CFAM.SeekFailure";
- static constexpr auto errDesc = "Failed to seek on the device.";
- static constexpr auto L = level::INFO;
- using ERRNO = _SeekFailure::ERRNO;
- using ADDRESS = _SeekFailure::ADDRESS;
- using OFFSET = _SeekFailure::OFFSET;
- using PATH = _SeekFailure::PATH;
- using metadata_types = std::tuple<ERRNO, ADDRESS, OFFSET, PATH>;
-
- const char* name() const noexcept
- {
- return errName;
- }
-
- const char* description() const noexcept
- {
- return errDesc;
- }
-
- const char* what() const noexcept
- {
- return errName;
- }
-};
-
-} // namespace CFAM
-} // namespace Proc
-} // namespace open_power
-} // namespace org
-
-
-namespace details
-{
-
-template <>
-struct map_exception_type<sdbusplus::org::open_power::Proc::CFAM::Error::SeekFailure>
-{
- using type = org::open_power::Proc::CFAM::SeekFailure;
-};
-
-}
-
-namespace xyz
-{
-namespace openbmc_project
-{
-namespace Common
-{
-namespace _Timeout
-{
-
-struct TIMEOUT_IN_MSEC
-{
- static constexpr auto str = "TIMEOUT_IN_MSEC=%llu";
- static constexpr auto str_short = "TIMEOUT_IN_MSEC";
- using type = std::tuple<std::decay_t<decltype(str)>,uint64_t>;
- explicit constexpr TIMEOUT_IN_MSEC(uint64_t a) : _entry(entry(str, a)) {};
- type _entry;
-};
-
-} // namespace _Timeout
-
-struct Timeout : public sdbusplus::exception_t
-{
- static constexpr auto errName = "xyz.openbmc_project.Common.Timeout";
- static constexpr auto errDesc = "Operation timed out.";
- static constexpr auto L = level::INFO;
- using TIMEOUT_IN_MSEC = _Timeout::TIMEOUT_IN_MSEC;
- using metadata_types = std::tuple<TIMEOUT_IN_MSEC>;
-
- const char* name() const noexcept
- {
- return errName;
- }
-
- const char* description() const noexcept
- {
- return errDesc;
- }
-
- const char* what() const noexcept
- {
- return errName;
- }
-};
-
-} // namespace Common
-} // namespace openbmc_project
-} // namespace xyz
-
-
-namespace details
-{
-
-template <>
-struct map_exception_type<sdbusplus::xyz::openbmc_project::Common::Error::Timeout>
-{
- using type = xyz::openbmc_project::Common::Timeout;
-};
-
-}
-
-namespace xyz
-{
-namespace openbmc_project
-{
-namespace Common
-{
-namespace _InvalidArgument
-{
-
-struct ARGUMENT_NAME
-{
- static constexpr auto str = "ARGUMENT_NAME=%s";
- static constexpr auto str_short = "ARGUMENT_NAME";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr ARGUMENT_NAME(const char* a) : _entry(entry(str, a)) {};
- type _entry;
-};
-struct ARGUMENT_VALUE
-{
- static constexpr auto str = "ARGUMENT_VALUE=%s";
- static constexpr auto str_short = "ARGUMENT_VALUE";
- using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
- explicit constexpr ARGUMENT_VALUE(const char* a) : _entry(entry(str, a)) {};
- type _entry;
-};
-
-} // namespace _InvalidArgument
-
-struct InvalidArgument : public sdbusplus::exception_t
-{
- static constexpr auto errName = "xyz.openbmc_project.Common.InvalidArgument";
- static constexpr auto errDesc = "Invalid argument was given.";
- static constexpr auto L = level::INFO;
- using ARGUMENT_NAME = _InvalidArgument::ARGUMENT_NAME;
- using ARGUMENT_VALUE = _InvalidArgument::ARGUMENT_VALUE;
- using metadata_types = std::tuple<ARGUMENT_NAME, ARGUMENT_VALUE>;
-
- const char* name() const noexcept
- {
- return errName;
- }
-
- const char* description() const noexcept
- {
- return errDesc;
- }
-
- const char* what() const noexcept
- {
- return errName;
- }
-};
-
-} // namespace Common
-} // namespace openbmc_project
-} // namespace xyz
-
-
-namespace details
-{
-
-template <>
-struct map_exception_type<sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument>
-{
- using type = xyz::openbmc_project::Common::InvalidArgument;
-};
-
-}
-
-namespace xyz
-{
-namespace openbmc_project
-{
-namespace Common
-{
-namespace _InternalFailure
-{
-
-
-} // namespace _InternalFailure
-
-struct InternalFailure : public sdbusplus::exception_t
-{
- static constexpr auto errName = "xyz.openbmc_project.Common.InternalFailure";
- static constexpr auto errDesc = "The operation failed internally.";
- static constexpr auto L = level::ERR;
- using metadata_types = std::tuple<>;
-
- const char* name() const noexcept
- {
- return errName;
- }
-
- const char* description() const noexcept
- {
- return errDesc;
- }
-
- const char* what() const noexcept
- {
- return errName;
- }
-};
-
-} // namespace Common
-} // namespace openbmc_project
-} // namespace xyz
-
-
-namespace details
-{
-
-template <>
-struct map_exception_type<sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure>
-{
- using type = xyz::openbmc_project::Common::InternalFailure;
-};
-
-}
-
-
-} // namespace logging
-
-} // namespace phosphor
diff --git a/filedescriptor.cpp b/filedescriptor.cpp
index 9354d6e..6a4b898 100644
--- a/filedescriptor.cpp
+++ b/filedescriptor.cpp
@@ -15,15 +15,18 @@
*/
#include <stdexcept>
#include <unistd.h>
-#include "filedescriptor.hpp"
#include <phosphor-logging/elog.hpp>
-#include "elog-errors.hpp"
+#include <phosphor-logging/elog-errors.hpp>
+#include <xyz/openbmc_project/Common/File/error.hpp>
+#include "filedescriptor.hpp"
namespace openpower
{
namespace util
{
+namespace file_error = sdbusplus::xyz::openbmc_project::Common::File::Error;
+
FileDescriptor::FileDescriptor(const std::string& path)
{
using namespace phosphor::logging;
@@ -32,9 +35,11 @@ FileDescriptor::FileDescriptor(const std::string& path)
if (fd < 0)
{
- elog<org::open_power::Proc::CFAM::OpenFailure>(
- org::open_power::Proc::CFAM::OpenFailure::ERRNO(errno),
- org::open_power::Proc::CFAM::OpenFailure::PATH(path.c_str()));
+ using metadata = xyz::openbmc_project::Common::File::Open;
+
+ elog<file_error::Open>(
+ metadata::ERRNO(errno),
+ metadata::PATH(path.c_str()));
}
}
diff --git a/org/open_power/Proc/CFAM.errors.yaml b/org/open_power/Proc/CFAM.errors.yaml
deleted file mode 100644
index b414185..0000000
--- a/org/open_power/Proc/CFAM.errors.yaml
+++ /dev/null
@@ -1,15 +0,0 @@
-# org.open_power.Proc.CFAM.OpenFailure
-- name: OpenFailure
- description: Failed to open the device.
-
-# org.open_power.Proc.CFAM.ReadFailure
-- name: ReadFailure
- description: Failed to read from the device.
-
-# org.open_power.Proc.CFAM.WriteFailure
-- name: WriteFailure
- description: Failed to write to the device.
-
-# org.open_power.Proc.CFAM.SeekFailure
-- name: SeekFailure
- description: Failed to seek on the device.
diff --git a/org/open_power/Proc/CFAM.metadata.yaml b/org/open_power/Proc/CFAM.metadata.yaml
deleted file mode 100644
index 5077f81..0000000
--- a/org/open_power/Proc/CFAM.metadata.yaml
+++ /dev/null
@@ -1,25 +0,0 @@
-- name: OpenFailure
- meta:
- - str: "ERRNO=%d"
- type: int32
- - str: "PATH=%s"
- type: string
-
-- name: ReadFailure
- inherits:
- - xyz.openbmc_project.Common.Callout.Device
-
-- name: WriteFailure
- inherits:
- - xyz.openbmc_project.Common.Callout.Device
-
-- name: SeekFailure
- meta:
- - str: "ERRNO=%d"
- type: int32
- - str: "ADDRESS=0x%0x"
- type: uint16
- - str: "OFFSET=%d"
- type: uint16
- - str: "PATH=%s"
- type: string
diff --git a/proc_control.cpp b/proc_control.cpp
index aceb6d6..f825510 100644
--- a/proc_control.cpp
+++ b/proc_control.cpp
@@ -18,11 +18,19 @@
#include <iostream>
#include <phosphor-logging/log.hpp>
#include <phosphor-logging/elog.hpp>
-#include "registration.hpp"
-#include "elog-errors.hpp"
+#include <phosphor-logging/elog-errors.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
+#include <xyz/openbmc_project/Common/Device/error.hpp>
+#include <xyz/openbmc_project/Common/File/error.hpp>
+#include "registration.hpp"
using namespace openpower::util;
+namespace common_error = sdbusplus::xyz::openbmc_project::
+ Common::Error;
+namespace device_error = sdbusplus::xyz::openbmc_project::
+ Common::Device::Error;
+namespace file_error = sdbusplus::xyz::openbmc_project::
+ Common::File::Error;
void usage(char** argv, const ProcedureMap& procedures)
{
@@ -60,29 +68,29 @@ int main(int argc, char** argv)
{
procedure->second();
}
- catch (org::open_power::Proc::CFAM::SeekFailure& e)
+ catch (file_error::Seek& e)
{
- commit<org::open_power::Proc::CFAM::SeekFailure>();
+ commit<file_error::Seek>();
return -1;
}
- catch (org::open_power::Proc::CFAM::OpenFailure& e)
+ catch (file_error::Open& e)
{
- commit<org::open_power::Proc::CFAM::OpenFailure>();
+ commit<file_error::Open>();
return -1;
}
- catch (org::open_power::Proc::CFAM::WriteFailure& e)
+ catch (device_error::WriteFailure& e)
{
- commit<org::open_power::Proc::CFAM::WriteFailure>();
+ commit<device_error::WriteFailure>();
return -1;
}
- catch (org::open_power::Proc::CFAM::ReadFailure& e)
+ catch (device_error::ReadFailure& e)
{
- commit<org::open_power::Proc::CFAM::ReadFailure>();
+ commit<device_error::ReadFailure>();
return -1;
}
- catch (sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument& e)
+ catch (common_error::InvalidArgument& e)
{
- commit<sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument>();
+ commit<common_error::InvalidArgument>();
return -1;
}
diff --git a/procedures/p9/cfam_overrides.cpp b/procedures/p9/cfam_overrides.cpp
index f3436ee..a594e0c 100644
--- a/procedures/p9/cfam_overrides.cpp
+++ b/procedures/p9/cfam_overrides.cpp
@@ -5,7 +5,8 @@
#include "p9_cfam.hpp"
#include "registration.hpp"
#include "targeting.hpp"
-#include "elog-errors.hpp"
+#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/elog-errors.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
/* File /var/lib/obmc/cfam_overrides requires whitespace-separated parameters
diff --git a/targeting.cpp b/targeting.cpp
index ce3fc67..205bf68 100644
--- a/targeting.cpp
+++ b/targeting.cpp
@@ -16,10 +16,11 @@
#include <endian.h>
#include <experimental/filesystem>
+#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/log.hpp>
#include <regex>
-#include <phosphor-logging/elog.hpp>
-#include "elog-errors.hpp"
+#include <xyz/openbmc_project/Common/File/error.hpp>
#include "targeting.hpp"
@@ -30,6 +31,7 @@ namespace targeting
using namespace phosphor::logging;
namespace fs = std::experimental::filesystem;
+namespace file_error = sdbusplus::xyz::openbmc_project::Common::File::Error;
int Target::getCFAMFD()
{
@@ -119,9 +121,11 @@ Targeting::Targeting(const std::string& fsiMasterDev,
}
catch (fs::filesystem_error& e)
{
- elog<org::open_power::Proc::CFAM::OpenFailure>(
- org::open_power::Proc::CFAM::OpenFailure::ERRNO(e.code().value()),
- org::open_power::Proc::CFAM::OpenFailure::PATH(e.path1().c_str()));
+ using metadata = xyz::openbmc_project::Common::File::Open;
+
+ elog<file_error::Open>(
+ metadata::ERRNO(e.code().value()),
+ metadata::PATH(e.path1().c_str()));
}
auto sortTargets = [](const std::unique_ptr<Target>& left,
diff --git a/test/Makefile.am b/test/Makefile.am
index ad8a173..52aefd0 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -5,12 +5,18 @@ TESTS = $(check_PROGRAMS)
# Basic test suite for hostcontrol interfaces
check_PROGRAMS = utest
-utest_CPPFLAGS = -Igtest $(GTEST_CPPFLAGS) $(AM_CPPFLAGS) \
- $(PHOSPHOR_LOGGING_CFLAGS)
+utest_CPPFLAGS = -Igtest $(GTEST_CPPFLAGS) $(AM_CPPFLAGS)
-utest_CXXFLAGS = $(PTHREAD_CFLAGS) $(PHOSPHOR_LOGGING_CFLAGS)
-utest_LDFLAGS = -lgtest_main -lgtest $(PTHREAD_LIBS) $(OESDK_TESTCASE_FLAGS) \
- $(PHOSPHOR_LOGGING_LIBS) -lstdc++fs
+utest_CXXFLAGS = $(PTHREAD_CFLAGS) \
+ $(PHOSPHOR_LOGGING_CFLAGS) \
+ $(PHOSPHOR_DBUS_INTERFACES_CFLAGS)
+
+utest_LDFLAGS = -lgtest_main -lgtest \
+ $(PTHREAD_LIBS) \
+ $(OESDK_TESTCASE_FLAGS) \
+ $(PHOSPHOR_LOGGING_LIBS) \
+ $(PHOSPHOR_DBUS_INTERFACES_LIBS) \
+ -lstdc++fs
utest_SOURCES = utest.cpp
utest_LDADD = $(top_srcdir)/targeting.cpp $(top_srcdir)/filedescriptor.cpp
OpenPOWER on IntegriCloud