Rev 838 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
750 | victor | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
3 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
||
4 | ;; Distributed under terms of the GNU General Public License ;; |
||
5 | ;; ;; |
||
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
593 | mikedld | 7 | |
465 | serge | 8 | $Revision: 839 $ |
9 | |||
593 | mikedld | 10 | |
465 | serge | 11 | |
12 | |||
13 | align 4 |
||
837 | serge | 14 | |
586 | serge | 15 | init_BIOS32: |
16 | mov edi, 0xE0000 |
||
17 | .pcibios_nxt: |
||
18 | cmp dword[edi], '_32_' ; "magic" word |
||
19 | je .BIOS32_found |
||
20 | .pcibios_nxt2: |
||
21 | add edi, 0x10 |
||
22 | cmp edi, 0xFFFF0 |
||
23 | je .BIOS32_not_found |
||
24 | jmp .pcibios_nxt |
||
25 | .BIOS32_found: ; magic word found, check control summ |
||
26 | |||
27 | movzx ecx, byte[edi + 9] |
||
28 | shl ecx, 4 |
||
29 | mov esi, edi |
||
30 | xor eax, eax |
||
31 | cld ; paranoia |
||
32 | @@: lodsb |
||
33 | add ah, al |
||
34 | loop @b |
||
35 | jnz .pcibios_nxt2 ; control summ must be zero |
||
36 | ; BIOS32 service found ! |
||
37 | mov ebp, [edi + 4] |
||
38 | mov [bios32_entry], ebp |
||
39 | ; check PCI BIOS present |
||
40 | mov eax, '$PCI' |
||
41 | xor ebx, ebx |
||
42 | push cs ; special for 'ret far' from BIOS |
||
43 | call ebp |
||
44 | test al, al |
||
45 | jnz .PCI_BIOS32_not_found |
||
46 | |||
47 | ; здесь создаются дискрипторы для PCI BIOS |
||
48 | |||
49 | add ebx, OS_BASE |
||
50 | dec ecx |
||
51 | mov [(pci_code_32-OS_BASE)], cx ;limit 0-15 |
||
52 | mov [(pci_data_32-OS_BASE)], cx ;limit 0-15 |
||
53 | |||
54 | mov [(pci_code_32-OS_BASE)+2], bx ;base 0-15 |
||
55 | mov [(pci_data_32-OS_BASE)+2], bx ;base 0-15 |
||
56 | |||
57 | shr ebx, 16 |
||
58 | mov [(pci_code_32-OS_BASE)+4], bl ;base 16-23 |
||
59 | mov [(pci_data_32-OS_BASE)+4], bl ;base 16-23 |
||
60 | |||
61 | shr ecx, 16 |
||
62 | and cl, 0x0F |
||
63 | mov ch, bh |
||
64 | add cx, D32 |
||
65 | mov [(pci_code_32-OS_BASE)+6], cx ;lim 16-19 & |
||
66 | mov [(pci_data_32-OS_BASE)+6], cx ;base 24-31 |
||
67 | |||
68 | mov [(pci_bios_entry-OS_BASE)], edx |
||
69 | ; jmp .end |
||
70 | .PCI_BIOS32_not_found: |
||
71 | ; здесь должна заполнятся pci_emu_dat |
||
72 | .BIOS32_not_found: |
||
73 | .end: |
||
837 | serge | 74 | ret |
586 | serge | 75 | |
76 | align 4 |
||
465 | serge | 77 | proc test_cpu |
78 | locals |
||
79 | cpu_type dd ? |
||
80 | cpu_id dd ? |
||
81 | cpu_Intel dd ? |
||
82 | cpu_AMD dd ? |
||
83 | endl |
||
84 | |||
85 | mov [cpu_type], 0 |
||
86 | xor eax, eax |
||
87 | mov [cpu_caps-OS_BASE], eax |
||
88 | mov [cpu_caps+4-OS_BASE], eax |
||
89 | |||
90 | pushfd |
||
91 | pop eax |
||
92 | mov ecx, eax |
||
93 | xor eax, 0x40000 |
||
94 | push eax |
||
95 | popfd |
||
96 | pushfd |
||
97 | pop eax |
||
98 | xor eax, ecx |
||
99 | mov [cpu_type], CPU_386 |
||
100 | jz .end_cpuid |
||
101 | push ecx |
||
102 | popfd |
||
103 | |||
104 | mov [cpu_type], CPU_486 |
||
105 | mov eax, ecx |
||
106 | xor eax, 0x200000 |
||
107 | push eax |
||
108 | popfd |
||
109 | pushfd |
||
110 | pop eax |
||
111 | xor eax, ecx |
||
112 | je .end_cpuid |
||
113 | mov [cpu_id], 1 |
||
114 | |||
115 | xor eax, eax |
||
116 | cpuid |
||
117 | |||
118 | mov [cpu_vendor-OS_BASE], ebx |
||
119 | mov [cpu_vendor+4-OS_BASE], edx |
||
120 | mov [cpu_vendor+8-OS_BASE], ecx |
||
121 | cmp ebx, dword [intel_str-OS_BASE] |
||
122 | jne .check_AMD |
||
123 | cmp edx, dword [intel_str+4-OS_BASE] |
||
124 | jne .check_AMD |
||
125 | cmp ecx, dword [intel_str+8-OS_BASE] |
||
126 | jne .check_AMD |
||
127 | mov [cpu_Intel], 1 |
||
128 | cmp eax, 1 |
||
129 | jl .end_cpuid |
||
130 | mov eax, 1 |
||
131 | cpuid |
||
132 | mov [cpu_sign-OS_BASE], eax |
||
133 | mov [cpu_info-OS_BASE], ebx |
||
134 | mov [cpu_caps-OS_BASE], edx |
||
135 | mov [cpu_caps+4-OS_BASE],ecx |
||
136 | |||
137 | shr eax, 8 |
||
138 | and eax, 0x0f |
||
139 | ret |
||
140 | .end_cpuid: |
||
141 | mov eax, [cpu_type] |
||
142 | ret |
||
143 | |||
144 | .check_AMD: |
||
145 | cmp ebx, dword [AMD_str-OS_BASE] |
||
146 | jne .unknown |
||
147 | cmp edx, dword [AMD_str+4-OS_BASE] |
||
148 | jne .unknown |
||
149 | cmp ecx, dword [AMD_str+8-OS_BASE] |
||
150 | jne .unknown |
||
151 | mov [cpu_AMD], 1 |
||
152 | cmp eax, 1 |
||
153 | jl .unknown |
||
154 | mov eax, 1 |
||
155 | cpuid |
||
156 | mov [cpu_sign-OS_BASE], eax |
||
157 | mov [cpu_info-OS_BASE], ebx |
||
158 | mov [cpu_caps-OS_BASE], edx |
||
159 | mov [cpu_caps+4-OS_BASE],ecx |
||
160 | shr eax, 8 |
||
161 | and eax, 0x0f |
||
162 | ret |
||
163 | .unknown: |
||
164 | mov eax, 1 |
||
165 | cpuid |
||
166 | mov [cpu_sign-OS_BASE], eax |
||
167 | mov [cpu_info-OS_BASE], ebx |
||
168 | mov [cpu_caps-OS_BASE], edx |
||
169 | mov [cpu_caps+4-OS_BASE],ecx |
||
170 | shr eax, 8 |
||
171 | and eax, 0x0f |
||
172 | ret |
||
173 | endp |
||
174 |