]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/DebugServicePei/DebugServicePei.c
MdeModulePkg: Add a PEIM to install Debug PPI
[mirror_edk2.git] / MdeModulePkg / Universal / DebugServicePei / DebugServicePei.c
1 /** @file
2 This driver installs gEdkiiDebugPpiGuid PPI to provide
3 debug services for PEIMs.
4
5 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
6
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16
17 #include <Uefi/UefiBaseType.h>
18 #include <Library/PeimEntryPoint.h>
19 #include <Library/PeiServicesLib.h>
20 #include <Library/DebugLib.h>
21
22 #include <Ppi/Debug.h>
23
24 #include "DebugService.h"
25
26 EDKII_DEBUG_PPI mDebugPpi = {
27 PeiDebugBPrint,
28 PeiDebugAssert
29 };
30
31 EFI_PEI_PPI_DESCRIPTOR mDebugServicePpi = {
32 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
33 &gEdkiiDebugPpiGuid,
34 (VOID *)&mDebugPpi
35 };
36
37 /**
38 Print a debug message to debug output device if the specified error level
39 is enabled.
40
41 @param[in] ErrorLevel The error level of the debug message.
42 @param[in] Format Format string for the debug message to print.
43 @param[in] Marker BASE_LIST marker for the variable argument list.
44
45 **/
46 VOID
47 EFIAPI
48 PeiDebugBPrint(
49 IN UINTN ErrorLevel,
50 IN CONST CHAR8 *Format,
51 IN BASE_LIST Marker
52 )
53 {
54 DebugBPrint(ErrorLevel, Format, Marker);
55 }
56
57 /**
58 Print an assert message containing a filename, line number, and description.
59 This may be followed by a breakpoint or a dead loop.
60
61 @param[in] FileName The pointer to the name of the source file that
62 generated the assert condition.
63 @param[in] LineNumber The line number in the source file that generated
64 the assert condition
65 @param[in] Description The pointer to the description of the assert condition.
66
67 **/
68 VOID
69 EFIAPI
70 PeiDebugAssert(
71 IN CONST CHAR8 *FileName,
72 IN UINTN LineNumber,
73 IN CONST CHAR8 *Description
74 )
75 {
76 DebugAssert(FileName, LineNumber, Description);
77 }
78
79 /**
80 Entry point of Debug Service PEIM
81
82 This funciton installs EDKII DEBUG PPI
83
84 @param FileHandle Handle of the file being invoked.
85 @param PeiServices Describes the list of possible PEI Services.
86
87 @retval EFI_SUCESS The entry point of Debug Service PEIM executes successfully.
88 @retval Others Some error occurs during the execution of this function.
89
90 **/
91 EFI_STATUS
92 EFIAPI
93 DebugSerivceInitialize (
94 IN EFI_PEI_FILE_HANDLE FileHandle,
95 IN CONST EFI_PEI_SERVICES **PeiServices
96 )
97 {
98 return PeiServicesInstallPpi (&mDebugServicePpi);
99 }
100