|
|
1.1 root 1: \ ***************************************************************************** 1.1.1.2 ! root 2: \ * Copyright (c) 2004, 2011 IBM Corporation 1.1 root 3: \ * All rights reserved. 4: \ * This program and the accompanying materials 5: \ * are made available under the terms of the BSD License 6: \ * which accompanies this distribution, and is available at 7: \ * http://www.opensource.org/licenses/bsd-license.php 8: \ * 9: \ * Contributors: 10: \ * IBM Corporation - initial implementation 11: \ ****************************************************************************/ 12: 13: 14: \ Set usb-debug flag to TRUE for debugging output: 15: 0 VALUE usb-debug-flag 16: false VALUE scan-time? 17: 18: VARIABLE ihandle-bulk-tran 19: 20: 21: \ Print a debug message when usb-debug-flag is set 22: : usb-debug-print ( str len -- ) 23: usb-debug-flag IF type cr ELSE 2drop THEN 24: ; 25: 26: \ Print a debug message with corresponding value when usb-debug-flag is set 27: : usb-debug-print-val ( str len val -- ) 28: usb-debug-flag IF -ROT type . cr ELSE drop 2drop THEN 29: ; 30: 31: \ show proceeding propeller only during scan process. 32: \ As soon USB-keyboard can be used, this must be suppressed. 33: 0 VALUE proceed-char 34: : show-proceed ( -- ) 35: scan-time? \ are we on usb-scan ? 36: IF 37: proceed-char 38: CASE 39: 0 OF 2d ENDOF \ show '-' 40: 1 OF 5c ENDOF \ show '\' 41: 2 OF 7c ENDOF \ show '|' 42: dup OF 2f ENDOF \ show '/' 43: ENDCASE 44: emit 8 emit 45: proceed-char 1 + 3 AND to proceed-char 46: THEN 47: ; 48: 49: \ delay with proceeding signs 50: : wait-proceed ( nl -- ) 51: show-proceed 52: BEGIN 53: dup d# 100 > ( nl true|false ) 54: WHILE 55: 100 - show-proceed 56: 100 ms \ do it in steps of 100ms 57: REPEAT 58: ms \ rest delay 59: ; 60: 61: \ register device alias 62: : do-alias-setting ( num name-str name-len ) 63: rot $cathex strdup \ create alias name 64: get-node node>path \ get path string 65: set-alias \ and set the alias 66: ; 67: 68: 69: 0 VALUE ohci-alias-num 70: 71: \ create a new ohci device alias for the current node: 72: : set-ohci-alias ( -- ) 73: ohci-alias-num dup 1+ TO ohci-alias-num ( num ) 74: s" ohci" 75: do-alias-setting 76: ; 77: 78: 0 VALUE cdrom-alias-num 79: 0 VALUE disk-alias-num \ shall start with: pci-disk-num 80: FALSE VALUE ext-disk-alias \ first external disk: not yet assigned 81: 82: \ create a new ohci device alias for the current node: 83: : set-drive-alias ( -- ) 84: space 5b emit 85: s" cdrom" drop ( name-str ) 86: get-node node>name comp 0= ( true|false ) 87: IF \ is this a cdrom ? 88: cdrom-alias-num dup 1+ TO cdrom-alias-num ( num ) 89: s" cdrom" \ yes, alias = cdrom 90: ELSE 91: s" sbc-dev" drop \ is this a scsi-block-device? 92: get-node node>name comp 0= ( true|false ) 93: IF 94: disk-alias-num dup 1 + to disk-alias-num 95: s" disk" \ all block devices will be named "disk" 96: 1.1.1.2 ! root 97: ext-disk-alias not \ flag for first ext. disk already assigned ! 98: IF ! 99: TRUE to ext-disk-alias ! 100: 2 s" hdd" \ add extra alias hdd2 for first USB disk 1.1 root 101: 2dup type 2 pick . 102: 8 emit 2f emit 103: do-alias-setting 104: THEN 105: ELSE 106: 0 s" ??? " \ unknown device 107: THEN 108: THEN ( num name-str name-len ) 109: 2dup type 2 pick . 110: 8 emit 5d emit cr 111: do-alias-setting 112: ; 113: 114: : usb-create-alias-name ( num -- str len ) 115: >r s" ohciX" 2dup + 1- ( str len last-char-ptr R: num ) 116: r> [char] 0 + swap c! ( str len R: ) 117: ; 118: 1.1.1.2 ! root 119: : ohci-scan-node ( str len -- ) ! 120: 2dup find-node ?dup IF ! 121: ( str len phandle ) ! 122: dup set-node ! 123: dup child ?dup IF ! 124: delete-node s" Deleting node" usb-debug-print ! 125: THEN ! 126: \ Check whether usb-ohci.fs has already been included: ! 127: s" enumerate" rot find-method IF ! 128: drop ! 129: \ Create instance for enumeration: ! 130: open-dev dup to my-self ! 131: s" enumerate" 2 pick $call-method \ Scan host controller ! 132: close-dev 0 to my-self ! 133: 0 set-node ! 134: ELSE ! 135: 2drop get-node ! 136: dup parent node>path select-dev \ Open parent ! 137: extend-device ! 138: s" usb-ohci.fs" included ! 139: s" open" $call-my-method 0= ABORT" OHCI open failed" ! 140: s" enumerate" $call-my-method ! 141: s" close" $call-my-method ! 142: finish-device ! 143: unselect-dev ! 144: THEN ( str len R: num ) ! 145: ELSE ! 146: 2drop 1.1 root 147: THEN 148: ; 149: 1.1.1.2 ! root 150: \ Scan all USB OHCI host controllers for attached devices: ! 151: : ohci-scan 1.1 root 152: \ Scan all OHCI chips: 153: space ." Scan USB... " cr 154: true to scan-time? \ show proceeding signs 155: 0 to disk-alias-num \ start with disk0 156: s" pci-disk-num" $find \ previously detected disks ? 157: IF 158: execute to disk-alias-num \ overwrite start number 159: ELSE 160: 2drop 161: THEN 162: 163: 0 >r \ Counter for alias 164: BEGIN 165: r@ usb-create-alias-name 166: find-alias ?dup ( false | str len len R: num ) 167: WHILE 1.1.1.2 ! root 168: ( str len R: num ) 1.1 root 169: usb-debug-flag IF 170: ." * Scanning hub " 2dup type ." ..." cr 171: THEN 1.1.1.2 ! root 172: ohci-scan-node ( R: num ) 1.1 root 173: r> 1+ >r ( R: num+1 ) 1.1.1.2 ! root 174: REPEAT ! 175: r> drop 1.1 root 176: 0 TO ohci-alias-num 177: 0 TO cdrom-alias-num 178: s" cdrom0" find-alias ( false | dev-path len ) 179: dup IF 180: s" cdrom" 2swap ( alias-name len' dev-path len ) 181: set-alias ( -- ) 182: \ cdrom-alias-num 1 + TO cdrom-alias-num 183: ELSE 184: drop ( -- ) 185: THEN 1.1.1.2 ! root 186: 1.1 root 187: false to scan-time? \ suppress proceeding signs 188: ; 189: 1.1.1.2 ! root 190: : usb-scan ! 191: s" ohci0" find-alias IF ! 192: drop ! 193: ohci-scan 1.1 root 194: THEN 195: ;
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.