summaryrefslogtreecommitdiff
path: root/BraswellPlatformPkg/Common/Library/Ksc
diff options
context:
space:
mode:
authorGuo Mang <mang.guo@intel.com>2016-08-03 10:08:22 +0800
committerGuo Mang <mang.guo@intel.com>2016-08-04 10:30:50 +0800
commitcc95732a88d815178f22793e13b3de8e4073e77b (patch)
tree2d81a3b6af7e67c0a8dacd578e170d2b7a80d428 /BraswellPlatformPkg/Common/Library/Ksc
parent40c3a7f1e81582b5a8279d405b5cb6ca80d99c42 (diff)
downloadedk2-platforms-cc95732a88d815178f22793e13b3de8e4073e77b.tar.xz
BraswellPlatformPkg: Move Library to Common/Library
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Guo Mang <mang.guo@intel.com> Reviewed-by: David Wei <david.wei@intel.com>
Diffstat (limited to 'BraswellPlatformPkg/Common/Library/Ksc')
-rw-r--r--BraswellPlatformPkg/Common/Library/Ksc/Dxe/DxeKscLib.c184
-rw-r--r--BraswellPlatformPkg/Common/Library/Ksc/Dxe/DxeKscLib.h26
-rw-r--r--BraswellPlatformPkg/Common/Library/Ksc/Dxe/DxeKscLib.inf34
-rw-r--r--BraswellPlatformPkg/Common/Library/Ksc/Pei/PeiKsc.h31
-rw-r--r--BraswellPlatformPkg/Common/Library/Ksc/Pei/PeiKscLib.c176
-rw-r--r--BraswellPlatformPkg/Common/Library/Ksc/Pei/PeiKscLib.inf34
-rw-r--r--BraswellPlatformPkg/Common/Library/Ksc/Smm/SmmKscLib.c217
-rw-r--r--BraswellPlatformPkg/Common/Library/Ksc/Smm/SmmKscLib.h24
-rw-r--r--BraswellPlatformPkg/Common/Library/Ksc/Smm/SmmKscLib.inf37
9 files changed, 763 insertions, 0 deletions
diff --git a/BraswellPlatformPkg/Common/Library/Ksc/Dxe/DxeKscLib.c b/BraswellPlatformPkg/Common/Library/Ksc/Dxe/DxeKscLib.c
new file mode 100644
index 0000000000..d4f5a59709
--- /dev/null
+++ b/BraswellPlatformPkg/Common/Library/Ksc/Dxe/DxeKscLib.c
@@ -0,0 +1,184 @@
+/** @file
+ Boot service DXE KSC library implementation.
+
+ Copyright (c) 1999 - 2015, Intel Corporation. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include "KscLib.h"
+#include "DxeKsclib.h"
+
+BOOLEAN mDxeKscLibInitialized = FALSE;
+
+//
+// Function implemenations
+//
+/**
+ Initialize the library.
+ Read KSC Command port (0x66), if found 0xff means no EC exists else EC exists
+
+ @return EFI_SUCCESS KscLib is successfully initialized.
+
+**/
+EFI_STATUS
+InitializeKscLib (
+ VOID
+ )
+{
+ if (IoRead8(KSC_C_PORT) == 0xff) {
+ mDxeKscLibInitialized = FALSE;
+ return EFI_DEVICE_ERROR; // EC Doesn't exists
+ }
+
+ mDxeKscLibInitialized = TRUE;
+
+ return EFI_SUCCESS; // EC exists
+}
+
+/**
+ Sends command to Keyboard System Controller.
+
+ @param Command Command byte to send
+
+ @retval EFI_SUCCESS Command success
+ @retval EFI_DEVICE_ERROR Command error
+
+**/
+EFI_STATUS
+SendKscCommand (
+ UINT8 Command
+ )
+{
+ UINTN Index;
+ UINT8 KscStatus = 0;
+
+ Index = 0;
+
+ //
+ // Wait for KSC to be ready (with a timeout)
+ //
+ ReceiveKscStatus (&KscStatus);
+ while (((KscStatus & KSC_S_IBF) != 0) && (Index < KSC_TIME_OUT)) {
+ gBS->Stall (15);
+ ReceiveKscStatus (&KscStatus);
+ Index++;
+ }
+ if (Index >= KSC_TIME_OUT) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ //
+ // Send the KSC command
+ //
+ DEBUG ((EFI_D_INFO, "SendKscCommand: command = %x\n", Command));
+ IoWrite8(KSC_C_PORT, Command);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Receives status from Keyboard System Controller.
+
+ @param Status Status byte to receive
+
+ @retval EFI_SUCCESS Always success
+
+**/
+EFI_STATUS
+ReceiveKscStatus (
+ UINT8 *KscStatus
+ )
+{
+ //
+ // Read and return the status
+ //
+ *KscStatus = IoRead8(KSC_C_PORT);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Sends data to Keyboard System Controller.
+
+ @param Data Data byte to send
+
+ @retval EFI_SUCCESS Success
+ @retval EFI_TIMEOUT Timeout
+ @retval Other Failed
+
+**/
+EFI_STATUS
+SendKscData (
+ UINT8 Data
+ )
+{
+ UINTN Index;
+ UINT8 KscStatus;
+
+ Index = 0;
+
+ //
+ // Wait for KSC to be ready (with a timeout)
+ //
+ ReceiveKscStatus (&KscStatus);
+ while (((KscStatus & KSC_S_IBF) != 0) && (Index < KSC_TIME_OUT)) {
+ gBS->Stall (15);
+ ReceiveKscStatus (&KscStatus);
+ Index++;
+ }
+ if (Index >= KSC_TIME_OUT) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ IoWrite8(KSC_D_PORT, Data);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Receives data from Keyboard System Controller.
+
+ @param Data Data byte received
+
+ @retval EFI_SUCCESS Read success
+ @retval EFI_DEVICE_ERROR Read error
+
+**/
+EFI_STATUS
+ReceiveKscData (
+ UINT8 *Data
+ )
+{
+ UINTN Index;
+ UINT8 KscStatus;
+
+ Index = 0;
+
+ //
+ // Wait for KSC to be ready (with a timeout)
+ //
+ ReceiveKscStatus (&KscStatus);
+ while (((KscStatus & KSC_S_OBF) == 0) && (Index < KSC_TIME_OUT)) {
+ gBS->Stall (15);
+ ReceiveKscStatus (&KscStatus);
+ Index++;
+ }
+ if (Index >= KSC_TIME_OUT) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ //
+ // Read KSC data and return
+ //
+ *Data = IoRead8(KSC_D_PORT);
+
+ return EFI_SUCCESS;
+}
diff --git a/BraswellPlatformPkg/Common/Library/Ksc/Dxe/DxeKscLib.h b/BraswellPlatformPkg/Common/Library/Ksc/Dxe/DxeKscLib.h
new file mode 100644
index 0000000000..5d1d7ee59d
--- /dev/null
+++ b/BraswellPlatformPkg/Common/Library/Ksc/Dxe/DxeKscLib.h
@@ -0,0 +1,26 @@
+/** @file
+ Platform Info Driver.
+
+ Copyright (c) 1999 - 2015, Intel Corporation. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _PLATFORM_INFO_DRIVER_H_
+#define _PLATFORM_INFO_DRIVER_H_
+
+#include <Library/IoLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseLib.h>
+#include <Library/HobLib.h>
+#include <Protocol/CpuIo2.h>
+#include <Library/UefiBootServicesTableLib.h>
+
+#endif
diff --git a/BraswellPlatformPkg/Common/Library/Ksc/Dxe/DxeKscLib.inf b/BraswellPlatformPkg/Common/Library/Ksc/Dxe/DxeKscLib.inf
new file mode 100644
index 0000000000..ac575975a1
--- /dev/null
+++ b/BraswellPlatformPkg/Common/Library/Ksc/Dxe/DxeKscLib.inf
@@ -0,0 +1,34 @@
+## @file
+# DxeKscLib Localized Abstract and Description Content
+#
+# Copyright (c) 1999 - 2015, Intel Corporation. All rights reserved.<BR>
+#
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php.
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = DxeKscLib
+ FILE_GUID = C8AE8AF6-ABB4-44b1-A679-E218E1782799
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = DxeKscLib
+
+[Sources]
+ DxeKscLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ BraswellPlatformPkg/BraswellPlatformPkg.dec
+ IntelFrameworkPkg/IntelFrameworkPkg.dec
+
+[LibraryClasses]
+ DebugLib
+ IoLib
diff --git a/BraswellPlatformPkg/Common/Library/Ksc/Pei/PeiKsc.h b/BraswellPlatformPkg/Common/Library/Ksc/Pei/PeiKsc.h
new file mode 100644
index 0000000000..fd4a16d503
--- /dev/null
+++ b/BraswellPlatformPkg/Common/Library/Ksc/Pei/PeiKsc.h
@@ -0,0 +1,31 @@
+/** @file
+ This file contains Multi Platform PPI information.
+
+ Copyright (c) 1999 - 2015, Intel Corporation. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _PEI_MULTIPLATFORM_PPI_H
+#define _PEI_MULTIPLATFORM_PPI_H
+
+//
+// Include files
+//
+#include <Library/IoLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseLib.h>
+#include "PeiKscLib.h"
+
+#ifndef STALL_ONE_MICRO_SECOND
+#define STALL_ONE_MICRO_SECOND 1
+#endif
+
+#endif
diff --git a/BraswellPlatformPkg/Common/Library/Ksc/Pei/PeiKscLib.c b/BraswellPlatformPkg/Common/Library/Ksc/Pei/PeiKscLib.c
new file mode 100644
index 0000000000..6d02a7293e
--- /dev/null
+++ b/BraswellPlatformPkg/Common/Library/Ksc/Pei/PeiKscLib.c
@@ -0,0 +1,176 @@
+/** @file
+ Ksc settings in PEI phase.
+
+ Copyright (c) 1999 - 2015, Intel Corporation. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include "PeiKsc.h"
+
+//
+// Function implemenations
+//
+/**
+ The PEI function requires CPU IO protocol, through which it reads KSC Command port
+ and ensures that EC exists or not.
+
+ Retval EFI_SUCCESS EC found and KscLib is successfully initialized.
+ Retval EFI_DEVICE_ERROR EC is NOT present on the system.
+
+**/
+EFI_STATUS
+InitializeKscLib ( )
+{
+ //
+ // Read from EC Command/Status port (0x66), if value is 0xFF means EC dose not exist.
+ //
+ if (IoRead8 (KSC_C_PORT) == 0xFF) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ return EFI_SUCCESS;
+
+}
+
+/**
+ Sends command to Keyboard System Controller.
+
+ @param[in] Command Command byte to send
+
+ @retval EFI_SUCCESS Command success
+ @retval EFI_DEVICE_ERROR Command error
+ @retval EFI_TIMEOUT Command timeout
+
+**/
+EFI_STATUS
+SendKscCommand (
+ IN UINT8 Command
+ )
+{
+ UINTN Index = 0;
+ UINT8 KscStatus = 0;
+
+ //
+ // Wait for KSC to be ready (with a timeout)
+ //
+ ReceiveKscStatus (&KscStatus);
+ while (((KscStatus & KSC_S_IBF) != 0) && (Index < KSC_TIME_OUT)) {
+ ReceiveKscStatus (&KscStatus);
+ Index++;
+ }
+
+ if (Index >= KSC_TIME_OUT) {
+ DEBUG ((EFI_D_INFO, "SendKscCommand Time Out Error\n"));
+ return EFI_TIMEOUT;
+ }
+ //
+ // Send the KSC command
+ //
+ IoWrite8 (KSC_C_PORT, Command);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Receives status from Keyboard System Controller.
+
+ @param[out] KscStatus Status byte to receive
+
+ @retval EFI_DEVICE_ERROR Ksc library has not initialized yet or KSC not present
+ @retval EFI_SUCCESS Get KSC status successfully
+
+**/
+EFI_STATUS
+ReceiveKscStatus (
+ OUT UINT8 *KscStatus
+ )
+{
+ *KscStatus = IoRead8 (KSC_C_PORT);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Sends data to Keyboard System Controller.
+
+ @param[in] Data Data byte to send
+
+ @retval EFI_SUCCESS Success
+ @retval EFI_DEVICE_ERROR Error
+ @retval EFI_TIMEOUT Command timeout
+
+**/
+EFI_STATUS
+SendKscData (
+ IN UINT8 Data
+ )
+{
+ UINTN Index = 0;
+ UINT8 KscStatus = 0;
+ //
+ // Wait for KSC to be ready (with a timeout)
+ //
+ ReceiveKscStatus (&KscStatus);
+ while (((KscStatus & KSC_S_IBF) != 0) && (Index < KSC_TIME_OUT)) {
+ ReceiveKscStatus (&KscStatus);
+ Index++;
+ }
+
+ if (Index >= KSC_TIME_OUT) {
+ DEBUG ((EFI_D_INFO, "SendKscData Time Out Error\n"));
+ return EFI_TIMEOUT;
+ }
+ //
+ // Write Data at EC Port (0x62)
+ //
+ IoWrite8 (KSC_D_PORT, Data);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Receives data from Keyboard System Controller.
+
+ @param[out] Data Data byte received
+
+ @retval EFI_SUCCESS Read success
+ @retval EFI_DEVICE_ERROR Read error
+ @retval EFI_TIMEOUT Command timeout
+
+**/
+EFI_STATUS
+ReceiveKscData (
+ OUT UINT8 *Data
+ )
+{
+ UINTN Index = 0;
+ UINT8 KscStatus = 0;
+ //
+ // Wait for KSC to be ready (with a timeout)
+ //
+ ReceiveKscStatus (&KscStatus);
+ while (((KscStatus & KSC_S_OBF) == 0) && (Index < KSC_TIME_OUT)) {
+ ReceiveKscStatus (&KscStatus);
+ Index++;
+ }
+
+ if (Index >= KSC_TIME_OUT) {
+ DEBUG ((EFI_D_INFO, "ReceiveKscData Time Out Error\n"));
+ return EFI_TIMEOUT;
+ }
+ //
+ // Read KSC data and return
+ //
+ *Data = IoRead8 (KSC_D_PORT);
+
+ return EFI_SUCCESS;
+}
+
diff --git a/BraswellPlatformPkg/Common/Library/Ksc/Pei/PeiKscLib.inf b/BraswellPlatformPkg/Common/Library/Ksc/Pei/PeiKscLib.inf
new file mode 100644
index 0000000000..a972b4aa20
--- /dev/null
+++ b/BraswellPlatformPkg/Common/Library/Ksc/Pei/PeiKscLib.inf
@@ -0,0 +1,34 @@
+## @file
+# Component description file for PEI KSC library
+#
+# Copyright (c) 1999 - 2015, Intel Corporation. All rights reserved.<BR>
+#
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php.
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PeiKscLib
+ FILE_GUID = CD537150-B828-477d-935E-C3853950FC75
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = PeiKscLib
+
+[Sources]
+ PeiKscLib.c
+ PeiKsc.h
+
+[Packages]
+ MdePkg/MdePkg.dec
+ BraswellPlatformPkg/BraswellPlatformPkg.dec
+
+[LibraryClasses]
+ DebugLib
+ IoLib
diff --git a/BraswellPlatformPkg/Common/Library/Ksc/Smm/SmmKscLib.c b/BraswellPlatformPkg/Common/Library/Ksc/Smm/SmmKscLib.c
new file mode 100644
index 0000000000..dc553ce523
--- /dev/null
+++ b/BraswellPlatformPkg/Common/Library/Ksc/Smm/SmmKscLib.c
@@ -0,0 +1,217 @@
+/** @file
+ SMM KSC library implementation.
+
+ Copyright (c) 1999 - 2015, Intel Corporation. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include "SmmKscLib.h"
+
+BOOLEAN mSmmKscLibInitialized = FALSE;
+
+//
+// Function implemenations
+//
+/**
+ Initialize the library.
+ The SMM library only requires SMM IO library and has no initialization.
+ However, this must be called prior to use of any other KSC library functions
+ for future compatibility.
+
+ @Return EFI_SUCCESS KscLib is successfully initialized.
+
+**/
+EFI_STATUS
+InitializeKscLib (
+ VOID
+ )
+{
+ //
+ // Fail if EC doesn't exist.
+ //
+ if (SmmIoRead8(KSC_C_PORT) == 0xff) {
+ mSmmKscLibInitialized = FALSE;
+ return EFI_DEVICE_ERROR;
+ }
+
+ mSmmKscLibInitialized = TRUE;
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Sends command to Keyboard System Controller.
+
+ @param Command Command byte to send
+
+ @retval EFI_SUCCESS Command success
+ @retval EFI_DEVICE_ERROR Command error
+
+**/
+EFI_STATUS
+SendKscCommand (
+ UINT8 Command
+ )
+{
+ UINTN Index;
+ UINT8 KscStatus = 0;
+
+ //
+ // Verify if KscLib has been initialized, NOT if EC dose not exist.
+ //
+ if (mSmmKscLibInitialized == FALSE) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ Index = 0;
+
+ //
+ // Wait for KSC to be ready (with a timeout)
+ //
+ ReceiveKscStatus (&KscStatus);
+ while (((KscStatus & KSC_S_IBF) != 0) && (Index < KSC_TIME_OUT)) {
+ SmmStall (15);
+ ReceiveKscStatus (&KscStatus);
+ Index++;
+ }
+ if (Index >= KSC_TIME_OUT) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ //
+ // Send the KSC command
+ //
+ SmmIoWrite8 (KSC_C_PORT, Command);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Receives status from Keyboard System Controller.
+
+ @param KscStatus Status byte to receive
+
+ @Return EFI_SUCCESS Always success
+
+**/
+EFI_STATUS
+ReceiveKscStatus (
+ UINT8 *KscStatus
+ )
+{
+ //
+ // Verify if KscLib has been initialized, NOT if EC dose not exist.
+ //
+ if (mSmmKscLibInitialized == FALSE) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ //
+ // Read and return the status
+ //
+ *KscStatus = SmmIoRead8 (KSC_C_PORT);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Sends data to Keyboard System Controller.
+
+ @param Data Data byte to send
+
+ @retval EFI_SUCCESS Success
+ @retval EFI_DEVICE_ERROR Error
+
+**/
+EFI_STATUS
+SendKscData (
+ UINT8 Data
+ )
+{
+ UINTN Index;
+ UINT8 KscStatus;
+
+ //
+ // Verify if KscLib has been initialized, NOT if EC dose not exist.
+ //
+ if (mSmmKscLibInitialized == FALSE) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ Index = 0;
+
+ //
+ // Wait for KSC to be ready (with a timeout)
+ //
+ ReceiveKscStatus (&KscStatus);
+ while (((KscStatus & KSC_S_IBF) != 0) && (Index < KSC_TIME_OUT)) {
+ SmmStall (15);
+ ReceiveKscStatus (&KscStatus);
+ Index++;
+ }
+ if (Index >= KSC_TIME_OUT) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ //
+ // Send the data and return
+ //
+ SmmIoWrite8 (KSC_D_PORT, Data);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Receives data from Keyboard System Controller.
+
+ @param Data Data byte received
+
+ @retval EFI_SUCCESS Read success
+ @retval EFI_DEVICE_ERROR Read error
+
+**/
+EFI_STATUS
+ReceiveKscData (
+ UINT8 *Data
+ )
+{
+ UINTN Index;
+ UINT8 KscStatus;
+
+ //
+ // Verify if KscLib has been initialized, NOT if EC dose not exist.
+ //
+ if (mSmmKscLibInitialized == FALSE) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ Index = 0;
+
+ //
+ // Wait for KSC to be ready (with a timeout)
+ //
+ ReceiveKscStatus (&KscStatus);
+ while (((KscStatus & KSC_S_OBF) == 0) && (Index < KSC_TIME_OUT)) {
+ SmmStall (15);
+ ReceiveKscStatus (&KscStatus);
+ Index++;
+ }
+ if (Index >= KSC_TIME_OUT) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ //
+ // Read KSC data and return
+ //
+ *Data = SmmIoRead8 (KSC_D_PORT);
+
+ return EFI_SUCCESS;
+}
diff --git a/BraswellPlatformPkg/Common/Library/Ksc/Smm/SmmKscLib.h b/BraswellPlatformPkg/Common/Library/Ksc/Smm/SmmKscLib.h
new file mode 100644
index 0000000000..52c626ed98
--- /dev/null
+++ b/BraswellPlatformPkg/Common/Library/Ksc/Smm/SmmKscLib.h
@@ -0,0 +1,24 @@
+/** @file
+ KSC Library from smm support
+
+ Copyright (c) 1999 - 2015, Intel Corporation. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _PLATFORM_INFO_DRIVER_H_
+#define _PLATFORM_INFO_DRIVER_H_
+
+#include "KscLib.h"
+#include <Library/DebugLib.h>
+#include "Library/SmmIoLib.h"
+#include "Library/StallSmmLib.h"
+
+#endif
diff --git a/BraswellPlatformPkg/Common/Library/Ksc/Smm/SmmKscLib.inf b/BraswellPlatformPkg/Common/Library/Ksc/Smm/SmmKscLib.inf
new file mode 100644
index 0000000000..d716dabf7d
--- /dev/null
+++ b/BraswellPlatformPkg/Common/Library/Ksc/Smm/SmmKscLib.inf
@@ -0,0 +1,37 @@
+## @file
+# Component description file for internal graphics device library
+#
+# Copyright (c) 1999 - 2015, Intel Corporation. All rights reserved.<BR>
+#
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php.
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = SmmKscLib
+ FILE_GUID = EA30D07C-2AE7-454e-AE1F-12FBF9BD3A62
+ MODULE_TYPE = DXE_SMM_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = SmmKscLib
+
+
+[Sources]
+ SmmKscLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ BraswellPlatformPkg/BraswellPlatformPkg.dec
+ IntelFrameworkPkg/IntelFrameworkPkg.dec
+
+
+[LibraryClasses]
+ DebugLib
+ SmmIoLib
+ StallSmmLib