Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3007 | art_zh | 1 | ; |
2 | ; Ghost Monitor - утилита (стресс) тестирования и мониторинга системы |
||
3 | ; Copyright (C) 2005, 2006, 2007 Mihailov Ilia (ghost.nsk@mail.ru) |
||
4 | ; All Right Reserved |
||
5 | |||
6 | ; |
||
7 | ; Библиотека для чипов Hudson |
||
8 | ; |
||
9 | ; |
||
10 | ; |
||
11 | ; | Chip name | ID Vin Fanin PWM Temp ISA SMBus |
||
12 | msg_A50: db 'AMD Hudson A50', 0 ; 0x20|0x21 9 3 2 3 + + |
||
13 | msg_A55: db 'AMD Hudson A55', 0 ; 0x20|0x21 9 3 2 3 + + |
||
14 | |||
15 | msg_amdunk: db 'Unknown AMD', 0 ; other, non zero ;-) |
||
16 | |||
17 | uglobal |
||
18 | wb_fans_num db 0 |
||
19 | endg |
||
20 | |||
21 | ;----------------------------------- |
||
22 | hudson_init: |
||
23 | ; Проверка наличия и инициализация |
||
24 | ; OUT - CF = 1 - error |
||
25 | |||
26 | mov ebx, 0xF00C3000 |
||
27 | mov eax, [ebx] |
||
28 | cmp eax, 0x17031022 |
||
29 | jne .not_found ; not a Fusion! |
||
30 | |||
31 | mov byte[wb_fans_num], 3 |
||
32 | mov edx, msg_A55 |
||
33 | @@: mov [hwm_chip_name], edx |
||
34 | mov dword[hwm_enable],1 |
||
35 | mov al, 0xE6 |
||
36 | mov bl, 0x0A |
||
37 | call pm2write ; init PWM_Control register |
||
38 | |||
39 | |||
40 | clc |
||
41 | ret |
||
42 | .not_found: stc |
||
43 | ret |
||
44 | |||
45 | ;----------------------------------- |
||
46 | hudson_getparam: |
||
47 | call hudson_get_temp |
||
48 | call hudson_get_fan_speed |
||
49 | mov edi, hudson_coeff |
||
50 | call hudson_get_volt |
||
51 | fld dword[V12] |
||
52 | fld dword[hudson_n12v_const] |
||
53 | faddp st1, st0 |
||
54 | fstp dword[V12] |
||
55 | ret |
||
56 | ;----------------------------------- |
||
57 | hudson_get_temp: |
||
58 | ; temp 1 |
||
59 | mov ebx, 0xF00C3000 |
||
60 | mov eax, [ebx+0xA4] |
||
61 | mov edx, eax |
||
62 | shr edx, 24 |
||
63 | mov [hwm_temps], dl ; integer degrees |
||
64 | mov edx, eax |
||
65 | shr edx, 21 |
||
66 | and dl, 7 ; 1/8th fractions of degree |
||
67 | cmp dl, 3 ; round 3/8 upto 0.4 |
||
68 | jb .corrected |
||
69 | inc dl |
||
70 | cmp dl, 8 ; 7/8 ~ 0.9 |
||
71 | jb .corrected |
||
72 | inc dl |
||
73 | .corrected: |
||
74 | mov [hwm_temps + 1], dl |
||
75 | |||
76 | ; temp 2 (3 SYSTIN) |
||
77 | xor ebx, ebx |
||
78 | mov al, 0x95 |
||
79 | call pm2read |
||
80 | mov bl, al |
||
81 | mov al, 0x96 ; SB internal sensor |
||
82 | call pm2read |
||
83 | mov bh, al |
||
84 | mov [hudson_temp_read], ebx |
||
85 | fild dword[hudson_temp_read] |
||
86 | fmul dword[hudson_temp_coef] |
||
87 | fidiv dword[hudson_int_64] |
||
88 | fadd dword[hudson_temp_offs] |
||
89 | fimul dword[hudson_int_2] |
||
90 | fistp dword[hudson_temp_read] |
||
91 | mov bx, word[hudson_temp_read] |
||
92 | mov ax, bx |
||
93 | xor bh, bh |
||
94 | shr eax, 1 |
||
95 | mov byte[hwm_temps + 2], al |
||
96 | or bl, 1 |
||
97 | jz @f |
||
98 | mov bh, 5 |
||
99 | mov byte[hwm_temps + 3], bh |
||
100 | |||
101 | |||
102 | ; temp 3 (VTIN) |
||
103 | xor ebx, ebx |
||
104 | mov al, 0xA1 |
||
105 | call pm2read |
||
106 | mov bl, al |
||
107 | mov al, 0xA2 ; temp sensor #2 |
||
108 | call pm2read |
||
109 | mov bh, al |
||
110 | mov [hudson_temp_read], ebx |
||
111 | fild dword[hudson_temp_read] |
||
112 | fmul dword[hudson_temp_coef] |
||
113 | fidiv dword[hudson_int_64] |
||
114 | fadd dword[hudson_temp_offs] |
||
115 | fimul dword[hudson_int_2] |
||
116 | fistp dword[hudson_temp_read] |
||
117 | mov bx, word[hudson_temp_read] |
||
118 | mov ax, bx |
||
119 | xor bh, bh |
||
120 | shr eax, 1 |
||
121 | mov byte[hwm_temps + 4], al |
||
122 | or bl, 1 |
||
123 | jz @f |
||
124 | mov bh, 5 |
||
125 | mov byte[hwm_temps + 5], bh |
||
126 | |||
127 | |||
128 | ; Проверка температуры, датчики с 127.5`C не используются |
||
129 | mov ecx, 3 |
||
130 | mov esi, hwm_temps |
||
131 | hudson_check_temp: |
||
132 | cmp word[esi + ecx * 2 - 2], 0x057F |
||
133 | jne hudson_temp_ok |
||
134 | mov word[esi + ecx * 2 - 2], 0 |
||
135 | hudson_temp_ok: |
||
136 | loop hudson_check_temp |
||
137 | |||
138 | ret |
||
139 | ;----------------------------------- |
||
140 | hudson_get_fan_speed: |
||
141 | ; fan1 |
||
142 | mov al, 0x47 |
||
143 | call [IO_Read] |
||
144 | and al, 0x30 |
||
145 | shr al, 4 |
||
146 | mov ebx, 1 |
||
147 | mov cl, al |
||
148 | shl ebx, cl ; <- div1 |
||
149 | xor eax, eax |
||
150 | mov al, 0x28 |
||
151 | call [IO_Read] |
||
152 | cmp al, 255 |
||
153 | jne @f |
||
154 | xor eax, eax ; ??? |
||
155 | ret ; ??? |
||
156 | @@: mul ebx |
||
157 | mov ebx, eax |
||
158 | mov eax, 1350000 |
||
159 | xor edx, edx |
||
160 | test ebx, ebx |
||
161 | jz .div0 |
||
162 | div ebx |
||
163 | mov [hwm_rpms], eax |
||
164 | |||
165 | mov al, 0x47 |
||
166 | call [IO_Read] |
||
167 | shr al, 6 |
||
168 | mov ebx, 1 |
||
169 | mov cl, al |
||
170 | shl ebx, cl ; <- div2 |
||
171 | xor eax, eax |
||
172 | mov al, 0x29 |
||
173 | call [IO_Read] |
||
174 | cmp al, 255 |
||
175 | jne @f |
||
176 | xor eax, eax |
||
177 | .div0: |
||
178 | ret |
||
179 | @@: mul ebx |
||
180 | mov ebx, eax |
||
181 | mov eax, 1350000 |
||
182 | xor edx, edx |
||
183 | test ebx, ebx |
||
184 | jz .div0 |
||
185 | div ebx |
||
186 | mov [hwm_rpms + 4], eax |
||
187 | |||
188 | mov al, 0x4B |
||
189 | call [IO_Read] |
||
190 | shr al, 6 |
||
191 | mov ebx, 1 |
||
192 | mov cl, al |
||
193 | shl ebx, cl ; <- div3 |
||
194 | xor eax, eax |
||
195 | mov al, 0x2A |
||
196 | call [IO_Read] |
||
197 | cmp al, 255 |
||
198 | jne @f |
||
199 | xor eax, eax |
||
200 | ret |
||
201 | @@: mul ebx |
||
202 | mov ebx, eax |
||
203 | mov eax, 1350000 |
||
204 | xor edx, edx |
||
205 | test ebx, ebx |
||
206 | jz .div0 |
||
207 | div ebx |
||
208 | mov [hwm_rpms + 8], eax |
||
209 | |||
210 | cmp byte[wb_fans_num], 3 |
||
211 | jna .wb_f_e |
||
212 | |||
213 | mov al, 0x59 |
||
214 | call [IO_Read] |
||
215 | and al, 3 |
||
216 | mov ebx, 1 |
||
217 | mov cl, al |
||
218 | shl ebx, cl ; <- div4, дописать учёт DIV_B2 |
||
219 | xor eax, eax |
||
220 | mov al, 0x3F |
||
221 | call [IO_Read] |
||
222 | cmp al, 255 |
||
223 | jne @f |
||
224 | xor eax, eax |
||
225 | ret |
||
226 | @@: mul ebx |
||
227 | mov ebx, eax |
||
228 | mov eax, 1350000 |
||
229 | xor edx, edx |
||
230 | test ebx, ebx |
||
231 | jz .div0 |
||
232 | div ebx |
||
233 | mov [hwm_rpms + 12], eax |
||
234 | |||
235 | mov al, 0x59 |
||
236 | call [IO_Read] |
||
237 | shr al, 2 |
||
238 | and al, 3 |
||
239 | mov ebx, 1 |
||
240 | mov cl, al |
||
241 | shl ebx, cl ; <- div5, дописать учёт DIV_B2 |
||
242 | xor eax, eax |
||
243 | mov al, 0x4e ; Выбираем bank 5 |
||
244 | mov bl, 5 |
||
245 | call [IO_Write] |
||
246 | mov al, 0x53 |
||
247 | call [IO_Read] |
||
248 | cmp al, 255 |
||
249 | jne @f |
||
250 | xor eax, eax |
||
251 | ret |
||
252 | @@: mul ebx |
||
253 | mov ebx, eax |
||
254 | mov eax, 1350000 |
||
255 | xor edx, edx |
||
256 | test ebx, ebx |
||
257 | jz .wb_f_e |
||
258 | div ebx |
||
259 | mov [hwm_rpms + 16], eax |
||
260 | |||
261 | .wb_f_e: |
||
262 | ret |
||
263 | ;----------------------------------- |
||
264 | hudson_get_volt: |
||
265 | ;mov edi, wb_coeff ; <-- possible differences for miscellaneous chip |
||
266 | mov esi, hwm_voltages |
||
267 | xor ecx, ecx |
||
268 | @@: mov eax, ecx |
||
269 | add al, 0x20 |
||
270 | call [IO_Read] |
||
271 | fld dword [edi + ecx * 4] |
||
272 | push eax |
||
273 | fild dword [esp] |
||
274 | fmulp st1, st0 |
||
275 | fstp dword [esi + ecx * 4] |
||
276 | pop eax |
||
277 | inc ecx |
||
278 | cmp ecx, 7 |
||
279 | jb @b |
||
280 | ret |
||
281 | |||
282 | align 4 |
||
283 | hudson_coeff: dd 0.016 ; Vcore |
||
284 | dd 0.016 ; Vin0 |
||
285 | dd 0.016 ; Vin1 (+3.3V) |
||
286 | dd 0.02688 ; AVcc (+5V) |
||
287 | dd 0.0608 ; Vin2 (+12V) |
||
288 | dd 0.0822857142857145 ; -12V |
||
289 | dd -0.02408 ; -5V ; false |
||
290 | |||
291 | hudson_n12v_const dd -14.9142857142857 |
||
292 | |||
293 | hudson_temp_offs dd -273.65 |
||
294 | hudson_temp_coef dd 0.517 |
||
295 | hudson_temp_read dd 0 |
||
296 | hudson_int_2 dd 2 |
||
297 | hudson_int_64 dd 64-->->->->->-> |
||
298 |