PCI

From: Nymia <Nymia_at_nospam.org>
Date: Fri Feb 16 2001 - 23:34:27 PST

Just wondering what is the status of PCI on VSTa? Any news would be greatly
appreciated.

If it is not yet written, then, will it be written as a FS or is it going to
be something else?

Also, made some research about PCI and found that it can be reached directly
or from the BIOS. One good source code I found was on Linux, located on
pci-pc.c and one on AtheOS on pci.c.

On Linux, the code fragment that directly checks for the PCI is posted
below:

static struct pci_ops * __init pci_check_direct(void)
{
 unsigned int tmp;
 unsigned long flags;

 __save_flags(flags); __cli();

 /*
  * Check if configuration type 1 works.
  */
 if (pci_probe & PCI_PROBE_CONF1) {
  outb (0x01, 0xCFB);
  tmp = inl (0xCF8);
  outl (0x80000000, 0xCF8);
  if (inl (0xCF8) == 0x80000000 &&
      pci_sanity_check(&pci_direct_conf1)) {
   outl (tmp, 0xCF8);
   __restore_flags(flags);
   printk("PCI: Using configuration type 1\n");
   request_region(0xCF8, 8, "PCI conf1");
   return &pci_direct_conf1;
  }
  outl (tmp, 0xCF8);
 }

 /*
  * Check if configuration type 2 works.
  */
 if (pci_probe & PCI_PROBE_CONF2) {
  outb (0x00, 0xCFB);
  outb (0x00, 0xCF8);
  outb (0x00, 0xCFA);
  if (inb (0xCF8) == 0x00 && inb (0xCFA) == 0x00 &&
      pci_sanity_check(&pci_direct_conf2)) {
   __restore_flags(flags);
   printk("PCI: Using configuration type 2\n");
   request_region(0xCF8, 4, "PCI conf2");
   return &pci_direct_conf2;
  }
 }

 __restore_flags(flags);
 return NULL;
}

Here's one that reads the config using the BIOS which is taken from AtheOS:

uint32 read_pci_config( int nBusNum, int nDevNum, int nFncNum, int nOffset,
int nSize )
{
  struct RMREGS rm;

  if ( 2 == nSize || 4 == nSize || 1 == nSize )
  {
    int anCmd[] = { 0xb108, 0xb109, 0x000, 0xb10a };
    uint32 anMasks[] = { 0x000000ff, 0x0000ffff, 0x00000000, 0xffffffff };
    memset( &rm, 0, sizeof( rm ) );

    rm.EAX = anCmd[nSize - 1];

    rm.EBX = (nBusNum << 8) | (((nDevNum << 3) | nFncNum));
    rm.EDI = nOffset;

    realint( 0x1a, &rm );

    if ( 0 == ((rm.EAX >> 8) & 0xff) ) {
      return( rm.ECX & anMasks[ nSize- 1 ] );
    } else {
      return( anMasks[ nSize- 1 ] );
    }
  }
  else
  {
    printk( "ERROR : Invalid size %d passed to read_pci_config()\n",
nSize );
    return( 0 );
  }
}
Received on Fri Feb 16 23:10:21 2001

This archive was generated by hypermail 2.1.8 : Thu Sep 22 2005 - 15:12:57 PDT