2009-11-02 Samuel Thibault <samuel.thibault@ens-lyon.org>
[grub2/jjazz.git] / include / grub / macho.h
blob0604100e90f34d37d1cd6e0ab7625a7e236e42cc
1 /*
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/>.
19 #ifndef GRUB_MACHO_H
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
26 grub_uint32_t magic;
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;
39 grub_uint32_t offset;
40 grub_uint32_t size;
41 grub_uint32_t align;
42 } __attribute__ ((packed));
44 /* File header for 32-bit. Always in native-endian. */
45 struct grub_macho_header32
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));
57 /* File header for 64-bit. Always in native-endian. */
58 struct grub_macho_header64
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));
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. */
80 struct grub_macho_cmd
82 grub_uint32_t cmd;
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
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));
105 #define GRUB_MACHO_CMD_THREAD 5
107 #endif