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