Subversion Repositories Kolibri OS

Rev

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