oem-ibm: Host Security Storage file

Added support for host security storage file

Tested: File created in required path and present in FileTable

Change-Id: I7d7b94ac6485eb39a3feff286c83ebf1e27a7686
Signed-off-by: Manjeet Singh <itsmanjeet1998@gmail.com>
diff --git a/oem/ibm/configurations/fileTable.json b/oem/ibm/configurations/fileTable.json
index 29ee8df..1100997 100644
--- a/oem/ibm/configurations/fileTable.json
+++ b/oem/ibm/configurations/fileTable.json
@@ -466,5 +466,9 @@
     {
         "path": "/usr/local/share/hostfw/running/81e006f0.lid,/var/lib/phosphor-software-manager/hostfw/running/81e006f0.lid",
         "file_traits": 1
+    },
+    {
+        "path": "/var/lib/phosphor-software-manager/hostfw/PHYP-SECURITY",
+        "file_traits": 4
     }
 ]
diff --git a/oem/ibm/service_files/meson.build b/oem/ibm/service_files/meson.build
index 1a2a817..129d2ec 100644
--- a/oem/ibm/service_files/meson.build
+++ b/oem/ibm/service_files/meson.build
@@ -6,6 +6,11 @@
     install_dir: systemd_system_unit_dir,
 )
 filesystem.copyfile(
+    'pldm-create-phyp-security.service',
+    install: true,
+    install_dir: systemd_system_unit_dir,
+)
+filesystem.copyfile(
     'pldm-create-phyp-nvram-cksum.service',
     install: true,
     install_dir: systemd_system_unit_dir,
diff --git a/oem/ibm/service_files/pldm-create-phyp-security.service b/oem/ibm/service_files/pldm-create-phyp-security.service
new file mode 100644
index 0000000..5eb8cef
--- /dev/null
+++ b/oem/ibm/service_files/pldm-create-phyp-security.service
@@ -0,0 +1,15 @@
+[Unit]
+Description=Create empty PHYP-SECURITY file
+Wants=obmc-vpnor-updatesymlinks.service
+After=obmc-vpnor-updatesymlinks.service
+Wants=obmc-flash-bios-init.service
+After=obmc-flash-bios-init.service
+
+[Service]
+ExecStart=/usr/bin/create-PHYP-SECURITY-file
+ConditionPathExists=!/var/lib/phosphor-software-manager/hostfw/PHYP-SECURITY
+Type=oneshot
+RemainAfterExit=no
+
+[Install]
+WantedBy=pldmd.service
diff --git a/oem/ibm/service_files/scripts/create-PHYP-SECURITY-file b/oem/ibm/service_files/scripts/create-PHYP-SECURITY-file
new file mode 100755
index 0000000..c5dba9b
--- /dev/null
+++ b/oem/ibm/service_files/scripts/create-PHYP-SECURITY-file
@@ -0,0 +1,22 @@
+#!/bin/sh
+mkdir -p /var/lib/phosphor-software-manager/hostfw
+PHYP_SECURITY=/var/lib/phosphor-software-manager/hostfw/PHYP-SECURITY
+SIZE=$((1024 * 64))
+PHYP_SECURITY_FILE_SIZE="$(stat -c%s "$PHYP_SECURITY")"
+
+if [ ! -f "$PHYP_SECURITY" ]; then
+    echo "PHYP-SECURITY file not found"
+    NEED_CREATE=true
+elif [ "$PHYP_SECURITY_FILE_SIZE" -ne "$SIZE" ]; then
+    echo "Invalid PHYP-SECURITY size: $PHYP_SECURITY_FILE_SIZE bytes, recreating PHYP-SECURITY file"
+    rm -f "$PHYP_SECURITY"
+    NEED_CREATE=true
+else
+    echo "PHYP-SECURITY file found with correct size: $PHYP_SECURITY_FILE_SIZE bytes"
+    NEED_CREATE=false
+fi
+
+if $NEED_CREATE; then
+    echo "creating new PHYP-SECURITY file"
+    truncate -s "$SIZE" "$PHYP_SECURITY"
+fi
diff --git a/oem/ibm/service_files/scripts/meson.build b/oem/ibm/service_files/scripts/meson.build
index 40742b0..a928a52 100644
--- a/oem/ibm/service_files/scripts/meson.build
+++ b/oem/ibm/service_files/scripts/meson.build
@@ -1,4 +1,8 @@
 install_data(
-    ['create-NVRAM-file', 'create-NVRAM-cksum-file'],
+    [
+        'create-NVRAM-file',
+        'create-NVRAM-cksum-file',
+        'create-PHYP-SECURITY-file',
+    ],
     install_dir: get_option('bindir'),
 )