2009-11-21 Samuel Thibault <samuel.thibault@ens-lyon.org>
[grub2.git] / include / grub / xnu.h
blobc3902e670d02cf08f163820e2297edd7423529f1
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_XNU_H
20 #define GRUB_XNU_H 1
22 #include <grub/bitmap.h>
24 /* Header of a hibernation image. */
25 struct grub_xnu_hibernate_header
27 /* Size of the image. Notice that file containing image is usually bigger. */
28 grub_uint64_t image_size;
29 grub_uint8_t unknown1[8];
30 /* Where to copy launchcode? */
31 grub_uint32_t launchcode_target_page;
32 /* How many pages of launchcode? */
33 grub_uint32_t launchcode_numpages;
34 /* Where to jump? */
35 grub_uint32_t entry_point;
36 /* %esp at start. */
37 grub_uint32_t stack;
38 grub_uint8_t unknown2[44];
39 #define GRUB_XNU_HIBERNATE_MAGIC 0x73696d65
40 grub_uint32_t magic;
41 grub_uint8_t unknown3[28];
42 /* This value is non-zero if page is encrypted. Unsupported. */
43 grub_uint64_t encoffset;
44 grub_uint8_t unknown4[360];
45 /* The size of additional header used to locate image without parsing FS.
46 Used only to skip it.
48 grub_uint32_t extmapsize;
49 } __attribute__ ((packed));
51 /* In-memory structure for temporary keeping device tree. */
52 struct grub_xnu_devtree_key
54 char *name;
55 int datasize; /* -1 for not leaves. */
56 union
58 struct grub_xnu_devtree_key *first_child;
59 void *data;
61 struct grub_xnu_devtree_key *next;
64 /* A structure used in memory-map values. */
65 struct
66 grub_xnu_extdesc
68 grub_uint32_t addr;
69 grub_uint32_t size;
70 } __attribute__ ((packed));
72 /* Header describing extension in the memory. */
73 struct grub_xnu_extheader
75 grub_uint32_t infoplistaddr;
76 grub_uint32_t infoplistsize;
77 grub_uint32_t binaryaddr;
78 grub_uint32_t binarysize;
79 } __attribute__ ((packed));
81 struct grub_xnu_devtree_key *grub_xnu_create_key (struct grub_xnu_devtree_key **parent,
82 char *name);
84 extern struct grub_xnu_devtree_key *grub_xnu_devtree_root;
86 void grub_xnu_free_devtree (struct grub_xnu_devtree_key *cur);
88 grub_err_t grub_xnu_writetree_toheap (void **start, grub_size_t *size);
89 struct grub_xnu_devtree_key *grub_xnu_create_value (struct grub_xnu_devtree_key **parent,
90 char *name);
92 void grub_xnu_lock (void);
93 void grub_xnu_unlock (void);
94 grub_err_t grub_xnu_resume (char *imagename);
95 struct grub_xnu_devtree_key *grub_xnu_find_key (struct grub_xnu_devtree_key *parent,
96 char *name);
97 grub_err_t grub_xnu_align_heap (int align);
98 grub_err_t grub_xnu_scan_dir_for_kexts (char *dirname, char *osbundlerequired,
99 int maxrecursion);
100 grub_err_t grub_xnu_load_kext_from_dir (char *dirname, char *osbundlerequired,
101 int maxrecursion);
102 void *grub_xnu_heap_malloc (int size);
103 extern grub_uint32_t grub_xnu_heap_real_start;
104 extern grub_size_t grub_xnu_heap_size;
105 extern char *grub_xnu_heap_start;
106 extern struct grub_video_bitmap *grub_xnu_bitmap;
107 #endif