コード例 #1
0
ファイル: dev_bcm1250.c プロジェクト: 1703011/asuswrt-merlin
static void
bcm1250_probe(cfe_driver_t *drv,
	      unsigned long probe_a, unsigned long probe_b, 
	      void *probe_ptr)
{
    int  index;

    index = 0;
    for (;;) {
	pcitag_t tag;

	if (pci_find_device(0x166d, 0x0001, index, &tag) != 0)
	   break;

	if (tag != 0x00000000) {   /* don't configure ourselves */
	    bcm1250_t *softc;
	    char descr[80];
	    phys_addr_t pa;

	    softc = (bcm1250_t *) KMALLOC(sizeof(bcm1250_t), 0);
	    if (softc == NULL) {
	        xprintf("BCM1250: No memory to complete probe\n");
		break;
	    }

	    softc->tag = tag;

	    pci_map_mem(tag, PCI_MAPREG(0), PCI_MATCH_BYTES, &pa);
	    xsprintf(descr, "%s at 0x%X", drv->drv_description, (uint32_t)pa);
	    softc->mem_base = pa;

	    /* Map the CPU0 mailbox registers of the device 1250.
               Note that our BAR2 space maps to its "alias" mailbox
               registers.  Set bit 3 for mbox_set; clear bit 3 for
               reading.  Address bits 15-4 are don't cares. */
	    pci_map_mem(tag, PCI_MAPREG(2), PCI_MATCH_BYTES, &pa);
	    softc->mailbox = pa;

	    softc->downloaded = 0;

	    cfe_attach(drv, softc, NULL, descr);
	}
	index++;
    }
}
コード例 #2
0
ファイル: ida.c プロジェクト: UnitedMarsupials/kame
static void
ida_pci_attach(pcici_t config_id, int unit)
{
  ida_pci_reg_t *reg;
  struct ida_ctl *ctlp;
  u_long id;
  vm_offset_t paddr, vaddr;

  id = pci_conf_read(config_id, PCI_ID_REG);
  switch (id) {
  case PCI_DEVICE_ID_COMPAQ_SMART2P:
    break;
  default:
    break;
  }

  if (!pci_map_mem(config_id, 0x14, &vaddr, &paddr)) {
    printf("ida: map failed.\n");
    return;
  }

  /* allocate and initialise a storage area for this controller */
  if (idadata[unit]) {
    printf("ida%d: controller structure already allocated\n", unit);
    return;
  }
  if ((ctlp = malloc(sizeof(struct ida_ctl), M_TEMP, M_NOWAIT)) == NULL) {
    printf("ida%d: unable to allocate controller structure\n", unit);
    return;
  }

  idadata[unit] = ctlp;
  bzero(ctlp, sizeof(struct ida_ctl));
  ctlp->ident = id;
  ctlp->iobase = vaddr;

  /* Install the interrupt handler. */
  if (!pci_map_int (config_id, idaintr, (void *)unit, &bio_imask)) {
    printf ("ida%d: failed to assign an interrupt handler\n", unit);
    free((caddr_t)ctlp, M_DEVBUF);
    idadata[unit] = 0;
    return;
  }

  if (!(ida_get_ctl_info(unit) && ida_attach_drives(unit))) {
    return;
  }

  reg = (ida_pci_reg_t *) vaddr;
  reg->interrupt = IDA_PCI_ENABLE_INTS;
  ida_cuckoo_wdc();
  return;
}