]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Include/Library/ResetUtilityLib.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Include / Library / ResetUtilityLib.h
1 /** @file
2 This header describes various helper functions for resetting the system.
3
4 Copyright (c) 2017 Intel Corporation. All rights reserved.<BR>
5 Copyright (c) 2016 Microsoft Corporation. All rights reserved.<BR>
6
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9 **/
10 #ifndef _RESET_UTILITY_LIB_H_
11 #define _RESET_UTILITY_LIB_H_
12
13 /**
14 This is a shorthand helper function to reset with a subtype so that
15 the caller doesn't have to bother with a function that has half a dozen
16 parameters.
17
18 This will generate a reset with status EFI_SUCCESS, a NULL string, and
19 no custom data. The subtype will be formatted in such a way that it can be
20 picked up by notification registrations and custom handlers.
21
22 NOTE: This call will fail if the architectural ResetSystem underpinnings
23 are not initialized. For DXE, you can add gEfiResetArchProtocolGuid
24 to your DEPEX.
25
26 @param[in] ResetSubtype GUID pointer for the reset subtype to be used.
27
28 **/
29 VOID
30 EFIAPI
31 ResetPlatformSpecificGuid (
32 IN CONST GUID *ResetSubtype
33 );
34
35 /**
36 This function examines the DataSize and ResetData parameters passed to
37 to ResetSystem() and detemrines if the ResetData contains a Null-terminated
38 Unicode string followed by a GUID specific subtype. If the GUID specific
39 subtype is present, then a pointer to the GUID value in ResetData is returned.
40
41 @param[in] DataSize The size, in bytes, of ResetData.
42 @param[in] ResetData Pointer to the data buffer passed into ResetSystem().
43
44 @retval Pointer Pointer to the GUID value in ResetData.
45 @retval NULL ResetData is NULL.
46 @retval NULL ResetData does not start with a Null-terminated
47 Unicode string.
48 @retval NULL A Null-terminated Unicode string is present, but there
49 are less than sizeof (GUID) bytes after the string.
50 @retval NULL No subtype is found.
51
52 **/
53 GUID *
54 EFIAPI
55 GetResetPlatformSpecificGuid (
56 IN UINTN DataSize,
57 IN CONST VOID *ResetData
58 );
59
60 /**
61 This is a helper function that creates the reset data buffer that can be
62 passed into ResetSystem().
63
64 The reset data buffer is returned in ResetData and contains ResetString
65 followed by the ResetSubtype GUID followed by the ExtraData.
66
67 NOTE: Strings are internally limited by MAX_UINT16.
68
69 @param[in, out] ResetDataSize On input, the size of the ResetData buffer. On
70 output, either the total number of bytes
71 copied, or the required buffer size.
72 @param[in, out] ResetData A pointer to the buffer in which to place the
73 final structure.
74 @param[in] ResetSubtype Pointer to the GUID specific subtype. This
75 parameter is optional and may be NULL.
76 @param[in] ResetString Pointer to a Null-terminated Unicode string
77 that describes the reset. This parameter is
78 optional and may be NULL.
79 @param[in] ExtraDataSize The size, in bytes, of ExtraData buffer.
80 @param[in] ExtraData Pointer to a buffer of extra data. This
81 parameter is optional and may be NULL.
82
83 @retval RETURN_SUCCESS ResetDataSize and ResetData are updated.
84 @retval RETURN_INVALID_PARAMETER ResetDataSize is NULL.
85 @retval RETURN_INVALID_PARAMETER ResetData is NULL.
86 @retval RETURN_INVALID_PARAMETER ExtraData was provided without a
87 ResetSubtype. This is not supported by the
88 UEFI spec.
89 @retval RETURN_BUFFER_TOO_SMALL An insufficient buffer was provided.
90 ResetDataSize is updated with minimum size
91 required.
92 **/
93 RETURN_STATUS
94 EFIAPI
95 BuildResetData (
96 IN OUT UINTN *ResetDataSize,
97 IN OUT VOID *ResetData,
98 IN CONST GUID *ResetSubtype OPTIONAL,
99 IN CONST CHAR16 *ResetString OPTIONAL,
100 IN UINTN ExtraDataSize OPTIONAL,
101 IN CONST VOID *ExtraData OPTIONAL
102 );
103
104 #endif // _RESET_UTILITY_LIB_H_