From d955a6bf755b410f87a2b8a38642a57782eaf7c6 Mon Sep 17 00:00:00 2001 From: "Artem Jerdev (art_zh)" Date: Tue, 6 Mar 2012 22:26:17 +0000 Subject: [PATCH] GMon: simple precautions against division-by-zero error git-svn-id: svn://kolibrios.org@2429 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/system/gmon/hwm_it87.inc | 90 +++++++++++++------------ programs/system/gmon/hwm_wb.inc | 107 ++++++++++++++++-------------- 2 files changed, 105 insertions(+), 92 deletions(-) diff --git a/programs/system/gmon/hwm_it87.inc b/programs/system/gmon/hwm_it87.inc index cf0b66fbd8..f6fe679a1c 100644 --- a/programs/system/gmon/hwm_it87.inc +++ b/programs/system/gmon/hwm_it87.inc @@ -4,13 +4,13 @@ ; All Right Reserved ; Integrated Technology Express -; Chip Temp Volt Fan ISA SMBus -; it8705 3 8+1* 3 + + -; it8712 3 8+1* 3 + + +; Chip Temp Volt Fan ISA SMBus +; it8705 3 8+1* 3 + + +; it8712 3 8+1* 3 + + ; SiS -; Chip Temp Volt Fan ISA SMBus -; sis950 3 8+1* 3 + + +; Chip Temp Volt Fan ISA SMBus +; sis950 3 8+1* 3 + + ; ; * - VBAT @@ -20,7 +20,7 @@ IT87_FANDIV equ 0x0B it8705 db 'IT8705F/SiS 950', 0 it8712 db 'IT8712F', 0 it8716 db 'IT8716F', 0 -ite_unk db 'Unknown ITE', 0 +ite_unk db 'Unknown ITE', 0 ite_coeff: dd 0.016 ; Vcore dd 0.016 ; Vin0 @@ -41,7 +41,7 @@ it87_init: call ReservePorts jc .no_io - mov eax, 0x55550187 ; переход в MB PnP Mode + mov eax, 0x55550187 ; переход в MB PnP Mode out 0x2e, al shr eax, 8 out 0x2e, al @@ -63,16 +63,16 @@ it87_init: mov al, 0x02 ; выход из режима out 0x2E, al out 0x2F, al - + mov ecx, 0x2e mov edx, 0x2f call FreePorts - + pop eax pop ebx cmp bl, 0x87 jne .no_io - + mov edx, it8705 cmp al, 0x05 je @f @@ -85,32 +85,32 @@ it87_init: mov edx, ite_unk @@: mov [hwm_chip_name], edx clc - ret - -.no_io: stc ret - ; cmp byte[acc_type], 2 ; Only ISA and SMBus - ; jae it87_no +.no_io: stc + ret + + ; cmp byte[acc_type], 2 ; Only ISA and SMBus + ; jae it87_no ;;--- Проверяем IT87* -------- - ; mov al, IT87_REGCHIP - ; call [IO_Read] - ; cmp al, IT87_CHIPID - ; jne it87_no ; это не it87 !!! + ; mov al, IT87_REGCHIP + ; call [IO_Read] + ; cmp al, IT87_CHIPID + ; jne it87_no ; это не it87 !!! ;;-~- not tested ~-~- - ; mov al, 0x21 ; --- узнаём идентификатор чипа -- - ; call [IO_Read] - ; mov edx, it8705 - ; cmp al, 0x05 - ; je @f - ; mov edx, it8712 - ; cmp al, 0x12 - ; je @f - ; mov edx, it8716 - ; cmp al, 0x16 - ; je @f - ; mov edx, ite_unk -; @@: mov [hwm_chip_name], edx + ; mov al, 0x21 ; --- узнаём идентификатор чипа -- + ; call [IO_Read] + ; mov edx, it8705 + ; cmp al, 0x05 + ; je @f + ; mov edx, it8712 + ; cmp al, 0x12 + ; je @f + ; mov edx, it8716 + ; cmp al, 0x16 + ; je @f + ; mov edx, ite_unk +; @@: mov [hwm_chip_name], edx ;;-~-~-~-~-~-~-~-~-~- ; clc ; ret @@ -154,11 +154,11 @@ it87_get_fan_speed: @@: mov al, 0x0D add al, cl call [IO_Read] - + test al, al jz @f cmp al, 0xff - je @f + je @f movzx ebx, al push ecx @@ -167,6 +167,8 @@ it87_get_fan_speed: pop ecx mov eax, 1350000 xor edx, edx + test ebx, ebx + jz @f div ebx mov [hwm_rpms + 4 * ecx], eax inc ecx @@ -180,17 +182,17 @@ it87_get_fan_speed: ; ; Volt = A * read_val + B ; -; A, B +; A, B ; --- 0 --- -; dd 0.01565, 0.0 ; VIN0 (Index = 0x20) -; dd 0.016, 0.0 ; VIN1 (Index = 0x21) -; dd 0.016, 0.0 ; VIN2 (Index = 0x22) -; dd 0.0, 0.0 ; VIN3 (Index = 0x23) -; dd 0.0608, 0.0 ; VIN4 (Index = 0x24) -; dd 0.0, 0.0 ; VIN5 (Index = 0x25) -; dd 0.0, 0.0 ; VIN6 (Index = 0x26) -; dd 0.08224, -22.104 ; VIN7 (Index = 0x27) -; dd 0.016, 0.0 ; VBAT (Index = 0x28) +; dd 0.01565, 0.0 ; VIN0 (Index = 0x20) +; dd 0.016, 0.0 ; VIN1 (Index = 0x21) +; dd 0.016, 0.0 ; VIN2 (Index = 0x22) +; dd 0.0, 0.0 ; VIN3 (Index = 0x23) +; dd 0.0608, 0.0 ; VIN4 (Index = 0x24) +; dd 0.0, 0.0 ; VIN5 (Index = 0x25) +; dd 0.0, 0.0 ; VIN6 (Index = 0x26) +; dd 0.08224, -22.104 ; VIN7 (Index = 0x27) +; dd 0.016, 0.0 ; VBAT (Index = 0x28) ; --- 1 --- ; dd 0.01614, 0.0 diff --git a/programs/system/gmon/hwm_wb.inc b/programs/system/gmon/hwm_wb.inc index 493355ce35..ae936dbef4 100644 --- a/programs/system/gmon/hwm_wb.inc +++ b/programs/system/gmon/hwm_wb.inc @@ -1,38 +1,38 @@ ; -; Ghost Monitor - утилита (стресс) тестирования и мониторинга системы +; Ghost Monitor - гвЁ«Ёв  (бваҐбб) вҐбвЁа®ў ­Ёп Ё ¬®­Ёв®аЁ­Ј  бЁб⥬л ; Copyright (C) 2005, 2006, 2007 Mihailov Ilia (ghost.nsk@mail.ru) ; All Right Reserved ; -; Библиотека для чипов WinBond +; ЃЁЎ«Ё®вҐЄ  ¤«п зЁЇ®ў WinBond ; ; -; Дописать получение инфы с других датчиков -; W83627DHG мониторинг аналогичен W83627EHF, дописать учёт DIV_B2 -; + 16.03.06 Исправлена ошибка в wb_get_cpu_temper с десятых градуса (было 30.5 30.0 31.5 ...) +; „®ЇЁб вм Ї®«г祭ЁҐ Ё­дл б ¤агЈЁе ¤ взЁЄ®ў +; W83627DHG ¬®­Ёв®аЁ­Ј  ­ «®ЈЁзҐ­ W83627EHF, ¤®ЇЁб вм гзсв DIV_B2 +; + 16.03.06 €бЇа ў«Ґ­  ®иЁЎЄ  ў wb_get_cpu_temper б ¤Ґбпвле Ја ¤гб  (Ўл«® 30.5 30.0 31.5 ...) ; ; -; О маркировке (?) : H - H/W Monitor, G - Pb-free package, T - ACPI, S - Smart Card Reader Interface +; Ћ ¬ аЄЁа®ўЄҐ (?) : H - H/W Monitor, G - Pb-free package, T - ACPI, S - Smart Card Reader Interface ; D - SuperIO supporting Intel* PECI* & SST* interfaces, U - UART ; -; | Chip name | ID Vin Fanin PWM Temp ISA SMBus -msg_wb27HF: db 'W83627HF', 0 ; 0x20|0x21 9 3 2 3 + + -msg_wb27THF: db 'W83627THF', 0 ; 0x90|0x91 7 3 3 3 + + -msg_wb37THF: db 'W83637THF', 0 ; 0x80 7 3 3 3 + + -msg_wb97HF: db 'W83697HF', 0 ; 0x60|0x61 8 2 2 2 + - +; | Chip name | ID Vin Fanin PWM Temp ISA SMBus +msg_wb27HF: db 'W83627HF', 0 ; 0x20|0x21 9 3 2 3 + + +msg_wb27THF: db 'W83627THF', 0 ; 0x90|0x91 7 3 3 3 + + +msg_wb37THF: db 'W83637THF', 0 ; 0x80 7 3 3 3 + + +msg_wb97HF: db 'W83697HF', 0 ; 0x60|0x61 8 2 2 2 + - msg_wb27THFA: db 'W83627THF-A', 0 ; 0x1A -msg_w83627DHG: db 'W83627DHG', 0 ; 0xC1 ? 5 ? 3 + + -msg_w83627EHF: db 'W83627EHF', 0 ; 0x88 10 5 3 3 + + -msg_w83627EHG: db 'W83627EHG', 0 ; 0xA1 10 5 3 3 + + +msg_w83627DHG: db 'W83627DHG', 0 ; 0xC1 ? 5 ? 3 + + +msg_w83627EHF: db 'W83627EHF', 0 ; 0x88 10 5 3 3 + + +msg_w83627EHG: db 'W83627EHG', 0 ; 0xA1 10 5 3 3 + + -; db 'W83781D', 0 ; 0x10|0x11 7 3 3 + + -; db 'W83782D', 0 ; 0x30 9 3 3 + + -; db 'AS99127F', 0 ; 0x31 7 3 3 - + -; db 'W83783S', 0 ; 0x40|0x41 5-6 3 1-2 - + -; db 'W83791D', 0 ; 0x70|0x71 10 5 3 - + -msg_wbunk: db 'Unknown Winbond', 0 ; other, non zero ;-) +; db 'W83781D', 0 ; 0x10|0x11 7 3 3 + + +; db 'W83782D', 0 ; 0x30 9 3 3 + + +; db 'AS99127F', 0 ; 0x31 7 3 3 - + +; db 'W83783S', 0 ; 0x40|0x41 5-6 3 1-2 - + +; db 'W83791D', 0 ; 0x70|0x71 10 5 3 - + +msg_wbunk: db 'Unknown Winbond', 0 ; other, non zero ;-) uglobal wb_fans_num db 0 @@ -40,7 +40,7 @@ endg ;----------------------------------- wb_init: -; Проверка наличия и инициализация +; Џа®ўҐаЄ  ­ «ЁзЁп Ё Ё­ЁжЁ «Ё§ жЁп ; OUT - CF = 1 - error cmp byte[acc_type], 2 ; Only ISA and SMBus jae wb_no @@ -53,13 +53,13 @@ wb_init: mov ah, al ;! mov al, 0x4e mov bl, 0x80 - call [IO_Write] + call [IO_Write] mov al, 0x4f call [IO_Read] cmp ax, 0xa35c - jne wb_no ; это не Winbond !!! + jne wb_no ; нв® ­Ґ Winbond !!! - ; --- узнаём идентификатор чипа -- + ; --- г§­ с¬ Ё¤Ґ­вЁдЁЄ в®а зЁЇ  -- mov al, 0x58 call [IO_Read] and al, 0xFE ; 0x20 = 0x21, 0x60 = 0x61, etc @@ -111,13 +111,13 @@ wb_getparam: ;----------------------------------- wb_get_temp: ; temp 1 - mov al, 0x4e ; Выбираем bank 1 + mov al, 0x4e ; ‚лЎЁа Ґ¬ bank 1 mov bl, 1 call [IO_Write] - mov al, 0x50 ; Получаем старший байт температуры (градусы) + mov al, 0x50 ; Џ®«гз Ґ¬ бв аиЁ© Ў ©в ⥬ЇҐа вгал (Ја ¤гбл) call [IO_Read] mov [hwm_temps], al - mov al, 0x51 ; Получаем младший байт температуры (x.5`C) + mov al, 0x51 ; Џ®«гз Ґ¬ ¬« ¤иЁ© Ў ©в ⥬ЇҐа вгал (x.5`C) call [IO_Read] cmp al, 0 ; if al == 0 then x.0, else x.5 je @f @@ -125,28 +125,28 @@ wb_get_temp: @@: mov [hwm_temps + 1], al ; temp 2 (3 SYSTIN) - mov al, 0x4e ; Выбираем bank 0 + mov al, 0x4e ; ‚лЎЁа Ґ¬ bank 0 xor bl, bl call [IO_Write] - mov al, 0x27 ; Получаем старший байт температуры (градусы) + mov al, 0x27 ; Џ®«гз Ґ¬ бв аиЁ© Ў ©в ⥬ЇҐа вгал (Ја ¤гбл) call [IO_Read] mov [hwm_temps + 2], al - + ; temp 3 (VTIN) - mov al, 0x4e ; Выбираем bank 2 + mov al, 0x4e ; ‚лЎЁа Ґ¬ bank 2 mov bl, 2 call [IO_Write] - mov al, 0x50 ; Получаем старший байт температуры (градусы) + mov al, 0x50 ; Џ®«гз Ґ¬ бв аиЁ© Ў ©в ⥬ЇҐа вгал (Ја ¤гбл) call [IO_Read] mov [hwm_temps + 4], al - mov al, 0x51 ; Получаем младший байт температуры (x.5`C) + mov al, 0x51 ; Џ®«гз Ґ¬ ¬« ¤иЁ© Ў ©в ⥬ЇҐа вгал (x.5`C) call [IO_Read] cmp al, 0 ; if al == 0 then x.0, else x.5 je @f mov al, 5 @@: mov [hwm_temps + 5], al - ; Проверка температуры, датчики с 127.5`C не используются + ; Џа®ўҐаЄ  ⥬ЇҐа вгал, ¤ взЁЄЁ б 127.5`C ­Ґ ЁбЇ®«м§говбп mov ecx, 3 mov esi, hwm_temps wb_check_temp: @@ -155,7 +155,7 @@ wb_check_temp: mov word[esi + ecx * 2 - 2], 0 wb_temp_ok: loop wb_check_temp - + ret ;----------------------------------- wb_get_fan_speed: @@ -166,7 +166,7 @@ wb_get_fan_speed: shr al, 4 mov ebx, 1 mov cl, al - shl ebx, cl ; <- div1 + shl ebx, cl ; <- div1 xor eax, eax mov al, 0x28 call [IO_Read] @@ -178,35 +178,40 @@ wb_get_fan_speed: mov ebx, eax mov eax, 1350000 xor edx, edx + test ebx, ebx + jz .div0 div ebx mov [hwm_rpms], eax - + mov al, 0x47 call [IO_Read] shr al, 6 mov ebx, 1 mov cl, al - shl ebx, cl ; <- div2 + shl ebx, cl ; <- div2 xor eax, eax mov al, 0x29 call [IO_Read] cmp al, 255 jne @f xor eax, eax +.div0: ret @@: mul ebx mov ebx, eax mov eax, 1350000 xor edx, edx + test ebx, ebx + jz .div0 div ebx mov [hwm_rpms + 4], eax - + mov al, 0x4B call [IO_Read] shr al, 6 mov ebx, 1 mov cl, al - shl ebx, cl ; <- div3 + shl ebx, cl ; <- div3 xor eax, eax mov al, 0x2A call [IO_Read] @@ -218,6 +223,8 @@ wb_get_fan_speed: mov ebx, eax mov eax, 1350000 xor edx, edx + test ebx, ebx + jz .div0 div ebx mov [hwm_rpms + 8], eax @@ -229,7 +236,7 @@ wb_get_fan_speed: and al, 3 mov ebx, 1 mov cl, al - shl ebx, cl ; <- div4, дописать учёт DIV_B2 + shl ebx, cl ; <- div4, ¤®ЇЁб вм гзсв DIV_B2 xor eax, eax mov al, 0x3F call [IO_Read] @@ -241,18 +248,20 @@ wb_get_fan_speed: mov ebx, eax mov eax, 1350000 xor edx, edx + test ebx, ebx + jz .div0 div ebx mov [hwm_rpms + 12], eax - + mov al, 0x59 call [IO_Read] shr al, 2 and al, 3 mov ebx, 1 mov cl, al - shl ebx, cl ; <- div5, дописать учёт DIV_B2 + shl ebx, cl ; <- div5, ¤®ЇЁб вм гзсв DIV_B2 xor eax, eax - mov al, 0x4e ; Выбираем bank 5 + mov al, 0x4e ; ‚лЎЁа Ґ¬ bank 5 mov bl, 5 call [IO_Write] mov al, 0x53 @@ -265,6 +274,8 @@ wb_get_fan_speed: mov ebx, eax mov eax, 1350000 xor edx, edx + test ebx, ebx + jz .wb_f_e div ebx mov [hwm_rpms + 16], eax @@ -272,7 +283,7 @@ wb_get_fan_speed: ret ;----------------------------------- wb_get_volt: - ;mov edi, wb_coeff ; <-- possible differences for miscellaneous chip + ;mov edi, wb_coeff ; <-- possible differences for miscellaneous chip mov esi, hwm_voltages xor ecx, ecx @@: mov eax, ecx @@ -296,8 +307,8 @@ wb_coeff: dd 0.016 ; Vcore dd 0.0608 ; Vin2 (+12V) dd 0.0822857142857145 ; -12V dd -0.02408 ; -5V ; false - + wb_n12v_const dd -14.9142857142857 - - + +