xref: /illumos-gate/usr/src/grub/grub-0.97/stage2/gpt.h (revision 44bc9120)
1 /*
2  *  GRUB  --  GRand Unified Bootloader
3  *  Copyright (C) 2002,2005,2006   Free Software Foundation, Inc.
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 
20 #ifndef _GPT_H
21 #define _GPT_H
22 
23 typedef signed char grub_int8_t;
24 typedef signed short grub_int16_t;
25 typedef signed int grub_int32_t;
26 typedef signed long long int grub_int64_t;
27 typedef unsigned char grub_uint8_t;
28 typedef unsigned short grub_uint16_t;
29 typedef unsigned int grub_uint32_t;
30 typedef unsigned long long int grub_uint64_t;
31 
32 struct grub_gpt_header
33 {
34   grub_uint64_t magic;
35   grub_uint32_t version;
36   grub_uint32_t headersize;
37   grub_uint32_t crc32;
38   grub_uint32_t unused1;
39   grub_uint64_t primary;
40   grub_uint64_t backup;
41   grub_uint64_t start;
42   grub_uint64_t end;
43   grub_uint8_t guid[16];
44   grub_uint64_t partitions;
45   grub_uint32_t maxpart;
46   grub_uint32_t partentry_size;
47   grub_uint32_t partentry_crc32;
48 } __attribute__ ((packed));
49 
50 struct grub_gpt_partentry
51 {
52   grub_uint64_t type1;
53   grub_uint64_t type2;
54   grub_uint8_t guid[16];
55   grub_uint64_t start;
56   grub_uint64_t end;
57   grub_uint8_t attrib;
58   char name[72];
59 } __attribute__ ((packed));
60 
61 #define GPT_HEADER_MAGIC       0x5452415020494645ULL
62 
63 #define        GPT_ENTRY_SECTOR(size,entry)                                    \
64        ((((entry) * (size) + 1) & ~(SECTOR_SIZE - 1)) >> SECTOR_BITS)
65 #define        GPT_ENTRY_INDEX(size,entry)                                     \
66        ((((entry) * (size) + 1) & (SECTOR_SIZE - 1)) - 1)
67 
68 #endif /* _GPT_H */
69