pnor : generate partition table

Implement a class that, upon construction, generates the virtual PNOR
partition table. The virtual PNOR is typically a subset of the full PNOR
image, by choosing partitions of interest.

The generation is based on upon information read from the
PNOR partition files and table of contents (toc) file.

Provide an interface to the virtual PNOR partition table.

Change-Id: I7a68e3833b8cf66e92eb6ca274f6a3c376ce0add
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
diff --git a/Makefile.am b/Makefile.am
index 5a26916..cf1f987 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,10 +1,23 @@
 ACLOCAL_AMFLAGS = -I m4
 sbin_PROGRAMS = mboxd mboxctl
 
-mboxd_SOURCES = mboxd.c common.c mboxd_dbus.c mboxd_flash.c mboxd_lpc.c mboxd_msg.c mboxd_windows.c mtd.c
+mboxd_SOURCES = \
+	mboxd.c \
+	common.c \
+	mboxd_dbus.c \
+	mboxd_flash.c \
+	mboxd_lpc.c \
+	mboxd_msg.c \
+	mboxd_windows.c \
+	mtd.c
 mboxd_LDFLAGS = $(LIBSYSTEMD_LIBS)
 mboxd_CFLAGS = $(LIBSYSTEMD_CFLAGS)
 
+if VIRTUAL_PNOR_ENABLED
+mboxd_SOURCES += pnor_partition_table.cpp
+mboxd_LDFLAGS += -lstdc++fs
+endif
+
 mboxctl_SOURCES = mboxctl.c
 mboxctl_LDFLAGS = $(LIBSYSTEMD_LIBS)
 mboxctl_CFLAGS = $(LIBSYSTEMD_CFLAGS)
@@ -14,6 +27,7 @@
 AM_LIBS = $(CODE_COVERAGE_LIBS)
 AM_CPPFLAGS = $(CODE_COVERAGE_CPPFLAGS)
 AM_CFLAGS = $(CODE_COVERAGE_CFLAGS)
+AM_CXXFLAGS = $(CODE_COVERAGE_CXXFLAGS)
 
 test_sanity_SOURCES = test/sanity.c
 
@@ -95,6 +109,12 @@
 test_get_mbox_info_v2_timeout_SOURCES = test/get_mbox_info_v2_timeout.c \
 					$(TEST_MBOX_SRCS) $(TEST_MOCK_SRCS)
 
+test_create_pnor_partition_table_SOURCES = \
+	test/create_pnor_partition_table.cpp \
+	common.c \
+	pnor_partition_table.cpp
+test_create_pnor_partition_table_LDFLAGS = -lstdc++fs
+
 check_PROGRAMS = test/sanity \
 		 test/copy_flash \
 		 test/erase_flash \
@@ -123,4 +143,8 @@
 		 test/sequence_numbers \
 		 test/get_mbox_info_v2_timeout
 
+if VIRTUAL_PNOR_ENABLED
+check_PROGRAMS += test/create_pnor_partition_table
+endif
+
 TESTS = $(check_PROGRAMS)