|
|
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: ! 14: \ Citrine storage controller. ! 15: 2dup type ! 16: ! 17: device-name s" ide" device-type ! 18: ! 19: ! 20: 3 encode-int s" #address-cells" property ! 21: 0 encode-int s" #size-cells" property ! 22: ! 23: : decode-unit 3 hex-decode-unit ; ! 24: : encode-unit 3 hex-encode-unit ; ! 25: ! 26: ! 27: : >ioa [ 10 config-l@ -10 and ] LITERAL + ; ! 28: : ioa@ >ioa rl@-le ; ! 29: : ioa! >ioa rl!-le ; ! 30: ! 31: ! 32: \ Clear request completion doorbell. ! 33: 2 228 ioa! ! 34: ! 35: \ status ! 36: CREATE ioasa 200 allot ioasa 200 erase \ can reduce to 8 later ! 37: ! 38: \ request/response queue ! 39: CREATE rrq 100 allot rrq 100 erase \ can be smaller ! 40: ! 41: \ data descriptor ! 42: CREATE ioadl 8 allot ! 43: ! 44: \ control block ! 45: CREATE ioarcb 80 allot ioarcb 80 erase ! 46: ioarcb dup l! ! 47: 60708090 ioarcb c + l! \ user handle ! 48: ioadl ioarcb 2c + l! \ read ioadl ! 49: ioasa ioarcb 34 + l! 200 ioarcb 38 + w! ! 50: ! 51: \ ioa config data (max. 16 devices) ! 52: CREATE ioacfg 404 allot ioacfg 404 erase ! 53: CREATE setsupbuff 2c allot setsupbuff 2c erase 2c setsupbuff w! 1 setsupbuff + 3 c! ! 54: ! 55: : wait-ready ( -- ) ! 56: 82800000 214 ioa! ! 57: 80000000 BEGIN dup 224 ioa@ cr .s dup 8000000 and IF ! 58: cr ." Unit check on SAS-Controller detected" ! 59: cr 42c ioa@ . ! 60: 8 110 ioa! ! 61: BEGIN cr 0 config-l@ dup . ffffffff <> UNTIL ! 62: \ ABORT" Unit check on SAS-Controller detected" ! 63: THEN ! 64: and ! 65: UNTIL drop ! 66: ; ! 67: ! 68: \ wait-ready ! 69: ! 70: : wait-ioa ( int-mask -- ) BEGIN dup 224 ioa@ and UNTIL drop ; ! 71: : init-ioa ( -- ) 82800000 214 ioa! 80000000 wait-ioa ; ! 72: : do-request ( -- ) ioasa 20 erase ioarcb 404 ioa! ! 73: 2 wait-ioa 2 228 ioa! ! 74: ; ! 75: ! 76: : setup-ioarcb ( rsrc type addr len -- ) ! 77: tuck 49000000 or ioadl l! ioadl 4 + l! \ setup ioadl ! 78: ioarcb 20 + l! ioadl ioarcb 2c + l! 8 ioarcb 30 + l! \ set len, ioadl addr ! 79: ioarcb 3e + c! ioarcb 8 + l! \ set type and resource ! 80: ioarcb 40 + 40 erase ; ! 81: ! 82: : setup-wrioarcb ( rsrc type addr len -- ) ! 83: tuck 49000000 or ioadl l! ioadl 4 + l! \ setup ioadl ! 84: ioarcb 1C + l! ioadl ioarcb 24 + l! 8 ioarcb 28 + l! \ set len, ioadl addr ! 85: ioarcb 3e + c! ioarcb 8 + l! \ set type and resource ! 86: ioarcb 40 + 40 erase ; ! 87: ! 88: : setup-idrrq ( rrq len -- ) ! 89: c4 ioarcb 42 + c! 8 lshift ioarcb 48 + l! ioarcb 44 + l! ; ! 90: : do-idrrq ( -- ) -1 1 0 0 setup-ioarcb rrq 100 setup-idrrq do-request ; ! 91: ! 92: : setup-query ( len -- ) c5 ioarcb 42 + c! 8 lshift ioarcb 48 + l! ; ! 93: : do-query ( -- ) -1 1 ioacfg 404 setup-ioarcb 404 setup-query do-request ; ! 94: ! 95: : setup-startUnit ( -- ) 1b ioarcb 42 + c! 3 ioarcb 46 + c! ; ! 96: : do-startUnit ( hndl -- ) 0 0 0 setup-ioarcb setup-startUnit do-request ; ! 97: ! 98: : setup-setsupported ( len -- ) 80 ioarcb 40 + c! fb ioarcb 42 + c! 8 lshift ioarcb 48 + l! ; ! 99: : do-setsupported ( -- ) -1 1 setsupbuff 2c setup-wrioarcb 2c setup-setsupported do-request ; ! 100: ! 101: \ ******************************** ! 102: \ read capacity ! 103: \ ******************************** ! 104: CREATE cap 8 allot ! 105: ! 106: : setup-cap ( -- ) 25 ioarcb 42 + c! cap 8 erase ; ! 107: : do-cap ( rsrc addr -- ) ! 108: >r 0 r> 8 setup-ioarcb setup-cap do-request ; ! 109: ! 110: : .id ( id -- ) ." @" lwsplit 2 0.r ." ," wbsplit 2 0.r ." ," 2 0.r ; ! 111: ! 112: : .cap ( rsrc -- ) ! 113: cap do-cap cap l@ cap 4 + l@ * d# 50000000 + d# 100000000 / ! 114: base @ >r decimal d# 10 /mod 4 .r ." ." 0 .r ." GB" r> base ! ; ! 115: ! 116: \ ******************************** ! 117: \ Test Unit Ready ! 118: \ ******************************** ! 119: : setup-test-unit-ready ( -- ) ! 120: 00 ioarcb 42 + c! \ SCSI cmd: Test-Unit-Ready ! 121: ; ! 122: ! 123: : do-test-unit-ready ( rsrc -- ) ! 124: 0 0 0 setup-ioarcb ( rsrc type addr len -- ) ! 125: setup-test-unit-ready ! 126: do-request ! 127: ; ! 128: ! 129: \ ******************************** ! 130: \ Check devices ! 131: \ ******************************** ! 132: : check-device ( ioacfg-entry -- ) ! 133: dup 2 + w@ 2001 and 0<> \ generic or raid disk ! 134: IF \ is an IOA resource ? ! 135: dup 8 + l@ ( ioacfg-entry rsrc ) \ get resource handle ! 136: 8 0 ! 137: DO ( ioacfg-entry rsrc ) ! 138: dup do-test-unit-ready ( ioacfg-entry rsrc ) ! 139: ioasa l@ 0= \ read returned status ! 140: IF ! 141: LEAVE ! 142: THEN ! 143: LOOP ! 144: drop ( ioacfg-entry ) ! 145: THEN ! 146: drop ( ) ! 147: ; ! 148: ! 149: : check-devices ( -- ) ! 150: ioacfg 4 + ( ioacfg-entry ) \ config block for 16 devices ! 151: ioacfg c@ 0 \ amount of detected devices ! 152: ?DO ! 153: dup ! 154: check-device ( ioacfg-entry ) ! 155: 40 + ! 156: LOOP ! 157: drop ! 158: ; ! 159: ! 160: \ ******************************** ! 161: \ Show Devices ! 162: \ ******************************** ! 163: : show-device ( ioacfg-entry -- ) ! 164: cr ." " dup 2 + w@ ! 165: dup 8000 and IF ." Controller :" THEN ! 166: dup 2000 and IF ." Disk (RAID Member):" THEN ! 167: dup 0002 and IF ." Disk (Volume Set) :" THEN ! 168: 0001 and IF ." Disk (Generic) :" THEN ! 169: space dup 4 + l@ ffffff and dup ffffff <> IF ! 170: .id ! 171: ELSE drop 9 spaces THEN space ! 172: dup 1c + 8 type space dup 24 + 10 type ! 173: dup 2 + w@ 8000 and 0= IF ! 174: space dup 8 + l@ .cap ! 175: THEN drop ! 176: ; ! 177: ! 178: : show-devices ( -- ) ! 179: ioacfg 4 + ioacfg c@ 0 ! 180: ?DO dup show-device 40 + LOOP drop ! 181: ; ! 182: ! 183: : setup-read ( lba len -- ) \ len is in blocks ! 184: 28 ioarcb 42 + c! ! 185: swap ioarcb 44 + l! ! 186: 8 lshift ioarcb 48 + l! ! 187: ; ! 188: ! 189: : do-read ( hndl lba len addr -- ) \ len is in blocks ! 190: over >r rot >r swap 0 -rot 200 * ( 0 hndl addr len* ) ! 191: setup-ioarcb r> r> ( lba len ) ! 192: setup-read do-request ! 193: ; ! 194: ! 195: : make-subnode ( rsrc-type rsrc-handle id -- ) ! 196: rot 2 and IF \ only device which are part of a RAID should be started ! 197: over do-startUnit \ at least on citrine there are problems starting ! 198: \ Generic SCSI devices ! 199: THEN do-setsupported ! 200: dup ffffff <> IF ! 201: \ we need max-#blocks for citrine-disk.fs ! 202: ( rsrc id ) ! 203: over cap do-cap cap l@ ( rsrc id max-#blocks ) ! 204: swap rot swap ( max-#block rsrc id ) \ this is what citrine-disk.fs expects... ! 205: s" citrine-disk.fs" included ! 206: ELSE ! 207: 2drop ! 208: THEN ! 209: ; ! 210: ! 211: : make-subnodes ( -- ) ! 212: ioacfg 4 + ioacfg c@ 0 ?DO dup 2 + w@ dup ( ioacfg rsrc-type rsrc-type ) ! 213: A000 \ 8000 = Resource Subtype is IOA Focal Point. ! 214: \ 2000 = Device is a member of a data redundancy group (eg. RAID). ! 215: \ (1000 = Device is designated for use as a hot spare. ! 216: \ Unfortunately obsidian reports disk which are not part of ! 217: \ of a RAID also as hot space even if they are not.) ! 218: \ all these devices should not appeat in DT ! 219: \ SIS40 page 60 ! 220: and 0= IF ! 221: swap dup ( rsrc-type ioacfg ioacfg ) ! 222: 8 + l@ over 4 + l@ ( rsrc-type ioacfg rsrc-handle rsrc-addr ) ! 223: ffffff and 2swap swap 2swap ( ioacfg rsrc-type rsrc-handle rsrc-addr ) ! 224: make-subnode ELSE drop THEN 40 + LOOP drop ; ! 225: ! 226: : do-it ( -- ) ! 227: init-ioa do-idrrq ! 228: do-query ! 229: check-devices ! 230: show-devices ! 231: ; ! 232: ! 233: : setup-shutdown ( -- ) ! 234: f7 ioarcb 42 + c! 0 ioarcb 48 + l! 0 ioarcb 44 + l! ; ! 235: : do-shutdown ( -- ) -1 1 0 0 setup-ioarcb setup-shutdown do-request ; ! 236: ! 237: : open true ; ! 238: : close ; ! 239: ! 240: : start ['] do-it CATCH IF cr ." Citrine disabled" ELSE make-subnodes THEN ; ! 241: ! 242: cr start cr cr
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.