diff options
author | kato <kato@FreeBSD.org> | 1998-01-16 11:32:13 +0000 |
---|---|---|
committer | kato <kato@FreeBSD.org> | 1998-01-16 11:32:13 +0000 |
commit | 3858c5f53c0c7ed81c7ca31a4aaa9eef270b81c4 (patch) | |
tree | 857d835a827e7be72368179e842a771428d6ec0f | |
parent | 60cfcc8b46b54678f36afb4ccd35f2d439150d6c (diff) | |
download | FreeBSD-src-3858c5f53c0c7ed81c7ca31a4aaa9eef270b81c4.zip FreeBSD-src-3858c5f53c0c7ed81c7ca31a4aaa9eef270b81c4.tar.gz |
Synchronize with NetBSD/pc98 based on NetBSD/i386 version 1.3G patch
level 117.
Reviewed by: Naofumi Honda <honda@Kururu.math.sci.hokudai.ac.jp>
-rw-r--r-- | sys/i386/isa/bs/bs.c | 15 | ||||
-rw-r--r-- | sys/i386/isa/bs/bs_isa.c | 138 | ||||
-rw-r--r-- | sys/i386/isa/bs/bsfunc.c | 31 | ||||
-rw-r--r-- | sys/i386/isa/bs/bsfunc.h | 21 | ||||
-rw-r--r-- | sys/i386/isa/bs/bshw.c | 14 | ||||
-rw-r--r-- | sys/i386/isa/bs/bshw.h | 4 | ||||
-rw-r--r-- | sys/i386/isa/bs/bshw.lst | 1 | ||||
-rw-r--r-- | sys/i386/isa/bs/bshw_dma.c | 23 | ||||
-rw-r--r-- | sys/i386/isa/bs/bshw_pdma.c | 17 | ||||
-rw-r--r-- | sys/i386/isa/bs/bsif.c | 149 | ||||
-rw-r--r-- | sys/i386/isa/bs/bsif.h | 39 | ||||
-rw-r--r-- | sys/i386/isa/bs/bsvar.h | 7 |
12 files changed, 253 insertions, 206 deletions
diff --git a/sys/i386/isa/bs/bs.c b/sys/i386/isa/bs/bs.c index 022af61..094959f 100644 --- a/sys/i386/isa/bs/bs.c +++ b/sys/i386/isa/bs/bs.c @@ -1,3 +1,4 @@ +/* $NecBSD: bs.c,v 1.1 1997/07/18 09:18:59 kmatsuda Exp $ */ /* $NetBSD$ */ /* * [NetBSD for NEC PC98 series] @@ -32,7 +33,7 @@ */ #ifdef __NetBSD__ -#include <dev/isa/bs/bsif.h> +#include <i386/Cbus/dev/bs/bsif.h> #endif #ifdef __FreeBSD__ #include <i386/isa/bs/bsif.h> @@ -134,7 +135,7 @@ bs_scsi_cmd(xs) s = splbio(); - TAILQ_INSERT_TAIL(&ti->ti_ctab, cb, ccb_chain) + TAILQ_INSERT_TAIL(&ti->ti_ctab, cb, ccb_chain); if (ti->ti_phase == FREE) { @@ -312,7 +313,7 @@ bscmddone(ti) bsc->sc_flags |= BSPOLLDONE; } - TAILQ_REMOVE(&ti->ti_ctab, cb, ccb_chain) + TAILQ_REMOVE(&ti->ti_ctab, cb, ccb_chain); if (xs) { @@ -1189,7 +1190,6 @@ bs_phase_error(ti, cb) { struct bs_softc *bsc = ti->ti_bsc; struct bs_err *pep; - char *s = NULL; if ((scsi_status & BSR_CM) == BSR_CMDERR && (scsi_status & BSR_PHVALID) == 0) @@ -1309,7 +1309,6 @@ bs_sequencer(bsc) if (scsi_status == ((u_int8_t) -1)) { bs_debug_print_all(bsc); - printf("%s strange scsi bus status\n"); return 1; } /************************************************** @@ -1547,10 +1546,10 @@ bs_scsi_cmd_poll_internal(cti) /* force all current jobs into the polling state. */ for (i = 0; i < NTARGETS; i++) { - if (ti = bsc->sc_ti[i]) + if ((ti = bsc->sc_ti[i]) != NULL) { ti->ti_flags |= BSFORCEIOPOLL; - if (cb = ti->ti_ctab.tqh_first) + if ((cb = ti->ti_ctab.tqh_first) != NULL) cb->flags |= BSFORCEIOPOLL; } } @@ -1616,7 +1615,7 @@ bs_scsi_cmd_poll(cti, targetcb) } bs_start_timeout(bsc); - softintr(bsc->sc_irqmasks); + softintr(bsc->sc_irq); splx(s); return error; } diff --git a/sys/i386/isa/bs/bs_isa.c b/sys/i386/isa/bs/bs_isa.c index fa4e2a0..7215de6 100644 --- a/sys/i386/isa/bs/bs_isa.c +++ b/sys/i386/isa/bs/bs_isa.c @@ -1,3 +1,4 @@ +/* $NecBSD: bs_isa.c,v 1.3 1997/10/31 17:43:35 honda Exp $ */ /* $NetBSD$ */ /* * [NetBSD for NEC PC98 series] @@ -28,26 +29,99 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include <dev/isa/bs/bsif.h> +#include <i386/Cbus/dev/bs/bsif.h> static int bs_isa_probe __P((struct device *, void *, void *)); static void bs_isa_attach __P((struct device *, struct device *, void *)); +static void bs_args_copy + __P((struct bs_softc *, struct isa_attach_args *, struct bshw *)); struct cfattach bs_isa_ca = { sizeof(struct bs_softc), bs_isa_probe, bs_isa_attach }; +static void +bs_args_copy(bsc, ia, hw) + struct bs_softc *bsc; + struct isa_attach_args *ia; + struct bshw *hw; +{ + + bsc->sc_hw = hw; + bsc->sc_iot = ia->ia_iot; + bsc->sc_memt = ia->ia_memt; + bsc->sc_dmat = ia->ia_dmat; + bsc->sc_delaybah = ia->ia_delaybah; /* should be die */ + bsc->sc_iobase = ia->ia_iobase; + if (ia->ia_maddr != MADDRUNK) + bsc->sm_offset = BSHW_SMITFIFO_OFFSET; + else + bsc->sm_offset = 0; + + bsc->sc_cfgflags = DVCFG_MINOR(ia->ia_cfgflags); + strcpy(bsc->sc_dvname, bsc->sc_dev.dv_xname); +} + static int bs_isa_probe(parent, match, aux) struct device *parent; void *match, *aux; { + struct bs_softc *bsc = (void *) match; struct isa_attach_args *ia = aux; + bus_space_handle_t ioh, memh = NULL; + bus_space_tag_t iot, memt; + struct bshw *hw; + u_int irq, drq; + int rv = 0; + + hw = DVCFG_HW(&bshw_hwsel, DVCFG_MAJOR(ia->ia_cfgflags)); + if (hw == NULL) + return rv; + + iot = ia->ia_iot; + memt = ia->ia_memt; + if (ia->ia_iobase == IOBASEUNK) + { + printf("%s: iobase not specified. Assume default port(0x%x)\n", + bsc->sc_dvname, BSHW_DEFAULT_PORT); + ia->ia_iobase = BSHW_DEFAULT_PORT; + } + + if (bus_space_map(iot, ia->ia_iobase, BSHW_IOSZ, 0, &ioh)) + return rv; + + if ((hw->hw_flags & BSHW_SMFIFO) != 0 && (ia->ia_maddr != MADDRUNK)) + { + ia->ia_maddr = (ia->ia_maddr & (~((NBPG * 2) - 1))) + NBPG; + ia->ia_msize = NBPG; + if (bus_space_map(memt, ia->ia_maddr, NBPG, 0, &memh)) + { + bus_space_unmap(iot, ioh, BSHW_IOSZ); + return 0; + } + } + else + ia->ia_maddr = MADDRUNK; + + irq = IRQUNK; + drq = DRQUNK; + bsc->sc_ioh = ioh; + bsc->sc_memh = memh; + bs_args_copy(bsc, ia, hw); + if (bshw_board_probe(bsc, &drq, &irq)) + goto bad; - ia->ia_irq = IRQUNK; - ia->ia_drq = DRQUNK; + ia->ia_irq = irq; + ia->ia_drq = drq; + ia->ia_iosize = BSHW_IOSZ; + rv = 1; - return bsprobe(parent, match, aux); +bad: + bus_space_unmap(iot, bsc->sc_ioh, BSHW_IOSZ); + if (ia->ia_maddr != MADDRUNK) + bus_space_unmap(memt, bsc->sc_memh, ia->ia_msize); + return rv; } static void @@ -55,6 +129,60 @@ bs_isa_attach(parent, self, aux) struct device *parent, *self; void *aux; { + extern struct scsi_adapter pc98texa55bs; + extern struct scsi_device bs_dev; + struct bs_softc *bsc = (void *) self; + struct isa_attach_args *ia = aux; + bus_space_tag_t iot, memt; + struct bshw *hw; + int i; + + printf("\n"); + + hw = DVCFG_HW(&bshw_hwsel, DVCFG_MAJOR(ia->ia_cfgflags)); + iot = ia->ia_iot; + memt = ia->ia_memt; + + if (bus_space_map(iot, ia->ia_iobase, BSHW_IOSZ, 0, &bsc->sc_ioh)) + panic("%s: bus io map failed\n", bsc->sc_dev.dv_xname); + + if (ia->ia_maddr != MADDRUNK && + bus_space_map(memt, ia->ia_maddr, NBPG, 0, &bsc->sc_memh)) + panic("%s: bus mem map failed\n", bsc->sc_dev.dv_xname); + + if (isa_dmamap_create(NULL, ia->ia_drq, MAXBSIZE, BUS_DMA_NOWAIT)) + { + printf("%s: can't set up ISA DMA map\n", bsc->sc_dev.dv_xname); + return; + } + + /* system initialize */ + bs_args_copy(bsc, ia, hw); + bs_hostque_init(bsc); + for (i = 0; i < NTARGETS; i++) + { + if (i != bsc->sc_hostid) + bs_init_target_info(bsc, i); + } + + bs_init_ccbque(BS_MAX_CCB); + bsc->sc_hstate = BSC_BOOTUP; + bsc->sc_retry = RETRIES; + bsc->sc_wc = delaycount * 250; + bs_reset_nexus(bsc); + + /* link upper layer */ + bsc->sc_link.adapter_target = bsc->sc_hostid; + bsc->sc_link.openings = XSMAX; + bsc->sc_link.max_target = 7; + bsc->sc_link.channel = SCSI_CHANNEL_ONLY_ONE; + bsc->sc_link.adapter_softc = bsc; + bsc->sc_link.adapter = &pc98texa55bs; + bsc->sc_link.device = &bs_dev; + + config_found(self, &bsc->sc_link, bsprint); - bsattach(parent, self, aux); + bsc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE, + IPL_BIO, bsintr, bsc); + bs_start_timeout(bsc); } diff --git a/sys/i386/isa/bs/bsfunc.c b/sys/i386/isa/bs/bsfunc.c index 3b99c7f..47dfe84 100644 --- a/sys/i386/isa/bs/bsfunc.c +++ b/sys/i386/isa/bs/bsfunc.c @@ -1,3 +1,4 @@ +/* $NecBSD: bsfunc.c,v 1.2 1997/10/31 17:43:37 honda Exp $ */ /* $NetBSD$ */ /* * [NetBSD for NEC PC98 series] @@ -32,7 +33,7 @@ */ #ifdef __NetBSD__ -#include <dev/isa/bs/bsif.h> +#include <i386/Cbus/dev/bs/bsif.h> #endif #ifdef __FreeBSD__ #include <i386/isa/bs/bsif.h> @@ -457,7 +458,6 @@ bs_scsibus_start(bsc) struct bs_softc *bsc; { struct targ_info *ti, *nextti = NULL; - struct ccb *cb; int error = HASERROR; u_int querm, bits, skip = 0; @@ -547,7 +547,7 @@ bs_reset_nexus(bsc) BS_SETUP_PHASE(UNDEF) bs_hostque_delete(bsc, ti); - if (cb = ti->ti_ctab.tqh_first) + if ((cb = ti->ti_ctab.tqh_first) != NULL) { if (bsc->sc_hstate == BSC_TARG_CHECK) { @@ -700,7 +700,7 @@ bs_init_target_info(bsc, target) ti->ti_bsc = bsc; ti->ti_id = target; - ti->sm_vaddr = (u_int8_t *) MADDRUNK; + ti->sm_offset = 0; ti->ti_cfgflags = BS_SCSI_NOPARITY | BS_SCSI_NOSAT; ti->ti_mflags = ~(BSSAT | BSDISC | BSSMIT | BSLINK); BS_SETUP_TARGSTATE(BS_TARG_CTRL); @@ -776,10 +776,8 @@ bs_setup_ctrl(ti, quirks, flags) (ti->targ_support & SID_Linked) == 0) flags &= ~BS_SCSI_LINK; - ti->sm_vaddr = (flags & BS_SCSI_NOSMIT) ? - (u_int8_t *) MADDRUNK : bsc->sm_vaddr; - - if (ti->sm_vaddr == (u_int8_t *) MADDRUNK) + ti->sm_offset = (flags & BS_SCSI_NOSMIT) ? 0 : bsc->sm_offset; + if (ti->sm_offset == 0) flags |= BS_SCSI_NOSMIT; else if (bsc->sc_cfgflags & BSC_SMITSAT_DISEN) flags |= BS_SCSI_NOSAT; @@ -902,8 +900,8 @@ bs_debug_print(bsc, ti) struct ccb *cb; /* host stat */ - printf("%s <DEBUG INFO> nexus %x bs %x bus status %x \n", - bsc->sc_dvname, ti, bsc->sc_nexus, (u_int) bsc->sc_busstat); + printf("%s <DEBUG INFO> nexus %lx bs %lx bus status %lx \n", + bsc->sc_dvname, (u_long) ti, (u_long) bsc->sc_nexus, (u_long) bsc->sc_busstat); /* target stat */ if (ti) @@ -912,14 +910,15 @@ bs_debug_print(bsc, ti) printf("%s(%d:%d) ph<%s> ", bsc->sc_dvname, ti->ti_id, ti->ti_lun, phase[(int) ti->ti_phase]); - printf("msgptr %x msg[0] %x status %x tqh %x fl %x\n", + printf("msgptr %x msg[0] %x status %x tqh %lx fl %x\n", (u_int) (ti->ti_msginptr), (u_int) (ti->ti_msgin[0]), - ti->ti_status, cb = ti->ti_ctab.tqh_first, ti->ti_flags); + ti->ti_status, (u_long) (cb = ti->ti_ctab.tqh_first), + ti->ti_flags); if (cb) - printf("cmdlen %x cmdaddr %x cmd[0] %x\n", - cb->cmdlen, cb->cmd, (int) cb->cmd[0]); - printf("datalen %x dataaddr %x seglen %x ", - sp->datalen, sp->data, sp->seglen); + printf("cmdlen %x cmdaddr %lx cmd[0] %x\n", + cb->cmdlen, (u_long) cb->cmd, (int) cb->cmd[0]); + printf("datalen %x dataaddr %lx seglen %x ", + sp->datalen, (u_long) sp->data, sp->seglen); if (cb) printf("odatalen %x flags %x\n", cb->datalen, cb->flags); diff --git a/sys/i386/isa/bs/bsfunc.h b/sys/i386/isa/bs/bsfunc.h index 9a89acf..5658a27 100644 --- a/sys/i386/isa/bs/bsfunc.h +++ b/sys/i386/isa/bs/bsfunc.h @@ -1,3 +1,4 @@ +/* $NecBSD: bsfunc.h,v 1.1 1997/07/18 09:19:03 kmatsuda Exp $ */ /* $NetBSD$ */ /* * [NetBSD for NEC PC98 series] @@ -163,11 +164,11 @@ bs_hostque_head(bsc, ti) struct targ_info *ti; { - if (ti->ti_flags & BSQUEUED) - TAILQ_REMOVE(&bsc->sc_sttab, ti, ti_wchain) - else + if (ti->ti_flags & BSQUEUED) { + TAILQ_REMOVE(&bsc->sc_sttab, ti, ti_wchain); + } else { ti->ti_flags |= BSQUEUED; - + } TAILQ_INSERT_HEAD(&bsc->sc_sttab, ti, ti_wchain); } @@ -177,12 +178,12 @@ bs_hostque_tail(bsc, ti) struct targ_info *ti; { - if (ti->ti_flags & BSQUEUED) - TAILQ_REMOVE(&bsc->sc_sttab, ti, ti_wchain) - else + if (ti->ti_flags & BSQUEUED) { + TAILQ_REMOVE(&bsc->sc_sttab, ti, ti_wchain); + } else { ti->ti_flags |= BSQUEUED; - - TAILQ_INSERT_TAIL(&bsc->sc_sttab, ti, ti_wchain) + } + TAILQ_INSERT_TAIL(&bsc->sc_sttab, ti, ti_wchain); } static BS_INLINE void @@ -194,7 +195,7 @@ bs_hostque_delete(bsc, ti) if (ti->ti_flags & BSQUEUED) { ti->ti_flags &= ~BSQUEUED; - TAILQ_REMOVE(&bsc->sc_sttab, ti, ti_wchain) + TAILQ_REMOVE(&bsc->sc_sttab, ti, ti_wchain); } } diff --git a/sys/i386/isa/bs/bshw.c b/sys/i386/isa/bs/bshw.c index 5d9632b..33a848e 100644 --- a/sys/i386/isa/bs/bshw.c +++ b/sys/i386/isa/bs/bshw.c @@ -1,3 +1,4 @@ +/* $NecBSD: bshw.c,v 1.1 1997/07/18 09:19:03 kmatsuda Exp $ */ /* $NetBSD$ */ /* * [NetBSD for NEC PC98 series] @@ -33,8 +34,8 @@ #ifdef __NetBSD__ #include <dev/isa/isadmareg.h> -#include <dev/isa/bs/bsif.h> -#include <dev/isa/bs/bshw.lst> +#include <i386/Cbus/dev/bs/bsif.h> +#include <i386/Cbus/dev/bs/bshw.lst> #endif #ifdef __FreeBSD__ #include <i386/isa/ic/i8237.h> @@ -241,7 +242,7 @@ bshw_bus_reset(bsc) for (i = 0; i < NTARGETS; i++) { - if (ti = bsc->sc_ti[i]) + if ((ti = bsc->sc_ti[i]) != NULL) { ti->ti_sync = 0; bshw_set_vsp(bsc, i, 0); @@ -271,7 +272,7 @@ bshw_board_probe(bsc, drq, irq) *drq = BUS_IOR(cmd_port) & 3; bsc->sc_dmachan = *drq; - bsc->sc_irqmasks = (1 << (*irq)); + bsc->sc_irq = (*irq); bsc->sc_membank = read_wd33c93(bsc, wd3s_mbank); bsc->sc_membank &= ~MBR_RST; @@ -350,7 +351,6 @@ bshw_set_synchronous(bsc, ti) struct bs_softc *bsc; struct targ_info *ti; { - struct bshw *hw = bsc->sc_hw; struct syncdata sd; int i; @@ -418,8 +418,8 @@ bshw_unlock(bsc) * DMA OPERATIONS **********************************************/ #ifdef __NetBSD__ -#include <dev/isa/bs/bshw_dma.c> -#include <dev/isa/bs/bshw_pdma.c> +#include <i386/Cbus/dev/bs/bshw_dma.c> +#include <i386/Cbus/dev/bs/bshw_pdma.c> #endif #ifdef __FreeBSD__ #include <i386/isa/bs/bshw_dma.c> diff --git a/sys/i386/isa/bs/bshw.h b/sys/i386/isa/bs/bshw.h index efca1cf..384cb0b 100644 --- a/sys/i386/isa/bs/bshw.h +++ b/sys/i386/isa/bs/bshw.h @@ -1,3 +1,4 @@ +/* $NecBSD: bshw.h,v 1.2 1997/10/31 17:43:38 honda Exp $ */ /* $NetBSD$ */ /* * [NetBSD for NEC PC98 series] @@ -46,8 +47,9 @@ #define BSHW_READ BSR_IOR #define BSHW_WRITE 0x0 -#define BSHW_CMD_CHECK(CCB, CAT) (bshw_cmd[(CCB)->cmd[0]] & (CAT)) +#define BSHW_SMITFIFO_OFFSET 0x1000 +#define BSHW_CMD_CHECK(CCB, CAT) (bshw_cmd[(CCB)->cmd[0]] & (CAT)) /********************************************************* * static inline declare. *********************************************************/ diff --git a/sys/i386/isa/bs/bshw.lst b/sys/i386/isa/bs/bshw.lst index 2a3f232..8446fb8 100644 --- a/sys/i386/isa/bs/bshw.lst +++ b/sys/i386/isa/bs/bshw.lst @@ -1,3 +1,4 @@ +/* $NecBSD: bshw.lst,v 1.1 1997/07/18 09:19:05 kmatsuda Exp $ */ /* $NetBSD$ */ /* * [NetBSD for NEC PC98 series] diff --git a/sys/i386/isa/bs/bshw_dma.c b/sys/i386/isa/bs/bshw_dma.c index b5b9238..b3683f6 100644 --- a/sys/i386/isa/bs/bshw_dma.c +++ b/sys/i386/isa/bs/bshw_dma.c @@ -1,3 +1,4 @@ +/* $NecBSD: bshw_dma.c,v 1.3 1997/07/26 06:03:16 honda Exp $ */ /* $NetBSD$ */ /* * [NetBSD for NEC PC98 series] @@ -56,7 +57,7 @@ bshw_dmaabort(bsc, ti) struct targ_info *tmpti; for (i = 0; i < NTARGETS; i++) - if (tmpti = bsc->sc_ti[i]) + if ((tmpti = bsc->sc_ti[i]) != NULL) tmpti->ti_scsp.seglen = 0; } else @@ -175,15 +176,15 @@ static short dmapageport[4] = { 0x27, 0x21, 0x23, 0x25 }; /* common dma settings */ #undef DMA1_SMSK -#define DMA1_SMSK (IO_DMA + 0x14) +#define DMA1_SMSK (0x15) #undef DMA1_MODE -#define DMA1_MODE (IO_DMA + 0x16) +#define DMA1_MODE (0x17) #undef DMA1_FFC -#define DMA1_FFC (IO_DMA + 0x18) +#define DMA1_FFC (0x19) #undef DMA37SM_SET #define DMA37SM_SET 0x04 #undef DMA1_CHN -#define DMA1_CHN(c) (IO_DMA + ((c) << 2)) +#define DMA1_CHN(c) (0x01 + ((c) << 2)) static BS_INLINE void bshw_dmastart(bsc) @@ -203,8 +204,10 @@ bshw_dmastart(bsc) if (need_pre_dma_flush) wbinvd(); #else /* NetBSD/pc98 */ - if (cpuspec->cpuspec_cache_flush_before) - (*cpuspec->cpuspec_cache_flush_before)(); + if (bsc->sc_dmadir & BSHW_READ) + cpu_cf_preRead(curcpu); + else + cpu_cf_preWrite(curcpu); #endif if (bsc->sc_dmadir & BSHW_READ) @@ -249,8 +252,10 @@ bshw_dmadone(bsc) if (need_post_dma_flush) invd(); #else - if (cpuspec->cpuspec_cache_flush_after) - (*cpuspec->cpuspec_cache_flush_after)(); + if (bsc->sc_dmadir & BSHW_READ) + cpu_cf_postRead(curcpu); + else + cpu_cf_postWrite(curcpu); #endif bsc->sc_flags &= (~BSDMASTART); diff --git a/sys/i386/isa/bs/bshw_pdma.c b/sys/i386/isa/bs/bshw_pdma.c index b803630..3443afb 100644 --- a/sys/i386/isa/bs/bshw_pdma.c +++ b/sys/i386/isa/bs/bshw_pdma.c @@ -1,3 +1,4 @@ +/* $NecBSD: bshw_pdma.c,v 1.4 1997/10/31 17:43:39 honda Exp $ */ /* $NetBSD$ */ /* * [NetBSD for NEC PC98 series] @@ -210,9 +211,10 @@ bs_lc_smit_xfer(ti, direction) count = (datalen > LC_FSZ ? LC_FSZ : datalen); #ifdef __FreeBSD__ - memcopy(ti->sm_vaddr, data, count); + memcopy((u_int8_t *)ti->sm_offset, data, count); #else /* NetBSD */ - bus_mem_read_multi_4(bsc->sc_bc, bsc->sc_memh, 0, data, count >> 2); + bus_space_read_region_4(bsc->sc_memt, bsc->sc_memh, + ti->sm_offset, (u_int32_t *) data, count >> 2); #endif /* NetBSD */ data += count; datalen -= count; @@ -230,9 +232,10 @@ bs_lc_smit_xfer(ti, direction) count = (datalen > LC_SFSZ ? LC_SFSZ : datalen); #ifdef __FreeBSD__ - memcopy(data, ti->sm_vaddr, count); + memcopy(data, (u_int8_t *)ti->sm_offset, count); #else /* NetBSD */ - bus_mem_write_multi_4(bsc->sc_bc, bsc->sc_memh, 0, data, count >> 2); + bus_space_write_region_4(bsc->sc_memt, bsc->sc_memh, + ti->sm_offset, (u_int32_t *) data, count >> 2); #endif /* NetBSD */ data += count; datalen -= count; @@ -242,9 +245,11 @@ bs_lc_smit_xfer(ti, direction) count = (datalen > LC_REST ? LC_REST : datalen); #ifdef __FreeBSD__ - memcopy(data, ti->sm_vaddr + LC_SFSZ, count); + memcopy(data, (u_int8_t *)(ti->sm_offset + LC_SFSZ), count); #else /* NetBSD */ - bus_mem_write_multi_4(bsc->sc_bc, bsc->sc_memh, LC_SFSZ, data, count >> 2); + bus_space_write_region_4(bsc->sc_memt, bsc->sc_memh, + ti->sm_offset + LC_SFSZ, + (u_int32_t *) data, count >> 2); #endif /* NetBSD */ data += count; datalen -= count; diff --git a/sys/i386/isa/bs/bsif.c b/sys/i386/isa/bs/bsif.c index 9629465..587ea00 100644 --- a/sys/i386/isa/bs/bsif.c +++ b/sys/i386/isa/bs/bsif.c @@ -1,3 +1,4 @@ +/* $NecBSD: bsif.c,v 1.6 1997/10/31 17:43:40 honda Exp $ */ /* * Copyright (c) HONDA Naofumi, KATO Takenori, 1996. All rights reserved. * @@ -32,7 +33,7 @@ #endif #ifdef __NetBSD__ -#include <dev/isa/bs/bsif.h> +#include <i386/Cbus/dev/bs/bsif.h> #endif /* __NetBSD__ */ #ifdef __FreeBSD__ #include "bs.h" @@ -43,8 +44,6 @@ * DEVICE DECLARE **************************************************/ #ifdef __NetBSD__ -int bsintr __P((void *)); -static int bsprint __P((void *, char *)); static void bs_scsi_minphys __P((struct buf *)); struct cfdriver bs_cd = { @@ -69,7 +68,7 @@ struct scsi_adapter pc98texa55bs = { #ifdef __FreeBSD__ static int bsprobe __P((struct isa_device *)); static int bsattach __P((struct isa_device *)); -static int bsprint __P((void *, char *)); +static int bsprint __P((void *, const char *)); static void bs_scsi_minphys __P((struct buf *)); static int bs_dmarangecheck __P((caddr_t, unsigned)); @@ -119,26 +118,12 @@ static struct bs_softc *bscdata[NBS]; static int bsprobe(dev) struct isa_device *dev; -#else /* __NetBSD__ */ -int -bsprobe(parent, self, aux) - struct device *parent; - struct device *self; - void *aux; -#endif /* __NetBSD__ */ { -#ifdef __FreeBSD__ struct bs_softc *bsc; int unit = dev->id_unit; -#else /* __NetBSD__ */ - struct bs_softc *bsc = (void *) self; - struct isa_attach_args *ia = aux; - bus_chipset_tag_t bc = ia->ia_bc; -#endif /* __NetBSD__ */ u_int irq, drq; int i, rv = 0; -#ifdef __FreeBSD__ if (unit >= NBS) { printf("bs%d: unit number too high\n", unit); return rv; @@ -158,89 +143,35 @@ bsprobe(parent, self, aux) callout_handle_init(&bsc->timeout_ch); bscdata[unit] = bsc; bsc->unit = unit; -#endif /* __FreeBSD__ */ -#ifdef __FreeBSD__ bsc->sc_cfgflags = DVCFG_MINOR(dev->id_flags); bsc->sc_hw = DVCFG_HW(&bshw_hwsel, DVCFG_MAJOR(dev->id_flags)); -#else /* __NetBSD__ */ - bsc->sc_cfgflags = DVCFG_MINOR(ia->ia_cfgflags); - bsc->sc_hw = DVCFG_HW(&bshw_hwsel, DVCFG_MAJOR(ia->ia_cfgflags)); -#endif /* __NetBSD__ */ if (bsc->sc_hw == NULL) return rv; -#ifdef __FreeBSD__ if ((bsc->sc_hw->hw_flags & BSHW_SMFIFO) && (dev->id_maddr != (caddr_t)MADDRUNK)) - bsc->sm_vaddr = (u_int8_t *) dev->id_maddr; + bsc->sm_offset = (u_long) dev->id_maddr; else - bsc->sm_vaddr = (u_int8_t *) MADDRUNK; -#else /* __NetBSD__ */ - if ((bsc->sc_hw->hw_flags & BSHW_SMFIFO) && (ia->ia_maddr != MADDRUNK)) - { - ia->ia_maddr &= ~((NBPG * 2) - 1); - ia->ia_maddr += NBPG; - ia->ia_msize = NBPG; - if (bus_mem_map(bc, ia->ia_maddr, NBPG, 0, &bsc->sc_memh)) - return 0; - bsc->sm_vaddr = (u_int8_t *) bsc->sc_memh; /* XXX */ - } - else - { - bsc->sm_vaddr = (u_int8_t *) MADDRUNK; - ia->ia_msize = 0; - } -#endif /* __NetBSD__ */ + bsc->sm_offset = (u_long) 0; -#ifdef __FreeBSD__ sprintf(bsc->sc_dvname, "bs%d", unit); -#else /* __NetBSD__ */ - strcpy(bsc->sc_dvname, bsc->sc_dev.dv_xname); -#endif /* __NetBSD__ */ -#ifdef __FreeBSD__ if (dev->id_iobase == 0) -#else /* __NetBSD__ */ - if (ia->ia_iobase == IOBASEUNK) -#endif /* __NetBSD__ */ { printf("%s: iobase not specified. Assume default port(0x%x)\n", bsc->sc_dvname, BSHW_DEFAULT_PORT); -#ifdef __FreeBSD__ dev->id_iobase = BSHW_DEFAULT_PORT; -#else /* __NetBSD__ */ - ia->ia_iobase = BSHW_DEFAULT_PORT; -#endif /* __NetBSD__ */ } -#ifdef __FreeBSD__ bsc->sc_iobase = dev->id_iobase; -#else /* __NetBSD__ */ - bsc->sc_iobase = ia->ia_iobase; - bsc->sc_bc = bc; - bsc->sc_delayioh = ia->ia_delayioh; - if (bus_io_map(bsc->sc_bc, bsc->sc_iobase, BSHW_IOSZ, &bsc->sc_ioh)) - return rv; -#endif /* __NetBSD__ */ - -#ifdef __FreeBSD__ irq = IRQUNK; drq = DRQUNK; -#else /* __NetBSD__ */ - irq = ia->ia_irq; - drq = ia->ia_drq; -#endif /* __NetBSD__ */ if (bshw_board_probe(bsc, &drq, &irq)) goto bad; -#ifdef __FreeBSD__ dev->id_irq = pc98_irq_ball[irq]; dev->id_drq = (short)drq; -#else /* __NetBSD__ */ - ia->ia_irq = irq; - ia->ia_drq = drq; -#endif /* __NetBSD__ */ /* initialize host queue and target info */ bs_hostque_init(bsc); @@ -251,33 +182,26 @@ bsprobe(parent, self, aux) /* initialize ccb queue */ bs_init_ccbque(BS_MAX_CCB); -#ifdef __NetBSD__ - /* init port data */ - ia->ia_iosize = BSHW_IOSZ; -#endif /* __NetBSD__ */ - /* scsi bus reset and restart */ bsc->sc_hstate = BSC_BOOTUP; bsc->sc_retry = RETRIES; bsc->sc_wc = delaycount * 250; /* about 1 sec */ bs_reset_nexus(bsc); -#ifdef __FreeBSD__ return BSHW_IOSZ; bad: return rv; -#else /* __NetBSD__ */ - rv = 1; -bad: - bus_io_unmap(bsc->sc_bc, bsc->sc_ioh, BSHW_IOSZ); - return rv; -#endif /* __NetBSD__ */ } +#endif /* __FreeBSD__ */ +#ifdef __FreeBSD__ static int +#else /* __NetBSD__ */ +int +#endif /* __NetBSD__ */ bsprint(aux, name) void *aux; - char *name; + const char *name; { if (name != NULL) @@ -289,47 +213,19 @@ bsprint(aux, name) static int bsattach(dev) struct isa_device *dev; -#else /* __NetBSD__ */ -void -bsattach(parent, self, aux) - struct device *parent; - struct device *self; - void *aux; -#endif /* __NetBSD__ */ { -#ifdef __FreeBSD__ int unit = dev->id_unit; struct bs_softc *bsc = bscdata[unit]; struct scsibus_data *scbus; -#else /* __NetBSD__ */ - struct bs_softc *bsc = (void *) self; - struct isa_attach_args *ia = aux; - - printf("\n"); -#endif /* __NetBSD__ */ - -#ifdef __NetBSD__ - bsc->sc_iobase = ia->ia_iobase; - bsc->sc_bc = ia->ia_bc; - bsc->sc_delayioh = ia->ia_delayioh; - if (bus_io_map(bsc->sc_bc, bsc->sc_iobase, BSHW_IOSZ, &bsc->sc_ioh)) - panic("%s: bus io map failed\n", bsc->sc_dev.dv_xname); -#endif /* __NetBSD__ */ -#ifdef __FreeBSD__ bsc->sc_link.adapter_unit = unit; bsc->sc_link.adapter_targ = bsc->sc_hostid; bsc->sc_link.flags = SDEV_BOUNCE; bsc->sc_link.opennings = XSMAX; -#else /* __NetBSD__ */ - bsc->sc_link.adapter_target = bsc->sc_hostid; - bsc->sc_link.openings = XSMAX; -#endif /* __NetBSD__ */ bsc->sc_link.adapter_softc = bsc; bsc->sc_link.adapter = &pc98texa55bs; bsc->sc_link.device = &bs_dev; -#ifdef __FreeBSD__ /* * Prepare the scsibus_data area for the upperlevel * scsi code. @@ -342,16 +238,10 @@ bsattach(parent, self, aux) * ask the adapter what subunits are present */ scsi_attachdevs(scbus); -#else /* __NetBSD__ */ - bsc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE, - IPL_BIO, bsintr, bsc); - config_found(self, &bsc->sc_link, bsprint); -#endif /* __NetBSD__ */ bs_start_timeout(bsc); -#ifdef __FreeBSD__ return 1; -#endif /* __FreeBSD__ */ } +#endif /* __FreeBSD__ */ #ifdef __NetBSD__ int @@ -413,9 +303,12 @@ void bs_alloc_buf(ti) struct targ_info *ti; { - extern int cold; + struct bs_softc *bsc = ti->ti_bsc; caddr_t addr, physaddr; + bus_dma_segment_t seg; + int rseg, error; u_int pages; + extern int cold; /* XXX: * strategy change! @@ -426,9 +319,15 @@ bs_alloc_buf(ti) pages = 4; else pages = 1; - ti->bounce_size = NBPG * pages; - if ((addr = alloc_bounce_buffer(ti->bounce_size)) == NULL) + + addr = NULL; + error = bus_dmamem_alloc(bsc->sc_dmat, ti->bounce_size, NBPG, 0, + &seg, 1, &rseg, BUS_DMA_NOWAIT); + if (rseg == 1 && error == 0) + error = bus_dmamem_map(bsc->sc_dmat, &seg, rseg, + ti->bounce_size, &addr, BUS_DMA_NOWAIT); + if (rseg != 1 || error != 0) { ti->bounce_size = NBPG; if ((addr = malloc(NBPG, M_DEVBUF, M_NOWAIT)) == NULL) diff --git a/sys/i386/isa/bs/bsif.h b/sys/i386/isa/bs/bsif.h index 7602bab..478944f 100644 --- a/sys/i386/isa/bs/bsif.h +++ b/sys/i386/isa/bs/bsif.h @@ -1,3 +1,4 @@ +/* $NecBSD: bsif.h,v 1.5 1997/10/23 20:52:34 honda Exp $ */ /* * Copyright (c) HONDA Naofumi, KATO Takenori, 1996. All rights reserved. * @@ -38,11 +39,13 @@ struct scsi_link sc_link; #define OS_DEPEND_MISC_HEADER \ - pisa_device_handle_t sc_pdv; \ - bus_chipset_tag_t sc_bc; \ - bus_io_handle_t sc_ioh; \ - bus_io_handle_t sc_delayioh; \ - bus_mem_handle_t sc_memh; + pisa_device_handle_t sc_dh; \ + bus_space_tag_t sc_iot; \ + bus_space_tag_t sc_memt; \ + bus_space_handle_t sc_ioh; \ + bus_space_handle_t sc_delaybah; \ + bus_space_handle_t sc_memh; \ + bus_dma_tag_t sc_dmat; #endif /* __NetBSD__ */ #ifdef __FreeBSD__ @@ -85,6 +88,10 @@ #include <dev/isa/isareg.h> #include <dev/isa/isavar.h> #include <dev/isa/pisaif.h> +#include <dev/isa/isadmavar.h> +#include <dev/isa/isadmareg.h> + +#include <dev/cons.h> #include <machine/cpufunc.h> #include <machine/bus.h> @@ -123,18 +130,18 @@ * BUS IO MAPPINGS & BS specific inclusion ***************************************************/ #ifdef __NetBSD__ -#define BUS_IO_DELAY ((void) bus_io_read_1(bsc->sc_bc, bsc->sc_delayioh, 0)) -#define BUS_IO_WEIGHT (bus_io_write_1(bsc->sc_bc, bsc->sc_delayioh, 0, 0)) -#define BUS_IOR(offs) (BUS_IO_DELAY, bus_io_read_1(bsc->sc_bc, bsc->sc_ioh, (offs))) -#define BUS_IOW(offs, val) (BUS_IO_DELAY, bus_io_write_1(bsc->sc_bc, bsc->sc_ioh, (offs), (val))) +#define BUS_IO_DELAY ((void) bus_space_read_1(bsc->sc_iot, bsc->sc_delaybah, 0)) +#define BUS_IO_WEIGHT (bus_space_write_1(bsc->sc_iot, bsc->sc_delaybah, 0, 0)) +#define BUS_IOR(offs) (bus_space_read_1(bsc->sc_iot, bsc->sc_ioh, (offs))) +#define BUS_IOW(offs, val) (bus_space_write_1(bsc->sc_iot, bsc->sc_ioh, (offs), (val))) #include <dev/ic/wd33c93reg.h> #include <dev/isa/ccbque.h> -#include <dev/isa/scsi_dvcfg.h> -#include <dev/isa/bs/bsvar.h> -#include <dev/isa/bs/bshw.h> -#include <dev/isa/bs/bsfunc.h> +#include <i386/Cbus/dev/scsi_dvcfg.h> +#include <i386/Cbus/dev/bs/bsvar.h> +#include <i386/Cbus/dev/bs/bshw.h> +#include <i386/Cbus/dev/bs/bsfunc.h> #endif /* __NetBSD__ */ #ifdef __FreeBSD__ @@ -193,8 +200,8 @@ extern int delaycount; /* (II) os depend declare */ #ifdef __NetBSD__ -int bsprobe __P((struct device *, struct device *, void *)); -void bsattach __P((struct device *, struct device *, void *)); +int bsintr __P((void *)); +int bsprint __P((void *, const char *)); #endif /* __NetBSD__ */ #ifdef __FreeBSD__ @@ -211,7 +218,7 @@ extern int dma_init_flag; * Please inform smp@freebsd.org if this is NOT the case. */ #else -#define softintr(y) ipending |= (y) +#define softintr(y) ipending |= (1 << y) #endif /* SMP */ static BS_INLINE void diff --git a/sys/i386/isa/bs/bsvar.h b/sys/i386/isa/bs/bsvar.h index 8267338..e9cf9c9 100644 --- a/sys/i386/isa/bs/bsvar.h +++ b/sys/i386/isa/bs/bsvar.h @@ -1,3 +1,4 @@ +/* $NecBSD: bsvar.h,v 1.2 1997/10/31 17:43:41 honda Exp $ */ /* $NetBSD$ */ /* * [NetBSD for NEC PC98 series] @@ -342,7 +343,7 @@ struct targ_info { u_int8_t *bounce_addr; u_int bounce_size; - u_int8_t *sm_vaddr; + u_long sm_offset; /***************************************** * target inq data @@ -437,14 +438,14 @@ struct bs_softc { struct bshw *sc_hw; /* hw selection */ - u_int8_t *sm_vaddr; /* smit buffer */ + u_long sm_offset; /* smit buffer offset */ u_int sc_RSTdelay; int sc_hwlock; /* hardware lock count */ int sc_iobase; /* iobase for FreeBSD */ - u_int32_t sc_irqmasks; /* irq */ + u_int32_t sc_irq; /* irq */ u_int sc_dmachan; /* dma channel */ u_int8_t sc_busstat; /* scsi bus status register */ |