UbixOS V2  2.0
gpt.h
Go to the documentation of this file.
1 /*-
2  * Copyright (c) 2010 Pawel Jakub Dawidek <pjd@FreeBSD.org>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * $FreeBSD: releng/10.2/sys/boot/common/gpt.h 213136 2010-09-24 19:49:12Z pjd $
27  */
28 
29 #ifndef _GPT_H_
30 #define _GPT_H_
31 
32 #include <sys/uuid.h>
33 #include <sys/device.h>
34 #include <string.h>
35 
36 #define bcopy(src, dst, len) memcpy((dst), (src), (len))
37 #define bzero(buf, size) memset((buf), 0, (size))
38 #define bcmp(b1, b2, len) (memcmp((b1), (b2), (len)) != 0)
39 
40 //MrOlsen (2016-01-11) NOTE: Fix This Temm Place To Store These Defines
41 #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
42 #define DEV_BSIZE (1<<DEV_BSHIFT)
43 
44 struct gpt_hdr {
45  char hdr_sig[8];
46 #define GPT_HDR_SIG "EFI PART"
48 #define GPT_HDR_REVISION 0x00010000
56  struct uuid hdr_uuid;
61  /*
62  * The header as defined in the EFI spec is not a multiple of 8 bytes
63  * and given that the alignment requirement is on an 8 byte boundary,
64  * padding will happen. We make the padding explicit so that we can
65  * correct the value returned by sizeof() when we put the size of the
66  * header in field hdr_size, or otherwise use offsetof().
67  */
69 };
70 
71 struct gpt_ent {
72  struct uuid ent_type;
73  struct uuid ent_uuid;
77 #define GPT_ENT_ATTR_PLATFORM (1ULL << 0)
78 #define GPT_ENT_ATTR_BOOTME (1ULL << 59)
79 #define GPT_ENT_ATTR_BOOTONCE (1ULL << 58)
80 #define GPT_ENT_ATTR_BOOTFAILED (1ULL << 57)
81  u_int16_t ent_name[36]; /* UTF-16. */
82 };
83 
84 #define GPT_ENT_TYPE_UNUSED \
85  {0x00000000,0x0000,0x0000,0x00,0x00,{0x00,0x00,0x00,0x00,0x00,0x00}}
86 #define GPT_ENT_TYPE_EFI \
87  {0xc12a7328,0xf81f,0x11d2,0xba,0x4b,{0x00,0xa0,0xc9,0x3e,0xc9,0x3b}}
88 #define GPT_ENT_TYPE_MBR \
89  {0x024dee41,0x33e7,0x11d3,0x9d,0x69,{0x00,0x08,0xc7,0x81,0xf3,0x9f}}
90 #define GPT_ENT_TYPE_FREEBSD \
91  {0x516e7cb4,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
92 #define GPT_ENT_TYPE_FREEBSD_BOOT \
93  {0x83bd6b9d,0x7f41,0x11dc,0xbe,0x0b,{0x00,0x15,0x60,0xb8,0x4f,0x0f}}
94 #define GPT_ENT_TYPE_FREEBSD_NANDFS \
95  {0x74ba7dd9,0xa689,0x11e1,0xbd,0x04,{0x00,0xe0,0x81,0x28,0x6a,0xcf}}
96 #define GPT_ENT_TYPE_FREEBSD_SWAP \
97  {0x516e7cb5,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
98 #define GPT_ENT_TYPE_FREEBSD_UFS \
99  {0x516e7cb6,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
100 #define GPT_ENT_TYPE_FREEBSD_VINUM \
101  {0x516e7cb8,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
102 #define GPT_ENT_TYPE_FREEBSD_ZFS \
103  {0x516e7cba,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
104 #define GPT_ENT_TYPE_PREP_BOOT \
105  {0x9e1a2d38,0xc612,0x4316,0xaa,0x26,{0x8b,0x49,0x52,0x1e,0x5a,0x8b}}
106 
107 
108 /*
109 
110  #include <drv.h>
111  */
112 
113  int gptread(const uuid_t *uuid, struct device_interface *devInfo, char *buf);
114  int gptfind(const uuid_t *uuid, struct device_interface *devInfo, int part);
115  void gptbootfailed(struct device_interface *devInfo);
116 
117 #endif /* !_GPT_H_ */
gpt_hdr::__reserved
uint32_t __reserved
Definition: gpt.h:51
device_interface
Definition: device.h:47
gpt_hdr::hdr_lba_start
u_int64_t hdr_lba_start
Definition: gpt.h:54
string.h
gpt_hdr::hdr_entsz
uint32_t hdr_entsz
Definition: gpt.h:59
gpt_hdr::hdr_crc_table
uint32_t hdr_crc_table
Definition: gpt.h:60
gpt_ent::ent_name
u_int16_t ent_name[36]
Definition: gpt.h:81
u_int64_t
__uint64_t u_int64_t
Definition: types.h:54
gpt_hdr::hdr_lba_alt
u_int64_t hdr_lba_alt
Definition: gpt.h:53
gpt_hdr::hdr_size
uint32_t hdr_size
Definition: gpt.h:49
gptbootfailed
void gptbootfailed(struct device_interface *devInfo)
Definition: gpt.c:216
gpt_ent
Definition: gpt.h:71
u_int16_t
__uint16_t u_int16_t
Definition: types.h:52
gpt_ent::ent_lba_start
u_int64_t ent_lba_start
Definition: gpt.h:74
buf
Definition: buf.h:35
gpt_ent::ent_uuid
struct uuid ent_uuid
Definition: gpt.h:73
gptfind
int gptfind(const uuid_t *uuid, struct device_interface *devInfo, int part)
Definition: gpt.c:99
gpt_hdr::hdr_entries
uint32_t hdr_entries
Definition: gpt.h:58
uint32_t
__uint32_t uint32_t
Definition: types.h:46
gpt_hdr::hdr_crc_self
uint32_t hdr_crc_self
Definition: gpt.h:50
uuid.h
gpt_hdr::hdr_lba_table
u_int64_t hdr_lba_table
Definition: gpt.h:57
gpt_hdr::hdr_revision
uint32_t hdr_revision
Definition: gpt.h:47
device.h
gpt_hdr::padding
uint32_t padding
Definition: gpt.h:68
gpt_hdr
Definition: gpt.h:44
gpt_ent::ent_lba_end
u_int64_t ent_lba_end
Definition: gpt.h:75
uuid
Definition: uuid.h:45
gpt_ent::ent_type
struct uuid ent_type
Definition: gpt.h:72
gpt_hdr::hdr_lba_self
u_int64_t hdr_lba_self
Definition: gpt.h:52
gpt_ent::ent_attr
u_int64_t ent_attr
Definition: gpt.h:76
gpt_hdr::hdr_uuid
struct uuid hdr_uuid
Definition: gpt.h:56
gpt_hdr::hdr_lba_end
u_int64_t hdr_lba_end
Definition: gpt.h:55
gptread
int gptread(const uuid_t *uuid, struct device_interface *devInfo, char *buf)
Definition: gpt.c:305
gpt_hdr::hdr_sig
char hdr_sig[8]
Definition: gpt.h:45