* [PATCH] Workaround for the keyboard hang problem in intel mac
@ 2008-05-06 17:12 Bean
2008-05-07 12:55 ` Robert Millan
0 siblings, 1 reply; 5+ messages in thread
From: Bean @ 2008-05-06 17:12 UTC (permalink / raw)
To: The development of GRUB 2
Hi,
This patch fix the keyboard hang problem when using boot camp to load
legacy system.
diff --git a/kern/i386/pc/startup.S b/kern/i386/pc/startup.S
index 5d4bbcb..455233a 100644
--- a/kern/i386/pc/startup.S
+++ b/kern/i386/pc/startup.S
@@ -1240,6 +1240,19 @@ FUNCTION(grub_console_getkey)
call prot_to_real
.code16
+ pushfw
+ sti
+
+1:
+ movb $1, %ah
+ int $0x16
+ jnz 2f
+ hlt
+ jmp 1b
+
+2:
+ popfw
+ movb $0, %ah
int $0x16
movw %ax, %dx /* real_to_prot uses %eax */
--
Bean
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Workaround for the keyboard hang problem in intel mac
2008-05-06 17:12 [PATCH] Workaround for the keyboard hang problem in intel mac Bean
@ 2008-05-07 12:55 ` Robert Millan
2008-05-07 13:55 ` Bean
0 siblings, 1 reply; 5+ messages in thread
From: Robert Millan @ 2008-05-07 12:55 UTC (permalink / raw)
To: The development of GRUB 2
On Wed, May 07, 2008 at 01:12:08AM +0800, Bean wrote:
> Hi,
>
> This patch fix the keyboard hang problem when using boot camp to load
> legacy system.
>
> diff --git a/kern/i386/pc/startup.S b/kern/i386/pc/startup.S
> index 5d4bbcb..455233a 100644
> --- a/kern/i386/pc/startup.S
> +++ b/kern/i386/pc/startup.S
> @@ -1240,6 +1240,19 @@ FUNCTION(grub_console_getkey)
> call prot_to_real
> .code16
>
> + pushfw
> + sti
> +
> +1:
> + movb $1, %ah
> + int $0x16
> + jnz 2f
> + hlt
> + jmp 1b
> +
> +2:
> + popfw
> + movb $0, %ah
I think it'd be nice to have a comment there explaining why this is done.
--
Robert Millan
<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Workaround for the keyboard hang problem in intel mac
2008-05-07 12:55 ` Robert Millan
@ 2008-05-07 13:55 ` Bean
2008-05-07 17:09 ` Pavel Roskin
0 siblings, 1 reply; 5+ messages in thread
From: Bean @ 2008-05-07 13:55 UTC (permalink / raw)
To: The development of GRUB 2
On Wed, May 7, 2008 at 8:55 PM, Robert Millan <rmh@aybabtu.com> wrote:
> I think it'd be nice to have a comment there explaining why this is done.
Hi,
You're right, here is the patch with comment:
diff --git a/kern/i386/pc/startup.S b/kern/i386/pc/startup.S
index 5d4bbcb..a67bf6d 100644
--- a/kern/i386/pc/startup.S
+++ b/kern/i386/pc/startup.S
@@ -1240,6 +1240,26 @@ FUNCTION(grub_console_getkey)
call prot_to_real
.code16
+ /*
+ * Due to a bug in apple's bootcamp implementation, INT 16/AH = 0 would
+ * cause the machine to hang at the second keystroke. However, we can
+ * work around this problem by ensuring the presence of keystroke with
+ * INT 16/AH = 1 before calling INT 16/AH = 0.
+ */
+
+ pushfw
+ sti
+
+1:
+ movb $1, %ah
+ int $0x16
+ jnz 2f
+ hlt
+ jmp 1b
+
+2:
+ popfw
+ movb $0, %ah
int $0x16
movw %ax, %dx /* real_to_prot uses %eax */
--
Bean
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Workaround for the keyboard hang problem in intel mac
2008-05-07 13:55 ` Bean
@ 2008-05-07 17:09 ` Pavel Roskin
2008-05-07 17:29 ` Bean
0 siblings, 1 reply; 5+ messages in thread
From: Pavel Roskin @ 2008-05-07 17:09 UTC (permalink / raw)
To: The development of GRUB 2
On Wed, 2008-05-07 at 21:55 +0800, Bean wrote:
> + /*
> + * Due to a bug in apple's bootcamp implementation, INT 16/AH = 0 would
> + * cause the machine to hang at the second keystroke. However, we can
> + * work around this problem by ensuring the presence of keystroke with
> + * INT 16/AH = 1 before calling INT 16/AH = 0.
> + */
Can it be because interrupts are not enabled during the call?
> + pushfw
> + sti
...
> + popfw
I would prefer explicit sti and cli without saving flags on the stack,
unless we want the code work with both enabled and disabled interrupts.
Robustness is not always handling unexpected situations. Sometimes it's
enforcing the rules and being clear about it.
It's just a suggestion, not an invitation for a long discussion about
three instructions :-)
--
Regards,
Pavel Roskin
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Workaround for the keyboard hang problem in intel mac
2008-05-07 17:09 ` Pavel Roskin
@ 2008-05-07 17:29 ` Bean
0 siblings, 0 replies; 5+ messages in thread
From: Bean @ 2008-05-07 17:29 UTC (permalink / raw)
To: The development of GRUB 2
On Thu, May 8, 2008 at 1:09 AM, Pavel Roskin <proski@gnu.org> wrote:
> On Wed, 2008-05-07 at 21:55 +0800, Bean wrote:
>
> > + /*
> > + * Due to a bug in apple's bootcamp implementation, INT 16/AH = 0 would
> > + * cause the machine to hang at the second keystroke. However, we can
> > + * work around this problem by ensuring the presence of keystroke with
> > + * INT 16/AH = 1 before calling INT 16/AH = 0.
> > + */
>
> Can it be because interrupts are not enabled during the call?
I just check, enabling interrupt alone doesn't solve the problem.
According to the discussion at:
https://www.opensolaris.org/jive/thread.jspa?threadID=7554&tstart=0
Some I/O port is not implemented, I guess this cause INT 16/AH = 0 to
wait forever.
>
> > + pushfw
> > + sti
> ...
> > + popfw
>
> I would prefer explicit sti and cli without saving flags on the stack,
> unless we want the code work with both enabled and disabled interrupts.
>
> Robustness is not always handling unexpected situations. Sometimes it's
> enforcing the rules and being clear about it.
>
> It's just a suggestion, not an invitation for a long discussion about
> three instructions :-)
Yep, actually, I think even the ending cli can be omitted, because it
will jump right back to protected mode after the keystroke is
received.
--
Bean
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-05-07 17:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-06 17:12 [PATCH] Workaround for the keyboard hang problem in intel mac Bean
2008-05-07 12:55 ` Robert Millan
2008-05-07 13:55 ` Bean
2008-05-07 17:09 ` Pavel Roskin
2008-05-07 17:29 ` Bean
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.