2590
|
1 ********************************************************************
|
|
2 * scsiquery - Get info on SCSI device through SS.DCmd call
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
|
6 * Edt/Rev YYYY/MM/DD Modified by
|
|
7 * Comment
|
|
8 * ------------------------------------------------------------------
|
|
9 * 1 2008/01/21 Boisy G. Pitre
|
|
10 * Created while on the FPSO Kikeh in the South China Sea.
|
|
11
|
|
12 nam scsiquery
|
|
13 ttl Get info on SCSI device through the SS.DCmd call
|
|
14
|
|
15 ifp1
|
|
16 use defsfile
|
|
17 use scfdefs
|
|
18 endc
|
|
19
|
|
20 tylg set Prgrm+Objct
|
|
21 atrv set ReEnt+rev
|
|
22 rev set $00
|
|
23 edition set 1
|
|
24
|
|
25 mod eom,name,tylg,atrv,start,size
|
|
26
|
|
27 org 0
|
|
28 code rmb 1
|
|
29 lsn rmb 3
|
|
30 left rmb 2
|
|
31 path rmb 1
|
|
32 numbuf rmb 16
|
|
33 txbuff rmb 2048 to accomodate CD-ROM sector sizes
|
|
34 rmb 200
|
|
35 size equ .
|
|
36
|
|
37 StartM fcc /SCSI Inquiry Utility/
|
|
38 cr fcb C$CR
|
|
39 VID fcc /Vendor ID : /
|
|
40 VIDL equ *-VID
|
|
41 PID fcc /Product ID : /
|
|
42 PIDL equ *-PID
|
|
43 RLV fcc /Revision : /
|
|
44 RLVL equ *-RLV
|
|
45 LBA fcc /Blocks : /
|
|
46 LBAL equ *-LBA
|
|
47 BSZ fcc /Block Size : /
|
|
48 BSZL equ *-BSZ
|
|
49
|
|
50 InquiryUnit fcb $12,$00,$00,$00,96,$00
|
|
51 ReadCapacity fcb $25,$00,$00,$00,$00,$00,$00,$00,$00,$00
|
|
52
|
|
53 name fcs /scsiquery/
|
|
54 fcb edition
|
|
55
|
|
56 start
|
|
57 leay txbuff,u
|
|
58 ldd #$2060
|
|
59 l@ sta ,y+
|
|
60 decb
|
|
61 bne l@
|
|
62 leay txbuff,u
|
|
63
|
|
64 l@ lda ,x+
|
|
65 cmpa #C$CR
|
|
66 beq ok@
|
|
67 cmpa #C$SPAC
|
|
68 beq ok@
|
|
69 sta ,y+
|
|
70 bra l@
|
|
71 ok@ ldd #'@*256+C$CR
|
|
72 std ,y
|
|
73 leax txbuff,u
|
|
74
|
|
75 lda #READ.
|
|
76 os9 I$Open
|
|
77 lbcs exit
|
|
78 sta path,u
|
|
79
|
|
80 leax StartM,pcr
|
|
81 lda #1
|
|
82 ldy #100
|
|
83 os9 I$WritLn
|
|
84
|
|
85 * Do INQUIRY
|
|
86 leax txbuff,u
|
|
87 leay InquiryUnit,pcr
|
|
88 lda path,u
|
|
89 ldb #SS.DCmd
|
|
90 os9 I$SetStt
|
|
91 lbcs exit
|
|
92
|
|
93 * Show Vendor ID
|
|
94 leax VID,pcr
|
|
95 ldy #VIDL
|
|
96 lda #1
|
|
97 os9 I$WritLn
|
|
98
|
|
99 leax txbuff+8,u
|
|
100 ldy #15-8+1
|
|
101 lda #1
|
|
102 os9 I$Write
|
|
103 leax cr,pcr
|
|
104 ldy #1
|
|
105 os9 I$WritLn
|
|
106
|
|
107 * Show Product ID
|
|
108 leax PID,pcr
|
|
109 ldy #PIDL
|
|
110 lda #1
|
|
111 os9 I$WritLn
|
|
112
|
|
113 leax txbuff+16,u
|
|
114 ldy #31-16+1
|
|
115 lda #1
|
|
116 os9 I$Write
|
|
117 leax cr,pcr
|
|
118 ldy #1
|
|
119 os9 I$WritLn
|
|
120
|
|
121 * Show Revision Level
|
|
122 leax RLV,pcr
|
|
123 ldy #RLVL
|
|
124 lda #1
|
|
125 os9 I$WritLn
|
|
126
|
|
127 leax txbuff+32,u
|
|
128 ldy #35-32+1
|
|
129 lda #1
|
|
130 os9 I$Write
|
|
131 leax cr,pcr
|
|
132 ldy #1
|
|
133 os9 I$WritLn
|
|
134
|
|
135 * Do READ CAPACITY
|
|
136 leax txbuff,u
|
|
137 leay ReadCapacity,pcr
|
|
138 lda path,u
|
|
139 ldb #SS.DCmd
|
|
140 os9 I$SetStt
|
|
141 bcs exit
|
|
142
|
|
143 * Show Number of Blocks
|
|
144 leax LBA,pcr
|
|
145 ldy #LBAL
|
|
146 lda #1
|
|
147 os9 I$WritLn
|
|
148
|
|
149 leax txbuff,u
|
|
150 leay numbuf,u
|
|
151 bsr itoa
|
|
152 lda #1
|
|
153 os9 I$Write
|
|
154
|
|
155 leax cr,pcr
|
|
156 ldy #1
|
|
157 os9 I$WritLn
|
|
158
|
|
159 * Show Block Size
|
|
160 leax BSZ,pcr
|
|
161 ldy #BSZL
|
|
162 lda #1
|
|
163 os9 I$WritLn
|
|
164
|
|
165 leax txbuff+4,u
|
|
166 leay numbuf,u
|
|
167 bsr itoa
|
|
168 lda #1
|
|
169 os9 I$Write
|
|
170
|
|
171 leax cr,pcr
|
|
172 ldy #1
|
|
173 os9 I$WritLn
|
|
174
|
|
175 exitok clrb
|
|
176 exit os9 F$Exit
|
|
177
|
|
178 * Entry:
|
|
179 * X = address of 32 bit value
|
|
180 * Y = address of buffer to hold number
|
|
181 * Exit:
|
|
182 * X = address of buffer holding number
|
|
183 * Y = length of number string in bytes
|
|
184 itoa pshs u,y
|
|
185 tfr y,u
|
|
186 ldb #10 max number of numbers (10^9)
|
|
187 pshs b save count on stack
|
|
188 leay Base,pcr point to base of numbers
|
|
189 s@ lda #$30 put #'0
|
|
190 sta ,u at U
|
|
191 s1@ bsr Sub32 ,X=,X-,Y
|
|
192 inc ,u
|
|
193 bcc s1@ if X>0, continue
|
|
194 bsr Add32 add back in
|
|
195 dec ,u+
|
|
196 dec ,s decrement counter
|
|
197 beq done@
|
|
198 lda ,s
|
|
199 cmpa #$09
|
|
200 beq comma@
|
|
201 cmpa #$06
|
|
202 beq comma@
|
|
203 cmpa #$03
|
|
204 bne s2@
|
|
205 comma@ ldb #',
|
|
206 stb ,u+
|
|
207 s2@ leay 4,y point to next
|
|
208 bra s@
|
|
209 done@ leas 1,s
|
|
210 * 1,234,567,890
|
|
211 ldb #14 length of string with commas + 1
|
|
212 ldx ,s++ get pointer to buffer
|
|
213 a@ decb
|
|
214 beq ex@
|
|
215 lda ,x+ get byte
|
|
216 cmpa #'0
|
|
217 beq a@
|
|
218 cmpa #',
|
|
219 beq a@
|
|
220 clra
|
|
221 tfr d,y transfer count into Y
|
|
222 v@ leax -1,x
|
|
223 puls u,pc
|
|
224 ex@ ldy #0001
|
|
225 bra v@
|
|
226
|
|
227 * Entry:
|
|
228 * X = address of 32 bit minuend
|
|
229 * Y = address of 32 bit subtrahend
|
|
230 * Exit:
|
|
231 * X = address of 32 bit difference
|
|
232 Sub32 ldd 2,x
|
|
233 subd 2,y
|
|
234 std 2,x
|
|
235 ldd ,x
|
|
236 sbcb 1,y
|
|
237 sbca ,y
|
|
238 std ,x
|
|
239 rts
|
|
240
|
|
241
|
|
242 * Entry:
|
|
243 * X = address of 32 bit number
|
|
244 * Y = address of 32 bit number
|
|
245 * Exit:
|
|
246 * X = address of 32 bit sum
|
|
247 Add32 ldd 2,x
|
|
248 addd 2,y
|
|
249 std 2,x
|
|
250 ldd ,x
|
|
251 adcb 1,y
|
|
252 adca ,y
|
|
253 std ,x
|
|
254 rts
|
|
255
|
|
256 Base fcb $3B,$9A,$CA,$00 1,000,000,000
|
|
257 fcb $05,$F5,$E1,$00 100,000,000
|
|
258 fcb $00,$98,$96,$80 10,000,000
|
|
259 fcb $00,$0f,$42,$40 1,000,000
|
|
260 fcb $00,$01,$86,$a0 100,000
|
|
261 fcb $00,$00,$27,$10 10,000
|
|
262 fcb $00,$00,$03,$e8 1,000
|
|
263 fcb $00,$00,$00,$64 100
|
|
264 fcb $00,$00,$00,$0a 10
|
|
265 fcb $00,$00,$00,$01 1
|
|
266
|
|
267 emod
|
|
268 eom equ *
|
|
269 end
|