PERFORCE change 55647 for review
Peter Wemm
peter at FreeBSD.org
Wed Jun 23 22:10:41 GMT 2004
http://perforce.freebsd.org/chv.cgi?CH=55647
Change 55647 by peter at peter_daintree on 2004/06/23 22:09:25
IFC @55646
Affected files ...
.. //depot/projects/hammer/sys/conf/files#65 integrate
.. //depot/projects/hammer/sys/conf/options#41 integrate
.. //depot/projects/hammer/sys/dev/cp/if_cp.c#6 integrate
.. //depot/projects/hammer/sys/dev/ctau/if_ct.c#7 integrate
.. //depot/projects/hammer/sys/dev/cx/if_cx.c#11 integrate
.. //depot/projects/hammer/sys/fs/udf/udf.h#6 integrate
.. //depot/projects/hammer/sys/fs/udf/udf_vfsops.c#10 integrate
.. //depot/projects/hammer/sys/fs/udf/udf_vnops.c#16 integrate
.. //depot/projects/hammer/sys/geom/vinum/geom_vinum_share.c#2 integrate
.. //depot/projects/hammer/sys/i386/i386/io_apic.c#9 integrate
.. //depot/projects/hammer/sys/netinet/tcp.h#7 integrate
.. //depot/projects/hammer/sys/netinet/tcp_input.c#29 integrate
.. //depot/projects/hammer/sys/netinet/tcp_output.c#17 integrate
.. //depot/projects/hammer/sys/netinet/tcp_sack.c#1 branch
.. //depot/projects/hammer/sys/netinet/tcp_seq.h#5 integrate
.. //depot/projects/hammer/sys/netinet/tcp_subr.c#23 integrate
.. //depot/projects/hammer/sys/netinet/tcp_syncache.c#18 integrate
.. //depot/projects/hammer/sys/netinet/tcp_timer.c#9 integrate
.. //depot/projects/hammer/sys/netinet/tcp_var.h#13 integrate
.. //depot/projects/hammer/sys/vm/uma_core.c#26 integrate
Differences ...
==== //depot/projects/hammer/sys/conf/files#65 (text+ko) ====
@@ -1,4 +1,4 @@
-# $FreeBSD: src/sys/conf/files,v 1.907 2004/06/22 20:13:24 brooks Exp $
+# $FreeBSD: src/sys/conf/files,v 1.908 2004/06/23 21:04:36 ps Exp $
#
# The long compile-with and dependency lines are required because of
# limitations in config: backslash-newline doesn't work in strings, and
@@ -1465,6 +1465,7 @@
netinet/tcp_hostcache.c optional inet
netinet/tcp_input.c optional inet
netinet/tcp_output.c optional inet
+netinet/tcp_sack.c optional inet
netinet/tcp_subr.c optional inet
netinet/tcp_syncache.c optional inet
netinet/tcp_timer.c optional inet
==== //depot/projects/hammer/sys/conf/options#41 (text+ko) ====
@@ -1,4 +1,4 @@
-# $FreeBSD: src/sys/conf/options,v 1.453 2004/06/13 17:29:06 mlaier Exp $
+# $FreeBSD: src/sys/conf/options,v 1.454 2004/06/23 21:04:37 ps Exp $
#
# On the handling of kernel options
#
@@ -354,6 +354,7 @@
SLIP_IFF_OPTS opt_slip.h
TCPDEBUG
TCP_SIGNATURE opt_inet.h
+TCP_SACK_DEBUG opt_tcp_sack.h
TCP_DROP_SYNFIN opt_tcp_input.h
XBONEHACK
==== //depot/projects/hammer/sys/dev/cp/if_cp.c#6 (text+ko) ====
@@ -18,11 +18,11 @@
* as long as this message is kept with the software, all derivative
* works or modified versions.
*
- * $Cronyx: if_cp.c,v 1.1.2.32 2004/02/26 17:56:39 rik Exp $
+ * Cronyx Id: if_cp.c,v 1.1.2.41 2004/06/23 17:09:13 rik Exp $
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/cp/if_cp.c,v 1.7 2004/06/23 11:23:53 rik Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/cp/if_cp.c,v 1.8 2004/06/23 18:13:09 rik Exp $");
#include <sys/param.h>
@@ -66,11 +66,7 @@
# endif
# include <netgraph/ng_message.h>
# include <netgraph/netgraph.h>
-# if __FreeBSD_version >= 500000
-# include <dev/cp/ng_cp.h>
-# else
-# include <netgraph/ng_cp.h>
-# endif
+# include <dev/cp/ng_cp.h>
#else
# include <net/if_sppp.h>
# define PP_CISCO IFF_LINK2
@@ -80,13 +76,8 @@
# include <net/bpf.h>
# define NBPFILTER NBPF
#endif
-#if __FreeBSD_version >= 500000
#include <dev/cx/machdep.h>
#include <dev/cp/cpddk.h>
-#else
-#include <i386/isa/cronyx/machdep.h>
-#include <pci/cpddk.h>
-#endif
#include <machine/cserial.h>
#include <machine/resource.h>
#include <machine/pmap.h>
@@ -116,26 +107,21 @@
{0, 0}
};
-typedef struct _bdrv_t {
- cp_board_t *board;
- struct resource *cp_res;
- struct resource *cp_irq;
- void *cp_intrhand;
-} bdrv_t;
-
-static driver_t cp_driver = {
- "cp",
- cp_methods,
- sizeof(bdrv_t),
-};
+typedef struct _cp_dma_mem_t {
+ unsigned long phys;
+ void *virt;
+ size_t size;
+#if __FreeBSD_version >= 500000
+ bus_dma_tag_t dmat;
+ bus_dmamap_t mapp;
+#endif
+} cp_dma_mem_t;
-static devclass_t cp_devclass;
-
typedef struct _drv_t {
char name [8];
cp_chan_t *chan;
cp_board_t *board;
- cp_buf_t buf;
+ cp_dma_mem_t dmamem;
int running;
#ifdef NETGRAPH
char nodename [NG_NODELEN+1];
@@ -152,6 +138,23 @@
struct cdev *devt;
} drv_t;
+typedef struct _bdrv_t {
+ cp_board_t *board;
+ struct resource *cp_res;
+ struct resource *cp_irq;
+ void *cp_intrhand;
+ cp_dma_mem_t dmamem;
+ drv_t channel [NCHAN];
+} bdrv_t;
+
+static driver_t cp_driver = {
+ "cp",
+ cp_methods,
+ sizeof(bdrv_t),
+};
+
+static devclass_t cp_devclass;
+
static void cp_receive (cp_chan_t *c, unsigned char *data, int len);
static void cp_transmit (cp_chan_t *c, void *attachment, int len);
static void cp_error (cp_chan_t *c, int data);
@@ -172,7 +175,6 @@
static cp_board_t *adapter [NBRD];
static drv_t *channel [NBRD*NCHAN];
-static cp_qbuf_t *queue [NBRD];
static struct callout_handle led_timo [NBRD];
static struct callout_handle timeout_handle;
@@ -298,6 +300,86 @@
extern struct cdevsw cp_cdevsw;
+#if __FreeBSD_version >= 500000
+static void
+cp_bus_dmamap_addr (void *arg, bus_dma_segment_t *segs, int nseg, int error)
+{
+ unsigned long *addr;
+
+ if (error)
+ return;
+
+ KASSERT(nseg == 1, ("too many DMA segments, %d should be 1", nseg));
+ addr = arg;
+ *addr = segs->ds_addr;
+}
+
+static int
+cp_bus_dma_mem_alloc (int bnum, int cnum, cp_dma_mem_t *dmem)
+{
+ int error;
+
+ error = bus_dma_tag_create (NULL, 16, 0, BUS_SPACE_MAXADDR_32BIT,
+ BUS_SPACE_MAXADDR, NULL, NULL, dmem->size, 1,
+ dmem->size, 0, NULL, NULL, &dmem->dmat);
+ if (error) {
+ if (cnum >= 0) printf ("cp%d-%d: ", bnum, cnum);
+ else printf ("cp%d: ", bnum);
+ printf ("couldn't allocate tag for dma memory\n");
+ return 0;
+ }
+ error = bus_dmamem_alloc (dmem->dmat, (void **)&dmem->virt,
+ BUS_DMA_NOWAIT | BUS_DMA_ZERO, &dmem->mapp);
+ if (error) {
+ if (cnum >= 0) printf ("cp%d-%d: ", bnum, cnum);
+ else printf ("cp%d: ", bnum);
+ printf ("couldn't allocate mem for dma memory\n");
+ bus_dma_tag_destroy (dmem->dmat);
+ return 0;
+ }
+ error = bus_dmamap_load (dmem->dmat, dmem->mapp, dmem->virt,
+ dmem->size, cp_bus_dmamap_addr, &dmem->phys, 0);
+ if (error) {
+ if (cnum >= 0) printf ("cp%d-%d: ", bnum, cnum);
+ else printf ("cp%d: ", bnum);
+ printf ("couldn't load mem map for dma memory\n");
+ bus_dmamem_free (dmem->dmat, dmem->virt, dmem->mapp);
+ bus_dma_tag_destroy (dmem->dmat);
+ return 0;
+ }
+ return 1;
+}
+
+static void
+cp_bus_dma_mem_free (cp_dma_mem_t *dmem)
+{
+ bus_dmamap_unload (dmem->dmat, dmem->mapp);
+ bus_dmamem_free (dmem->dmat, dmem->virt, dmem->mapp);
+ bus_dma_tag_destroy (dmem->dmat);
+}
+#else
+static int
+cp_bus_dma_mem_alloc (int bnum, int cnum, cp_dma_mem_t *dmem)
+{
+ dmem->virt = contigmalloc (dmem->size, M_DEVBUF, M_WAITOK,
+ 0x100000, 0xffffffff, 16, 0);
+ if (dmem->virt == NULL) {
+ if (cnum >= 0) printf ("cp%d-%d: ", bnum, cnum);
+ else printf ("cp%d: ", bnum);
+ printf ("couldn't allocate memory for dma memory\n", unit);
+ return 0;
+ }
+ dmem->phys = vtophys (dmem->virt);
+ return 1;
+}
+
+static void
+cp_bus_dma_mem_free (cp_dma_mem_t *dmem)
+{
+ contigfree (dmem->virt, dmem->size, M_DEVBUF);
+}
+#endif
+
/*
* Called if the probe succeeded.
*/
@@ -305,12 +387,12 @@
{
bdrv_t *bd = device_get_softc (dev);
int unit = device_get_unit (dev);
+ unsigned short res;
+ vm_offset_t vbase;
int rid, error;
- vm_offset_t vbase;
- cp_board_t *b;
+ cp_board_t *b;
cp_chan_t *c;
- drv_t *d;
- unsigned short res;
+ drv_t *d;
int s = splimp ();
b = malloc (sizeof(cp_board_t), M_DEVBUF, M_WAITOK);
@@ -343,15 +425,14 @@
splx (s);
return (ENXIO);
}
- queue[unit] = contigmalloc (sizeof(cp_qbuf_t), M_DEVBUF, M_WAITOK,
- 0x100000, 0xffffffff, 16, 0);
- if (queue[unit] == NULL) {
- printf ("cp%d: allocate memory for qbuf_t\n", unit);
+
+ bd->dmamem.size = sizeof(cp_qbuf_t);
+ if (! cp_bus_dma_mem_alloc (unit, -1, &bd->dmamem)) {
free (b, M_DEVBUF);
splx (s);
return (ENXIO);
}
- cp_reset (b, queue[unit], vtophys (queue[unit]));
+ cp_reset (b, bd->dmamem.virt, bd->dmamem.phys);
rid = 0;
bd->cp_irq = bus_alloc_resource (dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
@@ -380,14 +461,11 @@
for (c=b->chan; c<b->chan+NCHAN; ++c) {
if (! c->type)
continue;
- d = contigmalloc (sizeof(drv_t), M_DEVBUF, M_WAITOK,
- 0x100000, 0xffffffff, 16, 0);
- if (d == NULL) {
- printf ("cp%d-%d: cannot allocate memory for drv_t\n",
- unit, c->num);
- }
+ d = &bd->channel[c->num];
+ d->dmamem.size = sizeof(cp_buf_t);
+ if (! cp_bus_dma_mem_alloc (unit, c->num, &d->dmamem))
+ continue;
channel [b->num*NCHAN + c->num] = d;
- bzero (d, sizeof(drv_t));
sprintf (d->name, "cp%d.%d", b->num, c->num);
d->board = b;
d->chan = c;
@@ -444,7 +522,7 @@
bpfattach (&d->pp.pp_if, DLT_PPP, 4);
#endif /*NETGRAPH*/
cp_start_e1 (c);
- cp_start_chan (c, 1, 1, &d->buf, vtophys (&d->buf));
+ cp_start_chan (c, 1, 1, d->dmamem.virt, d->dmamem.phys);
/* Register callback functions. */
cp_register_transmit (c, &cp_transmit);
@@ -548,10 +626,10 @@
continue;
channel [b->num*NCHAN + c->num] = 0;
/* Deallocate buffers. */
- contigfree (d, sizeof (*d), M_DEVBUF);
+ cp_bus_dma_mem_free (&d->dmamem);
}
adapter [b->num] = 0;
- contigfree (queue[b->num], sizeof (cp_qbuf_t), M_DEVBUF);
+ cp_bus_dma_mem_free (&bd->dmamem);
free (b, M_DEVBUF);
splx (s);
return 0;
@@ -2326,7 +2404,6 @@
}
#endif
-
static int cp_modevent (module_t mod, int type, void *unused)
{
struct cdev *dev;
@@ -2400,7 +2477,7 @@
#else
DRIVER_MODULE (cp, pci, cp_driver, cp_devclass, cp_modevent, NULL);
#endif
-#elif __FreeBSD_version >= 400000
+#elif __FreeBSD_version >= 400000
#ifdef NETGRAPH
DRIVER_MODULE (cp, pci, cp_driver, cp_devclass, ng_mod_event, &typestruct);
#else
==== //depot/projects/hammer/sys/dev/ctau/if_ct.c#7 (text+ko) ====
@@ -18,10 +18,11 @@
* as long as this message is kept with the software, all derivative
* works or modified versions.
*
- * Cronyx Id: if_ct.c,v 1.1.2.22 2004/02/26 19:06:51 rik Exp $
+ * Cronyx Id: if_ct.c,v 1.1.2.31 2004/06/23 17:09:13 rik Exp $
*/
+
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/ctau/if_ct.c,v 1.9 2004/06/23 11:23:54 rik Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/ctau/if_ct.c,v 1.10 2004/06/23 18:13:10 rik Exp $");
#include <sys/param.h>
@@ -111,30 +112,21 @@
{0, 0}
};
-typedef struct _bdrv_t {
- ct_board_t *board;
- struct resource *base_res;
- struct resource *drq_res;
- struct resource *irq_res;
- int base_rid;
- int drq_rid;
- int irq_rid;
- void *intrhand;
-} bdrv_t;
-
-static driver_t ct_isa_driver = {
- "ct",
- ct_isa_methods,
- sizeof (bdrv_t),
-};
+typedef struct _ct_dma_mem_t {
+ unsigned long phys;
+ void *virt;
+ size_t size;
+#if __FreeBSD_version >= 500000
+ bus_dma_tag_t dmat;
+ bus_dmamap_t mapp;
+#endif
+} ct_dma_mem_t;
-static devclass_t ct_devclass;
-
typedef struct _drv_t {
char name [8];
ct_chan_t *chan;
ct_board_t *board;
- ct_buf_t buf;
+ ct_dma_mem_t dmamem;
int running;
#ifdef NETGRAPH
char nodename [NG_NODELEN+1];
@@ -151,6 +143,26 @@
struct cdev *devt;
} drv_t;
+typedef struct _bdrv_t {
+ ct_board_t *board;
+ struct resource *base_res;
+ struct resource *drq_res;
+ struct resource *irq_res;
+ int base_rid;
+ int drq_rid;
+ int irq_rid;
+ void *intrhand;
+ drv_t channel [NCHAN];
+} bdrv_t;
+
+static driver_t ct_isa_driver = {
+ "ct",
+ ct_isa_methods,
+ sizeof (bdrv_t),
+};
+
+static devclass_t ct_devclass;
+
static void ct_receive (ct_chan_t *c, char *data, int len);
static void ct_transmit (ct_chan_t *c, void *attachment, int len);
static void ct_error (ct_chan_t *c, int data);
@@ -446,6 +458,87 @@
}
extern struct cdevsw ct_cdevsw;
+
+#if __FreeBSD_version >= 500000
+static void
+ct_bus_dmamap_addr (void *arg, bus_dma_segment_t *segs, int nseg, int error)
+{
+ unsigned long *addr;
+
+ if (error)
+ return;
+
+ KASSERT(nseg == 1, ("too many DMA segments, %d should be 1", nseg));
+ addr = arg;
+ *addr = segs->ds_addr;
+}
+
+static int
+ct_bus_dma_mem_alloc (int bnum, int cnum, ct_dma_mem_t *dmem)
+{
+ int error;
+
+ error = bus_dma_tag_create (NULL, 16, 0, BUS_SPACE_MAXADDR_24BIT,
+ BUS_SPACE_MAXADDR, NULL, NULL, dmem->size, 1,
+ dmem->size, 0, NULL, NULL, &dmem->dmat);
+ if (error) {
+ if (cnum >= 0) printf ("ct%d-%d: ", bnum, cnum);
+ else printf ("ct%d: ", bnum);
+ printf ("couldn't allocate tag for dma memory\n");
+ return 0;
+ }
+ error = bus_dmamem_alloc (dmem->dmat, (void **)&dmem->virt,
+ BUS_DMA_NOWAIT | BUS_DMA_ZERO, &dmem->mapp);
+ if (error) {
+ if (cnum >= 0) printf ("ct%d-%d: ", bnum, cnum);
+ else printf ("ct%d: ", bnum);
+ printf ("couldn't allocate mem for dma memory\n");
+ bus_dma_tag_destroy (dmem->dmat);
+ return 0;
+ }
+ error = bus_dmamap_load (dmem->dmat, dmem->mapp, dmem->virt,
+ dmem->size, ct_bus_dmamap_addr, &dmem->phys, 0);
+ if (error) {
+ if (cnum >= 0) printf ("ct%d-%d: ", bnum, cnum);
+ else printf ("ct%d: ", bnum);
+ printf ("couldn't load mem map for dma memory\n");
+ bus_dmamem_free (dmem->dmat, dmem->virt, dmem->mapp);
+ bus_dma_tag_destroy (dmem->dmat);
+ return 0;
+ }
+ return 1;
+}
+
+static void
+ct_bus_dma_mem_free (ct_dma_mem_t *dmem)
+{
+ bus_dmamap_unload (dmem->dmat, dmem->mapp);
+ bus_dmamem_free (dmem->dmat, dmem->virt, dmem->mapp);
+ bus_dma_tag_destroy (dmem->dmat);
+}
+#else
+static int
+ct_bus_dma_mem_alloc (int bnum, int cnum, ct_dma_mem_t *dmem)
+{
+ dmem->virt = contigmalloc (dmem->size, M_DEVBUF, M_WAITOK,
+ 0x100000, 0x1000000, 16, 0);
+ if (dmem->virt == NULL) {
+ if (cnum >= 0) printf ("ct%d-%d: ", bnum, cnum);
+ else printf ("ct%d: ", bnum);
+ printf ("couldn't allocate memory for dma memory\n", unit);
+ return 0;
+ }
+ dmem->phys = vtophys (dmem->virt);
+ return 1;
+}
+
+static void
+ct_bus_dma_mem_free (ct_dma_mem_t *dmem)
+{
+ contigfree (dmem->virt, dmem->size, M_DEVBUF);
+}
+#endif
+
/*
* The adapter is present, initialize the driver structures.
*/
@@ -589,10 +682,11 @@
b->osc == 20000000 ? "20" : "16.384");
for (c=b->chan; c<b->chan+NCHAN; ++c) {
- d = contigmalloc (sizeof(drv_t), M_DEVBUF, M_WAITOK,
- 0x100000, 0x1000000, 16, 0);
+ d = &bd->channel[c->num];
+ d->dmamem.size = sizeof(ct_buf_t);
+ if (! ct_bus_dma_mem_alloc (unit, c->num, &d->dmamem))
+ continue;
channel [b->num*NCHAN + c->num] = d;
- bzero (d, sizeof(drv_t));
sprintf (d->name, "ct%d.%d", b->num, c->num);
d->board = b;
d->chan = c;
@@ -603,7 +697,7 @@
printf ("%s: cannot make common node\n", d->name);
channel [b->num*NCHAN + c->num] = 0;
c->sys = 0;
- contigfree (d, sizeof (*d), M_DEVBUF);
+ ct_bus_dma_mem_free (&d->dmamem);
continue;
}
#if __FreeBSD_version >= 500000
@@ -623,7 +717,7 @@
#endif
channel [b->num*NCHAN + c->num] = 0;
c->sys = 0;
- contigfree (d, sizeof (*d), M_DEVBUF);
+ ct_bus_dma_mem_free (&d->dmamem);
continue;
}
d->queue.ifq_maxlen = IFQ_MAXLEN;
@@ -654,7 +748,7 @@
* Header size is 4 bytes. */
bpfattach (&d->pp.pp_if, DLT_PPP, 4);
#endif /*NETGRAPH*/
- ct_start_chan (c, &d->buf, vtophys (&d->buf));
+ ct_start_chan (c, d->dmamem.virt, d->dmamem.phys);
ct_register_receive (c, &ct_receive);
ct_register_transmit (c, &ct_transmit);
ct_register_error (c, &ct_error);
@@ -748,7 +842,7 @@
continue;
/* Deallocate buffers. */
- contigfree (d, sizeof (*d), M_DEVBUF);
+ ct_bus_dma_mem_free (&d->dmamem);
}
bd->board = 0;
adapter [b->num] = 0;
@@ -1504,7 +1598,7 @@
case SERIAL_SETCLK:
/* Only for superuser! */
#if __FreeBSD_version < 500000
- error = suser (p);
+ error = suser (p);
#else /* __FreeBSD_version >= 500000 */
error = suser (td);
#endif /* __FreeBSD_version >= 500000 */
@@ -2296,9 +2390,8 @@
.newhook = ng_ct_newhook,
.connect = ng_ct_connect,
.rcvdata = ng_ct_rcvdata,
- .disconnect = ng_ct_disconnect
+ .disconnect = ng_ct_disconnect,
};
-
#endif /*NETGRAPH*/
#if __FreeBSD_version >= 500000
==== //depot/projects/hammer/sys/dev/cx/if_cx.c#11 (text+ko) ====
@@ -19,10 +19,11 @@
* as long as this message is kept with the software, all derivative
* works or modified versions.
*
- * Cronyx Id: if_cx.c,v 1.1.2.23 2004/02/26 17:56:40 rik Exp $
+ * Cronyx Id: if_cx.c,v 1.1.2.34 2004/06/23 17:09:13 rik Exp $
*/
+
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/cx/if_cx.c,v 1.22 2004/06/23 11:23:54 rik Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/cx/if_cx.c,v 1.23 2004/06/23 18:13:10 rik Exp $");
#include <sys/param.h>
@@ -57,8 +58,8 @@
#include <machine/cserial.h>
#include <machine/clock.h>
#if __FreeBSD_version < 500000
-#include <machine/ipl.h>
-#include <i386/isa/isa_device.h>
+# include <machine/ipl.h>
+# include <i386/isa/isa_device.h>
#endif
#include <machine/resource.h>
#if __FreeBSD_version <= 501000
@@ -142,30 +143,21 @@
{0, 0}
};
-typedef struct _bdrv_t {
- cx_board_t *board;
- struct resource *base_res;
- struct resource *drq_res;
- struct resource *irq_res;
- int base_rid;
- int drq_rid;
- int irq_rid;
- void *intrhand;
-} bdrv_t;
+typedef struct _cx_dma_mem_t {
+ unsigned long phys;
+ void *virt;
+ size_t size;
+#if __FreeBSD_version >= 500000
+ bus_dma_tag_t dmat;
+ bus_dmamap_t mapp;
+#endif
+} cx_dma_mem_t;
-static driver_t cx_isa_driver = {
- "cx",
- cx_isa_methods,
- sizeof (bdrv_t),
-};
-
-static devclass_t cx_devclass;
-
typedef struct _drv_t {
char name [8];
cx_chan_t *chan;
cx_board_t *board;
- cx_buf_t buf;
+ cx_dma_mem_t dmamem;
struct tty *tty;
struct callout_handle dcd_timeout_handle;
unsigned dtrwait;
@@ -196,6 +188,26 @@
short atimeout;
} drv_t;
+typedef struct _bdrv_t {
+ cx_board_t *board;
+ struct resource *base_res;
+ struct resource *drq_res;
+ struct resource *irq_res;
+ int base_rid;
+ int drq_rid;
+ int irq_rid;
+ void *intrhand;
+ drv_t channel [NCHAN];
+} bdrv_t;
+
+static driver_t cx_isa_driver = {
+ "cx",
+ cx_isa_methods,
+ sizeof (bdrv_t),
+};
+
+static devclass_t cx_devclass;
+
extern long csigma_fw_len;
extern const char *csigma_fw_version;
extern const char *csigma_fw_date;
@@ -571,6 +583,86 @@
return 0;
}
+#if __FreeBSD_version >= 500000
+static void
+cx_bus_dmamap_addr (void *arg, bus_dma_segment_t *segs, int nseg, int error)
+{
+ unsigned long *addr;
+
+ if (error)
+ return;
+
+ KASSERT(nseg == 1, ("too many DMA segments, %d should be 1", nseg));
+ addr = arg;
+ *addr = segs->ds_addr;
+}
+
+static int
+cx_bus_dma_mem_alloc (int bnum, int cnum, cx_dma_mem_t *dmem)
+{
+ int error;
+
+ error = bus_dma_tag_create (NULL, 16, 0, BUS_SPACE_MAXADDR_24BIT,
+ BUS_SPACE_MAXADDR, NULL, NULL, dmem->size, 1,
+ dmem->size, 0, NULL, NULL, &dmem->dmat);
+ if (error) {
+ if (cnum >= 0) printf ("cx%d-%d: ", bnum, cnum);
+ else printf ("cx%d: ", bnum);
+ printf ("couldn't allocate tag for dma memory\n");
+ return 0;
+ }
+ error = bus_dmamem_alloc (dmem->dmat, (void **)&dmem->virt,
+ BUS_DMA_NOWAIT | BUS_DMA_ZERO, &dmem->mapp);
+ if (error) {
+ if (cnum >= 0) printf ("cx%d-%d: ", bnum, cnum);
+ else printf ("cx%d: ", bnum);
+ printf ("couldn't allocate mem for dma memory\n");
+ bus_dma_tag_destroy (dmem->dmat);
+ return 0;
+ }
+ error = bus_dmamap_load (dmem->dmat, dmem->mapp, dmem->virt,
+ dmem->size, cx_bus_dmamap_addr, &dmem->phys, 0);
+ if (error) {
+ if (cnum >= 0) printf ("cx%d-%d: ", bnum, cnum);
+ else printf ("cx%d: ", bnum);
+ printf ("couldn't load mem map for dma memory\n");
+ bus_dmamem_free (dmem->dmat, dmem->virt, dmem->mapp);
+ bus_dma_tag_destroy (dmem->dmat);
+ return 0;
+ }
+ return 1;
+}
+
+static void
+cx_bus_dma_mem_free (cx_dma_mem_t *dmem)
+{
+ bus_dmamap_unload (dmem->dmat, dmem->mapp);
+ bus_dmamem_free (dmem->dmat, dmem->virt, dmem->mapp);
+ bus_dma_tag_destroy (dmem->dmat);
+}
+#else
+static int
+cx_bus_dma_mem_alloc (int bnum, int cnum, cx_dma_mem_t *dmem)
+{
+ dmem->virt = contigmalloc (dmem->size, M_DEVBUF, M_WAITOK,
+ 0x100000, 0x1000000, 16, 0);
+ if (dmem->virt == NULL) {
+ if (cnum >= 0) printf ("cx%d-%d: ", bnum, cnum);
+ else printf ("cx%d: ", bnum);
+ printf ("couldn't allocate memory for dma memory\n", unit);
+ return 0;
+ }
+ dmem->phys = vtophys (dmem->virt);
+ return 1;
+}
+
+static void
+cx_bus_dma_mem_free (cx_dma_mem_t *dmem)
+{
+ contigfree (dmem->virt, dmem->size, M_DEVBUF);
+}
+#endif
+
/*
* The adapter is present, initialize the driver structures.
*/
@@ -717,10 +809,11 @@
char *dnmc="cua %x";
if (c->type == T_NONE)
continue;
- d = contigmalloc (sizeof(drv_t), M_DEVBUF, M_WAITOK,
- 0x100000, 0x1000000, 16, 0);
+ d = &bd->channel[c->num];
+ d->dmamem.size = sizeof(cx_buf_t);
+ if (! cx_bus_dma_mem_alloc (unit, c->num, &d->dmamem))
+ continue;
channel [b->num*NCHAN + c->num] = d;
- bzero (d, sizeof(drv_t));
sprintf (d->name, "cx%d.%d", b->num, c->num);
d->board = b;
d->chan = c;
@@ -741,7 +834,7 @@
printf ("%s: cannot make common node\n", d->name);
channel [b->num*NCHAN + c->num] = 0;
c->sys = 0;
- contigfree (d, sizeof (*d), M_DEVBUF);
+ cx_bus_dma_mem_free (&d->dmamem);
continue;
}
#if __FreeBSD_version >= 500000
@@ -761,7 +854,7 @@
#endif
channel [b->num*NCHAN + c->num] = 0;
c->sys = 0;
- contigfree (d, sizeof (*d), M_DEVBUF);
+ cx_bus_dma_mem_free (&d->dmamem);
continue;
}
d->lo_queue.ifq_maxlen = IFQ_MAXLEN;
@@ -793,7 +886,7 @@
bpfattach (&d->pp.pp_if, DLT_PPP, 4);
#endif /*NETGRAPH*/
}
- cx_start_chan (c, &d->buf, vtophys (&d->buf));
+ cx_start_chan (c, d->dmamem.virt, d->dmamem.phys);
cx_register_receive (c, &cx_receive);
cx_register_transmit (c, &cx_transmit);
cx_register_error (c, &cx_error);
@@ -919,7 +1012,7 @@
continue;
/* Deallocate buffers. */
- contigfree (d, sizeof (*d), M_DEVBUF);
+ cx_bus_dma_mem_free (&d->dmamem);
}
bd->board = 0;
adapter [b->num] = 0;
@@ -2815,9 +2908,8 @@
.newhook = ng_cx_newhook,
.connect = ng_cx_connect,
.rcvdata = ng_cx_rcvdata,
- .disconnect = ng_cx_disconnect
+ .disconnect = ng_cx_disconnect,
};
-
#endif /*NETGRAPH*/
#if __FreeBSD_version >= 500000
==== //depot/projects/hammer/sys/fs/udf/udf.h#6 (text+ko) ====
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/fs/udf/udf.h,v 1.7 2004/06/16 09:47:05 phk Exp $
+ * $FreeBSD: src/sys/fs/udf/udf.h,v 1.8 2004/06/23 19:36:09 scottl Exp $
*/
#define UDF_HASHTBLSIZE 100
@@ -115,7 +115,9 @@
}
/*
- * Produce a suitable file number from an ICB.
+ * Produce a suitable file number from an ICB. The passed in ICB is expected
+ * to be in little endian (meaning that it hasn't been swapped for big
+ * endian machines yet).
* XXX If the fileno resolves to 0, we might be in big trouble.
* XXX Assumes the ICB is a long_ad. This struct is compatible with short_ad,
* but not ext_ad.
@@ -123,7 +125,7 @@
static __inline ino_t
udf_getid(struct long_ad *icb)
{
- return (icb->loc.lb_num);
+ return (le32toh(icb->loc.lb_num));
}
int udf_allocv(struct mount *, struct vnode **, struct thread *);
==== //depot/projects/hammer/sys/fs/udf/udf_vfsops.c#10 (text+ko) ====
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/fs/udf/udf_vfsops.c,v 1.17 2004/03/30 05:01:48 scottl Exp $
+ * $FreeBSD: src/sys/fs/udf/udf_vfsops.c,v 1.18 2004/06/23 19:36:09 scottl Exp $
*/
/* udf_vfsops.c */
@@ -87,6 +87,7 @@
#include <sys/proc.h>
#include <sys/queue.h>
#include <sys/vnode.h>
+#include <sys/endian.h>
#include <vm/uma.h>
@@ -382,8 +383,8 @@
* XXX Should we care about the partition type right now?
* XXX What about multiple partitions?
*/
- mvds_start = avdp.main_vds_ex.loc;
- mvds_end = mvds_start + (avdp.main_vds_ex.len - 1) / bsize;
+ mvds_start = le32toh(avdp.main_vds_ex.loc);
+ mvds_end = mvds_start + (le32toh(avdp.main_vds_ex.len) - 1) / bsize;
for (sector = mvds_start; sector < mvds_end; sector++) {
if ((error = bread(devvp, sector * btodb(bsize), bsize,
NOCRED, &bp)) != 0) {
@@ -392,11 +393,11 @@
}
lvd = (struct logvol_desc *)bp->b_data;
if (!udf_checktag(&lvd->tag, TAGID_LOGVOL)) {
- udfmp->bsize = lvd->lb_size;
+ udfmp->bsize = le32toh(lvd->lb_size);
udfmp->bmask = udfmp->bsize - 1;
udfmp->bshift = ffs(udfmp->bsize) - 1;
- fsd_part = lvd->_lvd_use.fsd_loc.loc.part_num;
- fsd_offset = lvd->_lvd_use.fsd_loc.loc.lb_num;
+ fsd_part = le16toh(lvd->_lvd_use.fsd_loc.loc.part_num);
+ fsd_offset = le32toh(lvd->_lvd_use.fsd_loc.loc.lb_num);
if (udf_find_partmaps(udfmp, lvd))
break;
logvol_found = 1;
@@ -404,9 +405,9 @@
pd = (struct part_desc *)bp->b_data;
if (!udf_checktag(&pd->tag, TAGID_PARTITION)) {
part_found = 1;
- part_num = pd->part_num;
- udfmp->part_len = pd->part_len;
- udfmp->part_start = pd->start_loc;
+ part_num = le16toh(pd->part_num);
+ udfmp->part_len = le32toh(pd->part_len);
+ udfmp->part_start = le32toh(pd->start_loc);
}
brelse(bp);
@@ -456,8 +457,8 @@
/*
* Find the file entry for the root directory.
*/
- sector = udfmp->root_icb.loc.lb_num + udfmp->part_start;
- size = udfmp->root_icb.len;
+ sector = le32toh(udfmp->root_icb.loc.lb_num) + udfmp->part_start;
+ size = le32toh(udfmp->root_icb.len);
if ((error = udf_readlblks(udfmp, sector, size, &bp)) != 0) {
printf("Cannot read sector %d\n", sector);
goto bail;
@@ -626,7 +627,7 @@
brelse(bp);
return (ENOMEM);
}
- size = UDF_FENTRY_SIZE + fe->l_ea + fe->l_ad;
+ size = UDF_FENTRY_SIZE + le32toh(fe->l_ea) + le32toh(fe->l_ad);
MALLOC(unode->fentry, struct file_entry *, size, M_UDFFENTRY,
M_NOWAIT | M_ZERO);
if (unode->fentry == NULL) {
@@ -736,7 +737,7 @@
unsigned char regid_id[UDF_REGID_ID_SIZE + 1];
int i, ptype, psize, error;
- for (i = 0; i < lvd->n_pm; i++) {
+ for (i = 0; i < le32toh(lvd->n_pm); i++) {
pmap = (union udf_pmap *)&lvd->maps[i * UDF_PMAP_SIZE];
ptype = pmap->data[0];
psize = pmap->data[1];
@@ -763,28 +764,28 @@
}
pms = &pmap->pms;
- MALLOC(udfmp->s_table, struct udf_sparing_table *, pms->st_size,
- M_UDFMOUNT, M_NOWAIT | M_ZERO);
+ MALLOC(udfmp->s_table, struct udf_sparing_table *,
+ le32toh(pms->st_size), M_UDFMOUNT, M_NOWAIT | M_ZERO);
if (udfmp->s_table == NULL)
return (ENOMEM);
/* Calculate the number of sectors per packet. */
/* XXX Logical or physical? */
- udfmp->p_sectors = pms->packet_len / udfmp->bsize;
+ udfmp->p_sectors = le16toh(pms->packet_len) / udfmp->bsize;
/*
* XXX If reading the first Sparing Table fails, should look
* for another table.
*/
- if ((error = udf_readlblks(udfmp, pms->st_loc[0], pms->st_size,
- &bp)) != 0) {
+ if ((error = udf_readlblks(udfmp, le32toh(pms->st_loc[0]),
+ le32toh(pms->st_size), &bp)) != 0) {
if (bp != NULL)
brelse(bp);
printf("Failed to read Sparing Table at sector %d\n",
- pms->st_loc[0]);
+ le32toh(pms->st_loc[0]));
return (error);
}
- bcopy(bp->b_data, udfmp->s_table, pms->st_size);
+ bcopy(bp->b_data, udfmp->s_table, le32toh(pms->st_size));
brelse(bp);
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list