2009-07-20 Joe Auricchio <jauricchio@gmail.com>
[grub2/phcoder.git] / include / grub / machoload.h
bloba80bac68cbcead0455f134793b41ab322c111ce2
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_MACHOLOAD_HEADER
20 #define GRUB_MACHOLOAD_HEADER 1
22 #include <grub/err.h>
23 #include <grub/elf.h>
24 #include <grub/file.h>
25 #include <grub/symbol.h>
26 #include <grub/types.h>
28 struct grub_macho_file
30 grub_file_t file;
31 grub_ssize_t offset32;
32 grub_ssize_t end32;
33 int ncmds32;
34 grub_size_t cmdsize32;
35 grub_uint8_t *cmds32;
36 grub_ssize_t offset64;
37 grub_ssize_t end64;
38 int ncmds64;
39 grub_size_t cmdsize64;
40 grub_uint8_t *cmds64;
42 typedef struct grub_macho_file *grub_macho_t;
44 grub_macho_t grub_macho_open (const char *);
45 grub_macho_t grub_macho_file (grub_file_t);
46 grub_err_t grub_macho_close (grub_macho_t);
48 int grub_macho_contains_macho32 (grub_macho_t);
49 grub_err_t grub_macho32_size (grub_macho_t macho, grub_addr_t *segments_start,
50 grub_addr_t *segments_end, int flags);
51 grub_uint32_t grub_macho32_get_entry_point (grub_macho_t macho);
53 /* Ignore BSS segments when loading. */
54 #define GRUB_MACHO_NOBSS 0x1
55 grub_err_t grub_macho32_load (grub_macho_t macho, char *offset, int flags);
57 /* Like filesize and file_read but take only 32-bit part
58 for current architecture. */
59 grub_size_t grub_macho32_filesize (grub_macho_t macho);
60 grub_err_t grub_macho32_readfile (grub_macho_t macho, void *dest);
62 #endif /* ! GRUB_MACHOLOAD_HEADER */