summaryrefslogtreecommitdiffstats
path: root/bsd_eth_drivers/libbsdport/bus.h
diff options
context:
space:
mode:
authorcvs2git <rtems-devel@rtems.org>2010-03-07 17:11:24 +0000
committercvs2git <rtems-devel@rtems.org>2010-03-07 17:11:24 +0000
commita9f34b79757de68cdd3f951077be0dd65da6354c (patch)
treef60c55f42307a08ebee35449d53e450e7f4a3321 /bsd_eth_drivers/libbsdport/bus.h
parent - importing updated version from SLAC as of 20090422 (diff)
downloadlibbsdport-a9f34b79757de68cdd3f951077be0dd65da6354c.tar.bz2
This commit was manufactured by cvs2svn to create tag 'R_20100307_p0'.R_20100307_p0
Sprout from base 2009-04-22 22:06:58 UTC Till Straumann <strauman@slac.stanford.edu> ' - importing updated version from SLAC as of 20090422' Cherrypick from master 2010-03-07 17:11:23 UTC Till Straumann <strauman@slac.stanford.edu> '2010-03-07 Till Straumann <Till.Straumann@TU-Berlin.de>': bsd_eth_drivers/.cvsignore bsd_eth_drivers/ChangeLog bsd_eth_drivers/Makefile.am bsd_eth_drivers/if_bge/.cvsignore bsd_eth_drivers/if_bge/Makefile.am bsd_eth_drivers/if_bge/if_bge.c bsd_eth_drivers/if_bge/if_bgereg.h bsd_eth_drivers/if_em/.cvsignore bsd_eth_drivers/if_em/Makefile.am bsd_eth_drivers/if_em/e1000_manage.c bsd_eth_drivers/if_em/e1000_manage.h bsd_eth_drivers/if_em/e1000_osdep.h bsd_eth_drivers/if_em/if_em.c bsd_eth_drivers/if_fxp/.cvsignore bsd_eth_drivers/if_fxp/Makefile.am bsd_eth_drivers/if_fxp/if_fxp.c bsd_eth_drivers/if_fxp/if_fxpvar.h bsd_eth_drivers/if_le/.cvsignore bsd_eth_drivers/if_pcn/.cvsignore bsd_eth_drivers/if_pcn/if_pcn.c bsd_eth_drivers/if_re/.cvsignore bsd_eth_drivers/if_re/Makefile.am bsd_eth_drivers/if_re/if_re.c bsd_eth_drivers/if_re/if_rl.c bsd_eth_drivers/if_re/if_rlreg.h bsd_eth_drivers/libbsdport/.cvsignore bsd_eth_drivers/libbsdport/Makefile.am bsd_eth_drivers/libbsdport/alldrv.c bsd_eth_drivers/libbsdport/bus.h bsd_eth_drivers/libbsdport/callout.h bsd_eth_drivers/libbsdport/devicet.c bsd_eth_drivers/libbsdport/ifmedia.c bsd_eth_drivers/libbsdport/libbsdport.h bsd_eth_drivers/libbsdport/libbsdport_api.h bsd_eth_drivers/libbsdport/libbsdport_post.h bsd_eth_drivers/libbsdport/miistuff.c bsd_eth_drivers/libbsdport/misc.c bsd_eth_drivers/libbsdport/mutex.h bsd_eth_drivers/libbsdport/rtems_callout.c bsd_eth_drivers/libbsdport/sysbus.c bsd_eth_drivers/libbsdport/taskqueue.h bsd_eth_drivers/links.am Cherrypick from freebsd_orig 2009-04-23 04:52:05 UTC Till Straumann <strauman@slac.stanford.edu> ' - importing original 'releng_7_1' version of FXP driver from FreeBSD.': bsd_eth_drivers/if_fxp/if_fxpreg.h bsd_eth_drivers/if_fxp/rcvbundl.h Delete: INSTALL Makefile.am bootstrap config.h.in configure.ac m4/acinclude.m4 m4/config-if-present.m4 m4/cvstag.m4 m4/multilib-fix.m4 m4/multilib-installdir.m4 m4/rtems-bsp-postlink.m4 m4/rtems-bsplist.m4 m4/rtems-check-libargs.m4 m4/rtems-checkprog.m4 m4/rtems-checktool.m4 m4/rtems-checktop.m4 m4/rtems-fixup-prefix.m4 m4/rtems-isml.m4 m4/rtems-ismultibsp.m4 m4/rtems-isrtems.m4 m4/rtems-makevars.m4 m4/rtems-multilib.m4 m4/rtems-options.m4 m4/rtems-setup-recurse.m4 m4/rtems-tools.m4 m4/rtems-trim-builddir.m4 m4/rtems-verscheck.m4 makefile.top.am makefile.top.in rtems-pre.am rtems.am ssrlApps.components.in
Diffstat (limited to 'bsd_eth_drivers/libbsdport/bus.h')
-rw-r--r--bsd_eth_drivers/libbsdport/bus.h121
1 files changed, 118 insertions, 3 deletions
diff --git a/bsd_eth_drivers/libbsdport/bus.h b/bsd_eth_drivers/libbsdport/bus.h
index 19cb24f..e4a9d29 100644
--- a/bsd_eth_drivers/libbsdport/bus.h
+++ b/bsd_eth_drivers/libbsdport/bus.h
@@ -17,6 +17,12 @@ typedef enum {
struct resource;
+struct resource_spec {
+ int type;
+ int rid;
+ int flags;
+};
+
typedef bus_addr_t bus_space_handle_t;
/* The 'bus_space_xxx()' inlines can be helped if the
@@ -59,7 +65,6 @@ bus_space_write_##nwidth(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
*(volatile type __attribute__((may_alias)) *)(h+o) = v; \
}\
}
-
BUS_SPACE_DECL(u_int32_t, long, 4)
BUS_SPACE_DECL(u_int16_t, word, 2)
BUS_SPACE_DECL(u_int8_t, byte, 1)
@@ -115,6 +120,8 @@ BUS_SPACE_DECL(u_int8_t, byte, 1, 8)
#error "Missing definitions of bus_space_XXX() for this CPU architecture"
#endif
+#define bus_space_write_stream_4(_t, _h, _o, _v) \
+ bus_space_write_4(_t, _h, _o, htole32(_v))
#undef BUS_SPACE_DECL
@@ -140,10 +147,17 @@ BUS_SPACE_DECL(u_int8_t, byte, 1, 8)
/* flags (1<<31) means unsupported */
#define RF_ACTIVE (1<<1)
#define RF_SHAREABLE (1<<2)
+#define RF_OPTIONAL (1<<3)
struct resource *
bus_alloc_resource_any(device_t dev, int type, int *prid, unsigned flags);
+int
+bus_alloc_resources(device_t dev, struct resource_spec *rs, struct resource **res);
+
+void
+bus_release_resources(device_t dev, const struct resource_spec *rs, struct resource **res);
+
#define FILTER_STRAY 1
#define FILTER_HANDLED 0
@@ -157,6 +171,29 @@ bus_setup_intr(device_t dev, struct resource *r, int flags, driver_filter_t filt
#define INTR_MPSAFE 0
#define INTR_TYPE_NET 0
+/*
+ * INTR_FAST handlers are already more like 'filters',
+ * i.e., they disable interrupts and schedule work
+ * on a task queue.
+ *
+ * During porting the fast handler has to be slightly
+ * rewritten (must return an int value, FILTER_HANDLED
+ * if a valid IRQ was detected and work has been scheduled
+ * and FILTER_STRAY if this device didn't interrupt).
+ *
+ * You need to then remove INTR_FAST from the flags,
+ * pass the converted handler as the 'filter' argument
+ * and a NULL handler argument to bus_setup_intr().
+ *
+ */
+extern int __INTR_FAST() __attribute__((
+ error("\n\n==> you need to convert bus_setup_intr(INTR_FAST) to new API;\n"
+ " consult <sys/bus.h>\n\n")
+));
+
+/* Barf at compile time if they try to use INTR_FAST */
+#define INTR_FAST (__INTR_FAST())
+
int
bus_teardown_intr(device_t dev, struct resource *r, void *cookiep);
@@ -177,6 +214,37 @@ rman_get_bushandle(struct resource *r);
bus_space_tag_t
rman_get_bustag(struct resource *r);
+/* Newer API (releng 7_1) */
+static inline u_int8_t bus_read_1(struct resource *r, bus_size_t o)
+{
+ return bus_space_read_1(rman_get_bustag(r), rman_get_bushandle(r), o);
+}
+
+static inline u_int16_t bus_read_2(struct resource *r, bus_size_t o)
+{
+ return bus_space_read_2(rman_get_bustag(r), rman_get_bushandle(r), o);
+}
+
+static inline u_int32_t bus_read_4(struct resource *r, bus_size_t o)
+{
+ return bus_space_read_4(rman_get_bustag(r), rman_get_bushandle(r), o);
+}
+
+static inline void bus_write_1(struct resource *r, bus_size_t o, u_int8_t v)
+{
+ bus_space_write_1(rman_get_bustag(r), rman_get_bushandle(r), o, v);
+}
+
+static inline void bus_write_2(struct resource *r, bus_size_t o, u_int16_t v)
+{
+ bus_space_write_2(rman_get_bustag(r), rman_get_bushandle(r), o, v);
+}
+
+static inline void bus_write_4(struct resource *r, bus_size_t o, u_int32_t v)
+{
+ bus_space_write_4(rman_get_bustag(r), rman_get_bushandle(r), o, v);
+}
+
#ifndef BUS_DMA_NOWAIT
/* ignored anyways */
#define BUS_DMA_NOWAIT 0
@@ -192,6 +260,20 @@ rman_get_bustag(struct resource *r);
#define BUS_DMA_COHERENT 0
#endif
+#ifndef BUS_DMA_ZERO
+/* ignored anyways */
+#define BUS_DMA_ZERO 0
+#endif
+
+#ifndef BUS_DMA_ALLOCNOW
+/* ignored anyways */
+#define BUS_DMA_ALLOCNOW 0
+#endif
+
+#ifndef BUS_DMA_ZERO
+#define BUS_DMA_ZERO 1
+#endif
+
/* unused */
#ifndef BUS_SPACE_MAXADDR
#define BUS_SPACE_MAXADDR 0xdeadbeef
@@ -223,6 +305,12 @@ typedef void *bus_dmamap_t;
int
bus_dma_tag_create(void *parent, unsigned alignment, unsigned bounds, uint32_t lowadd, uint32_t hiaddr, void (*filter)(void*), void *filterarg, unsigned maxsize, int nsegs, unsigned maxsegsize, unsigned flags, void (*lockfunc)(void*), void *lockarg, bus_dma_tag_t *ptag);
+/* Dummy NULL fcn pointer */
+#define busdma_lock_mutex 0
+
+extern uint32_t __busdma_dummy_Giant;
+#define Giant __busdma_dummy_Giant
+
void
bus_dma_tag_destroy(bus_dma_tag_t tag);
@@ -265,10 +353,10 @@ bus_get_dma_tag(device_t dev)
return 0;
}
-typedef void bus_dmamap_callback_t (void *, bus_dma_segment_t *, int, int);
+typedef void bus_dmamap_callback_t (void *arg, bus_dma_segment_t *segs, int nseg, int error);
static inline int
-bus_dmamap_load(bus_dma_tag_t tag, bus_dmamap_t map, caddr_t vaddr, bus_size_t size, void (*cb)(void *arg, bus_dma_segment_t *segs, int nseg, int error), void *arg, unsigned flags)
+bus_dmamap_load(bus_dma_tag_t tag, bus_dmamap_t map, void *vaddr, bus_size_t size, bus_dmamap_callback_t cb, void *arg, unsigned flags)
{
bus_dma_segment_t segs[1];
segs[0].ds_addr = CPU2BUSADDR(vaddr);
@@ -277,6 +365,28 @@ bus_dma_segment_t segs[1];
return 0;
}
+typedef void bus_dmamap_callback2_t (void *arg, bus_dma_segment_t *segs, int nsegs, bus_size_t mapsize, int error);
+
+static inline int
+bus_dmamap_load_mbuf(bus_dma_tag_t tag, bus_dmamap_t map, struct mbuf *m_head, bus_dmamap_callback2_t cb, void *arg, unsigned flags)
+{
+/* hopefully there's enough stack ... */
+bus_dma_segment_t segs[tag->maxsegs];
+struct mbuf *m;
+int n;
+bus_size_t sz;
+ for ( m=m_head, sz=0, n=0; m; m=m->m_next, n++ ) {
+ if ( n >= tag->maxsegs ) {
+ cb(arg, segs, n, sz, EFBIG);
+ return EFBIG;
+ }
+ segs[n].ds_addr = CPU2BUSADDR(mtod(m, unsigned));
+ sz += (segs[n].ds_len = m->m_len);
+ }
+ cb(arg, segs, n, sz, 0);
+ return 0;
+}
+
#define bus_dmamap_unload(tag, map) do {} while (0)
/* should we do something if we have no HW snooping ? */
@@ -285,4 +395,9 @@ bus_dma_segment_t segs[1];
#define bus_dmamap_create(tag, flags, pmap) ( *(pmap) = 0, 0 )
#define bus_dmamap_destroy(tag, map) do {} while (0)
+int
+resource_int_value(const char *name, int unit, const char *resname, int *result);
+int
+resource_long_value(const char *name, int unit, const char *resname, long *result);
+
#endif