[openfirmware] [commit] r2208 - in dev/usb2: device device/generic device/keyboard device/net device/serial device/storage device/userial hcd hcd/ehci hcd/ohci hcd/uhci
repository service
svn at openfirmware.info
Fri May 20 06:00:12 CEST 2011
Author: wmb
Date: Fri May 20 06:00:11 2011
New Revision: 2208
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2208
Log:
OLPC trac #10819 - When a USB device has been disconnected, disable its device node by setting the assigned-address property to -1, so that subsequent open attempts fail. If the device is later reconnected, the old node can be reused by assigning a new target number to assigned-address, as before.
Modified:
dev/usb2/device/common.fth
dev/usb2/device/generic/generic.fth
dev/usb2/device/keyboard/kbd.fth
dev/usb2/device/net/ethernet.fth
dev/usb2/device/serial/uart.fth
dev/usb2/device/storage/scsi.fth
dev/usb2/device/userial/userial.fth
dev/usb2/hcd/device.fth
dev/usb2/hcd/ehci/probe.fth
dev/usb2/hcd/ohci/probe.fth
dev/usb2/hcd/probehub.fth
dev/usb2/hcd/uhci/probe.fth
Modified: dev/usb2/device/common.fth
==============================================================================
--- dev/usb2/device/common.fth Fri May 20 01:22:54 2011 (r2207)
+++ dev/usb2/device/common.fth Fri May 20 06:00:11 2011 (r2208)
@@ -38,6 +38,7 @@
\ This needs to be called every time that the device could have changed
: set-device ( -- ) " assigned-address" get-int-property to device ;
+: set-device? ( -- error? ) set-device device -1 = ;
: init ( -- )
set-device
Modified: dev/usb2/device/generic/generic.fth
==============================================================================
--- dev/usb2/device/generic/generic.fth Fri May 20 01:22:54 2011 (r2207)
+++ dev/usb2/device/generic/generic.fth Fri May 20 06:00:11 2011 (r2208)
@@ -1,7 +1,7 @@
purpose: Generic USB device stub driver, useful for client programs
external
-: open ( -- flag ) device set-target true ;
+: open ( -- flag ) set-device? if false exit then device set-target true ;
: close ( -- ) ;
: init ( -- ) init device set-target ;
Modified: dev/usb2/device/keyboard/kbd.fth
==============================================================================
--- dev/usb2/device/keyboard/kbd.fth Fri May 20 01:22:54 2011 (r2207)
+++ dev/usb2/device/keyboard/kbd.fth Fri May 20 06:00:11 2011 (r2208)
@@ -327,7 +327,7 @@
\ kbd-buf and led-buf must have been allocated
: setup-hardware? ( -- error? )
- set-device
+ set-device? if true exit then
device set-target
reset? if
configuration set-config if
Modified: dev/usb2/device/net/ethernet.fth
==============================================================================
--- dev/usb2/device/net/ethernet.fth Fri May 20 01:22:54 2011 (r2207)
+++ dev/usb2/device/net/ethernet.fth Fri May 20 06:00:11 2011 (r2208)
@@ -217,7 +217,7 @@
: open ( -- ok? )
parse-args
- set-device
+ set-device? if false exit then
device set-target
opencount @ 0= if
Modified: dev/usb2/device/serial/uart.fth
==============================================================================
--- dev/usb2/device/serial/uart.fth Fri May 20 01:22:54 2011 (r2207)
+++ dev/usb2/device/serial/uart.fth Fri May 20 06:00:11 2011 (r2208)
@@ -52,7 +52,7 @@
: write ( adr len -- actual ) dup if write-bytes else nip then ;
: open ( -- flag )
- set-device
+ set-device? if false exit then
device set-target
refcount @ 0= if
Modified: dev/usb2/device/storage/scsi.fth
==============================================================================
--- dev/usb2/device/storage/scsi.fth Fri May 20 01:22:54 2011 (r2207)
+++ dev/usb2/device/storage/scsi.fth Fri May 20 06:00:11 2011 (r2208)
@@ -181,8 +181,6 @@
: set-address ( lun -- )
0 max max-lun min to lun
- set-device \ The device number may have changed if we recycled the node
- device set-target
reset? if
configuration set-config if
." USB storage scsi layer: Failed to set configuration" cr
@@ -192,7 +190,11 @@
;
: set-timeout ( n -- ) bulk-timeout max set-bulk-in-timeout ;
-: reopen-hardware ( -- ok? ) true ;
+: reopen-hardware ( -- ok? )
+ set-device? if false exit then \ The device number may have changed if we recycled the node
+ device set-target
+ true
+;
: open-hardware ( -- ok? ) alloc-bulk reopen-hardware ;
: reclose-hardware ( -- ) ;
: close-hardware ( -- ) free-bulk ;
Modified: dev/usb2/device/userial/userial.fth
==============================================================================
--- dev/usb2/device/userial/userial.fth Fri May 20 01:22:54 2011 (r2207)
+++ dev/usb2/device/userial/userial.fth Fri May 20 06:00:11 2011 (r2208)
@@ -17,7 +17,7 @@
;
: open ( -- flag )
- set-device
+ set-device? if false exit then
device set-target
reset? if
configuration set-config if
Modified: dev/usb2/hcd/device.fth
==============================================================================
--- dev/usb2/hcd/device.fth Fri May 20 01:22:54 2011 (r2207)
+++ dev/usb2/hcd/device.fth Fri May 20 06:00:11 2011 (r2208)
@@ -331,6 +331,23 @@
3drop false
;
+: disable-old-nodes ( port -- )
+ my-self ihandle>phandle child ( port phandle )
+ begin ?dup while ( port phandle )
+ " reg" 2 pick get-package-property 0= if ( port phandle adr len )
+ decode-int nip nip ( port phandle port1 )
+ 2 pick = if ( port phandle )
+ " assigned-address" ( port phandle propname$ )
+ 2 pick get-package-property 0= if ( port phandle adr len )
+ drop -1 swap be-l! ( port phandle )
+ then ( port phandle )
+ then ( port phandle )
+ then ( port phandle )
+ peer ( port phandle' )
+ repeat ( port )
+ drop ( )
+;
+
: (make-device-node) ( dev port intf -- )
swap ( dev intf port )
3dup reuse-old-node? if ( dev intf port )
Modified: dev/usb2/hcd/ehci/probe.fth
==============================================================================
--- dev/usb2/hcd/ehci/probe.fth Fri May 20 01:22:54 2011 (r2207)
+++ dev/usb2/hcd/ehci/probe.fth Fri May 20 06:00:11 2011 (r2208)
@@ -22,8 +22,11 @@
0 instance value probe-error? \ Back channel to selftest
: probe-root-hub-port ( port -- )
- false to probe-error?
- dup portsc@ 1 and 0= if drop exit then \ No device detected
+ false to probe-error? ( port )
+ dup portsc@ 1 and 0= if ( port ) \ No device detected
+ disable-old-nodes ( )
+ exit ( -- )
+ then ( port )
dup portsc@ h# c00 and h# 400 = if \ A low speed device detected
dup disown-port \ Disown the port
else \ Don't know what it is
Modified: dev/usb2/hcd/ohci/probe.fth
==============================================================================
--- dev/usb2/hcd/ohci/probe.fth Fri May 20 01:22:54 2011 (r2207)
+++ dev/usb2/hcd/ohci/probe.fth Fri May 20 06:00:11 2011 (r2208)
@@ -5,17 +5,20 @@
headers
: probe-root-hub-port ( port -- )
- dup hc-rh-psta@ 1 and 0= if drop exit then ( port ) \ No device connected
+ dup hc-rh-psta@ 1 and 0= if ( port )
+ disable-old-nodes ( )
+ exit ( -- )
+ then ( port )
\ Reset the port to determine the speed
- dup reset-port ( port )
+ dup reset-port ( port )
dup hc-rh-psta@ 200 and if speed-low else speed-full then ( port speed )
\ hub-port and hub-speed are irrelevant for OHCI (USB 1.1)
- 0 0 ( port speed hub-port hub-dev )
+ 0 0 ( port speed hub-port hub-dev )
\ Execute setup-new-node in root context and make-device-node in hub node context
- setup-new-node if execute then ( port dev xt )
+ setup-new-node if execute then ( port dev xt )
;
false value ports-powered?
Modified: dev/usb2/hcd/probehub.fth
==============================================================================
--- dev/usb2/hcd/probehub.fth Fri May 20 01:22:54 2011 (r2207)
+++ dev/usb2/hcd/probehub.fth Fri May 20 06:00:11 2011 (r2208)
@@ -68,7 +68,10 @@
over clear-status-change ( port error? )
if drop exit then ( port )
- hub-buf c@ 1 and 0= if drop exit then \ No device connected
+ hub-buf c@ 1 and 0= if ( port ) \ No device connected
+ disable-old-nodes ( port )
+ exit
+ then
hub-buf le-w@ h# 600 and 9 >> ( port speed )
\ hub-port and hub-dev route USB 1.1 transactions through USB 2.0 hubs
@@ -141,7 +144,8 @@
dup i port-status-changed? if ( hub-dev connected? )
if ( hub-dev )
dup i safe-probe-hub-port ( hub-dev )
- \ else Handle disconnect
+ else \ Handle disconnect
+ i disable-old-nodes ( hub-dev )
then ( hub-dev )
else ( hub-dev )
i port-is-hub? if ( hub-dev phandle )
Modified: dev/usb2/hcd/uhci/probe.fth
==============================================================================
--- dev/usb2/hcd/uhci/probe.fth Fri May 20 01:22:54 2011 (r2207)
+++ dev/usb2/hcd/uhci/probe.fth Fri May 20 06:00:11 2011 (r2208)
@@ -7,7 +7,10 @@
: probe-root-hub-port ( port -- )
\ Reset the port to perform connection status and speed detection
dup reset-port ( port )
- dup portsc@ 1 and 0= if drop exit then ( port ) \ No device-connected
+ dup portsc@ 1 and 0= if ( port ) \ No device-connected
+ disable-old-nodes ( )
+ exit ( -- )
+ then ( port )
dup portsc@ 100 and if speed-low else speed-full then ( port speed )
More information about the openfirmware
mailing list