Re: sysctl machdep.fakepckbc=1
> Date: Thu, 9 Mar 2017 16:13:01 +0100 > From: Martin Pieuchot <m...@openbsd.org> > > On 09/03/17(Thu) 14:48, Mark Kettenis wrote: > > > Date: Thu, 9 Mar 2017 14:04:04 +0100 > > > From: Martin Pieuchot <m...@openbsd.org> > > > > > > Many of us have x86 machines with a USB keyboard that's unusable in > > > ddb(4). That's generally because the BIOS presents a fake pckbd(4) > > > to the OS: > > > > > > pckbc0 at isa0 port 0x60/5 irq 1 irq 12 > > > pckbd0 at pckbc0 (kbd slot) > > > wskbd0 at pckbd0: console keyboard, using wsdisplay0 > > > > > > Some BIOSes allow you to disable this emulation. While this might > > > allow you to have a working USB keyboard in ddb(4) it generally means > > > you lose input in the bootloader. > > > > > > So the diff below introduces a new sysctl(3) to work around this problem. > > > Adding the following line in your /etc/sysctl.conf will force your first > > > USB keyboard to re-attach itself after cold boot and become the default > > > console keyboard. That means you now have a working keyboard in ddb(4)! > > > > > > sysctl machdep.fakepckbc=1 > > > > > > I hope this will improve the content of bug reports. > > > > Can't you already achieve this by disabling pckbc(4) in the kernel > > config? So something like this: > > > > # config -ef /bsd > > ... > > ukc> disable pckbc > > 250 pckbc0 disabled > > ukc> quit > > This doesn't work. > > The reason is that pckbc_cnattach() doesn't care about the value of > ``cf_fstate''. We could fix that of course but I see two downside: > > First we want "boot bsd -c" and early ddb(4) to work. At least until > the *hci(4) driver did its handshake with the BIOS we want a pckbc > input console. Right. We want the SMM-based pckbc(4) emulation that the BIOS provides to continue to work until we whack the usb controller. > Second downside is this one: > > > Only downside is that it doesn't stick. If you install a new kernel > > you need to repeat the excercise. > > This is only good for development, not for users having an unexpected > panic. It's a pity that we need a knob for this, but it seems to be very hard, if not impossible, to check whether the emulation is there. So your diff makes sense. Apart from the bikeshed about the name (fakepckbdc seems a bit weird, usbconsole makes more sense to me), this is ok kettenis@
Re: sysctl machdep.fakepckbc=1
On 09/03/17(Thu) 14:48, Mark Kettenis wrote: > > Date: Thu, 9 Mar 2017 14:04:04 +0100 > > From: Martin Pieuchot <m...@openbsd.org> > > > > Many of us have x86 machines with a USB keyboard that's unusable in > > ddb(4). That's generally because the BIOS presents a fake pckbd(4) > > to the OS: > > > > pckbc0 at isa0 port 0x60/5 irq 1 irq 12 > > pckbd0 at pckbc0 (kbd slot) > > wskbd0 at pckbd0: console keyboard, using wsdisplay0 > > > > Some BIOSes allow you to disable this emulation. While this might > > allow you to have a working USB keyboard in ddb(4) it generally means > > you lose input in the bootloader. > > > > So the diff below introduces a new sysctl(3) to work around this problem. > > Adding the following line in your /etc/sysctl.conf will force your first > > USB keyboard to re-attach itself after cold boot and become the default > > console keyboard. That means you now have a working keyboard in ddb(4)! > > > > sysctl machdep.fakepckbc=1 > > > > I hope this will improve the content of bug reports. > > Can't you already achieve this by disabling pckbc(4) in the kernel > config? So something like this: > > # config -ef /bsd > ... > ukc> disable pckbc > 250 pckbc0 disabled > ukc> quit This doesn't work. The reason is that pckbc_cnattach() doesn't care about the value of ``cf_fstate''. We could fix that of course but I see two downside: First we want "boot bsd -c" and early ddb(4) to work. At least until the *hci(4) driver did its handshake with the BIOS we want a pckbc input console. Second downside is this one: > Only downside is that it doesn't stick. If you install a new kernel > you need to repeat the excercise. This is only good for development, not for users having an unexpected panic.
Re: sysctl machdep.fakepckbc=1
> Date: Thu, 9 Mar 2017 14:04:04 +0100 > From: Martin Pieuchot <m...@openbsd.org> > > Many of us have x86 machines with a USB keyboard that's unusable in > ddb(4). That's generally because the BIOS presents a fake pckbd(4) > to the OS: > > pckbc0 at isa0 port 0x60/5 irq 1 irq 12 > pckbd0 at pckbc0 (kbd slot) > wskbd0 at pckbd0: console keyboard, using wsdisplay0 > > Some BIOSes allow you to disable this emulation. While this might > allow you to have a working USB keyboard in ddb(4) it generally means > you lose input in the bootloader. > > So the diff below introduces a new sysctl(3) to work around this problem. > Adding the following line in your /etc/sysctl.conf will force your first > USB keyboard to re-attach itself after cold boot and become the default > console keyboard. That means you now have a working keyboard in ddb(4)! > > sysctl machdep.fakepckbc=1 > > I hope this will improve the content of bug reports. Can't you already achieve this by disabling pckbc(4) in the kernel config? So something like this: # config -ef /bsd ... ukc> disable pckbc 250 pckbc0 disabled ukc> quit Only downside is that it doesn't stick. If you install a new kernel you need to repeat the excercise.
sysctl machdep.fakepckbc=1
Many of us have x86 machines with a USB keyboard that's unusable in ddb(4). That's generally because the BIOS presents a fake pckbd(4) to the OS: pckbc0 at isa0 port 0x60/5 irq 1 irq 12 pckbd0 at pckbc0 (kbd slot) wskbd0 at pckbd0: console keyboard, using wsdisplay0 Some BIOSes allow you to disable this emulation. While this might allow you to have a working USB keyboard in ddb(4) it generally means you lose input in the bootloader. So the diff below introduces a new sysctl(3) to work around this problem. Adding the following line in your /etc/sysctl.conf will force your first USB keyboard to re-attach itself after cold boot and become the default console keyboard. That means you now have a working keyboard in ddb(4)! sysctl machdep.fakepckbc=1 I hope this will improve the content of bug reports. I'm happy to change the name if you don't like ``fakepckbc'' maybe ``usbconsole''? Note that USB keyboards attached to xhci(4) still don't work in ddb(4). Index: sbin/sysctl/sysctl.8 === RCS file: /cvs/src/sbin/sysctl/sysctl.8,v retrieving revision 1.209 diff -u -p -r1.209 sysctl.8 --- sbin/sysctl/sysctl.84 Mar 2017 17:40:23 - 1.209 +++ sbin/sysctl/sysctl.89 Mar 2017 12:52:32 - @@ -370,6 +370,9 @@ and a few require a kernel compiled with .It machdep.sse Ta integer Ta no .It machdep.sse2 Ta integer Ta no .It machdep.xcrypt Ta integer Ta no +.It machdep.lidsuspend Ta integer Ta yes +.It machdep.lidaction Ta integer Ta yes +.It machdep.fakepckbc Ta integer Ta yes .It machdep.allowaperture Ta integer Ta yes .It machdep.led_blink Ta integer Ta yes .It machdep.ceccerrs Ta integer Ta no Index: sys/arch/amd64/amd64/machdep.c === RCS file: /cvs/src/sys/arch/amd64/amd64/machdep.c,v retrieving revision 1.225 diff -u -p -r1.225 machdep.c --- sys/arch/amd64/amd64/machdep.c 7 Mar 2017 11:49:42 - 1.225 +++ sys/arch/amd64/amd64/machdep.c 9 Mar 2017 12:22:52 - @@ -146,6 +146,11 @@ extern int db_console; #include #endif /* HIBERNATE */ +#include "pckbc.h" +#if NPCKBC > 0 +#include +#endif + /* the following is used externally (sysctl_hw) */ char machine[] = MACHINE; @@ -189,6 +194,7 @@ paddr_t tramp_pdirpa; int kbd_reset; int lid_action = 1; +int fake_pckbc; /* * safepri is a safe priority for sleep to set for a spin-wait @@ -506,6 +512,16 @@ cpu_sysctl(int *name, u_int namelen, voi lid_action = val; } return (error); +#if NPCKBC > 0 + case CPU_FAKEPCKBC: + if (fake_pckbc) + return (sysctl_rdint(oldp, oldlenp, newp, fake_pckbc)); + + error = sysctl_int(oldp, oldlenp, newp, newlen, _pckbc); + if (fake_pckbc) + pckbc_release_console(); + return (error); +#endif default: return (EOPNOTSUPP); } Index: sys/arch/amd64/include/cpu.h === RCS file: /cvs/src/sys/arch/amd64/include/cpu.h,v retrieving revision 1.108 diff -u -p -r1.108 cpu.h --- sys/arch/amd64/include/cpu.h2 Mar 2017 10:38:10 - 1.108 +++ sys/arch/amd64/include/cpu.h9 Mar 2017 12:50:00 - @@ -426,7 +426,8 @@ void mp_setperf_init(void); #define CPU_XCRYPT 12 /* supports VIA xcrypt in userland */ #define CPU_LIDSUSPEND 13 /* lid close causes a suspend */ #define CPU_LIDACTION 14 /* action caused by lid close */ -#define CPU_MAXID 15 /* number of valid machdep ids */ +#define CPU_FAKEPCKBC 15 /* fake pckbc(4) conroller */ +#define CPU_MAXID 16 /* number of valid machdep ids */ #defineCTL_MACHDEP_NAMES { \ { 0, 0 }, \ @@ -444,6 +445,7 @@ void mp_setperf_init(void); { "xcrypt", CTLTYPE_INT }, \ { "lidsuspend", CTLTYPE_INT }, \ { "lidaction", CTLTYPE_INT }, \ + { "fakepckbc", CTLTYPE_INT }, \ } /* Index: sys/arch/i386/i386/machdep.c === RCS file: /cvs/src/sys/arch/i386/i386/machdep.c,v retrieving revision 1.597 diff -u -p -r1.597 machdep.c --- sys/arch/i386/i386/machdep.c7 Mar 2017 11:49:42 - 1.597 +++ sys/arch/i386/i386/machdep.c9 Mar 2017 12:23:32 - @@ -168,6 +168,11 @@ extern struct proc *npxproc; #include #endif /* HIBERNATE */ +#include "pckbc.h" +#if NPCKBC > 0 +#include +#endif + #include "vmm.h" void replacesmap(void); @@ -235,6 +240,7 @@ voidvia_update_sensor(void *args); #endif int kbd_reset; int lid_action = 1; +int fake_pckbc; /* * safepri is a safe priority for sleep to set for a spin-