static int iop_pci_attach(device_t dev) { struct iop_softc *sc = device_get_softc(dev); int rid; bzero(sc, sizeof(struct iop_softc)); /* get resources */ rid = 0x10; sc->r_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); if (!sc->r_mem) return 0; rid = 0x00; sc->r_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_SHAREABLE | RF_ACTIVE); /* now setup the infrastructure to talk to the device */ pci_enable_busmaster(dev); sc->ibase = rman_get_virtual(sc->r_mem); sc->reg = (struct i2o_registers *)sc->ibase; sc->dev = dev; mtx_init(&sc->mtx, "pst lock", NULL, MTX_DEF); if (!iop_init(sc)) return 0; return bus_generic_attach(dev); }
sint32 EMU_CALL psx_init(void) { sint32 r; psx_endian_check(); psx_size_check(); // BIOS must be loaded first if ( !bios_get_image_native() || !bios_get_imagesize() ) return 0; // // BIOS must be a power of 2, or all hell breaks loose // { uint32 s = bios_get_imagesize(); if(s & (s - 1)) psx_hang("imagesize error"); } // // Environment inits // ps1preboot = getenvhex("ps1preboot"); ps2preboot = getenvhex("ps2preboot"); r = iop_init(); if(r) return r; r = ioptimer_init(); if(r) return r; r = r3000_init(); if(r) return r; r = spu_init(); if(r) return r; r = spucore_init(); if(r) return r; r = vfs_init(); if(r) return r; library_was_initialized = 1; return 0; }
static void iop_pci_attach(device_t parent, device_t self, void *aux) { struct pci_attach_args *pa; struct iop_softc *sc; pci_chipset_tag_t pc; pci_intr_handle_t ih; const char *intrstr; pcireg_t reg; int i; char intrbuf[PCI_INTRSTR_LEN]; sc = device_private(self); sc->sc_dev = self; pa = aux; pc = pa->pa_pc; printf(": "); /* * The kernel always uses the first memory mapping to communicate * with the IOP. */ for (i = PCI_MAPREG_START; i < PCI_MAPREG_END; i += 4) { reg = pci_conf_read(pc, pa->pa_tag, i); if (PCI_MAPREG_TYPE(reg) == PCI_MAPREG_TYPE_MEM) { sc->sc_memaddr = PCI_MAPREG_MEM_ADDR(reg); break; } } if (i == PCI_MAPREG_END) { printf("can't find mapping\n"); return; } /* Map the register window. */ if (pci_mapreg_map(pa, i, PCI_MAPREG_TYPE_MEM, 0, &sc->sc_iot, &sc->sc_ioh, NULL, NULL)) { aprint_error_dev(self, "can't map register window\n"); return; } /* Map the 2nd register window. */ if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_DPT && PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_DPT_RAID_2005S) { i += 4; /* next BAR */ if (i == PCI_MAPREG_END) { printf("can't find mapping\n"); return; } #if 0 /* Should we check it? (see FreeBSD's asr driver) */ reg = pci_conf_read(pc, pa->pa_tag, PCI_SUBSYS_ID_REG); printf("subid %x, %x\n", PCI_VENDOR(reg), PCI_PRODUCT(reg)); #endif if (pci_mapreg_map(pa, i, PCI_MAPREG_TYPE_MEM, 0, &sc->sc_msg_iot, &sc->sc_msg_ioh, NULL, NULL)) { aprint_error_dev(self, "can't map 2nd register window\n"); return; } } else { /* iop devices other than 2005S */ sc->sc_msg_iot = sc->sc_iot; sc->sc_msg_ioh = sc->sc_ioh; } sc->sc_pcibus = pa->pa_bus; sc->sc_pcidev = pa->pa_device; sc->sc_dmat = pa->pa_dmat; sc->sc_bus_memt = pa->pa_memt; sc->sc_bus_iot = pa->pa_iot; /* Enable the device. */ reg = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG); pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, reg | PCI_COMMAND_MASTER_ENABLE); /* Map and establish the interrupt.. */ if (pci_intr_map(pa, &ih)) { printf("can't map interrupt\n"); return; } intrstr = pci_intr_string(pc, ih, intrbuf, sizeof(intrbuf)); sc->sc_ih = pci_intr_establish(pc, ih, IPL_BIO, iop_intr, sc); if (sc->sc_ih == NULL) { printf("can't establish interrupt"); if (intrstr != NULL) printf(" at %s", intrstr); printf("\n"); return; } /* Attach to the bus-independent code. */ iop_init(sc, intrstr); }