summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mboxd_msg.c23
-rw-r--r--mboxd_msg.h22
-rw-r--r--vpnor/Makefile.am.include3
-rw-r--r--vpnor/mboxd_msg.cpp24
-rw-r--r--vpnor/mboxd_msg.hpp5
-rw-r--r--vpnor/mboxd_pnor_partition_table.cpp3
-rw-r--r--vpnor/test/Makefile.am.include26
7 files changed, 72 insertions, 34 deletions
diff --git a/mboxd_msg.c b/mboxd_msg.c
index 4ca8e24..487fb4f 100644
--- a/mboxd_msg.c
+++ b/mboxd_msg.c
@@ -30,9 +30,6 @@
#include "mboxd_windows.h"
#include "mboxd_lpc.h"
-static int mbox_handle_flush_window(struct mbox_context *context, union mbox_regs *req,
- struct mbox_msg *resp);
-
/*
* write_bmc_event_reg() - Write to the BMC controlled status register (reg 15)
* @context: The mbox context pointer
@@ -122,7 +119,7 @@ int clr_bmc_events(struct mbox_context *context, uint8_t bmc_event,
* Reset the LPC mapping to point back at the flash, or memory in case we're
* using a virtual pnor.
*/
-static int mbox_handle_reset(struct mbox_context *context,
+int mbox_handle_reset(struct mbox_context *context,
union mbox_regs *req, struct mbox_msg *resp)
{
/* Host requested it -> No BMC Event */
@@ -171,7 +168,7 @@ static uint16_t get_suggested_timeout(struct mbox_context *context)
* RESP[3:4]: Default write window size (number of blocks)
* RESP[5]: Block size (as shift)
*/
-static int mbox_handle_mbox_info(struct mbox_context *context,
+int mbox_handle_mbox_info(struct mbox_context *context,
union mbox_regs *req, struct mbox_msg *resp)
{
uint8_t mbox_api_version = req->msg.args[0];
@@ -250,7 +247,7 @@ static int mbox_handle_mbox_info(struct mbox_context *context,
* RESP[0:1]: Flash Size (number of blocks)
* RESP[2:3]: Erase Size (number of blocks)
*/
-static int mbox_handle_flash_info(struct mbox_context *context,
+int mbox_handle_flash_info(struct mbox_context *context,
union mbox_regs *req, struct mbox_msg *resp)
{
switch (context->version) {
@@ -314,7 +311,7 @@ static inline uint16_t get_lpc_addr_shifted(struct mbox_context *context)
* RESP[0:1]: LPC bus address for host to access this window (number of blocks)
* RESP[2:3]: Actual window size that the host can access (number of blocks)
*/
-static int mbox_handle_read_window(struct mbox_context *context,
+int mbox_handle_read_window(struct mbox_context *context,
union mbox_regs *req, struct mbox_msg *resp)
{
uint32_t flash_offset;
@@ -387,7 +384,7 @@ static int mbox_handle_read_window(struct mbox_context *context,
* RESP[0:1]: LPC bus address for host to access this window (number of blocks)
* RESP[2:3]: Actual window size that was mapped/host can access (n.o. blocks)
*/
-static int mbox_handle_write_window(struct mbox_context *context,
+int mbox_handle_write_window(struct mbox_context *context,
union mbox_regs *req, struct mbox_msg *resp)
{
int rc;
@@ -421,7 +418,7 @@ static int mbox_handle_write_window(struct mbox_context *context,
* ARGS[0:1]: Where within window to start (number of blocks)
* ARGS[2:3]: Number to mark dirty (number of blocks)
*/
-static int mbox_handle_dirty_window(struct mbox_context *context,
+int mbox_handle_dirty_window(struct mbox_context *context,
union mbox_regs *req, struct mbox_msg *resp)
{
uint32_t offset, size;
@@ -480,7 +477,7 @@ static int mbox_handle_dirty_window(struct mbox_context *context,
* ARGS[0:1]: Where within window to start (number of blocks)
* ARGS[2:3]: Number to erase (number of blocks)
*/
-static int mbox_handle_erase_window(struct mbox_context *context,
+int mbox_handle_erase_window(struct mbox_context *context,
union mbox_regs *req, struct mbox_msg *resp)
{
uint32_t offset, size;
@@ -533,7 +530,7 @@ static int mbox_handle_erase_window(struct mbox_context *context,
* V2:
* NONE
*/
-static int mbox_handle_flush_window(struct mbox_context *context,
+int mbox_handle_flush_window(struct mbox_context *context,
union mbox_regs *req, struct mbox_msg *resp)
{
int rc, i, offset, count;
@@ -629,7 +626,7 @@ static int mbox_handle_flush_window(struct mbox_context *context,
* V2:
* ARGS[0]: FLAGS
*/
-static int mbox_handle_close_window(struct mbox_context *context,
+int mbox_handle_close_window(struct mbox_context *context,
union mbox_regs *req, struct mbox_msg *resp)
{
uint8_t flags = 0;
@@ -663,7 +660,7 @@ static int mbox_handle_close_window(struct mbox_context *context,
*
* ARGS[0]: Bitmap of bits to ack (by clearing)
*/
-static int mbox_handle_ack(struct mbox_context *context, union mbox_regs *req,
+int mbox_handle_ack(struct mbox_context *context, union mbox_regs *req,
struct mbox_msg *resp)
{
uint8_t bmc_events = req->msg.args[0];
diff --git a/mboxd_msg.h b/mboxd_msg.h
index aebf3bd..d911b7b 100644
--- a/mboxd_msg.h
+++ b/mboxd_msg.h
@@ -21,4 +21,26 @@ int dispatch_mbox(struct mbox_context *context);
int init_mbox_dev(struct mbox_context *context);
void free_mbox_dev(struct mbox_context *context);
+/* Command handlers */
+int mbox_handle_reset(struct mbox_context *context,
+ union mbox_regs *req, struct mbox_msg *resp);
+int mbox_handle_mbox_info(struct mbox_context *context,
+ union mbox_regs *req, struct mbox_msg *resp);
+int mbox_handle_flash_info(struct mbox_context *context,
+ union mbox_regs *req, struct mbox_msg *resp);
+int mbox_handle_read_window(struct mbox_context *context,
+ union mbox_regs *req, struct mbox_msg *resp);
+int mbox_handle_close_window(struct mbox_context *context,
+ union mbox_regs *req, struct mbox_msg *resp);
+int mbox_handle_write_window(struct mbox_context *context,
+ union mbox_regs *req, struct mbox_msg *resp);
+int mbox_handle_dirty_window(struct mbox_context *context,
+ union mbox_regs *req, struct mbox_msg *resp);
+int mbox_handle_flush_window(struct mbox_context *context,
+ union mbox_regs *req, struct mbox_msg *resp);
+int mbox_handle_ack(struct mbox_context *context, union mbox_regs *req,
+ struct mbox_msg *resp);
+int mbox_handle_erase_window(struct mbox_context *context,
+ union mbox_regs *req, struct mbox_msg *resp);
+
#endif /* MBOXD_MSG_H */
diff --git a/vpnor/Makefile.am.include b/vpnor/Makefile.am.include
index edb97b7..0f3de00 100644
--- a/vpnor/Makefile.am.include
+++ b/vpnor/Makefile.am.include
@@ -2,7 +2,8 @@ mboxd_SOURCES += %reldir%/pnor_partition_table.cpp \
%reldir%/mboxd_pnor_partition_table.cpp \
%reldir%/mboxd_flash.cpp \
%reldir%/pnor_partition.cpp \
- %reldir%/mboxd_lpc_reset.cpp
+ %reldir%/mboxd_lpc_reset.cpp \
+ %reldir%/mboxd_msg.cpp
mboxd_LDFLAGS += -lstdc++fs \
$(SDBUSPLUS_LIBS) \
diff --git a/vpnor/mboxd_msg.cpp b/vpnor/mboxd_msg.cpp
new file mode 100644
index 0000000..130c098
--- /dev/null
+++ b/vpnor/mboxd_msg.cpp
@@ -0,0 +1,24 @@
+#include "config.h"
+
+extern "C" {
+#include "mbox.h"
+#include "mboxd_msg.h"
+};
+
+#include "vpnor/mboxd_msg.hpp"
+
+// clang-format off
+const mboxd_mbox_handler vpnor_mbox_handlers[NUM_MBOX_CMDS] =
+{
+ mbox_handle_reset,
+ mbox_handle_mbox_info,
+ mbox_handle_flash_info,
+ mbox_handle_read_window,
+ mbox_handle_close_window,
+ mbox_handle_write_window,
+ mbox_handle_dirty_window,
+ mbox_handle_flush_window,
+ mbox_handle_ack,
+ mbox_handle_erase_window
+};
+// clang-format on
diff --git a/vpnor/mboxd_msg.hpp b/vpnor/mboxd_msg.hpp
new file mode 100644
index 0000000..7485c38
--- /dev/null
+++ b/vpnor/mboxd_msg.hpp
@@ -0,0 +1,5 @@
+extern "C" {
+#include "mbox.h"
+
+extern const mboxd_mbox_handler vpnor_mbox_handlers[NUM_MBOX_CMDS];
+};
diff --git a/vpnor/mboxd_pnor_partition_table.cpp b/vpnor/mboxd_pnor_partition_table.cpp
index db53dc8..fad0c7f 100644
--- a/vpnor/mboxd_pnor_partition_table.cpp
+++ b/vpnor/mboxd_pnor_partition_table.cpp
@@ -10,6 +10,7 @@
#include "xyz/openbmc_project/Common/error.hpp"
#include <phosphor-logging/elog-errors.hpp>
#include <experimental/filesystem>
+#include "vpnor/mboxd_msg.hpp"
int init_vpnor(struct mbox_context *context)
{
@@ -44,6 +45,8 @@ int init_vpnor_from_paths(struct mbox_context *context)
if (context && !context->vpnor)
{
+ context->handlers = vpnor_mbox_handlers;
+
try
{
context->vpnor = new vpnor_partition_table;
diff --git a/vpnor/test/Makefile.am.include b/vpnor/test/Makefile.am.include
index 9a81d9c..85b2cbc 100644
--- a/vpnor/test/Makefile.am.include
+++ b/vpnor/test/Makefile.am.include
@@ -11,6 +11,7 @@ TEST_MBOX_VPNOR_INTEG_SRCS = \
vpnor/mboxd_lpc_reset.cpp \
vpnor/mboxd_pnor_partition_table.cpp \
vpnor/mboxd_flash.cpp \
+ vpnor/mboxd_msg.cpp \
vpnor/pnor_partition.cpp \
vpnor/pnor_partition_table.cpp \
%reldir%/tmpd.cpp
@@ -35,41 +36,29 @@ vpnor_test_create_read_window_partition_exists_LDFLAGS = $(OESDK_TESTCASE_FLAGS)
vpnor_test_create_read_window_partition_exists_LDADD = $(VPNOR_LDADD)
vpnor_test_write_patch_SOURCES = \
- $(TEST_MBOX_VPNOR_SRCS) \
+ $(TEST_MBOX_VPNOR_INTEG_SRCS) \
mtd.c \
- vpnor/mboxd_pnor_partition_table.cpp \
- vpnor/mboxd_flash.cpp \
- vpnor/pnor_partition.cpp \
%reldir%/write_patch.cpp
vpnor_test_write_patch_LDFLAGS = $(OESDK_TESTCASE_FLAGS)
vpnor_test_write_patch_LDADD = $(VPNOR_LDADD)
vpnor_test_write_prsv_SOURCES = \
- $(TEST_MBOX_VPNOR_SRCS) \
+ $(TEST_MBOX_VPNOR_INTEG_SRCS) \
mtd.c \
- vpnor/mboxd_pnor_partition_table.cpp \
- vpnor/mboxd_flash.cpp \
- vpnor/pnor_partition.cpp \
%reldir%/write_prsv.cpp
vpnor_test_write_prsv_LDFLAGS = $(OESDK_TESTCASE_FLAGS)
vpnor_test_write_prsv_LDADD = $(VPNOR_LDADD)
vpnor_test_write_ro_SOURCES = \
- $(TEST_MBOX_VPNOR_SRCS) \
+ $(TEST_MBOX_VPNOR_INTEG_SRCS) \
mtd.c \
- vpnor/mboxd_pnor_partition_table.cpp \
- vpnor/mboxd_flash.cpp \
- vpnor/pnor_partition.cpp \
%reldir%/write_ro.cpp
vpnor_test_write_ro_LDFLAGS = $(OESDK_TESTCASE_FLAGS)
vpnor_test_write_ro_LDADD = $(VPNOR_LDADD)
vpnor_test_write_rw_SOURCES = \
- $(TEST_MBOX_VPNOR_SRCS) \
+ $(TEST_MBOX_VPNOR_INTEG_SRCS) \
mtd.c \
- vpnor/mboxd_pnor_partition_table.cpp \
- vpnor/mboxd_flash.cpp \
- vpnor/pnor_partition.cpp \
%reldir%/write_rw.cpp
vpnor_test_write_rw_LDFLAGS = $(OESDK_TESTCASE_FLAGS)
vpnor_test_write_rw_LDADD = $(VPNOR_LDADD)
@@ -180,11 +169,8 @@ vpnor_test_read_patch_LDFLAGS = $(OESDK_TESTCASE_FLAGS)
vpnor_test_read_patch_LDADD = $(VPNOR_LDADD)
vpnor_test_write_patch_resize_SOURCES = \
- $(TEST_MBOX_VPNOR_SRCS) \
+ $(TEST_MBOX_VPNOR_INTEG_SRCS) \
mtd.c \
- vpnor/mboxd_pnor_partition_table.cpp \
- vpnor/mboxd_flash.cpp \
- vpnor/pnor_partition.cpp \
%reldir%/write_patch_resize.cpp
vpnor_test_write_patch_resize_LDFLAGS = $(OESDK_TESTCASE_FLAGS)
vpnor_test_write_patch_resize_LDADD = $(VPNOR_LDADD)
OpenPOWER on IntegriCloud