]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h
MdeModulePkg: Add ResetSystemPei PEIM
[mirror_edk2.git] / MdeModulePkg / Universal / ResetSystemPei / ResetSystem.h
1 /** @file
2
3 Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR>
4
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef _RESET_SYSTEM2_H_
16 #define _RESET_SYSTEM2_H_
17
18
19 #include <Uefi.h>
20 #include <PiPei.h>
21
22 #include <Ppi/Reset2.h>
23 #include <Ppi/PlatformSpecificResetFilter.h>
24 #include <Ppi/PlatformSpecificResetHandler.h>
25
26 #include <Library/BaseLib.h>
27 #include <Library/BaseMemoryLib.h>
28 #include <Library/DebugLib.h>
29 #include <Library/PeiServicesLib.h>
30 #include <Library/HobLib.h>
31 #include <Library/ResetSystemLib.h>
32 #include <Library/ReportStatusCodeLib.h>
33
34
35 //
36 // The maximum recursion depth to ResetSystem() by reset notification handlers
37 //
38 #define MAX_RESET_NOTIFY_DEPTH 10
39
40 //
41 // Data to put in GUIDed HOB
42 //
43 typedef struct {
44 UINT32 Signature;
45 UINT32 Count;
46 EFI_RESET_SYSTEM ResetFilters[0]; // ResetFilters[PcdGet32 (PcdMaximumResetNotifies)]
47 } RESET_FILTER_LIST;
48 #define RESET_FILTER_LIST_SIGNATURE SIGNATURE_32('r', 's', 't', 'l')
49
50
51 typedef struct {
52 EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI ResetFilter;
53 EFI_GUID *Guid;
54 } RESET_FILTER_INSTANCE;
55
56 /**
57 Resets the entire platform.
58
59 @param[in] ResetType The type of reset to perform.
60 @param[in] ResetStatus The status code for the reset.
61 @param[in] DataSize The size, in bytes, of ResetData.
62 @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or
63 EfiResetShutdown the data buffer starts with a Null-terminated
64 string, optionally followed by additional binary data.
65 The string is a description that the caller may use to further
66 indicate the reason for the system reset. ResetData is only
67 valid if ResetStatus is something other than EFI_SUCCESS
68 unless the ResetType is EfiResetPlatformSpecific
69 where a minimum amount of ResetData is always required.
70 For a ResetType of EfiResetPlatformSpecific the data buffer
71 also starts with a Null-terminated string that is followed
72 by an EFI_GUID that describes the specific type of reset to perform.
73
74 **/
75 VOID
76 EFIAPI
77 ResetSystem2 (
78 IN EFI_RESET_TYPE ResetType,
79 IN EFI_STATUS ResetStatus,
80 IN UINTN DataSize,
81 IN VOID *ResetData OPTIONAL
82 );
83 /**
84 Register a notification function to be called when ResetSystem() is called.
85
86 The RegisterResetNotify() function registers a notification function that is called when
87 ResetSystem()is called and prior to completing the reset of the platform.
88 The registered functions must not perform a platform reset themselves. These
89 notifications are intended only for the notification of components which may need some
90 special-purpose maintenance prior to the platform resetting.
91
92 @param[in] This A pointer to the EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI instance.
93 @param[in] ResetFunction Points to the function to be called when a ResetSystem() is executed.
94
95 @retval EFI_SUCCESS The reset notification function was successfully registered.
96 @retval EFI_INVALID_PARAMETER ResetFunction is NULL.
97 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to register the reset notification function.
98 @retval EFI_ALREADY_STARTED The reset notification function specified by ResetFunction has already been registered.
99
100 **/
101 EFI_STATUS
102 EFIAPI
103 RegisterResetNotify (
104 IN EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI *This,
105 IN EFI_RESET_SYSTEM ResetFunction
106 );
107
108 /**
109 Unregister a notification function.
110
111 The UnregisterResetNotify() function removes the previously registered
112 notification using RegisterResetNotify().
113
114 @param[in] This A pointer to the EFI_RESET_NOTIFICATION_PROTOCOL instance.
115 @param[in] ResetFunction The pointer to the ResetFunction being unregistered.
116
117 @retval EFI_SUCCESS The reset notification function was unregistered.
118 @retval EFI_INVALID_PARAMETER ResetFunction is NULL.
119 @retval EFI_INVALID_PARAMETER The reset notification function specified by ResetFunction was not previously
120 registered using RegisterResetNotify().
121
122 **/
123 EFI_STATUS
124 EFIAPI
125 UnregisterResetNotify (
126 IN EFI_RESET_NOTIFICATION_PROTOCOL *This,
127 IN EFI_RESET_SYSTEM ResetFunction
128 );
129 #endif