summaryrefslogtreecommitdiffstats
path: root/vpnor
diff options
context:
space:
mode:
authorAndrew Jeffery <andrew@aj.id.au>2018-03-26 15:37:33 +1030
committerAndrew Jeffery <andrew@aj.id.au>2018-04-04 17:27:31 +0930
commit943aba060f143667d502792f11e95f42bc7da346 (patch)
tree2cc5dcc7e4e82a1672daa3fec77f2df0c8fac738 /vpnor
parentefb09def5e21959972adde9f5c092f1840eff908 (diff)
downloadphosphor-mboxd-943aba060f143667d502792f11e95f42bc7da346.tar.gz
phosphor-mboxd-943aba060f143667d502792f11e95f42bc7da346.zip
vpnor: Configure a handler table in init_vpnor()
Currently the table just mirrors that which is set by the regular implementation, however getting to that point requires massaging the code a little. Thus, separate out this change from one that changes the behaviour of the commands to improve the readability of the latter change. Change-Id: I4007a8a4d508c6d850b8cc878bab8f72bd343498 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Diffstat (limited to 'vpnor')
-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
5 files changed, 40 insertions, 21 deletions
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