2009-05-02 23:19:20 +00:00
|
|
|
/*
|
|
|
|
* GRUB -- GRand Unified Bootloader
|
|
|
|
* Copyright (C) 2009 Free Software Foundation, Inc.
|
|
|
|
*
|
|
|
|
* GRUB is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* GRUB is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GRUB_MACHOLOAD_HEADER
|
|
|
|
#define GRUB_MACHOLOAD_HEADER 1
|
|
|
|
|
|
|
|
#include <grub/err.h>
|
|
|
|
#include <grub/elf.h>
|
|
|
|
#include <grub/file.h>
|
|
|
|
#include <grub/symbol.h>
|
|
|
|
#include <grub/types.h>
|
|
|
|
|
|
|
|
struct grub_macho_file
|
|
|
|
{
|
|
|
|
grub_file_t file;
|
|
|
|
grub_ssize_t offset32;
|
|
|
|
grub_ssize_t end32;
|
|
|
|
int ncmds32;
|
|
|
|
grub_size_t cmdsize32;
|
|
|
|
grub_uint8_t *cmds32;
|
2012-02-29 12:26:13 +00:00
|
|
|
grub_uint8_t *uncompressed32;
|
|
|
|
int compressed32;
|
|
|
|
grub_size_t compressed_size32;
|
|
|
|
grub_size_t uncompressed_size32;
|
2009-05-02 23:19:20 +00:00
|
|
|
grub_ssize_t offset64;
|
|
|
|
grub_ssize_t end64;
|
|
|
|
int ncmds64;
|
|
|
|
grub_size_t cmdsize64;
|
|
|
|
grub_uint8_t *cmds64;
|
2012-02-29 12:26:13 +00:00
|
|
|
grub_uint8_t *uncompressed64;
|
|
|
|
int compressed64;
|
|
|
|
grub_size_t compressed_size64;
|
|
|
|
grub_size_t uncompressed_size64;
|
2009-05-02 23:19:20 +00:00
|
|
|
};
|
|
|
|
typedef struct grub_macho_file *grub_macho_t;
|
|
|
|
|
2012-02-29 12:26:13 +00:00
|
|
|
grub_macho_t grub_macho_open (const char *, int is_64bit);
|
|
|
|
grub_macho_t grub_macho_file (grub_file_t file, const char *filename,
|
|
|
|
int is_64bit);
|
2009-05-02 23:19:20 +00:00
|
|
|
grub_err_t grub_macho_close (grub_macho_t);
|
|
|
|
|
2009-09-02 00:52:10 +00:00
|
|
|
grub_err_t grub_macho_size32 (grub_macho_t macho, grub_uint32_t *segments_start,
|
2012-02-29 12:26:13 +00:00
|
|
|
grub_uint32_t *segments_end, int flags,
|
|
|
|
const char *filename);
|
|
|
|
grub_uint32_t grub_macho_get_entry_point32 (grub_macho_t macho,
|
|
|
|
const char *filename);
|
2009-09-02 00:52:10 +00:00
|
|
|
|
|
|
|
grub_err_t grub_macho_size64 (grub_macho_t macho, grub_uint64_t *segments_start,
|
2012-02-29 12:26:13 +00:00
|
|
|
grub_uint64_t *segments_end, int flags,
|
|
|
|
const char *filename);
|
|
|
|
grub_uint64_t grub_macho_get_entry_point64 (grub_macho_t macho,
|
|
|
|
const char *filename);
|
2009-05-02 23:19:20 +00:00
|
|
|
|
|
|
|
/* Ignore BSS segments when loading. */
|
|
|
|
#define GRUB_MACHO_NOBSS 0x1
|
2012-02-08 18:26:01 +00:00
|
|
|
grub_err_t grub_macho_load32 (grub_macho_t macho, const char *filename,
|
2012-02-28 03:04:19 +00:00
|
|
|
char *offset, int flags, int *darwin_version);
|
2012-02-08 18:26:01 +00:00
|
|
|
grub_err_t grub_macho_load64 (grub_macho_t macho, const char *filename,
|
2012-02-28 03:04:19 +00:00
|
|
|
char *offset, int flags, int *darwin_version);
|
2009-05-02 23:19:20 +00:00
|
|
|
|
2009-06-10 21:04:23 +00:00
|
|
|
/* Like filesize and file_read but take only 32-bit part
|
2009-05-02 23:19:20 +00:00
|
|
|
for current architecture. */
|
2009-09-02 00:52:10 +00:00
|
|
|
grub_size_t grub_macho_filesize32 (grub_macho_t macho);
|
2012-02-08 18:26:01 +00:00
|
|
|
grub_err_t grub_macho_readfile32 (grub_macho_t macho, const char *filename,
|
|
|
|
void *dest);
|
2009-09-02 00:52:10 +00:00
|
|
|
grub_size_t grub_macho_filesize64 (grub_macho_t macho);
|
2012-02-08 18:26:01 +00:00
|
|
|
grub_err_t grub_macho_readfile64 (grub_macho_t macho, const char *filename,
|
|
|
|
void *dest);
|
2009-09-02 00:52:10 +00:00
|
|
|
|
2012-02-08 18:26:01 +00:00
|
|
|
void grub_macho_parse32 (grub_macho_t macho, const char *filename);
|
|
|
|
void grub_macho_parse64 (grub_macho_t macho, const char *filename);
|
2009-05-02 23:19:20 +00:00
|
|
|
|
|
|
|
#endif /* ! GRUB_MACHOLOAD_HEADER */
|