Rev 4879 | Rev 5837 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4879 | Rev 4977 | ||
---|---|---|---|
Line 1... | Line -... | ||
1 | ; |
- | |
- | 1 | ;------------------------------------------------------------------------------ |
|
2 | ; DEBUG BOARD for APPLICATIONS and KERNEL DEVELOPMENT |
2 | ; DEBUG BOARD for APPLICATIONS and KERNEL DEVELOPMENT |
3 | ; |
- | |
4 | ; See f63 |
3 | ; See f63 |
5 | ; |
- | |
6 | ; Compile with FASM for KolibriOS |
4 | ; Compile with FASM for KolibriOS |
- | 5 | ;------------------------------------------------------------------------------ |
|
7 | ; |
6 | include 'lang.inc' |
8 | WRITE_LOG equ 1 |
7 | WRITE_LOG equ 1 |
9 | P_LEN equ 11 |
8 | P_LEN equ 11 |
10 | include 'lang.inc' |
9 | ;------------------------------------------------------------------------------ |
11 | - | ||
12 | use32 |
10 | use32 |
13 | org 0x0 |
11 | org 0x0 |
14 | db 'MENUET01' ; 8 byte id |
12 | db 'MENUET01' |
15 | dd 0x01 ; header version |
13 | dd 0x01 |
16 | dd START ; start of code |
14 | dd START |
17 | dd I_END ; size of image |
15 | dd I_END |
18 | dd mem ; memory for app |
16 | dd mem |
19 | dd mem ; esp |
17 | dd mem |
20 | dd filename , 0x0 ; I_Param , I_Icon |
18 | dd filename, 0x0 |
- | 19 | ;------------------------------------------------------------------------------ |
|
21 | include '../../../macros.inc' |
20 | include '../../../macros.inc' |
22 | include '../../../debug.inc' |
21 | include '../../../debug.inc' |
23 | purge newline |
22 | purge newline |
24 | MAXSTRINGS = 16 |
23 | MAXSTRINGS = 16 |
25 | TMP = 80*(MAXSTRINGS+1) |
24 | TMP = 80*(MAXSTRINGS+1) |
26 | ;------------------------------------------------------------------------------ |
25 | ;------------------------------------------------------------------------------ |
27 | START: ; start of execution |
26 | START: |
28 | - | ||
29 | call CheckUnique |
27 | call CheckUnique |
30 | - | ||
31 | mov edi,filename |
28 | mov edi, filename |
32 | cmp [edi],byte 0 |
29 | cmp [edi], byte 0 |
33 | jnz param |
30 | jnz param |
34 | mov esi,default_filename |
31 | mov esi, default_filename |
35 | @@: |
32 | @@: |
36 | lodsb |
33 | lodsb |
37 | stosb |
34 | stosb |
38 | test al,al |
35 | test al,al |
39 | jnz @b |
36 | jnz @b |
40 | param: |
37 | param: |
41 | - | ||
42 | ; allow user to see messages written before start |
- | |
43 | ; mov ecx,4096 |
- | |
44 | ;flush: |
- | |
45 | ; mcall 63,2 |
- | |
46 | ; loop flush |
- | |
47 | - | ||
48 | mov ecx,TMP |
38 | mov ecx, TMP |
49 | xor eax,eax |
39 | xor eax, eax |
50 | mov edi,[targ] |
40 | mov edi, [targ] |
51 | rep stosb |
41 | rep stosb |
Line 56... | Line 46... | ||
56 | mcall 14 |
46 | mcall 14 |
57 | and eax,0xffff0000 |
47 | and eax, 0xffff0000 |
58 | sub eax,399 shl 16 |
48 | sub eax, 399 shl 16 |
59 | add eax,399 |
49 | add eax, 399 |
60 | mov [xstart],eax |
50 | mov [xstart], eax |
61 | mcall 48,3,sc,sizeof.system_colors |
51 | mcall 48, 3, sc, sizeof.sys_colors_new |
Line 62... | Line 52... | ||
62 | 52 | ||
63 | mov esi,filename |
53 | mov esi, filename |
64 | call CreateFile |
54 | call CreateFile |
65 | ;------------------------------------------------------------------------------ |
55 | ;------------------------------------------------------------------------------ |
Line 91... | Line 81... | ||
91 | call write_buffer |
81 | call write_buffer |
92 | @@: |
82 | @@: |
93 | movzx ebx,byte[buffer_length] |
83 | movzx ebx, byte[buffer_length] |
94 | mov [ebx+tmp],al |
84 | mov [ebx+tmp], al |
95 | inc [buffer_length] |
85 | inc [buffer_length] |
96 | - | ||
97 | mov ebp,[targ] |
86 | mov ebp, [targ] |
98 | .no4: |
87 | .no4: |
99 | cmp al,13 |
88 | cmp al, 13 |
100 | jne no13 |
89 | jne no13 |
101 | and [ebp-8],dword 0 |
90 | and [ebp-8], dword 0 |
Line 209... | Line 198... | ||
209 | .ok: |
198 | .ok: |
210 | pop esi |
199 | pop esi |
211 | ret |
200 | ret |
Line 212... | Line 201... | ||
212 | 201 | ||
213 | ;------------------------------------------------------------------------------ |
202 | ;------------------------------------------------------------------------------ |
214 | ; ********************************************* |
203 | ;************************ WINDOW DEFINITIONS AND DRAW ************************ |
215 | ; ******* WINDOW DEFINITIONS AND DRAW ******** |
- | |
216 | ; ********************************************* |
204 | ;------------------------------------------------------------------------------ |
217 | draw_window: |
205 | draw_window: |
218 | mcall 12,1 ; 1, start of draw |
206 | mcall 12, 1 ; 1, start of draw |
219 | mcall 48, 5 ; GetClientTop |
207 | mcall 48, 5 ; GetClientTop |
220 | shr ebx, 16 |
208 | shr ebx, 16 |
221 | mov ecx,ebx |
209 | mov ecx, ebx |
222 | shl ecx,16 |
210 | shl ecx, 16 |
223 | add ecx,MAXSTRINGS*10+45 ; [y start] *65536 + [y size] |
211 | add ecx, MAXSTRINGS*10+45 ; [y start] *65536 + [y size] |
224 | xor eax,eax ; function 0 : define and draw window |
- | |
225 | ; mov edx,[sc.work] ; color of work area RRGGBB,8->color gl |
212 | xor eax, eax ; function 0 : define and draw window |
226 | mov edx,0xffffff |
213 | mov edx, 0xffffff |
227 | or edx,0x14000000 |
214 | or edx, 0x14000000 |
228 | xor esi,esi |
215 | xor esi, esi |
229 | mcall ,[xstart],,,,title |
216 | mcall ,[xstart],,,,title |
230 | mov ebx,296 shl 16+5*6 |
217 | mov ebx, 296 shl 16+31 |
231 | mcall 8,,<5,12>,3,[sc.work] |
218 | mcall 8,,<4,13>,3,[sc.btn_face] |
232 | mov edx,[vmode] |
219 | mov edx, [vmode] |
233 | lea edx,[edx*4+duk] |
220 | lea edx, [edx*4+duk] |
234 | mcall 4,<300,8>,,,4 |
221 | mcall 4,<300,7>,,,4 |
235 | call draw_text |
222 | call draw_text |
236 | mcall 12,2 ; 2, end of draw |
223 | mcall 12, 2 ; 2, end of draw |
237 | ret |
224 | ret |
238 | ;------------------------------------------------------------------------------ |
225 | ;------------------------------------------------------------------------------ |
239 | draw_text: |
226 | draw_text: |
240 | mov ebx,15*65536+30 ; draw info text with function 4 |
- | |
241 | ; mov ecx,[sc.work_text] |
227 | mov ebx, 15*65536+30 ; draw info text with function 4 |
242 | xor ecx,ecx |
228 | xor ecx, ecx |
243 | or ecx,0x40000000 |
- | |
244 | ; mov edi,[sc.work] |
229 | or ecx, 0x40000000 |
245 | mov edi,0xffffff |
230 | mov edi, 0xffffff |
246 | mov edx,text1 |
231 | mov edx, text1 |
247 | cmp [vmode],0 |
232 | cmp [vmode], 0 |
248 | je .kern |
233 | je .kern |
Line 271... | Line 256... | ||
271 | add ebx,10 |
256 | add ebx, 10 |
272 | add edx,80 |
257 | add edx, 80 |
273 | cmp [edx],byte 'x' |
258 | cmp [edx], byte 'x' |
274 | jne newline |
259 | jne newline |
275 | ret |
260 | ret |
- | 261 | ||
276 | ;------------------------------------------------------------------------------ |
262 | ;------------------------------------------------------------------------------ |
277 | ;******************************************** |
- | |
278 | ;* input: esi = pointer to the file name * |
263 | ;* input: esi = pointer to the file name * |
279 | ;******************************************** |
264 | ;------------------------------------------------------------------------------ |
280 | - | ||
281 | CreateFile: |
265 | CreateFile: |
282 | pusha |
266 | pusha |
283 | mov dword [InfoStructure],2 ; create file |
267 | mov dword [InfoStructure+00], 2 ; create file |
284 | mov dword [InfoStructure+4],0 ; reserved |
268 | mov dword [InfoStructure+04], 0 ; reserved |
285 | mov dword [InfoStructure+8],0 ; reserved |
269 | mov dword [InfoStructure+08], 0 ; reserved |
286 | mov dword [InfoStructure+12],0 ; 0 bytes to write (just create) |
270 | mov dword [InfoStructure+12], 0 ; 0 bytes to write (just create) |
287 | mov dword [InfoStructure+16],0 ; NULL data pointer (no data) |
271 | mov dword [InfoStructure+16], 0 ; NULL data pointer (no data) |
288 | mov dword [InfoStructure+20],0 ; reserved |
272 | mov dword [InfoStructure+20], 0 ; reserved |
289 | mov dword [InfoStructure+21],esi ; pointer to the file name |
273 | mov dword [InfoStructure+21], esi ; pointer to the file name |
290 | mcall 70, InfoStructure |
274 | mcall 70, InfoStructure |
Line 292... | Line 276... | ||
292 | jz .out |
276 | jz .out |
293 | stc |
277 | stc |
294 | .out: |
278 | .out: |
295 | popa |
279 | popa |
296 | ret |
280 | ret |
297 | ;------------------------------------------------ |
281 | ;------------------------------------------------------------------------------ |
298 | ;******************************************** |
- | |
299 | ;* input: esi = pointer to the file name * |
282 | ;* input: esi = pointer to the file name * |
300 | ;* edx = pointer to data buffer * |
283 | ;* edx = pointer to data buffer * |
301 | ;* ecx = data length * |
284 | ;* ecx = data length * |
302 | ;******************************************** |
285 | ;------------------------------------------------------------------------------ |
303 | - | ||
304 | WriteToFile: |
286 | WriteToFile: |
305 | push ebx |
287 | push ebx |
306 | mov dword [InfoStructure],3 ; write to file |
288 | mov dword [InfoStructure+00], 3 ; write to file |
307 | mov eax, [filepos] |
289 | mov eax, [filepos] |
308 | mov dword [InfoStructure+4],eax ; lower position addr |
290 | mov dword [InfoStructure+04], eax ; lower position addr |
309 | mov dword [InfoStructure+8],0 ; upper position addr (0 for FAT) |
291 | mov dword [InfoStructure+08], 0 ; upper position addr (0 for FAT) |
310 | mov dword [InfoStructure+12],ecx ; number of bytes to write |
292 | mov dword [InfoStructure+12], ecx ; number of bytes to write |
311 | mov dword [InfoStructure+16],edx ; pointer to data buffer |
293 | mov dword [InfoStructure+16], edx ; pointer to data buffer |
312 | mov dword [InfoStructure+20],0 ; reserved |
294 | mov dword [InfoStructure+20], 0 ; reserved |
313 | mov dword [InfoStructure+21],esi ; pointer to the file name |
295 | mov dword [InfoStructure+21], esi ; pointer to the file name |
314 | mcall 70, InfoStructure |
296 | mcall 70, InfoStructure |
Line 318... | Line 300... | ||
318 | stc |
300 | stc |
319 | .out: |
301 | .out: |
320 | pop ebx |
302 | pop ebx |
321 | ret |
303 | ret |
Line 322... | Line 304... | ||
322 | 304 | ||
323 | ;------------------------------------------------- |
- | |
324 | ;******************************************** |
305 | ;------------------------------------------------------------------------------ |
325 | ;* input: esi = pointer to string * |
306 | ;* input: esi = pointer to string * |
326 | ;* edi = pointer to string * |
307 | ;* edi = pointer to string * |
327 | ;* ecx = data length * |
308 | ;* ecx = data length * |
328 | ;******************************************** |
309 | ;------------------------------------------------------------------------------ |
329 | StrCmp: |
310 | StrCmp: |
330 | repe cmpsb |
311 | repe cmpsb |
331 | ja .a_greater_b |
312 | ja .a_greater_b |
332 | jb .a_less_b |
313 | jb .a_less_b |
Line 339... | Line 320... | ||
339 | .a_greater_b: |
320 | .a_greater_b: |
340 | mov eax, -1 |
321 | mov eax, -1 |
341 | .end: |
322 | .end: |
342 | ret |
323 | ret |
Line 343... | Line 324... | ||
343 | 324 | ||
344 | ;------------------------------------------------- |
- | |
345 | ;******************************************** |
325 | ;------------------------------------------------------------------------------ |
346 | ;* input: edi = pointer to string * |
326 | ;* input: edi = pointer to string * |
347 | ;* ecx = data length * |
327 | ;* ecx = data length * |
348 | ;******************************************** |
328 | ;------------------------------------------------------------------------------ |
349 | ; 'a' - 'A' = 32 -> 'A'|32 = 'a' |
329 | ; 'a' - 'A' = 32 -> 'A'|32 = 'a' |
350 | ToLower: |
330 | ToLower: |
351 | xor eax, eax |
331 | xor eax, eax |
352 | .cycle: |
332 | .cycle: |
353 | or byte[edi+eax], 32 |
333 | or byte[edi+eax], 32 |
354 | inc eax |
334 | inc eax |
355 | loop .cycle |
335 | loop .cycle |
356 | .end: |
336 | .end: |
Line 357... | Line -... | ||
357 | ret |
- | |
358 | 337 | ret |
|
- | 338 | ||
- | 339 | ;------------------------------------------------------------------------------ |
|
- | 340 | ;* get info on current thread, save pid/tid |
|
- | 341 | ;* look for another process with same name and different pid/tid |
|
- | 342 | ;* if found, close self |
|
359 | 343 | ;* else continue normally |
|
360 | ;------------------------------------------------- |
- | |
361 | CheckUnique: |
- | |
362 | ;get info on current thread, save pid/tid |
- | |
363 | ;look for another process with same name and different pid/tid |
- | |
364 | ;if found, close self |
- | |
365 | ;else continue normally |
344 | ;------------------------------------------------------------------------------ |
366 | 345 | CheckUnique: |
|
367 | .get_thread_info: |
346 | .get_thread_info: |
368 | mov ebx, procinfo |
347 | mov ebx, procinfo |
369 | mov ecx, -1 |
348 | mov ecx, -1 |
370 | mcall 9 |
349 | mcall 9 |
371 | .get_pid: |
350 | |
372 | ; check_buffer |
351 | .get_pid: ; check_buffer |
373 | mov [process_count], eax |
352 | mov [process_count], eax |
374 | mov eax, [ebx+process_information.PID] |
353 | mov eax, [ebx+process_information.PID] |
Line 392... | Line 371... | ||
392 | 371 | ||
393 | .get_proc_name: |
372 | .get_proc_name: |
394 | lea edi, [ebx+process_information.process_name] |
373 | lea edi, [ebx+process_information.process_name] |
395 | push ecx |
374 | push ecx |
- | 375 | mov ecx, my_name_size-1 |
|
396 | mov ecx, my_name_size-1 |
376 | |
397 | .lower_case: |
377 | .lower_case: |
398 | call ToLower |
378 | call ToLower |
399 | lea esi, [my_name] |
- | |
400 | 379 | lea esi, [my_name] |
|
401 | mov ecx, my_name_size |
380 | mov ecx, my_name_size |
402 | call StrCmp |
- | |
403 | 381 | call StrCmp |
|
404 | pop ecx |
- | |
405 | 382 | pop ecx |
|
406 | cmp eax, 0 |
383 | cmp eax, 0 |
Line 407... | Line 384... | ||
407 | je .close_program |
384 | je .close_program |
408 | 385 | ||
409 | .next_thread: |
386 | .next_thread: |
Line 410... | Line 387... | ||
410 | inc ecx |
387 | inc ecx |
411 | jmp .check_threads |
388 | jmp .check_threads |
- | 389 | ||
412 | 390 | .close_program: |
|
413 | .close_program: |
391 | ; restore and active window of previous thread |
Line 414... | Line 392... | ||
414 | mcall 18,3 ; restore and active window of previous thread |
392 | mcall 18, 3 |
415 | mov eax, -1 |
393 | mov eax, -1 |
Line 416... | Line -... | ||
416 | mcall |
- | |
- | 394 | mcall |
|
- | 395 | ||
417 | 396 | .leave_check: |
|
- | 397 | ret |
|
418 | .leave_check: |
398 | |
419 | ret |
399 | |
420 | 400 | ;------------------------------------------------------------------------------ |
|
421 | 401 | ;*********************************** DATA ************************************ |
|
422 | 402 | ;------------------------------------------------------------------------------ |
|
423 | ;-------------------------------------------------- |
403 | align 4 |
424 | InfoStructure: |
404 | InfoStructure: |
425 | dd 0x0 ; subfunction number |
405 | dd 0x0 ; subfunction number |
426 | dd 0x0 ; position in the file in bytes |
- | |
427 | dd 0x0 ; upper part of the position address |
406 | dd 0x0 ; position in the file in bytes |
428 | dd 0x0 ; number of bytes to read |
407 | dd 0x0 ; upper part of the position address |
429 | dd 0x0 ; pointer to the buffer to write data |
408 | dd 0x0 ; number of bytes to read |
430 | db 0 |
- | |
431 | dd 0 ; pointer to the filename |
- | |
432 | - | ||
433 | filepos dd 0 |
- | |
434 | default_filename db '/sys/boardlog.txt',0 |
- | |
435 | ;------------------------------------------------------------------------------ |
- | |
436 | krnl_msg db 'K : ' |
- | |
437 | duk db 'KernUser' |
409 | dd 0x0 ; pointer to the buffer to write data |
438 | 410 | db 0x0 |
|
439 | ; DATA AREA |
411 | dd 0x0 ; pointer to the filename |
440 | 412 | filepos dd 0x0 |
|
441 | ; 11,11 > 0,-1 |
413 | default_filename db '/sys/boardlog.txt',0 |
442 | ; 5,11 > 0,-1 |
414 | ;------------------------------------------------------------------------------ |
443 | if lang eq ru |
415 | if lang eq ru |
444 | title db '®áª ®â« ¤ª¨ ¨ á®®¡é¥¨©',0 |
416 | title db '®áª ®â« ¤ª¨ ¨ á®®¡é¥¨©',0 |
445 | else if lang eq it |
417 | else if lang eq it |
- | 418 | title db 'Notifiche e informazioni generiche per il debug',0 |
|
- | 419 | else if lang eq ge |
|
- | 420 | title db 'Allgemeines debug- & nachrichtenboard',0 |
|
446 | title db 'Notifiche e informazioni generiche per il debug',0 |
421 | else |
447 | else if lang eq ge |
422 | title db 'General debug & message board',0 |
448 | title db 'Allgemeines debug- & nachrichtenboard',0 |
423 | end if |
449 | else |
- | |
450 | title db 'General debug & message board',0 |
424 | ;------------------------------------------------------------------------------ |
451 | end if |
425 | krnl_msg db 'K : ' |
452 | krnl_cnt dd 0 |
426 | duk db 'KernUser' |
453 | vmode dd 1 |
427 | krnl_cnt dd 0 |
454 | targ dd text2 |
428 | vmode dd 1 |
455 | 429 | targ dd text2 |
|
456 | my_name db 'board',0 |
430 | my_name db 'board',0 |
457 | my_name_size = $-my_name |
431 | my_name_size = $-my_name |
458 | process_count dd 0x0 |
432 | process_count dd 0x0 |
459 | pid_tid dd 0x0 |
433 | pid_tid dd 0x0 |
460 | ;------------------------------------------------------------------------------ |
- | |
461 | I_END: |
- | |
462 | ;------------------------------------------------------------------------------ |
434 | ;------------------------------------------------------------------------------ |
463 | offs dd ? |
435 | I_END: |
464 | flag rb 1 |
436 | ;------------------------------------------------------------------------------ |
465 | rd 2 |
- | |
466 | ;x1pos dd ? |
- | |
467 | ;y1pos dd ? |
437 | offs dd ? |
468 | text1 rb 80*(MAXSTRINGS+1) |
438 | flag rb 1 |
469 | tmp1 db ? |
439 | rd 2 |
470 | rd 2 |
- | |
471 | ;x2pos dd ? |
440 | text1 rb 80*(MAXSTRINGS+1) |
472 | ;y2pos dd ? |
- | |
473 | text2 rb 80*(MAXSTRINGS+1) |
441 | tmp1 db ? |
474 | tmp2 db ? |
442 | rd 2 |
475 | xstart dd ? |
443 | text2 rb 80*(MAXSTRINGS+1) |
476 | 444 | tmp2 db ? |
|
477 | sc system_colors |
- | |
478 | 445 | xstart dd ? |
|
479 | i_end: |
446 | sc sys_colors_new |
480 | buffer_length rb 1 |
447 | i_end: |
481 | ;------------------------------------------------------------------------------ |
448 | buffer_length rb 1 |
482 | tmp rb 256 |
449 | ;------------------------------------------------------------------------------ |