From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web08.4102.1665468067476464766 for ; Mon, 10 Oct 2022 23:01:07 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=c3/Z6/IN; spf=pass (domain: intel.com, ip: 192.55.52.151, mailfrom: dun.tan@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665468067; x=1697004067; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=AMsP5awPYk7eq336fYelYlQQnHQ9rAe5grhdrVcg5KM=; b=c3/Z6/INuzdLiwlquq/4GW/kyLk/3/XDKQHF0eF85oC3IdT7RC627OT6 NUdRFkXcY2EWlAN+xVdg/+2D55La8qCo3Qu9DxAbUC99x6LXJgGS1rhJs D0UVBEYw5SP7x2MIs+P558ZJko0SfXROUTlUugOpk5XVbjHy9vUk3UysQ 3FyJZIOL1Eo3EmKUEnCTqm0DVgho4xuqg+AScgJi5gRnAAgMI2yMClCrL dAYnnXkDO23wGWvS9VDLYa/WwAWg7zP0Nq2HTvv1rJjAqR3i9yqF326EP 1aFq73GxsgYkTAIzpzF4gzCnalNcW0rleQ1L/PojKFdYqswRUIsqd0qlE A==; X-IronPort-AV: E=McAfee;i="6500,9779,10496"; a="284797438" X-IronPort-AV: E=Sophos;i="5.95,175,1661842800"; d="scan'208";a="284797438" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2022 23:01:06 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10496"; a="657219935" X-IronPort-AV: E=Sophos;i="5.95,175,1661842800"; d="scan'208";a="657219935" Received: from shwdeopenlab702.ccr.corp.intel.com ([10.239.56.220]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2022 23:01:05 -0700 From: "duntan" To: devel@edk2.groups.io Cc: Zhiguang Liu , Eric Dong , Ray Ni , Rahul Kumar Subject: [PATCH] UefiCpuPkg:Add RegisterExceptionHandler in PeiCpuExceptionHandlerLib Date: Tue, 11 Oct 2022 14:00:47 +0800 Message-Id: <20221011060047.516-1-dun.tan@intel.com> X-Mailer: git-send-email 2.31.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add RegisterExceptionHandler for PeiCpuExceptionHandlerLib instance 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) * CPU_EXCEPTION_NUM); InitializeSpinLock (&ExceptionHandlerData->DisplayMessageSpinLock); Status = InitializeCpuExceptionHandlersWorker (VectorInfo, ExceptionHandlerData); -- 2.31.1.windows.1