ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / fs / partitions / efi.h
1 /************************************************************
2  * EFI GUID Partition Table
3  * Per Intel EFI Specification v1.02
4  * http://developer.intel.com/technology/efi/efi.htm
5  *
6  * By Matt Domsch <Matt_Domsch@dell.com>  Fri Sep 22 22:15:56 CDT 2000  
7  *   Copyright 2000,2001 Dell Inc.
8  *
9  *  This program is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 2 of the License, or
12  *  (at your option) any later version.
13  * 
14  *  This program is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *
19  *  You should have received a copy of the GNU General Public License
20  *  along with this program; if not, write to the Free Software
21  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  * 
23  ************************************************************/
24
25 #ifndef FS_PART_EFI_H_INCLUDED
26 #define FS_PART_EFI_H_INCLUDED
27
28 #include <linux/types.h>
29 #include <linux/config.h>
30 #include <linux/fs.h>
31 #include <linux/genhd.h>
32 #include <linux/kernel.h>
33 #include <linux/major.h>
34 #include <linux/string.h>
35 #include <linux/efi.h>
36
37 #define MSDOS_MBR_SIGNATURE 0xaa55
38 #define EFI_PMBR_OSTYPE_EFI 0xEF
39 #define EFI_PMBR_OSTYPE_EFI_GPT 0xEE
40
41 #define GPT_BLOCK_SIZE 512
42 #define GPT_HEADER_SIGNATURE 0x5452415020494645ULL
43 #define GPT_HEADER_REVISION_V1 0x00010000
44 #define GPT_PRIMARY_PARTITION_TABLE_LBA 1
45
46 #define PARTITION_SYSTEM_GUID \
47     EFI_GUID( 0xC12A7328, 0xF81F, 0x11d2, \
48               0xBA, 0x4B, 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B) 
49 #define LEGACY_MBR_PARTITION_GUID \
50     EFI_GUID( 0x024DEE41, 0x33E7, 0x11d3, \
51               0x9D, 0x69, 0x00, 0x08, 0xC7, 0x81, 0xF3, 0x9F)
52 #define PARTITION_MSFT_RESERVED_GUID \
53     EFI_GUID( 0xE3C9E316, 0x0B5C, 0x4DB8, \
54               0x81, 0x7D, 0xF9, 0x2D, 0xF0, 0x02, 0x15, 0xAE)
55 #define PARTITION_BASIC_DATA_GUID \
56     EFI_GUID( 0xEBD0A0A2, 0xB9E5, 0x4433, \
57               0x87, 0xC0, 0x68, 0xB6, 0xB7, 0x26, 0x99, 0xC7)
58 #define PARTITION_LINUX_RAID_GUID \
59     EFI_GUID( 0xa19d880f, 0x05fc, 0x4d3b, \
60               0xa0, 0x06, 0x74, 0x3f, 0x0f, 0x84, 0x91, 0x1e)
61 #define PARTITION_LINUX_SWAP_GUID \
62     EFI_GUID( 0x0657fd6d, 0xa4ab, 0x43c4, \
63               0x84, 0xe5, 0x09, 0x33, 0xc8, 0x4b, 0x4f, 0x4f)
64 #define PARTITION_LINUX_LVM_GUID \
65     EFI_GUID( 0xe6d6d379, 0xf507, 0x44c2, \
66               0xa2, 0x3c, 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28)
67
68 typedef struct _gpt_header {
69         u64 signature;
70         u32 revision;
71         u32 header_size;
72         u32 header_crc32;
73         u32 reserved1;
74         u64 my_lba;
75         u64 alternate_lba;
76         u64 first_usable_lba;
77         u64 last_usable_lba;
78         efi_guid_t disk_guid;
79         u64 partition_entry_lba;
80         u32 num_partition_entries;
81         u32 sizeof_partition_entry;
82         u32 partition_entry_array_crc32;
83         u8 reserved2[GPT_BLOCK_SIZE - 92];
84 } __attribute__ ((packed)) gpt_header;
85
86 typedef struct _gpt_entry_attributes {
87         u64 required_to_function:1;
88         u64 reserved:47;
89         u64 type_guid_specific:16;
90 } __attribute__ ((packed)) gpt_entry_attributes;
91
92 typedef struct _gpt_entry {
93         efi_guid_t partition_type_guid;
94         efi_guid_t unique_partition_guid;
95         u64 starting_lba;
96         u64 ending_lba;
97         gpt_entry_attributes attributes;
98         efi_char16_t partition_name[72 / sizeof (efi_char16_t)];
99 } __attribute__ ((packed)) gpt_entry;
100
101 typedef struct _legacy_mbr {
102         u8 boot_code[440];
103         u32 unique_mbr_signature;
104         u16 unknown;
105         struct partition partition_record[4];
106         u16 signature;
107 } __attribute__ ((packed)) legacy_mbr;
108
109 /* Functions */
110 extern int efi_partition(struct parsed_partitions *state, struct block_device *bdev);
111
112 #endif
113
114 /*
115  * Overrides for Emacs so that we follow Linus's tabbing style.
116  * Emacs will notice this stuff at the end of the file and automatically
117  * adjust the settings for this buffer only.  This must remain at the end
118  * of the file.
119  * --------------------------------------------------------------------------
120  * Local variables:
121  * c-indent-level: 4 
122  * c-brace-imaginary-offset: 0
123  * c-brace-offset: -4
124  * c-argdecl-indent: 4
125  * c-label-offset: -4
126  * c-continued-statement-offset: 4
127  * c-continued-brace-offset: 0
128  * indent-tabs-mode: nil
129  * tab-width: 8
130  * End:
131  */