|
|
1.1 ! root 1: \ ***************************************************************************** ! 2: \ * Copyright (c) 2004, 2008 IBM Corporation ! 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: \ #include "scsi-support.fs" ! 14: ! 15: \ Set usb-debug flag to TRUE for debugging output: ! 16: 0 VALUE usb-debug-flag ! 17: false VALUE scan-time? ! 18: ! 19: VARIABLE ihandle-bulk-tran ! 20: \ -scsi-supp- VARIABLE ihandle-scsi-tran ! 21: ! 22: \ uDOC (Micro-Disk-On-Chip) is a FLASH-device ! 23: \ normally connected to usb-port 5 on ELBA ! 24: \ ! 25: 0 VALUE uDOC-present \ device present and working? ! 26: ! 27: \ Print a debug message when usb-debug-flag is set ! 28: : usb-debug-print ( str len -- ) ! 29: usb-debug-flag IF type cr ELSE 2drop THEN ! 30: ; ! 31: ! 32: \ Print a debug message with corresponding value when usb-debug-flag is set ! 33: : usb-debug-print-val ( str len val -- ) ! 34: usb-debug-flag IF -ROT type . cr ELSE drop 2drop THEN ! 35: ; ! 36: ! 37: \ show proceeding propeller only during scan process. ! 38: \ As soon USB-keyboard can be used, this must be suppressed. ! 39: 0 VALUE proceed-char ! 40: : show-proceed ( -- ) ! 41: scan-time? \ are we on usb-scan ? ! 42: IF ! 43: proceed-char ! 44: CASE ! 45: 0 OF 2d ENDOF \ show '-' ! 46: 1 OF 5c ENDOF \ show '\' ! 47: 2 OF 7c ENDOF \ show '|' ! 48: dup OF 2f ENDOF \ show '/' ! 49: ENDCASE ! 50: emit 8 emit ! 51: proceed-char 1 + 3 AND to proceed-char ! 52: THEN ! 53: ; ! 54: ! 55: \ delay with proceeding signs ! 56: : wait-proceed ( nl -- ) ! 57: show-proceed ! 58: BEGIN ! 59: dup d# 100 > ( nl true|false ) ! 60: WHILE ! 61: 100 - show-proceed ! 62: 100 ms \ do it in steps of 100ms ! 63: REPEAT ! 64: ms \ rest delay ! 65: ; ! 66: ! 67: \ register device alias ! 68: : do-alias-setting ( num name-str name-len ) ! 69: rot $cathex strdup \ create alias name ! 70: get-node node>path \ get path string ! 71: set-alias \ and set the alias ! 72: ; ! 73: ! 74: ! 75: 0 VALUE ohci-alias-num ! 76: ! 77: \ create a new ohci device alias for the current node: ! 78: : set-ohci-alias ( -- ) ! 79: ohci-alias-num dup 1+ TO ohci-alias-num ( num ) ! 80: s" ohci" ! 81: do-alias-setting ! 82: ; ! 83: ! 84: 0 VALUE cdrom-alias-num ! 85: 0 VALUE disk-alias-num \ shall start with: pci-disk-num ! 86: FALSE VALUE ext-disk-alias \ first external disk: not yet assigned ! 87: ! 88: \ create a new ohci device alias for the current node: ! 89: : set-drive-alias ( -- ) ! 90: space 5b emit ! 91: s" cdrom" drop ( name-str ) ! 92: get-node node>name comp 0= ( true|false ) ! 93: IF \ is this a cdrom ? ! 94: cdrom-alias-num dup 1+ TO cdrom-alias-num ( num ) ! 95: s" cdrom" \ yes, alias = cdrom ! 96: ELSE ! 97: s" sbc-dev" drop \ is this a scsi-block-device? ! 98: get-node node>name comp 0= ( true|false ) ! 99: IF ! 100: disk-alias-num dup 1 + to disk-alias-num ! 101: s" disk" \ all block devices will be named "disk" ! 102: ! 103: \ this is a block-device. ! 104: \ check if parent is 'usb' and not 'hub' ! 105: \ if so this block-device is directly connected ! 106: \ to root-hub and must be the uDOC-device in Elba ! 107: s" usb" drop \ parent = usb controller ? (not hub) ! 108: get-node node>parent @ node>name ! 109: comp 0= \ parent node starts with 'usb' ? ! 110: IF ( true|false ) ! 111: 1 s" hdd" \ add extra alias hdd1 for IntFlash ! 112: 2dup type 2 pick . ! 113: 8 emit 2f emit ! 114: do-alias-setting ! 115: uDOC-present 1 and ! 116: IF ! 117: uDOC-present 2 or to uDOC-present \ present and ready ! 118: THEN ! 119: ELSE ! 120: ext-disk-alias not \ flag for first ext. disk already assigned ! 121: IF ! 122: TRUE to ext-disk-alias ! 123: 2 s" hdd" \ add extra alias hdd2 for first USB disk ! 124: 2dup type 2 pick . ! 125: 8 emit 2f emit ! 126: do-alias-setting ! 127: THEN ! 128: THEN ! 129: ELSE ! 130: 0 s" ??? " \ unknown device ! 131: THEN ! 132: THEN ( num name-str name-len ) ! 133: 2dup type 2 pick . ! 134: 8 emit 5d emit cr ! 135: do-alias-setting ! 136: ; ! 137: ! 138: : usb-create-alias-name ( num -- str len ) ! 139: >r s" ohciX" 2dup + 1- ( str len last-char-ptr R: num ) ! 140: r> [char] 0 + swap c! ( str len R: ) ! 141: ; ! 142: ! 143: ! 144: \ ***************************************************** ! 145: \ This is a final check to see, if a uDOC-device ! 146: \ is ready for booting ! 147: \ If physically present, but not working, an ! 148: \ Error-LED must be activated (on ELBA only!) ! 149: \ ***************************************************** ! 150: \ uDOC is now replaced by ModFD (Modular-Flash-Drive) ! 151: \ due to right properties ! 152: \ 'sys-signal-modfd-fault' sends an IPMI-Message to ! 153: \ aMM for generating a log entry and to switch on ! 154: \ an error LED (call to libsystem->libipmi) ! 155: \ ***************************************************** ! 156: \ although there are IPMI-warnings defined concerning ! 157: \ detected media errors, it doesn't make sense to send ! 158: \ a warning when booting from this device is impossible. ! 159: \ The decision was made to send an error call in this ! 160: \ case as well ! 161: \ ***************************************************** ! 162: \ uDOC-present bits: ! 163: \ ***************************************************** ! 164: \ D0: any device is connected on port 3 of root-hub ! 165: \ D1: device on port 3 is directly connected (no hub) ! 166: \ D2: warnings were received (scancodes) ! 167: \ D3: OverCurrentIndicator on USB-Port was set ! 168: \ D7: flag, set while ModFD is beeing processed ! 169: ! 170: : uDOC-check ( -- ) ! 171: #ifdef ELBA ! 172: uDOC-present 7 and \ flags concerning ModFD device ! 173: CASE ! 174: 0 OF \ not present not detected ! 175: uDOC-present 8 and 0<> \ not detected due to OverCurrent? ! 176: IF ! 177: 0d emit ." * OverCurrent on ModFD *" cr ! 178: sys-signal-modfd-fault ( -- ) \ send IPMI-call to BMC ! 179: ELSE ! 180: 0d emit ." ModFD not present" cr ! 181: THEN ! 182: ENDOF ! 183: ! 184: 1 OF \ present but not detected by USB ! 185: 0d emit ." * ModFD not accessible *" cr ! 186: sys-signal-modfd-fault ( -- ) \ send IPMI-call to BMC ! 187: ENDOF ! 188: ! 189: 3 OF \ present and detected ! 190: \ 0d emit ." ModFD OK" cr ! 191: ENDOF ! 192: ! 193: 7 OF \ present and detected but with warnings ! 194: 0d emit ." * ModFD Warnings *" cr ! 195: sys-signal-modfd-fault ( -- ) \ send IPMI-call to BMC ! 196: ENDOF ! 197: ! 198: dup OF \ we have a fault in our firmware ! ! 199: s" *** ModFD detection error ***" usb-debug-print ! 200: ENDOF ! 201: ENDCASE ! 202: #endif ! 203: ; ! 204: ! 205: \ ***************************************************** ! 206: \ check if actual processed device is ModFD and ! 207: \ then sets its warning bit ! 208: \ ***************************************************** ! 209: : uDOC-failure? ( -- ) ! 210: uDOC-present 80 and 0<> \ is ModFD actual beeing processed? ! 211: IF ! 212: uDOC-present 04 or to uDOC-present \ set Warning flag ! 213: THEN ! 214: ; ! 215: ! 216: \ Scan all USB host controllers for attached devices: ! 217: : usb-scan ! 218: \ Scan all OHCI chips: ! 219: space ." Scan USB... " cr ! 220: true to scan-time? \ show proceeding signs ! 221: 0 to uDOC-present \ mark as not present ! 222: 0 to disk-alias-num \ start with disk0 ! 223: s" pci-disk-num" $find \ previously detected disks ? ! 224: IF ! 225: execute to disk-alias-num \ overwrite start number ! 226: ELSE ! 227: 2drop ! 228: THEN ! 229: ! 230: 0 >r \ Counter for alias ! 231: BEGIN ! 232: r@ usb-create-alias-name ! 233: find-alias ?dup ( false | str len len R: num ) ! 234: WHILE ! 235: usb-debug-flag IF ! 236: ." * Scanning hub " 2dup type ." ..." cr ! 237: THEN ! 238: open-dev ?dup IF ( ihandle R: num ) ! 239: dup to my-self ! 240: dup ihandle>phandle dup set-node ! 241: child ?dup IF ! 242: delete-node s" Deleting node" usb-debug-print ! 243: THEN ! 244: >r s" enumerate" r@ $call-method \ Scan host controller ! 245: r> close-dev 0 set-node 0 to my-self ! 246: THEN ( R: num ) ! 247: r> 1+ >r ( R: num+1 ) ! 248: REPEAT r> drop ! 249: 0 TO ohci-alias-num ! 250: 0 TO cdrom-alias-num ! 251: s" cdrom0" find-alias ( false | dev-path len ) ! 252: dup IF ! 253: s" cdrom" 2swap ( alias-name len' dev-path len ) ! 254: set-alias ( -- ) ! 255: \ cdrom-alias-num 1 + TO cdrom-alias-num ! 256: ELSE ! 257: drop ( -- ) ! 258: THEN ! 259: uDOC-check \ check if uDOC-device is present and working (ELBA only) ! 260: false to scan-time? \ suppress proceeding signs ! 261: ; ! 262: ! 263: : usb-probe ! 264: ! 265: usb-scan ! 266: ! 267: cdrom-alias-num 0= IF ! 268: ." Not found CDROM! " cr ! 269: THEN ! 270: ." CDROM found " cdrom-alias-num . cr ! 271: ; ! 272: ! 273: ! 274: : usb-dev-test ( -- TRUE ) ! 275: s" USB Device Test " usb-debug-print ! 276: 1 usb-create-alias-name ! 277: find-alias ?dup IF ! 278: ." * open " 2dup type . cr ! 279: ELSE ! 280: s" can't found alias " usb-debug-print ! 281: THEN ! 282: open-dev ?dup IF ! 283: dup to my-self ! 284: dup ihandle>phandle dup set-node ! 285: s" bulk" $open-package ihandle-bulk-tran ! ! 286: \ make-media-ready ! 287: s" close all " usb-debug-print ! 288: close-dev 0 set-node 0 to my-self ! 289: ! 290: ihandle-bulk-tran close-package ! 291: ELSE ! 292: s" can't open usb hub" usb-debug-print ! 293: THEN ! 294: ! 295: TRUE ! 296: ; ! 297:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.