Пример #1
0
static void
mpc_attach(pcici_t tag, int unit)
{
  dev_t cdev = makedev(CDEV_MAJOR, unit);

  if (!unit)
    cdevsw_add(&cdev, &mpcdevsw, NULL);

  mpc_dynamic_handler = NULL;
  pci_map_int(tag, mpc_interrupt_handler, NULL, &net_imask);
}
Пример #2
0
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;
}