aboutsummaryrefslogtreecommitdiff
path: root/slof/fs/packages/bulk.fs
blob: 06d7eaecc7928d74872da27a9d143a919d04af80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
\ *****************************************************************************
\ * Copyright (c) 2004, 2008 IBM Corporation
\ * All rights reserved.
\ * This program and the accompanying materials
\ * are made available under the terms of the BSD License
\ * which accompanies this distribution, and is available at
\ * http://www.opensource.org/licenses/bsd-license.php
\ *
\ * Contributors:
\ *     IBM Corporation - initial implementation
\ ****************************************************************************/


s" bulk" device-name


\ standard open firmare method


: open  true  ;

\ standard open firmare method


: close ;


\ -------------------------------------------------
\	Locals
\ ------------------------------------------------


8 chars alloc-mem VALUE setup-packet


\ --------------------------------------------------
\ signature --->4bytes offset --->0
\ tag       --->4bytes offset --->4
\ trans-len --->4bytes offset --->8
\ dir-flag  --->1byte  offset --->c
\ lun       --->1byte  offset --->d
\ comm-len  --->1byte  offset --->e
\ --------------------------------------------------


0 VALUE cbw-addr
: build-cbw ( address tag transfer-len direction lun command-len -- )
   5 pick TO cbw-addr  ( address tag transfer-len direction lun command-len )
   cbw-addr 0f erase   ( address tag transfer-len direction lun command-len )
   cbw-addr e + c!     ( address tag transfer-len direction lun )
   cbw-addr d + c!     ( address tag transfer-len direction )
   cbw-addr c + c!     ( address tag transfer-len )
   cbw-addr 8 + l!-le  ( address tag )
   cbw-addr 4 + l!-le  ( address )
   43425355 cbw-addr l!-le ( address )
   drop  ;


\ ---------------------------------------------------
\ signature --->4bytes offset --->0
\ tag       --->4bytes offset --->4
\ residue   --->4bytes offset --->8
\ status    --->1byte  offset --->c
\ ---------------------------------------------------


0 VALUE csw-addr
: analyze-csw ( address -- residue tag true|reason false )
   TO csw-addr
   csw-addr l@-le 53425355 =  IF
      csw-addr c + c@ dup 0=  IF ( reason )
         drop
         csw-addr 8 + l@-le ( residue )
         csw-addr 4 + l@-le ( residue tag ) \ command  block tag
         TRUE               ( residue tag TRUE )
      ELSE
         FALSE              ( reason FALSE )
      THEN
   ELSE
      FALSE                 ( FALSE )
   THEN
   csw-addr 0c erase
;

: bulk-reset-recovery-procedure ( bulk-out-endp bulk-in-endp usb-addr -- )
  s" bulk-reset-recovery-procedure" $call-parent
;