Workaround for the keyboard hang problem in intel mac
PATCH 1/1 Workaround for the keyboard hang problem in intel mac
Hi,
This patch fix the keyboard hang problem when using boot camp to load legacy system.
kern/i386/pc/startup.S +13 -0
@@ -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 */
Signature · 1 line
Bean
Quoted 16 lines · Bean
Hi,
This patch fix the keyboard hang problem when using boot camp to load legacy system.
kern/i386/pc/startup.S +3
-0@@ -1240,6 +1240,19 @@ FUNCTION(grub_console_getkey) call prot_to_real .code16 + pushfw + sti +
kern/i386/pc/startup.S FUNCTION(grub_console_getkey) · line 1255
Quoted 10 lines
kern/i386/pc/startup.S +10
-0+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.
Signature · 5 lines
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 /.)
Quoted 1 line · Robert Millan
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:
kern/i386/pc/startup.S +20 -0
@@ -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 */
Signature · 1 line
Bean
kern/i386/pc/startup.S FUNCTION(grub_console_getkey) · line 1248
Quoted 6 lines · Bean
kern/i386/pc/startup.S +6
-0+ /* + * 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?
kern/i386/pc/startup.S FUNCTION(grub_console_getkey) · line 1251
Quoted 2 lines
kern/i386/pc/startup.S +2
-0+ pushfw + sti
...
kern/i386/pc/startup.S FUNCTION(grub_console_getkey) · line 1261
Quoted 1 line
kern/i386/pc/startup.S +1
-0+ 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 :-)
Signature · 2 lines
Regards, Pavel Roskin
Quoted 10 lines · Pavel Roskin
kern/i386/pc/startup.S FUNCTION(grub_console_getkey) · line 1248
Quoted 6 lines · Bean
kern/i386/pc/startup.S +6
-0+ /* + * 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.
Quoted 6 lines
kern/i386/pc/startup.S FUNCTION(grub_console_getkey) · line 1251
Quoted 3 lines
kern/i386/pc/startup.S +2
-0+ pushfw + sti...
Quoted 1 line
+ popfw
Quoted 8 lines
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.
Signature · 1 line
Bean