Fix cross compilation (e.g. on Darwin). Following changes to make.tmpl,
[AROS.git] / arch / all-pc / boot / grub2-aros / include / grub / macho.h
blob2dea625f1be53f425f6a4f0f7103dbcd1059456b
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 } GRUB_PACKED;
30 enum
32 GRUB_MACHO_CPUTYPE_IA32 = 0x00000007,
33 GRUB_MACHO_CPUTYPE_AMD64 = 0x01000007
36 #define GRUB_MACHO_FAT_MAGIC 0xcafebabe
37 #define GRUB_MACHO_FAT_EFI_MAGIC 0x0ef1fab9U
39 typedef grub_uint32_t grub_macho_cpu_type_t;
40 typedef grub_uint32_t grub_macho_cpu_subtype_t;
42 /* Architecture descriptor. Always in big-endian. */
43 struct grub_macho_fat_arch
45 grub_macho_cpu_type_t cputype;
46 grub_macho_cpu_subtype_t cpusubtype;
47 grub_uint32_t offset;
48 grub_uint32_t size;
49 grub_uint32_t align;
50 } GRUB_PACKED;
52 /* File header for 32-bit. Always in native-endian. */
53 struct grub_macho_header32
55 #define GRUB_MACHO_MAGIC32 0xfeedface
56 grub_uint32_t magic;
57 grub_macho_cpu_type_t cputype;
58 grub_macho_cpu_subtype_t cpusubtype;
59 grub_uint32_t filetype;
60 grub_uint32_t ncmds;
61 grub_uint32_t sizeofcmds;
62 grub_uint32_t flags;
63 } GRUB_PACKED;
65 /* File header for 64-bit. Always in native-endian. */
66 struct grub_macho_header64
68 #define GRUB_MACHO_MAGIC64 0xfeedfacf
69 grub_uint32_t magic;
70 grub_macho_cpu_type_t cputype;
71 grub_macho_cpu_subtype_t cpusubtype;
72 grub_uint32_t filetype;
73 grub_uint32_t ncmds;
74 grub_uint32_t sizeofcmds;
75 grub_uint32_t flags;
76 grub_uint32_t reserved;
77 } GRUB_PACKED;
79 /* Common header of Mach-O commands. */
80 struct grub_macho_cmd
82 grub_uint32_t cmd;
83 grub_uint32_t cmdsize;
84 } GRUB_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 } GRUB_PACKED;
105 /* 64-bit segment command. */
106 struct grub_macho_segment64
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 } GRUB_PACKED;
122 #define GRUB_MACHO_CMD_THREAD 5
124 struct grub_macho_lzss_header
126 char magic[8];
127 #define GRUB_MACHO_LZSS_MAGIC "complzss"
128 grub_uint32_t unused;
129 grub_uint32_t uncompressed_size;
130 grub_uint32_t compressed_size;
133 /* Convenience union. What do we need to load to identify the file type. */
134 union grub_macho_filestart
136 struct grub_macho_fat_header fat;
137 struct grub_macho_header32 thin32;
138 struct grub_macho_header64 thin64;
139 struct grub_macho_lzss_header lzss;
140 } GRUB_PACKED;
142 struct grub_macho_thread32
144 grub_uint32_t cmd;
145 grub_uint32_t cmdsize;
146 grub_uint8_t unknown1[48];
147 grub_uint32_t entry_point;
148 grub_uint8_t unknown2[20];
149 } GRUB_PACKED;
151 struct grub_macho_thread64
153 grub_uint32_t cmd;
154 grub_uint32_t cmdsize;
155 grub_uint8_t unknown1[0x88];
156 grub_uint64_t entry_point;
157 grub_uint8_t unknown2[0x20];
158 } GRUB_PACKED;
160 #define GRUB_MACHO_LZSS_OFFSET 0x180
162 grub_size_t
163 grub_decompress_lzss (grub_uint8_t *dst, grub_uint8_t *dstend,
164 grub_uint8_t *src, grub_uint8_t *srcend);
166 #endif