コード例 #1
0
ファイル: ppc.c プロジェクト: MarginC/kame
int
ppc_attach(device_t dev)
{
	struct ppc_data *ppc = DEVTOSOFTC(dev);

	device_t ppbus;
	device_t parent = device_get_parent(dev);

	device_printf(dev, "%s chipset (%s) in %s mode%s\n",
		      ppc_models[ppc->ppc_model], ppc_avms[ppc->ppc_avm],
		      ppc_modes[ppc->ppc_mode], (PPB_IS_EPP(ppc->ppc_mode)) ?
		      ppc_epp_protocol[ppc->ppc_epp] : "");
	
	if (ppc->ppc_fifo)
		device_printf(dev, "FIFO with %d/%d/%d bytes threshold\n",
			      ppc->ppc_fifo, ppc->ppc_wthr, ppc->ppc_rthr);

	if ((ppc->ppc_avm & PPB_ECP) && (ppc->ppc_dmachan > 0)) {
		/* acquire the DMA channel forever */	/* XXX */
		isa_dma_acquire(ppc->ppc_dmachan);
		isa_dmainit(ppc->ppc_dmachan, 1024); /* nlpt.BUFSIZE */
	}

	/* add ppbus as a child of this isa to parallel bridge */
	ppbus = device_add_child(dev, "ppbus", -1);

	/*
	 * Probe the ppbus and attach devices found.
	 */
	device_probe_and_attach(ppbus);

	/* register the ppc interrupt handler as default */
	if (ppc->res_irq) {
		/* default to the tty mask for registration */	/* XXX */
		if (BUS_SETUP_INTR(parent, dev, ppc->res_irq, INTR_TYPE_TTY,
					    ppcintr, dev, &ppc->intr_cookie) == 0) {

			/* remember the ppcintr is registered */
			ppc->ppc_registered = 1;
		}
	}

	return (0);
}
コード例 #2
0
int
ppc_attach(device_t dev)
{
	struct ppc_data *ppc = DEVTOSOFTC(dev);
	int error;

	mtx_init(&ppc->ppc_lock, device_get_nameunit(dev), "ppc", MTX_DEF);

	device_printf(dev, "%s chipset (%s) in %s mode%s\n",
		      ppc_models[ppc->ppc_model], ppc_avms[ppc->ppc_avm],
		      ppc_modes[ppc->ppc_mode], (PPB_IS_EPP(ppc->ppc_mode)) ?
		      ppc_epp_protocol[ppc->ppc_epp] : "");

	if (ppc->ppc_fifo)
		device_printf(dev, "FIFO with %d/%d/%d bytes threshold\n",
			      ppc->ppc_fifo, ppc->ppc_wthr, ppc->ppc_rthr);

	if (ppc->res_irq) {
		/* default to the tty mask for registration */	/* XXX */
		error = bus_setup_intr(dev, ppc->res_irq, INTR_TYPE_TTY |
		    INTR_MPSAFE, NULL, ppcintr, ppc, &ppc->intr_cookie);
		if (error) {
			device_printf(dev,
			    "failed to register interrupt handler: %d\n",
			    error);
			mtx_destroy(&ppc->ppc_lock);
			return (error);
		}
	}

	/* add ppbus as a child of this isa to parallel bridge */
	ppc->ppbus = device_add_child(dev, "ppbus", -1);

	/*
	 * Probe the ppbus and attach devices found.
	 */
	device_probe_and_attach(ppc->ppbus);

	return (0);
}