Dave Dubeau <ddubeau@neptec.com> wrote:
pete@qnx.com > wrote in message <8t4p4a$ssv$> 2@nntp.qnx.com> >…
Here’s an overview…
Look at the CA_PCI… functions…
You need to zero out the two bottom bits in the command register for the
device you want to shut off.
The command register is word sized, and at an offset 4 bytes into the
devices configuration space.
So use the _CA_PCI_Write_Config_Word() routine to stuff a zero into
it… it will be lifeless afterwards.
If this isn’t enough, let me know and I’ll expand on it.
Well, if ignorance is bliss, I’m a happy guy …
I’m pretty lost on how to find out where the device’s configuration space
is. Is there some sort of call I can make to find out info on the video
card or is it a standard type of address?
Thanks for all your help again.
OK… here’s a bunch of code from one of the trappers. You should be
able to figure out how to modify this to find the card you want to
disable.
// Completely disable I/O and memory accesses to given card
void OffPCI(unsigned busnum, unsigned devfuncnum)
{
unsigned ati_short;
_CA_PCI_Read_Config_Byte(busnum, devfuncnum, 4, 2, (char *)&ati_short);
ati_short &= ~3;
_CA_PCI_Write_Config_Byte(busnum, devfuncnum, 4, 2, (char *)&ati_short);
}
// Enable I/O and memory access
void OnPCI(unsigned busnum, unsigned devfuncnum)
{
unsigned ati_short;
_CA_PCI_Read_Config_Byte(busnum, devfuncnum, 4, 2, (char *)&ati_short);
ati_short |= 3;
_CA_PCI_Write_Config_Byte(busnum, devfuncnum, 4, 2, (char *)&ati_short);
}
// Turn off I/O ports only
void OffPCIIO(unsigned busnum, unsigned devfuncnum)
{
unsigned ati_short;
_CA_PCI_Read_Config_Byte(busnum, devfuncnum, 4, 2, (char *)&ati_short);
ati_short &= ~1;
_CA_PCI_Write_Config_Byte(busnum, devfuncnum, 4, 2, (char *)&ati_short);
}
// Turn on I/O port access
void OnPCIIO(unsigned busnum, unsigned devfuncnum)
{
unsigned ati_short;
_CA_PCI_Read_Config_Byte(busnum, devfuncnum, 4, 2, (char *)&ati_short);
ati_short |= 1;
_CA_PCI_Write_Config_Byte(busnum, devfuncnum, 4, 2, (char *)&ati_short);
}
int checkdevice(unsigned busnum, unsigned devfuncnum, unsigned long vendor, unsigned long product)
{
struct _pci_config_regs creg;
unsigned char ati_long;
unsigned short ati_short;
_CA_PCI_Read_Config_DWord(busnum, devfuncnum, 0, 16, (char *)&creg);
if (vendor == creg.Vendor_ID) // It’s the correct vendor
{
if (creg.Class_Code[2]==0x03) // It is a VGA compatible device
{
if (product == creg.Device_ID) // It’s the correct device ID
{
return(1);
}
}
}
return(0);
}
int check_pci(unsigned long vendor, unsigned long product, int n)
{
unsigned lastbus, busnum, device, function, num_fcns;
unsigned header_type, device_id, version, hardware;
int cc;
struct _osinfo info;
if(qnx_osinfo(0, &info) == -1)
{
return(0);
}
if(!(info.sflags & _PSF_PCI_BIOS)) // we have a PCI BIOS
{
return(0);
}
if(_CA_PCI_BIOS_Present(&lastbus, &version, &hardware) != PCI_SUCCESS)
{
printf(“No PCI BIOS\n”);
return(0);
}
lastbus &= 0x3F;
cc = 0;
which_card = n;
// Walk all the buses looking for the n’th occurence of
// a specific vendor/product
for(busnum = 0; busnum <= lastbus; busnum++)
{
for(device = 0; device < 32; device++)
{
_CA_PCI_Read_Config_Word(busnum, device << 3, offsetof(struct _pci_config_regs, Device_ID),
1, (char *)&device_id);
if(device_id == 0xffff)
continue;
_CA_PCI_Read_Config_Byte(busnum, device << 3, offsetof(struct _pci_config_regs, Header_Type),
1, (char *)&header_type);
if(header_type & 0x80) {
num_fcns = 8;
} else {
num_fcns = 1;
}
for(function = 0; function < num_fcns; function++)
{
if (checkdevice(busnum, (device << 3) | function, vendor, product))
{
cc++;
if (cc == n) return(1);
}
}
}
}
return(0);
}