Make MaxBootCycleCount Configurable

MaxBootCycleCount is a dbus property that is used to indicate
the maximum number of boot cycles that the post-code-manager
daemon can store the progress codes for, before it starts
wrapping.

Right now the MaxBootCycleCount is hardcoded to 100 in the code.
It should ideally be a configurable variable per platform so that
vendors can choose how may progress codes that we want to store.

Tested By:
1. Default configuration should set the value to 100 - PASSED.
2. Override the value to any number out of 1-100 and the cmake
   configuration step should throw an error - PASSED
3. Override the value to any number in between 1-100, and patch
   the daemon ,and make sure that MaxBootCycleCount value is set
   to the configured value.

Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com>
Change-Id: Ic07087a9d6696412e1e6c54fb9945b91f3c560dc
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7c68a66..6d291cc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,9 +15,15 @@
 
 set(DBUS_OBJECT_NAME "xyz/openbmc_project/State/Boot/PostCode0")
 set(DBUS_INTF_NAME "xyz.openbmc_project.State.Boot.PostCode")
+set(MAX_BOOT_CYCLE_COUNT 100 CACHE STRING "Max boot count Value")
+if(NOT MAX_BOOT_CYCLE_COUNT MATCHES "^([1-9][0-9]?|100)$")
+    message(FATAL_ERROR "Maximum boot cycle count must be a number from 1 to 100")
+endif()
 
 add_definitions(-DDBUS_OBJECT_NAME="/${DBUS_OBJECT_NAME}")
 add_definitions(-DDBUS_INTF_NAME="${DBUS_INTF_NAME}")
+add_definitions(-DMAX_BOOT_CYCLE_COUNT=${MAX_BOOT_CYCLE_COUNT})
+
 set(SRC_FILES src/post_code.cpp
     src/main.cpp )
 set ( SERVICE_FILES
diff --git a/inc/post_code.hpp b/inc/post_code.hpp
index 05ce284..08b1cc5 100644
--- a/inc/post_code.hpp
+++ b/inc/post_code.hpp
@@ -33,8 +33,6 @@
 #include <xyz/openbmc_project/State/Boot/PostCode/server.hpp>
 #include <xyz/openbmc_project/State/Host/server.hpp>
 
-#define MaxPostCodeCycles 100
-
 const static constexpr char *CurrentBootCycleCountName =
     "CurrentBootCycleCount";
 const static constexpr char *CurrentBootCycleIndexName =
@@ -177,7 +175,7 @@
             fs::path(strPostCodeListPath + strCurrentBootCycleCountName),
             count);
         currentBootCycleCount(count);
-        maxBootCycleNum(MaxPostCodeCycles);
+        maxBootCycleNum(MAX_BOOT_CYCLE_COUNT);
     }
     ~PostCode()
     {