2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2009 Free Software Foundation, Inc.
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.
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.
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/>.
20 #define GRUB_MACHO_H 1
21 #include <grub/types.h>
23 /* Multi-architecture header. Always in big-endian. */
24 struct grub_macho_fat_header
27 grub_uint32_t nfat_arch
;
28 } __attribute__ ((packed
));
29 #define GRUB_MACHO_FAT_MAGIC 0xcafebabe
31 typedef grub_uint32_t grub_macho_cpu_type_t
;
32 typedef grub_uint32_t grub_macho_cpu_subtype_t
;
34 /* Architecture descriptor. Always in big-endian. */
35 struct grub_macho_fat_arch
37 grub_macho_cpu_type_t cputype
;
38 grub_macho_cpu_subtype_t cpusubtype
;
42 } __attribute__ ((packed
));;
44 /* File header for 32-bit. Always in native-endian. */
45 struct grub_macho_header32
47 #define GRUB_MACHO_MAGIC32 0xfeedface
49 grub_macho_cpu_type_t cputype
;
50 grub_macho_cpu_subtype_t cpusubtype
;
51 grub_uint32_t filetype
;
53 grub_uint32_t sizeofcmds
;
55 } __attribute__ ((packed
));
57 /* File header for 64-bit. Always in native-endian. */
58 struct grub_macho_header64
60 #define GRUB_MACHO_MAGIC64 0xfeedfacf
62 grub_macho_cpu_type_t cputype
;
63 grub_macho_cpu_subtype_t cpusubtype
;
64 grub_uint32_t filetype
;
66 grub_uint32_t sizeofcmds
;
68 grub_uint32_t reserved
;
69 } __attribute__ ((packed
));
71 /* Convenience union. What do we need to load to identify the file type. */
72 union grub_macho_filestart
74 struct grub_macho_fat_header fat
;
75 struct grub_macho_header32 thin32
;
76 struct grub_macho_header64 thin64
;
77 } __attribute__ ((packed
));
79 /* Common header of Mach-O commands. */
83 grub_uint32_t cmdsize
;
84 } __attribute__ ((packed
));
86 typedef grub_uint32_t grub_macho_vmprot_t
;
88 /* 32-bit segment command. */
89 struct grub_macho_segment32
91 #define GRUB_MACHO_CMD_SEGMENT32 1
93 grub_uint32_t cmdsize
;
94 grub_uint8_t segname
[16];
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
;
103 } __attribute__ ((packed
));
105 #define GRUB_MACHO_CMD_THREAD 5