From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web11.17589.1665559680773652312 for ; Wed, 12 Oct 2022 00:28:01 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=oDRebLkZ; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: zhiguang.liu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665559680; x=1697095680; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=PpLJVYWLY3WqoR8RBCvuI34196TMw/mYEM1Ur8vY7As=; b=oDRebLkZp1iCXMEj+3QOtq4Ta7RoVh6JFRqzdWWf+jLhMtjiFbanpGa4 KabnnVqHPC8PlMEh0d6RZMkJ/NBEDFaNePNjTvy4hGt+7dikmijCI4NnP qtMW8jAEHCCxMH9gYVp6l3t2Lji9s+ZmteA8RfGce+4KqSpQ3djH1wqtY kGdiWs8zCaUzY5cPpHj0pm+Geg8Oyo3u3U2KClGxzjwjMedb41bhbO/S1 RQIFHRiOlqZGeDC4WrNa1aj8gxOLyh/LQz1qaCfg3W2Rq6Say74BrTyg4 QYMaI0ET5baLph3ryQTMD3nuy95RVH24Yvs1j0PLFtVLWJoFPo5vOpurN Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10497"; a="292047513" X-IronPort-AV: E=Sophos;i="5.95,178,1661842800"; d="scan'208";a="292047513" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2022 00:27:57 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10497"; a="626666716" X-IronPort-AV: E=Sophos;i="5.95,178,1661842800"; d="scan'208";a="626666716" Received: from shwdesfp01.ccr.corp.intel.com ([10.239.158.151]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2022 00:27:56 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Zhiguang Liu , Eric Dong , Ray Ni , Rahul Kumar Subject: [PATCH V2] UefiCpuPkg:Add RegisterExceptionHandler in PeiCpuExceptionHandlerLib Date: Wed, 12 Oct 2022 15:27:45 +0800 Message-Id: <20221012072745.549-1-zhiguang.liu@intel.com> X-Mailer: git-send-email 2.31.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The PEI instance of the CpuExceptionHandlerLib didn't implement the RegisterCpuInterruptHandler() API. This patch adds the missing API. Signed-off-by: Zhiguang Liu Cc: Eric Dong Cc: Ray Ni Cc: Rahul Kumar --- UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c index 940d83a92f..1c3012b770 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuException.c @@ -100,6 +100,42 @@ CommonExceptionHandler ( CommonExceptionHandlerWorker (ExceptionType, SystemContext, ExceptionHandlerData); } +/** + Registers a function to be called from the processor interrupt handler. + + This function registers and enables the handler specified by InterruptHandler for a processor + interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the + handler for the processor interrupt or exception type specified by InterruptType is uninstalled. + The installed handler is called once for each processor interrupt or exception. + NOTE: This function should be invoked after InitializeCpuExceptionHandlers() is invoked, + otherwise EFI_UNSUPPORTED returned. + + @param[in] InterruptType Defines which interrupt or exception to hook. + @param[in] InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called + when a processor interrupt occurs. If this parameter is NULL, then the handler + will be uninstalled. + + @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled. + @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was + previously installed. + @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not + previously installed. + @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported, + or this function is not supported. +**/ +EFI_STATUS +EFIAPI +RegisterCpuInterruptHandler ( + IN EFI_EXCEPTION_TYPE InterruptType, + IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler + ) +{ + EXCEPTION_HANDLER_DATA *ExceptionHandlerData; + + ExceptionHandlerData = GetExceptionHandlerData (); + return RegisterCpuInterruptHandlerWorker (InterruptType, InterruptHandler, ExceptionHandlerData); +} + /** Initializes all CPU exceptions entries and provides the default exception handlers. @@ -135,7 +171,7 @@ InitializeCpuExceptionHandlers ( ASSERT (ExceptionHandlerData != NULL); ExceptionHandlerData->IdtEntryCount = CPU_EXCEPTION_NUM; ExceptionHandlerData->ReservedVectors = ReservedVectors; - ExceptionHandlerData->ExternalInterruptHandler = NULL; + ExceptionHandlerData->ExternalInterruptHandler = AllocateZeroPool (sizeof (EFI_CPU_INTERRUPT_HANDLER) * ExceptionHandlerData->IdtEntryCount); InitializeSpinLock (&ExceptionHandlerData->DisplayMessageSpinLock); Status = InitializeCpuExceptionHandlersWorker (VectorInfo, ExceptionHandlerData); -- 2.31.1.windows.1