Add boot count into motherboard eeprom and clear command

The bmc boot count which was previously stored into
the file /etc/conf/bios.cnt, is now stored into the
motherboard FRU eeprom/sys/bus/i2c/devices/4-0050/eeprom
starting from offset of 4 bytes from 0x1000.

The reading and writing to the FRU eeprom is handled
by using the helper functions.

Added the new IPMI clear command which sets the eeprom
to the default value of ff ff ff ff.

Use of 4 bytes from 0x1000 location to check
if the boot counter is at the max value or at the default
value which server as a header to the boot count.

All corner cases such as invalid command and invalid
command length have been added

Tested:
ipmitool raw 0x34 0x71 0x00 - read current boot count.
ipmitool raw 0x34 0x71 0x01 - increment the boot count by 1.
ipmitool raw 0x34 0x71 0x02 - set the boot_count to all ff which
is its default value of eeprom location where the boot count is
stored.
ipmitool raw 0x34 0x71 0x03 byte1 byte2 byte3 byte4 - set the
boot count to desired value provided by the request parameter.
Reboot,powercyle,flashing bmc - performed to see if the value
retains.

Signed-off-by: Avenash Asai Thambi <avenash.thambi@fii-usa.com>
Change-Id: I99dd5e6ba1d943e558e984d948bd63552cd5278f
diff --git a/include/bioscommands.hpp b/include/bioscommands.hpp
index 15b6c13..6a705a5 100644
--- a/include/bioscommands.hpp
+++ b/include/bioscommands.hpp
@@ -15,12 +15,16 @@
 ********************************************************************************/
 
 #pragma once
+#define BOOT_COUNT_READ    0x00
+#define BOOT_COUNT_INCREMENT   0x01
+#define BOOT_COUNT_CLEAR   0x02
+#define BOOT_COUNT_SET   0x03
+#define FII_CMD_BIOS_BOOT_COUNT 0x71
+#define OPERATION_BYTE_LENGTH 1
+#define SET_BYTE_LENGTH 5
+#define BOOT_COUNT_HEADER 0xDEADBEEF
+#define INITIAL_VALUE 0x00000000
+#define START_BOOT_COUNT_VALUE 0x00000001
 
-#define BOOT_COUNT_FILE "/etc/conf/bios.cnt"
-
-enum fii_bios_cmds
-{
-    FII_CMD_BIOS_BOOT_COUNT = 0x71,
-};
-
-#define FII_CMD_BIOS_BOOT_COUNT_LEN 5
+size_t EEPROM_OFFSET = 4096;
+std::string EEPROM_PATH = "/sys/bus/i2c/devices/4-0050/eeprom";
diff --git a/include/common.hpp b/include/file_handling.hpp
similarity index 75%
rename from include/common.hpp
rename to include/file_handling.hpp
index c2d64a9..bb4f703 100644
--- a/include/common.hpp
+++ b/include/file_handling.hpp
@@ -1,7 +1,7 @@
 /********************************************************************************
 *                       HON HAI Precision IND.Co., LTD.                         *
 *            Personal Computer & Enterprise Product Business Group              *
-*                      Enterprise Product Business Gro:qup                      *
+*                      Enterprise Product Business Group                        *
 *                                                                               *
 *     Copyright (c) 2010 by FOXCONN/CESBG/CABG/SRD. All rights reserved.        *
 *     All data and information contained in this document is confidential       *
@@ -13,20 +13,17 @@
 *     permission of FOXCONN/CESBG/CABG/SRD.                                     *
 *                                                                               *
 ********************************************************************************/
-#include <sys/stat.h>
-#include <fcntl.h>
 #include <unistd.h>
-#include <iostream>
-#include <iomanip>
-#include <sstream>
-#include <fstream>
 
-#include <ipmid/api.hpp>
-#include <ipmid/utils.hpp>
-#include <ipmid/message.hpp>
-#include <phosphor-logging/log.hpp>
-#include <sdbusplus/message/types.hpp>
+std::system_error errnoException(const std::string& message);
 
-#define OP_CODE_READ	0b00
-#define OP_CODE_WRITE	0b01
+int sysopen(const std::string& path);
+
+void sysclose(int fd_);
+
+void lseeker(int fd_, size_t offset);
+
+void readBin(int fd_, size_t offset, void *ptr, size_t size);
+
+void writeBin(int fd_, size_t offset, void *ptr, size_t size);