diff --git a/sys/arch/hpcsh/conf/JORNADA690 b/sys/arch/hpcsh/conf/JORNADA690 index 23fade6fb486..96caa0f1c12b 100644 --- a/sys/arch/hpcsh/conf/JORNADA690 +++ b/sys/arch/hpcsh/conf/JORNADA690 @@ -1,4 +1,4 @@ -# $NetBSD: JORNADA690,v 1.6 2001/03/08 15:21:31 uch Exp $ +# $NetBSD: JORNADA690,v 1.7 2001/03/15 17:30:55 uch Exp $ # # JORNADA690 uch's Jornada 690 # @@ -85,6 +85,7 @@ scif0 at shb? port 0xa4000008 irq 12 hd64461if* at shb? irq 4 hd64461pcmcia* at hd64461if? +com* at hd64461if? # PCMCIA bus support pcmcia0 at hd64461pcmcia? controller 0 socket ? # I/O card, memory card diff --git a/sys/arch/hpcsh/conf/files.hpcsh b/sys/arch/hpcsh/conf/files.hpcsh index 0e244824a2ea..86b99ad69f5b 100644 --- a/sys/arch/hpcsh/conf/files.hpcsh +++ b/sys/arch/hpcsh/conf/files.hpcsh @@ -1,4 +1,4 @@ -# $NetBSD: files.hpcsh,v 1.8 2001/02/24 20:17:45 uch Exp $ +# $NetBSD: files.hpcsh,v 1.9 2001/03/15 17:30:55 uch Exp $ # maxpartitions 8 @@ -6,6 +6,7 @@ maxusers 2 16 64 file arch/hpcsh/hpcsh/conf.c file arch/hpcsh/hpcsh/machdep.c +file arch/hpcsh/hpcsh/console.c file arch/hpcsh/hpcsh/autoconf.c file arch/hpcsh/hpcsh/bus_space.c file arch/hpcsh/hpcsh/procfs_machdep.c procfs @@ -63,12 +64,15 @@ file arch/hpcsh/dev/pfckbd.c pfckbd needs-flag define hd64461if {} device hd64461if: hd64461if attach hd64461if at shb -file arch/hpcsh/dev/hd64461/hd64461.c hd64461if +file arch/hpcsh/dev/hd64461/hd64461.c hd64461if needs-flag device hd64461pcmcia: pcmciabus attach hd64461pcmcia at hd64461if file arch/hpcsh/dev/hd64461/hd64461pcmcia.c hd64461pcmcia +attach com at hd64461if with hd64461uart +file arch/hpcsh/dev/hd64461/hd64461uart.c hd64461uart + # network devices MII bus include "dev/mii/files.mii" diff --git a/sys/arch/hpcsh/dev/hd64461/hd64461pcmcia.c b/sys/arch/hpcsh/dev/hd64461/hd64461pcmcia.c index 4b4375f3c17b..7d55d298f561 100644 --- a/sys/arch/hpcsh/dev/hd64461/hd64461pcmcia.c +++ b/sys/arch/hpcsh/dev/hd64461/hd64461pcmcia.c @@ -1,4 +1,4 @@ -/* $NetBSD: hd64461pcmcia.c,v 1.2 2001/03/08 15:13:14 uch Exp $ */ +/* $NetBSD: hd64461pcmcia.c,v 1.3 2001/03/15 17:30:55 uch Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -233,6 +233,18 @@ static void set_bus_width(enum controller_channel, int); #ifdef DEBUG static void hd64461pcmcia_info(struct hd64461pcmcia_softc *); #endif +/* fix SH3 Area[56] bug */ +static void fixup_sh3_pcmcia_area(bus_space_tag_t); +#define _BUS_SPACE_ACCESS_HOOK() \ +{ \ + u_int8_t dummy __attribute__((__unused__)) = \ + *(volatile u_int8_t *)0xba000000; \ +} +_BUS_SPACE_WRITE(_sh3_pcmcia_bug, 1, 8) +_BUS_SPACE_WRITE_MULTI(_sh3_pcmcia_bug, 1, 8) +_BUS_SPACE_WRITE_REGION(_sh3_pcmcia_bug, 1, 8) +_BUS_SPACE_SET_MULTI(_sh3_pcmcia_bug, 1, 8) +#undef _BUS_SPACE_ACCESS_HOOK #define DELAY_MS(x) delay((x) * 1000) @@ -364,18 +376,21 @@ hd64461pcmcia_attach_channel(struct hd64461pcmcia_softc *sc, /* Attibute/Common memory extent */ membase = (channel == CHANNEL_0) ? HD64461_PCC0_MEMBASE : HD64461_PCC1_MEMBASE; - ch->ch_memt = bus_space_create("PCMCIA attribute memory", + + ch->ch_memt = bus_space_create(0, "PCMCIA attribute memory", membase, 0x01000000); /* 16MB */ - bus_space_alloc(ch->ch_memt, 0, 0x01000000, 0x01000000, + bus_space_alloc(ch->ch_memt, 0, 0x00ffffff, 0x01000000, 0x01000000, 0x01000000, 0, &ch->ch_membase_addr, &ch->ch_memh); + fixup_sh3_pcmcia_area(ch->ch_memt); /* Common memory space extent */ ch->ch_memsize = 0x01000000; for (i = 0; i < MEMWIN_16M_MAX; i++) { - ch->ch_cmemt[i] = bus_space_create("PCMCIA common memory", + ch->ch_cmemt[i] = bus_space_create(0, "PCMCIA common memory", membase + 0x01000000, ch->ch_memsize); + fixup_sh3_pcmcia_area(ch->ch_cmemt[i]); } /* I/O port extent and interrupt staff */ @@ -384,10 +399,10 @@ hd64461pcmcia_attach_channel(struct hd64461pcmcia_softc *sc, if (channel == CHANNEL_0) { ch->ch_iobase = 0; ch->ch_iosize = HD64461_PCC0_IOSIZE; - ch->ch_iot = bus_space_create("PCMCIA I/O port", + ch->ch_iot = bus_space_create(0, "PCMCIA I/O port", HD64461_PCC0_IOBASE, ch->ch_iosize); - + fixup_sh3_pcmcia_area(ch->ch_iot); hd64461_intr_establish(HD64461_IRQ_PCC0, IST_LEVEL, IPL_TTY, hd64461pcmcia_channel0_intr, ch); @@ -615,7 +630,7 @@ _chip_mem_map(pcmcia_chipset_handle_t pch, int kind, bus_addr_t card_addr, &cookie->wc_handle) != 0) goto bad; - // XXX bogus. bus_space_tag should be vtbl... + // XXX bogus. check window per common memory access. memory_window_16(ch->ch_channel, window); *offsetp = ofs + 0x01000000; /* skip attribute area */ cookie->wc_window = window; @@ -664,7 +679,7 @@ _chip_io_alloc(pcmcia_chipset_handle_t pch, bus_addr_t start, bus_size_t size, DPRINTF("map %#lx+%#lx\n", start, size); } else { if (bus_space_alloc(ch->ch_iot, ch->ch_iobase, - ch->ch_iobase + ch->ch_iosize, + ch->ch_iobase + ch->ch_iosize - 1, size, align, 0, 0, &pcihp->addr, &pcihp->ioh)) { DPRINTF("couldn't allocate %#lx\n", size); @@ -1026,6 +1041,17 @@ set_bus_width(enum controller_channel channel, int width) SHREG_BCR2 = r16; } +static void +fixup_sh3_pcmcia_area(bus_space_tag_t t) +{ + struct hpcsh_bus_space *hbs = (void *)t; + + hbs->hbs_w_1 = _sh3_pcmcia_bug_write_1; + hbs->hbs_wm_1 = _sh3_pcmcia_bug_write_multi_1; + hbs->hbs_wr_1 = _sh3_pcmcia_bug_write_region_1; + hbs->hbs_sm_1 = _sh3_pcmcia_bug_set_multi_1; +} + #ifdef DEBUG static void hd64461pcmcia_info(struct hd64461pcmcia_softc *sc) @@ -1207,4 +1233,3 @@ hd64461pcmcia_info(struct hd64461pcmcia_softc *sc) dbg_banner_end(); } #endif /* DEBUG */ - diff --git a/sys/arch/hpcsh/dev/hd64461/hd64461uart.c b/sys/arch/hpcsh/dev/hd64461/hd64461uart.c new file mode 100644 index 000000000000..b11873f75da7 --- /dev/null +++ b/sys/arch/hpcsh/dev/hd64461/hd64461uart.c @@ -0,0 +1,228 @@ +/* $NetBSD: hd64461uart.c,v 1.1 2001/03/15 17:30:56 uch Exp $ */ + +/*- + * Copyright (c) 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include +#include + +#ifdef DEBUG +#include +#endif + +#include +#include +#include + +#include + +static struct hd64461uart_chip { + struct hpcsh_bus_space __tag_body; + bus_space_tag_t io_tag; + int console; +} hd64461uart_chip; + +struct hd64461uart_softc { + struct com_softc sc_com; + + struct hd64461uart_chip *sc_chip; + enum hd64461_module_id sc_module_id; +}; + +/* boot console */ +cdev_decl(com); +void comcnprobe(struct consdev *); +void comcninit(struct consdev *); + +static int hd64461uart_match(struct device *, struct cfdata *, void *); +static void hd64461uart_attach(struct device *, struct device *, void *); + +struct cfattach hd64461uart_ca = { + sizeof(struct hd64461uart_softc), hd64461uart_match, + hd64461uart_attach +}; + +static void hd64461uart_init(void); +static u_int8_t hd64461uart_read_1(void *, bus_space_handle_t, bus_size_t); +static void hd64461uart_write_1(void *, bus_space_handle_t, bus_size_t, + u_int8_t); + +#ifdef DEBUG +static void hd64461uart_info(struct hd64461uart_softc *); +#endif + +#define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */ +#ifndef COMCN_SPEED +#define COMCN_SPEED 19200 +#endif + +void +hd64461uart_cnattach() +{ + hd64461uart_init(); + + comcnattach(hd64461uart_chip.io_tag, 0x0, COMCN_SPEED, COM_FREQ, + CONMODE); +} + +void +comcnprobe(struct consdev *cp) +{ + int maj; + + /* locate the major number */ + for (maj = 0; maj < nchrdev; maj++) + if (cdevsw[maj].d_open == comopen) + break; + + /* Initialize required fields. */ + cp->cn_dev = makedev(maj, 0); + cp->cn_pri = CN_NORMAL; +} + +void +comcninit(struct consdev *cp) +{ + hd64461uart_chip.console = 1; +} + +static int +hd64461uart_match(struct device *parent, struct cfdata *cf, void *aux) +{ + struct hd64461_attach_args *ha = aux; + + return (ha->ha_module_id == HD64461_MODULE_UART); +} + +static void +hd64461uart_attach(struct device *parent, struct device *self, void *aux) +{ + struct hd64461_attach_args *ha = aux; + struct hd64461uart_softc *sc = (struct hd64461uart_softc *)self; + struct com_softc *csc = &sc->sc_com; + u_int16_t r16; + + sc->sc_chip = &hd64461uart_chip; + if (sc->sc_chip->console) + printf(": console\n"); + + sc->sc_module_id = ha->ha_module_id; + + hd64461uart_init(); + + csc->sc_iot = sc->sc_chip->io_tag; + bus_space_map(csc->sc_iot, 0, 8, 0, &csc->sc_ioh); + csc->sc_iobase = 0; + csc->sc_frequency = COM_FREQ; + + /* switch port to UART */ + + /* supply clock */ + r16 = hd64461_reg_read_2(HD64461_SYSSTBCR_REG16); + r16 &= ~HD64461_SYSSTBCR_SURTSD; + hd64461_reg_write_2(HD64461_SYSSTBCR_REG16, r16); + +#ifdef DEBUG + if (bootverbose) + hd64461uart_info(sc); +#endif + /* sanity check */ + if (!comprobe1(csc->sc_iot, csc->sc_ioh)) { + printf(": device problem. don't attach.\n"); + + /* stop clock */ + r16 |= HD64461_SYSSTBCR_SURTSD; + hd64461_reg_write_2(HD64461_SYSSTBCR_REG16, r16); + return; + } + printf("\n"); + + com_attach_subr(csc); + + hd64461_intr_establish(HD64461_IRQ_UART, IST_LEVEL, IPL_TTY, + comintr, self); + +} + +static void +hd64461uart_init() +{ + if (hd64461uart_chip.io_tag) + return; + + hd64461uart_chip.io_tag = bus_space_create( + &hd64461uart_chip.__tag_body, "HD64461 UART I/O", + HD64461_UART_REGBASE, 0); /* no extent */ + + /* override bus_space_read_1, bus_space_write_1 */ + hd64461uart_chip.io_tag->hbs_r_1 = hd64461uart_read_1; + hd64461uart_chip.io_tag->hbs_w_1 = hd64461uart_write_1; +} + +static u_int8_t +hd64461uart_read_1(void *t, bus_space_handle_t h, bus_size_t ofs) +{ + return *(volatile u_int8_t *)(h + (ofs << 1)); +} + +static void +hd64461uart_write_1(void *t, bus_space_handle_t h, bus_size_t ofs, + u_int8_t val) +{ + + *(volatile u_int8_t *)(h + (ofs << 1)) = val; +} + +#ifdef DEBUG +static void +hd64461uart_info(struct hd64461uart_softc *sc) +{ + const char name[] = __FUNCTION__; + + dbg_banner_start(name, sizeof name); + dbg_banner_end(); +} +#endif /* DEBUG */ diff --git a/sys/arch/hpcsh/dev/hd64461/hd64461uartvar.h b/sys/arch/hpcsh/dev/hd64461/hd64461uartvar.h new file mode 100644 index 000000000000..66bde39dcd11 --- /dev/null +++ b/sys/arch/hpcsh/dev/hd64461/hd64461uartvar.h @@ -0,0 +1,39 @@ +/* $NetBSD: hd64461uartvar.h,v 1.1 2001/03/15 17:30:56 uch Exp $ */ + +/*- + * Copyright (c) 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by UCHIYAMA Yasushi. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +void hd64461uart_cnattach(void); diff --git a/sys/arch/hpcsh/hpcsh/bus_space.c b/sys/arch/hpcsh/hpcsh/bus_space.c index 10c946915fdd..9db707ba57f3 100644 --- a/sys/arch/hpcsh/hpcsh/bus_space.c +++ b/sys/arch/hpcsh/hpcsh/bus_space.c @@ -1,4 +1,4 @@ -/* $NetBSD: bus_space.c,v 1.2 2001/02/21 16:28:03 uch Exp $ */ +/* $NetBSD: bus_space.c,v 1.3 2001/03/15 17:30:56 uch Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -33,6 +33,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include @@ -43,137 +44,254 @@ #include #ifdef BUS_SPACE_DEBUG -#define DPRINTF(arg) printf arg +int bus_space_debug = 0; +#define DPRINTF(fmt, args...) \ + if (bus_space_debug) \ + printf("%s: " fmt, __FUNCTION__ , ##args) +#define DPRINTFN(n, arg) \ + if (bus_space_debug > (n)) \ + printf("%s: " fmt, __FUNCTION__ , ##args) #else -#define DPRINTF(arg) +#define DPRINTF(arg...) ((void)0) +#define DPRINTFN(n, arg...) ((void)0) #endif -#define BUS_SPACE_TAG_MAX 16 +#define _BUS_SPACE_ACCESS_HOOK() ((void)0) +_BUS_SPACE_READ(_bus_space, 1, 8) +_BUS_SPACE_READ(_bus_space, 2, 16) +_BUS_SPACE_READ(_bus_space, 4, 32) +_BUS_SPACE_READ(_bus_space, 8, 64) +_BUS_SPACE_READ_MULTI(_bus_space, 1, 8) +_BUS_SPACE_READ_MULTI(_bus_space, 2, 16) +_BUS_SPACE_READ_MULTI(_bus_space, 4, 32) +_BUS_SPACE_READ_MULTI(_bus_space, 8, 64) +_BUS_SPACE_READ_REGION(_bus_space, 1, 8) +_BUS_SPACE_READ_REGION(_bus_space, 2, 16) +_BUS_SPACE_READ_REGION(_bus_space, 4, 32) +_BUS_SPACE_READ_REGION(_bus_space, 8, 64) +_BUS_SPACE_WRITE(_bus_space, 1, 8) +_BUS_SPACE_WRITE(_bus_space, 2, 16) +_BUS_SPACE_WRITE(_bus_space, 4, 32) +_BUS_SPACE_WRITE(_bus_space, 8, 64) +_BUS_SPACE_WRITE_MULTI(_bus_space, 1, 8) +_BUS_SPACE_WRITE_MULTI(_bus_space, 2, 16) +_BUS_SPACE_WRITE_MULTI(_bus_space, 4, 32) +_BUS_SPACE_WRITE_MULTI(_bus_space, 8, 64) +_BUS_SPACE_WRITE_REGION(_bus_space, 1, 8) +_BUS_SPACE_WRITE_REGION(_bus_space, 2, 16) +_BUS_SPACE_WRITE_REGION(_bus_space, 4, 32) +_BUS_SPACE_WRITE_REGION(_bus_space, 8, 64) +_BUS_SPACE_SET_MULTI(_bus_space, 1, 8) +_BUS_SPACE_SET_MULTI(_bus_space, 2, 16) +_BUS_SPACE_SET_MULTI(_bus_space, 4, 32) +_BUS_SPACE_SET_MULTI(_bus_space, 8, 64) +_BUS_SPACE_COPY_REGION(_bus_space, 1, 8) +_BUS_SPACE_COPY_REGION(_bus_space, 2, 16) +_BUS_SPACE_COPY_REGION(_bus_space, 4, 32) +_BUS_SPACE_COPY_REGION(_bus_space, 8, 64) +#undef _BUS_SPACE_ACCESS_HOOK -static struct bus_space { - vaddr_t t_base; /* extent base */ - vsize_t t_size; /* extent size */ - struct extent *t_extent; -} bus_space[BUS_SPACE_TAG_MAX]; -static int bus_space_cnt; +static int _bus_space_map(void *, bus_addr_t, bus_size_t, int, + bus_space_handle_t *); +static void _bus_space_unmap(void *, bus_space_handle_t, bus_size_t); +static int _bus_space_subregion(void *, bus_space_handle_t, bus_size_t, + bus_size_t, bus_space_handle_t *); +static int _bus_space_alloc(void *, bus_addr_t, bus_addr_t, bus_size_t, + bus_size_t, bus_size_t, int, + bus_addr_t *, bus_space_handle_t *); +static void _bus_space_free(void *, bus_space_handle_t, bus_size_t); +static void *_bus_space_vaddr(void *, bus_space_handle_t); -#define CONTEXT_REF(x, t) struct bus_space *x = (struct bus_space *)(t) -#define ANONYMOUS(x) (x == BUS_SPACE_TAG_ANONYMOUS) +static struct hpcsh_bus_space __default_bus_space = { + hbs_extent : 0, + hbs_map : _bus_space_map, + hbs_unmap : _bus_space_unmap, + hbs_subregion : _bus_space_subregion, + hbs_alloc : _bus_space_alloc, + hbs_free : _bus_space_free, + hbs_vaddr : _bus_space_vaddr, + hbs_r_1 : _bus_space_read_1, + hbs_r_2 : _bus_space_read_2, + hbs_r_4 : _bus_space_read_4, + hbs_r_8 : _bus_space_read_8, + hbs_rm_1 : _bus_space_read_multi_1, + hbs_rm_2 : _bus_space_read_multi_2, + hbs_rm_4 : _bus_space_read_multi_4, + hbs_rm_8 : _bus_space_read_multi_8, + hbs_rr_1 : _bus_space_read_region_1, + hbs_rr_2 : _bus_space_read_region_2, + hbs_rr_4 : _bus_space_read_region_4, + hbs_rr_8 : _bus_space_read_region_8, + hbs_w_1 : _bus_space_write_1, + hbs_w_2 : _bus_space_write_2, + hbs_w_4 : _bus_space_write_4, + hbs_w_8 : _bus_space_write_8, + hbs_wm_1 : _bus_space_write_multi_1, + hbs_wm_2 : _bus_space_write_multi_2, + hbs_wm_4 : _bus_space_write_multi_4, + hbs_wm_8 : _bus_space_write_multi_8, + hbs_wr_1 : _bus_space_write_region_1, + hbs_wr_2 : _bus_space_write_region_2, + hbs_wr_4 : _bus_space_write_region_4, + hbs_wr_8 : _bus_space_write_region_8, + hbs_sm_1 : _bus_space_set_multi_1, + hbs_sm_2 : _bus_space_set_multi_2, + hbs_sm_4 : _bus_space_set_multi_4, + hbs_sm_8 : _bus_space_set_multi_8, + hbs_c_1 : _bus_space_copy_region_1, + hbs_c_2 : _bus_space_copy_region_2, + hbs_c_4 : _bus_space_copy_region_4, + hbs_c_8 : _bus_space_copy_region_8 +}; +/* create default bus_space_tag */ bus_space_tag_t -bus_space_create(const char *name, bus_addr_t addr, bus_size_t size) +bus_space_create(struct hpcsh_bus_space *hbs, const char *name, + bus_addr_t addr, bus_size_t size) { - struct bus_space *t; + if (hbs == 0) + hbs = malloc(sizeof(*hbs), M_DEVBUF, M_NOWAIT); + KASSERT(hbs); - KASSERT(bus_space_cnt < BUS_SPACE_TAG_MAX); + memset(hbs, 0, sizeof(*hbs)); - t = &bus_space[bus_space_cnt++]; - t->t_base = addr; - t->t_size = size; - t->t_extent = extent_create(name, t->t_base, t->t_base + t->t_size, - M_DEVBUF, 0, 0, EX_NOWAIT); + /* set default method */ + *hbs = __default_bus_space; + hbs->hbs_cookie = hbs; - if (!t->t_extent) { - panic("bus_space_create: unable to create bus_space for" - " 0x%08x-%#x\n", (unsigned)addr, (unsigned)size); + /* set access region */ + if (size == 0) { + hbs->hbs_base_addr = addr; /* no extent */ + } else { + hbs->hbs_extent = extent_create(name, addr, addr + size - 1, + M_DEVBUF, 0, 0, EX_NOWAIT); + if (hbs->hbs_extent == 0) { + panic("%s:: unable to create bus_space for " + "0x%08lx-%#lx\n", __FUNCTION__, addr, size); + } } - return (bus_space_tag_t)t; + return hbs; } -int -bus_space_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, int flags, - bus_space_handle_t *bshp) +void +bus_space_destroy(bus_space_tag_t t) { - int error; - CONTEXT_REF(_t, t); + struct hpcsh_bus_space *hbs = t; + struct extent *ex = hbs->hbs_extent; - if (ANONYMOUS(_t)) { - *bshp = (bus_space_handle_t)bpa; + if (ex != 0) + extent_destroy(ex); + + free(t, M_DEVBUF); +} + +/* default bus_space tag */ +static int +_bus_space_map(void *t, bus_addr_t bpa, bus_size_t size, int flags, + bus_space_handle_t *bshp) +{ + struct hpcsh_bus_space *hbs = t; + struct extent *ex = hbs->hbs_extent; + int error; + + if (ex == 0) { + *bshp = (bus_space_handle_t)(bpa + hbs->hbs_base_addr); return (0); } - bpa += _t->t_base; - error = extent_alloc_region(_t->t_extent, bpa, size, - EX_NOWAIT | EX_MALLOCOK); - if (error) + bpa += ex->ex_start; + error = extent_alloc_region(ex, bpa, size, EX_NOWAIT | EX_MALLOCOK); + + if (error) { + DPRINTF("failed.\n"); return (error); + } *bshp = (bus_space_handle_t)bpa; - DPRINTF(("\tbus_space_map:%#x(%#x)+%#x\n", bpa, - bpa - t->t_base, size)); + DPRINTF("success.\n"); return (0); } -int -bus_space_subregion(bus_space_tag_t t, bus_space_handle_t bsh, - bus_size_t offset, bus_size_t size, - bus_space_handle_t *nbshp) +static int +_bus_space_subregion(void *t, bus_space_handle_t bsh, + bus_size_t offset, bus_size_t size, + bus_space_handle_t *nbshp) { *nbshp = bsh + offset; return (0); } -int -bus_space_alloc(bus_space_tag_t t, bus_addr_t rstart, bus_addr_t rend, - bus_size_t size, bus_size_t alignment, bus_size_t boundary, - int flags, bus_addr_t *bpap, bus_space_handle_t *bshp) +static int +_bus_space_alloc(void *t, bus_addr_t rstart, bus_addr_t rend, + bus_size_t size, bus_size_t alignment, bus_size_t boundary, + int flags, bus_addr_t *bpap, bus_space_handle_t *bshp) { - u_long bpa; + struct hpcsh_bus_space *hbs = t; + struct extent *ex = hbs->hbs_extent; + u_long bpa, base; int error; - CONTEXT_REF(_t, t); - if (ANONYMOUS(_t)) { - *bshp = *bpap = rstart; + if (ex == 0) { + *bshp = *bpap = rstart + hbs->hbs_base_addr; return (0); } - rstart += _t->t_base; - rend += _t->t_base; - error = extent_alloc_subregion(_t->t_extent, rstart, rend, size, + base = ex->ex_start; + + error = extent_alloc_subregion(ex, rstart + base, rend + base, size, alignment, boundary, EX_FAST | EX_NOWAIT | EX_MALLOCOK, &bpa); - if (error) + + if (error) { + DPRINTF("failed.\n"); return (error); + } *bshp = (bus_space_handle_t)bpa; if (bpap) *bpap = bpa; - DPRINTF(("\tbus_space_alloc:%#x(%#x)+%#x\n", (unsigned)bpa, - (unsigned)(bpa - t->t_base), size)); + DPRINTF("success.\n"); return (0); } -void -bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size) +static void +_bus_space_free(void *t, bus_space_handle_t bsh, bus_size_t size) { - CONTEXT_REF(_t, t); + struct hpcsh_bus_space *hbs = t; + struct extent *ex = hbs->hbs_extent; - if (!ANONYMOUS(_t)) { - bus_space_unmap(t, bsh, size); - } + if (ex != 0) + _bus_space_unmap(t, bsh, size); } -void -bus_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size) +static void +_bus_space_unmap(void *t, bus_space_handle_t bsh, bus_size_t size) { + struct hpcsh_bus_space *hbs = t; + struct extent *ex = hbs->hbs_extent; int error; - CONTEXT_REF(_t, t); - if (ANONYMOUS(_t)) + if (ex == 0) return; - error = extent_free(_t->t_extent, bsh, size, EX_NOWAIT); + error = extent_free(ex, bsh, size, EX_NOWAIT); if (error) { - DPRINTF(("warning: %#x-%#x of %s space lost\n", - bsh, bsh+size, t->t_name)); + DPRINTF("%#lx-%#lx of %s space lost\n", bsh, bsh + size, + ex->ex_name); } } + +void * +_bus_space_vaddr(void *t, bus_space_handle_t h) +{ + return (void *)h; +} diff --git a/sys/arch/hpcsh/hpcsh/conf.c b/sys/arch/hpcsh/hpcsh/conf.c index c94ff4bf7b76..4f7a9ddd7d5f 100644 --- a/sys/arch/hpcsh/hpcsh/conf.c +++ b/sys/arch/hpcsh/hpcsh/conf.c @@ -1,4 +1,4 @@ -/* $NetBSD: conf.c,v 1.3 2001/02/09 19:54:11 uch Exp $ */ +/* $NetBSD: conf.c,v 1.4 2001/03/15 17:30:56 uch Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -136,6 +136,8 @@ cons_decl(com); cdev_decl(sci); #include "scif.h" cdev_decl(scif); +#include "com.h" +cdev_decl(com); #include "biconsdev.h" cdev_decl(biconsdev); @@ -166,7 +168,7 @@ struct cdevsw cdevsw[] = cdev_log_init(1,log), /* 5: /dev/klog */ cdev_ptc_init(NPTY,ptc), /* 6: pseudo-tty master */ cdev_tty_init(NPTY,pts), /* 7: pseudo-tty slave */ - cdev_notdef(), /* 8: (reserved) NS16550 compatible */ + cdev_tty_init(NCOM,com), /* 8: NS16550 compatible */ cdev_notdef(), /* 9: (reserved) parallel printer*/ cdev_disk_init(NWD, wd), /* 10: ST506/ESDI/IDE disk */ cdev_notdef(), /* 11: (reserved) floppy diskette */ @@ -244,22 +246,6 @@ static int chrtoblktbl[] = { /* 40 */ NODEV, }; -struct consdev constab[] = { -#if NBICONSDEV > 0 - cons_init(bicons), -#endif -#if NSCI > 0 - cons_init(sci), -#endif -#if NSCIF > 0 - cons_init(scif), -#endif -#if NCOM > 0 - cons_init(com), -#endif - { 0 }, -}; - /* * Swapdev is a fake block device implemented in sw.c and only used * internally to get to swstrategy. It cannot be provided to the diff --git a/sys/arch/hpcsh/hpcsh/console.c b/sys/arch/hpcsh/hpcsh/console.c new file mode 100644 index 000000000000..6f0623f161b4 --- /dev/null +++ b/sys/arch/hpcsh/hpcsh/console.c @@ -0,0 +1,170 @@ +/* $NetBSD: console.c,v 1.1 2001/03/15 17:30:56 uch Exp $ */ + +/*- + * Copyright (c) 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by UCHIYAMA Yasushi. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "biconsdev.h" +#include "hpcfb.h" +#include "pfckbd.h" +#include "sci.h" +#include "scif.h" +#include "com.h" +#include "hd64461if.h" + +#include +#include +#include /* cdev_decl */ +#include /* consdev */ +#include + +#include + +#if NBICONSDEV > 0 +#include +#include +#define DPRINTF(arg) printf arg +#else +#define DPRINTF(arg) +#endif + +#if NHPCFB > 0 +#include +#include +#include +#endif +#if NPFCKBD > 0 +#include +#endif + +#if NHD64461IF > 0 && NCOM > 0 +#include +#endif + +/* serial console */ +#define scicnpollc nullcnpollc +cdev_decl(sci); +cons_decl(sci); +#define scifcnpollc nullcnpollc +cdev_decl(scif); +cons_decl(scif); +cdev_decl(com); +cons_decl(com); + +/* builtin video console */ +#define biconscnpollc nullcnpollc +cdev_decl(biconsdev); +cons_decl(bicons); + +struct consdev constab[] = { +#if NBICONSDEV > 0 + cons_init(bicons), +#endif +#if NSCI > 0 + cons_init(sci), +#endif +#if NSCIF > 0 + cons_init(scif), +#endif +#if NCOM > 0 + cons_init(com), +#endif + { 0 } /* terminator */ +}; +#define CN_SELECTED (CN_REMOTE + 1) /* highest priority */ + +static int initialized; + +static void +set_console(void (*probe_func)(struct consdev *)) +{ + struct consdev *cp; + + for (cp = constab; cp->cn_probe; cp++) { + if (cp->cn_probe == probe_func) { + cp->cn_pri = CN_SELECTED; + initialized = 1; + break; + } + } +} + +void +consinit() +{ + struct consdev *cp; + + if (initialized) + return; + + /* select console */ + for (cp = constab; cp->cn_probe; cp++) + cp->cn_pri = CN_DEAD; + + switch (bootinfo->bi_cnuse) { + case BI_CNUSE_BUILTIN: +#if NBICONSDEV > 0 + set_console(biconscnprobe); +#endif + break; + case BI_CNUSE_SCI: +#if NSCI > 0 + set_console(scicnprobe); +#endif + break; + case BI_CNUSE_SCIF: +#if NSCIF > 0 + set_console(scifcnprobe); +#endif + break; + case BI_CNUSE_HD64461COM: +#if NHD64461IF > 0 && NCOM > 0 + set_console(comcnprobe); +#endif + break; + } + + if (initialized) + cninit(); + + if (bootinfo->bi_cnuse == BI_CNUSE_BUILTIN) { +#if NPFCKBD > 0 + pfckbd_cnattach(); +#endif +#if NHPCFB > 0 + hpcfb_cnattach(0); +#endif + } +} diff --git a/sys/arch/hpcsh/hpcsh/machdep.c b/sys/arch/hpcsh/hpcsh/machdep.c index 100cdbc43443..50f0622e8a62 100644 --- a/sys/arch/hpcsh/hpcsh/machdep.c +++ b/sys/arch/hpcsh/hpcsh/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.5 2001/02/24 20:17:45 uch Exp $ */ +/* $NetBSD: machdep.c,v 1.6 2001/03/15 17:30:56 uch Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -32,14 +32,12 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ - +#undef LOAD_ALL_MEMORY #include "opt_ddb.h" #include "opt_syscall_debug.h" #include "fs_mfs.h" #include "fs_nfs.h" #include "biconsdev.h" -#include "hpcfb.h" -#include "pfckbd.h" #include #include @@ -48,15 +46,14 @@ #include #include #include - #include - #include +#include -#include #include /* mfs_initminiroot() */ -#include +#include /* consdev */ + #include #include #include @@ -65,22 +62,11 @@ #include #if NBICONSDEV > 0 -#include -#include #define DPRINTF(arg) printf arg #else #define DPRINTF(arg) #endif -#if NHPCFB > 0 -#include -#include -#include -#endif -#if NPFCKBD > 0 -#include -#endif - /* * D-RAM location (Windows CE machine specific) * @@ -160,10 +146,7 @@ phys_ram_seg_t mem_clusters[VM_PHYSSEG_MAX]; int physmem; /* in hpcsh port, page unit */ /* Console */ -#include /* cdev_decl */ -#include /* consdev */ -#define scicnpollc nullcnpollc -#define scifcnpollc nullcnpollc +extern void consinit(void); void main(void); void machine_startup(int, char *[], struct bootinfo *); @@ -201,12 +184,9 @@ machine_startup(int argc, char *argv[], struct bootinfo *bi) /* setup bootstrap options */ makebootdev("wd0"); /* default boot device */ boothowto = 0; - for (i = 1; i < argc; i++) { // skip 1st arg (kernel name). + for (i = 1; i < argc; i++) { /* skip 1st arg (kernel name). */ char *cp = argv[i]; switch (*cp) { - case 'h': - bootinfo->bi_cnuse |= BI_CNUSE_SERIAL; - break; case 'b': /* boot device: -b=sd0 etc. */ p = cp + 2; @@ -224,6 +204,7 @@ machine_startup(int argc, char *argv[], struct bootinfo *bi) break; } } + #ifdef MFS /* * Check to see if a mini-root was loaded into memory. It resides @@ -440,7 +421,7 @@ haltsys: doshutdownhooks(); /* Finally, halt/reboot the system. */ - DPRINTF(("%s\n\n", howto & RB_HALT ? "halted." : "rebooting...")); + printf("%s\n\n", howto & RB_HALT ? "halted." : "rebooting..."); goto *(u_int32_t *)0xa0000000; while (1) @@ -482,7 +463,7 @@ mem_cluster_init(paddr_t addr) /* search CS3 */ __find_dram_shadow(addr, DRAM_BANK0_END); -#if notyet //XXX bank 0 only +#ifdef LOAD_ALL_MEMORY /* notyet */ __find_dram_shadow(DRAM_BANK1_START, DRAM_BANK1_END); #endif DPRINTF(("mem_cluster_cnt = %d\n", mem_cluster_cnt)); @@ -515,7 +496,7 @@ mem_cluster_load() { paddr_t start, end; psize_t size; -#if notyet +#ifdef LOAD_ALL_MEMORY /* notyet */ int i; /* Cluster 0 is always the kernel, which doesn't get loaded. */ @@ -625,26 +606,3 @@ __find_dram_shadow(paddr_t start, paddr_t end) mem_cluster_cnt++; } - -void -consinit() -{ - static int initted; - - if (initted) - return; - initted = 1; -#if NBICONSDEV > 0 - if (!(bootinfo->bi_cnuse & BI_CNUSE_SERIAL)) - bicons_set_priority(CN_REMOTE + 1); /* set highest */ -#endif - cninit(); - if (!(bootinfo->bi_cnuse & BI_CNUSE_SERIAL)) { -#if NPFCKBD > 0 - pfckbd_cnattach(); -#endif -#if NHPCFB > 0 - hpcfb_cnattach(0); -#endif - } -} diff --git a/sys/arch/hpcsh/hpcsh/shb.c b/sys/arch/hpcsh/hpcsh/shb.c index 001628b4ccd9..243ff55a6465 100644 --- a/sys/arch/hpcsh/hpcsh/shb.c +++ b/sys/arch/hpcsh/hpcsh/shb.c @@ -1,4 +1,4 @@ -/* $NetBSD: shb.c,v 1.3 2001/02/24 20:17:45 uch Exp $ */ +/* $NetBSD: shb.c,v 1.4 2001/03/15 17:30:56 uch Exp $ */ /*- * Copyright (c) 1993, 1994 Charles Hannum. All rights reserved. @@ -97,8 +97,8 @@ shbattach(parent, self, aux) printf("\n"); - sc->sc_iot = BUS_SPACE_TAG_ANONYMOUS; - sc->sc_memt = BUS_SPACE_TAG_ANONYMOUS; + sc->sc_iot = 0; + sc->sc_memt = 0; TAILQ_INIT(&sc->sc_subdevs); config_search(shbsearch, self, NULL); diff --git a/sys/arch/hpcsh/include/bootinfo.h b/sys/arch/hpcsh/include/bootinfo.h index fcc949312dbf..2aee8d9b8018 100644 --- a/sys/arch/hpcsh/include/bootinfo.h +++ b/sys/arch/hpcsh/include/bootinfo.h @@ -1,3 +1,8 @@ -/* $NetBSD: bootinfo.h,v 1.3 2001/02/07 15:29:22 uch Exp $ */ +/* $NetBSD: bootinfo.h,v 1.4 2001/03/15 17:30:56 uch Exp $ */ #include + +/* hpcsh specific goo */ +#define BI_CNUSE_SCI 2 +#define BI_CNUSE_SCIF 3 +#define BI_CNUSE_HD64461COM 4 diff --git a/sys/arch/hpcsh/include/bus.h b/sys/arch/hpcsh/include/bus.h index 6c29eab66a8a..e63897c6067f 100644 --- a/sys/arch/hpcsh/include/bus.h +++ b/sys/arch/hpcsh/include/bus.h @@ -1,7 +1,7 @@ -/* $NetBSD: bus.h,v 1.3 2001/02/21 16:28:03 uch Exp $ */ +/* $NetBSD: bus.h,v 1.4 2001/03/15 17:30:57 uch Exp $ */ /*- - * Copyright (c) 1996, 1997, 2001 The NetBSD Foundation, Inc. + * Copyright (c) 1997, 1998, 2000, 2001 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -38,41 +38,531 @@ */ /* - * Copyright (c) 1996 Charles M. Hannum. All rights reserved. - * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. + * Copyright (c) 1996 Carnegie-Mellon University. + * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christopher G. Demetriou - * for the NetBSD Project. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission + * Author: Chris G. Demetriou * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. */ #ifndef _HPCSH_BUS_H_ -#define _HPCSH_BUS_H_ -#define STATIC_INLINE static __inline +#define _HPCSH_BUS_H_ -#define __BUS_SPACE_HAS_STREAM_METHODS +#include + +#ifdef _KERNEL +/* + * Turn on BUS_SPACE_DEBUG if the global DEBUG option is enabled. + */ +#if defined(DEBUG) && !defined(BUS_SPACE_DEBUG) +#define BUS_SPACE_DEBUG +#endif + +#ifdef BUS_SPACE_DEBUG +#include /* for printf() prototype */ +/* + * Macros for checking the aligned-ness of pointers passed to bus + * space ops. Strict alignment is required by the Alpha architecture, + * and a trap will occur if unaligned access is performed. These + * may aid in the debugging of a broken device driver by displaying + * useful information about the problem. + */ +#define __BUS_SPACE_ALIGNED_ADDRESS(p, t) \ + ((((u_long)(p)) & (sizeof(t)-1)) == 0) + +#define __BUS_SPACE_ADDRESS_SANITY(p, t, d) \ +({ \ + if (__BUS_SPACE_ALIGNED_ADDRESS((p), t) == 0) { \ + printf("%s 0x%lx not aligned to %lu bytes %s:%d\n", \ + d, (u_long)(p), (u_long)sizeof(t), __FILE__, __LINE__); \ + } \ + (void) 0; \ +}) + +#define BUS_SPACE_ALIGNED_POINTER(p, t) __BUS_SPACE_ALIGNED_ADDRESS(p, t) +#else +#define __BUS_SPACE_ADDRESS_SANITY(p, t, d) (void) 0 +#define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t) +#endif /* BUS_SPACE_DEBUG */ +#endif /* _KERNEL */ + +/* + * Addresses (in bus space). + */ +typedef u_long bus_addr_t; +typedef u_long bus_size_t; + +/* + * Access methods for bus space. + */ +typedef struct hpcsh_bus_space *bus_space_tag_t; +typedef u_long bus_space_handle_t; + +struct extent; /* forward declaration */ + +struct hpcsh_bus_space { + struct extent *hbs_extent; + bus_addr_t hbs_base_addr; + + /* cookie */ + void *hbs_cookie; + + /* mapping/unmapping */ + int (*hbs_map)(void *, bus_addr_t, bus_size_t, + int, bus_space_handle_t *); + void (*hbs_unmap)(void *, bus_space_handle_t, + bus_size_t); + int (*hbs_subregion)(void *, bus_space_handle_t, + bus_size_t, bus_size_t, bus_space_handle_t *); + + /* allocation/deallocation */ + int (*hbs_alloc)(void *, bus_addr_t, bus_addr_t, + bus_size_t, bus_size_t, bus_size_t, int, + bus_addr_t *, bus_space_handle_t *); + void (*hbs_free)(void *, bus_space_handle_t, + bus_size_t); + + /* get kernel virtual address */ + void * (*hbs_vaddr)(void *, bus_space_handle_t); + + /* read (single) */ + u_int8_t (*hbs_r_1)(void *, bus_space_handle_t, + bus_size_t); + u_int16_t (*hbs_r_2)(void *, bus_space_handle_t, + bus_size_t); + u_int32_t (*hbs_r_4)(void *, bus_space_handle_t, + bus_size_t); + u_int64_t (*hbs_r_8)(void *, bus_space_handle_t, + bus_size_t); + + /* read multiple */ + void (*hbs_rm_1)(void *, bus_space_handle_t, + bus_size_t, u_int8_t *, bus_size_t); + void (*hbs_rm_2)(void *, bus_space_handle_t, + bus_size_t, u_int16_t *, bus_size_t); + void (*hbs_rm_4)(void *, bus_space_handle_t, + bus_size_t, u_int32_t *, bus_size_t); + void (*hbs_rm_8)(void *, bus_space_handle_t, + bus_size_t, u_int64_t *, bus_size_t); + + /* read region */ + void (*hbs_rr_1)(void *, bus_space_handle_t, + bus_size_t, u_int8_t *, bus_size_t); + void (*hbs_rr_2)(void *, bus_space_handle_t, + bus_size_t, u_int16_t *, bus_size_t); + void (*hbs_rr_4)(void *, bus_space_handle_t, + bus_size_t, u_int32_t *, bus_size_t); + void (*hbs_rr_8)(void *, bus_space_handle_t, + bus_size_t, u_int64_t *, bus_size_t); + + /* write (single) */ + void (*hbs_w_1)(void *, bus_space_handle_t, + bus_size_t, u_int8_t); + void (*hbs_w_2)(void *, bus_space_handle_t, + bus_size_t, u_int16_t); + void (*hbs_w_4)(void *, bus_space_handle_t, + bus_size_t, u_int32_t); + void (*hbs_w_8)(void *, bus_space_handle_t, + bus_size_t, u_int64_t); + + /* write multiple */ + void (*hbs_wm_1)(void *, bus_space_handle_t, + bus_size_t, const u_int8_t *, bus_size_t); + void (*hbs_wm_2)(void *, bus_space_handle_t, + bus_size_t, const u_int16_t *, bus_size_t); + void (*hbs_wm_4)(void *, bus_space_handle_t, + bus_size_t, const u_int32_t *, bus_size_t); + void (*hbs_wm_8)(void *, bus_space_handle_t, + bus_size_t, const u_int64_t *, bus_size_t); + + /* write region */ + void (*hbs_wr_1)(void *, bus_space_handle_t, + bus_size_t, const u_int8_t *, bus_size_t); + void (*hbs_wr_2)(void *, bus_space_handle_t, + bus_size_t, const u_int16_t *, bus_size_t); + void (*hbs_wr_4)(void *, bus_space_handle_t, + bus_size_t, const u_int32_t *, bus_size_t); + void (*hbs_wr_8)(void *, bus_space_handle_t, + bus_size_t, const u_int64_t *, bus_size_t); + + /* set multiple */ + void (*hbs_sm_1)(void *, bus_space_handle_t, + bus_size_t, u_int8_t, bus_size_t); + void (*hbs_sm_2)(void *, bus_space_handle_t, + bus_size_t, u_int16_t, bus_size_t); + void (*hbs_sm_4)(void *, bus_space_handle_t, + bus_size_t, u_int32_t, bus_size_t); + void (*hbs_sm_8)(void *, bus_space_handle_t, + bus_size_t, u_int64_t, bus_size_t); + + /* set region */ + void (*hbs_sr_1)(void *, bus_space_handle_t, + bus_size_t, u_int8_t, bus_size_t); + void (*hbs_sr_2)(void *, bus_space_handle_t, + bus_size_t, u_int16_t, bus_size_t); + void (*hbs_sr_4)(void *, bus_space_handle_t, + bus_size_t, u_int32_t, bus_size_t); + void (*hbs_sr_8)(void *, bus_space_handle_t, + bus_size_t, u_int64_t, bus_size_t); + + /* copy */ + void (*hbs_c_1)(void *, bus_space_handle_t, bus_size_t, + bus_space_handle_t, bus_size_t, bus_size_t); + void (*hbs_c_2)(void *, bus_space_handle_t, bus_size_t, + bus_space_handle_t, bus_size_t, bus_size_t); + void (*hbs_c_4)(void *, bus_space_handle_t, bus_size_t, + bus_space_handle_t, bus_size_t, bus_size_t); + void (*hbs_c_8)(void *, bus_space_handle_t, bus_size_t, + bus_space_handle_t, bus_size_t, bus_size_t); +}; + +#ifdef _KERNEL +/* + * Utility macros; INTERNAL USE ONLY. + */ + +#define __TYPENAME(BITS) u_int##BITS##_t + +#define _BUS_SPACE_READ(PREFIX, BYTES, BITS) \ +static __TYPENAME(BITS) \ +PREFIX##_read_##BYTES(void *, bus_space_handle_t, bus_size_t); \ +static __TYPENAME(BITS) \ +PREFIX##_read_##BYTES(void *tag, bus_space_handle_t bsh, \ + bus_size_t offset) \ +{ \ + _BUS_SPACE_ACCESS_HOOK(); \ + return *(volatile __TYPENAME(BITS) *)(bsh + offset); \ +} + +#define _BUS_SPACE_READ_MULTI(PREFIX, BYTES, BITS) \ +static void \ +PREFIX##_read_multi_##BYTES(void *, bus_space_handle_t, bus_size_t, \ + __TYPENAME(BITS) *, bus_size_t); \ +static void \ +PREFIX##_read_multi_##BYTES(void *tag, bus_space_handle_t bsh, \ + bus_size_t offset, __TYPENAME(BITS) *addr, \ + bus_size_t count) \ +{ \ + volatile __TYPENAME(BITS) *p = (void *)(bsh + offset); \ + _BUS_SPACE_ACCESS_HOOK(); \ + while (count--) \ + *addr++ = *p; \ +} + +#define _BUS_SPACE_READ_REGION(PREFIX, BYTES, BITS) \ +static void \ +PREFIX##_read_region_##BYTES(void *, bus_space_handle_t, bus_size_t, \ + __TYPENAME(BITS) *, bus_size_t); \ +static void \ +PREFIX##_read_region_##BYTES(void *tag, bus_space_handle_t bsh, \ + bus_size_t offset, __TYPENAME(BITS) *addr, \ + bus_size_t count) \ +{ \ + volatile __TYPENAME(BITS) *p = (void *)(bsh + offset); \ + _BUS_SPACE_ACCESS_HOOK(); \ + while (count--) \ + *addr++ = *p++; \ +} + +#define _BUS_SPACE_WRITE(PREFIX, BYTES, BITS) \ +static void \ +PREFIX##_write_##BYTES(void *, bus_space_handle_t, bus_size_t, \ + __TYPENAME(BITS)); \ +static void \ +PREFIX##_write_##BYTES(void *tag, bus_space_handle_t bsh, \ + bus_size_t offset, __TYPENAME(BITS) value) \ +{ \ + _BUS_SPACE_ACCESS_HOOK(); \ + *(volatile __TYPENAME(BITS) *)(bsh + offset) = value; \ +} + +#define _BUS_SPACE_WRITE_MULTI(PREFIX, BYTES, BITS) \ +static void \ +PREFIX##_write_multi_##BYTES(void *, bus_space_handle_t, bus_size_t, \ + const __TYPENAME(BITS) *, bus_size_t); \ +static void \ +PREFIX##_write_multi_##BYTES(void *tag, bus_space_handle_t bsh, \ + bus_size_t offset, \ + const __TYPENAME(BITS) *addr, \ + bus_size_t count) \ +{ \ + volatile __TYPENAME(BITS) *p = (void *)(bsh + offset); \ + _BUS_SPACE_ACCESS_HOOK(); \ + while (count--) \ + *p = *addr++; \ +} + +#define _BUS_SPACE_WRITE_REGION(PREFIX, BYTES, BITS) \ +static void \ +PREFIX##_write_region_##BYTES(void *, bus_space_handle_t, bus_size_t, \ + const __TYPENAME(BITS) *, bus_size_t); \ +static void \ +PREFIX##_write_region_##BYTES(void *tag, bus_space_handle_t bsh, \ + bus_size_t offset, \ + const __TYPENAME(BITS) *addr, \ + bus_size_t count) \ +{ \ + volatile __TYPENAME(BITS) *p = (void *)(bsh + offset); \ + _BUS_SPACE_ACCESS_HOOK(); \ + while (count--) \ + *p++ = *addr++; \ +} + +#define _BUS_SPACE_SET_MULTI(PREFIX, BYTES, BITS) \ +static void \ +PREFIX##_set_multi_##BYTES(void *, bus_space_handle_t, bus_size_t, \ + __TYPENAME(BITS), bus_size_t); \ +static void \ +PREFIX##_set_multi_##BYTES(void *tag, bus_space_handle_t bsh, \ + bus_size_t offset, __TYPENAME(BITS) value, \ + bus_size_t count) \ +{ \ + volatile __TYPENAME(BITS) *p = (void *)(bsh + offset); \ + _BUS_SPACE_ACCESS_HOOK(); \ + while (count--) \ + *p = value; \ +} + +#define _BUS_SPACE_COPY_REGION(PREFIX, BYTES, BITS) \ +static void \ +PREFIX##_copy_region_##BYTES(void *, bus_space_handle_t, bus_size_t, \ + bus_space_handle_t, bus_size_t, \ + bus_size_t); \ +static void \ +PREFIX##_copy_region_##BYTES(void *t, bus_space_handle_t h1, \ + bus_size_t o1, bus_space_handle_t h2, \ + bus_size_t o2, bus_size_t c) \ +{ \ + volatile __TYPENAME(BITS) *addr1 = (void *)(h1 + o1); \ + volatile __TYPENAME(BITS) *addr2 = (void *)(h2 + o2); \ + _BUS_SPACE_ACCESS_HOOK(); \ + \ + if (addr1 >= addr2) { /* src after dest: copy forward */ \ + while (c--) \ + *addr2++ = *addr1++; \ + } else { /* dest after src: copy backwards */ \ + addr1 += c - 1; \ + addr2 += c - 1; \ + while (c--) \ + *addr2-- = *addr1--; \ + } \ +} + +#define __hbs_c(a,b) __CONCAT(a,b) +#define __hbs_opname(op,size) __hbs_c(__hbs_c(__hbs_c(hbs_,op),_),size) + +#define __hbs_rs(sz, tn, t, h, o) \ + (__BUS_SPACE_ADDRESS_SANITY((h) + (o), tn, "bus addr"), \ + (*(t)->__hbs_opname(r,sz))((t)->hbs_cookie, h, o)) + +#define __hbs_ws(sz, tn, t, h, o, v) \ +do { \ + __BUS_SPACE_ADDRESS_SANITY((h) + (o), tn, "bus addr"); \ + (*(t)->__hbs_opname(w,sz))((t)->hbs_cookie, h, o, v); \ +} while (0) + +#define __hbs_nonsingle(type, sz, tn, t, h, o, a, c) \ +do { \ + __BUS_SPACE_ADDRESS_SANITY((a), tn, "buffer"); \ + __BUS_SPACE_ADDRESS_SANITY((h) + (o), tn, "bus addr"); \ + (*(t)->__hbs_opname(type,sz))((t)->hbs_cookie, h, o, a, c); \ +} while (0) + +#define __hbs_set(type, sz, tn, t, h, o, v, c) \ +do { \ + __BUS_SPACE_ADDRESS_SANITY((h) + (o), tn, "bus addr"); \ + (*(t)->__hbs_opname(type,sz))((t)->hbs_cookie, h, o, v, c); \ +} while (0) + +#define __hbs_copy(sz, tn, t, h1, o1, h2, o2, cnt) \ +do { \ + __BUS_SPACE_ADDRESS_SANITY((h1) + (o1), tn, "bus addr 1"); \ + __BUS_SPACE_ADDRESS_SANITY((h2) + (o2), tn, "bus addr 2"); \ + (*(t)->__hbs_opname(c,sz))((t)->hbs_cookie, h1, o1, h2, o2, cnt); \ +} while (0) + + +/* + * Create default bus_space tag. + */ +bus_space_tag_t bus_space_create(bus_space_tag_t, const char *, bus_addr_t, + bus_size_t); +void bus_space_destroy(bus_space_tag_t); + +/* + * Mapping and unmapping operations. + */ +#define bus_space_map(t, a, s, f, hp) \ + (*(t)->hbs_map)((t)->hbs_cookie, (a), (s), (f), (hp)) +#define bus_space_unmap(t, h, s) \ + (*(t)->hbs_unmap)((t)->hbs_cookie, (h), (s)) +#define bus_space_subregion(t, h, o, s, hp) \ + (*(t)->hbs_subregion)((t)->hbs_cookie, (h), (o), (s), (hp)) + +#endif /* _KERNEL */ + +#define BUS_SPACE_MAP_CACHEABLE 0x01 +#define BUS_SPACE_MAP_LINEAR 0x02 +#define BUS_SPACE_MAP_PREFETCHABLE 0x04 + +#ifdef _KERNEL +/* + * Allocation and deallocation operations. + */ +#define bus_space_alloc(t, rs, re, s, a, b, f, ap, hp) \ + (*(t)->hbs_alloc)((t)->hbs_cookie, (rs), (re), (s), (a), (b), \ + (f), (ap), (hp)) +#define bus_space_free(t, h, s) \ + (*(t)->hbs_free)((t)->hbs_cookie, (h), (s)) + +/* + * Get kernel virtual address for ranges mapped BUS_SPACE_MAP_LINEAR. + */ +#define bus_space_vaddr(t, h) \ + (*(t)->hbs_vaddr)((t)->hbs_cookie, (h)) + +/* + * Bus barrier operations. The hpcsh does not currently require + * barriers, but we must provide the flags to MI code. + */ +#define bus_space_barrier(t, h, o, l, f) \ + ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f))) + +#define BUS_SPACE_BARRIER_READ 0x01 +#define BUS_SPACE_BARRIER_WRITE 0x02 + + +/* + * Bus read (single) operations. + */ +#define bus_space_read_1(t, h, o) __hbs_rs(1,u_int8_t,(t),(h),(o)) +#define bus_space_read_2(t, h, o) __hbs_rs(2,u_int16_t,(t),(h),(o)) +#define bus_space_read_4(t, h, o) __hbs_rs(4,u_int32_t,(t),(h),(o)) +#define bus_space_read_8(t, h, o) __hbs_rs(8,u_int64_t,(t),(h),(o)) + + +/* + * Bus read multiple operations. + */ +#define bus_space_read_multi_1(t, h, o, a, c) \ + __hbs_nonsingle(rm,1,u_int8_t,(t),(h),(o),(a),(c)) +#define bus_space_read_multi_2(t, h, o, a, c) \ + __hbs_nonsingle(rm,2,u_int16_t,(t),(h),(o),(a),(c)) +#define bus_space_read_multi_4(t, h, o, a, c) \ + __hbs_nonsingle(rm,4,u_int32_t,(t),(h),(o),(a),(c)) +#define bus_space_read_multi_8(t, h, o, a, c) \ + __hbs_nonsingle(rm,8,u_int64_t,(t),(h),(o),(a),(c)) + + +/* + * Bus read region operations. + */ +#define bus_space_read_region_1(t, h, o, a, c) \ + __hbs_nonsingle(rr,1,u_int8_t,(t),(h),(o),(a),(c)) +#define bus_space_read_region_2(t, h, o, a, c) \ + __hbs_nonsingle(rr,2,u_int16_t,(t),(h),(o),(a),(c)) +#define bus_space_read_region_4(t, h, o, a, c) \ + __hbs_nonsingle(rr,4,u_int32_t,(t),(h),(o),(a),(c)) +#define bus_space_read_region_8(t, h, o, a, c) \ + __hbs_nonsingle(rr,8,u_int64_t,(t),(h),(o),(a),(c)) + + +/* + * Bus write (single) operations. + */ +#define bus_space_write_1(t, h, o, v) __hbs_ws(1,u_int8_t,(t),(h),(o),(v)) +#define bus_space_write_2(t, h, o, v) __hbs_ws(2,u_int16_t,(t),(h),(o),(v)) +#define bus_space_write_4(t, h, o, v) __hbs_ws(4,u_int32_t,(t),(h),(o),(v)) +#define bus_space_write_8(t, h, o, v) __hbs_ws(8,u_int64_t,(t),(h),(o),(v)) + + +/* + * Bus write multiple operations. + */ +#define bus_space_write_multi_1(t, h, o, a, c) \ + __hbs_nonsingle(wm,1,u_int8_t,(t),(h),(o),(a),(c)) +#define bus_space_write_multi_2(t, h, o, a, c) \ + __hbs_nonsingle(wm,2,u_int16_t,(t),(h),(o),(a),(c)) +#define bus_space_write_multi_4(t, h, o, a, c) \ + __hbs_nonsingle(wm,4,u_int32_t,(t),(h),(o),(a),(c)) +#define bus_space_write_multi_8(t, h, o, a, c) \ + __hbs_nonsingle(wm,8,u_int64_t,(t),(h),(o),(a),(c)) + + +/* + * Bus write region operations. + */ +#define bus_space_write_region_1(t, h, o, a, c) \ + __hbs_nonsingle(wr,1,u_int8_t,(t),(h),(o),(a),(c)) +#define bus_space_write_region_2(t, h, o, a, c) \ + __hbs_nonsingle(wr,2,u_int16_t,(t),(h),(o),(a),(c)) +#define bus_space_write_region_4(t, h, o, a, c) \ + __hbs_nonsingle(wr,4,u_int32_t,(t),(h),(o),(a),(c)) +#define bus_space_write_region_8(t, h, o, a, c) \ + __hbs_nonsingle(wr,8,u_int64_t,(t),(h),(o),(a),(c)) + + +/* + * Set multiple operations. + */ +#define bus_space_set_multi_1(t, h, o, v, c) \ + __hbs_set(sm,1,u_int8_t,(t),(h),(o),(v),(c)) +#define bus_space_set_multi_2(t, h, o, v, c) \ + __hbs_set(sm,2,u_int16_t,(t),(h),(o),(v),(c)) +#define bus_space_set_multi_4(t, h, o, v, c) \ + __hbs_set(sm,4,u_int32_t,(t),(h),(o),(v),(c)) +#define bus_space_set_multi_8(t, h, o, v, c) \ + __hbs_set(sm,8,u_int64_t,(t),(h),(o),(v),(c)) + + +/* + * Set region operations. + */ +#define bus_space_set_region_1(t, h, o, v, c) \ + __hbs_set(sr,1,u_int8_t,(t),(h),(o),(v),(c)) +#define bus_space_set_region_2(t, h, o, v, c) \ + __hbs_set(sr,2,u_int16_t,(t),(h),(o),(v),(c)) +#define bus_space_set_region_4(t, h, o, v, c) \ + __hbs_set(sr,4,u_int32_t,(t),(h),(o),(v),(c)) +#define bus_space_set_region_8(t, h, o, v, c) \ + __hbs_set(sr,8,u_int64_t,(t),(h),(o),(v),(c)) + + +/* + * Copy region operations. + */ +#define bus_space_copy_region_1(t, h1, o1, h2, o2, c) \ + __hbs_copy(1, u_int8_t, (t), (h1), (o1), (h2), (o2), (c)) +#define bus_space_copy_region_2(t, h1, o1, h2, o2, c) \ + __hbs_copy(2, u_int16_t, (t), (h1), (o1), (h2), (o2), (c)) +#define bus_space_copy_region_4(t, h1, o1, h2, o2, c) \ + __hbs_copy(4, u_int32_t, (t), (h1), (o1), (h2), (o2), (c)) +#define bus_space_copy_region_8(t, h1, o1, h2, o2, c) \ + __hbs_copy(8, u_int64_t, (t), (h1), (o1), (h2), (o2), (c)) + +/* + * Bus stream operations--defined in terms of non-stream counterparts + */ +#define __BUS_SPACE_HAS_STREAM_METHODS 1 #define bus_space_read_stream_1 bus_space_read_1 #define bus_space_read_stream_2 bus_space_read_2 #define bus_space_read_stream_4 bus_space_read_4 @@ -98,510 +588,7 @@ #define bus_space_write_region_stream_4 bus_space_write_region_4 #define bus_space_write_region_stream_8 bus_space_write_region_8 -#define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t) - -/* - * Bus address and size types - */ -typedef u_long bus_addr_t; -typedef u_long bus_size_t; - -/* - * Access methods for bus resources and address space. - */ -/* BUS_SPACE_TAG_ANONYMOUS has no extent. */ -#define BUS_SPACE_TAG_ANONYMOUS 0 -typedef void *bus_space_tag_t; -typedef u_long bus_space_handle_t; - -/* - * int bus_space_map (bus_space_tag_t t, bus_addr_t addr, - * bus_size_t size, int flags, bus_space_handle_t *bshp) - * - * Map a region of bus space. - */ -#define BUS_SPACE_MAP_CACHEABLE 0x01 -#define BUS_SPACE_MAP_LINEAR 0x02 -#ifndef SH4 -#define DUMMY_AREA6_READ() \ -{ \ - u_int8_t dummy __attribute__((__unused__)) = \ - *(volatile u_int8_t *)0xba000000; \ -} -#else -#define DUMMY_AREA6_READ() ((void)0) -#endif - -int bus_space_map(bus_space_tag_t, bus_addr_t, bus_size_t, int, - bus_space_handle_t *); - -/* - * u_intN_t bus_space_read_N(bus_space_tag_t tag, - * bus_space_handle_t bsh, bus_size_t offset)); - * - * Read a 1, 2, 4, or 8 byte quantity from bus space - * described by tag/handle/offset. - */ -STATIC_INLINE u_int8_t bus_space_read_1 - (bus_space_tag_t, bus_space_handle_t, bus_size_t); -STATIC_INLINE u_int16_t bus_space_read_2 - (bus_space_tag_t, bus_space_handle_t, bus_size_t); -STATIC_INLINE u_int32_t bus_space_read_4 - (bus_space_tag_t, bus_space_handle_t, bus_size_t); - -u_int8_t -bus_space_read_1(bus_space_tag_t tag, bus_space_handle_t bsh, - bus_size_t offset) -{ - u_int8_t r; - - r = *(volatile u_int8_t *)(bsh + offset); - - return r; -} - -u_int16_t -bus_space_read_2(bus_space_tag_t tag, bus_space_handle_t bsh, - bus_size_t offset) -{ - u_int16_t r; - r = *(volatile u_int16_t *)(bsh + offset); - return r; -} - -u_int32_t -bus_space_read_4(bus_space_tag_t tag, bus_space_handle_t bsh, - bus_size_t offset) -{ - u_int32_t r; - r = *(volatile u_int32_t *)(bsh + offset); - return r; -} - -/* - * void bus_space_read_multi_N(bus_space_tag_t tag, - * bus_space_handle_t bsh, bus_size_t offset, - * u_intN_t *addr, size_t count); - * - * Read `count' 1, 2, 4, or 8 byte quantities from bus space - * described by tag/handle/offset and copy into buffer provided. - */ -STATIC_INLINE void bus_space_read_multi_1(bus_space_tag_t, - bus_space_handle_t, bus_size_t, u_int8_t *, bus_size_t); -STATIC_INLINE void bus_space_read_multi_2(bus_space_tag_t, - bus_space_handle_t, bus_size_t, u_int16_t *, bus_size_t); -STATIC_INLINE void bus_space_read_multi_4(bus_space_tag_t, - bus_space_handle_t, bus_size_t, u_int32_t *, bus_size_t); - -void -bus_space_read_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh, - bus_size_t offset, u_int8_t *addr, bus_size_t count) -{ - while (count--) - *addr++ = bus_space_read_1(tag, bsh, offset); - -} - -void -bus_space_read_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh, - bus_size_t offset, u_int16_t *addr, bus_size_t count) -{ - while (count--) - *addr++ = bus_space_read_2(tag, bsh, offset); -} - -void -bus_space_read_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh, - bus_size_t offset, u_int32_t *addr, bus_size_t count) -{ - while (count--) - *addr++ = bus_space_read_4(tag, bsh, offset); -} - -/* - * int bus_space_alloc(bus_space_tag_t t, bus_addr_t rstart, - * bus_addr_t rend, bus_size_t size, bus_size_t align, - * bus_size_t boundary, int flags, bus_addr_t *addrp, - * bus_space_handle_t *bshp); - * - * Allocate a region of bus space. - */ -int bus_space_alloc(bus_space_tag_t, bus_addr_t, bus_addr_t, bus_size_t, - bus_size_t, bus_size_t, int, - bus_addr_t *, bus_space_handle_t *); - -/* - * int bus_space_free(bus_space_tag_t t, - * bus_space_handle_t bsh, bus_size_t size); - * - * Free a region of bus space. - */ -void bus_space_free(bus_space_tag_t, bus_space_handle_t, bus_size_t); - -/* - * int bus_space_unmap(bus_space_tag_t t, - * bus_space_handle_t bsh, bus_size_t size); - * - * Unmap a region of bus space. - */ -void bus_space_unmap(bus_space_tag_t, bus_space_handle_t, bus_size_t); - -/* - * int bus_space_subregion(bus_space_tag_t t, - * bus_space_handle_t bsh, bus_size_t offset, bus_size_t size, - * bus_space_handle_t *nbshp); - * - * Get a new handle for a subregion of an already-mapped area of bus space. - */ -int bus_space_subregion(bus_space_tag_t, bus_space_handle_t, - bus_size_t, bus_size_t, bus_space_handle_t *); - -/* - * void bus_space_read_region_N(bus_space_tag_t tag, - * bus_space_handle_t bsh, bus_size_t offset, - * u_intN_t *addr, size_t count); - * - * Read `count' 1, 2, 4, or 8 byte quantities from bus space - * described by tag/handle and starting at `offset' and copy into - * buffer provided. - */ -STATIC_INLINE void bus_space_read_region_1(bus_space_tag_t, - bus_space_handle_t, bus_size_t, u_int8_t *, bus_size_t); -STATIC_INLINE void bus_space_read_region_2(bus_space_tag_t, - bus_space_handle_t, bus_size_t, u_int16_t *, bus_size_t); -STATIC_INLINE void bus_space_read_region_4(bus_space_tag_t, - bus_space_handle_t, bus_size_t, u_int32_t *, bus_size_t); - -void -bus_space_read_region_1(bus_space_tag_t tag, bus_space_handle_t bsh, - bus_size_t offset, u_int8_t *addr, bus_size_t count) -{ - u_int8_t *p = (u_int8_t *)(bsh + offset); - - while (count--) - *addr++ = *p++; -} - -void -bus_space_read_region_2(bus_space_tag_t tag, bus_space_handle_t bsh, - bus_size_t offset, u_int16_t *addr, bus_size_t count) -{ - u_int16_t *p = (u_int16_t *)(bsh + offset); - - while (count--) - *addr++ = *p++; -} - -void -bus_space_read_region_4(bus_space_tag_t tag, bus_space_handle_t bsh, - bus_size_t offset, u_int32_t *addr, bus_size_t count) -{ - u_int32_t *p = (u_int32_t *)(bsh + offset); - - while (count--) - *addr++ = *p++; -} - -/* - * void bus_space_write_region_N(bus_space_tag_t tag, - * bus_space_handle_t bsh, bus_size_t offset, - * const u_intN_t *addr, size_t count); - * - * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided - * to bus space described by tag/handle starting at `offset'. - */ -STATIC_INLINE void bus_space_write_region_1(bus_space_tag_t, - bus_space_handle_t, bus_size_t, const u_int8_t *, bus_size_t); -STATIC_INLINE void bus_space_write_region_2(bus_space_tag_t, - bus_space_handle_t, bus_size_t, const u_int16_t *, bus_size_t); -STATIC_INLINE void bus_space_write_region_4(bus_space_tag_t, - bus_space_handle_t, bus_size_t, const u_int32_t *, bus_size_t); - -void -bus_space_write_region_1(bus_space_tag_t tag, bus_space_handle_t bsh, - bus_size_t offset, const u_int8_t *addr, - bus_size_t count) -{ - u_int8_t *p = (u_int8_t *)(bsh + offset); - - DUMMY_AREA6_READ(); - while (count--) - *p++ = *addr++; -} - -void -bus_space_write_region_2(bus_space_tag_t tag, bus_space_handle_t bsh, - bus_size_t offset, const u_int16_t *addr, - bus_size_t count) -{ - u_int16_t *p = (u_int16_t *)(bsh + offset); - - while (count--) - *p++ = *addr++; -} - -void -bus_space_write_region_4(bus_space_tag_t tag, bus_space_handle_t bsh, - bus_size_t offset, const u_int32_t *addr, - bus_size_t count) -{ - u_int32_t *p = (u_int32_t *)(bsh + offset); - - while (count--) - *p++ = *addr++; -} - -/* - * void bus_space_write_N(bus_space_tag_t tag, - * bus_space_handle_t bsh, bus_size_t offset, - * u_intN_t value); - * - * Write the 1, 2, 4, or 8 byte value `value' to bus space - * described by tag/handle/offset. - */ -STATIC_INLINE void bus_space_write_1(bus_space_tag_t, - bus_space_handle_t, bus_size_t, u_int8_t); -STATIC_INLINE void bus_space_write_2(bus_space_tag_t, - bus_space_handle_t, bus_size_t, u_int16_t); -STATIC_INLINE void bus_space_write_4(bus_space_tag_t, - bus_space_handle_t, bus_size_t, u_int32_t); - -void -bus_space_write_1(bus_space_tag_t tag, bus_space_handle_t bsh, - bus_size_t offset, u_int8_t value) -{ - DUMMY_AREA6_READ(); - *(volatile u_int8_t *)(bsh + offset) = value; -} - -void -bus_space_write_2(bus_space_tag_t tag, bus_space_handle_t bsh, - bus_size_t offset, u_int16_t value) -{ - *(volatile u_int16_t *)(bsh + offset) = value; -} - -void -bus_space_write_4(bus_space_tag_t tag, bus_space_handle_t bsh, - bus_size_t offset, u_int32_t value) -{ - *(volatile u_int32_t *)(bsh + offset) = value; -} - -/* - * void bus_space_write_multi_N(bus_space_tag_t tag, - * bus_space_handle_t bsh, bus_size_t offset, - * const u_intN_t *addr, size_t count); - * - * Write `count' 1, 2, 4, or 8 byte quantities from the buffer - * provided to bus space described by tag/handle/offset. - */ -STATIC_INLINE void bus_space_write_multi_1(bus_space_tag_t, - bus_space_handle_t, bus_size_t, u_int8_t *, bus_size_t); -STATIC_INLINE void bus_space_write_multi_2(bus_space_tag_t, - bus_space_handle_t, bus_size_t, u_int16_t *, bus_size_t); -STATIC_INLINE void bus_space_write_multi_4(bus_space_tag_t, - bus_space_handle_t, bus_size_t, u_int32_t *, bus_size_t); - -void -bus_space_write_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh, - bus_size_t offset, u_int8_t *addr, bus_size_t count) -{ - while (count--) - bus_space_write_1(tag, bsh, offset, *addr++); -} - -void -bus_space_write_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh, - bus_size_t offset, u_int16_t *addr, bus_size_t count) -{ - while (count--) - bus_space_write_2(tag, bsh, offset, *addr++); -} - -void -bus_space_write_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh, - bus_size_t offset, u_int32_t *addr, bus_size_t count) -{ - while (count--) - bus_space_write_4(tag, bsh, offset, *addr++); -} - -/* - * void bus_space_set_multi_N(bus_space_tag_t tag, - * bus_space_handle_t bsh, bus_size_t offset, u_intN_t val, - * size_t count); - * - * Write the 1, 2, 4, or 8 byte value `val' to bus space described - * by tag/handle/offset `count' times. - */ -STATIC_INLINE void bus_space_set_multi_1(bus_space_tag_t, - bus_space_handle_t, bus_size_t, u_int8_t, bus_size_t); -STATIC_INLINE void bus_space_set_multi_2(bus_space_tag_t, - bus_space_handle_t, bus_size_t, u_int16_t, bus_size_t); -STATIC_INLINE void bus_space_set_multi_4(bus_space_tag_t, - bus_space_handle_t, bus_size_t, u_int32_t, bus_size_t); - -void -bus_space_set_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh, - bus_size_t offset, u_int8_t val, bus_size_t count) -{ - while (count--) - bus_space_write_1(tag, bsh, offset, val); -} - -void -bus_space_set_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh, - bus_size_t offset, u_int16_t val, bus_size_t count) -{ - while (count--) - bus_space_write_2(tag, bsh, offset, val); -} - -void -bus_space_set_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh, - bus_size_t offset, u_int32_t val, bus_size_t count) -{ - while (count--) - bus_space_write_4(tag, bsh, offset, val); -} - -/* - * void bus_space_set_region_N(bus_space_tag_t tag, - * bus_space_handle_t bsh, bus_size_t offset, u_intN_t val, - * size_t count); - * - * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described - * by tag/handle starting at `offset'. - */ -STATIC_INLINE void bus_space_set_region_1(bus_space_tag_t, - bus_space_handle_t, bus_size_t, u_int8_t, bus_size_t); -STATIC_INLINE void bus_space_set_region_2(bus_space_tag_t, - bus_space_handle_t, bus_size_t, u_int16_t, bus_size_t); -STATIC_INLINE void bus_space_set_region_4(bus_space_tag_t, - bus_space_handle_t, bus_size_t, u_int32_t, bus_size_t); - -void -bus_space_set_region_1(bus_space_tag_t tag, bus_space_handle_t bsh, - bus_size_t offset, u_int8_t val, bus_size_t count) -{ - volatile u_int8_t *addr = (void *)(bsh + offset); - - while (count--) - *addr++ = val; -} - -void -bus_space_set_region_2(bus_space_tag_t tag, bus_space_handle_t bsh, - bus_size_t offset, u_int16_t val, bus_size_t count) -{ - volatile u_int16_t *addr = (void *)(bsh + offset); - - while (count--) - *addr++ = val; -} - -void -bus_space_set_region_4(bus_space_tag_t tag, bus_space_handle_t bsh, - bus_size_t offset, u_int32_t val, bus_size_t count) -{ - volatile u_int32_t *addr = (void *)(bsh + offset); - - while (count--) - *addr++ = val; -} - -/* - * void bus_space_copy_region_N(bus_space_tag_t tag, - * bus_space_handle_t bsh1, bus_size_t off1, - * bus_space_handle_t bsh2, bus_size_t off2, - * size_t count); - * - * Copy `count' 1, 2, 4, or 8 byte values from bus space starting - * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2. - */ -STATIC_INLINE void bus_space_copy_region_1(bus_space_tag_t, - bus_space_handle_t, bus_size_t, bus_space_handle_t, bus_size_t, - bus_size_t); -STATIC_INLINE void bus_space_copy_region_2(bus_space_tag_t, - bus_space_handle_t, bus_size_t, bus_space_handle_t, bus_size_t, - bus_size_t); -STATIC_INLINE void bus_space_copy_region_4(bus_space_tag_t, - bus_space_handle_t, bus_size_t, bus_space_handle_t, bus_size_t, - bus_size_t); - -void -bus_space_copy_region_1(bus_space_tag_t t, bus_space_handle_t h1, - bus_size_t o1, bus_space_handle_t h2, - bus_size_t o2, bus_size_t c) -{ - volatile u_int8_t *addr1 = (void *)(h1 + o1); - volatile u_int8_t *addr2 = (void *)(h2 + o2); - - if (addr1 >= addr2) { /* src after dest: copy forward */ - while (c--) - *addr2++ = *addr1++; - } else { /* dest after src: copy backwards */ - addr1 += c - 1; - addr2 += c - 1; - while (c--) - *addr2-- = *addr1--; - } -} - -void -bus_space_copy_region_2(bus_space_tag_t t, bus_space_handle_t h1, - bus_size_t o1, bus_space_handle_t h2, - bus_size_t o2, bus_size_t c) -{ - volatile u_int16_t *addr1 = (void *)(h1 + o1); - volatile u_int16_t *addr2 = (void *)(h2 + o2); - - if (addr1 >= addr2) { /* src after dest: copy forward */ - while (c--) - *addr2++ = *addr1++; - } else { /* dest after src: copy backwards */ - addr1 += c - 1; - addr2 += c - 1; - while (c--) - *addr2-- = *addr1--; - } -} - -void -bus_space_copy_region_4(bus_space_tag_t t, bus_space_handle_t h1, - bus_size_t o1, bus_space_handle_t h2, - bus_size_t o2, bus_size_t c) -{ - volatile u_int32_t *addr1 = (void *)(h1 + o1); - volatile u_int32_t *addr2 = (void *)(h2 + o2); - - if (addr1 >= addr2) { /* src after dest: copy forward */ - while (c--) - *addr2++ = *addr1++; - } else { /* dest after src: copy backwards */ - addr1 += c - 1; - addr2 += c - 1; - while (c--) - *addr2-- = *addr1--; - } -} - -/* - * Bus read/write barrier methods. - * - * void bus_space_barrier(bus_space_tag_t tag, - * bus_space_handle_t bsh, bus_size_t offset, - * bus_size_t len, int flags); - * - * Note: the sh3 does not currently require barriers, but we must - * provide the flags to MI code. - */ -#define bus_space_barrier(t, h, o, l, f) \ - ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f))) - -#define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */ -#define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */ +#endif /* _KERNEL */ /* * Flags used in various bus DMA methods. @@ -609,7 +596,8 @@ bus_space_copy_region_4(bus_space_tag_t t, bus_space_handle_t h1, #define BUS_DMA_WAITOK 0x00 /* safe to sleep (pseudo-flag) */ #define BUS_DMA_NOWAIT 0x01 /* not safe to sleep */ #define BUS_DMA_ALLOCNOW 0x02 /* perform resource allocation now */ -#define BUS_DMAMEM_NOSYNC 0x04 /* map memory to not require sync */ +#define BUS_DMA_COHERENT 0x04 /* map memory to not require sync */ +#define BUS_DMA_STREAMING 0x08 /* hint: sequential, unidirectional */ #define BUS_DMA_BUS1 0x10 /* placeholders for bus functions... */ #define BUS_DMA_BUS2 0x20 #define BUS_DMA_BUS3 0x40 @@ -619,21 +607,16 @@ bus_space_copy_region_4(bus_space_tag_t t, bus_space_handle_t h1, struct mbuf; struct uio; -#if 0 /* - * bus_dmasync_op_t - * * Operations performed by bus_dmamap_sync(). */ -typedef enum { - BUS_DMASYNC_PREREAD, - BUS_DMASYNC_POSTREAD, - BUS_DMASYNC_PREWRITE, - BUS_DMASYNC_POSTWRITE, -} bus_dmasync_op_t; +#define BUS_DMASYNC_PREREAD 0x01 +#define BUS_DMASYNC_POSTREAD 0x02 +#define BUS_DMASYNC_PREWRITE 0x04 +#define BUS_DMASYNC_POSTWRITE 0x08 -typedef struct sh3_bus_dma_tag *bus_dma_tag_t; -typedef struct sh3_bus_dmamap *bus_dmamap_t; +typedef struct hpcsh_bus_dma_tag *bus_dma_tag_t; +typedef struct hpcsh_bus_dmamap *bus_dmamap_t; /* * bus_dma_segment_t @@ -641,11 +624,11 @@ typedef struct sh3_bus_dmamap *bus_dmamap_t; * Describes a single contiguous DMA transaction. Values * are suitable for programming into DMA registers. */ -struct sh3_bus_dma_segment { +struct hpcsh_bus_dma_segment { bus_addr_t ds_addr; /* DMA address */ bus_size_t ds_len; /* length of transfer */ }; -typedef struct sh3_bus_dma_segment bus_dma_segment_t; +typedef struct hpcsh_bus_dma_segment bus_dma_segment_t; /* * bus_dma_tag_t @@ -654,39 +637,39 @@ typedef struct sh3_bus_dma_segment bus_dma_segment_t; * DMA for a given bus. */ -struct sh3_bus_dma_tag { +struct hpcsh_bus_dma_tag { void *_cookie; /* cookie used in the guts */ /* * DMA mapping methods. */ - int (*_dmamap_create)(bus_dma_tag_t, bus_size_t, int, - bus_size_t, bus_size_t, int, bus_dmamap_t *); - void (*_dmamap_destroy)(bus_dma_tag_t, bus_dmamap_t); - int (*_dmamap_load)(bus_dma_tag_t, bus_dmamap_t, void *, - bus_size_t, struct proc *, int); - int (*_dmamap_load_mbuf)(bus_dma_tag_t, bus_dmamap_t, - struct mbuf *, int); - int (*_dmamap_load_uio)(bus_dma_tag_t, bus_dmamap_t, - struct uio *, int); - int (*_dmamap_load_raw)(bus_dma_tag_t, bus_dmamap_t, - bus_dma_segment_t *, int, bus_size_t, int); - void (*_dmamap_unload)(bus_dma_tag_t, bus_dmamap_t); - void (*_dmamap_sync)(bus_dma_tag_t, bus_dmamap_t, - bus_dmasync_op_t); + int (*_dmamap_create) __P((bus_dma_tag_t, bus_size_t, int, + bus_size_t, bus_size_t, int, bus_dmamap_t *)); + void (*_dmamap_destroy) __P((bus_dma_tag_t, bus_dmamap_t)); + int (*_dmamap_load) __P((bus_dma_tag_t, bus_dmamap_t, void *, + bus_size_t, struct proc *, int)); + int (*_dmamap_load_mbuf) __P((bus_dma_tag_t, bus_dmamap_t, + struct mbuf *, int)); + int (*_dmamap_load_uio) __P((bus_dma_tag_t, bus_dmamap_t, + struct uio *, int)); + int (*_dmamap_load_raw) __P((bus_dma_tag_t, bus_dmamap_t, + bus_dma_segment_t *, int, bus_size_t, int)); + void (*_dmamap_unload) __P((bus_dma_tag_t, bus_dmamap_t)); + void (*_dmamap_sync) __P((bus_dma_tag_t, bus_dmamap_t, + bus_addr_t, bus_size_t, int)); /* * DMA memory utility functions. */ - int (*_dmamem_alloc)(bus_dma_tag_t, bus_size_t, bus_size_t, - bus_size_t, bus_dma_segment_t *, int, int *, int); - void (*_dmamem_free)(bus_dma_tag_t, - bus_dma_segment_t *, int); - int (*_dmamem_map)(bus_dma_tag_t, bus_dma_segment_t *, - int, size_t, caddr_t *, int); - void (*_dmamem_unmap)(bus_dma_tag_t, caddr_t, size_t); - paddr_t (*_dmamem_mmap)(bus_dma_tag_t, bus_dma_segment_t *, - int, off_t, int, int); + int (*_dmamem_alloc) __P((bus_dma_tag_t, bus_size_t, bus_size_t, + bus_size_t, bus_dma_segment_t *, int, int *, int)); + void (*_dmamem_free) __P((bus_dma_tag_t, + bus_dma_segment_t *, int)); + int (*_dmamem_map) __P((bus_dma_tag_t, bus_dma_segment_t *, + int, size_t, caddr_t *, int)); + void (*_dmamem_unmap) __P((bus_dma_tag_t, caddr_t, size_t)); + paddr_t (*_dmamem_mmap) __P((bus_dma_tag_t, bus_dma_segment_t *, + int, off_t, int, int)); }; #define bus_dmamap_create(t, s, n, m, b, f, p) \ @@ -703,9 +686,9 @@ struct sh3_bus_dma_tag { (*(t)->_dmamap_load_raw)((t), (m), (sg), (n), (s), (f)) #define bus_dmamap_unload(t, p) \ (*(t)->_dmamap_unload)((t), (p)) -#define bus_dmamap_sync(t, p, o) \ +#define bus_dmamap_sync(t, m, o, l, op) \ (void)((t)->_dmamap_sync ? \ - (*(t)->_dmamap_sync)((t), (p), (o)) : (void)0) + (*(t)->_dmamap_sync)((t), (m), (o), (l), (op)) : (void)0) #define bus_dmamem_alloc(t, s, a, b, sg, n, r, f) \ (*(t)->_dmamem_alloc)((t), (s), (a), (b), (sg), (n), (r), (f)) @@ -723,7 +706,7 @@ struct sh3_bus_dma_tag { * * Describes a DMA mapping. */ -struct sh3_bus_dmamap { +struct hpcsh_bus_dmamap { /* * PRIVATE MEMBERS: not for use my machine-independent code. */ @@ -740,43 +723,7 @@ struct sh3_bus_dmamap { */ int dm_nsegs; /* # valid segments in mapping */ bus_dma_segment_t dm_segs[1]; /* segments; variable length */ + bus_size_t dm_mapsize; /* size of the mapping */ }; -#ifdef _SH3_BUS_DMA_PRIVATE -int _bus_dmamap_create(bus_dma_tag_t, bus_size_t, int, bus_size_t, - bus_size_t, int, bus_dmamap_t *); -void _bus_dmamap_destroy(bus_dma_tag_t, bus_dmamap_t); -int _bus_dmamap_load(bus_dma_tag_t, bus_dmamap_t, void *, - bus_size_t, struct proc *, int); -int _bus_dmamap_load_mbuf(bus_dma_tag_t, bus_dmamap_t, - struct mbuf *, int); -int _bus_dmamap_load_uio(bus_dma_tag_t, bus_dmamap_t, - struct uio *, int); -int _bus_dmamap_load_raw(bus_dma_tag_t, bus_dmamap_t, - bus_dma_segment_t *, int, bus_size_t, int); -void _bus_dmamap_unload(bus_dma_tag_t, bus_dmamap_t); -void _bus_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, bus_dmasync_op_t); - -int _bus_dmamem_alloc(bus_dma_tag_t tag, bus_size_t size, - bus_size_t alignment, bus_size_t boundary, - bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags); -void _bus_dmamem_free(bus_dma_tag_t tag, bus_dma_segment_t *segs, - int nsegs); -int _bus_dmamem_map(bus_dma_tag_t tag, bus_dma_segment_t *segs, - int nsegs, size_t size, caddr_t *kvap, int flags); -void _bus_dmamem_unmap(bus_dma_tag_t tag, caddr_t kva, - size_t size); -paddr_t _bus_dmamem_mmap(bus_dma_tag_t tag, bus_dma_segment_t *segs, - int nsegs, off_t off, int prot, int flags); - -int _bus_dmamem_alloc_range(bus_dma_tag_t tag, bus_size_t size, - bus_size_t alignment, bus_size_t boundary, - bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags, - vm_offset_t low, vm_offset_t high); -#endif /* _SH3_BUS_DMA_PRIVATE */ - -#endif /* 0 */ - -bus_space_tag_t bus_space_create(const char *, bus_addr_t, bus_size_t); - #endif /* _HPCSH_BUS_H_ */