Rev 465 | Rev 593 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 465 | Rev 586 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | $Revision: 465 $ |
1 | $Revision: 586 $ |
2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
3 | ;; ;; |
3 | ;; ;; |
4 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
4 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
5 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; Distributed under terms of the GNU General Public License ;; |
6 | ;; ;; |
6 | ;; ;; |
7 | ;; ;; |
7 | ;; ;; |
8 | ;; PCI32.INC ;; |
8 | ;; PCI32.INC ;; |
9 | ;; ;; |
9 | ;; ;; |
10 | ;; 32 bit PCI driver code ;; |
10 | ;; 32 bit PCI driver code ;; |
11 | ;; ;; |
11 | ;; ;; |
- | 12 | ;; Version 0.3 April 9, 2007 ;; |
|
12 | ;; Version 0.2 December 21st, 2002 ;; |
13 | ;; Version 0.2 December 21st, 2002 ;; |
13 | ;; ;; |
14 | ;; ;; |
14 | ;; Author: Victor Prodan, victorprodan@yahoo.com ;; |
15 | ;; Author: Victor Prodan, victorprodan@yahoo.com ;; |
- | 16 | ;; Mihailov Ilia, ghost.nsk@gmail.com ;; |
|
15 | ;; Credits: ;; |
17 | ;; Credits: ;; |
16 | ;; Ralf Brown ;; |
18 | ;; Ralf Brown ;; |
17 | ;; Mike Hibbett, mikeh@oceanfree.net ;; |
19 | ;; Mike Hibbett, mikeh@oceanfree.net ;; |
18 | ;; ;; |
20 | ;; ;; |
19 | ;; See file COPYING for details ;; |
21 | ;; See file COPYING for details ;; |
Line 106... | Line 108... | ||
106 | ; |
108 | ; |
107 | ; Description |
109 | ; Description |
108 | ; read a register from the PCI config space into EAX/AX/AL |
110 | ; read a register from the PCI config space into EAX/AX/AL |
109 | ; IN: ah=bus,device+func=bh,register address=bl |
111 | ; IN: ah=bus,device+func=bh,register address=bl |
110 | ; number of bytes to read (1,2,4) coded into AL, bits 0-1 |
112 | ; number of bytes to read (1,2,4) coded into AL, bits 0-1 |
- | 113 | ; (0 - byte, 1 - word, 2 - dword) |
|
111 | ;*************************************************************************** |
114 | ;*************************************************************************** |
Line 112... | Line 115... | ||
112 | 115 | ||
Line 113... | Line 116... | ||
113 | align 4 |
116 | align 4 |
Line 236... | Line 239... | ||
236 | ; Description |
239 | ; Description |
237 | ; write a register from ECX/CX/CL into the PCI config space |
240 | ; write a register from ECX/CX/CL into the PCI config space |
238 | ; IN: ah=bus,device+func=bh,register address (dword aligned)=bl, |
241 | ; IN: ah=bus,device+func=bh,register address (dword aligned)=bl, |
239 | ; value to write in ecx |
242 | ; value to write in ecx |
240 | ; number of bytes to write (1,2,4) coded into AL, bits 0-1 |
243 | ; number of bytes to write (1,2,4) coded into AL, bits 0-1 |
- | 244 | ; (0 - byte, 1 - word, 2 - dword) |
|
241 | ;*************************************************************************** |
245 | ;*************************************************************************** |
Line 242... | Line 246... | ||
242 | 246 | ||
Line 243... | Line 247... | ||
243 | align 4 |
247 | align 4 |
Line 359... | Line 363... | ||
359 | 363 | ||
360 | pci_write_reg_err: |
364 | pci_write_reg_err: |
361 | xor eax,eax |
365 | xor eax,eax |
362 | dec eax |
366 | dec eax |
- | 367 | ret |
|
- | 368 | ||
- | 369 | ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
|
- | 370 | ||
- | 371 | ; VendID (2), DevID (2), Revision = 0 (1), Class Code (3), FNum (1), Bus (1) |
|
- | 372 | pci_emu_dat: times 30*10 db 0 |
|
- | 373 | ||
- | 374 | ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
|
- | 375 | align 4 |
|
- | 376 | sys_pcibios: |
|
- | 377 | cmp [pci_access_enabled], 1 |
|
- | 378 | jne .unsupported_func |
|
- | 379 | mov edi, [pci_bios_entry] |
|
- | 380 | test edi, edi |
|
- | 381 | jz .emulate_bios |
|
- | 382 | xchg ebx, eax |
|
- | 383 | xchg ecx, eax |
|
- | 384 | xchg edx, eax |
|
- | 385 | xchg esi, eax |
|
- | 386 | mov edi, eax |
|
- | 387 | ||
- | 388 | push ds |
|
- | 389 | mov ax, pci_data_sel |
|
- | 390 | mov ds, ax |
|
- | 391 | mov eax, ebp |
|
- | 392 | call pword [cs:pci_bios_entry] |
|
- | 393 | pop ds |
|
- | 394 | ||
- | 395 | jmp .return |
|
- | 396 | ;-=-=-=-=-=-=-=-= |
|
- | 397 | .emulate_bios: |
|
- | 398 | cmp ebp, 1 ; PCI_FUNCTION_ID |
|
- | 399 | jnz .not_PCI_BIOS_PRESENT |
|
- | 400 | mov edx, 'PCI ' |
|
- | 401 | xor ah, ah |
|
- | 402 | mov al, [OS_BASE+0x2F0000 + 0x9020] |
|
- | 403 | mov bx, [OS_BASE+0x2F0000 + 0x9022] |
|
- | 404 | mov cl, [OS_BASE+0x2F0000 + 0x9021] |
|
- | 405 | jmp .return |
|
- | 406 | ||
- | 407 | .not_PCI_BIOS_PRESENT: |
|
- | 408 | cmp ebp, 2 ; FIND_PCI_DEVICE |
|
- | 409 | jne .not_FIND_PCI_DEVICE |
|
- | 410 | mov esi, pci_emu_dat |
|
- | 411 | ..nxt: cmp [esi], cx |
|
- | 412 | jne ..no |
|
- | 413 | cmp [esi + 2], bx |
|
- | 414 | jne ..no |
|
- | 415 | dec dx |
|
- | 416 | jns ..no |
|
- | 417 | mov bx, [esi + 4] |
|
- | 418 | xor ah, ah |
|
- | 419 | jmp .return |
|
- | 420 | ..no: cmp word[esi], 0 |
|
- | 421 | je ..dev_not_found |
|
- | 422 | add esi, 10 |
|
- | 423 | jmp ..nxt |
|
- | 424 | ..dev_not_found: |
|
- | 425 | mov ah, 0x86 ; DEVICE_NOT_FOUND |
|
- | 426 | jmp .return |
|
- | 427 | ||
- | 428 | .not_FIND_PCI_DEVICE: |
|
- | 429 | cmp ebp, 3 ; FIND_PCI_CLASS_CODE |
|
- | 430 | jne .not_FIND_PCI_CLASS_CODE |
|
- | 431 | mov esi, pci_emu_dat |
|
- | 432 | shl ebx, 8 |
|
- | 433 | ..nxt2: cmp [esi], ebx |
|
- | 434 | jne ..no2 |
|
- | 435 | mov bx, [esi] |
|
- | 436 | xor ah, ah |
|
- | 437 | jmp .return |
|
- | 438 | ..no2: cmp dword[esi], 0 |
|
- | 439 | je ..dev_not_found2 |
|
- | 440 | add esi, 10 |
|
- | 441 | jmp ..nxt2 |
|
- | 442 | ..dev_not_found2: |
|
- | 443 | mov ah, 0x86 ; DEVICE_NOT_FOUND |
|
- | 444 | jmp .return |
|
- | 445 | ||
- | 446 | .not_FIND_PCI_CLASS_CODE: |
|
- | 447 | cmp ebp, 8 ; READ_CONFIG_* |
|
- | 448 | jb .not_READ_CONFIG |
|
- | 449 | cmp ebp, 0x0A |
|
- | 450 | ja .not_READ_CONFIG |
|
- | 451 | mov ebx, esi |
|
- | 452 | mov bh, al |
|
- | 453 | mov edx, ebp |
|
- | 454 | mov al, dl |
|
- | 455 | call pci_read_reg |
|
- | 456 | mov ecx, eax |
|
- | 457 | xor ah, ah ; SUCCESSFUL |
|
- | 458 | jmp .return |
|
- | 459 | .not_READ_CONFIG: |
|
- | 460 | cmp ebp, 0x0B ; WRITE_CONFIG_* |
|
- | 461 | jb .not_WRITE_CONFIG |
|
- | 462 | cmp ebp, 0x0D |
|
- | 463 | ja .not_WRITE_CONFIG |
|
- | 464 | mov ecx, ebx |
|
- | 465 | mov ebx, esi |
|
- | 466 | mov bh, al |
|
- | 467 | mov edx, ebp |
|
- | 468 | inc edx |
|
- | 469 | mov al, dl |
|
- | 470 | call pci_write_reg |
|
- | 471 | xor ah, ah ; SUCCESSFUL |
|
- | 472 | jmp .return |
|
- | 473 | .not_WRITE_CONFIG: |
|
- | 474 | .unsupported_func: |
|
- | 475 | mov ah, 0x81 ; FUNC_NOT_SUPPORTED |
|
- | 476 | .return:mov dword[esp + 8 ], edi |
|
- | 477 | mov dword[esp + 12], esi |
|
- | 478 | mov dword[esp + 24], ebx |
|
- | 479 | mov dword[esp + 28], edx |
|
- | 480 | mov dword[esp + 32], ecx |
|
- | 481 | mov dword[esp + 36], eax |