0
|
1 ********************************************************************
|
|
2 * PMap - Show process map information
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
|
6 * From "Inside Level II" by Kevin Darling
|
|
7 *
|
1255
|
8 * Edt/Rev YYYY/MM/DD Modified by
|
|
9 * Comment
|
0
|
10 * ------------------------------------------------------------------
|
1255
|
11 * ? 1987/02/08 Kevin Darling
|
|
12 * Original version.
|
|
13 *
|
|
14 * 2 1989/09/12 Ken Drexler
|
1350
|
15 * Revised to handle 4K or 8K blocks.
|
1597
|
16 *
|
|
17 * 3 2004/05/28 Rodney Hamilton
|
|
18 * Revised for NitrOS-9/OS9Tools compatibility.
|
|
19 * Revised to build for either 8K or 4K blocksize
|
|
20 * based on DAT parameters in SysType file.
|
1601
|
21 *
|
|
22 * 4 2004/06/03 Rodney Hamilton
|
|
23 * Added test for DEAD processes.
|
0
|
24
|
|
25 nam PMap
|
|
26 ttl Show process map information
|
|
27
|
|
28 ifp1
|
|
29 use defsfile
|
|
30 endc
|
|
31
|
|
32 Type set Prgrm+Objct
|
1255
|
33 Revs set ReEnt+0
|
0
|
34 Bufsiz set 512
|
1601
|
35 Edition set 4
|
0
|
36
|
1601
|
37 Stdout set 1
|
|
38 Maxnam set 30
|
|
39 Buflen set 80
|
0
|
40
|
|
41 pag
|
|
42 ***************************************************
|
|
43 *
|
|
44 mod PrgSiz,Name,Type,Revs,Entry,DatSiz
|
|
45
|
|
46 Name fcs /PMap/
|
1601
|
47 fcb Edition
|
0
|
48
|
|
49 * Data Equates
|
|
50 umem rmb 2
|
|
51 datimg rmb 2 datimg for copymem
|
|
52 lineptr rmb 2
|
|
53 number rmb 3
|
|
54 leadflag rmb 1
|
|
55 pid rmb 1
|
|
56 hdr rmb 12
|
1601
|
57 outbuf rmb Buflen
|
|
58 buffer rmb Bufsiz working proc. desc.
|
0
|
59 stack rmb 200
|
1601
|
60 DatSiz equ .
|
0
|
61
|
|
62 *************************************************
|
|
63 *
|
|
64 * Messages
|
|
65 *
|
1597
|
66 IFEQ DAT.BlSz-8192 8K blocks
|
|
67 Head1 fcc / ID 01 23 45 67 89 AB CD EF Program /
|
0
|
68 fcb C$CR
|
|
69
|
1597
|
70 Head2 fcc /____ __ __ __ __ __ __ __ __ ___________/
|
|
71 ELSE 4K blocks
|
|
72 Head1 fcc / ID 0 1 2 3 4 5 6 7 8 9 A B C D E F Program/
|
0
|
73 fcb C$CR
|
|
74
|
1597
|
75 Head2 fcc /____ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ _______/
|
|
76 ENDC
|
|
77 Hdrcr fcb C$CR
|
0
|
78
|
|
79 SysNam fcs "SYSTEM"
|
1601
|
80 Syslen equ *-SysNam
|
|
81 DeadNam fcs "DEAD"
|
|
82 Deadlen equ *-DeadNam
|
0
|
83
|
|
84 spc 3
|
|
85 ***************************************************
|
|
86 *
|
1601
|
87 Entry stu <umem
|
0
|
88 lda #1 start with process 1
|
1601
|
89 clr <pid
|
0
|
90
|
|
91 * Print header
|
|
92 leax buffer,u point at storage
|
|
93 os9 F$GBlkMp get block info
|
|
94 bcs Error
|
1597
|
95 IFEQ DAT.BlSz-8192
|
0
|
96 cmpd #8192 8k?
|
1597
|
97 ELSE
|
0
|
98 cmpd #4096 4k?
|
1597
|
99 ENDC
|
|
100 bne Error we only do 4k/8k
|
0
|
101
|
1601
|
102 leax <Hdrcr,pcr print line
|
0
|
103 lbsr PrintL1 print it
|
1601
|
104 leax <Head1,pcr
|
0
|
105 lbsr PrintL1 print it
|
1601
|
106 leax <Head2,pcr
|
0
|
107
|
|
108 lbsr PrintL1
|
|
109
|
|
110 * Main Program Loop
|
1601
|
111 Main ldu <umem
|
|
112 leax outbuf,u set line pointer
|
|
113 stx <lineptr
|
|
114 inc <pid next process
|
0
|
115 beq Bye >= 255 --> exit
|
1601
|
116 lda <pid get proc id
|
|
117 leax buffer,u set destination
|
0
|
118 os9 F$GPrDsc
|
|
119 bcs Main loop if no descriptor
|
|
120 bsr Output print data for descriptor
|
|
121 bra Main
|
|
122
|
|
123 Bye clrb
|
|
124 Error os9 F$Exit
|
|
125
|
|
126 * Subroutines
|
|
127
|
1597
|
128 Output lda P$ID,x process id
|
0
|
129 lbsr Outdecl
|
|
130 lbsr Space
|
|
131 lbsr Space
|
|
132
|
|
133 * Print Process DAT Image
|
|
134 * IN: x = process descriptor
|
|
135 *
|
1597
|
136 pshs x
|
0
|
137 leax P$DATImg,x point to DAT image
|
1597
|
138 IFEQ DAT.BlSz-8192
|
|
139 ldb #DAT.BlCt set count
|
|
140 ELSE
|
|
141 ldb #64/4 set count
|
|
142 ENDC
|
0
|
143 pshs b
|
|
144
|
|
145 PrntImg ldd ,x++ get DAT block
|
1597
|
146 cmpd #DAT.Free empty?
|
1601
|
147 bne PrntImg2
|
|
148 ldy <lineptr
|
1597
|
149 ldd #$2E2E was #".. (os9asm beta bug)
|
0
|
150 std ,y++
|
1601
|
151 sty <lineptr
|
|
152 lbsr Space
|
|
153 bra PrntImg3
|
0
|
154
|
|
155 PrntImg2 tfr b,a print block no.
|
|
156 lbsr Out2HS
|
|
157
|
|
158 PrntImg3 dec ,s count -= 1
|
1601
|
159 bne PrntImg
|
0
|
160 puls b,x
|
|
161
|
|
162 * Print primary module name
|
|
163 * IN: X - process descriptor
|
|
164 *
|
|
165 lbsr Space
|
1597
|
166 leay P$DATImg,x
|
1601
|
167 sty <datimg save pointer
|
|
168 ldb P$State,x check process state
|
|
169 andb #Dead was it DEAD?
|
|
170 beq Undead no, print name
|
|
171 leax >DeadNam,pcr
|
|
172 ldb #Deadlen
|
|
173 bra Copy0 yes, print "DEAD"
|
|
174
|
|
175 Undead ldx P$PModul,x x=offset in map
|
|
176 bne Doname
|
|
177 leax >SysNam,pcr point at name
|
|
178 ldb #Syslen
|
|
179 Copy0 ldy <lineptr
|
0
|
180
|
|
181 Copy lda ,x+
|
|
182 sta ,y+
|
|
183 decb
|
1601
|
184 bne Copy
|
0
|
185 bsr Name2
|
|
186 bra Printlin
|
|
187
|
|
188 Doname bsr Printnam
|
|
189
|
|
190 * Print Line
|
1601
|
191 Printlin ldx <lineptr terminate line
|
0
|
192 lda #C$CR
|
1597
|
193 sta ,x
|
1601
|
194 ldu <umem
|
1597
|
195 leax outbuf,u
|
0
|
196
|
|
197 * Print line
|
1601
|
198 PrintL1 ldy #Buflen
|
|
199 lda #Stdout
|
|
200 os9 I$WritLn
|
|
201 lbcs Error
|
0
|
202 rts
|
|
203
|
|
204 ** Find and print a module name
|
|
205 * IN: X - module offset
|
|
206 * U - data area
|
|
207 * datimg = pointer
|
|
208 *
|
|
209 Printnam equ *
|
|
210
|
|
211 * Read module header
|
1601
|
212 pshs u save u
|
|
213 leau hdr,u destination
|
|
214 ldd <datimg proc datimg pointer
|
0
|
215 ldy #10 set length
|
|
216 os9 F$CpyMem
|
|
217 lbcs Error
|
|
218
|
|
219 * Read name from Module to buffer
|
1601
|
220 ldd M$Name,u get name offset from header
|
|
221 ldu <lineptr move name to outbuf
|
|
222 leax d,x X - offset to name
|
|
223 ldd <datimg
|
|
224 ldy #Maxnam set maximum length
|
0
|
225 os9 F$CpyMem
|
1601
|
226 puls u
|
0
|
227 lbcs Error
|
|
228
|
1601
|
229 Name2 pshs x
|
|
230 ldx <lineptr
|
0
|
231 clrb set length = 0
|
|
232 Name3 incb
|
1601
|
233 lda ,x+
|
0
|
234 bpl Name3
|
|
235 cmpb #40
|
|
236 bcc Name5
|
|
237 anda #$7F clear d7
|
1601
|
238 sta -1,x
|
0
|
239 cmpb #9
|
|
240 bcc Name5
|
|
241 lda #C$SPAC
|
1601
|
242 Name4 sta ,x+
|
0
|
243 incb
|
|
244 cmpb #9
|
|
245 bcs Name4
|
1601
|
246 Name5 stx <lineptr
|
|
247 puls x,pc
|
0
|
248
|
|
249 * Print hex digit in A
|
|
250 Out2HS bsr Hexl
|
|
251
|
|
252 Space lda #C$SPAC
|
|
253 bra Print
|
|
254
|
|
255
|
|
256 * Print Hexidecimal Digit in A
|
1601
|
257 Hexl tfr a,b
|
0
|
258 lsra
|
|
259 lsra
|
|
260 lsra
|
|
261 lsra
|
|
262 bsr Outhex
|
1601
|
263 tfr b,a
|
0
|
264 Outhex anda #$0F
|
|
265 cmpa #$0A 0 - 9
|
|
266 bcs Outdig
|
|
267 adda #$07 A - F
|
|
268 Outdig adda #'0 make ASCII
|
|
269
|
|
270 * Put character in A in buf
|
1601
|
271 Print pshs x
|
|
272 ldx <lineptr
|
|
273 sta ,x+
|
|
274 stx <lineptr
|
|
275 puls x,pc
|
0
|
276
|
|
277 * Print 1 Decimal Digit in A
|
|
278 *
|
1601
|
279 Outdecl tfr a,b number to B
|
0
|
280 clra
|
|
281
|
|
282 * Print 2 Decimal Digits in D
|
1601
|
283 Outdec clr <leadflag
|
|
284 pshs x
|
|
285 ldx <umem
|
|
286 leax number,x
|
|
287 clr ,x
|
|
288 clr 1,x
|
|
289 clr 2,x
|
|
290 Hundred inc ,x
|
0
|
291 subd #100
|
|
292 bcc Hundred
|
|
293 addd #100
|
1601
|
294 Ten inc 1,x
|
0
|
295 subd #10
|
|
296 bcc Ten
|
|
297 addd #10
|
|
298 incb
|
1601
|
299 stb 2,x
|
0
|
300 bsr Printled
|
|
301 bsr Printled
|
|
302 bsr Printnum
|
|
303 bsr Space
|
1601
|
304 puls x,pc
|
0
|
305
|
1601
|
306 Printnum lda ,x+ get char
|
0
|
307 adda #'0-1 make ASCII
|
|
308 bra Print
|
|
309
|
1601
|
310 Printled tst <leadflag print leading zero?
|
0
|
311 bne Printnum yes
|
1601
|
312 ldb ,x is it zero?
|
|
313 inc <leadflag
|
0
|
314 decb
|
|
315 bne Printnum no, print zeros
|
1601
|
316 clr <leadflag
|
0
|
317 lda #C$SPAC
|
1601
|
318 leax 1,x
|
0
|
319 bra Print
|
|
320
|
|
321 emod
|
1601
|
322 PrgSiz equ *
|
0
|
323 end
|