flat assembler
Message board for the users of flat assembler.

Index > DOS > detecting NVIDIA video card

Author
Thread Post new topic Reply to topic
CandyMan



Joined: 04 Sep 2009
Posts: 414
Location: film "CandyMan" directed through Bernard Rose OR Candy Shop
CandyMan 29 Aug 2020, 17:29
Does anyone know how to detect NVIDIA video card in dos?
Assembly code is welcome.

_________________
smaller is better
Post 29 Aug 2020, 17:29
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4061
Location: vpcmpistri
bitRAKE 29 Aug 2020, 21:33

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 29 Aug 2020, 21:33
View user's profile Send private message Visit poster's website Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 794
Location: Adelaide
sinsi 29 Aug 2020, 21:34
Assuming it's a PCI card, scan the PCI configuration space for Nvidia's vendor ID (10DE).
From memory, some code (untested!)
Code:
;bus = 0 to 255, device = 0 to 31, function = 0 to 7, index = 0 to 255
    mov eax,80000000h or (bus shl 16) or (device shl 11) or (function shl 8) or (index) ;we want to read dword at index 0
    mov dx,0cf8h
    out dx,eax
    mov dx 0cfch
    in eax,dx
;EAX low 16 bits = vendor ID, high 16 = device ID
;If vendor is FFFF there is no device there.
    
Post 29 Aug 2020, 21:34
View user's profile Send private message Reply with quote
CandyMan



Joined: 04 Sep 2009
Posts: 414
Location: film "CandyMan" directed through Bernard Rose OR Candy Shop
CandyMan 31 Aug 2020, 09:08
Thanks, that's what I meant.
Post 31 Aug 2020, 09:08
View user's profile Send private message Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 794
Location: Adelaide
sinsi 03 Sep 2020, 05:10
Just to expand a little, if you find the vendor you would then read the dword at index=8.
This has the Class/Subclass/Prog IF/Revision information, a video card would be Class=3.

If you want to check for multiple video adapters you would keep scanning (e.g. SLI)
Post 03 Sep 2020, 05:10
View user's profile Send private message Reply with quote
Laaca



Joined: 12 Aug 2007
Posts: 3
Laaca 02 Nov 2020, 20:50
PCI scan is not necessary. Besides that - in situation when you have a integrated card + dedicated card is not clear which one is used.
I preffer to look into VideoBIOS segment - segment C000h.

Part of my Freepascal code:
Code:
Function MemB(segm,offs:word):byte;assembler;
asm
movzx ebx,segm
shl ebx,4
movzx eax,offs
add ebx,eax
mov al,fs:[ebx]
end;

Function RMString(segm,offs:word;len:byte):string;
var a:longint;
    s:string;
begin
s:='';
for a:=0 to len-1 do s:=s+char(MemB(segm,offs+a));
RMstring:=s;
end;

Procedure Get_SVGA(var vendor,device:word);
var pci:word;
    ven,dev:word;
begin
vendor:=0;
device:=0;
pci:=word(MemB($C000,$18))+word(MemB($C000,$19))*256;
if RMstring($C000,pci,4)='PCIR' then
   begin
   vendor:=word(MemB($C000,pci+4))+word(MemB($C000,pci+5))*256;
   device:=word(MemB($C000,pci+6))+word(MemB($C000,pci+7))*256;
   end;
end;
    
Post 02 Nov 2020, 20:50
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.