new api functions demo in PCIDEV.ASM

git-svn-id: svn://kolibrios.org@1351 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Artem Jerdev (art_zh) 2010-01-02 15:10:39 +00:00
parent 65a2f244a2
commit 56044329ab

View File

@ -1,12 +1,13 @@
;***************************************************************
;***************************************************************
; project name: PCI Device Enumeration
; target platform: KolibriOS
; compiler: flat assmebler 1.66
; version: 2.1
; last update: April 2007
; compiler: flat assembler 1.68
; version: 2.2
; last update: December 2007
; maintained by: Jason Delozier (cordata51@hotmail.com)
; Sergey Kuzmin (kuzmin_serg@list.ru)
; Mihailov Ilia (ghost.nsk@gmail.com)
; Artem Jerdev (art_zh@yahoo.com)
; project site: http://www.coolthemes.narod.ru/pcidev.html
;***************************************************************
;Summary: This program will attempt to scan the PCI Bus
@ -25,11 +26,22 @@
; Full device detection (like "ATI Radeon 9200") will increase app
; size a lot and probably it is function of particular drivers
;----------------------------------------------------------------
;2.2: PCIDEV 31/12/2009
;Author: Artem Jerdev <art_zh@yahoo.com>
;Features:
; fixed
; * English in some comments ;)
; added
; * ! user-accessible PCI memory channels detection
; * ! ASCII-dump as PCI memory access demonstration
; optimization
; * (yet needed)
;----------------------------------------------------------------
;2.1: PCIDEV ??/04/2007
;Author: Mihailov Ilia aka Ghost <ghost.nsk@gmail.com>
;Features:
; fixed
; * Same little bugs
; * Some little bugs
; * Source code formating
; * PCI version normalized 0210 -> 2.10
; added
@ -136,7 +148,9 @@
; * detect Revision, Class and Subclass of Device,
; * and make Description based on Class
;-------------------------------------------------------------
include '..\..\..\macros.inc'
;include '..\..\macros.inc'
include 'macros.inc'
MEOS_APP_START
CODE
call draw_window
@ -202,15 +216,15 @@ nomo: ;done drawing bars here
; Window inteface
mov cx, [PCI_Version]
add ch, '0'
mov [PCIWin + 85], ch ; 0xBADCODE but it work !
mov [PCIWin + 85], ch ; 0xBADCODE but it works !
mov ch, cl
shr cl, 4
and ch, 0x0f
add cx, '00'
mov [PCIWin + 87], cx
mov cl, [PCI_LastBus]
mov cl, [PCI_LastBus] ; will only work if [PCI_LastBus] < 10
add cl, '0'
mov [PCIWin + 105], cl
mov [PCIWin + 106], cl
mov edx, PCIWin
mov ebx, 20 * 65536 + 25 ; x start, ystart of text
@ -227,6 +241,7 @@ nomo: ;done drawing bars here
movzx ecx, byte [total] ; number to draw
mcall 47, 0x00020000,,150 * 65536 + 65, 0x224466
call Try_MMIO
mcall 12, 2 ; end of draw
ret
@ -274,12 +289,12 @@ Start_Enum:
mov cl, 0x0a ; Register to read (Get Subclass)
mcall 62 ; Read it
mov byte [PCI_SubClass], al; Save it
; from Mario79 august 2006
; by Mario79 august 2006
mov cl, 0x09 ; Register to read (Get Interface)
mcall 62 ; Read it
mov [PCI_Interface], al ; Save it
;
; from Ghost april 2007
; by Ghost april 2007
mov cl, 0x3c ; Register to read (Get IRQ)
@@: mcall 62 ; Read it
mov [PCI_IRQ], al ; Save it
@ -300,7 +315,31 @@ nextDev:
;------------------------------------------------------------------
;* Print device info to screen
Print_New_Device:
xor esi, esi ; Color of text
xor esi, esi ; default text color
; by art_zh December 2009
mov ch, byte [V_Bus]
mov cl, byte [V_Dev]
mcall 62, 11 ; detect uMMIO
cmp eax, -2
je no_ummio_here
mov esi, 0x990033 ; highlighted text color
mov bh, byte [V_Bus]
mov bl, byte [V_Dev]
mov byte [MMIO_Bus], bh
mov byte [MMIO_Dev], bl
add bh,'0'
mov [PCIWin + 129], bh ; uMMIO bus
mov al, bl
shr al, 1
shr al, 1
shr al, 1
add al,'0'
mov [PCIWin + 131], al ; uMMIO device
and bl, 7
add bl, '0'
mov [PCIWin + 133], bl ; uMMIO function
no_ummio_here:
movzx ecx,word [PCI_Vendor] ; Pointer to number to be written
mcall 47, 0x00040100 ; Write Vendor ID
and edx, 0xFFFF ;*****************************************
@ -401,7 +440,67 @@ Print_New_Device:
mcall 4,, 0x80000000,, 32 ; draw the text
movzx edx, bx ; get y coordinate
add edx, 0x0014000A ; add 10 to y coordinate and set x coordinate to 20
mov [gr_pos], edx
ret
;------------------------------------------------------------------
; Get the user-MMIO related info
;
; Added on ??-12-2009 by art_zh
;------------------------------------------------------------------
Try_MMIO:
xor ebx, ebx
mov edx, ebx
mov bh, byte [MMIO_BAR]
or bx, 12 ; function 12
mov ecx, 4096 ; =1 page to map
mcall 62
mov ecx, 0x80990022 ; print color : red
mov bh, byte [MMIO_BAR]
add bh, '0'
cmp eax, -3
jne @f
mov [bar_um+3], bh
mov ebx, [gr_pos]
mov edx, bar_um
mcall 4
jmp mmio_next_bar
@@:
cmp eax, -4
jne @f
mov [bar_io+3], bh
mov ebx, [gr_pos]
mov edx, bar_io
mcall 4
jmp mmio_next_bar
@@:
mov [bar_ram+3], bh
mov ebx, [gr_pos]
mov edx, bar_ram
mcall 4
mov edx, eax
mov esi, 64
mov ecx, 0x099 ; dump color : blue
add ebx, 10
mov [gr_pos], ebx
mcall 4
mov ecx, eax ; release the tried page
mcall 62,13
mmio_next_bar:
mov bh, [MMIO_BAR]
inc bh
cmp bh,6
je @f
mov [MMIO_BAR], bh
add [gr_pos], 10
jmp Try_MMIO
@@:
xor bh,bh
mov [MMIO_BAR], bh
ret
include 'VENDORS.INC'
;------------------------------------------------------------------
@ -414,19 +513,24 @@ Form: dw 800 ; window width (no more, special for 800x600)
dw 420 ; window height
dw 100 ; window y start
title db 'PCI Device Enumeration v 2.1 by J. Delozier, S. Kuzmin, V. Hanla, M. Zakiyanov', 0
title db 'PCI Device Enumerator v 2.2 by J.Delozier, S.Kuzmin, V.Hanla, M.Zakiyanov, A.Jerdev', 0
PCIWin mls \
'Please remember to enable PCI Access to Applications in Setup Menu.',\
' Don`t forget to enable PCI Access to Applications in Setup Menu.',\
'',\
'PCI Version = x.xx',\
'Last PCI Bus = x',\
'Quantity of devices =',\
'PCI Version = x.xx; Last PCI Bus = x',\
'User MMIO channel = 0F.F:F ',\
'Number of PCI units =',\
'',\
'VenID DevID Bus# Dev# Fnc Rev Class Subclass/ IRQ Company Description',\
' Interface',\
'----- ----- ---- ---- --- --- ----- --------- --- ------------------------------------------ ----------------'
bar_ram db 'BARx: MMIO block', 0
bar_io db 'BARx: IO ports',0
bar_um db 'BARx: unmapped',0
bar_rom db 'BAR6: Onboard ROM', 0 ; << no ROM test yet
;------------------------------------------------------------------
; UNINITIALIZED DATA AREA
UDATA
@ -447,5 +551,15 @@ PCI_SubClass db ?
PCI_Interface db ?
PCI_IRQ db ?
align 4
MMIO_Bus db ?
MMIO_Dev db ?
MMIO_BAR db 0
MMIO_Blk db 0
MMIO_Map rd 8
gr_pos dd ?
Proc_Info process_information
MEOS_APP_END