Subject: kern/21898: usb keyboard does not attach as console kb and other problems
To: None <gnats-bugs@gnats.netbsd.org>
From: The Grey Wolf <greywolf@rivendell.starwolf.com>
List: netbsd-bugs
Date: 06/15/2003 23:58:04
>Number:         21898
>Category:       kern
>Synopsis:       usb keyboard as console misbehaves
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jun 16 06:59:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Greywolf
>Release:        NetBSD 1.6T 15-Jun-2003
>Organization:
Star Wolf Innovations

				--*greywolf;
--
NetBSD: safe ports in a storm.
>Environment:
System: NetBSD rivendell.starwolf.com 1.6T NetBSD 1.6T (RIVENDELL) #1: Sun Jun 15 22:43:29 PDT 2003 root@:/usr/src/sys/arch/i386/compile/RIVENDELL i386
Architecture: i386
Machine: i386
== config file included below [LONG]
include 	"arch/i386/conf/std.i386"

options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary


maxusers	128		# estimated number of users

# CPU support.  At least one is REQUIRED.
options 	I686_CPU

# CPU-related options.
options 	VM86		# virtual 8086 emulation
options 	USER_LDT	# user-settable LDT; used by WINE
# insert delay no-ops in interrupts; recommended on very old machines

options 	MTRR		# memory-type range register syscall support
# doesn't work with MP just yet..

# delay between "rebooting ..." message and hardware reset, in milliseconds
options 	CPURESET_DELAY=0

# This option allows you to force a serial console at the specified
# I/O address.   see console(4) for details.
#	you don't want the option below ON iff you are using the
#	serial console option of the new boot strap code.

# The following options override the memory sizes passed in from the boot
# block.  Use them *only* if the boot block is unable to determine the correct
# values.  Note that the BIOS may *correctly* report less than 640k of base
# memory if the extended BIOS data area is located at the top of base memory
# (as is the case on most recent systems).

# Standard system options

options 	INSECURE	# disable kernel security levels - X needs this

options 	RTC_OFFSET=480	# hardware clock is this many mins. west of GMT
options 	NTP		# NTP phase/frequency locked loop

options 	KTRACE		# system call tracing via ktrace(1)
options 	SYSTRACE	# system call vetting via systrace(1)

options 	SYSVMSG		# System V-like message queues
options 	SYSVSEM		# System V-like semaphores
options 	SEMMNI=32	# number of semaphore identifiers
options 	SEMMNS=96	# number of semaphores in system
options 	SEMUME=24	# max number of undo entries per process
options 	SEMMNU=96	# number of undo structures in system
options 	SYSVSHM		# System V-like memory sharing
options 	P1003_1B_SEMAPHORE	# p1003.1b semaphore support

options 	LKM		# loadable kernel modules

options 	USERCONF	# userconf(4) support

# Beep when it is safe to power down the system (requires sysbeep)
options 	BEEP_ONHALT
# Some tunable details of the above feature (default values used below)
options 	BEEP_ONHALT_COUNT=3	# Times to beep
options 	BEEP_ONHALT_PITCH=1500	# Default frequency (in Hz)
options 	BEEP_ONHALT_PERIOD=83	# Default duration (in msecs)

# Enable experimental buffer queue strategy for better responsiveness under 
# high disk I/O load. Use it with caution - it's not proven to be stable yet.

# Diagnostic/debugging support options
options 	DDB		# in-kernel debugger
options 	DDB_HISTORY_SIZE=512	# enable history editing in DDB

# Compatibility options
options 	COMPAT_15	# NetBSD 1.5

options 	COMPAT_OSSAUDIO	# OSS (Voxware) audio driver compatibility
options 	COMPAT_LINUX	# binary compatibility with Linux
options 	COMPAT_FREEBSD	# binary compatibility with FreeBSD
options 	COMPAT_PECOFF	# kernel support to run Win32 apps

# File systems
file-system 	FFS		# UFS
file-system 	MFS		# memory file system
file-system 	NFS		# Network File System client
file-system 	NTFS		# Windows/NT file system (experimental)
file-system 	CD9660		# ISO 9660 + Rock Ridge file system
file-system 	MSDOSFS		# MS-DOS file system
file-system 	FDESC		# /dev/fd
file-system 	KERNFS		# /kern
file-system 	NULLFS		# loopback file system
file-system 	OVERLAY		# overlay file system
file-system 	PROCFS		# /proc
file-system 	UNION		# union file system
file-system	SMBFS		# experimental - CIFS; also needs nsmb (below)

# File system options
options 	QUOTA		# UFS quotas
options 	SOFTDEP		# FFS soft updates support.
options 	NFSSERVER	# Network File System server
				# immutable) behave as system flags.

# Networking options
options 	INET		# IP + ICMP + TCP + UDP
options 	INET6		# IPV6
options 	PFIL_HOOKS	# pfil(9) packet filter hooks
options 	IPFILTER_LOG	# ipmon(8) log support

# These options enable verbose messages for several subsystems.
# Warning, these may compile large string tables into the kernel!
options 	EISAVERBOSE	# verbose EISA device autoconfig messages
options 	MIIVERBOSE	# verbose PHY autoconfig messages
options 	PCIVERBOSE	# verbose PCI device autoconfig messages
options 	SCSIVERBOSE	# human readable SCSI error messages
options 	USBVERBOSE	# verbose USB device autoconfig messages
options 	I2OVERBOSE	# verbose I2O driver messages
options 	MCAVERBOSE	# verbose MCA device autoconfig messages

options 	NFS_BOOT_DHCP,NFS_BOOT_BOOTPARAM

#
# wscons options
#
# builtin terminal emulations
options 	WSEMUL_VT100		# VT100 / VT220 emulation
# different kernel output - see dev/wscons/wsdisplayvar.h
options 	WS_KERNEL_FG=WSCOL_BLUE
options		WS_KERNEL_COLATTR=WSATTR_HILIT
# compatibility to other console drivers
options 	WSDISPLAY_COMPAT_PCVT		# emulate some ioctls
options 	WSDISPLAY_COMPAT_SYSCONS	# emulate some ioctls
options 	WSDISPLAY_COMPAT_USL		# VT handling
options 	WSDISPLAY_COMPAT_RAWKBD		# can get raw scancodes
# see dev/pckbc/wskbdmap_mfii.c for implemented layouts
options 	PCKBD_LAYOUT="(KB_US | KB_SWAPCTRLCAPS)"
# allocate a number of virtual screens at autoconfiguration time
# use a large software cursor that doesn't blink
# modify the screen type of the console; defaults to "80x25"
# work around a hardware bug that loaded fonts don't work; found on ATI cards
options 	VGA_CONSOLE_ATI_BROKEN_FONTSEL
# the following enables some functions to get mouse console support.
# if you want a really secure system, it may be better not to enable them,
# see wsmoused(8), section SECURITY CONSIDERATIONS for more info.
options 	WSDISPLAY_CHARFUNCS		# mouse console support
# enable VGA raster mode capable of displaying multilingual text on console

# Kernel root file system and dump configuration.
config		netbsd	root on ? type ?

#
# Device configuration
#

mainbus0 at root

cpu* at mainbus?

# Doesn't do anything yet.

apm0	at mainbus0			# Advanced power management

# Tuning for power management, see apm(4) for more details.


# Basic Bus Support

# Advanced Control and Power Interface

# This option can be used to retrieve CPU and APIC information.
# that I/O APICs can be used if ACPI is enabled below.
# To use the I/O APIC(s), enable the ioapic line above.
options 	MPACPI		# configure CPUs and APICs using ACPI
				# (acpi at mainbus must also be enabled)
options 	MPACPI_SCANPCI	# find PCI roots using MPACPI

acpi0 		at mainbus0

# ACPI devices
acpiacad* 	at acpi?		# ACPI AC Adapter
acpibut* 	at acpi?		# ACPI Button
acpiec* 	at acpi?		# ACPI Embedded Controller
acpitz* 	at acpi?		# ACPI Thermal Zone

# Mainboard devices

# Sony Vaio jog dial

# Toshiba Libretto devices

# Plug-and-Play BIOS and attached devices


# mainboard audio chips

# com port
# If enabled, consider changing "com0", "com1", and "com2" under "ISA Serial
# Interfaces" to "com*", otherwise com2 will attach at pnpbios? and there
# will be no com0.  A side effect is pcmcia (and other) com? previously
# starting at com3 may attach as com1 or com2.

# parallel port
# The above "com*" comments apply, cf. "lpt0" under "ISA parallel
# "printer interfaces".


# IDE controller on Toshiba Portege 3000 series (crippled PCI device)

# PCI bus support
pci*	at mainbus? bus ?
pci*	at pchb? bus ?
pci*	at ppb? bus ?

# Configure PCI using BIOS information
options 	PCIBIOS			# PCI BIOS support

# System Controllers

# PCI bridges
pchb*	at pci? dev ? function ?	# PCI-Host bridges
pcib*	at pci? dev ? function ?	# PCI-ISA bridges
ppb*	at pci? dev ? function ?	# PCI-PCI bridges
# XXX 'puc's aren't really bridges, but there's no better place for them here
puc*	at pci? dev ? function ?	# PCI "universal" comm. cards

agp* 	at pchb?


# ISA bus support
isa0	at mainbus?
isa0	at pcib?

# ISA Plug-and-Play bus support
isapnp0	at isa?

# Coprocessor Support

# Math Coprocessor support
npx0	at isa? port 0xf0 irq 13	# x86 math coprocessor


# Console Devices

# ISA console
# Keyboard layout configuration for pccons
# pccons-specific options:


# wscons
pckbc0		at isa?			# pc keyboard controller
pckbd*		at pckbc?		# PC keyboard
pms*		at pckbc?		# PS/2 mouse for wsmouse
vga0		at isa?
vga*		at pci? dev ? function ?
pcdisplay0	at isa?			# CGA, MDA, EGA, HGA
wsdisplay*	at vga? console ?
wsdisplay*	at pcdisplay? console ?
wskbd*		at pckbd? console ?
wsmouse*	at pms? mux 0

pcppi0		at isa?
sysbeep0	at pcppi?

# Serial Devices

# PCI serial interfaces

# ISA Plug-and-Play serial interfaces

# ISA serial interfaces
com0	at isa? port 0x3f8 irq 4	# Standard PC serial ports
com1	at isa? port 0x2f8 irq 3
com2	at isa? port 0x3e8 irq 5

# Parallel Printer Interfaces

# PCI parallel printer interfaces
lpt*	at puc? port ?			# || ports on "universal" comm boards

# ISA parallel printer interfaces
lpt0	at isa? port 0x378 irq 7	# standard PC parallel ports
lpt1	at isa? port 0x278
lpt2	at isa? port 0x3bc

# Hardware monitors

# LM7[89] and compatible hardware monitors

# VIA VT82C686A hardware monitor
viapm*	at pci? dev ? function ?
viaenv* at viapm?


# I2O devices


# SCSI Controllers and Devices

# PCI SCSI controllers
ahc*	at pci? dev ? function ?	# Adaptec [23]94x, aic78x0 SCSI

# SCSI bus support
scsibus* at scsi?
scsibus0 at scsi?
scsibus1 at scsi?

# SCSI devices
sd*	at scsibus? target ? lun ?	# SCSI disk drives
sd0	at scsibus0 target 0 lun 0
sd1	at scsibus0 target 1 lun 0
sd2	at scsibus0 target 2 lun 0
sd3	at scsibus0 target 3 lun 0
sd4	at scsibus0 target 4 lun 0
sd5	at scsibus0 target 5 lun 0
st0	at scsibus0 target 4 lun 0
st0	at scsibus0 target 5 lun 0
st*	at scsibus? target ? lun ?	# SCSI tape drives
cd0	at scsibus0 target 6 lun 0
cd*	at scsibus? target ? lun ?	# SCSI CD-ROM drives
ch*	at scsibus? target ? lun ?	# SCSI autochangers
ses*	at scsibus? target ? lun ?	# SCSI Enclosure Services devices
ss*	at scsibus? target ? lun ?	# SCSI scanners
uk*	at scsibus? target ? lun ?	# SCSI unknown


# RAID controllers and devices



# IDE and related devices
# PCI IDE controllers - see pciide(4) for supported hardware.
# The 0x0001 flag force the driver to use DMA, even if the driver doesn't know
# how to set up DMA modes for this chip. This may work, or may cause
# a machine hang with some controllers.
pciide0 at pci? dev ? function ? flags 0
pciide* at pci? dev ? function ? flags 0x0000

# ISA Plug-and-Play IDE controllers
wdc*	at isapnp?

# ISA ST506, ESDI, and IDE controllers
# Use flags 0x01 if you want to try to use 32bits data I/O (the driver will
# fall back to 16bits I/O if 32bits I/O are not functional).
# Some controllers pass the initial 32bit test, but will fail later.
wdc0	at isa? port 0x1f0 irq 14 flags 0x00
wdc1	at isa? port 0x170 irq 15 flags 0x00

# IDE drives
# Flags are used only with controllers that support DMA operations
# and mode settings (e.g. some pciide controllers)
# The lowest order four bits (rightmost digit) of the flags define the PIO
# mode to use, the next set of four bits the DMA mode and the third set the
# UltraDMA mode. For each set of four bits, the 3 lower bits define the mode
# to use, and the last bit must be 1 for this setting to be used.
# For DMA and UDMA, 0xf (1111) means 'disable'.
# 0x0fac means 'use PIO mode 4, DMA mode 2, disable UltraDMA'.
# (0xc=1100, 0xa=1010, 0xf=1111)
# 0x0000 means "use whatever the drive claims to support".
wd*	at wdc? channel ? drive ? flags 0x0000
wd0	at pciide0 channel 0 drive 0 flags 0
wd1	at pciide0 channel 0 drive 1 flags 0
wd2	at pciide0 channel 1 drive 0 flags 0
wd3	at pciide0 channel 1 drive 1 flags 0
wd*	at pciide? channel ? drive ? flags 0x0000

# ATA RAID configuration support, as found on some Promise controllers.

# ATAPI bus support
atapibus* at atapi?

# ATAPI devices
# flags have the same meaning as for IDE drives.
cd*	at atapibus? drive ? flags 0x0000	# ATAPI CD-ROM drives
sd*	at atapibus? drive ? flags 0x0000	# ATAPI disk drives
st*	at atapibus? drive ? flags 0x0000	# ATAPI tape drives
uk*	at atapibus? drive ? flags 0x0000	# ATAPI unknown


# Miscellaneous mass storage devices

# ISA floppy
fdc0	at isa? port 0x3f0 irq 6 drq 2	# standard PC floppy controllers
fd*	at fdc? drive ?			# the drives themselves
# some machines need you to do this instead of fd*

# ISA CD-ROM devices

# ISA tape devices
# note: the wt driver conflicts unpleasantly with SMC boards at the
# same I/O address. The probe reprograms their EEPROMs. Don't
# uncomment it unless you are actually using it.

# Network Interfaces

# PCI network interfaces
ex*	at pci? dev ? function ?	# 3Com 90x[BC]
fxp*	at pci? dev ? function ?	# Intel EtherExpress PRO 10+/100B

# MII/PHY support
exphy*	at mii? phy ?			# 3Com internal PHYs
inphy*	at mii? phy ?			# Intel 82555 PHYs
ukphy*	at mii? phy ?			# generic unknown PHYs


# USB Controller and Devices

# PCI USB controllers
# The EHCI is not ready for prime time.
uhci*	at pci?	dev ? function ?	# Universal Host Controller (Intel)

# USB bus support
usb*	at uhci?

# USB Hubs
uhub*	at usb?
uhub*	at uhub? port ? configuration ? interface ?

# USB HID device
uhidev*	at uhub? port ? configuration ? interface ?

# USB Mice
ums*	at uhidev? reportid ?
wsmouse0 at ums? mux 0

# USB Keyboards
ukbd*	at uhidev? reportid ?
wskbd0	at ukbd? console ? mux 1

# USB Generic HID devices
uhid*	at uhidev? reportid ?

# USB Printer
ulpt*	at uhub? port ? configuration ? interface ?

# USB Modem
umodem*	at uhub? port ? configuration ?
ucom*	at umodem?

# USB Mass Storage
umass*	at uhub? port ? configuration ? interface ?

# USB audio
uaudio*	at uhub? port ? configuration ?

# USB MIDI
umidi* at uhub? port ? configuration ?

# USB IrDA
# USB-IrDA bridge spec
uirda* at uhub? port ? configuration ? interface ?
irframe* at uirda?

# SigmaTel STIr4200 USB/IrDA Bridge
ustir* at uhub? port ?
irframe* at ustir?

# USB Ethernet adapters
aue*	at uhub? port ?		# ADMtek AN986 Pegasus based adapters
cue*	at uhub? port ?		# CATC USB-EL1201A based adapters
kue*	at uhub? port ?		# Kawasaki LSI KL5KUSB101B based adapters
uax*	at uhub? port ?		# ASIX AX88172 based adapters
url*	at uhub? port ?		# Realtek RTL8150L based adapters

# Prolific PL2301/PL2302 host-to-host adapter

# Serial adapters





# Diamond Multimedia Rio 500
urio*	at uhub? port ?

# USB Handspring Visor
uvisor*	at uhub? port ?
ucom*	at uvisor?

# USB scanners
uscanner* at uhub? port ?

# USB scanners that use SCSI emulation, e.g., HP5300
usscanner* at uhub? port ?

# Y@P firmware loader
uyap* at uhub? port ?

# D-Link DSB-R100 USB radio

# USB Generic driver
ugen*	at uhub? port ?


# IrDA and Consumer Ir devices

# Toshiba Oboe

# PCI IEEE1394 controllers

# IEEE1394 nodes

# Audio Devices

# PCI audio devices
cmpci*	at pci? dev ? function ?	# C-Media CMI8338/8738
sv*	at pci? dev ? function ?	# S3 SonicVibes

# ISA Plug-and-Play audio devices

# ISA audio devices
# the "aria" probe might give false hits

# OPL[23] FM synthesizers
opl*	at cmpci? flags 1
opl*	at sv?

# Audio support
audio*	at audiobus?

# MPU 401 UARTs
mpu*	at cmpci?

# MIDI support
midi*	at midibus?
midi*	at pcppi?		# MIDI interface to the PC speaker

# The spkr driver provides a simple tone interface to the built in speaker.
spkr0	at pcppi?		# PC speaker


# FM-Radio devices
# ISA radio devices

# PCI radio devices

# Radio support


# TV cards

# Brooktree 848/849/878/879 based TV cards
bktr* at pci? dev ? function ?
radio* at bktr?


# Mice

# ISA busmice


# Joysticks


# ISA Plug-and-Play joysticks
joy*	at isapnp?			# Game ports (usually on audio cards)

# PCI joysticks
joy*	at pci?				# Game ports (usually on audio cards)

# ISA joysticks. Probe is a little strange; add only if you have one.


# Miscellaneous Devices

# Planetconnect Satellite receiver driver.

# Middle Digital, Inc. PCI-Weasel serial console board control
# devices (watchdog timer, etc.)

# Pull in optional local configuration
include	"arch/i386/conf/GENERIC.local"


# Pseudo-Devices

# disk/mass storage pseudo-devices
pseudo-device	ccd		4	# concatenated/striped disk devices
pseudo-device	raid		8	# RAIDframe disk driver
options 	RAID_AUTOCONFIG		# auto-configuration of RAID components
# Options to enable various other RAIDframe RAID types.

pseudo-device	md		1	# memory disk device (ramdisk)
pseudo-device	vnd		4	# disk-like interface to files

# network pseudo-devices
pseudo-device	bpfilter	8	# Berkeley packet filter
pseudo-device	ipfilter		# IP filter (firewall) and NAT
pseudo-device	loop			# network loopback
pseudo-device	tun		2	# network tunneling over tty
pseudo-device	gre		2	# generic L3 over IP tunnel
pseudo-device	gif		4	# IPv[46] over IPv[46] tunnel (RFC1933)
pseudo-device	vlan			# IEEE 802.1q encapsulation

# miscellaneous pseudo-devices
pseudo-device	pty			# pseudo-terminals
pseudo-device	tb		1	# tablet line discipline
pseudo-device	sequencer	1	# MIDI sequencer
# rnd works; RND_COM does not on port i386 yet.
pseudo-device	rnd			# /dev/random and in-kernel generator
pseudo-device	clockctl		# user control of clock subsystem

# a pseudo device needed for Coda	# also needs CODA (above)

# a pseudo device needed for SMBFS
pseudo-device	nsmb			# experimental - SMB requester

# wscons pseudo-devices
pseudo-device	wsmux			# mouse & keyboard multiplexor
pseudo-device	wsfont
pseudo-device	ksyms			# /dev/ksyms


options		MULTIPROCESSOR
options 	COM_MPLOCK	# com MP locking; REQUIRED on MP i386

options 	APM_NO_IDLE
options 	MPBIOS		# configure CPUs and APICs using MPBIOS
				# (acpi at mainbus must also be enabled)

ioapic*		at mainbus? apid ?
==
>Description:
	usb kb has several problems:
	1.  Kernel keyboard mappings do NOT extend to any keyboards besides
	    the (PS/2) console; nor to they extend to the USB keyboard when it
	    is the console keyboard.
	2.  Once the keys are remapped, i.e. swapctrlcaps, <control-alt-Fn>
	    and <control-alt-ESC> no longer work, even if the USB keyboard
	    is explicitly to be the console keyboard, i.e. wskbd0.
        3.  Once in X, <control-alt-Fn> doesn't work; I see (in dmesg):
	    usl_detachtimeout
	    usl_detachack: not detaching
	And I cannot connect to any other consoles unless I kill X
	completely.
>How-To-Repeat:
	Run machine with no PS2 kb/mouse attached, but with USB kb/mouse.
	compile kernel with, explicitly defined:
		wskbd0 at ukbd? console ? mux 1
	reboot
	observe	
>Fix:
	Not a clue, sorry.
>Release-Note:
>Audit-Trail:
>Unformatted: