vaseboot/include/VasEBoot/xnu.h

120 lines
4.1 KiB
C

/*
* VasEBoot -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* VasEBoot 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.
*
* VasEBoot 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 VasEBoot. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef VasEBoot_XNU_H
#define VasEBoot_XNU_H 1
#include <VasEBoot/bitmap.h>
/* Header of a hibernation image. */
struct VasEBoot_xnu_hibernate_header
{
/* Size of the image. Notice that file containing image is usually bigger. */
VasEBoot_uint64_t image_size;
VasEBoot_uint8_t unknown1[8];
/* Where to copy launchcode? */
VasEBoot_uint32_t launchcode_target_page;
/* How many pages of launchcode? */
VasEBoot_uint32_t launchcode_numpages;
/* Where to jump? */
VasEBoot_uint32_t entry_point;
/* %esp at start. */
VasEBoot_uint32_t stack;
VasEBoot_uint8_t unknown2[44];
#define VasEBoot_XNU_HIBERNATE_MAGIC 0x73696d65
VasEBoot_uint32_t magic;
VasEBoot_uint8_t unknown3[28];
/* This value is non-zero if page is encrypted. Unsupported. */
VasEBoot_uint64_t encoffset;
VasEBoot_uint8_t unknown4[360];
/* The size of additional header used to locate image without parsing FS.
Used only to skip it.
*/
VasEBoot_uint32_t extmapsize;
} VasEBoot_PACKED;
/* In-memory structure for temporary keeping device tree. */
struct VasEBoot_xnu_devtree_key
{
char *name;
int datasize; /* -1 for not leaves. */
union
{
struct VasEBoot_xnu_devtree_key *first_child;
void *data;
};
struct VasEBoot_xnu_devtree_key *next;
};
/* A structure used in memory-map values. */
struct
VasEBoot_xnu_extdesc
{
VasEBoot_uint32_t addr;
VasEBoot_uint32_t size;
} VasEBoot_PACKED;
/* Header describing extension in the memory. */
struct VasEBoot_xnu_extheader
{
VasEBoot_uint32_t infoplistaddr;
VasEBoot_uint32_t infoplistsize;
VasEBoot_uint32_t binaryaddr;
VasEBoot_uint32_t binarysize;
VasEBoot_uint32_t nameaddr;
VasEBoot_uint32_t namesize;
} VasEBoot_PACKED;
struct VasEBoot_xnu_devtree_key *VasEBoot_xnu_create_key (struct VasEBoot_xnu_devtree_key **parent,
const char *name);
extern struct VasEBoot_xnu_devtree_key *VasEBoot_xnu_devtree_root;
void VasEBoot_xnu_free_devtree (struct VasEBoot_xnu_devtree_key *cur);
VasEBoot_err_t VasEBoot_xnu_writetree_toheap (VasEBoot_addr_t *target, VasEBoot_size_t *size);
struct VasEBoot_xnu_devtree_key *VasEBoot_xnu_create_value (struct VasEBoot_xnu_devtree_key **parent,
const char *name);
void VasEBoot_xnu_lock (void);
void VasEBoot_xnu_unlock (void);
VasEBoot_err_t VasEBoot_xnu_resume (char *imagename);
VasEBoot_err_t VasEBoot_xnu_boot_resume (void);
struct VasEBoot_xnu_devtree_key *VasEBoot_xnu_find_key (struct VasEBoot_xnu_devtree_key *parent,
const char *name);
VasEBoot_err_t VasEBoot_xnu_align_heap (int align);
VasEBoot_err_t VasEBoot_xnu_scan_dir_for_kexts (char *dirname,
const char *osbundlerequired,
int maxrecursion);
VasEBoot_err_t VasEBoot_xnu_load_kext_from_dir (char *dirname,
const char *osbundlerequired,
int maxrecursion);
VasEBoot_err_t VasEBoot_xnu_heap_malloc (int size, void **src, VasEBoot_addr_t *target);
VasEBoot_err_t VasEBoot_xnu_fill_devicetree (void);
extern struct VasEBoot_relocator *VasEBoot_xnu_relocator;
extern VasEBoot_size_t VasEBoot_xnu_heap_size;
extern struct VasEBoot_video_bitmap *VasEBoot_xnu_bitmap;
typedef enum {VasEBoot_XNU_BITMAP_CENTER, VasEBoot_XNU_BITMAP_STRETCH}
VasEBoot_xnu_bitmap_mode_t;
extern VasEBoot_xnu_bitmap_mode_t VasEBoot_xnu_bitmap_mode;
extern int VasEBoot_xnu_is_64bit;
extern VasEBoot_addr_t VasEBoot_xnu_heap_target_start;
extern int VasEBoot_xnu_darwin_version;
#endif