xref: /freebsd/stand/efi/include/efifs.h (revision b9f654b163bce26de79705e77b872427c9f2afa1)
1 /* $FreeBSD$ */
2 #ifndef _EFI_FS_H
3 #define _EFI_FS_H
4 
5 /*++
6 
7 Copyright (c)  1999 - 2002 Intel Corporation. All rights reserved
8 This software and associated documentation (if any) is furnished
9 under a license and may only be used or copied in accordance
10 with the terms of the license. Except as permitted by such
11 license, no part of this software or documentation may be
12 reproduced, stored in a retrieval system, or transmitted in any
13 form or by any means without the express written consent of
14 Intel Corporation.
15 
16 Module Name:
17 
18     efifs.h
19 
20 Abstract:
21 
22     EFI File System structures
23 
24 
25 
26 Revision History
27 
28 --*/
29 
30 
31 //
32 // EFI Partition header (normaly starts in LBA 1)
33 //
34 
35 #define EFI_PARTITION_SIGNATURE         0x5053595320494249
36 #define EFI_PARTITION_REVISION          0x00010001
37 #define MIN_EFI_PARTITION_BLOCK_SIZE    512
38 #define EFI_PARTITION_LBA               1
39 
40 typedef struct _EFI_PARTITION_HEADER {
41     EFI_TABLE_HEADER    Hdr;
42     UINT32              DirectoryAllocationNumber;
43     UINT32              BlockSize;
44     EFI_LBA             FirstUsableLba;
45     EFI_LBA             LastUsableLba;
46     EFI_LBA             UnusableSpace;
47     EFI_LBA             FreeSpace;
48     EFI_LBA             RootFile;
49     EFI_LBA             SecutiryFile;
50 } EFI_PARTITION_HEADER;
51 
52 
53 //
54 // File header
55 //
56 
57 #define EFI_FILE_HEADER_SIGNATURE   0x454c494620494249
58 #define EFI_FILE_HEADER_REVISION    0x00010000
59 #define EFI_FILE_STRING_SIZE        260
60 
61 typedef struct _EFI_FILE_HEADER {
62     EFI_TABLE_HEADER    Hdr;
63     UINT32              Class;
64     UINT32              LBALOffset;
65     EFI_LBA             Parent;
66     UINT64              FileSize;
67     UINT64              FileAttributes;
68     EFI_TIME            FileCreateTime;
69     EFI_TIME            FileModificationTime;
70     EFI_GUID            VendorGuid;
71     CHAR16              FileString[EFI_FILE_STRING_SIZE];
72 } EFI_FILE_HEADER;
73 
74 
75 //
76 // Return the file's first LBAL which is in the same
77 // logical block as the file header
78 //
79 
80 #define EFI_FILE_LBAL(a)    ((EFI_LBAL *) (((CHAR8 *) (a)) + (a)->LBALOffset))
81 
82 #define EFI_FILE_CLASS_FREE_SPACE   1
83 #define EFI_FILE_CLASS_EMPTY        2
84 #define EFI_FILE_CLASS_NORMAL       3
85 
86 
87 //
88 // Logical Block Address List - the fundemental block
89 // description structure
90 //
91 
92 #define EFI_LBAL_SIGNATURE      0x4c41424c20494249
93 #define EFI_LBAL_REVISION       0x00010000
94 
95 typedef struct _EFI_LBAL {
96     EFI_TABLE_HEADER    Hdr;
97     UINT32              Class;
98     EFI_LBA             Parent;
99     EFI_LBA             Next;
100     UINT32              ArraySize;
101     UINT32              ArrayCount;
102 } EFI_LBAL;
103 
104 // Array size
105 #define EFI_LBAL_ARRAY_SIZE(lbal,offs,blks)  \
106         (((blks) - (offs) - (lbal)->Hdr.HeaderSize) / sizeof(EFI_RL))
107 
108 //
109 // Logical Block run-length
110 //
111 
112 typedef struct {
113     EFI_LBA     Start;
114     UINT64      Length;
115 } EFI_RL;
116 
117 //
118 // Return the run-length structure from an LBAL header
119 //
120 
121 #define EFI_LBAL_RL(a)      ((EFI_RL*) (((CHAR8 *) (a)) + (a)->Hdr.HeaderSize))
122 
123 #endif
124