mboxd: Add a backend abstraction layer to mboxd.
Introduce a backend abstraction, enabling multiple implementations to be
compiled in at once. This change formally abstracts the two existing
backends, mtd and vpnor.
With the backend abstraction in place, subsequent backends are easier to
implement.
This change is based of Evan's work and he retains authorship credit. I
(AJ) have reworked the patch to pass the vpnor tests, refactored some
parts to enable broader use of const structures and others to clarify
the initialisation sequences.
Due to the existing lack of abstraction the patch has unfortunately
wide-ranging impacts. I've whittled it down as much as I consider
reasonable.
Change-Id: I29984a36dae4ea86ec00b853d2a756f0b9afb3ec
Signed-off-by: Evan Lojewski <github@meklort.com>
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/vpnor/test/write_toc.cpp b/vpnor/test/write_toc.cpp
index 6f6b101..8b690a1 100644
--- a/vpnor/test/write_toc.cpp
+++ b/vpnor/test/write_toc.cpp
@@ -67,14 +67,12 @@
system_set_reserved_size(MEM_SIZE);
system_set_mtd_sizes(PNOR_SIZE, ERASE_SIZE);
- ctx = mbox_create_test_context(N_WINDOWS, WINDOW_SIZE);
- test::VpnorRoot root(ctx, toc, BLOCK_SIZE);
- vpnor::partition::Table table(ctx);
+ ctx = mbox_create_frontend_context(N_WINDOWS, WINDOW_SIZE);
+ test::VpnorRoot root(&ctx->backend, toc, BLOCK_SIZE);
+ vpnor::partition::Table table(&ctx->backend);
assert(table.capacity() == TOC_PART_SIZE);
- init_vpnor_from_paths(ctx);
-
rc = mbox_command_dispatch(ctx, get_info, sizeof(get_info));
assert(rc == MBOX_R_SUCCESS);