Version of board that write log file.

git-svn-id: svn://kolibrios.org@1571 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Asper 2010-08-17 21:40:33 +00:00
parent dc2f932249
commit a74d0205d1

View File

@ -5,33 +5,34 @@
; ;
; Compile with FASM for Menuet ; Compile with FASM for Menuet
; ;
LMARGIN equ (15+5) LMARGIN equ (15+5)
TMARGIN equ (35+5) TMARGIN equ (35+5)
HSPACE equ 16 HSPACE equ 16
VSPACE equ 12 VSPACE equ 12
IPC_BUF equ 160 IPC_BUF equ 160
DR_GRID equ 0;1 DR_GRID equ 0;1
WRITE_LOG equ 1
FL_KRNL equ 1 FL_KRNL equ 1
include 'lang.inc' include 'lang.inc'
use32 use32
org 0x0 org 0x0
db 'MENUET01' ; 8 byte id db 'MENUET01' ; 8 byte id
dd 0x01 ; header version dd 0x01 ; header version
dd START ; start of code dd START ; start of code
dd I_END ; size of image dd I_END ; size of image
dd i_end+0x2000 ; memory for app (4 Kb) dd i_end+0x2000 ; memory for app (4 Kb)
dd i_end+0x2000 ; esp dd i_end+0x2000 ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon dd 0x0 , 0x0 ; I_Param , I_Icon
include '..\..\..\MACROS.INC' include '..\..\..\MACROS.INC'
include 'debug.inc' include 'debug.inc'
purge newline purge newline
MAXSTRINGS = 16 MAXSTRINGS = 16
TMP = 80*(MAXSTRINGS+1) TMP = 80*(MAXSTRINGS+1)
START: ; start of execution START: ; start of execution
mcall 60,1,ipcbuff,IPC_BUF+20 mcall 60,1,ipcbuff,IPC_BUF+20
mcall 40,1000111b mcall 40,1000111b
@ -64,24 +65,28 @@ START: ; start of execution
mov ecx,sc mov ecx,sc
mov edx,sizeof.system_colors mov edx,sizeof.system_colors
mcall mcall
if WRITE_LOG
mov esi, filename
call CreateFile
end if
red: red:
call draw_window call draw_window
still: still:
mov eax,23 ; wait here for event mov eax,23 ; wait here for event
mov ebx,1 mov ebx,1
mcall mcall
cmp eax,1 ; redraw request ? cmp eax,1 ; redraw request ?
je red je red
cmp eax,2 ; key in buffer ? cmp eax,2 ; key in buffer ?
je key je key
cmp eax,3 ; button in buffer ? cmp eax,3 ; button in buffer ?
je button je button
cmp eax,7 cmp eax,7
je ipc je ipc
mov eax,63 mov eax,63
mov ebx,2 mov ebx,2
@ -91,6 +96,25 @@ still:
jne still jne still
new_data: new_data:
if WRITE_LOG
pusha
mov [tmp], al
mov edx, tmp
mov ecx, 1
mov esi, filename
.write_to_logfile:
call WriteToFile
cmp eax, 5
jne @f
mov esi, filename
mov [filepos], 0
call CreateFile
jmp .write_to_logfile
@@:
inc [filepos]
popa
end if
mov ebp,[targ] mov ebp,[targ]
.no4: .no4:
cmp al,13 cmp al,13
@ -123,15 +147,15 @@ still:
jmp new_check jmp new_check
no10: no10:
cmp ebp,text1 cmp ebp,text1
je add2 je add2
mov ecx,[krnl_cnt] mov ecx,[krnl_cnt]
cmp al,[krnl_msg+ecx] cmp al,[krnl_msg+ecx]
jne .noknl jne .noknl
inc [krnl_cnt] inc [krnl_cnt]
cmp [krnl_cnt],4 cmp [krnl_cnt],4
jne new_check jne new_check
mov [targ],text1 mov [targ],text1
.noknl: .noknl:
mov ebp,[targ] mov ebp,[targ]
jecxz .add jecxz .add
push eax push eax
@ -153,10 +177,10 @@ still:
mcall mcall
cmp ebx,1 cmp ebx,1
je new_data je new_data
cmp [vmode],2 cmp [vmode],2
je still je still
call draw_window call draw_window
jmp still jmp still
@ -173,7 +197,7 @@ still:
.lp: .lp:
mcall 9 mcall 9
cmp [ebx+30],esi cmp [ebx+30],esi
je .ok je .ok
loop .lp loop .lp
and [dump_len],0 and [dump_len],0
jmp red jmp red
@ -184,17 +208,17 @@ still:
mov ecx,12 mov ecx,12
rep movsb rep movsb
jmp red jmp red
key: ; key key: ; key
mov al,2 ; just read it and ignore mov al,2 ; just read it and ignore
mcall mcall
cmp ah,' ' cmp ah,' '
je button.no_krnl_flt je button.no_krnl_flt
cmp [vmode],2 cmp [vmode],2
jne still jne still
cmp ah,176 ;left cmp ah,176 ;left
jb still jb still
cmp ah,179 ;right cmp ah,179 ;right
ja still ja still
mov ecx,[offs] mov ecx,[offs]
shr eax,8 shr eax,8
sub eax,176 sub eax,176
@ -207,41 +231,41 @@ still:
arrows dd -1,16,-16,1 arrows dd -1,16,-16,1
button: ; button button: ; button
mov al,17 ; get id mov al,17 ; get id
mcall mcall
cmp ah,1 ; button id=1 ? cmp ah,1 ; button id=1 ?
jne .noclose jne .noclose
or eax,-1 ; close this program or eax,-1 ; close this program
mcall mcall
.noclose: .noclose:
shr eax,8 shr eax,8
cmp eax,10 cmp eax,10
jb .nodump jb .nodump
lea edi,[eax-10] lea edi,[eax-10]
mcall 37,1 mcall 37,1
sub eax,[edi*4+dump_cell_marg] sub eax,[edi*4+dump_cell_marg]
sub eax,TMARGIN+VSPACE sub eax,TMARGIN+VSPACE
push eax push eax
and eax,0xffff and eax,0xffff
xor edx,edx xor edx,edx
div word[edi*4+dump_cell_size+2] div word[edi*4+dump_cell_size+2]
mov ecx,eax mov ecx,eax
shl ecx,16 shl ecx,16
xor edx,edx xor edx,edx
pop eax pop eax
shr eax,16 shr eax,16
div word[edi*4+dump_cell_size] div word[edi*4+dump_cell_size]
mov cx,ax mov cx,ax
.check_sel: .check_sel:
mov eax,ecx mov eax,ecx
shl ax,12 shl ax,12
shr eax,12 shr eax,12
inc eax inc eax
cmp eax,[dump_len] cmp eax,[dump_len]
ja still;.nosel ja still;.nosel
mov dword[sel_byte],ecx mov dword[sel_byte],ecx
dec eax dec eax
mov [offs],eax mov [offs],eax
@ -257,7 +281,7 @@ arrows dd -1,16,-16,1
and byte[ipcbuff],0 and byte[ipcbuff],0
inc [vmode] inc [vmode]
cmp [vmode],3 cmp [vmode],3
jb .vmok jb .vmok
and [vmode],0 and [vmode],0
.vmok: .vmok:
jmp red jmp red
@ -270,7 +294,7 @@ add_char:
mov [ebp+esi],al mov [ebp+esi],al
inc dword[ebp-8] inc dword[ebp-8]
cmp dword[ebp-8],80 cmp dword[ebp-8],80
jb .ok jb .ok
mov dword[ebp-8],79 mov dword[ebp-8],79
.ok: .ok:
pop esi pop esi
@ -283,18 +307,18 @@ add_char:
draw_window: draw_window:
mov eax,12 ; function 12:tell os about windowdraw mov eax,12 ; function 12:tell os about windowdraw
mov ebx,1 ; 1, start of draw mov ebx,1 ; 1, start of draw
mcall mcall
; DRAW WINDOW ; DRAW WINDOW
xor eax,eax ; function 0 : define and draw window xor eax,eax ; function 0 : define and draw window
; mov ebx,50*65536+400 ; [x start] *65536 + [x size] ; mov ebx,50*65536+400 ; [x start] *65536 + [x size]
mov ebx,[xstart] mov ebx,[xstart]
mov ecx,MAXSTRINGS*10+45 ; [y start] *65536 + [y size] mov ecx,MAXSTRINGS*10+45 ; [y start] *65536 + [y size]
mov edx,[sc.work] ; color of work area RRGGBB,8->color gl mov edx,[sc.work] ; color of work area RRGGBB,8->color gl
or edx,0x13000000 or edx,0x13000000
mov edi,title ; WINDOW LABEL mov edi,title ; WINDOW LABEL
mcall mcall
mov ecx,4 mov ecx,4
@ -307,12 +331,12 @@ draw_window:
mcall 4,<300,8>,,,4 mcall 4,<300,8>,,,4
cmp [vmode],2 cmp [vmode],2
je no_mdbg je no_mdbg
mov ebx,15*65536+33 ; draw info text with function 4 mov ebx,15*65536+33 ; draw info text with function 4
mov ecx,[sc.work_text] mov ecx,[sc.work_text]
mov edx,text1 mov edx,text1
cmp [vmode],0 cmp [vmode],0
je .kern je .kern
mov edx,text2 mov edx,text2
.kern: .kern:
mov esi,80 mov esi,80
@ -333,10 +357,10 @@ draw_window:
end if end if
mov ecx,[dump_len] mov ecx,[dump_len]
call dump_btn call dump_btn
call draw_dump call draw_dump
enddraw: enddraw:
mov eax,12 ; function 12:tell os about windowdraw mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw mov ebx,2 ; 2, end of draw
mcall mcall
ret ret
@ -398,10 +422,10 @@ draw_dump:
call draw_numbers call draw_numbers
mcall 4,(LMARGIN+2) shl 16+27,0,dump_title,dump_t_len-dump_title mcall 4,(LMARGIN+2) shl 16+27,0,dump_title,dump_t_len-dump_title
mcall 47,0x30101,ipcbuff+8,(LMARGIN+2+6*29)shl 16+27 mcall 47,0x30101,ipcbuff+8,(LMARGIN+2+6*29)shl 16+27
add edx,(6*27) shl 16 add edx,(6*27) shl 16
mov ecx,offs mov ecx,offs
mcall mcall
sub edx,(5*6)shl 16 sub edx,(5*6)shl 16
mcall ,0x30001 mcall ,0x30001
mov ecx,16 mov ecx,16
mov edi,HSPACE shl 16 mov edi,HSPACE shl 16
@ -503,6 +527,73 @@ dump_btn: ; ecx-length
.ex: .ex:
ret ret
if WRITE_LOG
;********************************************
;* input: esi = pointer to the file name *
;********************************************
CreateFile:
pusha
mov dword [InfoStructure], 2 ; create file
mov dword [InfoStructure+4], 0 ; reserved
mov dword [InfoStructure+8], 0 ; reserved
mov dword [InfoStructure+12], 0 ; 0 bytes to write (just create)
mov dword [InfoStructure+16], 0 ; NULL data pointer (no data)
mov dword [InfoStructure+20], 0 ; reserved
mov dword [InfoStructure+21], esi ; pointer to the file name
mcall 70, InfoStructure
clc
test eax, eax
jz .out
stc
.out:
popa
ret
;********************************************
;* input: esi = pointer to the file name *
;* edx = pointer to data buffer *
;* ecx = data length *
;********************************************
WriteToFile:
push ebx
mov dword [InfoStructure], 3 ; write to file
mov eax, [filepos]
mov dword [InfoStructure+4], eax ; lower position addr
mov dword [InfoStructure+8], 0 ; upper position addr (0 for FAT)
mov dword [InfoStructure+12], ecx ; number of bytes to write
mov dword [InfoStructure+16], edx ; pointer to data buffer
mov dword [InfoStructure+20], 0 ; reserved
mov dword [InfoStructure+21], esi ; pointer to the file name
mcall 70, InfoStructure
clc
test eax, eax
jz .out
stc
.out:
pop ebx
ret
InfoStructure:
dd 0x0 ; subfunction number
dd 0x0 ; position in the file in bytes
dd 0x0 ; upper part of the position address
dd 0x0 ; number of bytes to read
dd 0x0 ; pointer to the buffer to write data
db 0
dd 0 ; pointer to the filename
filepos dd 0
filename db '/sys/boardlog.txt',0
tmp db 0
end if
krnl_msg db 'K : ' krnl_msg db 'K : '
duk db 'KernUserDump' duk db 'KernUserDump'
numb db 'Byte: Word: Dword: Hex:' numb db 'Byte: Word: Dword: Hex:'
@ -517,14 +608,14 @@ dump_cell_size dw HSPACE,VSPACE,6,VSPACE
; 11,11 > 0,-1 ; 11,11 > 0,-1
; 5,11 > 0,-1 ; 5,11 > 0,-1
if lang eq ru if lang eq ru
title db '„®áª  ®â« ¤ª¨ ¨ á®®¡é¥­¨©',0 title db '„®áª  ®â« ¤ª¨ ¨ á®®¡é¥­¨©',0
else if lang eq en else if lang eq en
title db 'General debug & message board',0 title db 'General debug & message board',0
else else
title db 'Allgemeines debug- & nachrichtenboard',0 title db 'Allgemeines debug- & nachrichtenboard',0
end if end if
krnl_cnt dd 0 krnl_cnt dd 0
vmode dd 0 vmode dd 1
targ dd text2 targ dd text2
I_END: I_END:
offs dd ? offs dd ?