Subversion Repositories Kolibri OS

Rev

Rev 593 | Rev 750 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 593 Rev 594
Line -... Line 1...
-
 
1
$Revision: 594 $
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
3
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
4
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
6
;;                                                              ;;
Line 19... Line 20...
19
;;                                                              ;;
20
;;                                                              ;;
20
;;  See file COPYING for details                                ;;
21
;;  See file COPYING for details                                ;;
21
;;                                                              ;;
22
;;                                                              ;;
22
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
23
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 23... Line -...
23
 
-
 
24
$Revision: 593 $
-
 
Line 25... Line 24...
25
 
24
 
26
 
25
 
27
;***************************************************************************
26
;***************************************************************************
28
;   Function
27
;   Function
Line 373... Line 372...
373
pci_emu_dat:	times	30*10 db 0
372
pci_emu_dat:	times	30*10 db 0
Line 374... Line 373...
374
 
373
 
375
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
374
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
376
align 4
375
align 4
377
sys_pcibios:
-
 
378
	cmp	[pci_access_enabled], 1
-
 
379
        jne	.unsupported_func
-
 
380
	mov	edi, [pci_bios_entry]
-
 
381
	test	edi, edi
-
 
382
	jz	.emulate_bios
376
sys_pcibios:
383
	xchg	ebx, eax
377
	xchg	ebx, eax
384
	xchg	ecx, eax
378
	xchg	ecx, eax
385
	xchg	edx, eax
379
	xchg	edx, eax
386
	xchg	esi, eax
380
	xchg	esi, eax
-
 
381
        xchg    edi, eax
-
 
382
	cmp	[pci_access_enabled], 1
-
 
383
        jne	.unsupported_func
-
 
384
        cmp     [pci_bios_entry], 0
Line 387... Line 385...
387
        mov     edi, eax
385
	jz	.emulate_bios
388
 
386
 
389
        push ds
387
        push    ds
390
        mov ax, pci_data_sel
388
        mov     ax, pci_data_sel
-
 
389
        mov     ds, ax
391
        mov ds, ax
390
        mov     eax, ebp
392
        mov eax, ebp
391
        mov     ah, 0B1h
Line 393... Line 392...
393
        call pword [cs:pci_bios_entry]
392
        call    pword [cs:pci_bios_entry]
394
        pop ds
393
        pop     ds
395
 
394
 
396
	jmp	.return
395
	jmp	.return
397
	;-=-=-=-=-=-=-=-=
396
	;-=-=-=-=-=-=-=-=
398
.emulate_bios:
397
.emulate_bios:
399
	cmp	ebp, 1			; PCI_FUNCTION_ID
-
 
400
	jnz	.not_PCI_BIOS_PRESENT
398
	cmp	ebp, 1			; PCI_FUNCTION_ID
401
	mov	edx, 'PCI '
399
	jnz	.not_PCI_BIOS_PRESENT
402
	xor	ah, ah
400
	mov	edx, 'PCI '
-
 
401
        mov     al, [OS_BASE+0x2F0000 + 0x9020]
403
        mov     al, [OS_BASE+0x2F0000 + 0x9020]
402
        mov     bx, [OS_BASE+0x2F0000 + 0x9022]
Line 404... Line 403...
404
        mov     bx, [OS_BASE+0x2F0000 + 0x9022]
403
        mov     cl, [OS_BASE+0x2F0000 + 0x9021]
405
        mov     cl, [OS_BASE+0x2F0000 + 0x9021]
404
        xor     ah, ah
406
	jmp	.return
405
	jmp	.return_abcd
407
 
406
 
408
.not_PCI_BIOS_PRESENT:
407
.not_PCI_BIOS_PRESENT:
409
	cmp	ebp, 2			; FIND_PCI_DEVICE
408
	cmp	ebp, 2			; FIND_PCI_DEVICE
410
	jne	.not_FIND_PCI_DEVICE
409
	jne	.not_FIND_PCI_DEVICE
411
	mov	esi, pci_emu_dat
410
	mov	ebx, pci_emu_dat
412
..nxt:	cmp	[esi], cx
411
..nxt:	cmp	[ebx], dx
413
	jne	..no
412
	jne	..no
414
	cmp	[esi + 2], bx
413
	cmp	[ebx + 2], cx
415
	jne	..no
414
	jne	..no
416
	dec	dx
415
	dec	si
417
	jns	..no
416
	jns	..no
418
	mov	bx, [esi + 4]
417
	mov	bx, [ebx + 4]
419
	xor	ah, ah
418
	xor     ah, ah
420
	jmp	.return
419
	jmp	.return_ab
421
..no:	cmp	word[esi], 0
420
..no:	cmp	word[ebx], 0
422
	je	..dev_not_found
421
	je	..dev_not_found
423
	add	esi, 10
422
	add	ebx, 10
Line 424... Line 423...
424
	jmp	..nxt
423
	jmp	..nxt
425
..dev_not_found:
424
..dev_not_found:
426
	mov	ah, 0x86		; DEVICE_NOT_FOUND
425
	mov	ah, 0x86		; DEVICE_NOT_FOUND
427
	jmp	.return
426
	jmp	.return_a
428
 
427
 
429
.not_FIND_PCI_DEVICE:
428
.not_FIND_PCI_DEVICE:
430
	cmp	ebp, 3			; FIND_PCI_CLASS_CODE
429
	cmp	ebp, 3			; FIND_PCI_CLASS_CODE
431
	jne	.not_FIND_PCI_CLASS_CODE
430
	jne	.not_FIND_PCI_CLASS_CODE
432
	mov	esi, pci_emu_dat
431
	mov	esi, pci_emu_dat
433
	shl	ebx, 8
432
	shl	ecx, 8
434
..nxt2:	cmp	[esi], ebx
433
..nxt2:	cmp	[esi], ecx
435
	jne	..no2
434
	jne	..no2
436
	mov	bx, [esi]
435
	mov	bx, [esi]
437
	xor	ah, ah
436
	xor     ah, ah
438
	jmp	.return
-
 
439
..no2:	cmp	dword[esi], 0
-
 
440
	je	..dev_not_found2
-
 
Line 441... Line 437...
441
	add	esi, 10
437
	jmp	.return_ab
442
	jmp	..nxt2
438
..no2:	cmp	dword[esi], 0
443
..dev_not_found2:
439
	je	..dev_not_found
444
	mov	ah, 0x86		; DEVICE_NOT_FOUND
440
	add	esi, 10
445
	jmp	.return
441
	jmp	..nxt2
446
 
442
 
447
.not_FIND_PCI_CLASS_CODE:
443
.not_FIND_PCI_CLASS_CODE:
448
	cmp	ebp, 8			; READ_CONFIG_*
444
	cmp	ebp, 8			; READ_CONFIG_*
-
 
445
	jb	.not_READ_CONFIG
449
	jb	.not_READ_CONFIG
446
	cmp	ebp, 0x0A
450
	cmp	ebp, 0x0A
447
	ja	.not_READ_CONFIG
451
	ja	.not_READ_CONFIG
448
	mov     eax, ebp
452
	mov	ebx, esi
449
	mov     ah, bh
453
	mov	bh, al
450
	mov     edx, edi
454
	mov	edx, ebp
451
	mov     bh, bl
455
	mov	al, dl
452
	mov     bl, dl
456
	call	pci_read_reg
453
	call	pci_read_reg
457
	mov	ecx, eax
454
	mov	ecx, eax
458
	xor	ah, ah			; SUCCESSFUL
455
	xor	ah, ah			; SUCCESSFUL
459
	jmp	.return
456
	jmp	.return_abc
460
.not_READ_CONFIG:
457
.not_READ_CONFIG:
461
	cmp	ebp, 0x0B		; WRITE_CONFIG_*
458
	cmp	ebp, 0x0B		; WRITE_CONFIG_*
462
	jb	.not_WRITE_CONFIG
459
	jb	.not_WRITE_CONFIG
463
	cmp	ebp, 0x0D
-
 
464
	ja	.not_WRITE_CONFIG
460
	cmp	ebp, 0x0D
465
	mov	ecx, ebx
461
	ja	.not_WRITE_CONFIG
466
	mov	ebx, esi
462
	lea     eax, [ebp+1]
467
	mov	bh, al
463
	mov     ah, bh
468
	mov	edx, ebp
464
	mov     edx, edi
469
	inc	edx
465
	mov     bh, bl
470
	mov	al, dl
466
	mov     bl, dl
471
	call	pci_write_reg
467
	call	pci_write_reg
472
	xor	ah, ah			; SUCCESSFUL
468
	xor	ah, ah			; SUCCESSFUL
473
	jmp	.return
469
	jmp	.return_abc
474
.not_WRITE_CONFIG:
470
.not_WRITE_CONFIG:
-
 
471
.unsupported_func:
475
.unsupported_func:
472
	mov	ah, 0x81		; FUNC_NOT_SUPPORTED
-
 
473
.return:mov	dword[esp + 8 ], edi
-
 
474
	mov	dword[esp + 12], esi
-
 
475
.return_abcd:
476
	mov	ah, 0x81		; FUNC_NOT_SUPPORTED
476
	mov	dword[esp + 28], edx
477
.return:mov	dword[esp + 8 ], edi
477
.return_abc: