buffer: Implement "readEntryHeader"
Add struct QueueEntryHeader along with it.
Tested: Unit Tested
Signed-off-by: Brandon Kim <brandonkim@google.com>
Change-Id: Icbfe8d39db4242664794d8c65a84488aeffd23a6
diff --git a/include/buffer.hpp b/include/buffer.hpp
index ad845c4..d199a94 100644
--- a/include/buffer.hpp
+++ b/include/buffer.hpp
@@ -49,6 +49,24 @@
static_assert(sizeof(CircularBufferHeader) == 0x30,
"Size of CircularBufferHeader struct is incorrect.");
+struct QueueEntryHeader
+{
+ little_uint16_t sequenceId; // Offset 0x0
+ little_uint16_t entrySize; // Offset 0x2
+ uint8_t checksum; // Offset 0x4
+ uint8_t rdeCommandType; // Offset 0x5
+ // RDE Command Offset 0x6
+ bool operator==(const QueueEntryHeader& other) const
+ {
+ return std::tie(this->sequenceId, this->entrySize, this->checksum,
+ this->rdeCommandType) ==
+ std::tie(other.sequenceId, other.entrySize, other.checksum,
+ other.rdeCommandType);
+ }
+};
+static_assert(sizeof(QueueEntryHeader) == 0x6,
+ "Size of QueueEntryHeader struct is incorrect.");
+
/**
* An interface class for the buffer helper APIs
*/
@@ -99,6 +117,13 @@
virtual std::vector<uint8_t>
wraparoundRead(const uint32_t offset, const uint32_t length,
const uint32_t additionalBoundaryCheck) = 0;
+ /**
+ * Read the entry header from shared buffer
+ *
+ * @param[in] offset - offset to read from
+ * @return the entry header
+ */
+ virtual struct QueueEntryHeader readEntryHeader(size_t offset) = 0;
};
/**
@@ -120,6 +145,7 @@
std::vector<uint8_t>
wraparoundRead(const uint32_t offset, const uint32_t length,
const uint32_t additionalBoundaryCheck = 0) override;
+ struct QueueEntryHeader readEntryHeader(size_t offset) override;
private:
/** @brief The Error log queue starts after the UE region, which is where