feat: mise à jour du code pour compilation sur LZASM en stdcall

This commit is contained in:
Nicolas Hordé 2007-03-23 16:52:03 +00:00
parent a7110cd360
commit 2dba1d4217
1 changed files with 113 additions and 540 deletions

View File

@ -1,551 +1,124 @@
.model tiny model tiny,stdcall
.486 p586N
smart locals
.code jumps
codeseg
option procalign:byte
include "..\include\mem.h"
include "..\include\divers.h"
include "..\include\cpu.h"
include "..\include\pci.h"
org 0h org 0h
include ..\include\pci.h
include ..\include\mem.h
start: start:
header exe <,1,0,,,offset imports,,> header exe <,1,0,,,offset imports,,offset realstart>
realstart: realstart:
call getpciinfos call [cs:print],offset msg_cpu_detect
mov [pciversion],bx call [cs:cpuinfo],offset thecpu
mov [nbbus],cl call [cs:setinfo],offset thecpu,offset temp
mov [pcitype],al call [cs:print],offset msg_ok2
push offset temp
xor edx,edx xor eax,eax
mov dl,[nbbus] mov al,[thecpu.family]
inc dl push eax
push edx mov al,[thecpu.models]
mov dx,[pciversion] push eax
push edx mov al,[thecpu.stepping]
mov dx,[pciversion] push eax
shr dx,8 push offset thecpu.names
push edx push offset thecpu.vendor
push offset msg call [cs:print],offset msg_cpu_detect_inf
call [print] call [cs:print],offset msg_pci
call [cs:pciinfo],offset thepci
mov di,offset types jc nopci
mov bx,7 call [cs:print],offset msg_ok2
mov al,pcitype xor eax,eax
vote: mov al,[thepci.maxbus]
bt ax,bx push eax
jnc nowas mov al,[thepci.version_minor]
shl bx,1 push eax
push word ptr [di+bx] mov al,[thepci.version_major]
call [print] push eax
shr bx,1 call [cs:print],offset msg_pci_info
nowas: call [cs:print],offset msg_pci_enum
dec bx xor bx,bx
jns vote xor cx,cx
push offset return xor si,si
call [print] searchpci:
call [cs:getcardinfo],bx,cx,si,offset temp
xor ax,ax jc stopthis
xor cx,cx mov al,[(pcidata offset temp).subclass]
mov si,offset infos push ax
search: mov al,[(pcidata offset temp).class]
mov di,si push ax
call Getallfunctionsinfos call [cs:getpcisubclass]
jc stopthis push dx
mov dh,[si+pci.subclass] push ax
mov dl,[si+pci.class] mov al,[(pcidata offset temp).class]
;sousclasse xor ah,ah
mov di,offset subclasse push ax
call getpcisubclass call [cs:getpciclass]
push di push dx
;classe push ax
mov di,offset classe push 4
call getpciclass push esi
push di push 4
;fonction push ecx
mov dl,ch push 4
push edx push ebx
;device mov ax,[(pcidata offset temp).device]
mov dl,cl push eax
push edx mov ax,[(pcidata offset temp).vendor]
;bus push eax
mov dl,al call [cs:print],offset msg_pci_card
push edx inc si
;device cmp si,7
mov dx,[si+pci.device] jbe searchpci
push edx
;vendeur
mov dx,[si+pci.vendor]
push edx
push offset msg2
call [print]
inc ch
cmp ch,7
jbe search
stopthis: stopthis:
xor ch,ch xor si,si
inc cl inc cx
cmp cl,31 cmp cx,31
jbe search jbe searchpci
xor cl,cl xor cx,cx
inc al inc bx
cmp al,16 cmp bx,16
jbe search jbe searchpci
retf jmp next
nopci:
call [cs:print],offset msg_echec2
next:
call [cs:detectvmware]
jne novirtual
call [cs:print],offset msg_vmware
novirtual:
retf
msg db "COS2000 hardware detecteur V1.6\lBIOS PCI version %hB.%hB a ete detecte !\lNombre de bus : %u\lCaracterisques PCI: ",0 importing
msg2 db "Peripherique :%hW Constructeur :%hW Id :%hB.%hB.%hB Classe :%0.%0\l",0 use VIDEO.LIB,print
return db "\l",0 use DETECT.LIB,cpuinfo
classe db 128 dup (0) use DETECT.LIB,setinfo
subclasse db 128 dup (0) use DETECT.LIB,pciinfo
use DETECT.LIB,getcardinfo
use DETECT.LIB,getpcisubclass
use DETECT.LIB,getpciclass
use DETECT.LIB,detectvmware
endi
types dw config1 thepci pciinf <>
dw config2 thecpu cpu <>
dw null temp db 256 dup (0)
dw null
dw config3
dw config4
dw null
dw null
null db 'indefini',0 msg_ok2 db "\h70 [\c02 Ok \c07]\l",0
config1 db 'Config Mechanism 1',0 msg_echec2 db "\h70 [\c0CPasser\c07]\l",0
config2 db 'Config Mechanism 2',0 msg_cpu_detect db "Dectection du processeur",0
config3 db 'Special Cycle Mechanism 1',0 msg_cpu_detect_inf db " -Fondeur : %0\l -Modele : %0\l -Revision : %u\l -Version : %u\l -Famille : %u\l -Technologies: %0\l",0
config4 db 'Special Cycle Mechanism 2',0 msg_pci db "Detection des systemes PCI",0
msg_pci_info db " -Version : %yB.%yB\l -Numero bus max: %u\l",0
PciVersion dw 0 msg_pci_enum db " -Enumeration des peripheriques PCI:\l"
Nbbus db 0 db " |Vendeur|Modele|Bus |Dev.|Func|Classe.Sous-classe\l",0
PciType db 0 msg_pci_card db " | %hW | %hW |%w|%w|%w|%0P.%0P\l",0
infos db 256 dup (0) msg_vmware db "\c04 VMWare a ete detecte !!!\c07\l",0
;fonction 0-7 bus 0-255 device 0-31
;renvoie en es:di de classe dl
getpciclass:
push ax cx dx si di ds es
push es
push di
mov di,dx
and di,0FFh
shl di,1
mov di,[offset classes+di]
mov cx,0FFh
mov al,0
push cs
pop es
repne scasb
sub cx,0FFh
neg cx
sub di,cx
mov si,di
push cs
pop ds
pop di
pop es
rep movsb
pop es ds di si dx cx ax
ret
;renvoie en es:di la sous-classe de dh et de classe dl
getpcisubclass:
push ax cx dx si di ds es
push es
push di
mov di,dx
and di,0FFh
shl di,1
mov di,[offset classesd+di]
xchg dh,dl
xor dh,dh
cmp dx,80h
jne suiteac
mov di,offset divers
jmp found
suiteac:
shl dx,1
add di,dx
mov di,[di]
found:
mov cx,0FFh
mov al,0
push cs
pop es
repne scasb
sub cx,0FFh
neg cx
sub di,cx
mov si,di
push cs
pop ds
pop di
pop es
rep movsb
pop es ds di si dx cx ax
ret
divers db 'divers',0
classes:
dw offset class0
dw offset class1
dw offset class2
dw offset class3
dw offset class4
dw offset class5
dw offset class6
dw offset class7
dw offset class8
dw offset class9
dw offset class10
dw offset class11
dw offset class12
dw offset class13
dw offset class14
dw offset class15
dw offset class16
dw offset class17
class0 db 'ancien',0
class1 db 'stockage',0
class2 db 'reseau',0
class3 db 'affichage',0
class4 db 'multimedia',0
class5 db 'memoire',0
class6 db 'pont',0
class7 db 'communication',0
class8 db 'systeme',0
class9 db 'acquisition',0
class10 db 'dock',0
class11 db 'processeur',0
class12 db 'bus serie',0
class13 db 'sans fil',0
class14 db 'intelligent',0
class15 db 'satellite',0
class16 db 'cryptage',0
class17 db 'traitement signal',0
;Classes et sous classes
classesd:
dw offset class0d
dw offset class1d
dw offset class2d
dw offset class3d
dw offset class4d
dw offset class5d
dw offset class6d
dw offset class7d
dw offset class8d
dw offset class9d
dw offset class10d
dw offset class11d
dw offset class12d
dw offset class13d
dw offset class14d
dw offset class15d
dw offset class16d
dw offset class17d
class0d:
dw offset subclass00
dw offset subclass01
subclass00 db 'divers',0
subclass01 db 'vga',0
class1d:
dw offset subclass10
dw offset subclass11
dw offset subclass12
dw offset subclass13
dw offset subclass14
subclass10 db 'scsi',0
subclass11 db 'ide',0
subclass12 db 'disquette',0
subclass13 db 'ipi',0
subclass14 db 'raid',0
class2d:
dw offset subclass20
dw offset subclass21
dw offset subclass22
dw offset subclass23
dw offset subclass24
subclass20 db 'ethernet',0
subclass21 db 'token ring',0
subclass22 db 'fddi',0
subclass23 db 'atm',0
subclass24 db 'isdn',0
class3d:
dw offset subclass30
dw offset subclass31
dw offset subclass32
subclass30 db 'vga',0
subclass31 db 'xga',0
subclass32 db '3D',0
class4d:
dw offset subclass40
dw offset subclass41
dw offset subclass42
subclass40 db 'video',0
subclass41 db 'audio',0
subclass42 db 'telephonie',0
class5d:
dw offset subclass50
dw offset subclass51
subclass50 db 'ram',0
subclass51 db 'flash',0
class6d:
dw offset subclass60
dw offset subclass61
dw offset subclass62
dw offset subclass63
dw offset subclass64
dw offset subclass65
dw offset subclass66
dw offset subclass67
dw offset subclass68
subclass60 db 'hote',0
subclass61 db 'isa',0
subclass62 db 'eisa',0
subclass63 db 'mca',0
subclass64 db 'pci',0
subclass65 db 'pcmcia',0
subclass66 db 'nubus',0
subclass67 db 'cardbus',0
subclass68 db 'RACEway',0
class7d:
dw offset subclass70
dw offset subclass71
dw offset subclass72
dw offset subclass73
subclass70 db 'serie',0
subclass71 db 'parallele',0
subclass72 db 'serie multiport',0
subclass73 db 'modem',0
class8d:
dw offset subclass80
dw offset subclass81
dw offset subclass82
dw offset subclass83
dw offset subclass84
subclass80 db 'pic',0
subclass81 db 'dma',0
subclass82 db 'timer',0
subclass83 db 'rtc',0
subclass84 db 'hotplug',0
class9d:
dw offset subclass90
dw offset subclass91
dw offset subclass92
dw offset subclass93
dw offset subclass94
subclass90 db 'clavier',0
subclass91 db 'stylo',0
subclass92 db 'souris',0
subclass93 db 'scanner',0
subclass94 db 'joystick',0
class10d:
dw offset subclass100
subclass100 db 'station',0
class11d:
dw offset subclass110
dw offset subclass111
dw offset subclass112
dw offset subclass113
dw offset subclass114
subclass110 db '386',0
subclass111 db '486',0
subclass112 db 'pentium',0
subclass113 db 'alpha',0
subclass114 db 'coprocesseur',0
class12d:
dw offset subclass120
dw offset subclass121
dw offset subclass122
dw offset subclass123
dw offset subclass124
dw offset subclass125
subclass120 db 'firewire',0
subclass121 db 'access',0
subclass122 db 'ssa',0
subclass123 db 'usb',0
subclass124 db 'fibre',0
subclass125 db 'smbus',0
class13d:
dw offset subclass130
dw offset subclass131
dw offset subclass132
subclass130 db 'irda',0
subclass131 db 'ir',0
subclass132 db 'rf',0
class14d:
dw offset subclass140
subclass140 db 'IO arch',0
class15d:
dw offset subclass150
dw offset subclass151
dw offset subclass152
dw offset subclass153
subclass150 db 'tv',0
subclass151 db 'audio',0
subclass152 db 'voix',0
subclass153 db 'donnees',0
class16d:
dw offset subclass160
dw offset subclass161
subclass160 db 'reseau',0
subclass161 db 'jeux',0
class17d:
dw offset subclass170
subclass170 db 'dpio',0
;bx pci version, cl nbbus, al pci type
getPciInfos:
push dx
mov ax,0B101h
xor edi,edi
mov edx," PCI"
int 1Ah
jc ErrorPci
cmp dx,04350h
jne ErrorPci
clc
pop dx
ret
errorpci:
stc
pop dx
ret
;al=bus cl=deviceid ch=func es:di
Getallfunctionsinfos:
push ax bx dx di
cmp ch,0
je amultiorfirst
mov bl,0Eh
push cx
xor ch,ch
call getfunctioninfo
pop cx
and dl,80h
cmp dl,0
jne amultiorfirst
mov word ptr [di],0000h
jmp notexist
amultiorfirst:
xor bl,bl
goinfos:
call getfunctioninfo
inc bl
cmp bl,2
ja notzarb
cmp dl,0FFh
je notexist
notzarb:
mov es:[di],dl
inc di
cmp bl,255
jb goinfos
pop di
push di
cmp word ptr [di],0000h
je notexist
clc
pop di dx bx ax
ret
notexist:
stc
pop di dx bx ax
ret
; PCI TYPE 1
;*******************************************************************
config1_addr equ 0CF8h
config1_data equ 0CFCh
pci_type1_detect:
mov dx, config1_addr+3
mov al, 01h
out dx,al
mov dx,config1_addr
in eax,dx
mov ecx,eax
mov eax,80000000h
out dx,eax
in eax,dx
cmp eax,80000000h
jne endofdetectiontype1
mov eax,ecx
out dx,eax
endofdetectiontype1:
ret
;al=bus bl=index cl=deviceid ch=func->dl
getfunctioninfo:
push eax bx cx
mov ah,80h
shl eax,16
mov ah,cl
shl ah,3
or ah,ch
mov al,bl
and al,0fch
mov dx,0cf8h
out dx,eax
mov dx,0CFCh
and bl,3
or dl,bl
in al,dx
mov dl,al
pop cx bx eax
ret
; PCI TYPE 2
;*******************************************************************
config2_reg0 equ 0CFBh
config2_reg1 equ 0CF8h
config2_reg2 equ 0CFAh
pci_type2_detect:
xor ax,ax
mov dx,config2_reg0
out dx,ax
mov dx,config2_reg1
out dx,ax
mov dx,config2_reg2
out dx,ax
mov ax,config2_reg1
in al,dx
cmp al,0
jne endofdetectiontype2
mov ax,config2_reg0
in al,dx
cmp al,0
jne endofdetectiontype2
endofdetectiontype2:
ret
imports:
db "VIDEO.LIB::print",0
print dd 0
dw 0
end start