]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmCommon.h
MdeModulePkg/FaultTolerantWriteDxe: factor out boot service accesses
[mirror_edk2.git] / MdeModulePkg / Universal / FaultTolerantWriteDxe / FaultTolerantWriteSmmCommon.h
1 /** @file
2
3 The common header file for SMM FTW module and SMM FTW DXE Module.
4
5 Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved. <BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #ifndef __SMM_FTW_COMMON_H__
17 #define __SMM_FTW_COMMON_H__
18
19 #include <Protocol/SmmFirmwareVolumeBlock.h>
20 #include <Protocol/SmmFaultTolerantWrite.h>
21
22 #define FTW_FUNCTION_GET_MAX_BLOCK_SIZE 1
23 #define FTW_FUNCTION_ALLOCATE 2
24 #define FTW_FUNCTION_WRITE 3
25 #define FTW_FUNCTION_RESTART 4
26 #define FTW_FUNCTION_ABORT 5
27 #define FTW_FUNCTION_GET_LAST_WRITE 6
28
29 typedef struct {
30 UINTN Function;
31 EFI_STATUS ReturnStatus;
32 UINT8 Data[1];
33 } SMM_FTW_COMMUNICATE_FUNCTION_HEADER;
34
35 ///
36 /// Size of SMM communicate header, without including the payload.
37 ///
38 #define SMM_COMMUNICATE_HEADER_SIZE (OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data))
39
40 ///
41 /// Size of SMM FTW communicate function header, without including the payload.
42 ///
43 #define SMM_FTW_COMMUNICATE_HEADER_SIZE (OFFSET_OF (SMM_FTW_COMMUNICATE_FUNCTION_HEADER, Data))
44
45 typedef struct {
46 UINTN BlockSize;
47 } SMM_FTW_GET_MAX_BLOCK_SIZE_HEADER;
48
49 typedef struct {
50 EFI_GUID CallerId;
51 UINTN PrivateDataSize;
52 UINTN NumberOfWrites;
53 } SMM_FTW_ALLOCATE_HEADER;
54
55 typedef struct {
56 EFI_LBA Lba;
57 UINTN Offset;
58 UINTN PrivateDataSize;
59 EFI_PHYSICAL_ADDRESS FvbBaseAddress;
60 EFI_FVB_ATTRIBUTES_2 FvbAttributes;
61 UINTN Length;
62 UINT8 Data[1];
63 } SMM_FTW_WRITE_HEADER;
64
65 typedef struct {
66 EFI_PHYSICAL_ADDRESS FvbBaseAddress;
67 EFI_FVB_ATTRIBUTES_2 FvbAttributes;
68 } SMM_FTW_RESTART_HEADER;
69
70 typedef struct {
71 EFI_GUID CallerId;
72 EFI_LBA Lba;
73 UINTN Offset;
74 UINTN Length;
75 UINTN PrivateDataSize;
76 BOOLEAN Complete;
77 UINT8 Data[1];
78 } SMM_FTW_GET_LAST_WRITE_HEADER;
79
80 /**
81 Shared entry point of the module
82
83 @retval EFI_SUCCESS The initialization finished successfully.
84 @retval EFI_OUT_OF_RESOURCES Allocate memory error
85 @retval EFI_INVALID_PARAMETER Workspace or Spare block does not exist
86
87 **/
88 EFI_STATUS
89 MmFaultTolerantWriteInitialize (
90 VOID
91 );
92
93 /**
94 This function checks if the buffer is valid per processor architecture and
95 does not overlap with SMRAM.
96
97 @param Buffer The buffer start address to be checked.
98 @param Length The buffer length to be checked.
99
100 @retval TRUE This buffer is valid per processor architecture and does not
101 overlap with SMRAM.
102 @retval FALSE This buffer is not valid per processor architecture or overlaps
103 with SMRAM.
104 **/
105 BOOLEAN
106 FtwSmmIsBufferOutsideSmmValid (
107 IN EFI_PHYSICAL_ADDRESS Buffer,
108 IN UINT64 Length
109 );
110
111 /**
112 Notify the system that the SMM FTW driver is ready
113 **/
114 VOID
115 FtwNotifySmmReady (
116 VOID
117 );
118
119 #endif