cleanup, trimming some fat.

git-svn-id: svn://kolibrios.org@4788 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2014-04-07 20:31:09 +00:00
parent ae5097b525
commit a11044300e
2 changed files with 107 additions and 1094 deletions

View File

@ -83,7 +83,8 @@ button: ; button
cmp ah, 1 ; button id = 1 ?
jne @f
exit: mcall -1 ; close this program
exit:
mcall -1 ; close this program
@@:
cmp eax, 0x0000ff00
jg load_drv
@ -102,7 +103,7 @@ exit: mcall -1 ; close this program
load_drv:
shr eax, 16
mov word [selected], ax
mov [selected], ax
mov bl, 6 ; get a dword
mov bh, ah ; bus
@ -110,9 +111,9 @@ load_drv:
mov cl, 0 ; offset to device/vendor id
mcall 62 ; get ID's
mov word [PCI_Vendor], ax
mov [PCI_Vendor], ax
shr eax, 16
mov word [PCI_Device], ax
mov [PCI_Device], ax
call get_drv_ptr
mov ecx, eax
@ -145,19 +146,18 @@ hook:
mov [IOCTL.output], 0
mcall 68, 17, IOCTL
mov byte[drivernumber], al
mov [drivernumber], al
jmp still
reset:
movzx ebx, byte[drivernumber]
movzx ebx, [drivernumber]
mcall 74,,2
jmp still
unload:
movzx ebx, byte[drivernumber]
movzx ebx, [drivernumber]
mcall 74,,3
jmp still
@ -202,46 +202,49 @@ draw_window:
;* Gets the PCI Version and Last Bus
Get_PCI_Info:
mcall 62, 0
mov word [PCI_Version], ax
mov [PCI_Version], ax
mcall 62, 1
mov byte [PCI_LastBus], al
mov [PCI_LastBus], al
;----------------------------------------------------------
;* Get all devices on PCI Bus
mov edx, 20 shl 16 + 110 ; set start write position
cmp al, 0xff ; 0xFF means no pci bus found
jne Pci_Exists ;
ret ; if no bus then leave
Pci_Exists:
mov byte [V_Bus], 0 ; reset varibles
mov byte [V_Dev], 0 ;
mov [V_Bus], 0
mov [V_Dev], 0
mov edx, 20 shl 16 + 110 ; set start write position
Start_Enum:
mov bl , 6 ; get a dword
mov bh , byte [V_Bus] ; bus of pci device
mov ch , byte [V_Dev] ; device number/function
mov bl, 6 ; read dword
mov bh, [V_Bus]
mov ch, [V_Dev]
mov cl, 0 ; offset to device/vendor id
mcall 62 ; get ID's
cmp ax, 0 ; Vendor ID should not be 0 or 0xFFFF
je nextDev ; check next device if nothing exists here
cmp ax, 0xffff ;
je nextDev ;
mov word [PCI_Vendor], ax ; There is a device here, save the ID's
mov [PCI_Vendor], ax ; There is a device here, save the ID's
shr eax, 16 ;
mov word [PCI_Device], ax ;
mov [PCI_Device], ax ;
mov bl, 4 ; Read config byte
mov bh , byte [V_Bus] ; Bus #
mov ch , byte [V_Dev] ; Device # on bus
mov bh, [V_Bus] ; Bus #
mov ch, [V_Dev] ; Device # on bus
mov cl, 0x08 ; Register to read (Get Revision)
mcall 62 ; Read it
mov byte [PCI_Rev], al ; Save it
mov [PCI_Rev], al ; Save it
mov cl, 0x0b ; Register to read (Get class)
mcall 62 ; Read it
mov byte [PCI_Class], al ; Save it
mov [PCI_Class], al ; Save it
mov cl, 0x0a ; Register to read (Get Subclass)
mcall 62 ; Read it
mov byte [PCI_SubClass], al ; Save it
mov [PCI_SubClass], al ; Save it
mov cl, 0x09 ; Register to read (Get Interface)
mcall 62 ; Read it
mov [PCI_Interface], al ; Save it
@ -273,19 +276,19 @@ Start_Enum:
js nextDev
nextdev2:
test byte [V_Dev], 7
test [V_Dev], 7
jnz nextDev
or byte [V_Dev], 7
or [V_Dev], 7
nextDev:
inc [V_Dev] ; lower 3 bits are the function number
jnz Start_Enum ; jump until we reach zero
mov byte [V_Dev], 0 ; reset device number
inc byte [V_Bus] ; next bus
mov al , byte [PCI_LastBus] ; get last bus
cmp byte [V_Bus], al ; was it last bus
mov [V_Dev], 0 ; reset device number
inc [V_Bus] ; next bus
mov al, [PCI_LastBus] ; get last bus
cmp [V_Bus], al ; was it last bus
jbe Start_Enum ; if not jump to keep searching
ret
@ -338,12 +341,12 @@ Print_New_Device:
shl ecx, 16
add ecx, 9
movzx edx, byte [V_Bus]
shl dx , 8
mov dl , byte [V_Dev]
xor edx, edx
mov dh, [V_Bus]
mov dl, [V_Dev]
mov esi, 0x0000c0ff ; color: yellow if selected, blue otherwise
cmp word [selected], dx
cmp [selected], dx
jne @f
mov esi, 0x00c0c000
@@:
@ -355,24 +358,24 @@ Print_New_Device:
pop edx
xor esi, esi ; Color of text
movzx ecx, word [PCI_Vendor] ; number to be written
movzx ecx, [PCI_Vendor] ; number to be written
mcall 47, 0x00040100 ; Write Vendor ID
add edx, (4*6+18) shl 16
movzx ecx, word [PCI_Device] ; get Vendor ID
movzx ecx, [PCI_Device] ; get Vendor ID
mcall ; Draw Vendor ID to Window
add edx, (4*6+18) shl 16
movzx ecx, byte [V_Bus] ; get bus number
movzx ecx, [V_Bus]
mcall ,0x00020100 ; draw bus number to screen
add edx, (2*6+18) shl 16
movzx ecx, byte [V_Dev] ; get device number
movzx ecx, [V_Dev]
shr ecx, 3 ; device number is bits 3-7
mcall ; Draw device Number To Window
add edx, (2*6+18) shl 16
movzx ecx, byte [PCI_Rev] ; get revision number
movzx ecx, [PCI_Rev]
mcall ; Draw Revision to screen
add edx, (2*6+18) shl 16
@ -390,7 +393,7 @@ Print_New_Device:
; Prints the Vendor's Name based on Vendor ID
;------------------------------------------------------------------
mov edx, VendorsTab
mov cx , word[PCI_Vendor]
mov cx, [PCI_Vendor]
.fn: mov ax, [edx]
add edx, 6
@ -539,12 +542,14 @@ V_Bus db ?
V_Dev db ?
PCI_Version dw ?
PCI_LastBus db ?
; Dont change order
PCI_Vendor dw ?
PCI_Device dw ?
PCI_Bus db ?
PCI_Dev db ?
PCI_Rev db ?
; don`t change order!!!
; Dont change order
PCI_Class db ?
PCI_SubClass db ?
PCI_Interface db ?

File diff suppressed because it is too large Load Diff