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