1 /** @file
2 
3   The common header file for SMM FTW module and SMM FTW DXE Module.
4 
5 Copyright (c) 2011, 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 #endif
81