GMon: simple precautions against division-by-zero error

git-svn-id: svn://kolibrios.org@2429 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Artem Jerdev (art_zh) 2012-03-06 22:26:17 +00:00
parent ba28bfb5a8
commit d955a6bf75
2 changed files with 105 additions and 92 deletions

View File

@ -4,13 +4,13 @@
; All Right Reserved ; All Right Reserved
; Integrated Technology Express ; Integrated Technology Express
; Chip Temp Volt Fan ISA SMBus ; Chip Temp Volt Fan ISA SMBus
; it8705 3 8+1* 3 + + ; it8705 3 8+1* 3 + +
; it8712 3 8+1* 3 + + ; it8712 3 8+1* 3 + +
; SiS ; SiS
; Chip Temp Volt Fan ISA SMBus ; Chip Temp Volt Fan ISA SMBus
; sis950 3 8+1* 3 + + ; sis950 3 8+1* 3 + +
; ;
; * - VBAT ; * - VBAT
@ -20,7 +20,7 @@ IT87_FANDIV equ 0x0B
it8705 db 'IT8705F/SiS 950', 0 it8705 db 'IT8705F/SiS 950', 0
it8712 db 'IT8712F', 0 it8712 db 'IT8712F', 0
it8716 db 'IT8716F', 0 it8716 db 'IT8716F', 0
ite_unk db 'Unknown ITE', 0 ite_unk db 'Unknown ITE', 0
ite_coeff: dd 0.016 ; Vcore ite_coeff: dd 0.016 ; Vcore
dd 0.016 ; Vin0 dd 0.016 ; Vin0
@ -41,7 +41,7 @@ it87_init:
call ReservePorts call ReservePorts
jc .no_io jc .no_io
mov eax, 0x55550187 ; ïåðåõîä â MB PnP Mode mov eax, 0x55550187 ; ïåðåõîä â MB PnP Mode
out 0x2e, al out 0x2e, al
shr eax, 8 shr eax, 8
out 0x2e, al out 0x2e, al
@ -87,30 +87,30 @@ it87_init:
clc clc
ret ret
.no_io: stc .no_io: stc
ret ret
; cmp byte[acc_type], 2 ; Only ISA and SMBus ; cmp byte[acc_type], 2 ; Only ISA and SMBus
; jae it87_no ; jae it87_no
;;--- Ïðîâåðÿåì IT87* -------- ;;--- Ïðîâåðÿåì IT87* --------
; mov al, IT87_REGCHIP ; mov al, IT87_REGCHIP
; call [IO_Read] ; call [IO_Read]
; cmp al, IT87_CHIPID ; cmp al, IT87_CHIPID
; jne it87_no ; ýòî íå it87 !!! ; jne it87_no ; ýòî íå it87 !!!
;;-~- not tested ~-~- ;;-~- not tested ~-~-
; mov al, 0x21 ; --- óçíà¸ì èäåíòèôèêàòîð ÷èïà -- ; mov al, 0x21 ; --- óçíà¸ì èäåíòèôèêàòîð ÷èïà --
; call [IO_Read] ; call [IO_Read]
; mov edx, it8705 ; mov edx, it8705
; cmp al, 0x05 ; cmp al, 0x05
; je @f ; je @f
; mov edx, it8712 ; mov edx, it8712
; cmp al, 0x12 ; cmp al, 0x12
; je @f ; je @f
; mov edx, it8716 ; mov edx, it8716
; cmp al, 0x16 ; cmp al, 0x16
; je @f ; je @f
; mov edx, ite_unk ; mov edx, ite_unk
; @@: mov [hwm_chip_name], edx ; @@: mov [hwm_chip_name], edx
;;-~-~-~-~-~-~-~-~-~- ;;-~-~-~-~-~-~-~-~-~-
; clc ; clc
; ret ; ret
@ -167,6 +167,8 @@ it87_get_fan_speed:
pop ecx pop ecx
mov eax, 1350000 mov eax, 1350000
xor edx, edx xor edx, edx
test ebx, ebx
jz @f
div ebx div ebx
mov [hwm_rpms + 4 * ecx], eax mov [hwm_rpms + 4 * ecx], eax
inc ecx inc ecx
@ -180,17 +182,17 @@ it87_get_fan_speed:
; ;
; Volt = A * read_val + B ; Volt = A * read_val + B
; ;
; A, B ; A, B
; --- 0 --- ; --- 0 ---
; dd 0.01565, 0.0 ; VIN0 (Index = 0x20) ; dd 0.01565, 0.0 ; VIN0 (Index = 0x20)
; dd 0.016, 0.0 ; VIN1 (Index = 0x21) ; dd 0.016, 0.0 ; VIN1 (Index = 0x21)
; dd 0.016, 0.0 ; VIN2 (Index = 0x22) ; dd 0.016, 0.0 ; VIN2 (Index = 0x22)
; dd 0.0, 0.0 ; VIN3 (Index = 0x23) ; dd 0.0, 0.0 ; VIN3 (Index = 0x23)
; dd 0.0608, 0.0 ; VIN4 (Index = 0x24) ; dd 0.0608, 0.0 ; VIN4 (Index = 0x24)
; dd 0.0, 0.0 ; VIN5 (Index = 0x25) ; dd 0.0, 0.0 ; VIN5 (Index = 0x25)
; dd 0.0, 0.0 ; VIN6 (Index = 0x26) ; dd 0.0, 0.0 ; VIN6 (Index = 0x26)
; dd 0.08224, -22.104 ; VIN7 (Index = 0x27) ; dd 0.08224, -22.104 ; VIN7 (Index = 0x27)
; dd 0.016, 0.0 ; VBAT (Index = 0x28) ; dd 0.016, 0.0 ; VBAT (Index = 0x28)
; --- 1 --- ; --- 1 ---
; dd 0.01614, 0.0 ; dd 0.01614, 0.0

View File

@ -1,38 +1,38 @@
; ;
; Ghost Monitor - утилита (стресс) тестирования и мониторинга системы ; Ghost Monitor - ã⨫¨â  (áâà¥áá) â¥áâ¨à®¢ ­¨ï ¨ ¬®­¨â®à¨­£  á¨á⥬ë
; Copyright (C) 2005, 2006, 2007 Mihailov Ilia (ghost.nsk@mail.ru) ; Copyright (C) 2005, 2006, 2007 Mihailov Ilia (ghost.nsk@mail.ru)
; All Right Reserved ; All Right Reserved
; ;
; Библиотека для чипов WinBond ; <EFBFBD>¨¡«¨®â¥ª  ¤«ï 稯®¢ WinBond
; ;
; ;
; Дописать получение инфы с других датчиков ; „®¯¨á âì ¯®«ã祭¨¥ ¨­äë á ¤àã£¨å ¤ â稪®¢
; W83627DHG мониторинг аналогичен W83627EHF, дописать учёт DIV_B2 ; W83627DHG ¬®­¨â®à¨­£  ­ «®£¨ç¥­ W83627EHF, ¤®¯¨á âì ãçñâ DIV_B2
; + 16.03.06 Исправлена ошибка в wb_get_cpu_temper с десятых градуса (было 30.5 30.0 31.5 ...) ; + 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 ; D - SuperIO supporting Intel* PECI* & SST* interfaces, U - UART
; ;
; | Chip name | ID Vin Fanin PWM Temp ISA SMBus ; | Chip name | ID Vin Fanin PWM Temp ISA SMBus
msg_wb27HF: db 'W83627HF', 0 ; 0x20|0x21 9 3 2 3 + + msg_wb27HF: db 'W83627HF', 0 ; 0x20|0x21 9 3 2 3 + +
msg_wb27THF: db 'W83627THF', 0 ; 0x90|0x91 7 3 3 3 + + msg_wb27THF: db 'W83627THF', 0 ; 0x90|0x91 7 3 3 3 + +
msg_wb37THF: db 'W83637THF', 0 ; 0x80 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_wb97HF: db 'W83697HF', 0 ; 0x60|0x61 8 2 2 2 + -
msg_wb27THFA: db 'W83627THF-A', 0 ; 0x1A msg_wb27THFA: db 'W83627THF-A', 0 ; 0x1A
msg_w83627DHG: db 'W83627DHG', 0 ; 0xC1 ? 5 ? 3 + + msg_w83627DHG: db 'W83627DHG', 0 ; 0xC1 ? 5 ? 3 + +
msg_w83627EHF: db 'W83627EHF', 0 ; 0x88 10 5 3 3 + + msg_w83627EHF: db 'W83627EHF', 0 ; 0x88 10 5 3 3 + +
msg_w83627EHG: db 'W83627EHG', 0 ; 0xA1 10 5 3 3 + + msg_w83627EHG: db 'W83627EHG', 0 ; 0xA1 10 5 3 3 + +
; db 'W83781D', 0 ; 0x10|0x11 7 3 3 + + ; db 'W83781D', 0 ; 0x10|0x11 7 3 3 + +
; db 'W83782D', 0 ; 0x30 9 3 3 + + ; db 'W83782D', 0 ; 0x30 9 3 3 + +
; db 'AS99127F', 0 ; 0x31 7 3 3 - + ; db 'AS99127F', 0 ; 0x31 7 3 3 - +
; db 'W83783S', 0 ; 0x40|0x41 5-6 3 1-2 - + ; db 'W83783S', 0 ; 0x40|0x41 5-6 3 1-2 - +
; db 'W83791D', 0 ; 0x70|0x71 10 5 3 - + ; db 'W83791D', 0 ; 0x70|0x71 10 5 3 - +
msg_wbunk: db 'Unknown Winbond', 0 ; other, non zero ;-) msg_wbunk: db 'Unknown Winbond', 0 ; other, non zero ;-)
uglobal uglobal
wb_fans_num db 0 wb_fans_num db 0
@ -40,7 +40,7 @@ endg
;----------------------------------- ;-----------------------------------
wb_init: wb_init:
; Проверка наличия и инициализация ; <EFBFBD>஢¥àª  ­ «¨ç¨ï ¨ ¨­¨æ¨ «¨§ æ¨ï
; OUT - CF = 1 - error ; OUT - CF = 1 - error
cmp byte[acc_type], 2 ; Only ISA and SMBus cmp byte[acc_type], 2 ; Only ISA and SMBus
jae wb_no jae wb_no
@ -57,9 +57,9 @@ wb_init:
mov al, 0x4f mov al, 0x4f
call [IO_Read] call [IO_Read]
cmp ax, 0xa35c cmp ax, 0xa35c
jne wb_no ; это не Winbond !!! jne wb_no ; íâ® ­¥ Winbond !!!
; --- узнаём идентификатор чипа -- ; --- 㧭 ñ¬ ¨¤¥­â¨ä¨ª â®à 稯  --
mov al, 0x58 mov al, 0x58
call [IO_Read] call [IO_Read]
and al, 0xFE ; 0x20 = 0x21, 0x60 = 0x61, etc and al, 0xFE ; 0x20 = 0x21, 0x60 = 0x61, etc
@ -111,13 +111,13 @@ wb_getparam:
;----------------------------------- ;-----------------------------------
wb_get_temp: wb_get_temp:
; temp 1 ; temp 1
mov al, 0x4e ; Выбираем bank 1 mov al, 0x4e ; ‚롨ࠥ¬ bank 1
mov bl, 1 mov bl, 1
call [IO_Write] call [IO_Write]
mov al, 0x50 ; Получаем старший байт температуры (градусы) mov al, 0x50 ; <EFBFBD>®«ãç ¥¬ áâ à訩 ¡ ©â ⥬¯¥à âãàë (£à ¤ãáë)
call [IO_Read] call [IO_Read]
mov [hwm_temps], al mov [hwm_temps], al
mov al, 0x51 ; Получаем младший байт температуры (x.5`C) mov al, 0x51 ; <EFBFBD>®«ãç ¥¬ ¬« ¤è¨© ¡ ©â ⥬¯¥à âãàë (x.5`C)
call [IO_Read] call [IO_Read]
cmp al, 0 ; if al == 0 then x.0, else x.5 cmp al, 0 ; if al == 0 then x.0, else x.5
je @f je @f
@ -125,28 +125,28 @@ wb_get_temp:
@@: mov [hwm_temps + 1], al @@: mov [hwm_temps + 1], al
; temp 2 (3 SYSTIN) ; temp 2 (3 SYSTIN)
mov al, 0x4e ; Выбираем bank 0 mov al, 0x4e ; ‚롨ࠥ¬ bank 0
xor bl, bl xor bl, bl
call [IO_Write] call [IO_Write]
mov al, 0x27 ; Получаем старший байт температуры (градусы) mov al, 0x27 ; <EFBFBD>®«ãç ¥¬ áâ à訩 ¡ ©â ⥬¯¥à âãàë (£à ¤ãáë)
call [IO_Read] call [IO_Read]
mov [hwm_temps + 2], al mov [hwm_temps + 2], al
; temp 3 (VTIN) ; temp 3 (VTIN)
mov al, 0x4e ; Выбираем bank 2 mov al, 0x4e ; ‚롨ࠥ¬ bank 2
mov bl, 2 mov bl, 2
call [IO_Write] call [IO_Write]
mov al, 0x50 ; Получаем старший байт температуры (градусы) mov al, 0x50 ; <EFBFBD>®«ãç ¥¬ áâ à訩 ¡ ©â ⥬¯¥à âãàë (£à ¤ãáë)
call [IO_Read] call [IO_Read]
mov [hwm_temps + 4], al mov [hwm_temps + 4], al
mov al, 0x51 ; Получаем младший байт температуры (x.5`C) mov al, 0x51 ; <EFBFBD>®«ãç ¥¬ ¬« ¤è¨© ¡ ©â ⥬¯¥à âãàë (x.5`C)
call [IO_Read] call [IO_Read]
cmp al, 0 ; if al == 0 then x.0, else x.5 cmp al, 0 ; if al == 0 then x.0, else x.5
je @f je @f
mov al, 5 mov al, 5
@@: mov [hwm_temps + 5], al @@: mov [hwm_temps + 5], al
; Проверка температуры, датчики с 127.5`C не используются ; <EFBFBD>஢¥àª  ⥬¯¥à âãàë, ¤ â稪¨ á 127.5`C ­¥ ¨á¯®«ì§ãîâáï
mov ecx, 3 mov ecx, 3
mov esi, hwm_temps mov esi, hwm_temps
wb_check_temp: wb_check_temp:
@ -166,7 +166,7 @@ wb_get_fan_speed:
shr al, 4 shr al, 4
mov ebx, 1 mov ebx, 1
mov cl, al mov cl, al
shl ebx, cl ; <- div1 shl ebx, cl ; <- div1
xor eax, eax xor eax, eax
mov al, 0x28 mov al, 0x28
call [IO_Read] call [IO_Read]
@ -178,6 +178,8 @@ wb_get_fan_speed:
mov ebx, eax mov ebx, eax
mov eax, 1350000 mov eax, 1350000
xor edx, edx xor edx, edx
test ebx, ebx
jz .div0
div ebx div ebx
mov [hwm_rpms], eax mov [hwm_rpms], eax
@ -186,18 +188,21 @@ wb_get_fan_speed:
shr al, 6 shr al, 6
mov ebx, 1 mov ebx, 1
mov cl, al mov cl, al
shl ebx, cl ; <- div2 shl ebx, cl ; <- div2
xor eax, eax xor eax, eax
mov al, 0x29 mov al, 0x29
call [IO_Read] call [IO_Read]
cmp al, 255 cmp al, 255
jne @f jne @f
xor eax, eax xor eax, eax
.div0:
ret ret
@@: mul ebx @@: mul ebx
mov ebx, eax mov ebx, eax
mov eax, 1350000 mov eax, 1350000
xor edx, edx xor edx, edx
test ebx, ebx
jz .div0
div ebx div ebx
mov [hwm_rpms + 4], eax mov [hwm_rpms + 4], eax
@ -206,7 +211,7 @@ wb_get_fan_speed:
shr al, 6 shr al, 6
mov ebx, 1 mov ebx, 1
mov cl, al mov cl, al
shl ebx, cl ; <- div3 shl ebx, cl ; <- div3
xor eax, eax xor eax, eax
mov al, 0x2A mov al, 0x2A
call [IO_Read] call [IO_Read]
@ -218,6 +223,8 @@ wb_get_fan_speed:
mov ebx, eax mov ebx, eax
mov eax, 1350000 mov eax, 1350000
xor edx, edx xor edx, edx
test ebx, ebx
jz .div0
div ebx div ebx
mov [hwm_rpms + 8], eax mov [hwm_rpms + 8], eax
@ -229,7 +236,7 @@ wb_get_fan_speed:
and al, 3 and al, 3
mov ebx, 1 mov ebx, 1
mov cl, al mov cl, al
shl ebx, cl ; <- div4, дописать учёт DIV_B2 shl ebx, cl ; <- div4, ¤®¯¨á âì ãçñâ DIV_B2
xor eax, eax xor eax, eax
mov al, 0x3F mov al, 0x3F
call [IO_Read] call [IO_Read]
@ -241,6 +248,8 @@ wb_get_fan_speed:
mov ebx, eax mov ebx, eax
mov eax, 1350000 mov eax, 1350000
xor edx, edx xor edx, edx
test ebx, ebx
jz .div0
div ebx div ebx
mov [hwm_rpms + 12], eax mov [hwm_rpms + 12], eax
@ -250,9 +259,9 @@ wb_get_fan_speed:
and al, 3 and al, 3
mov ebx, 1 mov ebx, 1
mov cl, al mov cl, al
shl ebx, cl ; <- div5, дописать учёт DIV_B2 shl ebx, cl ; <- div5, ¤®¯¨á âì ãçñâ DIV_B2
xor eax, eax xor eax, eax
mov al, 0x4e ; Выбираем bank 5 mov al, 0x4e ; ‚롨ࠥ¬ bank 5
mov bl, 5 mov bl, 5
call [IO_Write] call [IO_Write]
mov al, 0x53 mov al, 0x53
@ -265,6 +274,8 @@ wb_get_fan_speed:
mov ebx, eax mov ebx, eax
mov eax, 1350000 mov eax, 1350000
xor edx, edx xor edx, edx
test ebx, ebx
jz .wb_f_e
div ebx div ebx
mov [hwm_rpms + 16], eax mov [hwm_rpms + 16], eax
@ -272,7 +283,7 @@ wb_get_fan_speed:
ret ret
;----------------------------------- ;-----------------------------------
wb_get_volt: 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 mov esi, hwm_voltages
xor ecx, ecx xor ecx, ecx
@@: mov eax, ecx @@: mov eax, ecx