Rev 7425 | Rev 8560 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4977 | Akyltist | 1 | ;------------------------------------------------------------------------------ |
2 | ; DEBUG BOARD for APPLICATIONS and KERNEL DEVELOPMENT |
||
3 | ; See f63 |
||
4 | ; Compile with FASM for KolibriOS |
||
5 | ;------------------------------------------------------------------------------ |
||
5925 | pathoswith | 6 | use32 |
7 | org 0 |
||
4977 | Akyltist | 8 | db 'MENUET01' |
5925 | pathoswith | 9 | dd 1 |
4977 | Akyltist | 10 | dd START |
11 | dd I_END |
||
12 | dd mem |
||
13 | dd mem |
||
5925 | pathoswith | 14 | dd filename |
15 | dd 0 |
||
4977 | Akyltist | 16 | ;------------------------------------------------------------------------------ |
5925 | pathoswith | 17 | include 'lang.inc' |
1741 | dunkaist | 18 | include '../../../macros.inc' |
3013 | dunkaist | 19 | include '../../../debug.inc' |
5925 | pathoswith | 20 | purge newline |
6592 | leency | 21 | ;SMALL FONT |
5925 | pathoswith | 22 | MAXSTRINGS = 45 |
6592 | leency | 23 | LINE_H = 10 |
24 | WINDOW_W = 399 |
||
25 | WINDOW_H = MAXSTRINGS*LINE_H+45 |
||
26 | FONT_TYPE = 0x40000000 |
||
27 | ;BIG FONT |
||
28 | ; MAXSTRINGS = 30 |
||
29 | ; LINE_H = 15 |
||
30 | ; WINDOW_W = 630 |
||
31 | ; WINDOW_H = MAXSTRINGS*LINE_H+50 |
||
32 | ; FONT_TYPE = 0x50000000 |
||
33 | |||
2234 | mario79 | 34 | ;------------------------------------------------------------------------------ |
5925 | pathoswith | 35 | START: |
4977 | Akyltist | 36 | call CheckUnique |
37 | mov edi, filename |
||
38 | cmp [edi], byte 0 |
||
39 | jnz param |
||
40 | mov esi, default_filename |
||
5925 | pathoswith | 41 | @@: |
4977 | Akyltist | 42 | lodsb |
43 | stosb |
||
44 | test al,al |
||
45 | jnz @b |
||
5925 | pathoswith | 46 | param: |
47 | mov ecx, (MAXSTRINGS+1)*20 |
||
48 | mov edi, text1 |
||
49 | mov eax, ' ' |
||
50 | rep stosd |
||
4672 | izikiel | 51 | |
5925 | pathoswith | 52 | mov ecx, (MAXSTRINGS+1)*20 |
53 | mov edi, text2 |
||
54 | rep stosd |
||
4672 | izikiel | 55 | |
5925 | pathoswith | 56 | mov byte [tmp1], 'x' |
57 | mov byte [tmp2], 'x' |
||
58 | |||
4977 | Akyltist | 59 | mcall 14 |
60 | and eax, 0xffff0000 |
||
6592 | leency | 61 | sub eax, WINDOW_W shl 16 |
62 | add eax, WINDOW_W |
||
4977 | Akyltist | 63 | mov [xstart], eax |
6162 | leency | 64 | mcall 48, 3, sc, sizeof.system_colors |
31 | halyavin | 65 | |
4977 | Akyltist | 66 | mov esi, filename |
67 | call CreateFile |
||
2234 | mario79 | 68 | ;------------------------------------------------------------------------------ |
69 | red: |
||
5925 | pathoswith | 70 | call draw_window |
2234 | mario79 | 71 | ;------------------------------------------------------------------------------ |
31 | halyavin | 72 | still: |
4977 | Akyltist | 73 | cmp [buffer_length], 0 |
74 | je @f |
||
75 | call write_buffer |
||
5925 | pathoswith | 76 | @@: |
4977 | Akyltist | 77 | mcall 23, 50 ; wait here for event |
78 | cmp eax, 1 ; redraw request ? |
||
79 | je red |
||
31 | halyavin | 80 | |
4977 | Akyltist | 81 | cmp eax, 2 ; key in buffer ? |
82 | je key |
||
31 | halyavin | 83 | |
4977 | Akyltist | 84 | cmp eax, 3 ; button in buffer ? |
85 | je button |
||
447 | heavyiron | 86 | |
4977 | Akyltist | 87 | mcall 63, 2 |
88 | cmp ebx, 1 |
||
89 | jne still |
||
31 | halyavin | 90 | |
2234 | mario79 | 91 | new_data: |
4977 | Akyltist | 92 | cmp [buffer_length], 255 |
93 | jne @f |
||
94 | call write_buffer |
||
5925 | pathoswith | 95 | @@: |
4977 | Akyltist | 96 | movzx ebx, byte[buffer_length] |
97 | mov [ebx+tmp], al |
||
98 | inc [buffer_length] |
||
99 | mov ebp, [targ] |
||
5925 | pathoswith | 100 | cmp al, 10 |
101 | jz new_line |
||
4977 | Akyltist | 102 | cmp al, 13 |
5925 | pathoswith | 103 | jz new_check |
104 | jmp char |
||
4480 | mario79 | 105 | ;------------------------------------------ |
106 | write_buffer: |
||
4977 | Akyltist | 107 | pusha |
108 | mov edx, tmp |
||
5925 | pathoswith | 109 | movzx ecx, byte[buffer_length] |
4977 | Akyltist | 110 | mov esi, filename |
5925 | pathoswith | 111 | .write_to_logfile: |
4977 | Akyltist | 112 | call WriteToFile |
113 | cmp eax, 5 |
||
114 | jne @f |
||
115 | mov esi, filename |
||
116 | mov [filepos], 0 |
||
117 | call CreateFile |
||
118 | jnc .write_to_logfile |
||
2234 | mario79 | 119 | @@: |
4977 | Akyltist | 120 | movzx eax,byte[buffer_length] |
121 | add [filepos],eax |
||
122 | xor eax,eax |
||
123 | mov [buffer_length],al |
||
124 | popa |
||
125 | ret |
||
2234 | mario79 | 126 | ;------------------------------------------ |
5925 | pathoswith | 127 | new_line: |
4977 | Akyltist | 128 | and [ebp-8], dword 0 |
129 | inc dword [ebp-4] |
||
130 | cmp [ebp-4], dword MAXSTRINGS |
||
131 | jbe .noypos |
||
132 | mov [ebp-4], dword MAXSTRINGS |
||
133 | lea esi, [ebp+80] |
||
134 | mov edi, ebp |
||
5925 | pathoswith | 135 | mov ecx, 20*(MAXSTRINGS) |
4977 | Akyltist | 136 | cld |
5925 | pathoswith | 137 | rep movsd |
1571 | Asper | 138 | |
4977 | Akyltist | 139 | mov esi, [ebp-4] |
140 | imul esi, 80 |
||
141 | add esi, [ebp-8] |
||
142 | add esi, ebp |
||
5925 | pathoswith | 143 | mov ecx, 20 |
144 | mov eax, ' ' |
||
145 | rep stosd |
||
146 | .noypos: |
||
4977 | Akyltist | 147 | mov [targ],text2 |
148 | and [krnl_cnt],0 |
||
149 | jmp new_check |
||
2234 | mario79 | 150 | ;------------------------------------------ |
5925 | pathoswith | 151 | char: |
4977 | Akyltist | 152 | cmp ebp, text1 |
153 | je add2 |
||
154 | mov ecx, [krnl_cnt] |
||
155 | cmp al, [krnl_msg+ecx] |
||
156 | jne .noknl |
||
157 | inc [krnl_cnt] |
||
158 | cmp [krnl_cnt], 4 |
||
159 | jne new_check |
||
160 | mov [targ], text1 |
||
5925 | pathoswith | 161 | .noknl: |
4977 | Akyltist | 162 | mov ebp, [targ] |
163 | jecxz .add |
||
164 | push eax |
||
165 | mov esi, krnl_msg |
||
5925 | pathoswith | 166 | .l1: |
4977 | Akyltist | 167 | lodsb |
168 | call add_char |
||
169 | loop .l1 |
||
170 | pop eax |
||
5925 | pathoswith | 171 | .add: |
4977 | Akyltist | 172 | and [krnl_cnt], 0 |
2234 | mario79 | 173 | add2: |
4977 | Akyltist | 174 | call add_char |
1571 | Asper | 175 | |
2234 | mario79 | 176 | new_check: |
4977 | Akyltist | 177 | mcall 63, 2 |
178 | cmp ebx, 1 |
||
179 | je new_data |
||
180 | call draw_text |
||
181 | jmp still |
||
2234 | mario79 | 182 | ;------------------------------------------------------------------------------ |
183 | key: |
||
4977 | Akyltist | 184 | mcall 2 |
185 | cmp ah, ' ' |
||
186 | je button.noclose |
||
7425 | leency | 187 | cmp ah, 51 ; F2 |
188 | je open_boardlog |
||
4977 | Akyltist | 189 | jmp still |
7425 | leency | 190 | open_boardlog: |
191 | mcall 70, open_log_in_tinypad |
||
192 | jmp red |
||
193 | |||
2234 | mario79 | 194 | ;------------------------------------------------------------------------------ |
195 | button: |
||
4977 | Akyltist | 196 | mcall 17 ; get id |
197 | cmp ah, 1 ; button id=1 ? |
||
198 | jne .noclose |
||
199 | or eax, -1 ; close this program |
||
200 | mcall |
||
5925 | pathoswith | 201 | .noclose: |
4977 | Akyltist | 202 | xor [vmode], 1 |
203 | jmp red |
||
2234 | mario79 | 204 | ;------------------------------------------------------------------------------ |
131 | diamond | 205 | add_char: |
4977 | Akyltist | 206 | push esi |
207 | mov esi, [ebp-4] |
||
208 | imul esi, 80 |
||
209 | add esi, [ebp-8] |
||
210 | mov [ebp+esi], al |
||
211 | inc dword[ebp-8] |
||
212 | cmp dword[ebp-8], 80 |
||
213 | jb .ok |
||
214 | mov dword[ebp-8], 79 |
||
2234 | mario79 | 215 | .ok: |
4977 | Akyltist | 216 | pop esi |
217 | ret |
||
5925 | pathoswith | 218 | |
2234 | mario79 | 219 | ;------------------------------------------------------------------------------ |
4977 | Akyltist | 220 | ;************************ WINDOW DEFINITIONS AND DRAW ************************ |
221 | ;------------------------------------------------------------------------------ |
||
31 | halyavin | 222 | draw_window: |
4977 | Akyltist | 223 | mcall 12, 1 ; 1, start of draw |
224 | mcall 48, 5 ; GetClientTop |
||
225 | shr ebx, 16 |
||
226 | mov ecx, ebx |
||
227 | shl ecx, 16 |
||
6592 | leency | 228 | add ecx, WINDOW_H ; [y start] *65536 + [y size] |
4977 | Akyltist | 229 | mov edx, 0xffffff |
230 | or edx, 0x14000000 |
||
231 | xor esi, esi |
||
6592 | leency | 232 | mcall 0,[xstart],,,,title |
4977 | Akyltist | 233 | mov ebx, 296 shl 16+31 |
6162 | leency | 234 | mcall 8,,<4,13>,3,[sc.work_button] |
4977 | Akyltist | 235 | mov edx, [vmode] |
236 | lea edx, [edx*4+duk] |
||
5925 | pathoswith | 237 | mov ecx, 0x80 |
238 | shr ecx, 24 |
||
6162 | leency | 239 | add ecx, [sc.work_button_text] |
4977 | Akyltist | 240 | mcall 4,<300,7>,,,4 |
241 | call draw_text |
||
242 | mcall 12, 2 ; 2, end of draw |
||
243 | ret |
||
2234 | mario79 | 244 | ;------------------------------------------------------------------------------ |
245 | draw_text: |
||
4977 | Akyltist | 246 | mov ebx, 15*65536+30 ; draw info text with function 4 |
247 | xor ecx, ecx |
||
6592 | leency | 248 | or ecx, FONT_TYPE |
4977 | Akyltist | 249 | mov edi, 0xffffff |
250 | mov edx, text1 |
||
251 | cmp [vmode], 0 |
||
252 | je .kern |
||
253 | mov edx, text2 |
||
5925 | pathoswith | 254 | .kern: |
4977 | Akyltist | 255 | push ebx ecx edx |
256 | mcall 9, procinfo,-1 |
||
257 | mov eax, [ebx+42] |
||
258 | xor edx, edx |
||
259 | mov ebx, 6 |
||
260 | div ebx |
||
261 | pop edx ecx ebx |
||
262 | mov esi, 80 |
||
263 | cmp eax, esi |
||
264 | ja @f |
||
265 | mov esi, eax |
||
2234 | mario79 | 266 | @@: |
4977 | Akyltist | 267 | cmp esi, 5 |
268 | ja @f |
||
269 | mov esi, 5 |
||
2234 | mario79 | 270 | @@: |
4977 | Akyltist | 271 | sub esi, 4 |
272 | mov eax, 4 |
||
2234 | mario79 | 273 | newline: |
4977 | Akyltist | 274 | mcall |
6592 | leency | 275 | add ebx, LINE_H |
4977 | Akyltist | 276 | add edx, 80 |
277 | cmp [edx], byte 'x' |
||
278 | jne newline |
||
279 | ret |
||
280 | |||
3586 | fedesco | 281 | ;------------------------------------------------------------------------------ |
1571 | Asper | 282 | ;* input: esi = pointer to the file name * |
4977 | Akyltist | 283 | ;------------------------------------------------------------------------------ |
1571 | Asper | 284 | CreateFile: |
4977 | Akyltist | 285 | pusha |
286 | mov dword [InfoStructure+00], 2 ; create file |
||
287 | mov dword [InfoStructure+04], 0 ; reserved |
||
288 | mov dword [InfoStructure+08], 0 ; reserved |
||
289 | mov dword [InfoStructure+12], 0 ; 0 bytes to write (just create) |
||
290 | mov dword [InfoStructure+16], 0 ; NULL data pointer (no data) |
||
291 | mov dword [InfoStructure+20], 0 ; reserved |
||
292 | mov dword [InfoStructure+21], esi ; pointer to the file name |
||
293 | mcall 70, InfoStructure |
||
294 | test eax, eax |
||
295 | jz .out |
||
296 | stc |
||
5925 | pathoswith | 297 | .out: |
4977 | Akyltist | 298 | popa |
299 | ret |
||
300 | ;------------------------------------------------------------------------------ |
||
1571 | Asper | 301 | ;* input: esi = pointer to the file name * |
302 | ;* edx = pointer to data buffer * |
||
303 | ;* ecx = data length * |
||
4977 | Akyltist | 304 | ;------------------------------------------------------------------------------ |
1571 | Asper | 305 | WriteToFile: |
4977 | Akyltist | 306 | push ebx |
307 | mov dword [InfoStructure+00], 3 ; write to file |
||
308 | mov eax, [filepos] |
||
309 | mov dword [InfoStructure+04], eax ; lower position addr |
||
310 | mov dword [InfoStructure+08], 0 ; upper position addr (0 for FAT) |
||
311 | mov dword [InfoStructure+12], ecx ; number of bytes to write |
||
312 | mov dword [InfoStructure+16], edx ; pointer to data buffer |
||
313 | mov dword [InfoStructure+20], 0 ; reserved |
||
314 | mov dword [InfoStructure+21], esi ; pointer to the file name |
||
315 | mcall 70, InfoStructure |
||
316 | clc |
||
317 | test eax, eax |
||
318 | jz .out |
||
319 | stc |
||
5925 | pathoswith | 320 | .out: |
321 | pop ebx |
||
4977 | Akyltist | 322 | ret |
4672 | izikiel | 323 | |
4977 | Akyltist | 324 | ;------------------------------------------------------------------------------ |
4672 | izikiel | 325 | ;* input: esi = pointer to string * |
326 | ;* edi = pointer to string * |
||
327 | ;* ecx = data length * |
||
4977 | Akyltist | 328 | ;------------------------------------------------------------------------------ |
4672 | izikiel | 329 | StrCmp: |
4977 | Akyltist | 330 | repe cmpsb |
331 | ja .a_greater_b |
||
332 | jb .a_less_b |
||
5925 | pathoswith | 333 | .equal: |
4977 | Akyltist | 334 | mov eax, 0 |
335 | jmp .end |
||
5925 | pathoswith | 336 | .a_less_b: |
4977 | Akyltist | 337 | mov eax, 1 |
338 | jmp .end |
||
5925 | pathoswith | 339 | .a_greater_b: |
4977 | Akyltist | 340 | mov eax, -1 |
5925 | pathoswith | 341 | .end: |
4977 | Akyltist | 342 | ret |
4672 | izikiel | 343 | |
4977 | Akyltist | 344 | ;------------------------------------------------------------------------------ |
345 | ;* input: edi = pointer to string * |
||
346 | ;* ecx = data length * |
||
347 | ;------------------------------------------------------------------------------ |
||
4672 | izikiel | 348 | ; 'a' - 'A' = 32 -> 'A'|32 = 'a' |
349 | ToLower: |
||
4977 | Akyltist | 350 | xor eax, eax |
4672 | izikiel | 351 | .cycle: |
4977 | Akyltist | 352 | or byte[edi+eax], 32 |
353 | inc eax |
||
354 | loop .cycle |
||
4672 | izikiel | 355 | .end: |
4977 | Akyltist | 356 | ret |
4672 | izikiel | 357 | |
4977 | Akyltist | 358 | ;------------------------------------------------------------------------------ |
359 | ;* get info on current thread, save pid/tid |
||
360 | ;* look for another process with same name and different pid/tid |
||
361 | ;* if found, close self |
||
362 | ;* else continue normally |
||
363 | ;------------------------------------------------------------------------------ |
||
4672 | izikiel | 364 | CheckUnique: |
5925 | pathoswith | 365 | .get_thread_info: |
4977 | Akyltist | 366 | mov ebx, procinfo |
367 | mov ecx, -1 |
||
368 | mcall 9 |
||
4672 | izikiel | 369 | |
5925 | pathoswith | 370 | .get_pid: ; check_buffer |
4977 | Akyltist | 371 | mov [process_count], eax |
372 | mov eax, [ebx+process_information.PID] |
||
373 | mov [pid_tid], eax |
||
374 | mov ecx, 2 |
||
4672 | izikiel | 375 | |
5925 | pathoswith | 376 | .check_threads: |
4977 | Akyltist | 377 | cmp ecx, [process_count] |
378 | ja .leave_check |
||
379 | mov eax, 9 |
||
380 | mcall |
||
4672 | izikiel | 381 | |
5925 | pathoswith | 382 | .check_slot_free: |
4977 | Akyltist | 383 | cmp dword [ebx+process_information.slot_state], 9 |
384 | je .next_thread |
||
4672 | izikiel | 385 | |
5925 | pathoswith | 386 | .check_pid: |
4977 | Akyltist | 387 | mov eax, [pid_tid] |
388 | cmp [ebx+process_information.PID], eax |
||
389 | je .next_thread |
||
4672 | izikiel | 390 | |
5925 | pathoswith | 391 | .get_proc_name: |
4977 | Akyltist | 392 | lea edi, [ebx+process_information.process_name] |
393 | push ecx |
||
394 | mov ecx, my_name_size-1 |
||
4672 | izikiel | 395 | |
5925 | pathoswith | 396 | .lower_case: |
4977 | Akyltist | 397 | call ToLower |
398 | lea esi, [my_name] |
||
399 | mov ecx, my_name_size |
||
400 | call StrCmp |
||
401 | pop ecx |
||
402 | cmp eax, 0 |
||
403 | je .close_program |
||
4672 | izikiel | 404 | |
5925 | pathoswith | 405 | .next_thread: |
4977 | Akyltist | 406 | inc ecx |
407 | jmp .check_threads |
||
4672 | izikiel | 408 | |
5925 | pathoswith | 409 | .close_program: |
4977 | Akyltist | 410 | ; restore and active window of previous thread |
5925 | pathoswith | 411 | mcall 18, 3 |
412 | mov eax, -1 |
||
4977 | Akyltist | 413 | mcall |
4672 | izikiel | 414 | |
5925 | pathoswith | 415 | .leave_check: |
4977 | Akyltist | 416 | ret |
4672 | izikiel | 417 | |
5925 | pathoswith | 418 | ;------------------------------------------------------------------------------ |
419 | ; DATA |
||
4672 | izikiel | 420 | |
31 | halyavin | 421 | if lang eq ru |
2234 | mario79 | 422 | title db 'Доска отладки и сообщений',0 |
3586 | fedesco | 423 | else if lang eq it |
424 | title db 'Notifiche e informazioni generiche per il debug',0 |
||
425 | else if lang eq ge |
||
426 | title db 'Allgemeines debug- & nachrichtenboard',0 |
||
427 | else |
||
2234 | mario79 | 428 | title db 'General debug & message board',0 |
31 | halyavin | 429 | end if |
5925 | pathoswith | 430 | |
7431 | leency | 431 | default_filename db '/tmp0/1/boardlog.txt',0 |
4977 | Akyltist | 432 | krnl_msg db 'K : ' |
433 | duk db 'KernUser' |
||
434 | my_name db 'board',0 |
||
5925 | pathoswith | 435 | my_name_size = $-my_name |
436 | |||
437 | align 4 |
||
438 | vmode dd 1 |
||
439 | targ dd text2 |
||
440 | |||
31 | halyavin | 441 | I_END: |
5925 | pathoswith | 442 | |
443 | InfoStructure: |
||
444 | dd ? ; subfunction number |
||
445 | dd ? ; position in the file in bytes |
||
446 | dd ? ; upper part of the position address |
||
447 | dd ? ; number of bytes to read |
||
448 | dd ? ; pointer to the buffer to write data |
||
449 | db ? |
||
450 | dd ? ; pointer to the filename |
||
451 | |||
7425 | leency | 452 | open_log_in_tinypad: |
453 | dd 7 |
||
454 | dd 0 |
||
455 | dd filename |
||
456 | dd 0 |
||
457 | dd 0 |
||
458 | db '/sys/tinypad',0 |
||
459 | |||
5925 | pathoswith | 460 | buffer_length rb 3 |
461 | process_count dd ? |
||
462 | krnl_cnt dd ? |
||
463 | pid_tid dd ? |
||
464 | filepos dd ? |
||
4977 | Akyltist | 465 | xstart dd ? |
6162 | leency | 466 | sc system_colors |
5925 | pathoswith | 467 | |
468 | rd 2 |
||
469 | text1 rb 80*(MAXSTRINGS+1) |
||
470 | tmp1 dd ? |
||
471 | |||
472 | rd 2 |
||
473 | text2 rb 80*(MAXSTRINGS+1) |
||
474 | tmp2 dd ? |
||
475 | |||
4977 | Akyltist | 476 | tmp rb 256 |
477 | filename rb 256 |
||
5925 | pathoswith | 478 | procinfo rb 1024 |
4977 | Akyltist | 479 | stackbuf rb 2000h |
5925 | pathoswith | 480 | mem:300,7>4,13> |