|
|
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: \ OF properties
15: \ -----------------------------------------------------------
16:
17: s" scsi" device-name
18: s" block-type" device-type
19: 1 encode-int s" #address-cells" property
20: 0 encode-int s" #size-cells" property
21:
22:
23: : encode-unit 1 hex-encode-unit ;
24:
25: : decode-unit 1 hex-decode-unit ;
26:
27:
28: \ -----------------------------------------------------------
29: \ Specific properties
30: \ -----------------------------------------------------------
31:
32: 1 chars alloc-mem VALUE ch-buffer
33: 8 VALUE mps-dcp
34: 0 VALUE port-number
35: 0 VALUE my-usb-address
36:
37:
38: : control-std-get-maxlun
39: ( MPS fun-addr dir data-buff data-len -- TRUE | FALSE )
40: s" control-std-get-maxlun" $call-parent
41: ;
42:
43:
44: : control-std-get-configuration-descriptor
45: ( data-buffer data-len MPS funcAddr -- TRUE|FALSE )
46: s" control-std-get-configuration-descriptor" $call-parent
47: ;
48:
49: : rw-endpoint
50: ( pt ed-type toggle buffer length mps address -- toggle TRUE|toggle FALSE )
51: s" rw-endpoint" $call-parent
52: ;
53:
54: : controlxfer ( dir addr dlen setup-packet MPS ep-fun -- TRUE|FALSE )
55: s" controlxfer" $call-parent
56: ;
57:
58: : control-std-set-configuration
59: ( configvalue FuncAddr -- TRUE|FALSE )
60: s" control-std-set-configuration" $call-parent
61: ;
62:
63: \ This method is used for extracting the properties from it's parent and
64: \ storing these value to temporary variable so that they can used later.
65:
66: : extract-properties ( -- )
67: s" USB-ADDRESS" get-inherited-property ( prop-addr prop-len FALSE | TRUE )
68: IF
69: s" notpossible" usb-debug-print
70: ELSE
71: decode-int nip nip to my-usb-address
72: THEN
73: s" MPS-DCP" get-inherited-property ( prop-addr prop-len FALSE | TRUE )
74: IF
75: s" MPS-DCP property not found.Assume 8 as MAX PACKET SIZE" usb-debug-print
76: s" for the default control pipe" usb-debug-print
77: 8 to mps-dcp
78: ELSE
79: s" MPS-DCP property found!!" usb-debug-print
80: decode-int nip nip to mps-dcp
81: THEN
82: s" reg" get-inherited-property ( prop-addr prop-len FLASE | TRUE )
83: IF
84: s" notpossible" usb-debug-print
85: ELSE
86: decode-int nip nip to port-number
87: THEN
88: ;
89:
90:
91: \ This method is used for creating the child nodes for every Logical unit
92: \ available in the device, this method will call control-std-get-maxlun for
93: \ for finding the maximum Logical units supported by the device and along with
94: \ the creation of nodes this method encodes the properties of the node also.
95:
96: : create-tree ( -- )
97: mps-dcp my-usb-address 0 ch-buffer 1 ( MPS fun-addr dir data-buff data-len )
98: control-std-get-maxlun ( TRUE | FALSE )
99:
100: \ This method extracts the maximum number of Logical Units Supported by
101: \ the Device . if no Logical Units are present then 0 will be taken as the
102: \ max logical units. if the device doesn't support the GET-MAX-LUN command
103: \ then the device may can be stalled as a temporary fix to come out from
104: \ the stalling situations we can issue the control-std-set-configuration with
105: \ appropriate arguments
106:
107:
108: IF
109: s" GET-MAX-LUN IS WORKING :" usb-debug-print
110: ELSE
111: s" ERROR in GET-MAX-LUN " usb-debug-print
112: THEN
113: ch-buffer c@ 1 + 0 ( max-lun+1 0 )
114: DO
115: s" iManufacturer" get-inherited-property drop ( prop-addr prop-len TRUE )
116: decode-int nip nip ( iManu )
117: s" iProduct" get-inherited-property drop
118: ( iManu prop-addr prop-len TRUE | FALSE )
119: decode-int nip nip ( iManu iProd )
120: s" iSerialNumber" get-inherited-property drop
121: ( iManu iProd prop-addr prop-len TRUE | FALSE )
122: decode-int nip nip ( iManu iProd iSerNum )
123: s" MPS-BULKOUT" get-inherited-property drop
124: ( iManu iProd iSerNum prop-len prop-addr TRUE | FALSE )
125: decode-int nip nip ( iManu iProd iSerNum MPS-BULKOUT )
126: s" BULK-OUT-EP-ADDR" get-inherited-property drop
127: ( iManu iProd iSerNum MPS-BULKOUT prop-addr prop-len TRUE|FALSE )
128: decode-int nip nip ( iManu iProd iSerNum MPS-BULKOUT BULK-OUT-EP-ADDR )
129: s" MPS-BULKIN" get-inherited-property drop
130: ( iManu iProd iSerNum MPS-BULKOUT BULK-OUT-EP-ADDR prop-addr prop-len
131: TRUE | FALSE )
132: decode-int nip nip
133: ( iManu iProd iSernum MPS-BULKOUT BULK-OUT-EP-ADDR MPS-BULKIN )
134: s" BULK-IN-EP-ADDR" get-inherited-property drop
135: ( iManu iProd iSernum MPS-BULKOUT BULK-OUT-EP-ADDR MPS-BULKIN prop-addr
136: prop-len TRUE | FALSE )
137: decode-int nip nip
138: ( iManu iProd iSernum MPS-BULKOUT BULK-OUT-EP-ADDR MPS-BULKIN
139: BULKIN-EP-ADDR )
140: mps-dcp port-number my-usb-address I
141: ( iManu iProd iSernum MPS-BULKOUT BULK-OUT-EP-ADDR MPS-BULKIN
142: BULKIN-EP-ADDR mps-dcp port-address my-usb-address lun-number )
143: new-device
144:
145: \ creates new device child node, doesn't consume any argument from stack
146:
147: ( iManu iProd iSernum MPS-BULKOUT BULK-OUT-EP-ADDR MPS-BULKIN
148: BULKIN-EP-ADDR mps-dcp port-address my-usb-address lun-number )
149:
150: set-space
151: ( iManu iProd iSernum MPS-BULKOUT BULK-OUT-EP-ADDR MPS-BULKIN
152: BULKIN-EP-ADDR mps-dcp port-number my-usb-address )
153: encode-int s" USB-ADDRESS" property
154: ( iManu iProd iSernum MPS-BULKOUT BULK-OUT-EP-ADDR MPS-BULKIN
155: BULKIN-EP-ADDR mps-dcp port-number )
156: encode-int s" reg" property
157: ( iManu iProd iSernum MPS-BULKOUT BULK-OUT-EP-ADDR MPS-BULKIN )
158: ( BULKIN-EP-ADDR mps-dcp port-number )
159: encode-int s" MPS-DCP" property
160: ( iManu iProd iSernum MPS-BULKOUT BULK-OUT-EP-ADDR MPS-BULKIN
161: BULKIN-EP-ADDR )
162: I encode-int s" LUN" property
163: ( iManu iProd iSernum MPS-BULKOUT BULK-OUT-EP-ADDR MPS-BULKIN
164: BULKIN-EP-ADDR )
165: encode-int s" BULK-IN-EP-ADDR" property
166: ( iManu iProd iSernum MPS-BULKOUT BULK-OUT-EP-ADDR MPS-BULKIN )
167: encode-int s" MPS-BULKIN" property
168: ( iManu iProd iSernum MPS-BULKOUT BULK-OUT-EP-ADDR )
169: encode-int s" BULK-OUT-EP-ADDR" property
170: ( iManu iProd iSernum MPS-BULKOUT )
171: encode-int s" MPS-BULKOUT" property ( iManu iProd iSerNum )
172: encode-int s" iSerialNumber" property ( iManu iProd )
173: encode-int s" iProduct" property ( iManu )
174: encode-int s" iManufacturer" property ( -- )
175: s" usb-storage.fs" INCLUDED
176: finish-device
177: LOOP
178: ;
179:
180: extract-properties \ Extract the properties from parent
181: create-tree \ this method creates the node for every lun with properties
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.