Rev 8111 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8111 | Rev 9715 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2020. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2022. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
5 | ;; ;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
7 | 7 | ||
8 | $Revision$ |
8 | $Revision$ |
9 | 9 | ||
10 | HPET_ID = 0x0000 |
10 | HPET_ID = 0x0000 |
11 | HPET_PERIOD = 0x0004 |
11 | HPET_PERIOD = 0x0004 |
12 | HPET_CFG_ENABLE = 0x0001 |
12 | HPET_CFG_ENABLE = 0x0001 |
13 | HPET_CFG = 0x0010 |
13 | HPET_CFG = 0x0010 |
14 | HPET_COUNTER = 0x00f0 |
14 | HPET_COUNTER = 0x00f0 |
15 | HPET_T0_CFG = 0x0100 |
15 | HPET_T0_CFG = 0x0100 |
16 | 16 | ||
17 | HPET_TN_LEVEL = 0x0002 |
17 | HPET_TN_LEVEL = 0x0002 |
18 | HPET_TN_ENABLE = 0x0004 |
18 | HPET_TN_ENABLE = 0x0004 |
19 | HPET_TN_FSB = 0x4000 |
19 | HPET_TN_FSB = 0x4000 |
20 | 20 | ||
21 | uglobal |
21 | uglobal |
22 | hpet_base rd 1 |
22 | hpet_base rd 1 |
23 | hpet_period rd 1 |
23 | hpet_period rd 1 |
24 | hpet_timers rd 1 |
24 | hpet_timers rd 1 |
25 | hpet_tsc_start rd 2 |
25 | hpet_tsc_start rd 2 |
26 | endg |
26 | endg |
27 | 27 | ||
28 | align 4 |
28 | align 4 |
29 | init_hpet: |
29 | init_hpet: |
30 | mov ebx, [hpet_base] |
30 | mov ebx, [hpet_base] |
31 | test ebx, ebx |
31 | test ebx, ebx |
32 | jz .done |
32 | jz .done |
33 | 33 | ||
34 | mov eax, [ebx] |
34 | mov eax, [ebx] |
35 | and ah, 0x1F |
35 | and ah, 0x1F |
36 | inc ah |
36 | inc ah |
37 | movzx eax, ah |
37 | movzx eax, ah |
38 | mov [hpet_timers], eax |
38 | mov [hpet_timers], eax |
39 | mov ecx, eax |
39 | mov ecx, eax |
40 | 40 | ||
41 | mov eax, [ebx+HPET_PERIOD] |
41 | mov eax, [ebx + HPET_PERIOD] |
42 | xor edx, edx |
42 | xor edx, edx |
43 | shld edx, eax, 10 |
43 | shld edx, eax, 10 |
44 | shl eax, 10 |
44 | shl eax, 10 |
45 | mov esi, 1000000 |
45 | mov esi, 1000000 |
46 | div esi |
46 | div esi |
47 | mov [hpet_period], eax |
47 | mov [hpet_period], eax |
48 | 48 | ||
49 | mov esi, [ebx+HPET_CFG] |
49 | mov esi, [ebx + HPET_CFG] |
50 | and esi, not HPET_CFG_ENABLE |
50 | and esi, not HPET_CFG_ENABLE |
51 | mov [ebx+HPET_CFG], esi ;stop main counter |
51 | mov [ebx + HPET_CFG], esi ;stop main counter |
52 | 52 | ||
53 | lea edx, [ebx+HPET_T0_CFG] |
53 | lea edx, [ebx + HPET_T0_CFG] |
54 | @@: |
54 | @@: |
55 | jcxz @F |
55 | jcxz @F |
56 | mov eax, [edx] |
56 | mov eax, [edx] |
57 | and eax, not (HPET_TN_ENABLE+HPET_TN_LEVEL+HPET_TN_FSB) |
57 | and eax, not (HPET_TN_ENABLE + HPET_TN_LEVEL + HPET_TN_FSB) |
58 | mov [edx], eax |
58 | mov [edx], eax |
59 | add edx, 0x20 |
59 | add edx, 0x20 |
60 | dec ecx |
60 | dec ecx |
61 | jmp @B |
61 | jmp @B |
62 | @@: |
62 | @@: |
63 | mov [ebx+HPET_COUNTER], ecx ;reset main counter |
63 | mov [ebx + HPET_COUNTER], ecx ;reset main counter |
64 | mov [ebx+HPET_COUNTER+4], ecx |
64 | mov [ebx + HPET_COUNTER + 4], ecx |
65 | 65 | ||
66 | or esi, HPET_CFG_ENABLE |
66 | or esi, HPET_CFG_ENABLE |
67 | mov [ebx+HPET_CFG], esi ;and start again |
67 | mov [ebx + HPET_CFG], esi ;and start again |
68 | 68 | ||
69 | .done: |
69 | .done: |
70 | rdtsc |
70 | rdtsc |
71 | mov [hpet_tsc_start], eax |
71 | mov [hpet_tsc_start], eax |
72 | mov [hpet_tsc_start+4], edx |
72 | mov [hpet_tsc_start + 4], edx |
73 | 73 | ||
74 | ret |
74 | ret |