xnu.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 2009 Free Software Foundation, Inc.
  4. *
  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.
  9. *
  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.
  14. *
  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/>.
  17. */
  18. #ifndef GRUB_XNU_H
  19. #define GRUB_XNU_H 1
  20. #include <grub/bitmap.h>
  21. /* Header of a hibernation image. */
  22. struct grub_xnu_hibernate_header
  23. {
  24. /* Size of the image. Notice that file containing image is usually bigger. */
  25. grub_uint64_t image_size;
  26. grub_uint8_t unknown1[8];
  27. /* Where to copy launchcode? */
  28. grub_uint32_t launchcode_target_page;
  29. /* How many pages of launchcode? */
  30. grub_uint32_t launchcode_numpages;
  31. /* Where to jump? */
  32. grub_uint32_t entry_point;
  33. /* %esp at start. */
  34. grub_uint32_t stack;
  35. grub_uint8_t unknown2[44];
  36. #define GRUB_XNU_HIBERNATE_MAGIC 0x73696d65
  37. grub_uint32_t magic;
  38. grub_uint8_t unknown3[28];
  39. /* This value is non-zero if page is encrypted. Unsupported. */
  40. grub_uint64_t encoffset;
  41. grub_uint8_t unknown4[360];
  42. /* The size of additional header used to locate image without parsing FS.
  43. Used only to skip it.
  44. */
  45. grub_uint32_t extmapsize;
  46. } __attribute__ ((packed));
  47. /* In-memory structure for temporary keeping device tree. */
  48. struct grub_xnu_devtree_key
  49. {
  50. char *name;
  51. int datasize; /* -1 for not leaves. */
  52. union
  53. {
  54. struct grub_xnu_devtree_key *first_child;
  55. void *data;
  56. };
  57. struct grub_xnu_devtree_key *next;
  58. };
  59. /* A structure used in memory-map values. */
  60. struct
  61. grub_xnu_extdesc
  62. {
  63. grub_uint32_t addr;
  64. grub_uint32_t size;
  65. } __attribute__ ((packed));
  66. /* Header describing extension in the memory. */
  67. struct grub_xnu_extheader
  68. {
  69. grub_uint32_t infoplistaddr;
  70. grub_uint32_t infoplistsize;
  71. grub_uint32_t binaryaddr;
  72. grub_uint32_t binarysize;
  73. grub_uint32_t nameaddr;
  74. grub_uint32_t namesize;
  75. } __attribute__ ((packed));
  76. struct grub_xnu_devtree_key *grub_xnu_create_key (struct grub_xnu_devtree_key **parent,
  77. char *name);
  78. extern struct grub_xnu_devtree_key *grub_xnu_devtree_root;
  79. void grub_xnu_free_devtree (struct grub_xnu_devtree_key *cur);
  80. grub_err_t grub_xnu_writetree_toheap (void **start, grub_size_t *size);
  81. struct grub_xnu_devtree_key *grub_xnu_create_value (struct grub_xnu_devtree_key **parent,
  82. char *name);
  83. void grub_xnu_lock (void);
  84. void grub_xnu_unlock (void);
  85. grub_err_t grub_xnu_resume (char *imagename);
  86. grub_err_t grub_xnu_boot_resume (void);
  87. struct grub_xnu_devtree_key *grub_xnu_find_key (struct grub_xnu_devtree_key *parent,
  88. char *name);
  89. grub_err_t grub_xnu_align_heap (int align);
  90. grub_err_t grub_xnu_scan_dir_for_kexts (char *dirname, char *osbundlerequired,
  91. int maxrecursion);
  92. grub_err_t grub_xnu_load_kext_from_dir (char *dirname, char *osbundlerequired,
  93. int maxrecursion);
  94. void *grub_xnu_heap_malloc (int size);
  95. grub_err_t grub_xnu_fill_devicetree (void);
  96. extern grub_uint32_t grub_xnu_heap_real_start;
  97. extern grub_size_t grub_xnu_heap_size;
  98. extern void *grub_xnu_heap_start;
  99. extern struct grub_video_bitmap *grub_xnu_bitmap;
  100. typedef enum {GRUB_XNU_BITMAP_CENTER, GRUB_XNU_BITMAP_STRETCH}
  101. grub_xnu_bitmap_mode_t;
  102. extern grub_xnu_bitmap_mode_t grub_xnu_bitmap_mode;
  103. extern int grub_xnu_is_64bit;
  104. #endif