vaseboot/include/VasEBoot/i386/xnu.h

150 lines
4.7 KiB
C

/*
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* VAS_EBOOT 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.
*
* VAS_EBOOT 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 VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef VAS_EBOOT_CPU_XNU_H
#define VAS_EBOOT_CPU_XNU_H 1
#include <VasEBoot/err.h>
#include <VasEBoot/efi/api.h>
#include <VasEBoot/cpu/relocator.h>
#define XNU_RELOCATOR(x) (VasEBoot_relocator32_ ## x)
#define VAS_EBOOT_XNU_PAGESIZE 4096
typedef VasEBoot_uint32_t VasEBoot_xnu_ptr_t;
struct VasEBoot_xnu_boot_params_common
{
/* Command line passed to xnu. */
VasEBoot_uint8_t cmdline[1024];
/* Later are the same as EFI's get_memory_map (). */
VasEBoot_xnu_ptr_t efi_mmap;
VasEBoot_uint32_t efi_mmap_size;
VasEBoot_uint32_t efi_mem_desc_size;
VasEBoot_uint32_t efi_mem_desc_version;
/* Later are video parameters. */
VasEBoot_xnu_ptr_t lfb_base;
#define VAS_EBOOT_XNU_VIDEO_SPLASH 1
#define VAS_EBOOT_XNU_VIDEO_TEXT_IN_VIDEO 2
VasEBoot_uint32_t lfb_mode;
VasEBoot_uint32_t lfb_line_len;
VasEBoot_uint32_t lfb_width;
VasEBoot_uint32_t lfb_height;
VasEBoot_uint32_t lfb_depth;
/* Pointer to device tree and its len. */
VasEBoot_xnu_ptr_t devtree;
VasEBoot_uint32_t devtreelen;
/* First used address by kernel or boot structures. */
VasEBoot_xnu_ptr_t heap_start;
/* Last used address by kernel or boot structures minus previous value. */
VasEBoot_uint32_t heap_size;
/* First memory page containing runtime code or data. */
VasEBoot_uint32_t efi_runtime_first_page;
/* First memory page containing runtime code or data minus previous value. */
VasEBoot_uint32_t efi_runtime_npages;
} VAS_EBOOT_PACKED;
struct VasEBoot_xnu_boot_params_v1
{
VasEBoot_uint16_t verminor;
VasEBoot_uint16_t vermajor;
struct VasEBoot_xnu_boot_params_common common;
VasEBoot_uint32_t efi_system_table;
/* Size of VasEBoot_efi_uintn_t in bits. */
VasEBoot_uint8_t efi_uintnbits;
} VAS_EBOOT_PACKED;
#define VAS_EBOOT_XNU_BOOTARGSV1_VERMINOR 5
#define VAS_EBOOT_XNU_BOOTARGSV1_VERMAJOR 1
struct VasEBoot_xnu_boot_params_v2
{
VasEBoot_uint16_t verminor;
VasEBoot_uint16_t vermajor;
/* Size of VasEBoot_efi_uintn_t in bits. */
VasEBoot_uint8_t efi_uintnbits;
VasEBoot_uint8_t unused[3];
struct VasEBoot_xnu_boot_params_common common;
VasEBoot_uint64_t efi_runtime_first_page_virtual;
VasEBoot_uint32_t efi_system_table;
VasEBoot_uint32_t unused2[9];
VasEBoot_uint64_t ram_size;
VasEBoot_uint64_t fsbfreq;
VasEBoot_uint32_t unused3[734];
} VAS_EBOOT_PACKED;
#define VAS_EBOOT_XNU_BOOTARGSV2_VERMINOR 0
#define VAS_EBOOT_XNU_BOOTARGSV2_VERMAJOR 2
union VasEBoot_xnu_boot_params_any
{
struct VasEBoot_xnu_boot_params_v1 v1;
struct VasEBoot_xnu_boot_params_v2 v2;
};
struct VasEBoot_xnu_devprop_header
{
VasEBoot_uint32_t length;
/* Always set to 1. Version? */
VasEBoot_uint32_t alwaysone;
VasEBoot_uint32_t num_devices;
};
struct VasEBoot_xnu_devprop_device_header
{
VasEBoot_uint32_t length;
VasEBoot_uint32_t num_values;
};
void VasEBoot_cpu_xnu_unload (void);
struct VasEBoot_xnu_devprop_device_descriptor;
struct VasEBoot_xnu_devprop_device_descriptor *
VasEBoot_xnu_devprop_add_device (struct VasEBoot_efi_device_path *path, int length);
VasEBoot_err_t
VasEBoot_xnu_devprop_remove_device (struct VasEBoot_xnu_devprop_device_descriptor *dev);
VasEBoot_err_t
VasEBoot_xnu_devprop_remove_property (struct VasEBoot_xnu_devprop_device_descriptor *dev,
char *name);
VasEBoot_err_t
VasEBoot_xnu_devprop_add_property_utf8 (struct VasEBoot_xnu_devprop_device_descriptor *dev,
char *name, void *data, int datalen);
VasEBoot_err_t
VasEBoot_xnu_devprop_add_property_utf16 (struct VasEBoot_xnu_devprop_device_descriptor *dev,
VasEBoot_uint16_t *name, int namelen,
void *data, int datalen);
VasEBoot_err_t
VasEBoot_xnu_devprop_remove_property_utf8 (struct VasEBoot_xnu_devprop_device_descriptor *dev,
char *name);
void VasEBoot_cpu_xnu_init (void);
void VasEBoot_cpu_xnu_fini (void);
extern VasEBoot_uint32_t VasEBoot_xnu_entry_point;
extern VasEBoot_uint32_t VasEBoot_xnu_stack;
extern VasEBoot_uint32_t VasEBoot_xnu_arg1;
extern char VasEBoot_xnu_cmdline[1024];
VasEBoot_err_t VasEBoot_xnu_boot (void);
#endif