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
24 #include <grub/file.h>
25 #include <grub/symbol.h>
26 #include <grub/types.h>
28 struct grub_macho_file
31 grub_ssize_t offset32
;
34 grub_size_t cmdsize32
;
36 grub_uint8_t
*uncompressed32
;
38 grub_size_t compressed_size32
;
39 grub_size_t uncompressed_size32
;
40 grub_ssize_t offset64
;
43 grub_size_t cmdsize64
;
45 grub_uint8_t
*uncompressed64
;
47 grub_size_t compressed_size64
;
48 grub_size_t uncompressed_size64
;
50 typedef struct grub_macho_file
*grub_macho_t
;
52 grub_macho_t
grub_macho_open (const char *, int is_64bit
);
53 grub_macho_t
grub_macho_file (grub_file_t file
, const char *filename
,
55 grub_err_t
grub_macho_close (grub_macho_t
);
57 grub_err_t
grub_macho_size32 (grub_macho_t macho
, grub_uint32_t
*segments_start
,
58 grub_uint32_t
*segments_end
, int flags
,
59 const char *filename
);
60 grub_uint32_t
grub_macho_get_entry_point32 (grub_macho_t macho
,
61 const char *filename
);
63 grub_err_t
grub_macho_size64 (grub_macho_t macho
, grub_uint64_t
*segments_start
,
64 grub_uint64_t
*segments_end
, int flags
,
65 const char *filename
);
66 grub_uint64_t
grub_macho_get_entry_point64 (grub_macho_t macho
,
67 const char *filename
);
69 /* Ignore BSS segments when loading. */
70 #define GRUB_MACHO_NOBSS 0x1
71 grub_err_t
grub_macho_load32 (grub_macho_t macho
, const char *filename
,
72 char *offset
, int flags
, int *darwin_version
);
73 grub_err_t
grub_macho_load64 (grub_macho_t macho
, const char *filename
,
74 char *offset
, int flags
, int *darwin_version
);
76 /* Like filesize and file_read but take only 32-bit part
77 for current architecture. */
78 grub_size_t
grub_macho_filesize32 (grub_macho_t macho
);
79 grub_err_t
grub_macho_readfile32 (grub_macho_t macho
, const char *filename
,
81 grub_size_t
grub_macho_filesize64 (grub_macho_t macho
);
82 grub_err_t
grub_macho_readfile64 (grub_macho_t macho
, const char *filename
,
85 void grub_macho_parse32 (grub_macho_t macho
, const char *filename
);
86 void grub_macho_parse64 (grub_macho_t macho
, const char *filename
);
88 #endif /* ! GRUB_MACHOLOAD_HEADER */