public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Jiewen Yao <jiewen.yao@intel.com>
To: edk2-devel@lists.01.org
Cc: Michael D Kinney <michael.d.kinney@intel.com>,
	Kelly Steele <kelly.steele@intel.com>
Subject: [PATCH 1/2] QuarkSocPkg/SmmChildDispatch: Add SmiHandlerProfile support.
Date: Thu, 16 Mar 2017 22:04:42 +0800	[thread overview]
Message-ID: <1489673083-10856-2-git-send-email-jiewen.yao@intel.com> (raw)
In-Reply-To: <1489673083-10856-1-git-send-email-jiewen.yao@intel.com>

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Kelly Steele <kelly.steele@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
---
 QuarkSocPkg/QuarkNorthCluster/Smm/DxeSmm/QncSmmDispatcher/QNCSmmCore.c         | 41 +++++++++++++++++++-
 QuarkSocPkg/QuarkNorthCluster/Smm/DxeSmm/QncSmmDispatcher/QNCSmmDispatcher.inf |  3 +-
 2 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/QuarkSocPkg/QuarkNorthCluster/Smm/DxeSmm/QncSmmDispatcher/QNCSmmCore.c b/QuarkSocPkg/QuarkNorthCluster/Smm/DxeSmm/QncSmmDispatcher/QNCSmmCore.c
index c2f75f8..0a8239c 100644
--- a/QuarkSocPkg/QuarkNorthCluster/Smm/DxeSmm/QncSmmDispatcher/QNCSmmCore.c
+++ b/QuarkSocPkg/QuarkNorthCluster/Smm/DxeSmm/QncSmmDispatcher/QNCSmmCore.c
@@ -2,7 +2,7 @@
 This driver is responsible for the registration of child drivers
 and the abstraction of the QNC SMI sources.
 
-Copyright (c) 2013-2016 Intel Corporation.
+Copyright (c) 2013-2017 Intel Corporation.
 
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
@@ -23,6 +23,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include "QNCSmm.h"
 #include "QNCSmmHelpers.h"
 
+#include <Library/SmiHandlerProfileLib.h>
+
 //
 // /////////////////////////////////////////////////////////////////////////////
 // MODULE / GLOBAL DATA
@@ -331,6 +333,7 @@ Returns:
   DATABASE_RECORD             *Record;
   QNC_SMM_QUALIFIED_PROTOCOL  *Qualified;
   INTN                        Index;
+  UINTN                       ContextSize;
 
   //
   // Check for invalid parameter
@@ -363,6 +366,7 @@ Returns:
   // Perform linked list housekeeping
   //
   Record->Signature = DATABASE_RECORD_SIGNATURE;
+  ContextSize = 0;
 
   switch (Qualified->Type) {
   //
@@ -383,6 +387,7 @@ Returns:
 
     InsertTailList (&mPrivateData.CallbackDataBase, &Record->Link);
     CopyMem (&Record->SrcDesc, &SX_SOURCE_DESC, sizeof (Record->SrcDesc));
+    ContextSize = sizeof(Record->ChildContext.Sx);
     //
     // use default clear source function
     //
@@ -425,6 +430,7 @@ Returns:
     InsertTailList (&mPrivateData.CallbackDataBase, &Record->Link);
     CopyMem (&Record->SrcDesc, &SW_SOURCE_DESC, sizeof (Record->SrcDesc));
     Record->BufferSize = sizeof (EFI_SMM_SW_REGISTER_CONTEXT);
+    ContextSize = sizeof(Record->ChildContext.Sw);
     //
     // use default clear source function
     //
@@ -434,6 +440,7 @@ Returns:
 
     InsertTailList (&mPrivateData.CallbackDataBase, &Record->Link);
     CopyMem (&Record->SrcDesc, &GPI_SOURCE_DESC, sizeof (Record->SrcDesc));
+    ContextSize = sizeof(Record->ChildContext.Gpi);
     //
     // use default clear source function
     //
@@ -450,6 +457,7 @@ Returns:
     InsertTailList (&mPrivateData.CallbackDataBase, &Record->Link);
     CopyMem (&Record->SrcDesc, &QNCN_SOURCE_DESCS[Record->ChildContext.QNCn.Type], sizeof (Record->SrcDesc));
     Record->ClearSource = QNCSmmQNCnClearSource;
+    ContextSize = sizeof(Record->ChildContext.QNCn);
     break;
 
   case PeriodicTimerType:
@@ -462,6 +470,7 @@ Returns:
     InsertTailList (&mPrivateData.CallbackDataBase, &Record->Link);
     Record->BufferSize = sizeof (EFI_SMM_PERIODIC_TIMER_CONTEXT);
     Record->ClearSource = QNCSmmPeriodicTimerClearSource;
+    ContextSize = sizeof(Record->ChildContext.PeriodicTimer);
     break;
 
   default:
@@ -488,6 +497,8 @@ Returns:
   //
   *DispatchHandle = (EFI_HANDLE) (&Record->Link);
 
+  SmiHandlerProfileRegisterHandler (Qualified->Guid, DispatchFunction, (UINTN)RETURN_ADDRESS (0), RegisterContext, ContextSize);
+
   return EFI_SUCCESS;
 
 Error:
@@ -522,6 +533,8 @@ Returns:
   DATABASE_RECORD *RecordToDelete;
   DATABASE_RECORD *RecordInDb;
   LIST_ENTRY      *LinkInDb;
+  QNC_SMM_QUALIFIED_PROTOCOL  *Qualified;
+  UINTN                       ContextSize;
 
   if (DispatchHandle == NULL) {
     return EFI_INVALID_PARAMETER;
@@ -552,7 +565,31 @@ Returns:
   }
   if (SafeToDisable) {
     QNCSmmDisableSource( &RecordToDelete->SrcDesc );
-}
+  }
+
+  Qualified = QUALIFIED_PROTOCOL_FROM_GENERIC (This);
+  switch (Qualified->Type) {
+  case SxType:
+    ContextSize = sizeof(RecordToDelete->ChildContext.Sx);
+    break;
+  case SwType:
+    ContextSize = sizeof(RecordToDelete->ChildContext.Sw);
+    break;
+  case GpiType:
+    ContextSize = sizeof(RecordToDelete->ChildContext.Gpi);
+    break;
+  case QNCnType:
+    ContextSize = sizeof(RecordToDelete->ChildContext.QNCn);
+    break;
+  case PeriodicTimerType:
+    ContextSize = sizeof(RecordToDelete->ChildContext.PeriodicTimer);
+    break;
+  default:
+    ASSERT(FALSE);
+    ContextSize = 0;
+    break;
+  }
+  SmiHandlerProfileUnregisterHandler (Qualified->Guid, RecordToDelete->Callback, RecordToDelete->CallbackContext, ContextSize);
 
   FreePool (RecordToDelete);
 
diff --git a/QuarkSocPkg/QuarkNorthCluster/Smm/DxeSmm/QncSmmDispatcher/QNCSmmDispatcher.inf b/QuarkSocPkg/QuarkNorthCluster/Smm/DxeSmm/QncSmmDispatcher/QNCSmmDispatcher.inf
index ed94825..23b806a 100644
--- a/QuarkSocPkg/QuarkNorthCluster/Smm/DxeSmm/QncSmmDispatcher/QNCSmmDispatcher.inf
+++ b/QuarkSocPkg/QuarkNorthCluster/Smm/DxeSmm/QncSmmDispatcher/QNCSmmDispatcher.inf
@@ -3,7 +3,7 @@
 #
 # This driver is responsible for the registration of child drivers
 #  and the abstraction of the ICH SMI sources.
-# Copyright (c) 2013-2015 Intel Corporation.
+# Copyright (c) 2013-2017 Intel Corporation.
 #
 # This program and the accompanying materials
 # are licensed and made available under the terms and conditions of the BSD License
@@ -66,6 +66,7 @@
   DevicePathLib
   S3IoLib
   QNCAccessLib
+  SmiHandlerProfileLib
 
 [Protocols]
   gEfiSmmCpuProtocolGuid                        # PROTOCOL ALWAYS_CONSUMED
-- 
2.7.4.windows.1



  reply	other threads:[~2017-03-16 14:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-16 14:04 [PATCH 0/2] Add SmiHandlerProfile on Quark Jiewen Yao
2017-03-16 14:04 ` Jiewen Yao [this message]
2017-03-16 14:04 ` [PATCH 2/2] QuarkPlatformPkg: enable SmiHandlerProfile Jiewen Yao

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=1489673083-10856-2-git-send-email-jiewen.yao@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