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,10 +35,11 @@ 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
;load driver
@ -48,9 +49,12 @@ START:
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ìñ
@ -182,7 +186,7 @@ draw:
cmp byte[flag_micro_info], 1
mov eax, SF_CHANGE_WINDOW
mov ebx, -1
mov ecx,ebx;-1
mov ecx, ebx
jz draw.micro
mov esi,0x00000115 ; link with 58 line
@ -386,7 +390,7 @@ draw:
mov esi, [sc.work_button]
mcall
mov eax,SF_DRAW_TEXT;4
mov eax, SF_DRAW_TEXT
mov ebx, 0x000a0020
mov ecx, 0x90000000
add ecx, [sc.work_text]
@ -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