Subversion Repositories Kolibri OS

Rev

Rev 135 | Rev 447 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
31 halyavin 1
;
2
;   DEBUG BOARD for APPLICATIONS and KERNEL DEVELOPMENT
3
;
4
;   See f63
5
;
6
;   Compile with FASM for Menuet
7
;
131 diamond 8
LMARGIN equ (15+5)
9
TMARGIN equ (35+5)
10
HSPACE  equ 16
11
VSPACE  equ 12
12
IPC_BUF equ 160
13
DR_GRID equ 0;1
31 halyavin 14
 
131 diamond 15
FL_KRNL equ 1
16
 
31 halyavin 17
include 'lang.inc'
18
 
19
   use32
20
   org    0x0
21
   db     'MENUET01'              ; 8 byte id
22
   dd     0x01                    ; header version
23
   dd     START                   ; start of code
24
   dd     I_END                   ; size of image
131 diamond 25
   dd     i_end+0x2000                  ; memory for app (4 Kb)
26
   dd     i_end+0x2000                  ; esp
31 halyavin 27
   dd     0x0 , 0x0               ; I_Param , I_Icon
131 diamond 28
include 'MACROS.INC'
29
include 'debug.inc'
30
purge newline
31 halyavin 31
MAXSTRINGS = 16
131 diamond 32
TMP = 80*(MAXSTRINGS+1)
31 halyavin 33
 
34
START:                          ; start of execution
35
 
131 diamond 36
     mcall 60,1,ipcbuff,IPC_BUF+20
37
     mcall 40,1000111b
38
     mov  [ipcbuff+4],8
31 halyavin 39
     mov  ecx,1024
40
    flush:
41
     mov  eax,63
42
     mov  ebx,2
43
     int  0x40
44
     loop flush
45
 
131 diamond 46
     mov  ecx, TMP
31 halyavin 47
     xor  eax, eax
131 diamond 48
     mov  edi, [targ]
31 halyavin 49
     rep  stosb
50
 
131 diamond 51
     mov  [tmp1],'x'
52
     mov  [tmp2],'x'
31 halyavin 53
 
54
     mov  eax,14
55
     int  0x40
56
     and  eax,0xffff0000
131 diamond 57
     sub  eax,399 shl 16
58
     add  eax,399
31 halyavin 59
     mov  [xstart],eax
131 diamond 60
  red:
31 halyavin 61
     call draw_window
62
 
63
still:
64
 
65
    mov  eax,23                 ; wait here for event
66
    mov  ebx,1
67
    int  0x40
68
 
69
    cmp  eax,1                  ; redraw request ?
70
    je   red
71
    cmp  eax,2                  ; key in buffer ?
72
    je   key
73
    cmp  eax,3                  ; button in buffer ?
74
    je   button
131 diamond 75
    cmp  eax,7
76
    je   ipc
31 halyavin 77
    mov  eax,63
78
    mov  ebx,2
79
    int  0x40
80
 
81
    cmp  ebx,1
82
    jne  still
131 diamond 83
 
31 halyavin 84
  new_data:
131 diamond 85
    mov  ebp,[targ]
86
  .no4:
31 halyavin 87
    cmp  al,13
88
    jne  no13
131 diamond 89
    and  dword[ebp-8],0
31 halyavin 90
    jmp  new_check
91
   no13:
92
    cmp  al,10
93
    jne  no10
131 diamond 94
    inc  dword[ebp-4]
95
    cmp  dword[ebp-4],MAXSTRINGS
96
    jbe  .noypos
97
    mov  dword[ebp-4],MAXSTRINGS
98
    lea  esi,[ebp+80]
99
    mov  edi,ebp
31 halyavin 100
    mov  ecx,80*(MAXSTRINGS)
101
    cld
102
    rep  movsb
103
 
131 diamond 104
    mov  esi,[ebp-4]
31 halyavin 105
    imul esi,80
131 diamond 106
    add  esi,[ebp-8]
107
    add  esi,ebp
31 halyavin 108
    mov  ecx,80
109
    xor  al,al
110
    rep  stosb
131 diamond 111
  .noypos:
112
    mov  [targ],text2
113
    and  [krnl_cnt],0
31 halyavin 114
    jmp  new_check
115
  no10:
131 diamond 116
    cmp  ebp,text1
117
    je   add2
118
  		mov  ecx,[krnl_cnt]
119
		  cmp  al,[krnl_msg+ecx]
120
  		jne  .noknl
121
		  inc  [krnl_cnt]
122
  		cmp  [krnl_cnt],4
123
  		jne  new_check
124
    mov  [targ],text1
125
  	.noknl:
126
    mov  ebp,[targ]
127
	   jecxz .add
128
    push eax
129
    mov  esi,krnl_msg
130
   .l1:
131
    lodsb
132
    call add_char
133
    loop .l1
134
    pop  eax
135
   .add:
136
    and  [krnl_cnt],0
137
  add2:
138
    call add_char
31 halyavin 139
 
140
  new_check:
141
 
142
    mov  eax,63
143
    mov  ebx,2
144
    int  0x40
145
 
146
    cmp  ebx,1
147
    je   new_data
148
 
131 diamond 149
    cmp  [vmode],2
150
    je   still
31 halyavin 151
    call draw_window
152
 
153
    jmp  still
154
 
131 diamond 155
  ipc:
156
    mov  [vmode],2
157
    mov  eax,ipcbuff
158
    mov  esi,[eax+8]
159
    mov  byte[eax],1
160
    push dword[eax+12]
161
    pop  [dump_len]
162
    mcall 9,work,-1
163
    mov  ecx,eax
164
   .lp:
165
    mcall 9
166
    cmp  [ebx+30],esi
167
    je   .ok
168
    loop .lp
169
    and  [dump_len],0
170
    jmp  red
171
  .ok:
172
    mov  [pid],esi
173
    lea  esi,[ebx+10]
174
    mov  edi,dump_title+10
175
    mov  ecx,12
176
    rep  movsb
177
    jmp  red
31 halyavin 178
  key:                          ; key
179
    mov  eax,2                  ; just read it and ignore
180
    int  0x40
131 diamond 181
    cmp  ah,' '
182
    je   button.no_krnl_flt
183
    cmp  [vmode],2
184
    jne  still
185
    cmp  ah,176 ;left
186
    jb   still
187
    cmp  ah,179 ;right
188
    ja  still
189
    mov  ecx,[offs]
190
    shr  eax,8
191
    sub  eax,176
192
    add  ecx,[arrows+eax*4]
193
    shl  ecx,12
194
    shr  cx,12
195
    jmp  button.check_sel
196
  .nol:
31 halyavin 197
    jmp  still
198
 
131 diamond 199
arrows dd -1,16,-16,1
200
 
31 halyavin 201
  button:                       ; button
202
    mov  eax,17                 ; get id
203
    int  0x40
204
 
205
    cmp  ah,1                   ; button id=1 ?
131 diamond 206
    jne  .noclose
31 halyavin 207
 
208
    mov  eax,-1                 ; close this program
209
    int  0x40
131 diamond 210
  .noclose:
211
   	shr  eax,8
212
  		cmp  eax,10
213
  		jb   .nodump
214
		  lea  edi,[eax-10]
215
  		mcall 37,1
216
		  sub  eax,[edi*4+dump_cell_marg]
217
  		sub  eax,TMARGIN+VSPACE
218
  		push eax
219
    and  eax,0xffff
220
		  xor  edx,edx
221
  		div  word[edi*4+dump_cell_size+2]
222
		  mov  ecx,eax
223
    shl  ecx,16
224
  		xor  edx,edx
225
		  pop  eax
226
  		shr  eax,16
227
  		div  word[edi*4+dump_cell_size]
228
  		mov  cx,ax
229
  .check_sel:
230
  		mov  eax,ecx
231
    shl  ax,12
232
    shr  eax,12
233
    inc  eax
234
    cmp  eax,[dump_len]
235
    ja   still;.nosel
236
    mov  dword[sel_byte],ecx
237
    dec  eax
238
    mov  [offs],eax
239
    jmp  red
31 halyavin 240
 
131 diamond 241
  .nodump:
242
    cmp  eax,2
243
    jne  .no_krnl_flt
244
    xor  [flag],FL_KRNL
31 halyavin 245
    jmp  still
131 diamond 246
  .no_krnl_flt:
247
    mov  [ipcbuff+4],8
248
    and  byte[ipcbuff],0
249
    inc  [vmode]
250
    cmp  [vmode],3
251
    jb   .vmok
252
    and  [vmode],0
253
  .vmok:
254
    jmp  red
31 halyavin 255
 
131 diamond 256
add_char:
257
    push esi
258
    mov  esi,[ebp-4]
259
    imul esi,80
260
    add  esi,[ebp-8]
261
    mov  [ebp+esi],al
262
    inc  dword[ebp-8]
263
    cmp  dword[ebp-8],80
264
    jb   .ok
265
    mov  dword[ebp-8],79
266
  .ok:
267
    pop  esi
268
    ret
31 halyavin 269
 
270
;   *********************************************
271
;   *******  WINDOW DEFINITIONS AND DRAW ********
272
;   *********************************************
273
 
274
 
275
draw_window:
276
 
277
    mov  eax,48
278
    mov  ebx,3
279
    mov  ecx,sc
280
    mov  edx,sizeof.system_colors
281
    int  0x40
282
 
283
    mov  eax,12                    ; function 12:tell os about windowdraw
284
    mov  ebx,1                     ; 1, start of draw
285
    int  0x40
286
 
287
                                   ; DRAW WINDOW
288
    mov  eax,0                     ; function 0 : define and draw window
289
;   mov  ebx,50*65536+400          ; [x start] *65536 + [x size]
290
    mov  ebx,[xstart]
131 diamond 291
    mov  ecx,MAXSTRINGS*10+45      ; [y start] *65536 + [y size]
31 halyavin 292
    mov  edx,[sc.work]             ; color of work area RRGGBB,8->color gl
205 heavyiron 293
    or   edx,0x13000000
294
    mov  edi,header                ; WINDOW LABEL
31 halyavin 295
    int  0x40
205 heavyiron 296
 
131 diamond 297
    mov  ecx,4
298
    mov  esi,[sc.work]
299
    mov  ebx,316 shl 16+5*6
300
    mov  edx,3;+1 shl 30
301
    mcall 8,,<5,12>
302
    mov  edx,[vmode]
303
    lea  edx,[edx*4+duk]
304
    mcall 4,<320,8>,,,4
305
 
306
    cmp  [vmode],2
307
    je   no_mdbg
31 halyavin 308
    mov  ebx,15*65536+33           ; draw info text with function 4
309
    mov  ecx,[sc.work_text]
131 diamond 310
    mov  edx,text1
311
    cmp  [vmode],0
312
    je   .kern
313
    mov  edx,text2
314
  .kern:
31 halyavin 315
    mov  esi,80
316
  newline:
317
    mov  eax,4
318
    int  0x40
319
    add  ebx,10
320
    add  edx,80
321
    cmp  [edx],byte 'x'
322
    jne  newline
131 diamond 323
    jmp  enddraw
324
  no_mdbg:
325
  if DUMP_TEST eq 1
326
    mov  esi,0
327
    mov  [dump_len],100;IPC_BUF
328
  else
329
    mov  esi,ipcbuff+16
330
  end if
331
    mov  ecx,[dump_len]
332
    call dump_btn
333
  		call draw_dump
334
		enddraw:
31 halyavin 335
    mov  eax,12                    ; function 12:tell os about windowdraw
336
    mov  ebx,2                     ; 2, end of draw
337
    int  0x40
338
 
339
    ret
340
 
131 diamond 341
if DR_GRID eq 1
342
draw_grid:
343
  mov  ecx,11
344
  mov  edi,(TMARGIN+VSPACE)shl 16+TMARGIN+VSPACE
345
 .l1:
346
  push ecx
347
  mov  ebx,LMARGIN shl 16+LMARGIN+16*HSPACE
348
  mcall 38,,edi,0
349
  add  edi,VSPACE shl 16+VSPACE
350
  pop  ecx
351
  loop .l1
352
  mov  ecx,17
353
  mov  edi,(TMARGIN+VSPACE)shl 16+TMARGIN+VSPACE*10
354
  mov  ebx,LMARGIN shl 16+LMARGIN
355
 .l2:
356
  push ecx
357
  mcall 38,,edi,0
358
  add  ebx,HSPACE shl 16+HSPACE
359
  pop  ecx
360
  loop .l2
361
  ret
362
end if
31 halyavin 363
 
131 diamond 364
draw_numbers:
365
  mcall 4,(LMARGIN+2) shl 16+180,0,numb,numb_len-numb
366
  mov  eax,dword[sel_byte]
367
  shl  ax,12
368
  shr  eax,12
369
  mov  edi,eax
370
if ~ DUMP_TEST eq 1
371
  add  edi,ipcbuff+16
372
end if
373
  mov  edx,(LMARGIN+2+6*6)shl 16+180
374
  mov  ebx,0x30000
375
  movzx ecx,byte[edi]
376
  mcall 47,,,,0x4e00e7
377
  add  ebx,0x20000
378
  add  edx,(6*10)shl 16
379
  movzx ecx,word[edi]
380
  mcall
381
  add  ebx,0x50000
382
  add  edx,(6*13)shl 16
383
  mov  ecx,[edi]
384
  mcall
385
  mov  ebx,0x80100
386
  add  edx,(6*19)shl 16
387
  mcall
388
.ex:
389
  ret
390
 
391
draw_dump:
392
; esi - data ptr, ecx - length
393
  jecxz draw_numbers.ex
394
  pusha
395
  call draw_numbers
396
  mcall 4,(LMARGIN+2) shl 16+27,0,dump_title,dump_t_len-dump_title
397
  mcall 47,0x30101,ipcbuff+8,(LMARGIN+2+6*29)shl 16+27
398
  add   edx,(6*27) shl 16
399
  mov   ecx,offs
400
  mcall
401
  sub   edx,(5*6)shl 16
402
  mcall ,0x30001
403
  mov  ecx,16
404
  mov  edi,HSPACE shl 16
405
  mov  ebx,(LMARGIN+5)shl 16+42
406
  call draw_marks
407
  mov  ecx,[esp+24]
408
  dec  ecx
409
  shr  ecx,4
410
  inc  ecx
411
  mov  ebx,(LMARGIN-10)shl 16+TMARGIN+2+VSPACE
412
  mov  edi,VSPACE
413
  call draw_marks
414
  popa
415
		mov  edx,TMARGIN+2
416
		mov  edi,ecx
417
	.lp:
418
		add  edx,(LMARGIN+2) shl 16+VSPACE
419
		mov  ecx,16
420
		cmp  edi,ecx
421
		jae  .less
422
		mov  ecx,edi
423
	.less:
424
		sub  edi,ecx
425
		push esi ecx
426
		mov  ebx,0x20100
427
	.lp1:
428
		push ecx esi
429
		movzx ecx,byte[esi]
430
		mcall 47,,,,0
431
		add  edx,HSPACE shl 16
432
		pop  esi ecx
433
		inc  esi
434
		loop .lp1
435
		pusha
436
		mov  ebx,edx
437
		and  ebx,0xffff
438
		add  ebx,(LMARGIN+16*HSPACE+15)shl 16
439
		mov  edx,[esp+36]
440
		mov  esi,[esp+32]
441
		mcall 4,,0
442
		popa
443
		add  esp,8
444
		and  edx,0xffff
445
		test edi,edi
446
		jnz  .lp
447
.ex:
448
		ret
449
 
450
draw_marks:
451
; ebx -xy, edi-addition, ecx -cycles
452
		pusha
453
  mov  edx,__hexdigits
454
  mov  eax,4
455
  mov  esi,1
456
.tt:
457
  push ecx
458
  mcall ,,0xffffff
459
  add  ebx,edi
460
  inc  edx
461
  pop  ecx
462
  loop .tt
463
  popa
464
  ret
465
 
466
dump_btn: ; ecx-length
467
  jecxz draw_dump.ex
468
		pusha
469
		test ecx,0xffff
470
		je   .even
471
		add  ecx,16
472
	.even:
473
		shr  ecx,4
474
		imul ecx,VSPACE
475
		add  ecx,(TMARGIN+VSPACE)shl 16-5
476
		mcall 8,LMARGIN shl 16+16*HSPACE-5,,10+3 shl 29,[sc.work]
477
		inc  edx
478
		mcall ,(LMARGIN+16*HSPACE+15)shl 16+6*16
479
		mov  edx,0xff0000
480
		mov  esi,dump_cell_size
481
		xor  eax,eax
482
		movzx ebx,[sel_byte]
483
		lodsw
484
		imul bx,ax
485
		shl  ebx,16
486
		lea  ebx,[ebx+eax+LMARGIN shl 16]
487
		movzx ecx,[sel_byte+2]
488
		lodsw
489
		imul cx,ax
490
		shl  ecx,16
491
		lea  ecx,[ecx+eax+(TMARGIN+VSPACE) shl 16]
492
		mcall 13
493
		movzx ebx,[sel_byte]
494
		lodsw
495
		imul bx,ax
496
		shl  ebx,16
497
		lea  ebx,[ebx+eax+(LMARGIN+16*HSPACE+15)shl 16]
498
  mcall 13
499
		popa
500
.ex:
501
		ret
502
 
503
krnl_msg db 'K : '
504
duk db 'KernUserDump'
505
numb db 'Byte:     Word:       Dword:               Hex:'
506
numb_len:
507
dump_title db 'Dump from              (pid=    h)         Offset:     (   h)'
508
dump_t_len:
509
 
31 halyavin 510
; DATA AREA
511
 
131 diamond 512
dump_cell_marg dd LMARGIN shl 16,(LMARGIN+16*HSPACE+15)shl 16
513
dump_cell_size dw HSPACE,VSPACE,6,VSPACE
514
; 11,11 > 0,-1
515
; 5,11  > 0,-1
31 halyavin 516
if lang eq ru
205 heavyiron 517
   header    db   '   ',0
135 diamond 518
else if lang eq en
205 heavyiron 519
   header    db   'GENERAL DEBUG & MESSAGE BOARD',0
135 diamond 520
else
205 heavyiron 521
   header    db   'ALLGEMEINES DEBUG- & NACHRICHTENBOARD',0
31 halyavin 522
end if
205 heavyiron 523
   krnl_cnt dd 0
131 diamond 524
   vmode dd 0
525
   targ  dd text2
31 halyavin 526
I_END:
131 diamond 527
     offs dd ?
528
     flag rb 1
529
     ipcbuff rb IPC_BUF+20
530
     rd 2
531
;     x1pos  dd ?
532
;     y1pos  dd ?
533
     text1 rb 80*(MAXSTRINGS+1)
534
     tmp1  db ?
535
     rd 2
536
;     x2pos  dd ?
537
;     y2pos  dd ?
538
     text2 rb 80*(MAXSTRINGS+1)
539
     tmp2  db ?
540
     work rb 4096
541
     sel_byte  dw ?,?
542
     pid  dd ?
31 halyavin 543
     xstart dd ?
131 diamond 544
     dump_len dd ?
545
     sc system_colors
546
i_end: