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 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
7 |
|
---|
8 | **/
|
---|
9 |
|
---|
10 | #ifndef __SMM_FTW_COMMON_H__
|
---|
11 | #define __SMM_FTW_COMMON_H__
|
---|
12 |
|
---|
13 | #include <Protocol/SmmFirmwareVolumeBlock.h>
|
---|
14 | #include <Protocol/SmmFaultTolerantWrite.h>
|
---|
15 |
|
---|
16 | #define FTW_FUNCTION_GET_MAX_BLOCK_SIZE 1
|
---|
17 | #define FTW_FUNCTION_ALLOCATE 2
|
---|
18 | #define FTW_FUNCTION_WRITE 3
|
---|
19 | #define FTW_FUNCTION_RESTART 4
|
---|
20 | #define FTW_FUNCTION_ABORT 5
|
---|
21 | #define FTW_FUNCTION_GET_LAST_WRITE 6
|
---|
22 |
|
---|
23 | typedef struct {
|
---|
24 | UINTN Function;
|
---|
25 | EFI_STATUS ReturnStatus;
|
---|
26 | UINT8 Data[1];
|
---|
27 | } SMM_FTW_COMMUNICATE_FUNCTION_HEADER;
|
---|
28 |
|
---|
29 | ///
|
---|
30 | /// Size of SMM communicate header, without including the payload.
|
---|
31 | ///
|
---|
32 | #define SMM_COMMUNICATE_HEADER_SIZE (OFFSET_OF (EFI_MM_COMMUNICATE_HEADER, Data))
|
---|
33 |
|
---|
34 | ///
|
---|
35 | /// Size of SMM FTW communicate function header, without including the payload.
|
---|
36 | ///
|
---|
37 | #define SMM_FTW_COMMUNICATE_HEADER_SIZE (OFFSET_OF (SMM_FTW_COMMUNICATE_FUNCTION_HEADER, Data))
|
---|
38 |
|
---|
39 | typedef struct {
|
---|
40 | UINTN BlockSize;
|
---|
41 | } SMM_FTW_GET_MAX_BLOCK_SIZE_HEADER;
|
---|
42 |
|
---|
43 | typedef struct {
|
---|
44 | EFI_GUID CallerId;
|
---|
45 | UINTN PrivateDataSize;
|
---|
46 | UINTN NumberOfWrites;
|
---|
47 | } SMM_FTW_ALLOCATE_HEADER;
|
---|
48 |
|
---|
49 | typedef struct {
|
---|
50 | EFI_LBA Lba;
|
---|
51 | UINTN Offset;
|
---|
52 | UINTN PrivateDataSize;
|
---|
53 | EFI_PHYSICAL_ADDRESS FvbBaseAddress;
|
---|
54 | EFI_FVB_ATTRIBUTES_2 FvbAttributes;
|
---|
55 | UINTN Length;
|
---|
56 | UINT8 Data[1];
|
---|
57 | } SMM_FTW_WRITE_HEADER;
|
---|
58 |
|
---|
59 | typedef struct {
|
---|
60 | EFI_PHYSICAL_ADDRESS FvbBaseAddress;
|
---|
61 | EFI_FVB_ATTRIBUTES_2 FvbAttributes;
|
---|
62 | } SMM_FTW_RESTART_HEADER;
|
---|
63 |
|
---|
64 | typedef struct {
|
---|
65 | EFI_GUID CallerId;
|
---|
66 | EFI_LBA Lba;
|
---|
67 | UINTN Offset;
|
---|
68 | UINTN Length;
|
---|
69 | UINTN PrivateDataSize;
|
---|
70 | BOOLEAN Complete;
|
---|
71 | UINT8 Data[1];
|
---|
72 | } SMM_FTW_GET_LAST_WRITE_HEADER;
|
---|
73 |
|
---|
74 | /**
|
---|
75 | Shared entry point of the module.
|
---|
76 |
|
---|
77 | @retval EFI_SUCCESS The initialization finished successfully.
|
---|
78 | @retval EFI_OUT_OF_RESOURCES Allocate memory error
|
---|
79 | @retval EFI_INVALID_PARAMETER Workspace or Spare block does not exist
|
---|
80 |
|
---|
81 | **/
|
---|
82 | EFI_STATUS
|
---|
83 | MmFaultTolerantWriteInitialize (
|
---|
84 | VOID
|
---|
85 | );
|
---|
86 |
|
---|
87 | /**
|
---|
88 | This function checks if the buffer is valid per processor architecture and
|
---|
89 | does not overlap with SMRAM.
|
---|
90 |
|
---|
91 | @param Buffer The buffer start address to be checked.
|
---|
92 | @param Length The buffer length to be checked.
|
---|
93 |
|
---|
94 | @retval TRUE This buffer is valid per processor architecture and does not
|
---|
95 | overlap with SMRAM.
|
---|
96 | @retval FALSE This buffer is not valid per processor architecture or overlaps
|
---|
97 | with SMRAM.
|
---|
98 | **/
|
---|
99 | BOOLEAN
|
---|
100 | FtwSmmIsBufferOutsideSmmValid (
|
---|
101 | IN EFI_PHYSICAL_ADDRESS Buffer,
|
---|
102 | IN UINT64 Length
|
---|
103 | );
|
---|
104 |
|
---|
105 | /**
|
---|
106 | Notify the system that the SMM FTW driver is ready.
|
---|
107 | **/
|
---|
108 | VOID
|
---|
109 | FtwNotifySmmReady (
|
---|
110 | VOID
|
---|
111 | );
|
---|
112 |
|
---|
113 | #endif
|
---|