Subversion Repositories Kolibri OS

Rev

Rev 109 | Rev 205 | 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
293
    or   edx,0x03000000
294
    int  0x40
295
 
296
                                   ; WINDOW LABEL
297
    mov  eax,4                     ; function 4 : write text to window
298
    mov  ebx,8*65536+8             ; [x start] *65536 + [y start]
299
    mov  ecx,[sc.grab_text]        ; color of text RRGGBB
300
    or   ecx,0x10000000
301
    mov  edx,header                ; pointer to text beginning
302
    mov  esi,header.len            ; text length
303
    int  0x40
304
 
131 diamond 305
    mov  ecx,4
306
    mov  esi,[sc.work]
307
    mov  ebx,316 shl 16+5*6
308
    mov  edx,3;+1 shl 30
309
    mcall 8,,<5,12>
310
    mov  edx,[vmode]
311
    lea  edx,[edx*4+duk]
312
    mcall 4,<320,8>,,,4
313
 
314
    cmp  [vmode],2
315
    je   no_mdbg
31 halyavin 316
    mov  ebx,15*65536+33           ; draw info text with function 4
317
    mov  ecx,[sc.work_text]
131 diamond 318
    mov  edx,text1
319
    cmp  [vmode],0
320
    je   .kern
321
    mov  edx,text2
322
  .kern:
31 halyavin 323
    mov  esi,80
324
  newline:
325
    mov  eax,4
326
    int  0x40
327
    add  ebx,10
328
    add  edx,80
329
    cmp  [edx],byte 'x'
330
    jne  newline
131 diamond 331
    jmp  enddraw
332
  no_mdbg:
333
  if DUMP_TEST eq 1
334
    mov  esi,0
335
    mov  [dump_len],100;IPC_BUF
336
  else
337
    mov  esi,ipcbuff+16
338
  end if
339
    mov  ecx,[dump_len]
340
    call dump_btn
341
  		call draw_dump
342
		enddraw:
31 halyavin 343
    mov  eax,12                    ; function 12:tell os about windowdraw
344
    mov  ebx,2                     ; 2, end of draw
345
    int  0x40
346
 
347
    ret
348
 
131 diamond 349
if DR_GRID eq 1
350
draw_grid:
351
  mov  ecx,11
352
  mov  edi,(TMARGIN+VSPACE)shl 16+TMARGIN+VSPACE
353
 .l1:
354
  push ecx
355
  mov  ebx,LMARGIN shl 16+LMARGIN+16*HSPACE
356
  mcall 38,,edi,0
357
  add  edi,VSPACE shl 16+VSPACE
358
  pop  ecx
359
  loop .l1
360
  mov  ecx,17
361
  mov  edi,(TMARGIN+VSPACE)shl 16+TMARGIN+VSPACE*10
362
  mov  ebx,LMARGIN shl 16+LMARGIN
363
 .l2:
364
  push ecx
365
  mcall 38,,edi,0
366
  add  ebx,HSPACE shl 16+HSPACE
367
  pop  ecx
368
  loop .l2
369
  ret
370
end if
31 halyavin 371
 
131 diamond 372
draw_numbers:
373
  mcall 4,(LMARGIN+2) shl 16+180,0,numb,numb_len-numb
374
  mov  eax,dword[sel_byte]
375
  shl  ax,12
376
  shr  eax,12
377
  mov  edi,eax
378
if ~ DUMP_TEST eq 1
379
  add  edi,ipcbuff+16
380
end if
381
  mov  edx,(LMARGIN+2+6*6)shl 16+180
382
  mov  ebx,0x30000
383
  movzx ecx,byte[edi]
384
  mcall 47,,,,0x4e00e7
385
  add  ebx,0x20000
386
  add  edx,(6*10)shl 16
387
  movzx ecx,word[edi]
388
  mcall
389
  add  ebx,0x50000
390
  add  edx,(6*13)shl 16
391
  mov  ecx,[edi]
392
  mcall
393
  mov  ebx,0x80100
394
  add  edx,(6*19)shl 16
395
  mcall
396
.ex:
397
  ret
398
 
399
draw_dump:
400
; esi - data ptr, ecx - length
401
  jecxz draw_numbers.ex
402
  pusha
403
  call draw_numbers
404
  mcall 4,(LMARGIN+2) shl 16+27,0,dump_title,dump_t_len-dump_title
405
  mcall 47,0x30101,ipcbuff+8,(LMARGIN+2+6*29)shl 16+27
406
  add   edx,(6*27) shl 16
407
  mov   ecx,offs
408
  mcall
409
  sub   edx,(5*6)shl 16
410
  mcall ,0x30001
411
  mov  ecx,16
412
  mov  edi,HSPACE shl 16
413
  mov  ebx,(LMARGIN+5)shl 16+42
414
  call draw_marks
415
  mov  ecx,[esp+24]
416
  dec  ecx
417
  shr  ecx,4
418
  inc  ecx
419
  mov  ebx,(LMARGIN-10)shl 16+TMARGIN+2+VSPACE
420
  mov  edi,VSPACE
421
  call draw_marks
422
  popa
423
		mov  edx,TMARGIN+2
424
		mov  edi,ecx
425
	.lp:
426
		add  edx,(LMARGIN+2) shl 16+VSPACE
427
		mov  ecx,16
428
		cmp  edi,ecx
429
		jae  .less
430
		mov  ecx,edi
431
	.less:
432
		sub  edi,ecx
433
		push esi ecx
434
		mov  ebx,0x20100
435
	.lp1:
436
		push ecx esi
437
		movzx ecx,byte[esi]
438
		mcall 47,,,,0
439
		add  edx,HSPACE shl 16
440
		pop  esi ecx
441
		inc  esi
442
		loop .lp1
443
		pusha
444
		mov  ebx,edx
445
		and  ebx,0xffff
446
		add  ebx,(LMARGIN+16*HSPACE+15)shl 16
447
		mov  edx,[esp+36]
448
		mov  esi,[esp+32]
449
		mcall 4,,0
450
		popa
451
		add  esp,8
452
		and  edx,0xffff
453
		test edi,edi
454
		jnz  .lp
455
.ex:
456
		ret
457
 
458
draw_marks:
459
; ebx -xy, edi-addition, ecx -cycles
460
		pusha
461
  mov  edx,__hexdigits
462
  mov  eax,4
463
  mov  esi,1
464
.tt:
465
  push ecx
466
  mcall ,,0xffffff
467
  add  ebx,edi
468
  inc  edx
469
  pop  ecx
470
  loop .tt
471
  popa
472
  ret
473
 
474
dump_btn: ; ecx-length
475
  jecxz draw_dump.ex
476
		pusha
477
		test ecx,0xffff
478
		je   .even
479
		add  ecx,16
480
	.even:
481
		shr  ecx,4
482
		imul ecx,VSPACE
483
		add  ecx,(TMARGIN+VSPACE)shl 16-5
484
		mcall 8,LMARGIN shl 16+16*HSPACE-5,,10+3 shl 29,[sc.work]
485
		inc  edx
486
		mcall ,(LMARGIN+16*HSPACE+15)shl 16+6*16
487
		mov  edx,0xff0000
488
		mov  esi,dump_cell_size
489
		xor  eax,eax
490
		movzx ebx,[sel_byte]
491
		lodsw
492
		imul bx,ax
493
		shl  ebx,16
494
		lea  ebx,[ebx+eax+LMARGIN shl 16]
495
		movzx ecx,[sel_byte+2]
496
		lodsw
497
		imul cx,ax
498
		shl  ecx,16
499
		lea  ecx,[ecx+eax+(TMARGIN+VSPACE) shl 16]
500
		mcall 13
501
		movzx ebx,[sel_byte]
502
		lodsw
503
		imul bx,ax
504
		shl  ebx,16
505
		lea  ebx,[ebx+eax+(LMARGIN+16*HSPACE+15)shl 16]
506
  mcall 13
507
		popa
508
.ex:
509
		ret
510
 
511
krnl_msg db 'K : '
512
duk db 'KernUserDump'
513
numb db 'Byte:     Word:       Dword:               Hex:'
514
numb_len:
515
dump_title db 'Dump from              (pid=    h)         Offset:     (   h)'
516
dump_t_len:
517
 
31 halyavin 518
; DATA AREA
519
 
131 diamond 520
dump_cell_marg dd LMARGIN shl 16,(LMARGIN+16*HSPACE+15)shl 16
521
dump_cell_size dw HSPACE,VSPACE,6,VSPACE
522
; 11,11 > 0,-1
523
; 5,11  > 0,-1
31 halyavin 524
if lang eq ru
525
   header:
526
        db   '   '
527
    .len = $ - header
528
else
529
   header:
530
        db   'GENERAL DEBUG & MESSAGE BOARD'
531
    .len = $ - header
532
end if
131 diamond 533
		 krnl_cnt dd 0
534
   vmode dd 0
535
   targ  dd text2
31 halyavin 536
I_END:
131 diamond 537
     offs dd ?
538
     flag rb 1
539
     ipcbuff rb IPC_BUF+20
540
     rd 2
541
;     x1pos  dd ?
542
;     y1pos  dd ?
543
     text1 rb 80*(MAXSTRINGS+1)
544
     tmp1  db ?
545
     rd 2
546
;     x2pos  dd ?
547
;     y2pos  dd ?
548
     text2 rb 80*(MAXSTRINGS+1)
549
     tmp2  db ?
550
     work rb 4096
551
     sel_byte  dw ?,?
552
     pid  dd ?
31 halyavin 553
     xstart dd ?
131 diamond 554
     dump_len dd ?
555
     sc system_colors
556
i_end: