summaryrefslogtreecommitdiffstats
path: root/pnor_partition_table.hpp
diff options
context:
space:
mode:
authorAndrew Jeffery <andrew@aj.id.au>2018-02-28 23:16:48 +1030
committerAndrew Jeffery <andrew@aj.id.au>2018-03-24 13:59:32 +1030
commitae1edb940c65e13e610108203e6a1cba0ab424c7 (patch)
tree404e3aeffeca9a94635599cd3d1d1b09d56b10d3 /pnor_partition_table.hpp
parentcd928513e21f02ebca1f68a414f5347a7de8326d (diff)
downloadphosphor-mboxd-ae1edb940c65e13e610108203e6a1cba0ab424c7.tar.gz
phosphor-mboxd-ae1edb940c65e13e610108203e6a1cba0ab424c7.zip
pnor_partition_table: Raise exception for unmapped offsets
Allow reads and writes of offsets that don't map onto partitions defined in the ToC. Do so by ignoring the mapping failure and filling a window with 0xff in the hole from the requested offset to the following partition. This change also removes the reliance on InternalFailure as the exception of choice for communicating failures. We can do better without the teeth-pulling required by phosphor-logging by translating custom exceptions into phosphor-logging exceptions at the edges. Change-Id: Ibfa961a66b0b979354c6dc226ccbe7e9fbafc16d Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Diffstat (limited to 'pnor_partition_table.hpp')
-rw-r--r--pnor_partition_table.hpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/pnor_partition_table.hpp b/pnor_partition_table.hpp
index 730e75b..88c8fb9 100644
--- a/pnor_partition_table.hpp
+++ b/pnor_partition_table.hpp
@@ -163,6 +163,8 @@ class Table
*
* @returns const reference to pnor_partition, if found, else an
* exception will be thrown.
+ *
+ * Throws: UnmappedOffset
*/
const pnor_partition& partition(size_t offset) const;
@@ -172,6 +174,8 @@ class Table
*
* @returns const reference to pnor_partition, if found, else an
* exception will be thrown.
+ *
+ * Throws: UnknownPartition
*/
const pnor_partition& partition(const std::string& name) const;
@@ -304,6 +308,35 @@ class InvalidTocEntry : public TocEntryError
}
};
+class UnmappedOffset : public std::exception
+{
+ public:
+ UnmappedOffset(size_t base, size_t next) : base(base), next(next)
+ {
+ }
+
+ const size_t base;
+ const size_t next;
+};
+
+class OutOfBoundsOffset : public ReasonedError
+{
+ public:
+ OutOfBoundsOffset(const std::string&& reason) :
+ ReasonedError(std::move(reason))
+ {
+ }
+};
+
+class UnknownPartition : public ReasonedError
+{
+ public:
+ UnknownPartition(const std::string&& reason) :
+ ReasonedError(std::move(reason))
+ {
+ }
+};
+
} // namespace virtual_pnor
} // namespace openpower
OpenPOWER on IntegriCloud