1 /** @file
2   Guid & data structure used for EFI System Resource Table (ESRT)
3 
4   Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.<BR>
5   Copyright (c) Microsoft Corporation.<BR>
6   SPDX-License-Identifier: BSD-2-Clause-Patent
7 
8   @par Revision Reference:
9   GUIDs defined in UEFI 2.5 spec.
10 
11 **/
12 
13 #ifndef _SYSTEM_RESOURCE_TABLE_H__
14 #define _SYSTEM_RESOURCE_TABLE_H__
15 
16 #define EFI_SYSTEM_RESOURCE_TABLE_GUID \
17   { \
18     0xb122a263, 0x3661, 0x4f68, {0x99, 0x29, 0x78, 0xf8, 0xb0, 0xd6, 0x21, 0x80 } \
19   }
20 
21 ///
22 /// Current Entry Version
23 ///
24 #define EFI_SYSTEM_RESOURCE_TABLE_FIRMWARE_RESOURCE_VERSION  1
25 
26 ///
27 /// Firmware Type Definitions
28 ///
29 #define ESRT_FW_TYPE_UNKNOWN         0x00000000
30 #define ESRT_FW_TYPE_SYSTEMFIRMWARE  0x00000001
31 #define ESRT_FW_TYPE_DEVICEFIRMWARE  0x00000002
32 #define ESRT_FW_TYPE_UEFIDRIVER      0x00000003
33 
34 ///
35 /// Last Attempt Status Values
36 ///
37 #define LAST_ATTEMPT_STATUS_SUCCESS                         0x00000000
38 #define LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL              0x00000001
39 #define LAST_ATTEMPT_STATUS_ERROR_INSUFFICIENT_RESOURCES    0x00000002
40 #define LAST_ATTEMPT_STATUS_ERROR_INCORRECT_VERSION         0x00000003
41 #define LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT            0x00000004
42 #define LAST_ATTEMPT_STATUS_ERROR_AUTH_ERROR                0x00000005
43 #define LAST_ATTEMPT_STATUS_ERROR_PWR_EVT_AC                0x00000006
44 #define LAST_ATTEMPT_STATUS_ERROR_PWR_EVT_BATT              0x00000007
45 #define LAST_ATTEMPT_STATUS_ERROR_UNSATISFIED_DEPENDENCIES  0x00000008
46 
47 ///
48 /// LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL_VENDOR_RANGE_MAX is defined as
49 /// 0x4000 as of UEFI Specification 2.8B. This will be modified in the
50 /// future to the correct value 0x3FFF. To ensure correct implementation,
51 /// this change is preemptively made in the value defined below.
52 ///
53 /// When the UEFI Specification is updated, this comment block can be
54 /// removed.
55 ///
56 #define LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL_VENDOR_RANGE_MIN  0x00001000
57 #define LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL_VENDOR_RANGE_MAX  0x00003FFF
58 
59 typedef struct {
60   ///
61   /// The firmware class field contains a GUID that identifies a firmware component
62   /// that can be updated via UpdateCapsule(). This GUID must be unique within all
63   /// entries of the ESRT.
64   ///
65   EFI_GUID    FwClass;
66   ///
67   /// Identifies the type of firmware resource.
68   ///
69   UINT32      FwType;
70   ///
71   /// The firmware version field represents the current version of the firmware
72   /// resource, value must always increase as a larger number represents a newer
73   /// version.
74   ///
75   UINT32      FwVersion;
76   ///
77   /// The lowest firmware resource version to which a firmware resource can be
78   /// rolled back for the given system/device. Generally this is used to protect
79   /// against known and fixed security issues.
80   ///
81   UINT32      LowestSupportedFwVersion;
82   ///
83   /// The capsule flags field contains the CapsuleGuid flags (bits 0- 15) as defined
84   /// in the EFI_CAPSULE_HEADER that will be set in the capsule header.
85   ///
86   UINT32      CapsuleFlags;
87   ///
88   /// The last attempt version field describes the last firmware version for which
89   /// an update was attempted (uses the same format as Firmware Version).
90   /// Last Attempt Version is updated each time an UpdateCapsule() is attempted for
91   /// an ESRT entry and is preserved across reboots (non-volatile). However, in
92   /// cases where the attempt version is not recorded due to limitations in the
93   /// update process, the field shall set to zero after a failed update. Similarly,
94   /// in the case of a removable device, this value is set to 0 in cases where the
95   /// device has not been updated since being added to the system.
96   ///
97   UINT32    LastAttemptVersion;
98   ///
99   /// The last attempt status field describes the result of the last firmware update
100   /// attempt for the firmware resource entry.
101   /// LastAttemptStatus is updated each time an UpdateCapsule() is attempted for an
102   /// ESRT entry and is preserved across reboots (non-volatile).
103   /// If a firmware update has never been attempted or is unknown, for example after
104   /// fresh insertion of a removable device, LastAttemptStatus must be set to Success.
105   ///
106   UINT32    LastAttemptStatus;
107 } EFI_SYSTEM_RESOURCE_ENTRY;
108 
109 typedef struct {
110   ///
111   /// The number of firmware resources in the table, must not be zero.
112   ///
113   UINT32    FwResourceCount;
114   ///
115   /// The maximum number of resource array entries that can be within the table
116   /// without reallocating the table, must not be zero.
117   ///
118   UINT32    FwResourceCountMax;
119   ///
120   /// The version of the EFI_SYSTEM_RESOURCE_ENTRY entities used in this table.
121   /// This field should be set to 1.
122   ///
123   UINT64    FwResourceVersion;
124   ///
125   /// Array of EFI_SYSTEM_RESOURCE_ENTRY
126   ///
127   // EFI_SYSTEM_RESOURCE_ENTRY  Entries[];
128 } EFI_SYSTEM_RESOURCE_TABLE;
129 
130 extern EFI_GUID  gEfiSystemResourceTableGuid;
131 
132 #endif
133