1 /** @file
2   Guid & data structure used for EFI System Resource Table (ESRT)
3 
4   Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
5   SPDX-License-Identifier: BSD-2-Clause-Patent
6 
7   @par Revision Reference:
8   GUIDs defined in UEFI 2.5 spec.
9 
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 
46 typedef struct {
47   ///
48   /// The firmware class field contains a GUID that identifies a firmware component
49   /// that can be updated via UpdateCapsule(). This GUID must be unique within all
50   /// entries of the ESRT.
51   ///
52   EFI_GUID                   FwClass;
53   ///
54   /// Identifies the type of firmware resource.
55   ///
56   UINT32                     FwType;
57   ///
58   /// The firmware version field represents the current version of the firmware
59   /// resource, value must always increase as a larger number represents a newer
60   /// version.
61   ///
62   UINT32                     FwVersion;
63   ///
64   /// The lowest firmware resource version to which a firmware resource can be
65   /// rolled back for the given system/device. Generally this is used to protect
66   /// against known and fixed security issues.
67   ///
68   UINT32                     LowestSupportedFwVersion;
69   ///
70   /// The capsule flags field contains the CapsuleGuid flags (bits 0- 15) as defined
71   /// in the EFI_CAPSULE_HEADER that will be set in the capsule header.
72   ///
73   UINT32                     CapsuleFlags;
74   ///
75   /// The last attempt version field describes the last firmware version for which
76   /// an update was attempted (uses the same format as Firmware Version).
77   /// Last Attempt Version is updated each time an UpdateCapsule() is attempted for
78   /// an ESRT entry and is preserved across reboots (non-volatile). However, in
79   /// cases where the attempt version is not recorded due to limitations in the
80   /// update process, the field shall set to zero after a failed update. Similarly,
81   /// in the case of a removable device, this value is set to 0 in cases where the
82   /// device has not been updated since being added to the system.
83   ///
84   UINT32                     LastAttemptVersion;
85   ///
86   /// The last attempt status field describes the result of the last firmware update
87   /// attempt for the firmware resource entry.
88   /// LastAttemptStatus is updated each time an UpdateCapsule() is attempted for an
89   /// ESRT entry and is preserved across reboots (non-volatile).
90   /// If a firmware update has never been attempted or is unknown, for example after
91   /// fresh insertion of a removable device, LastAttemptStatus must be set to Success.
92   ///
93   UINT32                     LastAttemptStatus;
94 } EFI_SYSTEM_RESOURCE_ENTRY;
95 
96 typedef struct {
97   ///
98   /// The number of firmware resources in the table, must not be zero.
99   ///
100   UINT32                     FwResourceCount;
101   ///
102   /// The maximum number of resource array entries that can be within the table
103   /// without reallocating the table, must not be zero.
104   ///
105   UINT32                     FwResourceCountMax;
106   ///
107   /// The version of the EFI_SYSTEM_RESOURCE_ENTRY entities used in this table.
108   /// This field should be set to 1.
109   ///
110   UINT64                     FwResourceVersion;
111   ///
112   /// Array of EFI_SYSTEM_RESOURCE_ENTRY
113   ///
114   //EFI_SYSTEM_RESOURCE_ENTRY  Entries[];
115 } EFI_SYSTEM_RESOURCE_TABLE;
116 
117 extern EFI_GUID gEfiSystemResourceTableGuid;
118 
119 #endif
120