1 /*++
2 
3 Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution.  The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8 
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11 
12 Module Name:
13 
14   EfiFirmwareFileSystem.h
15 
16 Abstract:
17 
18   This file defines the data structures that comprise the FFS file system.
19 
20 --*/
21 
22 #ifndef _EFI_FFS_FILE_SYSTEM_H_
23 #define _EFI_FFS_FILE_SYSTEM_H_
24 
25 #include "EfiImageFormat.h"
26 
27 //
28 // GUIDs defined by the FFS specification.
29 //
30 #define EFI_FIRMWARE_FILE_SYSTEM_GUID \
31   { \
32     0x7A9354D9, 0x0468, 0x444a, {0x81, 0xCE, 0x0B, 0xF6, 0x17, 0xD8, 0x90, 0xDF} \
33   }
34 
35 #define EFI_FFS_VOLUME_TOP_FILE_GUID \
36   { \
37     0x1BA0062E, 0xC779, 0x4582, {0x85, 0x66, 0x33, 0x6A, 0xE8, 0xF7, 0x8F, 0x9} \
38   }
39 
40 //
41 // FFS specific file types
42 //
43 #define EFI_FV_FILETYPE_FFS_PAD 0xF0
44 
45 //
46 // FFS File Attributes
47 //
48 #define FFS_ATTRIB_TAIL_PRESENT     0x01
49 #define FFS_ATTRIB_RECOVERY         0x02
50 #define FFS_ATTRIB_DATA_ALIGNMENT   0x38
51 #define FFS_ATTRIB_CHECKSUM         0x40
52 #if (PI_SPECIFICATION_VERSION < 0x00010000)
53 #define FFS_ATTRIB_HEADER_EXTENSION 0x04
54 #else
55 //
56 // PI 1.0 definition.
57 //
58 #define FFS_ATTRIB_FIXED           0x04
59 #endif
60 
61 
62 //
63 // FFS_FIXED_CHECKSUM is the default checksum value used when the
64 // FFS_ATTRIB_CHECKSUM attribute bit is clear
65 // This value is defined in PI 1.2.
66 //
67 #define FFS_FIXED_CHECKSUM  0xAA
68 
69 
70 //
71 // File state definitions
72 //
73 #define EFI_FILE_HEADER_CONSTRUCTION  0x01
74 #define EFI_FILE_HEADER_VALID         0x02
75 #define EFI_FILE_DATA_VALID           0x04
76 #define EFI_FILE_MARKED_FOR_UPDATE    0x08
77 #define EFI_FILE_DELETED              0x10
78 #define EFI_FILE_HEADER_INVALID       0x20
79 
80 #define EFI_FILE_ALL_STATE_BITS       (EFI_FILE_HEADER_CONSTRUCTION | \
81                                  EFI_FILE_HEADER_VALID | \
82                                  EFI_FILE_DATA_VALID | \
83                                  EFI_FILE_MARKED_FOR_UPDATE | \
84                                  EFI_FILE_DELETED | \
85                                  EFI_FILE_HEADER_INVALID \
86           )
87 
88 #define EFI_TEST_FFS_ATTRIBUTES_BIT(FvbAttributes, TestAttributes, Bit) \
89     ( \
90       (BOOLEAN) ( \
91           (FvbAttributes & EFI_FVB_ERASE_POLARITY) ? (((~TestAttributes) & Bit) == Bit) : ((TestAttributes & Bit) == Bit) \
92         ) \
93     )
94 
95 //
96 // FFS file integrity check structure
97 //
98 typedef UINT16  EFI_FFS_FILE_TAIL;
99 
100 typedef union {
101   struct {
102     UINT8 Header;
103     UINT8 File;
104   } Checksum;
105 #if (PI_SPECIFICATION_VERSION < 0x00010000)
106   UINT16  TailReference;
107 #else
108   UINT16  Checksum16;
109 #endif
110 } EFI_FFS_INTEGRITY_CHECK;
111 
112 //
113 // FFS file header definition
114 //
115 typedef UINT8 EFI_FFS_FILE_ATTRIBUTES;
116 typedef UINT8 EFI_FFS_FILE_STATE;
117 
118 typedef struct {
119   EFI_GUID                Name;
120   EFI_FFS_INTEGRITY_CHECK IntegrityCheck;
121   EFI_FV_FILETYPE         Type;
122   EFI_FFS_FILE_ATTRIBUTES Attributes;
123   UINT8                   Size[3];
124   EFI_FFS_FILE_STATE      State;
125 } EFI_FFS_FILE_HEADER;
126 
127 #endif
128