Upgraded GRUB2 to 2.00 release.
[AROS.git] / arch / all-pc / boot / grub2-aros / include / grub / macho.h
blob6a98b6e127b7bd5ad0b5085a1a394195ae68b893
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 /* Common header of Mach-O commands. */
72 struct grub_macho_cmd
74 grub_uint32_t cmd;
75 grub_uint32_t cmdsize;
76 } __attribute__ ((packed));
78 typedef grub_uint32_t grub_macho_vmprot_t;
80 /* 32-bit segment command. */
81 struct grub_macho_segment32
83 #define GRUB_MACHO_CMD_SEGMENT32 1
84 grub_uint32_t cmd;
85 grub_uint32_t cmdsize;
86 grub_uint8_t segname[16];
87 grub_uint32_t vmaddr;
88 grub_uint32_t vmsize;
89 grub_uint32_t fileoff;
90 grub_uint32_t filesize;
91 grub_macho_vmprot_t maxprot;
92 grub_macho_vmprot_t initprot;
93 grub_uint32_t nsects;
94 grub_uint32_t flags;
95 } __attribute__ ((packed));
97 /* 64-bit segment command. */
98 struct grub_macho_segment64
100 #define GRUB_MACHO_CMD_SEGMENT64 0x19
101 grub_uint32_t cmd;
102 grub_uint32_t cmdsize;
103 grub_uint8_t segname[16];
104 grub_uint64_t vmaddr;
105 grub_uint64_t vmsize;
106 grub_uint64_t fileoff;
107 grub_uint64_t filesize;
108 grub_macho_vmprot_t maxprot;
109 grub_macho_vmprot_t initprot;
110 grub_uint32_t nsects;
111 grub_uint32_t flags;
112 } __attribute__ ((packed));
114 #define GRUB_MACHO_CMD_THREAD 5
116 struct grub_macho_lzss_header
118 char magic[8];
119 #define GRUB_MACHO_LZSS_MAGIC "complzss"
120 grub_uint32_t unused;
121 grub_uint32_t uncompressed_size;
122 grub_uint32_t compressed_size;
125 /* Convenience union. What do we need to load to identify the file type. */
126 union grub_macho_filestart
128 struct grub_macho_fat_header fat;
129 struct grub_macho_header32 thin32;
130 struct grub_macho_header64 thin64;
131 struct grub_macho_lzss_header lzss;
132 } __attribute__ ((packed));
134 #define GRUB_MACHO_LZSS_OFFSET 0x180
136 grub_size_t
137 grub_decompress_lzss (grub_uint8_t *dst, grub_uint8_t *dstend,
138 grub_uint8_t *src, grub_uint8_t *srcend);
140 #endif