summaryrefslogtreecommitdiffstats
path: root/security/smc_pa_ctrl
diff options
context:
space:
mode:
authorBryan Buckley <bryan.buckley@ti.com>2011-10-19 19:12:18 -0500
committerJeffrey Tinker <jtinker@google.com>2011-10-20 13:33:52 -0700
commit1d03b509dd304ff330aeda3d419e131febc5712a (patch)
tree7c480f1a2fe504917e938baf6f9474a93adf679f /security/smc_pa_ctrl
parentbf4beebf2cea4ba090fa2ebe2ee4c67a848a826a (diff)
downloadhardware_ti_omap4-1d03b509dd304ff330aeda3d419e131febc5712a.zip
hardware_ti_omap4-1d03b509dd304ff330aeda3d419e131febc5712a.tar.gz
hardware_ti_omap4-1d03b509dd304ff330aeda3d419e131febc5712a.tar.bz2
SMC: Initial release of smc_pa_strl, tf_daemon
These userspace components are used to load secure services in the normal (non-secure) world. The SMC kernel driver is required to use these binaries. Secure services enable certain security features such as hardware-accelerated crypto, secure storage, drm, and much more. Author: "Trusted Logic <smc_support@trusted-logic.com>." Gerrit refuses to accept. Change-Id: Ie81604d3fee31abc319643401c3cc66888f9f848 Signed-off-by: Bryan Buckley <bryan.buckley@ti.com> Signed-off-by: Trusted Logic <smc_support@trusted-logic.com>
Diffstat (limited to 'security/smc_pa_ctrl')
-rw-r--r--security/smc_pa_ctrl/Android.mk25
-rw-r--r--security/smc_pa_ctrl/s_version.h114
-rw-r--r--security/smc_pa_ctrl/smc_pa_ctrl.c219
-rw-r--r--security/smc_pa_ctrl/smc_pa_ctrl_linux.c284
-rw-r--r--security/smc_pa_ctrl/smc_pa_ctrl_os.h61
5 files changed, 703 insertions, 0 deletions
diff --git a/security/smc_pa_ctrl/Android.mk b/security/smc_pa_ctrl/Android.mk
new file mode 100644
index 0000000..fe0bdf4
--- /dev/null
+++ b/security/smc_pa_ctrl/Android.mk
@@ -0,0 +1,25 @@
+ifeq ($(TARGET_BOARD_PLATFORM),omap4)
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_PRELINK_MODULE := false
+LOCAL_ARM_MODE := arm
+
+LOCAL_SRC_FILES:= \
+ smc_pa_ctrl.c smc_pa_ctrl_linux.c
+
+LOCAL_CFLAGS += -DLINUX
+LOCAL_CFLAGS += -D__ANDROID32__
+
+ifdef S_VERSION_BUILD
+LOCAL_CFLAGS += -DS_VERSION_BUILD=$(S_VERSION_BUILD)
+endif
+
+LOCAL_CFLAGS += -I $(LOCAL_PATH)/../tf_sdk/include/
+
+LOCAL_MODULE:= smc_pa_ctrl
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_EXECUTABLE)
+endif
diff --git a/security/smc_pa_ctrl/s_version.h b/security/smc_pa_ctrl/s_version.h
new file mode 100644
index 0000000..139c11f
--- /dev/null
+++ b/security/smc_pa_ctrl/s_version.h
@@ -0,0 +1,114 @@
+/**
+ * Copyright(c) 2011 Trusted Logic. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name Trusted Logic nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __S_VERSION_H__
+#define __S_VERSION_H__
+
+/*
+ * Usage: define S_VERSION_BUILD on the compiler's command line.
+ *
+ * Then set:
+ * - S_VERSION_OS
+ * - S_VERSION_PLATFORM
+ * - S_VERSION_MAIN
+ * - S_VERSION_ENG is optional
+ * - S_VERSION_PATCH is optional
+ * - S_VERSION_BUILD = 0 if S_VERSION_BUILD not defined or empty
+ */
+#if defined(WIN32)
+#define S_VERSION_OS "W" /* "W" for Windows PC (XP, Vista…) */
+#define S_VERSION_PLATFORM "X" /* "X" for ix86 PC simulators */
+#elif defined(__ANDROID32__)
+#define S_VERSION_OS "A" /* "A" for Android */
+#define S_VERSION_PLATFORM "G" /* "G" for 4430 */
+#elif defined(LINUX)
+#define S_VERSION_OS "L" /* "L" for Linux */
+#define S_VERSION_PLATFORM "X" /* "X" for ix86 PC simulators */
+#else
+#define S_VERSION_OS "X" /* "X" for Secure-World */
+#define S_VERSION_PLATFORM "G" /* "G" for 4430 */
+#endif
+
+/*
+ * This version number must be updated for each new release
+ */
+#define S_VERSION_MAIN "01.04"
+#define S_VERSION_RESOURCE 1,4,0,S_VERSION_BUILD
+
+/*
+* If this is a patch or engineering version use the following
+* defines to set the version number. Else set these values to 0.
+*/
+#define S_VERSION_PATCH 11
+#define S_VERSION_ENG 0
+
+#ifdef S_VERSION_BUILD
+/* TRICK: detect if S_VERSION is defined but empty */
+#if 0 == S_VERSION_BUILD-0
+#undef S_VERSION_BUILD
+#define S_VERSION_BUILD 0
+#endif
+#else
+/* S_VERSION_BUILD is not defined */
+#define S_VERSION_BUILD 0
+#endif
+
+#define __STRINGIFY(X) #X
+#define __STRINGIFY2(X) __STRINGIFY(X)
+
+#if S_VERSION_ENG != 0
+#define _S_VERSION_ENG "e" __STRINGIFY2(S_VERSION_ENG)
+#else
+#define _S_VERSION_ENG ""
+#endif
+
+#if S_VERSION_PATCH != 0
+#define _S_VERSION_PATCH "p" __STRINGIFY2(S_VERSION_PATCH)
+#else
+#define _S_VERSION_PATCH ""
+#endif
+
+#if !defined(NDEBUG) || defined(_DEBUG)
+#define S_VERSION_VARIANT "D "
+#else
+#define S_VERSION_VARIANT " "
+#endif
+
+#define S_VERSION_STRING \
+ "SMC" \
+ S_VERSION_OS \
+ S_VERSION_PLATFORM \
+ S_VERSION_MAIN \
+ _S_VERSION_PATCH \
+ _S_VERSION_ENG \
+ "." __STRINGIFY2(S_VERSION_BUILD) " " \
+ S_VERSION_VARIANT
+
+#endif /* __S_VERSION_H__ */
diff --git a/security/smc_pa_ctrl/smc_pa_ctrl.c b/security/smc_pa_ctrl/smc_pa_ctrl.c
new file mode 100644
index 0000000..93db1a5
--- /dev/null
+++ b/security/smc_pa_ctrl/smc_pa_ctrl.c
@@ -0,0 +1,219 @@
+/**
+ * Copyright(c) 2011 Trusted Logic. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name Trusted Logic nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "s_type.h"
+#include "s_version.h"
+#include "smc_pa_ctrl_os.h"
+
+
+/*---------------------------------------------------------------------------
+ * Utility Functions
+ *---------------------------------------------------------------------------*/
+
+static void printUsage(bool bSuccess)
+{
+#ifdef BOOT_TIME_PA
+ printf("usage : smc_boot_pa_ctrl <options> [command]\n");
+ printf(" Options:\n");
+ printf(" -h, --help: Print this help\n");
+ printf(" Commands:\n");
+ printf(" -c <conf> : Configuration file path\n");
+ printf(" start <pa_file_path>: load and start the SMC PA\n");
+ printf("\n");
+#else
+ printf("usage : smc_pa_ctrl <options> [command]\n");
+ printf(" Options:\n");
+ printf(" -h, --help: Print this help\n");
+ printf(" Commands:\n");
+ printf(" -c <conf> : Configuration file path\n");
+ printf(" start <pa_file_path>: load and start the SMC PA\n");
+ printf(" stop: stop the SMC PA\n");
+ printf("\n");
+#endif
+
+ exit(bSuccess ? 0 : 1);
+}
+
+
+
+/*---------------------------------------------------------------------------
+ * Application Entry-Point
+ *---------------------------------------------------------------------------*/
+
+int main(int argc, char *argv[])
+{
+ char* pPAFileName = NULL;
+ char* pConfFileName = NULL;
+ int nCommand = SCX_SMC_PA_CTRL_NONE;
+ int nStatus = 0;
+
+#ifdef BOOT_TIME_PA
+ printf("SMC BOOT PA Control\n");
+ printf(S_VERSION_STRING "\n");
+#else
+ printf("SMC PA Control\n");
+ printf(S_VERSION_STRING "\n");
+#endif
+
+ /* Skip program name */
+ argv ++;
+ argc --;
+
+ while (argc != 0)
+ {
+ if (argv[0][0] == '-')
+ {
+ /*
+ * This is an option
+ */
+
+ if ((strcmp(argv[0], "--help") == 0) || (strcmp(argv[0], "-h") == 0))
+ {
+ printUsage(true);
+ }
+ else if (strcmp(argv[0], "-c") == 0)
+ {
+ /* Next argument */
+ argc --;
+ argv ++;
+
+ if (argc <= 0)
+ {
+ printf("Missing argument for the option '-c'\n\n");
+ printUsage(false);
+ }
+
+ pConfFileName = malloc(strlen(argv[0]) + 1);
+ if (pConfFileName == NULL)
+ {
+ printf("Out of memory\n");
+ exit(2);
+ }
+
+ strcpy(pConfFileName, argv[0]);
+ }
+ else
+ {
+ printf("Invalid option [%s]\n\n", argv[0]);
+ printUsage(false);
+ }
+ }
+ else
+ {
+ /*
+ * This is a command
+ */
+ if (strcmp(argv[0], "start") == 0)
+ {
+ /* Next argument */
+ argc --;
+ argv ++;
+
+ if (argc <= 0)
+ {
+ printf("Missing argument for the command 'start'\n\n");
+ printUsage(false);
+ }
+
+ pPAFileName = malloc(strlen(argv[0]) + 1);
+ if (pPAFileName == NULL)
+ {
+ printf("Out of memory\n");
+ exit(2);
+ }
+
+ strcpy(pPAFileName, argv[0]);
+
+ nCommand = SCX_SMC_PA_CTRL_START;
+ }
+#ifndef BOOT_TIME_PA
+ else if (strcmp(argv[0], "stop") == 0)
+ {
+ nCommand = SCX_SMC_PA_CTRL_STOP;
+ }
+#endif
+ else
+ {
+ printf("Invalid command [%s]\n\n", argv[0]);
+ printUsage(false);
+ }
+ }
+
+ argc --;
+ argv ++;
+ }
+
+ switch (nCommand)
+ {
+ case SCX_SMC_PA_CTRL_START:
+ /*
+ * Load and execute the SMC PA
+ */
+
+ if (pConfFileName == NULL)
+ {
+ printf("Configuration file path is missing !\n");
+ printUsage(false);
+ }
+
+ nStatus = smcPAStart(pPAFileName, pConfFileName);
+ break;
+
+#ifndef BOOT_TIME_PA
+ case SCX_SMC_PA_CTRL_STOP:
+ /*
+ * Stop the SMC PA
+ */
+
+ if (pConfFileName != NULL)
+ {
+ printf("Configuration file cannot be used with the 'stop' command\n\n");
+ printUsage(false);
+ }
+
+ nStatus = smcPAStop();
+ break;
+#endif
+
+ default:
+ printf("No command specified\n\n");
+ printUsage(false);
+ break;
+ }
+
+ free(pPAFileName);
+ free(pConfFileName);
+
+ return nStatus;
+}
diff --git a/security/smc_pa_ctrl/smc_pa_ctrl_linux.c b/security/smc_pa_ctrl/smc_pa_ctrl_linux.c
new file mode 100644
index 0000000..a0eab92
--- /dev/null
+++ b/security/smc_pa_ctrl/smc_pa_ctrl_linux.c
@@ -0,0 +1,284 @@
+/**
+ * Copyright(c) 2011 Trusted Logic. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name Trusted Logic nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#ifndef WIN32
+#include <sys/ioctl.h>
+#include <unistd.h>
+#endif
+#include <fcntl.h>
+#include <errno.h>
+
+#include "smc_pa_ctrl_os.h"
+#include "s_type.h"
+
+#ifndef BOOT_TIME_PA
+#define SMC_DRIVER_NAME "/dev/tf_ctrl"
+#else
+#define SMC_DRIVER_NAME "/dev/supervisor"
+#endif
+
+#define IOCTL_SCX_SMC_PA_CTRL \
+ _IOWR('z', 0xFF, SCX_SMC_PA_CTRL)
+
+
+typedef struct
+{
+ uint32_t nPACommand; /* SCX_PA_CTRL_xxx */
+
+ /* For the SCX_SMC_PA_CTRL_START command only */
+ uint32_t nPASize; /* PA buffer size */
+ uint8_t* pPABuffer; /* PA buffer */
+ uint32_t nConfSize; /* Configuration buffer size, including the */
+ /* zero-terminating character (may be zero) */
+ uint8_t* pConfBuffer; /* Configuration buffer, zero-terminated */
+ /* string (may be NULL) */
+} SCX_SMC_PA_CTRL;
+
+static uint8_t* readLocalFile(const char* pFileName, uint32_t* pnBufferSize, bool bIsString)
+{
+ uint8_t* pBuffer = NULL;
+ FILE* pFile = NULL;
+ uint32_t nBytesToAllocate;
+ int nBytesRead;
+ int nResult;
+
+ struct stat statFile;
+
+ *pnBufferSize = 0;
+
+ if (stat(pFileName, &statFile) != 0)
+ {
+ printf("Cannot read '%s' !\n", pFileName);
+ goto error;
+ }
+
+ nBytesToAllocate = statFile.st_size;
+
+ if (bIsString)
+ {
+ /* Allocate enough room for the zero-terminated string */
+ nBytesToAllocate ++;
+ }
+
+ pBuffer = (uint8_t*)malloc(nBytesToAllocate);
+ if (pBuffer == NULL)
+ {
+ printf("Out of memory for the buffer [%u bytes] !\n", nBytesToAllocate);
+ goto error;
+ }
+
+ pFile = fopen(pFileName, "rb");
+ if (pFile == NULL)
+ {
+ printf("Cannot open '%s' !\n", pFileName);
+ goto error;
+ }
+
+ nBytesRead = fread(pBuffer, 1, statFile.st_size, pFile);
+
+ if (nBytesRead != statFile.st_size)
+ {
+ printf("Cannot read bytes from '%s' [%i] !\n", pFileName, nBytesRead);
+ goto error;
+ }
+
+ nResult = fclose(pFile);
+
+ pFile = NULL;
+
+ if (nResult != 0)
+ {
+ printf("Cannot close '%s' !\n", pFileName);
+ goto error;
+ }
+
+ if (bIsString)
+ {
+ /* Set the zero-terminated string */
+ pBuffer[nBytesRead] = 0;
+ }
+
+ *pnBufferSize = nBytesToAllocate;
+
+ return pBuffer;
+
+ /*
+ * Error handling.
+ */
+
+error:
+ free(pBuffer);
+ if (pFile != NULL)
+ {
+ fclose(pFile);
+ }
+
+ return NULL;
+}
+
+
+
+
+int smcPAStart(const char* pPAFileName, const char* pConfFileName)
+{
+ int fd = 0;
+ int nStatus = 0;
+ SCX_SMC_PA_CTRL paCtrl;
+
+ memset(&paCtrl, 0, sizeof(SCX_SMC_PA_CTRL));
+ paCtrl.nPACommand = SCX_SMC_PA_CTRL_START;
+
+#ifdef BOOT_TIME_PA
+ printf("Starting the SMC BOOT PA '%s'. Driver name : %s", pPAFileName, SMC_DRIVER_NAME);
+#else
+ printf("Starting the SMC PA '%s'", pPAFileName);
+#endif
+ if (pConfFileName != NULL)
+ {
+ printf(" with the Configuration file '%s'", pConfFileName);
+ }
+ else
+ {
+ printf("Configuration file is mandatory\n");
+ nStatus = -1;
+ goto end;
+ }
+ printf("...\n");
+
+ paCtrl.pPABuffer = readLocalFile(pPAFileName, &paCtrl.nPASize, false);
+ if (paCtrl.pPABuffer == NULL)
+ {
+ nStatus = -2;
+ goto end;
+ }
+
+ paCtrl.pConfBuffer = readLocalFile(pConfFileName, &paCtrl.nConfSize, false);
+ if (paCtrl.pConfBuffer == NULL)
+ {
+ nStatus = -4;
+ goto end;
+ }
+
+ #ifndef WIN32
+ fd = open(SMC_DRIVER_NAME, O_RDWR, 0);
+ #endif
+ if (fd == -1)
+ {
+ nStatus = errno;
+#ifdef BOOT_TIME_PA
+ printf("Boot time driver open failed [%d] !\n", nStatus);
+#else
+ printf("SMC driver open failed [%d] !\n", nStatus);
+#endif
+ goto end;
+ }
+
+ #ifndef WIN32
+ nStatus = ioctl(fd, IOCTL_SCX_SMC_PA_CTRL, &paCtrl);
+ #endif
+ if (nStatus != 0)
+ {
+ nStatus = errno;
+#ifdef BOOT_TIME_PA
+ printf("Starting the BOOT TIME PA failed [%d] !\n", nStatus);
+#else
+ printf("Starting the SMC PA failed [%d] !\n", nStatus);
+#endif
+ goto end;
+ }
+
+#ifdef BOOT_TIME_PA
+ printf("Boot time PA '%s' has been launched successfully.\n", pPAFileName);
+#else
+ printf("Starting the SMC PA '%s': Done\n", pPAFileName);
+#endif
+
+end:
+ if (fd != 0)
+ {
+ #ifndef WIN32
+ close(fd);
+ #endif
+ }
+
+ free(paCtrl.pPABuffer);
+ free(paCtrl.pConfBuffer);
+
+ return nStatus;
+}
+
+int smcPAStop(void)
+{
+ int fd = 0;
+ int nStatus = 0;
+ SCX_SMC_PA_CTRL paCtrl;
+
+ memset(&paCtrl, 0, sizeof(SCX_SMC_PA_CTRL));
+ paCtrl.nPACommand = SCX_SMC_PA_CTRL_STOP;
+
+ printf("Stopping the SMC PA...\n");
+
+ #ifndef WIN32
+ fd = open(SMC_DRIVER_NAME, O_RDWR, 0);
+ #endif
+ if (fd == 0)
+ {
+ nStatus = errno;
+ printf("SMC driver open failed [%d] !\n", nStatus);
+ goto end;
+ }
+
+ #ifndef WIN32
+ nStatus = ioctl(fd, IOCTL_SCX_SMC_PA_CTRL, &paCtrl);
+ #endif
+ if (nStatus != 0)
+ {
+ printf("Stopping the SMC PA failed [%d] !\n", nStatus);
+ goto end;
+ }
+
+ printf("Stopping the SMC PA: Done\n");
+
+end:
+
+ if (fd != 0)
+ {
+ #ifndef WIN32
+ close(fd);
+ #endif
+ }
+
+ return nStatus;
+}
diff --git a/security/smc_pa_ctrl/smc_pa_ctrl_os.h b/security/smc_pa_ctrl/smc_pa_ctrl_os.h
new file mode 100644
index 0000000..4e087e5
--- /dev/null
+++ b/security/smc_pa_ctrl/smc_pa_ctrl_os.h
@@ -0,0 +1,61 @@
+/**
+ * Copyright(c) 2011 Trusted Logic. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name Trusted Logic nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SMC_PA_CTRL_OH_H__
+#define _SMC_PA_CTRL_OH_H__
+
+#ifdef __SYMBIAN32__
+#define EXOS_TRACE_ACTIVE
+#define printf RDebugPrintf
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/*
+ * The SCX PA Control types.
+ */
+#define SCX_SMC_PA_CTRL_NONE 0
+#define SCX_SMC_PA_CTRL_START 1
+#define SCX_SMC_PA_CTRL_STOP 2
+
+
+
+int smcPAStart(const char* pPAFileName, const char* pConfFileName);
+int smcPAStop(void);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SMC_PA_CTRL_OH_H__ */