]> git.proxmox.com Git - grub2.git/blob - include/grub/macho.h
Merged with mainline
[grub2.git] / include / grub / macho.h
1 /*
2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2009 Free Software Foundation, Inc.
4 *
5 * GRUB 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 3 of the License, or
8 * (at your option) any later version.
9 *
10 * GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #ifndef GRUB_MACHO_H
20 #define GRUB_MACHO_H 1
21 #include <grub/types.h>
22
23 /* Multi-architecture header. Always in big-endian. */
24 struct grub_macho_fat_header
25 {
26 grub_uint32_t magic;
27 grub_uint32_t nfat_arch;
28 } __attribute__ ((packed));
29 #define GRUB_MACHO_FAT_MAGIC 0xcafebabe
30
31 typedef grub_uint32_t grub_macho_cpu_type_t;
32 typedef grub_uint32_t grub_macho_cpu_subtype_t;
33
34 /* Architecture descriptor. Always in big-endian. */
35 struct grub_macho_fat_arch
36 {
37 grub_macho_cpu_type_t cputype;
38 grub_macho_cpu_subtype_t cpusubtype;
39 grub_uint32_t offset;
40 grub_uint32_t size;
41 grub_uint32_t align;
42 } __attribute__ ((packed));
43
44 /* File header for 32-bit. Always in native-endian. */
45 struct grub_macho_header32
46 {
47 #define GRUB_MACHO_MAGIC32 0xfeedface
48 grub_uint32_t magic;
49 grub_macho_cpu_type_t cputype;
50 grub_macho_cpu_subtype_t cpusubtype;
51 grub_uint32_t filetype;
52 grub_uint32_t ncmds;
53 grub_uint32_t sizeofcmds;
54 grub_uint32_t flags;
55 } __attribute__ ((packed));
56
57 /* File header for 64-bit. Always in native-endian. */
58 struct grub_macho_header64
59 {
60 #define GRUB_MACHO_MAGIC64 0xfeedfacf
61 grub_uint32_t magic;
62 grub_macho_cpu_type_t cputype;
63 grub_macho_cpu_subtype_t cpusubtype;
64 grub_uint32_t filetype;
65 grub_uint32_t ncmds;
66 grub_uint32_t sizeofcmds;
67 grub_uint32_t flags;
68 grub_uint32_t reserved;
69 } __attribute__ ((packed));
70
71 /* Convenience union. What do we need to load to identify the file type. */
72 union grub_macho_filestart
73 {
74 struct grub_macho_fat_header fat;
75 struct grub_macho_header32 thin32;
76 struct grub_macho_header64 thin64;
77 } __attribute__ ((packed));
78
79 /* Common header of Mach-O commands. */
80 struct grub_macho_cmd
81 {
82 grub_uint32_t cmd;
83 grub_uint32_t cmdsize;
84 } __attribute__ ((packed));
85
86 typedef grub_uint32_t grub_macho_vmprot_t;
87
88 /* 32-bit segment command. */
89 struct grub_macho_segment32
90 {
91 #define GRUB_MACHO_CMD_SEGMENT32 1
92 grub_uint32_t cmd;
93 grub_uint32_t cmdsize;
94 grub_uint8_t segname[16];
95 grub_uint32_t vmaddr;
96 grub_uint32_t vmsize;
97 grub_uint32_t fileoff;
98 grub_uint32_t filesize;
99 grub_macho_vmprot_t maxprot;
100 grub_macho_vmprot_t initprot;
101 grub_uint32_t nsects;
102 grub_uint32_t flags;
103 } __attribute__ ((packed));
104
105 /* 64-bit segment command. */
106 struct grub_macho_segment64
107 {
108 #define GRUB_MACHO_CMD_SEGMENT64 0x19
109 grub_uint32_t cmd;
110 grub_uint32_t cmdsize;
111 grub_uint8_t segname[16];
112 grub_uint64_t vmaddr;
113 grub_uint64_t vmsize;
114 grub_uint64_t fileoff;
115 grub_uint64_t filesize;
116 grub_macho_vmprot_t maxprot;
117 grub_macho_vmprot_t initprot;
118 grub_uint32_t nsects;
119 grub_uint32_t flags;
120 } __attribute__ ((packed));
121
122 #define GRUB_MACHO_CMD_THREAD 5
123
124 #endif