Exemplo n.º 1
0
static VOID FreeCard(struct BusContext *context, struct DevBase *base)
{

   if(context != NULL)
   {
#if !(defined(__MORPHOS__) || defined(__amigaos4__))
      if(base->prometheus_base != NULL)
         FreePrometheusCard(context, base);
#endif
#ifdef __mc68000
      if(base->powerpci_base != NULL)
         FreePowerPCICard(context, base);
#endif
#ifdef __amigaos4__
      if(base->expansion_base != NULL)
         FreeExpansionCard(context, base);
#endif
#ifdef __MORPHOS__
      if(base->openpci_base != NULL)
         FreeOpenPCICard(context, base);
#endif
   }

   return;
}
Exemplo n.º 2
0
struct BusContext *AllocPowerPCICard(ULONG index, struct DevBase *base)
{
   BOOL success = TRUE;
   struct BusContext *context;
   ULONG card = 0;
   UWORD i = 0, vendor_id, product_id;

   /* Find a compatible card */

   context = AllocMem(sizeof(struct BusContext), MEMF_PUBLIC | MEMF_CLEAR);
   if(context == NULL)
      success = FALSE;

   if(success)
   {
      while(i <= index)
      {
         card = pci_find_device(0xffff, 0xffff, card);
         product_id = pci_read_conf_word(card, PCI_DEVICE_ID);
         vendor_id = pci_read_conf_word(card, PCI_VENDOR_ID);
         if(IsCardCompatible(vendor_id, product_id, base))
            i++;
      }

      context->card = (APTR)card;
      if(card == NULL)
         success = FALSE;
   }

   /* Get base address */

   if(success)
   {
      context->io_base = (UPINT)pci_get_base_start(card, BAR_NO);
      if(context->io_base == NULL)
         success = FALSE;
      if((context->io_base & 0xffff0000) == 0xee0000)
         context->io_base += 0x10000;
   }

   if(!success)
   {
      FreePowerPCICard(context, base);
      context = NULL;
   }

   return context;
}