Subversion Repositories Kolibri OS

Rev

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