Subversion Repositories Kolibri OS

Rev

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