PERFORCE change 95599 for review
Marcel Moolenaar
marcel at FreeBSD.org
Wed Apr 19 17:33:09 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=95599
Change 95599 by marcel at marcel_nfs on 2006/04/19 17:32:51
Revamp ppc(4):
o Move the ppc files out of files.<arch> and into the
generic file. There's too much duplication.
o Move the ppc options from options.<arch> to options.
Too much duplication.
o Add a PCI bus attachment and probe single port parallel
cards. This requires the support for non-xero I/O port
RIDs.
o Add seperate ISA and ACPI attachments. When ISA is
configured in the kernel, the ACPI attachment will use
ISA dma.
o Remove any and all ISA specifics from ppc.c and move
it to the ISA bus attachment.
o Change ppc_write() to a dummy function that always
returns EINVAL. This is used by non-ISA attachments.
o White-space fixups.
This breaks PC98.
Affected files ...
.. //depot/projects/uart/conf/files#60 edit
.. //depot/projects/uart/conf/files.alpha#15 edit
.. //depot/projects/uart/conf/files.amd64#18 edit
.. //depot/projects/uart/conf/files.i386#23 edit
.. //depot/projects/uart/conf/files.ia64#16 edit
.. //depot/projects/uart/conf/files.pc98#20 edit
.. //depot/projects/uart/conf/options#29 edit
.. //depot/projects/uart/conf/options.alpha#5 edit
.. //depot/projects/uart/conf/options.amd64#7 edit
.. //depot/projects/uart/conf/options.i386#12 edit
.. //depot/projects/uart/conf/options.ia64#6 edit
.. //depot/projects/uart/conf/options.pc98#11 edit
.. //depot/projects/uart/dev/ppc/ppc.c#9 edit
.. //depot/projects/uart/dev/ppc/ppc_acpi.c#1 add
.. //depot/projects/uart/dev/ppc/ppc_isa.c#1 add
.. //depot/projects/uart/dev/ppc/ppc_pci.c#1 add
.. //depot/projects/uart/dev/ppc/ppc_puc.c#4 edit
.. //depot/projects/uart/dev/ppc/ppcreg.h#2 edit
.. //depot/projects/uart/dev/ppc/ppcvar.h#4 edit
Differences ...
==== //depot/projects/uart/conf/files#60 (text+ko) ====
@@ -804,6 +804,11 @@
dev/ppbus/pps.c optional pps
dev/ppbus/vpo.c optional vpo
dev/ppbus/vpoio.c optional vpo
+dev/ppc/ppc.c optional ppc
+dev/ppc/ppc_acpi.c optional ppc acpi
+dev/ppc/ppc_isa.c optional ppc isa
+dev/ppc/ppc_pci.c optional ppc pci
+dev/ppc/ppc_puc.c optional ppc puc
dev/pst/pst-iop.c optional pst
dev/pst/pst-pci.c optional pst pci
dev/pst/pst-raid.c optional pst
==== //depot/projects/uart/conf/files.alpha#15 (text+ko) ====
@@ -179,8 +179,6 @@
dev/fdc/fdc_isa.c optional fdc isa
dev/hwpmc/hwpmc_alpha.c optional hwpmc
dev/kbd/kbd.c optional atkbd | sc | ukbd
-dev/ppc/ppc.c optional ppc
-dev/ppc/ppc_puc.c optional ppc puc
dev/sio/sio.c optional sio
dev/sio/sio_isa.c optional sio isa
dev/syscons/schistory.c optional sc
==== //depot/projects/uart/conf/files.amd64#18 (text+ko) ====
@@ -173,8 +173,6 @@
dev/kbd/kbd.c optional atkbd | sc | ukbd
dev/mem/memutil.c optional mem
dev/nve/if_nve.c optional nve pci
-dev/ppc/ppc.c optional ppc
-dev/ppc/ppc_puc.c optional ppc puc
dev/sio/sio.c optional sio
dev/sio/sio_isa.c optional sio isa
dev/speaker/spkr.c optional speaker
==== //depot/projects/uart/conf/files.i386#23 (text+ko) ====
@@ -193,8 +193,6 @@
dev/mse/mse_isa.c optional mse isa
dev/nve/if_nve.c optional nve pci
dev/pcf/pcf_isa.c optional pcf
-dev/ppc/ppc.c optional ppc
-dev/ppc/ppc_puc.c optional ppc puc pci
dev/random/nehemiah.c optional random
dev/sbni/if_sbni.c optional sbni
dev/sbni/if_sbni_isa.c optional sbni isa
==== //depot/projects/uart/conf/files.ia64#16 (text+ko) ====
@@ -58,8 +58,6 @@
dev/fb/vga.c optional vga
dev/hwpmc/hwpmc_ia64.c optional hwpmc
dev/kbd/kbd.c optional atkbd | sc | ukbd
-dev/ppc/ppc.c optional ppc isa
-dev/ppc/ppc_puc.c optional ppc puc
dev/syscons/schistory.c optional sc
dev/syscons/scmouse.c optional sc
dev/syscons/scterm-dumb.c optional sc
==== //depot/projects/uart/conf/files.pc98#20 (text+ko) ====
@@ -110,7 +110,6 @@
dev/mem/memutil.c optional mem
dev/mse/mse.c optional mse
dev/mse/mse_cbus.c optional mse isa
-dev/ppc/ppc_puc.c optional ppc puc pci
dev/sbni/if_sbni.c optional sbni
dev/sbni/if_sbni_pci.c optional sbni pci
dev/snc/dp83932.c optional snc
==== //depot/projects/uart/conf/options#29 (text+ko) ====
@@ -121,6 +121,8 @@
MUTEX_WAKE_ALL
NSWBUF_MIN opt_swap.h
PANIC_REBOOT_WAIT_TIME opt_panic.h
+PPC_DEBUG opt_ppc.h
+PPC_PROBE_CHIPSET opt_ppc.h
PPS_SYNC opt_ntp.h
PREEMPTION opt_sched.h
QUOTA
==== //depot/projects/uart/conf/options.alpha#5 (text+ko) ====
@@ -18,9 +18,6 @@
MAXMEM
-PPC_PROBE_CHIPSET opt_ppc.h
-PPC_DEBUG opt_ppc.h
-
VGA_ALT_SEQACCESS opt_vga.h
VGA_DEBUG opt_vga.h
VGA_NO_FONT_LOADING opt_vga.h
==== //depot/projects/uart/conf/options.amd64#7 (text+ko) ====
@@ -49,8 +49,6 @@
# EOF
# -------------------------------
HAMMER opt_cpu.h
-PPC_PROBE_CHIPSET opt_ppc.h
-PPC_DEBUG opt_ppc.h
PSM_HOOKRESUME opt_psm.h
PSM_RESETAFTERSUSPEND opt_psm.h
PSM_DEBUG opt_psm.h
==== //depot/projects/uart/conf/options.i386#12 (text+ko) ====
@@ -15,8 +15,6 @@
PERFMON
PMAP_SHPGPERPROC opt_pmap.h
POWERFAIL_NMI opt_trap.h
-PPC_DEBUG opt_ppc.h
-PPC_PROBE_CHIPSET opt_ppc.h
# Options for emulators. These should only be used at config time, so
# they are handled like options for static filesystems
==== //depot/projects/uart/conf/options.ia64#6 (text+ko) ====
@@ -11,9 +11,6 @@
COMPAT_IA32 opt_compat.h
-PPC_PROBE_CHIPSET opt_ppc.h
-PPC_DEBUG opt_ppc.h
-
VGA_ALT_SEQACCESS opt_vga.h
VGA_DEBUG opt_vga.h
VGA_NO_FONT_LOADING opt_vga.h
==== //depot/projects/uart/conf/options.pc98#11 (text+ko) ====
@@ -14,8 +14,6 @@
PERFMON
PMAP_SHPGPERPROC opt_pmap.h
POWERFAIL_NMI opt_trap.h
-PPC_DEBUG opt_ppc.h
-PPC_PROBE_CHIPSET opt_ppc.h
# Options for emulators. These should only be used at config time, so
# they are handled like options for static filesystems
==== //depot/projects/uart/dev/ppc/ppc.c#9 (text+ko) ====
@@ -36,18 +36,17 @@
#include <sys/module.h>
#include <sys/bus.h>
#include <sys/malloc.h>
-#include <sys/kdb.h>
-#include <vm/vm.h>
-#include <vm/pmap.h>
#include <machine/clock.h>
#include <machine/bus.h>
#include <machine/resource.h>
-#include <machine/vmparam.h>
#include <sys/rman.h>
-#include <isa/isareg.h>
-#include <isa/isavar.h>
+#ifdef __i386__
+#include <vm/vm.h>
+#include <vm/pmap.h>
+#include <machine/vmparam.h>
+#endif
#include <dev/ppbus/ppbconf.h>
#include <dev/ppbus/ppb_msq.h>
@@ -57,9 +56,10 @@
#include "ppbus_if.h"
-static int ppc_isa_probe(device_t dev);
+static void ppcintr(void *arg);
-static void ppcintr(void *arg);
+#define IO_LPTSIZE_EXTENDED 8 /* "Extended" LPT controllers */
+#define IO_LPTSIZE_NORMAL 4 /* "Normal" LPT controllers */
#define LOG_PPC(function, ppc, string) \
if (bootverbose) printf("%s: %s\n", function, string)
@@ -68,37 +68,8 @@
#define DEVTOSOFTC(dev) ((struct ppc_data *)device_get_softc(dev))
devclass_t ppc_devclass;
-
-static device_method_t ppc_methods[] = {
- /* device interface */
- DEVMETHOD(device_probe, ppc_isa_probe),
- DEVMETHOD(device_attach, ppc_attach),
- DEVMETHOD(device_detach, ppc_detach),
-
- /* bus interface */
- DEVMETHOD(bus_read_ivar, ppc_read_ivar),
- DEVMETHOD(bus_setup_intr, ppc_setup_intr),
- DEVMETHOD(bus_teardown_intr, ppc_teardown_intr),
- DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
+const char ppc_driver_name[] = "ppc";
- /* ppbus interface */
- DEVMETHOD(ppbus_io, ppc_io),
- DEVMETHOD(ppbus_exec_microseq, ppc_exec_microseq),
- DEVMETHOD(ppbus_reset_epp, ppc_reset_epp),
- DEVMETHOD(ppbus_setmode, ppc_setmode),
- DEVMETHOD(ppbus_ecp_sync, ppc_ecp_sync),
- DEVMETHOD(ppbus_read, ppc_read),
- DEVMETHOD(ppbus_write, ppc_write),
-
- { 0, 0 }
- };
-
-static driver_t ppc_driver = {
- "ppc",
- ppc_methods,
- sizeof(struct ppc_data),
-};
-
static char *ppc_models[] = {
"SMC-like", "SMC FDC37C665GT", "SMC FDC37C666GT", "PC87332", "PC87306",
"82091AA", "Generic", "W83877F", "W83877AF", "Winbond", "PC87334",
@@ -1593,12 +1564,7 @@
#ifdef PPC_DEBUG
printf("d");
#endif
- isa_dmadone(
- ppc->ppc_dmaflags,
- ppc->ppc_dmaddr,
- ppc->ppc_dmacnt,
- ppc->ppc_dmachan);
-
+ ppc->ppc_dmadone(ppc);
ppc->ppc_dmastat = PPC_DMA_COMPLETE;
/* wakeup the waiting process */
@@ -1620,163 +1586,10 @@
return (EINVAL);
}
-/*
- * Call this function if you want to send data in any advanced mode
- * of your parallel port: FIFO, DMA
- *
- * If what you want is not possible (no ECP, no DMA...),
- * EINVAL is returned
- */
int
ppc_write(device_t dev, char *buf, int len, int how)
{
- struct ppc_data *ppc = DEVTOSOFTC(dev);
- char ecr, ecr_sav, ctr, ctr_sav;
- int s, error = 0;
- int spin;
-
-#ifdef PPC_DEBUG
- printf("w");
-#endif
-
- ecr_sav = r_ecr(ppc);
- ctr_sav = r_ctr(ppc);
-
- /*
- * Send buffer with DMA, FIFO and interrupts
- */
- if ((ppc->ppc_avm & PPB_ECP) && (ppc->ppc_registered)) {
-
- if (ppc->ppc_dmachan > 0) {
-
- /* byte mode, no intr, no DMA, dir=0, flush fifo
- */
- ecr = PPC_ECR_STD | PPC_DISABLE_INTR;
- w_ecr(ppc, ecr);
-
- /* disable nAck interrupts */
- ctr = r_ctr(ppc);
- ctr &= ~IRQENABLE;
- w_ctr(ppc, ctr);
-
- ppc->ppc_dmaflags = 0;
- ppc->ppc_dmaddr = (caddr_t)buf;
- ppc->ppc_dmacnt = (u_int)len;
-
- switch (ppc->ppc_mode) {
- case PPB_COMPATIBLE:
- /* compatible mode with FIFO, no intr, DMA, dir=0 */
- ecr = PPC_ECR_FIFO | PPC_DISABLE_INTR | PPC_ENABLE_DMA;
- break;
- case PPB_ECP:
- ecr = PPC_ECR_ECP | PPC_DISABLE_INTR | PPC_ENABLE_DMA;
- break;
- default:
- error = EINVAL;
- goto error;
- }
-
- w_ecr(ppc, ecr);
- ecr = r_ecr(ppc);
-
- /* enter splhigh() not to be preempted
- * by the dma interrupt, we may miss
- * the wakeup otherwise
- */
- s = splhigh();
-
- ppc->ppc_dmastat = PPC_DMA_INIT;
-
- /* enable interrupts */
- ecr &= ~PPC_SERVICE_INTR;
- ppc->ppc_irqstat = PPC_IRQ_DMA;
- w_ecr(ppc, ecr);
-
- isa_dmastart(
- ppc->ppc_dmaflags,
- ppc->ppc_dmaddr,
- ppc->ppc_dmacnt,
- ppc->ppc_dmachan);
-#ifdef PPC_DEBUG
- printf("s%d", ppc->ppc_dmacnt);
-#endif
- ppc->ppc_dmastat = PPC_DMA_STARTED;
-
- /* Wait for the DMA completed interrupt. We hope we won't
- * miss it, otherwise a signal will be necessary to unlock the
- * process.
- */
- do {
- /* release CPU */
- error = tsleep(ppc,
- PPBPRI | PCATCH, "ppcdma", 0);
-
- } while (error == EWOULDBLOCK);
-
- splx(s);
-
- if (error) {
-#ifdef PPC_DEBUG
- printf("i");
-#endif
- /* stop DMA */
- isa_dmadone(
- ppc->ppc_dmaflags, ppc->ppc_dmaddr,
- ppc->ppc_dmacnt, ppc->ppc_dmachan);
-
- /* no dma, no interrupt, flush the fifo */
- w_ecr(ppc, PPC_ECR_RESET);
-
- ppc->ppc_dmastat = PPC_DMA_INTERRUPTED;
- goto error;
- }
-
- /* wait for an empty fifo */
- while (!(r_ecr(ppc) & PPC_FIFO_EMPTY)) {
-
- for (spin=100; spin; spin--)
- if (r_ecr(ppc) & PPC_FIFO_EMPTY)
- goto fifo_empty;
-#ifdef PPC_DEBUG
- printf("Z");
-#endif
- error = tsleep(ppc, PPBPRI | PCATCH, "ppcfifo", hz/100);
- if (error != EWOULDBLOCK) {
-#ifdef PPC_DEBUG
- printf("I");
-#endif
- /* no dma, no interrupt, flush the fifo */
- w_ecr(ppc, PPC_ECR_RESET);
-
- ppc->ppc_dmastat = PPC_DMA_INTERRUPTED;
- error = EINTR;
- goto error;
- }
- }
-
-fifo_empty:
- /* no dma, no interrupt, flush the fifo */
- w_ecr(ppc, PPC_ECR_RESET);
-
- } else
- error = EINVAL; /* XXX we should FIFO and
- * interrupts */
- } else
- error = EINVAL;
-
-error:
-
- /* PDRQ must be kept unasserted until nPDACK is
- * deasserted for a minimum of 350ns (SMC datasheet)
- *
- * Consequence may be a FIFO that never empty
- */
- DELAY(1);
-
- w_ecr(ppc, ecr_sav);
- w_ctr(ppc, ctr_sav);
-
- return (error);
+ return (EINVAL);
}
void
@@ -1809,31 +1622,8 @@
return (ENXIO);
}
-static struct isa_pnp_id lpc_ids[] = {
- { 0x0004d041, "Standard parallel printer port" }, /* PNP0400 */
- { 0x0104d041, "ECP parallel printer port" }, /* PNP0401 */
- { 0 }
-};
-
-static int
-ppc_isa_probe(device_t dev)
-{
- device_t parent;
- int error;
-
- parent = device_get_parent(dev);
-
- error = ISA_PNP_PROBE(parent, dev, lpc_ids);
- if (error == ENXIO)
- return (ENXIO);
- else if (error != 0) /* XXX shall be set after detection */
- device_set_desc(dev, "Parallel port");
-
- return(ppc_probe(dev));
-}
-
int
-ppc_probe(device_t dev)
+ppc_probe(device_t dev, int rid)
{
#ifdef __i386__
static short next_bios_ppc = 0;
@@ -1848,11 +1638,10 @@
ppc = DEVTOSOFTC(dev);
bzero(ppc, sizeof(struct ppc_data));
- ppc->rid_irq = ppc->rid_drq = ppc->rid_ioport = 0;
- ppc->res_irq = ppc->res_drq = ppc->res_ioport = 0;
+ ppc->rid_ioport = rid;
/* retrieve ISA parameters */
- error = bus_get_resource(dev, SYS_RES_IOPORT, 0, &port, NULL);
+ error = bus_get_resource(dev, SYS_RES_IOPORT, rid, &port, NULL);
#ifdef __i386__
/*
@@ -1869,7 +1658,7 @@
device_printf(dev, "parallel port not found.\n");
return ENXIO;
}
- bus_set_resource(dev, SYS_RES_IOPORT, 0, port,
+ bus_set_resource(dev, SYS_RES_IOPORT, rid, port,
IO_LPTSIZE_EXTENDED);
}
#endif
@@ -1878,7 +1667,7 @@
* There isn't a bios list on alpha. Put it in the usual place.
*/
if (error) {
- bus_set_resource(dev, SYS_RES_IOPORT, 0, 0x3bc,
+ bus_set_resource(dev, SYS_RES_IOPORT, rid, 0x3bc,
IO_LPTSIZE_NORMAL);
}
#endif
@@ -1981,12 +1770,6 @@
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);
@@ -2192,6 +1975,4 @@
return (error);
}
-DRIVER_MODULE(ppc, isa, ppc_driver, ppc_devclass, 0, 0);
-DRIVER_MODULE(ppc, acpi, ppc_driver, ppc_devclass, 0, 0);
MODULE_DEPEND(ppc, ppbus, 1, 1, 1);
==== //depot/projects/uart/dev/ppc/ppc_puc.c#4 (text+ko) ====
@@ -33,7 +33,7 @@
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/bus.h>
-
+
#include <machine/bus.h>
#include <dev/puc/puc_bus.h>
@@ -49,14 +49,15 @@
static device_method_t ppc_puc_methods[] = {
/* device interface */
- DEVMETHOD(device_probe, ppc_puc_probe),
- DEVMETHOD(device_attach, ppc_attach),
+ DEVMETHOD(device_probe, ppc_puc_probe),
+ DEVMETHOD(device_attach, ppc_attach),
+ DEVMETHOD(device_detach, ppc_detach),
/* bus interface */
DEVMETHOD(bus_read_ivar, ppc_read_ivar),
DEVMETHOD(bus_setup_intr, ppc_setup_intr),
DEVMETHOD(bus_teardown_intr, ppc_teardown_intr),
- DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
+ DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
/* ppbus interface */
DEVMETHOD(ppbus_io, ppc_io),
@@ -67,11 +68,11 @@
DEVMETHOD(ppbus_read, ppc_read),
DEVMETHOD(ppbus_write, ppc_write),
- { 0, 0 }
- };
-
+ { 0, 0 }
+};
+
static driver_t ppc_puc_driver = {
- "ppc",
+ ppc_driver_name,
ppc_puc_methods,
sizeof(struct ppc_data),
};
@@ -89,7 +90,7 @@
return (ENXIO);
device_set_desc(dev, "Parallel port");
- return (ppc_probe(dev));
+ return (ppc_probe(dev, 0));
}
DRIVER_MODULE(ppc, puc, ppc_puc_driver, ppc_devclass, 0, 0);
==== //depot/projects/uart/dev/ppc/ppcreg.h#2 (text+ko) ====
@@ -82,6 +82,7 @@
int ppc_dmaflags; /* dma transfer flags */
caddr_t ppc_dmaddr; /* buffer address */
u_int ppc_dmacnt; /* count of bytes sent with dma */
+ void (*ppc_dmadone)(struct ppc_data*);
#define PPC_PWORD_MASK 0x30
#define PPC_PWORD_16 0x00
==== //depot/projects/uart/dev/ppc/ppcvar.h#4 (text+ko) ====
@@ -28,7 +28,7 @@
*
*/
-int ppc_probe(device_t dev);
+int ppc_probe(device_t dev, int rid);
int ppc_attach(device_t dev);
int ppc_detach(device_t dev);
int ppc_read_ivar(device_t bus, device_t dev, int index, uintptr_t *val);
@@ -46,4 +46,5 @@
void ppc_ecp_sync(device_t);
int ppc_setmode(device_t, int);
-extern devclass_t ppc_devclass;
+extern devclass_t ppc_devclass;
+extern const char ppc_driver_name[];
More information about the p4-projects
mailing list