summaryrefslogtreecommitdiff
path: root/Vlv2TbltDevicePkg/FmpSample/FmpSample.h
blob: 8a9589f12b0a8cc21a50db7a212f91c42239b605 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/** @file
  FmpSample header file

  Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>

  This program and the accompanying materials
  are licensed and made available under the terms and conditions of the BSD License
  which accompanies this distribution.  The full text of the license may be found at
  http://opensource.org/licenses/bsd-license.php.

  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

**/

#ifndef _FMP_SAMPLE_UPDATE_H_
#define _FMP_SAMPLE_UPDATE_H_

#include <PiDxe.h>

#include <Guid/SystemResourceTable.h>
#include <Guid/FmpSampleImageInfoGuid.h>

#include <Protocol/FirmwareManagement.h>

#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PcdLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/DevicePathLib.h>
#include <Library/HobLib.h>

//
// Current Firmwarre version
//
#define CURRENT_FIRMWARE_VERSION            0x00000001
//
// The lowesest Supported Firmware Version
//
#define LOWEST_SUPPORTED_FIRMWARE_VERSION   0x00000001


//
// Image Version number
//

#define FMP_SAMPLE_PRIVATE_DATA_SIGNATURE  SIGNATURE_32('F', 'M', 'P', 'S')

#pragma pack(1)
typedef struct{
  UINT32 Version;
  UINT32 Data;
}FMP_SAMPLE_UDPATE_DATA;
#pragma pack()

//
// LAN MAC private data structure.
//
struct _FMP_SAMPLE_PRIVATE_DATA{
  UINT32                            Signature;
  EFI_FIRMWARE_MANAGEMENT_PROTOCOL  Fmp;
  EFI_HANDLE                        Handle;
  UINT8                             DescriptorCount;
  EFI_SYSTEM_RESOURCE_ENTRY         EsrtInfo;
  FMP_SAMPLE_UDPATE_DATA            UpdateData;
};

typedef struct _FMP_SAMPLE_PRIVATE_DATA  FMP_SAMPLE_PRIVATE_DATA;


/**
  Returns a pointer to the FMP_SAMPLE_PRIVATE_DATA structure from the input a as Fmp.
  
  If the signatures matches, then a pointer to the data structure that contains 
  a specified field of that data structure is returned.
   
  @param  a              Pointer to the field specified by ServiceBinding within 
                         a data structure of type FMP_SAMPLE_PRIVATE_DATA.
 
**/
#define FMP_SAMPLE_PRIVATE_DATA_FROM_FMP(a) \
  CR ( \
  (a), \
  FMP_SAMPLE_PRIVATE_DATA, \
  Fmp, \
  FMP_SAMPLE_PRIVATE_DATA_SIGNATURE \
  )


EFI_STATUS
EFIAPI FmpGetImageInfo(
  IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL       *This,
  IN OUT    UINTN                           *ImageInfoSize,
  IN OUT    EFI_FIRMWARE_IMAGE_DESCRIPTOR   *ImageInfo,
  OUT       UINT32                          *DescriptorVersion,
  OUT       UINT8                           *DescriptorCount,
  OUT       UINTN                           *DescriptorSize,
  OUT       UINT32                          *PackageVersion,
  OUT       CHAR16                          **PackageVersionName
  );

EFI_STATUS
EFIAPI FmpGetImage(
  IN  EFI_FIRMWARE_MANAGEMENT_PROTOCOL  *This,
  IN  UINT8                             ImageIndex,
  IN  OUT  VOID                         *Image,
  IN  OUT  UINTN                        *ImageSize
  );

EFI_STATUS
EFIAPI FmpSetImage(
  IN  EFI_FIRMWARE_MANAGEMENT_PROTOCOL                 *This,
  IN  UINT8                                            ImageIndex,
  IN  CONST VOID                                       *Image,
  IN  UINTN                                            ImageSize,
  IN  CONST VOID                                       *VendorCode,
  IN  EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS    Progress,
  OUT CHAR16                                           **AbortReason
  );

EFI_STATUS
EFIAPI FmpCheckImage(
  IN  EFI_FIRMWARE_MANAGEMENT_PROTOCOL  *This,
  IN  UINT8                             ImageIndex,
  IN  CONST VOID                        *Image,
  IN  UINTN                             ImageSize,
  OUT UINT32                            *ImageUpdatable
  );

EFI_STATUS
EFIAPI FmpGetPackageInfo(
  IN  EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
  OUT UINT32                           *PackageVersion,
  OUT CHAR16                           **PackageVersionName,
  OUT UINT32                           *PackageVersionNameMaxLen,
  OUT UINT64                           *AttributesSupported,
  OUT UINT64                           *AttributesSetting
  );

EFI_STATUS
EFIAPI FmpSetPackageInfo(
  IN  EFI_FIRMWARE_MANAGEMENT_PROTOCOL   *This,
  IN  CONST VOID                         *Image,
  IN  UINTN                              ImageSize,
  IN  CONST VOID                         *VendorCode,
  IN  UINT32                             PackageVersion,
  IN  CONST CHAR16                       *PackageVersionName
  );

/*++
  
  Routine Description:
  
     Initialize FmpSampleDriver private data structure.
  
  Arguments:
  

     FmpSamplePrivate     - private data structure to be initialized.
  
  Returns:

  --*/
EFI_STATUS
InitializePrivateData(
  IN FMP_SAMPLE_PRIVATE_DATA *FmpSamplePrivate
  );

extern EFI_FIRMWARE_MANAGEMENT_PROTOCOL mFirmwareManagementProtocol;

#endif