xnu
PATCH 1/1 xnu
Hello. Here is my xnu patch. Tested on i386-pc, i386-efi and x86_64-efi. On non-efi it needs efiemu otherwise you need only include/grub/autoefi.h file from efiemu patch. To resume xnu from hibernation do:xnu_resume <hibernation file>
Note: you don't need efiemu in this case
How to boot xnu:
<efiemu if not on efi platform>
[on pc only:] vbe_mode=0xYYY # desired vga mode
fsb=133.3 # your fsb frequencyxnu_kernel <kernel> <command line>
<insert modules>
boot
Modules can be inserted one of the following ways:
1) xnu_mkext <mkext file>
2) xnu_kext extension.kext
3) xnu_kext extension.kext/Info.plist extension.kext/extension
4) xnu_kextdir <directory containing extensions>
It's also possible to execute these commands multiple times
The most typical case isxnu_kernel /mach_kernel rd=disk0sXxnu_mkext /System/Library/Extensions.mkext
If you need to add values to device tree the command xnu_devtree <devtree file>
This file uses the following format:
valuename:valuedata;
keyname{
contents
}
keyname, valuename and valuedata are in hex.
If you need to adda ramdisk executexnu_ramdisk <ramdisk file>
ramdisk will be exposed as /dev/md0 which may be used as boot device with rd=md0.
The areas which need more work (every help is welcome):
1) testing on different platforms
2) Detect "device-properties" value in device tree. There are several trivial values in device tree present in boot.efi but not in grub2. These ones are easy to add and AFAIK don't change anything. But the value "device-properties" is difficult. I already know it's format but not where the values come from. It contains info about gfx and sound card which may not work if this value is missing. The current workaround is xnu_devtree command with a dump of device-properties
3) autodetect fsb frequency
4) Support video splash
5) Define and use an unified interface to retrieve video information uniformly across platforms
6) Boot by UUID. I know how to do it but need md5 for it which is a part of pending luks patch
7) Scripts for automatic creating of grub.cfg entries
8) Support for prelinked kernel. It's compressed and I have yet looked how to decompress it (seems it's compressed with something called lzss)
9) Use claimmap once available (see my multiboot on efi patch)
10) Better collaboration with memory management once advanced mm's available
11) Resume from encrypted hibernation
Signature · 2 lines
Regards Vladimir 'phcoder' Serbinenko
conf/i386-efi.rmk +7 -0
@@ -194,5 +194,12 @@ fixvideo_mod_SOURCES = commands/efi/fixvideo.c fixvideo_mod_CFLAGS = $(COMMON_CFLAGS) fixvideo_mod_LDFLAGS = $(COMMON_LDFLAGS) +pkglib_MODULES += xnu.mod +xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/efi/xnu.c\ + loader/macho.c loader/xnu.c loader/i386/xnu_helper.S +xnu_mod_CFLAGS = $(COMMON_CFLAGS) -Werror -Wall +xnu_mod_LDFLAGS = $(COMMON_LDFLAGS) +xnu_mod_ASFLAGS = $(COMMON_ASFLAGS) + include $(srcdir)/conf/i386.mk include $(srcdir)/conf/common.mk
conf/i386-pc.rmk +7 -0
@@ -225,6 +225,13 @@ linux_mod_SOURCES = loader/i386/linux.c linux_mod_CFLAGS = $(COMMON_CFLAGS) linux_mod_LDFLAGS = $(COMMON_LDFLAGS) +pkglib_MODULES += xnu.mod +xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/pc/xnu.c\ + loader/macho.c loader/xnu.c loader/i386/xnu_helper.S +xnu_mod_CFLAGS = $(COMMON_CFLAGS) -Werror -Wall +xnu_mod_LDFLAGS = $(COMMON_LDFLAGS) +xnu_mod_ASFLAGS = $(COMMON_ASFLAGS) + # # Only arch dependant part of normal.mod will be here. Common part for # all architecures of normal.mod is at start and should be kept at sync
conf/x86_64-efi.rmk +7 -0
@@ -197,5 +197,12 @@ fixvideo_mod_SOURCES = commands/efi/fixvideo.c fixvideo_mod_CFLAGS = $(COMMON_CFLAGS) fixvideo_mod_LDFLAGS = $(COMMON_LDFLAGS) +pkglib_MODULES += xnu.mod +xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/efi/xnu.c\ + loader/macho.c loader/xnu.c loader/i386/xnu_helper.S +xnu_mod_CFLAGS = $(COMMON_CFLAGS) -Werror -Wall +xnu_mod_LDFLAGS = $(COMMON_LDFLAGS) +xnu_mod_ASFLAGS = $(COMMON_ASFLAGS) + include $(srcdir)/conf/i386.mk include $(srcdir)/conf/common.mk
include/grub/efi/efi.h +1 -0
@@ -56,6 +56,7 @@ EXPORT_FUNC(grub_efi_get_device_path) (grub_efi_handle_t handle);int EXPORT_FUNC (grub_efi_exit_boot_services ) (grub_efi_uintn_t map_key);void EXPORT_FUNC (grub_reboot ) (void );void EXPORT_FUNC (grub_halt ) (void ); +int EXPORT_FUNC (grub_efi_finish_boot_services ) (void );void grub_efi_mm_init (void );void grub_efi_mm_fini (void );
include/grub/i386/macho.h new file +11 -0
@@ -0,0 +1,11 @@ +#define GRUB_MACHO_CPUTYPE_IS_HOST32 (x) ((x)==0x00000007) +#define GRUB_MACHO_CPUTYPE_IS_HOST64 (x) ((x)==0x01000007) + +struct grub_macho_thread32 +{ +grub_uint32_t cmd; +grub_uint32_t cmdsize; +grub_uint8_t unknown1[48 ]; +grub_uint32_t entry_point; +grub_uint8_t unknown2[20 ]; +} __attribute__ ((packed));
include/grub/i386/xnu.h new file +58 -0
58 lines not on this page · raw message
include/grub/macho.h new file +107 -0
107 lines not on this page · raw message
include/grub/machoload.h new file +62 -0
62 lines not on this page · raw message
include/grub/x86_64/macho.h new file +1 -0
@@ -0,0 +1 @@ +#include <grub/i386/macho.h>
include/grub/x86_64/xnu.h new file +1 -0
@@ -0,0 +1 @@ +#include <grub/i386/xnu.h>
include/grub/xnu.h new file +105 -0
105 lines not on this page · raw message
kern/efi/efi.c +23 -0
@@ -734,3 +734,26 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp) dp = (grub_efi_device_path_t *) ((char *) dp + len); } } + +int +grub_efi_finish_boot_services (void ) +{ +grub_efi_uintn_t mmap_size =0 ; +grub_efi_uintn_t map_key; +grub_efi_uintn_t desc_size; +grub_efi_uint32_t desc_version; +void *mmap_buf =0 ; + +if (grub_efi_get_memory_map (&mmap_size, mmap_buf, &map_key, + &desc_size, &desc_version) <0 ) +return 0 ; + + mmap_buf =grub_malloc (mmap_size); + +if (grub_efi_get_memory_map (&mmap_size, mmap_buf, &map_key, + &desc_size, &desc_version) <=0 ) +return 0 ; + +return grub_efi_exit_boot_services (map_key); +} +
kern/efi/mm.c +1 -1
@@ -47,7 +47,7 @@ static struct allocated_page *allocated_pages = 0;/* The minimum and maximum heap size for GRUB itself. */ #define MIN_HEAP_SIZE 0x100000 -#define MAX_HEAP_SIZE (16 * 0x100000) +#define MAX_HEAP_SIZE (1600 * 0x100000)/* Allocate pages. Return the pointer to the first of allocated pages. */
loader/i386/efi/xnu.c new file +177 -0
177 lines not on this page · raw message
loader/i386/pc/xnu.c new file +67 -0
67 lines not on this page · raw message
loader/i386/xnu.c new file +471 -0
471 lines not on this page · raw message
loader/i386/xnu_helper.S new file +88 -0
89 lines not on this page · raw message
loader/macho.c new file +395 -0
395 lines not on this page · raw message
loader/xnu.c new file +1376 -0
1,376 lines not on this page · raw message
loader/xnu_resume.c new file +134 -0
2 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
I have your whole patch series applied and have been trying to use this to boot the PureDarwin 9 kernel (on various x86 32 & 64 bit machines):
menuentry "PureDarwin 9 (phcoder efiemu)" {
#efiemu_loadcore /osstore/STAGE1a/grub2/efiemu32.o efiemu_loadcore /osstore/STAGE1a/grub2/efiemu64.o efiemu_pnvram /osstore/STAGE2/DARWIN/pnvram_vars efiemu_acpi
efiemu_prepare
set fsb=667
xnu_kernel /osstore/STAGE2/DARWIN/live/mach_kernel -v -s rd=md0 xnu_mkext /osstore/STAGE2/DARWIN/live/System/Library/Extensions.mkext xnu_ramdisk /osstore/STAGE2/DARWIN/darwin1.img
}
where darwin files are from:
http://xref.puredarwin.org/puredarwinnano0df46.tbz2
where pnvram_vars is a blank file and darwin1.img is an disk image with an hfs partition in it (still working the layout of that fs per http://www.insanelymac.com/forum/index.php?showtopic=144128&p=1023069&#entry1023069)
I doesn't matter if I set gfxterm/vbe_mode/fsb or not, the best I get is an immediately panic'ed kernel.
I can only see the output on a CRT monitor of a 2CPU(x4 core) EM64T server (black text on a _dark_ blue background - very hard to read).
A Xen HVM freezes up and the text (if any) is invisible, as well as on several laptop LCDs (hard to really test these platforms since can't "see" the crash).
It seems xnu_mkext works because the output differs when that line is ommited (complains abount not having an /Extensions for ACPI)
Do you have any pointers to improve the video output?
-joey
On Sat, Apr 18, 2009 at 1:22 AM, Joey Korkames <[email protected]<joey%[email protected]>
Quoted 8 lines
wrote:
I have your whole patch series applied and have been trying to use this to boot the PureDarwin 9 kernel (on various x86 32 & 64 bit machines):
menuentry "PureDarwin 9 (phcoder efiemu)" {
#efiemu_loadcore /osstore/STAGE1a/grub2/efiemu32.oefiemu_loadcore/osstore/STAGE1a/grub2/efiemu64.o
efiemu64.o works on x64 machines only. efiemu32.o works everywhere and I recommends using it.
Quoted 3 lines
efiemu_pnvram/osstore/STAGE2/DARWIN/pnvram_varsefiemu_acpi
This command is eliminated in the last patch.
Quoted 7 lines
efiemu_prepare
set fsb=667
xnu_kernel/osstore/STAGE2/DARWIN/live/mach_kernel -v -s rd=md0xnu_mkext/osstore/STAGE2/DARWIN/live/System/Library/Extensions.mkextxnu_ramdisk/osstore/STAGE2/DARWIN/darwin1.img
Quoted 6 lines
}
where darwin files are from:
http://xref.puredarwin.org/puredarwinnano0df46.tbz2where
pnvram_varsis a blank file
You may also just do efiemu_pnvram with no file as an argument
Quoted 5 lines
and darwin1.img is an disk image with an hfs partition in it (still working the layout of that fs per
http://www.insanelymac.com/forum/index.php?showtopic=144128&p=1023069&#entry1023069
)
I haven't checked you image but notice it must be a pure filesystem
Quoted 6 lines
I doesn't matter if I set gfxterm/vbe_mode/fsb or not, the best I get is an immediately panic'ed kernel.
I can only see the output on a CRT monitor of a 2CPU(x4 core) EM64T server (black text on a _dark_ blue background - very hard to read).
Quoted 9 lines
A Xen HVM freezes up and the text (if any) is invisible, as well as on several laptop LCDs (hard to really test these platforms since can't "see" the crash).
It seems
xnu_mkextworks because the output differs when that line is ommited (complains abount not having an /Extensions for ACPI)Do you have any pointers to improve the video output?
Unfortunately there is no consensus yet as to how graphics should be for now it's the following interface:
[on pc only:] vbe_mode=0xYYY # desired vga mode
The blind mode in this patch doesn't work correctly, you are likely to get
a mysterious panic due to memory overwrite
I have done some improvements on the patch and will send it after few tests
Quoted 10 lines
-joey
_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 4 lines
xnu_kernel/osstore/STAGE2/DARWIN/live/mach_kernel -v -s rd=md0Quoted 1 line
-v option controls the booter and not the kernel. It's totally ignored by
grub which always boots the kernel in verbose mode. In future I'll add a command to load the splash which will switch to splash mode
Thanks for the comments. After reading those and peeking around your code, I have a much better config that allos xnu.mod to give proper panic text:
#http://grub.enbug.org/gfxterm loadfont /osstore/STAGE1a/grub2/unifont.pf2 set gfxmode="800x600x32" set vbe_mode=0x115 terminal_output gfxterm
thanks
-joey
New improved version. Numerous bugfixes. Thanks to Florian Idelberger for the time he spent on testing and to David Miller for pointing a nasty mistake out. Also I added fsb autodetection for intel cpus (thanks to Kabyl for the information about Intel speedstep) but I tested fsb autodetect only on my own laptop so it may or may not work in general. Parameter fsb= is still present and overrides autodetect
Quoted 60 lines · phcoder
Hello. Here is my xnu patch. Tested on i386-pc, i386-efi and x86_64-efi. On non-efi it needs efiemu otherwise you need only
include/grub/autoefi.hfile from efiemu patch. To resume xnu from hibernation do:xnu_resume<hibernation file>
Note: you don't need efiemu in this case
How to boot xnu:
<efiemu if not on efi platform>
[on pc only:] vbe_mode=0xYYY # desired vga mode
fsb=133.3 # your fsb frequencyxnu_kernel<kernel> <command line>
<insert modules>
boot
Modules can be inserted one of the following ways:
1)xnu_mkext<mkext file>
2)xnu_kextextension.kext
3)xnu_kextextension.kext/Info.plist extension.kext/extension
4)xnu_kextdir<directory containing extensions>
It's also possible to execute these commands multiple times
The most typical case isxnu_kernel/mach_kernel rd=disk0sXxnu_mkext/System/Library/Extensions.mkextIf you need to add values to device tree the command
xnu_devtree<devtree file>
This file uses the following format:
valuename:valuedata;
keyname{
contents
}
keyname, valuename and valuedata are in hex.If you need to adda ramdisk execute
xnu_ramdisk<ramdisk file>
ramdisk will be exposed as/dev/md0which may be used as boot device with rd=md0.The areas which need more work (every help is welcome):
1) testing on different platforms
2) Detect "device-properties" value in device tree. There are several trivial values in device tree present in boot.efi but not in grub2. These ones are easy to add and AFAIK don't change anything. But the value "device-properties" is difficult. I already know it's format but not where the values come from. It contains info about gfx and sound card which may not work if this value is missing. The current workaround isxnu_devtreecommand with a dump of device-properties
3) autodetect fsb frequency
4) Support video splash
5) Define and use an unified interface to retrieve video information uniformly across platforms
6) Boot by UUID. I know how to do it but need md5 for it which is a part of pending luks patch
7) Scripts for automatic creating of grub.cfg entries
8) Support for prelinked kernel. It's compressed and I have yet looked how to decompress it (seems it's compressed with something called lzss)
9) Use claimmap once available (see my multiboot on efi patch)
10) Better collaboration with memory management once advanced mm's available
11) Resume from encrypted hibernation
Quoted 5 lines
--
Regards
Vladimir 'phcoder' Serbinenko
conf/i386-efi.rmk +8 -1
@@ -98,7 +98,7 @@ kernel_mod_SOURCES = kern/i386/efi/startup.S kern/main.c kern/device.c \ kernel_mod_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \ env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \ partition.h pc_partition.h rescue.h symbol.h term.h time.h types.h \ - efi/efi.h efi/time.h efi/disk.h list.h handler.h command.h + efi/efi.h efi/time.h efi/disk.h i386/pit.h list.h handler.h command.h kernel_mod_CFLAGS = $(COMMON_CFLAGS) kernel_mod_ASFLAGS = $(COMMON_ASFLAGS) kernel_mod_LDFLAGS = $(COMMON_LDFLAGS)
@@ -194,5 +194,12 @@ fixvideo_mod_SOURCES = commands/efi/fixvideo.c fixvideo_mod_CFLAGS = $(COMMON_CFLAGS) fixvideo_mod_LDFLAGS = $(COMMON_LDFLAGS) +pkglib_MODULES += xnu.mod +xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/efi/xnu.c\ + loader/macho.c loader/xnu.c loader/i386/xnu_helper.S +xnu_mod_CFLAGS = $(COMMON_CFLAGS) -Werror -Wall +xnu_mod_LDFLAGS = $(COMMON_LDFLAGS) +xnu_mod_ASFLAGS = $(COMMON_ASFLAGS) + include $(srcdir)/conf/i386.mk include $(srcdir)/conf/common.mk
conf/i386-pc.rmk +8 -1
@@ -61,7 +61,7 @@ kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \ partition.h pc_partition.h rescue.h symbol.h term.h time.h types.h \ machine/biosdisk.h machine/boot.h machine/console.h machine/init.h \ machine/memory.h machine/loader.h machine/vga.h machine/vbe.h \ - machine/kernel.h machine/pxe.h list.h handler.h command.h + machine/kernel.h machine/pxe.h i386/pit.h list.h handler.h command.h kernel_img_CFLAGS = $(COMMON_CFLAGS) kernel_img_ASFLAGS = $(COMMON_ASFLAGS) kernel_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS) -Wl,-Ttext,$(GRUB_MEMORY_MACHINE_LINK_ADDR) $(COMMON_CFLAGS)
@@ -225,6 +225,13 @@ linux_mod_SOURCES = loader/i386/linux.c linux_mod_CFLAGS = $(COMMON_CFLAGS) linux_mod_LDFLAGS = $(COMMON_LDFLAGS) +pkglib_MODULES += xnu.mod +xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/pc/xnu.c\ + loader/macho.c loader/xnu.c loader/i386/xnu_helper.S +xnu_mod_CFLAGS = $(COMMON_CFLAGS) -Werror -Wall +xnu_mod_LDFLAGS = $(COMMON_LDFLAGS) +xnu_mod_ASFLAGS = $(COMMON_ASFLAGS) + # # Only arch dependant part of normal.mod will be here. Common part for # all architecures of normal.mod is at start and should be kept at sync
conf/x86_64-efi.rmk +8 -1
@@ -100,7 +100,7 @@ kernel_mod_SOURCES = kern/x86_64/efi/startup.S kern/x86_64/efi/callwrap.S \ kernel_mod_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \ env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \ partition.h pc_partition.h rescue.h symbol.h term.h time.h types.h \ - efi/efi.h efi/time.h efi/disk.h machine/loader.h list.h handler.h \ + efi/efi.h efi/time.h efi/disk.h machine/loader.h i386/pit.h list.h handler.h \ command.h kernel_mod_CFLAGS = $(COMMON_CFLAGS) kernel_mod_ASFLAGS = $(COMMON_ASFLAGS)
@@ -197,5 +197,12 @@ fixvideo_mod_SOURCES = commands/efi/fixvideo.c fixvideo_mod_CFLAGS = $(COMMON_CFLAGS) fixvideo_mod_LDFLAGS = $(COMMON_LDFLAGS) +pkglib_MODULES += xnu.mod +xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/efi/xnu.c\ + loader/macho.c loader/xnu.c loader/i386/xnu_helper.S +xnu_mod_CFLAGS = $(COMMON_CFLAGS) -Werror -Wall +xnu_mod_LDFLAGS = $(COMMON_LDFLAGS) +xnu_mod_ASFLAGS = $(COMMON_ASFLAGS) + include $(srcdir)/conf/i386.mk include $(srcdir)/conf/common.mk
include/grub/efi/efi.h +1 -0
@@ -56,6 +56,7 @@ EXPORT_FUNC(grub_efi_get_device_path) (grub_efi_handle_t handle);int EXPORT_FUNC (grub_efi_exit_boot_services ) (grub_efi_uintn_t map_key);void EXPORT_FUNC (grub_reboot ) (void );void EXPORT_FUNC (grub_halt ) (void ); +int EXPORT_FUNC (grub_efi_finish_boot_services ) (void );void grub_efi_mm_init (void );void grub_efi_mm_fini (void );
include/grub/i386/macho.h new file +11 -0
@@ -0,0 +1,11 @@ +#define GRUB_MACHO_CPUTYPE_IS_HOST32 (x) ((x)==0x00000007) +#define GRUB_MACHO_CPUTYPE_IS_HOST64 (x) ((x)==0x01000007) + +struct grub_macho_thread32 +{ +grub_uint32_t cmd; +grub_uint32_t cmdsize; +grub_uint8_t unknown1[48 ]; +grub_uint32_t entry_point; +grub_uint8_t unknown2[20 ]; +} __attribute__ ((packed));
include/grub/i386/pit.h +2 -1
@@ -20,7 +20,8 @@#define KERNEL_CPU_PIT_HEADER 1#include <grub/types.h> +#include <grub/err.h> -extern void grub_pit_wait (grub_uint16_t tics); +void EXPORT_FUNC (grub_pit_wait ) (grub_uint16_t tics);#endif /* ! KERNEL_CPU_PIT_HEADER */
include/grub/i386/xnu.h new file +58 -0
58 lines not on this page · raw message
include/grub/macho.h new file +107 -0
107 lines not on this page · raw message
include/grub/machoload.h new file +62 -0
62 lines not on this page · raw message
include/grub/x86_64/macho.h new file +1 -0
@@ -0,0 +1 @@ +#include <grub/i386/macho.h>
include/grub/x86_64/xnu.h new file +1 -0
@@ -0,0 +1 @@ +#include <grub/i386/xnu.h>
include/grub/xnu.h new file +105 -0
105 lines not on this page · raw message
kern/efi/efi.c +23 -0
@@ -734,3 +734,26 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp) dp = (grub_efi_device_path_t *) ((char *) dp + len); } } + +int +grub_efi_finish_boot_services (void ) +{ +grub_efi_uintn_t mmap_size =0 ; +grub_efi_uintn_t map_key; +grub_efi_uintn_t desc_size; +grub_efi_uint32_t desc_version; +void *mmap_buf =0 ; + +if (grub_efi_get_memory_map (&mmap_size, mmap_buf, &map_key, + &desc_size, &desc_version) <0 ) +return 0 ; + + mmap_buf =grub_malloc (mmap_size); + +if (grub_efi_get_memory_map (&mmap_size, mmap_buf, &map_key, + &desc_size, &desc_version) <=0 ) +return 0 ; + +return grub_efi_exit_boot_services (map_key); +} +
kern/efi/mm.c +1 -1
@@ -47,7 +47,7 @@ static struct allocated_page *allocated_pages = 0;/* The minimum and maximum heap size for GRUB itself. */ #define MIN_HEAP_SIZE 0x100000 -#define MAX_HEAP_SIZE (16 * 0x100000) +#define MAX_HEAP_SIZE (1600 * 0x100000)/* Allocate pages. Return the pointer to the first of allocated pages. */
loader/i386/efi/xnu.c new file +177 -0
177 lines not on this page · raw message
loader/i386/pc/xnu.c new file +67 -0
67 lines not on this page · raw message
loader/i386/xnu.c new file +516 -0
516 lines not on this page · raw message
loader/i386/xnu_helper.S new file +107 -0
108 lines not on this page · raw message
loader/macho.c new file +395 -0
395 lines not on this page · raw message
loader/xnu.c new file +1377 -0
1,281 lines not on this page · raw message
loader/xnu_resume.c new file +134 -0
134 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
This patch did not work as well as the last one posted (on my test machine). The last one got all the way to trying to run /sbin/launchd off the ramdisk - log post of this one's boot attempt are attached.
Oh, here is my updated menuentry, works well and gives me serial output of the darwin kernel (as well as on the VGA monitor):
menuentry "PureDarwin 9 (phcoder efiemu)" {
echo "Switching to VESA and booting Darwin (slow)... " #bootloader must tickle VESA before xnu can use it loadfont /osstore/STAGE1a/grub2/unifont.pf2 set gfxmode="800x600x32"
set vbe_mode=0x115
terminal_output gfxterm
echo "VESA enabled. Booting Darwin (slow)... "
#efiemu_loadcore /osstore/STAGE1a/grub2/efiemu64.o efiemu_loadcore /osstore/STAGE1a/grub2/efiemu32.o efiemu_pnvram
efiemu_prepare
xnu_kernel /osstore/STAGE2/DARWIN/live/mach_kernel -s -f debug=0x08 serial=2 serialbaud=9600 rd=md0 xnu_mkext /osstore/STAGE2/DARWIN/live/System/Library/Extensions.mkext
xnu_ramdisk /osstore/STAGE2/DARWIN/ramdisk.hfs
# ^^30MB too big? (full /System/Library/Extensions) - yes, box will reboot before kernel turnover
# ^^if ramdisk is invalid, like FBSD, will attempt NFSMOUNT (to nowhere) - else, tries /sbin/launchd
}
Thanks
-joey
Quoted 4 lines · Vladimir Serbinenko
<< HTML content follows >>
New improved version. Numerous bugfixes. Thanks to Florian Idelberger for the time he spent on testing and to David Miller for pointing a nasty mistake out. Also I added fsb autodetection for intel cpus (thanks to Kabyl for the information about Intel speedstep) but I tested fsb autodetect only on my own laptop so it may or may not work in general. Parameter fsb= is still present and overrides autodetect
Switching to VESA and booting Darwin (slow)...
Serial mode specified: 00000002version_variant = 0
version = Darwin Kernel Version 9.5.0: Thu Sep 18 14:14:00 PDT 2008; root:xnu-1228.7.58.obj/RELEASE_I386
EM64T supported and will be enabled
EFI region: type = 7/7, base = 0x0, top = 0x88
EFI region: type = 8/8, base = 0x89, top = 0x9f
EFI region: type = 8/8, base = 0xca, top = 0xcb
EFI region: type = 8/8, base = 0xe4, top = 0xff
EFI region: type = 7/7, base = 0x100, top = 0x9bfbc
EFI region: type = 5/5, base = 0x9bfbd, top = 0x9bfbd
EFI region: type = 6/6, base = 0x9bfbe, top = 0x9bfc0
EFI region: type = 7/7, base = 0x9bfc1, top = 0xcff4f
EFI region: type = 9/9, base = 0xcff50, top = 0xcff5d
EFI region: type = 10/10, base = 0xcff5e, top = 0xcff5e
EFI region: type = 8/8, base = 0xcff5f, top = 0xcff7f
EFI region: type = 8/8, base = 0xcff80, top = 0xcffff
EFI region: type = 8/8, base = 0xe0000, top = 0xeffff
EFI region: type = 8/8, base = 0xfec00, top = 0xfec0f
EFI region: type = 8/8, base = 0xfee00, top = 0xfee00
EFI region: type = 8/8, base = 0xff000, top = 0xfffff
Physical memory 3328 MBHIGH_MEM_BASE 0xffe00000 fixed per-cpu begin 0xffe17000
tramp: 0xffe00000, GDT: 0xffe02000, LDT: 0xffe04000, IDT: 0xffe03000, KTSS: 0xffe14000, DFTSS: 0xffe15000
MCTSS: 0xffe15000
gdt/idt reloaded, tr reset to KERNEL_TSS
Kernel virtual space from 0x0 to 0xfe7fffff.
64 bit mode enabled
Available physical space from 0xa58000 to 0xcff4f000EFI_FSB_frequency: read FSBFrequency value: 100000000
BUS: Frequency = 100.0000MHz, cvtt2n = 0000000A.00000000, cvtn2t = 00000000.19999999, cvtInt = 0098967F.FFFFA920
TSC: Frequency = 700.0000MHz, cvtt2n = 00000001.6DB6DB6D, cvtn2t = 00000000.B3333333, gran = 7
RCBA: vaddr = 00A6E000, paddr = FED1C001
HPET: vaddr = 00A72000, paddr = FED00000
HPET: Frequency = 14.318179MHz, cvtt2n = 00000045.D75E0F7F, cvtn2t = 00000000.03AA5B32initialize_screen: b=DC000000, w=00000320, h=00000258, r=00000C80, d=00000001pmap_steal_memory: 00C4B000 - 00C4C000; size=00001000pmap_steal_memory: 00C4C000 - 010C1000; size=00475000pmap_steal_memory: 010C1000 - 010CE000; size=0000D000pmap_steal_memory: 010CE000 - 014CE000; size=00400000pmap_steal_memory: 014CE000 - 037F8AF0; size=0232AAF0
CPU identification: Intel(R) Xeon(R) CPU L5410 @ 2.33GHz
CPU features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM SSE3 MON DSCPL VMX EST TM2 SSSE3 CX16 TPR PDCM SSE4.1
HTT: 4 cores per package; 4 logical cpus per package
CPU extended features: XD EM64T
Initializing EFI runtime services
Boot args version 1 revision 4 mode 32
Processing 32-bit EFI tables at 0x9bfbe060
RuntimeServices table at 0x9bfbe000MSR_IA32_APIC_BASE 0xfee00000 enabled BSP
Boot cpu local APIC id 0x0
[RTCLOCK] frequency 700000000 (700000000)
maxDec: 21474836470
Kernel boot args: '-s -f debug=0x08 serial=2 serialbaud=9600'
ACPI: RSDP @ 0xf5a50/0x0024 (v002 PTLTD )
ACPI: XSDT @ 0xcff55a96/0x0094 (v001 PTLTD XSDT 0x06040000 LTP 0x00000000)
ACPI: FACP @ 0xcff5dd9c/0x00F4 (v003 INTEL SANCLMNT 0x06040000 PTL 0x00000003)
ACPI: DSDT @ 0xcff575fc/0x671C (v001 Intel SANCLMNT 0x06040000 MSFT 0x03000001)
ACPI: FACS @ 0xcff5efc0/0x0040
ACPI: APIC @ 0xcff5de90/0x00BC (v001 PTLTD APIC 0x06040000 LTP 0x00000000)
ACPI: MCFG @ 0xcff5df4c/0x003C (v001 PTLTD MCFG 0x06040000 LTP 0x00000000)
ACPI: BOOT @ 0xcff5df88/0x0028 (v001 PTLTD $SBFTBL$ 0x06040000 LTP 0x00000001)
ACPI: SPCR @ 0xcff5dfb0/0x0050 (v001 PTLTD $UCRTBL$ 0x06040000 PTL 0x00000001)
ACPI: SSDT @ 0xcff5739d/0x025F (v001 PmRef Cpu0Tst 0x00003000 INTL 0x20061109)
ACPI: SSDT @ 0xcff572f7/0x00A6 (v001 PmRef Cpu7Tst 0x00003000 INTL 0x20061109)
ACPI: SSDT @ 0xcff57251/0x00A6 (v001 PmRef Cpu6Tst 0x00003000 INTL 0x20061109)
ACPI: SSDT @ 0xcff571ab/0x00A6 (v001 PmRef Cpu5Tst 0x00003000 INTL 0x20061109)
ACPI: SSDT @ 0xcff57105/0x00A6 (v001 PmRef Cpu4Tst 0x00003000 INTL 0x20061109)
ACPI: SSDT @ 0xcff5705f/0x00A6 (v001 PmRef Cpu3Tst 0x00003000 INTL 0x20061109)
ACPI: SSDT @ 0xcff56fb9/0x00A6 (v001 PmRef Cpu2Tst 0x00003000 INTL 0x20061109)
ACPI: SSDT @ 0xcff56f13/0x00A6 (v001 PmRef Cpu1Tst 0x00003000 INTL 0x20061109)
ACPI: SSDT @ 0xcff55b2a/0x13E9 (v001 PmRef CpuPm 0x00003000 INTL 0x20061109)
panic(cpu 0 caller 0x001AB328): "commpage no match on last routine"@/Volumes/work/darwin/9F33-roots/BuildRoot/SourceCache/xnu/xnu-1228.7.58/osfmk/i386/commpage/commpage.c:404 Debugger called: <panic>
Backtrace (CPU 0), Frame : Return Address (4 potential args on stack)0x3fa6fe68 : 0x12b0fa (0x4598d8 0x3fa6fe9c 0x133243 0x0)0x3fa6feb8 : 0x1ab328 (0x465a28 0x3fa6ff14 0x2000 0x0)0x3fa6ff38 : 0x1ab531 (0xffff0000 0x524ee8 0x0 0x530f80)0x3fa6ff88 : 0x18204b (0x4b83010 0x1 0x0 0x54a0c0)0x3fa6ffa8 : 0x137dac (0x0 0x0 0x137d3d 0x0)0x3fa6ffc8 : 0x19ecbc (0x0 0xffffffff 0x1a202a 0x0)
Backtrace terminated-invalid frame pointer 0
BSD process name corresponding to current thread: Unknown
Mac OS version:
Not yet set
Kernel version:
Darwin Kernel Version 9.5.0: Thu Sep 18 14:14:00 PDT 2008; root:xnu-1228.7.58.obj/RELEASE_I386 System model name: X7DCL
Attempting to commit panic log to NVRAM
Your FSB wasn't detected correctly (or rather not detected at all, what's your CPU?). The actual bug is that if fsb frequency is too low the kernel will crash when trying to use 64-bit mode (you can use -legacy parameter to put xnu in 32-bit mode). You need to specify fsb with a variable. Can you come to irc.freenode.net#grub ?
(e.g. for 200Mhz: set fsb=200).
On Fri, Apr 24, 2009 at 2:41 AM, Joey Korkames <[email protected]<joey%[email protected]>
Quoted 18 lines
wrote:
This patch did not work as well as the last one posted (on my test machine). The last one got all the way to trying to run
/sbin/launchdoff the ramdisk - log post of this one's boot attempt are attached.Oh, here is my updated menuentry, works well and gives me serial output of the darwin kernel (as well as on the VGA monitor):
menuentry "PureDarwin 9 (phcoder efiemu)" {
echo "Switching to VESA and booting Darwin (slow)... " #bootloader must tickle VESA before xnu can use it loadfont /osstore/STAGE1a/grub2/unifont.pf2 set gfxmode="800x600x32"
set vbe_mode=0x115
terminal_outputgfxterm
echo "VESA enabled. Booting Darwin (slow)... "
Quoted 7 lines
#efiemu_loadcore /osstore/STAGE1a/grub2/efiemu64.o
efiemu_loadcore/osstore/STAGE1a/grub2/efiemu32.oefiemu_pnvram
efiemu_prepare
xnu_kernel/osstore/STAGE2/DARWIN/live/mach_kernel -s -f debug=0x08
serial=2 serialbaud=9600 rd=md0
-f parameter isn't actually used. Use xnu_kextdir if you don't want to use mkext
Quoted 5 lines
xnu_mkext/osstore/STAGE2/DARWIN/live/System/Library/Extensions.mkextxnu_ramdisk/osstore/STAGE2/DARWIN/ramdisk.hfs
# ^^30MB too big? (full /System/Library/Extensions) - yes, box will
reboot before kernel turnover
Can you give more info about it
Quoted 29 lines
# ^^if ramdisk is invalid, like FBSD, will attempt NFSMOUNT (to
nowhere) - else, tries/sbin/launchd}
Thanks
-joeyVladimir Serbinenko writes:
<< HTML content follows >>
Quoted 9 lines
New improved version. Numerous bugfixes. Thanks to Florian Idelberger for the time he spent on testing and to David Miller for pointing a nasty mistake out. Also I added fsb autodetection for intel cpus (thanks to Kabyl for the information about Intel speedstep) but I tested fsb autodetect only on my own laptop so it may or may not work in general. Parameter fsb= is still present and overrides autodetect
_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 4 lines · Vladimir Serbinenko
<< HTML content follows >>
Your FSB wasn't detected correctly (or rather not detected at all, what's your CPU?). The actual bug is that if fsb frequency is too low the kernel will crash when trying to use 64-bit mode (you can use -legacy parameter to put xnu in 32-bit mode). You need to specify fsb with a variable. Can you come to <URL:http://irc.freenode.net#grub>irc.freenode.net#grub ? (e.g. for 200Mhz: set fsb=200).
Correct you are, It was a Intel Xeon L5410. http://en.wikipedia.org/wiki/Xeon tells me it is a fsb=1333 and now the boot gets to where it was on the first patch. Boot log at bottom. My ramdisk isn't fully populated yet so the launchd error is not (necessarily) a bug.
I'm lurking on #grub as joeykork.
Quoted 29 lines · On Fri, Apr 24, 2009 at 2:41 AM, Joey Korkames…
This patch did not work as well as the last one posted (on my test machine). The last one got all the way to trying to run
/sbin/launchdoff the ramdisk - log post of this one's boot attempt are attached.Oh, here is my updated menuentry, works well and gives me serial output of the darwin kernel (as well as on the VGA monitor):
menuentry "PureDarwin 9 (phcoder efiemu)" {
echo "Switching to VESA and booting Darwin (slow)... " #bootloader must tickle VESA before xnu can use itloadfont /osstore/STAGE1a/grub2/unifont.pf2 set gfxmode="800x600x32" set vbe_mode=0x115 terminal_output gfxterm echo "VESA enabled. Booting Darwin (slow)... " #efiemu_loadcore /osstore/STAGE1a/grub2/efiemu64.o efiemu_loadcore /osstore/STAGE1a/grub2/efiemu32.o efiemu_pnvram efiemu_prepare xnu_kernel /osstore/STAGE2/DARWIN/live/mach_kernel -s -f debug=0x08 serial=2 serialbaud=9600 rd=md0
Quoted 2 lines
-f parameter isn't actually used. Use
xnu_kextdirif you don't want to use mkext
Ok, dropping the -f. I don't think xnu_kextdir will work with (pxefs).
Quoted 10 lines
xnu_mkext/osstore/STAGE2/DARWIN/live/System/Library/Extensions.mkextxnu_ramdisk/osstore/STAGE2/DARWIN/ramdisk.hfs
# ^^30MB too big? (full /System/Library/Extensions) - yes, box will reboot before kernel turnoverCan you give more info about it
I'll test again, that conclusion was before I had a stable menuentry. But basically, putting a full /System/Library/Extensions folder from a PureDarwin iso into my ramdisk caused my machine to reboot itself (triple-fault?) before I saw any kernel printfs.
Boot log:
----------
Switching to VESA and booting Darwin (slow)...
Serial mode specified: 00000002version_variant = 0
version = Darwin Kernel Version 9.5.0: Thu Sep 18 14:14:00 PDT 2008; root:xnu-1228.7.58.obj/RELEASE_I386
EM64T supported and will be enabled
EFI region: type = 7/7, base = 0x0, top = 0x88
EFI region: type = 8/8, base = 0x89, top = 0x9f
EFI region: type = 8/8, base = 0xca, top = 0xcb
EFI region: type = 8/8, base = 0xe4, top = 0xff
EFI region: type = 7/7, base = 0x100, top = 0x9bfbc
EFI region: type = 5/5, base = 0x9bfbd, top = 0x9bfbd
EFI region: type = 6/6, base = 0x9bfbe, top = 0x9bfc0
EFI region: type = 7/7, base = 0x9bfc1, top = 0xcff4f
EFI region: type = 9/9, base = 0xcff50, top = 0xcff5d
EFI region: type = 10/10, base = 0xcff5e, top = 0xcff5e
EFI region: type = 8/8, base = 0xcff5f, top = 0xcff7f
EFI region: type = 8/8, base = 0xcff80, top = 0xcffff
EFI region: type = 8/8, base = 0xe0000, top = 0xeffff
EFI region: type = 8/8, base = 0xfec00, top = 0xfec0f
EFI region: type = 8/8, base = 0xfee00, top = 0xfee00
EFI region: type = 8/8, base = 0xff000, top = 0xfffff
Physical memory 3328 MBHIGH_MEM_BASE 0xffe00000 fixed per-cpu begin 0xffe17000
tramp: 0xffe00000, GDT: 0xffe02000, LDT: 0xffe04000, IDT: 0xffe03000, KTSS: 0xffe14000, DFTSS: 0xffe15000
MCTSS: 0xffe15000
gdt/idt reloaded, tr reset to KERNEL_TSS
Kernel virtual space from 0x0 to 0xfe7fffff.
64 bit mode enabled
Available physical space from 0x1058000 to 0xcff4f000EFI_FSB_frequency: read FSBFrequency value: 1333000000
BUS: Frequency = 1333.0000MHz, cvtt2n = 00000000.C00C4A83, cvtn2t = 00000001.553F7CEE, cvtInt = 000B726B.8BFE44F9
TSC: Frequency = 9331.0019MHz, cvtt2n = 00000000.1B6F785B, cvtn2t = 00000009.54BC6AD2, gran = 7
RCBA: vaddr = 0106E000, paddr = FED1C001
HPET: vaddr = 01072000, paddr = FED00000
HPET: Frequency = 14.318179MHz, cvtt2n = 00000045.D75E0F7F, cvtn2t = 00000000.03AA5B32initialize_screen: b=DC000000, w=00000320, h=00000258, r=00000C80, d=00000001pmap_steal_memory: 0124B000 - 0124C000; size=00001000pmap_steal_memory: 0124C000 - 016BF000; size=00473000pmap_steal_memory: 016BF000 - 016CC000; size=0000D000pmap_steal_memory: 016CC000 - 01ACC000; size=00400000pmap_steal_memory: 01ACC000 - 03DE6608; size=0231A608
CPU identification: Intel(R) Xeon(R) CPU L5410 @ 2.33GHz
CPU features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM SSE3 MON DSCPL VMX EST TM2 SSSE3 CX16 TPR PDCM SSE4.1
HTT: 4 cores per package; 4 logical cpus per package
CPU extended features: XD EM64T
Initializing EFI runtime services
Boot args version 1 revision 4 mode 32
Processing 32-bit EFI tables at 0x9bfbe060
RuntimeServices table at 0x9bfbe000MSR_IA32_APIC_BASE 0xfee00000 enabled BSP
Boot cpu local APIC id 0x0
[RTCLOCK] frequency 9330000000 (9331000019)
maxDec: 1611015488
Kernel boot args: '-s -f debug=0x08 serial=2 serialbaud=9600 rd=md0'
ACPI: RSDP @ 0xf5a50/0x0024 (v002 PTLTD )
ACPI: XSDT @ 0xcff55a96/0x0094 (v001 PTLTD XSDT 0x06040000 LTP 0x00000000)
ACPI: FACP @ 0xcff5dd9c/0x00F4 (v003 INTEL SANCLMNT 0x06040000 PTL 0x00000003)
ACPI: DSDT @ 0xcff575fc/0x671C (v001 Intel SANCLMNT 0x06040000 MSFT 0x03000001)
ACPI: FACS @ 0xcff5efc0/0x0040
ACPI: APIC @ 0xcff5de90/0x00BC (v001 PTLTD APIC 0x06040000 LTP 0x00000000)
ACPI: MCFG @ 0xcff5df4c/0x003C (v001 PTLTD MCFG 0x06040000 LTP 0x00000000)
ACPI: BOOT @ 0xcff5df88/0x0028 (v001 PTLTD $SBFTBL$ 0x06040000 LTP 0x00000001)
ACPI: SPCR @ 0xcff5dfb0/0x0050 (v001 PTLTD $UCRTBL$ 0x06040000 PTL 0x00000001)
ACPI: SSDT @ 0xcff5739d/0x025F (v001 PmRef Cpu0Tst 0x00003000 INTL 0x20061109)
ACPI: SSDT @ 0xcff572f7/0x00A6 (v001 PmRef Cpu7Tst 0x00003000 INTL 0x20061109)
ACPI: SSDT @ 0xcff57251/0x00A6 (v001 PmRef Cpu6Tst 0x00003000 INTL 0x20061109)
ACPI: SSDT @ 0xcff571ab/0x00A6 (v001 PmRef Cpu5Tst 0x00003000 INTL 0x20061109)
ACPI: SSDT @ 0xcff57105/0x00A6 (v001 PmRef Cpu4Tst 0x00003000 INTL 0x20061109)
ACPI: SSDT @ 0xcff5705f/0x00A6 (v001 PmRef Cpu3Tst 0x00003000 INTL 0x20061109)
ACPI: SSDT @ 0xcff56fb9/0x00A6 (v001 PmRef Cpu2Tst 0x00003000 INTL 0x20061109)
ACPI: SSDT @ 0xcff56f13/0x00A6 (v001 PmRef Cpu1Tst 0x00003000 INTL 0x20061109)
ACPI: SSDT @ 0xcff55b2a/0x13E9 (v001 PmRef CpuPm 0x00003000 INTL 0x20061109)cpu_data_alloc(1) 0x463c6000 desc_table: 0x4ef45000 ldt: 0x4ef48000 int_stack: 0x4ef41000-0x4ef45000cpu_data_alloc(2) 0x463dd000 desc_table: 0x4ef70000 ldt: 0x4ef73000 int_stack: 0x4ef6c000-0x4ef70000cpu_data_alloc(3) 0x4ef32000 desc_table: 0x4ef9b000 ldt: 0x4ef9e000 int_stack: 0x4ef97000-0x4ef9b000cpu_data_alloc(4) 0x4efc4000 desc_table: 0x4efc9000 ldt: 0x4efcc000 int_stack: 0x4efc5000-0x4efc9000cpu_data_alloc(5) 0x4eff4000 desc_table: 0x4eff9000 ldt: 0x4effc000 int_stack: 0x4eff5000-0x4eff9000cpu_data_alloc(6) 0x4f024000 desc_table: 0x4f029000 ldt: 0x4f02c000 int_stack: 0x4f025000-0x4f029000cpu_data_alloc(7) 0x4f054000 desc_table: 0x4f059000 ldt: 0x4f05c000 int_stack: 0x4f055000-0x4f059000
cpu_datap(1):0x463dd000 local apic id 0x1 remapped from 2
cpu_datap(2):0x4efc4000 local apic id 0x2 remapped from 4
cpu_datap(3):0x4f024000 local apic id 0x3 remapped from 6
cpu_datap(4):0x463c6000 local apic id 0x4 remapped from 1
cpu_datap(5):0x4ef32000 local apic id 0x5 remapped from 3
cpu_datap(6):0x4eff4000 local apic id 0x6 remapped from 5
Started cpu 1 (lapic id 00000001)
Started cpu 2 (lapic id 00000002)
Started cpu 3 (lapic id 00000003)
Started cpu 4 (lapic id 00000004)
Started cpu 5 (lapic id 00000005)
Started cpu 6 (lapic id 00000006)
Started cpu 7 (lapic id 00000007)bsd_autoconf: calling kminit
Serial keyboard started
panic(cpu 3 caller 0x0036FE27): "Process 1 exec of /sbin/launchd failed, errno 2\n"@/Volumes/work/darwin/9F33-roots/BuildRoot/SourceCache/xnu/xnu-1228.7.58/bsd/kern/kern_exec.c:2885 Debugger called: <panic>
Backtrace (CPU 3), Frame : Return Address (4 potential args on stack)0x4f1abe48 : 0x12b0fa (0x4598d8 0x4f1abe7c 0x133243 0x0)0x4f1abe98 : 0x36fe27 (0x498bac 0x5196e4 0x2 0x0)0x4f1abef8 : 0x3518d8 (0x53cac50 0x7e 0x52dcdac 0x80000001)0x4f1abf38 : 0x37f30a (0x52e8ba0 0x8b0af0b4 0x1a236f 0x52e8c7c)0x4f1abf68 : 0x1291aa (0x52e8ba0 0x
--------------------
(serial stopped here)
Update. No need to initialize efiemu manually anymore
Quoted 65 lines · phcoder
Hello. Here is my xnu patch. Tested on i386-pc, i386-efi and x86_64-efi. On non-efi it needs efiemu otherwise you need only
include/grub/autoefi.hfile from efiemu patch. To resume xnu from hibernation do:xnu_resume<hibernation file>
Note: you don't need efiemu in this case
How to boot xnu:
<efiemu if not on efi platform>
[on pc only:] vbe_mode=0xYYY # desired vga mode
fsb=133.3 # your fsb frequencyxnu_kernel<kernel> <command line>
<insert modules>
boot
Modules can be inserted one of the following ways:
1)xnu_mkext<mkext file>
2)xnu_kextextension.kext
3)xnu_kextextension.kext/Info.plist extension.kext/extension
4)xnu_kextdir<directory containing extensions>
It's also possible to execute these commands multiple times
The most typical case isxnu_kernel/mach_kernel rd=disk0sXxnu_mkext/System/Library/Extensions.mkextIf you need to add values to device tree the command
xnu_devtree<devtree file>
This file uses the following format:
valuename:valuedata;
keyname{
contents
}
keyname, valuename and valuedata are in hex.If you need to adda ramdisk execute
xnu_ramdisk<ramdisk file>
ramdisk will be exposed as/dev/md0which may be used as boot device with rd=md0.The areas which need more work (every help is welcome):
1) testing on different platforms
2) Detect "device-properties" value in device tree. There are several trivial values in device tree present in boot.efi but not in grub2. These ones are easy to add and AFAIK don't change anything. But the value "device-properties" is difficult. I already know it's format but not where the values come from. It contains info about gfx and sound card which may not work if this value is missing. The current workaround isxnu_devtreecommand with a dump of device-properties
3) autodetect fsb frequency
4) Support video splash
5) Define and use an unified interface to retrieve video information uniformly across platforms
6) Boot by UUID. I know how to do it but need md5 for it which is a part of pending luks patch
7) Scripts for automatic creating of grub.cfg entries
8) Support for prelinked kernel. It's compressed and I have yet looked how to decompress it (seems it's compressed with something called lzss)
9) Use claimmap once available (see my multiboot on efi patch)
10) Better collaboration with memory management once advanced mm's available
11) Resume from encrypted hibernation--
Regards
Vladimir 'phcoder' Serbinenko
Signature · 2 lines
Regards Vladimir 'phcoder' Serbinenko
conf/i386-efi.rmk +8 -1
@@ -99,7 +99,7 @@ kernel_mod_SOURCES = kern/i386/efi/startup.S kern/main.c kern/device.c \ kernel_mod_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \ env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \ partition.h pc_partition.h rescue.h symbol.h term.h time.h types.h \ - efi/efi.h efi/time.h efi/disk.h list.h handler.h command.h + efi/efi.h efi/time.h efi/disk.h i386/pit.h list.h handler.h command.h kernel_mod_CFLAGS = $(COMMON_CFLAGS) kernel_mod_ASFLAGS = $(COMMON_ASFLAGS) kernel_mod_LDFLAGS = $(COMMON_LDFLAGS)
@@ -201,5 +201,12 @@ fixvideo_mod_SOURCES = commands/efi/fixvideo.c fixvideo_mod_CFLAGS = $(COMMON_CFLAGS) fixvideo_mod_LDFLAGS = $(COMMON_LDFLAGS) +pkglib_MODULES += xnu.mod +xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/efi/xnu.c\ + loader/macho.c loader/xnu.c loader/i386/xnu_helper.S +xnu_mod_CFLAGS = $(COMMON_CFLAGS) -Werror -Wall +xnu_mod_LDFLAGS = $(COMMON_LDFLAGS) +xnu_mod_ASFLAGS = $(COMMON_ASFLAGS) + include $(srcdir)/conf/i386.mk include $(srcdir)/conf/common.mk
conf/i386-pc.rmk +8 -1
@@ -61,7 +61,7 @@ kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \ partition.h pc_partition.h rescue.h symbol.h term.h time.h types.h \ machine/biosdisk.h machine/boot.h machine/console.h machine/init.h \ machine/memory.h machine/loader.h machine/vga.h machine/vbe.h \ - machine/kernel.h machine/pxe.h list.h handler.h command.h + machine/kernel.h machine/pxe.h i386/pit.h list.h handler.h command.h kernel_img_CFLAGS = $(COMMON_CFLAGS) kernel_img_ASFLAGS = $(COMMON_ASFLAGS) kernel_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS) -Wl,-Ttext,$(GRUB_MEMORY_MACHINE_LINK_ADDR) $(COMMON_CFLAGS)
@@ -227,6 +227,13 @@ linux_mod_SOURCES = loader/i386/linux.c linux_mod_CFLAGS = $(COMMON_CFLAGS) linux_mod_LDFLAGS = $(COMMON_LDFLAGS) +pkglib_MODULES += xnu.mod +xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/pc/xnu.c\ + loader/macho.c loader/xnu.c loader/i386/xnu_helper.S +xnu_mod_CFLAGS = $(COMMON_CFLAGS) -Werror -Wall +xnu_mod_LDFLAGS = $(COMMON_LDFLAGS) +xnu_mod_ASFLAGS = $(COMMON_ASFLAGS) + # # Only arch dependant part of normal.mod will be here. Common part for # all architecures of normal.mod is at start and should be kept at sync
conf/x86_64-efi.rmk +8 -1
@@ -100,7 +100,7 @@ kernel_mod_SOURCES = kern/x86_64/efi/startup.S kern/x86_64/efi/callwrap.S \ kernel_mod_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \ env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \ partition.h pc_partition.h rescue.h symbol.h term.h time.h types.h \ - efi/efi.h efi/time.h efi/disk.h machine/loader.h list.h handler.h \ + efi/efi.h efi/time.h efi/disk.h machine/loader.h i386/pit.h list.h handler.h \ command.h kernel_mod_CFLAGS = $(COMMON_CFLAGS) kernel_mod_ASFLAGS = $(COMMON_ASFLAGS)
@@ -203,5 +203,12 @@ fixvideo_mod_SOURCES = commands/efi/fixvideo.c fixvideo_mod_CFLAGS = $(COMMON_CFLAGS) fixvideo_mod_LDFLAGS = $(COMMON_LDFLAGS) +pkglib_MODULES += xnu.mod +xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/efi/xnu.c\ + loader/macho.c loader/xnu.c loader/i386/xnu_helper.S +xnu_mod_CFLAGS = $(COMMON_CFLAGS) -Werror -Wall +xnu_mod_LDFLAGS = $(COMMON_LDFLAGS) +xnu_mod_ASFLAGS = $(COMMON_ASFLAGS) + include $(srcdir)/conf/i386.mk include $(srcdir)/conf/common.mk
include/grub/efi/efi.h +1 -0
@@ -56,6 +56,7 @@ EXPORT_FUNC(grub_efi_get_device_path) (grub_efi_handle_t handle);int EXPORT_FUNC (grub_efi_exit_boot_services ) (grub_efi_uintn_t map_key);void EXPORT_FUNC (grub_reboot ) (void );void EXPORT_FUNC (grub_halt ) (void ); +int EXPORT_FUNC (grub_efi_finish_boot_services ) (void );void grub_efi_mm_init (void );void grub_efi_mm_fini (void );
include/grub/i386/macho.h new file +11 -0
@@ -0,0 +1,11 @@ +#define GRUB_MACHO_CPUTYPE_IS_HOST32 (x) ((x)==0x00000007) +#define GRUB_MACHO_CPUTYPE_IS_HOST64 (x) ((x)==0x01000007) + +struct grub_macho_thread32 +{ +grub_uint32_t cmd; +grub_uint32_t cmdsize; +grub_uint8_t unknown1[48 ]; +grub_uint32_t entry_point; +grub_uint8_t unknown2[20 ]; +} __attribute__ ((packed));
include/grub/i386/pit.h +2 -1
@@ -20,7 +20,8 @@#define KERNEL_CPU_PIT_HEADER 1#include <grub/types.h> +#include <grub/err.h> -extern void grub_pit_wait (grub_uint16_t tics); +void EXPORT_FUNC (grub_pit_wait ) (grub_uint16_t tics);#endif /* ! KERNEL_CPU_PIT_HEADER */
include/grub/i386/xnu.h new file +60 -0
60 lines not on this page · raw message
include/grub/macho.h new file +107 -0
107 lines not on this page · raw message
include/grub/machoload.h new file +62 -0
62 lines not on this page · raw message
include/grub/x86_64/macho.h new file +1 -0
@@ -0,0 +1 @@ +#include <grub/i386/macho.h>
include/grub/x86_64/xnu.h new file +1 -0
@@ -0,0 +1 @@ +#include <grub/i386/xnu.h>
include/grub/xnu.h new file +104 -0
104 lines not on this page · raw message
kern/efi/efi.c +23 -0
@@ -734,3 +734,26 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp) dp = (grub_efi_device_path_t *) ((char *) dp + len); } } + +int +grub_efi_finish_boot_services (void ) +{ +grub_efi_uintn_t mmap_size =0 ; +grub_efi_uintn_t map_key; +grub_efi_uintn_t desc_size; +grub_efi_uint32_t desc_version; +void *mmap_buf =0 ; + +if (grub_efi_get_memory_map (&mmap_size, mmap_buf, &map_key, + &desc_size, &desc_version) <0 ) +return 0 ; + + mmap_buf =grub_malloc (mmap_size); + +if (grub_efi_get_memory_map (&mmap_size, mmap_buf, &map_key, + &desc_size, &desc_version) <=0 ) +return 0 ; + +return grub_efi_exit_boot_services (map_key); +} +
kern/efi/mm.c +1 -1
@@ -47,7 +47,7 @@ static struct allocated_page *allocated_pages = 0;/* The minimum and maximum heap size for GRUB itself. */ #define MIN_HEAP_SIZE 0x100000 -#define MAX_HEAP_SIZE (16 * 0x100000) +#define MAX_HEAP_SIZE (1600 * 0x100000)/* Allocate pages. Return the pointer to the first of allocated pages. */
loader/i386/efi/xnu.c new file +177 -0
177 lines not on this page · raw message
loader/i386/pc/xnu.c new file +67 -0
67 lines not on this page · raw message
loader/i386/xnu.c new file +539 -0
539 lines not on this page · raw message
loader/i386/xnu_helper.S new file +192 -0
192 lines not on this page · raw message
loader/macho.c new file +395 -0
395 lines not on this page · raw message
loader/xnu.c new file +1345 -0
1,173 lines not on this page · raw message
loader/xnu_resume.c new file +136 -0
136 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
commited
Quoted 76 lines · Vladimir 'phcoder' Serbinenko
Update. No need to initialize efiemu manually anymore
Quoted 60 lines · phcoder
Hello. Here is my xnu patch. Tested on i386-pc, i386-efi and x86_64-efi. On non-efi it needs efiemu otherwise you need only
include/grub/autoefi.hfile from efiemu patch. To resume xnu from hibernation do:xnu_resume<hibernation file>
Note: you don't need efiemu in this case
How to boot xnu:
<efiemu if not on efi platform>
[on pc only:] vbe_mode=0xYYY # desired vga mode
fsb=133.3 # your fsb frequencyxnu_kernel<kernel> <command line>
<insert modules>
boot
Modules can be inserted one of the following ways:
1)xnu_mkext<mkext file>
2)xnu_kextextension.kext
3)xnu_kextextension.kext/Info.plist extension.kext/extension
4)xnu_kextdir<directory containing extensions>
It's also possible to execute these commands multiple times The most typical case isxnu_kernel/mach_kernel rd=disk0sXxnu_mkext/System/Library/Extensions.mkextIf you need to add values to device tree the command
xnu_devtree<devtree file>
This file uses the following format:
valuename:valuedata;
keyname{
contents
}
keyname, valuename and valuedata are in hex.If you need to adda ramdisk execute
xnu_ramdisk<ramdisk file>
ramdisk will be exposed as/dev/md0which may be used as boot device with rd=md0.The areas which need more work (every help is welcome):
1) testing on different platforms
2) Detect "device-properties" value in device tree. There are several trivial values in device tree present in boot.efi but not in grub2. These ones are easy to add and AFAIK don't change anything. But the value "device-properties" is difficult. I already know it's format but not where the values come from. It contains info about gfx and sound card which may not work if this value is missing. The current workaround isxnu_devtreecommand with a dump of device-properties
3) autodetect fsb frequency
4) Support video splash
5) Define and use an unified interface to retrieve video information uniformly across platforms
6) Boot by UUID. I know how to do it but need md5 for it which is a part of pending luks patch
7) Scripts for automatic creating of grub.cfg entries
8) Support for prelinked kernel. It's compressed and I have yet looked how to decompress it (seems it's compressed with something called lzss)
9) Use claimmap once available (see my multiboot on efi patch)
10) Better collaboration with memory management once advanced mm's available
11) Resume from encrypted hibernationQuoted 5 lines
--
Regards
Vladimir 'phcoder' Serbinenko--
Regards
Vladimir 'phcoder' Serbinenko
Signature · 2 lines
Regards Vladimir 'phcoder' Serbinenko
Hi,
xnu usage is quite complicated, perhaps you could write a wiki page on it.
Quoted 92 lines · Vladimir 'phcoder' Serbinenko
commited
Quoted 67 lines · Vladimir 'phcoder' Serbinenko
Update. No need to initialize efiemu manually anymore
Quoted 63 lines · phcoder
Hello. Here is my xnu patch. Tested on i386-pc, i386-efi and x86_64-efi. On non-efi it needs efiemu otherwise you need only
include/grub/autoefi.hfile from efiemu patch. To resume xnu from hibernation do:xnu_resume<hibernation file>
Note: you don't need efiemu in this case
How to boot xnu:
<efiemu if not on efi platform>
[on pc only:] vbe_mode=0xYYY # desired vga mode
fsb=133.3 # your fsb frequencyxnu_kernel<kernel> <command line>
<insert modules>
boot
Modules can be inserted one of the following ways:
1)xnu_mkext<mkext file>
2)xnu_kextextension.kext
3)xnu_kextextension.kext/Info.plist extension.kext/extension
4)xnu_kextdir<directory containing extensions>
It's also possible to execute these commands multiple times The most typical case isxnu_kernel/mach_kernel rd=disk0sXxnu_mkext/System/Library/Extensions.mkextIf you need to add values to device tree the command
xnu_devtree<devtree file>
This file uses the following format:
valuename:valuedata;
keyname{
contents
}
keyname, valuename and valuedata are in hex.If you need to adda ramdisk execute
xnu_ramdisk<ramdisk file>
ramdisk will be exposed as/dev/md0which may be used as boot device with rd=md0.The areas which need more work (every help is welcome):
1) testing on different platforms
2) Detect "device-properties" value in device tree. There are several trivial values in device tree present in boot.efi but not in grub2. These ones are easy to add and AFAIK don't change anything. But the value "device-properties" is difficult. I already know it's format but not where the values come from. It contains info about gfx and sound card which may not work if this value is missing. The current workaround isxnu_devtreecommand with a dump of device-properties
3) autodetect fsb frequency
4) Support video splash
5) Define and use an unified interface to retrieve video information uniformly across platforms
6) Boot by UUID. I know how to do it but need md5 for it which is a part of pending luks patch
7) Scripts for automatic creating of grub.cfg entries
8) Support for prelinked kernel. It's compressed and I have yet looked how to decompress it (seems it's compressed with something called lzss)
9) Use claimmap once available (see my multiboot on efi patch)
10) Better collaboration with memory management once advanced mm's available
11) Resume from encrypted hibernation--
Quoted 8 lines
Quoted 2 lines
Regards
Vladimir 'phcoder' Serbinenko--
Regards
Vladimir 'phcoder' Serbinenko--
Regards
Vladimir 'phcoder' Serbinenko_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 1 line
Bean
Quoted 4 lines · Bean
Hi,
xnu usage is quite complicated, perhaps you could write a wiki page on it.
On it
Quoted 115 lines
Quoted 10 lines · Vladimir 'phcoder' Serbinenko
commited
Quoted 6 lines · Vladimir 'phcoder' Serbinenko
Update. No need to initialize efiemu manually anymore
Quoted 2 lines · phcoder
Hello. Here is my xnu patch. Tested on i386-pc, i386-efi and
x86_64-efi.
Quoted 1 line
Quoted 1 line
Quoted 1 line
On non-efi it needs efiemu otherwise you need only
include/grub/autoefi.hQuoted 30 lines
Quoted 30 lines
Quoted 30 lines
file from efiemu patch. To resume xnu from hibernation do:
xnu_resume<hibernation file>
Note: you don't need efiemu in this case
How to boot xnu:
<efiemu if not on efi platform>
[on pc only:] vbe_mode=0xYYY # desired vga mode fsb=133.3 # your fsb frequencyxnu_kernel<kernel> <command line>
<insert modules>
boot
Modules can be inserted one of the following ways:
1)xnu_mkext<mkext file>
2)xnu_kextextension.kext
3)xnu_kextextension.kext/Info.plist extension.kext/extension
4)xnu_kextdir<directory containing extensions> It's also possible to execute these commands multiple times The most typical case isxnu_kernel/mach_kernel rd=disk0sXxnu_mkext/System/Library/Extensions.mkextIf you need to add values to device tree the command
xnu_devtree<devtree file>
This file uses the following format:
valuename:valuedata;
keyname{
contents
}
keyname, valuename and valuedata are in hex.Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
If you need to adda ramdisk execute
xnu_ramdisk<ramdisk file>
ramdisk will be exposed as/dev/md0which may be used as boot devicewith
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
rd=md0.
The areas which need more work (every help is welcome):
1) testing on different platforms
2) Detect "device-properties" value in device tree. There are several trivial values in device tree present in boot.efi but not in grub2.These
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
ones are easy to add and AFAIK don't change anything. But the value "device-properties" is difficult. I already know it's format but not
where
Quoted 1 line
Quoted 1 line
Quoted 1 line
the values come from. It contains info about gfx and sound card which
may
Quoted 1 line
Quoted 1 line
Quoted 1 line
not work if this value is missing. The current workaround is
xnu_devtreeQuoted 6 lines
Quoted 6 lines
Quoted 6 lines
command with a dump of device-properties
3) autodetect fsb frequency
4) Support video splash
5) Define and use an unified interface to retrieve video information uniformly across platforms
6) Boot by UUID. I know how to do it but need md5 for it which is apart
Quoted 22 lines
Quoted 11 lines
Quoted 11 lines
of pending luks patch
7) Scripts for automatic creating of grub.cfg entries
8) Support for prelinked kernel. It's compressed and I have yet looked how to decompress it (seems it's compressed with something called lzss)
9) Use claimmap once available (see my multiboot on efi patch)
10) Better collaboration with memory management once advanced mm's available
11) Resume from encrypted hibernation--
Quoted 8 lines
Quoted 2 lines
Regards
Vladimir 'phcoder' Serbinenko--
Regards
Vladimir 'phcoder' SerbinenkoQuoted 10 lines
--
Regards
Vladimir 'phcoder' Serbinenko_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel--
Bean_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 2 lines
Regards Vladimir 'phcoder' Serbinenko