AMDtemp: fix parser and code style. TODO: add function for device subsystem

git-svn-id: svn://kolibrios.org@9883 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Doczom 2022-10-16 21:00:24 +00:00
parent 8057f62185
commit 19cab98b13
2 changed files with 481 additions and 435 deletions

View File

@ -1,4 +1,4 @@
;; Copyright (C) 2021-2022, Michail Frolov aka Doczom
;; Copyright (C) 2021-2022, Michael Frolov aka Doczom
macro send_notify send_str{
mov dword[run_notify.message], send_str
@ -22,7 +22,7 @@ include '..\..\macros.inc'
include '..\..\KOSfuncs.inc'
include '..\..\dll.inc'
; include 'parser.inc' ; this modul does not work
include 'parser.inc'
START:
;init heap
mcall 68, 11
@ -35,43 +35,47 @@ START:
; init futex
mcall SF_FUTEX, SSF_CREATE, futex_cmd
mov [futex_handle], eax
; parse cmd_line TODO: fix parser and testing
;call pars_cmd
;test eax, eax
;jnz exit
; parse cmd_line
cmp byte[PATH], 0
jz @f
call parse_cmd
@@:
;;óñòàíîâêà ìàñêà ñîáûòèé íà ïîëó÷åíèå ïåðåïèñîâêè è íàæàòèÿ íà êíîïêó
mcall SF_SET_EVENTS_MASK,0x05
mcall SF_SET_EVENTS_MASK, 0x05
;load driver
mcall SF_SYS_MISC, SSF_LOAD_DRIVER_PE, [drv_ptr], 0
mov dword[drv_struct.handl],eax
test eax,eax ;ïðîâåðêà çàãðóçêè
mov dword[drv_struct.handl], eax
test eax, eax ;ïðîâåðêà çàãðóçêè
jz error_drv
main:
mcall SF_SYS_MISC, SSF_CONTROL_DRIVER, drv_struct
cmp byte[PATH], 0
cmp dword[save_ptr], 0
jz still
;call add_file
mcall 51, 1, thread_auto_save, thread_auto_save.stack
cmp eax, -1
jz still
mov dword[PID_AUTO_SAVE], eax
still: ;void main()
call draw
;;îæèäàíèå ñîáûòèÿ â òå÷åíèè 2000ìñ
mcall SF_WAIT_EVENT_TIMEOUT,200 ;2 second
mcall SF_WAIT_EVENT_TIMEOUT, 200 ;2 second
dec eax ; redraw request ?
je still
cmp eax,2 ;button
cmp eax, 2 ;button
jz button
jmp still
button:
mcall SF_GET_BUTTON
cmp eax,1
cmp eax, 1
jz still
dec ah
je exit
;; id button micro_info = 8
cmp ah,7 ;// ah-1=7
cmp ah, 7 ;// ah-1=7
jnz .no_micro_info
xor byte[flag_micro_info],1
xor byte[flag_micro_info], 1
jmp still
.no_micro_info:
; id button log = 9
@ -133,7 +137,7 @@ button:
; òóò âûçîâ ôóíêöèè openDialog
invoke OpenDialog_Start, OpenDialog_data
cmp [OpenDialog_data.status],1
cmp [OpenDialog_data.status], 1
jne still
;mov dword[log_path], openfile_path
@ -169,31 +173,31 @@ draw:
mov dword[frame_struct.FR_BACK_COLOR], eax
mov eax,SF_CREATE_WINDOW
mov ebx,0x00ff0132
mov ecx,0x00150114 ; link with 80 line
mov edx,0x14000000
add edx,[sc.work]
mov edi,title
mov eax, SF_CREATE_WINDOW
mov ebx, 0x00ff0132
mov ecx, 0x00150114 ; link with 80 line
mov edx, 0x14000000
add edx, [sc.work]
mov edi, title
mcall
mcall SF_SYS_MISC, SSF_CONTROL_DRIVER, drv_struct
cmp byte[flag_micro_info],1
mov eax,SF_CHANGE_WINDOW
mov ebx,-1
mov ecx,ebx;-1
cmp byte[flag_micro_info], 1
mov eax, SF_CHANGE_WINDOW
mov ebx, -1
mov ecx, ebx
jz draw.micro
mov esi,0x00000115 ; link with 58 line
mov edx,0x00000132
mcall
;;ñîçäàíèå êíîïêè ïåðåêëþ÷åíèÿ ðåæèìà
mov eax,SF_DEFINE_BUTTON
mov ebx,0x00fc0010
mov ecx,0x001d0015
mov edx,0x00000008
mov esi,[sc.work_button]
mov eax, SF_DEFINE_BUTTON
mov ebx, 0x00fc0010
mov ecx, 0x001d0015
mov edx, 0x00000008
mov esi, [sc.work_button]
mcall
;;âûâîä çíàêà íà êíîïêó
;;òàê êàê ôóíêöèÿ writeText íå äîëæíà èçìåíÿòü ðåãèñòðû
@ -201,164 +205,164 @@ draw:
;; Äàëåå, òàê êàê òåêñò âûâîäèòñÿ ïî÷òè âñåãäà ñ îäèíàêîâûì
;; ñìåùåíèåì âíèç(ðàâíûì 15) äûííûå(ñòðîêè) èìåþò îäèíàêîâûé
;; ðàçìåð , òî èñïîëüçóåòñÿ èíñòðóêöèÿ add
mov eax,SF_DRAW_TEXT
mov ebx,0x01000020
mov ecx,0x81000000
add ecx,[sc.work_text]
mov edx,_up
mov eax, SF_DRAW_TEXT
mov ebx, 0x01000020
mov ecx, 0x81000000
add ecx, [sc.work_text]
mov edx, _up
mcall
;ñîçäàíèå êíîïêè çàïóñêà/âûêëþ÷åíèÿ ëîãà
mov eax,SF_DEFINE_BUTTON
mov ebx,0x00a00070
mov ecx,0x004a0015
mov edx,0x00000009 ;id button
mov esi,[sc.work_button]
mov eax, SF_DEFINE_BUTTON
mov ebx, 0x00a00070
mov ecx, 0x004a0015
mov edx, 0x00000009 ;id button
mov esi, [sc.work_button]
mcall
; âûâîä òåêñòà
mov eax,SF_DRAW_TEXT
mov ebx,0x00a8004c
mov ecx,0x90000000
add ecx,[sc.work_text]
mov edx,[text_log_butt]
mov eax, SF_DRAW_TEXT
mov ebx, 0x00a8004c
mov ecx, 0x90000000
add ecx, [sc.work_text]
mov edx, [text_log_butt]
mcall
;ñîçäàíèå êíîïêè ñîõðàíåíèÿ ëîãà â ôàéë
mov eax,SF_DEFINE_BUTTON
mov ebx,0x00a00070
mov ecx,0x00630015
mov edx,0x0000000a ; id=10
mov esi,[sc.work_button]
mov eax, SF_DEFINE_BUTTON
mov ebx, 0x00a00070
mov ecx, 0x00630015
mov edx, 0x0000000a ; id=10
mov esi, [sc.work_button]
mcall
; âûâîä òåêñòà
mov eax,SF_DRAW_TEXT
mov ebx,0x00a80065
mov ecx,0x90000000
add ecx,[sc.work_text]
mov edx,_save_log
mov eax, SF_DRAW_TEXT
mov ebx, 0x00a80065
mov ecx, 0x90000000
add ecx, [sc.work_text]
mov edx, _save_log
mcall
;âûâîä "Tctl:"
mov ebx,0x00150035
mov ecx,0x90000000
add ecx,[sc.work_text]
mov edx,_Tctl
mov ebx, 0x00150035
mov ecx, 0x90000000
add ecx, [sc.work_text]
mov edx, _Tctl
mcall
;âûâîä "Tmax:"
add ebx, 0x15
add edx,7
add edx, 7
mcall
;âûâîä "Tcrit hyst:"
;mov ebx,0x0015005f
add ebx, 0x15
add edx,7
add edx, 7
mcall
;âûâîä "Tcrit:"
add ebx,0x15;0x2a
add edx,7
add ebx, 0x15;0x2a
add edx, 7
mcall
;âûâîä "Tdie:"
;mov ebx,0x00150089 ;0x00a5005f
add ebx, 0x15
add edx,7
add edx, 7
mcall
;âûâîä "Tccd1:"
add ebx,0x2b;0x19
add edx,7
add ebx, 0x2b;0x19
add edx, 7
mcall
;âûâîä "Tccd2:"
add ebx,0x15
add edx,7
add ebx, 0x15
add edx, 7
mcall
;âûâîä "Tccd3:"
add ebx,0x15
add edx,7
add ebx, 0x15
add edx, 7
mcall
;âûâîä "Tccd4:"
add ebx,0x15
add edx,7
add ebx, 0x15
add edx, 7
mcall
;âûâîä "Tccd5:"
mov ebx,0x009d00b4
add edx,7
mov ebx, 0x009d00b4
add edx, 7
mcall
;âûâîä "Tccd6:"
add ebx,0x15
add edx,7
add ebx, 0x15
add edx, 7
mcall
;âûâîä "Tccd7:"
add ebx,0x15
add edx,7
add ebx, 0x15
add edx, 7
mcall
;âûâîä "Tccd8:"
add ebx,0x15
add edx,7
add ebx, 0x15
add edx, 7
mcall
;;;;;;input data driver;;;;;;;;;
mov eax,0x004a0035 ;0x004a0020
mov eax, 0x004a0035 ;0x004a0020
mov ebx, drv_data.Tctl ;âûâîä äàííûõ îò äðàéâåðà
call write_data
add eax,0x15
add eax, 0x15
mov byte[write_data.defaunt_color], 1
mov ebx, drv_data.Tmax
call write_data
add eax,0x2a
add eax, 0x2a
mov byte[write_data.defaunt_color], 1
mov ebx, drv_data.Tcrit
call write_data
add eax,0x40;0x19
add eax, 0x40;0x19
mov ebx, drv_data.Tccd1
call write_data
add eax,0x15
add ebx,4
add eax, 0x15
add ebx, 4
call write_data
add eax,0x15
add ebx,4
add eax, 0x15
add ebx, 4
call write_data
add eax,0x15
add ebx,4
add eax, 0x15
add ebx, 4
call write_data
mov eax,0x00d000b4
add ebx,4
mov eax, 0x00d000b4
add ebx, 4
call write_data
add eax,0x15
add ebx,4
add eax, 0x15
add ebx, 4
call write_data
add eax,0x15
add ebx,4
add eax, 0x15
add ebx, 4
call write_data
add eax,0x15
add ebx,4
add eax, 0x15
add ebx, 4
call write_data
mov eax,0x004a0089
mov eax, 0x004a0089
mov ebx, drv_data.Tdie
mov byte[write_data.defaunt_color], 1
call write_data
mov eax,0x004a005f
mov eax, 0x004a005f
mov byte[write_data.defaunt_color], 1
mov ebx, drv_data.Tcrit_hyst
call write_data
@ -375,31 +379,31 @@ draw:
jmp @f
.micro:
mov esi,0x00000035
mov edx,0x000000c0
mov esi, 0x00000035
mov edx, 0x000000c0
mcall
mov eax,SF_DEFINE_BUTTON
mov ebx,0x00a70010
mov ecx,0x001d0015
mov edx,eax;0x00000008
mov esi,[sc.work_button]
mov eax, SF_DEFINE_BUTTON
mov ebx, 0x00a70010
mov ecx, 0x001d0015
mov edx, eax;0x00000008
mov esi, [sc.work_button]
mcall
mov eax,SF_DRAW_TEXT;4
mov ebx,0x000a0020
mov ecx,0x90000000
add ecx,[sc.work_text]
mov edx,_Tctl
mov eax, SF_DRAW_TEXT
mov ebx, 0x000a0020
mov ecx, 0x90000000
add ecx, [sc.work_text]
mov edx, _Tctl
mcall
add ebx,0x00a00000
mov ecx,0x81000000
add ecx,[sc.work_text]
mov edx,_down
add ebx, 0x00a00000
mov ecx, 0x81000000
add ecx, [sc.work_text]
mov edx, _down
mcall
mov eax,0x004a0020
mov eax, 0x004a0020
mov ebx, drv_data.Tctl
call write_data
@@:
@ -417,16 +421,16 @@ write_data:
push eax ;save koord
push ebx ;save *value
;mov edx,[ebx] ;edx=value
mov esi,ebx
cmp dword[ebx],-1 ; flag ziro data
mov ecx,0x90000000
mov ebx,eax
mov esi, ebx
cmp dword[ebx], -1 ; flag ziro data
mov ecx, 0x90000000
mov ebx, eax
jnz @f
;write n/a
add ecx,[sc.work_text]
mov eax,SF_DRAW_TEXT
add ecx, [sc.work_text]
mov eax, SF_DRAW_TEXT
add ebx, 0x00100000
mov edx,_NA
mov edx, _NA
mcall
pop ebx
pop eax
@ -454,15 +458,15 @@ write_data:
div dword[drv_data.Tcrit]
cmp eax, 9
jb @f
mov dword[.color_text],0x00d50000 ; red
mov dword[.color_text], 0x00d50000 ; red
jmp .end_set_color
@@:
cmp eax, 7
jb @f
mov dword[.color_text],0x00f07000 ; orange
mov dword[.color_text], 0x00f07000 ; orange
jmp .end_set_color
@@:
mov dword[.color_text],0x0000a500 ; green
mov dword[.color_text], 0x0000a500 ; green
.end_set_color:
pop ecx
pop edx
@ -477,9 +481,9 @@ write_data:
;value-value_in_1 = value_in_2
;input value_in_2, koord_start+dot_kord+1*size_w(char=8)
push eax ;save koord
mov eax,[esi] ; eax = value
xor edx,edx
mov ebx,1000
mov eax, [esi] ; eax = value
xor edx, edx
mov ebx, 1000
div ebx
cmp eax, 100
jae .dot_4
@ -493,49 +497,49 @@ write_data:
.dot_3: ; <-|
mov edi, 8
.write:
mov ecx,edx
mov ecx, edx
pop edx ; edx = koord
push ecx ;save mask string
shl edi, 16
push edx ; save koord
add edx, edi
mov ecx,eax ;ecx = value/1000
mov ebx,0x80030000 ; ebx = mask sysfn47
mov eax,SF_DRAW_NUMBER
mov esi,0x10000000
add esi,[.color_text]
mov ecx, eax ;ecx = value/1000
mov ebx, 0x80030000 ; ebx = mask sysfn47
mov eax, SF_DRAW_NUMBER
mov esi, 0x10000000
add esi, [.color_text]
mcall
pop ebx ; ebx = koord
add ebx, 0x00180000 ; x + x_size_char*3
mov eax,SF_DRAW_TEXT
mov ecx,0x90000000
add ecx,[.color_text]
mov edx,_dot
mov eax, SF_DRAW_TEXT
mov ecx, 0x90000000
add ecx, [.color_text]
mov edx, _dot
mcall
mov eax,SF_DRAW_NUMBER
mov edx,ebx
mov esi,0x10000000
add esi,[.color_text]
mov ebx,0x00030000
mov eax, SF_DRAW_NUMBER
mov edx, ebx
mov esi, 0x10000000
add esi, [.color_text]
mov ebx, 0x00030000
add edx,0x80000
add edx, 0x80000
pop ecx
mcall
mov eax,SF_DRAW_TEXT
mov ebx,edx
mov ecx,0x80000000
add ecx,[.color_text]
add ebx,0x180000
mov edx,_t
mov eax, SF_DRAW_TEXT
mov ebx, edx
mov ecx, 0x80000000
add ecx, [.color_text]
add ebx, 0x180000
mov edx, _t
mcall
mov ecx,0x90000000
add ecx,[.color_text]
add ebx,0x60000
mov edx,_C
mov ecx, 0x90000000
add ecx, [.color_text]
add ebx, 0x60000
mov edx, _C
mcall
pop ebx
pop eax
@ -555,6 +559,7 @@ exit:
mcall SF_FUTEX, SSF_DESTROY, [futex_handle]
mcall 68, 13, [log_ptr] ; free page
mcall 18, 18, dword[PID_AUTO_SAVE]
mcall SF_TERMINATE_PROCESS
err_load_lib:
@ -654,14 +659,14 @@ thread_timer:
movsd
movsd
; cmp dword[save_file], 0
; jnz .no_save_mode
; push dword[log_path]
; mov eax, [save_ptr]
; mov [log_path], eax
; mcall 70, file_log
; pop dword[log_path]
;.no_save_mode:
cmp dword[save_ptr], 0
jz .no_save_mode
push dword[log_path]
mov eax, [save_ptr]
mov [log_path], eax
mcall 70, file_log
pop dword[log_path]
.no_save_mode:
jmp @b
.err_alloc_2:
send_notify Error_text.alloc_2
@ -675,6 +680,51 @@ thread_timer:
.exit:
mov byte[futex_cmd], 0x00
mcall -1
thread_auto_save:
mcall 40, 0 ;clear event mask
;calculate first data in file(4 value border graphic)
mov eax,[drv_data.Tmax]
mov ebx, graph_start_1.new_data
call int_to_str
;create file
mcall 70, .file
mov dword[.file], 3
mov dword[.log_size], 20
mov dword[.log_offset], 19
mov dword[.log_ptr], graph_start_1.new_data
@@:
mcall 5, 100*60
; add new item in file
push dword[.log_offset]
mov dword[.log_size], 4
mov dword[.log_offset], 2
mov eax,[.index_item]
imul eax,1000
mov ebx, graph_start_1.new_data
call int_to_str
mcall SF_FILE, .file
inc dword[.index_item]
pop dword[.log_offset]
mov dword[.log_size], 20
; get string y koord
mov eax,[drv_data.Tctl]
mov ebx, graph_start_1.new_data_2
call int_to_str
mcall SF_FILE, .file
add dword[.log_offset], 20
jmp @b
mcall -1
.index_item: dd 1
.file:
dd 2
.log_offset: dd 0
dd 0
.log_size: dd 19
.log_ptr: dd graph_start_1
db 0
save_ptr: dd 0 ; pointer to save file or zero
PID_AUTO_SAVE: dd 0 ; for break this thread
;Data_program;
title db 'AMDtemp',0
path_drv db '/kolibrios/drivers/sensors/k10temp.sys',0
@ -725,8 +775,6 @@ log_path: dd openfile_path
futex_handle: dd 0
futex_cmd: dd 0 ;1- stop 2 - save in file & no exit 3 - save in file & exit
;save_file: db 0 ; 0 - no 1 - save ïî ñòàðèíêå
;save_ptr: dd 0 ; pointer to save file
drv_ptr: dd path_drv ; pointer to path on driver
frame_text_1: db 'General info',0
@ -799,6 +847,10 @@ run_notify:
dd 0
db '/sys/@notify',0
align 4
graph_start_1: db '0 0000 0 ' ; 9 byte
.new_data: db '0000.0000 ' ; 10-19 byte 10 byte
.new_data_2: db '0000.0000 ' ; 20-29 byte 10 byte
align 4
graph_start: db '0 0000 0 ' ; 9 byte
.new_data: db '0000.0000 ' ; 10-19 byte 10 byte
.new_data_2: db '0000.0000 ' ; 20-29 byte 10 byte
@ -856,6 +908,8 @@ STACKTOP:
rb 512 ; 512 byte for stack
thread_timer.stack:
rb 512 ; 512 byte for stack
thread_auto_save.stack:
;rb 1024
procinfo process_information
openfile_path:

View File

@ -1,4 +1,5 @@
pars_cmd:
; AMDtemp -s/sd0/4/data/temp/log.grf -d"/sd0/4/data/äàò÷èê òåìïåðàòóðû com ïîðò/sensors.sys"
parse_cmd:
mov edi, PATH
mov ecx, 512
.still:
@ -9,55 +10,46 @@ pars_cmd:
jz .end_parser
dec edi
mov ebx, edi ;save edi
cmp byte[edi],'"'
jnz @f ;.skip_string
mov eax, [save_file]
cmp eax, [.flag_drv]
jae .str_save
or word[edi], 0x2020 ; ïåðåâîäèì â íèæíèé ðåãèñòð
cmp dword[drv_ptr], 0
jnz .err
mov [drv_ptr],edi
inc dword[drv_ptr]
jmp .skip_string
.str_save:
cmp dword[save_ptr], 0
jnz .err
mov [save_ptr],edi
inc dword[save_ptr]
jmp .skip_string
@@:
cmp word[edi], '-s'
jnz @f
cmp word[edi], 's-'
jnz @f
cmp dword[save_file], 0
jnz @f
mov [save_file], edi
@@:
cmp word[edi], 'd-'
jnz @f
cmp dword[.flag_drv], 0
jnz @f
mov [.flag_drv], edi
add edi, 2
sub ecx, 2
call .get_str
mov [save_ptr],eax
jmp .still
@@:
cmp edi, ebx
jz .err
cmp word[edi], '-d'
jnz @f
add edi, 2
sub ecx, 2
call .get_str
mov [drv_ptr],eax
jmp .still
@@:
cmp byte[edi], 0
jnz @f
.end_parser:
ret
@@:
inc edi
jmp .still
.skip_string:
inc edi
.get_str:
push edi
inc dword[esp]
mov al, '"'
rep scasb
test ecx, ecx
jz .err
mov byte[edi-1], 0x00
jmp .still
.err:
or eax, -1
cmp byte[edi], al
jz @f
dec dword[esp]
mov al, ' '
dec edi
@@:
inc edi
repne scasb
and byte[edi - 1], 0
pop eax
ret
.end_parser:
xor eax, eax
ret
.flag_drv: dd 0;don`t using in other code