Skip to contentSkip to conversation

grub.efi x86_64 on Apple 64bit efi models - status of testing

PATCH Peter Cros 5 participants 11 messages Feb 9, 2009 – Feb 11, 2009

lore
Share & tools
lore

Peter Cros

author
#0 lore raw

I have got to a standstill with this, some major stoppers found and could
use some help to debug further. I hope someone can take a look at this please, its getting beyond my limited C code reading and hacking capabilities, but I do want to see grub.efi working on current Apple Intel Macs.

Apple Linux/OSX users can benefit from grub.efi major advantages over the Apple pc-bios emulation which cannot boot external drives and has other installation problems for Linux users. Apple Mac users multi-booting GNU/Linux and Mac OSX are a good testing ground for EFI booting. A number of people in the ubuntuforums have tested grub.efi x86 and x86_64 on Apple intel Macs from intel core2duo on. There have also been some recent reported problems posted on grub-devel list.

I have not seen anything for IA32/64 machines.

From early 2008, Macs have been using 64bit EFI, needing x86_64 grub.efi, and I have posted on ubuntuforums a full x86_64 grub.efi package with all modules and grub.cfg for people to try.

No one has been able to get x86_64 grub.efi to boot and run either Mac OSX (boot.efi) or ubuntu 810 2.6.27 kernels (configured for EFI). All this works well for x86 grub.efi on Intel Macs with the earlier 32 bit firmware.

-------------------------------

Three specific issues are stopping useful testing -

1. Mac models from imac8,1 early 2008 are unable to boot grub.efi 64bit when 4GB RAM is fitted.
Dropping to 2GB RAM enables grub.efi to boot and display grub.cfg menu
with fully functional command line. This leads to the next problems -

2. The grub.efi chainloader command fails to load /usr/standalone/i386/boot.efi, reporting ' error: cannot load image '

3. grub.efi successfully loads ubuntu x86 2.6.7-7 kernel ( or earlier debian 2.6.26 ) using command line or menuentry, but the boot fails.

After boot command, the boot screen goes to black and no further progress seen,
except in one case some garbled video indicating possible boot but failure to init.

4. Finally, there was a problem getting ubuntu 810 amd64 to complete initialization after booting in earlier 32 bit grub.efi tests, and other issues with accelerated graphics and keyboard. - Not yet the issue here.

-------------------------

I got as far as locating the area in the grub2 code as shown in the attached diffs of commented files, and will continue to look throught the code, or can try any suggested debugging. I have some access to an Imac8,1 MacBook Pro 4,1 and a MacBook2,1.
( So far using set debug=all or selective, grub_printf(); grub_getkey(); asm volatile ("ret" : : ); )

But I am not a programmer and need help to go further. The x86 32 bit grub.efi functions very well on MacBook2,1 and other earlier 32 bit EFI Apples, but the later models need the x86_64 build, and at present it is not functional at all. The Apple firmware and EFI seems to need special treatment.

-------------------------
Diffs - ( these are just grub2 rev 1972 commented 'pxwdebug' to show where I got to )

Diff 1. Failing to run grub.efi with 4GB RAM.

grub2 r=1972

kern/x86_64/efi/startup.S 2009-02-09 18:19:32.000000000 +1100 renamed from kern/x86_64/efi/startup.S 2009-02-04 17:04:14.000000000 +1100 +2 -1
@@ -57,10 +57,12 @@ VARIABLE(grub_prefix)
 codestart:
 
     movq    %rcx, EXT_C(grub_efi_image_handle)
     movq    %rdx, EXT_C(grub_efi_system_table)
 
+/*pxwdebug - with 4GB RAM,  startup hangs before the call */
+
     call    EXT_C(grub_main)
     ret
 
-------------------------
 

Diff 2. Failure of efi chainloader for Mac OSX

grub2 r=1972

loader/efi/chainloader.c 2009-02-09 17:50:35.000000000 +1100 renamed from loader/efi/chainloader.c 2009-02-04 17:04:22.000000000 +1100 +2 -3
@@ -253,21 +253,21 @@ grub_rescue_cmd_chainloader (int argc, c
       if (grub_errno == GRUB_ERR_NONE)
     grub_error (GRUB_ERR_BAD_OS, "too small");
 
       goto fail;
     }
-
+/* pxwdebug macosx 10.4 10.5 fail to load with grub.efi x86_64 */
   status = efi_call_6 (b->load_image, 0, grub_efi_image_handle, file_path,
               (void *) ((grub_addr_t) address), size,
               &image_handle);
   if (status != GRUB_EFI_SUCCESS)
     {
       if (status == GRUB_EFI_OUT_OF_RESOURCES)
     grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of resources");
       else
     grub_error (GRUB_ERR_BAD_OS, "cannot load image");
-
+/*pxwdebug  error message is "cannot load image" */
       goto fail;
     }
 
-------------------------------

Diff 3. efi Linux boot fails.

grub2 r=1972

loader/i386/efi/linux.c 2009-02-09 18:09:22.000000000 +1100 renamed from loader/i386/efi/linux.c 2009-02-04 17:04:22.000000000 +1100 +2 -2
@@ -419,19 +419,19 @@ grub_linux_boot (void)
   asm volatile ("cli" : : );
 
   /* Load the IDT and the GDT for the bootstrap.  */
   asm volatile ("lidt %0" : : "m" (idt_desc));
   asm volatile ("lgdt %0" : : "m" (gdt_desc));
-
+/*pxwdebug x86_64 linux boot fails */
 #ifdef __x86_64__
 
   jumpvector.kernel_entry = (grub_uint64_t) grub_linux_real_boot;
   jumpvector.kernel_cs = 0x10;
 
   asm volatile ( "mov %0, %%rbx" : : "m" (params->code32_start));
   asm volatile ( "mov %0, %%rsi" : : "m" (real_mode_mem));
-
+/*pxwdebug boot fails after ljmp */
   asm volatile ( "ljmp *%0" : : "m" (jumpvector));
 
 #else
 
   /* Pass parameters.  */

-------------------------

Signature · 1 line
Cros
#1 lore raw
Quoted 7 lines

-------------------------------

Three specific issues are stopping useful testing -

1. Mac models from imac8,1 early 2008 are unable to boot grub.efi 64bit when 4GB RAM is fitted.
  Dropping to 2GB RAM enables grub.efi to boot and display grub.cfg  menu with fully functional command line. This leads to the next problems -

Quoted 6 lines

2. The grub.efi chainloader command fails to load /usr/standalone/i386/boot.efi, reporting ' error: cannot load image '

3. grub.efi successfully loads ubuntu x86 2.6.7-7 kernel ( or earlier debian 2.6.26 ) using command line or menuentry, but the boot fails.

After boot command, the boot screen goes to black and no further progress seen, except in one case some garbled video indicating possible boot but failure to init.

As I pointed out on the forums, the farthest I got with one kernel was for it to show either a shell (with init=/bin/sh) or the debian lenny install screen. All PCI and usb devices seemed to not work at all though, so doesn't

Quoted 1 line

4. Finally, there was a problem getting ubuntu 810 amd64 to complete initialization after booting in earlier 32 bit grub.efi tests, and other issues with accelerated graphics and keyboard. - Not yet the issue here.

The accelerated graphics from what I understand are a general issue with EFI booting, not much grub can do about it for now. If I understand it correctly, either grub would have to play a bigger part in video initilization, or more likely, the accelerated graphics drivers would have to be rewritten, not very likely I think.

Keyboard and usb in general is already an issue. For example the keyboard in the air, and probably in all macs is connected through usb, which so far seems to mean it for example does not work with a new module calle "at_keyboard" which should support keymaps and other nice stuff in the future. Before that we had a patch that solved a loss of keyboard input after about 2 mins, for the normal keyboard support. I assume the earlier one worked cause it relied more on callbacks to the EFI subsystem to make the usb.

Maybe this sums it up a bit. Of course, if any of the devs feel like I misrepresented some facts, feel free to correct.

#2 lore raw
Quoted 5 lines · On Mon, Feb 09, 2009 at 01:38:49PM +0100, step21 wrote:

Keyboard and usb in general is already an issue. For example the keyboard in the air, and probably in all macs is connected through usb, which so far seems to mean it for example does not work with a new module calle "at_keyboard" which should support keymaps and other nice stuff in the future.

Note at_keyboard is for PC/AT keyboards. But what you said applies to usb_keyboard too.

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
#3 lore raw

Mmm, I was under the impression I should test at_keyboard. However now this doesn't seem to make much sense. So usb_keyboard is not loaded automatically or is it?

Quoted 23 lines · Robert Millan
Quoted 5 lines · On Mon, Feb 09, 2009 at 01:38:49PM +0100, step21 wrote:

Keyboard and usb in general is already an issue. For example the keyboard in the air, and probably in all macs is connected through usb, which so far seems to mean it for example does not work with a new module calle "at_keyboard" which should support keymaps and other nice stuff in the future.

Note at_keyboard is for PC/AT keyboards.  But what you said applies to usb_keyboard too.

--
Robert Millan

 The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

#4 lore raw
Quoted 1 line · On Mon, Feb 09, 2009 at 03:26:25PM +0100, step21 wrote:

Mmm, I was under the impression I should test at_keyboard.

That'd be because I told you to test at_keyboard ;-)

But I was wrong, as Vesa pointed out the keyboard on Mac hardware is wired to the USB controller.

Quoted 2 lines

So usb_keyboard is not loaded
automatically or is it?

No. First we need it to be complete / stable and add support for EHCI (btw, anyone feels like writing an EHCI driver?).

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
#5 lore raw

2009/2/9 Robert Millan <[email protected]>:

Quoted 5 lines · On Mon, Feb 09, 2009 at 03:26:25PM +0100, step21 wrote:
Quoted 1 line

Mmm, I was under the impression I should test at_keyboard.

That'd be because I told you to test at_keyboard ;-)

Quoted 9 lines

But I was wrong, as Vesa pointed out the keyboard on Mac hardware is wired to the USB controller.

Quoted 2 lines

So usb_keyboard is not loaded
automatically or is it?

No. First we need it to be complete / stable and add support for EHCI (btw, anyone feels like writing an EHCI driver?).

Is EHCi driver needed for keyboard support?

I was under the impression that keyboards always appear connected to the low-full speed root hub, not the hihg-speed one.

Thanks

Michal

#6 lore raw
Quoted 10 lines · Michal Suchanek
Quoted 5 lines
Quoted 2 lines

So usb_keyboard is not loaded
automatically or is it?

No. First we need it to be complete / stable and add support for EHCI (btw, anyone feels like writing an EHCI driver?).

Is EHCi driver needed for keyboard support?

I was under the impression that keyboards always appear connected to the low-full speed root hub, not the hihg-speed one.

This would change things. Can someone confirm?

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
#7 lore raw
Quoted 7 lines · Robert Millan
Quoted 6 lines · Michal Suchanek
Quoted 5 lines
Quoted 2 lines

So usb_keyboard is not loaded
automatically or is it?

No. First we need it to be complete / stable and add support for EHCI (btw, anyone feels like writing an EHCI driver?).

Quoted 6 lines
Quoted 4 lines

Is EHCi driver needed for keyboard support?

I was under the impression that keyboards always appear connected to the low-full speed root hub, not the hihg-speed one.

This would change things. Can someone confirm?

Using system-profiler, it show me that the webcam is connected on a High speed usb bus, and not the keyboard :

USB Bus:

      Host Controller Location: Built In USB
      Host Controller Driver: AppleUSBUHCI
      PCI Device ID: 0x27c8
      PCI Revision ID: 0x0002
      PCI Vendor ID: 0x8086
      Bus Number: 0x1d

        Apple Internal Keyboard / Trackpad:

          Product ID: 0x021b
          Vendor ID: 0x05ac  (Apple Inc.)
          Version: 0.18
          Speed: Up to 12 Mb/sec
          Manufacturer: Apple Computer
          Location ID: 0x1d200000
          Current Available (mA): 500
          Current Required (mA): 40

this make sense, as a high speed bus is not really needed for a keyboard, I guess.

Signature · 1 line
Michael Scherer
#8 lore raw
In reply to Robert Millan

Tonight did some debugging on loading uhci / usb_keyboard. For starters: it is confirmed that it is uhci where everything fails so far as "insmod uhci; echo 1; insmod usb_keyboard; echo 2; terminal_input usb_keyboard; echo 3" (as suggested by nyu on irc I think) did not produce a single echo output.
I inserted some debug statements which so far led me to bus/usb/usbhub.c

Output.
bus/usb/uhci.c:661: at uhci init
bus/usb/uhci.c:663: at inithw
bus/usb/usb.c:36:device=uhci
bus/usb/usbhub.c:152:ports=2
bus/usb/usbhub.c:156:determined speed
bus/usb/usbhub.c:160:assigned device

These debug statements were all added by me iirc.
To see what I added: http://paste.debian.net/28056/ (usbhub.c)
http://paste.debian.net/28058/ (usb.c)
btw, did anyone notice that in usbhub.c it says "usb.c" in the header? confused me for a moment.

As far as I can tell so far it fails to enable the port with "err = controller->dev->portstatus (controller, i, 1);"
Why that fails I have no idea though, but I will try to continue with it tomorrow.

Best regards, step21

Quoted 27 lines · Robert Millan
Quoted 10 lines · Michal Suchanek
Quoted 5 lines
Quoted 2 lines

So usb_keyboard is not loaded
automatically or is it?

No.  First we need it to be complete / stable and add support for EHCI (btw, anyone feels like writing an EHCI driver?).

Is EHCi driver needed for keyboard support?

I was under the impression that keyboards always appear connected to the low-full speed root hub, not the hihg-speed one.

This would change things.  Can someone confirm?

--
Robert Millan

 The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

#9 lore raw

O.k. I tracked it down a bit more, but would like some input. Command executed:
"insmod uhci; echo 1; insmod usb_keyboard; echo 2; terminal_input usb_keyboard; echo 3"
Basically uhci and usb_keyboard load consistently now, for whatever reason. (I suspect it was sth about some weird device just taking forever to respond, although I wasn't able to reproduce this)
I get returned to the prompt, but no input is accepted. I tried to put some debug statements into console.c and some others I think have to do with terminal_input but those don't show up, however the last "echo 3" does appear. So I would like some pointers on where it would best to insert some more debug statements, or maybe if efi/console.c needs to be adapted to work with usb_keyboard, as I understand that at first it only was included in the compile for i386 anyway ...

Quoted 57 lines · On Tue, Feb 10, 2009 at 2:55 AM, step21 <[email protected]> wrote:

Tonight did some debugging on loading uhci / usb_keyboard. For starters: it is confirmed that it is uhci where everything fails so far as "insmod uhci; echo 1; insmod usb_keyboard; echo 2; terminal_input usb_keyboard; echo 3" (as suggested by nyu on irc I think) did not produce a single echo output.
I inserted some debug statements which so far led me to bus/usb/usbhub.c

Output.
bus/usb/uhci.c:661: at uhci init
bus/usb/uhci.c:663: at inithw
bus/usb/usb.c:36:device=uhci
bus/usb/usbhub.c:152:ports=2
bus/usb/usbhub.c:156:determined speed
bus/usb/usbhub.c:160:assigned device

These debug statements were all added by me iirc.
To see what I added: http://paste.debian.net/28056/ (usbhub.c)
http://paste.debian.net/28058/ (usb.c)
btw, did anyone notice that in usbhub.c it says "usb.c" in the header? confused me for a moment.

As far as I can tell so far it fails to enable the port with "err = controller->dev->portstatus (controller, i, 1);"
Why that fails I have no idea though, but I will try to continue with it tomorrow.

Best regards, step21

Quoted 27 lines · Robert Millan
Quoted 10 lines · Michal Suchanek
Quoted 5 lines
Quoted 2 lines

So usb_keyboard is not loaded
automatically or is it?

No.  First we need it to be complete / stable and add support for EHCI (btw, anyone feels like writing an EHCI driver?).

Is EHCi driver needed for keyboard support?

I was under the impression that keyboards always appear connected to the low-full speed root hub, not the hihg-speed one.

This would change things.  Can someone confirm?

--
Robert Millan

 The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

#10 lore raw
In reply to Robert Millan

O.k. I now found the semi-colon on the keyboard (it was indeed the ö key) However now it seems no uhci modules was built. I updated to svn rev 1985 from trunk, what I could see from the list and the web svn view I thought the usb patch was merged there already? Or do I have to pass a flag or something so it gets built?

Quoted 27 lines · Robert Millan
Quoted 1 line · On Mon, Feb 09, 2009 at 03:26:25PM +0100, step21 wrote:

Mmm, I was under the impression I should test at_keyboard.

That'd be because I told you to test at_keyboard ;-)

But I was wrong, as Vesa pointed out the keyboard on Mac hardware is wired to the USB controller.

Quoted 2 lines

So usb_keyboard is not loaded
automatically or is it?

No.  First we need it to be complete / stable and add support for EHCI (btw, anyone feels like writing an EHCI driver?).

--
Robert Millan

 The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel