Rev 3702 | Rev 3711 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3702 | Rev 3706 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | ;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2012. 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 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 7... | Line 7... | ||
7 | 7 | ||
Line 8... | Line 8... | ||
8 | $Revision: 3702 $ |
8 | $Revision: 3706 $ |
9 | 9 | ||
10 | 10 | ||
Line 115... | Line 115... | ||
115 | ; ATA with 28 or 48 bit for sector number? |
115 | ; ATA with 28 or 48 bit for sector number? |
116 | mov eax, [esp+4] |
116 | mov eax, [esp+4] |
117 | cmp eax, 0x10000000 |
117 | cmp eax, 0x10000000 |
118 | jae .lba48 |
118 | jae .lba48 |
119 | .lba28: |
119 | .lba28: |
- | 120 | pushfd |
|
120 | cli |
121 | cli |
121 | xor eax, eax |
122 | xor eax, eax |
122 | mov edx, [hdbase] |
123 | mov edx, [hdbase] |
123 | inc edx |
124 | inc edx |
124 | out dx, al; ATAFeatures регистр "особенностей" |
125 | out dx, al ; ATA Features регистр "особенностей" |
125 | inc edx |
126 | inc edx |
126 | inc eax |
127 | inc eax |
127 | out dx, al; ATASectorCount счётчик секторов |
128 | out dx, al ; ATA Sector Counter счётчик секторов |
128 | inc edx |
129 | inc edx |
129 | mov eax, [esp+4] |
130 | mov eax, [esp+4+4] |
130 | out dx, al; ATASectorNumber регистр номера сектора |
131 | out dx, al ; LBA Low LBA (7:0) |
131 | shr eax, 8 |
132 | shr eax, 8 |
132 | inc edx |
133 | inc edx |
133 | out dx, al; ATACylinder номер цилиндра (младший байт) |
134 | out dx, al ; LBA Mid LBA (15:8) |
134 | shr eax, 8 |
135 | shr eax, 8 |
135 | inc edx |
136 | inc edx |
136 | out dx, al; номер цилиндра (старший байт) |
137 | out dx, al ; LBA High LBA (23:16) |
137 | shr eax, 8 |
138 | shr eax, 8 |
138 | inc edx |
139 | inc edx |
139 | and al, 1+2+4+8 |
140 | and al, 1+2+4+8 ; LBA (27:24) |
140 | add al, byte [hdid] |
141 | add al, byte [hdid] |
141 | add al, 128+64+32 |
142 | add al, 128+64+32 |
142 | out dx, al; номер головки/номер диска |
143 | out dx, al ; номер головки/номер диска |
143 | inc edx |
144 | inc edx |
144 | mov al, 20h |
145 | mov al, 20h ; READ SECTOR(S) |
145 | out dx, al; ATACommand регистр команд |
146 | out dx, al ; ATACommand регистр команд |
146 | sti |
147 | popfd |
147 | jmp .continue |
148 | jmp .continue |
148 | .lba48: |
149 | .lba48: |
- | 150 | pushfd |
|
149 | cli |
151 | cli |
150 | xor eax, eax |
152 | xor eax, eax |
151 | mov edx, [hdbase] |
153 | mov edx, [hdbase] |
152 | inc edx |
154 | inc edx |
153 | out dx, al ; Features Previous Reserved |
155 | out dx, al ; Features Previous Reserved |
Line 155... | Line 157... | ||
155 | inc edx |
157 | inc edx |
156 | out dx, al ; Sector Count Previous Sector count (15:8) |
158 | out dx, al ; Sector Count Previous Sector count (15:8) |
157 | inc eax |
159 | inc eax |
158 | out dx, al ; Sector Count Current Sector count (7:0) |
160 | out dx, al ; Sector Count Current Sector count (7:0) |
159 | inc edx |
161 | inc edx |
160 | mov eax, [esp+4] |
162 | mov eax, [esp+4+4] |
161 | rol eax,8 |
163 | rol eax,8 |
162 | out dx, al ; LBA Low Previous LBA (31:24) |
164 | out dx, al ; LBA Low Previous LBA (31:24) |
163 | xor eax,eax ; because only 32 bit cache |
165 | xor eax,eax ; because only 32 bit cache |
164 | inc edx |
166 | inc edx |
165 | out dx, al ; LBA Mid Previous LBA (39:32) |
167 | out dx, al ; LBA Mid Previous LBA (39:32) |
166 | inc edx |
168 | inc edx |
167 | out dx, al ; LBA High Previous LBA (47:40) |
169 | out dx, al ; LBA High Previous LBA (47:40) |
168 | sub edx,2 |
170 | sub edx,2 |
169 | mov eax, [esp+4] |
171 | mov eax, [esp+4+4] |
170 | out dx, al ; LBA Low Current LBA (7:0) |
172 | out dx, al ; LBA Low Current LBA (7:0) |
171 | shr eax, 8 |
173 | shr eax, 8 |
172 | inc edx |
174 | inc edx |
173 | out dx, al ; LBA Mid Current LBA (15:8) |
175 | out dx, al ; LBA Mid Current LBA (15:8) |
174 | shr eax, 8 |
176 | shr eax, 8 |
Line 179... | Line 181... | ||
179 | add al, 128+64+32 |
181 | add al, 128+64+32 |
180 | out dx, al; номер головки/номер диска |
182 | out dx, al; номер головки/номер диска |
181 | inc edx |
183 | inc edx |
182 | mov al, 24h ; READ SECTOR(S) EXT |
184 | mov al, 24h ; READ SECTOR(S) EXT |
183 | out dx, al; ATACommand регистр команд |
185 | out dx, al; ATACommand регистр команд |
184 | sti |
186 | popfd |
185 | .continue: |
187 | .continue: |
186 | call wait_for_sector_buffer |
188 | call wait_for_sector_buffer |
Line 187... | Line 189... | ||
187 | 189 | ||
188 | cmp [hd_error], 0 |
190 | cmp [hd_error], 0 |
Line 289... | Line 291... | ||
289 | pop edi esi ecx |
291 | pop edi esi ecx |
290 | ret |
292 | ret |
Line 291... | Line 293... | ||
291 | 293 | ||
292 | align 4 |
294 | align 4 |
293 | cache_write_pio: |
- | |
294 | cmp dword[esi], 0x10000000 |
- | |
295 | jae .bad |
295 | cache_write_pio: |
Line 296... | Line 296... | ||
296 | ; call disable_ide_int |
296 | ; call disable_ide_int |
297 | 297 | ||
298 | ; Выбрать нужный диск |
298 | ; Выбрать нужный диск |
Line 304... | Line 304... | ||
304 | 304 | ||
305 | call wait_for_hd_idle |
305 | call wait_for_hd_idle |
306 | cmp [hd_error], 0 |
306 | cmp [hd_error], 0 |
Line -... | Line 307... | ||
- | 307 | jne hd_write_error |
|
- | 308 | ||
- | 309 | ; ATA with 28 or 48 bit for sector number? |
|
- | 310 | mov eax, [esi] |
|
- | 311 | cmp eax, 0x10000000 |
|
- | 312 | jae .lba48 |
|
307 | jne hd_write_error |
313 | .lba28: |
308 | 314 | pushfd |
|
309 | cli |
315 | cli |
310 | xor eax, eax |
316 | xor eax, eax |
311 | mov edx, [hdbase] |
317 | mov edx, [hdbase] |
312 | inc edx |
318 | inc edx |
313 | out dx, al |
319 | out dx, al ; ATA Features регистр "особенностей" |
314 | inc edx |
320 | inc edx |
315 | inc eax |
321 | inc eax |
316 | out dx, al |
322 | out dx, al ; ATA Sector Counter счётчик секторов |
317 | inc edx |
323 | inc edx |
318 | mov eax, [esi] ; eax = sector to write |
324 | mov eax, [esi] ; eax = sector to write |
319 | out dx, al |
325 | out dx, al ; LBA Low LBA (7:0) |
320 | shr eax, 8 |
326 | shr eax, 8 |
321 | inc edx |
327 | inc edx |
322 | out dx, al |
328 | out dx, al ; LBA Mid LBA (15:8) |
323 | shr eax, 8 |
329 | shr eax, 8 |
324 | inc edx |
330 | inc edx |
325 | out dx, al |
331 | out dx, al ; LBA High LBA (23:16) |
326 | shr eax, 8 |
332 | shr eax, 8 |
327 | inc edx |
333 | inc edx |
328 | and al, 1+2+4+8 |
334 | and al, 1+2+4+8 ; LBA (27:24) |
329 | add al, byte [hdid] |
335 | add al, byte [hdid] |
330 | add al, 128+64+32 |
336 | add al, 128+64+32 |
- | 337 | out dx, al ; номер головки/номер диска |
|
- | 338 | inc edx |
|
- | 339 | mov al, 30h ; WRITE SECTOR(S) |
|
- | 340 | out dx, al ; ATACommand регистр команд |
|
- | 341 | popfd |
|
- | 342 | jmp .continue |
|
- | 343 | .lba48: |
|
- | 344 | pushfd |
|
- | 345 | cli |
|
- | 346 | xor eax, eax |
|
- | 347 | mov edx, [hdbase] |
|
- | 348 | inc edx |
|
- | 349 | out dx, al ; Features Previous Reserved |
|
- | 350 | out dx, al ; Features Current Reserved |
|
- | 351 | inc edx |
|
- | 352 | out dx, al ; Sector Count Previous Sector count (15:8) |
|
- | 353 | inc eax |
|
331 | out dx, al |
354 | out dx, al ; Sector Count Current Sector count (7:0) |
- | 355 | inc edx |
|
- | 356 | mov eax, [esi] |
|
- | 357 | rol eax,8 |
|
- | 358 | out dx, al ; LBA Low Previous LBA (31:24) |
|
- | 359 | xor eax,eax ; because only 32 bit cache |
|
- | 360 | inc edx |
|
- | 361 | out dx, al ; LBA Mid Previous LBA (39:32) |
|
- | 362 | inc edx |
|
- | 363 | out dx, al ; LBA High Previous LBA (47:40) |
|
- | 364 | sub edx,2 |
|
- | 365 | mov eax, [esi] |
|
- | 366 | out dx, al ; LBA Low Current LBA (7:0) |
|
- | 367 | shr eax, 8 |
|
332 | inc edx |
368 | inc edx |
- | 369 | out dx, al ; LBA Mid Current LBA (15:8) |
|
- | 370 | shr eax, 8 |
|
- | 371 | inc edx |
|
- | 372 | out dx, al ; LBA High Current LBA (23:16) |
|
- | 373 | inc edx |
|
- | 374 | mov al, byte [hdid] |
|
- | 375 | add al, 128+64+32 |
|
- | 376 | out dx, al; номер головки/номер диска |
|
- | 377 | inc edx |
|
333 | mov al, 30h |
378 | mov al, 34h ; WRITE SECTOR(S) EXT |
334 | out dx, al |
379 | out dx, al; ATACommand регистр команд |
335 | sti |
380 | popfd |
Line 336... | Line 381... | ||
336 | 381 | .continue: |
|
337 | call wait_for_sector_buffer |
382 | call wait_for_sector_buffer |
Line 358... | Line 403... | ||
358 | 403 | ||
359 | ; call enable_ide_int |
404 | ; call enable_ide_int |
Line 360... | Line 405... | ||
360 | pop esi ecx |
405 | pop esi ecx |
361 | - | ||
362 | ret |
- | |
363 | .bad: |
- | |
Line 364... | Line 406... | ||
364 | inc [hd_error] |
406 | |
Line 365... | Line 407... | ||
365 | ret |
407 | ret |
366 | 408 |