]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerSmm.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Universal / StatusCodeHandler / Smm / StatusCodeHandlerSmm.c
1 /** @file
2 Status Code Handler Driver which produces general handlers and hook them
3 onto the SMM status code router.
4
5 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #include "StatusCodeHandlerSmm.h"
11
12 EFI_SMM_RSC_HANDLER_PROTOCOL *mRscHandlerProtocol = NULL;
13
14
15 /**
16 Dispatch initialization request to sub status code devices based on
17 customized feature flags.
18
19 **/
20 VOID
21 InitializationDispatcherWorker (
22 VOID
23 )
24 {
25 EFI_STATUS Status;
26
27 //
28 // If enable UseSerial, then initialize serial port.
29 // if enable UseRuntimeMemory, then initialize runtime memory status code worker.
30 //
31 if (FeaturePcdGet (PcdStatusCodeUseSerial)) {
32 //
33 // Call Serial Port Lib API to initialize serial port.
34 //
35 Status = SerialPortInitialize ();
36 ASSERT_EFI_ERROR (Status);
37 }
38 if (FeaturePcdGet (PcdStatusCodeUseMemory)) {
39 Status = MemoryStatusCodeInitializeWorker ();
40 ASSERT_EFI_ERROR (Status);
41 }
42 }
43
44 /**
45 Entry point of SMM Status Code Driver.
46
47 This function is the entry point of SMM Status Code Driver.
48
49 @param ImageHandle The firmware allocated handle for the EFI image.
50 @param SystemTable A pointer to the EFI System Table.
51
52 @retval EFI_SUCCESS The entry point is executed successfully.
53
54 **/
55 EFI_STATUS
56 EFIAPI
57 StatusCodeHandlerSmmEntry (
58 IN EFI_HANDLE ImageHandle,
59 IN EFI_SYSTEM_TABLE *SystemTable
60 )
61 {
62 EFI_STATUS Status;
63
64 Status = gSmst->SmmLocateProtocol (
65 &gEfiSmmRscHandlerProtocolGuid,
66 NULL,
67 (VOID **) &mRscHandlerProtocol
68 );
69 ASSERT_EFI_ERROR (Status);
70
71 //
72 // Dispatch initialization request to supported devices
73 //
74 InitializationDispatcherWorker ();
75
76 if (FeaturePcdGet (PcdStatusCodeUseSerial)) {
77 mRscHandlerProtocol->Register (SerialStatusCodeReportWorker);
78 }
79 if (FeaturePcdGet (PcdStatusCodeUseMemory)) {
80 mRscHandlerProtocol->Register (MemoryStatusCodeReportWorker);
81 }
82
83 return EFI_SUCCESS;
84 }