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_CPU_XNU_H
20 #define GRUB_CPU_XNU_H 1
23 #include <grub/efi/api.h>
24 #include <grub/cpu/relocator.h>
26 #define XNU_RELOCATOR(x) (grub_relocator32_ ## x)
28 #define GRUB_XNU_PAGESIZE 4096
29 typedef grub_uint32_t grub_xnu_ptr_t
;
31 struct grub_xnu_boot_params_common
33 /* Command line passed to xnu. */
34 grub_uint8_t cmdline
[1024];
36 /* Later are the same as EFI's get_memory_map (). */
37 grub_xnu_ptr_t efi_mmap
;
38 grub_uint32_t efi_mmap_size
;
39 grub_uint32_t efi_mem_desc_size
;
40 grub_uint32_t efi_mem_desc_version
;
42 /* Later are video parameters. */
43 grub_xnu_ptr_t lfb_base
;
44 #define GRUB_XNU_VIDEO_SPLASH 1
45 #define GRUB_XNU_VIDEO_TEXT_IN_VIDEO 2
46 grub_uint32_t lfb_mode
;
47 grub_uint32_t lfb_line_len
;
48 grub_uint32_t lfb_width
;
49 grub_uint32_t lfb_height
;
50 grub_uint32_t lfb_depth
;
52 /* Pointer to device tree and its len. */
53 grub_xnu_ptr_t devtree
;
54 grub_uint32_t devtreelen
;
56 /* First used address by kernel or boot structures. */
57 grub_xnu_ptr_t heap_start
;
58 /* Last used address by kernel or boot structures minus previous value. */
59 grub_uint32_t heap_size
;
60 /* First memory page containing runtime code or data. */
61 grub_uint32_t efi_runtime_first_page
;
62 /* First memory page containing runtime code or data minus previous value. */
63 grub_uint32_t efi_runtime_npages
;
66 struct grub_xnu_boot_params_v1
68 grub_uint16_t verminor
;
69 grub_uint16_t vermajor
;
70 struct grub_xnu_boot_params_common common
;
72 grub_uint32_t efi_system_table
;
73 /* Size of grub_efi_uintn_t in bits. */
74 grub_uint8_t efi_uintnbits
;
76 #define GRUB_XNU_BOOTARGSV1_VERMINOR 5
77 #define GRUB_XNU_BOOTARGSV1_VERMAJOR 1
79 struct grub_xnu_boot_params_v2
81 grub_uint16_t verminor
;
82 grub_uint16_t vermajor
;
84 /* Size of grub_efi_uintn_t in bits. */
85 grub_uint8_t efi_uintnbits
;
86 grub_uint8_t unused
[3];
88 struct grub_xnu_boot_params_common common
;
90 grub_uint64_t efi_runtime_first_page_virtual
;
91 grub_uint32_t efi_system_table
;
92 grub_uint32_t unused2
[9];
93 grub_uint64_t ram_size
;
94 grub_uint64_t fsbfreq
;
95 grub_uint32_t unused3
[734];
97 #define GRUB_XNU_BOOTARGSV2_VERMINOR 0
98 #define GRUB_XNU_BOOTARGSV2_VERMAJOR 2
100 union grub_xnu_boot_params_any
102 struct grub_xnu_boot_params_v1 v1
;
103 struct grub_xnu_boot_params_v2 v2
;
106 struct grub_xnu_devprop_header
108 grub_uint32_t length
;
109 /* Always set to 1. Version? */
110 grub_uint32_t alwaysone
;
111 grub_uint32_t num_devices
;
114 struct grub_xnu_devprop_device_header
116 grub_uint32_t length
;
117 grub_uint32_t num_values
;
120 void grub_cpu_xnu_unload (void);
122 struct grub_xnu_devprop_device_descriptor
;
124 struct grub_xnu_devprop_device_descriptor
*
125 grub_xnu_devprop_add_device (struct grub_efi_device_path
*path
, int length
);
127 grub_xnu_devprop_remove_device (struct grub_xnu_devprop_device_descriptor
*dev
);
129 grub_xnu_devprop_remove_property (struct grub_xnu_devprop_device_descriptor
*dev
,
132 grub_xnu_devprop_add_property_utf8 (struct grub_xnu_devprop_device_descriptor
*dev
,
133 char *name
, void *data
, int datalen
);
135 grub_xnu_devprop_add_property_utf16 (struct grub_xnu_devprop_device_descriptor
*dev
,
136 grub_uint16_t
*name
, int namelen
,
137 void *data
, int datalen
);
139 grub_xnu_devprop_remove_property_utf8 (struct grub_xnu_devprop_device_descriptor
*dev
,
141 void grub_cpu_xnu_init (void);
142 void grub_cpu_xnu_fini (void);
144 extern grub_uint32_t grub_xnu_entry_point
;
145 extern grub_uint32_t grub_xnu_stack
;
146 extern grub_uint32_t grub_xnu_arg1
;
147 extern char grub_xnu_cmdline
[1024];
148 grub_err_t
grub_xnu_boot (void);