public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Eric Jin <eric.jin@intel.com>
To: edk2-devel@lists.01.org
Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>,
	Jiaxin Wu <jiaxin.wu@intel.com>
Subject: [edk2-test][Patch] uefi-sct\SctPkg: Add TPL Check in SimpleTextIn/SimpleTextInEx
Date: Fri, 12 Oct 2018 12:57:14 +0800	[thread overview]
Message-ID: <20181012045714.12968-1-eric.jin@intel.com> (raw)

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Jin <eric.jin@intel.com>
Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
---
 .../BlackBoxTest/SimpleTextInBBTestFunction.c      | 186 ++++++++++++--------
 .../SimpleTextInputExBBTestConformance.c           | 190 ++++++++++++++++++--
 .../BlackBoxTest/SimpleTextInputExBBTestFunction.c |  66 +++++--
 .../BlackBoxTest/SimpleTextInBBTestFunction.c      | 186 ++++++++++++--------
 .../SimpleTextInputExBBTestConformance.c           | 192 +++++++++++++++++++--
 .../BlackBoxTest/SimpleTextInputExBBTestFunction.c |  70 ++++++--
 6 files changed, 681 insertions(+), 209 deletions(-)

diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleTextIn/BlackBoxTest/SimpleTextInBBTestFunction.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleTextIn/BlackBoxTest/SimpleTextInBBTestFunction.c
index 284d2c7..f062101 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleTextIn/BlackBoxTest/SimpleTextInBBTestFunction.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleTextIn/BlackBoxTest/SimpleTextInBBTestFunction.c
@@ -1,7 +1,7 @@
 /** @file
 
   Copyright 2006 - 2016 Unified EFI, Inc.<BR>
-  Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2010 - 2018, 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
@@ -59,6 +59,7 @@ BBTestResetFunctionAutoTest (
 
   UINTN                                Index;
   EFI_INPUT_KEY                        Key;
+  EFI_TPL                              OldTpl;
 
   //
   // Get the Standard Library Interface
@@ -136,83 +137,122 @@ BBTestResetFunctionAutoTest (
     //
     // Call SimpleTextIn.Reset() with ExtendedVerification as FALSE
     //
-    Status = SimpleIn->Reset (SimpleIn, FALSE);
-    if (EFI_ERROR(Status)) {
-      AssertionType = EFI_TEST_ASSERTION_FAILED;
-    } else {
-      AssertionType = EFI_TEST_ASSERTION_PASSED;
+    OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+    gtBS->RestoreTPL (OldTpl);
+    if (OldTpl <= TPL_APPLICATION) {
+      if (OldTpl < TPL_APPLICATION) {
+        OldTpl = gtBS->RaiseTPL (TPL_APPLICATION);
+        Status = SimpleIn->Reset (SimpleIn, FALSE);
+        gtBS->RestoreTPL (OldTpl);
+       } else {
+        Status = SimpleIn->Reset (SimpleIn, FALSE);
+       }
+      if (EFI_ERROR(Status)) {
+        AssertionType = EFI_TEST_ASSERTION_FAILED;
+      } else {
+        AssertionType = EFI_TEST_ASSERTION_PASSED;
+      }
+      StandardLib->RecordAssertion (
+                     StandardLib,
+                     AssertionType,
+                     gSimpleTextInInterfaceTestAssertionGuid001,
+                     L"EFI_SIMPLE_TEXT_IN_PROTOCOL.Reset - Reset() with ExtendedVerification as FALSE",
+                     L"%a:%d: Status = %r",
+                     __FILE__,
+                     (UINTN)__LINE__,
+                     Status
+                     );
     }
-    StandardLib->RecordAssertion (
-                   StandardLib,
-                   AssertionType,
-                   gSimpleTextInInterfaceTestAssertionGuid001,
-                   L"EFI_SIMPLE_TEXT_IN_PROTOCOL.Reset - Reset() with ExtendedVerification as FALSE",
-                   L"%a:%d: Status = %r",
-                   __FILE__,
-                   (UINTN)__LINE__,
-                   Status
-                   );
-   //
-   //Auto test, after reset(), no key input, ReadKeyStroke() should return EFI_NOT_READY
-   //
-   Status = SimpleIn->ReadKeyStroke (SimpleIn, &Key);
-
-   if (Status != EFI_NOT_READY) {
-      AssertionType = EFI_TEST_ASSERTION_FAILED;
-   } else {
-      AssertionType = EFI_TEST_ASSERTION_PASSED;
-   }
-   StandardLib->RecordAssertion (
-                  StandardLib,
-                  AssertionType,
-                  gSimpleTextInInterfaceTestAssertionGuid012,
-                  L"EFI_SIMPLE_TEXT_IN_PROTOCOL.Reset - Reset() with ExtendedVerification as FALSE, ReadKeyStroke() verification with no key input",
-                  L"%a:%d: Status = %r, Expected = %r",
-                  __FILE__,
-                  (UINTN)__LINE__,
-                  Status,
-                  EFI_NOT_READY
-                  );
+    //
+    //Auto test, after reset(), no key input, ReadKeyStroke() should return EFI_NOT_READY
+    //
+    OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+    gtBS->RestoreTPL (OldTpl);
+    if (OldTpl <= TPL_APPLICATION) {
+      if (OldTpl < TPL_APPLICATION) {
+        OldTpl = gtBS->RaiseTPL (TPL_APPLICATION);
+        Status = SimpleIn->ReadKeyStroke (SimpleIn, &Key);
+        gtBS->RestoreTPL (OldTpl);
+      } else {
+        Status = SimpleIn->ReadKeyStroke (SimpleIn, &Key);
+      }
+      if (Status != EFI_NOT_READY) {
+        AssertionType = EFI_TEST_ASSERTION_FAILED;
+      } else {
+        AssertionType = EFI_TEST_ASSERTION_PASSED;
+      }
+      StandardLib->RecordAssertion (
+                     StandardLib,
+                     AssertionType,
+                     gSimpleTextInInterfaceTestAssertionGuid012,
+                     L"EFI_SIMPLE_TEXT_IN_PROTOCOL.Reset - Reset() with ExtendedVerification as FALSE, ReadKeyStroke() verification with no key input",
+                     L"%a:%d: Status = %r, Expected = %r",
+                     __FILE__,
+                     (UINTN)__LINE__,
+                     Status,
+                     EFI_NOT_READY
+                     );
+    } 
     //
     // Call SimpleTextIn.Reset() with ExtendedVerification as TRUE
     //
-    Status = SimpleIn->Reset (SimpleIn, TRUE);
-    if (EFI_ERROR(Status)) {
-      AssertionType = EFI_TEST_ASSERTION_FAILED;
-    } else {
-      AssertionType = EFI_TEST_ASSERTION_PASSED;
+    OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+    gtBS->RestoreTPL (OldTpl);
+    if (OldTpl <= TPL_APPLICATION) {
+       if (OldTpl < TPL_APPLICATION) {
+        OldTpl = gtBS->RaiseTPL (TPL_APPLICATION);
+        Status = SimpleIn->Reset (SimpleIn, TRUE);
+        gtBS->RestoreTPL (OldTpl);
+       } else {
+        Status = SimpleIn->Reset (SimpleIn, TRUE);
+       }
+      if (EFI_ERROR(Status)) {
+        AssertionType = EFI_TEST_ASSERTION_FAILED;
+      } else {
+        AssertionType = EFI_TEST_ASSERTION_PASSED;
+      }
+      StandardLib->RecordAssertion (
+                     StandardLib,
+                     AssertionType,
+                     gSimpleTextInInterfaceTestAssertionGuid002,
+                     L"EFI_SIMPLE_TEXT_IN_PROTOCOL.Reset - Reset() with ExtendedVerification as TRUE",
+                     L"%a:%d: Status = %r",
+                     __FILE__,
+                     (UINTN)__LINE__,
+                     Status
+                     );
     }
-    StandardLib->RecordAssertion (
-                   StandardLib,
-                   AssertionType,
-                   gSimpleTextInInterfaceTestAssertionGuid002,
-                   L"EFI_SIMPLE_TEXT_IN_PROTOCOL.Reset - Reset() with ExtendedVerification as TRUE",
-                   L"%a:%d: Status = %r",
-                   __FILE__,
-                   (UINTN)__LINE__,
-                   Status
-                   );
-   //
-   //Auto test, after reset(), no key input, ReadKeyStroke() should return EFI_NOT_READY
-   //
-    Status = SimpleIn->ReadKeyStroke (SimpleIn, &Key);
-
-   if (Status!=EFI_NOT_READY) {
-      AssertionType = EFI_TEST_ASSERTION_FAILED;
-   } else {
-      AssertionType = EFI_TEST_ASSERTION_PASSED;
-   }
-   StandardLib->RecordAssertion (
-                  StandardLib,
-                  AssertionType,
-                  gSimpleTextInInterfaceTestAssertionGuid013,
-                  L"EFI_SIMPLE_TEXT_IN_PROTOCOL.Reset - Reset() with ExtendedVerification as TRUE, ReadKeyStroke() verification with no key input",
-                  L"%a:%d: Status = %r, Expected = %r",
-                  __FILE__,
-                  (UINTN)__LINE__,
-                  Status,
-                  EFI_NOT_READY
-                  );
+
+    //
+    //Auto test, after reset(), no key input, ReadKeyStroke() should return EFI_NOT_READY
+    //
+    OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+    gtBS->RestoreTPL (OldTpl);
+    if (OldTpl <= TPL_APPLICATION) {
+       if (OldTpl < TPL_APPLICATION) {
+         OldTpl = gtBS->RaiseTPL (TPL_APPLICATION);
+        Status = SimpleIn->ReadKeyStroke (SimpleIn, &Key);
+        gtBS->RestoreTPL (OldTpl);
+       } else {
+        Status = SimpleIn->ReadKeyStroke (SimpleIn, &Key);
+       }
+      if (Status != EFI_NOT_READY) {
+        AssertionType = EFI_TEST_ASSERTION_FAILED;
+      } else {
+        AssertionType = EFI_TEST_ASSERTION_PASSED;
+      }
+      StandardLib->RecordAssertion (
+                     StandardLib,
+                     AssertionType,
+                     gSimpleTextInInterfaceTestAssertionGuid013,
+                     L"EFI_SIMPLE_TEXT_IN_PROTOCOL.Reset - Reset() with ExtendedVerification as TRUE, ReadKeyStroke() verification with no key input",
+                     L"%a:%d: Status = %r, Expected = %r",
+                     __FILE__,
+                     (UINTN)__LINE__,
+                     Status,
+                     EFI_NOT_READY
+                     );
+    } 
   }
 
   return EFI_SUCCESS;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleTextInputEx/BlackBoxTest/SimpleTextInputExBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleTextInputEx/BlackBoxTest/SimpleTextInputExBBTestConformance.c
index 04cbc6a..d997b65 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleTextInputEx/BlackBoxTest/SimpleTextInputExBBTestConformance.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleTextInputEx/BlackBoxTest/SimpleTextInputExBBTestConformance.c
@@ -1,7 +1,7 @@
 /** @file
 
   Copyright 2006 - 2016 Unified EFI, Inc.<BR>
-  Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2010 - 2018, 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
@@ -338,6 +338,7 @@ BBTestReadKeyStrokeExConformanceTestCheckpoint1 (
 {
   EFI_STATUS            Status;
   EFI_TEST_ASSERTION    AssertionType;
+  EFI_TPL               OldTpl;
 
   //
   //Call Reset to reset to console
@@ -350,11 +351,25 @@ BBTestReadKeyStrokeExConformanceTestCheckpoint1 (
   //
   //Call ReadKeyStrokeEx with KeyData being NULL
   //
-  Status = SimpleTextInputEx->ReadKeyStrokeEx (
+  OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+  gtBS->RestoreTPL (OldTpl);
+
+  if (OldTpl <= TPL_APPLICATION) {
+    if (OldTpl < TPL_APPLICATION) {
+      OldTpl = gtBS->RaiseTPL (TPL_APPLICATION);
+      Status = SimpleTextInputEx->ReadKeyStrokeEx (
                           SimpleTextInputEx,
                           NULL
                           );
-  
+      gtBS->RestoreTPL (OldTpl);
+    } else {
+      Status = SimpleTextInputEx->ReadKeyStrokeEx (
+                          SimpleTextInputEx,
+                          NULL
+                          );
+    }
+  }
+
   if ( EFI_INVALID_PARAMETER != Status) {
     AssertionType = EFI_TEST_ASSERTION_FAILED;
   } else {
@@ -384,6 +399,7 @@ BBTestReadKeyStrokeExConformanceTestCheckpoint2 (
   EFI_STATUS            Status;
   EFI_TEST_ASSERTION    AssertionType;
   EFI_KEY_DATA          Key;
+  EFI_TPL               OldTpl;
 
   //
   //Call Reset to reset to console
@@ -396,10 +412,24 @@ BBTestReadKeyStrokeExConformanceTestCheckpoint2 (
   //
   //Call ReadKeyStrokeEx with console just been reseted
   //
-  Status = SimpleTextInputEx->ReadKeyStrokeEx (
+  OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+  gtBS->RestoreTPL (OldTpl);
+
+  if (OldTpl <= TPL_APPLICATION) {
+    if (OldTpl < TPL_APPLICATION) {
+      OldTpl = gtBS->RaiseTPL (TPL_APPLICATION);
+      Status = SimpleTextInputEx->ReadKeyStrokeEx (
+                          SimpleTextInputEx,
+                          &Key
+                          );
+      gtBS->RestoreTPL (OldTpl);
+    } else {
+      Status = SimpleTextInputEx->ReadKeyStrokeEx (
                           SimpleTextInputEx,
                           &Key
                           );
+    }
+  }
   
   if ( EFI_NOT_READY != Status) {
     AssertionType = EFI_TEST_ASSERTION_FAILED;
@@ -429,14 +459,30 @@ BBTestSetStateConformanceTestCheckpoint1 (
 {
   EFI_STATUS            Status;
   EFI_TEST_ASSERTION    AssertionType;
+  EFI_TPL               OldTpl;
 
   //
   //Call SetState with KeyToggleState being NULL
   //
-  Status = SimpleTextInputEx-> SetState (
+
+  OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+  gtBS->RestoreTPL (OldTpl);
+
+  if (OldTpl <= TPL_CALLBACK) {
+    if (OldTpl < TPL_CALLBACK) {
+      OldTpl = gtBS->RaiseTPL (TPL_CALLBACK);
+      Status = SimpleTextInputEx->SetState (
                         SimpleTextInputEx,
                         NULL
                         );
+      gtBS->RestoreTPL (OldTpl);
+    } else {
+      Status = SimpleTextInputEx->SetState (
+                        SimpleTextInputEx,
+                        NULL
+                        );
+    }
+  }
   
   if ( EFI_INVALID_PARAMETER != Status) {
     AssertionType = EFI_TEST_ASSERTION_FAILED;
@@ -467,6 +513,7 @@ BBTestSetStateConformanceTestCheckpoint2 (
   EFI_STATUS            Status;
   EFI_TEST_ASSERTION    AssertionType;
   UINTN                 Index;
+  EFI_TPL               OldTpl;
   
   EFI_KEY_TOGGLE_STATE  UnsupportedState[] = {
                           EFI_SCROLL_LOCK_ACTIVE,
@@ -491,10 +538,25 @@ BBTestSetStateConformanceTestCheckpoint2 (
   //Call SetState with KeyToggleState being a unsupported bit set
   //
   for ( Index=0; UnsupportedState[Index]; Index++ ) {
-    Status = SimpleTextInputEx->SetState (
+
+    OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+    gtBS->RestoreTPL (OldTpl);
+
+    if (OldTpl <= TPL_CALLBACK) {
+      if (OldTpl < TPL_CALLBACK) {
+        OldTpl = gtBS->RaiseTPL (TPL_CALLBACK);
+        Status = SimpleTextInputEx->SetState (
+                            SimpleTextInputEx,
+                            UnsupportedState+Index
+                            );
+        gtBS->RestoreTPL (OldTpl);
+      } else {
+        Status = SimpleTextInputEx->SetState (
                             SimpleTextInputEx,
                             UnsupportedState+Index
                             );
+      }
+    }
   
     if ( EFI_UNSUPPORTED != Status) {
     AssertionType = EFI_TEST_ASSERTION_FAILED;
@@ -526,18 +588,35 @@ BBTestRegisterKeyNotifyConformanceTestCheckpoint1 (
   EFI_STATUS            Status;
   EFI_TEST_ASSERTION    AssertionType;
   VOID                  *NotifyHandle;
-
+  EFI_TPL               OldTpl;
 
   //
   //Call RegisterKeyNotify with KeyData being NULL
   //
-  Status = SimpleTextInputEx-> RegisterKeyNotify (
+
+  OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+  gtBS->RestoreTPL (OldTpl);
+
+  if (OldTpl <= TPL_CALLBACK) {
+    if (OldTpl < TPL_CALLBACK) {
+      OldTpl = gtBS->RaiseTPL (TPL_CALLBACK);
+      Status = SimpleTextInputEx->RegisterKeyNotify (
                         SimpleTextInputEx,
                         NULL,
                         TestRegisterNotifyFunction,
                         &NotifyHandle
                         );
-  
+      gtBS->RestoreTPL (OldTpl);
+    } else {
+      Status = SimpleTextInputEx->RegisterKeyNotify (
+                        SimpleTextInputEx,
+                        NULL,
+                        TestRegisterNotifyFunction,
+                        &NotifyHandle
+                        );
+    }
+  }
+
   if ( EFI_INVALID_PARAMETER != Status) {
     AssertionType = EFI_TEST_ASSERTION_FAILED;
   } else {
@@ -568,6 +647,7 @@ BBTestRegisterKeyNotifyConformanceTestCheckpoint2 (
   EFI_TEST_ASSERTION    AssertionType;
   EFI_KEY_DATA          Key;
   VOID                  *NotifyHandle;
+  EFI_TPL               OldTpl; 
 
   Key.Key.UnicodeChar = 'R';
   Key.Key.ScanCode = 0X00;
@@ -575,12 +655,29 @@ BBTestRegisterKeyNotifyConformanceTestCheckpoint2 (
   //
   //Call RegisterKeyNotify with KeyNotificationFunction being NULL
   //
-  Status = SimpleTextInputEx-> RegisterKeyNotify (
+
+  OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+  gtBS->RestoreTPL (OldTpl);
+
+  if (OldTpl <= TPL_CALLBACK) {
+    if (OldTpl < TPL_CALLBACK) {
+      OldTpl = gtBS->RaiseTPL (TPL_CALLBACK);
+      Status = SimpleTextInputEx-> RegisterKeyNotify (
+                        SimpleTextInputEx,
+                        &Key,
+                        NULL,
+                        &NotifyHandle
+                        );
+      gtBS->RestoreTPL (OldTpl);
+    } else {
+      Status = SimpleTextInputEx-> RegisterKeyNotify (
                         SimpleTextInputEx,
                         &Key,
                         NULL,
                         &NotifyHandle
                         );
+    }
+  }
   
   if ( EFI_INVALID_PARAMETER != Status) {
     AssertionType = EFI_TEST_ASSERTION_FAILED;
@@ -611,6 +708,7 @@ BBTestRegisterKeyNotifyConformanceTestCheckpoint3 (
   EFI_STATUS            Status;
   EFI_TEST_ASSERTION    AssertionType;
   EFI_KEY_DATA          Key;
+  EFI_TPL               OldTpl;
 
   Key.Key.UnicodeChar = 'R';
   Key.Key.ScanCode = 0X00;
@@ -618,12 +716,28 @@ BBTestRegisterKeyNotifyConformanceTestCheckpoint3 (
   //
   //Call RegisterKeyNotify with NotifyHandle being NULL
   //
-  Status = SimpleTextInputEx-> RegisterKeyNotify (
+  OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+  gtBS->RestoreTPL (OldTpl);
+
+  if (OldTpl <= TPL_CALLBACK) {
+    if (OldTpl < TPL_CALLBACK) {
+      OldTpl = gtBS->RaiseTPL (TPL_CALLBACK);
+      Status = SimpleTextInputEx-> RegisterKeyNotify (
                         SimpleTextInputEx,
                         &Key,
                         TestRegisterNotifyFunction,
                         NULL
                         );
+      gtBS->RestoreTPL (OldTpl);
+    } else {
+      Status = SimpleTextInputEx-> RegisterKeyNotify (
+                        SimpleTextInputEx,
+                        &Key,
+                        TestRegisterNotifyFunction,
+                        NULL
+                        );
+    }
+  }
   
   if ( EFI_INVALID_PARAMETER != Status) {
     AssertionType = EFI_TEST_ASSERTION_FAILED;
@@ -653,14 +767,29 @@ BBTestUnregisterKeyNotifyConformanceTestCheckpoint1 (
 {
   EFI_STATUS            Status;
   EFI_TEST_ASSERTION    AssertionType;
+  EFI_TPL               OldTpl;
 
   //
   //Call UnregisterKeyNotify with NotifyHandle being NULL
   //
-  Status = SimpleTextInputEx-> UnregisterKeyNotify (
+  OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+  gtBS->RestoreTPL (OldTpl);
+
+  if (OldTpl <= TPL_CALLBACK) {
+    if (OldTpl < TPL_CALLBACK) {
+      OldTpl = gtBS->RaiseTPL (TPL_CALLBACK);
+      Status = SimpleTextInputEx-> UnregisterKeyNotify (
+                        SimpleTextInputEx,
+                        NULL
+                        );
+      gtBS->RestoreTPL (OldTpl);
+    } else {
+      Status = SimpleTextInputEx-> UnregisterKeyNotify (
                         SimpleTextInputEx,
                         NULL
                         );
+    }
+  }
   
   if ( EFI_INVALID_PARAMETER != Status) {
     AssertionType = EFI_TEST_ASSERTION_FAILED;
@@ -692,6 +821,7 @@ BBTestUnregisterKeyNotifyConformanceTestCheckpoint2 (
   EFI_TEST_ASSERTION    AssertionType;
   EFI_KEY_DATA          Key;
   VOID                  *NotifyHandle;
+  EFI_TPL               OldTpl;
 
   Key.Key.UnicodeChar = 'R';
   Key.Key.ScanCode = 0X00;
@@ -723,11 +853,25 @@ BBTestUnregisterKeyNotifyConformanceTestCheckpoint2 (
   //
   //Call UnregisterKeyNotify with the invalid NotifyHandle
   //
-  Status = SimpleTextInputEx-> UnregisterKeyNotify (
+  OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+  gtBS->RestoreTPL (OldTpl);
+
+  if (OldTpl <= TPL_CALLBACK) {
+    if (OldTpl < TPL_CALLBACK) {
+      OldTpl = gtBS->RaiseTPL (TPL_CALLBACK);
+      Status = SimpleTextInputEx->UnregisterKeyNotify (
                         SimpleTextInputEx,
                         NotifyHandle
                         );
-  
+      gtBS->RestoreTPL (OldTpl);
+    } else {
+      Status = SimpleTextInputEx->UnregisterKeyNotify (
+                        SimpleTextInputEx,
+                        NotifyHandle
+                        );
+    }
+  }
+
   //
   // Invalid Parameter or Not Found
   //
@@ -762,6 +906,7 @@ BBTestUnregisterKeyNotifyConformanceTestCheckpoint3 (
   EFI_KEY_DATA          Key;
   VOID                  *NotifyHandle;
   VOID                  *InvalidNotifyHandle;
+  EFI_TPL               OldTpl;
   
   Key.Key.UnicodeChar = 'R';
   Key.Key.ScanCode = 0X00;
@@ -798,10 +943,25 @@ BBTestUnregisterKeyNotifyConformanceTestCheckpoint3 (
   //
   //Call UnregisterKeyNotify with NotifyHandle with a illegal format
   //
-  Status = SimpleTextInputEx-> UnregisterKeyNotify (
+  OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+  gtBS->RestoreTPL (OldTpl);
+
+  if (OldTpl <= TPL_CALLBACK) {
+    if (OldTpl < TPL_CALLBACK) {
+      OldTpl = gtBS->RaiseTPL (TPL_CALLBACK);
+      Status = SimpleTextInputEx-> UnregisterKeyNotify (
                         SimpleTextInputEx,
                         InvalidNotifyHandle
                         );
+      gtBS->RestoreTPL (OldTpl);
+    } else {
+      Status = SimpleTextInputEx-> UnregisterKeyNotify (
+                        SimpleTextInputEx,
+                        InvalidNotifyHandle
+                        );
+    }
+  }
+
   
   if ( EFI_INVALID_PARAMETER != Status) {
     AssertionType = EFI_TEST_ASSERTION_FAILED;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleTextInputEx/BlackBoxTest/SimpleTextInputExBBTestFunction.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleTextInputEx/BlackBoxTest/SimpleTextInputExBBTestFunction.c
index e2b2f45..153ade0 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleTextInputEx/BlackBoxTest/SimpleTextInputExBBTestFunction.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/SimpleTextInputEx/BlackBoxTest/SimpleTextInputExBBTestFunction.c
@@ -1,7 +1,7 @@
 /** @file
 
   Copyright 2006 - 2016 Unified EFI, Inc.<BR>
-  Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2010 - 2018, 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
@@ -471,6 +471,8 @@ BBTestResetFunctionAutoTestCheckpoint1 (
   UINTN                 Index;
   UINTN                 ExtendedIndex;
   EFI_KEY_DATA          Key;
+  EFI_TPL               OldTpl;
+  
   BOOLEAN               ExtendedVerification[] = {
                           TRUE,
                           FALSE
@@ -478,33 +480,67 @@ BBTestResetFunctionAutoTestCheckpoint1 (
 
   ResetStatus = EFI_SUCCESS;
   ReadKeyStatus = EFI_NOT_READY;
+
   //
   // Call Reset with ExtendedVerification being TRUE or FALSE
   //
   for ( ExtendedIndex=0; ExtendedIndex<2; ExtendedIndex++ ) {
     AssertionType = EFI_TEST_ASSERTION_PASSED;
     for ( Index=0; Index<REPEAT_RESET; Index++ ) {
-    //
-    //Call Reset to reset to console
-    //
-      ResetStatus = SimpleTextInputEx->Reset (
+      //
+      //Call Reset to reset to console
+      //
+      OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+      gtBS->RestoreTPL (OldTpl);
+
+      if (OldTpl <= TPL_APPLICATION) {
+        if (OldTpl < TPL_APPLICATION) {
+          OldTpl = gtBS->RaiseTPL (TPL_APPLICATION);
+          ResetStatus = SimpleTextInputEx->Reset (
                                     SimpleTextInputEx,
                                     ExtendedVerification[ExtendedIndex]
                                     );
-      if ( EFI_SUCCESS != ResetStatus ) {
-        AssertionType = EFI_TEST_ASSERTION_FAILED;
-        break;
+          gtBS->RestoreTPL (OldTpl);
+        } else {
+          ResetStatus = SimpleTextInputEx->Reset (
+                                    SimpleTextInputEx,
+                                    ExtendedVerification[ExtendedIndex]
+                                    );
+        }
+      
+
+        if ( EFI_SUCCESS != ResetStatus ) {
+          AssertionType = EFI_TEST_ASSERTION_FAILED;
+          break;
+        }
       }
-    //
-    //Call ReadKeyStrokeEx to check if the console has been reset
-    //
-      ReadKeyStatus = SimpleTextInputEx->ReadKeyStrokeEx (
+      
+      //
+      //Call ReadKeyStrokeEx to check if the console has been reset
+      //
+      OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+      gtBS->RestoreTPL (OldTpl);
+
+      if (OldTpl <= TPL_APPLICATION) {
+        if (OldTpl < TPL_APPLICATION) {
+          OldTpl = gtBS->RaiseTPL (TPL_APPLICATION);
+          ReadKeyStatus = SimpleTextInputEx->ReadKeyStrokeEx (
                                     SimpleTextInputEx,
                                     &Key
                                     );
-      if ( EFI_NOT_READY != ReadKeyStatus ) {
-        AssertionType = EFI_TEST_ASSERTION_FAILED;
-        break;
+          gtBS->RestoreTPL (OldTpl);
+        } else {
+          ReadKeyStatus = SimpleTextInputEx->ReadKeyStrokeEx (
+                                    SimpleTextInputEx,
+                                    &Key
+                                    );
+        }
+      
+
+        if ( EFI_NOT_READY != ReadKeyStatus ) {
+          AssertionType = EFI_TEST_ASSERTION_FAILED;
+          break;
+        }
       }
     }
     
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/SimpleTextIn/BlackBoxTest/SimpleTextInBBTestFunction.c b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/SimpleTextIn/BlackBoxTest/SimpleTextInBBTestFunction.c
index 284d2c7..ee1173d 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/SimpleTextIn/BlackBoxTest/SimpleTextInBBTestFunction.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/SimpleTextIn/BlackBoxTest/SimpleTextInBBTestFunction.c
@@ -1,7 +1,7 @@
 /** @file
 
   Copyright 2006 - 2016 Unified EFI, Inc.<BR>
-  Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2010 - 2018, 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
@@ -59,6 +59,7 @@ BBTestResetFunctionAutoTest (
 
   UINTN                                Index;
   EFI_INPUT_KEY                        Key;
+  EFI_TPL                              OldTpl;
 
   //
   // Get the Standard Library Interface
@@ -136,83 +137,122 @@ BBTestResetFunctionAutoTest (
     //
     // Call SimpleTextIn.Reset() with ExtendedVerification as FALSE
     //
-    Status = SimpleIn->Reset (SimpleIn, FALSE);
-    if (EFI_ERROR(Status)) {
-      AssertionType = EFI_TEST_ASSERTION_FAILED;
-    } else {
-      AssertionType = EFI_TEST_ASSERTION_PASSED;
+    OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+    gtBS->RestoreTPL (OldTpl);
+    if (OldTpl <= TPL_APPLICATION) {
+      if (OldTpl < TPL_APPLICATION) {
+        OldTpl = gtBS->RaiseTPL (TPL_APPLICATION);
+        Status = SimpleIn->Reset (SimpleIn, FALSE);
+        gtBS->RestoreTPL (OldTpl);
+      } else {
+        Status = SimpleIn->Reset (SimpleIn, FALSE);
+      }
+      if (EFI_ERROR(Status)) {
+        AssertionType = EFI_TEST_ASSERTION_FAILED;
+      } else {
+        AssertionType = EFI_TEST_ASSERTION_PASSED;
+      }
+      StandardLib->RecordAssertion (
+                     StandardLib,
+                     AssertionType,
+                     gSimpleTextInInterfaceTestAssertionGuid001,
+                     L"EFI_SIMPLE_TEXT_IN_PROTOCOL.Reset - Reset() with ExtendedVerification as FALSE",
+                     L"%a:%d: Status = %r",
+                     __FILE__,
+                     (UINTN)__LINE__,
+                     Status
+                     );
     }
-    StandardLib->RecordAssertion (
-                   StandardLib,
-                   AssertionType,
-                   gSimpleTextInInterfaceTestAssertionGuid001,
-                   L"EFI_SIMPLE_TEXT_IN_PROTOCOL.Reset - Reset() with ExtendedVerification as FALSE",
-                   L"%a:%d: Status = %r",
-                   __FILE__,
-                   (UINTN)__LINE__,
-                   Status
-                   );
-   //
-   //Auto test, after reset(), no key input, ReadKeyStroke() should return EFI_NOT_READY
-   //
-   Status = SimpleIn->ReadKeyStroke (SimpleIn, &Key);
-
-   if (Status != EFI_NOT_READY) {
-      AssertionType = EFI_TEST_ASSERTION_FAILED;
-   } else {
-      AssertionType = EFI_TEST_ASSERTION_PASSED;
-   }
-   StandardLib->RecordAssertion (
-                  StandardLib,
-                  AssertionType,
-                  gSimpleTextInInterfaceTestAssertionGuid012,
-                  L"EFI_SIMPLE_TEXT_IN_PROTOCOL.Reset - Reset() with ExtendedVerification as FALSE, ReadKeyStroke() verification with no key input",
-                  L"%a:%d: Status = %r, Expected = %r",
-                  __FILE__,
-                  (UINTN)__LINE__,
-                  Status,
-                  EFI_NOT_READY
-                  );
+    //
+    //Auto test, after reset(), no key input, ReadKeyStroke() should return EFI_NOT_READY
+    //
+    OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+    gtBS->RestoreTPL (OldTpl);
+    if (OldTpl <= TPL_APPLICATION) {
+      if (OldTpl < TPL_APPLICATION) {
+        OldTpl = gtBS->RaiseTPL (TPL_APPLICATION);
+        Status = SimpleIn->ReadKeyStroke (SimpleIn, &Key);
+        gtBS->RestoreTPL (OldTpl);
+      } else {
+        Status = SimpleIn->ReadKeyStroke (SimpleIn, &Key);
+      }
+      if (Status != EFI_NOT_READY) {
+        AssertionType = EFI_TEST_ASSERTION_FAILED;
+      } else {
+        AssertionType = EFI_TEST_ASSERTION_PASSED;
+      }
+      StandardLib->RecordAssertion (
+                     StandardLib,
+                     AssertionType,
+                     gSimpleTextInInterfaceTestAssertionGuid012,
+                     L"EFI_SIMPLE_TEXT_IN_PROTOCOL.Reset - Reset() with ExtendedVerification as FALSE, ReadKeyStroke() verification with no key input",
+                     L"%a:%d: Status = %r, Expected = %r",
+                     __FILE__,
+                     (UINTN)__LINE__,
+                     Status,
+                     EFI_NOT_READY
+                     );
+    } 
     //
     // Call SimpleTextIn.Reset() with ExtendedVerification as TRUE
     //
-    Status = SimpleIn->Reset (SimpleIn, TRUE);
-    if (EFI_ERROR(Status)) {
-      AssertionType = EFI_TEST_ASSERTION_FAILED;
-    } else {
-      AssertionType = EFI_TEST_ASSERTION_PASSED;
+    OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+    gtBS->RestoreTPL (OldTpl);
+    if (OldTpl <= TPL_APPLICATION) {
+      if (OldTpl < TPL_APPLICATION) {
+        OldTpl = gtBS->RaiseTPL (TPL_APPLICATION);
+        Status = SimpleIn->Reset (SimpleIn, TRUE);
+        gtBS->RestoreTPL (OldTpl);
+      } else {
+        Status = SimpleIn->Reset (SimpleIn, TRUE);
+      }
+      if (EFI_ERROR(Status)) {
+        AssertionType = EFI_TEST_ASSERTION_FAILED;
+      } else {
+        AssertionType = EFI_TEST_ASSERTION_PASSED;
+      }
+      StandardLib->RecordAssertion (
+                     StandardLib,
+                     AssertionType,
+                     gSimpleTextInInterfaceTestAssertionGuid002,
+                     L"EFI_SIMPLE_TEXT_IN_PROTOCOL.Reset - Reset() with ExtendedVerification as TRUE",
+                     L"%a:%d: Status = %r",
+                     __FILE__,
+                     (UINTN)__LINE__,
+                     Status
+                     );
     }
-    StandardLib->RecordAssertion (
-                   StandardLib,
-                   AssertionType,
-                   gSimpleTextInInterfaceTestAssertionGuid002,
-                   L"EFI_SIMPLE_TEXT_IN_PROTOCOL.Reset - Reset() with ExtendedVerification as TRUE",
-                   L"%a:%d: Status = %r",
-                   __FILE__,
-                   (UINTN)__LINE__,
-                   Status
-                   );
-   //
-   //Auto test, after reset(), no key input, ReadKeyStroke() should return EFI_NOT_READY
-   //
-    Status = SimpleIn->ReadKeyStroke (SimpleIn, &Key);
-
-   if (Status!=EFI_NOT_READY) {
-      AssertionType = EFI_TEST_ASSERTION_FAILED;
-   } else {
-      AssertionType = EFI_TEST_ASSERTION_PASSED;
-   }
-   StandardLib->RecordAssertion (
-                  StandardLib,
-                  AssertionType,
-                  gSimpleTextInInterfaceTestAssertionGuid013,
-                  L"EFI_SIMPLE_TEXT_IN_PROTOCOL.Reset - Reset() with ExtendedVerification as TRUE, ReadKeyStroke() verification with no key input",
-                  L"%a:%d: Status = %r, Expected = %r",
-                  __FILE__,
-                  (UINTN)__LINE__,
-                  Status,
-                  EFI_NOT_READY
-                  );
+
+    //
+    //Auto test, after reset(), no key input, ReadKeyStroke() should return EFI_NOT_READY
+    //
+    OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+    gtBS->RestoreTPL (OldTpl);
+    if (OldTpl <= TPL_APPLICATION) {
+      if (OldTpl < TPL_APPLICATION) {
+        OldTpl = gtBS->RaiseTPL (TPL_APPLICATION);
+        Status = SimpleIn->ReadKeyStroke (SimpleIn, &Key);
+        gtBS->RestoreTPL (OldTpl);
+      } else {
+        Status = SimpleIn->ReadKeyStroke (SimpleIn, &Key);
+      }
+      if (Status != EFI_NOT_READY) {
+        AssertionType = EFI_TEST_ASSERTION_FAILED;
+      } else {
+        AssertionType = EFI_TEST_ASSERTION_PASSED;
+      }
+      StandardLib->RecordAssertion (
+                     StandardLib,
+                     AssertionType,
+                     gSimpleTextInInterfaceTestAssertionGuid013,
+                     L"EFI_SIMPLE_TEXT_IN_PROTOCOL.Reset - Reset() with ExtendedVerification as TRUE, ReadKeyStroke() verification with no key input",
+                     L"%a:%d: Status = %r, Expected = %r",
+                     __FILE__,
+                     (UINTN)__LINE__,
+                     Status,
+                     EFI_NOT_READY
+                     );
+    } 
   }
 
   return EFI_SUCCESS;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/SimpleTextInputEx/BlackBoxTest/SimpleTextInputExBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/SimpleTextInputEx/BlackBoxTest/SimpleTextInputExBBTestConformance.c
index 4f2a5e7..3e230f9 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/SimpleTextInputEx/BlackBoxTest/SimpleTextInputExBBTestConformance.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/SimpleTextInputEx/BlackBoxTest/SimpleTextInputExBBTestConformance.c
@@ -1,7 +1,7 @@
 /** @file
 
   Copyright 2006 - 2016 Unified EFI, Inc.<BR>
-  Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2010 - 2018, 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
@@ -153,7 +153,7 @@ BBTestSetStateConformanceTest (
         return Status;
       }
       BBTestSetStateConformanceTestCheckpoint2 ( StandardLib, SimpleTextInputEx );
-	  
+  
       Status = gtBS->FreePool (DevicePathStr);
       if (EFI_ERROR(Status))
         return Status;
@@ -338,6 +338,7 @@ BBTestReadKeyStrokeExConformanceTestCheckpoint1 (
 {
   EFI_STATUS            Status;
   EFI_TEST_ASSERTION    AssertionType;
+  EFI_TPL               OldTpl;
 
   //
   //Call Reset to reset to console
@@ -350,11 +351,25 @@ BBTestReadKeyStrokeExConformanceTestCheckpoint1 (
   //
   //Call ReadKeyStrokeEx with KeyData being NULL
   //
-  Status = SimpleTextInputEx->ReadKeyStrokeEx (
+  OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+  gtBS->RestoreTPL (OldTpl);
+
+  if (OldTpl <= TPL_APPLICATION) {
+    if (OldTpl < TPL_APPLICATION) {
+      OldTpl = gtBS->RaiseTPL (TPL_APPLICATION);
+      Status = SimpleTextInputEx->ReadKeyStrokeEx (
                           SimpleTextInputEx,
                           NULL
                           );
-  
+      gtBS->RestoreTPL (OldTpl);
+    } else {
+      Status = SimpleTextInputEx->ReadKeyStrokeEx (
+                          SimpleTextInputEx,
+                          NULL
+                          );
+    }
+  }
+
   if ( EFI_INVALID_PARAMETER != Status) {
     AssertionType = EFI_TEST_ASSERTION_FAILED;
   } else {
@@ -384,6 +399,7 @@ BBTestReadKeyStrokeExConformanceTestCheckpoint2 (
   EFI_STATUS            Status;
   EFI_TEST_ASSERTION    AssertionType;
   EFI_KEY_DATA          Key;
+  EFI_TPL               OldTpl;
 
   //
   //Call Reset to reset to console
@@ -396,10 +412,24 @@ BBTestReadKeyStrokeExConformanceTestCheckpoint2 (
   //
   //Call ReadKeyStrokeEx with console just been reseted
   //
-  Status = SimpleTextInputEx->ReadKeyStrokeEx (
+  OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+  gtBS->RestoreTPL (OldTpl);
+
+  if (OldTpl <= TPL_APPLICATION) {
+    if (OldTpl < TPL_APPLICATION) {
+      OldTpl = gtBS->RaiseTPL (TPL_APPLICATION);
+      Status = SimpleTextInputEx->ReadKeyStrokeEx (
+                          SimpleTextInputEx,
+                          &Key
+                          );
+      gtBS->RestoreTPL (OldTpl);
+    } else {
+      Status = SimpleTextInputEx->ReadKeyStrokeEx (
                           SimpleTextInputEx,
                           &Key
                           );
+    }
+  }
   
   if ( EFI_NOT_READY != Status) {
     AssertionType = EFI_TEST_ASSERTION_FAILED;
@@ -429,14 +459,30 @@ BBTestSetStateConformanceTestCheckpoint1 (
 {
   EFI_STATUS            Status;
   EFI_TEST_ASSERTION    AssertionType;
+  EFI_TPL               OldTpl;
 
   //
   //Call SetState with KeyToggleState being NULL
   //
-  Status = SimpleTextInputEx-> SetState (
+
+  OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+  gtBS->RestoreTPL (OldTpl);
+
+  if (OldTpl <= TPL_CALLBACK) {
+    if (OldTpl < TPL_CALLBACK) {
+      OldTpl = gtBS->RaiseTPL (TPL_CALLBACK);
+      Status = SimpleTextInputEx->SetState (
+                        SimpleTextInputEx,
+                        NULL
+                        );
+      gtBS->RestoreTPL (OldTpl);
+    } else {
+      Status = SimpleTextInputEx->SetState (
                         SimpleTextInputEx,
                         NULL
                         );
+    }
+  }
   
   if ( EFI_INVALID_PARAMETER != Status) {
     AssertionType = EFI_TEST_ASSERTION_FAILED;
@@ -467,6 +513,7 @@ BBTestSetStateConformanceTestCheckpoint2 (
   EFI_STATUS            Status;
   EFI_TEST_ASSERTION    AssertionType;
   UINTN                 Index;
+  EFI_TPL               OldTpl;
   
   EFI_KEY_TOGGLE_STATE  UnsupportedState[] = {
                           EFI_SCROLL_LOCK_ACTIVE,
@@ -491,10 +538,25 @@ BBTestSetStateConformanceTestCheckpoint2 (
   //Call SetState with KeyToggleState being a unsupported bit set
   //
   for ( Index=0; UnsupportedState[Index]; Index++ ) {
-    Status = SimpleTextInputEx->SetState (
+
+    OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+    gtBS->RestoreTPL (OldTpl);
+
+    if (OldTpl <= TPL_CALLBACK) {
+      if (OldTpl < TPL_CALLBACK) {
+        OldTpl = gtBS->RaiseTPL (TPL_CALLBACK);
+        Status = SimpleTextInputEx->SetState (
+                            SimpleTextInputEx,
+                            UnsupportedState+Index
+                            );
+        gtBS->RestoreTPL (OldTpl);
+      } else {
+        Status = SimpleTextInputEx->SetState (
                             SimpleTextInputEx,
                             UnsupportedState+Index
                             );
+      }
+    }
   
     if ( EFI_UNSUPPORTED != Status) {
     AssertionType = EFI_TEST_ASSERTION_FAILED;
@@ -526,18 +588,35 @@ BBTestRegisterKeyNotifyConformanceTestCheckpoint1 (
   EFI_STATUS            Status;
   EFI_TEST_ASSERTION    AssertionType;
   VOID                  *NotifyHandle;
-
+  EFI_TPL               OldTpl;
 
   //
   //Call RegisterKeyNotify with KeyData being NULL
   //
-  Status = SimpleTextInputEx-> RegisterKeyNotify (
+
+  OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+  gtBS->RestoreTPL (OldTpl);
+
+  if (OldTpl <= TPL_CALLBACK) {
+    if (OldTpl < TPL_CALLBACK) {
+      OldTpl = gtBS->RaiseTPL (TPL_CALLBACK);
+      Status = SimpleTextInputEx->RegisterKeyNotify (
                         SimpleTextInputEx,
                         NULL,
                         TestRegisterNotifyFunction,
                         &NotifyHandle
                         );
-  
+      gtBS->RestoreTPL (OldTpl);
+    } else {
+      Status = SimpleTextInputEx->RegisterKeyNotify (
+                        SimpleTextInputEx,
+                        NULL,
+                        TestRegisterNotifyFunction,
+                        &NotifyHandle
+                        );
+    }
+  }
+
   if ( EFI_INVALID_PARAMETER != Status) {
     AssertionType = EFI_TEST_ASSERTION_FAILED;
   } else {
@@ -568,6 +647,7 @@ BBTestRegisterKeyNotifyConformanceTestCheckpoint2 (
   EFI_TEST_ASSERTION    AssertionType;
   EFI_KEY_DATA          Key;
   VOID                  *NotifyHandle;
+  EFI_TPL               OldTpl; 
 
   Key.Key.UnicodeChar = 'R';
   Key.Key.ScanCode = 0X00;
@@ -575,12 +655,29 @@ BBTestRegisterKeyNotifyConformanceTestCheckpoint2 (
   //
   //Call RegisterKeyNotify with KeyNotificationFunction being NULL
   //
-  Status = SimpleTextInputEx-> RegisterKeyNotify (
+
+  OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+  gtBS->RestoreTPL (OldTpl);
+
+  if (OldTpl <= TPL_CALLBACK) {
+    if (OldTpl < TPL_CALLBACK) {
+      OldTpl = gtBS->RaiseTPL (TPL_CALLBACK);
+      Status = SimpleTextInputEx-> RegisterKeyNotify (
+                        SimpleTextInputEx,
+                        &Key,
+                        NULL,
+                        &NotifyHandle
+                        );
+      gtBS->RestoreTPL (OldTpl);
+    } else {
+      Status = SimpleTextInputEx-> RegisterKeyNotify (
                         SimpleTextInputEx,
                         &Key,
                         NULL,
                         &NotifyHandle
                         );
+    }
+  }
   
   if ( EFI_INVALID_PARAMETER != Status) {
     AssertionType = EFI_TEST_ASSERTION_FAILED;
@@ -611,6 +708,7 @@ BBTestRegisterKeyNotifyConformanceTestCheckpoint3 (
   EFI_STATUS            Status;
   EFI_TEST_ASSERTION    AssertionType;
   EFI_KEY_DATA          Key;
+  EFI_TPL               OldTpl;
 
   Key.Key.UnicodeChar = 'R';
   Key.Key.ScanCode = 0X00;
@@ -618,12 +716,28 @@ BBTestRegisterKeyNotifyConformanceTestCheckpoint3 (
   //
   //Call RegisterKeyNotify with NotifyHandle being NULL
   //
-  Status = SimpleTextInputEx-> RegisterKeyNotify (
+  OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+  gtBS->RestoreTPL (OldTpl);
+
+  if (OldTpl <= TPL_CALLBACK) {
+    if (OldTpl < TPL_CALLBACK) {
+      OldTpl = gtBS->RaiseTPL (TPL_CALLBACK);
+      Status = SimpleTextInputEx-> RegisterKeyNotify (
                         SimpleTextInputEx,
                         &Key,
                         TestRegisterNotifyFunction,
                         NULL
                         );
+      gtBS->RestoreTPL (OldTpl);
+    } else {
+      Status = SimpleTextInputEx-> RegisterKeyNotify (
+                        SimpleTextInputEx,
+                        &Key,
+                        TestRegisterNotifyFunction,
+                        NULL
+                        );
+    }
+  }
   
   if ( EFI_INVALID_PARAMETER != Status) {
     AssertionType = EFI_TEST_ASSERTION_FAILED;
@@ -653,14 +767,29 @@ BBTestUnregisterKeyNotifyConformanceTestCheckpoint1 (
 {
   EFI_STATUS            Status;
   EFI_TEST_ASSERTION    AssertionType;
+  EFI_TPL               OldTpl;
 
   //
   //Call UnregisterKeyNotify with NotifyHandle being NULL
   //
-  Status = SimpleTextInputEx-> UnregisterKeyNotify (
+  OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+  gtBS->RestoreTPL (OldTpl);
+
+  if (OldTpl <= TPL_CALLBACK) {
+    if (OldTpl < TPL_CALLBACK) {
+      OldTpl = gtBS->RaiseTPL (TPL_CALLBACK);
+      Status = SimpleTextInputEx-> UnregisterKeyNotify (
                         SimpleTextInputEx,
                         NULL
                         );
+      gtBS->RestoreTPL (OldTpl);
+    } else {
+      Status = SimpleTextInputEx-> UnregisterKeyNotify (
+                        SimpleTextInputEx,
+                        NULL
+                        );
+    }
+  }
   
   if ( EFI_INVALID_PARAMETER != Status) {
     AssertionType = EFI_TEST_ASSERTION_FAILED;
@@ -692,6 +821,7 @@ BBTestUnregisterKeyNotifyConformanceTestCheckpoint2 (
   EFI_TEST_ASSERTION    AssertionType;
   EFI_KEY_DATA          Key;
   VOID                  *NotifyHandle;
+  EFI_TPL               OldTpl;
 
   Key.Key.UnicodeChar = 'R';
   Key.Key.ScanCode = 0X00;
@@ -723,11 +853,25 @@ BBTestUnregisterKeyNotifyConformanceTestCheckpoint2 (
   //
   //Call UnregisterKeyNotify with the invalid NotifyHandle
   //
-  Status = SimpleTextInputEx-> UnregisterKeyNotify (
+  OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+  gtBS->RestoreTPL (OldTpl);
+
+  if (OldTpl <= TPL_CALLBACK) {
+    if (OldTpl < TPL_CALLBACK) {
+      OldTpl = gtBS->RaiseTPL (TPL_CALLBACK);
+      Status = SimpleTextInputEx->UnregisterKeyNotify (
                         SimpleTextInputEx,
                         NotifyHandle
                         );
-  
+      gtBS->RestoreTPL (OldTpl);
+    } else {
+      Status = SimpleTextInputEx->UnregisterKeyNotify (
+                        SimpleTextInputEx,
+                        NotifyHandle
+                        );
+    }
+  }
+
   //
   // Invalid Parameter or Not Found
   //
@@ -762,6 +906,7 @@ BBTestUnregisterKeyNotifyConformanceTestCheckpoint3 (
   EFI_KEY_DATA          Key;
   VOID                  *NotifyHandle;
   VOID                  *InvalidNotifyHandle;
+  EFI_TPL               OldTpl;
   
   Key.Key.UnicodeChar = 'R';
   Key.Key.ScanCode = 0X00;
@@ -798,10 +943,25 @@ BBTestUnregisterKeyNotifyConformanceTestCheckpoint3 (
   //
   //Call UnregisterKeyNotify with NotifyHandle with a illegal format
   //
-  Status = SimpleTextInputEx-> UnregisterKeyNotify (
+  OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+  gtBS->RestoreTPL (OldTpl);
+
+  if (OldTpl <= TPL_CALLBACK) {
+    if (OldTpl < TPL_CALLBACK) {
+      OldTpl = gtBS->RaiseTPL (TPL_CALLBACK);
+      Status = SimpleTextInputEx-> UnregisterKeyNotify (
                         SimpleTextInputEx,
                         InvalidNotifyHandle
                         );
+      gtBS->RestoreTPL (OldTpl);
+    } else {
+      Status = SimpleTextInputEx-> UnregisterKeyNotify (
+                        SimpleTextInputEx,
+                        InvalidNotifyHandle
+                        );
+    }
+  }
+
   
   if ( EFI_INVALID_PARAMETER != Status) {
     AssertionType = EFI_TEST_ASSERTION_FAILED;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/SimpleTextInputEx/BlackBoxTest/SimpleTextInputExBBTestFunction.c b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/SimpleTextInputEx/BlackBoxTest/SimpleTextInputExBBTestFunction.c
index 7c424ef..ce5a80a 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/SimpleTextInputEx/BlackBoxTest/SimpleTextInputExBBTestFunction.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/SimpleTextInputEx/BlackBoxTest/SimpleTextInputExBBTestFunction.c
@@ -1,7 +1,7 @@
 /** @file
 
   Copyright 2006 - 2016 Unified EFI, Inc.<BR>
-  Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2010 - 2018, 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
@@ -292,7 +292,7 @@ BBTestSetStateFunctionManualTest (
         Status = gtBS->FreePool (DevicePathStr);
         return Status;
       }
-	  BBTestSetStateFunctionManualTestCheckpoint1 ( StandardLib, SimpleTextInputEx );
+      BBTestSetStateFunctionManualTestCheckpoint1 ( StandardLib, SimpleTextInputEx );
       Status = gtBS->FreePool (DevicePathStr);
       if (EFI_ERROR(Status))
         return Status;
@@ -307,7 +307,7 @@ BBTestSetStateFunctionManualTest (
                    L"\r\nCurrent Device: ConsoleSplitter/TxtIn"
                    );
     BBTestSetStateFunctionManualTestCheckpoint1 ( StandardLib, SimpleTextInputEx );
-	
+  
   }
   
   return EFI_SUCCESS;
@@ -471,6 +471,8 @@ BBTestResetFunctionAutoTestCheckpoint1 (
   UINTN                 Index;
   UINTN                 ExtendedIndex;
   EFI_KEY_DATA          Key;
+  EFI_TPL               OldTpl;
+  
   BOOLEAN               ExtendedVerification[] = {
                           TRUE,
                           FALSE
@@ -478,33 +480,67 @@ BBTestResetFunctionAutoTestCheckpoint1 (
 
   ResetStatus = EFI_SUCCESS;
   ReadKeyStatus = EFI_NOT_READY;
+
   //
   // Call Reset with ExtendedVerification being TRUE or FALSE
   //
   for ( ExtendedIndex=0; ExtendedIndex<2; ExtendedIndex++ ) {
     AssertionType = EFI_TEST_ASSERTION_PASSED;
     for ( Index=0; Index<REPEAT_RESET; Index++ ) {
-    //
-    //Call Reset to reset to console
-    //
-      ResetStatus = SimpleTextInputEx->Reset (
+      //
+      //Call Reset to reset to console
+      //
+      OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+      gtBS->RestoreTPL (OldTpl);
+
+      if (OldTpl <= TPL_APPLICATION) {
+        if (OldTpl < TPL_APPLICATION) {
+          OldTpl = gtBS->RaiseTPL (TPL_APPLICATION);
+          ResetStatus = SimpleTextInputEx->Reset (
                                     SimpleTextInputEx,
                                     ExtendedVerification[ExtendedIndex]
                                     );
-      if ( EFI_SUCCESS != ResetStatus ) {
-        AssertionType = EFI_TEST_ASSERTION_FAILED;
-        break;
+          gtBS->RestoreTPL (OldTpl);
+        } else {
+          ResetStatus = SimpleTextInputEx->Reset (
+                                    SimpleTextInputEx,
+                                    ExtendedVerification[ExtendedIndex]
+                                    );
+        }
+      
+
+        if ( EFI_SUCCESS != ResetStatus ) {
+          AssertionType = EFI_TEST_ASSERTION_FAILED;
+          break;
+        }
       }
-    //
-    //Call ReadKeyStrokeEx to check if the console has been reset
-    //
-      ReadKeyStatus = SimpleTextInputEx->ReadKeyStrokeEx (
+      
+      //
+      //Call ReadKeyStrokeEx to check if the console has been reset
+      //
+      OldTpl = gtBS->RaiseTPL (TPL_HIGH_LEVEL);
+      gtBS->RestoreTPL (OldTpl);
+
+      if (OldTpl <= TPL_APPLICATION) {
+        if (OldTpl < TPL_APPLICATION) {
+          OldTpl = gtBS->RaiseTPL (TPL_APPLICATION);
+          ReadKeyStatus = SimpleTextInputEx->ReadKeyStrokeEx (
                                     SimpleTextInputEx,
                                     &Key
                                     );
-      if ( EFI_NOT_READY != ReadKeyStatus ) {
-        AssertionType = EFI_TEST_ASSERTION_FAILED;
-        break;
+          gtBS->RestoreTPL (OldTpl);
+        } else {
+          ReadKeyStatus = SimpleTextInputEx->ReadKeyStrokeEx (
+                                    SimpleTextInputEx,
+                                    &Key
+                                    );
+        }
+      
+
+        if ( EFI_NOT_READY != ReadKeyStatus ) {
+          AssertionType = EFI_TEST_ASSERTION_FAILED;
+          break;
+        }
       }
     }
     
-- 
2.9.0.windows.1



             reply	other threads:[~2018-10-12  4:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-12  4:57 Eric Jin [this message]
2018-10-12  8:45 ` [edk2-test][Patch] uefi-sct\SctPkg: Add TPL Check in SimpleTextIn/SimpleTextInEx Supreeth Venkatesh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181012045714.12968-1-eric.jin@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox