summaryrefslogtreecommitdiff
path: root/inc/storage.h
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-04-14 23:40:25 -0400
committerbd <bdunahu@operationnull.com>2025-04-14 23:40:25 -0400
commita7620015acc2401165b4587cbb6c9a118d944493 (patch)
tree5bbe698fe42a7d32578df6170e464508a78a8e50 /inc/storage.h
parent2140a23041d3920e001457f2c2acb0853094963d (diff)
Add preprocess method to storage, removing nearly all duplication
Diffstat (limited to 'inc/storage.h')
-rw-r--r--inc/storage.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/inc/storage.h b/inc/storage.h
index 972e24a..1bf5805 100644
--- a/inc/storage.h
+++ b/inc/storage.h
@@ -3,6 +3,7 @@
#include "definitions.h"
#include <algorithm>
#include <array>
+#include <functional>
#include <map>
#include <vector>
@@ -48,6 +49,23 @@ class Storage
protected:
/**
+ * Helper for all access methods.
+ * Calls `request_handler` when `id` is allowed to complete its
+ * request cycle.
+ * May include extra checks depending on storage device.
+ * @param the source making the request
+ * @param the address to write to
+ * @param the function to call when an access should be completed
+ */
+ virtual int
+ process(void *id, int address, std::function<void(int index, int offset)> request_handler) = 0;
+ /**
+ * Helper for process. Given `id`, returns 0 if the request should trivially be ignored.
+ * @param the source making the request
+ * @return 0 if the request should not be completed, 1 if it should be evaluated further.
+ */
+ int preprocess(void *id);
+ /**
* Returns OK if `id` should complete its request this cycle. In the case it can, automatically
* clears the current requester.
* @param the id asking for a resource