Subversion Repositories Kolibri OS

Rev

Rev 3586 | Rev 4672 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;
  2. ;   DEBUG BOARD for APPLICATIONS and KERNEL DEVELOPMENT
  3. ;
  4. ;   See f63
  5. ;
  6. ;   Compile with FASM for Menuet
  7. ;
  8. WRITE_LOG  equ 1
  9.  
  10. include 'lang.inc'
  11.  
  12.    use32
  13.    org    0x0
  14.    db     'MENUET01'              ; 8 byte id
  15.    dd     0x01                    ; header version
  16.    dd     START                   ; start of code
  17.    dd     I_END                   ; size of image
  18.    dd     mem                   ; memory for app
  19.    dd     mem                   ; esp
  20.    dd     filename , 0x0          ; I_Param , I_Icon
  21. include '../../../macros.inc'
  22. include '../../../debug.inc'
  23. purge newline
  24. MAXSTRINGS = 16
  25. TMP = 80*(MAXSTRINGS+1)
  26. ;------------------------------------------------------------------------------
  27. START:                          ; start of execution
  28.         mov     edi,filename
  29.         cmp     [edi],byte 0
  30.         jnz     param
  31.         mov     esi,default_filename
  32. @@:
  33.         lodsb
  34.         stosb
  35.         test    al,al
  36.         jnz     @b
  37. param:
  38.  
  39. ; allow user to see messages written before start
  40. ;       mov     ecx,4096
  41. ;flush:
  42. ;       mcall   63,2
  43. ;       loop    flush
  44.  
  45.         mov     ecx,TMP
  46.         xor     eax,eax
  47.         mov     edi,[targ]
  48.         rep     stosb
  49.  
  50.         mov     [tmp1],'x'
  51.         mov     [tmp2],'x'
  52.  
  53.         mcall   14
  54.         and     eax,0xffff0000
  55.         sub     eax,399 shl 16
  56.         add     eax,399
  57.         mov     [xstart],eax
  58.         mcall   48,3,sc,sizeof.system_colors
  59.  
  60.         mov     esi,filename
  61.         call    CreateFile
  62. ;------------------------------------------------------------------------------
  63. red:
  64.         call draw_window
  65. ;------------------------------------------------------------------------------
  66. still:
  67.         cmp     [buffer_length],0
  68.         je      @f
  69.         call    write_buffer
  70. @@:
  71.         mcall   23,50           ; wait here for event
  72.         cmp     eax,1                   ; redraw request ?
  73.         je      red
  74.  
  75.         cmp     eax,2                   ; key in buffer ?
  76.         je      key
  77.  
  78.         cmp     eax,3                   ; button in buffer ?
  79.         je      button
  80.  
  81.         mcall   63,2
  82.         cmp     ebx,1
  83.         jne     still
  84.  
  85. new_data:
  86.         cmp     [buffer_length],255
  87.         jne     @f
  88.         call    write_buffer
  89. @@:
  90.         movzx   ebx,byte[buffer_length]
  91.         mov     [ebx+tmp],al
  92.         inc     [buffer_length]
  93.  
  94.         mov     ebp,[targ]
  95. .no4:
  96.         cmp     al,13
  97.         jne     no13
  98.         and     [ebp-8],dword 0
  99.         jmp     new_check
  100. ;------------------------------------------
  101. write_buffer:
  102.         pusha
  103.         mov     edx,tmp
  104.         movzx   ecx,byte[buffer_length] ;1
  105.         mov     esi,filename
  106. .write_to_logfile:
  107.         call    WriteToFile
  108.         cmp     eax,5
  109.         jne     @f
  110.         mov     esi,filename
  111.         mov     [filepos],0
  112.         call    CreateFile
  113.         jnc     .write_to_logfile
  114. @@:
  115.         movzx   eax,byte[buffer_length]
  116.         add     [filepos],eax
  117.         xor     eax,eax
  118.         mov     [buffer_length],al
  119.         popa
  120.         ret
  121. ;------------------------------------------
  122. no13:
  123.         cmp     al,10
  124.         jne     no10
  125.         and     [ebp-8],dword 0
  126.         inc     dword [ebp-4]
  127.         cmp     [ebp-4],dword MAXSTRINGS
  128.         jbe     .noypos
  129.         mov     [ebp-4],dword MAXSTRINGS
  130.         lea     esi,[ebp+80]
  131.         mov     edi,ebp
  132.         mov     ecx,80*(MAXSTRINGS)
  133.         cld
  134.         rep     movsb
  135.  
  136.         mov     esi,[ebp-4]
  137.         imul    esi,80
  138.         add     esi,[ebp-8]
  139.         add     esi,ebp
  140.         mov     ecx,80
  141.         xor     al,al
  142.         rep     stosb
  143. .noypos:
  144.         mov     [targ],text2
  145.         and     [krnl_cnt],0
  146.         jmp     new_check
  147. ;------------------------------------------
  148. no10:
  149.         cmp     ebp,text1
  150.         je      add2
  151.         mov     ecx,[krnl_cnt]
  152.         cmp     al,[krnl_msg+ecx]
  153.         jne     .noknl
  154.         inc     [krnl_cnt]
  155.         cmp     [krnl_cnt],4
  156.         jne     new_check
  157.         mov     [targ],text1
  158. .noknl:
  159.         mov     ebp,[targ]
  160.         jecxz   .add
  161.         push    eax
  162.         mov     esi,krnl_msg
  163. .l1:
  164.         lodsb
  165.         call    add_char
  166.         loop    .l1
  167.         pop     eax
  168. .add:
  169.         and     [krnl_cnt],0
  170. add2:
  171.         call    add_char
  172.  
  173. new_check:
  174.         mcall   63,2
  175.         cmp     ebx,1
  176.         je      new_data
  177.         call    draw_text
  178.         jmp     still
  179. ;------------------------------------------------------------------------------
  180. key:
  181.         mcall   2
  182.         cmp     ah,' '
  183.         je      button.noclose
  184.         jmp     still
  185. ;------------------------------------------------------------------------------
  186. button:
  187.         mcall   17      ; get id
  188.         cmp     ah,1            ; button id=1 ?
  189.         jne     .noclose
  190.         or      eax,-1          ; close this program
  191.         mcall
  192. .noclose:
  193.         xor     [vmode],1
  194.         jmp     red
  195. ;------------------------------------------------------------------------------
  196. add_char:
  197.         push    esi
  198.         mov     esi,[ebp-4]
  199.         imul    esi,80
  200.         add     esi,[ebp-8]
  201.         mov     [ebp+esi],al
  202.         inc     dword[ebp-8]
  203.         cmp     dword[ebp-8],80
  204.         jb      .ok
  205.         mov     dword[ebp-8],79
  206. .ok:
  207.         pop     esi
  208.         ret
  209. ;------------------------------------------------------------------------------
  210. ;   *********************************************
  211. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  212. ;   *********************************************
  213. draw_window:
  214.         mcall   12,1    ; 1, start of draw
  215.         xor     eax,eax              ; function 0 : define and draw window
  216.         mov     ecx,MAXSTRINGS*10+45       ; [y start] *65536 + [y size]
  217. ;       mov     edx,[sc.work]              ; color of work area RRGGBB,8->color gl
  218.         mov     edx,0xffffff
  219.         or      edx,0x14000000
  220.         xor     esi,esi
  221.         mcall   ,[xstart],,,,title
  222.         mov     ebx,296 shl 16+5*6
  223.         mcall   8,,<5,12>,3,[sc.work]
  224.         mov     edx,[vmode]
  225.         lea     edx,[edx*4+duk]
  226.         mcall   4,<300,8>,,,4
  227.         call    draw_text
  228.         mcall   12,2    ; 2, end of draw
  229.         ret
  230. ;------------------------------------------------------------------------------
  231. draw_text:
  232.         mov     ebx,15*65536+30    ; draw info text with function 4
  233. ;       mov     ecx,[sc.work_text]
  234.         xor     ecx,ecx
  235.         or      ecx,0x40000000
  236. ;       mov     edi,[sc.work]
  237.         mov     edi,0xffffff
  238.         mov     edx,text1
  239.         cmp     [vmode],0
  240.         je      .kern
  241.         mov     edx,text2
  242. .kern:
  243.         push    ebx ecx edx
  244.         mcall   9,procinfo,-1
  245.         mov     eax,[ebx+42]
  246.         xor     edx,edx
  247.         mov     ebx,6
  248.         div     ebx
  249.         pop     edx ecx ebx
  250.         mov     esi,80
  251.         cmp     eax,esi
  252.         ja      @f
  253.         mov     esi,eax
  254. @@:
  255.         cmp     esi,5
  256.         ja      @f
  257.         mov     esi,5
  258. @@:
  259.         sub     esi,4
  260.         mov     eax,4
  261. newline:
  262.         mcall
  263.         add     ebx,10
  264.         add     edx,80
  265.         cmp     [edx],byte 'x'
  266.         jne     newline
  267.         ret
  268. ;------------------------------------------------------------------------------
  269. ;********************************************
  270. ;*  input:  esi = pointer to the file name  *
  271. ;********************************************
  272.  
  273. CreateFile:
  274.         pusha
  275.         mov     dword [InfoStructure],2         ; create file
  276.         mov     dword [InfoStructure+4],0       ; reserved
  277.         mov     dword [InfoStructure+8],0       ; reserved
  278.         mov     dword [InfoStructure+12],0      ; 0 bytes to write (just create)
  279.         mov     dword [InfoStructure+16],0      ; NULL data pointer (no data)
  280.         mov     dword [InfoStructure+20],0      ; reserved
  281.         mov     dword [InfoStructure+21],esi    ; pointer to the file name
  282.         mcall   70, InfoStructure
  283.         test    eax,eax
  284.         jz      .out
  285.         stc
  286. .out:
  287.         popa
  288.         ret
  289. ;------------------------------------------------
  290. ;********************************************
  291. ;*  input:  esi = pointer to the file name  *
  292. ;*          edx = pointer to data buffer    *
  293. ;*          ecx = data length               *
  294. ;********************************************
  295.  
  296. WriteToFile:
  297.         push    ebx
  298.         mov     dword [InfoStructure],3         ; write to file
  299.         mov     eax,  [filepos]
  300.         mov     dword [InfoStructure+4],eax     ; lower position addr
  301.         mov     dword [InfoStructure+8],0       ; upper position addr (0 for FAT)
  302.         mov     dword [InfoStructure+12],ecx    ; number of bytes to write
  303.         mov     dword [InfoStructure+16],edx    ; pointer to data buffer
  304.         mov     dword [InfoStructure+20],0      ; reserved
  305.         mov     dword [InfoStructure+21],esi    ; pointer to the file name
  306.         mcall   70, InfoStructure
  307.         clc
  308.         test    eax,eax
  309.         jz      .out
  310.         stc
  311. .out:
  312.         pop      ebx
  313.         ret
  314. ;--------------------------------------------------
  315. InfoStructure:
  316.         dd 0x0  ; subfunction number
  317.         dd 0x0  ; position in the file in bytes
  318.         dd 0x0  ; upper part of the position address
  319.         dd 0x0  ; number of bytes to read
  320.         dd 0x0  ; pointer to the buffer to write data
  321.         db 0
  322.         dd 0    ; pointer to the filename
  323.  
  324. filepos dd 0
  325. default_filename db '/sys/boardlog.txt',0
  326. ;------------------------------------------------------------------------------
  327. krnl_msg db 'K : '
  328. duk db 'KernUser'
  329.  
  330. ; DATA AREA
  331.  
  332. ; 11,11 > 0,-1
  333. ; 5,11  > 0,-1
  334. if lang eq ru
  335.  title  db '„®áª  ®â« ¤ª¨ ¨ á®®¡é¥­¨©',0
  336. else if lang eq it
  337.  title  db 'Notifiche e informazioni generiche per il debug',0
  338. else if lang eq ge
  339.  title  db 'Allgemeines debug- & nachrichtenboard',0
  340. else
  341.  title  db 'General debug & message board',0
  342. end if
  343. krnl_cnt        dd 0
  344. vmode           dd 1
  345. targ            dd text2
  346. ;------------------------------------------------------------------------------
  347. I_END:
  348. ;------------------------------------------------------------------------------
  349. offs    dd ?
  350. flag    rb 1
  351.         rd 2
  352. ;x1pos  dd ?
  353. ;y1pos  dd ?
  354. text1   rb 80*(MAXSTRINGS+1)
  355. tmp1    db ?
  356.         rd 2
  357. ;x2pos  dd ?
  358. ;y2pos  dd ?
  359. text2   rb 80*(MAXSTRINGS+1)
  360. tmp2    db ?
  361. xstart  dd ?
  362.  
  363. sc system_colors
  364.  
  365. i_end:
  366. buffer_length   rb 1
  367. ;------------------------------------------------------------------------------
  368. tmp     rb      256
  369. ;------------------------------------------------------------------------------
  370. filename        rb 256
  371. ;------------------------------------------------------------------------------
  372. align 4
  373. procinfo:
  374.         rb 1024
  375. ;------------------------------------------------------------------------------
  376. align 4
  377. stackbuf        rb 2000h
  378. ;------------------------------------------------------------------------------
  379. mem:
  380.