refactor: mise à jour vers fasm, librairies et noyau

This commit is contained in:
Nicolas Hordé 2019-07-09 10:33:10 +02:00
parent d2028e1803
commit a9cba3a71a
9 changed files with 1785 additions and 1933 deletions

View File

@ -18,4 +18,5 @@ struc cpu
.now3d2 db 0 .now3d2 db 0
.htt db 0 .htt db 0
.apic db 0 .apic db 0
.sizeof = $ - .vendor
} }

View File

@ -3,6 +3,7 @@ struc diskbuffer
.size dw 12 .size dw 12
.current dw 0FFFFh .current dw 0FFFFh
.chain dw 128 dup (0FFFFh) .chain dw 128 dup (0FFFFh)
.sizeof = $ - .size
} }
struc dpt struc dpt
@ -18,6 +19,7 @@ struc dpt
.formatbyte db 0F6h ;Octet de formatage .formatbyte db 0F6h ;Octet de formatage
.headsettlingtime db 000h ;Temps de repos des tˆtes .headsettlingtime db 000h ;Temps de repos des tˆtes
.delaymotornormspeed db 008h ;Temps de monte en vitesse du moteur .delaymotornormspeed db 008h ;Temps de monte en vitesse du moteur
.sizeof = $ - .steprateheadunload
} }
struc entries struc entries
@ -35,6 +37,7 @@ struc entries
.filedate dw 0 .filedate dw 0
.filegroup dw 0 .filegroup dw 0
.filesize dd 0 .filesize dd 0
.sizeof = $ - .filename
} }
;Pour recherches ;Pour recherches
@ -45,6 +48,7 @@ struc find files
.adressdirectory dw 0 ;En cluster .adressdirectory dw 0 ;En cluster
.firstsearch db 1 ;Premiere requete ? .firstsearch db 1 ;Premiere requete ?
.result entries .result entries
.sizeof = $ - .files
} }
struc bootinfo vendor,drivename,serialnumber struc bootinfo vendor,drivename,serialnumber
@ -69,4 +73,5 @@ struc bootinfo vendor,drivename,serialnumber
.serialnumber dd 01020304h ;no de serie .serialnumber dd 01020304h ;no de serie
.drivename db 'COS2000 ' ;nom de volume .drivename db 'COS2000 ' ;nom de volume
.typeoffat db 'FAT12 ' ;FAT .typeoffat db 'FAT12 ' ;FAT
.sizeof = $ - .vendor
} }

View File

@ -1,32 +1,36 @@
struc point struc point
coordx db 0 {
coordy db 0 .coordx db 0
ends point .coordy db 0
}
struc vgainf struc vgainf
lines db 0 {
columns db 0 .lines db 0
x db 0 .columns db 0
y db 0 .x db 0
xy dw 0 .y db 0
colors db 7 .xy dw 0
mode db 0FFh .colors db 7
pagesize dw 0 .modenum db 0FFh
style db 0 .pagesize dw 0
font db 0 .style db 0
graphic db 0 .font db 0
nbpage db 0 .graphic db 0
color db 0 .nbpage db 0
cursor db 0 .color db 0
segments dw 0 .cursor db 0
linesize dw 0 .segments dw 0
adress dw 0 .linesize dw 0
base dw 0 .adress dw 0
scrolling db 1 .base dw 0
ends vgainf .scrolling db 1
.sizeof = $ - .lines
}
struc vertex2d struc vertex2d
px dw ? {
py dw ? .px dw ?
ends vertex2d .py dw ?
}

View File

@ -111,13 +111,13 @@ macro importing
macro noimporting macro noimporting
{ {
imports: imports:
dd 0 ende
} }
macro noexporting macro noexporting
{ {
imports: imports:
dd 0 ende
} }
macro ende macro ende
@ -132,7 +132,7 @@ macro endi
macro use lib*,fonction* macro use lib*,fonction*
{ {
db "&lib&::&fonction&",0 db `lib,"::",`fonction,0
fonction: fonction:
dd 0 dd 0
dd 0 dd 0
@ -140,7 +140,7 @@ fonction:
macro declare fonction* macro declare fonction*
{ {
db "&fonction&",0 db `fonction,0
dw fonction dw fonction
} }
@ -148,50 +148,27 @@ macro declare fonction*
; Macroinstructions for defining and calling procedures ; Macroinstructions for defining and calling procedures
macro stdcall proc,[arg] ; directly call STDCALL procedure macro stdcall proc,[arg] ; directly call STDCALL procedure
{ common {
common
if ~ arg eq if ~ arg eq
reverse reverse
pushw arg push arg
common
end if
call proc }
macro invoke proc,[arg] ; indirectly call STDCALL procedure
{ common
if ~ arg eq
reverse
pushw arg
common
end if
call [proc] }
macro ccall proc,[arg] ; directly call CDECL procedure
{ common
size@ccall = 0
if ~ arg eq
reverse
pushw arg
size@ccall = size@ccall+2
common common
end if end if
push cs
call proc call proc
if size@ccall }
add sp,size@ccall
end if }
macro cinvoke proc,[arg] ; indirectly call CDECL procedure macro invoke proc,[arg] ; directly call STDCALL procedure
{ common {
size@ccall = 0 common
if ~ arg eq if ~ arg eq
reverse reverse
pushw arg push arg
size@ccall = size@ccall+2
common common
end if end if
call [proc] call far [cs:proc]
if size@ccall }
add sp,size@ccall
end if }
macro proc [args] ; define procedure macro proc [args] ; define procedure
{ common { common
@ -231,10 +208,6 @@ macro define@proc name,statement
flag = 11b \} flag = 11b \}
match =stdcall, statement \{ params equ match =stdcall, statement \{ params equ
flag = 11b \} flag = 11b \}
match =c args, statement \{ params equ args
flag = 10001b \}
match =c, statement \{ params equ
flag = 10001b \}
match =params, params \{ params equ statement match =params, params \{ params equ statement
flag = 0 \} flag = 0 \}
virtual at bp+4 virtual at bp+4

View File

@ -1,17 +1,10 @@
model tiny,stdcall
p586
locals
jumps
codeseg
option procalign:byte
include "..\include\mem.h" include "..\include\mem.h"
include "..\include\cpu.h" include "..\include\cpu.h"
include "..\include\pci.h" include "..\include\pci.h"
org 0h org 0h
header exe <"CE",1,0,0,offset exports,,,> header exe 1
exporting exporting
declare cpuinfo declare cpuinfo
@ -26,73 +19,68 @@ declare pcireaddword
declare detectvmware declare detectvmware
ende ende
PROC detectvmware FAR proc detectvmware uses eax ebx ecx edx
USES eax,ebx,ecx,edx
mov eax,564D5868h mov eax,564D5868h
mov ebx,12345h mov ebx,12345h
mov ecx,00Ah mov ecx,00Ah
mov edx,5658h mov edx,5658h
in ax,dx in ax,dx
cmp ebx,564D5868h cmp ebx,564D5868h
ret retf
endp detectvmware endp
;renvoie un pointer dx:ax vers la classe %0 ;renvoie un pointer dx:ax vers la classe %0
PROC getpciclass FAR proc getpciclass uses di, class:word
ARG @class:word mov di,[class]
USES di
mov di,[@class]
and di,0FFh and di,0FFh
shl di,1 shl di,1
mov ax,[cs:offset classes+di] mov ax,[cs:classes+di]
mov dx,cs mov dx,cs
ret retf
endp getpciclass endp
;renvoie un pointer dx:ax vers la sous-classe de %1 et de classe %0 ;renvoie un pointer dx:ax vers la sous-classe de %1 et de classe %0
PROC getpcisubclass FAR proc getpcisubclass uses di, class:word,subclass:word
ARG @class:word,@subclass:word mov di,[class]
USES di
mov di,[@class]
and di,0FFh and di,0FFh
shl di,1 shl di,1
mov di,[cs:offset classesd+di] mov di,[cs:classesd+di]
mov dx,[@subclass] mov dx,[subclass]
and dx,0FFh and dx,0FFh
cmp dx,80h cmp dx,80h
jne @@suiteac jne .suiteac
mov ax,offset divers mov ax,divers
jmp @@found jmp .found
@@suiteac: .suiteac:
shl dx,1 shl dx,1
add di,dx add di,dx
mov ax,[cs:di] mov ax,[cs:di]
@@found: .found:
mov dx,cs mov dx,cs
ret retf
endp getpcisubclass endp
divers db 'divers',0 divers db 'divers',0
classes: classes:
dw offset class0 dw class0
dw offset class1 dw class1
dw offset class2 dw class2
dw offset class3 dw class3
dw offset class4 dw class4
dw offset class5 dw class5
dw offset class6 dw class6
dw offset class7 dw class7
dw offset class8 dw class8
dw offset class9 dw class9
dw offset class10 dw class10
dw offset class11 dw class11
dw offset class12 dw class12
dw offset class13 dw class13
dw offset class14 dw class14
dw offset class15 dw class15
dw offset class16 dw class16
dw offset class17 dw class17
class0 db 'ancien',0 class0 db 'ancien',0
class1 db 'stockage',0 class1 db 'stockage',0
class2 db 'reseau',0 class2 db 'reseau',0
@ -115,37 +103,37 @@ class17 db 'traitement signal',0
;Classes et sous classes ;Classes et sous classes
classesd: classesd:
dw offset class0d dw class0d
dw offset class1d dw class1d
dw offset class2d dw class2d
dw offset class3d dw class3d
dw offset class4d dw class4d
dw offset class5d dw class5d
dw offset class6d dw class6d
dw offset class7d dw class7d
dw offset class8d dw class8d
dw offset class9d dw class9d
dw offset class10d dw class10d
dw offset class11d dw class11d
dw offset class12d dw class12d
dw offset class13d dw class13d
dw offset class14d dw class14d
dw offset class15d dw class15d
dw offset class16d dw class16d
dw offset class17d dw class17d
class0d: class0d:
dw offset subclass00 dw subclass00
dw offset subclass01 dw subclass01
subclass00 db 'divers',0 subclass00 db 'divers',0
subclass01 db 'vga',0 subclass01 db 'vga',0
class1d: class1d:
dw offset subclass10 dw subclass10
dw offset subclass11 dw subclass11
dw offset subclass12 dw subclass12
dw offset subclass13 dw subclass13
dw offset subclass14 dw subclass14
subclass10 db 'scsi',0 subclass10 db 'scsi',0
subclass11 db 'ide',0 subclass11 db 'ide',0
subclass12 db 'disquette',0 subclass12 db 'disquette',0
@ -153,11 +141,11 @@ subclass13 db 'ipi',0
subclass14 db 'raid',0 subclass14 db 'raid',0
class2d: class2d:
dw offset subclass20 dw subclass20
dw offset subclass21 dw subclass21
dw offset subclass22 dw subclass22
dw offset subclass23 dw subclass23
dw offset subclass24 dw subclass24
subclass20 db 'ethernet',0 subclass20 db 'ethernet',0
subclass21 db 'token ring',0 subclass21 db 'token ring',0
subclass22 db 'fddi',0 subclass22 db 'fddi',0
@ -165,37 +153,37 @@ subclass23 db 'atm',0
subclass24 db 'isdn',0 subclass24 db 'isdn',0
class3d: class3d:
dw offset subclass30 dw subclass30
dw offset subclass31 dw subclass31
dw offset subclass32 dw subclass32
subclass30 db 'vga',0 subclass30 db 'vga',0
subclass31 db 'xga',0 subclass31 db 'xga',0
subclass32 db '3D',0 subclass32 db '3D',0
class4d: class4d:
dw offset subclass40 dw subclass40
dw offset subclass41 dw subclass41
dw offset subclass42 dw subclass42
subclass40 db 'video',0 subclass40 db 'video',0
subclass41 db 'audio',0 subclass41 db 'audio',0
subclass42 db 'telephonie',0 subclass42 db 'telephonie',0
class5d: class5d:
dw offset subclass50 dw subclass50
dw offset subclass51 dw subclass51
subclass50 db 'ram',0 subclass50 db 'ram',0
subclass51 db 'flash',0 subclass51 db 'flash',0
class6d: class6d:
dw offset subclass60 dw subclass60
dw offset subclass61 dw subclass61
dw offset subclass62 dw subclass62
dw offset subclass63 dw subclass63
dw offset subclass64 dw subclass64
dw offset subclass65 dw subclass65
dw offset subclass66 dw subclass66
dw offset subclass67 dw subclass67
dw offset subclass68 dw subclass68
subclass60 db 'hote',0 subclass60 db 'hote',0
subclass61 db 'isa',0 subclass61 db 'isa',0
subclass62 db 'eisa',0 subclass62 db 'eisa',0
@ -207,21 +195,21 @@ subclass67 db 'cardbus',0
subclass68 db 'RACEway',0 subclass68 db 'RACEway',0
class7d: class7d:
dw offset subclass70 dw subclass70
dw offset subclass71 dw subclass71
dw offset subclass72 dw subclass72
dw offset subclass73 dw subclass73
subclass70 db 'serie',0 subclass70 db 'serie',0
subclass71 db 'parallele',0 subclass71 db 'parallele',0
subclass72 db 'serie multiport',0 subclass72 db 'serie multiport',0
subclass73 db 'modem',0 subclass73 db 'modem',0
class8d: class8d:
dw offset subclass80 dw subclass80
dw offset subclass81 dw subclass81
dw offset subclass82 dw subclass82
dw offset subclass83 dw subclass83
dw offset subclass84 dw subclass84
subclass80 db 'pic',0 subclass80 db 'pic',0
subclass81 db 'dma',0 subclass81 db 'dma',0
subclass82 db 'timer',0 subclass82 db 'timer',0
@ -229,11 +217,11 @@ subclass83 db 'rtc',0
subclass84 db 'hotplug',0 subclass84 db 'hotplug',0
class9d: class9d:
dw offset subclass90 dw subclass90
dw offset subclass91 dw subclass91
dw offset subclass92 dw subclass92
dw offset subclass93 dw subclass93
dw offset subclass94 dw subclass94
subclass90 db 'clavier',0 subclass90 db 'clavier',0
subclass91 db 'stylo',0 subclass91 db 'stylo',0
subclass92 db 'souris',0 subclass92 db 'souris',0
@ -241,15 +229,15 @@ subclass93 db 'scanner',0
subclass94 db 'joystick',0 subclass94 db 'joystick',0
class10d: class10d:
dw offset subclass100 dw subclass100
subclass100 db 'station',0 subclass100 db 'station',0
class11d: class11d:
dw offset subclass110 dw subclass110
dw offset subclass111 dw subclass111
dw offset subclass112 dw subclass112
dw offset subclass113 dw subclass113
dw offset subclass114 dw subclass114
subclass110 db '386',0 subclass110 db '386',0
subclass111 db '486',0 subclass111 db '486',0
subclass112 db 'pentium',0 subclass112 db 'pentium',0
@ -257,12 +245,12 @@ subclass113 db 'alpha',0
subclass114 db 'coprocesseur',0 subclass114 db 'coprocesseur',0
class12d: class12d:
dw offset subclass120 dw subclass120
dw offset subclass121 dw subclass121
dw offset subclass122 dw subclass122
dw offset subclass123 dw subclass123
dw offset subclass124 dw subclass124
dw offset subclass125 dw subclass125
subclass120 db 'firewire',0 subclass120 db 'firewire',0
subclass121 db 'access',0 subclass121 db 'access',0
subclass122 db 'ssa',0 subclass122 db 'ssa',0
@ -271,87 +259,86 @@ subclass124 db 'fibre',0
subclass125 db 'smbus',0 subclass125 db 'smbus',0
class13d: class13d:
dw offset subclass130 dw subclass130
dw offset subclass131 dw subclass131
dw offset subclass132 dw subclass132
subclass130 db 'irda',0 subclass130 db 'irda',0
subclass131 db 'ir',0 subclass131 db 'ir',0
subclass132 db 'rf',0 subclass132 db 'rf',0
class14d: class14d:
dw offset subclass140 dw subclass140
subclass140 db 'IO arch',0 subclass140 db 'IO arch',0
class15d: class15d:
dw offset subclass150 dw subclass150
dw offset subclass151 dw subclass151
dw offset subclass152 dw subclass152
dw offset subclass153 dw subclass153
subclass150 db 'tv',0 subclass150 db 'tv',0
subclass151 db 'audio',0 subclass151 db 'audio',0
subclass152 db 'voix',0 subclass152 db 'voix',0
subclass153 db 'donnees',0 subclass153 db 'donnees',0
class16d: class16d:
dw offset subclass160 dw subclass160
dw offset subclass161 dw subclass161
subclass160 db 'reseau',0 subclass160 db 'reseau',0
subclass161 db 'jeux',0 subclass161 db 'jeux',0
class17d: class17d:
dw offset subclass170 dw subclass170
subclass170 db 'dpio',0 subclass170 db 'dpio',0
;al=bus cl=deviceid ch=func es:di ;al=bus cl=deviceid ch=func es:di
PROC getcardinfo FAR proc getcardinfo uses eax bx di, bus:word,device:word,function:word,pointer:word
ARG @bus:word,@device:word,@function:word,@pointer:word mov di,[pointer]
USES eax,bx,di cmp [function],0
mov di,[@pointer] je .amultiorfirst
cmp [@function],0 virtual at 0
je @@amultiorfirst .pcidata pcidata
call pcireadbyte,[@bus],[@device],0,offset (pcidata).typed end virtual
stdcall pcireadbyte,[bus],[device],0,.pcidata.typed
and al,multifunction and al,multifunction
cmp al,0 cmp al,0
jne @@amultiorfirst jne .amultiorfirst
mov [word ptr di],0000h mov word [di],0000h
jmp @@notexist jmp .notexist
@@amultiorfirst: .amultiorfirst:
xor bx,bx xor bx,bx
@@goinfos: .goinfos:
call pcireadword,[@bus],[@device],[@function],bx stdcall pcireadword,[bus],[device],[function],bx
inc bl inc bl
inc bl inc bl
cmp bl,2 cmp bl,2
ja @@notzarb ja .notzarb
cmp ax,0FFFFh cmp ax,0FFFFh
je @@notexist je .notexist
cmp ax,00000h cmp ax,00000h
je @@notexist je .notexist
@@notzarb: .notzarb:
mov [ds:di],ax mov [ds:di],ax
inc di inc di
inc di inc di
cmp bl,40h cmp bl,40h
jbe @@goinfos jbe .goinfos
clc clc
ret retf
@@notexist: .notexist:
stc stc
ret retf
endp getcardinfo endp
;lit un octet du bus %0 device %1 function %2 nø %3 et le met en AL ;lit un octet du bus %0 device %1 function %2 nø %3 et le met en AL
PROC pcireadbyte FAR proc pcireadbyte uses bx dx, bus:word,device:word,function:word,pointer:word
ARG @bus:word,@device:word,@function:word,@pointer:word mov al,byte [bus]
USES bx,dx
mov al,[byte ptr @bus]
mov ah,80h mov ah,80h
shl eax,16 shl eax,16
mov ah,[byte ptr @device] mov ah,byte [device]
shl ah,3 shl ah,3
or ah,[byte ptr @function] or ah,byte [function]
mov bl,[byte ptr @pointer] mov bl,byte [pointer]
mov al,bl mov al,bl
and al,0fch and al,0fch
mov dx,config1addr mov dx,config1addr
@ -360,20 +347,18 @@ PROC pcireadbyte FAR
and bl,3 and bl,3
or dl,bl or dl,bl
in al,dx in al,dx
ret retf
endp pcireadbyte endp
;lit 2 octet du bus %0 device %1 function %2 nø %3 et le met en AX ;lit 2 octet du bus %0 device %1 function %2 nø %3 et le met en AX
PROC pcireadword FAR proc pcireadword uses bx dx, bus:word,device:word,function:word,pointer:word
ARG @bus:word,@device:word,@function:word,@pointer:word mov al,byte [bus]
USES bx,dx
mov al,[byte ptr @bus]
mov ah,80h mov ah,80h
shl eax,16 shl eax,16
mov ah,[byte ptr @device] mov ah,byte [device]
shl ah,3 shl ah,3
or ah,[byte ptr @function] or ah,byte [function]
mov bl,[byte ptr @pointer] mov bl,byte [pointer]
mov al,bl mov al,bl
and al,0fch and al,0fch
mov dx,config1addr mov dx,config1addr
@ -382,20 +367,18 @@ PROC pcireadword FAR
and bl,3 and bl,3
or dl,bl or dl,bl
in ax,dx in ax,dx
ret retf
endp pcireadword endp
;lit 4 octet du bus %0 device %1 function %2 nø %3 et le met en EAX ;lit 4 octet du bus %0 device %1 function %2 nø %3 et le met en EAX
PROC pcireaddword FAR proc pcireaddword uses bx dx, bus:word,device:word,function:word,pointer:word
ARG @bus:word,@device:word,@function:word,@pointer:word mov al,byte [bus]
USES bx,dx
mov al,[byte ptr @bus]
mov ah,80h mov ah,80h
shl eax,16 shl eax,16
mov ah,[byte ptr @device] mov ah,byte [device]
shl ah,3 shl ah,3
or ah,[byte ptr @function] or ah,byte [function]
mov bl,[byte ptr @pointer] mov bl,byte [pointer]
mov al,bl mov al,bl
and al,0fch and al,0fch
mov dx,config1addr mov dx,config1addr
@ -404,263 +387,266 @@ PROC pcireaddword FAR
and bl,3 and bl,3
or dl,bl or dl,bl
in eax,dx in eax,dx
ret retf
endp pcireaddword endp
;Prob avec str pci ;Prob avec str pci
;renvoie en %0 la structure pciinf carry if error ;renvoie en %0 la structure pciinf carry if error
PROC pciinfo FAR proc pciinfo uses ax bx cx edx edi, pointer:word
ARG @pointer:word
USES ax,bx,cx,edx,edi
mov ax,0B101h mov ax,0B101h
xor edi,edi xor edi,edi
mov edx," PCI" mov edx," PCI"
int 1Ah int 1Ah
jc @@errorpci jc .errorpci
cmp dx,04350h cmp dx,04350h
jne @@errorpci jne .errorpci
cmp ah,0 cmp ah,0
jne @@errorpci jne .errorpci
mov di,[@pointer] mov di,[pointer]
mov [(pciinf di).version_major],bh virtual at di
mov [(pciinf di).version_minor],bl .pciinf pciinf
mov [(pciinf di).types],al end virtual
mov [(pciinf di).maxbus],cl mov [.pciinf.version_major],bh
mov [.pciinf.version_minor],bl
mov [.pciinf.types],al
mov [.pciinf.maxbus],cl
clc clc
ret retf
@@errorpci: .errorpci:
stc stc
ret retf
endp pciinfo endp
;retourne en DS:%1 les set supporté du processeur par rapport a la struct %0 ;retfourne en DS:%1 les set supporté du processeur par rapport a la struct %0
PROC setinfo FAR proc setinfo uses bx si di, pointer:word,set:word
ARG @pointer:word,@set:word mov di,[set]
USES bx,si,di virtual at 0
mov di,[@set] .cpu cpu
lea si,[ds:cpu.mmx] end virtual
add si,[@pointer] lea si,[ds:.cpu.mmx]
mov bx,offset @@theset add si,[pointer]
@@set: mov bx,.theset
cmp [word ptr cs:bx],0FFFFh .set:
je @@endofset cmp word [cs:bx],0FFFFh
cmp [byte ptr si],1 je .endofset
jne @@nextset cmp byte [si],1
jne .nextset
push bx push bx
mov bx,[cs:bx] mov bx,[cs:bx]
@@put: .put:
mov al,[cs:bx] mov al,[cs:bx]
cmp al,0 cmp al,0
je @@enofput je .enofput
mov [di],al mov [di],al
inc bx inc bx
inc di inc di
jmp @@put jmp .put
@@enofput: .enofput:
pop bx pop bx
@@nextset: .nextset:
inc bx inc bx
inc bx inc bx
inc si inc si
jmp @@set jmp .set
@@endofset: .endofset:
mov [byte ptr di],0 mov byte [di],0
ret retf
@@theset dw offset @@mmx .theset dw .mmx
dw offset @@mmx2 dw .mmx2
dw offset @@sse dw .sse
dw offset @@sse2 dw .sse2
dw offset @@sse3 dw .sse3
dw offset @@fpu dw .fpu
dw offset @@now3d dw .now3d
dw offset @@now3d2 dw .now3d2
dw offset @@htt dw .htt
dw offset @@apic dw .apic
dw 0FFFFh dw 0FFFFh
@@mmx db "MMX ",0 .mmx db "MMX ",0
@@mmx2 db "MMX2 ",0 .mmx2 db "MMX2 ",0
@@now3d db "3dNow! ",0 .now3d db "3dNow! ",0
@@now3d2 db "3dNow Extended! ",0 .now3d2 db "3dNow Extended! ",0
@@htt db "HyperThreading",0 .htt db "HyperThreading",0
@@sse db "SSE ",0 .sse db "SSE ",0
@@sse2 db "SSE2 ",0 .sse2 db "SSE2 ",0
@@sse3 db "SSE3 ",0 .sse3 db "SSE3 ",0
@@apic db "APIC ",0 .apic db "APIC ",0
@@fpu db "FPU ",0 .fpu db "FPU ",0
endp setinfo endp
;retourne en DS:%0 les capacités du processeur ;retfourne en DS:%0 les capacités du processeur
PROC cpuinfo FAR proc cpuinfo uses eax ebx ecx edx si di ds es, pointer:word
ARG @pointer:word
USES eax,ebx,ecx,edx,si,di,ds,es
push ds push ds
pop es pop es
mov di,[@pointer] mov di,[pointer]
mov al,0 mov al,0
mov cx,size cpu virtual at 0
.cpu cpu
end virtual
mov cx,.cpu.sizeof
cld cld
rep stosb rep stosb
mov di,[@pointer] mov di,[pointer]
call nocpuid ;Test si cpuid est dispo call nocpuid ;Test si cpuid est dispo
je @@nocpuidatall je .nocpuidatall
xor eax,eax xor eax,eax
cpuid ;Fonction 0 de CPUID cpuid ;Fonction 0 de CPUID
mov [dword ptr (cpu di).vendor],ebx ;Vendeur sur 13 octets mov dword [.cpu.vendor],ebx ;Vendeur sur 13 octets
mov [dword ptr (cpu di+4).vendor],edx mov dword [.cpu.vendor+4],edx
mov [dword ptr (cpu di+8).vendor],ecx mov dword [.cpu.vendor+8],ecx
mov [byte ptr (cpu di+12).vendor],0 mov byte [.cpu.vendor+12],0
cmp eax,1 cmp eax,1
jb @@nofonc1 jb .nofonc1
mov eax,1 mov eax,1
cpuid ;Fonction 1 de CPUID cpuid ;Fonction 1 de CPUID
mov ebx,eax ;infos de model mov ebx,eax ;infos de model
and ebx,1111b and ebx,1111b
mov [(cpu di).stepping],bl mov [.cpu.stepping],bl
shr eax,4 shr eax,4
mov ebx,eax mov ebx,eax
and ebx,1111b and ebx,1111b
mov [(cpu di).models],bl mov [.cpu.models],bl
shr eax,4 shr eax,4
mov ebx,eax mov ebx,eax
and ebx,1111b and ebx,1111b
mov [(cpu di).family],bl mov [.cpu.family],bl
shr eax,4 shr eax,4
mov ebx,eax mov ebx,eax
and ebx,11b and ebx,11b
mov [(cpu di).types],bl mov [.cpu.types],bl
shr eax,2 shr eax,2
mov ebx,eax mov ebx,eax
and ebx,1111b and ebx,1111b
mov [(cpu di).emodels],bl mov [.cpu.emodels],bl
shr eax,4 shr eax,4
mov [(cpu di).efamily],al mov [.cpu.efamily],al
mov ebx,edx mov ebx,edx
and ebx,1 ;infos de jeu d'instruction and ebx,1 ;infos de jeu d'instruction
setnz [(cpu di).fpu] setnz [.cpu.fpu]
mov ebx,edx mov ebx,edx
and ebx,100000000000000000000000b and ebx,100000000000000000000000b
setnz [(cpu di).mmx] setnz [.cpu.mmx]
mov ebx,edx mov ebx,edx
and ebx,10000000000000000000000000b and ebx,10000000000000000000000000b
setnz [(cpu di).sse] setnz [.cpu.sse]
mov ebx,edx mov ebx,edx
and ebx,100000000000000000000000000b and ebx,100000000000000000000000000b
setnz [(cpu di).sse2] setnz [.cpu.sse2]
mov ebx,ecx mov ebx,ecx
and ebx,1b and ebx,1b
setnz [(cpu di).sse3] setnz [.cpu.sse3]
mov ebx,edx mov ebx,edx
and ebx,10000000000000000000000000000b and ebx,10000000000000000000000000000b
setnz [(cpu di).htt] setnz [.cpu.htt]
@@nofonc1: .nofonc1:
mov eax,80000000h ;Fonction 80000000 de CPUID mov eax,80000000h ;Fonction 80000000 de CPUID
cpuid cpuid
cmp eax,80000001h cmp eax,80000001h
jb @@nofonc8 jb .nofonc8
mov eax,80000001h ;Fonction 80000000 de CPUID mov eax,80000001h ;Fonction 80000000 de CPUID
cpuid cpuid
mov ebx,edx mov ebx,edx
and ebx,10000000000000000000000b and ebx,10000000000000000000000b
setnz [(cpu di).mmx2] setnz [.cpu.mmx2]
mov ebx,edx mov ebx,edx
and ebx,1000000000000000000000000000000b and ebx,1000000000000000000000000000000b
setnz [(cpu di).now3d] setnz [.cpu.now3d]
mov ebx,edx mov ebx,edx
and ebx,10000000000000000000000000000000b and ebx,10000000000000000000000000000000b
setnz [(cpu di).now3d2] setnz [.cpu.now3d2]
mov ebx,edx mov ebx,edx
and ebx,1000000000b and ebx,1000000000b
setnz [(cpu di).apic] setnz [.cpu.apic]
@@nofonc8: .nofonc8:
mov si,offset @@marks mov si,.marks
push cs push cs
pop ds pop ds
@@search: .search:
mov di,[@pointer] mov di,[pointer]
mov cx,12 mov cx,12
cld cld
rep cmpsb rep cmpsb
jne @@notthegood jne .notthegood
cmp cx,0 cmp cx,0
jne @@notthegood jne .notthegood
mov cl,[si] mov cl,[si]
inc si inc si
mov di,[@pointer] mov di,[pointer]
cld cld
rep movsb rep movsb
mov al,0 mov al,0
stosb stosb
mov di,[@pointer] mov di,[pointer]
cmp [es:(cpu di).family],15 cmp [es:.cpu.family],15
jne @@notextended jne .notextended
mov al,[es:(cpu di).efamily] mov al,[es:.cpu.efamily]
mov ah,[es:(cpu di).emodels] mov ah,[es:.cpu.emodels]
mov di,[si+2] mov di,[si+2]
jmp @@searchmodel jmp .searchmodel
@@notextended: .notextended:
mov al,[es:(cpu di).family] mov al,[es:.cpu.family]
mov ah,[es:(cpu di).models] mov ah,[es:.cpu.models]
mov di,[si] mov di,[si]
@@searchmodel: .searchmodel:
cmp [di],ax cmp [di],ax
jne @@notgoodfamily jne .notgoodfamily
mov si,di mov si,di
inc si inc si
inc si inc si
lea di,[es:cpu.names] lea di,[es:.cpu.names]
add di,[@pointer] add di,[pointer]
@@copystr: .copystr:
mov al,[si] mov al,[si]
mov [es:di],al mov [es:di],al
inc si inc si
inc di inc di
cmp al,0 cmp al,0
jne @@copystr jne .copystr
jmp @@endofsearch jmp .endofsearch
@@notgoodfamily: .notgoodfamily:
inc di inc di
@@nextelement: .nextelement:
inc di inc di
cmp [byte ptr di-1],0 cmp byte [di-1],0
jne @@nextelement jne .nextelement
jmp @@searchmodel jmp .searchmodel
@@notthegood: .notthegood:
inc si inc si
cmp [word ptr si],0FFFFh cmp word [si],0FFFFh
jne @@notthegood jne .notthegood
inc si inc si
inc si inc si
cmp [word ptr si],0FFFFh cmp word [si],0FFFFh
je @@endofsearch je .endofsearch
jmp @@search jmp .search
@@endofsearch: .endofsearch:
ret retf
@@nocpuidatall: .nocpuidatall:
ret retf
;tableau avec vendeur taille + chainereelle + pointeur famille + pointeur famille etendue ;tableau avec vendeur taille + chainereelle + pointeur famille + pointeur famille etendue
@@marks db "GenuineIntel",5,"Intel" .marks db "GenuineIntel",5,"Intel"
dw @@intelfamily,@@intelfamilye dw .intelfamily,.intelfamilye
dw 0FFFFh dw 0FFFFh
db "AuthenticAMD",3,"Amd" db "AuthenticAMD",3,"Amd"
dw @@amdfamily,@@amdfamilye dw .amdfamily,.amdfamilye
dw 0FFFFh dw 0FFFFh
db "CyrixInstead",5,"Cyrix" db "CyrixInstead",5,"Cyrix"
dw @@cyrixfamily,@@cyrixfamilye dw .cyrixfamily,.cyrixfamilye
dw 0FFFFh dw 0FFFFh
dw 0FFFFh dw 0FFFFh
;tableau avec famille modele et chaine 0 ;tableau avec famille modele et chaine 0
@@intelfamily: .intelfamily:
db 4,0,"486 DX-25/33",0 db 4,0,"486 DX-25/33",0
db 4,1,"486 DX-50",0 db 4,1,"486 DX-50",0
db 4,2,"486 SX",0 db 4,2,"486 SX",0
@ -690,7 +676,7 @@ db 6,11,"Pentium III (0.13
db 7,0,"Itanium (IA-64)",0 db 7,0,"Itanium (IA-64)",0
db 0FFh,0FFh,"Inconnu",0 db 0FFh,0FFh,"Inconnu",0
@@intelfamilye: .intelfamilye:
db 0,0,"Pentium IV (0.18 µm)",0 db 0,0,"Pentium IV (0.18 µm)",0
db 0,1,"Pentium IV (0.18 µm)",0 db 0,1,"Pentium IV (0.18 µm)",0
db 0,2,"Pentium IV (0.13 µm)",0 db 0,2,"Pentium IV (0.13 µm)",0
@ -698,7 +684,7 @@ db 0,3,"Pentium IV (0.09
db 1,0,"Itanium 2 (IA-64)",0 db 1,0,"Itanium 2 (IA-64)",0
db 0FFh,0FFh,"Inconnu",0 db 0FFh,0FFh,"Inconnu",0
@@amdfamily: .amdfamily:
db 4,3,"486 DX/2",0 db 4,3,"486 DX/2",0
db 4,7,"486 DX/2-WB",0 db 4,7,"486 DX/2-WB",0
db 4,8,"486 DX/4",0 db 4,8,"486 DX/4",0
@ -725,12 +711,12 @@ db 6,8,"Athlon (Thoroughbred)",0
db 6,10,"Athlon (Barton)",0 db 6,10,"Athlon (Barton)",0
db 0FFh,0FFh,"Inconnu",0 db 0FFh,0FFh,"Inconnu",0
@@amdfamilye: .amdfamilye:
db 0,4,"Athlon 64",0 db 0,4,"Athlon 64",0
db 0,5,"Athlon 64 FX/Opteron",0 db 0,5,"Athlon 64 FX/Opteron",0
db 0FFh,0FFh,"Inconnu",0 db 0FFh,0FFh,"Inconnu",0
@@cyrixfamily: .cyrixfamily:
db 4,4,"MediaGX",0 db 4,4,"MediaGX",0
db 5,2,"6x86/6x86L",0 db 5,2,"6x86/6x86L",0
db 5,4,"MediaGX MMX Enhanced",0 db 5,4,"MediaGX MMX Enhanced",0
@ -742,10 +728,10 @@ db 6,8,"WinChip C5N",0
db 6,9,"WinChip C5XL/WinChip C5P",0 db 6,9,"WinChip C5XL/WinChip C5P",0
db 0FFh,0FFh,"Inconnu",0 db 0FFh,0FFh,"Inconnu",0
@@cyrixfamilye: .cyrixfamilye:
db 0FFh,0FFh,"Inconnu",0 db 0FFh,0FFh,"Inconnu",0
endp cpuinfo endp
;Test si CPUID est supporté oui=not Equal ;Test si CPUID est supporté oui=not Equal
nocpuid: nocpuid:

File diff suppressed because it is too large Load Diff

View File

@ -384,7 +384,3 @@ endp

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff