Mercurial > hg > Members > kono > nitros9-code
annotate level1/cmds/devs.asm @ 2568:ad7819d6c5c5
Updated
author | boisy |
---|---|
date | Sat, 12 Feb 2011 01:26:34 +0000 |
parents | 84ea83668304 |
children |
rev | line source |
---|---|
963 | 1 ******************************************************************** |
2 * devs - Show device table entries | |
3 * | |
4 * $Id$ | |
5 * | |
1325
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
963
diff
changeset
|
6 * Edt/Rev YYYY/MM/DD Modified by |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
963
diff
changeset
|
7 * Comment |
963 | 8 * ------------------------------------------------------------------ |
1325
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
963
diff
changeset
|
9 * 2 ????/??/?? |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
963
diff
changeset
|
10 * Original version. |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
963
diff
changeset
|
11 * |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
963
diff
changeset
|
12 * 3 ????/??/?? Alan DeKok |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
963
diff
changeset
|
13 * Reworked. |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
963
diff
changeset
|
14 * |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
963
diff
changeset
|
15 * 3 2003/01/07 Boisy G. Pitre |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
963
diff
changeset
|
16 * Renamed to devs ala OS-9/68K, reworked. |
963 | 17 |
18 nam devs | |
19 ttl Show device table entries | |
20 | |
21 ifp1 | |
22 use defsfile | |
23 endc | |
24 | |
25 tylg set Prgrm+Objct | |
26 atrv set ReEnt+rev | |
1325
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
963
diff
changeset
|
27 rev set $00 |
963 | 28 edition set 3 |
29 | |
30 mod eom,name,tylg,atrv,start,size | |
31 | |
32 MaxEnts set 64 maximmum entries we display | |
33 | |
34 org 0 | |
35 memstrt rmb 2 | |
36 outptr rmb 2 | |
37 counter rmb 1 | |
38 narrow rmb 1 | |
39 curdte rmb 2 | |
40 ddevtbl rmb 2 device table pointer | |
41 devcount rmb 1 | |
42 descptr rmb 2 | |
43 numbytes rmb 1 | |
44 lnbuff rmb 80 | |
45 IFGT Level-1 | |
46 datimg rmb 4 | |
47 devtbcpy rmb MaxEnts*DEVSIZ | |
48 descrip rmb 256 | |
49 syspdesc rmb P$Size | |
50 ENDC | |
51 stack rmb 200 | |
52 size equ . | |
53 | |
54 name fcs /devs/ | |
55 fcb edition | |
56 | |
57 Header1 fcc /Device Table at: / | |
58 x12Len equ *-Header1 | |
59 NHeader fcc /Dv Desc Drvr Stat File Usr/ | |
60 fcb C$CR | |
61 NHeaderL equ *-NHeader | |
62 NHeader2 fcc /Nm Port Name Mem Mgr Cnt/ | |
63 fcb C$CR | |
64 NHeader2L equ *-NHeader2 | |
65 NUndln fcc /------- ----------- ---- ---/ | |
66 fcb C$CR | |
67 NUndlnL equ *-NUndln | |
68 Header fcc /Device Desc Driver Static File Usr/ | |
69 fcb C$CR | |
70 HeaderL equ *-Header | |
71 Header2 fcc /Name Port Name Mem Manager Cnt/ | |
72 fcb C$CR | |
73 Header2L equ *-Header2 | |
74 Undln fcc /----------- ------------- ------- ---/ | |
75 MyCR fcb C$CR | |
76 UndlnL equ *-Undln | |
77 Init fcs /Init/ | |
78 | |
79 start ldd ,x get parameter bytes | |
80 cmpd #$2D3F -? | |
81 lbeq Help | |
82 lda #MaxEnts get maximum entries we support | |
83 sta <devcount and save as count | |
84 leax Init,pcr | |
85 clra | |
86 pshs u | |
87 os9 F$Link | |
88 bcs Exit | |
89 lda <DevCnt,u get device count | |
90 os9 F$UnLink unlink module | |
91 puls u restore static pointer | |
92 cmpa <devcount is table same or larger than our default? | |
93 bge cont branch if so | |
94 sta <devcount else store smaller count | |
95 cont stu <memstrt | |
96 clr <narrow assume wide | |
97 lda #$01 | |
98 ldb #SS.ScSiz | |
99 os9 I$GetStt | |
100 bcs cont2 | |
101 cmpx #HeaderL+1 | |
102 bge cont2 | |
103 sta <narrow | |
104 cont2 leax >MyCR,pcr | |
105 ldy #$0001 | |
106 os9 I$WritLn output a CR | |
107 lbcs Exit | |
108 leax >Header1,pcr dump out header | |
109 ldy #x12Len | |
110 os9 I$Write | |
111 lbcs Exit | |
112 IFGT Level-1 | |
113 lda #$01 | |
114 leax >syspdesc,u | |
115 os9 F$GPrDsc get system process descriptor | |
116 bcs Exit | |
117 leax <P$DATImg,x | |
118 stx <datimg save address of system's DAT image | |
119 ENDC | |
120 bra L00D3 | |
121 | |
122 ClnExit clrb | |
123 Exit os9 F$Exit | |
124 | |
125 L00D3 equ * | |
126 IFGT Level-1 | |
127 ldu <memstrt | |
128 leau <ddevtbl,u | |
129 ldd <datimg | |
130 ldx #D.DevTbl I/O device table | |
131 ldy #$0002 size of the pointer | |
132 os9 F$CpyMem | |
133 lbcs Exit | |
134 ldu <memstrt | |
135 ldd <ddevtbl | |
136 ELSE | |
137 ldd >D.DevTbl | |
138 std <ddevtbl | |
139 ENDC | |
140 leay <lnbuff,u | |
141 sty <outptr | |
142 lbsr HexWord output D as hex word | |
143 lbsr PrintBuf | |
144 | |
145 lda #$01 | |
146 leax >MyCR,pcr dump out another CR | |
147 ldy #$0001 | |
148 os9 I$WritLn | |
149 lbcs Exit | |
150 | |
151 leax >Header,pcr | |
152 ldy #HeaderL | |
153 tst <narrow | |
154 beq branch1 | |
155 leax >NHeader,pcr | |
156 ldy #NHeaderL | |
157 branch1 os9 I$WritLn | |
158 lbcs Exit | |
159 | |
160 leax >Header2,pcr | |
161 ldy #Header2L | |
162 tst <narrow | |
163 beq branch2 | |
164 leax >NHeader2,pcr | |
165 ldy #NHeader2L | |
166 branch2 os9 I$WritLn | |
167 lbcs Exit | |
168 leax >Undln,pcr | |
169 ldy #UndlnL | |
170 tst <narrow | |
171 beq branch3 | |
172 leax >NUndln,pcr | |
173 ldy #NUndlnL | |
174 branch3 os9 I$WritLn | |
175 lbcs Exit | |
176 | |
177 IFGT Level-1 | |
178 ldu <memstrt | |
179 lda <devcount | |
180 ldb #DEVSIZ | |
181 mul | |
182 tfr d,y | |
183 leau >devtbcpy,u | |
184 ldx <ddevtbl | |
185 ldd <datimg | |
186 os9 F$CpyMem copy the device table over | |
187 lbcs Exit | |
188 stu <curdte save pointer to start of DevTbl | |
189 ELSE | |
190 ldd <ddevtbl | |
191 std <curdte | |
192 ENDC | |
193 ldb <devcount | |
194 stb <counter total number of entries to get | |
195 | |
196 L0155 bsr L0165 | |
197 dec <counter | |
198 lbeq ClnExit if done them all, exit | |
199 | |
200 ldx <curdte get current pointer | |
201 leax DEVSIZ,x go to the next one | |
202 stx <curdte save the pointer again | |
203 bra L0155 and loop back | |
204 | |
205 L0165 ldu <memstrt get static pointer | |
206 leay <lnbuff,u point to line buffer | |
207 sty <outptr save as ptr | |
208 lda #C$SPAC space | |
209 ldb #5 assume this length | |
210 tst <narrow are we narrow? | |
211 beq L0171 branch if not | |
212 ldb #3 else load new size | |
213 L0171 sta ,y+ save spaces | |
214 decb | |
215 bne L0171 | |
216 | |
217 ldx <curdte get the current pointer | |
218 ldx V$DESC,x descriptor? | |
219 bne L017D if exists, go do it | |
220 rts otherwise exit | |
221 | |
222 L017D equ * | |
223 IFGT Level-1 | |
224 pshs u | |
225 leau >descrip,u to another buffer | |
226 ldd <datimg system DAT image | |
227 ldy #256 | |
228 os9 F$CpyMem | |
229 puls u | |
230 lbcs Exit | |
231 | |
232 leax >descrip,u point to the start of the buffer | |
233 ELSE | |
234 stx <descptr save descriptor pointer | |
235 ENDC | |
236 ldd M$Name,x pointer to the name | |
237 leax d,x | |
238 lda #5 assume this size | |
239 tst <narrow are we narrow? | |
240 beq branch4 branch if not | |
241 lda #3 else get new size | |
242 branch4 bsr Str2Buf dump out the first few bytes of the name | |
243 | |
244 IFGT Level-1 | |
245 leax >descrip,u | |
246 ELSE | |
247 ldx <descptr | |
248 ENDC | |
249 tst <narrow | |
250 bne skip1 | |
251 lda M$Port,x port address of the device | |
252 lbsr HexByte | |
253 ldy <outptr | |
254 leay -1,y | |
255 sty <outptr | |
256 skip1 ldd M$Port+1,x | |
257 lbsr HexWord | |
258 lbsr Space | |
259 * IFGT Level-1 | |
260 * leax >descrip,u | |
261 * ELSE | |
262 * ldx <descptr | |
263 * ENDC | |
264 ldd M$PDev,x device driver name offset | |
265 leax d,x | |
266 lda #9 | |
267 tst <narrow | |
268 beq branch5 | |
269 lda #7 | |
270 branch5 bsr Str2Buf dump out bytes of the driver name | |
271 ldx <curdte | |
272 ldd V$STAT,x | |
273 lbsr HexWord | |
274 lbsr Space | |
275 IFGT Level-1 | |
276 leax >descrip,u | |
277 ELSE | |
278 ldx <descptr | |
279 ENDC | |
280 ldd M$FMGr,x file manager name offset | |
281 leax d,x point to it | |
282 lda #9 | |
283 tst <narrow | |
284 beq branch6 | |
285 lda #7 | |
286 branch6 bsr Str2Buf dump out bytes of the file manager's name | |
287 ldx <curdte | |
288 lda V$USRS,x use count | |
289 lbsr HexByte print it | |
290 ldx <outptr | |
291 leax -1,x | |
292 bra L01E8 | |
293 | |
294 PrintBuf ldx <outptr | |
295 L01E8 lda #C$CR save a CR in memory | |
296 sta ,x | |
297 ldu <memstrt | |
298 leax <lnbuff,u to the buffer | |
299 ldy #80 80 characters max. | |
300 lda #1 | |
301 os9 I$WritLn dump the buffer out | |
302 lbcs Exit | |
303 rts | |
304 | |
305 * Entry: | |
306 * A = number of bytes to write buffer | |
307 * X = ptr to string to write to buffer | |
308 Str2Buf sta <numbytes dump out A bytes at X | |
309 clrb | |
310 bra L0207 | |
311 | |
312 L0204 lbsr Put2Buf | |
313 L0207 incb increment B | |
314 cmpb <numbytes equal to number of bytes? | |
315 bcc NSpaces branch if so | |
316 lda ,x+ else get byte at X | |
317 bpl L0204 branch if hi bit clear | |
318 anda #$7F else clear it | |
319 lbsr Put2Buf dump it out | |
320 cmpb <numbytes compare against num bytes | |
321 bcc L0221 branch if equal | |
322 | |
323 * Fill the rest with spaces | |
324 NSpaces lbsr Space | |
325 incb | |
326 cmpb <numbytes | |
327 bcs NSpaces | |
328 L0221 rts | |
329 | |
330 HexWord pshs b | |
331 bsr MakeHex | |
332 puls a | |
333 HexByte bsr MakeHex | |
334 Space lda #C$SPAC output a space | |
335 bra Put2Buf | |
336 | |
337 MakeHex tfr a,b | |
338 lsra | |
339 lsra | |
340 lsra | |
341 lsra | |
342 bsr L0238 | |
343 tfr b,a | |
344 L0238 anda #$0F get the number | |
345 cmpa #$0A >10? | |
346 bcs L0240 no, make it a number | |
347 adda #$07 if so, make it A-F | |
348 L0240 adda #$30 | |
349 * Entry: A = char to put in buffer | |
350 Put2Buf pshs x save X | |
351 ldx <outptr get buffer pointer | |
352 sta ,x+ store char and in X | |
353 stx <outptr save new outptr | |
354 puls pc,x and return | |
355 | |
356 Help lda #1 to STDOUT | |
357 leax HMsg,pcr | |
358 ldy #HLen | |
359 os9 I$Write | |
360 clrb | |
361 os9 F$Exit | |
362 | |
363 HMsg fcc /devs: show devices in device table/ | |
364 fdb C$CR,C$LF | |
365 HLen equ *-HMsg | |
366 | |
367 emod | |
368 eom equ * | |
369 end |